[phpmix-cvs] drupal/modules/akismet akismet_admin.inc, NONE, 1.1 akismet_cron.inc, NONE, 1.1 akisme
Status: Pre-Alpha
Brought to you by:
markus_petrux
From: <php...@li...> - 2006-06-18 11:04:33
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17111 Modified Files: akismet.module CHANGELOG.txt Added Files: akismet_admin.inc akismet_cron.inc Log Message: Code related to cron and the admin side of life has been externalized. Moderator queue has been rewritten. It's a bit more powerful now. CHANGELOG.txt has been updated. Index: CHANGELOG.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/CHANGELOG.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CHANGELOG.txt 12 Jun 2006 05:27:44 -0000 1.1 --- CHANGELOG.txt 18 Jun 2006 11:04:19 -0000 1.2 *************** *** 4,13 **** Akismet module in CVS ------------------------------------------------ - Prevent from sending e-mail notifications to the same user who has written the content. ! - Removing unnecessary code in hook_install. ! Akismet module v1.0.0 for Drupal 4.7, 2006-06-12 ------------------------------------------------ ! - initial release --- 4,17 ---- Akismet module in CVS ------------------------------------------------ + - Rewritten moderation queue. It is now a bit more powerful, allowing + operations against multiple items. + - Code related to admin and cron has been moved to external files + which are only loaded when needed. This is to minimize resource + consumption during normal site operation. - Prevent from sending e-mail notifications to the same user who has written the content. ! - Removed unnecessary code in hook_install. Akismet module v1.0.0 for Drupal 4.7, 2006-06-12 ------------------------------------------------ ! - Initial release --- NEW FILE: akismet_cron.inc --- <?php // $Id: akismet_cron.inc,v 1.1 2006/06/18 11:04:18 markus_petrux Exp $ /** * Shutdown function executed at cron time. */ function akismet_cron_shutdown() { watchdog('cron', t('Akismet cron started at %time.', array('%time' => format_date(time(), 'custom', 'H:i:s')))); // Update version information, if requested to. _akismet_check_version(); // Expired content spam that we have to remove from each content repository. $expired_content_spam = array('nids'=>array(), 'cids'=>array()); // Spam marks that we have to remove from the 'spam marks' table. $obsolete_spam_marks = array('nids'=>array(), 'cids'=>array()); // Retrieve the list of expired content spam, based on the age specified in the settings panel. $expire_spam_age = variable_get('akismet_remove_spam_age', 259200); if ($expire_spam_age > 0) { $result = db_query('SELECT content_type, content_id FROM {akismet_spam_marks} WHERE spam_created < %d', time() - $expire_spam_age); if (db_num_rows($result)) { while ($s = db_fetch_object($result)) { $key = ($s->content_type == 'node' ? 'nids' : 'cids'); $expired_content_spam[$key][] = $s->content_id; $obsolete_spam_marks[$key][] = $s->content_id; } } } // Deal with possible spam marks for content that have already been removed from database. // Note: when Drupal deletes a node, all its comments are deleted, but no hook is invoked, // so that may lead to orphans in the 'spam marks' table. // This is why this cron task is being more complex that it could really be. Anyway, these // queries shouldn't be too heavy. $result = db_query('SELECT s.content_id FROM {akismet_spam_marks} s LEFT JOIN {node} n ON s.content_id = n.nid WHERE s.content_type = \'node\' AND n.nid IS NULL'); if (db_num_rows($result)) { while ($s = db_fetch_object($result)) { if (!in_array($s->content_id, $obsolete_spam_marks['nids'])) { $obsolete_spam_marks['nids'][] = $s->content_id; } } } $result = db_query('SELECT s.content_id FROM {akismet_spam_marks} s LEFT JOIN {comments} c ON s.content_id = c.cid WHERE s.content_type = \'comment\' AND c.cid IS NULL'); if (db_num_rows($result)) { while ($s = db_fetch_object($result)) { if (!in_array($s->content_id, $obsolete_spam_marks['cids'])) { $obsolete_spam_marks['cids'][] = $s->content_id; } } } // From this point on is where we really will delete stuff from database. // Drupal cache will need to be cleared so anonymous users get updated views. $clear_cache = FALSE; // Remove expired spam from each content repository. $expired_nids_removed = count($expired_content_spam['nids']); $expired_cids_removed = count($expired_content_spam['cids']); if ($expired_nids_removed > 0) { $deleted_items = array(); $delete_count = 0; foreach ($expired_content_spam['nids'] as $nid) { if (akismet_content_delete('node', $nid)) { $deleted_items[] = $nid; $delete_count++; } } if ($delete_count > 0) { $message = t('Akismet housekeeping') .': '. format_plural($delete_count, '1 expired spam node removed from database', '%count expired spam nodes removed from database'). '<br />'.t('Node ID List: %nids', array('%nids' => implode(',', $deleted_items))); watchdog('cron', $message); $clear_cache = TRUE; } } if ($expired_cids_removed > 0) { $deleted_items = array(); $delete_count = 0; foreach ($expired_content_spam['cids'] as $cid) { if (akismet_content_delete('comment', $cid)) { $deleted_items[] = $cid; $delete_count++; } } if ($delete_count > 0) { $message = t('Akismet housekeeping') .': '. format_plural($delete_count, '1 expired spam comment removed from database', '%count expired spam comments removed from database'). '<br />'.t('Comment ID List: %cids', array('%cids' => implode(',', $deleted_items))); watchdog('cron', $message); $clear_cache = TRUE; } } // Remove obsolete spam marks from database. $spam_nids_removed = count($obsolete_spam_marks['nids']); $spam_cids_removed = count($obsolete_spam_marks['cids']); $spam_marks_removed = $spam_nids_removed + $spam_cids_removed; if ($spam_nids_removed > 0) { $spam_nids_list = implode(',', $obsolete_spam_marks['nids']); db_query('DELETE FROM {akismet_spam_marks} WHERE content_type = \'node\' AND content_id IN (%s)', $spam_nids_list); } if ($spam_cids_removed > 0) { $spam_cids_list = implode(',', $obsolete_spam_marks['cids']); db_query('DELETE FROM {akismet_spam_marks} WHERE content_type = \'comment\' AND content_id IN (%s)', $spam_cids_list); } if ($spam_marks_removed > 0) { $message = t('Akismet housekeeping') .': '. format_plural($spam_marks_removed, '1 spam mark removed from database', '%count spam marks removed from database'); if (isset($spam_nids_list)) { $message .= '<br />'. t('Node ID List: %nids', array('%nids' => $spam_nids_list)); } if (isset($spam_cids_list)) { $message .= '<br />'. t('Comment ID List: %cids', array('%cids' => $spam_cids_list)); } watchdog('cron', $message); $clear_cache = TRUE; } // If anything was removed, then clear Drupal cache. if ($clear_cache) { akismet_clear_cache(); } watchdog('cron', t('Akismet cron completed at %time.', array('%time' => format_date(time(), 'custom', 'H:i:s')))); } Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** akismet.module 12 Jun 2006 05:27:44 -0000 1.21 --- akismet.module 18 Jun 2006 11:04:17 -0000 1.22 *************** *** 4,9 **** /********************************************************************************\ ! @TODO: Enhance moderation queue with a form to allow multiple operations. ! @TODO: Review the help page. \********************************************************************************/ --- 4,9 ---- /********************************************************************************\ ! @TODO: Think about and implement some kind of anti-spambot measures. ! Maybe we do something to prevent (or minimize) Denial of Service (DoS). \********************************************************************************/ *************** *** 40,43 **** --- 40,59 ---- $output = t('Use <a href="%akismet">Akismet Service</a> to protect your site from being spammed.', array('%akismet' => 'http://akismet.com')); break; + case 'admin/help#akismet': + $output = t('<p>In order to use the <a href="%akismet">Akismet Service</a>, you need a <a href="%wpapikey">WordPress.com API key</a>. If you don\'t have one already, you can get it by simply signing up for a free account at <a href="%wordpress-com">wordpress.com</a>. Please, consult the <a href="%akismet-faq">Akismet FAQ</a> for further information.</p> + <p>The <em>akismet module</em> may automatically check for spam posted in content (nodes and/or comments) by any user, except node or comment administrators respectively. It is also possible, from the <a href="%access-control">access control</a> panel, to grant <em>%no-check-perm</em> permission to <em>user roles</em> of your choice.</p> + <p>Content marked as <em>spam</em> is still saved into database so it can be reviewed by content administrators. There is <a href="%akismet-settings">an option</a> that allows you to specify how long this information will be kept in the database. <em>Spam</em> older than a specified age will be automatically removed. Requires crontab.</p> + <p>Automatic spam detection can be enabled or disabled by content type and/or comments. In addition to this, the <em>akismet module</em> makes it easy for <em>content administrators</em> to manually <em>publish</em>/<em>unpublish</em> content and <em>mark</em>/<em>unmark</em> content as spam, from links available at the bottom of content.</p> + <p></p>', + array( + '%akismet' => 'http://akismet.com', + '%wpapikey' => 'http://wordpress.com/api-keys/', + '%wordpress-com' => 'http://wordpress.com', + '%akismet-faq' => 'http://akismet.com/faq/', + '%akismet-settings' => url('admin/settings/akismet'), + '%access-control' => url('admin/access'), + '%no-check-perm' => t('post with no akismet checking') + )); + break; case 'admin/help/akismet': case 'admin/settings/akismet': *************** *** 57,83 **** } break; ! case 'admin/akismet/nodes': ! $output = t('Below is the list of nodes awaiting for moderation. Click on the titles to see the content, the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the nodes upon your needs.'); ! $output .= '<br />'. t('<strong>Note:</strong> To interact fully with the <a href="%akismet">Akismet Service</a> you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use the submit <em>ham</em> operation rather than simply publishing content that was identified as spam (false positives). This is necessary in order to let Akismet learn from its mistakes. Thank you.', array('%akismet' => 'http://akismet.com')); ! break; ! case 'admin/akismet/comments': ! $output = t('Below is the list of comments awaiting for moderation. Click on the subjects to see the comments, the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the comments upon your needs.'); ! $output .= '<br />'. t('<strong>Note:</strong> To interact fully with the <a href="%akismet">Akismet Service</a> you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use the submit <em>ham</em> operation rather than simply publishing content that was identified as spam (false positives). This is necessary in order to let Akismet learn from its mistakes. Thank you.', array('%akismet' => 'http://akismet.com')); ! break; ! case 'admin/help#akismet': ! $output = t('<p>In order to use the <a href="%akismet">Akismet Service</a>, you need a <a href="%wpapikey">WordPress.com API key</a>. If you don\'t have one already, you can get it by simply signing up for a free account at <a href="%wordpress-com">wordpress.com</a>. Please, consult the <a href="%akismet-faq">Akismet FAQ</a> for further information.</p> ! <p>The <em>akismet module</em> may automatically check for spam posted in content (nodes and/or comments) by any user, except node or comment administrators respectively. It is also possible, from the <a href="%access-control">access control</a> panel, to grant <em>%no-check-perm</em> permission to <em>user roles</em> of your choice.</p> ! <p>Content marked as <em>spam</em> is still saved into database so it can be reviewed by content administrators. There is <a href="%akismet-settings">an option</a> that allows you to specify how long this information will be kept in the database. <em>Spam</em> older than a specified age will be automatically removed. Requires crontab.</p> ! <p>Automatic spam detection can be enabled or disabled by content type and/or comments. In addition to this, the <em>akismet module</em> makes it easy for <em>content administrators</em> to manually <em>publish</em>/<em>unpublish</em> content and <em>mark</em>/<em>unmark</em> content as spam, from links available at the bottom of content.</p> ! <p></p>', ! array( ! '%akismet' => 'http://akismet.com', ! '%wpapikey' => 'http://wordpress.com/api-keys/', ! '%wordpress-com' => 'http://wordpress.com', ! '%akismet-faq' => 'http://akismet.com/faq/', ! '%akismet-settings' => url('admin/settings/akismet'), ! '%access-control' => url('admin/access'), ! '%no-check-perm' => t('post with no akismet checking') ! )); break; } --- 73,106 ---- } break; ! default: ! if (arg(0) == 'admin' && arg(1) == 'akismet' && !isset($_POST['edit'])) { ! if (arg(2) == 'nodes') { ! if (arg(3) == 'unpublished') { ! $output = t('Below is the list of <strong>unpublished nodes</strong> awaiting for moderation.'); ! } ! else if (arg(3) == 'published') { ! $output = t('Below is the list of <strong>published nodes</strong>.'); ! } ! else { // spam ! $output = t('Below is the list of <strong>nodes marked as spam</strong> awaiting for moderation.'); ! } ! $output .= ' '. t('Click on the titles to see the content of the nodes or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the nodes upon your needs.'); ! } ! else if (arg(2) == 'comments') { ! if (arg(3) == 'unpublished') { ! $output = t('Below is the list of <strong>unpublished comments</strong> awaiting for moderation.'); ! } ! else if (arg(3) == 'published') { ! $output = t('Below is the list of <strong>published comments</strong>.'); ! } ! else { // spam ! $output = t('Below is the list of <strong>comments marked as spam</strong> awaiting for moderation.'); ! } ! $output .= ' '. t('Click on the subjects to see the comments or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the comments upon your needs.'); ! } ! if (!empty($output)) { ! $output .= '<br />'. t('<strong>Note:</strong> To interact fully with the <a href="%akismet">Akismet Service</a> you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use the submit <em>ham</em> operation rather than simply publishing content that was identified as spam (false positives). This is necessary in order to let Akismet learn from its mistakes. Thank you.', array('%akismet' => 'http://akismet.com')); ! } ! } break; } *************** *** 104,225 **** */ function akismet_cron() { register_shutdown_function('akismet_cron_shutdown'); } - function akismet_cron_shutdown() { - watchdog('cron', t('Akismet cron started at %time.', array('%time' => format_date(time(), 'custom', 'H:i:s')))); - - // Update version information, if requested to. - _akismet_check_version(); - - // Expired content spam that we have to remove from each content repository. - $expired_content_spam = array('nids'=>array(), 'cids'=>array()); - // Spam marks that we have to remove from the 'spam marks' table. - $obsolete_spam_marks = array('nids'=>array(), 'cids'=>array()); - - // Retrieve the list of expired content spam, based on the age specified in the settings panel. - $expire_spam_age = variable_get('akismet_remove_spam_age', 259200); - if ($expire_spam_age > 0) { - $result = db_query('SELECT content_type, content_id FROM {akismet_spam_marks} WHERE spam_created < %d', time() - $expire_spam_age); - if (db_num_rows($result)) { - while ($s = db_fetch_object($result)) { - $key = ($s->content_type == 'node' ? 'nids' : 'cids'); - $expired_content_spam[$key][] = $s->content_id; - $obsolete_spam_marks[$key][] = $s->content_id; - } - } - } - - // Deal with possible spam marks for content that have already been removed from database. - // Note: when Drupal deletes a node, all its comments are deleted, but no hook is invoked, - // so that may lead to orphans in the 'spam marks' table. - // This is why this cron task is being more complex that it could really be. Anyway, these - // queries shouldn't be too heavy. - $result = db_query('SELECT s.content_id FROM {akismet_spam_marks} s LEFT JOIN {node} n ON s.content_id = n.nid WHERE s.content_type = \'node\' AND n.nid IS NULL'); - if (db_num_rows($result)) { - while ($s = db_fetch_object($result)) { - if (!in_array($s->content_id, $obsolete_spam_marks['nids'])) { - $obsolete_spam_marks['nids'][] = $s->content_id; - } - } - } - $result = db_query('SELECT s.content_id FROM {akismet_spam_marks} s LEFT JOIN {comments} c ON s.content_id = c.cid WHERE s.content_type = \'comment\' AND c.cid IS NULL'); - if (db_num_rows($result)) { - while ($s = db_fetch_object($result)) { - if (!in_array($s->content_id, $obsolete_spam_marks['cids'])) { - $obsolete_spam_marks['cids'][] = $s->content_id; - } - } - } - - // From this point on is where we really will delete stuff from database. - // Drupal cache will need to be cleared so anonymous users get updated views. - $clear_cache = FALSE; - - // Remove expired spam from each content repository. - $expired_nids_removed = count($expired_content_spam['nids']); - $expired_cids_removed = count($expired_content_spam['cids']); - if ($expired_nids_removed > 0) { - $deleted_items = array(); - $delete_count = 0; - foreach ($expired_content_spam['nids'] as $nid) { - if (akismet_content_delete('node', $nid)) { - $deleted_items[] = $nid; - $delete_count++; - } - } - if ($delete_count > 0) { - $message = t('Akismet housekeeping') .': '. format_plural($delete_count, '1 expired spam node removed from database', '%count expired spam nodes removed from database'). - '<br />'.t('Node ID List: %nids', array('%nids' => implode(',', $deleted_items))); - watchdog('cron', $message); - $clear_cache = TRUE; - } - } - if ($expired_cids_removed > 0) { - $deleted_items = array(); - $delete_count = 0; - foreach ($expired_content_spam['cids'] as $cid) { - if (akismet_content_delete('comment', $cid)) { - $deleted_items[] = $cid; - $delete_count++; - } - } - if ($delete_count > 0) { - $message = t('Akismet housekeeping') .': '. format_plural($delete_count, '1 expired spam comment removed from database', '%count expired spam comments removed from database'). - '<br />'.t('Comment ID List: %cids', array('%cids' => implode(',', $deleted_items))); - watchdog('cron', $message); - $clear_cache = TRUE; - } - } - - // Remove obsolete spam marks from database. - $spam_nids_removed = count($obsolete_spam_marks['nids']); - $spam_cids_removed = count($obsolete_spam_marks['cids']); - $spam_marks_removed = $spam_nids_removed + $spam_cids_removed; - if ($spam_nids_removed > 0) { - $spam_nids_list = implode(',', $obsolete_spam_marks['nids']); - db_query('DELETE FROM {akismet_spam_marks} WHERE content_type = \'node\' AND content_id IN (%s)', $spam_nids_list); - } - if ($spam_cids_removed > 0) { - $spam_cids_list = implode(',', $obsolete_spam_marks['cids']); - db_query('DELETE FROM {akismet_spam_marks} WHERE content_type = \'comment\' AND content_id IN (%s)', $spam_cids_list); - } - if ($spam_marks_removed > 0) { - $message = t('Akismet housekeeping') .': '. format_plural($spam_marks_removed, '1 spam mark removed from database', '%count spam marks removed from database'); - if (isset($spam_nids_list)) { - $message .= '<br />'. t('Node ID List: %nids', array('%nids' => $spam_nids_list)); - } - if (isset($spam_cids_list)) { - $message .= '<br />'. t('Comment ID List: %cids', array('%cids' => $spam_cids_list)); - } - watchdog('cron', $message); - $clear_cache = TRUE; - } - - // If anything was removed, then clear Drupal cache. - if ($clear_cache) { - akismet_clear_cache(); - } - watchdog('cron', t('Akismet cron completed at %time.', array('%time' => format_date(time(), 'custom', 'H:i:s')))); - } /** --- 127,133 ---- */ function akismet_cron() { + require_once('./'. drupal_get_path('module', 'akismet') . '/akismet_cron.inc'); register_shutdown_function('akismet_cron_shutdown'); } /** *************** *** 227,451 **** */ function akismet_settings() { ! $form = array(); ! ! $enable_options = array('1' => t('Enabled'), '0' => t('Disabled')); ! ! $akismet_wpapikey = variable_get('akismet_wpapikey', ''); ! if (empty($akismet_wpapikey)) { ! $akismet_collapsed = FALSE; ! } ! else { ! $akismet_collapsed = $is_valid = (akismet_api_cmd_verify_key($akismet_wpapikey) == AKISMET_API_RESULT_SUCCESS ? TRUE : FALSE); ! } ! if ($akismet_collapsed) { ! $akismet_collapsed = variable_get('akismet_connection_enabled', 1); ! } ! ! $form['service'] = array( ! '#type' => 'fieldset', '#title' => t('Akismet Service Options'), ! '#collapsible' => TRUE, '#collapsed' => $akismet_collapsed ! ); ! $form['service']['akismet_wpapikey'] = array( ! '#type' => 'textfield', '#title' => t('WordPress.com API key'), ! '#size' => 30, '#maxlength' => 60, ! '#default_value' => $akismet_wpapikey, ! '#description' => t('Please, enter here your <a href="%wpapikey">WordPress.com API key</a>. If you don\'t have one already, you can get it by simply signing up for a free account at <a href="%wordpress-com">WordPress.com</a>. Note that this information is required in order to use the <a href="%akismet">Akismet Service</a>. Please, consult the <a href="%akismet-faq">Akismet FAQ</a> for further information.', ! array( ! '%wpapikey' => 'http://wordpress.com/api-keys/', ! '%wordpress-com' => 'http://wordpress.com', ! '%akismet' => 'http://akismet.com', ! '%akismet-faq' => 'http://akismet.com/faq/' ! )) ! ); ! if (!empty($akismet_wpapikey) && !$is_valid) { ! $form['service']['akismet_wpapikey']['#description'] .= '<div class="marker">'. t('<strong>WARNING: Your API Key doesn\'t seem to be valid!</strong>') .'</div>'; ! } ! $form['service']['akismet_connection_enabled'] = array( ! '#type' => 'radios', '#title' => t('Akismet connections'), ! '#options' => $enable_options, ! '#default_value' => variable_get('akismet_connection_enabled', 1), ! '#description' => t('<strong>This option must be enabled in order to perform real requests to the <a href="%akismet">Akismet Service</a>.</strong> You may want to disable this option for testing purposes, however. In this case, the <em>akismet module</em> will operate as normal, except sending real requests to the <a href="%akismet">Akismet Service</a>. ie. no automatic spam detection will be performed and no remote requests will be made when content is manually <em>marked</em>/<em>unmarked</em> as spam.<br />Note: regardless of this option, the <em>akismet module</em> will still connect, from this panel, to validate your <a href="%wpapikey">WordPress.com API key</a>, if specified.', ! array( ! '%akismet' => 'http://akismet.com', ! '%wpapikey' => 'http://wordpress.com/api-keys/' ! )) ! ); ! $timeout_options = array(); ! for ($n = 1; $n <= 30; $n++) { ! $timeout_options[$n] = $n; ! } ! $form['service']['akismet_connection_timeout'] = array( ! '#type' => 'select', '#title' => t('Connection timeout'), ! '#default_value' => variable_get('akismet_connection_timeout', 10), ! '#options' => $timeout_options, ! '#description' => t('This option allows you to specify the connection timeout in seconds that is used for real time Akismet connections.') ! ); ! ! $form['general'] = array( ! '#type' => 'fieldset', '#title' => t('General Options'), ! '#collapsible' => TRUE, '#collapsed' => $akismet_collapsed ! ); ! $age_options = drupal_map_assoc(array(0, 86400, 259200, 604800, 1209600), 'format_interval'); ! $age_options[0] = t('never'); ! $age_options[2592000] = t('1 month'); ! $form['general']['akismet_version_check_age'] = array( ! '#type' => 'select', '#title' => t('Check for updates every'), ! '#default_value' => variable_get('akismet_version_check_age', 604800), ! '#options' => $age_options, ! '#description' => t('This option allows you to customize how often the akismet module will check for updates. To disable automatic version checks you can set this option to <em>none</em>. This process is automated through cron task, but it may also be triggered when module version is displayed on top of this panel.') ! ); ! $age_options = drupal_map_assoc(array(0, 3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 1814400), 'format_interval'); ! $age_options[0] = t('never'); ! $age_options[2592000] = t('1 month'); ! $age_options[5184000] = t('2 months'); ! $age_options[7776000] = t('3 months'); ! $age_options[10368000] = t('4 months'); ! $age_options[15768000] = t('6 months'); ! $age_options[31536000] = t('1 year'); ! $form['general']['akismet_remove_spam_age'] = array( ! '#type' => 'select', '#title' => t('Remove spam older than'), ! '#default_value' => variable_get('akismet_remove_spam_age', 259200), ! '#options' => $age_options, ! '#description' => t('Content marked as <em>spam</em> is still saved into database so it can be reviewed by content administrators. This option allows you to specify how long this information will be kept in the database. <em>Spam</em> older than the age specified here will be automatically removed. Requires crontab.') ! ); ! $form['general']['akismet_records_per_page'] = array( ! '#type' => 'select', '#title' => t('Records per page'), ! '#default_value' => variable_get('akismet_records_per_page', 50), ! '#options' => drupal_map_assoc(array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200)), ! '#description' => t('The maximum number of records per page on moderation queue.') ! ); ! $form['general']['akismet_blocks_counter'] = array( ! '#type' => 'select', '#title' => t('Number of blocks'), ! '#default_value' => variable_get('akismet_blocks_counter', 1), ! '#options' => array(0=>t('none'), 1=>1, 2=>2, 3=>3, 4=>4, 5=>5), ! '#description' => t('The akismet module may generate a number of blocks for you to display the current spam counter anywhere on your site. The number of blocks is variable to help you keep your <a href="%admin-block">blocks administration panel</a> as clean as possible. This option allows you to specify how many blocks you wish to use. If you do not plan to show the spam counter to your visitors, set this option to <em>none</em>.', ! array( ! '%admin-block' => url('admin/block') ! )) ! ); ! $form['general']['akismet_email_enabled'] = array( ! '#type' => 'radios', '#title' => t('E-mail notifications'), ! '#options' => $enable_options, ! '#default_value' => variable_get('akismet_email_enabled', 1), ! '#description' => t('Use this option to <em>enable</em> or <em>disable</em> e-mail notifications to content moderators. If enabled, users with proper permissions are allowed to set, from their user profiles, whether they wish to receive e-mail notications for all new (or updated) posts, just for content needing approval or no notifications at all. Users are notified about content types they are allowed to moderate only.') ! ); ! ! $form['node_options'] = array( ! '#type' => 'fieldset', '#title' => t('Node Options'), ! '#collapsible' => TRUE, '#collapsed' => TRUE ! ); ! $form['node_options']['akismet_check_nodetypes'] = array( ! '#type' => 'checkboxes', '#title' => t('Check for spam in these node types'), ! '#options' => node_get_types(), ! '#default_value' => variable_get('akismet_check_nodetypes', NULL), ! '#description' => t('Use this option to <em>enable</em> or <em>disable</em> spam check for nodes of types specified here. When this option is enabled, a request will be sent to the <a href="%akismet">Akismet Service</a>, in real time. If the <a href="%akismet">Akismet Service</a> was down, nodes would simply be queued for manual moderation. Users with <a href="%admin-access">%admin-nodes</a> permission and <a href="%admin-access">spam moderators</a> are exempt from this check.', ! array( ! '%akismet' => 'http://akismet.com', ! '%admin-nodes' => t('administer nodes'), ! '%admin-access' => url('admin/access') ! )) ! ); ! $form['node_options']['akismet_node_publish_links'] = array( ! '#type' => 'radios', '#title' => t('Show publish/unpublish links'), ! '#options' => $enable_options, ! '#default_value' => variable_get('akismet_node_publish_links', 0), ! '#description' => t('Use this option to <em>enable</em> or <em>disable</em> links for <em>publish</em>/<em>unpublish</em> operations in nodes. If enabled, these links will only be displayed to <a href="%admin-access">spam moderators</a> and users with <a href="%admin-access">%admin-nodes</a> permission.', ! array( ! '%admin-nodes' => t('administer nodes'), ! '%admin-access' => url('admin/access') ! )) ! ); ! $form['node_options']['akismet_node_spam_links'] = array( ! '#type' => 'radios', '#title' => t('Show submit spam/ham links'), ! '#options' => $enable_options, ! '#default_value' => variable_get('akismet_node_spam_links', 0), ! '#description' => t('Use this option to <em>enable</em> or <em>disable</em> links for <em>submit spam</em>/<em>ham</em> operations in nodes. If enabled, these links will only be displayed to <a href="%admin-access">spam moderators</a> and users with <a href="%admin-access">%admin-nodes</a> permission.', ! array( ! '%admin-nodes' => t('administer nodes'), ! '%admin-access' => url('admin/access') ! )) ! .'<br />'. t('<strong>Note:</strong> To interact fully with the <a href="%akismet">Akismet Service</a> you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use these links to submit missed spam and false positives (ham), otherwise Akismet will never learn from its mistakes. Thank you.', ! array( ! '%akismet' => 'http://akismet.com' ! )) ! ); ! ! if (module_exist('comment')) { ! $form['comment_options'] = array( ! '#type' => 'fieldset', '#title' => t('Comment Options'), ! '#collapsible' => TRUE, '#collapsed' => TRUE ! ); ! $form['comment_options']['akismet_check_comments'] = array( ! '#type' => 'radios', '#title' => t('Check for spam in comments'), ! '#options' => $enable_options, ! '#default_value' => variable_get('akismet_check_comments', 1), ! '#description' => t('Use this option to <em>enable</em> or <em>disable</em> spam check for comments. When this option is enabled, a request will be sent to the <a href="%akismet">Akismet Service</a>, in real time. If the <a href="%akismet">Akismet Service</a> was down, comments would simply be queued for manual moderation. Users with <a href="%admin-access">%admin-comments</a> permission and <a href="%admin-access">spam moderators</a> are exempt from this check.', ! array( ! '%akismet' => 'http://akismet.com', ! '%admin-comments' => t('administer comments'), ! '%admin-access' => url('admin/access') ! )) ! ); ! $form['comment_options']['akismet_comment_publish_links'] = array( ! '#type' => 'radios', '#title' => t('Show publish/unpublish links'), ! '#options' => $enable_options, ! '#default_value' => variable_get('akismet_comment_publish_links', 1), ! '#description' => t('Use this option to <em>enable</em> or <em>disable</em> links for <em>publish</em>/<em>unpublish</em> operations in comments. If enabled, these links will only be displayed to <a href="%admin-access">spam moderators</a> and users with <a href="%admin-access">%admin-comments</a> permission.', ! array( ! '%admin-comments' => t('administer comments'), ! '%admin-access' => url('admin/access') ! )) ! ); ! $form['comment_options']['akismet_comment_spam_links'] = array( ! '#type' => 'radios', '#title' => t('Show submit spam/ham links'), ! '#options' => $enable_options, ! '#default_value' => variable_get('akismet_comment_spam_links', 1), ! '#description' => t('Use this option to <em>enable</em> or <em>disable</em> links for <em>submit spam</em>/<em>ham</em> operations in comments. If enabled, these links will only be displayed to <a href="%admin-access">spam moderators</a> and users with <a href="%admin-access">%admin-comments</a> permission.', ! array( ! '%admin-comments' => t('administer comments'), ! '%admin-access' => url('admin/access') ! )) ! .'<br />'. t('<strong>Note:</strong> To interact fully with the <a href="%akismet">Akismet Service</a> you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use these links to submit missed spam and false positives (ham), otherwise Akismet will never learn from its mistakes. Thank you.', ! array( ! '%akismet' => 'http://akismet.com' ! )) ! ); ! } ! ! $date_formats = array( ! 'F j, Y', 'j F, Y', 'Y, F j', ! 'M j, Y', 'j M, Y', 'Y, M j', ! 'Y/m/d', 'm/d/Y', 'd/m/Y', ! 'Y-m-d', 'm-d-Y', 'd-m-Y' ! ); ! $date_options = array(); ! $now = time(); ! foreach ($date_formats as $format) { ! $date_options[$format] = format_date($now, 'custom', $format); ! } ! ! $form['counter_options'] = array( ! '#type' => 'fieldset', '#title' => t('Spam Counter Options'), ! '#collapsible' => TRUE, '#collapsed' => TRUE ! ); ! $form['counter_options']['akismet_counter_spam'] = array( ! '#type' => 'textfield', '#title' => t('Spam counter'), ! '#default_value' => akismet_get_spam_counter(), ! '#size' => 10, '#maxlength' => 10, ! '#description' => t('This counter is incremented for every spam caught by Akismet.') ! ); ! $form['counter_options']['akismet_counter_since'] = array( ! '#type' => 'date', '#title' => t('Counting since'), ! '#default_value' => variable_get('akismet_counter_since', array('day' => date('j'), 'month' => date('n'), 'year' => date('Y'))), ! '#description' => t('This is the date that will tell your visitors when your Akismet spam counter started to increment.') ! ); ! $form['counter_options']['akismet_counter_date_format'] = array( ! '#type' => 'select', '#title' => t('Date format'), ! '#default_value' => variable_get('akismet_counter_date_format', $date_formats[0]), ! '#options' => $date_options, ! '#description' => t('Date format used to render the <em>Counting since</em> date.') ! ); ! ! return $form; } --- 135,140 ---- */ function akismet_settings() { ! require_once('./'. drupal_get_path('module', 'akismet') . '/akismet_admin.inc'); ! return _akismet_settings_form(); } *************** *** 455,458 **** --- 144,148 ---- function akismet_menu($may_cache) { $items = array(); + if ($may_cache) { // Changes in content types force the menu to be rebuilt, *************** *** 471,478 **** --- 161,180 ---- $items[] = array('path' => 'admin/akismet/nodes', 'title' => t('nodes'), 'type' => MENU_LOCAL_TASK, 'weight' => 1); + $items[] = array('path' => 'admin/akismet/nodes/spam', 'title' => t('spam'), + 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 0); + $items[] = array('path' => 'admin/akismet/nodes/unpublished', 'title' => t('unpublished nodes'), + 'type' => MENU_LOCAL_TASK, 'weight' => 1); + $items[] = array('path' => 'admin/akismet/nodes/published', 'title' => t('published nodes'), + 'type' => MENU_LOCAL_TASK, 'weight' => 2); } if (isset($moderator_types['comments'])) { $items[] = array('path' => 'admin/akismet/comments', 'title' => t('comments'), 'type' => MENU_LOCAL_TASK, 'weight' => 2); + $items[] = array('path' => 'admin/akismet/comments/spam', 'title' => t('spam'), + 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 0); + $items[] = array('path' => 'admin/akismet/comments/unpublished', 'title' => t('unpublished comments'), + 'type' => MENU_LOCAL_TASK, 'weight' => 1); + $items[] = array('path' => 'admin/akismet/comments/published', 'title' => t('published comments'), + 'type' => MENU_LOCAL_TASK, 'weight' => 2); } } *************** *** 501,505 **** --- 203,214 ---- } } + else { + // Load the administration specific code? + if (arg(0) == 'admin' && arg(1) == 'akismet') { + require_once('./'. drupal_get_path('module', 'akismet') . '/akismet_admin.inc'); + } + } } + return $items; } *************** *** 689,692 **** --- 398,405 ---- else { watchdog('content', t('Spam detected by Akismet in %content-type-name: %title', array('%content-type-name' => $content_type_name, '%title' => theme('placeholder', $node->title))), WATCHDOG_WARNING, l(t('view'), 'node/'. $node->nid)); + // If requested to, generate a delay so the spammer has to wait for a while. + if (($seconds = variable_get('akismet_spambot_delay', 60)) > 0) { + sleep($seconds); + } } } *************** *** 812,815 **** --- 525,532 ---- else { watchdog('content', t('Spam detected by Akismet in comment: %subject', array('%subject' => theme('placeholder', $comment->subject))), WATCHDOG_WARNING, l(t('view'), 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid)); + // If requested to, generate a delay so the spammer has to wait for a while. + if (($seconds = variable_get('akismet_spambot_delay', 60)) > 0) { + sleep($seconds); + } } } *************** *** 822,929 **** /** - * Menu callback; Moderation queue. - * - * @param string Operation code: overview (default), nodes, comments. - */ - function akismet_callback_queue($op = '') { - // Compute exactly what the current user is allowed to moderate. - $moderator_types = akismet_get_moderator_types(); - $moderator_types_count = count($moderator_types); - $allowed_comments = (isset($moderator_types['comments']) ? TRUE : FALSE); - $allowed_nodes = $moderator_types; - if ($allowed_comments) { - unset($allowed_nodes['comments']); - } - $allowed_nodes_count = count($allowed_nodes); - - if ($allowed_nodes_count > 0) { - $sql_nodetypes = array(); - foreach ($allowed_nodes as $type => $name) { - $sql_nodetypes[] = '\''. $type .'\''; - } - $sql_nodetypes = implode(', ', $sql_nodetypes); - $sql_nodes = 'SELECT n.*, s.spam_created FROM {akismet_spam_marks} s INNER JOIN {node} n ON s.content_id = n.nid WHERE s.content_type = \'node\' AND (n.type IN ('. $sql_nodetypes .') OR n.status = 0)'; - $sql_nodes_cnt = 'SELECT COUNT(*) AS cnt FROM {akismet_spam_marks} s INNER JOIN {node} n ON s.content_id = n.nid WHERE s.content_type = \'node\' AND (n.type IN ('. $sql_nodetypes .') OR n.status = 0)'; - } - if ($allowed_comments) { - $sql_comments = 'SELECT c.*, s.spam_created FROM {akismet_spam_marks} s INNER JOIN {comments} c ON s.content_id = c.cid WHERE s.content_type = \'comment\' OR c.status = '. COMMENT_NOT_PUBLISHED; - $sql_comments_cnt = 'SELECT COUNT(*) AS cnt FROM {akismet_spam_marks} s INNER JOIN {comments} c ON s.content_id = c.cid WHERE s.content_type = \'comment\' OR c.status = '. COMMENT_NOT_PUBLISHED; - } - - if (empty($op) || $op == 'overview') { - $items = array(); - if ($allowed_nodes_count > 0) { - $count = db_result(db_query(db_rewrite_sql($sql_nodes_cnt))); - $label = ($count > 0 ? l(t('Nodes'), 'admin/akismet/nodes') : t('Nodes')); - $items[] = '<p><strong>'. $label .': '. $count .'</strong></p>'; - } - if ($allowed_comments) { - $count = db_result(db_query(db_rewrite_sql($sql_comments_cnt))); - $label = ($count > 0 ? l(t('Comments'), 'admin/akismet/comments') : t('Comments')); - $items[] = '<p><strong>'. $label .': '. $count .'</strong></p>'; - } - return '<h3>'. t('Items in moderation queue:') .'</h3>'. theme('item_list', $items); - } - - if ($op == 'nodes') { - $sql = $sql_nodes; - $sql_count = $sql_nodes_cnt; - $headers = array( - array('data' => t('Title'), 'field' => 'title'), - array('data' => t('Type'), 'field' => 'type'), - array('data' => t('Author'), 'field' => 'name'), - array('data' => t('Status'), 'field' => 'status'), - array('data' => t('Created'), 'field' => 'spam_created', 'sort' => 'desc') - ); - } - else { // comments - $sql = $sql_comments; - $sql_count = $sql_comments_cnt; - $headers = array( - array('data' => t('Subject'), 'field' => 'subject'), - array('data' => t('Author'), 'field' => 'name'), - array('data' => t('Status'), 'field' => 'status'), - array('data' => t('Created'), 'field' => 'spam_created', 'sort' => 'desc') - ); - } - - $records_per_page = variable_get('akismet_records_per_page', 50); - $result = pager_query($sql . tablesort_sql($headers), $records_per_page, 0, $sql_cnt); - $rows = array(); - while ($content = db_fetch_object($result)) { - if ($op == 'nodes') { - $rows[] = array( - l($content->title, 'node/'. $content->nid, array('title' => truncate_utf8($content->body, 128))) .' '. theme('mark', node_mark($content->nid, $content->changed)), - node_get_name($content), - theme('username', $content), - ($node->status ? t('published') : t('not published')), - t('%time ago', array('%time' => format_interval(time() - $content->spam_created))) - ); - } - else { // comments - $content->name = $content->uid ? $content->registered_name : $content->name; - $rows[] = array( - l($content->subject, 'node/'. $content->nid, array('title' => truncate_utf8($content->comment, 128)), NULL, 'comment-'. $content->cid) .' '. theme('mark', node_mark($content->nid, $content->timestamp)), - theme('username', $content), - ($content->status == COMMENT_PUBLISHED ? t('published') : t('not published')), - t('%time ago', array('%time' => format_interval(time() - $content->spam_created))) - ); - } - } - - if (count($rows) <= 0) { - if ($op == 'nodes') { - drupal_set_message(t('There are no nodes in the moderation queue.')); - } - else { // comments - drupal_set_message(t('There are no comments in the moderation queue.')); - } - return ''; - } - - return theme('table', $headers, $rows) . theme('pager', NULL, $records_per_page, 0); - } - - /** * Check if specified content is marked as spam. * --- 539,542 ---- --- NEW FILE: akismet_admin.inc --- <?php // $Id: akismet_admin.inc,v 1.1 2006/06/18 11:04:17 markus_petrux Exp $ /** * Build the akismet settings form. */ function _akismet_settings_form() { $form = array(); $enable_options = array('1' => t('Enabled'), '0' => t('Disabled')); $akismet_wpapikey = variable_get('akismet_wpapikey', ''); if (empty($akismet_wpapikey)) { $akismet_collapsed = FALSE; } else { $akismet_collapsed = $is_valid = (akismet_api_cmd_verify_key($akismet_wpapikey) == AKISMET_API_RESULT_SUCCESS ? TRUE : FALSE); } if ($akismet_collapsed) { $akismet_collapsed = variable_get('akismet_connection_enabled', 1); } $form['service'] = array( '#type' => 'fieldset', '#title' => t('Akismet Service Options'), '#collapsible' => TRUE, '#collapsed' => $akismet_collapsed ); $form['service']['akismet_wpapikey'] = array( '#type' => 'textfield', '#title' => t('WordPress.com API key'), '#size' => 30, '#maxlength' => 60, '#default_value' => $akismet_wpapikey, '#description' => t('Please, enter here your <a href="%wpapikey">WordPress.com API key</a>. If you don\'t have one already, you can get it by simply signing up for a free account at <a href="%wordpress-com">WordPress.com</a>. Note that this information is required in order to use the <a href="%akismet">Akismet Service</a>. Please, consult the <a href="%akismet-faq">Akismet FAQ</a> for further information.', array( '%wpapikey' => 'http://wordpress.com/api-keys/', '%wordpress-com' => 'http://wordpress.com', '%akismet' => 'http://akismet.com', '%akismet-faq' => 'http://akismet.com/faq/' )) ); if (!empty($akismet_wpapikey) && !$is_valid) { $form['service']['akismet_wpapikey']['#description'] .= '<div class="marker">'. t('<strong>WARNING: Your API Key doesn\'t seem to be valid!</strong>') .'</div>'; } $form['service']['akismet_connection_enabled'] = array( '#type' => 'radios', '#title' => t('Akismet connections'), '#options' => $enable_options, '#default_value' => variable_get('akismet_connection_enabled', 1), '#description' => t('<strong>This option must be enabled in order to perform real requests to the <a href="%akismet">Akismet Service</a>.</strong> You may want to disable this option for testing purposes, however. In this case, the <em>akismet module</em> will operate as normal, except sending real requests to the <a href="%akismet">Akismet Service</a>. ie. no automatic spam detection will be performed and no remote requests will be made when content is manually <em>marked</em>/<em>unmarked</em> as spam.<br />Note: regardless of this option, the <em>akismet module</em> will still connect, from this panel, to validate your <a href="%wpapikey">WordPress.com API key</a>, if specified.', array( '%akismet' => 'http://akismet.com', '%wpapikey' => 'http://wordpress.com/api-keys/' )) ); $timeout_options = array(); for ($n = 1; $n <= 30; $n++) { $timeout_options[$n] = $n; } $form['service']['akismet_connection_timeout'] = array( '#type' => 'select', '#title' => t('Connection timeout'), '#default_value' => variable_get('akismet_connection_timeout', 10), '#options' => $timeout_options, '#description' => t('This option allows you to specify the connection timeout in seconds that is used for real time Akismet connections.') ); $form['general'] = array( '#type' => 'fieldset', '#title' => t('General Options'), '#collapsible' => TRUE, '#collapsed' => $akismet_collapsed ); $age_options = drupal_map_assoc(array(0, 86400, 259200, 604800, 1209600), 'format_interval'); $age_options[0] = t('never'); $age_options[2592000] = t('1 month'); $form['general']['akismet_version_check_age'] = array( '#type' => 'select', '#title' => t('Check for updates every'), '#default_value' => variable_get('akismet_version_check_age', 604800), '#options' => $age_options, '#description' => t('This option allows you to customize how often the akismet module will check for updates. To disable automatic version checks you can set this option to <em>none</em>. This process is automated through cron task, but it may also be triggered when module version is displayed on top of this panel.') ); $age_options = drupal_map_assoc(array(0, 3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 1814400), 'format_interval'); $age_options[0] = t('never'); $age_options[2592000] = t('1 month'); $age_options[5184000] = t('2 months'); $age_options[7776000] = t('3 months'); $age_options[10368000] = t('4 months'); $age_options[15768000] = t('6 months'); $age_options[31536000] = t('1 year'); $form['general']['akismet_remove_spam_age'] = array( '#type' => 'select', '#title' => t('Remove spam older than'), '#default_value' => variable_get('akismet_remove_spam_age', 259200), '#options' => $age_options, '#description' => t('Content marked as <em>spam</em> is still saved into database so it can be reviewed by content administrators. This option allows you to specify how long this information will be kept in the database. <em>Spam</em> older than the age specified here will be automatically removed. Requires crontab.') ); $form['general']['akismet_records_per_page'] = array( '#type' => 'select', '#title' => t('Records per page'), '#default_value' => variable_get('akismet_records_per_page', 50), '#options' => drupal_map_assoc(array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200)), '#description' => t('The maximum number of records per page on moderation queue.') ); $form['general']['akismet_blocks_counter'] = array( '#type' => 'select', '#title' => t('Number of blocks'), '#default_value' => variable_get('akismet_blocks_counter', 1), '#options' => array(0=>t('none'), 1=>1, 2=>2, 3=>3, 4=>4, 5=>5), '#description' => t('The akismet module may generate a number of blocks for you to display the current spam counter anywhere on your site. The number of blocks is variable to help you keep your <a href="%admin-block">blocks administration panel</a> as clean as possible. This option allows you to specify how many blocks you wish to use. If you do not plan to show the spam counter to your visitors, set this option to <em>none</em>.', array( '%admin-block' => url('admin/block') )) ); $form['general']['akismet_email_enabled'] = array( '#type' => 'radios', '#title' => t('E-mail notifications'), '#options' => $enable_options, '#default_value' => variable_get('akismet_email_enabled', 1), '#description' => t('Use this option to <em>enable</em> or <em>disable</em> e-mail notifications to content moderators. If enabled, users with proper permissions are allowed to set, from their user profiles, whether they wish to receive e-mail notications for all new (or updated) posts, just for content needing approval or no notifications at all. Users are notified about content types they are allowed to moderate only.') ); $form['node_options'] = array( '#type' => 'fieldset', '#title' => t('Node Options'), '#collapsible' => TRUE, '#collapsed' => TRUE ); $form['node_options']['akismet_check_nodetypes'] = array( '#type' => 'checkboxes', '#title' => t('Check for spam in these node types'), '#options' => node_get_types(), '#default_value' => variable_get('akismet_check_nodetypes', NULL), '#description' => t('Use this option to <em>enable</em> or <em>disable</em> spam check for nodes of types specified here. When this option is enabled, a request will be sent to the <a href="%akismet">Akismet Service</a>, in real time. If the <a href="%akismet">Akismet Service</a> was down, nodes would simply be queued for manual moderation. Users with <a href="%admin-access">%admin-nodes</a> permission and <a href="%admin-access">spam moderators</a> are exempt from this check.', array( '%akismet' => 'http://akismet.com', '%admin-nodes' => t('administer nodes'), '%admin-access' => url('admin/access') )) ); $form['node_options']['akismet_node_publish_links'] = array( '#type' => 'radios', '#title' => t('Show publish/unpublish links'), '#options' => $enable_options, '#default_value' => variable_get('akismet_node_publish_links', 0), '#description' => t('Use this option to <em>enable</em> or <em>disable</em> links for <em>publish</em>/<em>unpublish</em> operations in nodes. If enabled, these links will only be displayed to <a href="%admin-access">spam moderators</a> and users with <a href="%admin-access">%admin-nodes</a> permission.', array( '%admin-nodes' => t('administer nodes'), '%admin-access' => url('admin/access') )) ); $form['node_options']['akismet_node_spam_links'] = array( '#type' => 'radios', '#title' => t('Show submit spam/ham links'), '#options' => $enable_options, '#default_value' => variable_get('akismet_node_spam_links', 0), '#description' => t('Use this option to <em>enable</em> or <em>disable</em> links for <em>submit spam</em>/<em>ham</em> operations in nodes. If enabled, these links will only be displayed to <a href="%admin-access">spam moderators</a> and users with <a href="%admin-access">%admin-nodes</a> permission.', array( '%admin-nodes' => t('administer nodes'), '%admin-access' => url('admin/access') )) .'<br />'. t('<strong>Note:</strong> To interact fully with the <a href="%akismet">Akismet Service</a> you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use these links to submit missed spam and false positives (ham), otherwise Akismet will never learn from its mistakes. Thank you.', array( '%akismet' => 'http://akismet.com' )) ); if (module_exist('comment')) { $form['comment_options'] = array( '#type' => 'fieldset', '#title' => t('Comment Options'), '#collapsible' => TRUE, '#collapsed' => TRUE ); $form['comment_options']['akismet_check_comments'] = array( '#type' => 'radios', '#title' => t('Check for spam in comments'), '#options' => $enable_options, '#default_value' => variable_get('akismet_check_comments', 1), '#description' => t('Use this option to <em>enable</em> or <em>disable</em> spam check for comments. When this option is enabled, a request will be sent to the <a href="%akismet">Akismet Service</a>, in real time. If the <a href="%akismet">Akismet Service</a> was down, comments would simply be queued for manual moderation. Users with <a href="%admin-access">%admin-comments</a> permission and <a href="%admin-access">spam moderators</a> are exempt from this check.', array( '%akismet' => 'http://akismet.com', '%admin-comments' => t('administer comments'), '%admin-access' => url('admin/access') )) ); $form['comment_options']['akismet_comment_publish_links'] = array( '#type' => 'radios', '#title' => t('Show publish/unpublish links'), '#options' => $enable_options, '#default_value' => variable_get('akismet_comment_publish_links', 1), '#description' => t('Use this option to <em>enable</em> or <em>disable</em> links for <em>publish</em>/<em>unpublish</em> operations in comments. If enabled, these links will only be displayed to <a href="%admin-access">spam moderators</a> and users with <a href="%admin-access">%admin-comments</a> permission.', array( '%admin-comments' => t('administer comments'), '%admin-access' => url('admin/access') )) ); $form['comment_options']['akismet_comment_spam_links'] = array( '#type' => 'radios', '#title' => t('Show submit spam/ham links'), '#options' => $enable_options, '#default_value' => variable_get('akismet_comment_spam_links', 1), '#description' => t('Use this option to <em>enable</em> or <em>disable</em> links for <em>submit spam</em>/<em>ham</em> operations in comments. If enabled, these links will only be displayed to <a href="%admin-access">spam moderators</a> and users with <a href="%admin-access">%admin-comments</a> permission.', array( '%admin-comments' => t('administer comments'), '%admin-access' => url('admin/access') )) .'<br />'. t('<strong>Note:</strong> To interact fully with the <a href="%akismet">Akismet Service</a> you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use these links to submit missed spam and false positives (ham), otherwise Akismet will never learn from its mistakes. Thank you.', array( '%akismet' => 'http://akismet.com' )) ); } $date_formats = array( 'F j, Y', 'j F, Y', 'Y, F j', 'M j, Y', 'j M, Y', 'Y, M j', 'Y/m/d', 'm/d/Y', 'd/m/Y', 'Y-m-d', 'm-d-Y', 'd-m-Y' ); $date_options = array(); $now = time(); foreach ($date_formats as $format) { $date_options[$format] = format_date($now, 'custom', $format); } $form['counter_options'] = array( '#type' => 'fieldset', '#title' => t('Spam Counter Options'), '#collapsible' => TRUE, '#collapsed' => TRUE ); $form['counter_options']['akismet_counter_spam'] = array( '#type' => 'textfield', '#title' => t('Spam counter'), '#default_value' => akismet_get_spam_counter(), '#size' => 10, '#maxlength' => 10, '#description' => t('This counter is incremented for every spam caught by Akismet.') ); $form['counter_options']['akismet_counter_since'] = array( '#type' => 'date', '#title' => t('Counting since'), '#default_value' => variable_get('akismet_counter_since', array('day' => date('j'), 'month' => date('n'), 'year' => date('Y'))), '#description' => t('This is the date that will tell your visitors when your Akismet spam counter started to increment.') ); $form['counter_options']['akismet_counter_date_format'] = array( '#type' => 'select', '#title' => t('Date format'), '#default_value' => variable_get('akismet_counter_date_format', $date_formats[0]), '#options' => $date_options, '#description' => t('Date format used to render the <em>Counting since</em> date.') ); $form['anti_spambot'] = array( '#type' => 'fieldset', '#title' => t('Anti-Spambot Options'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('The goal of this section is not to replace anything that the <a href="%akismet">Akismet Service</a> itself can do a lot better than us, but to provide a set of simple rules that can be applied to prevent from certain types of spambot attacks.', array( '%akismet' => 'http://akismet.com' )) ); $delay_options = drupal_map_assoc(array(0, 30, 60, 90, 120), 'format_interval'); $delay_options[0] = t('none'); $form['anti_spambot']['akismet_spambot_delay'] = array( '#type' => 'select', '#title' => t('Delay when spam is detected'), '#default_value' => variable_get('akismet_spambot_delay', 60), '#options' => $delay_options, '#description' => t('Use this option to delay the response to submitted content that has been marked as spam or to requests that are being identified by anti-spambot rules.') ); $anti_spambot_detection = array( 'ip' => t('IP addresses that have detected spam in the moderation queue'), 'dup' => t('Duplicated content that has already been identified as spam'), ); $form['anti_spambot']['akismet_spambot_detection'] = array( '#type' => 'checkboxes', '#title' => t('Identify spambots by'), '#options' => $anti_spambot_detection, '#default_value' => variable_get('akismet_spambot_detection', ''... [truncated message content] |