MI update

This commit is contained in:
JoseluCross
2018-09-30 10:39:03 +02:00
parent aaa9a83eb2
commit c7ede8cb6e
2 changed files with 20 additions and 1 deletions

View File

@@ -295,9 +295,11 @@ function loginRegister($default){
"title" => ucfirst($default),
"description" => "Start now in CodeShare",
"page" => $default,
"state" => 0, //0=no logged, 1 login fail, 2 register fail, 3 all correct (render home)
"state" => 0, //0=no logged, 1 login fail, 2 register fail, 3 all correct (render home), 4 captcha failed
);
$response = checkCaptcha($_POST['g-recaptcha-response']);
if(array_key_exists('email',$_POST) or array_key_exists('emailre',$_POST)){
if($_POST["email"]){
$bool=checklogin($_POST['email'],$_POST['pwd']);
@@ -312,6 +314,8 @@ function loginRegister($default){
}
}
if($response)
if($bool) {
header("Location: index.php");
}else

View File

@@ -78,3 +78,18 @@ function groupByCategory(&$supported){
}
return $grouped;
}
function checkCaptcha($response){
$url = "https://www.google.com/recaptcha/api/siteverify";
$post = 'secret='.'6Lc7gXAUAAAAAOTbo2u3IXoSB6KlhtVmUHTzpcGY&response='. $response;
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
return json_decode($response)["success"];
}