/** * Clean up the nonce DB by using Cron * * @WordPress: Action avhfdas_clean_nonce */ public function actionHandleCronCleanNonce() { $removed = 0; $options = $this->_core->getOptions(); $all = get_option($this->_core->getDbNonces()); if (is_array($all)) { foreach ($all as $key => $value) { if (!(false === AVH_Security::verifyNonce($key, $value))) { unset($all[$key]); $removed++; } } update_option($this->_core->getDbNonces(), $all); } if ($options['general']['cron_nonces_email']) { $to = get_option('admin_email'); $subject = sprintf('[%s] AVH First Defense Against Spam - Cron - ' . __('Clean nonces', 'avh-fdas'), wp_specialchars_decode(get_option('blogname'), ENT_QUOTES)); $message[] = sprintf(__('Deleted %d nonce\'s from the database', 'avh-fdas'), $removed); AVH_Common::sendMail($to, $subject, $message, $this->_settings->getSetting('mail_footer')); } }
/** * Handles the admin_action_blacklist call * * @WordPress Action admin_action_blacklist */ public function actionHandleBlacklistUrl() { if (!(isset($_REQUEST['action']) && 'blacklist' == $_REQUEST['action'])) { return; } $ip = $_REQUEST['i']; if (!(false === AVH_Security::verifyNonce($_REQUEST['_avhnonce'], $ip))) { $blacklist = $this->_core->getDataElement('lists', 'blacklist'); if (!empty($blacklist)) { $b = explode("\r\n", $blacklist); } else { $b = array(); } if (!in_array($ip, $b)) { array_push($b, $ip); $this->_setBlacklistOption($b); wp_redirect(admin_url('admin.php?page=' . AVH_FDAS_Define::MENU_SLUG_GENERAL . '&m=' . AVH_FDAS_Define::ADDED_BLACKLIST . '&i=' . $ip)); } else { wp_redirect(admin_url('admin.php?page=' . AVH_FDAS_Define::MENU_SLUG_GENERAL . '&m=' . AVH_FDAS_Define::ERROR_EXISTS_IN_BLACKLIST . '&i=' . $ip)); } } else { wp_redirect(admin_url('admin.php?page=' . AVH_FDAS_Define::MENU_SLUG_GENERAL . '&m=' . AVH_FDAS_Define::ERROR_INVALID_REQUEST)); } }