Adding Google reCaptcha system

Also disable all shop and buypoints functionality as default in config.php
This commit is contained in:
Znote
2017-01-22 05:06:37 +01:00
parent 05800d282d
commit 984e62e095
5 changed files with 73 additions and 28 deletions

View File

@@ -21,10 +21,27 @@ if (empty($_POST) === false) {
}
if ($config['use_captcha']) {
include_once 'captcha/securimage.php';
$securimage = new Securimage();
if ($securimage->check($_POST['captcha_code']) == false) {
$errors[] = 'Captcha image verification was submitted wrong.';
$captcha = (isset($_POST['g-recaptcha-response'])) ? $_POST['g-recaptcha-response'] : false;
if(!$captcha) {
$errors[] = 'Please check the the captcha form.';
} else {
$secretKey = $config['captcha_secret_key'];
$ip = $_SERVER['REMOTE_ADDR'];
// curl start
$curl_connection = curl_init("https://www.google.com/recaptcha/api/siteverify");
$post_string = "secret=".$secretKey."&response=".$captcha."&remoteip=".$ip;
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
$response = curl_exec($curl_connection);
curl_close($curl_connection);
// Curl end
$responseKeys = json_decode($response,true);
if(intval($responseKeys["success"]) !== 1) {
$errors[] = 'Captcha failed.';
}
}
}
@@ -171,10 +188,7 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
if ($config['use_captcha']) {
?>
<li>
<b>Write the image symbols in the text field to verify that you are a human:</b>
<img id="captcha" src="captcha/securimage_show.php" alt="CAPTCHA Image" /><br>
<input type="text" name="captcha_code" size="10" maxlength="6" />
<a href="#" onclick="document.getElementById('captcha').src = 'captcha/securimage_show.php?' + Math.random(); return false">[ Different Image ]</a><br><br>
<div class="g-recaptcha" data-sitekey="<?php echo $config['captcha_site_key']; ?>"></div>
</li>
<?php
}
@@ -187,7 +201,6 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
<p>No <a href='http://en.wikipedia.org/wiki/Video_game_bot' target="_blank">botting</a> allowed.</p>
<p>The staff can delete, ban, do whatever they want with your account and your <br>
submitted information. (Including exposing and logging your IP).</p>
<p></p>
</li>
<li>
Do you agree to follow the server rules?<br>