echo '<div class="content error">'; echo '<p class="message">' . $message . '</p>'; if (!empty($action)) { echo $action; } else { echo '<p class="action"><a href="javascript:history.go(-1)" class="button">' . yourls__('← Go back and try again', 'isq_translation') . '</a></p>'; } echo '</div>'; include 'footer.php'; die; } if (empty($_REQUEST['url'])) { display_error(yourls__('You haven\'t entered a URL to shorten.', 'isq_translation')); } // Check if the keyword is reserved if (!empty($_REQUEST['keyword']) && yourls_keyword_is_reserved($_REQUEST['keyword'])) { display_error(sprintf(yourls__('The keyword %1$s is reserved.'), '<span class="key">' . $_REQUEST['keyword'] . '</span>')); } // Check what CAPTCHA method was used $antispam_method = $_REQUEST['antispam_method']; if ($antispam_method == 'user_login') { // User is logged into YOURLS } else { if ($antispam_method == 'recaptcha') { // Google reCAPTCHA is enabled $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 reCAPTCHA was completed incorrectly if ($recaptcha_json['success'] != 'true') { display_error(yourls__('Are you a bot? Google certainly thinks you are.', 'isq_translation')); }
/** * Check if keyword id is free (ie not already taken, and not reserved). Return bool. * */ function yourls_keyword_is_free($keyword) { $free = true; if (yourls_keyword_is_reserved($keyword) or yourls_keyword_is_taken($keyword)) { $free = false; } return yourls_apply_filter('keyword_is_free', $free, $keyword); }
function yourls_keyword_is_free($keyword) { if (yourls_keyword_is_reserved($keyword) or yourls_keyword_is_taken($keyword)) { return false; } return true; }