/** * Creates a random, one time use token. * * @since 2.0.4 * * @param string|int $action Scalar value to add context to the nonce. * @return string The one use form token */ function bb_create_nonce($action = -1) { $user = bb_get_current_user(); $uid = (int) $user->ID; $i = bb_nonce_tick(); return substr(bb_hash($i . $action . $uid, 'nonce'), -12, 10); }
*/ define('NOSPAMUSER_AGENT', ' | NoSpamUser/0.8'); if (!function_exists('add_action')) { @(include_once dirname(dirname(dirname(__FILE__))) . '/bb-load.php' or exit); if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' && isset($_POST['nonce']) && bb_verify_nonce($_POST['nonce'], 'nospamuser-nonce-' . $_SERVER['REMOTE_ADDR'])) { $settings = bb_get_option('nospamuser-settings'); if ($settings['recaptcha_mode'] == 'aggressive') { exit; } if (!function_exists('recaptcha_check_answer')) { // Compatibility with anything else that uses reCAPTCHA require_once dirname(__FILE__) . '/recaptchalib.php'; } $resp = recaptcha_check_answer($settings['recaptcha_priv'], $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']); if ($resp->is_valid) { setcookie('nospamuser-override', bb_create_nonce('nospamuser-override-' . $_SERVER['REMOTE_ADDR']), bb_nonce_tick() * apply_filters('bb_nonce_life', 86400) / 2); } bb_safe_redirect(bb_get_uri('register.php', null, BB_URI_CONTEXT_BB_USER_FORMS + BB_URI_CONTEXT_HEADER)); } exit; } function nospamuser_install() { bb_update_option('nospamuser-settings', wp_parse_args(bb_get_option('nospamuser-settings'), array('days' => 30, 'min_occur' => 5, 'max_occur' => 10, 'api_key' => '', 'recaptcha_mode' => 'aggressive', 'recapthca_pub' => '', 'recaptcha_priv' => '', 'stats_public' => 0))); } bb_register_plugin_activation_hook(__FILE__, 'nospamuser_install'); function nospamuser_admin_parse() { bb_check_admin_referer('nospamuser-admin'); $settings = bb_get_option('nospamuser-settings'); $success = array();