[phpmix-cvs] drupal/modules/akismet CHANGELOG.txt, 1.3, 1.4 INSTALL.txt, 1.3, 1.4 README.txt, 1.4,
Status: Pre-Alpha
Brought to you by:
markus_petrux
From: <php...@li...> - 2006-06-20 01:14:02
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24972 Modified Files: CHANGELOG.txt INSTALL.txt README.txt akismet.module akismet_admin.inc Log Message: A few fixes here and there. I believe this is now ready for 1.1.0. Index: akismet_admin.inc =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet_admin.inc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** akismet_admin.inc 18 Jun 2006 11:53:25 -0000 1.2 --- akismet_admin.inc 20 Jun 2006 01:13:54 -0000 1.3 *************** *** 12,27 **** $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( --- 12,27 ---- $akismet_wpapikey = variable_get('akismet_wpapikey', ''); if (empty($akismet_wpapikey)) { ! $service_fieldset_collapsed = FALSE; } else { ! $service_fieldset_collapsed = $is_valid = (akismet_api_cmd_verify_key($akismet_wpapikey) == AKISMET_API_RESULT_SUCCESS ? TRUE : FALSE); } ! if ($service_fieldset_collapsed) { ! $service_fieldset_collapsed = variable_get('akismet_connection_enabled', 1); } $form['service'] = array( '#type' => 'fieldset', '#title' => t('Akismet Service Options'), ! '#collapsible' => TRUE, '#collapsed' => $service_fieldset_collapsed ); $form['service']['akismet_wpapikey'] = array( *************** *** 63,67 **** $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'); --- 63,67 ---- $form['general'] = array( '#type' => 'fieldset', '#title' => t('General Options'), ! '#collapsible' => TRUE, '#collapsed' => TRUE ); $age_options = drupal_map_assoc(array(0, 86400, 259200, 604800, 1209600), 'format_interval'); *************** *** 236,253 **** $delay_options = drupal_map_assoc(array(0, 30, 60, 90, 120, 150, 180), '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 when content has been identified as spam or to requests that match the rules defined below.') ); ! $anti_spambot_detection = array( ! 'ip' => t('IP addresses used by known spammers'), ! 'dup' => t('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', ''), '#description' => t('These rules will be applied before sending any request to the <a href="%akismet">Akismet Service</a>. If a request to send content matches any of these rules, the actions defined below will be triggered. Requests to send content are checked against spam that is stored locally (visible from the <a href="%moderation-queue">moderation queue</a>).', array( --- 236,254 ---- $delay_options = drupal_map_assoc(array(0, 30, 60, 90, 120, 150, 180), 'format_interval'); $delay_options[0] = t('none'); ! $form['anti_spambot']['akismet_antispambot_delay'] = array( '#type' => 'select', '#title' => t('Delay when spam is detected'), ! '#default_value' => variable_get('akismet_antispambot_delay', 60), '#options' => $delay_options, '#description' => t('Use this option to delay the response when content has been identified as spam or to requests that match the rules defined below.') ); ! $anti_spambot_rules = array( ! 'ip' => t('IP addresses used by known spammers.'), ! 'mail' => t('E-mail addresses used by known spammers.'), ! 'body' => t('Content that has already been identified as spam.'), ); ! $form['anti_spambot']['akismet_antispambot_rules'] = array( '#type' => 'checkboxes', '#title' => t('Identify spambots by'), ! '#options' => $anti_spambot_rules, ! '#default_value' => variable_get('akismet_antispambot_rules', NULL), '#description' => t('These rules will be applied before sending any request to the <a href="%akismet">Akismet Service</a>. If a request to send content matches any of these rules, the actions defined below will be triggered. Requests to send content are checked against spam that is stored locally (visible from the <a href="%moderation-queue">moderation queue</a>).', array( *************** *** 257,269 **** ); $anti_spambot_actions = array( ! 'none' => t('None (only the delay specified above, if any)'), ! '403a' => t('Generate a 403 error (Drupal generated page)'), ! '403b' => t('Generate a 403 error (blank page)') ); ! $form['anti_spambot']['akismet_spambot_action'] = array( '#type' => 'radios', '#title' => t('Actions against spambots'), '#options' => $anti_spambot_actions, ! '#default_value' => variable_get('akismet_spambot_action', '403b'), ! '#description' => t('Use this option to specify what to do against spambots identified by any of the above rules. When a <em>403 error</em> (access denied) is generated, no request to the <a href="%akismet">Akismet Service</a> will be made, the request to post content will not be stored into database and no further moderator notifications will be sent. If any case, when a rule matches, a record of the event will be <a href="%admin-logs">logged</a> for further analysis.', array( '%akismet' => 'http://akismet.com', --- 258,271 ---- ); $anti_spambot_actions = array( ! 'none' => t('None (only the delay specified above, if any).'), ! '503' => t('HTTP error 503 (Service Unavailable), showing a simple blank page.'), ! '403' => t('HTTP error 403 (Forbidden), showing a simple blank page.'), ! '403d' => t('HTTP error 403 (Forbidden), showing a Drupal generated page.') ); ! $form['anti_spambot']['akismet_antispambot_action'] = array( '#type' => 'radios', '#title' => t('Actions against spambots'), '#options' => $anti_spambot_actions, ! '#default_value' => variable_get('akismet_antispambot_action', '503'), ! '#description' => t('Use this option to specify what to do against spambots identified by any of the above rules. When a <em>HTTP error</em> is generated (403 or 503), no request to the <a href="%akismet">Akismet Service</a> will be made, the request to post content will not be stored into database and no further moderator notifications will be sent. In any case, when a rule matches, a record of the event will be <a href="%admin-logs">logged</a> for further analysis.', array( '%akismet' => 'http://akismet.com', *************** *** 583,587 **** else { if ($submode == 'spam') { ! $message = t('There is no spam in the moderation queue.') .'<br />'. t('It must be your lucky day! ;-)'); } else if ($submode == 'unpublished') { --- 585,589 ---- else { if ($submode == 'spam') { ! $message = ($mode == 'nodes' ? t('There is no spam in the nodes moderation queue.') : t('There is no spam in the comments moderation queue.')) .'<br />'. t('It must be your lucky day! ;-)'); } else if ($submode == 'unpublished') { *************** *** 634,638 **** $valid_operations = akismet_moderator_operations($mode, $submode); ! // Make sure we deal with valid combination of mode, submode and operation. if (!isset($valid_operations[$operation])) { return; --- 636,640 ---- $valid_operations = akismet_moderator_operations($mode, $submode); ! // Make sure we deal with a valid combination of mode, submode and operation. if (!isset($valid_operations[$operation])) { return; *************** *** 645,649 **** $form = array(); ! $form['items'] = array('#prefix' => '<p>'. $confirm_message .'</p><ul>', '#suffix' => '</ul>', '#tree' => TRUE); // array_filter() returns only elements with actual values foreach (array_filter($edit['items']) as $content_id => $value) { --- 647,651 ---- $form = array(); ! $form['items'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE); // array_filter() returns only elements with actual values foreach (array_filter($edit['items']) as $content_id => $value) { *************** *** 657,661 **** $form['operation'] = array('#type' => 'hidden', '#value' => $operation); ! $path = 'admin/akismet/'. $mode .'/'. $submode; return confirm_form('akismet_confirm_multiple_operation', $form, $confirm_message, $path, $confirm_warning, $confirm_button, t('Cancel')); } --- 659,669 ---- $form['operation'] = array('#type' => 'hidden', '#value' => $operation); ! // Redirect to a non-existent menu item to make tabs disappear. ! menu_set_active_item(''); ! ! $path = 'admin/akismet/'. $mode; ! if ($submode != 'spam') { ! $path .= '/'. $submode; ! } return confirm_form('akismet_confirm_multiple_operation', $form, $confirm_message, $path, $confirm_warning, $confirm_button, t('Cancel')); } *************** *** 670,674 **** $valid_operations = akismet_moderator_operations($mode, $submode); ! // Make sure we deal with valid combination of mode, submode and operation. if (!isset($valid_operations[$operation])) { return 'admin/akismet'; --- 678,682 ---- $valid_operations = akismet_moderator_operations($mode, $submode); ! // Make sure we deal with a valid combination of mode, submode and operation. if (!isset($valid_operations[$operation])) { return 'admin/akismet'; *************** *** 710,713 **** drupal_set_message($message); } ! return 'admin/akismet/'. $mode .'/'. $submode; } --- 718,726 ---- drupal_set_message($message); } ! ! $path = 'admin/akismet/'. $mode; ! if ($submode != 'spam') { ! $path .= '/'. $submode; ! } ! return $path; } Index: INSTALL.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/INSTALL.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** INSTALL.txt 7 Jun 2006 23:27:19 -0000 1.3 --- INSTALL.txt 20 Jun 2006 01:13:54 -0000 1.4 *************** *** 4,11 **** ******************************************************************** Name : akismet ! Version : 1.0.0 Author : markus_petrux [ http://www.phpmix.org ] Drupal : 4.7 ******************************************************************** INSTALLATION: --- 4,21 ---- ******************************************************************** Name : akismet ! Version : 1.1.0 Author : markus_petrux [ http://www.phpmix.org ] Drupal : 4.7 + + ******************************************************************** + CONTENTS: + + * INSTALLATION + * UPGRADING from 1.0.0 + * UNINSTALLATION + * OPTIONAL INSTALLATION STEP + + ******************************************************************** INSTALLATION: *************** *** 26,31 **** 6. You're done. ******************************************************************** ! OPTIONAL: If you have installed the controlpanel module, you may want to check --- 36,79 ---- 6. You're done. + ******************************************************************** ! UPGRADING from 1.0.0: ! ! 1. Copy all new modules files, keeping directory structure, to the ! folder 'modules/akismet'. ! ! 2. Run your Drupal update.php script to populate database changes. ! A couple of fields have been added to the {akismet_spam_marks} ! table. ! ! 3. Visit 'admin/settings/akismet' and review module settings. A few ! options have been added. ! ! 4. You're done. ! ! ! ******************************************************************** ! UNINSTALLATION: ! ! Should you wish to uninstall this module, you may proceed as ! follows: ! ! 1. Disable the akismet module in 'admin/modules'. ! ! 2. Drop module tables: ! ! DROP TABLE {akismet_spam_marks}; ! DROP TABLE {akismet_moderator}; ! ! ! Please, make backups of your database BEFORE running any SQL query ! that may alter your database, such as the above DROP statements. ! ! Before running the above mentioned SQL statements, be sure to adapt ! the table names to your installation (table prefix). ! ! ! ******************************************************************** ! OPTIONAL INSTALLATION STEP: If you have installed the controlpanel module, you may want to check *************** *** 36,39 **** --- 84,88 ---- Note: As you'll soon notice, graphics are not my best, though. ;-) + ******************************************************************** Please, see the file README.txt for further information. Index: README.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/README.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** README.txt 12 Jun 2006 01:54:56 -0000 1.4 --- README.txt 20 Jun 2006 01:13:54 -0000 1.5 *************** *** 4,8 **** ******************************************************************** Name : akismet ! Version : 1.0.0 Author : markus_petrux [ http://www.phpmix.org ] Drupal : 4.7 --- 4,8 ---- ******************************************************************** Name : akismet ! Version : 1.1.0 Author : markus_petrux [ http://www.phpmix.org ] Drupal : 4.7 *************** *** 42,47 **** * Ability to perform publish/unpublish and submit spam/ham operations from links at the bottom of content. ! * Basic moderator queue to review unpublished content or content that ! has been marked as spam. * All operations are logged to watchdog, trying not to generate a lot of records though. --- 42,49 ---- * Ability to perform publish/unpublish and submit spam/ham operations from links at the bottom of content. ! * Enhanced moderator queue for nodes and comments aimed to help ! moderators to review spam, unpublished or even published content. ! * An experimental set of anti-spambot measures that can be configured ! from the settings panel. * All operations are logged to watchdog, trying not to generate a lot of records though. *************** *** 71,75 **** ******************************************************************** ! INSTALLATION: Please, see the file INSTALL.txt in this directory. --- 73,77 ---- ******************************************************************** ! INSTALLATION - UPGRADE - UNINSTALLATION: Please, see the file INSTALL.txt in this directory. Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** akismet.module 18 Jun 2006 11:04:17 -0000 1.22 --- akismet.module 20 Jun 2006 01:13:54 -0000 1.23 *************** *** 2,12 **** // $Id$ - /********************************************************************************\ - - @TODO: Think about and implement some kind of anti-spambot measures. - Maybe we do something to prevent (or minimize) Denial of Service (DoS). - - \********************************************************************************/ - /** * Akismet Drupal and Module versions. --- 2,5 ---- *************** *** 399,403 **** 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); } --- 392,396 ---- 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_antispambot_delay', 60)) > 0) { sleep($seconds); } *************** *** 418,422 **** case 'insert': case 'update': ! if (!variable_get('akismet_check_comments', 0) || akismet_is_spam_moderator('comments')) { akismet_notify_moderators('comment', $comment, ($comment->status == COMMENT_PUBLISHED ? TRUE : FALSE), FALSE); } --- 411,415 ---- case 'insert': case 'update': ! if (!variable_get('akismet_check_comments', 0) || akismet_is_spam_moderator('comments') || !variable_get('akismet_connection_enabled', 1)) { akismet_notify_moderators('comment', $comment, ($comment->status == COMMENT_PUBLISHED ? TRUE : FALSE), FALSE); } *************** *** 432,451 **** */ function akismet_form_alter($form_id, &$form) { - // If Akismet connections are not enabled, we have nothing else to do here. - if (!variable_get('akismet_connection_enabled', 1)) { - return; - } - // Hook into comment edit/reply form. if ($form_id == 'comment_form' && variable_get('akismet_check_comments', 1)) { if (!akismet_is_spam_moderator('comments')) { ! if (isset($form['cid']) && isset($form['cid']['#value']) && is_numeric($form['cid']['#value'])) { ! // This is the simple hook method, we already have the $cid. ! $form['#submit']['_akismet_comment_form_submit'] = array(); } ! else { ! // This is a bit more complex, because the user is creating a new comment, so ! // how can we get the $cid? See comments below, within our own submit callback. ! $form['#submit'] = array('_akismet_comment_form_submit' => array($form['#submit'])); } } --- 425,462 ---- */ function akismet_form_alter($form_id, &$form) { // Hook into comment edit/reply form. if ($form_id == 'comment_form' && variable_get('akismet_check_comments', 1)) { + // ...only if current user is not moderator. if (!akismet_is_spam_moderator('comments')) { ! // ...also check if Akismet connections are enabled. ! if (variable_get('akismet_connection_enabled', 1)) { ! if (isset($form['cid']) && isset($form['cid']['#value']) && is_numeric($form['cid']['#value'])) { ! // This is the simple hook method, we already have the $cid. ! $form['#submit']['_akismet_comment_form_submit'] = array(); ! } ! else { ! // This is a bit more complex, because the user is creating a new comment, so ! // how can we get the $cid? See comments below, within our own submit callback. ! $form['#submit'] = array('_akismet_comment_form_submit' => array($form['#submit'])); ! } } ! // Inject anti-spambot code, if requested to. ! if (akismet_is_anti_spambot_enabled()) { ! $form['#validate']['_akismet_comment_form_validate'] = array(); ! } ! } ! } ! // Hook into node edit form. ! else if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) { ! // ...only if current user is not moderator. ! if (!akismet_is_spam_moderator('comments')) { ! // ...also check if it's about a node type that we have been explicitly requested to check. ! $check_nodetypes = variable_get('akismet_check_nodetypes', NULL); ! $node_type = $form['type']['#value']; ! if (is_array($check_nodetypes) && isset($check_nodetypes[$node_type]) && $check_nodetypes[$node_type]) { ! // Inject anti-spambot code, if requested to. ! if (akismet_is_anti_spambot_enabled()) { ! $form['#validate']['_akismet_node_form_validate'] = array(); ! } } } *************** *** 454,457 **** --- 465,536 ---- /** + * Node form validate callback; check for spambots. + */ + function _akismet_node_form_validate($form_id, $form_values) { + global $user; + $antispambot_rules = akismet_get_anti_spambot_rules(); + $sql_where = array(); + $sql_args = array(); + if ($antispambot_rules['ip']) { + $sql_where[] = 's.hostname = \'%s\''; + $sql_args[] = $_SERVER['REMOTE_ADDR']; + } + if ($antispambot_rules['body']) { + $sql_where[] = 'n.body = \'%s\''; + $sql_args[] = $form_values['body']; + } + if ($antispambot_rules['mail']) { + $sql_where[] = 's.mail = \'%s\''; + $sql_args[] = (isset($user->mail) ? $user->mail : ''); + } + if (count($sql_where) > 0) { + if ($antispambot_rules['body'] || $antispambot_rules['mail']) { + $sql_stmt = 'SELECT 1 FROM {node} n INNER JOIN {node_revisions} r ON r.nid = n.nid INNER JOIN {akismet_spam_marks} s ON s.content_type = \'node\' AND s.content_id = n.nid WHERE (%cond)'; + } + else { + $sql_stmt = 'SELECT 1 FROM {akismet_spam_marks} s WHERE s.content_type = \'node\' AND (%cond)'; + } + $sql_stmt = str_replace('%cond', implode(' OR ', $sql_where), $sql_stmt); + if (db_result(db_query($sql_stmt, $sql_args, 0, 1))) { + akismet_anti_spambot_action(array(t('SQL') => $sql_stmt, t('E-mail') => (isset($user->mail) ? $user->mail : ''), t('Body') => $form_values['body'])); + } + } + } + + /** + * Comment form validate callback; check for spambots. + */ + function _akismet_comment_form_validate($form_id, $form_values) { + $antispambot_rules = akismet_get_anti_spambot_rules(); + $sql_where = array(); + $sql_args = array(); + if ($antispambot_rules['ip']) { + $sql_where[] = 's.hostname = \'%s\''; + $sql_args[] = $_SERVER['REMOTE_ADDR']; + } + if ($antispambot_rules['body']) { + $sql_where[] = 'c.comment = \'%s\''; + $sql_args[] = $form_values['comment']; + } + if ($antispambot_rules['mail']) { + $sql_where[] = 's.mail = \'%s\''; + $sql_args[] = $form_values['mail']; + } + + if (count($sql_where) > 0) { + if ($antispambot_rules['body'] || $antispambot_rules['mail']) { + $sql_stmt = 'SELECT 1 FROM {comments} c INNER JOIN {akismet_spam_marks} s ON s.content_type = \'comment\' AND s.content_id = c.cid WHERE (%cond)'; + } + else { + $sql_stmt = 'SELECT 1 FROM {akismet_spam_marks} s WHERE s.content_type = \'comment\' AND (%cond)'; + } + $sql_stmt = str_replace('%cond', implode(' OR ', $sql_where), $sql_stmt); + if (db_result(db_query($sql_stmt, $sql_args, 0, 1))) { + akismet_anti_spambot_action(array(t('SQL') => $sql_stmt, t('E-mail') => $form_values['mail'], t('Comment') => $form_values['comment'])); + } + } + } + + /** * Comment form submit callback; check for spam. */ *************** *** 526,530 **** 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); } --- 605,609 ---- 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_antispambot_delay', 60)) > 0) { sleep($seconds); } *************** *** 539,542 **** --- 618,697 ---- /** + * Get anti-spambot rules. + * + * @return array + */ + function akismet_get_anti_spambot_rules() { + static $antispambot_rules = FALSE; + if (!$antispambot_rules) { + $antispambot_rules = array(); + $options = variable_get('akismet_antispambot_rules', NULL); + if (is_array($options)) { + foreach ($options as $key => $value) { + if (is_string($key)) { + $antispambot_rules[$key] = ($key === $value ? TRUE : FALSE); + } + } + } + } + return $antispambot_rules; + } + + /** + * Check if anti-spambot options are enabled. + * + * @return boolean TRUE if enabled; FALSE otherwise. + */ + function akismet_is_anti_spambot_enabled() { + $antispambot_rules = akismet_get_anti_spambot_rules(); + return (count($antispambot_rules) > 0 ? TRUE : FALSE); + } + + /** + * Perform an anti-spambot action based on module settings. + * + * @param array Extra data, used here to enhance the logged information, for debugging purposes. + */ + function akismet_anti_spambot_action($debug_info) { + $antispambot_action = variable_get('akismet_antispambot_action', '503'); + + // First action is generate a delay, if requested to. + if (($seconds = variable_get('akismet_antispambot_delay', 60)) > 0) { + sleep($seconds); + } + + // If no other action was set, we're done. + if ($antispambot_action == 'none') { + return; + } + + $items = array(); + foreach ($debug_info as $label => $value) { + $items[] = '<strong>'. check_plain($label) .'</strong>: '. check_plain($value); + } + + // From here on, the request is killed using different methods. + if ($antispambot_action == '403d') { + drupal_access_denied(); + $message = t('Spambot detected (action: 403 Forbidden).'); + } + else if ($antispambot_action == '403') { + @header('HTTP/1.0 403 Forbidden'); + print t('Access denied'); + $message = t('Spambot detected (action: 403 Forbidden).'); + } + else { // 503 + @header('HTTP/1.0 503 Service unavailable'); + print t('Service unavailable'); + $message = t('Spambot detected (action: 503 Service unavailable).'); + } + + watchdog('akismet', $message .'<p>'. t('Additional information:') .'</p>'. theme('item_list', $items)); + + module_invoke_all('exit'); + exit; + } + + /** * Check if specified content is marked as spam. * *************** *** 709,713 **** '%content-link' => url('node/'. $content->nid, NULL, 'comment-'. $content->cid, TRUE) ); ! $message_title = t('[%site-name] New comment posted on \'%title\'', array('%site-name' => $site_name, '%title' => check_plain($node->title))); } else { --- 864,868 ---- '%content-link' => url('node/'. $content->nid, NULL, 'comment-'. $content->cid, TRUE) ); ! $message_title = t('[%site-name] moderator notification - Posted comment on \'%title\'', array('%site-name' => $site_name, '%title' => check_plain($node->title))); } else { *************** *** 718,722 **** '%content-link' => url('node/'. $content->nid, NULL, NULL, TRUE) ); ! $message_title = t('[%site-name] New %type \'%title\'', array('%site-name' => $site_name, '%type' => check_plain($moderator_types[$content->type]), '%title' => check_plain($content->title))); } $message_args['%content-status'] = ($is_published ? t('published') : t('published')) . ($is_spam ? ' ('. t('marked as spam') .')' : ''); --- 873,877 ---- '%content-link' => url('node/'. $content->nid, NULL, NULL, TRUE) ); ! $message_title = t('[%site-name] moderator notification - Posted %type \'%title\'', array('%site-name' => $site_name, '%type' => check_plain($moderator_types[$content->type]), '%title' => check_plain($content->title))); } $message_args['%content-status'] = ($is_published ? t('published') : t('published')) . ($is_spam ? ' ('. t('marked as spam') .')' : ''); *************** *** 1090,1096 **** --- 1245,1253 ---- function akismet_content_spam_operation($content_type, $content, $op, $log_action = TRUE) { if ($content_type == 'node') { + global $user; $content_id = $content->nid; $content_title = $content->title; $content_link = l(t('view'), 'node/'. $content->nid); + $user_mail = (isset($user->mail) ? $user->mail : ''); } else { // comment *************** *** 1098,1105 **** $content_title = $content->subject; $content_link = l(t('view'), 'node/'. $content->nid, NULL, NULL, 'comment-'. $content->cid); } if ($op == 'submit-spam') { ! db_query('INSERT INTO {akismet_spam_marks} (content_type, content_id, spam_created) VALUES (\'%s\', %d, %d)', $content_type, $content_id, time()); if (variable_get('akismet_connection_enabled', 1)) { --- 1255,1264 ---- $content_title = $content->subject; $content_link = l(t('view'), 'node/'. $content->nid, NULL, NULL, 'comment-'. $content->cid); + $user_mail = $content->mail; } if ($op == 'submit-spam') { ! $hostname = (!empty($content->hostname) ? $content->hostname : $_SERVER['REMOTE_ADDR']); ! db_query('INSERT INTO {akismet_spam_marks} (content_type, content_id, spam_created, hostname, mail) VALUES (\'%s\', %d, %d, \'%s\', \'%s\')', $content_type, $content_id, time(), $hostname, $user_mail); if (variable_get('akismet_connection_enabled', 1)) { *************** *** 1210,1214 **** global $user; $comment_data['permalink'] = url('node/'. $content->nid); ! $comment_data['comment_author_email'] = $user->mail; $comment_data['comment_author_url'] = ''; $comment_data['comment_content'] = $content->body; --- 1369,1373 ---- global $user; $comment_data['permalink'] = url('node/'. $content->nid); ! $comment_data['comment_author_email'] = (isset($user->mail) ? $user->mail : ''); $comment_data['comment_author_url'] = ''; $comment_data['comment_content'] = $content->body; Index: CHANGELOG.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/CHANGELOG.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CHANGELOG.txt 18 Jun 2006 11:53:25 -0000 1.3 --- CHANGELOG.txt 20 Jun 2006 01:13:54 -0000 1.4 *************** *** 4,7 **** --- 4,10 ---- Akismet module in CVS ------------------------------------------------ + + Akismet module v1.1.0 for Drupal 4.7, 2006-06-20 + ------------------------------------------------ - Added experimental feature: anti-spambot options to prevent from Denial of Service (DoS) caused by certain spambots. |