. */ // First we check to make sure you meet the requirements global $wp_version; $exit_msg_ms = 'Sorry, but this plugin is not supported (and will not work) on WordPress single installs.'; $exit_msg_ver = 'Sorry, but this plugin is not supported on pre-3.3 WordPress installs.'; if( !is_multisite() ) { exit($exit_msg_ms); } if (version_compare($wp_version,"3.2","<")) { exit($exit_msg_ver); } // Internationalization add_action( 'init', 'ippy_scc_internationalization' ); function ippy_scc_internationalization() { load_plugin_textdomain('ippy_scc', false, 'sitewide-comment-control/languages' ); } // The Hook add_filter ('preprocess_comment', 'ippy_scc_preprocess'); function ippy_scc_preprocess ($data) { extract ($data); // it's a pingback or trackback so let it through. if ('' != $comment_type) { return $data; } // It's a logged in user so it's good. get_currentuserinfo(); if ( is_user_logged_in() ) { return $data; } // Get blacklist $ippy_scc_string = get_site_option('ippy_scc_keys'); $ippy_scc_array = explode("\n", $ippy_scc_string); $ippy_scc_size = sizeof($ippy_scc_array); // Go through blacklist for($i = 0; $i < $ippy_scc_size; $i++) { $ippy_scc_current = trim($ippy_scc_array[$i]); $ippy_scc_type_now = get_site_option('ippy_scc_type'); if ($ippy_scc_type_now == 'moderate') $ippy_scc_type_now = 0; if(stripos($comment_author_email, $ippy_scc_current) !== false) { if ( get_site_option('ippy_scc_type') == 'blackhole' ) { wp_redirect( get_permalink() ); die; } if ( get_site_option('ippy_scc_type') == 'spam' || 'moderate' ) { $time = current_time('mysql'); // Get the date $result = array( 'comment_post_ID' => $comment_post_ID, 'comment_author' => $comment_author, 'comment_author_email' => $comment_author_email, 'comment_author_url' => $comment_author_url, 'comment_content' => $comment_content, 'comment_type' => $comment_type, 'comment_parent' => $comment_parent, 'user_id' => $user_ID, 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], 'comment_agent' => $_SERVER['HTTP_USER_AGENT'], 'comment_date' => $time, 'comment_approved' => $ippy_scc_type_now, ); wp_insert_comment($result); } wp_safe_redirect( $_SERVER['HTTP_REFERER'] ); die; } } return $data; } // Create the options for the message and spam assassin and set some defaults. function ippy_scc_activate() { update_site_option('ippy_scc_keys','spammer@example.com'); update_site_option('ippy_scc_type','blackhole'); } // Delete the options if the plugin is being turned off (pet peeve) - This DOES wipe out your blacklist. function ippy_scc_deactivate() { delete_site_option('ippy_scc_keys'); delete_site_option('ippy_scc_type'); } // Options Pages // add the admin options page add_action('network_admin_menu', 'ippy_scc_admin_add_page'); function ippy_scc_admin_add_page() { global $ippy_scc_options_page; $ippy_scc_options_page = add_submenu_page('settings.php', __('Sitewide Comment Control', 'ippy_scc'), __('Comment Control', 'ippy_scc'), 'manage_networks', 'ippy_scc', 'ippy_scc_options'); } function ippy_scc_plugin_help() { global $ippy_scc_options_page; $screen = get_current_screen(); if ($screen->id == 'settings_page_ippy_scc-network') return; $screen->add_help_tab( array( 'id' => 'ippy-ssc-base', 'title' => __('Readme', 'sfc'), 'content' => '
' . __( 'When you run a network, blacklisting commenters is handled per-site. That\'s normally okay, but sometimes people decide to be trolls and spam your whole network. This plugin allows you to ban, spam or moderate an unregistered commenter network wide. It does not replace the per-site blacklists or moderation lists, but simply adds on to it.', 'ippy_scc' ) . '
' . '' . __( 'When a user posts a comment and they\'re on the list, they are redirected to the post they just tried to comment on, but their comment has been shunted to the mysterious black hole along with your socks. If you pick \'blackhole\', no one will ever see the comment. Pick \'spam\' and they go to spam. Pick \'moderate\' and the post is forced into moderation.', 'ippy_scc' ) . '
' . '' . __( 'A sample email of spammer@example.com is included in the plugin for you to play with.', 'ippy_scc' ) . '
' . '' . __( 'Limited free support can be found in the WordPress forums.','sfc').'
'. '