mirror of
https://gitlab.com/CodeSolutionsProject/CodeShare.git
synced 2026-02-15 01:21:35 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de64484707 | ||
|
|
a4ff90636f | ||
|
|
f3401a900d | ||
|
|
d55f3e70d7 | ||
|
|
1ef6ae4b7a | ||
| 5977f157be | |||
| 5fba4f41ce | |||
| 55bef8ce98 | |||
| 2e4b9b9697 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,4 +2,5 @@ project.json
|
||||
*.db
|
||||
.idea/
|
||||
*.sql
|
||||
vendor/
|
||||
vendor/
|
||||
.vs
|
||||
|
||||
BIN
.vs/slnx.sqlite
BIN
.vs/slnx.sqlite
Binary file not shown.
Binary file not shown.
@@ -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",
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
User's roles
|
||||
0: Normal user
|
||||
1: Normal user with ban
|
||||
2: Moderator
|
||||
3: Administrator
|
||||
@@ -193,6 +193,11 @@ function loginOrRegister($state,$request){
|
||||
return loginRegister("login",'BAD_CREDENTIAL');
|
||||
}
|
||||
case 2:
|
||||
$captcha = checkCaptcha($request->get("g-recaptcha-response"));
|
||||
if(!$captcha){
|
||||
return "CAPTCHA_FAIL";
|
||||
}
|
||||
|
||||
$state = register($request->get('emailre'),$request->get('emailre-re'),
|
||||
$request->get('pwdre'), $request->get('pwdre-re'),$request->get('nick'),$app['data']);
|
||||
if ($state == '')
|
||||
@@ -268,7 +273,7 @@ function HTTPError($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;
|
||||
try{
|
||||
$user = getUser($app);
|
||||
@@ -277,16 +282,18 @@ $app->error(function (\Exception $e,$request, $code = 500) use ($app) {
|
||||
}
|
||||
if ($app['debug']) {
|
||||
return;
|
||||
}else{
|
||||
|
||||
$error = HTTPError($code);
|
||||
return $app['twig']->render($app['fronthtml'].'/error.twig', Array(
|
||||
'page' => array("title"=>$code),
|
||||
'error' => $error,
|
||||
'user' => $user,
|
||||
));
|
||||
}else {
|
||||
$code=500;
|
||||
if($e instanceof \Symfony\Component\HttpKernel\Exception\HttpException)
|
||||
$error = HTTPError($e->getStatusCode());
|
||||
|
||||
|
||||
}
|
||||
return $app['twig']->render($app['fronthtml'].'/error.twig', Array(
|
||||
'page' => array("title"=>$code),
|
||||
'error' => $error,
|
||||
'user' => $user,
|
||||
));
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -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