mirror of
https://gitlab.com/CodeSolutionsProject/CodeShare.git
synced 2026-02-15 09:31:33 +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
|
*.db
|
||||||
.idea/
|
.idea/
|
||||||
*.sql
|
*.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">
|
<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
2
Source/composer.lock
generated
@@ -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",
|
||||||
|
|||||||
@@ -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');
|
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,
|
||||||
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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"];
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user