X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/cc7b1505cd9fafd87c3672f669e13e98b0c544f7..022dfbbbe3215917d84708eb09acca93b21ae9e0:/wp-content/plugins/akismet/akismet.php
diff --git a/wp-content/plugins/akismet/akismet.php b/wp-content/plugins/akismet/akismet.php
index 8d8997ab..53e9a9ff 100644
--- a/wp-content/plugins/akismet/akismet.php
+++ b/wp-content/plugins/akismet/akismet.php
@@ -2,81 +2,151 @@
/*
Plugin Name: Akismet
Plugin URI: http://akismet.com/
-Description: Akismet checks your comments against the Akismet web serivce to see if they look like spam or not. You need a WordPress.com API key to use this service. You can review the spam it catches under "Manage" and it automatically deletes old spam after 15 days. Hat tip: Michael Hampton and Chris J. Davis for help with the plugin.
+Description: Akismet checks your comments against the Akismet web service to see if they look like spam or not. You need a WordPress.com API key to use it. You can review the spam it catches under "Comments." To show off your Akismet stats just put <?php akismet_counter(); ?>
in your template.
+Version: 2.0.2
Author: Matt Mullenweg
-Version: 1.15
Author URI: http://photomatt.net/
*/
-add_action('admin_menu', 'ksd_config_page');
+// If you hardcode a WP.com API key here, all key config screens will be hidden
+$wpcom_api_key = '';
-if ( ! function_exists('wp_nonce_field') ) {
- function akismet_nonce_field($action = -1) {
- return;
- }
+function akismet_init() {
+ global $wpcom_api_key, $akismet_api_host, $akismet_api_port;
+
+ if ( $wpcom_api_key )
+ $akismet_api_host = $wpcom_api_key . '.rest.akismet.com';
+ else
+ $akismet_api_host = get_option('wordpress_api_key') . '.rest.akismet.com';
+
+ $akismet_api_port = 80;
+ add_action('admin_menu', 'akismet_config_page');
+}
+add_action('init', 'akismet_init');
+
+if ( !function_exists('wp_nonce_field') ) {
+ function akismet_nonce_field($action = -1) { return; }
$akismet_nonce = -1;
} else {
- function akismet_nonce_field($action = -1) {
- return wp_nonce_field($action);
- }
+ function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
$akismet_nonce = 'akismet-update-key';
}
-function ksd_config_page() {
- global $wpdb;
+function akismet_config_page() {
if ( function_exists('add_submenu_page') )
- add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', __FILE__, 'akismet_conf');
+ add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf');
}
function akismet_conf() {
- global $akismet_nonce;
+ global $akismet_nonce, $wpcom_api_key;
+
if ( isset($_POST['submit']) ) {
- if ( !current_user_can('manage_options') )
+ if ( function_exists('current_user_can') && !current_user_can('manage_options') )
die(__('Cheatin’ uh?'));
- check_admin_referer($akismet_nonce);
- $key = preg_replace('/[^a-h0-9]/i', '', $_POST['key']);
- if ( akismet_verify_key( $key ) )
+ check_admin_referer( $akismet_nonce );
+ $key = preg_replace( '/[^a-h0-9]/i', '', $_POST['key'] );
+
+ if ( empty($key) ) {
+ $key_status = 'empty';
+ $ms[] = 'new_key_empty';
+ delete_option('wordpress_api_key');
+ } else {
+ $key_status = akismet_verify_key( $key );
+ }
+
+ if ( $key_status == 'valid' ) {
update_option('wordpress_api_key', $key);
+ $ms[] = 'new_key_valid';
+ } else if ( $key_status == 'invalid' ) {
+ $ms[] = 'new_key_invalid';
+ } else if ( $key_status == 'failed' ) {
+ $ms[] = 'new_key_failed';
+ }
+
+ if ( isset( $_POST['akismet_discard_month'] ) )
+ update_option( 'akismet_discard_month', 'true' );
else
- $invalid_key = true;
+ update_option( 'akismet_discard_month', 'false' );
}
- if ( !akismet_verify_key( get_option('wordpress_api_key') ) )
- $invalid_key = true;
-?>
+ if ( $key_status != 'valid' ) {
+ $key = get_option('wordpress_api_key');
+ if ( empty( $key ) ) {
+ if ( $key_status != 'failed' ) {
+ if ( akismet_verify_key( '1234567890ab' ) == 'failed' )
+ $ms[] = 'no_connection';
+ else
+ $ms[] = 'key_empty';
+ }
+ $key_status = 'empty';
+ } else {
+ $key_status = akismet_verify_key( $key );
+ }
+ if ( $key_status == 'valid' ) {
+ $ms[] = 'key_valid';
+ } else if ( $key_status == 'invalid' ) {
+ delete_option('wordpress_api_key');
+ $ms[] = 'key_empty';
+ } else if ( !empty($key) && $key_status == 'failed' ) {
+ $ms[] = 'key_failed';
+ }
+ }
+
+ $messages = array(
+ 'new_key_empty' => array('color' => 'aa0', 'text' => __('Your key has been cleared.')),
+ 'new_key_valid' => array('color' => '2d2', 'text' => __('Your key has been verified. Happy blogging!')),
+ 'new_key_invalid' => array('color' => 'd22', 'text' => __('The key you entered is invalid. Please double-check it.')),
+ 'new_key_failed' => array('color' => 'd22', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')),
+ 'no_connection' => array('color' => 'd22', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')),
+ 'key_empty' => array('color' => 'aa0', 'text' => sprintf(__('Please enter an API key. (Get your key.)'), 'http://wordpress.com/profile/')),
+ 'key_valid' => array('color' => '2d2', 'text' => __('This key is valid.')),
+ 'key_failed' => array('color' => 'aa0', 'text' => __('The key below was previously validated but a connection to akismet.com can not be established at this time. Please check your server configuration.')));
+?>
+
+
".__('Akismet is not active.')." ".sprintf(__('You must enter your WordPress.com API key for it to work.'), "plugins.php?page=$path")."
+ + + + + + + + +