Dump from SVN
This commit is contained in:
44
config/lib/loginManager/lmUtils.php
Normal file
44
config/lib/loginManager/lmUtils.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* loginManager/lmUtils.php
|
||||
* @desc utilities for correct functioning
|
||||
* @version 1.0
|
||||
* @author Fándly Gergő Zoltán
|
||||
* @copy 2017 Fándly Gergő Zoltán
|
||||
*/
|
||||
|
||||
class lmUtils{
|
||||
/**
|
||||
* generate a random string with special character
|
||||
* @param int $length length of the requested string
|
||||
* @return string
|
||||
*/
|
||||
public static function randomString($length){
|
||||
$charset="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_-=+\?/.>,<";
|
||||
$charsetLength=strlen($charset);
|
||||
$string="";
|
||||
for($i=0; $i<$length; $i++){
|
||||
$string.=$charset[rand(0, $charsetLength-1)];
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* validate google ReCaptcha
|
||||
* @param string $secretkey secret key to captcha API
|
||||
* @param string $response response of API
|
||||
* @return bool
|
||||
*/
|
||||
public static function validateCaptcha($secretkey, $response){
|
||||
$verify=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretkey."&response=".$response);
|
||||
$data=json_decode($verify);
|
||||
if($data->success){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user