Fix captchas
This commit is contained in:
@@ -23,7 +23,6 @@ if (!isset($_SESSION['editor'])) {
|
||||
<link rel="alternate" type="application/rss+xml" title="xxx.org.za RSS feed" href="/feed" />
|
||||
<script type="text/javascript" src="../utilities.js"></script>
|
||||
<? include_once('./tinymce_init.inc.php'); ?>
|
||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||
</head>
|
||||
<?
|
||||
flush();
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
<link rel="alternate" type="application/rss+xml" title="xxx.org.za RSS feed" href="/feed" />
|
||||
<script type="text/javascript" src="../utilities.js"></script>
|
||||
<? include_once('tinymce_init.inc.php'); ?>
|
||||
<? if (!$is_admin ) { ?>
|
||||
<script src="https://www.google.com/recaptcha/api.js"></script>
|
||||
<? } ?>
|
||||
</head>
|
||||
<?
|
||||
flush();
|
||||
|
||||
+11
-6
@@ -2,12 +2,17 @@
|
||||
$result = get_post_data(TRUE, TRUE);
|
||||
extract($result[0], EXTR_OVERWRITE);
|
||||
|
||||
if (isset($_POST['recaptcha_challenge_field']) && isset($_POST['recaptcha_response_field'])) {
|
||||
include_once('../lib/recaptchalib.inc.php');
|
||||
$privatekey = config('RECAPTCHA_SECRET');
|
||||
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"],
|
||||
$_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
|
||||
if (!$resp->is_valid) {
|
||||
if (isset($_POST['g-recaptcha-response'])) {
|
||||
$captcha = $_POST['g-recaptcha-response'];
|
||||
if (! $captcha) {
|
||||
$validate['captcha'] = 'Invalid captcha. Please try again.';
|
||||
include('./write.inc.php');
|
||||
return;
|
||||
}
|
||||
$captcha_resp = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".urlencode(config('RECAPTCHA_SECRET'))."&response=".
|
||||
$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
|
||||
var_dump($captcha_resp);
|
||||
if ($captcha_resp.success==false) {
|
||||
$validate['captcha'] = 'The words you typed in the captcha were not correct. Please try again.';
|
||||
include('./write.inc.php');
|
||||
return;
|
||||
|
||||
@@ -161,3 +161,7 @@ ul.error-box li {
|
||||
position:relative;
|
||||
top:0.6em;
|
||||
}
|
||||
|
||||
.g-recaptcha {
|
||||
margin-left: 120px;
|
||||
}
|
||||
|
||||
@@ -111,24 +111,6 @@ if (isset($file_src) || isset($img)) {
|
||||
if (!$is_admin && (($action == "") || isset($validate['captcha']))) {
|
||||
echo '<div><br class="clear" /></div>';
|
||||
echo '<div class="g-recaptcha" data-sitekey="'.htmlspecialchars(config('RECAPTCHA_SITE_KEY')).'"></div>';
|
||||
echo '<div id="captcha" style="display: none;">';
|
||||
echo '<div id="recaptcha_image"></div>';
|
||||
$redo_cap_class = isset($validate['captcha']) ? 'class="no" ' : '';
|
||||
echo '<label '.$redo_cap_class.'for="recaptcha_response_field">Type the two words:</label>';
|
||||
echo '<input type="text" name="recaptcha_response_field" id="recaptcha_response_field" maxlength="150" value="" />';
|
||||
echo '<span class="required"> *</span>';
|
||||
echo '<span class="icons">';
|
||||
echo '<a href="javascript:Recaptcha.reload()">';
|
||||
echo '<img src="/graphics/recaptcha-refresh.png" alt="Refresh CAPTCHA" title="Refresh CAPTCHA" /></a>';
|
||||
echo '<span class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type(\'audio\')">';
|
||||
echo '<img src="/graphics/recaptcha-audio.png" alt="Get audio CAPTCHA" title="Audio version" /></a></span>';
|
||||
echo '<span class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type(\'image\')">';
|
||||
echo '<img src="/graphics/recaptcha-text.png" alt="Get image CAPTCHA" title="Image version" /></a></span>';
|
||||
echo '<a href="javascript:Recaptcha.showhelp()">';
|
||||
echo '<img src="/graphics/recaptcha-help.png" alt="CAPTCHA help" title="Help" /></a>';
|
||||
echo '</span>';
|
||||
echo '<br class="clear" />';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if ($is_admin) {
|
||||
|
||||
Reference in New Issue
Block a user