示例#1
0
 function check_version()
 {
     if (rs_wpss_is_admin_sproc(TRUE)) {
         return;
     }
     if (current_user_can('manage_network')) {
         /* Check for pending admin notices */
         $admin_notices = get_option('spamshield_admin_notices');
         if (!empty($admin_notices)) {
             add_action('network_admin_notices', array($this, 'admin_notices'));
         }
         /* Make sure not network activated */
         if (is_plugin_active_for_network(WPSS_PLUGIN_BASENAME)) {
             deactivate_plugins(WPSS_PLUGIN_BASENAME, TRUE, TRUE);
             $notice_text = __('Plugin deactivated. WP-SpamShield is not available for network activation.', WPSS_PLUGIN_NAME);
             $new_admin_notice = array('style' => 'error', 'notice' => $notice_text);
             update_option('spamshield_admin_notices', $new_admin_notice);
             add_action('network_admin_notices', array($this, 'admin_notices'));
             rs_wpss_append_log_data($notice_text, FALSE);
             return FALSE;
         }
     }
     if (rs_wpss_is_user_admin()) {
         /* Check for deprecated options */
         self::deprecated_options_check();
         /* Check if plugin has been upgraded */
         $this->upgrade_check();
         /* Check for pending admin notices */
         $admin_notices = get_option('spamshield_admin_notices');
         if (!empty($admin_notices)) {
             add_action('admin_notices', array($this, 'admin_notices'));
         }
         /* Make sure user has minimum required WordPress version, in order to prevent issues */
         $wpss_wp_version = WPSS_WP_VERSION;
         if (!empty($wpss_wp_version) && version_compare($wpss_wp_version, WPSS_REQUIRED_WP_VERSION, '<')) {
             deactivate_plugins(WPSS_PLUGIN_BASENAME);
             $notice_text = sprintf(__('Plugin deactivated. WordPress Version %s required. Please upgrade WordPress to the latest version.', WPSS_PLUGIN_NAME), WPSS_REQUIRED_WP_VERSION);
             $new_admin_notice = array('style' => 'error', 'notice' => $notice_text);
             update_option('spamshield_admin_notices', $new_admin_notice);
             add_action('admin_notices', array($this, 'admin_notices'));
             rs_wpss_append_log_data($notice_text, FALSE);
             return FALSE;
         }
         /* Make sure user has minimum required PHP version, in order to prevent issues */
         $wpss_php_version = WPSS_PHP_VERSION;
         if (!empty($wpss_php_version) && version_compare($wpss_php_version, WPSS_REQUIRED_PHP_VERSION, '<')) {
             deactivate_plugins(WPSS_PLUGIN_BASENAME);
             $notice_text = sprintf(__('<p>Plugin deactivated. <strong>Your server is running PHP version %3$s, but WP-SpamShield requires at least PHP %1$s.</strong> We are no longer supporting PHP 5.2, as it has not been supported by the PHP team <a href=%2$s>since 2011</a>, and there are known security, performance, and compatibility issues.</p><p>The version of PHP running on your server is <em>extremely out of date</em>. You should upgrade your PHP version as soon as possible.</p><p>If you need help with this, please contact your web hosting company and ask them to switch your PHP version to 5.4 or 5.5. Please see the <a href=%4$s>plugin documentation</a> and <a href=%5$s>changelog</a> if you have further questions.</p>', WPSS_PLUGIN_NAME), WPSS_REQUIRED_PHP_VERSION, '"http://php.net/archive/2011.php#id2011-08-23-1" target="_blank" rel="external" ', $wpss_php_version, '"' . WPSS_HOME_URL . '?src=' . WPSS_VERSION . '-php-notice#wpss_requirements" target="_blank" rel="external" ', '"' . WPSS_HOME_URL . 'version-history/?src=' . WPSS_VERSION . '-php-notice#ver_182" target="_blank" rel="external" ');
             /* NEEDS TRANSLATION - Added 1.8.2 */
             $new_admin_notice = array('style' => 'error', 'notice' => $notice_text);
             update_option('spamshield_admin_notices', $new_admin_notice);
             add_action('admin_notices', array($this, 'admin_notices'));
             rs_wpss_append_log_data($notice_text, FALSE);
             return FALSE;
         }
         $this->check_nag_notices();
         /* Security Check - See if(extremely) old version of plugin still active */
         $old_version = 'wp-spamfree/wp-spamfree.php';
         $old_version_active = rs_wpss_is_plugin_active($old_version, FALSE);
         if (!empty($old_version_active)) {
             /***
              * Not safe to keep old version active due to unpatched security hole(s), broken PHP, and lack of maintenance.
              * For security reasons, deactivate old version.
              ***/
             deactivate_plugins($old_version);
             /* Clean up database */
             $del_options = array('wp_spamfree_version', 'spamfree_count', 'spamfree_options');
             foreach ($del_options as $i => $option) {
                 delete_option($option);
             }
             /***
              * Good to go!
              * Since WP-SpamShield takes over 100% of old version's responsibilities, there is no loss of functionality, only improvements.
              * Site speed will improve and server load will now drop dramatically.
              ***/
         }
         /* Compatibility Checks */
         if (TRUE === WPSS_COMPAT_MODE || defined('WPSS_SOFT_COMPAT_MODE')) {
             rs_wpss_admin_jp_fix();
         }
         rs_wpss_admin_ao_fix();
         rs_wpss_admin_fscf_fix();
     }
 }
 function check_requirements()
 {
     if (rs_wpss_is_admin_sproc(TRUE) || rs_wpss_is_doing_ajax()) {
         return;
     }
     if (current_user_can('manage_network')) {
         /* Check for pending admin notices */
         $admin_notices = get_option('spamshield_admin_notices');
         if (!empty($admin_notices)) {
             add_action('network_admin_notices', array($this, 'admin_notices'));
         }
         /* Make sure not network activated */
         if (is_plugin_active_for_network(WPSS_PLUGIN_BASENAME)) {
             deactivate_plugins(WPSS_PLUGIN_BASENAME, TRUE, TRUE);
             $notice_text = __('Plugin deactivated. WP-SpamShield is not available for network activation.', 'wp-spamshield');
             /* TO DO: Fix translation. */
             $new_admin_notice = array('style' => 'error notice is-dismissible', 'notice' => $notice_text);
             update_option('spamshield_admin_notices', $new_admin_notice);
             add_action('network_admin_notices', array($this, 'admin_notices'));
             rs_wpss_append_log_data($notice_text, FALSE);
             return FALSE;
         }
     }
     if (rs_wpss_is_user_admin()) {
         /* Check for deprecated options */
         self::deprecated_options_check();
         /* Check if plugin has been upgraded */
         $this->upgrade_check();
         /* Check for outdated WordPress versions with known security flaws */
         $this->insecure_wordpress_check();
         /* Check for pending admin notices */
         $admin_notices = get_option('spamshield_admin_notices');
         if (!empty($admin_notices)) {
             add_action('admin_notices', array($this, 'admin_notices'));
         }
         /* Make sure user has minimum required WordPress version, in order to prevent issues */
         $wpss_wp_version = WPSS_WP_VERSION;
         if (!empty($wpss_wp_version) && version_compare($wpss_wp_version, WPSS_REQUIRED_WP_VERSION, '<')) {
             deactivate_plugins(WPSS_PLUGIN_BASENAME);
             $notice_text = sprintf(__('Plugin deactivated. WordPress Version %s required. Please upgrade WordPress to the latest version.', 'wp-spamshield'), WPSS_REQUIRED_WP_VERSION);
             /* TO DO: Fix translation. */
             $new_admin_notice = array('style' => 'error notice is-dismissible', 'notice' => $notice_text);
             update_option('spamshield_admin_notices', $new_admin_notice);
             add_action('admin_notices', array($this, 'admin_notices'));
             rs_wpss_append_log_data($notice_text, FALSE);
             return FALSE;
         }
         /* Make sure user has minimum required PHP version, in order to prevent issues */
         $wpss_php_version = WPSS_PHP_VERSION;
         if (!empty($wpss_php_version) && version_compare($wpss_php_version, WPSS_REQUIRED_PHP_VERSION, '<')) {
             deactivate_plugins(WPSS_PLUGIN_BASENAME);
             $notice_text = '<p>' . __('Plugin <strong>deactivated</strong>.') . ' ' . str_replace('WordPress', 'WP-SpamShield', sprintf(__('Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.'), WPSS_PHP_VERSION, WPSS_VERSION, WPSS_REQUIRED_PHP_VERSION)) . ' ' . sprintf(__('We are no longer supporting PHP 5.2, as it reached its End of Life (no longer supported by the PHP team) <a href=%2$s>in 2011</a>, and there are known security, performance, and compatibility issues. We are phasing out support for PHP 5.3 as it reached End of Life in 2014.</p><p>The version of PHP running on your server is <em>extremely out of date</em>. You should upgrade your PHP version as soon as possible.</p><p>If you need help with this, please contact your web hosting company and ask them to switch your PHP version to 5.5, 5.6, or higher. Please see the <a href=%4$s>plugin documentation</a> and <a href=%5$s>changelog</a> if you have further questions.', 'wp-spamshield'), WPSS_REQUIRED_PHP_VERSION, '"http://php.net/archive/2011.php#id2011-08-23-1" target="_blank" rel="external" ', $wpss_php_version, '"' . rs_wpss_append_url(WPSS_HOME_URL . '?src=' . WPSS_VERSION . '-php-notice#wpss_requirements') . '" target="_blank" rel="external" ', '"' . rs_wpss_append_url(WPSS_HOME_URL . 'version-history/?src=' . WPSS_VERSION . '-php-notice#ver_182') . '" target="_blank" rel="external" ') . '</p>';
             /* TO DO: NEEDS TRANSLATION - Added 1.8.2, Updated 1.9.7.4 */
             $new_admin_notice = array('style' => 'error notice is-dismissible', 'notice' => $notice_text);
             update_option('spamshield_admin_notices', $new_admin_notice);
             add_action('admin_notices', array($this, 'admin_notices'));
             rs_wpss_append_log_data($notice_text, FALSE);
             return FALSE;
         }
         $wpss_wp_config_error = $this->check_wp_config_status();
         /* TO DO: Make version for Network Admins when we add full Multisite compatibility (Network Activation) */
         if (!empty($wpss_wp_config_error)) {
             deactivate_plugins(WPSS_PLUGIN_BASENAME);
             $correct_error = sprintf(__('Please check your <a href="%1$s">settings</a> and correct the error.', 'wp-spamshield'), WPSS_ADMIN_URL . '/options-general.php');
             $notice_text = sprintf('<p>%1$s <strong>%2$s %3$s</strong> %4$s</p>', __('Plugin <strong>deactivated</strong>.'), __('There is an error in your WordPress configuration.', 'wp-spamshield'), $wpss_wp_config_error, $correct_error);
             /* TO DO: NEEDS TRANSLATION - Added 1.9.7.1 */
             $new_admin_notice = array('style' => 'error', 'notice' => $notice_text);
             update_option('spamshield_admin_notices', $new_admin_notice);
             add_action('admin_notices', array($this, 'admin_notices'));
             rs_wpss_append_log_data($notice_text, FALSE);
             return FALSE;
         }
         $this->check_cpn_notices();
         /* Security Check - See if(extremely) old version of plugin still active */
         $old_version = 'wp-spamfree/wp-spamfree.php';
         $old_version_active = WPSS_Compatibility::is_plugin_active($old_version, FALSE);
         if (!empty($old_version_active)) {
             /**
              * Not safe to keep old version active due to unpatched security hole(s), broken PHP, and lack of maintenance.
              * For security reasons, deactivate old version.
              */
             deactivate_plugins($old_version);
             /* Clean up database */
             $del_options = array('wp_spamfree_version', 'spamfree_count', 'spamfree_options');
             foreach ($del_options as $i => $option) {
                 delete_option($option);
             }
             /**
              * Good to go!
              * Since WP-SpamShield takes over 100% of old version's responsibilities, there is no loss of functionality, only improvements.
              * Site speed will improve and server load will now drop dramatically.
              */
         }
         /* Compatibility Checks */
         if (TRUE === WPSS_COMPAT_MODE || defined('WPSS_SOFT_COMPAT_MODE')) {
             rs_wpss_admin_jp_fix();
         }
         rs_wpss_admin_ao_fix();
         rs_wpss_admin_fscf_fix();
     }
 }