--- spam2.module 2007-09-09 17:40:16.031250000 -0400 +++ spam.module 2007-09-14 10:51:21.328125000 -0400 @@ -219,43 +219,58 @@ define('WEIGHT_NEVER_SPAM', -200); * @return Text appropriate for current $path */ function spam_help($path) { +// $output = NULL; +// $output = "\n"; switch ($path) { case 'admin/help#spam': - $output = '
'. t("The spam module is a powerful collection of tools designed to help website administrators to automatically deal with spam. Spam is any content that is posted to a website that is unrelated to the subject at hand, usually in the form of advertising and links back to the spammer's own website. This module can automatically detect spam, instantly unpublish it, and send notification to the site administrator.") .'
'; + $output .= ''. t("The spam module is a powerful collection of tools designed to help website administrators to automatically deal with spam. Spam is any content that is posted to a website that is unrelated to the subject at hand, usually in the form of advertising and links back to the spammer's own website. This module can automatically detect spam, instantly unpublish it, and send notification to the site administrator.") .'
'; break; case 'admin/settings/spam': - $output = ''. t("These are the global settings controlling the Spam module. Filter settings can be found at Spam filters.", array('@link' => url('admin/content/spam'))) .'
'; + $output .= ''. t("These are the global settings controlling the Spam module.") .'
'; break; case 'admin/content/comment/list/spam': case 'admin/spam/comments': - $output = t('The following comments have been marked as spam.'); + $output .= ''. t('The following comments have been marked as spam.') .'
'; break; case 'admin/content/comment/list/reported': - $output = t('The following comments have been reported as spam.'); + $output .= ''. t('The following comments have been reported as spam.') .'
'; break; case 'admin/content/node/list/spam': case 'admin/spam/node': - $output = t('The following content has been marked as spam.'); + $output .= ''. t('The following content has been marked as spam.') .'
'; break; case 'admin/content/node/list/reported': - $output = t('The following content has been reported as spam.'); + $output .= ''. t('The following content has been reported as spam.') .'
'; break; case 'admin/logs/spam': - $output = t('If enabled, the spam module will log the various filter actions that lead up to site content being marked as spam or not spam. These logs can be helpful in understanding why certain content was or was not marked as spam.'); + $output .= t('If enabled, the spam module will log the various filter actions that lead up to site content being marked as spam or not spam. These logs can be helpful in understanding why certain content was or was not marked as spam.'); break; case 'admin/logs/spam/blockedips': - $output = t('The following IPs have been marked as blocked.'); + $output .= t('The following IPs have been marked as blocked.'); + break; + case 'admin/settings/spam/filter': + $output .= t('This page allows you to select which type of postings will be checked for spam.'); + break; + case 'admin/settings/spam/limits': + $output .= t('This page allows you to set limits for the spam module.'); + break; + case 'admin/settings/spam/actions': + $output .= t('This page allows you to select which actions should be taken when spam is detected.'); + break; + case 'admin/settings/spam/advanced': + $output .= t('This page allows you to specify additional options for the spam module.'); break; case 'admin/settings/spam/custom': - $output = t('Custom filters allow you to define words, phrases and/or regular expressions to be tested against new content on your site. If your custom filter matches, you can cause this to increase or decrease the probability that the given content is spam. For example, if a comment about "viagra" is completely out of place on your site, you can create a custom filter such that any comment with the word "viagra" in it will always be marked as spam.'); + $output .= t('Custom filters allow you to define words, phrases and/or regular expressions to be tested against new content on your site. If your custom filter matches, you can cause this to increase or decrease the probability that the given content is spam. For example, if a comment about "viagra" is completely out of place on your site, you can create a custom filter such that any comment with the word "viagra" in it will always be marked as spam.'); break; case 'admin/settings/spam/url': - $output = t('The spam filter\'s Bayesian logic automatically learns spammer web domains. Any new comment or other content containing one of the web domain names listed below will be automatically marked as spam. For example, if "spam.com" is listed below, a new comment containing the text "http://spam.com/great/deals" will be marked as spam.'); + $output .= t('The spam filter\'s Bayesian logic automatically learns spammer web domains. Any new comment or other content containing one of the web domain names listed below will be automatically marked as spam. For example, if "spam.com" is listed below, a new comment containing the text "http://spam.com/great/deals" will be marked as spam.'); $output .= ""; $output .= t('The advantage that url filters offer is that they are automatically learned by the bayesian filter. However, it is possible to instead block spammer domains by defining an appropriate custom filter.'); break; } - return $output; + if ($output) { return "\n". $output ."\n"; } + else { return NULL; } } /** @@ -300,14 +315,22 @@ function spam_admin_settings_filter() { '#description' => t('Enable this option to filter new comments as they are posted, determining whether or not they are spam.'), ); + $form['filter']['content_types'] = array( + '#type' => 'fieldset', + '#title' => t('Filter content types'), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + '#description' => t('Examine these content types as they are posted, determining whether or not they are spam. This could be useful if you allow anonymous users to post content or public registrations.'), + ); + $node_types = node_get_types(); foreach ($node_types as $type => $properties) { - $form['filter']["spam_filter_$type"] = array( + $form['filter']['content_types']["spam_filter_$type"] = array( '#type' => 'checkbox', '#title' => t("Filter $properties->name content"), '#return_value' => 1, '#default_value' => variable_get("spam_filter_$type", 0), - '#description' => t("Enable this option to filter new $name content as it is posted, determining whether or not it is spam."), +// '#description' => t("Enable this option to filter new $name content as it is posted, determining whether or not it is spam."), ); } @@ -592,7 +615,7 @@ function spam_nodeapi(&$node, $op, $arg case 'view': if ($arg === 0) { if (user_access('bypass filter')) { - spam_log(SPAM_DEBUG, t('spam_nodeapi: skipping node "%title" for user "@name"', array('%title' => $node->title, '%name' => $user->name)), 'node', $node->nid); + spam_log(SPAM_DEBUG, t('spam_nodeapi: skipping node "%title" for user "@name"', array('%title' => $node->title, '@name' => $user->name)), 'node', $node->nid); return; } // check if this is a blacklisted spammer IP @@ -1213,7 +1236,7 @@ function spam_bayesian_filter($tokens = } } - $probability = ($total / $i); + $probability = round($total / $i, 1); spam_log(SPAM_LOG, t("bayesian filter: examined @num tokens, spam probability of @percent%", array('@num' => $i, '@percent' => $probability))); return ($probability); }