9 Commits

Author SHA1 Message Date
JoseluCross
de64484707 HotFix: Captcha 2018-10-27 09:32:54 +02:00
JoseluCross
a4ff90636f HotFix: Error repaired 2018-10-26 17:19:17 +02:00
JoseluCross
f3401a900d HotFix: HTTP errors 2018-10-26 16:49:27 +02:00
JoseluCross
d55f3e70d7 Merge branch 'master' of ssh://gitlab.com/CodeSolutionsProject/CodeShare 2018-10-26 16:43:08 +02:00
JoseluCross
1ef6ae4b7a ReCaptcha #10 2018-10-26 16:42:47 +02:00
5977f157be Update .gitignore 2018-10-25 23:57:26 +00:00
5fba4f41ce Delete slnx.sqlite-journal 2018-10-25 23:57:00 +00:00
55bef8ce98 Delete slnx.sqlite 2018-10-25 23:56:52 +00:00
2e4b9b9697 Delete ROLES 2018-10-25 23:55:03 +00:00
8 changed files with 36 additions and 25 deletions

3
.gitignore vendored
View File

@@ -2,4 +2,5 @@ project.json
*.db *.db
.idea/ .idea/
*.sql *.sql
vendor/ vendor/
.vs

Binary file not shown.

Binary file not shown.

View File

@@ -79,6 +79,10 @@
<input type="checkbox" required="required" name="tos" id="tos"> <input type="checkbox" required="required" name="tos" id="tos">
</div> </div>
</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="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success">Submit</button> <button type="submit" class="btn btn-success">Submit</button>

2
Source/composer.lock generated
View File

@@ -1,7 +1,7 @@
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "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" "This file is @generated automatically"
], ],
"content-hash": "1d57e016803e2095db2110462e070da3", "content-hash": "1d57e016803e2095db2110462e070da3",

View File

@@ -1,5 +0,0 @@
User's roles
0: Normal user
1: Normal user with ban
2: Moderator
3: Administrator

View File

@@ -193,6 +193,11 @@ function loginOrRegister($state,$request){
return loginRegister("login",'BAD_CREDENTIAL'); return loginRegister("login",'BAD_CREDENTIAL');
} }
case 2: case 2:
$captcha = checkCaptcha($request->get("g-recaptcha-response"));
if(!$captcha){
return "CAPTCHA_FAIL";
}
$state = register($request->get('emailre'),$request->get('emailre-re'), $state = register($request->get('emailre'),$request->get('emailre-re'),
$request->get('pwdre'), $request->get('pwdre-re'),$request->get('nick'),$app['data']); $request->get('pwdre'), $request->get('pwdre-re'),$request->get('nick'),$app['data']);
if ($state == '') if ($state == '')
@@ -268,7 +273,7 @@ function HTTPError($code){
return array("text"=>$text,"number"=>$code); return array("text"=>$text,"number"=>$code);
} }
$app->error(function (\Exception $e,$request, $code = 500) use ($app) { $app->error(function (\Exception $e,$request) use ($app) {
$user = null; $user = null;
try{ try{
$user = getUser($app); $user = getUser($app);
@@ -277,16 +282,18 @@ $app->error(function (\Exception $e,$request, $code = 500) use ($app) {
} }
if ($app['debug']) { if ($app['debug']) {
return; return;
}else{ }else {
$code=500;
$error = HTTPError($code); if($e instanceof \Symfony\Component\HttpKernel\Exception\HttpException)
return $app['twig']->render($app['fronthtml'].'/error.twig', Array( $error = HTTPError($e->getStatusCode());
'page' => array("title"=>$code),
'error' => $error,
'user' => $user,
));
} }
return $app['twig']->render($app['fronthtml'].'/error.twig', Array(
'page' => array("title"=>$code),
'error' => $error,
'user' => $user,
));
}); });

View File

@@ -81,15 +81,19 @@ function groupByCategory($supported){
function checkCaptcha($response){ function checkCaptcha($response){
$url = "https://www.google.com/recaptcha/api/siteverify"; $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 ); $options = array(
curl_setopt( $ch, CURLOPT_POST, 1); 'http' => array(
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post); "header" => "Content-type: application/x-www-form-urlencoded\r\n",
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1); "method" => 'POST',
curl_setopt( $ch, CURLOPT_HEADER, 0); 'content'=> http_build_query($post)
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1); )
);
$context = stream_context_create($options);
$response = file_get_contents($url,false,$context);
$response = curl_exec( $ch ); return json_decode($response,true)["success"];
return json_decode($response)["success"];
} }