phpmix-cvs Mailing List for phpMiX Open Source eXperiments
Status: Pre-Alpha
Brought to you by:
markus_petrux
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
(160) |
May
|
Jun
(117) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: <php...@li...> - 2006-06-20 16:42:20
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14713 Modified Files: CHANGELOG.txt Log Message: typo Index: CHANGELOG.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/CHANGELOG.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CHANGELOG.txt 20 Jun 2006 15:16:44 -0000 1.6 --- CHANGELOG.txt 20 Jun 2006 16:42:17 -0000 1.7 *************** *** 14,18 **** prevention code. - Added a function to expand the SQL query used to match spambots. ! This is hopefully better, for debuggin purposes. --- 14,18 ---- prevention code. - Added a function to expand the SQL query used to match spambots. ! This is hopefully better, for debugging purposes. |
From: <php...@li...> - 2006-06-20 15:16:53
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9818 Modified Files: CHANGELOG.txt INSTALL.txt README.txt akismet.module Log Message: - Fixed bug: Do not apply anti-spambot checks if there have already been errors detected in the form. - Fixed bug: Do not check for empty body/mail in anti-spambot prevention code. - Added a function to expand the SQL query used to match spambots. This is hopefully better, for debuggin purposes. - Version changed to 1.1.2 and releasing... Index: CHANGELOG.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/CHANGELOG.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CHANGELOG.txt 20 Jun 2006 01:18:12 -0000 1.5 --- CHANGELOG.txt 20 Jun 2006 15:16:44 -0000 1.6 *************** *** 4,7 **** --- 4,19 ---- Akismet module in CVS ------------------------------------------------ + - No changes yet. + + + Akismet module v1.1.2 for Drupal 4.7, 2006-06-20 + ------------------------------------------------ + - Fixed bug: Do not apply anti-spambot checks if there have already + been errors detected in the form. + - Fixed bug: Do not check for empty body/mail in anti-spambot + prevention code. + - Added a function to expand the SQL query used to match spambots. + This is hopefully better, for debuggin purposes. + Akismet module v1.1.0 for Drupal 4.7, 2006-06-20 *************** *** 20,23 **** --- 32,36 ---- speed up some queries. Requires running http://site/update.php + Akismet module v1.0.0 for Drupal 4.7, 2006-06-12 ------------------------------------------------ Index: INSTALL.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/INSTALL.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** INSTALL.txt 20 Jun 2006 01:13:54 -0000 1.4 --- INSTALL.txt 20 Jun 2006 15:16:44 -0000 1.5 *************** *** 4,8 **** ******************************************************************** Name : akismet ! Version : 1.1.0 Author : markus_petrux [ http://www.phpmix.org ] Drupal : 4.7 --- 4,8 ---- ******************************************************************** Name : akismet ! Version : 1.1.2 Author : markus_petrux [ http://www.phpmix.org ] Drupal : 4.7 *************** *** 13,17 **** * INSTALLATION ! * UPGRADING from 1.0.0 * UNINSTALLATION * OPTIONAL INSTALLATION STEP --- 13,18 ---- * INSTALLATION ! * UPGRADING from 1.1.0 to 1.1.2 ! * UPGRADING from 1.0.0 to 1.1.0 * UNINSTALLATION * OPTIONAL INSTALLATION STEP *************** *** 38,42 **** ******************************************************************** ! UPGRADING from 1.0.0: 1. Copy all new modules files, keeping directory structure, to the --- 39,53 ---- ******************************************************************** ! UPGRADING from 1.1.0 to 1.1.2: ! ! 1. Copy the file akismet.module to the folder 'modules/akismet'. ! No other changes have been made. Please consult the file ! CHANGELOG.txt for details. ! ! 2. You're done. ! ! ! ******************************************************************** ! UPGRADING from 1.0.0 to 1.1.0: 1. Copy all new modules files, keeping directory structure, to the Index: README.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/README.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** README.txt 20 Jun 2006 01:13:54 -0000 1.5 --- README.txt 20 Jun 2006 15:16:44 -0000 1.6 *************** *** 4,8 **** ******************************************************************** Name : akismet ! Version : 1.1.0 Author : markus_petrux [ http://www.phpmix.org ] Drupal : 4.7 --- 4,8 ---- ******************************************************************** Name : akismet ! Version : 1.1.2 Author : markus_petrux [ http://www.phpmix.org ] Drupal : 4.7 Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** akismet.module 20 Jun 2006 01:22:40 -0000 1.24 --- akismet.module 20 Jun 2006 15:16:44 -0000 1.25 *************** *** 6,10 **** */ define('AKISMET_DRUPAL_VERSION', '4.7'); ! define('AKISMET_MODULE_VERSION', '1.1.0'); define('AKISMET_MODULE_HOMEURL', 'http://www.phpmix.org/projects/drupal/4_7/akismet'); define('AKISMET_MODULE_USERAGENT', 'phpMiX.org | projects/drupal/4_7/akismet | '. AKISMET_MODULE_VERSION); --- 6,10 ---- */ define('AKISMET_DRUPAL_VERSION', '4.7'); ! define('AKISMET_MODULE_VERSION', '1.1.2'); define('AKISMET_MODULE_HOMEURL', 'http://www.phpmix.org/projects/drupal/4_7/akismet'); define('AKISMET_MODULE_USERAGENT', 'phpMiX.org | projects/drupal/4_7/akismet | '. AKISMET_MODULE_VERSION); *************** *** 468,471 **** --- 468,477 ---- */ function _akismet_node_form_validate($form_id, $form_values) { + // Quit if there have already been errors in the form. + if (form_get_errors()) { + return; + } + + // Ok, let's build a quick query to see if we can catch a spambot. global $user; $antispambot_rules = akismet_get_anti_spambot_rules(); *************** *** 476,487 **** $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']) { --- 482,494 ---- $sql_args[] = $_SERVER['REMOTE_ADDR']; } ! if ($antispambot_rules['body'] && !empty($form_values['body'])) { $sql_where[] = 'n.body = \'%s\''; $sql_args[] = $form_values['body']; } ! if ($antispambot_rules['mail'] && !empty($user->mail)) { $sql_where[] = 's.mail = \'%s\''; ! $sql_args[] = $user->mail; } + if (count($sql_where) > 0) { if ($antispambot_rules['body'] || $antispambot_rules['mail']) { *************** *** 493,497 **** $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'])); } } --- 500,508 ---- $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') => _akismet_translate_query($sql_stmt, $sql_args), ! t('E-mail') => (isset($user->mail) ? $user->mail : ''), ! t('Body') => $form_values['body'] ! )); } } *************** *** 502,505 **** --- 513,522 ---- */ function _akismet_comment_form_validate($form_id, $form_values) { + // Quit if there have already been errors in the form. + if (form_get_errors()) { + return; + } + + // Ok, let's build a quick query to see if we can catch a spambot. $antispambot_rules = akismet_get_anti_spambot_rules(); $sql_where = array(); *************** *** 509,517 **** $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']; --- 526,534 ---- $sql_args[] = $_SERVER['REMOTE_ADDR']; } ! if ($antispambot_rules['body'] && !empty($form_values['comment'])) { $sql_where[] = 'c.comment = \'%s\''; $sql_args[] = $form_values['comment']; } ! if ($antispambot_rules['mail'] && !empty($form_values['mail'])) { $sql_where[] = 's.mail = \'%s\''; $sql_args[] = $form_values['mail']; *************** *** 527,531 **** $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'])); } } --- 544,552 ---- $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') => _akismet_translate_query($sql_stmt, $sql_args), ! t('E-mail') => $form_values['mail'], ! t('Comment') => $form_values['comment'] ! )); } } *************** *** 694,697 **** --- 715,736 ---- /** + * Expand query for debugging purposes. + * + * @param string SQL statement. + * @param mixed array or variable list of arguments. + */ + function _akismet_translate_query($query) { + $args = func_get_args(); + array_shift($args); + $query = db_prefix_tables($query); + if (isset($args[0]) && is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + _db_query_callback($args, TRUE); + $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); + return $query; + } + + /** * Check if specified content is marked as spam. * |
From: <php...@li...> - 2006-06-20 01:22:47
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29548 Modified Files: akismet.module Log Message: Let's release this and see what happens. :-/ Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** akismet.module 20 Jun 2006 01:13:54 -0000 1.23 --- akismet.module 20 Jun 2006 01:22:40 -0000 1.24 *************** *** 6,10 **** */ define('AKISMET_DRUPAL_VERSION', '4.7'); ! define('AKISMET_MODULE_VERSION', '1.0.0'); define('AKISMET_MODULE_HOMEURL', 'http://www.phpmix.org/projects/drupal/4_7/akismet'); define('AKISMET_MODULE_USERAGENT', 'phpMiX.org | projects/drupal/4_7/akismet | '. AKISMET_MODULE_VERSION); --- 6,10 ---- */ define('AKISMET_DRUPAL_VERSION', '4.7'); ! define('AKISMET_MODULE_VERSION', '1.1.0'); define('AKISMET_MODULE_HOMEURL', 'http://www.phpmix.org/projects/drupal/4_7/akismet'); define('AKISMET_MODULE_USERAGENT', 'phpMiX.org | projects/drupal/4_7/akismet | '. AKISMET_MODULE_VERSION); |
From: <php...@li...> - 2006-06-20 01:18:16
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27346 Modified Files: CHANGELOG.txt Log Message: Forgot to add something about new columns to the changelog. Index: CHANGELOG.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/CHANGELOG.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CHANGELOG.txt 20 Jun 2006 01:13:54 -0000 1.4 --- CHANGELOG.txt 20 Jun 2006 01:18:12 -0000 1.5 *************** *** 17,20 **** --- 17,22 ---- written the content. - Removed unnecessary code in hook_install. + - Added a couple of columns to the {akismet_spam_marks} table to + speed up some queries. Requires running http://site/update.php Akismet module v1.0.0 for Drupal 4.7, 2006-06-12 |
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. |
From: <php...@li...> - 2006-06-19 21:04:03
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4345 Modified Files: akismet.install Log Message: Update 2: Add columns hostname and mail to {akismet_spam_marks} table. Index: akismet.install =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.install,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** akismet.install 12 Jun 2006 05:27:44 -0000 1.4 --- akismet.install 19 Jun 2006 21:03:58 -0000 1.5 *************** *** 13,18 **** content_id int(10) unsigned NOT NULL default 0, spam_created int(11) unsigned NOT NULL default 0, UNIQUE content (content_type, content_id), ! INDEX spam_created (spam_created) ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); db_query("CREATE TABLE {akismet_moderator} ( --- 13,22 ---- content_id int(10) unsigned NOT NULL default 0, spam_created int(11) unsigned NOT NULL default 0, + hostname varchar(128) NOT NULL default '', + mail varchar(128) NOT NULL default '', UNIQUE content (content_type, content_id), ! INDEX spam_created (spam_created), ! INDEX hostname (hostname), ! INDEX mail (mail) ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); db_query("CREATE TABLE {akismet_moderator} ( *************** *** 28,35 **** content_type varchar(20) NOT NULL default '', content_id integer NOT NULL default 0 CHECK (content_id >= 0), ! spam_created integer NOT NULL default 0 CHECK (spam_created >= 0) )"); db_query("CREATE UNIQUE INDEX {akismet_spam_marks_content} ON {akismet_spam_marks} (content_type, content_id)"); db_query("CREATE INDEX {akismet_spam_marks_spamcreated} ON {akismet_spam_marks} (spam_created)"); db_query("CREATE TABLE {akismet_moderator} ( uid INTEGER NOT NULL DEFAULT 0 CHECK (uid >= 0), --- 32,43 ---- content_type varchar(20) NOT NULL default '', content_id integer NOT NULL default 0 CHECK (content_id >= 0), ! spam_created integer NOT NULL default 0 CHECK (spam_created >= 0), ! hostname varchar(128) NOT NULL default '', ! mail varchar(128) NOT NULL default '' )"); db_query("CREATE UNIQUE INDEX {akismet_spam_marks_content} ON {akismet_spam_marks} (content_type, content_id)"); db_query("CREATE INDEX {akismet_spam_marks_spamcreated} ON {akismet_spam_marks} (spam_created)"); + db_query("CREATE INDEX {akismet_spam_marks_hostname} ON {akismet_spam_marks} (hostname)"); + db_query("CREATE INDEX {akismet_spam_marks_mail} ON {akismet_spam_marks} (mail)"); db_query("CREATE TABLE {akismet_moderator} ( uid INTEGER NOT NULL DEFAULT 0 CHECK (uid >= 0), *************** *** 43,47 **** /** ! * Update 1: Add table for user extensions. */ function akismet_update_1() { --- 51,55 ---- /** ! * Update 1: Add table for moderator extensions. */ function akismet_update_1() { *************** *** 71,72 **** --- 79,114 ---- return $ret; } + + /** + * Update 2: Add columns hostname and mail to {akismet_spam_marks} table. + */ + function akismet_update_2() { + $ret = array(); + + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + $ret[] = update_sql("ALTER TABLE {akismet_spam_marks} ADD COLUMN hostname varchar(128) NOT NULL default ''"); + $ret[] = update_sql("ALTER TABLE {akismet_spam_marks} ADD INDEX hostname (hostname)"); + + $ret[] = update_sql("ALTER TABLE {akismet_spam_marks} ADD COLUMN mail varchar(128) NOT NULL default ''"); + $ret[] = update_sql("ALTER TABLE {akismet_spam_marks} ADD INDEX mail (mail)"); + break; + + case 'pgsql': + $ret[] = update_sql("ALTER TABLE {akismet_spam_marks} ADD COLUMN hostname VARCHAR(128)"); + $ret[] = update_sql("ALTER TABLE {akismet_spam_marks} ALTER COLUMN hostname SET DEFAULT ''"); + $ret[] = update_sql("UPDATE TABLE {akismet_spam_marks} SET hostname = '' WHERE hostname IS NULL"); + $ret[] = update_sql("ALTER TABLE {akismet_spam_marks} ALTER COLUMN hostname SET NOT NULL"); + $ret[] = update_sql("CREATE INDEX {akismet_spam_marks_hostname} ON {akismet_spam_marks} (hostname)"); + + $ret[] = update_sql("ALTER TABLE {akismet_spam_marks} ADD COLUMN mail VARCHAR(128)"); + $ret[] = update_sql("ALTER TABLE {akismet_spam_marks} ALTER COLUMN mail SET DEFAULT ''"); + $ret[] = update_sql("UPDATE TABLE {akismet_spam_marks} SET mail = '' WHERE mail IS NULL"); + $ret[] = update_sql("ALTER TABLE {akismet_spam_marks} ALTER COLUMN mail SET NOT NULL"); + $ret[] = update_sql("CREATE INDEX {akismet_spam_marks_mail} ON {akismet_spam_marks} (mail)"); + break; + } + + return $ret; + } |
From: <php...@li...> - 2006-06-18 11:53:29
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28252 Modified Files: akismet_admin.inc CHANGELOG.txt Log Message: I believe I forgot to mention that a new feature is being added to prevent Denial of Service situations caused by certain spambots. Here, I'm revising the related new options. The actual implementaion of the corresponding checks/actions is coming... Index: CHANGELOG.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/CHANGELOG.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CHANGELOG.txt 18 Jun 2006 11:04:19 -0000 1.2 --- CHANGELOG.txt 18 Jun 2006 11:53:25 -0000 1.3 *************** *** 4,7 **** --- 4,9 ---- Akismet module in CVS ------------------------------------------------ + - Added experimental feature: anti-spambot options to prevent from + Denial of Service (DoS) caused by certain spambots. - Rewritten moderation queue. It is now a bit more powerful, allowing operations against multiple items. Index: akismet_admin.inc =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet_admin.inc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** akismet_admin.inc 18 Jun 2006 11:04:17 -0000 1.1 --- akismet_admin.inc 18 Jun 2006 11:53:25 -0000 1.2 *************** *** 229,238 **** '#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( --- 229,238 ---- '#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 aimed to prevent Denial of Service (DoS) situations that could be caused by certain spambots.', array( '%akismet' => 'http://akismet.com' )) ); ! $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( *************** *** 240,248 **** '#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( --- 240,248 ---- '#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( *************** *** 250,258 **** '#options' => $anti_spambot_detection, '#default_value' => variable_get('akismet_spambot_detection', ''), ! '#description' => t('Mark the rules by which spambots may be identified.') ); $anti_spambot_actions = array( 'none' => t('None (only the delay specified above, if any)'), ! '403a' => t('Generate a 403 error (normal)'), '403b' => t('Generate a 403 error (blank page)') ); --- 250,262 ---- '#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( ! '%akismet' => 'http://akismet.com', ! '%moderation-queue' => url('admin/akismet') ! )) ); $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)') ); *************** *** 261,265 **** '#options' => $anti_spambot_actions, '#default_value' => variable_get('akismet_spambot_action', '403b'), ! '#description' => t('Use this option to specify what to do agaisnt identified spambots.') ); --- 265,273 ---- '#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', ! '%admin-logs' => url('admin/logs') ! )) ); |
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] |
From: <php...@li...> - 2006-06-12 05:27:47
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13969 Modified Files: akismet.install akismet.module Added Files: CHANGELOG.txt Log Message: - Prevent from sending e-mail notifications to the same user who has written the content. - Removing unnecessary code in hook_install. - Added CHANGELOG.txt --- NEW FILE: CHANGELOG.txt --- $Id: CHANGELOG.txt,v 1.1 2006/06/12 05:27:44 markus_petrux Exp $ ********************************************************************** 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 Index: akismet.install =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.install,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** akismet.install 10 Jun 2006 17:57:35 -0000 1.3 --- akismet.install 12 Jun 2006 05:27:44 -0000 1.4 *************** *** 6,11 **** */ function akismet_install() { - $ret = array(); - switch ($GLOBALS['db_type']) { case 'mysql': --- 6,9 ---- *************** *** 42,47 **** break; } - - return $ret; } --- 40,43 ---- Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** akismet.module 12 Jun 2006 02:03:15 -0000 1.20 --- akismet.module 12 Jun 2006 05:27:44 -0000 1.21 *************** *** 1028,1032 **** */ function akismet_notify_moderators($content_type, $content, $is_published, $is_spam) { ! global $base_url; // Proceed only if e-mail notifications are enabled. --- 1028,1032 ---- */ function akismet_notify_moderators($content_type, $content, $is_published, $is_spam) { ! global $user, $base_url; // Proceed only if e-mail notifications are enabled. *************** *** 1060,1068 **** $moderators = array(); while ($u = db_fetch_object($result)) { ! $moderators[$u->uid] = array( ! 'name' => $u->name, ! 'email_to' => $u->mail, ! 'email_for' => (!is_null($u->email_for) ? $u->email_for : 'approval') ! ); } --- 1060,1070 ---- $moderators = array(); while ($u = db_fetch_object($result)) { ! if ($u->uid != $user->uid) { ! $moderators[$u->uid] = array( ! 'name' => $u->name, ! 'email_to' => $u->mail, ! 'email_for' => (!is_null($u->email_for) ? $u->email_for : 'approval') ! ); ! } } |
From: <php...@li...> - 2006-06-12 02:03:23
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10412 Modified Files: akismet.module Log Message: Changing module version to 1.0.0. :-) Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** akismet.module 12 Jun 2006 00:48:43 -0000 1.19 --- akismet.module 12 Jun 2006 02:03:15 -0000 1.20 *************** *** 13,17 **** */ define('AKISMET_DRUPAL_VERSION', '4.7'); ! define('AKISMET_MODULE_VERSION', '1.0.0 beta'); define('AKISMET_MODULE_HOMEURL', 'http://www.phpmix.org/projects/drupal/4_7/akismet'); define('AKISMET_MODULE_USERAGENT', 'phpMiX.org | projects/drupal/4_7/akismet | '. AKISMET_MODULE_VERSION); --- 13,17 ---- */ define('AKISMET_DRUPAL_VERSION', '4.7'); ! define('AKISMET_MODULE_VERSION', '1.0.0'); define('AKISMET_MODULE_HOMEURL', 'http://www.phpmix.org/projects/drupal/4_7/akismet'); define('AKISMET_MODULE_USERAGENT', 'phpMiX.org | projects/drupal/4_7/akismet | '. AKISMET_MODULE_VERSION); |
From: <php...@li...> - 2006-06-12 01:54:59
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5609 Modified Files: README.txt Log Message: Updated README with list of features. Index: README.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/README.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** README.txt 7 Jun 2006 23:27:19 -0000 1.3 --- README.txt 12 Jun 2006 01:54:56 -0000 1.4 *************** *** 24,27 **** --- 24,74 ---- ******************************************************************** + FEATURES: + + * Ability to check for spam in comments and/or nodes, sending a + query to Akismet, in real time. + * The actual content types that should be checked can be selected + from the settings panel. + * Real time connections can be disabled. + * Detected spam is still recorded into database. However, a cron + task can be customized to automatically remove spam older than a + specified age. + * Moderators can submit missed spam or false possitives (ham) back + to Akismet. + * Users may inherit moderator status depending on permissions + assigned to them such as 'administer nodes', 'administer comments' + or a set of 'moderate spam in <content-type>' permissions created + by this module. + * 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. + * Spam counter that also reminds the 'counting since date'. This + information can be changed at will from the settings panel. + * The spam counter is displayed on the settings panel and the + moderation queue. It can also be displayed to user by means of a + fully configurable and themable block. + * There is also an option in the settings panel that allows + administrators set how many blocks they wish to use (or none at + all). This is aimed to keep the block administration panel as clean + as possible. Each block can be customized independently. + * Opt-in option for content administrators and moderators to receive + e-mail notifications about new (or updated) content, only content + needing approval or nothing at all. The site administrator can + disable this option, though. If enabled, content administrators and + moderators will have a new block of settings in their user profiles. + * Comprehensive settings panel where every option has been self + documented with descriptions. Almost every feature can be customized. + * A couple of buttons are included in the contrib subdirectory for + those who use the control panel module. I'm not really good with + graphics, I did it the best that I could... + * Finally, this module has a simple, but hopefuly useful, version + checker. It can check for updates at intervals that are customized + in the settings panel. This option can be disabled. + + + ******************************************************************** INSTALLATION: |
From: <php...@li...> - 2006-06-12 00:48:50
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30108 Modified Files: akismet.module Log Message: Added mail functionality to notification engine. Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** akismet.module 10 Jun 2006 19:01:04 -0000 1.18 --- akismet.module 12 Jun 2006 00:48:43 -0000 1.19 *************** *** 4,11 **** /********************************************************************************\ - @TODO: Implement an opt-in option for administrators to e-mail them when content - is posted (maybe for all posts, or for detected spam or nothing). - @TODO: Review the help page. @TODO: Enhance moderation queue with a form to allow multiple operations. \********************************************************************************/ --- 4,9 ---- /********************************************************************************\ @TODO: Enhance moderation queue with a form to allow multiple operations. + @TODO: Review the help page. \********************************************************************************/ *************** *** 453,698 **** /** - * Implementation of hook_user(). - */ - function akismet_user($op, &$edit, &$account, $category = NULL) { - $moderator_email_for_options = array( - 'all' => t('All new (or updated) content'), - 'approval' => t('Only content needing approval'), - 'never' => t('Never') - ); - switch ($op) { - case 'form': - if ($category == 'account' && variable_get('akismet_email_enabled', 1)) { - $moderator_types = akismet_get_moderator_types($account); - $moderator_types_count = count($moderator_types); - if ($moderator_types_count > 0) { - $form = array(); - $form['akismet_moderator'] = array( - '#type' => 'fieldset', '#title' => t('Akismet moderator settings'), - '#weight' => 5, - '#collapsible' => TRUE, '#collapsed' => FALSE, - '#description' => t('You are currently moderator for the following content types: %types.', array('%types' => implode(', ', $moderator_types))) - ); - $form['akismet_moderator']['akismet_moderator_email_for'] = array( - '#type' => 'radios', '#title' => t('Send me e-mails for'), - '#options' => $moderator_email_for_options, - '#default_value' => (isset($moderator_email_for_options[$edit['akismet_moderator_email_for']]) ? $edit['akismet_moderator_email_for'] : 'approval') - ); - return $form; - } - } - break; - case 'load': - $moderator_types = akismet_get_moderator_types($account); - $moderator_types_count = count($moderator_types); - if ($moderator_types_count > 0) { - $moderator_data = db_fetch_object(db_query('SELECT * FROM {akismet_moderator} WHERE uid = %d', $account->uid)); - $account->akismet_moderator_email_for = (isset($moderator_data->email_for) && isset($moderator_types[$moderator_data->email_for]) ? $moderator_data->email_for : 'approval'); - } - break; - case 'insert': - case 'update': - $moderator_types = akismet_get_moderator_types($account); - $moderator_types_count = count($moderator_types); - if ($moderator_types_count > 0 && isset($edit['akismet_moderator_email_for'])) { - if (!isset($moderator_email_for_options[$edit['akismet_moderator_email_for']])) { - $edit['akismet_moderator_email_for'] = 'approval'; - } - db_query('UPDATE {akismet_moderator} SET email_for = \'%s\' WHERE uid = %d', $edit['akismet_moderator_email_for'], $account->uid); - if (!db_affected_rows()) { - db_query('INSERT INTO {akismet_moderator} (uid, email_for) VALUES (%d, \'%s\')', $account->uid, $edit['akismet_moderator_email_for']); - } - $edit['akismet_moderator_email_for'] = NULL; - break; - } - // Fall through, to remove possible garbage. - case 'delete': - db_query('DELETE FROM {akismet_moderator} WHERE uid = %d', $account->uid); - break; - } - } - - function akismet_notify_users() { - // Proceed only if e-mail notifications are enabled. - if (!variable_get('akismet_email_enabled', 0)) { - return; - } - // @TODO: - } - - /** - * Get the current akismet spam counter. - * - * @return integer - */ - function akismet_get_spam_counter() { - return (int)variable_get('akismet_counter_spam', 0); - } - - /** - * Format the 'Counting since' date. - * - * @return string Counting since date formatted according to module settings. - */ - function akismet_get_counting_since() { - $since = variable_get('akismet_counter_since', array('day' => date('j'), 'month' => date('n'), 'year' => date('Y'))); - $format = variable_get('akismet_counter_date_format', 'F j, Y'); - $replace = array( - 'd' => sprintf('%02d', $since['day']), - 'j' => $since['day'], - 'm' => sprintf('%02d', $since['month']), - 'M' => format_date(gmmktime(0, 0, 0, $since['month'], 2, 1970), 'custom', 'M', 0), - 'F' => format_date(gmmktime(0, 0, 0, $since['month'], 2, 1970), 'custom', 'F', 0), - 'Y' => $since['year'] - ); - return strtr($format, $replace); - } - - /** - * Implementation of hook_block(). - */ - function akismet_block($op = 'list', $delta = 0, $edit = array()) { - static $block_fields = FALSE; - if (!$block_fields) { - $block_fields = array( - 'type' => array( - '#type' => 'radios', - '#title' => t('Display counter as'), - '#options' => array('image' => t('Image'), 'text' => t('Text')), - '#default_value' => 'image' - ), - 'sitename' => array( - '#type' => 'radios', - '#title' => t('Show site name'), - '#options' => array('1' => t('Enabled'), '0' => t('Disabled')), - '#default_value' => '1' - ), - 'newwin' => array( - '#type' => 'radios', - '#title' => t('Open Akismet link in new window'), - '#options' => array('1' => t('Enabled'), '0' => t('Disabled')), - '#default_value' => '1' - ) - ); - } - switch ($op) { - case 'list': - $blocks_counter = variable_get('akismet_blocks_counter', 1); - $blocks = array(); - for ($i = 0; $i < $blocks_counter; $i++) { - $blocks[] = array('info' => t('Akismet spam counter (block:%count)', array('%count' => ($i+1)))); - } - return $blocks; - - case 'configure': - if ($delta < 0 || $delta >= variable_get('akismet_blocks_counter', 1)) { - drupal_set_message(t('Oops! You are requesting a non-existing block, changes will not be saved.'), 'error'); - break; - } - $form = array(); - $form['description'] = array( - '#type' => 'markup', - '#value' => '<div class="description"><p>'. t('These options allow to customize the look of this <em>akismet spam counter</em> block.') .'</p></div>' - ); - $block_settings = variable_get('akismet_blocks_'. $delta, FALSE); - foreach ($block_fields as $field_key => $field_info) { - $field_name = 'akismet_blocks_'. $delta .'_'. $field_key; - $form[$field_name] = array(); - foreach ($field_info as $key => $value) { - $form[$field_name][$key] = $value; - } - if ($block_settings && isset($block_settings[$field_key])) { - $form[$field_name]['#default_value'] = $block_settings[$field_key]; - } - } - return $form; - - case 'save': - if ($delta < 0 || $delta >= variable_get('akismet_blocks_counter', 1)) { - drupal_set_message(t('Oops! You have requested a non-existing block, changes were not saved.'), 'error'); - break; - } - $block_settings = array(); - foreach ($block_fields as $field_key => $field_info) { - $field_name = 'akismet_blocks_'. $delta .'_'. $field_key; - $block_settings[$field_key] = $edit[$field_name]; - } - variable_set('akismet_blocks_'. $delta, $block_settings); - break; - - case 'view': - if ($delta >= 0 && $delta < variable_get('akismet_blocks_counter', 1)) { - $block_settings = variable_get('akismet_blocks_'. $delta, FALSE); - if (!$block_settings) { - $block_settings = array(); - } - - $block_args = array( - 'content' => '', // Built below. - 'counter' => akismet_get_spam_counter(), - 'since' => akismet_get_counting_since(), - 'text' => '', // Built below. - 'image' => '', // Built below. - 'block' => array('delta' => $delta) // completed below with current block settings. - ); - - foreach ($block_fields as $field_key => $field_info) { - if (!isset($block_settings[$field_key])) { - $block_settings[$field_key] = $field_info['#default_value']; - } - $block_args['block'][$field_key] = $block_settings[$field_key]; - } - - $target = ($block_settings['newwin'] ? ' target="_blank"' : ''); - $block_args['text'] = array( - 'plain' => array( - 'short' => check_plain(t('Proudly protected by Akismet, %count spam caught since %since.', array('%site_name' => variable_get('site_name', 'drupal'), '%count' => $block_args['counter'], '%since' => $block_args['since']))), - 'long' => check_plain(t('%site_name is proudly protected by Akismet, %count spam caught since %since.', array('%site_name' => variable_get('site_name', 'drupal'), '%count' => $block_args['counter'], '%since' => $block_args['since']))) - ), - 'html' => array( - 'short' => t('Proudly protected by <a href="%akismet"%target>Akismet</a>, %count spam caught since %since', array('%site_name' => variable_get('site_name', 'drupal'), '%akismet' => 'http://akismet.com', '%target' => $target, '%count' => $block_args['counter'], '%since' => $block_args['since'])), - 'long' => t('%site_name is proudly protected by <a href="%akismet"%target>Akismet</a>, %count spam caught since %since', array('%site_name' => variable_get('site_name', 'drupal'), '%akismet' => 'http://akismet.com', '%target' => $target, '%count' => $block_args['counter'], '%since' => $block_args['since'])) - ) - ); - $text_version = ($block_settings['sitename'] ? 'long' : 'short'); - $title_text = $block_args['text']['plain'][$text_version]; - $image_url = base_path() . drupal_get_path('module', 'akismet') .'/akismet.gif'; - $block_args['image'] = '<img src="'. $image_url .'" title="'. $title_text .'" alt="'. $title_text .'" />'; - - if ($block_settings['type'] == 'image') { - $block_args['content'] = '<a href="http://akismet.com" title="'. $title_text .'"'. $target .'>'. $block_args['image'] .'</a>'; - } - else { - $block_args['content'] = $block_args['text']['html'][$text_version]; - } - - $block = array(); - $block['subject'] = t('Akismet spam counter'); - $block['content'] = theme('akismet_counter_block', $block_args); - return $block; - } - break; - } - } - - /** - * Allow themes customize the content of the akismet spam counter block. - * - * @param array arguments where each element is: - * content: String; the completely built block content. - * counter: Integer; the current spam counter. - * since : String; the formatted 'counting since' date. - * text : Array; with 2 subarrays defined as follows: - * plain: Array with 2 elements ('short' and 'long'). - * html : Array with 2 elements ('short' and 'long'). - * image : String; the completely built IMG tag. - * block : Array; Block settings. - * @return string The content of the block. - */ - function theme_akismet_counter_block($args) { - return $args['content']; - } - - /** * Implementation of hook_menu(). */ --- 451,454 ---- *************** *** 883,886 **** --- 639,643 ---- // If Akismet connections are not enabled, we have nothing else to do here. if (!variable_get('akismet_connection_enabled', 1)) { + akismet_notify_moderators('node', $node, ($node->status ? TRUE : FALSE), FALSE); break; } *************** *** 888,891 **** --- 645,649 ---- // Also quit asap, if current user has administration permission. if (akismet_is_spam_moderator($node->type)) { + akismet_notify_moderators('node', $node, ($node->status ? TRUE : FALSE), FALSE); break; } *************** *** 894,897 **** --- 652,656 ---- $check_nodetypes = variable_get('akismet_check_nodetypes', NULL); if (!is_array($check_nodetypes) || !isset($check_nodetypes[$node->type]) || !$check_nodetypes[$node->type]) { + akismet_notify_moderators('node', $node, ($node->status ? TRUE : FALSE), FALSE); break; } *************** *** 899,903 **** // Ok, let's send a query to Akismet. $akismet_api_result = akismet_api_cmd_comment_check(akismet_prepare_comment_data('node', $node)); ! if ($akismet_api_result != AKISMET_API_RESULT_IS_HAM) { if ($akismet_api_result == AKISMET_API_RESULT_IS_SPAM) { // Oops! Akismet is telling us we got spammed, let's mark the comment as such. --- 658,665 ---- // Ok, let's send a query to Akismet. $akismet_api_result = akismet_api_cmd_comment_check(akismet_prepare_comment_data('node', $node)); ! if ($akismet_api_result == AKISMET_API_RESULT_IS_HAM) { ! akismet_notify_moderators('node', $node, ($node->status ? TRUE : FALSE), FALSE); ! } ! else { if ($akismet_api_result == AKISMET_API_RESULT_IS_SPAM) { // Oops! Akismet is telling us we got spammed, let's mark the comment as such. *************** *** 905,908 **** --- 667,675 ---- // Increment Akismet spam counter variable_set('akismet_counter_spam', akismet_get_spam_counter() + 1); + + akismet_notify_moderators('node', $node, FALSE, TRUE); + } + else { + akismet_notify_moderators('node', $node, FALSE, FALSE); } *************** *** 935,940 **** */ function akismet_comment(&$comment, $op) { ! if ($op == 'delete') { ! db_query('DELETE FROM {akismet_spam_marks} WHERE content_type = \'comment\' AND content_id = %d', $comment->cid); } } --- 702,715 ---- */ function akismet_comment(&$comment, $op) { ! switch ($op) { ! 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); ! } ! break; ! case 'delete': ! db_query('DELETE FROM {akismet_spam_marks} WHERE content_type = \'comment\' AND content_id = %d', $comment->cid); ! break; } } *************** *** 1007,1011 **** if ($comment) { $akismet_api_result = akismet_api_cmd_comment_check(akismet_prepare_comment_data('comment', $comment)); ! if ($akismet_api_result != AKISMET_API_RESULT_IS_HAM) { if ($akismet_api_result == AKISMET_API_RESULT_IS_SPAM) { // Oops! Akismet is telling us we got spammed, let's mark the comment as such. --- 782,789 ---- if ($comment) { $akismet_api_result = akismet_api_cmd_comment_check(akismet_prepare_comment_data('comment', $comment)); ! if ($akismet_api_result == AKISMET_API_RESULT_IS_HAM) { ! akismet_notify_moderators('comment', $comment, ($comment->status == COMMENT_PUBLISHED ? TRUE : FALSE), FALSE); ! } ! else { if ($akismet_api_result == AKISMET_API_RESULT_IS_SPAM) { // Oops! Akismet is telling us we got spammed, let's mark the comment as such. *************** *** 1013,1016 **** --- 791,799 ---- // Increment Akismet spam counter variable_set('akismet_counter_spam', akismet_get_spam_counter() + 1); + + akismet_notify_moderators('comment', $comment, FALSE, TRUE); + } + else { + akismet_notify_moderators('comment', $comment, FALSE, FALSE); } *************** *** 1237,1240 **** --- 1020,1380 ---- /** + * Notify moderators of new/updated content, only content needing approval or nothing at all. + * + * @param string Content type; can be either 'node' or 'comment'. + * @param object Content object. + * @param boolean TRUE if content is in published status. + * @param boolean TRUE if content has been marked as spam. + */ + function akismet_notify_moderators($content_type, $content, $is_published, $is_spam) { + global $base_url; + + // Proceed only if e-mail notifications are enabled. + if (!variable_get('akismet_email_enabled', 0)) { + return; + } + + // Make sure we have an object. + $content = (object)$content; + + // Compute the related moderator permission. + if ($content_type == 'comment') { + $moderator_permission = 'moderate spam in comments'; + $administer_permission = 'administer comments'; + } + else { + $moderator_types = akismet_get_moderator_types($account); + $moderator_permission = 'moderate spam in nodes of type '. $moderator_types[$content->type]; + $administer_permission = 'administer nodes'; + } + + // Obtain list of moderators of the specified content type. + $sql = 'SELECT u.uid, u.name, u.mail, m.email_for'. + ' FROM {permission} p'. + ' INNER JOIN {users_roles} r ON r.rid = p.rid'. + ' INNER JOIN {users} u ON u.uid = r.uid OR u.uid = 1'. + ' LEFT JOIN {akismet_moderator} m ON m.uid = u.uid'. + ' WHERE p.perm LIKE \'%%%s%%\''. + ' OR p.perm LIKE \'%%%s%%\''; + $result = db_query($sql, $moderator_permission, $administer_permission); + $moderators = array(); + while ($u = db_fetch_object($result)) { + $moderators[$u->uid] = array( + 'name' => $u->name, + 'email_to' => $u->mail, + 'email_for' => (!is_null($u->email_for) ? $u->email_for : 'approval') + ); + } + + // Extract unique email addresses and ignore those who have requested to not get e-mail notifications. + $unique_emails = array(); + foreach ($moderators as $uid => $moderator) { + if ($moderator['email_for'] == 'all' || ($moderator['email_for'] == 'approval' && !$is_published)) { + if (!isset($unique_emails[$moderator['email_to']])) { + $unique_emails[$moderator['email_to']] = $uid; + } + } + } + if (count($unique_emails) <= 0) { + return; + } + + // If this is about a comment, try to load the node. + // Also, prepare arguments for notification message. + $site_name = variable_get('site_name', t('Drupal')); + if ($content_type == 'comment') { + if (!($node = akismet_content_load('node', $content->nid))) { + watchdog('akismet', t('An error has ocurred while trying to notify moderators about a comment. The associated node could not be loaded.'), WATCHDOG_NOTICE, l(t('view'), 'node/'. $content->nid, NULL, NULL, 'comment-'. $content->cid)); + return; + } + $message_args = array( + '%title-label' => t('Subject'), + '%content-title' => check_plain($content->subject), + '%content-type' => t('comment'), + '%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 { + $message_args = array( + '%title-label' => t('Title'), + '%content-title' => check_plain($content->title), + '%content-type' => check_plain($moderator_types[$content->type]), + '%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') .')' : ''); + $message_args['%site-name'] = check_plain($site_name); + $message_args['%site-link'] = $base_url . base_path(); + + $message_body = t(<<<EOT + Hello %user-name, + + You can use the following information to review this %content-type: + + %title-label: %content-title + URL: %content-link + Status: %content-status + + Please, do not reply to this e-mail. It is an automated notification you are receiving because you are a moderator at %site-name. If you no longer wish to receive such notifications, you can change your moderator settings in your user profile. + + Thank you + + %site-link + EOT + , $message_args); + + // Log the notification to watchdog. + watchdog('akismet', t('Trying to notify the following recipients: %emails', array('%emails' => implode(', ', array_keys($unique_emails))))); + + // Send e-mails. + $site_mail = variable_get('site_mail', ini_get('sendmail_from')); + $headers = "From: $site_mail\nReply-to: $site_mail\nX-Mailer: Drupal\nReturn-path: $site_mail\nErrors-to: $site_mail"; + foreach ($unique_emails as $email_to => $uid) { + user_mail( + $email_to, + $message_title, + str_replace('%user-name', check_plain($moderators[$uid]['name']), $message_body), + $headers + ); + } + } + + /** + * Implementation of hook_user(). + */ + function akismet_user($op, &$edit, &$account, $category = NULL) { + $moderator_email_for_options = array( + 'all' => t('All new (or updated) content'), + 'approval' => t('Only content needing approval'), + 'never' => t('Never') + ); + switch ($op) { + case 'form': + if ($category == 'account' && variable_get('akismet_email_enabled', 1)) { + $moderator_types = akismet_get_moderator_types($account); + $moderator_types_count = count($moderator_types); + if ($moderator_types_count > 0) { + $form = array(); + $form['akismet_moderator'] = array( + '#type' => 'fieldset', '#title' => t('Akismet moderator settings'), + '#weight' => 5, + '#collapsible' => TRUE, '#collapsed' => FALSE, + '#description' => t('You are currently moderator for the following content types: %types.', array('%types' => implode(', ', $moderator_types))) + ); + $form['akismet_moderator']['akismet_moderator_email_for'] = array( + '#type' => 'radios', '#title' => t('Send me e-mails for'), + '#options' => $moderator_email_for_options, + '#default_value' => (isset($moderator_email_for_options[$edit['akismet_moderator_email_for']]) ? $edit['akismet_moderator_email_for'] : 'approval') + ); + return $form; + } + } + break; + case 'load': + $moderator_types = akismet_get_moderator_types($account); + $moderator_types_count = count($moderator_types); + if ($moderator_types_count > 0) { + $moderator_data = db_fetch_object(db_query('SELECT * FROM {akismet_moderator} WHERE uid = %d', $account->uid)); + $account->akismet_moderator_email_for = (isset($moderator_data->email_for) && isset($moderator_email_for_options[$moderator_data->email_for]) ? $moderator_data->email_for : 'approval'); + } + break; + case 'insert': + case 'update': + $moderator_types = akismet_get_moderator_types($account); + $moderator_types_count = count($moderator_types); + if ($moderator_types_count > 0 && isset($edit['akismet_moderator_email_for'])) { + if (!isset($moderator_email_for_options[$edit['akismet_moderator_email_for']])) { + $edit['akismet_moderator_email_for'] = 'approval'; + } + db_query('UPDATE {akismet_moderator} SET email_for = \'%s\' WHERE uid = %d', $edit['akismet_moderator_email_for'], $account->uid); + if (!db_affected_rows()) { + db_query('INSERT INTO {akismet_moderator} (uid, email_for) VALUES (%d, \'%s\')', $account->uid, $edit['akismet_moderator_email_for']); + } + $edit['akismet_moderator_email_for'] = NULL; + break; + } + // Fall through, to remove possible garbage. + case 'delete': + db_query('DELETE FROM {akismet_moderator} WHERE uid = %d', $account->uid); + break; + } + } + + /** + * Get the current akismet spam counter. + * + * @return integer + */ + function akismet_get_spam_counter() { + return (int)variable_get('akismet_counter_spam', 0); + } + + /** + * Format the 'Counting since' date. + * + * @return string Counting since date formatted according to module settings. + */ + function akismet_get_counting_since() { + $since = variable_get('akismet_counter_since', array('day' => date('j'), 'month' => date('n'), 'year' => date('Y'))); + $format = variable_get('akismet_counter_date_format', 'F j, Y'); + $replace = array( + 'd' => sprintf('%02d', $since['day']), + 'j' => $since['day'], + 'm' => sprintf('%02d', $since['month']), + 'M' => format_date(gmmktime(0, 0, 0, $since['month'], 2, 1970), 'custom', 'M', 0), + 'F' => format_date(gmmktime(0, 0, 0, $since['month'], 2, 1970), 'custom', 'F', 0), + 'Y' => $since['year'] + ); + return strtr($format, $replace); + } + + /** + * Implementation of hook_block(). + */ + function akismet_block($op = 'list', $delta = 0, $edit = array()) { + static $block_fields = FALSE; + if (!$block_fields) { + $block_fields = array( + 'type' => array( + '#type' => 'radios', + '#title' => t('Display counter as'), + '#options' => array('image' => t('Image'), 'text' => t('Text')), + '#default_value' => 'image' + ), + 'sitename' => array( + '#type' => 'radios', + '#title' => t('Show site name'), + '#options' => array('1' => t('Enabled'), '0' => t('Disabled')), + '#default_value' => '1' + ), + 'newwin' => array( + '#type' => 'radios', + '#title' => t('Open Akismet link in new window'), + '#options' => array('1' => t('Enabled'), '0' => t('Disabled')), + '#default_value' => '1' + ) + ); + } + switch ($op) { + case 'list': + $blocks_counter = variable_get('akismet_blocks_counter', 1); + $blocks = array(); + for ($i = 0; $i < $blocks_counter; $i++) { + $blocks[] = array('info' => t('Akismet spam counter (block:%count)', array('%count' => ($i+1)))); + } + return $blocks; + + case 'configure': + if ($delta < 0 || $delta >= variable_get('akismet_blocks_counter', 1)) { + drupal_set_message(t('Oops! You are requesting a non-existing block, changes will not be saved.'), 'error'); + break; + } + $form = array(); + $form['description'] = array( + '#type' => 'markup', + '#value' => '<div class="description"><p>'. t('These options allow to customize the look of this <em>akismet spam counter</em> block.') .'</p></div>' + ); + $block_settings = variable_get('akismet_blocks_'. $delta, FALSE); + foreach ($block_fields as $field_key => $field_info) { + $field_name = 'akismet_blocks_'. $delta .'_'. $field_key; + $form[$field_name] = array(); + foreach ($field_info as $key => $value) { + $form[$field_name][$key] = $value; + } + if ($block_settings && isset($block_settings[$field_key])) { + $form[$field_name]['#default_value'] = $block_settings[$field_key]; + } + } + return $form; + + case 'save': + if ($delta < 0 || $delta >= variable_get('akismet_blocks_counter', 1)) { + drupal_set_message(t('Oops! You have requested a non-existing block, changes were not saved.'), 'error'); + break; + } + $block_settings = array(); + foreach ($block_fields as $field_key => $field_info) { + $field_name = 'akismet_blocks_'. $delta .'_'. $field_key; + $block_settings[$field_key] = $edit[$field_name]; + } + variable_set('akismet_blocks_'. $delta, $block_settings); + break; + + case 'view': + if ($delta >= 0 && $delta < variable_get('akismet_blocks_counter', 1)) { + $block_settings = variable_get('akismet_blocks_'. $delta, FALSE); + if (!$block_settings) { + $block_settings = array(); + } + + $block_args = array( + 'content' => '', // Built below. + 'counter' => akismet_get_spam_counter(), + 'since' => akismet_get_counting_since(), + 'text' => '', // Built below. + 'image' => '', // Built below. + 'block' => array('delta' => $delta) // completed below with current block settings. + ); + + foreach ($block_fields as $field_key => $field_info) { + if (!isset($block_settings[$field_key])) { + $block_settings[$field_key] = $field_info['#default_value']; + } + $block_args['block'][$field_key] = $block_settings[$field_key]; + } + + $target = ($block_settings['newwin'] ? ' target="_blank"' : ''); + $block_args['text'] = array( + 'plain' => array( + 'short' => check_plain(t('Proudly protected by Akismet, %count spam caught since %since.', array('%site_name' => variable_get('site_name', 'drupal'), '%count' => $block_args['counter'], '%since' => $block_args['since']))), + 'long' => check_plain(t('%site_name is proudly protected by Akismet, %count spam caught since %since.', array('%site_name' => variable_get('site_name', 'drupal'), '%count' => $block_args['counter'], '%since' => $block_args['since']))) + ), + 'html' => array( + 'short' => t('Proudly protected by <a href="%akismet"%target>Akismet</a>, %count spam caught since %since', array('%site_name' => variable_get('site_name', 'drupal'), '%akismet' => 'http://akismet.com', '%target' => $target, '%count' => $block_args['counter'], '%since' => $block_args['since'])), + 'long' => t('%site_name is proudly protected by <a href="%akismet"%target>Akismet</a>, %count spam caught since %since', array('%site_name' => variable_get('site_name', 'drupal'), '%akismet' => 'http://akismet.com', '%target' => $target, '%count' => $block_args['counter'], '%since' => $block_args['since'])) + ) + ); + $text_version = ($block_settings['sitename'] ? 'long' : 'short'); + $title_text = $block_args['text']['plain'][$text_version]; + $image_url = base_path() . drupal_get_path('module', 'akismet') .'/akismet.gif'; + $block_args['image'] = '<img src="'. $image_url .'" title="'. $title_text .'" alt="'. $title_text .'" />'; + + if ($block_settings['type'] == 'image') { + $block_args['content'] = '<a href="http://akismet.com" title="'. $title_text .'"'. $target .'>'. $block_args['image'] .'</a>'; + } + else { + $block_args['content'] = $block_args['text']['html'][$text_version]; + } + + $block = array(); + $block['subject'] = t('Akismet spam counter'); + $block['content'] = theme('akismet_counter_block', $block_args); + return $block; + } + break; + } + } + + /** + * Allow themes customize the content of the akismet spam counter block. + * + * @param array arguments where each element is: + * content: String; the completely built block content. + * counter: Integer; the current spam counter. + * since : String; the formatted 'counting since' date. + * text : Array; with 2 subarrays defined as follows: + * plain: Array with 2 elements ('short' and 'long'). + * html : Array with 2 elements ('short' and 'long'). + * image : String; the completely built IMG tag. + * block : Array; Block settings. + * @return string The content of the block. + */ + function theme_akismet_counter_block($args) { + return $args['content']; + } + + /** * Load a node or a comment. * |
From: <php...@li...> - 2006-06-10 19:01:19
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7310 Modified Files: akismet.module Log Message: Reviewed module settings regarding e-mail notifications. Implementation of hook_user to let users decide whether they wish to get e-mail notifications for all content, just content in need of approval or nothing at all. Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** akismet.module 10 Jun 2006 13:36:35 -0000 1.17 --- akismet.module 10 Jun 2006 19:01:04 -0000 1.18 *************** *** 60,68 **** 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; --- 60,68 ---- 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; *************** *** 137,141 **** // 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)) { --- 137,141 ---- // 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)) { *************** *** 145,149 **** } } ! $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)) { --- 145,149 ---- } } ! $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)) { *************** *** 200,208 **** 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) { --- 200,208 ---- 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) { *************** *** 261,265 **** ); 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( --- 261,265 ---- ); 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( *************** *** 326,329 **** --- 326,335 ---- )) ); + $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( *************** *** 443,481 **** ); ! $email_to_options = array( ! 'site_email' => t('Main Site Address'), ! 'site_admin' => t('Main Site Administrator'), ! 'content_admins' => t('Content Administrators'), ! 'content_moderators' => t('Content Moderators') ! ); ! $email_when_options = array( ! 'all' => t('Content is posted'), 'approval' => t('Only content needing approval'), 'never' => t('Never') ); ! $form['email_options'] = array( ! '#type' => 'fieldset', '#title' => t('E-mail Options'), ! '#collapsible' => TRUE, '#collapsed' => TRUE ! ); ! $form['email_options']['akismet_email_to'] = array( ! '#type' => 'checkboxes', '#title' => t('Send e-mails to'), ! '#options' => $email_to_options, ! '#default_value' => variable_get('akismet_email_to', 0), ! '#description' => t('Use this option to select groups of users to whom e-mail notifications will be sent, when content is posted, based on the criteria specified below. It worths to mention that content administrators and moderators will only be notified about posts they have proper access to.') ! ); ! $form['email_options']['akismet_email_exclude_self'] = array( ! '#type' => 'radios', '#title' => t('Exclude notifications to self poster'), ! '#options' => $enable_options, ! '#default_value' => variable_get('akismet_email_exclude_self', 1), ! '#description' => t('Use this option to exclude self poster from receiving e-mail notifications.') ! ); ! $form['email_options']['akismet_email_when'] = array( ! '#type' => 'radios', '#title' => t('Send e-mails when'), ! '#options' => $email_when_options, ! '#default_value' => variable_get('akismet_email_when', 'approval'), ! '#description' => t('Use this option to specify the critica for which the user groups specified above should receive e-mail notifications.') ! ); ! return $form; } --- 449,522 ---- ); ! return $form; ! } ! ! /** ! * Implementation of hook_user(). ! */ ! function akismet_user($op, &$edit, &$account, $category = NULL) { ! $moderator_email_for_options = array( ! 'all' => t('All new (or updated) content'), 'approval' => t('Only content needing approval'), 'never' => t('Never') ); ! switch ($op) { ! case 'form': ! if ($category == 'account' && variable_get('akismet_email_enabled', 1)) { ! $moderator_types = akismet_get_moderator_types($account); ! $moderator_types_count = count($moderator_types); ! if ($moderator_types_count > 0) { ! $form = array(); ! $form['akismet_moderator'] = array( ! '#type' => 'fieldset', '#title' => t('Akismet moderator settings'), ! '#weight' => 5, ! '#collapsible' => TRUE, '#collapsed' => FALSE, ! '#description' => t('You are currently moderator for the following content types: %types.', array('%types' => implode(', ', $moderator_types))) ! ); ! $form['akismet_moderator']['akismet_moderator_email_for'] = array( ! '#type' => 'radios', '#title' => t('Send me e-mails for'), ! '#options' => $moderator_email_for_options, ! '#default_value' => (isset($moderator_email_for_options[$edit['akismet_moderator_email_for']]) ? $edit['akismet_moderator_email_for'] : 'approval') ! ); ! return $form; ! } ! } ! break; ! case 'load': ! $moderator_types = akismet_get_moderator_types($account); ! $moderator_types_count = count($moderator_types); ! if ($moderator_types_count > 0) { ! $moderator_data = db_fetch_object(db_query('SELECT * FROM {akismet_moderator} WHERE uid = %d', $account->uid)); ! $account->akismet_moderator_email_for = (isset($moderator_data->email_for) && isset($moderator_types[$moderator_data->email_for]) ? $moderator_data->email_for : 'approval'); ! } ! break; ! case 'insert': ! case 'update': ! $moderator_types = akismet_get_moderator_types($account); ! $moderator_types_count = count($moderator_types); ! if ($moderator_types_count > 0 && isset($edit['akismet_moderator_email_for'])) { ! if (!isset($moderator_email_for_options[$edit['akismet_moderator_email_for']])) { ! $edit['akismet_moderator_email_for'] = 'approval'; ! } ! db_query('UPDATE {akismet_moderator} SET email_for = \'%s\' WHERE uid = %d', $edit['akismet_moderator_email_for'], $account->uid); ! if (!db_affected_rows()) { ! db_query('INSERT INTO {akismet_moderator} (uid, email_for) VALUES (%d, \'%s\')', $account->uid, $edit['akismet_moderator_email_for']); ! } ! $edit['akismet_moderator_email_for'] = NULL; ! break; ! } ! // Fall through, to remove possible garbage. ! case 'delete': ! db_query('DELETE FROM {akismet_moderator} WHERE uid = %d', $account->uid); ! break; ! } ! } ! function akismet_notify_users() { ! // Proceed only if e-mail notifications are enabled. ! if (!variable_get('akismet_email_enabled', 0)) { ! return; ! } ! // @TODO: } *************** *** 716,731 **** if (variable_get('akismet_node_publish_links', 0)) { if ($content->status) { ! $links[] = l(t('unpublish'), "akismet/node/$content->nid/unpublish"); } else { ! $links[] = l(t('publish'), "akismet/node/$content->nid/publish"); } } if (variable_get('akismet_node_spam_links', 0)) { if (akismet_content_is_spam('node', $content->nid)) { ! $links[] = l((variable_get('akismet_connection_enabled', 1) ? t('submit ham') : t('mark as ham')), "akismet/node/$content->nid/submit-ham"); } else { ! $links[] = l((variable_get('akismet_connection_enabled', 1) ? t('submit spam') : t('mark as spam')), "akismet/node/$content->nid/submit-spam"); } } --- 757,772 ---- if (variable_get('akismet_node_publish_links', 0)) { if ($content->status) { ! $links[] = l(t('unpublish'), 'akismet/node/'. $content->nid .'/unpublish'); } else { ! $links[] = l(t('publish'), 'akismet/node/'. $content->nid .'/publish'); } } if (variable_get('akismet_node_spam_links', 0)) { if (akismet_content_is_spam('node', $content->nid)) { ! $links[] = l((variable_get('akismet_connection_enabled', 1) ? t('submit ham') : t('mark as ham')), 'akismet/node/'. $content->nid .'/submit-ham'); } else { ! $links[] = l((variable_get('akismet_connection_enabled', 1) ? t('submit spam') : t('mark as spam')), 'akismet/node/'. $content->nid .'/submit-spam'); } } *************** *** 734,749 **** if (variable_get('akismet_comment_publish_links', 1)) { if ($content->status == COMMENT_PUBLISHED) { ! $links[] = l(t('unpublish'), "akismet/comment/$content->cid/unpublish"); } else if ($content->status == COMMENT_NOT_PUBLISHED) { ! $links[] = l(t('publish'), "akismet/comment/$content->cid/publish"); } } if (variable_get('akismet_comment_spam_links', 1)) { if (akismet_content_is_spam('comment', $content->cid)) { ! $links[] = l((variable_get('akismet_connection_enabled', 1) ? t('submit ham') : t('mark as ham')), "akismet/comment/$content->cid/submit-ham"); } else { ! $links[] = l((variable_get('akismet_connection_enabled', 1) ? t('submit spam') : t('mark as spam')), "akismet/comment/$content->cid/submit-spam"); } } --- 775,790 ---- if (variable_get('akismet_comment_publish_links', 1)) { if ($content->status == COMMENT_PUBLISHED) { ! $links[] = l(t('unpublish'), 'akismet/comment/'. $content->cid .'/unpublish'); } else if ($content->status == COMMENT_NOT_PUBLISHED) { ! $links[] = l(t('publish'), 'akismet/comment/'. $content->cid .'/publish'); } } if (variable_get('akismet_comment_spam_links', 1)) { if (akismet_content_is_spam('comment', $content->cid)) { ! $links[] = l((variable_get('akismet_connection_enabled', 1) ? t('submit ham') : t('mark as ham')), 'akismet/comment/'. $content->cid .'/submit-ham'); } else { ! $links[] = l((variable_get('akismet_connection_enabled', 1) ? t('submit spam') : t('mark as spam')), 'akismet/comment/'. $content->cid .'/submit-spam'); } } *************** *** 778,785 **** if ($content_type == 'node') { ! drupal_goto("node/$content->nid"); } else { // comment ! drupal_goto("node/$content->nid", NULL, "comment-$content->cid"); } } --- 819,826 ---- if ($content_type == 'node') { ! drupal_goto('node/'. $content->nid); } else { // comment ! drupal_goto('node/'. $content->nid, NULL, 'comment-'. $content->cid); } } *************** *** 826,833 **** if ($content_type == 'node') { ! drupal_goto("node/$content->nid"); } else { // comment ! drupal_goto("node/$content->nid", NULL, "comment-$content->cid"); } } --- 867,874 ---- if ($content_type == 'node') { ! drupal_goto('node/'. $content->nid); } else { // comment ! drupal_goto('node/'. $content->nid, NULL, 'comment-'. $content->cid); } } *************** *** 877,889 **** // Record the event to watchdog. if ($akismet_api_result == AKISMET_API_RESULT_ERROR) { ! watchdog('content', t('Akismet service seems to be down, %content-type-name queued for manual approval: %title', array('%content-type-name' => $content_type_name, '%title' => theme('placeholder', $node->title))), WATCHDOG_WARNING, l(t('view'), "node/$node->nid")); } 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")); } } break; case 'delete': ! db_query("DELETE FROM {akismet_spam_marks} WHERE content_type = 'node' AND content_id = %d", $node->nid); break; } --- 918,930 ---- // Record the event to watchdog. if ($akismet_api_result == AKISMET_API_RESULT_ERROR) { ! watchdog('content', t('Akismet service seems to be down, %content-type-name queued for manual approval: %title', array('%content-type-name' => $content_type_name, '%title' => theme('placeholder', $node->title))), WATCHDOG_WARNING, l(t('view'), 'node/'. $node->nid)); } 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)); } } break; case 'delete': ! db_query('DELETE FROM {akismet_spam_marks} WHERE content_type = \'node\' AND content_id = %d', $node->nid); break; } *************** *** 895,899 **** function akismet_comment(&$comment, $op) { if ($op == 'delete') { ! db_query("DELETE FROM {akismet_spam_marks} WHERE content_type = 'comment' AND content_id = %d", $comment->cid); } } --- 936,940 ---- function akismet_comment(&$comment, $op) { if ($op == 'delete') { ! db_query('DELETE FROM {akismet_spam_marks} WHERE content_type = \'comment\' AND content_id = %d', $comment->cid); } } *************** *** 984,991 **** // Record the event to watchdog. if ($akismet_api_result == AKISMET_API_RESULT_ERROR) { ! watchdog('content', t('Akismet service seems to be down, comment queued for manual approval: %subject', array('%subject' => theme('placeholder', $comment->subject))), WATCHDOG_WARNING, l(t('view'), "node/$comment->nid", NULL, NULL, "comment-$comment->cid")); } 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")); } } --- 1025,1032 ---- // Record the event to watchdog. if ($akismet_api_result == AKISMET_API_RESULT_ERROR) { ! watchdog('content', t('Akismet service seems to be down, comment queued for manual approval: %subject', array('%subject' => theme('placeholder', $comment->subject))), WATCHDOG_WARNING, l(t('view'), 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid)); } 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)); } } *************** *** 1016,1028 **** $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; } --- 1057,1069 ---- $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; } *************** *** 1070,1074 **** 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), --- 1111,1115 ---- 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), *************** *** 1080,1084 **** $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')), --- 1121,1125 ---- $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')), *************** *** 1109,1113 **** */ function akismet_content_is_spam($content_type, $content_id) { ! return db_result(db_query("SELECT 1 FROM {akismet_spam_marks} WHERE content_type = '%s' AND content_id = %d", $content_type, $content_id)); } --- 1150,1154 ---- */ function akismet_content_is_spam($content_type, $content_id) { ! return db_result(db_query('SELECT 1 FROM {akismet_spam_marks} WHERE content_type = \'%s\' AND content_id = %d', $content_type, $content_id)); } *************** *** 1138,1169 **** * Get the types the current user is allowed to moderate. * * @return array Moderator Types. */ ! function akismet_get_moderator_types() { ! static $moderator_types = FALSE; ! if ($moderator_types === FALSE) { ! $moderator_types = array(); $node_types = node_get_types(); ! if (user_access('administer nodes')) { foreach ($node_types as $type => $name) { ! $moderator_types[$type] = $name; } } else { foreach ($node_types as $type => $name) { ! if (user_access('moderate spam in nodes of type '. $node_types[$type])) { ! $moderator_types[$type] = $name; } } } ! if (user_access('administer comments') || user_access('moderate spam in comments')) { ! $moderator_types['comments'] = t('comments'); } } ! return $moderator_types; } --- 1179,1218 ---- * Get the types the current user is allowed to moderate. * + * @param object The account to check; use current user if not given. * @return array Moderator Types. */ ! function akismet_get_moderator_types($account = NULL) { ! global $user; ! static $node_types = FALSE; ! static $moderator_types = array(); ! if (is_null($account)) { ! $account = $user; ! } ! ! if ($node_types === FALSE) { $node_types = node_get_types(); + } ! if (!isset($moderator_types[$account->uid])) { ! if (user_access('administer nodes', $account)) { foreach ($node_types as $type => $name) { ! $moderator_types[$account->uid][$type] = $name; } } else { foreach ($node_types as $type => $name) { ! if (user_access('moderate spam in nodes of type '. $node_types[$type], $account)) { ! $moderator_types[$account->uid][$type] = $name; } } } ! if (user_access('administer comments', $account) || user_access('moderate spam in comments', $account)) { ! $moderator_types[$account->uid]['comments'] = t('comments'); } } ! return $moderator_types[$account->uid]; } *************** *** 1171,1179 **** * Is current user spam moderator? * ! * @param string Moderator Type ('comments' or node type). * @return boolean TRUE if current user is moderator of specified type; FALSE otherwise. */ ! function akismet_is_spam_moderator($moderator_type) { ! $moderator_types = akismet_get_moderator_types(); return isset($moderator_types[$moderator_type]); } --- 1220,1236 ---- * Is current user spam moderator? * ! * @param string Moderator Type (comments, node type or NULL). ! * @param object The account to check; use current user if not given. * @return boolean TRUE if current user is moderator of specified type; FALSE otherwise. */ ! function akismet_is_spam_moderator($moderator_type = NULL, $account = NULL) { ! global $user; ! if (is_null($account)) { ! $account = $user; ! } ! $moderator_types = akismet_get_moderator_types($account); ! if (is_null($moderator_type)) { ! return (count($moderator_types) > 0 ? TRUE : FALSE); ! } return isset($moderator_types[$moderator_type]); } *************** *** 1280,1293 **** $content_id = $content->nid; $content_title = $content->title; ! $content_link = l(t('view'), "node/$content->nid"); } else { // comment $content_id = $content->cid; $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)) { --- 1337,1350 ---- $content_id = $content->nid; $content_title = $content->title; ! $content_link = l(t('view'), 'node/'. $content->nid); } else { // comment $content_id = $content->cid; $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)) { *************** *** 1300,1304 **** } else { // submit-ham ! db_query("DELETE FROM {akismet_spam_marks} WHERE content_type = '%s' AND content_id = %d", $content_type, $content_id); if (variable_get('akismet_connection_enabled', 1)) { --- 1357,1361 ---- } else { // submit-ham ! db_query('DELETE FROM {akismet_spam_marks} WHERE content_type = \'%s\' AND content_id = %d', $content_type, $content_id); if (variable_get('akismet_connection_enabled', 1)) { *************** *** 1335,1339 **** if ($log_action) { $action = ($op == 'publish' ? t('Content published') : t('Content unpublished')); ! watchdog('content', t('%action: %title', array('%action' => $action, '%title' => theme('placeholder', $content->title))), WATCHDOG_NOTICE, l(t('view'), "node/$content->nid")); } } --- 1392,1396 ---- if ($log_action) { $action = ($op == 'publish' ? t('Content published') : t('Content unpublished')); ! watchdog('content', t('%action: %title', array('%action' => $action, '%title' => theme('placeholder', $content->title))), WATCHDOG_NOTICE, l(t('view'), 'node/'. $content->nid)); } } *************** *** 1359,1363 **** if ($log_action) { $action = ($op == 'publish' ? t('Comment published') : t('Comment unpublished')); ! watchdog('content', t('%action: %subject', array('%action' => $action, '%subject' => theme('placeholder', $content->subject))), WATCHDOG_NOTICE, l(t('view'), "node/$content->nid", NULL, NULL, "comment-$content->cid")); } } --- 1416,1420 ---- if ($log_action) { $action = ($op == 'publish' ? t('Comment published') : t('Comment unpublished')); ! watchdog('content', t('%action: %subject', array('%action' => $action, '%subject' => theme('placeholder', $content->subject))), WATCHDOG_NOTICE, l(t('view'), 'node/'. $content->nid, NULL, NULL, 'comment-'. $content->cid)); } } *************** *** 1390,1394 **** // Prepare data that varies depending on type of content. if ($content_type == 'comment') { ! $comment_data['permalink'] = url("node/$content->nid", NULL, "comment-$content->cid", TRUE); $comment_data['comment_author_email'] = $content->mail; $comment_data['comment_author_url'] = $content->homepage; --- 1447,1451 ---- // Prepare data that varies depending on type of content. if ($content_type == 'comment') { ! $comment_data['permalink'] = url('node/'. $content->nid, NULL, 'comment-'. $content->cid, TRUE); $comment_data['comment_author_email'] = $content->mail; $comment_data['comment_author_url'] = $content->homepage; *************** *** 1397,1401 **** else { global $user; ! $comment_data['permalink'] = url("node/$content->nid"); $comment_data['comment_author_email'] = $user->mail; $comment_data['comment_author_url'] = ''; --- 1454,1458 ---- else { global $user; ! $comment_data['permalink'] = url('node/'. $content->nid); $comment_data['comment_author_email'] = $user->mail; $comment_data['comment_author_url'] = ''; *************** *** 1461,1470 **** */ function _akismet_get_version_message($url) { - global $user; - if ($user->uid != 1) { - return ''; - } $new_version = _akismet_check_version(isset($_GET['vchk']) ? TRUE : FALSE); - $output = ''; if (empty($new_version)) { drupal_set_message(t('Sorry, could not connect to remote server to check for new version information. Please, consult the <a href="%admin-logs">log</a> for details.', array('%admin-logs' => url('admin/logs'))), 'error'); --- 1518,1522 ---- *************** *** 1478,1489 **** } } - $output = '<p>'; - $output .= t('You are running version <strong>%your-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION)); $timestamp_last = variable_get('akismet_version_check_timestamp', 0); ! if ($timestamp_last) { ! $output .= '<br />'. t('Last time checked: %last. The time is now %time.', array('%last' => format_date($timestamp_last), '%time' => format_date(time()))); ! } ! $output .= '<br />'. t('<a href="%check">Check for newest version</a>.', array('%check' => url($url, 'vchk=1'))); ! $output .= '</p>'; return $output; } --- 1530,1539 ---- } } $timestamp_last = variable_get('akismet_version_check_timestamp', 0); ! $output = '<p>' ! .t('You are running version <strong>%your-version</strong>', array('%your-version' => AKISMET_MODULE_VERSION)) ! .($timestamp_last > 0 ? ', '. t('version checked %time ago', array('%time' => format_interval(time() - $timestamp_last))) : '') ! .'. '. t('<a href="%check">Check for newest version</a>.', array('%check' => url($url, 'vchk=1'))) ! .'</p>'; return $output; } *************** *** 1502,1506 **** global $base_url; if (!empty($key)) { ! $request = "key=$key&blog=$base_url". base_path(); $response = _akismet_api_http_post($request, AKISMET_API_HOST, '/'. AKISMET_API_VERSION .'/verify-key'); } --- 1552,1556 ---- global $base_url; if (!empty($key)) { ! $request = 'key='. $key .'&blog='. $base_url . base_path(); $response = _akismet_api_http_post($request, AKISMET_API_HOST, '/'. AKISMET_API_VERSION .'/verify-key'); } *************** *** 1641,1646 **** ."Host: $host\r\n" ."Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" ! ."Content-Length: ". strlen($request) ."\r\n" ! ."User-Agent: ". AKISMET_API_USERAGENT ."\r\n" ."\r\n" .$request; --- 1691,1696 ---- ."Host: $host\r\n" ."Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" ! .'Content-Length: '. strlen($request) ."\r\n" ! .'User-Agent: '. AKISMET_API_USERAGENT ."\r\n" ."\r\n" .$request; |
From: <php...@li...> - 2006-06-10 17:57:38
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14944 Modified Files: akismet.install Log Message: Ahem, the new table is for moderator options so better change the name. Index: akismet.install =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.install,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** akismet.install 10 Jun 2006 17:50:00 -0000 1.2 --- akismet.install 10 Jun 2006 17:57:35 -0000 1.3 *************** *** 18,22 **** INDEX spam_created (spam_created) ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); ! db_query("CREATE TABLE {akismet_user} ( uid int(10) unsigned NOT NULL default 0, email_for varchar(20) NOT NULL default '', --- 18,22 ---- INDEX spam_created (spam_created) ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); ! db_query("CREATE TABLE {akismet_moderator} ( uid int(10) unsigned NOT NULL default 0, email_for varchar(20) NOT NULL default '', *************** *** 34,43 **** db_query("CREATE UNIQUE INDEX {akismet_spam_marks_content} ON {akismet_spam_marks} (content_type, content_id)"); db_query("CREATE INDEX {akismet_spam_marks_spamcreated} ON {akismet_spam_marks} (spam_created)"); ! db_query("CREATE TABLE {akismet_user} ( uid INTEGER NOT NULL DEFAULT 0 CHECK (uid >= 0), email_for VARCHAR(20) NOT NULL DEFAULT '', PRIMARY KEY (uid) )"); ! db_query("CREATE INDEX {akismet_user_email_for} ON {akismet_user} (email_for)"); break; } --- 34,43 ---- db_query("CREATE UNIQUE INDEX {akismet_spam_marks_content} ON {akismet_spam_marks} (content_type, content_id)"); db_query("CREATE INDEX {akismet_spam_marks_spamcreated} ON {akismet_spam_marks} (spam_created)"); ! db_query("CREATE TABLE {akismet_moderator} ( uid INTEGER NOT NULL DEFAULT 0 CHECK (uid >= 0), email_for VARCHAR(20) NOT NULL DEFAULT '', PRIMARY KEY (uid) )"); ! db_query("CREATE INDEX {akismet_moderator_email_for} ON {akismet_moderator} (email_for)"); break; } *************** *** 55,59 **** case 'mysql': case 'mysqli': ! $ret[] = update_sql("CREATE TABLE {akismet_user} ( uid int(10) unsigned NOT NULL default 0, email_for varchar(20) NOT NULL default '', --- 55,59 ---- case 'mysql': case 'mysqli': ! $ret[] = update_sql("CREATE TABLE {akismet_moderator} ( uid int(10) unsigned NOT NULL default 0, email_for varchar(20) NOT NULL default '', *************** *** 64,73 **** case 'pgsql': ! $ret[] = update_sql("CREATE TABLE {akismet_user} ( uid INTEGER NOT NULL DEFAULT 0 CHECK (uid >= 0), email_for VARCHAR(20) NOT NULL DEFAULT '', PRIMARY KEY (uid) )"); ! $ret[] = update_sql("CREATE INDEX {akismet_user_email_for} ON {akismet_user} (email_for)"); break; } --- 64,73 ---- case 'pgsql': ! $ret[] = update_sql("CREATE TABLE {akismet_moderator} ( uid INTEGER NOT NULL DEFAULT 0 CHECK (uid >= 0), email_for VARCHAR(20) NOT NULL DEFAULT '', PRIMARY KEY (uid) )"); ! $ret[] = update_sql("CREATE INDEX {akismet_moderator_email_for} ON {akismet_moderator} (email_for)"); break; } |
From: <php...@li...> - 2006-06-10 17:50:09
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11323 Modified Files: akismet.install Log Message: Added new table for user extensions (email options). Index: akismet.install =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.install,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** akismet.install 4 Jun 2006 00:52:45 -0000 1.1 --- akismet.install 10 Jun 2006 17:50:00 -0000 1.2 *************** *** 6,9 **** --- 6,11 ---- */ function akismet_install() { + $ret = array(); + switch ($GLOBALS['db_type']) { case 'mysql': *************** *** 16,19 **** --- 18,27 ---- INDEX spam_created (spam_created) ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); + db_query("CREATE TABLE {akismet_user} ( + uid int(10) unsigned NOT NULL default 0, + email_for varchar(20) NOT NULL default '', + PRIMARY KEY (uid), + INDEX email_for (email_for) + ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); break; *************** *** 21,32 **** db_query("CREATE TABLE {akismet_spam_marks} ( content_type varchar(20) NOT NULL default '', ! content_id integer NOT NULL default 0, ! spam_created integer NOT NULL default 0, ! CHECK (content_id>=0), ! CHECK (spam_created>=0) )"); db_query("CREATE UNIQUE INDEX {akismet_spam_marks_content} ON {akismet_spam_marks} (content_type, content_id)"); db_query("CREATE INDEX {akismet_spam_marks_spamcreated} ON {akismet_spam_marks} (spam_created)"); break; } } --- 29,76 ---- db_query("CREATE TABLE {akismet_spam_marks} ( content_type varchar(20) NOT NULL default '', ! content_id integer NOT NULL default 0 CHECK (content_id >= 0), ! spam_created integer NOT NULL default 0 CHECK (spam_created >= 0) )"); db_query("CREATE UNIQUE INDEX {akismet_spam_marks_content} ON {akismet_spam_marks} (content_type, content_id)"); db_query("CREATE INDEX {akismet_spam_marks_spamcreated} ON {akismet_spam_marks} (spam_created)"); + db_query("CREATE TABLE {akismet_user} ( + uid INTEGER NOT NULL DEFAULT 0 CHECK (uid >= 0), + email_for VARCHAR(20) NOT NULL DEFAULT '', + PRIMARY KEY (uid) + )"); + db_query("CREATE INDEX {akismet_user_email_for} ON {akismet_user} (email_for)"); + break; + } + + return $ret; + } + + /** + * Update 1: Add table for user extensions. + */ + function akismet_update_1() { + $ret = array(); + + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + $ret[] = update_sql("CREATE TABLE {akismet_user} ( + uid int(10) unsigned NOT NULL default 0, + email_for varchar(20) NOT NULL default '', + PRIMARY KEY (uid), + INDEX email_for (email_for) + ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); + break; + + case 'pgsql': + $ret[] = update_sql("CREATE TABLE {akismet_user} ( + uid INTEGER NOT NULL DEFAULT 0 CHECK (uid >= 0), + email_for VARCHAR(20) NOT NULL DEFAULT '', + PRIMARY KEY (uid) + )"); + $ret[] = update_sql("CREATE INDEX {akismet_user_email_for} ON {akismet_user} (email_for)"); break; } + + return $ret; } |
From: <php...@li...> - 2006-06-10 13:36:41
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv743 Modified Files: akismet.module Log Message: Changed how problems are displayed when checking for version updates. Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** akismet.module 10 Jun 2006 13:14:44 -0000 1.16 --- akismet.module 10 Jun 2006 13:36:35 -0000 1.17 *************** *** 17,21 **** define('AKISMET_MODULE_VERSION', '1.0.0 beta'); define('AKISMET_MODULE_HOMEURL', 'http://www.phpmix.org/projects/drupal/4_7/akismet'); ! define('AKISMET_MODULE_USERAGENT', 'phpMiX Version Checker | projects/drupal/4_7/akismet | '. AKISMET_MODULE_VERSION); --- 17,21 ---- define('AKISMET_MODULE_VERSION', '1.0.0 beta'); define('AKISMET_MODULE_HOMEURL', 'http://www.phpmix.org/projects/drupal/4_7/akismet'); ! define('AKISMET_MODULE_USERAGENT', 'phpMiX.org | projects/drupal/4_7/akismet | '. AKISMET_MODULE_VERSION); *************** *** 1466,1472 **** } $new_version = _akismet_check_version(isset($_GET['vchk']) ? TRUE : FALSE); ! $output = '<p>'; if (empty($new_version)) { ! $output .= t('Sorry, could not connect to remote server to check for version information. Please, consult the <a href="%admin-logs">log</a> for details.', array('%admin-logs' => url('admin/logs'))); } else { --- 1466,1472 ---- } $new_version = _akismet_check_version(isset($_GET['vchk']) ? TRUE : FALSE); ! $output = ''; if (empty($new_version)) { ! drupal_set_message(t('Sorry, could not connect to remote server to check for new version information. Please, consult the <a href="%admin-logs">log</a> for details.', array('%admin-logs' => url('admin/logs'))), 'error'); } else { *************** *** 1475,1487 **** } if ($new_version != AKISMET_MODULE_VERSION) { ! $output .= t('Your installation does <strong>not</strong> seem to be up to date. Updates are available, please visit the <a href="%module-url" target="_blank">Akismet module home</a> to obtain the latest version. The latest available version is <strong>%new-version</strong>. ', array('%module-url' => AKISMET_MODULE_HOMEURL, '%new-version' => $new_version)); } } $output .= t('You are running version <strong>%your-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION)); $timestamp_last = variable_get('akismet_version_check_timestamp', 0); if ($timestamp_last) { ! $output .= ' '. t('Last time checked: <strong>%last</strong>. The time is now %time.', array('%last' => format_date($timestamp_last), '%time' => format_date(time()))); } ! $output .= ' '. t('<a href="%check">Check for newest version</a>.', array('%check' => url($url, 'vchk=1'))); $output .= '</p>'; return $output; --- 1475,1488 ---- } if ($new_version != AKISMET_MODULE_VERSION) { ! drupal_set_message(t('Your installation does <strong>not</strong> seem to be up to date. Updates are available, please visit the <a href="%module-url" target="_blank">Akismet module home</a> to obtain the latest version. The latest available version is <strong>%new-version</strong>. ', array('%module-url' => AKISMET_MODULE_HOMEURL, '%new-version' => $new_version)), 'error'); } } + $output = '<p>'; $output .= t('You are running version <strong>%your-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION)); $timestamp_last = variable_get('akismet_version_check_timestamp', 0); if ($timestamp_last) { ! $output .= '<br />'. t('Last time checked: %last. The time is now %time.', array('%last' => format_date($timestamp_last), '%time' => format_date(time()))); } ! $output .= '<br />'. t('<a href="%check">Check for newest version</a>.', array('%check' => url($url, 'vchk=1'))); $output .= '</p>'; return $output; |
From: <php...@li...> - 2006-06-10 13:14:47
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23963 Modified Files: akismet.module Log Message: Added new settings for e-mail notification. The actual implementation is coming... Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** akismet.module 10 Jun 2006 02:30:10 -0000 1.15 --- akismet.module 10 Jun 2006 13:14:44 -0000 1.16 *************** *** 264,269 **** } $form['service']['akismet_connection_enabled'] = array( ! '#type' => 'radios', ! '#title' => t('Akismet connections'), '#options' => $enable_options, '#default_value' => variable_get('akismet_connection_enabled', 1), --- 264,268 ---- } $form['service']['akismet_connection_enabled'] = array( ! '#type' => 'radios', '#title' => t('Akismet connections'), '#options' => $enable_options, '#default_value' => variable_get('akismet_connection_enabled', 1), *************** *** 333,338 **** ); $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), --- 332,336 ---- ); $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), *************** *** 345,350 **** ); $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), --- 343,347 ---- ); $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), *************** *** 356,361 **** ); $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), --- 353,357 ---- ); $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), *************** *** 377,382 **** ); $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), --- 373,377 ---- ); $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), *************** *** 389,394 **** ); $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), --- 384,388 ---- ); $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), *************** *** 400,405 **** ); $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), --- 394,398 ---- ); $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), *************** *** 450,453 **** --- 443,480 ---- ); + $email_to_options = array( + 'site_email' => t('Main Site Address'), + 'site_admin' => t('Main Site Administrator'), + 'content_admins' => t('Content Administrators'), + 'content_moderators' => t('Content Moderators') + ); + $email_when_options = array( + 'all' => t('Content is posted'), + 'approval' => t('Only content needing approval'), + 'never' => t('Never') + ); + $form['email_options'] = array( + '#type' => 'fieldset', '#title' => t('E-mail Options'), + '#collapsible' => TRUE, '#collapsed' => TRUE + ); + $form['email_options']['akismet_email_to'] = array( + '#type' => 'checkboxes', '#title' => t('Send e-mails to'), + '#options' => $email_to_options, + '#default_value' => variable_get('akismet_email_to', 0), + '#description' => t('Use this option to select groups of users to whom e-mail notifications will be sent, when content is posted, based on the criteria specified below. It worths to mention that content administrators and moderators will only be notified about posts they have proper access to.') + ); + $form['email_options']['akismet_email_exclude_self'] = array( + '#type' => 'radios', '#title' => t('Exclude notifications to self poster'), + '#options' => $enable_options, + '#default_value' => variable_get('akismet_email_exclude_self', 1), + '#description' => t('Use this option to exclude self poster from receiving e-mail notifications.') + ); + $form['email_options']['akismet_email_when'] = array( + '#type' => 'radios', '#title' => t('Send e-mails when'), + '#options' => $email_when_options, + '#default_value' => variable_get('akismet_email_when', 'approval'), + '#description' => t('Use this option to specify the critica for which the user groups specified above should receive e-mail notifications.') + ); + return $form; } |
From: <php...@li...> - 2006-06-10 02:30:13
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30743 Modified Files: akismet.module Log Message: Simple relocation of some functions. Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** akismet.module 10 Jun 2006 02:19:17 -0000 1.14 --- akismet.module 10 Jun 2006 02:30:10 -0000 1.15 *************** *** 34,116 **** /** - * Check module version. - * - * @param boolean FALSE will return a cached value (if exists); otherwise it will perform a real time connection. - * @return string The latest released module version, - * NFND if the server reports "Module Not Found" (something that shouldn't happen) or - * an empty string if connection fails (reason logged to watchdog). - */ - function _akismet_check_version($refresh = FALSE) { - global $base_url; - $version_string = variable_get('akismet_version_string', FALSE); - $timestamp_now = time(); - if (!$version_string) { - $refresh = TRUE; - } - else { - $timestamp_age = variable_get('akismet_version_check_age', 604800); - if ($timestamp_age > 0) { - $timestamp_last = variable_get('akismet_version_check_timestamp', 0); - if (($timestamp_last + $timestamp_age) < $timestamp_now) { - $refresh = TRUE; - } - } - } - if ($refresh) { - $version_url = AKISMET_MODULE_HOMEURL .'/version'; - $result = drupal_http_request($version_url, array('User-Agent' => AKISMET_MODULE_USERAGENT, 'Referer' => $base_url . base_path())); - if (!isset($result->code) || !in_array($result->code, array(200,302,307)) || empty($result->data)) { - watchdog('version check', t('Could not check version of akismet module, due to "%error".', array('%error' => theme('placeholder', $result->code .' '. $result->error))), WATCHDOG_ERROR, l(t('check'), $version_url, array('target'=>'_blank'), NULL, NULL, TRUE)); - return ''; - } - $new_version = trim($result->data); - if (AKISMET_MODULE_VERSION != $new_version) { - watchdog('version check', t('New version of akismet module seems to be available. Your currently installed version is <strong>%your-version</strong>. The latest available version is <strong>%new-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION, '%new-version' => $new_version)), WATCHDOG_WARNING, l(t('module home'), AKISMET_MODULE_HOMEURL, array('target'=>'_blank'), NULL, NULL, TRUE)); - } - else { - watchdog('version check', t('Your version of akismet module is up to date.'), WATCHDOG_WARNING, l(t('module home'), AKISMET_MODULE_HOMEURL, array('target'=>'_blank'), NULL, NULL, TRUE)); - } - $version_string = $new_version; - variable_set('akismet_version_string', $version_string); - variable_set('akismet_version_check_timestamp', $timestamp_now); - } - return $version_string; - } - - /** - * Get version information message. - * - * @param string URL of the current page. - * @return string - */ - function _akismet_get_version_message($url) { - global $user; - if ($user->uid != 1) { - return ''; - } - $new_version = _akismet_check_version(isset($_GET['vchk']) ? TRUE : FALSE); - $output = '<p>'; - if (empty($new_version)) { - $output .= t('Sorry, could not connect to remote server to check for version information. Please, consult the <a href="%admin-logs">log</a> for details.', array('%admin-logs' => url('admin/logs'))); - } - else { - if (isset($_GET['vchk'])) { - drupal_goto($url); - } - if ($new_version != AKISMET_MODULE_VERSION) { - $output .= t('Your installation does <strong>not</strong> seem to be up to date. Updates are available, please visit the <a href="%module-url" target="_blank">Akismet module home</a> to obtain the latest version. The latest available version is <strong>%new-version</strong>. ', array('%module-url' => AKISMET_MODULE_HOMEURL, '%new-version' => $new_version)); - } - } - $output .= t('You are running version <strong>%your-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION)); - $timestamp_last = variable_get('akismet_version_check_timestamp', 0); - if ($timestamp_last) { - $output .= ' '. t('Last time checked: <strong>%last</strong>. The time is now %time.', array('%last' => format_date($timestamp_last), '%time' => format_date(time()))); - } - $output .= ' '. t('<a href="%check">Check for newest version</a>.', array('%check' => url($url, 'vchk=1'))); - $output .= '</p>'; - return $output; - } - - /** * Implementation of hook_help(). */ --- 34,37 ---- *************** *** 1458,1461 **** --- 1379,1465 ---- /************************************************************\ + phpMiX Version Checker + \************************************************************/ + + /** + * Check module version. + * + * @param boolean FALSE will return a cached value (if exists); otherwise it will perform a real time connection. + * @return string The latest released module version, + * NFND if the server reports "Module Not Found" (something that shouldn't happen) or + * an empty string if connection fails (reason logged to watchdog). + */ + function _akismet_check_version($refresh = FALSE) { + global $base_url; + $version_string = variable_get('akismet_version_string', FALSE); + $timestamp_now = time(); + if (!$version_string) { + $refresh = TRUE; + } + else { + $timestamp_age = variable_get('akismet_version_check_age', 604800); + if ($timestamp_age > 0) { + $timestamp_last = variable_get('akismet_version_check_timestamp', 0); + if (($timestamp_last + $timestamp_age) < $timestamp_now) { + $refresh = TRUE; + } + } + } + if ($refresh) { + $version_url = AKISMET_MODULE_HOMEURL .'/version'; + $result = drupal_http_request($version_url, array('User-Agent' => AKISMET_MODULE_USERAGENT, 'Referer' => $base_url . base_path())); + if (!isset($result->code) || !in_array($result->code, array(200,302,307)) || empty($result->data)) { + watchdog('version check', t('Could not check version of akismet module, due to "%error".', array('%error' => theme('placeholder', $result->code .' '. $result->error))), WATCHDOG_ERROR, l(t('check'), $version_url, array('target'=>'_blank'), NULL, NULL, TRUE)); + return ''; + } + $new_version = trim($result->data); + if (AKISMET_MODULE_VERSION != $new_version) { + watchdog('version check', t('New version of akismet module seems to be available. Your currently installed version is <strong>%your-version</strong>. The latest available version is <strong>%new-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION, '%new-version' => $new_version)), WATCHDOG_WARNING, l(t('module home'), AKISMET_MODULE_HOMEURL, array('target'=>'_blank'), NULL, NULL, TRUE)); + } + else { + watchdog('version check', t('Your version of akismet module is up to date.'), WATCHDOG_WARNING, l(t('module home'), AKISMET_MODULE_HOMEURL, array('target'=>'_blank'), NULL, NULL, TRUE)); + } + $version_string = $new_version; + variable_set('akismet_version_string', $version_string); + variable_set('akismet_version_check_timestamp', $timestamp_now); + } + return $version_string; + } + + /** + * Get version information message. + * + * @param string URL of the current page. + * @return string + */ + function _akismet_get_version_message($url) { + global $user; + if ($user->uid != 1) { + return ''; + } + $new_version = _akismet_check_version(isset($_GET['vchk']) ? TRUE : FALSE); + $output = '<p>'; + if (empty($new_version)) { + $output .= t('Sorry, could not connect to remote server to check for version information. Please, consult the <a href="%admin-logs">log</a> for details.', array('%admin-logs' => url('admin/logs'))); + } + else { + if (isset($_GET['vchk'])) { + drupal_goto($url); + } + if ($new_version != AKISMET_MODULE_VERSION) { + $output .= t('Your installation does <strong>not</strong> seem to be up to date. Updates are available, please visit the <a href="%module-url" target="_blank">Akismet module home</a> to obtain the latest version. The latest available version is <strong>%new-version</strong>. ', array('%module-url' => AKISMET_MODULE_HOMEURL, '%new-version' => $new_version)); + } + } + $output .= t('You are running version <strong>%your-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION)); + $timestamp_last = variable_get('akismet_version_check_timestamp', 0); + if ($timestamp_last) { + $output .= ' '. t('Last time checked: <strong>%last</strong>. The time is now %time.', array('%last' => format_date($timestamp_last), '%time' => format_date(time()))); + } + $output .= ' '. t('<a href="%check">Check for newest version</a>.', array('%check' => url($url, 'vchk=1'))); + $output .= '</p>'; + return $output; + } + + /************************************************************\ Akismet API implementation \************************************************************/ |
From: <php...@li...> - 2006-06-10 02:19:21
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26228 Modified Files: akismet.module Log Message: Reviewed useragent strings. Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** akismet.module 10 Jun 2006 01:51:37 -0000 1.13 --- akismet.module 10 Jun 2006 02:19:17 -0000 1.14 *************** *** 17,20 **** --- 17,21 ---- define('AKISMET_MODULE_VERSION', '1.0.0 beta'); define('AKISMET_MODULE_HOMEURL', 'http://www.phpmix.org/projects/drupal/4_7/akismet'); + define('AKISMET_MODULE_USERAGENT', 'phpMiX Version Checker | projects/drupal/4_7/akismet | '. AKISMET_MODULE_VERSION); *************** *** 25,29 **** define('AKISMET_API_PORT', 80); define('AKISMET_API_VERSION', '1.1'); ! define('AKISMET_USERAGENT', 'Drupal/'. AKISMET_DRUPAL_VERSION .' | akismet.module/'. AKISMET_MODULE_VERSION); define('AKISMET_API_RESULT_ERROR', -1); define('AKISMET_API_RESULT_SUCCESS', 0); --- 26,30 ---- define('AKISMET_API_PORT', 80); define('AKISMET_API_VERSION', '1.1'); ! define('AKISMET_API_USERAGENT', 'Drupal/'. AKISMET_DRUPAL_VERSION .' | akismet.module/'. AKISMET_MODULE_VERSION); define('AKISMET_API_RESULT_ERROR', -1); define('AKISMET_API_RESULT_SUCCESS', 0); *************** *** 58,62 **** if ($refresh) { $version_url = AKISMET_MODULE_HOMEURL .'/version'; ! $result = drupal_http_request($version_url, array('User-Agent' => AKISMET_USERAGENT, 'Referer' => $base_url . base_path())); if (!isset($result->code) || !in_array($result->code, array(200,302,307)) || empty($result->data)) { watchdog('version check', t('Could not check version of akismet module, due to "%error".', array('%error' => theme('placeholder', $result->code .' '. $result->error))), WATCHDOG_ERROR, l(t('check'), $version_url, array('target'=>'_blank'), NULL, NULL, TRUE)); --- 59,63 ---- if ($refresh) { $version_url = AKISMET_MODULE_HOMEURL .'/version'; ! $result = drupal_http_request($version_url, array('User-Agent' => AKISMET_MODULE_USERAGENT, 'Referer' => $base_url . base_path())); if (!isset($result->code) || !in_array($result->code, array(200,302,307)) || empty($result->data)) { watchdog('version check', t('Could not check version of akismet module, due to "%error".', array('%error' => theme('placeholder', $result->code .' '. $result->error))), WATCHDOG_ERROR, l(t('check'), $version_url, array('target'=>'_blank'), NULL, NULL, TRUE)); *************** *** 1609,1613 **** ."Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" ."Content-Length: ". strlen($request) ."\r\n" ! ."User-Agent: ". AKISMET_USERAGENT ."\r\n" ."\r\n" .$request; --- 1610,1614 ---- ."Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" ."Content-Length: ". strlen($request) ."\r\n" ! ."User-Agent: ". AKISMET_API_USERAGENT ."\r\n" ."\r\n" .$request; |
From: <php...@li...> - 2006-06-10 01:51:41
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14040 Modified Files: akismet.module Log Message: Woohoo, forgot to call the version checker from cron. Implemented cron using register_shutdown_function. Also, fixed a couple of minor typos Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** akismet.module 10 Jun 2006 00:57:54 -0000 1.12 --- akismet.module 10 Jun 2006 01:51:37 -0000 1.13 *************** *** 41,44 **** --- 41,45 ---- */ function _akismet_check_version($refresh = FALSE) { + global $base_url; $version_string = variable_get('akismet_version_string', FALSE); $timestamp_now = time(); *************** *** 57,61 **** if ($refresh) { $version_url = AKISMET_MODULE_HOMEURL .'/version'; ! $result = drupal_http_request($version_url); if (!isset($result->code) || !in_array($result->code, array(200,302,307)) || empty($result->data)) { watchdog('version check', t('Could not check version of akismet module, due to "%error".', array('%error' => theme('placeholder', $result->code .' '. $result->error))), WATCHDOG_ERROR, l(t('check'), $version_url, array('target'=>'_blank'), NULL, NULL, TRUE)); --- 58,62 ---- if ($refresh) { $version_url = AKISMET_MODULE_HOMEURL .'/version'; ! $result = drupal_http_request($version_url, array('User-Agent' => AKISMET_USERAGENT, 'Referer' => $base_url . base_path())); if (!isset($result->code) || !in_array($result->code, array(200,302,307)) || empty($result->data)) { watchdog('version check', t('Could not check version of akismet module, due to "%error".', array('%error' => theme('placeholder', $result->code .' '. $result->error))), WATCHDOG_ERROR, l(t('check'), $version_url, array('target'=>'_blank'), NULL, NULL, TRUE)); *************** *** 183,186 **** --- 184,195 ---- */ 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()); *************** *** 291,294 **** --- 300,304 ---- akismet_clear_cache(); } + watchdog('cron', t('Akismet cron completed at %time.', array('%time' => format_date(time(), 'custom', 'H:i:s')))); } *************** *** 509,513 **** '#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 visitor when your Akismet spam counter started to increment.') ); $form['counter_options']['akismet_counter_date_format'] = array( --- 519,523 ---- '#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( |
From: <php...@li...> - 2006-06-10 00:58:01
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24482 Modified Files: akismet.module Log Message: Implemented automatic version checker. Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** akismet.module 9 Jun 2006 09:02:12 -0000 1.11 --- akismet.module 10 Jun 2006 00:57:54 -0000 1.12 *************** *** 12,15 **** --- 12,23 ---- /** + * Akismet Drupal and Module versions. + */ + define('AKISMET_DRUPAL_VERSION', '4.7'); + define('AKISMET_MODULE_VERSION', '1.0.0 beta'); + define('AKISMET_MODULE_HOMEURL', 'http://www.phpmix.org/projects/drupal/4_7/akismet'); + + + /** * Akismet API constants. */ *************** *** 17,21 **** define('AKISMET_API_PORT', 80); define('AKISMET_API_VERSION', '1.1'); ! define('AKISMET_USERAGENT', 'Drupal/4.7 | akismet.module/1.0'); define('AKISMET_API_RESULT_ERROR', -1); define('AKISMET_API_RESULT_SUCCESS', 0); --- 25,29 ---- define('AKISMET_API_PORT', 80); define('AKISMET_API_VERSION', '1.1'); ! define('AKISMET_USERAGENT', 'Drupal/'. AKISMET_DRUPAL_VERSION .' | akismet.module/'. AKISMET_MODULE_VERSION); define('AKISMET_API_RESULT_ERROR', -1); define('AKISMET_API_RESULT_SUCCESS', 0); *************** *** 25,28 **** --- 33,114 ---- /** + * Check module version. + * + * @param boolean FALSE will return a cached value (if exists); otherwise it will perform a real time connection. + * @return string The latest released module version, + * NFND if the server reports "Module Not Found" (something that shouldn't happen) or + * an empty string if connection fails (reason logged to watchdog). + */ + function _akismet_check_version($refresh = FALSE) { + $version_string = variable_get('akismet_version_string', FALSE); + $timestamp_now = time(); + if (!$version_string) { + $refresh = TRUE; + } + else { + $timestamp_age = variable_get('akismet_version_check_age', 604800); + if ($timestamp_age > 0) { + $timestamp_last = variable_get('akismet_version_check_timestamp', 0); + if (($timestamp_last + $timestamp_age) < $timestamp_now) { + $refresh = TRUE; + } + } + } + if ($refresh) { + $version_url = AKISMET_MODULE_HOMEURL .'/version'; + $result = drupal_http_request($version_url); + if (!isset($result->code) || !in_array($result->code, array(200,302,307)) || empty($result->data)) { + watchdog('version check', t('Could not check version of akismet module, due to "%error".', array('%error' => theme('placeholder', $result->code .' '. $result->error))), WATCHDOG_ERROR, l(t('check'), $version_url, array('target'=>'_blank'), NULL, NULL, TRUE)); + return ''; + } + $new_version = trim($result->data); + if (AKISMET_MODULE_VERSION != $new_version) { + watchdog('version check', t('New version of akismet module seems to be available. Your currently installed version is <strong>%your-version</strong>. The latest available version is <strong>%new-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION, '%new-version' => $new_version)), WATCHDOG_WARNING, l(t('module home'), AKISMET_MODULE_HOMEURL, array('target'=>'_blank'), NULL, NULL, TRUE)); + } + else { + watchdog('version check', t('Your version of akismet module is up to date.'), WATCHDOG_WARNING, l(t('module home'), AKISMET_MODULE_HOMEURL, array('target'=>'_blank'), NULL, NULL, TRUE)); + } + $version_string = $new_version; + variable_set('akismet_version_string', $version_string); + variable_set('akismet_version_check_timestamp', $timestamp_now); + } + return $version_string; + } + + /** + * Get version information message. + * + * @param string URL of the current page. + * @return string + */ + function _akismet_get_version_message($url) { + global $user; + if ($user->uid != 1) { + return ''; + } + $new_version = _akismet_check_version(isset($_GET['vchk']) ? TRUE : FALSE); + $output = '<p>'; + if (empty($new_version)) { + $output .= t('Sorry, could not connect to remote server to check for version information. Please, consult the <a href="%admin-logs">log</a> for details.', array('%admin-logs' => url('admin/logs'))); + } + else { + if (isset($_GET['vchk'])) { + drupal_goto($url); + } + if ($new_version != AKISMET_MODULE_VERSION) { + $output .= t('Your installation does <strong>not</strong> seem to be up to date. Updates are available, please visit the <a href="%module-url" target="_blank">Akismet module home</a> to obtain the latest version. The latest available version is <strong>%new-version</strong>. ', array('%module-url' => AKISMET_MODULE_HOMEURL, '%new-version' => $new_version)); + } + } + $output .= t('You are running version <strong>%your-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION)); + $timestamp_last = variable_get('akismet_version_check_timestamp', 0); + if ($timestamp_last) { + $output .= ' '. t('Last time checked: <strong>%last</strong>. The time is now %time.', array('%last' => format_date($timestamp_last), '%time' => format_date(time()))); + } + $output .= ' '. t('<a href="%check">Check for newest version</a>.', array('%check' => url($url, 'vchk=1'))); + $output .= '</p>'; + return $output; + } + + /** * Implementation of hook_help(). */ *************** *** 37,46 **** $output = t('<p>The <a href="%akismet-module-home">akismet module</a> for <a href="%drupal">Drupal</a> allows you to use the <a href="%akismet">Akismet Service</a> to protect your site from being spammed.</p>', array( ! '%akismet-module-home' => 'http://www.phpmix.org/projects/drupal', '%drupal' => 'http://drupal.org', '%akismet' => 'http://akismet.com' )); case 'admin/akismet': ! $output .= t('<p>Akismet has caught <strong>%count spam</strong> for you since <strong>%since</strong>.</p>', array('%count' => variable_get('akismet_counter_spam', 0), '%since' => akismet_get_counting_since())); if ($section == 'admin/settings/akismet') { $output .= theme('more_help_link', url('admin/help/akismet')); --- 123,135 ---- $output = t('<p>The <a href="%akismet-module-home">akismet module</a> for <a href="%drupal">Drupal</a> allows you to use the <a href="%akismet">Akismet Service</a> to protect your site from being spammed.</p>', array( ! '%akismet-module-home' => AKISMET_MODULE_HOMEURL, '%drupal' => 'http://drupal.org', '%akismet' => 'http://akismet.com' )); + if ($section == 'admin/settings/akismet') { + $output .= _akismet_get_version_message($section); + } case 'admin/akismet': ! $output .= t('<p>Akismet has caught <strong>%count spam</strong> for you since <strong>%since</strong>.</p>', array('%count' => akismet_get_spam_counter(), '%since' => akismet_get_counting_since())); if ($section == 'admin/settings/akismet') { $output .= theme('more_help_link', url('admin/help/akismet')); *************** *** 223,231 **** } ! $form['general'] = array( ! '#type' => 'fieldset', '#title' => t('General settings'), '#collapsible' => TRUE, '#collapsed' => $akismet_collapsed ); ! $form['general']['akismet_wpapikey'] = array( '#type' => 'textfield', '#title' => t('WordPress.com API key'), '#size' => 30, '#maxlength' => 60, --- 312,320 ---- } ! $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, *************** *** 240,246 **** ); if (!empty($akismet_wpapikey) && !$is_valid) { ! $form['general']['akismet_wpapikey']['#description'] .= '<div class="marker">'. t("<strong>WARNING: Your API Key doesn't seem to be valid!</strong>") .'</div>'; } ! $form['general']['akismet_connection_enabled'] = array( '#type' => 'radios', '#title' => t('Akismet connections'), --- 329,335 ---- ); 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'), *************** *** 257,261 **** $timeout_options[$n] = $n; } ! $form['general']['akismet_connection_timeout'] = array( '#type' => 'select', '#title' => t('Connection timeout'), '#default_value' => variable_get('akismet_connection_timeout', 10), --- 346,350 ---- $timeout_options[$n] = $n; } ! $form['service']['akismet_connection_timeout'] = array( '#type' => 'select', '#title' => t('Connection timeout'), '#default_value' => variable_get('akismet_connection_timeout', 10), *************** *** 263,266 **** --- 352,369 ---- '#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'); *************** *** 294,298 **** $form['node_options'] = array( ! '#type' => 'fieldset', '#title' => t('Node options'), '#collapsible' => TRUE, '#collapsed' => TRUE ); --- 397,401 ---- $form['node_options'] = array( ! '#type' => 'fieldset', '#title' => t('Node Options'), '#collapsible' => TRUE, '#collapsed' => TRUE ); *************** *** 338,342 **** if (module_exist('comment')) { $form['comment_options'] = array( ! '#type' => 'fieldset', '#title' => t('Comment options'), '#collapsible' => TRUE, '#collapsed' => TRUE ); --- 441,445 ---- if (module_exist('comment')) { $form['comment_options'] = array( ! '#type' => 'fieldset', '#title' => t('Comment Options'), '#collapsible' => TRUE, '#collapsed' => TRUE ); *************** *** 394,403 **** $form['counter_options'] = array( ! '#type' => 'fieldset', '#title' => t('Counter options'), '#collapsible' => TRUE, '#collapsed' => TRUE ); $form['counter_options']['akismet_counter_spam'] = array( '#type' => 'textfield', '#title' => t('Spam counter'), ! '#default_value' => variable_get('akismet_counter_spam', 0), '#size' => 10, '#maxlength' => 10, '#description' => t('This counter is incremented for every spam caught by Akismet.') --- 497,506 ---- $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.') *************** *** 419,422 **** --- 522,534 ---- /** + * Get the current akismet spam counter. + * + * @return integer + */ + function akismet_get_spam_counter() { + return (int)variable_get('akismet_counter_spam', 0); + } + + /** * Format the 'Counting since' date. * *************** *** 518,522 **** $block_args = array( 'content' => '', // Built below. ! 'counter' => variable_get('akismet_counter_spam', 0), 'since' => akismet_get_counting_since(), 'text' => '', // Built below. --- 630,634 ---- $block_args = array( 'content' => '', // Built below. ! 'counter' => akismet_get_spam_counter(), 'since' => akismet_get_counting_since(), 'text' => '', // Built below. *************** *** 792,796 **** akismet_content_spam_operation('node', $node, 'submit-spam', FALSE); // Increment Akismet spam counter ! variable_set('akismet_counter_spam', intval(variable_get('akismet_counter_spam', 0)) + 1); } --- 904,908 ---- akismet_content_spam_operation('node', $node, 'submit-spam', FALSE); // Increment Akismet spam counter ! variable_set('akismet_counter_spam', akismet_get_spam_counter() + 1); } *************** *** 900,904 **** akismet_content_spam_operation('comment', $comment, 'submit-spam', FALSE); // Increment Akismet spam counter ! variable_set('akismet_counter_spam', intval(variable_get('akismet_counter_spam', 0)) + 1); } --- 1012,1016 ---- akismet_content_spam_operation('comment', $comment, 'submit-spam', FALSE); // Increment Akismet spam counter ! variable_set('akismet_counter_spam', akismet_get_spam_counter() + 1); } |
From: <php...@li...> - 2006-06-09 09:02:22
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9446 Modified Files: akismet.module Log Message: Implemented customizable (and themable) block to display the akismet spam counter. There is also a new option in the settings panel that allows administrators set how many blocks they wish to use (or none at all). This is aimed to keep the block administration panel as clean as possible. Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** akismet.module 8 Jun 2006 01:38:31 -0000 1.10 --- akismet.module 9 Jun 2006 09:02:12 -0000 1.11 *************** *** 4,8 **** /********************************************************************************\ - @TODO: Implement a themable block (or something for spam counter). @TODO: Implement an opt-in option for administrators to e-mail them when content is posted (maybe for all posts, or for detected spam or nothing). --- 4,7 ---- *************** *** 284,287 **** --- 283,295 ---- '#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['node_options'] = array( *************** *** 430,433 **** --- 438,586 ---- /** + * Implementation of hook_block(). + */ + function akismet_block($op = 'list', $delta = 0, $edit = array()) { + static $block_fields = FALSE; + if (!$block_fields) { + $block_fields = array( + 'type' => array( + '#type' => 'radios', + '#title' => t('Display counter as'), + '#options' => array('image' => t('Image'), 'text' => t('Text')), + '#default_value' => 'image' + ), + 'sitename' => array( + '#type' => 'radios', + '#title' => t('Show site name'), + '#options' => array('1' => t('Enabled'), '0' => t('Disabled')), + '#default_value' => '1' + ), + 'newwin' => array( + '#type' => 'radios', + '#title' => t('Open Akismet link in new window'), + '#options' => array('1' => t('Enabled'), '0' => t('Disabled')), + '#default_value' => '1' + ) + ); + } + switch ($op) { + case 'list': + $blocks_counter = variable_get('akismet_blocks_counter', 1); + $blocks = array(); + for ($i = 0; $i < $blocks_counter; $i++) { + $blocks[] = array('info' => t('Akismet spam counter (block:%count)', array('%count' => ($i+1)))); + } + return $blocks; + + case 'configure': + if ($delta < 0 || $delta >= variable_get('akismet_blocks_counter', 1)) { + drupal_set_message(t('Oops! You are requesting a non-existing block, changes will not be saved.'), 'error'); + break; + } + $form = array(); + $form['description'] = array( + '#type' => 'markup', + '#value' => '<div class="description"><p>'. t('These options allow to customize the look of this <em>akismet spam counter</em> block.') .'</p></div>' + ); + $block_settings = variable_get('akismet_blocks_'. $delta, FALSE); + foreach ($block_fields as $field_key => $field_info) { + $field_name = 'akismet_blocks_'. $delta .'_'. $field_key; + $form[$field_name] = array(); + foreach ($field_info as $key => $value) { + $form[$field_name][$key] = $value; + } + if ($block_settings && isset($block_settings[$field_key])) { + $form[$field_name]['#default_value'] = $block_settings[$field_key]; + } + } + return $form; + + case 'save': + if ($delta < 0 || $delta >= variable_get('akismet_blocks_counter', 1)) { + drupal_set_message(t('Oops! You have requested a non-existing block, changes were not saved.'), 'error'); + break; + } + $block_settings = array(); + foreach ($block_fields as $field_key => $field_info) { + $field_name = 'akismet_blocks_'. $delta .'_'. $field_key; + $block_settings[$field_key] = $edit[$field_name]; + } + variable_set('akismet_blocks_'. $delta, $block_settings); + break; + + case 'view': + if ($delta >= 0 && $delta < variable_get('akismet_blocks_counter', 1)) { + $block_settings = variable_get('akismet_blocks_'. $delta, FALSE); + if (!$block_settings) { + $block_settings = array(); + } + + $block_args = array( + 'content' => '', // Built below. + 'counter' => variable_get('akismet_counter_spam', 0), + 'since' => akismet_get_counting_since(), + 'text' => '', // Built below. + 'image' => '', // Built below. + 'block' => array('delta' => $delta) // completed below with current block settings. + ); + + foreach ($block_fields as $field_key => $field_info) { + if (!isset($block_settings[$field_key])) { + $block_settings[$field_key] = $field_info['#default_value']; + } + $block_args['block'][$field_key] = $block_settings[$field_key]; + } + + $target = ($block_settings['newwin'] ? ' target="_blank"' : ''); + $block_args['text'] = array( + 'plain' => array( + 'short' => check_plain(t('Proudly protected by Akismet, %count spam caught since %since.', array('%site_name' => variable_get('site_name', 'drupal'), '%count' => $block_args['counter'], '%since' => $block_args['since']))), + 'long' => check_plain(t('%site_name is proudly protected by Akismet, %count spam caught since %since.', array('%site_name' => variable_get('site_name', 'drupal'), '%count' => $block_args['counter'], '%since' => $block_args['since']))) + ), + 'html' => array( + 'short' => t('Proudly protected by <a href="%akismet"%target>Akismet</a>, %count spam caught since %since', array('%site_name' => variable_get('site_name', 'drupal'), '%akismet' => 'http://akismet.com', '%target' => $target, '%count' => $block_args['counter'], '%since' => $block_args['since'])), + 'long' => t('%site_name is proudly protected by <a href="%akismet"%target>Akismet</a>, %count spam caught since %since', array('%site_name' => variable_get('site_name', 'drupal'), '%akismet' => 'http://akismet.com', '%target' => $target, '%count' => $block_args['counter'], '%since' => $block_args['since'])) + ) + ); + $text_version = ($block_settings['sitename'] ? 'long' : 'short'); + $title_text = $block_args['text']['plain'][$text_version]; + $image_url = base_path() . drupal_get_path('module', 'akismet') .'/akismet.gif'; + $block_args['image'] = '<img src="'. $image_url .'" title="'. $title_text .'" alt="'. $title_text .'" />'; + + if ($block_settings['type'] == 'image') { + $block_args['content'] = '<a href="http://akismet.com" title="'. $title_text .'"'. $target .'>'. $block_args['image'] .'</a>'; + } + else { + $block_args['content'] = $block_args['text']['html'][$text_version]; + } + + $block = array(); + $block['subject'] = t('Akismet spam counter'); + $block['content'] = theme('akismet_counter_block', $block_args); + return $block; + } + break; + } + } + + /** + * Allow themes customize the content of the akismet spam counter block. + * + * @param array arguments where each element is: + * content: String; the completely built block content. + * counter: Integer; the current spam counter. + * since : String; the formatted 'counting since' date. + * text : Array; with 2 subarrays defined as follows: + * plain: Array with 2 elements ('short' and 'long'). + * html : Array with 2 elements ('short' and 'long'). + * image : String; the completely built IMG tag. + * block : Array; Block settings. + * @return string The content of the block. + */ + function theme_akismet_counter_block($args) { + return $args['content']; + } + + /** * Implementation of hook_menu(). */ *************** *** 775,778 **** --- 928,933 ---- /** * Menu callback; Moderation queue. + * + * @param string Operation code: overview (default), nodes, comments. */ function akismet_callback_queue($op = '') { |
From: <php...@li...> - 2006-06-08 03:51:06
|
Update of /cvsroot/phpmix/drupal/modules/akismet/contrib/controlpanel/48x48 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17551/48x48 Log Message: Directory /cvsroot/phpmix/drupal/modules/akismet/contrib/controlpanel/48x48 added to the repository |
From: <php...@li...> - 2006-06-08 03:51:06
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21666 Modified Files: INSTALL.txt README.txt Log Message: Revised README and INSTALL files. Index: INSTALL.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/INSTALL.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** INSTALL.txt 4 Jun 2006 01:01:54 -0000 1.2 --- INSTALL.txt 7 Jun 2006 23:27:19 -0000 1.3 *************** *** 4,18 **** ******************************************************************** Name : akismet ! Version : 0.0.1 Author : markus_petrux [ http://www.phpmix.org ] Drupal : 4.7 ******************************************************************** - WARNING: - - This module is still under development !!! - - - ******************************************************************** INSTALLATION: --- 4,12 ---- ******************************************************************** Name : akismet ! Version : 1.0.0 Author : markus_petrux [ http://www.phpmix.org ] Drupal : 4.7 ******************************************************************** INSTALLATION: *************** *** 24,28 **** 3. Enable the akismet module in 'admin/modules' ! 4. You're done. ******************************************************************** --- 18,38 ---- 3. Enable the akismet module in 'admin/modules' ! 4. Visit 'admin/settings/akismet' and enter your WordPress.com API ! Key. You may wish to review and adapt the other options to suit ! your needs. ! ! 5. Check new permissions added by this module at 'admin/access'. ! ! 6. You're done. ! ! ******************************************************************** ! OPTIONAL: ! ! If you have installed the controlpanel module, you may want to check ! the contrib folder included with this module. It contains a couple of ! images that you could use instead of the default one. Please, consult ! the controlpanel module docs for further information on where to place ! this images. ! Note: As you'll soon notice, graphics are not my best, though. ;-) ******************************************************************** Index: README.txt =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/README.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README.txt 4 Jun 2006 01:01:54 -0000 1.2 --- README.txt 7 Jun 2006 23:27:19 -0000 1.3 *************** *** 4,18 **** ******************************************************************** Name : akismet ! Version : 0.0.1 Author : markus_petrux [ http://www.phpmix.org ] Drupal : 4.7 ******************************************************************** - WARNING: - - This module is still under development !!! - - - ******************************************************************** DESCRIPTION: --- 4,12 ---- ******************************************************************** Name : akismet ! Version : 1.0.0 Author : markus_petrux [ http://www.phpmix.org ] Drupal : 4.7 ******************************************************************** DESCRIPTION: |
From: <php...@li...> - 2006-06-08 03:51:06
|
Update of /cvsroot/phpmix/drupal/modules/akismet/contrib/controlpanel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17142/controlpanel Log Message: Directory /cvsroot/phpmix/drupal/modules/akismet/contrib/controlpanel added to the repository |