Giving users the option not to use reCAPTCHA. If you don't input reCAPTCHA keys, basic spam protection will be enabled, even though its less effective.
This commit is contained in:
12
index.php
12
index.php
@@ -31,11 +31,23 @@ $title = isset( $_REQUEST['title'] ) ? yourls_sanitize_title( $_REQUEST['title
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if ( !empty(ISQ::$recaptcha['sitekey']) && !empty(ISQ::$recaptcha['secret']) ) {
|
||||||
|
?>
|
||||||
<div class="form-item recaptcha-container">
|
<div class="form-item recaptcha-container">
|
||||||
<p><label class="primary" title=""><?php yourls_e( 'Verification', 'isq_translation'); ?></label></p>
|
<p><label class="primary" title=""><?php yourls_e( 'Verification', 'isq_translation'); ?></label></p>
|
||||||
<p><label class="secondary"><?php yourls_e( 'reCAPTCHA verification used to ensure you are not a bot.', 'isq_translation'); ?></label></p>
|
<p><label class="secondary"><?php yourls_e( 'reCAPTCHA verification used to ensure you are not a bot.', 'isq_translation'); ?></label></p>
|
||||||
<div class="g-recaptcha" data-sitekey="<?php echo ISQ::$recaptcha['sitekey']; ?>"></div>
|
<div class="g-recaptcha" data-sitekey="<?php echo ISQ::$recaptcha['sitekey']; ?>"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<?php
|
||||||
|
} else {
|
||||||
|
?>
|
||||||
|
<div class="hidden">
|
||||||
|
<input type="hidden" name="basic_antispam">
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<div class="form-item submit-container">
|
<div class="form-item submit-container">
|
||||||
<input type="submit" class="button" value="<?php yourls_e( 'Shorten', 'isq_translation'); ?>">
|
<input type="submit" class="button" value="<?php yourls_e( 'Shorten', 'isq_translation'); ?>">
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ ISQ::$social = array(
|
|||||||
|
|
||||||
// reCAPTCHA API KEYS
|
// reCAPTCHA API KEYS
|
||||||
// Get yourls from https://www.google.com/recaptcha/admin
|
// Get yourls from https://www.google.com/recaptcha/admin
|
||||||
|
// If you don't want to use reCAPTCHA, that's cool. Leave this empty, and basic
|
||||||
|
// antispam protection will be provided.
|
||||||
ISQ::$recaptcha = array(
|
ISQ::$recaptcha = array(
|
||||||
'sitekey' => '',
|
'sitekey' => '',
|
||||||
'secret' => ''
|
'secret' => ''
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ a, a:visited {
|
|||||||
box-shadow: 0 0 3px 0 #CCC;
|
box-shadow: 0 0 3px 0 #CCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
/* Header */
|
/* Header */
|
||||||
.site-header {
|
.site-header {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|||||||
22
result.php
22
result.php
@@ -3,16 +3,26 @@ $dependencies = array( 'ZeroClipboard' );
|
|||||||
|
|
||||||
include('header.php');
|
include('header.php');
|
||||||
|
|
||||||
$recaptcha_data = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . ISQ::$recaptcha['secret'] . '&response=' . $_REQUEST['g-recaptcha-response']);
|
function display_error($message) {
|
||||||
$recaptcha_json = json_decode($recaptcha_data, TRUE);
|
echo '<div class="content"><p class="error">' . $message . '</p></div>';
|
||||||
|
|
||||||
// What happens when the CAPTCHA was completed incorrectly
|
|
||||||
if ($recaptcha_json['success'] != 'true') {
|
|
||||||
echo '<div class="content"><p class="error">' . yourls__( 'Are you a bot? Google certainly thinks so. Please go back and try again.', 'isq_translation' ) . '</p></div>';
|
|
||||||
include('footer.php');
|
include('footer.php');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !empty(ISQ::$recaptcha['sitekey']) && !empty(ISQ::$recaptcha['secret']) ) {
|
||||||
|
$recaptcha_data = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . ISQ::$recaptcha['secret'] . '&response=' . $_REQUEST['g-recaptcha-response']);
|
||||||
|
$recaptcha_json = json_decode($recaptcha_data, TRUE);
|
||||||
|
|
||||||
|
// What happens when the CAPTCHA was completed incorrectly
|
||||||
|
if ( $recaptcha_json['success'] != 'true' ) {
|
||||||
|
display_error( yourls__( 'Are you a bot? Google certainly thinks you are. Please go back and try again.', 'isq_translation' ) );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( $_REQUEST['basic_antispam'] != "" ) {
|
||||||
|
display_error( yourls__( 'Are you a bot? The verification was not completed successfully. Please go back and try again.', 'isq_translation' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$url = isset( $_REQUEST['url'] ) ? yourls_sanitize_url( $_REQUEST['url'] ) : '';
|
$url = isset( $_REQUEST['url'] ) ? yourls_sanitize_url( $_REQUEST['url'] ) : '';
|
||||||
$keyword = isset( $_REQUEST['keyword'] ) ? yourls_sanitize_keyword( $_REQUEST['keyword'] ) : '' ;
|
$keyword = isset( $_REQUEST['keyword'] ) ? yourls_sanitize_keyword( $_REQUEST['keyword'] ) : '' ;
|
||||||
$title = isset( $_REQUEST['title'] ) ? yourls_sanitize_title( $_REQUEST['title'] ) : '' ;
|
$title = isset( $_REQUEST['title'] ) ? yourls_sanitize_title( $_REQUEST['title'] ) : '' ;
|
||||||
|
|||||||
Reference in New Issue
Block a user