mirror of
https://gitlab.com/CodeSolutionsProject/CodeShare.git
synced 2026-02-14 09:01:33 +01:00
ReCaptcha #10
This commit is contained in:
@@ -79,6 +79,10 @@
|
||||
<input type="checkbox" required="required" name="tos" id="tos">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" for="captcha"></label>
|
||||
<div class="col-sm-10 g-recaptcha" data-sitekey="6Ld-C3cUAAAAADjyFgwdcVuLJqfCr0F3s2p1mE86"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" class="btn btn-success">Submit</button>
|
||||
|
||||
2
Source/composer.lock
generated
2
Source/composer.lock
generated
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "1d57e016803e2095db2110462e070da3",
|
||||
|
||||
@@ -19,7 +19,7 @@ $app = new Silex\Application();
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
$app['debug'] = false;
|
||||
$app['debug'] = true;
|
||||
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());
|
||||
$app->register(new Silex\Provider\TwigServiceProvider(), array(
|
||||
'twig.path' => __DIR__.'/../',
|
||||
@@ -143,7 +143,12 @@ $app->get('/login', function(Request $request) use ($app){
|
||||
}
|
||||
else{
|
||||
$state = checkInfo($request);
|
||||
return loginOrRegister($state,$request);
|
||||
$captcha = checkCaptcha($request->get("g-recaptcha-response"));
|
||||
if($captcha)
|
||||
return loginOrRegister($state,$request);
|
||||
else{
|
||||
return "CAPTCHA_FAIL";
|
||||
}
|
||||
}
|
||||
|
||||
})->bind('login')->method('GET|POST');
|
||||
@@ -159,7 +164,12 @@ $app->get('/signup', function(Request $request) use ($app){
|
||||
return loginRegister('sign-up');
|
||||
}else{
|
||||
$state = checkInfo($request);
|
||||
return loginOrRegister($state,$request);
|
||||
$captcha = checkCaptcha($request->get("g-recaptcha-response"));
|
||||
if($captcha)
|
||||
return loginOrRegister($state,$request);
|
||||
else{
|
||||
return "CAPTCHA_FAIL";
|
||||
}
|
||||
}
|
||||
|
||||
})->bind('register')->method('GET|POST');
|
||||
|
||||
@@ -81,15 +81,19 @@ function groupByCategory($supported){
|
||||
|
||||
function checkCaptcha($response){
|
||||
$url = "https://www.google.com/recaptcha/api/siteverify";
|
||||
$post = 'secret='.'6Lc7gXAUAAAAAOTbo2u3IXoSB6KlhtVmUHTzpcGY&response='. $response;
|
||||
//$post = 'secret='.'6Ld-C3cUAAAAAC6NhPw-rn4LsdM2PjKg255H6j0o&response='. $response;
|
||||
$post = array('secret' => "6Ld-C3cUAAAAAC6NhPw-rn4LsdM2PjKg255H6j0o",
|
||||
'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);
|
||||
$options = array(
|
||||
'http' => array(
|
||||
"header" => "Content-type: application/x-www-form-urlencoded\r\n",
|
||||
"method" => 'POST',
|
||||
'content'=> http_build_query($post)
|
||||
)
|
||||
);
|
||||
$context = stream_context_create($options);
|
||||
$response = file_get_contents($url,false,$context);
|
||||
|
||||
$response = curl_exec( $ch );
|
||||
return json_decode($response)["success"];
|
||||
return json_decode($response,true)["success"];
|
||||
}
|
||||
Reference in New Issue
Block a user