Merge lp:~yoboy-leguesh/ubuntu-party/upgrade-wp3.0.4 into lp:ubuntu-party

Proposed by YoBoY
Status: Merged
Approved by: YoBoY
Approved revision: 3
Merged at revision: 2
Proposed branch: lp:~yoboy-leguesh/ubuntu-party/upgrade-wp3.0.4
Merge into: lp:ubuntu-party
Diff against target: 3609 lines (+1875/-1231)
22 files modified
wp-admin/includes/file.php (+1/-1)
wp-admin/includes/plugin.php (+1/-1)
wp-admin/includes/update-core.php (+1/-1)
wp-admin/plugins.php (+3/-3)
wp-config-sample.php (+99/-90)
wp-content/plugins/akismet/admin.php (+746/-0)
wp-content/plugins/akismet/akismet.css (+7/-0)
wp-content/plugins/akismet/akismet.js (+10/-0)
wp-content/plugins/akismet/akismet.php (+370/-1050)
wp-content/plugins/akismet/legacy.php (+396/-0)
wp-content/plugins/akismet/readme.txt (+67/-9)
wp-content/plugins/akismet/widget.php (+90/-0)
wp-includes/canonical.php (+7/-5)
wp-includes/capabilities.php (+5/-8)
wp-includes/comment.php (+4/-14)
wp-includes/formatting.php (+2/-1)
wp-includes/functions.php (+1/-1)
wp-includes/kses.php (+12/-27)
wp-includes/load.php (+1/-1)
wp-includes/ms-files.php (+2/-2)
wp-includes/version.php (+1/-1)
xmlrpc.php (+49/-16)
To merge this branch: bzr merge lp:~yoboy-leguesh/ubuntu-party/upgrade-wp3.0.4
Reviewer Review Type Date Requested Status
Ubuntu Party WebApps Developpers Pending
Review via email: mp+47409@code.launchpad.net

Description of the change

Mise à jour vers wordpress 3.0.4
Mise à jour du plugin akismet

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'wp-admin/includes/file.php'
--- wp-admin/includes/file.php 2011-01-25 15:27:25 +0000
+++ wp-admin/includes/file.php 2011-01-25 16:02:14 +0000
@@ -937,7 +937,7 @@
937 $error_string = __('<strong>Error:</strong> There was an error connecting to the server, Please verify the settings are correct.');937 $error_string = __('<strong>Error:</strong> There was an error connecting to the server, Please verify the settings are correct.');
938 if ( is_wp_error($error) )938 if ( is_wp_error($error) )
939 $error_string = $error->get_error_message();939 $error_string = $error->get_error_message();
940 echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';940 echo '<div id="message" class="error"><p>' . esc_html( $error_string ) . '</p></div>';
941 }941 }
942942
943 $types = array();943 $types = array();
944944
=== modified file 'wp-admin/includes/plugin.php'
--- wp-admin/includes/plugin.php 2011-01-25 15:27:25 +0000
+++ wp-admin/includes/plugin.php 2011-01-25 16:02:14 +0000
@@ -483,6 +483,7 @@
483 ob_start();483 ob_start();
484 include(WP_PLUGIN_DIR . '/' . $plugin);484 include(WP_PLUGIN_DIR . '/' . $plugin);
485 do_action( 'activate_plugin', trim( $plugin) );485 do_action( 'activate_plugin', trim( $plugin) );
486 do_action( 'activate_' . trim( $plugin ) );
486 if ( $network_wide ) {487 if ( $network_wide ) {
487 $current[$plugin] = time();488 $current[$plugin] = time();
488 update_site_option( 'active_sitewide_plugins', $current );489 update_site_option( 'active_sitewide_plugins', $current );
@@ -491,7 +492,6 @@
491 sort($current);492 sort($current);
492 update_option('active_plugins', $current);493 update_option('active_plugins', $current);
493 }494 }
494 do_action( 'activate_' . trim( $plugin ) );
495 do_action( 'activated_plugin', trim( $plugin) );495 do_action( 'activated_plugin', trim( $plugin) );
496 if ( ob_get_length() > 0 ) {496 if ( ob_get_length() > 0 ) {
497 $output = ob_get_clean();497 $output = ob_get_clean();
498498
=== modified file 'wp-admin/includes/update-core.php'
--- wp-admin/includes/update-core.php 2011-01-25 15:27:25 +0000
+++ wp-admin/includes/update-core.php 2011-01-25 16:02:14 +0000
@@ -274,7 +274,7 @@
274 $mysql_version = $wpdb->db_version();274 $mysql_version = $wpdb->db_version();
275 $required_php_version = '4.3';275 $required_php_version = '4.3';
276 $required_mysql_version = '4.1.2';276 $required_mysql_version = '4.1.2';
277 $wp_version = '3.0.1';277 $wp_version = '3.0.4';
278 $php_compat = version_compare( $php_version, $required_php_version, '>=' );278 $php_compat = version_compare( $php_version, $required_php_version, '>=' );
279 $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );279 $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
280280
281281
=== modified file 'wp-admin/plugins.php'
--- wp-admin/plugins.php 2011-01-25 15:27:25 +0000
+++ wp-admin/plugins.php 2011-01-25 16:02:14 +0000
@@ -255,11 +255,11 @@
255 foreach ( $plugin_info as $plugin ) {255 foreach ( $plugin_info as $plugin ) {
256 if ( $plugin['is_uninstallable'] ) {256 if ( $plugin['is_uninstallable'] ) {
257 /* translators: 1: plugin name, 2: plugin author */257 /* translators: 1: plugin name, 2: plugin author */
258 echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)' ), $plugin['Name'], $plugin['Author'] ), '</li>';258 echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)' ), esc_html($plugin['Name']), esc_html($plugin['Author']) ), '</li>';
259 $data_to_delete = true;259 $data_to_delete = true;
260 } else {260 } else {
261 /* translators: 1: plugin name, 2: plugin author */261 /* translators: 1: plugin name, 2: plugin author */
262 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), $plugin['Name'], $plugin['Author'] ), '</li>';262 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), esc_html($plugin['Name']), esc_html($plugin['Author']) ), '</li>';
263 }263 }
264 }264 }
265 ?>265 ?>
@@ -289,7 +289,7 @@
289 <ul class="code">289 <ul class="code">
290 <?php290 <?php
291 foreach ( (array)$files_to_delete as $file )291 foreach ( (array)$files_to_delete as $file )
292 echo '<li>' . str_replace(WP_PLUGIN_DIR, '', $file) . '</li>';292 echo '<li>' . esc_html(str_replace(WP_PLUGIN_DIR, '', $file)) . '</li>';
293 ?>293 ?>
294 </ul>294 </ul>
295 </div>295 </div>
296296
=== modified file 'wp-config-sample.php'
--- wp-config-sample.php 2011-01-25 15:27:25 +0000
+++ wp-config-sample.php 2011-01-25 16:02:14 +0000
@@ -1,90 +1,99 @@
1<?php1<?php
2/**2/**
3 * The base configurations of the WordPress.3 * La configuration de base de votre installation WordPress.
4 *4 *
5 * This file has the following configurations: MySQL settings, Table Prefix,5 * Ce fichier contient les réglages de configuration suivants : réglages MySQL,
6 * Secret Keys, WordPress Language, and ABSPATH. You can find more information6 * préfixe de table, clefs secrètes, langue utilisée, et ABSPATH.
7 * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing7 * Vous pouvez en savoir plus à leur sujet en allant sur
8 * wp-config.php} Codex page. You can get the MySQL settings from your web host.8 * {@link http://codex.wordpress.org/Editing_wp-config.php Modifier
9 *9 * wp-config.php} (en anglais). C'est votre hébergeur qui doit vous donner vos
10 * This file is used by the wp-config.php creation script during the10 * codes MySQL.
11 * installation. You don't have to use the web site, you can just copy this file11 *
12 * to "wp-config.php" and fill in the values.12 * Ce fichier est utilisé par le script de création de wp-config.php pendant
13 *13 * le processus d'installation. Vous n'avez pas à utiliser le site web, vous
14 * @package WordPress14 * pouvez simplement renommer ce fichier en "wp-config.php" et remplir les
15 */15 * valeurs.
1616 *
17// ** MySQL settings - You can get this info from your web host ** //17 * @package WordPress
18/** The name of the database for WordPress */18 */
19define('DB_NAME', 'database_name_here');19
2020// ** Réglages MySQL - Votre hébergeur doit vous fournir ces informations. ** //
21/** MySQL database username */21/** Nom de la base de données de WordPress. */
22define('DB_USER', 'username_here');22define('DB_NAME', 'votre_nom_de_bdd');
2323
24/** MySQL database password */24/** Utilisateur de la base de données MySQL. */
25define('DB_PASSWORD', 'password_here');25define('DB_USER', 'votre_utilisateur_de_bdd');
2626
27/** MySQL hostname */27/** Mot de passe de la base de données MySQL. */
28define('DB_HOST', 'localhost');28define('DB_PASSWORD', 'votre_mdp_de_bdd');
2929
30/** Database Charset to use in creating database tables. */30/** Adresse de l'hébergement MySQL. */
31define('DB_CHARSET', 'utf8');31define('DB_HOST', 'localhost');
3232
33/** The Database Collate type. Don't change this if in doubt. */33/** Jeu de caractères à utiliser par la base de données lors de la création des tables. */
34define('DB_COLLATE', '');34define('DB_CHARSET', 'utf8');
3535
36/**#@+36/** Type de collation de la base de données.
37 * Authentication Unique Keys and Salts.37 * N'y touchez que si vous savez ce que vous faites.
38 *38 */
39 * Change these to different unique phrases!39define('DB_COLLATE', '');
40 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}40
41 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.41/**#@+
42 *42 * Clefs uniques d'authentification et salage.
43 * @since 2.6.043 *
44 */44 * Remplacez les valeurs par défaut par des phrases uniques !
45define('AUTH_KEY', 'put your unique phrase here');45 * Vous pouvez générer des phrases aléatoires en utilisant
46define('SECURE_AUTH_KEY', 'put your unique phrase here');46 * {@link https://api.wordpress.org/secret-key/1.1/salt/ le service de clefs secrètes de WordPress.org}.
47define('LOGGED_IN_KEY', 'put your unique phrase here');47 * Vous pouvez modifier ces phrases à n'importe quel moment, afin d'invalider tous les cookies existants.
48define('NONCE_KEY', 'put your unique phrase here');48 * Cela forcera également tous les utilisateurs à se reconnecter.
49define('AUTH_SALT', 'put your unique phrase here');49 *
50define('SECURE_AUTH_SALT', 'put your unique phrase here');50 * @since 2.6.0
51define('LOGGED_IN_SALT', 'put your unique phrase here');51 */
52define('NONCE_SALT', 'put your unique phrase here');52define('AUTH_KEY', 'put your unique phrase here');
5353define('SECURE_AUTH_KEY', 'put your unique phrase here');
54/**#@-*/54define('LOGGED_IN_KEY', 'put your unique phrase here');
5555define('NONCE_KEY', 'put your unique phrase here');
56/**56define('AUTH_SALT', 'put your unique phrase here');
57 * WordPress Database Table prefix.57define('SECURE_AUTH_SALT', 'put your unique phrase here');
58 *58define('LOGGED_IN_SALT', 'put your unique phrase here');
59 * You can have multiple installations in one database if you give each a unique59define('NONCE_SALT', 'put your unique phrase here');
60 * prefix. Only numbers, letters, and underscores please!60/**#@-*/
61 */61
62$table_prefix = 'wp_';62/**
6363 * Préfixe de base de données pour les tables de WordPress.
64/**64 *
65 * WordPress Localized Language, defaults to English.65 * Vous pouvez installer plusieurs WordPress sur une seule base de données
66 *66 * si vous leur donnez chacune un préfixe unique.
67 * Change this to localize WordPress. A corresponding MO file for the chosen67 * N'utilisez que des chiffres, des lettres non-accentuées, et des caractères soulignés!
68 * language must be installed to wp-content/languages. For example, install68 */
69 * de.mo to wp-content/languages and set WPLANG to 'de' to enable German69$table_prefix = 'wp_';
70 * language support.70
71 */71/**
72define ('WPLANG', 'fr_FR');72 * Langue de localisation de WordPress, par défaut en Anglais.
7373 *
74/**74 * Modifiez cette valeur pour localiser WordPress. Un fichier MO correspondant
75 * For developers: WordPress debugging mode.75 * au langage choisi doit être installé dans le dossier wp-content/languages.
76 *76 * Par exemple, pour mettre en place une traduction française, mettez le fichier
77 * Change this to true to enable the display of notices during development.77 * fr_FR.mo dans wp-content/languages, et réglez l'option ci-dessous à "fr_FR".
78 * It is strongly recommended that plugin and theme developers use WP_DEBUG78 */
79 * in their development environments.79define ('WPLANG', 'fr_FR');
80 */80
81define('WP_DEBUG', false);81/**
8282 * Pour les développeurs : le mode deboguage de WordPress.
83/* That's all, stop editing! Happy blogging. */83 *
8484 * En passant la valeur suivante à "true", vous activez l'affichage des
85/** Absolute path to the WordPress directory. */85 * notifications d'erreurs pendant votre essais.
86if ( !defined('ABSPATH') )86 * Il est fortemment recommandé que les développeurs d'extensions et
87 define('ABSPATH', dirname(__FILE__) . '/');87 * de thèmes se servent de WP_DEBUG dans leur environnement de
8888 * développement.
89/** Sets up WordPress vars and included files. */89 */
90require_once(ABSPATH . 'wp-settings.php');90define('WP_DEBUG', false);
91
92/* C'est tout, ne touchez pas à ce qui suit ! Bon blogging ! */
93
94/** Chemin absolu vers le dossier de WordPress. */
95if ( !defined('ABSPATH') )
96 define('ABSPATH', dirname(__FILE__) . '/');
97
98/** Réglage des variables de WordPress et de ses fichiers inclus. */
99require_once(ABSPATH . 'wp-settings.php');
91\ No newline at end of file100\ No newline at end of file
92101
=== added file 'wp-content/plugins/akismet/admin.php'
--- wp-content/plugins/akismet/admin.php 1970-01-01 00:00:00 +0000
+++ wp-content/plugins/akismet/admin.php 2011-01-25 16:02:14 +0000
@@ -0,0 +1,746 @@
1<?php
2add_action( 'admin_menu', 'akismet_config_page' );
3add_action( 'admin_menu', 'akismet_stats_page' );
4akismet_admin_warnings();
5
6function akismet_admin_init() {
7 global $wp_version;
8
9 // all admin functions are disabled in old versions
10 if ( !function_exists('is_multisite') && version_compare( $wp_version, '3.0', '<' ) ) {
11
12 function akismet_version_warning() {
13 echo "
14 <div id='akismet-warning' class='updated fade'><p><strong>".sprintf(__('Akismet %s requires WordPress 3.0 or higher.'), AKISMET_VERSION) ."</strong> ".sprintf(__('Please <a href="%s">upgrade WordPress</a> to a current version, or <a href="%s">downgrade to version 2.4 of the Akismet plugin</a>.'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/'). "</p></div>
15 ";
16 }
17 add_action('admin_notices', 'akismet_version_warning');
18
19 return;
20 }
21
22 if ( function_exists( 'get_plugin_page_hook' ) )
23 $hook = get_plugin_page_hook( 'akismet-stats-display', 'index.php' );
24 else
25 $hook = 'dashboard_page_akismet-stats-display';
26 add_action('admin_head-'.$hook, 'akismet_stats_script');
27 add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal');
28 wp_register_style('akismet.css', AKISMET_PLUGIN_URL . 'akismet.css');
29 wp_enqueue_style('akismet.css');
30 wp_register_script('akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery'));
31 wp_enqueue_script('akismet.js');
32}
33add_action('admin_init', 'akismet_admin_init');
34
35function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
36$akismet_nonce = 'akismet-update-key';
37
38function akismet_config_page() {
39 if ( function_exists('add_submenu_page') )
40 add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf');
41}
42
43function akismet_plugin_action_links( $links, $file ) {
44 if ( $file == plugin_basename( dirname(__FILE__).'/akismet.php' ) ) {
45 $links[] = '<a href="plugins.php?page=akismet-key-config">'.__('Settings').'</a>';
46 }
47
48 return $links;
49}
50
51add_filter( 'plugin_action_links', 'akismet_plugin_action_links', 10, 2 );
52
53function akismet_conf() {
54 global $akismet_nonce, $wpcom_api_key;
55
56 if ( isset($_POST['submit']) ) {
57 if ( function_exists('current_user_can') && !current_user_can('manage_options') )
58 die(__('Cheatin&#8217; uh?'));
59
60 check_admin_referer( $akismet_nonce );
61 $key = preg_replace( '/[^a-h0-9]/i', '', $_POST['key'] );
62 $home_url = parse_url( get_bloginfo('url') );
63
64 if ( empty($key) ) {
65 $key_status = 'empty';
66 $ms[] = 'new_key_empty';
67 delete_option('wordpress_api_key');
68 } elseif ( empty($home_url['host']) ) {
69 $key_status = 'empty';
70 $ms[] = 'bad_home_url';
71 } else {
72 $key_status = akismet_verify_key( $key );
73 }
74
75 if ( $key_status == 'valid' ) {
76 update_option('wordpress_api_key', $key);
77 $ms[] = 'new_key_valid';
78 } else if ( $key_status == 'invalid' ) {
79 $ms[] = 'new_key_invalid';
80 } else if ( $key_status == 'failed' ) {
81 $ms[] = 'new_key_failed';
82 }
83
84 if ( isset( $_POST['akismet_discard_month'] ) )
85 update_option( 'akismet_discard_month', 'true' );
86 else
87 update_option( 'akismet_discard_month', 'false' );
88
89 if ( isset( $_POST['akismet_show_user_comments_approved'] ) )
90 update_option( 'akismet_show_user_comments_approved', 'true' );
91 else
92 update_option( 'akismet_show_user_comments_approved', 'false' );
93
94 } elseif ( isset($_POST['check']) ) {
95 akismet_get_server_connectivity(0);
96 }
97
98 if ( empty( $key_status) || $key_status != 'valid' ) {
99 $key = get_option('wordpress_api_key');
100 if ( empty( $key ) ) {
101 if ( empty( $key_status ) || $key_status != 'failed' ) {
102 if ( akismet_verify_key( '1234567890ab' ) == 'failed' )
103 $ms[] = 'no_connection';
104 else
105 $ms[] = 'key_empty';
106 }
107 $key_status = 'empty';
108 } else {
109 $key_status = akismet_verify_key( $key );
110 }
111 if ( $key_status == 'valid' ) {
112 $ms[] = 'key_valid';
113 } else if ( $key_status == 'invalid' ) {
114 delete_option('wordpress_api_key');
115 $ms[] = 'key_empty';
116 } else if ( !empty($key) && $key_status == 'failed' ) {
117 $ms[] = 'key_failed';
118 }
119 }
120
121 $messages = array(
122 'new_key_empty' => array('color' => 'aa0', 'text' => __('Your key has been cleared.')),
123 'new_key_valid' => array('color' => '4AB915', 'text' => __('Your key has been verified. Happy blogging!')),
124 'new_key_invalid' => array('color' => '888', 'text' => __('The key you entered is invalid. Please double-check it.')),
125 'new_key_failed' => array('color' => '888', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')),
126 'no_connection' => array('color' => '888', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')),
127 'key_empty' => array('color' => 'aa0', 'text' => sprintf(__('Please enter an API key. (<a href="%s" style="color:#fff">Get your key.</a>)'), 'http://akismet.com/get/')),
128 'key_valid' => array('color' => '4AB915', 'text' => __('This key is valid.')),
129 '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.')),
130 'bad_home_url' => array('color' => '888', 'text' => sprintf( __('Your WordPress home URL %s is invalid. Please fix the <a href="%s">home option</a>.'), esc_html( get_bloginfo('url') ), admin_url('options.php#home') ) ),
131 );
132?>
133<?php if ( !empty($_POST['submit'] ) ) : ?>
134<div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div>
135<?php endif; ?>
136<div class="wrap">
137<h2><?php _e('Akismet Configuration'); ?></h2>
138<?php if (isset($_GET['message']) && $_GET['message'] == 'success') { ?>
139 <div class="updated below-h2" id="message"><p><?php _e( '<strong>Sign up success!</strong> Please check your email for your Akismet API Key and enter it below.' ); ?></p></div>
140<?php } ?>
141<div class="narrow">
142<form action="" method="post" id="akismet-conf" style="margin: auto; width: 400px; ">
143<?php if ( !$wpcom_api_key ) { ?>
144 <p><?php printf(__('For many people, <a href="%1$s">Akismet</a> will greatly reduce or even completely eliminate the comment and trackback spam you get on your site. If one does happen to get through, simply mark it as "spam" on the moderation screen and Akismet will learn from the mistakes. If you don\'t have an API key yet, you can get one at <a href="%2$s">Akismet.com</a>.'), 'http://akismet.com/', 'http://akismet.com/get/'); ?></p>
145
146<h3><label for="key"><?php _e('Akismet API Key'); ?></label></h3>
147<?php foreach ( $ms as $m ) : ?>
148 <p style="padding: .5em; background-color: #<?php echo $messages[$m]['color']; ?>; color: #fff; font-weight: bold;"><?php echo $messages[$m]['text']; ?></p>
149<?php endforeach; ?>
150<p><input id="key" name="key" type="text" size="15" maxlength="12" value="<?php echo get_option('wordpress_api_key'); ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php _e('<a href="http://akismet.com/get/">What is this?</a>'); ?>)</p>
151<?php if ( isset( $invalid_key) && $invalid_key ) { ?>
152<h3><?php _e('Why might my key be invalid?'); ?></h3>
153<p><?php _e('This can mean one of two things, either you copied the key wrong or that the plugin is unable to reach the Akismet servers, which is most often caused by an issue with your web host around firewalls or similar.'); ?></p>
154<?php } ?>
155<?php } ?>
156<?php akismet_nonce_field($akismet_nonce) ?>
157<p><label><input name="akismet_discard_month" id="akismet_discard_month" value="true" type="checkbox" <?php if ( get_option('akismet_discard_month') == 'true' ) echo ' checked="checked" '; ?> /> <?php _e('Auto-delete spam submitted on posts more than a month old.'); ?></label></p>
158<p><label><input name="akismet_show_user_comments_approved" id="akismet_show_user_comments_approved" value="true" type="checkbox" <?php if ( get_option('akismet_show_user_comments_approved') == 'true' ) echo ' checked="checked" '; ?> /> <?php _e('Show the number of comments you\'ve approved beside each comment author.'); ?></label></p>
159 <p class="submit"><input type="submit" name="submit" value="<?php _e('Update options &raquo;'); ?>" /></p>
160</form>
161
162<form action="" method="post" id="akismet-connectivity" style="margin: auto; width: 400px; ">
163
164<h3><?php _e('Server Connectivity'); ?></h3>
165<?php
166 if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') ) {
167 ?>
168 <p style="padding: .5em; background-color: #888; color: #fff; font-weight:bold;"><?php _e('Network functions are disabled.'); ?></p>
169 <p><?php echo sprintf( __('Your web host or server administrator has disabled PHP\'s <code>fsockopen</code> or <code>gethostbynamel</code> functions. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet\'s system requirements</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
170 <?php
171 } else {
172 $servers = akismet_get_server_connectivity();
173 $fail_count = count($servers) - count( array_filter($servers) );
174 if ( is_array($servers) && count($servers) > 0 ) {
175 // some connections work, some fail
176 if ( $fail_count > 0 && $fail_count < count($servers) ) { ?>
177 <p style="padding: .5em; background-color: #aa0; color: #fff; font-weight:bold;"><?php _e('Unable to reach some Akismet servers.'); ?></p>
178 <p><?php echo sprintf( __('A network problem or firewall is blocking some connections from your web server to Akismet.com. Akismet is working but this may cause problems during times of network congestion. Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
179 <?php
180 // all connections fail
181 } elseif ( $fail_count > 0 ) { ?>
182 <p style="padding: .5em; background-color: #888; color: #fff; font-weight:bold;"><?php _e('Unable to reach any Akismet servers.'); ?></p>
183 <p><?php echo sprintf( __('A network problem or firewall is blocking all connections from your web server to Akismet.com. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
184 <?php
185 // all connections work
186 } else { ?>
187 <p style="padding: .5em; background-color: #4AB915; color: #fff; font-weight:bold;"><?php _e('All Akismet servers are available.'); ?></p>
188 <p><?php _e('Akismet is working correctly. All servers are accessible.'); ?></p>
189 <?php
190 }
191 } else {
192 ?>
193 <p style="padding: .5em; background-color: #888; color: #fff; font-weight:bold;"><?php _e('Unable to find Akismet servers.'); ?></p>
194 <p><?php echo sprintf( __('A DNS problem or firewall is preventing all access from your web server to Akismet.com. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
195 <?php
196 }
197 }
198
199 if ( !empty($servers) ) {
200?>
201<table style="width: 100%;">
202<thead><th><?php _e('Akismet server'); ?></th><th><?php _e('Network Status'); ?></th></thead>
203<tbody>
204<?php
205 asort($servers);
206 foreach ( $servers as $ip => $status ) {
207 $color = ( $status ? '#4AB915' : '#888');
208 ?>
209 <tr>
210 <td><?php echo htmlspecialchars($ip); ?></td>
211 <td style="padding: 0 .5em; font-weight:bold; color: #fff; background-color: <?php echo $color; ?>"><?php echo ($status ? __('Accessible') : __('Re-trying') ); ?></td>
212
213 <?php
214 }
215 }
216?>
217</tbody>
218</table>
219 <p><?php if ( get_option('akismet_connectivity_time') ) echo sprintf( __('Last checked %s ago.'), human_time_diff( get_option('akismet_connectivity_time') ) ); ?></p>
220 <p class="submit"><input type="submit" name="check" value="<?php _e('Check network status &raquo;'); ?>" /></p>
221 <p><?php printf( __('<a href="%s" target="_blank">Click here</a> to confirm that <a href="%s" target="_blank">Akismet.com is up</a>.'), 'http://status.automattic.com/9931/136079/Akismet-API', 'http://status.automattic.com/9931/136079/Akismet-API' ); ?></p>
222</form>
223
224</div>
225</div>
226<?php
227}
228
229function akismet_stats_page() {
230 if ( function_exists('add_submenu_page') )
231 add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
232
233}
234
235function akismet_stats_script() {
236 ?>
237<script type="text/javascript">
238function resizeIframe() {
239
240 document.getElementById('akismet-stats-frame').style.height = "2500px";
241
242};
243function resizeIframeInit() {
244 document.getElementById('akismet-stats-frame').onload = resizeIframe;
245 window.onresize = resizeIframe;
246}
247addLoadEvent(resizeIframeInit);
248</script><?php
249}
250
251
252function akismet_stats_display() {
253 global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
254 $blog = urlencode( get_bloginfo('url') );
255
256 $url = 'http://';
257 if ( is_ssl() )
258 $url = 'https://';
259
260 $url .= 'akismet.com/web/1.0/user-stats.php';
261 $url .= "?blog={$blog}&api_key=" . akismet_get_key();
262 ?>
263 <div class="wrap">
264 <iframe src="<?php echo $url; ?>" width="100%" height="100%" frameborder="0" id="akismet-stats-frame"></iframe>
265 </div>
266 <?php
267}
268
269function akismet_stats() {
270 if ( !function_exists('did_action') || did_action( 'rightnow_end' ) ) // We already displayed this info in the "Right Now" section
271 return;
272 if ( !$count = get_option('akismet_spam_count') )
273 return;
274 $path = plugin_basename(__FILE__);
275 echo '<h3>' . _x( 'Spam', 'comments' ) . '</h3>';
276 global $submenu;
277 if ( isset( $submenu['edit-comments.php'] ) )
278 $link = 'edit-comments.php';
279 else
280 $link = 'edit.php';
281 echo '<p>'.sprintf( _n( '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', $count ), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'</p>';
282}
283add_action('activity_box_end', 'akismet_stats');
284
285function akismet_admin_warnings() {
286 global $wpcom_api_key;
287 if ( !get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit']) ) {
288 function akismet_warning() {
289 echo "
290 <div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet is almost ready.')."</strong> ".sprintf(__('You must <a href="%1$s">enter your Akismet API key</a> for it to work.'), "plugins.php?page=akismet-key-config")."</p></div>
291 ";
292 }
293 add_action('admin_notices', 'akismet_warning');
294 return;
295 } elseif ( ( empty($_SERVER['SCRIPT_FILENAME']) || basename($_SERVER['SCRIPT_FILENAME']) == 'edit-comments.php' ) && wp_next_scheduled('akismet_schedule_cron_recheck') ) {
296 function akismet_warning() {
297 global $wpdb;
298 $waiting = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) );
299 $next_check = human_time_diff( wp_next_scheduled('akismet_schedule_cron_recheck') );
300 if ( $waiting > 0 )
301 echo "
302 <div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet has detected a problem.')."</strong> ".sprintf(_n('A server or network problem prevented Akismet from checking %d comment. It has been temporarily held for moderation and will be automatically re-checked in %s.', 'A server or network problem prevented Akismet from checking %d comments. They have been temporarily held for moderation and will be automatically re-checked in %s.', $waiting), number_format_i18n( $waiting ), $next_check)."</p></div>
303 ";
304 }
305 add_action('admin_notices', 'akismet_warning');
306 return;
307 }
308}
309
310// FIXME placeholder
311
312function akismet_comment_row_action( $a, $comment ) {
313
314 // failsafe for old WP versions
315 if ( !function_exists('add_comment_meta') )
316 return $a;
317
318 $akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
319 $user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
320 $comment_status = wp_get_comment_status( $comment->comment_ID );
321 $desc = null;
322 if ( !$user_result || $user_result == $akismet_result ) {
323 // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
324 if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' )
325 $desc = __( 'Flagged as spam by Akismet' );
326 elseif ( $akismet_result == 'false' && $comment_status == 'spam' )
327 $desc = __( 'Cleared by Akismet' );
328 } else {
329 $who = get_comment_meta( $comment->comment_ID, 'akismet_user', true );
330 if ( $user_result == 'true' )
331 $desc = sprintf( __('Flagged as spam by %s'), $who );
332 else
333 $desc = sprintf( __('Un-spammed by %s'), $who );
334 }
335
336 // add a History item to the hover links, just after Edit
337 if ( $akismet_result ) {
338 $b = array();
339 foreach ( $a as $k => $item ) {
340 $b[ $k ] = $item;
341 if ( $k == 'edit' )
342 $b['history'] = '<a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="'. esc_attr__( 'View comment history' ) . '"> '. __('History') . '</a>';
343 }
344
345 $a = $b;
346 }
347
348 if ( $desc )
349 echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' ) . '">'.htmlspecialchars($desc).'</a></span>';
350
351 if ( apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') ) == 'true' ) {
352 $comment_count = akismet_get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );
353 $comment_count = intval( $comment_count );
354 echo '<span class="akismet-user-comment-count" commentid="'.$comment->comment_ID.'" style="display:none;"><br><span class="akismet-user-comment-counts">'.sprintf( _n( '%s approved', '%s approved', $comment_count ), number_format_i18n( $comment_count ) ) . '</span></span>';
355 }
356
357 return $a;
358}
359
360add_filter( 'comment_row_actions', 'akismet_comment_row_action', 10, 2 );
361
362function akismet_comment_status_meta_box($comment) {
363 $history = akismet_get_comment_history( $comment->comment_ID );
364
365 if ( $history ) {
366 echo '<div class="akismet-history" style="margin: 13px;">';
367 foreach ( $history as $row ) {
368 $time = date( 'D d M Y @ h:i:m a', $row['time'] ) . ' GMT';
369 echo '<div style="margin-bottom: 13px;"><span style="color: #999;" alt="' . $time . '" title="' . $time . '">' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</span> - ';
370 echo htmlspecialchars( $row['message'] ) . '</div>';
371 }
372
373 echo '</div>';
374
375 }
376}
377
378
379// add an extra column header to the comments screen
380function akismet_comments_columns( $columns ) {
381 $columns[ 'akismet' ] = __( 'Akismet' );
382 return $columns;
383}
384
385#add_filter( 'manage_edit-comments_columns', 'akismet_comments_columns' );
386
387// Show stuff in the extra column
388function akismet_comment_column_row( $column, $comment_id ) {
389 if ( $column != 'akismet' )
390 return;
391
392 $history = akismet_get_comment_history( $comment_id );
393
394 if ( $history ) {
395 echo '<dl class="akismet-history">';
396 foreach ( $history as $row ) {
397 echo '<dt>' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</dt>';
398 echo '<dd>' . htmlspecialchars( $row['message'] ) . '</dd>';
399 }
400
401 echo '</dl>';
402 }
403}
404
405#add_action( 'manage_comments_custom_column', 'akismet_comment_column_row', 10, 2 );
406
407// END FIXME
408
409// call out URLS in comments
410function akismet_text_add_link_callback( $m ) {
411
412 // bare link?
413 if ( $m[4] == $m[2] )
414 return '<a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a>';
415 else
416 return '<span title="'.$m[2].'" class="comment-link"><a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a></span>';
417}
418
419function akismet_text_add_link_class( $comment_text ) {
420
421 return preg_replace_callback( '#<a ([^>]*)href="([^"]+)"([^>]*)>(.*?)</a>#i', 'akismet_text_add_link_callback', $comment_text );
422}
423
424add_filter('comment_text', 'akismet_text_add_link_class');
425
426
427// WP 2.5+
428function akismet_rightnow() {
429 global $submenu, $wp_db_version;
430
431 // clean_url was deprecated in WP 3.0
432 $esc_url = 'clean_url';
433 if ( function_exists( 'esc_url' ) )
434 $esc_url = 'esc_url';
435
436 if ( 8645 < $wp_db_version ) // 2.7
437 $link = 'edit-comments.php?comment_status=spam';
438 elseif ( isset( $submenu['edit-comments.php'] ) )
439 $link = 'edit-comments.php?page=akismet-admin';
440 else
441 $link = 'edit.php?page=akismet-admin';
442
443 if ( $count = get_option('akismet_spam_count') ) {
444 $intro = sprintf( _n(
445 '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',
446 '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',
447 $count
448 ), 'http://akismet.com/', number_format_i18n( $count ) );
449 } else {
450 $intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/' );
451 }
452
453 if ( $queue_count = akismet_spam_count() ) {
454 $queue_text = sprintf( _n(
455 'There\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
456 'There are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
457 $queue_count
458 ), number_format_i18n( $queue_count ), $esc_url($link) );
459 } else {
460 $queue_text = sprintf( __( "There's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), $esc_url($link) );
461 }
462
463 $text = $intro . '<br />' . $queue_text;
464 echo "<p class='akismet-right-now'>$text</p>\n";
465}
466
467add_action('rightnow_end', 'akismet_rightnow');
468
469
470// For WP >= 2.5
471function akismet_check_for_spam_button($comment_status) {
472 if ( 'approved' == $comment_status )
473 return;
474 if ( function_exists('plugins_url') )
475 $link = 'admin.php?action=akismet_recheck_queue';
476 else
477 $link = 'edit-comments.php?page=akismet-admin&amp;recheckqueue=true&amp;noheader=true';
478 echo "</div><div class='alignleft'><a class='button-secondary checkforspam' href='$link'>" . __('Check for Spam') . "</a>";
479}
480add_action('manage_comments_nav', 'akismet_check_for_spam_button');
481
482function akismet_submit_nonspam_comment ( $comment_id ) {
483 global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
484 $comment_id = (int) $comment_id;
485
486 $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
487 if ( !$comment ) // it was deleted
488 return;
489
490 // use the original version stored in comment_meta if available
491 $as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
492 if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) ) {
493 $comment = (object) array_merge( (array)$comment, $as_submitted );
494 }
495
496 $comment->blog = get_bloginfo('url');
497 $comment->blog_lang = get_locale();
498 $comment->blog_charset = get_option('blog_charset');
499 $comment->permalink = get_permalink($comment->comment_post_ID);
500 $comment->reporter_ip = $_SERVER['REMOTE_ADDR'];
501 if ( is_object($current_user) ) {
502 $comment->reporter = $current_user->user_login;
503 }
504 if ( is_object($current_site) ) {
505 $comment->site_domain = $current_site->domain;
506 }
507
508 $comment->user_role = '';
509 if ( isset( $comment->user_ID ) )
510 $comment->user_role = akismet_get_user_roles($comment->user_ID);
511
512 if ( akismet_test_mode() )
513 $comment->is_test = 'true';
514
515 $query_string = '';
516 foreach ( $comment as $key => $data )
517 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
518
519 $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-ham", $akismet_api_port);
520 if ( $comment->reporter ) {
521 akismet_update_comment_history( $comment_id, sprintf( __('%s reported this comment as not spam'), $comment->reporter ), 'report-ham' );
522 update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
523 update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
524 }
525
526 do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
527}
528
529function akismet_submit_spam_comment ( $comment_id ) {
530 global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
531 $comment_id = (int) $comment_id;
532
533 $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
534 if ( !$comment ) // it was deleted
535 return;
536 if ( 'spam' != $comment->comment_approved )
537 return;
538
539 // use the original version stored in comment_meta if available
540 $as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
541 if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) ) {
542 $comment = (object) array_merge( (array)$comment, $as_submitted );
543 }
544
545 $comment->blog = get_bloginfo('url');
546 $comment->blog_lang = get_locale();
547 $comment->blog_charset = get_option('blog_charset');
548 $comment->permalink = get_permalink($comment->comment_post_ID);
549 $comment->reporter_ip = $_SERVER['REMOTE_ADDR'];
550 if ( is_object($current_user) ) {
551 $comment->reporter = $current_user->user_login;
552 }
553 if ( is_object($current_site) ) {
554 $comment->site_domain = $current_site->domain;
555 }
556
557 $comment->user_role = '';
558 if ( isset( $comment->user_ID ) )
559 $comment->user_role = akismet_get_user_roles($comment->user_ID);
560
561 if ( akismet_test_mode() )
562 $comment->is_test = 'true';
563
564 $query_string = '';
565 foreach ( $comment as $key => $data )
566 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
567
568 $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port);
569 if ( $comment->reporter ) {
570 akismet_update_comment_history( $comment_id, sprintf( __('%s reported this comment as spam'), $comment->reporter ), 'report-spam' );
571 update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
572 update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
573 }
574 do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
575}
576
577// For WP 2.7+
578function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
579 if ( $new_status == $old_status )
580 return;
581
582 if ( !is_admin() )
583 return;
584
585 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
586 return;
587
588 if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
589 return;
590
591 global $current_user;
592 $reporter = '';
593 if ( is_object( $current_user ) )
594 $reporter = $current_user->user_login;
595
596 // Assumption alert:
597 // We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
598 // is changed automatically by another plugin. Unfortunately WordPress doesn't provide an unambiguous way to
599 // determine why the transition_comment_status action was triggered. And there are several different ways by which
600 // to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
601 // We'll assume that this is an explicit user action if POST or GET has an 'action' key.
602 if ( isset($_POST['action']) || isset($_GET['action']) ) {
603 if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
604 return akismet_submit_spam_comment( $comment->comment_ID );
605 } elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
606 return akismet_submit_nonspam_comment( $comment->comment_ID );
607 }
608 }
609
610 if ( !get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
611 akismet_update_comment_history( $comment->comment_ID, sprintf( __('%s changed the comment status to %s'), $reporter, $new_status ), 'status-' . $new_status );
612}
613
614add_action( 'transition_comment_status', 'akismet_transition_comment_status', 10, 3 );
615
616// Total spam in queue
617// get_option( 'akismet_spam_count' ) is the total caught ever
618function akismet_spam_count( $type = false ) {
619 global $wpdb;
620
621 if ( !$type ) { // total
622 $count = wp_cache_get( 'akismet_spam_count', 'widget' );
623 if ( false === $count ) {
624 if ( function_exists('wp_count_comments') ) {
625 $count = wp_count_comments();
626 $count = $count->spam;
627 } else {
628 $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'");
629 }
630 wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );
631 }
632 return $count;
633 } elseif ( 'comments' == $type || 'comment' == $type ) { // comments
634 $type = '';
635 } else { // pingback, trackback, ...
636 $type = $wpdb->escape( $type );
637 }
638
639 return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type'");
640}
641
642
643function akismet_recheck_queue() {
644 global $wpdb, $akismet_api_host, $akismet_api_port;
645
646 if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )
647 return;
648
649 $moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'", ARRAY_A );
650 foreach ( (array) $moderation as $c ) {
651 $c['user_ip'] = $c['comment_author_IP'];
652 $c['user_agent'] = $c['comment_agent'];
653 $c['referrer'] = '';
654 $c['blog'] = get_bloginfo('url');
655 $c['blog_lang'] = get_locale();
656 $c['blog_charset'] = get_option('blog_charset');
657 $c['permalink'] = get_permalink($c['comment_post_ID']);
658
659 $c['user_role'] = '';
660 if ( isset( $c['user_ID'] ) )
661 $c['user_role'] = akismet_get_user_roles($c['user_ID']);
662
663 if ( akismet_test_mode() )
664 $c['is_test'] = 'true';
665
666 $id = (int) $c['comment_ID'];
667
668 $query_string = '';
669 foreach ( $c as $key => $data )
670 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
671
672 $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
673 if ( 'true' == $response[1] ) {
674 wp_set_comment_status($c['comment_ID'], 'spam');
675 update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );
676 akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam' );
677
678 } elseif ( 'false' == $response[1] ) {
679 update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' );
680 akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham' );
681 // abnormal result: error
682 } else {
683 update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' );
684 akismet_update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)'), $response[1]), 'check-error' );
685 }
686
687 }
688 wp_redirect( $_SERVER['HTTP_REFERER'] );
689 exit;
690}
691
692add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');
693
694// Check connectivity between the WordPress blog and Akismet's servers.
695// Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect).
696function akismet_check_server_connectivity() {
697 global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
698
699 $test_host = 'rest.akismet.com';
700
701 // Some web hosts may disable one or both functions
702 if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') )
703 return array();
704
705 $ips = gethostbynamel($test_host);
706 if ( !$ips || !is_array($ips) || !count($ips) )
707 return array();
708
709 $servers = array();
710 foreach ( $ips as $ip ) {
711 $response = akismet_verify_key( akismet_get_key(), $ip );
712 // even if the key is invalid, at least we know we have connectivity
713 if ( $response == 'valid' || $response == 'invalid' )
714 $servers[$ip] = true;
715 else
716 $servers[$ip] = false;
717 }
718
719 return $servers;
720}
721
722// Check the server connectivity and store the results in an option.
723// Cached results will be used if not older than the specified timeout in seconds; use $cache_timeout = 0 to force an update.
724// Returns the same associative array as akismet_check_server_connectivity()
725function akismet_get_server_connectivity( $cache_timeout = 86400 ) {
726 $servers = get_option('akismet_available_servers');
727 if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false )
728 return $servers;
729
730 // There's a race condition here but the effect is harmless.
731 $servers = akismet_check_server_connectivity();
732 update_option('akismet_available_servers', $servers);
733 update_option('akismet_connectivity_time', time());
734 return $servers;
735}
736
737// Returns true if server connectivity was OK at the last check, false if there was a problem that needs to be fixed.
738function akismet_server_connectivity_ok() {
739 // skip the check on WPMU because the status page is hidden
740 global $wpcom_api_key;
741 if ( $wpcom_api_key )
742 return true;
743 $servers = akismet_get_server_connectivity();
744 return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) );
745}
746
0747
=== added file 'wp-content/plugins/akismet/akismet.css'
--- wp-content/plugins/akismet/akismet.css 1970-01-01 00:00:00 +0000
+++ wp-content/plugins/akismet/akismet.css 2011-01-25 16:02:14 +0000
@@ -0,0 +1,7 @@
1#submitted-on { position: relative; }
2#the-comment-list .author .akismet-user-comment-count { display: inline; }
3#dashboard_recent_comments .akismet-status { display: none; } /* never show the flagged by text on the dashboard */
4.akismet-status { float: right; }
5.akismet-status a { color: #AAA; font-style: italic; }
6span.comment-link a { text-decoration: underline; }
7span.comment-link:after { content: " " attr(title) " "; color: #aaa; text-decoration: none; }
08
=== added file 'wp-content/plugins/akismet/akismet.js'
--- wp-content/plugins/akismet/akismet.js 1970-01-01 00:00:00 +0000
+++ wp-content/plugins/akismet/akismet.js 2011-01-25 16:02:14 +0000
@@ -0,0 +1,10 @@
1jQuery(document).ready(function () {
2 jQuery('.akismet-status').each(function () {
3 var thisId = jQuery(this).attr('commentid');
4 jQuery(this).prependTo('#comment-' + thisId + ' .column-comment div:first-child');
5 });
6 jQuery('.akismet-user-comment-count').each(function () {
7 var thisId = jQuery(this).attr('commentid');
8 jQuery(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
9 });
10});
011
=== modified file 'wp-content/plugins/akismet/akismet.php'
--- wp-content/plugins/akismet/akismet.php 2011-01-25 15:27:25 +0000
+++ wp-content/plugins/akismet/akismet.php 2011-01-25 16:02:14 +0000
@@ -1,21 +1,56 @@
1<?php1<?php
2/**
3 * @package Akismet
4 */
2/*5/*
3Plugin Name: Akismet6Plugin Name: Akismet
4Plugin URI: http://akismet.com/7Plugin URI: http://akismet.com/
5Description: Akismet checks your comments against the Akismet web service to see if they look like spam or not. You need an <a href="http://akismet.com/get/">API key</a> to use it. You can review the spam it catches under "Comments." To show off your Akismet stats just put <code>&lt;?php akismet_counter(); ?&gt;</code> in your template. See also: <a href="http://wordpress.org/extend/plugins/stats/">WP Stats plugin</a>.8Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and track-back spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your <a href="plugins.php?page=akismet-key-config">Akismet configuration</a> page, and save your API key.
6Version: 2.3.09Version: 2.5.2
7Author: Automattic10Author: Automattic
8Author URI: http://automattic.com/wordpress-plugins/11Author URI: http://automattic.com/wordpress-plugins/
9*/12License: GPLv2
1013*/
11define('AKISMET_VERSION', '2.3.0');14
1215/*
13// If you hardcode a WP.com API key here, all key config screens will be hidden16This program is free software; you can redistribute it and/or
17modify it under the terms of the GNU General Public License
18as published by the Free Software Foundation; either version 2
19of the License, or (at your option) any later version.
20
21This program is distributed in the hope that it will be useful,
22but WITHOUT ANY WARRANTY; without even the implied warranty of
23MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24GNU General Public License for more details.
25
26You should have received a copy of the GNU General Public License
27along with this program; if not, write to the Free Software
28Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29*/
30
31define('AKISMET_VERSION', '2.5.2');
32define('AKISMET_PLUGIN_URL', plugin_dir_url( __FILE__ ));
33
34/** If you hardcode a WP.com API key here, all key config screens will be hidden */
14if ( defined('WPCOM_API_KEY') )35if ( defined('WPCOM_API_KEY') )
15 $wpcom_api_key = constant('WPCOM_API_KEY');36 $wpcom_api_key = constant('WPCOM_API_KEY');
16else37else
17 $wpcom_api_key = '';38 $wpcom_api_key = '';
1839
40// Make sure we don't expose any info if called directly
41if ( !function_exists( 'add_action' ) ) {
42 echo "Hi there! I'm just a plugin, not much I can do when called directly.";
43 exit;
44}
45
46if ( isset($wp_db_version) && $wp_db_version <= 9872 )
47 include_once dirname( __FILE__ ) . '/legacy.php';
48
49include_once dirname( __FILE__ ) . '/widget.php';
50
51if ( is_admin() )
52 require_once dirname( __FILE__ ) . '/admin.php';
53
19function akismet_init() {54function akismet_init() {
20 global $wpcom_api_key, $akismet_api_host, $akismet_api_port;55 global $wpcom_api_key, $akismet_api_host, $akismet_api_port;
2156
@@ -25,235 +60,9 @@
25 $akismet_api_host = get_option('wordpress_api_key') . '.rest.akismet.com';60 $akismet_api_host = get_option('wordpress_api_key') . '.rest.akismet.com';
2661
27 $akismet_api_port = 80;62 $akismet_api_port = 80;
28 add_action('admin_menu', 'akismet_config_page');
29 add_action('admin_menu', 'akismet_stats_page');
30 akismet_admin_warnings();
31}63}
32add_action('init', 'akismet_init');64add_action('init', 'akismet_init');
3365
34function akismet_admin_init() {
35 if ( function_exists( 'get_plugin_page_hook' ) )
36 $hook = get_plugin_page_hook( 'akismet-stats-display', 'index.php' );
37 else
38 $hook = 'dashboard_page_akismet-stats-display';
39 add_action('admin_head-'.$hook, 'akismet_stats_script');
40}
41add_action('admin_init', 'akismet_admin_init');
42
43if ( !function_exists('wp_nonce_field') ) {
44 function akismet_nonce_field($action = -1) { return; }
45 $akismet_nonce = -1;
46} else {
47 function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
48 $akismet_nonce = 'akismet-update-key';
49}
50
51if ( !function_exists('number_format_i18n') ) {
52 function number_format_i18n( $number, $decimals = null ) { return number_format( $number, $decimals ); }
53}
54
55function akismet_config_page() {
56 if ( function_exists('add_submenu_page') )
57 add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf');
58
59}
60
61function akismet_conf() {
62 global $akismet_nonce, $wpcom_api_key;
63
64 if ( isset($_POST['submit']) ) {
65 if ( function_exists('current_user_can') && !current_user_can('manage_options') )
66 die(__('Cheatin&#8217; uh?'));
67
68 check_admin_referer( $akismet_nonce );
69 $key = preg_replace( '/[^a-h0-9]/i', '', $_POST['key'] );
70
71 if ( empty($key) ) {
72 $key_status = 'empty';
73 $ms[] = 'new_key_empty';
74 delete_option('wordpress_api_key');
75 } else {
76 $key_status = akismet_verify_key( $key );
77 }
78
79 if ( $key_status == 'valid' ) {
80 update_option('wordpress_api_key', $key);
81 $ms[] = 'new_key_valid';
82 } else if ( $key_status == 'invalid' ) {
83 $ms[] = 'new_key_invalid';
84 } else if ( $key_status == 'failed' ) {
85 $ms[] = 'new_key_failed';
86 }
87
88 if ( isset( $_POST['akismet_discard_month'] ) )
89 update_option( 'akismet_discard_month', 'true' );
90 else
91 update_option( 'akismet_discard_month', 'false' );
92 } elseif ( isset($_POST['check']) ) {
93 akismet_get_server_connectivity(0);
94 }
95
96 if ( $key_status != 'valid' ) {
97 $key = get_option('wordpress_api_key');
98 if ( empty( $key ) ) {
99 if ( $key_status != 'failed' ) {
100 if ( akismet_verify_key( '1234567890ab' ) == 'failed' )
101 $ms[] = 'no_connection';
102 else
103 $ms[] = 'key_empty';
104 }
105 $key_status = 'empty';
106 } else {
107 $key_status = akismet_verify_key( $key );
108 }
109 if ( $key_status == 'valid' ) {
110 $ms[] = 'key_valid';
111 } else if ( $key_status == 'invalid' ) {
112 delete_option('wordpress_api_key');
113 $ms[] = 'key_empty';
114 } else if ( !empty($key) && $key_status == 'failed' ) {
115 $ms[] = 'key_failed';
116 }
117 }
118
119 $messages = array(
120 'new_key_empty' => array('color' => 'aa0', 'text' => __('Your key has been cleared.')),
121 'new_key_valid' => array('color' => '2d2', 'text' => __('Your key has been verified. Happy blogging!')),
122 'new_key_invalid' => array('color' => 'd22', 'text' => __('The key you entered is invalid. Please double-check it.')),
123 '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.')),
124 'no_connection' => array('color' => 'd22', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')),
125 'key_empty' => array('color' => 'aa0', 'text' => sprintf(__('Please enter an API key. (<a href="%s" style="color:#fff">Get your key.</a>)'), 'http://akismet.com/get/')),
126 'key_valid' => array('color' => '2d2', 'text' => __('This key is valid.')),
127 '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.')));
128?>
129<?php if ( !empty($_POST['submit'] ) ) : ?>
130<div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div>
131<?php endif; ?>
132<div class="wrap">
133<h2><?php _e('Akismet Configuration'); ?></h2>
134<div class="narrow">
135<form action="" method="post" id="akismet-conf" style="margin: auto; width: 400px; ">
136<?php if ( !$wpcom_api_key ) { ?>
137 <p><?php printf(__('For many people, <a href="%1$s">Akismet</a> will greatly reduce or even completely eliminate the comment and trackback spam you get on your site. If one does happen to get through, simply mark it as "spam" on the moderation screen and Akismet will learn from the mistakes. If you don\'t have an API key yet, you can get one at <a href="%2$s">Akismet.com</a>.'), 'http://akismet.com/', 'http://akismet.com/get/'); ?></p>
138
139<h3><label for="key"><?php _e('Akismet API Key'); ?></label></h3>
140<?php foreach ( $ms as $m ) : ?>
141 <p style="padding: .5em; background-color: #<?php echo $messages[$m]['color']; ?>; color: #fff; font-weight: bold;"><?php echo $messages[$m]['text']; ?></p>
142<?php endforeach; ?>
143<p><input id="key" name="key" type="text" size="15" maxlength="12" value="<?php echo get_option('wordpress_api_key'); ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php _e('<a href="http://akismet.com/get/">What is this?</a>'); ?>)</p>
144<?php if ( $invalid_key ) { ?>
145<h3><?php _e('Why might my key be invalid?'); ?></h3>
146<p><?php _e('This can mean one of two things, either you copied the key wrong or that the plugin is unable to reach the Akismet servers, which is most often caused by an issue with your web host around firewalls or similar.'); ?></p>
147<?php } ?>
148<?php } ?>
149<?php akismet_nonce_field($akismet_nonce) ?>
150<p><label><input name="akismet_discard_month" id="akismet_discard_month" value="true" type="checkbox" <?php if ( get_option('akismet_discard_month') == 'true' ) echo ' checked="checked" '; ?> /> <?php _e('Automatically discard spam comments on posts older than a month.'); ?></label></p>
151 <p class="submit"><input type="submit" name="submit" value="<?php _e('Update options &raquo;'); ?>" /></p>
152</form>
153
154<form action="" method="post" id="akismet-connectivity" style="margin: auto; width: 400px; ">
155
156<h3><?php _e('Server Connectivity'); ?></h3>
157<?php
158 if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') ) {
159 ?>
160 <p style="padding: .5em; background-color: #d22; color: #fff; font-weight:bold;"><?php _e('Network functions are disabled.'); ?></p>
161 <p><?php echo sprintf( __('Your web host or server administrator has disabled PHP\'s <code>fsockopen</code> or <code>gethostbynamel</code> functions. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet\'s system requirements</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
162 <?php
163 } else {
164 $servers = akismet_get_server_connectivity();
165 $fail_count = count($servers) - count( array_filter($servers) );
166 if ( is_array($servers) && count($servers) > 0 ) {
167 // some connections work, some fail
168 if ( $fail_count > 0 && $fail_count < count($servers) ) { ?>
169 <p style="padding: .5em; background-color: #aa0; color: #fff; font-weight:bold;"><?php _e('Unable to reach some Akismet servers.'); ?></p>
170 <p><?php echo sprintf( __('A network problem or firewall is blocking some connections from your web server to Akismet.com. Akismet is working but this may cause problems during times of network congestion. Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
171 <?php
172 // all connections fail
173 } elseif ( $fail_count > 0 ) { ?>
174 <p style="padding: .5em; background-color: #d22; color: #fff; font-weight:bold;"><?php _e('Unable to reach any Akismet servers.'); ?></p>
175 <p><?php echo sprintf( __('A network problem or firewall is blocking all connections from your web server to Akismet.com. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
176 <?php
177 // all connections work
178 } else { ?>
179 <p style="padding: .5em; background-color: #2d2; color: #fff; font-weight:bold;"><?php _e('All Akismet servers are available.'); ?></p>
180 <p><?php _e('Akismet is working correctly. All servers are accessible.'); ?></p>
181 <?php
182 }
183 } else {
184 ?>
185 <p style="padding: .5em; background-color: #d22; color: #fff; font-weight:bold;"><?php _e('Unable to find Akismet servers.'); ?></p>
186 <p><?php echo sprintf( __('A DNS problem or firewall is preventing all access from your web server to Akismet.com. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
187 <?php
188 }
189 }
190
191 if ( !empty($servers) ) {
192?>
193<table style="width: 100%;">
194<thead><th><?php _e('Akismet server'); ?></th><th><?php _e('Network Status'); ?></th></thead>
195<tbody>
196<?php
197 asort($servers);
198 foreach ( $servers as $ip => $status ) {
199 $color = ( $status ? '#2d2' : '#d22');
200 ?>
201 <tr>
202 <td><?php echo htmlspecialchars($ip); ?></td>
203 <td style="padding: 0 .5em; font-weight:bold; color: #fff; background-color: <?php echo $color; ?>"><?php echo ($status ? __('No problems') : __('Obstructed') ); ?></td>
204
205 <?php
206 }
207 }
208?>
209</tbody>
210</table>
211 <p><?php if ( get_option('akismet_connectivity_time') ) echo sprintf( __('Last checked %s ago.'), human_time_diff( get_option('akismet_connectivity_time') ) ); ?></p>
212 <p class="submit"><input type="submit" name="check" value="<?php _e('Check network status &raquo;'); ?>" /></p>
213</form>
214
215</div>
216</div>
217<?php
218}
219
220function akismet_stats_page() {
221 if ( function_exists('add_submenu_page') )
222 add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
223
224}
225
226function akismet_stats_script() {
227 ?>
228<script type="text/javascript">
229function resizeIframe() {
230 var height = document.documentElement.clientHeight;
231 height -= document.getElementById('akismet-stats-frame').offsetTop;
232 height += 100; // magic padding
233
234 document.getElementById('akismet-stats-frame').style.height = height +"px";
235
236};
237function resizeIframeInit() {
238 document.getElementById('akismet-stats-frame').onload = resizeIframe;
239 window.onresize = resizeIframe;
240}
241addLoadEvent(resizeIframeInit);
242</script><?php
243}
244
245
246function akismet_stats_display() {
247 global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
248 $blog = urlencode( get_option('home') );
249 $url = "http://".akismet_get_key().".web.akismet.com/1.0/user-stats.php?blog={$blog}";
250 ?>
251 <div class="wrap">
252 <iframe src="<?php echo $url; ?>" width="100%" height="100%" frameborder="0" id="akismet-stats-frame"></iframe>
253 </div>
254 <?php
255}
256
257function akismet_get_key() {66function akismet_get_key() {
258 global $wpcom_api_key;67 global $wpcom_api_key;
259 if ( !empty($wpcom_api_key) )68 if ( !empty($wpcom_api_key) )
@@ -272,104 +81,11 @@
272 return $response[1];81 return $response[1];
273}82}
27483
275// Check connectivity between the WordPress blog and Akismet's servers.84// if we're in debug or test modes, use a reduced service level so as not to polute training or stats data
276// Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect).85function akismet_test_mode() {
277function akismet_check_server_connectivity() {86 if ( defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE )
278 global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
279
280 $test_host = 'rest.akismet.com';
281
282 // Some web hosts may disable one or both functions
283 if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') )
284 return array();
285
286 $ips = gethostbynamel($test_host);
287 if ( !$ips || !is_array($ips) || !count($ips) )
288 return array();
289
290 $servers = array();
291 foreach ( $ips as $ip ) {
292 $response = akismet_verify_key( akismet_get_key(), $ip );
293 // even if the key is invalid, at least we know we have connectivity
294 if ( $response == 'valid' || $response == 'invalid' )
295 $servers[$ip] = true;
296 else
297 $servers[$ip] = false;
298 }
299
300 return $servers;
301}
302
303// Check the server connectivity and store the results in an option.
304// Cached results will be used if not older than the specified timeout in seconds; use $cache_timeout = 0 to force an update.
305// Returns the same associative array as akismet_check_server_connectivity()
306function akismet_get_server_connectivity( $cache_timeout = 86400 ) {
307 $servers = get_option('akismet_available_servers');
308 if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false )
309 return $servers;
310
311 // There's a race condition here but the effect is harmless.
312 $servers = akismet_check_server_connectivity();
313 update_option('akismet_available_servers', $servers);
314 update_option('akismet_connectivity_time', time());
315 return $servers;
316}
317
318// Returns true if server connectivity was OK at the last check, false if there was a problem that needs to be fixed.
319function akismet_server_connectivity_ok() {
320 // skip the check on WPMU because the status page is hidden
321 global $wpcom_api_key;
322 if ( $wpcom_api_key )
323 return true;87 return true;
324 $servers = akismet_get_server_connectivity();88 return false;
325 return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) );
326}
327
328function akismet_admin_warnings() {
329 global $wpcom_api_key;
330 if ( !get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit']) ) {
331 function akismet_warning() {
332 echo "
333 <div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet is almost ready.')."</strong> ".sprintf(__('You must <a href="%1$s">enter your Akismet API key</a> for it to work.'), "plugins.php?page=akismet-key-config")."</p></div>
334 ";
335 }
336 add_action('admin_notices', 'akismet_warning');
337 return;
338 } elseif ( get_option('akismet_connectivity_time') && empty($_POST) && is_admin() && !akismet_server_connectivity_ok() ) {
339 function akismet_warning() {
340 echo "
341 <div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet has detected a problem.')."</strong> ".sprintf(__('A server or network problem is preventing Akismet from working correctly. <a href="%1$s">Click here for more information</a> about how to fix the problem.'), "plugins.php?page=akismet-key-config")."</p></div>
342 ";
343 }
344 add_action('admin_notices', 'akismet_warning');
345 return;
346 }
347}
348
349function akismet_get_host($host) {
350 // if all servers are accessible, just return the host name.
351 // if not, return an IP that was known to be accessible at the last check.
352 if ( akismet_server_connectivity_ok() ) {
353 return $host;
354 } else {
355 $ips = akismet_get_server_connectivity();
356 // a firewall may be blocking access to some Akismet IPs
357 if ( count($ips) > 0 && count(array_filter($ips)) < count($ips) ) {
358 // use DNS to get current IPs, but exclude any known to be unreachable
359 $dns = (array)gethostbynamel( rtrim($host, '.') . '.' );
360 $dns = array_filter($dns);
361 foreach ( $dns as $ip ) {
362 if ( array_key_exists( $ip, $ips ) && empty( $ips[$ip] ) )
363 unset($dns[$ip]);
364 }
365 // return a random IP from those available
366 if ( count($dns) )
367 return $dns[ array_rand($dns) ];
368
369 }
370 }
371 // if all else fails try the host name
372 return $host;
373}89}
37490
375// return a comma-separated list of role names for the given user91// return a comma-separated list of role names for the given user
@@ -384,42 +100,76 @@
384 if ( isset($comment_user->roles) )100 if ( isset($comment_user->roles) )
385 $roles = join(',', $comment_user->roles);101 $roles = join(',', $comment_user->roles);
386 }102 }
387 103
104 if ( is_multisite() && is_super_admin( $user_id ) ) {
105 if ( empty( $roles ) ) {
106 $roles = 'super_admin';
107 } else {
108 $comment_user->roles[] = 'super_admin';
109 $roles = join( ',', $comment_user->roles );
110 }
111 }
112
388 return $roles;113 return $roles;
389}114}
390115
391// Returns array with headers in $response[0] and body in $response[1]116// Returns array with headers in $response[0] and body in $response[1]
392function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {117function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
393 global $wp_version;118 global $wp_version;
394 119
395 $akismet_version = constant('AKISMET_VERSION');120 $akismet_ua = "WordPress/{$wp_version} | ";
396121 $akismet_ua .= 'Akismet/' . constant( 'AKISMET_VERSION' );
397 $http_request = "POST $path HTTP/1.0\r\n";122
398 $http_request .= "Host: $host\r\n";123 $content_length = strlen( $request );
399 $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n";124
400 $http_request .= "Content-Length: " . strlen($request) . "\r\n";
401 $http_request .= "User-Agent: WordPress/$wp_version | Akismet/$akismet_version\r\n";
402 $http_request .= "\r\n";
403 $http_request .= $request;
404
405 $http_host = $host;125 $http_host = $host;
406 // use a specific IP if provided - needed by akismet_check_server_connectivity()126 // use a specific IP if provided
407 if ( $ip && long2ip(ip2long($ip)) ) {127 // needed by akismet_check_server_connectivity()
128 if ( $ip && long2ip( ip2long( $ip ) ) ) {
408 $http_host = $ip;129 $http_host = $ip;
409 } else {130 } else {
410 $http_host = akismet_get_host($host);131 $http_host = $host;
411 }132 }
412133
413 $response = '';134 // use the WP HTTP class if it is available
414 if( false != ( $fs = @fsockopen($http_host, $port, $errno, $errstr, 10) ) ) {135 if ( function_exists( 'wp_remote_post' ) ) {
415 fwrite($fs, $http_request);136 $http_args = array(
416137 'body' => $request,
417 while ( !feof($fs) )138 'headers' => array(
418 $response .= fgets($fs, 1160); // One TCP-IP packet139 'Content-Type' => 'application/x-www-form-urlencoded; ' .
419 fclose($fs);140 'charset=' . get_option( 'blog_charset' ),
420 $response = explode("\r\n\r\n", $response, 2);141 'Host' => $host,
421 }142 'User-Agent' => $akismet_ua
422 return $response;143 ),
144 'httpversion' => '1.0',
145 'timeout' => 15
146 );
147 $akismet_url = "http://{$http_host}{$path}";
148 $response = wp_remote_post( $akismet_url, $http_args );
149 if ( is_wp_error( $response ) )
150 return '';
151
152 return array( $response['headers'], $response['body'] );
153 } else {
154 $http_request = "POST $path HTTP/1.0\r\n";
155 $http_request .= "Host: $host\r\n";
156 $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
157 $http_request .= "Content-Length: {$content_length}\r\n";
158 $http_request .= "User-Agent: {$akismet_ua}\r\n";
159 $http_request .= "\r\n";
160 $http_request .= $request;
161
162 $response = '';
163 if( false != ( $fs = @fsockopen( $http_host, $port, $errno, $errstr, 10 ) ) ) {
164 fwrite( $fs, $http_request );
165
166 while ( !feof( $fs ) )
167 $response .= fgets( $fs, 1160 ); // One TCP-IP packet
168 fclose( $fs );
169 $response = explode( "\r\n\r\n", $response, 2 );
170 }
171 return $response;
172 }
423}173}
424174
425// filter handler used to return a spam result to pre_comment_approved175// filter handler used to return a spam result to pre_comment_approved
@@ -427,12 +177,124 @@
427 // bump the counter here instead of when the filter is added to reduce the possibility of overcounting177 // bump the counter here instead of when the filter is added to reduce the possibility of overcounting
428 if ( $incr = apply_filters('akismet_spam_count_incr', 1) )178 if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
429 update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );179 update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
180 // this is a one-shot deal
181 remove_filter( 'pre_comment_approved', 'akismet_result_spam' );
430 return 'spam';182 return 'spam';
431}183}
432184
433function akismet_auto_check_comment( $comment ) {185function akismet_result_hold( $approved ) {
434 global $akismet_api_host, $akismet_api_port;186 // once only
435187 remove_filter( 'pre_comment_approved', 'akismet_result_hold' );
188 return '0';
189}
190
191// how many approved comments does this author have?
192function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
193 global $wpdb;
194
195 if ( !empty($user_id) )
196 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE user_id = %d AND comment_approved = 1", $user_id ) );
197
198 if ( !empty($comment_author_email) )
199 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_author_email = %s AND comment_author = %s AND comment_author_url = %s AND comment_approved = 1", $comment_author_email, $comment_author, $comment_author_url ) );
200
201 return 0;
202}
203
204function akismet_microtime() {
205 $mtime = explode( ' ', microtime() );
206 return $mtime[1] + $mtime[0];
207}
208
209// log an event for a given comment, storing it in comment_meta
210function akismet_update_comment_history( $comment_id, $message, $event=null ) {
211 global $current_user;
212
213 // failsafe for old WP versions
214 if ( !function_exists('add_comment_meta') )
215 return false;
216
217 $user = '';
218 if ( is_object($current_user) && isset($current_user->user_login) )
219 $user = $current_user->user_login;
220
221 $event = array(
222 'time' => akismet_microtime(),
223 'message' => $message,
224 'event' => $event,
225 'user' => $user,
226 );
227
228 // $unique = false so as to allow multiple values per comment
229 $r = add_comment_meta( $comment_id, 'akismet_history', $event, false );
230}
231
232// get the full comment history for a given comment, as an array in reverse chronological order
233function akismet_get_comment_history( $comment_id ) {
234
235 // failsafe for old WP versions
236 if ( !function_exists('add_comment_meta') )
237 return false;
238
239 $history = get_comment_meta( $comment_id, 'akismet_history', false );
240 usort( $history, 'akismet_cmp_time' );
241 return $history;
242}
243
244function akismet_cmp_time( $a, $b ) {
245 return $a['time'] > $b['time'] ? -1 : 1;
246}
247
248// this fires on wp_insert_comment. we can't update comment_meta when akismet_auto_check_comment() runs
249// because we don't know the comment ID at that point.
250function akismet_auto_check_update_meta( $id, $comment ) {
251 global $akismet_last_comment;
252
253 // failsafe for old WP versions
254 if ( !function_exists('add_comment_meta') )
255 return false;
256
257 // wp_insert_comment() might be called in other contexts, so make sure this is the same comment
258 // as was checked by akismet_auto_check_comment
259 if ( is_object($comment) && !empty($akismet_last_comment) && is_array($akismet_last_comment) ) {
260 if ( intval($akismet_last_comment['comment_post_ID']) == intval($comment->comment_post_ID)
261 && $akismet_last_comment['comment_author'] == $comment->comment_author
262 && $akismet_last_comment['comment_author_email'] == $comment->comment_author_email ) {
263 // normal result: true or false
264 if ( $akismet_last_comment['akismet_result'] == 'true' ) {
265 update_comment_meta( $comment->comment_ID, 'akismet_result', 'true' );
266 akismet_update_comment_history( $comment->comment_ID, __('Akismet caught this comment as spam'), 'check-spam' );
267 if ( $comment->comment_approved != 'spam' )
268 akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed'.$comment->comment_approved );
269 } elseif ( $akismet_last_comment['akismet_result'] == 'false' ) {
270 update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' );
271 akismet_update_comment_history( $comment->comment_ID, __('Akismet cleared this comment'), 'check-ham' );
272 if ( $comment->comment_approved == 'spam' ) {
273 if ( wp_blacklist_check($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent) )
274 akismet_update_comment_history( $comment->comment_ID, __('Comment was caught by wp_blacklist_check'), 'wp-blacklisted' );
275 else
276 akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed-'.$comment->comment_approved );
277 }
278 // abnormal result: error
279 } else {
280 update_comment_meta( $comment->comment_ID, 'akismet_error', time() );
281 akismet_update_comment_history( $comment->comment_ID, sprintf( __('Akismet was unable to check this comment (response: %s), will automatically retry again later.'), $akismet_last_comment['akismet_result']), 'check-error' );
282 }
283
284 // record the complete original data as submitted for checking
285 if ( isset($akismet_last_comment['comment_as_submitted']) )
286 update_comment_meta( $comment->comment_ID, 'akismet_as_submitted', $akismet_last_comment['comment_as_submitted'] );
287 }
288 }
289}
290
291add_action( 'wp_insert_comment', 'akismet_auto_check_update_meta', 10, 2 );
292
293
294function akismet_auto_check_comment( $commentdata ) {
295 global $akismet_api_host, $akismet_api_port, $akismet_last_comment;
296
297 $comment = $commentdata;
436 $comment['user_ip'] = $_SERVER['REMOTE_ADDR'];298 $comment['user_ip'] = $_SERVER['REMOTE_ADDR'];
437 $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];299 $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
438 $comment['referrer'] = $_SERVER['HTTP_REFERER'];300 $comment['referrer'] = $_SERVER['HTTP_REFERER'];
@@ -443,17 +305,44 @@
443 305
444 $comment['user_role'] = akismet_get_user_roles($comment['user_ID']);306 $comment['user_role'] = akismet_get_user_roles($comment['user_ID']);
445307
446 $ignore = array( 'HTTP_COOKIE' );308 $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
447309 $comment['akismet_comment_nonce'] = 'inactive';
448 foreach ( $_SERVER as $key => $value )310 if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
311 $comment['akismet_comment_nonce'] = 'failed';
312 if ( isset( $_POST['akismet_comment_nonce'] ) && wp_verify_nonce( $_POST['akismet_comment_nonce'], 'akismet_comment_nonce_' . $comment['comment_post_ID'] ) )
313 $comment['akismet_comment_nonce'] = 'passed';
314
315 // comment reply in wp-admin
316 if ( isset( $_POST['_ajax_nonce-replyto-comment'] ) && check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ) )
317 $comment['akismet_comment_nonce'] = 'passed';
318
319 }
320
321 if ( akismet_test_mode() )
322 $comment['is_test'] = 'true';
323
324 foreach ($_POST as $key => $value ) {
325 if ( is_string($value) )
326 $comment["POST_{$key}"] = $value;
327 }
328
329 $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
330
331 foreach ( $_SERVER as $key => $value ) {
449 if ( !in_array( $key, $ignore ) && is_string($value) )332 if ( !in_array( $key, $ignore ) && is_string($value) )
450 $comment["$key"] = $value;333 $comment["$key"] = $value;
334 else
335 $comment["$key"] = '';
336 }
451337
452 $query_string = '';338 $query_string = '';
453 foreach ( $comment as $key => $data )339 foreach ( $comment as $key => $data )
454 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';340 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
341
342 $commentdata['comment_as_submitted'] = $comment;
455343
456 $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);344 $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
345 $commentdata['akismet_result'] = $response[1];
457 if ( 'true' == $response[1] ) {346 if ( 'true' == $response[1] ) {
458 // akismet_spam_count will be incremented later by akismet_result_spam()347 // akismet_spam_count will be incremented later by akismet_result_spam()
459 add_filter('pre_comment_approved', 'akismet_result_spam');348 add_filter('pre_comment_approved', 'akismet_result_spam');
@@ -469,10 +358,17 @@
469 // akismet_result_spam() won't be called so bump the counter here358 // akismet_result_spam() won't be called so bump the counter here
470 if ( $incr = apply_filters('akismet_spam_count_incr', 1) )359 if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
471 update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );360 update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
472 die;361 wp_redirect( $_SERVER['HTTP_REFERER'] );
362 die();
473 }363 }
474 }364 }
475 365
366 // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
367 if ( 'true' != $response[1] && 'false' != $response[1] ) {
368 add_filter('pre_comment_approved', 'akismet_result_hold');
369 wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
370 }
371
476 if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {372 if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {
477 // WP 2.1+: delete old comments daily373 // WP 2.1+: delete old comments daily
478 if ( !wp_next_scheduled('akismet_scheduled_delete') )374 if ( !wp_next_scheduled('akismet_scheduled_delete') )
@@ -481,706 +377,130 @@
481 // WP 2.0: run this one time in ten377 // WP 2.0: run this one time in ten
482 akismet_delete_old();378 akismet_delete_old();
483 }379 }
484 return $comment;380 $akismet_last_comment = $commentdata;
381 return $commentdata;
485}382}
486383
384add_action('preprocess_comment', 'akismet_auto_check_comment', 1);
385
487function akismet_delete_old() {386function akismet_delete_old() {
488 global $wpdb;387 global $wpdb;
489 $now_gmt = current_time('mysql', 1);388 $now_gmt = current_time('mysql', 1);
490 $wpdb->query("DELETE FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'");389 $comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'");
390 if ( empty( $comment_ids ) )
391 return;
392
393 $comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );
394
395 do_action( 'delete_comment', $comment_ids );
396 $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( $comma_comment_ids )");
397 $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id IN ( $comma_comment_ids )");
398 clean_comment_cache( $comment_ids );
491 $n = mt_rand(1, 5000);399 $n = mt_rand(1, 5000);
492 if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number400 if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number
493 $wpdb->query("OPTIMIZE TABLE $wpdb->comments");401 $wpdb->query("OPTIMIZE TABLE $wpdb->comments");
402
494}403}
495404
496add_action('akismet_scheduled_delete', 'akismet_delete_old');405add_action('akismet_scheduled_delete', 'akismet_delete_old');
497406
498function akismet_submit_nonspam_comment ( $comment_id ) {407function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
499 global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;408 global $wpdb, $akismet_api_host, $akismet_api_port;
500 $comment_id = (int) $comment_id;409
501410 $id = (int) $id;
502 $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");411 $c = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID = '$id'", ARRAY_A );
503 if ( !$comment ) // it was deleted412 if ( !$c )
504 return;413 return;
505 $comment->blog = get_option('home');414
506 $comment->blog_lang = get_locale();415 $c['user_ip'] = $c['comment_author_IP'];
507 $comment->blog_charset = get_option('blog_charset');416 $c['user_agent'] = $c['comment_agent'];
508 $comment->permalink = get_permalink($comment->comment_post_ID);417 $c['referrer'] = '';
509 if ( is_object($current_user) ) {418 $c['blog'] = get_option('home');
510 $comment->reporter = $current_user->user_login;419 $c['blog_lang'] = get_locale();
511 }420 $c['blog_charset'] = get_option('blog_charset');
512 if ( is_object($current_site) ) {421 $c['permalink'] = get_permalink($c['comment_post_ID']);
513 $comment->site_domain = $current_site->domain;422 $id = $c['comment_ID'];
514 }423 if ( akismet_test_mode() )
515 $comment->user_role = akismet_get_user_roles($comment->user_ID);424 $c['is_test'] = 'true';
516425 $c['recheck_reason'] = $recheck_reason;
517 $query_string = '';426
518 foreach ( $comment as $key => $data )427 $query_string = '';
519 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';428 foreach ( $c as $key => $data )
520429 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
521 $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-ham", $akismet_api_port);430
522}431 $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
523432 return $response[1];
524function akismet_submit_spam_comment ( $comment_id ) {433}
525 global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;434
526 $comment_id = (int) $comment_id;435function akismet_cron_recheck() {
527
528 $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
529 if ( !$comment ) // it was deleted
530 return;
531 if ( 'spam' != $comment->comment_approved )
532 return;
533 $comment->blog = get_option('home');
534 $comment->blog_lang = get_locale();
535 $comment->blog_charset = get_option('blog_charset');
536 $comment->permalink = get_permalink($comment->comment_post_ID);
537 if ( is_object($current_user) ) {
538 $comment->reporter = $current_user->user_login;
539 }
540 if ( is_object($current_site) ) {
541 $comment->site_domain = $current_site->domain;
542 }
543 $comment->user_role = akismet_get_user_roles($comment->user_ID);
544 $query_string = '';
545 foreach ( $comment as $key => $data )
546 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
547
548 $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port);
549}
550
551add_action('preprocess_comment', 'akismet_auto_check_comment', 1);
552
553// For old versions of WP only
554function akismet_set_comment_status( $comment_id, $status ) {
555 if ( $status == 'spam' ) {
556 akismet_submit_spam_comment( $comment_id );
557 } elseif ( $status == 'approve' ) {
558 akismet_submit_nonspam_comment( $comment_id );
559 }
560}
561
562// For WP 2.7+
563function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
564 if ( $new_status == $old_status )
565 return;
566
567 if ( $new_status == 'spam' ) {
568 akismet_submit_spam_comment( $comment->comment_ID );
569 } elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
570 akismet_submit_nonspam_comment( $comment->comment_ID );
571 }
572}
573
574function akismet_spamtoham( $comment ) { akismet_submit_nonspam_comment( $comment->comment_ID ); }
575
576if ( function_exists( 'wp_transition_comment_status' ) ) {
577 add_action( 'transition_comment_status', 'akismet_transition_comment_status', 10, 3 );
578} else {
579 add_action('wp_set_comment_status', 'akismet_set_comment_status', 10, 2);
580 add_action('edit_comment', 'akismet_submit_spam_comment');
581 add_filter( 'comment_spam_to_approved', 'akismet_spamtoham' );
582 add_filter( 'comment_spam_to_unapproved', 'akismet_spamtoham' );
583}
584// Total spam in queue
585// get_option( 'akismet_spam_count' ) is the total caught ever
586function akismet_spam_count( $type = false ) {
587 global $wpdb;436 global $wpdb;
588437
589 if ( !$type ) { // total438 delete_option('akismet_available_servers');
590 $count = wp_cache_get( 'akismet_spam_count', 'widget' );439
591 if ( false === $count ) {440 $comment_errors = $wpdb->get_col( "
592 if ( function_exists('wp_count_comments') ) {441 SELECT comment_id
593 $count = wp_count_comments();442 FROM {$wpdb->prefix}commentmeta
594 $count = $count->spam;443 WHERE meta_key = 'akismet_error'
595 } else {444 LIMIT 100
596 $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'");445 " );
446
447 foreach ( (array) $comment_errors as $comment_id ) {
448 // if the comment no longer exists, remove the meta entry from the queue to avoid getting stuck
449 if ( !get_comment( $comment_id ) ) {
450 delete_comment_meta( $comment_id, 'akismet_error' );
451 continue;
452 }
453
454 add_comment_meta( $comment_id, 'akismet_rechecking', true );
455 $status = akismet_check_db_comment( $comment_id, 'retry' );
456
457 $msg = '';
458 if ( $status == 'true' ) {
459 $msg = __( 'Akismet caught this comment as spam during an automatic retry.' );
460 } elseif ( $status == 'false' ) {
461 $msg = __( 'Akismet cleared this comment during an automatic retry.' );
462 }
463
464 // If we got back a legit response then update the comment history
465 // other wise just bail now and try again later. No point in
466 // re-trying all the comments once we hit one failure.
467 if ( !empty( $msg ) ) {
468 delete_comment_meta( $comment_id, 'akismet_error' );
469 akismet_update_comment_history( $comment_id, $msg, 'cron-retry' );
470 update_comment_meta( $comment_id, 'akismet_result', $status );
471 // make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere.
472 $comment = get_comment( $comment_id );
473 if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) {
474 if ( $status == 'true' ) {
475 wp_spam_comment( $comment_id );
476 } elseif ( $status == 'false' ) {
477 // comment is good, but it's still in the pending queue. depending on the moderation settings
478 // we may need to change it to approved.
479 if ( check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type) )
480 wp_set_comment_status( $comment_id, 1 );
481 }
597 }482 }
598 wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );483 } else {
484 delete_comment_meta( $comment_id, 'akismet_rechecking' );
485 wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
486 return;
599 }487 }
600 return $count;488 }
601 } elseif ( 'comments' == $type || 'comment' == $type ) { // comments
602 $type = '';
603 } else { // pingback, trackback, ...
604 $type = $wpdb->escape( $type );
605 }
606
607 return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type'");
608}
609
610function akismet_spam_comments( $type = false, $page = 1, $per_page = 50 ) {
611 global $wpdb;
612
613 $page = (int) $page;
614 if ( $page < 2 )
615 $page = 1;
616
617 $per_page = (int) $per_page;
618 if ( $per_page < 1 )
619 $per_page = 50;
620
621 $start = ( $page - 1 ) * $per_page;
622 $end = $start + $per_page;
623
624 if ( $type ) {
625 if ( 'comments' == $type || 'comment' == $type )
626 $type = '';
627 else
628 $type = $wpdb->escape( $type );
629 return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type' ORDER BY comment_date DESC LIMIT $start, $end");
630 }
631
632 // All
633 return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT $start, $end");
634}
635
636// Totals for each comment type
637// returns array( type => count, ... )
638function akismet_spam_totals() {
639 global $wpdb;
640 $totals = $wpdb->get_results( "SELECT comment_type, COUNT(*) AS cc FROM $wpdb->comments WHERE comment_approved = 'spam' GROUP BY comment_type" );
641 $return = array();
642 foreach ( $totals as $total )
643 $return[$total->comment_type ? $total->comment_type : 'comment'] = $total->cc;
644 return $return;
645}
646
647function akismet_manage_page() {
648 global $wpdb, $submenu, $wp_db_version;
649
650 // WP 2.7 has its own spam management page
651 if ( 8645 <= $wp_db_version )
652 return;
653
654 $count = sprintf(__('Akismet Spam (%s)'), akismet_spam_count());
655 if ( isset( $submenu['edit-comments.php'] ) )
656 add_submenu_page('edit-comments.php', __('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught' );
657 elseif ( function_exists('add_management_page') )
658 add_management_page(__('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught');
659}
660
661function akismet_caught() {
662 global $wpdb, $comment, $akismet_caught, $akismet_nonce;
663
664 akismet_recheck_queue();
665 if (isset($_POST['submit']) && 'recover' == $_POST['action'] && ! empty($_POST['not_spam'])) {
666 check_admin_referer( $akismet_nonce );
667 if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )
668 die(__('You do not have sufficient permission to moderate comments.'));
669
670 $i = 0;
671 foreach ($_POST['not_spam'] as $comment):
672 $comment = (int) $comment;
673 if ( function_exists('wp_set_comment_status') )
674 wp_set_comment_status($comment, 'approve');
675 else
676 $wpdb->query("UPDATE $wpdb->comments SET comment_approved = '1' WHERE comment_ID = '$comment'");
677 akismet_submit_nonspam_comment($comment);
678 ++$i;
679 endforeach;
680 $to = add_query_arg( 'recovered', $i, $_SERVER['HTTP_REFERER'] );
681 wp_redirect( $to );
682 exit;
683 }
684 if ('delete' == $_POST['action']) {
685 check_admin_referer( $akismet_nonce );
686 if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )
687 die(__('You do not have sufficient permission to moderate comments.'));
688
689 $delete_time = $wpdb->escape( $_POST['display_time'] );
690 $nuked = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
691 wp_cache_delete( 'akismet_spam_count', 'widget' );
692 $to = add_query_arg( 'deleted', 'all', $_SERVER['HTTP_REFERER'] );
693 wp_redirect( $to );
694 exit;
695 }
696
697if ( isset( $_GET['recovered'] ) ) {
698 $i = (int) $_GET['recovered'];
699 echo '<div class="updated"><p>' . sprintf(__('%1$s comments recovered.'), $i) . "</p></div>";
700}
701
702if (isset( $_GET['deleted'] ) )
703 echo '<div class="updated"><p>' . __('All spam deleted.') . '</p></div>';
704
705if ( isset( $GLOBALS['submenu']['edit-comments.php'] ) )
706 $link = 'edit-comments.php';
707else
708 $link = 'edit.php';
709?>
710<style type="text/css">
711.akismet-tabs {
712 list-style: none;
713 margin: 0;
714 padding: 0;
715 clear: both;
716 border-bottom: 1px solid #ccc;
717 height: 31px;
718 margin-bottom: 20px;
719 background: #ddd;
720 border-top: 1px solid #bdbdbd;
721}
722.akismet-tabs li {
723 float: left;
724 margin: 5px 0 0 20px;
725}
726.akismet-tabs a {
727 display: block;
728 padding: 4px .5em 3px;
729 border-bottom: none;
730 color: #036;
731}
732.akismet-tabs .active a {
733 background: #fff;
734 border: 1px solid #ccc;
735 border-bottom: none;
736 color: #000;
737 font-weight: bold;
738 padding-bottom: 4px;
739}
740#akismetsearch {
741 float: right;
742 margin-top: -.5em;
743}
744
745#akismetsearch p {
746 margin: 0;
747 padding: 0;
748}
749</style>
750<div class="wrap">
751<h2><?php _e('Caught Spam') ?></h2>
752<?php
753$count = get_option( 'akismet_spam_count' );
754if ( $count ) {
755?>
756<p><?php printf(__('Akismet has caught <strong>%1$s spam</strong> for you since you first installed it.'), number_format_i18n($count) ); ?></p>
757<?php
758}
759
760$spam_count = akismet_spam_count();
761
762if ( 0 == $spam_count ) {
763 echo '<p>'.__('You have no spam currently in the queue. Must be your lucky day. :)').'</p>';
764 echo '</div>';
765} else {
766 echo '<p>'.__('You can delete all of the spam from your database with a single click. This operation cannot be undone, so you may wish to check to ensure that no legitimate comments got through first. Spam is automatically deleted after 15 days, so don&#8217;t sweat it.').'</p>';
767?>
768<?php if ( !isset( $_POST['s'] ) ) { ?>
769<form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
770<?php akismet_nonce_field($akismet_nonce) ?>
771<input type="hidden" name="action" value="delete" />
772<?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?>&nbsp; &nbsp; <input type="submit" class="button delete" name="Submit" value="<?php _e('Delete all'); ?>" />
773<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" />
774</form>
775<?php } ?>
776</div>
777<div class="wrap">
778<?php if ( isset( $_POST['s'] ) ) { ?>
779<h2><?php _e('Search'); ?></h2>
780<?php } else { ?>
781<?php echo '<p>'.__('These are the latest comments identified as spam by Akismet. If you see any mistakes, simply mark the comment as "not spam" and Akismet will learn from the submission. If you wish to recover a comment from spam, simply select the comment, and click Not Spam. After 15 days we clean out the junk for you.').'</p>'; ?>
782<?php } ?>
783<?php
784if ( isset( $_POST['s'] ) ) {
785 $s = $wpdb->escape($_POST['s']);
786 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE
787 (comment_author LIKE '%$s%' OR
788 comment_author_email LIKE '%$s%' OR
789 comment_author_url LIKE ('%$s%') OR
790 comment_author_IP LIKE ('%$s%') OR
791 comment_content LIKE ('%$s%') ) AND
792 comment_approved = 'spam'
793 ORDER BY comment_date DESC");
794} else {
795 if ( isset( $_GET['apage'] ) )
796 $page = (int) $_GET['apage'];
797 else
798 $page = 1;
799
800 if ( $page < 2 )
801 $page = 1;
802
803 $current_type = false;
804 if ( isset( $_GET['ctype'] ) )
805 $current_type = preg_replace( '|[^a-z]|', '', $_GET['ctype'] );
806
807 $comments = akismet_spam_comments( $current_type, $page );
808 $total = akismet_spam_count( $current_type );
809 $totals = akismet_spam_totals();
810?>
811<ul class="akismet-tabs">
812<li <?php if ( !isset( $_GET['ctype'] ) ) echo ' class="active"'; ?>><a href="edit-comments.php?page=akismet-admin"><?php _e('All'); ?></a></li>
813<?php
814foreach ( $totals as $type => $type_count ) {
815 if ( 'comment' == $type ) {
816 $type = 'comments';
817 $show = __('Comments');
818 } else {
819 $show = ucwords( $type );
820 }
821 $type_count = number_format_i18n( $type_count );
822 $extra = $current_type === $type ? ' class="active"' : '';
823 echo "<li $extra><a href='edit-comments.php?page=akismet-admin&amp;ctype=$type'>$show ($type_count)</a></li>";
824}
825do_action( 'akismet_tabs' ); // so plugins can add more tabs easily
826?>
827</ul>
828<?php
829}
830
831if ($comments) {
832?>
833<form method="post" action="<?php echo attribute_escape("$link?page=akismet-admin"); ?>" id="akismetsearch">
834<p> <input type="text" name="s" value="<?php if (isset($_POST['s'])) echo attribute_escape($_POST['s']); ?>" size="17" />
835 <input type="submit" class="button" name="submit" value="<?php echo attribute_escape(__('Search Spam &raquo;')) ?>" /> </p>
836</form>
837<?php if ( $total > 50 ) {
838$total_pages = ceil( $total / 50 );
839$r = '';
840if ( 1 < $page ) {
841 $args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;
842 $r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('&laquo; Previous Page') .'</a>' . "\n";
843}
844if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {
845 for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
846 if ( $page == $page_num ) :
847 $r .= "<strong>$page_num</strong>\n";
848 else :
849 $p = false;
850 if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
851 $args['apage'] = ( 1 == $page_num ) ? '' : $page_num;
852 $r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
853 $in = true;
854 elseif ( $in == true ) :
855 $r .= "...\n";
856 $in = false;
857 endif;
858 endif;
859 endfor;
860}
861if ( ( $page ) * 50 < $total || -1 == $total ) {
862 $args['apage'] = $page + 1;
863 $r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page &raquo;') .'</a>' . "\n";
864}
865echo "<p>$r</p>";
866?>
867
868<?php } ?>
869<form style="clear: both;" method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
870<?php akismet_nonce_field($akismet_nonce) ?>
871<input type="hidden" name="action" value="recover" />
872<ul id="spam-list" class="commentlist" style="list-style: none; margin: 0; padding: 0;">
873<?php
874$i = 0;
875foreach($comments as $comment) {
876 $i++;
877 $comment_date = mysql2date(get_option("date_format") . " @ " . get_option("time_format"), $comment->comment_date);
878 $post = get_post($comment->comment_post_ID);
879 $post_title = $post->post_title;
880 if ($i % 2) $class = 'class="alternate"';
881 else $class = '';
882 echo "\n\t<li id='comment-$comment->comment_ID' $class>";
883 ?>
884
885<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
886
887<?php comment_text() ?>
888
889<p><label for="spam-<?php echo $comment->comment_ID; ?>">
890<input type="checkbox" id="spam-<?php echo $comment->comment_ID; ?>" name="not_spam[]" value="<?php echo $comment->comment_ID; ?>" />
891<?php _e('Not Spam') ?></label> &#8212; <?php comment_date('M j, g:i A'); ?> &#8212; [
892<?php
893$post = get_post($comment->comment_post_ID);
894$post_title = wp_specialchars( $post->post_title, 'double' );
895$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
896?>
897 <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] </p>
898
899
900<?php
901}
902?>
903</ul>
904<?php if ( $total > 50 ) {
905$total_pages = ceil( $total / 50 );
906$r = '';
907if ( 1 < $page ) {
908 $args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;
909 $r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('&laquo; Previous Page') .'</a>' . "\n";
910}
911if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {
912 for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
913 if ( $page == $page_num ) :
914 $r .= "<strong>$page_num</strong>\n";
915 else :
916 $p = false;
917 if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
918 $args['apage'] = ( 1 == $page_num ) ? '' : $page_num;
919 $r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
920 $in = true;
921 elseif ( $in == true ) :
922 $r .= "...\n";
923 $in = false;
924 endif;
925 endif;
926 endfor;
927}
928if ( ( $page ) * 50 < $total || -1 == $total ) {
929 $args['apage'] = $page + 1;
930 $r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page &raquo;') .'</a>' . "\n";
931}
932echo "<p>$r</p>";
933}
934?>
935<p class="submit">
936<input type="submit" name="submit" value="<?php echo attribute_escape(__('De-spam marked comments &raquo;')); ?>" />
937</p>
938<p><?php _e('Comments you de-spam will be submitted to Akismet as mistakes so it can learn and get better.'); ?></p>
939</form>
940<?php
941} else {
942?>
943<p><?php _e('No results found.'); ?></p>
944<?php } ?>
945
946<?php if ( !isset( $_POST['s'] ) ) { ?>
947<form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
948<?php akismet_nonce_field($akismet_nonce) ?>
949<p><input type="hidden" name="action" value="delete" />
950<?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?>&nbsp; &nbsp; <input type="submit" name="Submit" class="button" value="<?php echo attribute_escape(__('Delete all')); ?>" />
951<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" /></p>
952</form>
953<?php } ?>
954</div>
955<?php
956 }
957}
958
959add_action('admin_menu', 'akismet_manage_page');
960
961// WP < 2.5
962function akismet_stats() {
963 if ( !function_exists('did_action') || did_action( 'rightnow_end' ) ) // We already displayed this info in the "Right Now" section
964 return;
965 if ( !$count = get_option('akismet_spam_count') )
966 return;
967 $path = plugin_basename(__FILE__);
968 echo '<h3>'.__('Spam').'</h3>';
969 global $submenu;
970 if ( isset( $submenu['edit-comments.php'] ) )
971 $link = 'edit-comments.php';
972 else
973 $link = 'edit.php';
974 echo '<p>'.sprintf(__('<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.'), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'</p>';
975}
976
977add_action('activity_box_end', 'akismet_stats');
978
979// WP 2.5+
980function akismet_rightnow() {
981 global $submenu, $wp_db_version;
982
983 if ( 8645 < $wp_db_version ) // 2.7
984 $link = 'edit-comments.php?comment_status=spam';
985 elseif ( isset( $submenu['edit-comments.php'] ) )
986 $link = 'edit-comments.php?page=akismet-admin';
987 else
988 $link = 'edit.php?page=akismet-admin';
989
990 if ( $count = get_option('akismet_spam_count') ) {
991 $intro = sprintf( __ngettext(
992 '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already,',
993 '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already,',
994 $count
995 ), 'http://akismet.com/', number_format_i18n( $count ) );
996 } else {
997 $intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog,'), 'http://akismet.com/' );
998 }
999
1000 if ( $queue_count = akismet_spam_count() ) {
1001 $queue_text = sprintf( __ngettext(
1002 'and there\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
1003 'and there are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
1004 $queue_count
1005 ), number_format_i18n( $queue_count ), clean_url($link) );
1006 } else {
1007 $queue_text = sprintf( __( "but there's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), clean_url($link) );
1008 }
1009
1010 $text = sprintf( _c( '%1$s %2$s|akismet_rightnow' ), $intro, $queue_text );
1011
1012 echo "<p class='akismet-right-now'>$text</p>\n";
1013}
1014 489
1015add_action('rightnow_end', 'akismet_rightnow');490 $remaining = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) );
1016491 if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
1017// For WP <= 2.3.x492 wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
1018global $pagenow;493 }
1019494}
1020if ( 'moderation.php' == $pagenow ) {495add_action( 'akismet_schedule_cron_recheck', 'akismet_cron_recheck' );
1021 function akismet_recheck_button( $page ) {496
1022 global $submenu;497function akismet_add_comment_nonce( $post_id ) {
1023 if ( isset( $submenu['edit-comments.php'] ) )498 echo '<p style="display: none;">';
1024 $link = 'edit-comments.php';499 wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
1025 else500 echo '</p>';
1026 $link = 'edit.php';501}
1027 $button = "<a href='$link?page=akismet-admin&amp;recheckqueue=true&amp;noheader=true' style='display: block; width: 100px; position: absolute; right: 7%; padding: 5px; font-size: 14px; text-decoration: underline; background: #fff; border: 1px solid #ccc;'>" . __('Recheck Queue for Spam') . "</a>";502
1028 $page = str_replace( '<div class="wrap">', '<div class="wrap">' . $button, $page );503$akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
1029 return $page;504
1030 }505if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
1031506 add_action( 'comment_form', 'akismet_add_comment_nonce' );
1032 if ( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'" ) )
1033 ob_start( 'akismet_recheck_button' );
1034}
1035
1036// For WP >= 2.5
1037function akismet_check_for_spam_button($comment_status) {
1038 if ( 'approved' == $comment_status )
1039 return;
1040 if ( function_exists('plugins_url') )
1041 $link = 'admin.php?action=akismet_recheck_queue';
1042 else
1043 $link = 'edit-comments.php?page=akismet-admin&amp;recheckqueue=true&amp;noheader=true';
1044 echo "</div><div class='alignleft'><a class='button-secondary checkforspam' href='$link'>" . __('Check for Spam') . "</a>";
1045}
1046add_action('manage_comments_nav', 'akismet_check_for_spam_button');
1047
1048function akismet_recheck_queue() {
1049 global $wpdb, $akismet_api_host, $akismet_api_port;
1050
1051 if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )
1052 return;
1053
1054 $moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'", ARRAY_A );
1055 foreach ( (array) $moderation as $c ) {
1056 $c['user_ip'] = $c['comment_author_IP'];
1057 $c['user_agent'] = $c['comment_agent'];
1058 $c['referrer'] = '';
1059 $c['blog'] = get_option('home');
1060 $c['blog_lang'] = get_locale();
1061 $c['blog_charset'] = get_option('blog_charset');
1062 $c['permalink'] = get_permalink($c['comment_post_ID']);
1063 $c['user_role'] = akismet_get_user_roles($c['user_ID']);
1064 $id = (int) $c['comment_ID'];
1065
1066 $query_string = '';
1067 foreach ( $c as $key => $data )
1068 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
1069
1070 $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
1071 if ( 'true' == $response[1] ) {
1072 $wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'spam' WHERE comment_ID = $id" );
1073 }
1074 }
1075 wp_redirect( $_SERVER['HTTP_REFERER'] );
1076 exit;
1077}
1078
1079add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');
1080
1081function akismet_check_db_comment( $id ) {
1082 global $wpdb, $akismet_api_host, $akismet_api_port;
1083
1084 $id = (int) $id;
1085 $c = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID = '$id'", ARRAY_A );
1086 if ( !$c )
1087 return;
1088
1089 $c['user_ip'] = $c['comment_author_IP'];
1090 $c['user_agent'] = $c['comment_agent'];
1091 $c['referrer'] = '';
1092 $c['blog'] = get_option('home');
1093 $c['blog_lang'] = get_locale();
1094 $c['blog_charset'] = get_option('blog_charset');
1095 $c['permalink'] = get_permalink($c['comment_post_ID']);
1096 $id = $c['comment_ID'];
1097
1098 $query_string = '';
1099 foreach ( $c as $key => $data )
1100 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
1101
1102 $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
1103 return $response[1];
1104}
1105
1106// This option causes tons of FPs, was removed in 2.1
1107function akismet_kill_proxy_check( $option ) { return 0; }
1108add_filter('option_open_proxy_check', 'akismet_kill_proxy_check');
1109
1110// Widget stuff
1111function widget_akismet_register() {
1112 if ( function_exists('register_sidebar_widget') ) :
1113 function widget_akismet($args) {
1114 extract($args);
1115 $options = get_option('widget_akismet');
1116 $count = number_format_i18n(get_option('akismet_spam_count'));
1117 ?>
1118 <?php echo $before_widget; ?>
1119 <?php echo $before_title . $options['title'] . $after_title; ?>
1120 <div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><?php printf( __( '%1$s %2$sspam comments%3$s %4$sblocked by%5$s<br />%6$sAkismet%7$s' ), '<span id="akismet1"><span id="akismetcount">' . $count . '</span>', '<span id="akismetsc">', '</span></span>', '<span id="akismet2"><span id="akismetbb">', '</span>', '<span id="akismeta">', '</span></span>' ); ?></a></div></div>
1121 <?php echo $after_widget; ?>
1122 <?php
1123 }
1124
1125 function widget_akismet_style() {
1126 ?>
1127<style type="text/css">
1128#aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}
1129#aka:hover{border:none;text-decoration:none}
1130#aka:hover #akismet1{display:none}
1131#aka:hover #akismet2,#akismet1{display:block}
1132#akismet2{display:none;padding-top:2px}
1133#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}
1134#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}
1135#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'); ?>/wp-content/plugins/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
1136</style>
1137 <?php
1138 }
1139
1140 function widget_akismet_control() {
1141 $options = $newoptions = get_option('widget_akismet');
1142 if ( $_POST["akismet-submit"] ) {
1143 $newoptions['title'] = strip_tags(stripslashes($_POST["akismet-title"]));
1144 if ( empty($newoptions['title']) ) $newoptions['title'] = __('Spam Blocked');
1145 }
1146 if ( $options != $newoptions ) {
1147 $options = $newoptions;
1148 update_option('widget_akismet', $options);
1149 }
1150 $title = htmlspecialchars($options['title'], ENT_QUOTES);
1151 ?>
1152 <p><label for="akismet-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="akismet-title" name="akismet-title" type="text" value="<?php echo $title; ?>" /></label></p>
1153 <input type="hidden" id="akismet-submit" name="akismet-submit" value="1" />
1154 <?php
1155 }
1156
1157 register_sidebar_widget('Akismet', 'widget_akismet', null, 'akismet');
1158 register_widget_control('Akismet', 'widget_akismet_control', null, 75, 'akismet');
1159 if ( is_active_widget('widget_akismet') )
1160 add_action('wp_head', 'widget_akismet_style');
1161 endif;
1162}
1163
1164add_action('init', 'widget_akismet_register');
1165
1166// Counter for non-widget users
1167function akismet_counter() {
1168?>
1169<style type="text/css">
1170#akismetwrap #aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}
1171#aka:hover{border:none;text-decoration:none}
1172#aka:hover #akismet1{display:none}
1173#aka:hover #akismet2,#akismet1{display:block}
1174#akismet2{display:none;padding-top:2px}
1175#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}
1176#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}
1177#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'); ?>/wp-content/plugins/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
1178</style>
1179<?php
1180$count = number_format_i18n(get_option('akismet_spam_count'));
1181?>
1182<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount"><?php echo $count; ?></span> <span id="akismetsc"><?php _e('spam comments') ?></span></div> <div id="akismet2"><span id="akismetbb"><?php _e('blocked by') ?></span><br /><span id="akismeta">Akismet</span></div></a></div></div>
1183<?php
1184}
1185
1186?>
1187507
=== added file 'wp-content/plugins/akismet/legacy.php'
--- wp-content/plugins/akismet/legacy.php 1970-01-01 00:00:00 +0000
+++ wp-content/plugins/akismet/legacy.php 2011-01-25 16:02:14 +0000
@@ -0,0 +1,396 @@
1<?php
2
3function akismet_spam_comments( $type = false, $page = 1, $per_page = 50 ) {
4 global $wpdb;
5
6 $page = (int) $page;
7 if ( $page < 2 )
8 $page = 1;
9
10 $per_page = (int) $per_page;
11 if ( $per_page < 1 )
12 $per_page = 50;
13
14 $start = ( $page - 1 ) * $per_page;
15 $end = $start + $per_page;
16
17 if ( $type ) {
18 if ( 'comments' == $type || 'comment' == $type )
19 $type = '';
20 else
21 $type = $wpdb->escape( $type );
22 return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type' ORDER BY comment_date DESC LIMIT $start, $end");
23 }
24
25 // All
26 return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT $start, $end");
27}
28
29// Totals for each comment type
30// returns array( type => count, ... )
31function akismet_spam_totals() {
32 global $wpdb;
33 $totals = $wpdb->get_results( "SELECT comment_type, COUNT(*) AS cc FROM $wpdb->comments WHERE comment_approved = 'spam' GROUP BY comment_type" );
34 $return = array();
35 foreach ( $totals as $total )
36 $return[$total->comment_type ? $total->comment_type : 'comment'] = $total->cc;
37 return $return;
38}
39
40function akismet_manage_page() {
41 global $wpdb, $submenu, $wp_db_version;
42
43 // WP 2.7 has its own spam management page
44 if ( 8645 <= $wp_db_version )
45 return;
46
47 $count = sprintf(__('Akismet Spam (%s)'), akismet_spam_count());
48 if ( isset( $submenu['edit-comments.php'] ) )
49 add_submenu_page('edit-comments.php', __('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught' );
50 elseif ( function_exists('add_management_page') )
51 add_management_page(__('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught');
52}
53
54function akismet_caught() {
55 global $wpdb, $comment, $akismet_caught, $akismet_nonce;
56
57 akismet_recheck_queue();
58 if (isset($_POST['submit']) && 'recover' == $_POST['action'] && ! empty($_POST['not_spam'])) {
59 check_admin_referer( $akismet_nonce );
60 if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )
61 die(__('You do not have sufficient permission to moderate comments.'));
62
63 $i = 0;
64 foreach ($_POST['not_spam'] as $comment):
65 $comment = (int) $comment;
66 if ( function_exists('wp_set_comment_status') )
67 wp_set_comment_status($comment, 'approve');
68 else
69 $wpdb->query("UPDATE $wpdb->comments SET comment_approved = '1' WHERE comment_ID = '$comment'");
70 akismet_submit_nonspam_comment($comment);
71 ++$i;
72 endforeach;
73 $to = add_query_arg( 'recovered', $i, $_SERVER['HTTP_REFERER'] );
74 wp_redirect( $to );
75 exit;
76 }
77 if ('delete' == $_POST['action']) {
78 check_admin_referer( $akismet_nonce );
79 if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )
80 die(__('You do not have sufficient permission to moderate comments.'));
81
82 $delete_time = $wpdb->escape( $_POST['display_time'] );
83 $comment_ids = $wpdb->get_col( "SELECT comment_id FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
84 if ( !empty( $comment_ids ) ) {
85 do_action( 'delete_comment', $comment_ids );
86 $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_id IN ( " . implode( ', ', $comment_ids ) . " )");
87 wp_cache_delete( 'akismet_spam_count', 'widget' );
88 }
89 $to = add_query_arg( 'deleted', 'all', $_SERVER['HTTP_REFERER'] );
90 wp_redirect( $to );
91 exit;
92 }
93
94if ( isset( $_GET['recovered'] ) ) {
95 $i = (int) $_GET['recovered'];
96 echo '<div class="updated"><p>' . sprintf(__('%1$s comments recovered.'), $i) . "</p></div>";
97}
98
99if (isset( $_GET['deleted'] ) )
100 echo '<div class="updated"><p>' . __('All spam deleted.') . '</p></div>';
101
102if ( isset( $GLOBALS['submenu']['edit-comments.php'] ) )
103 $link = 'edit-comments.php';
104else
105 $link = 'edit.php';
106?>
107<style type="text/css">
108.akismet-tabs {
109 list-style: none;
110 margin: 0;
111 padding: 0;
112 clear: both;
113 border-bottom: 1px solid #ccc;
114 height: 31px;
115 margin-bottom: 20px;
116 background: #ddd;
117 border-top: 1px solid #bdbdbd;
118}
119.akismet-tabs li {
120 float: left;
121 margin: 5px 0 0 20px;
122}
123.akismet-tabs a {
124 display: block;
125 padding: 4px .5em 3px;
126 border-bottom: none;
127 color: #036;
128}
129.akismet-tabs .active a {
130 background: #fff;
131 border: 1px solid #ccc;
132 border-bottom: none;
133 color: #000;
134 font-weight: bold;
135 padding-bottom: 4px;
136}
137#akismetsearch {
138 float: right;
139 margin-top: -.5em;
140}
141
142#akismetsearch p {
143 margin: 0;
144 padding: 0;
145}
146</style>
147<div class="wrap">
148<h2><?php _e('Caught Spam') ?></h2>
149<?php
150$count = get_option( 'akismet_spam_count' );
151if ( $count ) {
152?>
153<p><?php printf(__('Akismet has caught <strong>%1$s spam</strong> for you since you first installed it.'), number_format_i18n($count) ); ?></p>
154<?php
155}
156
157$spam_count = akismet_spam_count();
158
159if ( 0 == $spam_count ) {
160 echo '<p>'.__('You have no spam currently in the queue. Must be your lucky day. :)').'</p>';
161 echo '</div>';
162} else {
163 echo '<p>'.__('You can delete all of the spam from your database with a single click. This operation cannot be undone, so you may wish to check to ensure that no legitimate comments got through first. Spam is automatically deleted after 15 days, so don&#8217;t sweat it.').'</p>';
164?>
165<?php if ( !isset( $_POST['s'] ) ) { ?>
166<form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
167<?php akismet_nonce_field($akismet_nonce) ?>
168<input type="hidden" name="action" value="delete" />
169<?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?>&nbsp; &nbsp; <input type="submit" class="button delete" name="Submit" value="<?php _e('Delete all'); ?>" />
170<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" />
171</form>
172<?php } ?>
173</div>
174<div class="wrap">
175<?php if ( isset( $_POST['s'] ) ) { ?>
176<h2><?php _e('Search'); ?></h2>
177<?php } else { ?>
178<?php echo '<p>'.__('These are the latest comments identified as spam by Akismet. If you see any mistakes, simply mark the comment as "not spam" and Akismet will learn from the submission. If you wish to recover a comment from spam, simply select the comment, and click Not Spam. After 15 days we clean out the junk for you.').'</p>'; ?>
179<?php } ?>
180<?php
181if ( isset( $_POST['s'] ) ) {
182 $s = $wpdb->escape($_POST['s']);
183 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE
184 (comment_author LIKE '%$s%' OR
185 comment_author_email LIKE '%$s%' OR
186 comment_author_url LIKE ('%$s%') OR
187 comment_author_IP LIKE ('%$s%') OR
188 comment_content LIKE ('%$s%') ) AND
189 comment_approved = 'spam'
190 ORDER BY comment_date DESC");
191} else {
192 if ( isset( $_GET['apage'] ) )
193 $page = (int) $_GET['apage'];
194 else
195 $page = 1;
196
197 if ( $page < 2 )
198 $page = 1;
199
200 $current_type = false;
201 if ( isset( $_GET['ctype'] ) )
202 $current_type = preg_replace( '|[^a-z]|', '', $_GET['ctype'] );
203
204 $comments = akismet_spam_comments( $current_type, $page );
205 $total = akismet_spam_count( $current_type );
206 $totals = akismet_spam_totals();
207?>
208<ul class="akismet-tabs">
209<li <?php if ( !isset( $_GET['ctype'] ) ) echo ' class="active"'; ?>><a href="edit-comments.php?page=akismet-admin"><?php _e('All'); ?></a></li>
210<?php
211foreach ( $totals as $type => $type_count ) {
212 if ( 'comment' == $type ) {
213 $type = 'comments';
214 $show = __('Comments');
215 } else {
216 $show = ucwords( $type );
217 }
218 $type_count = number_format_i18n( $type_count );
219 $extra = $current_type === $type ? ' class="active"' : '';
220 echo "<li $extra><a href='edit-comments.php?page=akismet-admin&amp;ctype=$type'>$show ($type_count)</a></li>";
221}
222do_action( 'akismet_tabs' ); // so plugins can add more tabs easily
223?>
224</ul>
225<?php
226}
227
228if ($comments) {
229?>
230<form method="post" action="<?php echo attribute_escape("$link?page=akismet-admin"); ?>" id="akismetsearch">
231<p> <input type="text" name="s" value="<?php if (isset($_POST['s'])) echo attribute_escape($_POST['s']); ?>" size="17" />
232 <input type="submit" class="button" name="submit" value="<?php echo attribute_escape(__('Search Spam &raquo;')) ?>" /> </p>
233</form>
234<?php if ( $total > 50 ) {
235$total_pages = ceil( $total / 50 );
236$r = '';
237if ( 1 < $page ) {
238 $args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;
239 $r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('&laquo; Previous Page') .'</a>' . "\n";
240}
241if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {
242 for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
243 if ( $page == $page_num ) :
244 $r .= "<strong>$page_num</strong>\n";
245 else :
246 $p = false;
247 if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
248 $args['apage'] = ( 1 == $page_num ) ? '' : $page_num;
249 $r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
250 $in = true;
251 elseif ( $in == true ) :
252 $r .= "...\n";
253 $in = false;
254 endif;
255 endif;
256 endfor;
257}
258if ( ( $page ) * 50 < $total || -1 == $total ) {
259 $args['apage'] = $page + 1;
260 $r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page &raquo;') .'</a>' . "\n";
261}
262echo "<p>$r</p>";
263?>
264
265<?php } ?>
266<form style="clear: both;" method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
267<?php akismet_nonce_field($akismet_nonce) ?>
268<input type="hidden" name="action" value="recover" />
269<ul id="spam-list" class="commentlist" style="list-style: none; margin: 0; padding: 0;">
270<?php
271$i = 0;
272foreach($comments as $comment) {
273 $i++;
274 $comment_date = mysql2date(get_option("date_format") . " @ " . get_option("time_format"), $comment->comment_date);
275 $post = get_post($comment->comment_post_ID);
276 $post_title = $post->post_title;
277 if ($i % 2) $class = 'class="alternate"';
278 else $class = '';
279 echo "\n\t<li id='comment-$comment->comment_ID' $class>";
280 ?>
281
282<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
283
284<?php comment_text() ?>
285
286<p><label for="spam-<?php echo $comment->comment_ID; ?>">
287<input type="checkbox" id="spam-<?php echo $comment->comment_ID; ?>" name="not_spam[]" value="<?php echo $comment->comment_ID; ?>" />
288<?php _e('Not Spam') ?></label> &#8212; <?php comment_date('M j, g:i A'); ?> &#8212; [
289<?php
290$post = get_post($comment->comment_post_ID);
291$post_title = wp_specialchars( $post->post_title, 'double' );
292$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
293?>
294 <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] </p>
295
296
297<?php
298}
299?>
300</ul>
301<?php if ( $total > 50 ) {
302$total_pages = ceil( $total / 50 );
303$r = '';
304if ( 1 < $page ) {
305 $args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;
306 $r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('&laquo; Previous Page') .'</a>' . "\n";
307}
308if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {
309 for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
310 if ( $page == $page_num ) :
311 $r .= "<strong>$page_num</strong>\n";
312 else :
313 $p = false;
314 if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
315 $args['apage'] = ( 1 == $page_num ) ? '' : $page_num;
316 $r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
317 $in = true;
318 elseif ( $in == true ) :
319 $r .= "...\n";
320 $in = false;
321 endif;
322 endif;
323 endfor;
324}
325if ( ( $page ) * 50 < $total || -1 == $total ) {
326 $args['apage'] = $page + 1;
327 $r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page &raquo;') .'</a>' . "\n";
328}
329echo "<p>$r</p>";
330}
331?>
332<p class="submit">
333<input type="submit" name="submit" value="<?php echo attribute_escape(__('De-spam marked comments &raquo;')); ?>" />
334</p>
335<p><?php _e('Comments you de-spam will be submitted to Akismet as mistakes so it can learn and get better.'); ?></p>
336</form>
337<?php
338} else {
339?>
340<p><?php _e('No results found.'); ?></p>
341<?php } ?>
342
343<?php if ( !isset( $_POST['s'] ) ) { ?>
344<form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
345<?php akismet_nonce_field($akismet_nonce) ?>
346<p><input type="hidden" name="action" value="delete" />
347<?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?>&nbsp; &nbsp; <input type="submit" name="Submit" class="button" value="<?php echo attribute_escape(__('Delete all')); ?>" />
348<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" /></p>
349</form>
350<?php } ?>
351</div>
352<?php
353 }
354}
355
356add_action('admin_menu', 'akismet_manage_page');
357
358function redirect_old_akismet_urls( ) {
359 global $wp_db_version;
360 $script_name = array_pop( split( '/', $_SERVER['PHP_SELF'] ) );
361
362 $page = '';
363 if ( !empty( $_GET['page'] ) )
364 $page = $_GET['page'];
365
366 // 2.7 redirect for people who might have bookmarked the old page
367 if ( 8204 < $wp_db_version && ( 'edit-comments.php' == $script_name || 'edit.php' == $script_name ) && 'akismet-admin' == $page ) {
368 $new_url = esc_url( 'edit-comments.php?comment_status=spam' );
369 wp_redirect( $new_url, 301 );
370 exit;
371 }
372}
373add_action( 'admin_init', 'redirect_old_akismet_urls' );
374
375// For WP <= 2.3.x
376global $pagenow;
377
378if ( 'moderation.php' == $pagenow ) {
379 function akismet_recheck_button( $page ) {
380 global $submenu;
381 if ( isset( $submenu['edit-comments.php'] ) )
382 $link = 'edit-comments.php';
383 else
384 $link = 'edit.php';
385 $button = "<a href='$link?page=akismet-admin&amp;recheckqueue=true&amp;noheader=true' style='display: block; width: 100px; position: absolute; right: 7%; padding: 5px; font-size: 14px; text-decoration: underline; background: #fff; border: 1px solid #ccc;'>" . __('Recheck Queue for Spam') . "</a>";
386 $page = str_replace( '<div class="wrap">', '<div class="wrap">' . $button, $page );
387 return $page;
388 }
389
390 if ( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'" ) )
391 ob_start( 'akismet_recheck_button' );
392}
393
394// This option causes tons of FPs, was removed in 2.1
395function akismet_kill_proxy_check( $option ) { return 0; }
396add_filter('option_open_proxy_check', 'akismet_kill_proxy_check');
0397
=== modified file 'wp-content/plugins/akismet/readme.txt'
--- wp-content/plugins/akismet/readme.txt 2011-01-25 15:27:25 +0000
+++ wp-content/plugins/akismet/readme.txt 2011-01-25 16:02:14 +0000
@@ -1,9 +1,10 @@
1=== Akismet ===1=== Akismet ===
2Contributors: matt, ryan, andy, mdawaffe, tellyworth, automattic2Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, automattic
3Tags: akismet, comments, spam3Tags: akismet, comments, spam
4Requires at least: 2.04Requires at least: 3.0
5Tested up to: 3.05Tested up to: 3.1
6Stable tag: 2.3.06Stable tag: 2.5.2
7License: GPLv2
78
8Akismet checks your comments against the Akismet web service to see if they look like spam or not.9Akismet checks your comments against the Akismet web service to see if they look like spam or not.
910
@@ -12,11 +13,15 @@
12Akismet checks your comments against the Akismet web service to see if they look like spam or not and lets you13Akismet checks your comments against the Akismet web service to see if they look like spam or not and lets you
13review the spam it catches under your blog's "Comments" admin screen.14review the spam it catches under your blog's "Comments" admin screen.
1415
15Want to show off how much spam Akismet has caught for you? Just put `<?php akismet_counter(); ?>` in your template.16Major new features in Akismet 2.5 include:
1617
17See also: [WP Stats plugin](http://wordpress.org/extend/plugins/stats/).18* A comment status history, so you can easily see which comments were caught or cleared by Akismet, and which were spammed or unspammed by a moderator
1819* Links are highlighted in the comment body, to reveal hidden or misleading links
19PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it.20* If your web host is unable to reach Akismet's servers, the plugin will automatically retry when your connection is back up
21* Moderators can see the number of approved comments for each user
22* Spam and Unspam reports now include more information, to help improve accuracy
23
24PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it. Keys are free for personal blogs, with paid subscriptions available for businesses and commercial sites.
2025
21== Installation ==26== Installation ==
2227
@@ -26,6 +31,59 @@
2631
27== Changelog ==32== Changelog ==
2833
34= 2.5.2 =
35
36* Properly format the comment count for author counts
37* Look for super admins on multisite installs when looking up user roles
38* Increase the HTTP request timeout
39* Removed padding for author approved count
40* Fix typo in function name
41* Set Akismet stats iframe height to fixed 2500px. Better to have one tall scroll bar than two side by side.
42
43= 2.5.1 =
44
45* Fix a bug that caused the "Auto delete" option to fail to discard comments correctly
46* Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce
47* Fixed padding bug in "author" column of posts screen
48* Added margin-top to "cleared by ..." badges on dashboard
49* Fix possible error when calling akismet_cron_recheck()
50* Fix more PHP warnings
51* Clean up XHTML warnings for comment nonce
52* Fix for possible condition where scheduled comment re-checks could get stuck
53* Clean up the comment meta details after deleting a comment
54* Only show the status badge if the comment status has been changed by someone/something other than Akismet
55* Show a 'History' link in the row-actions
56* Translation fixes
57* Reduced font-size on author name
58* Moved "flagged by..." notification to top right corner of comment container and removed heavy styling
59* Hid "flagged by..." notification while on dashboard
60
61= 2.5.0 =
62
63* Track comment actions under 'Akismet Status' on the edit comment screen
64* Fix a few remaining deprecated function calls ( props Mike Glendinning )
65* Use HTTPS for the stats IFRAME when wp-admin is using HTTPS
66* Use the WordPress HTTP class if available
67* Move the admin UI code to a separate file, only loaded when needed
68* Add cron retry feature, to replace the old connectivity check
69* Display Akismet status badge beside each comment
70* Record history for each comment, and display it on the edit page
71* Record the complete comment as originally submitted in comment_meta, to use when reporting spam and ham
72* Highlight links in comment content
73* New option, "Show the number of comments you've approved beside each comment author."
74* New option, "Use a nonce on the comment form."
75
76= 2.4.0 =
77
78* Spell out that the license is GPLv2
79* Fix PHP warnings
80* Fix WordPress deprecated function calls
81* Fire the delete_comment action when deleting comments
82* Move code specific for older WP versions to legacy.php
83* General code clean up
84
85= 2.3.0 =
86
29* Fix "Are you sure" nonce message on config screen in WPMU87* Fix "Are you sure" nonce message on config screen in WPMU
30* Fix XHTML compliance issue in sidebar widget88* Fix XHTML compliance issue in sidebar widget
31* Change author link; remove some old references to WordPress.com accounts89* Change author link; remove some old references to WordPress.com accounts
3290
=== added file 'wp-content/plugins/akismet/widget.php'
--- wp-content/plugins/akismet/widget.php 1970-01-01 00:00:00 +0000
+++ wp-content/plugins/akismet/widget.php 2011-01-25 16:02:14 +0000
@@ -0,0 +1,90 @@
1<?php
2/**
3 * @package Akismet
4 */
5// Widget stuff
6function widget_akismet_register() {
7 if ( function_exists('register_sidebar_widget') ) :
8 function widget_akismet($args) {
9 extract($args);
10 $options = get_option('widget_akismet');
11 $count = get_option('akismet_spam_count');
12 ?>
13 <?php echo $before_widget; ?>
14 <?php echo $before_title . $options['title'] . $after_title; ?>
15 <div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><?php printf( _n( '%1$s%2$s%3$s %4$sspam comment%5$s %6$sblocked by%7$s<br />%8$sAkismet%9$s', '%1$s%2$s%3$s %4$sspam comments%5$s %6$sblocked by%7$s<br />%8$sAkismet%9$s', $count ), '<span id="akismet1"><span id="akismetcount">', number_format_i18n( $count ), '</span>', '<span id="akismetsc">', '</span></span>', '<span id="akismet2"><span id="akismetbb">', '</span>', '<span id="akismeta">', '</span></span>' ); ?></a></div></div>
16 <?php echo $after_widget; ?>
17 <?php
18 }
19
20 function widget_akismet_style() {
21 $plugin_dir = '/wp-content/plugins';
22 if ( defined( 'PLUGINDIR' ) )
23 $plugin_dir = '/' . PLUGINDIR;
24
25 ?>
26<style type="text/css">
27#aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}
28#aka:hover{border:none;text-decoration:none}
29#aka:hover #akismet1{display:none}
30#aka:hover #akismet2,#akismet1{display:block}
31#akismet2{display:none;padding-top:2px}
32#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}
33#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}
34#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'), $plugin_dir; ?>/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
35</style>
36 <?php
37 }
38
39 function widget_akismet_control() {
40 $options = $newoptions = get_option('widget_akismet');
41 if ( isset( $_POST['akismet-submit'] ) && $_POST["akismet-submit"] ) {
42 $newoptions['title'] = strip_tags(stripslashes($_POST["akismet-title"]));
43 if ( empty($newoptions['title']) ) $newoptions['title'] = __('Spam Blocked');
44 }
45 if ( $options != $newoptions ) {
46 $options = $newoptions;
47 update_option('widget_akismet', $options);
48 }
49 $title = htmlspecialchars($options['title'], ENT_QUOTES);
50 ?>
51 <p><label for="akismet-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="akismet-title" name="akismet-title" type="text" value="<?php echo $title; ?>" /></label></p>
52 <input type="hidden" id="akismet-submit" name="akismet-submit" value="1" />
53 <?php
54 }
55
56 if ( function_exists( 'wp_register_sidebar_widget' ) ) {
57 wp_register_sidebar_widget( 'akismet', 'Akismet', 'widget_akismet', null, 'akismet');
58 wp_register_widget_control( 'akismet', 'Akismet', 'widget_akismet_control', null, 75, 'akismet');
59 } else {
60 register_sidebar_widget('Akismet', 'widget_akismet', null, 'akismet');
61 register_widget_control('Akismet', 'widget_akismet_control', null, 75, 'akismet');
62 }
63 if ( is_active_widget('widget_akismet') )
64 add_action('wp_head', 'widget_akismet_style');
65 endif;
66}
67
68add_action('init', 'widget_akismet_register');
69
70// Counter for non-widget users
71function akismet_counter() {
72 $plugin_dir = '/wp-content/plugins';
73 if ( defined( 'PLUGINDIR' ) )
74 $plugin_dir = '/' . PLUGINDIR;
75
76?>
77<style type="text/css">
78#akismetwrap #aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}
79#aka:hover{border:none;text-decoration:none}
80#aka:hover #akismet1{display:none}
81#aka:hover #akismet2,#akismet1{display:block}
82#akismet2{display:none;padding-top:2px}
83#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}
84#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}
85#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'), $plugin_dir; ?>/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
86</style>
87<?php
88$count = get_option('akismet_spam_count');
89printf( _n( '<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount">%1$s</span> <span id="akismetsc">spam comment</span></div> <div id="akismet2"><span id="akismetbb">blocked by</span><br /><span id="akismeta">Akismet</span></div></a></div></div>', '<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount">%1$s</span> <span id="akismetsc">spam comments</span></div> <div id="akismet2"><span id="akismetbb">blocked by</span><br /><span id="akismeta">Akismet</span></div></a></div></div>', $count ), number_format_i18n( $count ) );
90}
091
=== modified file 'wp-includes/canonical.php'
--- wp-includes/canonical.php 2011-01-25 15:27:25 +0000
+++ wp-includes/canonical.php 2011-01-25 16:02:14 +0000
@@ -103,10 +103,6 @@
103 } elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {103 } elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
104 if ( $redirect_url = get_permalink(get_query_var('p')) )104 if ( $redirect_url = get_permalink(get_query_var('p')) )
105 $redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);105 $redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
106 if ( get_query_var( 'page' ) ) {
107 $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
108 $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
109 }
110 } elseif ( is_single() && !empty($_GET['name']) && ! $redirect_url ) {106 } elseif ( is_single() && !empty($_GET['name']) && ! $redirect_url ) {
111 if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) )107 if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) )
112 $redirect['query'] = remove_query_arg('name', $redirect['query']);108 $redirect['query'] = remove_query_arg('name', $redirect['query']);
@@ -180,12 +176,18 @@
180176
181 }177 }
182 } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false ) {178 } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false ) {
183 $category = get_term_by('slug', get_query_var('category_name'), 'category');179 $category = get_category_by_path(get_query_var('category_name'));
184 $post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category', array('fields' => 'tt_ids'));180 $post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category', array('fields' => 'tt_ids'));
185 if ( (!$category || is_wp_error($category)) || ( !is_wp_error($post_terms) && !empty($post_terms) && !in_array($category->term_taxonomy_id, $post_terms) ) )181 if ( (!$category || is_wp_error($category)) || ( !is_wp_error($post_terms) && !empty($post_terms) && !in_array($category->term_taxonomy_id, $post_terms) ) )
186 $redirect_url = get_permalink($wp_query->get_queried_object_id());182 $redirect_url = get_permalink($wp_query->get_queried_object_id());
187 }183 }
188184
185 // Post Paging
186 if ( is_singular() && get_query_var('page') && $redirect_url ) {
187 $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
188 $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
189 }
190
189 // paging and feeds191 // paging and feeds
190 if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {192 if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
191 if ( !$redirect_url )193 if ( !$redirect_url )
192194
=== modified file 'wp-includes/capabilities.php'
--- wp-includes/capabilities.php 2011-01-25 15:27:25 +0000
+++ wp-includes/capabilities.php 2011-01-25 16:02:14 +0000
@@ -799,9 +799,6 @@
799 case 'remove_user':799 case 'remove_user':
800 $caps[] = 'remove_users';800 $caps[] = 'remove_users';
801 break;801 break;
802 case 'delete_user':
803 $caps[] = 'delete_users';
804 break;
805 case 'promote_user':802 case 'promote_user':
806 $caps[] = 'promote_users';803 $caps[] = 'promote_users';
807 break;804 break;
@@ -1028,10 +1025,13 @@
1028 case 'delete_user':1025 case 'delete_user':
1029 case 'delete_users':1026 case 'delete_users':
1030 // If multisite these caps are allowed only for super admins.1027 // If multisite these caps are allowed only for super admins.
1031 if ( is_multisite() && !is_super_admin( $user_id ) )1028 if ( is_multisite() && !is_super_admin( $user_id ) ) {
1032 $caps[] = 'do_not_allow';1029 $caps[] = 'do_not_allow';
1033 else1030 } else {
1031 if ( 'delete_user' == $cap )
1032 $cap = 'delete_users';
1034 $caps[] = $cap;1033 $caps[] = $cap;
1034 }
1035 break;1035 break;
1036 case 'create_users':1036 case 'create_users':
1037 if ( is_multisite() && !get_site_option( 'add_new_users' ) )1037 if ( is_multisite() && !get_site_option( 'add_new_users' ) )
@@ -1079,9 +1079,6 @@
1079function current_user_can_for_blog( $blog_id, $capability ) {1079function current_user_can_for_blog( $blog_id, $capability ) {
1080 $current_user = wp_get_current_user();1080 $current_user = wp_get_current_user();
10811081
1082 if ( is_multisite() && is_super_admin() )
1083 return true;
1084
1085 if ( empty( $current_user ) )1082 if ( empty( $current_user ) )
1086 return false;1083 return false;
10871084
10881085
=== modified file 'wp-includes/comment.php'
--- wp-includes/comment.php 2011-01-25 15:27:25 +0000
+++ wp-includes/comment.php 2011-01-25 16:02:14 +0000
@@ -18,9 +18,8 @@
18 * check fails. If any of the parameter contents match the blacklist of words,18 * check fails. If any of the parameter contents match the blacklist of words,
19 * then the check fails.19 * then the check fails.
20 *20 *
21 * If the comment is a trackback and part of the blogroll, then the trackback is21 * If the comment author was approved before, then the comment is
22 * automatically whitelisted. If the comment author was approved before, then22 * automatically whitelisted.
23 * the comment is automatically whitelisted.
24 *23 *
25 * If none of the checks fail, then the failback is to set the check to pass24 * If none of the checks fail, then the failback is to set the check to pass
26 * (return true).25 * (return true).
@@ -80,16 +79,7 @@
8079
81 // Comment whitelisting:80 // Comment whitelisting:
82 if ( 1 == get_option('comment_whitelist')) {81 if ( 1 == get_option('comment_whitelist')) {
83 if ( 'trackback' == $comment_type || 'pingback' == $comment_type ) { // check if domain is in blogroll82 if ( 'trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '' ) {
84 $uri = parse_url($url);
85 $domain = $uri['host'];
86 $uri = parse_url( home_url() );
87 $home_domain = $uri['host'];
88 if ( $wpdb->get_var($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_url LIKE (%s) LIMIT 1", '%'.$domain.'%')) || $domain == $home_domain )
89 return true;
90 else
91 return false;
92 } elseif ( $author != '' && $email != '' ) {
93 // expected_slashed ($author, $email)83 // expected_slashed ($author, $email)
94 $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1");84 $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1");
95 if ( ( 1 == $ok_to_comment ) &&85 if ( ( 1 == $ok_to_comment ) &&
@@ -1654,7 +1644,7 @@
1654 trackback($tb_ping, $post_title, $excerpt, $post_id);1644 trackback($tb_ping, $post_title, $excerpt, $post_id);
1655 $pinged[] = $tb_ping;1645 $pinged[] = $tb_ping;
1656 } else {1646 } else {
1657 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_ping', '')) WHERE ID = %d", $post_id) );1647 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post_id) );
1658 }1648 }
1659 }1649 }
1660 }1650 }
16611651
=== modified file 'wp-includes/formatting.php'
--- wp-includes/formatting.php 2011-01-25 15:27:25 +0000
+++ wp-includes/formatting.php 2011-01-25 16:02:14 +0000
@@ -2236,7 +2236,8 @@
22362236
2237 // Replace ampersands and single quotes only when displaying.2237 // Replace ampersands and single quotes only when displaying.
2238 if ( 'display' == $_context ) {2238 if ( 'display' == $_context ) {
2239 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);2239 $url = wp_kses_normalize_entities( $url );
2240 $url = str_replace( '&amp;', '&#038;', $url );
2240 $url = str_replace( "'", '&#039;', $url );2241 $url = str_replace( "'", '&#039;', $url );
2241 }2242 }
22422243
22432244
=== modified file 'wp-includes/functions.php'
--- wp-includes/functions.php 2011-01-25 15:27:25 +0000
+++ wp-includes/functions.php 2011-01-25 16:02:14 +0000
@@ -2125,7 +2125,7 @@
2125 $siteurl = get_option( 'siteurl' );2125 $siteurl = get_option( 'siteurl' );
2126 $upload_path = get_option( 'upload_path' );2126 $upload_path = get_option( 'upload_path' );
2127 $upload_path = trim($upload_path);2127 $upload_path = trim($upload_path);
2128 $main_override = defined( 'MULTISITE' ) && is_main_site();2128 $main_override = is_multisite() && defined( 'MULTISITE' ) && is_main_site();
2129 if ( empty($upload_path) ) {2129 if ( empty($upload_path) ) {
2130 $dir = WP_CONTENT_DIR . '/uploads';2130 $dir = WP_CONTENT_DIR . '/uploads';
2131 } else {2131 } else {
21322132
=== modified file 'wp-includes/kses.php'
--- wp-includes/kses.php 2011-01-25 15:27:25 +0000
+++ wp-includes/kses.php 2011-01-25 16:02:14 +0000
@@ -670,7 +670,7 @@
670 break;670 break;
671 }671 }
672672
673 if ( $arreach['name'] == 'style' ) {673 if ( strtolower($arreach['name']) == 'style' ) {
674 $orig_value = $arreach['value'];674 $orig_value = $arreach['value'];
675675
676 $value = safecss_filter_attr($orig_value);676 $value = safecss_filter_attr($orig_value);
@@ -762,7 +762,7 @@
762 # "value"762 # "value"
763 {763 {
764 $thisval = $match[1];764 $thisval = $match[1];
765 if ( in_array($attrname, $uris) )765 if ( in_array(strtolower($attrname), $uris) )
766 $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);766 $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
767767
768 if(FALSE === array_key_exists($attrname, $attrarr)) {768 if(FALSE === array_key_exists($attrname, $attrarr)) {
@@ -778,7 +778,7 @@
778 # 'value'778 # 'value'
779 {779 {
780 $thisval = $match[1];780 $thisval = $match[1];
781 if ( in_array($attrname, $uris) )781 if ( in_array(strtolower($attrname), $uris) )
782 $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);782 $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
783783
784 if(FALSE === array_key_exists($attrname, $attrarr)) {784 if(FALSE === array_key_exists($attrname, $attrarr)) {
@@ -794,7 +794,7 @@
794 # value794 # value
795 {795 {
796 $thisval = $match[1];796 $thisval = $match[1];
797 if ( in_array($attrname, $uris) )797 if ( in_array(strtolower($attrname), $uris) )
798 $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);798 $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
799799
800 if(FALSE === array_key_exists($attrname, $attrarr)) {800 if(FALSE === array_key_exists($attrname, $attrarr)) {
@@ -1017,14 +1017,9 @@
1017 * @return string Sanitized content1017 * @return string Sanitized content
1018 */1018 */
1019function wp_kses_bad_protocol_once($string, $allowed_protocols) {1019function wp_kses_bad_protocol_once($string, $allowed_protocols) {
1020 global $_kses_allowed_protocols;1020 $string2 = preg_split( '/:|&#0*58;|&#x0*3a;/i', $string, 2 );
1021 $_kses_allowed_protocols = $allowed_protocols;1021 if ( isset($string2[1]) && ! preg_match('%/\?%', $string2[0]) )
10221022 $string = wp_kses_bad_protocol_once2( $string2[0], $allowed_protocols ) . trim( $string2[1] );
1023 $string2 = preg_split('/:|&#58;|&#x3a;/i', $string, 2);
1024 if ( isset($string2[1]) && !preg_match('%/\?%', $string2[0]) )
1025 $string = wp_kses_bad_protocol_once2($string2[0]) . trim($string2[1]);
1026 else
1027 $string = preg_replace_callback('/^((&[^;]*;|[\sA-Za-z0-9])*)'.'(:|&#58;|&#[Xx]3[Aa];)\s*/', 'wp_kses_bad_protocol_once2', $string);
10281023
1029 return $string;1024 return $string;
1030}1025}
@@ -1038,29 +1033,19 @@
1038 * @access private1033 * @access private
1039 * @since 1.0.01034 * @since 1.0.0
1040 *1035 *
1041 * @param mixed $matches string or preg_replace_callback() matches array to check for bad protocols1036 * @param string $string URI scheme to check against the whitelist
1037 * @param string $allowed_protocols Allowed protocols
1042 * @return string Sanitized content1038 * @return string Sanitized content
1043 */1039 */
1044function wp_kses_bad_protocol_once2($matches) {1040function wp_kses_bad_protocol_once2( $string, $allowed_protocols ) {
1045 global $_kses_allowed_protocols;
1046
1047 if ( is_array($matches) ) {
1048 if ( empty($matches[1]) )
1049 return '';
1050
1051 $string = $matches[1];
1052 } else {
1053 $string = $matches;
1054 }
1055
1056 $string2 = wp_kses_decode_entities($string);1041 $string2 = wp_kses_decode_entities($string);
1057 $string2 = preg_replace('/\s/', '', $string2);1042 $string2 = preg_replace('/\s/', '', $string2);
1058 $string2 = wp_kses_no_null($string2);1043 $string2 = wp_kses_no_null($string2);
1059 $string2 = strtolower($string2);1044 $string2 = strtolower($string2);
10601045
1061 $allowed = false;1046 $allowed = false;
1062 foreach ( (array) $_kses_allowed_protocols as $one_protocol)1047 foreach ( (array) $allowed_protocols as $one_protocol )
1063 if (strtolower($one_protocol) == $string2) {1048 if ( strtolower($one_protocol) == $string2 ) {
1064 $allowed = true;1049 $allowed = true;
1065 break;1050 break;
1066 }1051 }
10671052
=== modified file 'wp-includes/load.php'
--- wp-includes/load.php 2011-01-25 15:27:25 +0000
+++ wp-includes/load.php 2011-01-25 16:02:14 +0000
@@ -579,7 +579,7 @@
579 if ( defined( 'MULTISITE' ) )579 if ( defined( 'MULTISITE' ) )
580 return MULTISITE;580 return MULTISITE;
581581
582 if ( defined( 'VHOST' ) || defined( 'SUNRISE' ) )582 if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) )
583 return true;583 return true;
584584
585 return false;585 return false;
586586
=== modified file 'wp-includes/ms-files.php'
--- wp-includes/ms-files.php 2011-01-25 15:27:25 +0000
+++ wp-includes/ms-files.php 2011-01-25 16:02:14 +0000
@@ -29,14 +29,14 @@
29 die( '404 &#8212; File not found.' );29 die( '404 &#8212; File not found.' );
30}30}
3131
32$mime = wp_check_filetype( $_SERVER[ 'REQUEST_URI' ] );32$mime = wp_check_filetype( $file );
33if( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )33if( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
34 $mime[ 'type' ] = mime_content_type( $file );34 $mime[ 'type' ] = mime_content_type( $file );
3535
36if( $mime[ 'type' ] )36if( $mime[ 'type' ] )
37 $mimetype = $mime[ 'type' ];37 $mimetype = $mime[ 'type' ];
38else38else
39 $mimetype = 'image/' . substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 );39 $mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
4040
41header( 'Content-type: ' . $mimetype ); // always send this41header( 'Content-type: ' . $mimetype ); // always send this
42if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) )42if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) )
4343
=== modified file 'wp-includes/version.php'
--- wp-includes/version.php 2011-01-25 15:27:25 +0000
+++ wp-includes/version.php 2011-01-25 16:02:14 +0000
@@ -8,7 +8,7 @@
8 *8 *
9 * @global string $wp_version9 * @global string $wp_version
10 */10 */
11$wp_version = '3.0.1';11$wp_version = '3.0.4';
1212
13/**13/**
14 * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.14 * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
1515
=== modified file 'xmlrpc.php'
--- xmlrpc.php 2011-01-25 15:27:25 +0000
+++ xmlrpc.php 2011-01-25 16:02:14 +0000
@@ -1156,9 +1156,12 @@
11561156
1157 do_action('xmlrpc_call', 'wp.deleteComment');1157 do_action('xmlrpc_call', 'wp.deleteComment');
11581158
1159 if ( ! get_comment($comment_ID) )1159 if ( !$comment = get_comment( $comment_ID ) )
1160 return new IXR_Error( 404, __( 'Invalid comment ID.' ) );1160 return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
11611161
1162 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
1163 return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
1164
1162 return wp_delete_comment($comment_ID);1165 return wp_delete_comment($comment_ID);
1163 }1166 }
11641167
@@ -1185,11 +1188,14 @@
1185 if ( !current_user_can( 'moderate_comments' ) )1188 if ( !current_user_can( 'moderate_comments' ) )
1186 return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );1189 return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
11871190
1191 if ( !$comment = get_comment( $comment_ID ) )
1192 return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
1193
1194 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
1195 return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
1196
1188 do_action('xmlrpc_call', 'wp.editComment');1197 do_action('xmlrpc_call', 'wp.editComment');
11891198
1190 if ( ! get_comment($comment_ID) )
1191 return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
1192
1193 if ( isset($content_struct['status']) ) {1199 if ( isset($content_struct['status']) ) {
1194 $statuses = get_comment_statuses();1200 $statuses = get_comment_statuses();
1195 $statuses = array_keys($statuses);1201 $statuses = array_keys($statuses);
@@ -1417,7 +1423,7 @@
1417 if ( !$user = $this->login($username, $password) )1423 if ( !$user = $this->login($username, $password) )
1418 return $this->error;1424 return $this->error;
14191425
1420 if ( !current_user_can( 'edit_posts' ) )1426 if ( !current_user_can( 'edit_pages' ) )
1421 return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );1427 return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
14221428
1423 do_action('xmlrpc_call', 'wp.getPageStatusList');1429 do_action('xmlrpc_call', 'wp.getPageStatusList');
@@ -1957,7 +1963,7 @@
1957 if ( !$actual_post || $actual_post['post_type'] != 'post' )1963 if ( !$actual_post || $actual_post['post_type'] != 'post' )
1958 return new IXR_Error(404, __('Sorry, no such post.'));1964 return new IXR_Error(404, __('Sorry, no such post.'));
19591965
1960 if ( !current_user_can('edit_post', $post_ID) )1966 if ( !current_user_can('delete_post', $post_ID) )
1961 return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.'));1967 return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.'));
19621968
1963 $result = wp_delete_post($post_ID);1969 $result = wp_delete_post($post_ID);
@@ -1987,30 +1993,42 @@
1987 $username = $args[1];1993 $username = $args[1];
1988 $password = $args[2];1994 $password = $args[2];
1989 $content_struct = $args[3];1995 $content_struct = $args[3];
1990 $publish = $args[4];1996 $publish = isset( $args[4] ) ? $args[4] : 0;
19911997
1992 if ( !$user = $this->login($username, $password) )1998 if ( !$user = $this->login($username, $password) )
1993 return $this->error;1999 return $this->error;
19942000
1995 do_action('xmlrpc_call', 'metaWeblog.newPost');2001 do_action('xmlrpc_call', 'metaWeblog.newPost');
19962002
1997 $cap = ( $publish ) ? 'publish_posts' : 'edit_posts';
1998 $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
1999 $post_type = 'post';
2000 $page_template = '';2003 $page_template = '';
2001 if ( !empty( $content_struct['post_type'] ) ) {2004 if ( !empty( $content_struct['post_type'] ) ) {
2002 if ( $content_struct['post_type'] == 'page' ) {2005 if ( $content_struct['post_type'] == 'page' ) {
2003 $cap = ( $publish ) ? 'publish_pages' : 'edit_pages';2006 if ( $publish || 'publish' == $content_struct['page_status'])
2007 $cap = 'publish_pages';
2008 else
2009 $cap = 'edit_pages';
2004 $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' );2010 $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' );
2005 $post_type = 'page';2011 $post_type = 'page';
2006 if ( !empty( $content_struct['wp_page_template'] ) )2012 if ( !empty( $content_struct['wp_page_template'] ) )
2007 $page_template = $content_struct['wp_page_template'];2013 $page_template = $content_struct['wp_page_template'];
2008 } elseif ( $content_struct['post_type'] == 'post' ) {2014 } elseif ( $content_struct['post_type'] == 'post' ) {
2009 // This is the default, no changes needed2015 if ( $publish || 'publish' == $content_struct['post_status'])
2016 $cap = 'publish_posts';
2017 else
2018 $cap = 'edit_posts';
2019 $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
2020 $post_type = 'post';
2010 } else {2021 } else {
2011 // No other post_type values are allowed here2022 // No other post_type values are allowed here
2012 return new IXR_Error( 401, __( 'Invalid post type.' ) );2023 return new IXR_Error( 401, __( 'Invalid post type.' ) );
2013 }2024 }
2025 } else {
2026 if ( $publish || 'publish' == $content_struct['post_status'])
2027 $cap = 'publish_posts';
2028 else
2029 $cap = 'edit_posts';
2030 $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
2031 $post_type = 'post';
2014 }2032 }
20152033
2016 if ( !current_user_can( $cap ) )2034 if ( !current_user_can( $cap ) )
@@ -2275,17 +2293,32 @@
2275 $page_template = '';2293 $page_template = '';
2276 if ( !empty( $content_struct['post_type'] ) ) {2294 if ( !empty( $content_struct['post_type'] ) ) {
2277 if ( $content_struct['post_type'] == 'page' ) {2295 if ( $content_struct['post_type'] == 'page' ) {
2278 $cap = ( $publish ) ? 'publish_pages' : 'edit_pages';2296 if ( $publish || 'publish' == $content_struct['page_status'] )
2297 $cap = 'publish_pages';
2298 else
2299 $cap = 'edit_pages';
2279 $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' );2300 $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' );
2280 $post_type = 'page';2301 $post_type = 'page';
2281 if ( !empty( $content_struct['wp_page_template'] ) )2302 if ( !empty( $content_struct['wp_page_template'] ) )
2282 $page_template = $content_struct['wp_page_template'];2303 $page_template = $content_struct['wp_page_template'];
2283 } elseif ( $content_struct['post_type'] == 'post' ) {2304 } elseif ( $content_struct['post_type'] == 'post' ) {
2284 // This is the default, no changes needed2305 if ( $publish || 'publish' == $content_struct['post_status'] )
2306 $cap = 'publish_posts';
2307 else
2308 $cap = 'edit_posts';
2309 $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
2310 $post_type = 'post';
2285 } else {2311 } else {
2286 // No other post_type values are allowed here2312 // No other post_type values are allowed here
2287 return new IXR_Error( 401, __( 'Invalid post type.' ) );2313 return new IXR_Error( 401, __( 'Invalid post type.' ) );
2288 }2314 }
2315 } else {
2316 if ( $publish || 'publish' == $content_struct['post_status'] )
2317 $cap = 'publish_posts';
2318 else
2319 $cap = 'edit_posts';
2320 $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
2321 $post_type = 'post';
2289 }2322 }
22902323
2291 if ( !current_user_can( $cap ) )2324 if ( !current_user_can( $cap ) )
@@ -3101,7 +3134,7 @@
31013134
3102 do_action('xmlrpc_call', 'mt.publishPost');3135 do_action('xmlrpc_call', 'mt.publishPost');
31033136
3104 if ( !current_user_can('edit_post', $post_ID) )3137 if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) )
3105 return new IXR_Error(401, __('Sorry, you cannot edit this post.'));3138 return new IXR_Error(401, __('Sorry, you cannot edit this post.'));
31063139
3107 $postdata = wp_get_single_post($post_ID,ARRAY_A);3140 $postdata = wp_get_single_post($post_ID,ARRAY_A);
@@ -3339,4 +3372,4 @@
33393372
3340$wp_xmlrpc_server = new wp_xmlrpc_server();3373$wp_xmlrpc_server = new wp_xmlrpc_server();
3341$wp_xmlrpc_server->serve_request();3374$wp_xmlrpc_server->serve_request();
3342?>3375?>
3343\ No newline at end of file3376\ No newline at end of file

Subscribers

People subscribed via source and target branches