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() { $this->_settings = AVH_FDAS_Settings::getInstance(); $this->_db_version = 28; $this->_comment = '<!-- AVH First Defense Against Spam version ' . AVH_FDAS_Define::PLUGIN_VERSION; $this->_db_options = 'avhfdas'; $this->_db_data = 'avhfdas_data'; $this->_db_nonces = 'avhfdas_nonces'; /** * Default options - General Purpose */ $this->_default_options_general = array('version' => AVH_FDAS_Define::PLUGIN_VERSION, 'dbversion' => $this->_db_version, 'use_sfs' => 1, 'use_php' => 0, 'use_sh' => 0, 'useblacklist' => 1, 'addblacklist' => 0, 'usewhitelist' => 1, 'diewithmessage' => 1, 'emailsecuritycheck' => 0, 'useipcache' => 0, 'commentnonce' => 0, 'cron_nonces_email' => 0, 'cron_ipcache_email' => 0); $this->_default_options_spam = array('whentoemail' => -1, 'whentodie' => 3, 'whentodie_email' => 15, 'sfsapikey' => '', 'error' => 0); $this->_default_options_honey = array('whentoemailtype' => -1, 'whentoemail' => -1, 'whentodietype' => 4, 'whentodie' => 25, 'phpapikey' => '', 'usehoneypot' => 0, 'honeypoturl' => ''); $this->_default_options_spamhaus = array('email' => 0); $this->_default_options_ipcache = array('email' => 0, 'daystokeep' => 7); $this->_default_options = array('general' => $this->_default_options_general, 'sfs' => $this->_default_options_spam, 'php' => $this->_default_options_honey, 'ipcache' => $this->_default_options_ipcache, 'spamhaus' => $this->_default_options_spamhaus); /** * Default Data */ $this->_default_data_spam = array('190001' => 0); $this->_default_data_lists = array('blacklist' => '', 'whitelist' => ''); $this->_default_data = array('counters' => $this->_default_data_spam, 'lists' => $this->_default_data_lists); /** * Default Nonces */ $this->_default_nonces_data = null; $this->_default_nonces = array('default' => $this->_default_nonces_data); /** * Set the options for the program */ $this->_loadOptions(); $this->_loadData(); $this->_setTables(); // Check if we have to do upgrades if (!isset($this->_options['general']['dbversion']) || $this->getOptionElement('general', 'dbversion') < $this->_db_version) { $this->_doUpgrade(); } $this->_settings->storeSetting('siteurl', get_option('siteurl')); $this->_settings->storeSetting('graphics_url', plugins_url('images', $this->_settings->plugin_basename)); $this->_settings->storeSetting('js_url', plugins_url('js', $this->_settings->plugin_basename)); $this->_settings->storeSetting('css_url', plugins_url('css', $this->_settings->plugin_basename)); $this->_settings->storeSetting('lang_dir', AVH_FDAS_Define::PLUGIN_PATH . '/lang/'); $this->_settings->storeSetting('searchengines', array('0' => 'Undocumented', '1' => 'AltaVista', '2' => 'Ask', '3' => 'Baidu', '4' => 'Excite', '5' => 'Google', '6' => 'Looksmart', '7' => 'Lycos', '8' => 'MSN', '9' => 'Yahoo', '10' => 'Cuil', '11' => 'InfoSeek', '12' => 'Miscellaneous')); $footer[] = ''; $footer[] = '--'; $footer[] = sprintf('Your blog is protected by AVH First Defense Against Spam v%s', AVH_FDAS_Define::PLUGIN_VERSION); $footer[] = 'http://blog.avirtualhome.com/wordpress-plugins'; $this->_settings->storeSetting('mail_footer', $footer); load_plugin_textdomain('avh-fdas', false, $this->_settings->lang_dir); return; }
/** * Initialize the plugin */ function avh_FDAS_init() { $_settings = AVH_FDAS_Settings::getInstance(); $_settings->storeSetting('plugin_working_dir', pathinfo(__FILE__, PATHINFO_DIRNAME)); // Admin if (is_admin()) { require_once $_settings->plugin_working_dir . '/class/avh-fdas.admin.php'; $avhfdas_admin = new AVH_FDAS_Admin(); // Activation Hook register_activation_hook(__FILE__, array(&$avhfdas_admin, 'installPlugin')); // Deactivation Hook register_deactivation_hook(__FILE__, array(&$avhfdas_admin, 'deactivatePlugin')); } require_once $_settings->plugin_working_dir . '/class/avh-fdas.public.php'; new AVH_FDAS_Public(); }
/** * Do the HTTP call to and report the spammer * * @param string $username * @param string $email * @param string $ip_addr */ private function _handleReportSpammer($username, $email, $ip_addr) { if (!empty($email)) { $url = 'http://www.stopforumspam.com/add.php'; $call = wp_remote_post($url, array('user-agent' => 'WordPress/AVH ' . AVH_FDAS_Define::PLUGIN_VERSION . '; ' . get_bloginfo('url'), 'body' => array('username' => $username, 'ip_addr' => $ip_addr, 'email' => $email, 'api_key' => $this->_core->getOptionElement('sfs', 'sfsapikey')))); if (is_wp_error($call) || 200 != $call['response']['code']) { $to = get_option('admin_email'); $subject = sprintf('[%s] AVH First Defense Against Spam - ' . __('Error reporting spammer', 'avh-fdas'), wp_specialchars_decode(get_option('blogname'), ENT_QUOTES)); if (is_wp_error($call)) { $message = $call->get_error_messages(); } else { $message[] = $call['body']; } AVH_Common::sendMail($to, $subject, $message, $this->_settings->getSetting('mail_footer')); } } }
/** * 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'; }
} $_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 remove_action('deactivate_' . AVH_FDAS_Define::PLUGIN_FILE, 'deactivate_sitewide_plugin'); $key = array_search(AVH_FDAS_Define::PLUGIN_FILE, $active_plugins); if ($key !== false) { do_action('deactivate_plugin', AVH_FDAS_Define::PLUGIN_FILE); array_splice($active_plugins, $key, 1);