public function handleInitializePlugin() { // Get The Registry $this->_settings = AVH_FDAS_Settings::getInstance(); $this->_classes = AVH_FDAS_Classes::getInstance(); // Initialize the plugin $this->_core = $this->_classes->load_class('Core', 'plugin', true); $this->_spamcheck = $this->_classes->load_class('SpamCheck', 'plugin', true); $this->_core_options = $this->_core->getOptions(); // Public actions and filters if (1 == $this->_core_options['general']['commentnonce']) { add_action('comment_form', array($this, 'actionAddNonceFieldToComment')); add_filter('preprocess_comment', array($this, 'filterCheckNonceFieldToComment'), 1); } add_action('get_header', array($this, 'handleActionGetHeader')); add_action('pre_comment_on_post', array($this, 'handleActionPreCommentOnPost'), 1); add_filter('registration_errors', array($this, 'handleFilterRegistrationErrors'), 10, 3); add_filter('wpmu_validate_user_signup', array($this, 'handleFilterWPMUValidateUserSignup'), 1); if ($this->_core_options['php']['usehoneypot']) { add_action('comment_form', array($this, 'handleActionDisplayHoneypotUrl')); add_action('login_footer', array($this, 'handleActionDisplayHoneypotUrl')); } // Private actions for Cron add_action('avhfdas_clean_nonce', array($this, 'actionHandleCronCleanNonce')); add_action('avhfdas_clean_ipcache', array($this, 'actionHandleCronCleanIpCache')); /** * Hook in registration process for Events Manager */ if (defined('EM_VERSION')) { add_filter('em_registration_errors', array($this, 'handleFilterRegistrationErrors'), 10, 3); } }
/** * Singleton method to access the Registry * * @access public */ public static function getInstance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
function __construct() { // Get The Registry $this->_settings = AVH_FDAS_Settings::getInstance(); $this->_classes = AVH_FDAS_Classes::getInstance(); // Initialize the plugin $this->_core = $this->_classes->load_class('Core', 'plugin', true); $this->_ipcachedb = $this->_classes->load_class('DB', 'plugin', true); $this->screen = 'avh_f_d_a_s_page_avh_first_defense_against_spam_ip_cache_'; $default_status = get_user_option('avhfdas_ip_cache_list_last_view'); if (empty($default_status)) { $default_status = 'all'; } $status = isset($_REQUEST['avhfdas_ip_cache_list_status']) ? $_REQUEST['avhfdas_ip_cache_list_status'] : $default_status; if (!in_array($status, array('all', 'ham', 'spam', 'search'))) { $status = 'all'; } if ($status != $default_status && 'search' != $status) { update_user_meta(get_current_user_id(), 'avhfdas_ip_cache_list_last_view', $status); } if (AVH_Common::getWordpressVersion() >= 3.2) { parent::__construct(array('plural' => 'ips', 'singular' => 'ip', 'ajax' => true)); } else { parent::WP_List_Table(array('plural' => 'ips', 'singular' => 'ip', 'ajax' => true)); } }
/** * PHP5 Constructor */ public function __construct() { // Get The Registry $this->_settings = AVH_FDAS_Settings::getInstance(); $this->_classes = AVH_FDAS_Classes::getInstance(); // Initialize the plugin $this->_core = $this->_classes->load_class('Core', 'plugin', true); $this->_ipcachedb = $this->_classes->load_class('DB', 'plugin', true); $this->_visiting_ip = AVH_Visitor::getUserIp(); $this->_visiting_email = ''; $this->_core_options = $this->_core->getOptions(); $this->_core_data = $this->_core->getData(); $this->_spaminfo = null; $this->_spammer_detected = false; $this->_ip_in_white_list = false; $this->_ip_in_cache = false; $this->_spamcheck_functions_array[00] = 'Blacklist'; $this->_spamcheck_functions_array[02] = 'IpCache'; $this->_spamcheck_functions_array[05] = 'StopForumSpam'; $this->_spamcheck_functions_array[10] = 'ProjectHoneyPot'; $this->_spamcheck_functions_array[11] = 'Spamhaus'; }
/** * Handles the Get and Post after a submit on the IP cache Log page * * @WordPress Action load-$page_hook */ public function actionLoadPagehookHandlePostGetIpCacheLog() { $this->_ip_cache_list = $this->_classes->load_class('IPCacheList', 'plugin', true); $pagenum = $this->_ip_cache_list->get_pagenum(); $doaction = $this->_ip_cache_list->current_action(); if ($doaction) { switch ($doaction) { case 'delete': case 'blacklist': case 'ham': case 'spam': // These are the BULK actions check_admin_referer('bulk-ips'); if (isset($_REQUEST['delete_ips'])) { $ips = $_REQUEST['delete_ips']; } elseif (wp_get_referer()) { wp_redirect(wp_get_referer()); exit; } $redirect_to = remove_query_arg(array($doaction), wp_get_referer()); $redirect_to = add_query_arg('paged', $pagenum, $redirect_to); switch ($doaction) { case 'delete': $deleted = 0; foreach ($ips as $ip) { $this->_db->deleteIp($ip); $deleted++; } if ($deleted) { $redirect_to = add_query_arg(array('deleted' => $deleted), $redirect_to); } wp_redirect($redirect_to); exit; break; case 'blacklist': $blacklisted = 0; $blacklist = $this->_core->getDataElement('lists', 'blacklist'); if (!empty($blacklist)) { $b = explode("\r\n", $blacklist); } else { $b = array(); } foreach ($ips as $ip) { $ip = long2ip($ip); if (!in_array($ip, $b)) { array_push($b, $ip); $this->_db->deleteIp($ip); $blacklisted++; } } if ($blacklisted) { $this->_setBlacklistOption($b); $redirect_to = add_query_arg(array('blacklisted' => $blacklisted), $redirect_to); } wp_redirect($redirect_to); exit; break; case 'ham': case 'spam': $hamspammed = 0; $new_status = $doaction == 'ham' ? 0 : 1; foreach ($ips as $ip) { $result = $this->_db->updateIpCache(array('ip' => $ip, 'spam' => $new_status)); if ($result !== false) { $hamspammed++; } } if ($hamspammed) { $arg = $doaction == 'ham' ? 'hammed' : 'spammed'; $redirect_to = add_query_arg(array($arg => $hamspammed), $redirect_to); } wp_redirect($redirect_to); exit; break; } break; case 'spamip': case 'hamip': case 'blacklistip': case 'deleteip': // These are the ROW actions $redirect_to = remove_query_arg(array($doaction), wp_get_referer()); $redirect_to = add_query_arg('paged', $pagenum, $redirect_to); $ip = absint($_GET['i']); switch ($doaction) { case 'spamip': case 'hamip': check_admin_referer('hamspam-ip_' . $ip); $new_status = $doaction == 'hamip' ? 0 : 1; $result = $this->_db->updateIpCache(array('ip' => $ip, 'spam' => $new_status)); if ($result) { $arg = $doaction == 'hamip' ? 'hammed' : 'spammed'; $redirect_to = add_query_arg(array($arg => 1), $redirect_to); } wp_redirect($redirect_to); exit; break; case 'blacklistip': $blacklist = $this->_core->getDataElement('lists', 'blacklist'); if (!empty($blacklist)) { $b = explode("\r\n", $blacklist); } else { $b = array(); } $ip_human = long2ip($ip); if (!in_array($ip_human, $b)) { array_push($b, $ip_human); $this->_db->deleteIp($ip); $this->_setBlacklistOption($b); $redirect_to = add_query_arg(array('blacklisted' => 1), $redirect_to); } wp_redirect($redirect_to); exit; break; case 'deleteip': $result = $this->_db->deleteIp($ip); if ($result) { $redirect_to = add_query_arg(array('deleted' => 1), $redirect_to); } $redirect_to = add_query_arg(array('deleted' => $deleted), $redirect_to); } break; } } elseif (!empty($_GET['_wp_http_referer'])) { wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); exit; } if (isset($_REQUEST['deleted']) || isset($_REQUEST['blacklisted']) || isset($_REQUEST['hammed']) || isset($_REQUEST['spammed'])) { $deleted = isset($_REQUEST['deleted']) ? (int) $_REQUEST['deleted'] : 0; $blacklisted = isset($_REQUEST['blacklisted']) ? (int) $_REQUEST['blacklisted'] : 0; $hammed = isset($_REQUEST['hammed']) ? (int) $_REQUEST['hammed'] : 0; $spammed = isset($_REQUEST['spammed']) ? (int) $_REQUEST['spammed'] : 0; if ($deleted > 0) { $this->_ip_cache_list->messages[] = sprintf(_n('%s IP permanently deleted', '%s IP\'s deleted', $deleted), $deleted); } if ($blacklisted > 0) { $this->_ip_cache_list->messages[] = sprintf(_n('%s IP added to the blacklist', '%s IP\'s added to the blacklist', $blacklisted), $blacklisted); } if ($hammed > 0) { $this->_ip_cache_list->messages[] = sprintf(_n('%s IP marked as ham', '%s IP\'s marked as ham', $hammed), $hammed); } if ($spammed > 0) { $this->_ip_cache_list->messages[] = sprintf(_n('%s IP marked as spam', '%s IP\'s marked as spam', $spammed), $spammed); } } $this->_ip_cache_list->prepare_items(); $total_pages = $this->_ip_cache_list->get_pagination_arg('total_pages'); if ($pagenum > $total_pages && $total_pages > 0) { wp_redirect(add_query_arg('paged', $total_pages)); exit; } }
* You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ if (!defined('AVH_FRAMEWORK')) { define('AVH_FRAMEWORK', true); } $_dir = dirname(__FILE__); $_basename = plugin_basename(__FILE__); require_once $_dir . '/libs/avh-registry.php'; require_once $_dir . '/libs/avh-common.php'; require_once $_dir . '/libs/avh-security.php'; require_once $_dir . '/libs/avh-visitor.php'; require_once $_dir . '/class/avh-fdas.registry.php'; require_once $_dir . '/class/avh-fdas.define.php'; if (AVH_Common::getWordpressVersion() >= 2.8) { $_classes = AVH_FDAS_Classes::getInstance(); $_classes->setDir($_dir); $_classes->setClassFilePrefix('avh-fdas.'); $_classes->setClassNamePrefix('AVH_FDAS_'); unset($_classes); $_settings = AVH_FDAS_Settings::getInstance(); $_settings->storeSetting('plugin_dir', $_dir); $_settings->storeSetting('plugin_basename', $_basename); require $_dir . '/avh-fdas.client.php'; } else { add_action('activate_' . AVH_FDAS_Define::PLUGIN_FILE, 'avh_fdas_remove_plugin'); } function avh_fdas_remove_plugin() { $active_plugins = (array) get_option('active_plugins'); // workaround for WPMU deactivation bug