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>
|
||||
|
||||
<?php
|
||||
if ( !empty(ISQ::$recaptcha['sitekey']) && !empty(ISQ::$recaptcha['secret']) ) {
|
||||
?>
|
||||
<div class="form-item recaptcha-container">
|
||||
<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>
|
||||
<div class="g-recaptcha" data-sitekey="<?php echo ISQ::$recaptcha['sitekey']; ?>"></div>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<div class="hidden">
|
||||
<input type="hidden" name="basic_antispam">
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="form-item submit-container">
|
||||
<input type="submit" class="button" value="<?php yourls_e( 'Shorten', 'isq_translation'); ?>">
|
||||
|
||||
@@ -40,6 +40,8 @@ ISQ::$social = array(
|
||||
|
||||
// reCAPTCHA API KEYS
|
||||
// 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(
|
||||
'sitekey' => '',
|
||||
'secret' => ''
|
||||
|
||||
@@ -48,6 +48,10 @@ a, a:visited {
|
||||
box-shadow: 0 0 3px 0 #CCC;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.site-header {
|
||||
margin: 0 auto;
|
||||
|
||||
16
result.php
16
result.php
@@ -3,14 +3,24 @@ $dependencies = array( 'ZeroClipboard' );
|
||||
|
||||
include('header.php');
|
||||
|
||||
function display_error($message) {
|
||||
echo '<div class="content"><p class="error">' . $message . '</p></div>';
|
||||
include('footer.php');
|
||||
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' ) {
|
||||
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');
|
||||
die();
|
||||
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'] ) : '';
|
||||
|
||||
Reference in New Issue
Block a user