Superior antispam protection. Instead of duplicating code by checking what method is being used in both index.php and result.php, now the check is performed in index.php and a POST variable is passed to the result.php page. Furthermore, antispam protection is ommitted if the user is logged into YOURLS.

This commit is contained in:
Tom Slominski
2015-03-22 18:36:25 +00:00
parent 222e7a3b8c
commit 3998b6c1a6
2 changed files with 43 additions and 17 deletions

View File

@@ -32,21 +32,28 @@ $title = isset( $_REQUEST['title'] ) ? yourls_sanitize_title( $_REQUEST['title
</div>
<?php
if ( !empty(ISQ::$recaptcha['sitekey']) && !empty(ISQ::$recaptcha['secret']) ) {
if ( yourls_is_valid_user() == 1 ) {
echo '<input type="hidden" name="antispam_method" value="user_login" class="hidden">';
} else if ( !empty(ISQ::$recaptcha['sitekey']) && !empty(ISQ::$recaptcha['secret']) ) {
$dependencies[] = 'reCAPTCHA';
?>
<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
echo '<input type="hidden" name="antispam_method" value="recaptcha" class="hidden">';
?>
<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
echo '<input type="hidden" name="antispam_method" value="basic" class="hidden">';
echo '<input type="hidden" name="basic_antispam" class="hidden">';
}
?>