function wpss_insert_footer_js()
 {
     /***
      * Insert WP-SpamShield JS into footer. This adds essential hidden fields to the relevant forms via jQuery. (REF2XJS and FVFJS)
      * Added 1.8.9.9
      ***/
     if (!is_admin() && is_user_logged_in() || !is_user_logged_in()) {
         $wpss_key_values = spamshield_get_key_values();
         $wpss_js_key = $wpss_key_values['wpss_js_key'];
         $wpss_js_val = $wpss_key_values['wpss_js_val'];
         $spamshield_options = get_option('spamshield_options');
         $comment_min_length = !empty($spamshield_options['comment_min_length']) ? $spamshield_options['comment_min_length'] : '15';
         /* Add REF2XJS and FVFJS code */
         echo "\n";
         global $wpss_ao_active;
         $ao_noop_open = $ao_noop_close = '';
         if (empty($wpss_ao_active)) {
             $wpss_ao_active = spamshield_is_plugin_active('autoptimize/autoptimize.php');
         }
         if (!empty($wpss_ao_active)) {
             $ao_noop_open = '<!--noptimize-->';
             $ao_noop_close = '<!--/noptimize-->';
         }
         /* Add noptimize tags if Autoptimize is active */
         echo $ao_noop_open . '<script type=\'text/javascript\'>' . "\n" . '/* <![CDATA[ */' . "\n" . WPSS_REF2XJS . '=escape(document[\'referrer\']);' . "\n" . 'hf4N=\'' . $wpss_js_key . '\';' . "\n" . 'hf4V=\'' . $wpss_js_val . '\';' . "\n" . 'jQuery(document).ready(function($){' . 'var e="#commentform, .comment-respond form, .comment-form, #registerform, #loginform, #wpss_contact_form, .wpcf7-form, .gform_wrapper form, #buddypress #signup_form, .buddypress #signup_form";$(e).submit(function(){$("<input>").attr("type","hidden").attr("name","' . WPSS_REF2XJS . '").attr("value",' . WPSS_REF2XJS . ').appendTo(e);';
         if (FALSE == WPSS_COMPAT_MODE) {
             echo '$("<input>").attr("type","hidden").attr("name",hf4N).attr("value",hf4V).appendTo(e);';
         }
         echo 'return true;});';
         if (TRUE == WPSS_COMPAT_MODE) {
             echo 'var h="form[method=\'post\']";$(h).submit(function(){$("<input>").attr("type","hidden").attr("name",hf4N).attr("value",hf4V).appendTo(h);return true;});';
         } else {
             echo '$("#comment").attr({minlength:"' . $comment_min_length . '",maxlength:"15360"})';
         }
         echo '});' . "\n" . '/* ]]> */' . "\n" . '</script>' . $ao_noop_close . " " . "\n";
     }
 }
Ejemplo n.º 2
0
 function spamshield_check_version()
 {
     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', 'spamshield_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', 'spamshield_admin_notices');
             spamshield_append_log_data("\n" . $notice_text, FALSE);
             return FALSE;
         }
     }
     if (current_user_can('manage_options')) {
         /* Check if plugin has been upgraded */
         spamshield_upgrade_check();
         /* Check for pending admin notices */
         $admin_notices = get_option('spamshield_admin_notices');
         if (!empty($admin_notices)) {
             add_action('admin_notices', 'spamshield_admin_notices');
         }
         /* Make sure user has minimum required WordPress version, in order to prevent issues */
         $wpss_wp_version = RSMP_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', 'spamshield_admin_notices');
             spamshield_append_log_data("\n" . $notice_text, FALSE);
             return FALSE;
         }
         /* Make sure user has minimum required PHP version, in order to prevent issues */
         $wpss_php_version = RSMP_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', 'spamshield_admin_notices');
             spamshield_append_log_data("\n" . $notice_text, FALSE);
             return FALSE;
         }
         /* Security Check - See if (extremely) old version of plugin still active */
         $old_version = 'wp-spamfree/wp-spamfree.php';
         $old_version_active = spamshield_is_plugin_active($old_version);
         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 */
         spamshield_admin_jp_fix();
     }
 }