From f5262c2e538a46b8b7dd15eaf4398172532af352 Mon Sep 17 00:00:00 2001 From: Kenji ITO Date: Sat, 18 Nov 2017 21:42:12 +0900 Subject: [PATCH 1/3] Added Akismet class --- system/classes/Akismet.php | 377 +++++++++++++++++++++++++++++++++++++ 1 file changed, 377 insertions(+) create mode 100644 system/classes/Akismet.php diff --git a/system/classes/Akismet.php b/system/classes/Akismet.php new file mode 100644 index 000000000..edfc732b2 --- /dev/null +++ b/system/classes/Akismet.php @@ -0,0 +1,377 @@ +APIKey = $APIKey; + $this->siteURL = $siteURL; + $this->isAPIKeyVerified = $this->verifyAPIKey(); + } + + /** + * Write into error log + * + * @param string $entry + */ + private function log($entry) + { + if (is_callable('COM_errorLog')) { + COM_errorLog($entry); + } else { + log($entry); + } + } + + /** + * Return User Agent string + * + * @return string + */ + private function getUAString() + { + return sprintf(self::UA, VERSION, self::VERSION); + } + + /** + * Send request to Akismet server + * + * @param string $path + * @param array $data + * @return array|false in case of success, return an array of (0 => 'response headers', 1 => 'result'), + * otherwise false + */ + private function send($path, array $data) + { + $data = http_build_query($data, '', '&'); + $host = $http_host = 'rest.akismet.com'; + $port = 443; + $akismetUA = $this->getUAString(); + $contentLength = strlen($data); + $httpRequest = "POST {$path} HTTP/1.0\r\n" + . "Host: {$host}\r\n" + . "Content-Type: application/x-www-form-urlencoded\r\n" + . "Content-Length: {$contentLength}\r\n" + . "User-Agent: {$akismetUA}\r\n" + . "\r\n" + . $data; + + if (($fs = @fsockopen('ssl://' . $http_host, $port, $errNo, $errStr, self::STREAM_TIMEOUT)) !== false) { + stream_set_timeout($fs, self::STREAM_TIMEOUT); + fwrite($fs, $httpRequest); + $response = ''; + + while (!feof($fs)) { + $response .= fgets($fs, 1160); + } + + fclose($fs); + $response = explode("\r\n\r\n", $response, 2); + } else { + $this->log(sprintf('Code: %d Message: %s', $errNo, $errStr)); + $response = false; + } + + return $response; + } + + /** + * Extract a value from response text + * + * @param string $haystack response text + * @param string $needle field name + * @return string + */ + private function extractValueFromResponse($haystack, $needle) + { + $haystack = trim(str_replace(array("\r\n", "\r"), "\n", $haystack)); + + foreach (explode("\n", $haystack) as $line) { + if (stripos($line, $needle) === 0) { + $colon = strpos($line, ':'); + + return trim(substr($line, $colon + 1)); + } + } + + return ''; + } + + /** + * Check if your API key is valid + * + * @see https://akismet.com/development/api/#verify-key + * @return bool true = valid, false otherwise + */ + public function verifyAPIKey() + { + if (!isset($this->siteURL, $this->APIKey)) { + return false; + } + + $path = '/1.1/verify-key'; + $data = array( + 'key' => $this->APIKey, + 'blog' => $this->siteURL, + ); + $response = $this->send($path, $data); + + if (is_array($response) && ($response[1] === 'valid')) { + return true; + } else { + if (is_array($response)) { + $this->log( + sprintf( + 'Verification failed. The following is the response from the server: \\n%s', + $response[0] + ) + ); + } + + return false; + } + } + + /** + * Check for spam + * + * @param string $uri + * @param string $content + * @param string $commentType + * @param string $commentAuthor + * @param string $commentAuthorEmail + * @param string $commentAuthorURL + * @param bool $isTest + * @return array + */ + private function prepareData($uri, $content, $commentType, + $commentAuthor, $commentAuthorEmail, $commentAuthorURL, $isTest) + { + global $LANG01; + + $data = array( + 'blog' => $this->siteURL, + 'blog_charset' => COM_getCharset(), + 'blog_lang' => COM_getLangIso639Code(), + 'user_ip' => Input::server('REMOTE_ADDR'), + 'user_agent' => Input::server('HTTP_USER_AGENT'), + 'referrer' => Input::server('HTTP_REFERER'), + 'permalink' => $uri, + 'comment_content' => $content, + 'comment_type' => $commentType, + ); + + if (!empty($commentAuthor) && ($commentAuthor !== $LANG01[24])) { // Anonymous + $data['comment_author'] = $commentAuthor; + } + if (!empty($commentAuthorEmail)) { + $data['comment_author_email'] = $commentAuthorEmail; + } + if (!empty($commentAuthorURL)) { + $data['comment_author_url'] = $commentAuthorURL; + } + if ($isTest) { + $data['is_test'] = 1; + } + + return $data; + } + + /** + * Check for spam + * + * @see https://akismet.com/development/api/#comment-check + * @param string $uri + * @param string $content + * @param string $commentAuthor + * @param string $commentAuthorEmail + * @param string $commentAuthorURL + * @param string $commentType + * @param bool $isTest + * @return int either RESULT_HAM, RESULT_SPAM or RESULT_MAYBE_SPAM + */ + public function checkForSpam($uri, $content, $commentAuthor, $commentAuthorEmail = null, + $commentAuthorURL = null, $commentType = self::COMMENT_TYPE_COMMENT, $isTest = false) + { + if (!$this->isAPIKeyVerified) { + // Doesn't check + return false; + } + + $path = '/1.1/comment-check'; + $data = $this->prepareData( + $uri, $content, $commentType, $commentAuthor, $commentAuthorEmail, $commentAuthorURL, $isTest + ); + $response = $this->send($path, $data); + + if (!is_array($response)) { + return false; + } + + switch ($response[1]) { + case 'false': + // Not a spam + return self::RESULT_HAM; + break; + + case 'true': + // Spam + if ($this->extractValueFromResponse($response[0], 'X-akismet-pro-tip') === 'discard') { + // Blatant spam + return self::RESULT_SPAM; + } else { + // Maybe spam + return self::RESULT_MAYBE_SPAM; + } + + break; + + case 'invalid': + $this->log('Invalid request:' . $this->extractValueFromResponse($response[0], 'X-akismet-debug-help')); + + return self::RESULT_HAM; + break; + + default: + $this->log('Unknown result code "' . $response[1] . '" returned.'); + + return self::RESULT_HAM; + break; + } + } + + /** + * Submit a spam + * + * @see https://akismet.com/development/api/#submit-spam + * @param string $uri + * @param string $content + * @param string $commentAuthor + * @param string $commentAuthorEmail + * @param string $commentAuthorURL + * @param string $commentType + * @param bool $isTest + * @return bool true on success, false otherwise + */ + public function submitSpam($uri, $content, $commentAuthor, $commentAuthorEmail = null, + $commentAuthorURL = null, $commentType = self::COMMENT_TYPE_COMMENT, $isTest = false) + { + if (!$this->isAPIKeyVerified) { + // Doesn't check + return false; + } + + $path = '/1.1/submit-spam'; + $data = $this->prepareData( + $uri, $content, $commentType, $commentAuthor, $commentAuthorEmail, $commentAuthorURL, $isTest + ); + $response = $this->send($path, $data); + + if (is_array($response) && ($response[1]) === 'Thanks for making the web a better place.') { + return true; + } else { + return false; + } + } + + /** + * Submit a ham + * + * @see https://akismet.com/development/api/#submit-ham + * @param string $uri + * @param string $content + * @param string $commentAuthor + * @param string $commentAuthorEmail + * @param string $commentAuthorURL + * @param string $commentType + * @param bool $isTest + * @return bool true on success, false otherwise + */ + public function submitHam($uri, $content, $commentAuthor, $commentAuthorEmail = null, + $commentAuthorURL = null, $commentType = self::COMMENT_TYPE_COMMENT, $isTest = false) + { + if (!$this->isAPIKeyVerified) { + // Doesn't check + return false; + } + + $path = '/1.1/submit-ham'; + $data = $this->prepareData( + $uri, $content, $commentType, $commentAuthor, $commentAuthorEmail, $commentAuthorURL, $isTest + ); + $response = $this->send($path, $data); + + if (is_array($response) && ($response[1]) === 'Thanks for making the web a better place.') { + return true; + } else { + return false; + } + } +} From eedfda5f9f1174454b0f39d44ac0045da38fc986 Mon Sep 17 00:00:00 2001 From: Kenji ITO Date: Sun, 19 Nov 2017 10:15:09 +0900 Subject: [PATCH 2/3] Refactored method signature --- system/classes/Akismet.php | 62 ++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/system/classes/Akismet.php b/system/classes/Akismet.php index edfc732b2..c486399fc 100644 --- a/system/classes/Akismet.php +++ b/system/classes/Akismet.php @@ -25,12 +25,12 @@ class Akismet const COMMENT_TYPE_TRACKBACK = 'trackback'; // Result types - const RESULT_HAM = 0; - const RESULT_SPAM = 1; - const RESULT_MAYBE_SPAM = 2; + const RESULT_HAM = 0; // = PLG_SPAM_NOT_FOUND + const RESULT_SPAM = 1; // = PLG_SPAM_FOUND + const RESULT_MAYBE_SPAM = 2; // = PLG_SPAM_UNSURE - // Time out in seconds - const STREAM_TIMEOUT = 10; + // Time out in seconds when $_SPX_CONF['timeout'] is not set + const STREAM_TIMEOUT = 5; /** * API key @@ -110,6 +110,8 @@ private function getUAString() */ private function send($path, array $data) { + global $_SPX_CONF; + $data = http_build_query($data, '', '&'); $host = $http_host = 'rest.akismet.com'; $port = 443; @@ -122,9 +124,10 @@ private function send($path, array $data) . "User-Agent: {$akismetUA}\r\n" . "\r\n" . $data; + $timeout = isset($_SPX_CONF['timeout']) ? (int) $_SPX_CONF['timeout'] : self::STREAM_TIMEOUT; - if (($fs = @fsockopen('ssl://' . $http_host, $port, $errNo, $errStr, self::STREAM_TIMEOUT)) !== false) { - stream_set_timeout($fs, self::STREAM_TIMEOUT); + if (($fs = @fsockopen('ssl://' . $http_host, $port, $errNo, $errStr, $timeout)) !== false) { + stream_set_timeout($fs, $timeout); fwrite($fs, $httpRequest); $response = ''; @@ -200,10 +203,10 @@ public function verifyAPIKey() } /** - * Check for spam + * Prepare common data for APIs * - * @param string $uri * @param string $content + * @param string $permanentLink * @param string $commentType * @param string $commentAuthor * @param string $commentAuthorEmail @@ -211,8 +214,7 @@ public function verifyAPIKey() * @param bool $isTest * @return array */ - private function prepareData($uri, $content, $commentType, - $commentAuthor, $commentAuthorEmail, $commentAuthorURL, $isTest) + private function prepareData($content, $permanentLink, $commentType, $commentAuthor, $commentAuthorEmail, $commentAuthorURL, $isTest) { global $LANG01; @@ -223,7 +225,7 @@ private function prepareData($uri, $content, $commentType, 'user_ip' => Input::server('REMOTE_ADDR'), 'user_agent' => Input::server('HTTP_USER_AGENT'), 'referrer' => Input::server('HTTP_REFERER'), - 'permalink' => $uri, + 'permalink' => $permanentLink, 'comment_content' => $content, 'comment_type' => $commentType, ); @@ -248,17 +250,17 @@ private function prepareData($uri, $content, $commentType, * Check for spam * * @see https://akismet.com/development/api/#comment-check - * @param string $uri * @param string $content + * @param string $permanentLink + * @param string $commentType * @param string $commentAuthor * @param string $commentAuthorEmail * @param string $commentAuthorURL - * @param string $commentType * @param bool $isTest - * @return int either RESULT_HAM, RESULT_SPAM or RESULT_MAYBE_SPAM + * @return int either RESULT_HAM, RESULT_SPAM or RESULT_MAYBE_SPAM */ - public function checkForSpam($uri, $content, $commentAuthor, $commentAuthorEmail = null, - $commentAuthorURL = null, $commentType = self::COMMENT_TYPE_COMMENT, $isTest = false) + public function checkForSpam($content, $permanentLink, $commentType = self::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null, $isTest = false) { if (!$this->isAPIKeyVerified) { // Doesn't check @@ -267,7 +269,7 @@ public function checkForSpam($uri, $content, $commentAuthor, $commentAuthorEmail $path = '/1.1/comment-check'; $data = $this->prepareData( - $uri, $content, $commentType, $commentAuthor, $commentAuthorEmail, $commentAuthorURL, $isTest + $content, $permanentLink, $commentType, $commentAuthor, $commentAuthorEmail, $commentAuthorURL, $isTest ); $response = $this->send($path, $data); @@ -311,17 +313,17 @@ public function checkForSpam($uri, $content, $commentAuthor, $commentAuthorEmail * Submit a spam * * @see https://akismet.com/development/api/#submit-spam - * @param string $uri * @param string $content + * @param string $permanentLink + * @param string $commentType * @param string $commentAuthor * @param string $commentAuthorEmail * @param string $commentAuthorURL - * @param string $commentType * @param bool $isTest - * @return bool true on success, false otherwise + * @return bool true on success, false otherwise */ - public function submitSpam($uri, $content, $commentAuthor, $commentAuthorEmail = null, - $commentAuthorURL = null, $commentType = self::COMMENT_TYPE_COMMENT, $isTest = false) + public function submitSpam($content, $permanentLink, $commentType = self::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null, $isTest = false) { if (!$this->isAPIKeyVerified) { // Doesn't check @@ -330,7 +332,7 @@ public function submitSpam($uri, $content, $commentAuthor, $commentAuthorEmail = $path = '/1.1/submit-spam'; $data = $this->prepareData( - $uri, $content, $commentType, $commentAuthor, $commentAuthorEmail, $commentAuthorURL, $isTest + $content, $permanentLink, $commentType, $commentAuthor, $commentAuthorEmail, $commentAuthorURL, $isTest ); $response = $this->send($path, $data); @@ -345,17 +347,17 @@ public function submitSpam($uri, $content, $commentAuthor, $commentAuthorEmail = * Submit a ham * * @see https://akismet.com/development/api/#submit-ham - * @param string $uri * @param string $content + * @param string $permanentLink + * @param string $commentType * @param string $commentAuthor * @param string $commentAuthorEmail * @param string $commentAuthorURL - * @param string $commentType * @param bool $isTest - * @return bool true on success, false otherwise + * @return bool true on success, false otherwise */ - public function submitHam($uri, $content, $commentAuthor, $commentAuthorEmail = null, - $commentAuthorURL = null, $commentType = self::COMMENT_TYPE_COMMENT, $isTest = false) + public function submitHam($content, $permanentLink, $commentType = self::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null, $isTest = false) { if (!$this->isAPIKeyVerified) { // Doesn't check @@ -364,7 +366,7 @@ public function submitHam($uri, $content, $commentAuthor, $commentAuthorEmail = $path = '/1.1/submit-ham'; $data = $this->prepareData( - $uri, $content, $commentType, $commentAuthor, $commentAuthorEmail, $commentAuthorURL, $isTest + $content, $permanentLink, $commentType, $commentAuthor, $commentAuthorEmail, $commentAuthorURL, $isTest ); $response = $this->send($path, $data); From 2f97d401d898992fd965999f81a04400daad1890 Mon Sep 17 00:00:00 2001 From: Kenji ITO Date: Sun, 19 Nov 2017 13:13:50 +0900 Subject: [PATCH 3/3] Added Akismet module for the Spam-X plugin (feature request #733) --- plugins/calendar/functions.inc | 6 +- plugins/links/functions.inc | 9 +- plugins/spamx/Akismet.Examine.class.php | 72 +++ plugins/spamx/BannedUsers.Examine.class.php | 23 +- plugins/spamx/BaseCommand.class.php | 16 +- plugins/spamx/BlackList.Examine.class.php | 23 +- plugins/spamx/Header.Examine.class.php | 22 +- plugins/spamx/IP.Examine.class.php | 35 +- plugins/spamx/IPofUrl.Examine.class.php | 24 +- plugins/spamx/SFS.Examine.class.php | 20 +- plugins/spamx/SLV.Examine.class.php | 22 +- plugins/spamx/SNL.Examine.class.php | 22 +- plugins/spamx/configuration_validation.php | 4 + plugins/spamx/functions.inc | 48 +- plugins/spamx/install_defaults.php | 42 +- plugins/spamx/install_updates.php | 19 + plugins/spamx/language/english.php | 13 +- plugins/spamx/language/english_utf-8.php | 13 +- plugins/spamx/language/japanese_utf-8.php | 13 +- public_html/docs/english/changes.html | 1 + public_html/docs/english/spamx.html | 478 ++++++++++-------- public_html/docs/japanese/changes.html | 1 + public_html/docs/japanese/spamx.html | 325 +++++++----- public_html/profiles.php | 60 ++- public_html/submit.php | 8 +- public_html/usersettings.php | 9 +- system/classes/Akismet.php | 12 +- system/lib-comment.php | 11 +- system/lib-plugins.php | 37 +- system/lib-trackback.php | 9 +- .../dummy/plugins/calendar/functions.inc | 8 +- tests/files/dummy/plugins/links/functions.inc | 8 +- tests/files/dummy/system/lib-plugins.php | 43 +- 33 files changed, 907 insertions(+), 549 deletions(-) create mode 100644 plugins/spamx/Akismet.Examine.class.php diff --git a/plugins/calendar/functions.inc b/plugins/calendar/functions.inc index 3082ef705..ea5a21c9a 100644 --- a/plugins/calendar/functions.inc +++ b/plugins/calendar/functions.inc @@ -10,7 +10,7 @@ // | API method and 2) implements all the common code needed by the Calendar | // | plugin's PHP files. | // +---------------------------------------------------------------------------+ -// | Copyright (C) 2000-2011 by the following authors: | +// | Copyright (C) 2000-2017 by the following authors: | // | | // | Authors: Tony Bibbs - tony AT tonybibbs DOT com | // | Tom Willett - twillett AT users DOT sourceforge DOT net | @@ -484,8 +484,8 @@ function plugin_savesubmission_calendar($A) . $A['address1'] . '' . $A['address2'] . '' . $A['city'] . ', ' . $A['zipcode'] . '' . $A['description'] . '

'; - $result = PLG_checkforSpam($spamCheck, $_CONF['spamx']); - if ($result > 0) { + $result = PLG_checkForSpam($spamCheck, $_CONF['spamx'], $A['url'], Geeklog\Akismet::COMMENT_TYPE_EVENT); + if ($result > PLG_SPAM_NOT_FOUND) { COM_updateSpeedlimit('submit'); COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden'); } diff --git a/plugins/links/functions.inc b/plugins/links/functions.inc index d73d31791..664c861c6 100644 --- a/plugins/links/functions.inc +++ b/plugins/links/functions.inc @@ -10,7 +10,7 @@ // | API method and 2) implements all the common code needed by the Links | // | Plugins' PHP files. | // +---------------------------------------------------------------------------+ -// | Copyright (C) 2000-2010 by the following authors: | +// | Copyright (C) 2000-2017 by the following authors: | // | | // | Authors: Tony Bibbs - tony AT tonybibbs DOT com | // | Mark Limburg - mlimburg AT users.sourceforge DOT net | @@ -1073,10 +1073,11 @@ function plugin_save_submit_links($A) } else { $link = COM_createLink($A['title'], $A['url']); } - $spamcheck = '

'. $link .' (' . $A['categorydd'] . ')' + $spamCheck = '

'. $link .' (' . $A['categorydd'] . ')' . $A['description'] . '

'; - $result = PLG_checkforSpam($spamcheck, $_CONF['spamx']); - if ($result > 0) { + $result = PLG_checkForSpam($spamCheck, $_CONF['spamx'], $link, Geeklog\Akismet::COMMENT_TYPE_LINK); + + if ($result > PLG_SPAM_NOT_FOUND) { COM_updateSpeedlimit('submit'); COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden'); } diff --git a/plugins/spamx/Akismet.Examine.class.php b/plugins/spamx/Akismet.Examine.class.php new file mode 100644 index 000000000..77d610d73 --- /dev/null +++ b/plugins/spamx/Akismet.Examine.class.php @@ -0,0 +1,72 @@ +verifyAPIKey()) { + $answer = $akismet->checkForSpam( + $comment, $permanentLink, $commentType, $commentAuthor, $commentAuthorEmail, $commentAuthorURL + ); + + if (($answer == PLG_SPAM_FOUND) || ($answer == PLG_SPAM_UNSURE)) { + SPAMX_log( + $LANG_SX00['foundspam'] . 'Akismet' . $LANG_SX00['foundspam2'] . $this->getUid() + . $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR'] + ); + } + } + + return $answer; + } +} diff --git a/plugins/spamx/BannedUsers.Examine.class.php b/plugins/spamx/BannedUsers.Examine.class.php index 9733c2107..cce88c0e2 100644 --- a/plugins/spamx/BannedUsers.Examine.class.php +++ b/plugins/spamx/BannedUsers.Examine.class.php @@ -33,13 +33,20 @@ class BannedUsers extends BaseCommand * Here we do the work * * @param string $comment - * @return int + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php */ - public function execute($comment) + public function execute($comment, $permanentLink, $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null) { - global $_TABLES, $_USER, $LANG_SX00, $LANG28; + global $_TABLES, $LANG_SX00, $LANG28; - $uid = COM_isAnonUser() ? 1 : $_USER['uid']; + $uid = $this->getUid(); // Get homepage URLs of all banned users $result = DB_query("SELECT DISTINCT homepage FROM {$_TABLES['users']} WHERE status = 0 AND homepage IS NOT NULL AND homepage <> ''"); @@ -54,14 +61,14 @@ public function execute($comment) // hex notation $comment = preg_replace_callback('/&#x([a-f0-9]+);/mi', array($this, 'callbackHex'), $comment); - $ans = 0; + $answer = PLG_SPAM_NOT_FOUND; for ($i = 0; $i < $numRows; $i++) { list($val) = DB_fetchArray($result); $pattern = $this->prepareRegularExpression($val); if (preg_match($pattern, $comment)) { - $ans = 1; // quit on first positive match + $answer = PLG_SPAM_FOUND; // quit on first positive match SPAMX_log($LANG_SX00['foundspam'] . $val . ' (' . $LANG28[42] . ')' . $LANG_SX00['foundspam2'] . $uid . $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR'] @@ -70,8 +77,8 @@ public function execute($comment) } } - $this->result = $ans; + $this->result = $answer; - return $ans; + return $answer; } } diff --git a/plugins/spamx/BaseCommand.class.php b/plugins/spamx/BaseCommand.class.php index b9dadfd7b..749880c66 100644 --- a/plugins/spamx/BaseCommand.class.php +++ b/plugins/spamx/BaseCommand.class.php @@ -36,7 +36,21 @@ protected function callbackHex($str) return chr('0x' . $str); } - abstract public function execute($comment); + /** + * Here we do the work + * + * @param string $comment + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php + */ + abstract public function execute( + $comment, $permanentLink, $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null); /** * Returns one of the result codes defined in "lib-plugins.php" diff --git a/plugins/spamx/BlackList.Examine.class.php b/plugins/spamx/BlackList.Examine.class.php index 219bf913d..7318d04d4 100644 --- a/plugins/spamx/BlackList.Examine.class.php +++ b/plugins/spamx/BlackList.Examine.class.php @@ -31,10 +31,17 @@ class BlackList extends BaseCommand /** * Here we do the work * - * @param string - * @return int + * @param string $comment + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php */ - public function execute($comment) + public function execute($comment, $permanentLink, $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null) { global $_CONF, $_TABLES, $LANG_SX00; @@ -44,7 +51,7 @@ public function execute($comment) * Include Blacklist Data */ $result = DB_query("SELECT value FROM {$_TABLES['spamx']} WHERE name='Personal'", 1); - $nrows = DB_numRows($result); + $numRows = DB_numRows($result); // named entities $comment = html_entity_decode($comment); @@ -55,14 +62,14 @@ public function execute($comment) // hex notation $comment = preg_replace_callback('/&#x([a-f0-9]+);/mi', array($this, 'callbackHex'), $comment); - $ans = PLG_SPAM_NOT_FOUND; + $answer = PLG_SPAM_NOT_FOUND; - for ($i = 1; $i <= $nrows; $i++) { + for ($i = 1; $i <= $numRows; $i++) { list($val) = DB_fetchArray($result); $pattern = $this->prepareRegularExpression($val); if (preg_match($pattern, $comment)) { - $ans = PLG_SPAM_FOUND; // quit on first positive match + $answer = PLG_SPAM_FOUND; // quit on first positive match $this->updateStat('Personal', $val); SPAMX_log($LANG_SX00['foundspam'] . $val . $LANG_SX00['foundspam2'] . $uid . @@ -71,6 +78,6 @@ public function execute($comment) } } - return $ans; + return $answer; } } diff --git a/plugins/spamx/Header.Examine.class.php b/plugins/spamx/Header.Examine.class.php index 9881f8c29..ae72dcc41 100644 --- a/plugins/spamx/Header.Examine.class.php +++ b/plugins/spamx/Header.Examine.class.php @@ -30,10 +30,17 @@ class Header extends BaseCommand /** * Here we do the work * - * @param string - * @return int + * @param string $comment + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php */ - public function execute($comment) + public function execute($comment, $permanentLink, $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null) { global $_TABLES, $LANG_SX00; @@ -58,7 +65,7 @@ public function execute($comment) $result = DB_query("SELECT value FROM {$_TABLES['spamx']} WHERE name='HTTPHeader'", 1); $numRows = DB_numRows($result); - $ans = PLG_SPAM_NOT_FOUND; + $answer = PLG_SPAM_NOT_FOUND; for ($i = 0; $i < $numRows; $i++) { list ($entry) = DB_fetchArray($result); @@ -71,18 +78,19 @@ public function execute($comment) foreach ($headers as $key => $content) { if (strcasecmp($name, $key) === 0) { if (preg_match($pattern, $content)) { - $ans = PLG_SPAM_FOUND; // quit on first positive match + $answer = PLG_SPAM_FOUND; // quit on first positive match $this->updateStat('HTTPHeader', $entry); SPAMX_log($LANG_SX00['foundspam'] . $entry . $LANG_SX00['foundspam2'] . $uid . $LANG_SX00['foundspam3'] . - $_SERVER['REMOTE_ADDR']); + $_SERVER['REMOTE_ADDR'] + ); break; } } } } - return $ans; + return $answer; } } diff --git a/plugins/spamx/IP.Examine.class.php b/plugins/spamx/IP.Examine.class.php index f1a63556e..189c7b317 100644 --- a/plugins/spamx/IP.Examine.class.php +++ b/plugins/spamx/IP.Examine.class.php @@ -27,13 +27,19 @@ class IP extends BaseCommand { /** - * The execute method examines the IP address a comment is coming from, - * comparing it against a blacklist of banned IP addresses. + * Here we do the work * - * @param string $comment Comment text to examine - * @return int 0: no spam, else: spam detected + * @param string $comment + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php */ - public function execute($comment) + public function execute($comment, $permanentLink, $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null) { return $this->_process($_SERVER['REMOTE_ADDR']); } @@ -59,17 +65,17 @@ public function reexecute($comment, $date, $ip, $type) /** * Private internal method to match an IP address against a CIDR * - * @param string $iptocheck IP address to check + * @param string $ipToCheck IP address to check * @param string $CIDR IP address range to check against * @return boolean true if IP falls into the CIDR, else false * @todo CIDR support for IPv6 addresses * Original author: Ian B, taken from * @link http://www.php.net/manual/en/function.ip2long.php#71939 */ - private function _matchCIDR($iptocheck, $CIDR) + private function _matchCIDR($ipToCheck, $CIDR) { // not for IPv6 addresses - if (strpos($iptocheck, ':') !== false) { + if (strpos($ipToCheck, ':') !== false) { return false; } @@ -97,7 +103,7 @@ private function _matchCIDR($iptocheck, $CIDR) $high = $i | (~$mask & 0xFFFFFFFF); // now split the ip we're checking against up into classes - $ex = explode('.', $iptocheck); + $ex = explode('.', $ipToCheck); if (count($ex) == 4) { // now convert the ip we're checking against to an int @@ -147,7 +153,7 @@ private function _matchRange($ip, $range) * address against a blacklist of IP regular expressions. * * @param string $ip IP address of comment poster - * @return int 0: no spam, else: spam detected + * @return int PLG_SPAM_NOT_FOUND: no spam, PLG_SPAM_FOUND: spam detected */ private function _process($ip) { @@ -161,7 +167,7 @@ private function _process($ip) $result = DB_query("SELECT value FROM {$_TABLES['spamx']} WHERE name='IP'", 1); $numRows = DB_numRows($result); - $ans = PLG_SPAM_NOT_FOUND; + $answer = PLG_SPAM_NOT_FOUND; for ($i = 0; $i < $numRows; $i++) { list($val) = DB_fetchArray($result); @@ -176,15 +182,16 @@ private function _process($ip) } if ($matches) { - $ans = PLG_SPAM_FOUND; // quit on first positive match + $answer = PLG_SPAM_FOUND; // quit on first positive match $this->updateStat('IP', $val); SPAMX_log($LANG_SX00['foundspam'] . $val . $LANG_SX00['foundspam2'] . $uid . - $LANG_SX00['foundspam3'] . $ip); + $LANG_SX00['foundspam3'] . $ip) + ; break; } } - return $ans; + return $answer; } } diff --git a/plugins/spamx/IPofUrl.Examine.class.php b/plugins/spamx/IPofUrl.Examine.class.php index 2191a53e2..5992d5ac2 100644 --- a/plugins/spamx/IPofUrl.Examine.class.php +++ b/plugins/spamx/IPofUrl.Examine.class.php @@ -30,11 +30,18 @@ class IPofUrl extends BaseCommand * Here we do the work * * @param string $comment - * @return int + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php */ - public function execute($comment) + public function execute($comment, $permanentLink, $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null) { - global $_CONF, $_TABLES, $LANG_SX00; + global $_TABLES, $LANG_SX00; $uid = $this->getUid(); @@ -48,7 +55,7 @@ public function execute($comment) $result = DB_query("SELECT value FROM {$_TABLES['spamx']} WHERE name='IPofUrl'", 1); $numRows = DB_numRows($result); - $ans = PLG_SPAM_NOT_FOUND; + $answer = PLG_SPAM_NOT_FOUND; for ($j = 1; $j <= $numRows; $j++) { list($val) = DB_fetchArray($result); @@ -57,20 +64,21 @@ public function execute($comment) $ip = gethostbyname($urls[2][$i]); if ($val == $ip) { - $ans = PLG_SPAM_FOUND; // quit on first positive match + $answer = PLG_SPAM_FOUND; // quit on first positive match $this->updateStat('IPofUrl', $val); SPAMX_log($LANG_SX00['foundspam'] . $urls[2][$i] . $LANG_SX00['foundspam2'] . $uid . - $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR']); + $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR'] + ); break; } } - if ($ans == PLG_SPAM_FOUND) { + if ($answer == PLG_SPAM_FOUND) { break; } } - return $ans; + return $answer; } } diff --git a/plugins/spamx/SFS.Examine.class.php b/plugins/spamx/SFS.Examine.class.php index 930993277..b61b545f6 100644 --- a/plugins/spamx/SFS.Examine.class.php +++ b/plugins/spamx/SFS.Examine.class.php @@ -25,26 +25,34 @@ class SFS extends BaseCommand * Here we do the work * * @param string $comment - * @return int + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php */ - public function execute($comment) + public function execute($comment, $permanentLink, $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null) { global $LANG_SX00; - $ans = PLG_SPAM_NOT_FOUND; + $answer = PLG_SPAM_NOT_FOUND; $uid = $this->getUid(); $SFS = new SFSbase(); if ($SFS->CheckForSpam($comment)) { - $ans = PLG_SPAM_FOUND; + $answer = PLG_SPAM_FOUND; SPAMX_log($LANG_SX00['foundspam'] . 'Stop Forum Spam (SFS)' . $LANG_SX00['foundspam2'] . $uid . - $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR']); + $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR'] + ); } // tell the Action module that we've already been triggered $GLOBALS['SFS_triggered'] = true; - return $ans; + return $answer; } } diff --git a/plugins/spamx/SLV.Examine.class.php b/plugins/spamx/SLV.Examine.class.php index ffcd1f3af..b57661924 100644 --- a/plugins/spamx/SLV.Examine.class.php +++ b/plugins/spamx/SLV.Examine.class.php @@ -31,27 +31,35 @@ class SLV extends BaseCommand /** * Here we do the work * - * @param string - * @return int + * @param string $comment + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php */ - public function execute($comment) + public function execute($comment, $permanentLink, $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null) { global $LANG_SX00; - $ans = PLG_SPAM_NOT_FOUND; + $answer = PLG_SPAM_NOT_FOUND; $uid = $this->getUid(); $slv = new SLVbase(); if ($slv->CheckForSpam($comment)) { - $ans = PLG_SPAM_FOUND; + $answer = PLG_SPAM_FOUND; SPAMX_log($LANG_SX00['foundspam'] . 'Spam Link Verification (SLV)' . $LANG_SX00['foundspam2'] . $uid . - $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR']); + $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR'] + ); } // tell the Action module that we've already been triggered $GLOBALS['slv_triggered'] = true; - return $ans; + return $answer; } } diff --git a/plugins/spamx/SNL.Examine.class.php b/plugins/spamx/SNL.Examine.class.php index 693fc536a..2351686e5 100644 --- a/plugins/spamx/SNL.Examine.class.php +++ b/plugins/spamx/SNL.Examine.class.php @@ -27,26 +27,34 @@ class SNL extends BaseCommand * Here we do the work * * @param string $comment - * @return int + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php */ - public function execute($comment) + public function execute($comment, $permanentLink, $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null) { global $LANG_SX00; - $ans = PLG_SPAM_NOT_FOUND; + $answer = PLG_SPAM_NOT_FOUND; $uid = $this->getUid(); - $SNL = new SNLbase(); + if ($SNL->CheckForSpam($comment)) { - $ans = PLG_SPAM_FOUND; + $answer = PLG_SPAM_FOUND; SPAMX_log($LANG_SX00['foundspam'] . 'Spam Number of Links (SNL)' . $LANG_SX00['foundspam2'] . $uid . - $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR']); + $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR'] + ); } // tell the Action module that we've already been triggered $GLOBALS['SNL_triggered'] = true; - return $ans; + return $answer; } } diff --git a/plugins/spamx/configuration_validation.php b/plugins/spamx/configuration_validation.php index b45fc02c8..41477b88b 100644 --- a/plugins/spamx/configuration_validation.php +++ b/plugins/spamx/configuration_validation.php @@ -40,8 +40,12 @@ $_CONF_VALIDATE['spamx']['notification_email'] = array('rule' => 'email'); $_CONF_VALIDATE['spamx']['spamx_action'] = array('rule' => 'numeric'); $_CONF_VALIDATE['spamx']['max_age'] = array('rule' => 'numeric'); + // Modules $_CONF_VALIDATE['spamx']['sfs_enabled'] = array('rule' => 'boolean'); $_CONF_VALIDATE['spamx']['sfs_confidence'] = array('rule' => array('range', 0, 101)); $_CONF_VALIDATE['spamx']['snl_enabled'] = array('rule' => 'boolean'); $_CONF_VALIDATE['spamx']['snl_num_links'] = array('rule' => 'numeric'); +$_CONF_VALIDATE['spamx']['snl_num_links'] = array('rule' => 'numeric'); +$_CONF_VALIDATE['spamx']['akismet_enabled'] = array('rule' => 'boolean'); +$_CONF_VALIDATE['spamx']['akismet_api_key'] = array('rule' => 'stringOrEmpty'); diff --git a/plugins/spamx/functions.inc b/plugins/spamx/functions.inc index 2226ddb0a..e9c04b69b 100644 --- a/plugins/spamx/functions.inc +++ b/plugins/spamx/functions.inc @@ -392,6 +392,8 @@ function plugin_upgrade_spamx() } } + spamx_update_ConfValues_1_3_4(); + $current_version = '1.3.5'; // Shipped with Geeklog-2.2.0 break; @@ -440,11 +442,19 @@ function plugin_migrate_spamx($old_conf) /** * Check a post for spam * - * @param string $comment comment text - * @param int $action (former spam action - not used any more) - * @return int > 0: spam detected, == 0: no spam + * @param string $comment comment text + * @param int $action (former spam action - not used any more) + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php */ -function plugin_checkforSpam_spamx($comment, $action = -1) +function plugin_checkforSpam_spamx($comment, $action = -1, $permanentLink, + $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null) { global $_CONF, $_SPX_CONF, $_TABLES; @@ -482,37 +492,39 @@ function plugin_checkforSpam_spamx($comment, $action = -1) $spamx_path = $_CONF['path'] . 'plugins/spamx/'; - // Set up Spamx_Examine array - $Spamx_Examine = array(); + // Set up SpamxExaminer array + $spamxExaminerSources = array(); if ($dir = @opendir($spamx_path)) { while (($file = readdir($dir)) !== false) { if (is_file($spamx_path . $file)) { if (substr($file, -18) == '.Examine.class.php') { - $sfile = str_replace('.Examine.class.php', '', $file); - $Spamx_Examine[] = $sfile; + $sourceFile = str_replace('.Examine.class.php', '', $file); + $spamxExaminerSources[] = $sourceFile; } } } closedir($dir); } - $res = PLG_SPAM_NOT_FOUND; - - asort($Spamx_Examine); // Sort the files. IP Class needs to execute before Stop Forum Spam class yo save on calls to stopforumspam.com + // Sort the files. IP Class needs to execute before Stop Forum Spam class yo save on calls to stopforumspam.com + asort($spamxExaminerSources); + $answer = PLG_SPAM_NOT_FOUND; - foreach ($Spamx_Examine as $Examine) { - $filename = $Examine . '.Examine.class.php'; - require_once($spamx_path . $filename); + foreach ($spamxExaminerSources as $spamxExaminerSource) { + $filename = $spamxExaminerSource . '.Examine.class.php'; + require_once $spamx_path . $filename; - $EX = new $Examine; - $res = $EX->execute($comment); + $examiner = new $spamxExaminerSource; + $answer = $examiner->execute( + $comment, $permanentLink, $commentType, $commentAuthor, $commentAuthorEmail, $commentAuthorURL + ); - if ($res != PLG_SPAM_NOT_FOUND) { + if ($answer != PLG_SPAM_NOT_FOUND) { break; } } - return $res; + return $answer; } /** diff --git a/plugins/spamx/install_defaults.php b/plugins/spamx/install_defaults.php index 91861b47f..d129fddf9 100644 --- a/plugins/spamx/install_defaults.php +++ b/plugins/spamx/install_defaults.php @@ -85,9 +85,15 @@ // The number of links the module Spam Number of Links allows in a post $_SPX_DEFAULT['snl_num_links'] = 5; +// If the module Akismet is enabled +$_SPX_DEFAULT['akismet_enabled'] = false; + +// API key for Akismet +$_SPX_DEFAULT['akismet_api_key'] = ''; + /** * Initialize Spam-X plugin configuration - * Creates the database entries for the configuation if they don't already + * Creates the database entries for the configuration if they don't already * exist. Initial values will be taken from $_SPX_CONF if available (e.g. from * an old config.php), uses $_SPX_DEFAULT otherwise. * @@ -113,31 +119,29 @@ function plugin_initconfig_spamx() $c->add('sg_main', null, 'subgroup', 0, 0, null, 0, true, 'spamx', 0); $c->add('tab_main', null, 'tab', 0, 0, null, 0, true, 'spamx', 0); $c->add('fs_main', null, 'fieldset', 0, 0, null, 0, true, 'spamx', 0); - $c->add('logging', $_SPX_DEFAULT['logging'], 'select', - 0, 0, 1, 10, true, 'spamx', 0); - $c->add('timeout', $_SPX_DEFAULT['timeout'], 'text', - 0, 0, null, 30, true, 'spamx', 0); - $c->add('notification_email', $_SPX_DEFAULT['notification_email'], - 'text', 0, 0, null, 40, $enable_email, 'spamx', 0); - $c->add('spamx_action', $_SPX_DEFAULT['action'], 'text', - 0, 0, null, 50, false, 'spamx', 0); - $c->add('max_age', $_SPX_DEFAULT['max_age'], 'text', - 0, 0, null, 60, true, 'spamx', 0); + $c->add('logging', $_SPX_DEFAULT['logging'], 'select', 0, 0, 1, 10, true, 'spamx', 0); + $c->add('timeout', $_SPX_DEFAULT['timeout'], 'text', 0, 0, null, 30, true, 'spamx', 0); + $c->add('notification_email', $_SPX_DEFAULT['notification_email'], 'text', 0, 0, null, 40, $enable_email, 'spamx', 0); + $c->add('spamx_action', $_SPX_DEFAULT['action'], 'text', 0, 0, null, 50, false, 'spamx', 0); + $c->add('max_age', $_SPX_DEFAULT['max_age'], 'text', 0, 0, null, 60, true, 'spamx', 0); $c->add('records_delete', $_SPX_DEFAULT['records_delete'], '%text', 0, 0, null, 70, true, 'spamx', 0); $c->add('tab_modules', null, 'tab', 0, 0, null, 0, true, 'spamx', 10); + + // Stop Forum Spam (SFS) $c->add('fs_sfs', null, 'fieldset', 0, 0, null, 0, true, 'spamx', 10); - $c->add('sfs_enabled', $_SPX_DEFAULT['sfs_enabled'], 'select', - 0, 0, 1, 10, true, 'spamx', 10); - $c->add('sfs_confidence', $_SPX_DEFAULT['sfs_confidence'], 'text', - 0, 0, null, 20, true, 'spamx', 10); + $c->add('sfs_enabled', $_SPX_DEFAULT['sfs_enabled'], 'select', 0, 0, 1, 10, true, 'spamx', 10); + $c->add('sfs_confidence', $_SPX_DEFAULT['sfs_confidence'], 'text', 0, 0, null, 20, true, 'spamx', 10); + // Spam Number of Links (SNL) $c->add('fs_snl', null, 'fieldset', 0, 10, null, 0, true, 'spamx', 10); - $c->add('snl_enabled', $_SPX_DEFAULT['snl_enabled'], 'select', - 0, 10, 1, 10, true, 'spamx', 10); - $c->add('snl_num_links', $_SPX_DEFAULT['snl_num_links'], 'text', - 0, 10, null, 20, true, 'spamx', 10); + $c->add('snl_enabled', $_SPX_DEFAULT['snl_enabled'], 'select', 0, 10, 1, 10, true, 'spamx', 10); + $c->add('snl_num_links', $_SPX_DEFAULT['snl_num_links'], 'text', 0, 10, null, 20, true, 'spamx', 10); + // Akismet + $c->add('fs_akismet', null, 'fieldset', 0, 20, null, 0, true, 'spamx', 10); + $c->add('akismet_enabled', $_SPX_DEFAULT['akismet_enabled'], 'select', 0, 20, 1, 10, true, 'spamx', 10); + $c->add('akismet_api_key', $_SPX_DEFAULT['akismet_api_key'], 'text', 0, 20, null, 20, true, 'spamx', 10); } return true; diff --git a/plugins/spamx/install_updates.php b/plugins/spamx/install_updates.php index dcd617bfb..b0b548354 100644 --- a/plugins/spamx/install_updates.php +++ b/plugins/spamx/install_updates.php @@ -59,3 +59,22 @@ function spamx_update_ConfValues_1_3_0() return true; } + +function spamx_update_ConfValues_1_3_4() +{ + global $_CONF, $_SPX_DEFAULT; + + // Now add in new Config options + require_once $_CONF['path_system'] . 'classes/config.class.php'; + + $c = config::get_instance(); + + require_once $_CONF['path'] . 'plugins/spamx/install_defaults.php'; + + // Add in new config options for Akismet module + $c->add('fs_akismet', null, 'fieldset', 0, 20, null, 0, true, 'spamx', 10); + $c->add('akismet_enabled', $_SPX_DEFAULT['akismet_enabled'], 'select', 0, 10, 1, 10, true, 'spamx', 10); + $c->add('akismet_api_key', $_SPX_DEFAULT['akismet_api_key'], 'text', 0, 0, null, 20, true, 'spamx', 10); + + return true; +} diff --git a/plugins/spamx/language/english.php b/plugins/spamx/language/english.php index 506daa1a7..175ebfb7a 100644 --- a/plugins/spamx/language/english.php +++ b/plugins/spamx/language/english.php @@ -4,12 +4,10 @@ * File: english.php * This is the English language file for the Geeklog Spam-X plugin * - * Copyright (C) 2004-2008 by the following authors: + * Copyright (C) 2004-2017 by the following authors: * Author Tom Willett tomw AT pigstye DOT net * * Licensed under GNU General Public License - * - * $Id: english.php,v 1.23 2008/04/13 11:59:08 dhaun Exp $ */ global $LANG32; @@ -170,7 +168,9 @@ 'sfs_enabled' => 'Enable SFS', 'sfs_confidence' => 'Confidence Threshold', 'snl_enabled' => 'Enable SNL', - 'snl_num_links' => 'Number of links' + 'snl_num_links' => 'Number of links', + 'akismet_enabled' => 'Enable Akismet', + 'akismet_api_key' => 'API Key', ); $LANG_configsubgroups['spamx'] = array( @@ -185,12 +185,11 @@ $LANG_fs['spamx'] = array( 'fs_main' => 'Spam-X Main Settings', 'fs_sfs' => 'Stop Forum Spam (SFS)', - 'fs_snl' => 'Spam Number of Links (SNL)' + 'fs_snl' => 'Spam Number of Links (SNL)', + 'fs_akismet' => 'Akismet', ); $LANG_configselects['spamx'] = array( 0 => array('True' => 1, 'False' => 0), 1 => array('True' => TRUE, 'False' => FALSE) ); - -?> diff --git a/plugins/spamx/language/english_utf-8.php b/plugins/spamx/language/english_utf-8.php index 217661298..11c0c0111 100644 --- a/plugins/spamx/language/english_utf-8.php +++ b/plugins/spamx/language/english_utf-8.php @@ -4,12 +4,10 @@ * File: english_utf-8.php * This is the English language file for the Geeklog Spam-X plugin * - * Copyright (C) 2004-2008 by the following authors: + * Copyright (C) 2004-2017 by the following authors: * Author Tom Willett tomw AT pigstye DOT net * * Licensed under GNU General Public License - * - * $Id: english.php,v 1.23 2008/04/13 11:59:08 dhaun Exp $ */ global $LANG32; @@ -170,7 +168,9 @@ 'sfs_enabled' => 'Enable SFS', 'sfs_confidence' => 'Confidence Threshold', 'snl_enabled' => 'Enable SNL', - 'snl_num_links' => 'Number of links' + 'snl_num_links' => 'Number of links', + 'akismet_enabled' => 'Enable Akismet', + 'akismet_api_key' => 'API Key', ); $LANG_configsubgroups['spamx'] = array( @@ -185,12 +185,11 @@ $LANG_fs['spamx'] = array( 'fs_main' => 'Spam-X Main Settings', 'fs_sfs' => 'Stop Forum Spam (SFS)', - 'fs_snl' => 'Spam Number of Links (SNL)' + 'fs_snl' => 'Spam Number of Links (SNL)', + 'fs_akismet' => 'Akismet', ); $LANG_configselects['spamx'] = array( 0 => array('True' => 1, 'False' => 0), 1 => array('True' => TRUE, 'False' => FALSE) ); - -?> diff --git a/plugins/spamx/language/japanese_utf-8.php b/plugins/spamx/language/japanese_utf-8.php index cec3a4868..93b44325b 100644 --- a/plugins/spamx/language/japanese_utf-8.php +++ b/plugins/spamx/language/japanese_utf-8.php @@ -4,17 +4,15 @@ * File: japanese_utf-8.php * This is the Japanese language file for the Geeklog Spam-X plugin * - * Copyright (C) 2004-2008 by the following authors: + * Copyright (C) 2004-2017 by the following authors: * Author Tom Willett tomw AT pigstye DOT net * Tranlated by Ivy (Geeklog Japanese) * Copyright (C) 2008 Takahiro Kambe * Additional translation to Japanese by taca AT back-street DOT net - * Copyright (C) 2006,2007,2008 Geeklog.jp group + * Copyright (C) 2006-2017 Geeklog.jp group * Additional translation to Japanese by Geeklog.jp group info AT geeklog DOT jp * * Licensed under GNU General Public License - * - * $Id: japanese_utf-8.php,v 1.14 2008/09/09 18:26:18 dhaun Exp $ */ global $LANG32; @@ -170,7 +168,9 @@ 'sfs_enabled' => 'Stop Forum Spamモジュールを有効にする', 'sfs_confidence' => '信頼スコアの閾値', 'snl_enabled' => 'Spam Number of Linksモジュールを有効にする', - 'snl_num_links' => 'リンクの数' + 'snl_num_links' => 'リンクの数', + 'akismet_enabled' => 'Akismetモジュールを有効にする', + 'akismet_api_key' => 'APIキー', ); $LANG_configsubgroups['spamx'] = array( @@ -185,7 +185,8 @@ $LANG_fs['spamx'] = array( 'fs_main' => 'Spam-Xの設定', 'fs_sfs' => 'Stop Forum Spam', - 'fs_snl' => 'Spam Number of Links' + 'fs_snl' => 'Spam Number of Links', + 'fs_akismet' => 'Akismet', ); // Note: entries 0, 1, 9, and 12 are the same as in $LANG_configselects['Core'] diff --git a/public_html/docs/english/changes.html b/public_html/docs/english/changes.html index f53a45aee..32875dd55 100644 --- a/public_html/docs/english/changes.html +++ b/public_html/docs/english/changes.html @@ -27,6 +27,7 @@

New Features and Improvements

  • Dropped support for Live Journal authentication.
  • +
  • Added Akismet module for the Spam-X plugin.
diff --git a/public_html/docs/english/spamx.html b/public_html/docs/english/spamx.html index fe4e8fe7e..8a8546f97 100644 --- a/public_html/docs/english/spamx.html +++ b/public_html/docs/english/spamx.html @@ -1,14 +1,15 @@ - - Geeklog Documentation - Geeklog Spam-X Plugin - - + + Geeklog Documentation - Geeklog Spam-X Plugin + + -

Geeklog

+

Geeklog

Geeklog Spam-X Plugin

@@ -16,349 +17,394 @@

Geeklog Spam-X Plugin

Introduction

The Geeklog Spam-X plugin was created to fight the problem of comment spam -for Geeklog systems. If you are unfamiliar with comment spam you might see the -Comment Spam -Manifesto.

+ for Geeklog systems. If you are unfamiliar with comment spam you might see the + Comment Spam + Manifesto.

Spam protection in Geeklog is mostly based on the Spam-X plugin, originally -developed by Tom Willet. It has a modular architecture that allows it to be -extended with new modules to fight the spammer's latest tricks, should the need -arise.

+ developed by Tom Willet. It has a modular architecture that allows it to be + extended with new modules to fight the spammer's latest tricks, should the need + arise.

What is being checked for spam?

Geeklog and the Spam-X plugin will check the following for spam:

    -
  • Story submissions
  • -
  • Comments
  • -
  • Trackbacks and Pingbacks
  • -
  • Event submissions
  • -
  • Link submissions
  • -
  • The text sent with the "Email story to a friend" option
  • -
  • Emails sent to users via the "send email" form from their profile page
  • -
  • A user's profile
  • +
  • Story submissions
  • +
  • Comments
  • +
  • Trackbacks and Pingbacks
  • +
  • Event submissions
  • +
  • Link submissions
  • +
  • The text sent with the "Email story to a friend" option
  • +
  • Emails sent to users via the "send email" form from their profile page
  • +
  • A user's profile

Module Types

The Spam-X plugin was built to be expandable to easily adapt to changes the -comment spammers might make. There are three types of modules: Examine, Action, and Admin. A new module is contained in a file and can simply be -dropped in and it will be added to the plugin.

+ comment spammers might make. There are three types of modules: Examine, Action, and Admin. A new module is contained in a file and can simply be + dropped in and it will be added to the plugin.

Examine Modules

Geeklog ships with the following examine modules:

Spam Link Verification (SLV)

SLV is a centralized, server-based service that examines posts made on -websites and detects when certain links show up in unusually high numbers. In -other words, when a spammer starts spamming a lot of sites with the same URLs -and those sites all report to SLV, the system will recognize this as a spam -wave and will flag posts containing these URLs as spam.

+ websites and detects when certain links show up in unusually high numbers. In + other words, when a spammer starts spamming a lot of sites with the same URLs + and those sites all report to SLV, the system will recognize this as a spam + wave and will flag posts containing these URLs as spam.

In other words still, it's a dynamic blacklist that automatically updates -itself when a spammer starts spamming for their site. And it can only get -better (in terms of accuracy and reaction speed) the more sites use it.

+ itself when a spammer starts spamming for their site. And it can only get + better (in terms of accuracy and reaction speed) the more sites use it.

SLV is a free service run by Russ Jones at www.linksleeve.org.

+ href="http://www.linksleeve.org/">www.linksleeve.org.

Privacy Notice: -It should be stressed that using SLV means that information from your site -is being sent to a third party's site. In some legislations you may have to -inform your users about this fact - please check with your local privacy -laws.

+ It should be stressed that using SLV means that information from your site + is being sent to a third party's site. In some legislations you may have to + inform your users about this fact - please check with your local privacy + laws.

Sending information to an external site may also be undesirable on some -setups, e.g. on a company intranet. You can disable SLV support by removing the -four files SLV.Examine.class.php, SLVbase.class.php, -SLVreport.Action.class.php, and SLVwhitelist.Admin.class.php - from your Spam-X directory (/path/to/geeklog/plugins/spamx). Or you -can simply disable the Spam-X plugin entirely (or uninstall it).

+ setups, e.g. on a company intranet. You can disable SLV support by removing the + four files SLV.Examine.class.php, SLVbase.class.php, + SLVreport.Action.class.php, and SLVwhitelist.Admin.class.php + from your Spam-X directory (/path/to/geeklog/plugins/spamx). Or you + can simply disable the Spam-X plugin entirely (or uninstall it).

The SLV Examine and Action modules will extract all URLs from a post and -only send those to SLV (i.e. the rest of the post's content is not being sent). -They also remove any links that contain your Geeklog site's URL. In case a post -does not contain any external links, the modules simply do not contact SLV at -all.

+ only send those to SLV (i.e. the rest of the post's content is not being sent). + They also remove any links that contain your Geeklog site's URL. In case a post + does not contain any external links, the modules simply do not contact SLV at + all.

Personal Blacklist

The Personal Blacklist module lets you add keywords and URLs that typically -exist in spam posts. When you're being hit by spam, make sure to add the URLs -of those spam posts to your Personal Blacklist so that they can be filtered out -automatically, should the spammer try to post them again.

+ exist in spam posts. When you're being hit by spam, make sure to add the URLs + of those spam posts to your Personal Blacklist so that they can be filtered out + automatically, should the spammer try to post them again.

This will also help you get rid of spam that made it through, as you can -then use the Mass Delete Comments and Mass Delete Trackbacks modules to easily -remove large numbers of spam posts from your database.

+ then use the Mass Delete Comments and Mass Delete Trackbacks modules to easily + remove large numbers of spam posts from your database.

The Personal Blacklist also has an option to import the Geeklog censor list and ban all comments which -contain one of those words. This or an expanded list might be useful for a -website that caters to children. Then no comments with offensive language could -be posted.

+ href="config.html#desc_censorlist">censor list and ban all comments which + contain one of those words. This or an expanded list might be useful for a + website that caters to children. Then no comments with offensive language could + be posted.

IP Filter

Sometimes you will encounter spam that is coming from one or only a few IP -addresses. By simply adding those IP addresses to the IP Filter module, any -posts from these IPs will be blocked automatically.

+ addresses. By simply adding those IP addresses to the IP Filter module, any + posts from these IPs will be blocked automatically.

In addition to single IP addresses, you can also add IP address ranges, -either in CIDR notation or as simple from-to ranges.

+ either in CIDR notation or as + simple from-to ranges.

Please note that IP addresses aren't really a good filter criterion. While -some ISPs and hosting services are known to host spammers, it won't help much -to block an IP address by one of the well-known ISPs. Often, the spammer will -get a new IP address the next time he connects to the internet, while the -blocked IP address will be reused and may be used by some innocent user.

+ some ISPs and hosting services are known to host spammers, it won't help much + to block an IP address by one of the well-known ISPs. Often, the spammer will + get a new IP address the next time he connects to the internet, while the + blocked IP address will be reused and may be used by some innocent user.

IP of URL Filter

This module is only useful in a few special cases: Here you enter the IP -address of a webserver that is used to host domains for which you may see spam. -Some spammers have a lot of their sites on only a few webservers, so instead of -adding lots of domains to your blacklist, you only add the IP addresses of -those webservers. The Spam-X module will then check all the URLs in a post to -see if any of these is hosted on one of those blacklisted webservers.

+ address of a webserver that is used to host domains for which you may see spam. + Some spammers have a lot of their sites on only a few webservers, so instead of + adding lots of domains to your blacklist, you only add the IP addresses of + those webservers. The Spam-X module will then check all the URLs in a post to + see if any of these is hosted on one of those blacklisted webservers.

HTTP Header Filter

This module lets you filter for certain HTTP headers. Every HTTP request -sent to your site is accompanied by a series of headers identifying, for -example, the browser that your visitors uses, their preferred language, and -other information.

+ sent to your site is accompanied by a series of headers identifying, for + example, the browser that your visitors uses, their preferred language, and + other information.

With the Header filter module, you can block HTTP requests with certain -headers. For example, some spammers are using Perl scripts to send their spam -posts. The user agent (browser identification) sent by Perl scripts is usually -something like "libwww-perl/5.805" (the version number may vary). So to block -posts made by this user agent, you would enter:

+ headers. For example, some spammers are using Perl scripts to send their spam + posts. The user agent (browser identification) sent by Perl scripts is usually + something like "libwww-perl/5.805" (the version number may vary). So to block + posts made by this user agent, you would enter:

- - + + + + + + + +
Header:User-Agent
Content:^libwww-perl
Header:User-Agent
Content:^libwww-perl

This would block all posts from user agents beginning with "libwww-perl".

Stop Forum Spam (SFS)

-

Stop Forum Spam is a centralized, server-based service that provides lists of -ips, usernames and email addresses of know spammers of forums and blogs. With this -module enabled, on new user registrations the ip of the user and email address -will be checked against the SFS database. If found the Geeklog user account will -not be created.

+

Stop Forum Spam is a centralized, server-based service that provides lists of + ips, usernames and email addresses of know spammers of forums and blogs. With this + module enabled, on new user registrations the ip of the user and email address + will be checked against the SFS database. If found the Geeklog user account will + not be created.

SFS is a free service and can be found at www.stopforumspam.com.

+ href="http://www.stopforumspam.com/">www.stopforumspam.com.

Privacy Notice: -Enabling SFS means that user information (ip and email address) from your site -is being sent to a third party. In some legislations you may have to inform your -users about this fact - please check with your local privacy laws.

+ Enabling SFS means that user information (ip and email address) from your site + is being sent to a third party. In some legislation you may have to inform your + users about this fact - please check with your local privacy laws.

Spam Number of Links (SNL)

-

With this module enabled you can limit the number of links that appear in a -post and user profile. To enable the module and set the number of links you need -to update the Spam-X configuration. If enabled you should allow at least 1 link -to take into account when a user creates a profile since Homepage is a default -user field.

+

With this module enabled you can limit the number of links that appear in a + post and user profile. To enable the module and set the number of links you need + to update the Spam-X configuration. If enabled you should allow at least 1 link + to take into account when a user creates a profile since Homepage is a default + user field.

+ +

Akismet

+ +

With this module enabled, you can use Akismet service provided at + https://akismet.com/. However, to enable this module, + you have to sign up at this page, + get your API key, and set it at the Configuration > Spam-X > Modules > + Akismet > API Key. +

Action Modules

Once one of the examine modules detects a spam post, -the action modules will decide what to do with the spam. Most of the time, you -will simply want to delete the post then, so this is what the Delete -Action module does.

+ the action modules will decide what to do with the spam. Most of the time, you + will simply want to delete the post then, so this is what the Delete + Action module does.

As the name implies, the Mail Admin Action module sends an email to -the site admin when a spam post is encountered. Since this can cause quite a -lot of emails being sent, it is disabled by default.

+ the site admin when a spam post is encountered. Since this can cause quite a + lot of emails being sent, it is disabled by default.

Action modules have to be enabled specifically before they are used (examine -modules, on the other hand, are activated by simply dropping them into the -Spam-X directory). For this, every action module has a unique number that needs -to be added up with the number of the other action modules you want to enable -and entered as the value for the spamx config -variable in Geeklog's main configuration.

+ modules, on the other hand, are activated by simply dropping them into the + Spam-X directory). For this, every action module has a unique number that needs + to be added up with the number of the other action modules you want to enable + and entered as the value for the spamx config + variable in Geeklog's main configuration.

Example

The Delete Action module has the value 128, while the Mail Admin Action -module has the value 8. So to activate both modules, add 128 + 8 = 136 and -enter that in the Configuration admin panel.

+ module has the value 8. So to activate both modules, add 128 + 8 = 136 and + enter that in the Configuration admin panel.

The SLV Examine module is complemented by a SLV Action -module that ensures that SLV is notified of spam posts caught by other examine -modules. It "piggybacks" on the Delete Action module, i.e. when you activate -the Delete Action module, you'll also enable the SLV Action module.

+ module that ensures that SLV is notified of spam posts caught by other examine + modules. It "piggybacks" on the Delete Action module, i.e. when you activate + the Delete Action module, you'll also enable the SLV Action module.

Admin Modules

The Admin modules for the Personal Blacklist, IP Filter, IP of URL Filter, and HTTP Header Filter modules provide you with a form to add -new entries. To delete an existing entry, simply click on it.

+ href="#ip">IP Filter, IP of URL Filter, and HTTP Header Filter modules provide you with a form to add + new entries. To delete an existing entry, simply click on it.

With the SLV Whitelist admin module you can add URLs that -you don't want to be reported to SLV. This is useful when posts on your site -happen to contain certain URLs quite often but you don't want those to be -considered spam by SLV.
Note that your site's URL (i.e. $_CONF['site_url']) is automatically -whitelisted, so you don't need to add it here.

+ you don't want to be reported to SLV. This is useful when posts on your site + happen to contain certain URLs quite often but you don't want those to be + considered spam by SLV.
Note that your site's URL (i.e. $_CONF['site_url']) is automatically + whitelisted, so you don't need to add it here.

The Log View module lets you inspect and clear the Spam-X -logfile. The logfile contains additional information about the spam posts, e.g. -which IP address they came from, the user id (if posted by a logged-in user), -and which of the examine modules caught the spam post.

+ logfile. The logfile contains additional information about the spam posts, e.g. + which IP address they came from, the user id (if posted by a logged-in user), + and which of the examine modules caught the spam post.

In case a large number of spam posts made it through without being caught, -the Mass Delete Comments and Mass Delete -Trackbacks modules will help you get rid of them easily. Before you -use these modules, make sure to add the URLs or keywords from those spams to -your Personal Blacklist.

+ the Mass Delete Comments and Mass Delete + Trackbacks modules will help you get rid of them easily. Before you + use these modules, make sure to add the URLs or keywords from those spams to + your Personal Blacklist.

Note about MT-Blacklist

MT-Blacklist was a blacklist, i.e. a listing of URLs that were used in spam -posts, originally developed for Movable Type (hence the name) and maintained by -Jay Allen.

+ posts, originally developed for Movable Type (hence the name) and maintained by + Jay Allen.

Maintaining a blacklist is a lot of work, and you're continually playing -catch-up with the spammers. Therefore, Jay Allen eventually discontinued -MT-Blacklist on the assumption that new and better methods to detect spam -are now available.

+ catch-up with the spammers. Therefore, Jay Allen eventually discontinued + MT-Blacklist on the assumption that new and better methods to detect spam + are now available.

Starting with Geeklog 1.4.1, Geeklog no longer uses MT-Blacklist. All -MT-Blacklist entries are removed from the database when you upgrade to -Geeklog 1.4.1 and the MT-Blacklist examine and admin modules are no longer -included.

+ MT-Blacklist entries are removed from the database when you upgrade to + Geeklog 1.4.1 and the MT-Blacklist examine and admin modules are no longer + included.

Trackback Spam

Trackbacks are also run through Spam-X before -they will be accepted by Geeklog. There are also some additional checks that -can be performed on trackbacks: Geeklog can be configured to check if the site -that supposedly sent the trackback actually contains a link back to your site. -In addition, Geeklog can also check if the IP address of the site in the -trackback URL matches the IP address that sent the trackback. Trackbacks that -fail any of these tests are usually spam. Please refer to the documentation for the -configuration for more information.

+ they will be accepted by Geeklog. There are also some additional checks that + can be performed on trackbacks: Geeklog can be configured to check if the site + that supposedly sent the trackback actually contains a link back to your site. + In addition, Geeklog can also check if the IP address of the site in the + trackback URL matches the IP address that sent the trackback. Trackbacks that + fail any of these tests are usually spam. Please refer to the documentation for the + configuration for more information.

Configuration

The Spam-X plugin's configuration can be changed from the Configuration admin -panel:

+ panel:

Spam-X Main Settings

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VariableDefault ValueDescription
loggingtrueWhether to log recognized spam posts in the spamx.log logfile - (if set to true) or not (false).
timeout5Timeout (in seconds) for contacting external services such as SLV and SFS.
notification_email$_CONF['site_mail']Email address to which spam notifications are sent when the Mail Admin - action module is enabled.
spamx_action128This only exists as a fallback in case $_CONF['spamx'] in Geeklog's main - configuration is not set. I.e. $_CONF['spamx'] takes - precedence.
max_age0The max age in days to keep Spam-X records since there last update (0 = infinite). SLV Whitelist records will not be deleted.
records_delete'email', 'IP'The Spam-X record types to delete when max age is reached. Default types include:
    -
  • Personal Blacklist = 'Personal'
  • -
  • HTTP Header Blacklist = 'HTTPHeader'
  • -
  • IP Blacklist = 'IP'
  • -
  • IP of URL Blacklist = 'IPofUrl'
  • -
  • SFS Email Blacklist = 'email'
  • -
  • SLV Whitelist = 'SLVwhitelist'
  • -
VariableDefault ValueDescription
loggingtrueWhether to log recognized spam posts in the spamx.log logfile + (if set to true) or not (false). +
timeout5Timeout (in seconds) for contacting external services such as SLV and SFS.
notification_email$_CONF['site_mail']Email address to which spam notifications are sent when the Mail Admin + action module is enabled. +
spamx_action128This only exists as a fallback in case $_CONF['spamx'] in Geeklog's main + configuration is not set. I.e. $_CONF['spamx'] takes + precedence. +
max_age0The max age in days to keep Spam-X records since there last update (0 = infinite). SLV Whitelist records + will not be deleted. +
records_delete'email', 'IP'The Spam-X record types to delete when max age is reached. Default types include: +
    +
  • Personal Blacklist = 'Personal'
  • +
  • HTTP Header Blacklist = 'HTTPHeader'
  • +
  • IP Blacklist = 'IP'
  • +
  • IP of URL Blacklist = 'IPofUrl'
  • +
  • SFS Email Blacklist = 'email'
  • +
  • SLV Whitelist = 'SLVwhitelist'
  • +
+

Modules

- - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VariableDefault ValueDescription
sfs_enabledtrueWhether the Stop Forum Spam (SFS) module is enabled or not. If enabled then email and ip addresses of new user registrations will be checked with StopForumSpam.com to see if they are spam.
sfs_confidence25The threshold for the Stop Forum Spam confidence score (as a percentage) which is a reasonably good indicator that the field under test, would result in unwanted activity. The range of this inputed value must be from 1 to 100.
snl_enabledtrueWhether the Spam Number of Links (SNL) module is enabled or not. If enabled it will only allow a specified number of links in a post or when a user creates or updates their profile.
snl_num_links5The maximum number of links allowed in a post or profile before it is considered spam.
VariableDefault ValueDescription
sfs_enabledtrueWhether the Stop Forum Spam (SFS) module is enabled or not. If enabled then email and ip addresses of new + user registrations will be checked with StopForumSpam.com to see if they are spam. +
sfs_confidence25The threshold for the Stop Forum Spam confidence score (as a percentage) which is a reasonably good + indicator that the field under test, would result in unwanted activity. The range of this inputed value must + be from 1 to 100. +
snl_enabledtrueWhether the Spam Number of Links (SNL) module is enabled or not. If enabled it will only allow a specified + number of links in a post or when a user creates or updates their profile. +
snl_num_links5The maximum number of links allowed in a post or profile before it is considered spam.
akismet_enabledfalseWhether the Akismet module is enabled or not. If enabled it will check with Akismet service. +
akismet_api_key(none)The API key you got at this page.

More Information

Further information as well as a support forum for the Spam-X plugin can be -found on the Spam-X Plugin's Homepage and in the Geeklog -Wiki.

+ found on the Spam-X Plugin's + Homepage and in the Geeklog + Wiki.

diff --git a/public_html/docs/japanese/changes.html b/public_html/docs/japanese/changes.html index 3ee9f02e1..f6570c318 100644 --- a/public_html/docs/japanese/changes.html +++ b/public_html/docs/japanese/changes.html @@ -27,6 +27,7 @@

New Features and Improvements

  • Dropped support for Live Journal authentication.
  • +
  • Added Akismet module for the Spam-X plugin.
diff --git a/public_html/docs/japanese/spamx.html b/public_html/docs/japanese/spamx.html index f7a278c90..47f31d174 100644 --- a/public_html/docs/japanese/spamx.html +++ b/public_html/docs/japanese/spamx.html @@ -1,248 +1,321 @@ - - - Spam-Xプラグイン | Geeklogドキュメント - - - + + + Spam-Xプラグイン | Geeklogドキュメント + + + -

Geeklog Documentation

+

Geeklog Documentation

Geeklog Spam-Xプラグイン

概要

-

Geeklog Spam-Xプラグインは、Geeklogシステムに対するコメントスパム対策として開発されました。コメントスパムをよく知らない方はコメントスパムマニフェストをご覧ください。

+

Geeklog Spam-Xプラグインは、Geeklogシステムに対するコメントスパム対策として開発されました。コメントスパムをよく知らない方はコメントスパムマニフェストをご覧ください。

-

Geeklogでのスパム対策はもっぱらTom Willetが開発したSpam-Xプラグインに頼っています。このプラグインはモジュール構造を採用しており、スパム送信者の最新の手法に対応する必要が生じた場合は、新しいモジュールで機能を拡張できるようになっています。

+

Geeklogでのスパム対策はもっぱらTom + Willetが開発したSpam-Xプラグインに頼っています。このプラグインはモジュール構造を採用しており、スパム送信者の最新の手法に対応する必要が生じた場合は、新しいモジュールで機能を拡張できるようになっています。

スパム検索の対象となるもの

GeeklogとSpam-Xプラグインは次のものを対象とします。

    -
  • 投稿される記事
  • -
  • コメント
  • -
  • トラックバックとピングバック
  • -
  • 投稿されるイベント
  • -
  • 投稿されるリンク
  • -
  • 「友だちに記事をメールする」機能で添えられる文章
  • -
  • ユーザープロフィールのページからメールフォーム経由で送信されるEメール
  • -
  • ユーザーのプロフィール
  • +
  • 投稿される記事
  • +
  • コメント
  • +
  • トラックバックとピングバック
  • +
  • 投稿されるイベント
  • +
  • 投稿されるリンク
  • +
  • 「友だちに記事をメールする」機能で添えられる文章
  • +
  • ユーザープロフィールのページからメールフォーム経由で送信されるEメール
  • +
  • ユーザーのプロフィール

モジュールの種類

-

Spam-Xプラグインは、コメントスパム送信者の変化に対して容易に対応できるよう、拡張性を重視して開発されました。検出(Examine)アクション(Action)管理(Admin)モジュールの3種類があります。新規モジュールは1個のファイルに収められているので、該当ディレクトリに追加しさえすれば、プラグインの機能を追加できます。

+

Spam-Xプラグインは、コメントスパム送信者の変化に対して容易に対応できるよう、拡張性を重視して開発されました。検出(Examine)アクション(Action)管理(Admin)モジュールの3種類があります。新規モジュールは1個のファイルに収められているので、該当ディレクトリに追加しさえすれば、プラグインの機能を追加できます。

検出モジュール

Geeklogには次の検出モジュールが同梱されています。

スパムリンク検証(SLV: Spam Link Verification)

-

SLVは集約されたサーバを拠点としたサービスで、Webサイトに投稿されたものを検証し、特定のリンクが異常なほど多く見られる場合にそれを検出します。言い換えれば、スパム送信者が多くのサイトに同一URLを含むスパムを送信し始め、これらのサイトすべてがSLVに報告した場合、SLVシステムはこの傾向をスパムと認識し、該当URLを含む投稿をスパムと判定します。

+

+ SLVは集約されたサーバを拠点としたサービスで、Webサイトに投稿されたものを検証し、特定のリンクが異常なほど多く見られる場合にそれを検出します。言い換えれば、スパム送信者が多くのサイトに同一URLを含むスパムを送信し始め、これらのサイトすべてがSLVに報告した場合、SLVシステムはこの傾向をスパムと認識し、該当URLを含む投稿をスパムと判定します。

-

さらに言い換えると、SLVは、スパム送信者がサイトにスパムを送信し始めたときに、自動的に更新されるブラックリストであると言えます。SLVを使用するサイトが増えれば増えるほど(正確さと反応速度という点では)、ますますその質が高まります。

+

+ さらに言い換えると、SLVは、スパム送信者がサイトにスパムを送信し始めたときに、自動的に更新されるブラックリストであると言えます。SLVを使用するサイトが増えれば増えるほど(正確さと反応速度という点では)、ますますその質が高まります。

SLVはRuss Jonesがwww.linksleeve.orgで運営している無料のサービスです。

-

プライバシーポリシーの表示
-SLVを使用しているということは、自分のサイトから第三者のサイトに情報を送信していることになるということを強調しておいた方がよいでしょう。法体系によっては、ユーザーにこの事実を告知する必要があるかもしれません。ご自分の地域のプライバシーに関する法律を確認してください。

+

プライバシーポリシーの表示
+ SLVを使用しているということは、自分のサイトから第三者のサイトに情報を送信していることになるということを強調しておいた方がよいでしょう。法体系によっては、ユーザーにこの事実を告知する必要があるかもしれません。ご自分の地域のプライバシーに関する法律を確認してください。 +

-

運用している状況によっては(たとえば、企業のイントラネットなど)、情報を外部のサイトに送信することが望ましくない場合もあるでしょう。その場合は、 SLV.Examine.class.php, SLVbase.class.php, SLVreport.Action.class.php, SLVwhitelist.Admin.class.php の4つのファイルをSpam-Xのディレクトリ(/path/to/geeklog/plugins/spamx)から削除すれば、SLVを無効にできます。単にSpam-Xプラグインを無効にする(または、アンインストールする)だけでもよいです。

+

運用している状況によっては(たとえば、企業のイントラネットなど)、情報を外部のサイトに送信することが望ましくない場合もあるでしょう。その場合は、 SLV.Examine.class.php, SLVbase.class.php, SLVreport.Action.class.php, + SLVwhitelist.Admin.class.php の4つのファイルをSpam-Xのディレクトリ(/path/to/geeklog/plugins/spamx)から削除すれば、SLVを無効にできます。単にSpam-Xプラグインを無効にする(または、アンインストールする)だけでもよいです。 +

-

SLV検証モジュールとアクションモジュールは、投稿されたデータからすべてのURLを抽出し、SLVへ送信するだけです(つまり、投稿されたデータのURL以外の部分は送信されません。)。また、自分のGeeklogサイトのURLを含むリンクはすべて除外します。投稿されたデータに外部リンクが含まれていない場合、これらのモジュールはSLVと通信を行いません。

+

+ SLV検証モジュールとアクションモジュールは、投稿されたデータからすべてのURLを抽出し、SLVへ送信するだけです(つまり、投稿されたデータのURL以外の部分は送信されません。)。また、自分のGeeklogサイトのURLを含むリンクはすべて除外します。投稿されたデータに外部リンクが含まれていない場合、これらのモジュールはSLVと通信を行いません。

パーソナルブラックリスト(Personal Blacklist)

-

パーソナルブラックリストモジュールを使用すると、スパム投稿によく見られるキーワードとURLをブラックリストに追加できます。スパムが投稿されている場合、そのURLをパーソナルブラックリストに追加すれば、送信者が再びスパムを投稿しても締め出すことができます。

+

+ パーソナルブラックリストモジュールを使用すると、スパム投稿によく見られるキーワードとURLをブラックリストに追加できます。スパムが投稿されている場合、そのURLをパーソナルブラックリストに追加すれば、送信者が再びスパムを投稿しても締め出すことができます。

上記を行うことにより、既に受信したスパムを削除しやすくなります。データベースから多数のスパム投稿を削除するのに、一括コメント削除と一括トラックバック削除を使用できるようになるからです。

-

パーソナルブラックリストには、Geeklogのバッドワードリスト(censor list)を読み込み、バッドワードを含むコメントをすべて禁止する機能があります。このようなリストは子ども向けのサイトには有用でしょう。ふさわしくない言葉を含むコメントは投稿できなくなるからです。

+

パーソナルブラックリストには、Geeklogのバッドワードリスト(censor list)を読み込み、バッドワードを含むコメントをすべて禁止する機能があります。このようなリストは子ども向けのサイトには有用でしょう。ふさわしくない言葉を含むコメントは投稿できなくなるからです。 +

IPフィルター(IP Filter)

1つないし少数のIPアドレスから送信されるスパムに出くわすこともあります。IPフィルターモジュールを追加することで、これらのIPアドレスから送信されるスパムを自動的にブロックできます。

-

単一のIPアドレスだけでなく、CIDR表記や開始アドレス-終了アドレス という形式で、IPアドレスの範囲を指定することもできます。

+

単一のIPアドレスだけでなく、CIDR表記や開始アドレス-終了アドレス + という形式で、IPアドレスの範囲を指定することもできます。

-

IPアドレスが実際にはあまりよい判断基準にはならないということに注意してください。インターネットサービスプロバイダやホスティングサービスの中にはスパムの温床として知られているものもありますが、それらのIPアドレスをブロックしてもあまり役には立たないでしょう。スパム送信者はインターネットへ接続し直すときに新しいIPアドレスを取得するのに対し、ブロックされたIPアドレスは他の罪もないユーザーが使用することがよくあるからです。

+

+ IPアドレスが実際にはあまりよい判断基準にはならないということに注意してください。インターネットサービスプロバイダやホスティングサービスの中にはスパムの温床として知られているものもありますが、それらのIPアドレスをブロックしてもあまり役には立たないでしょう。スパム送信者はインターネットへ接続し直すときに新しいIPアドレスを取得するのに対し、ブロックされたIPアドレスは他の罪もないユーザーが使用することがよくあるからです。

URLのIPフィルター(IP of URL Filter)

-

このモジュールが役に立つのは少数の特別な場合だけです。ここでは、スパム送信元のドメインを収容しているWebサーバのIPアドレスを入力します。スパム送信者の中には多数のサイトを少数のWebサーバ上で運営しているものがいます。このような場合は、多数のドメイン名ではなくWebサーバのIPアドレスをブラックリストに追加すればよいでしょう。Spam-Xプラグインは、投稿されたデータ中のすべてのURLをチェックし、該当するIPアドレスがないかチェックします。

+

+ このモジュールが役に立つのは少数の特別な場合だけです。ここでは、スパム送信元のドメインを収容しているWebサーバのIPアドレスを入力します。スパム送信者の中には多数のサイトを少数のWebサーバ上で運営しているものがいます。このような場合は、多数のドメイン名ではなくWebサーバのIPアドレスをブラックリストに追加すればよいでしょう。Spam-Xプラグインは、投稿されたデータ中のすべてのURLをチェックし、該当するIPアドレスがないかチェックします。

HTTPヘッダーフィルター(HTTP Header Filter)

このモジュールを使用すると、ある種のHTTPヘッダーを検出することができます。サイトへ送信されるすべてのHTTPリクエストには、訪問者が使用しているWebブラウザーや使用言語などの情報を識別するヘッダーが付随しています。

-

HTTPヘッダーフィルターモジュールを使用すると、ある種のHTTPリクエストをブロックすることができます。たとえば、スパム送信者の中には、スパムを送信するのにPerlスクリプトを使用しているものがいます。Perlスクリプトが送信するユーザーエージェント(ブラウザー識別情報)は "libwww-perl/5.805" (バージョン番号はこれとは違う場合もある)のようなものが多いです。したがって、このユーザーエージェントが送信するスパムをブロックするには、次のように入力します。

+

+ HTTPヘッダーフィルターモジュールを使用すると、ある種のHTTPリクエストをブロックすることができます。たとえば、スパム送信者の中には、スパムを送信するのにPerlスクリプトを使用しているものがいます。Perlスクリプトが送信するユーザーエージェント(ブラウザー識別情報)は + "libwww-perl/5.805" (バージョン番号はこれとは違う場合もある)のようなものが多いです。したがって、このユーザーエージェントが送信するスパムをブロックするには、次のように入力します。

- - + + + + + + + +
Header:User-Agent
Content:^libwww-perl
Header:User-Agent
Content:^libwww-perl

これで "libwww-perl" で始まるユーザーエージェントからのスパム投稿はすべてブロックされます。

Stop Forum Spam (SFS)

Stop Forum Spamは集約されたサーバーを基にするサービスで、 -掲示板やブログの既知のスパム送信者のIPアドレス、ユーザー名、メールアドレスのリストを提供します。 -このモジュールを有効にすると、新規ユーザーの登録の際に、ユーザーのIPアドレスとメールアドレスを -SFSのデータベースでチェックします。該当データが見つかった場合、 -Geeklog上のユーザーアカウントは作成されません。

+ 掲示板やブログの既知のスパム送信者のIPアドレス、ユーザー名、メールアドレスのリストを提供します。 + このモジュールを有効にすると、新規ユーザーの登録の際に、ユーザーのIPアドレスとメールアドレスを + SFSのデータベースでチェックします。該当データが見つかった場合、 + Geeklog上のユーザーアカウントは作成されません。

SFSはフリーのサービスで、www.stopforumspam.comで運営されています。

+ href="http://www.stopforumspam.com/">www.stopforumspam.comで運営されています。

Spam Number of Links (SNL)

このモジュールを有効にすると、投稿とユーザーのプロフィールに含まれるリンクの数を制限することができます。 -このモジュールを有効にしてリンクの数を設定するには、 -コンフィギュレーションからSpam-Xの設定を変更する必要があります。有効にする場合は、リンク数を少なくとも1個に設定した方がよいでしょう。 -ホームページのフィールドは既定でプロフィールのページに作成されるからです。

+ このモジュールを有効にしてリンクの数を設定するには、 + コンフィギュレーションからSpam-Xの設定を変更する必要があります。有効にする場合は、リンク数を少なくとも1個に設定した方がよいでしょう。 + ホームページのフィールドは既定でプロフィールのページに作成されるからです。

+ +

Akismet

+ +

このモジュールを有効にすると、 + https://akismet.com/で提供されているサービスを利用できます。しかしながら、このモジュールを有効にするには、 + このページでサインアップして、 + APIキーを取得し、そのキーを コンフィギュレーション > Spam-X > モジュール > + Akismet > APIキー で有効にする必要があります。 +

アクションモジュール

-

いったん検出モジュールがスパム投稿を検出すると、アクションモジュールがスパムをどう処理するかを判断します。たいていの場合、スパムを削除するだけでよいですが、これを行うのが削除アクション(Delete Action) モジュールです。

+

いったん検出モジュールがスパム投稿を検出すると、アクションモジュールがスパムをどう処理するかを判断します。たいていの場合、スパムを削除するだけでよいですが、これを行うのが削除アクション(Delete + Action) モジュールです。

-

その名前が示すとおり、管理者メールアクション(Mail Admin Action) モジュールはスパムを検出したときに、サイト管理者にメールで通知します。多数の通知メールが送られる可能性があるため、デフォルトでは無効になっています。

+

その名前が示すとおり、管理者メールアクション(Mail Admin Action) + モジュールはスパムを検出したときに、サイト管理者にメールで通知します。多数の通知メールが送られる可能性があるため、デフォルトでは無効になっています。

-

アクションモジュールは使用する前に個別に有効にする必要があります(一方、検出モジュールはSpam-Xのディレクトリにファイルを入れるだけで有効になります。)。このため、すべてのアクションモジュールは独自の番号を持っています。有効にしたいすべてのモジュールの番号を足し合わせた数値を、「管理者用メニュー - コンフィギュレーション - Geeklog - ユーザーと投稿」の「Spam-X」に入力します。

+

+ アクションモジュールは使用する前に個別に有効にする必要があります(一方、検出モジュールはSpam-Xのディレクトリにファイルを入れるだけで有効になります。)。このため、すべてのアクションモジュールは独自の番号を持っています。有効にしたいすべてのモジュールの番号を足し合わせた数値を、「管理者用メニュー + - コンフィギュレーション - Geeklog - ユーザーと投稿」の「Spam-X」に入力します。

削除アクションモジュールの数字は 128、管理者メールアクションモジュールは 8 です。両方のモジュールを有効にするには、128 + 8 = 136 を入力します。

-

SLV検出モジュールは、他の検出モジュールが捕捉したスパム投稿を確実にSLVに通知します。SLVアクション(SLV Action) モジュールによって補完されています。このモジュールは削除アクションモジュールと連動しているので、削除アクションモジュールを有効にすると、SLVアクションモジュールも有効になります。

+

SLV検出モジュールは、他の検出モジュールが捕捉したスパム投稿を確実にSLVに通知します。SLVアクション(SLV Action) + モジュールによって補完されています。このモジュールは削除アクションモジュールと連動しているので、削除アクションモジュールを有効にすると、SLVアクションモジュールも有効になります。

管理モジュール

-

パーソナルブラックリストIPフィルターURLのIPフィルターHTTPヘッダーフィルターモジュール用の管理モジュールは新しい項目を追加するためのフォームを提供します。既存の項目を削除するには、単にその項目をクリックするだけです。

+

パーソナルブラックリストIPフィルターURLのIPフィルターHTTPヘッダーフィルターモジュール用の管理モジュールは新しい項目を追加するためのフォームを提供します。既存の項目を削除するには、単にその項目をクリックするだけです。 +

-

SLVホワイトリスト管理モジュールを使えば、SLVに通報したくないURLを追加できます。サイトに投稿されるデータにたまたまある特定のURLが頻繁に含まれているが、SLVにスパムと判定されてほしくないときに役に立ちます。
自分のサイトのURL(つまり、「管理者用メニュー - コンフィギュレーション - Geeklog - サイト」の「サイトURL」)は自動的にホワイトリストに登録されるので、このモジュールで新たに登録する必要はありません。

+

SLVホワイトリスト管理モジュールを使えば、SLVに通報したくないURLを追加できます。サイトに投稿されるデータにたまたまある特定のURLが頻繁に含まれているが、SLVにスパムと判定されてほしくないときに役に立ちます。
自分のサイトのURL(つまり、「管理者用メニュー + - コンフィギュレーション - Geeklog - サイト」の「サイトURL」)は自動的にホワイトリストに登録されるので、このモジュールで新たに登録する必要はありません。 +

-

ログ閲覧モジュールを使用すれば、Spam-Xログファイルの閲覧・クリアができます。ログファイルには、スパム送信元のIPアドレスやユーザーID(登録ユーザーがスパムを投稿した場合)、検出モジュール名などの追加情報が含まれています。

+

ログ閲覧モジュールを使用すれば、Spam-Xログファイルの閲覧・クリアができます。ログファイルには、スパム送信元のIPアドレスやユーザーID(登録ユーザーがスパムを投稿した場合)、検出モジュール名などの追加情報が含まれています。 +

-

多数のスパムが投稿されても検出されなかった場合は、一括コメント削除モジュールと一括トラックバック削除モジュールがスパムの削除に役立つでしょう。これらのモジュールを使用する前に、スパムに含まれるURLやキーワードをパーソナルブラックリストに忘れずに追加してください。

+

多数のスパムが投稿されても検出されなかった場合は、一括コメント削除モジュールと一括トラックバック削除モジュールがスパムの削除に役立つでしょう。これらのモジュールを使用する前に、スパムに含まれるURLやキーワードをパーソナルブラックリストに忘れずに追加してください。 +

MTブラックリスト(MT-Blacklist)に関する注意

MTブラックリストは、スパム送信に利用されたURLのブラックリストで、Movable Type用にJay Allenによって開発・維持されていました。そのため、MT-Blacklistという名前がついています。

-

ブラックリストの維持を行うのは大変手間のかかることであり、スパム送信者を絶えず把握しておかなければなりません。そのため、Jay Allenは現在ではスパムを検出するより優れた方法があると想定して、最終的にMTブラックリストの更新をやめてしまいました

+

ブラックリストの維持を行うのは大変手間のかかることであり、スパム送信者を絶えず把握しておかなければなりません。そのため、Jay Allenは現在ではスパムを検出するより優れた方法があると想定して、最終的にMTブラックリストの更新をやめてしまいました

-

Geeklog 1.4.1以降、GeeklogではもはやMTブラックリストを使用していません。1.4.1にアップグレードするときに、データベースからMTブラックリストのデータは削除され、MTブラックリスト用の検出・アクションモジュールはもはや同梱されていません。

+

Geeklog + 1.4.1以降、GeeklogではもはやMTブラックリストを使用していません。1.4.1にアップグレードするときに、データベースからMTブラックリストのデータは削除され、MTブラックリスト用の検出・アクションモジュールはもはや同梱されていません。

トラックバックスパム

-

トラックバックもまた、Geeklogが受け入れる前にSpam-Xプラグインで検査されます。トラックバックの場合、追加できるチェックがあります。トラックバックを送信してきたサイトが自分のサイトへのバックリンクを含んでいるかどうかをチェックするよう、設定できます。さらに、トラックバックURLに含まれるサイトのIPアドレスがトラックバック送信元のIPアドレスと一致するかをチェックすることもできます。これらの検査に合格しないトラックバックはふつう、スパムです。詳細は、設定用のドキュメントを参照してください。

+

トラックバックもまた、Geeklogが受け入れる前にSpam-Xプラグインで検査されます。トラックバックの場合、追加できるチェックがあります。トラックバックを送信してきたサイトが自分のサイトへのバックリンクを含んでいるかどうかをチェックするよう、設定できます。さらに、トラックバックURLに含まれるサイトのIPアドレスがトラックバック送信元のIPアドレスと一致するかをチェックすることもできます。これらの検査に合格しないトラックバックはふつう、スパムです。詳細は、設定用のドキュメントを参照してください。

コンフィギュレーション

-

Spam-Xプラグインの設定は、「管理者用メニュー - コンフィギュレーション - Spam-X」から行えます。

+

Spam-Xプラグインの設定は、「管理者用メニュー - コンフィギュレーション - Spam-X」から行えます。

Spam-Xの設定

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
項目(変数)デフォルト説明
ログを有効にする(logging)はい(true)はい(true)にすると、スパムと認識された投稿がログファイル(spamx.log)に記録されます。
タイムアウト(timeout)5(秒)SLVなどの外部サービスと通信する際のタイムアウトとなる秒数を指定します。
メールで通知する(notification_email)「管理者用メニュー - コンフィギュレーション - Geeklog - サイト」の「サイトのメールアドレス」の設定値管理者メールアクションモジュールが有効になっている場合、スパム通知の送信先メールアドレスを指定します。指定しない場合は、サイトのメールアドレス($_CONF['site_mail'])に送信されます。
Spam-Xの動作(action)128「管理者用メニュー - コンフィギュレーション - Geeklog - ユーザーと投稿」の「Spam-X」が設定されていない場合に備えるための設定です。言い換えれば、「管理者用メニュー - コンフィギュレーション - Geeklog - ユーザーと投稿」の「Spam-X」の設定の方が優先します。
スパム記録の保存日数(max_age)0Spam-Xの記録をデータベースに保存する最大の日数を指定します(0 = 無制限に保存)。SLVホワイトリストの記録は削除しません。
削除する記録の種類(records_delete)'email', 'IP'スパム記録の保存日数に達した時に削除する記録の種類を指定します。デフォルトでは次のものがあります:
    -
  • 'Personal' = パーソナルブラックリスト
  • -
  • 'HTTPHeader' = HTTPヘッダーブラックリスト
  • -
  • 'IP' = IPフィルター
  • -
  • 'IPofUrl' = URLのIPフィルター
  • -
  • 'email' = Stop Forum Spamのブラックリスト
  • -
  • 'SLVwhitelist' = SLVホワイトリスト
  • -
項目(変数)デフォルト説明
ログを有効にする(logging)はい(true)はい(true)にすると、スパムと認識された投稿がログファイル(spamx.log)に記録されます。
タイムアウト(timeout)5(秒)SLVなどの外部サービスと通信する際のタイムアウトとなる秒数を指定します。
メールで通知する(notification_email)「管理者用メニュー - コンフィギュレーション - Geeklog - サイト」の「サイトのメールアドレス」の設定値管理者メールアクションモジュールが有効になっている場合、スパム通知の送信先メールアドレスを指定します。指定しない場合は、サイトのメールアドレス($_CONF['site_mail'])に送信されます。 +
Spam-Xの動作(action)128「管理者用メニュー - コンフィギュレーション - Geeklog - ユーザーと投稿」の「Spam-X」が設定されていない場合に備えるための設定です。言い換えれば、「管理者用メニュー + - コンフィギュレーション - Geeklog - ユーザーと投稿」の「Spam-X」の設定の方が優先します。 +
スパム記録の保存日数(max_age)0Spam-Xの記録をデータベースに保存する最大の日数を指定します(0 = 無制限に保存)。SLVホワイトリストの記録は削除しません。
削除する記録の種類(records_delete)'email', 'IP'スパム記録の保存日数に達した時に削除する記録の種類を指定します。デフォルトでは次のものがあります: +
    +
  • 'Personal' = パーソナルブラックリスト
  • +
  • 'HTTPHeader' = HTTPヘッダーブラックリスト
  • +
  • 'IP' = IPフィルター
  • +
  • 'IPofUrl' = URLのIPフィルター
  • +
  • 'email' = Stop Forum Spamのブラックリスト
  • +
  • 'SLVwhitelist' = SLVホワイトリスト
  • +
+

モジュール

- - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
項目(変数)デフォルト説明
Stop Forum Spamモジュールを有効(sfs_enabled)いいえ(false)Stop Forum Spam (SFS)モジュールを有効にするかどうかを指定します。有効にすると、ユーザー新規登録時にユーザーのメールアドレスとIPアドレスをStopForumSpam.comに照会してスパム判定を行います。
信頼スコアの閾値(sfs_confidence)25Stop Forum Spamの信頼スコアの閾値(パーセント)で、この値を超えると、検証しているフィールドが望ましくない活動を行うことになることを示すかなり良い目安になります。1から100の範囲で入力します。
Spam Number of Linksモジュールを有効(snl_enabled)いいえ(false)Spam Number of Links (SNL)モジュールを有効にするかどうかを指定します。有効にすると、ユーザーが投稿したり、プロフィールを作成・更新したりする際に、含まれるリンクの数を指定された数に制限するようになります。
リンク数(snl_num_links)5投稿やプロフィールでリンクと見なさないリンクの最大数。
項目(変数)デフォルト説明
Stop Forum Spamモジュールを有効(sfs_enabled)いいえ(false)Stop Forum Spam + (SFS)モジュールを有効にするかどうかを指定します。有効にすると、ユーザー新規登録時にユーザーのメールアドレスとIPアドレスをStopForumSpam.comに照会してスパム判定を行います。 +
信頼スコアの閾値(sfs_confidence)25Stop Forum Spamの信頼スコアの閾値(パーセント)で、この値を超えると、検証しているフィールドが望ましくない活動を行うことになることを示すかなり良い目安になります。1から100の範囲で入力します。 +
Spam Number of Linksモジュールを有効(snl_enabled)いいえ(false)Spam Number of Links + (SNL)モジュールを有効にするかどうかを指定します。有効にすると、ユーザーが投稿したり、プロフィールを作成・更新したりする際に、含まれるリンクの数を指定された数に制限するようになります。 +
リンク数(snl_num_links)5投稿やプロフィールでリンクと見なさないリンクの最大数。
Akismetモジュールを有効にするいいえAkismetを有効にするかどうかを指定します。有効にすると、Akismetサービスを利用します。 +
APIキー(なし)このページで取得したAkismetのAPIキーを指定します。

詳細情報

-

Spam-Xプラグインの詳細情報とサポート掲示板は、Spam-XプラグインのホームページGeeklog Wikiにあります。

+

Spam-Xプラグインの詳細情報とサポート掲示板は、Spam-XプラグインのホームページGeeklog Wikiにあります。

diff --git a/public_html/profiles.php b/public_html/profiles.php index 2b0a1c5bb..e3bb1da63 100644 --- a/public_html/profiles.php +++ b/public_html/profiles.php @@ -44,12 +44,12 @@ * @param int $uid User ID of person to send email to * @param bool $cc Whether to send a copy of the message to the author * @param string $author The name of the person sending the email -* @param string $authoremail Email address of person sending the email +* @param string $authorEmail Email address of person sending the email * @param string $subject Subject of email * @param string $message Text of message to send * @return string Meta redirect or HTML for the contact form */ -function contactemail($uid, $cc, $author, $authoremail, $subject, $message) +function contactemail($uid, $cc, $author, $authorEmail, $subject, $message) { global $_CONF, $_TABLES, $_USER, $LANG04, $LANG08, $LANG12; @@ -82,7 +82,7 @@ function contactemail($uid, $cc, $author, $authoremail, $subject, $message) } if (!empty($author) && !empty($subject) && !empty($message)) { - if (COM_isemail($authoremail) && (strpos($author, '@') === false)) { + if (COM_isemail($authorEmail) && (strpos($author, '@') === false)) { $result = DB_query("SELECT username,fullname,email FROM {$_TABLES['users']} WHERE uid = $uid"); $A = DB_fetchArray($result); @@ -102,8 +102,11 @@ function contactemail($uid, $cc, $author, $authoremail, $subject, $message) // do a spam check with the unfiltered message text and subject $mailtext = $subject . "\n" . $message . $sig; - $result = PLG_checkforSpam($mailtext, $_CONF['spamx']); - if ($result > 0) { + $result = PLG_checkForSpam( + $mailtext, $_CONF['spamx'], COM_getCurrentURL(), Geeklog\Akismet::COMMENT_TYPE_CONTACT_FORM, + $author, $authorEmail + ); + if ($result > PLG_SPAM_NOT_FOUND) { COM_updateSpeedlimit('mail'); COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden'); } @@ -125,7 +128,7 @@ function contactemail($uid, $cc, $author, $authoremail, $subject, $message) } else { $to = array($A['email'] => $A['username']); } - $from = array($authoremail => $author); + $from = array($authorEmail => $author); $sent = COM_mail($to, $subject, $message, $from); @@ -285,10 +288,10 @@ function contactform($uid, $cc = false, $subject = '', $message = '') * * @param string $sid id of story to email * @param string $to name of person / friend to email -* @param string $toemail friend's email address +* @param string $toEmail friend's email address * @param string $from name of person sending the email -* @param string $fromemail sender's email address -* @param string $shortmsg short intro text to send with the story +* @param string $fromEmail sender's email address +* @param string $shortMessage short intro text to send with the story * @return string Meta refresh * * Modification History @@ -301,7 +304,7 @@ function contactform($uid, $cc = false, $subject = '', $message = '') * this code * */ -function mailstory($sid, $to, $toemail, $from, $fromemail, $shortmsg) +function mailstory($sid, $to, $toEmail, $from, $fromEmail, $shortMessage) { global $_CONF, $_TABLES, $LANG01, $LANG08; @@ -341,27 +344,30 @@ function mailstory($sid, $to, $toemail, $from, $fromemail, $shortmsg) COM_redirect($_CONF['site_url'] . '/index.php'); } - $shortmsg = COM_stripslashes($shortmsg); - $mailtext = sprintf($LANG08[23], $from, $fromemail) . LB; - if (strlen($shortmsg) > 0) { - $mailtext .= LB . sprintf($LANG08[28], $from) . $shortmsg . LB; + $shortMessage = COM_stripslashes($shortMessage); + $mailText = sprintf($LANG08[23], $from, $fromEmail) . LB; + if (strlen($shortMessage) > 0) { + $mailText .= LB . sprintf($LANG08[28], $from) . $shortMessage . LB; } // just to make sure this isn't an attempt at spamming users ... - $result = PLG_checkforSpam($mailtext, $_CONF['spamx']); - if ($result > 0) { + $result = PLG_checkForSpam( + $mailText, $_CONF['spamx'], COM_getCurrentURL(), Geeklog\Akismet::COMMENT_TYPE_CONTACT_FORM, + $from, $fromEmail + ); + if ($result > PLG_SPAM_NOT_FOUND) { COM_updateSpeedlimit('mail'); COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden'); } - $mailtext .= '------------------------------------------------------------' + $mailText .= '------------------------------------------------------------' . LB . LB . COM_undoSpecialChars($story->displayElements('title')) . LB . strftime($_CONF['date'], $story->DisplayElements('unixdate')) . LB; if ($_CONF['contributedbyline'] == 1) { $author = COM_getDisplayName($story->displayElements('uid')); - $mailtext .= $LANG01[1] . ' ' . $author . LB; + $mailText .= $LANG01[1] . ' ' . $author . LB; } $introtext = $story->DisplayElements('introtext'); @@ -372,32 +378,32 @@ function mailstory($sid, $to, $toemail, $from, $fromemail, $shortmsg) $introtext = str_replace(array("\012\015", "\015"), LB, $introtext); $bodytext = str_replace(array("\012\015", "\015"), LB, $bodytext); - $mailtext .= LB . $introtext; + $mailText .= LB . $introtext; if (! empty($bodytext)) { - $mailtext .= LB . LB . $bodytext; + $mailText .= LB . LB . $bodytext; } - $mailtext .= LB . LB + $mailText .= LB . LB . '------------------------------------------------------------' . LB; if ($story->DisplayElements('commentcode') == 0) { // comments allowed - $mailtext .= $LANG08[24] . LB + $mailText .= $LANG08[24] . LB . COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid . '#comments'); } else { // comments not allowed - just add the story's URL - $mailtext .= $LANG08[33] . LB + $mailText .= $LANG08[33] . LB . COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid); } - $mailto = array($toemail => $to); - $mailfrom = array($fromemail => $from); + $mailto = array($toEmail => $to); + $mailfrom = array($fromEmail => $from); $subject = 'Re: ' . COM_undoSpecialChars(GLText::stripTags($story->DisplayElements('title'))); - $sent = COM_mail($mailto, $subject, $mailtext, $mailfrom); + $sent = COM_mail($mailto, $subject, $mailText, $mailfrom); if ($sent && $_CONF['mail_cc_enabled'] && (Geeklog\Input::post('cc') === 'on')) { $ccmessage = sprintf($LANG08[38], $to); - $ccmessage .= "\n------------------------------------------------------------\n\n" . $mailtext; + $ccmessage .= "\n------------------------------------------------------------\n\n" . $mailText; $sent = COM_mail($mailfrom, $subject, $ccmessage, $mailfrom); } diff --git a/public_html/submit.php b/public_html/submit.php index 487359067..93763c330 100644 --- a/public_html/submit.php +++ b/public_html/submit.php @@ -292,8 +292,12 @@ function savestory(array $A) $story->loadSubmission(); // pseudo-formatted story text for the spam check - $result = PLG_checkforSpam($story->getSpamCheckFormat(), $_CONF['spamx']); - if ($result > 0) { + $url = COM_buildURL($_CONF['site_url'] . '/article.php?story=' . $story->getSid()); + $result = PLG_checkForSpam( + $story->getSpamCheckFormat(), $_CONF['spamx'], $url, Geeklog\Akismet::COMMENT_TYPE_BLOG_POST + ); + + if ($result > PLG_SPAM_NOT_FOUND) { COM_updateSpeedlimit('submit'); COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden'); } diff --git a/public_html/usersettings.php b/public_html/usersettings.php index 6c9aac99e..87efbf7c5 100644 --- a/public_html/usersettings.php +++ b/public_html/usersettings.php @@ -1016,8 +1016,13 @@ function saveuser(array $A) } $profile .= $A['location'] . '' . $A['sig'] . '' . $A['about'] . '' . $A['pgpkey'] . '

'; - $result = PLG_checkforSpam($profile, $_CONF['spamx']); - if ($result > 0) { + + $url = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid']; + $result = PLG_checkForSpam( + $profile, $_CONF['spamx'], $url, Geeklog\Akismet::COMMENT_TYPE_PROFILE, + $A['username'], $A['email'], $A['homepage'] + ); + if ($result > PLG_SPAM_NOT_FOUND) { COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden'); } diff --git a/system/classes/Akismet.php b/system/classes/Akismet.php index c486399fc..1c5a14a53 100644 --- a/system/classes/Akismet.php +++ b/system/classes/Akismet.php @@ -23,6 +23,9 @@ class Akismet const COMMENT_TYPE_SIGNUP = 'signup'; const COMMENT_TYPE_MESSAGE = 'message'; const COMMENT_TYPE_TRACKBACK = 'trackback'; + const COMMENT_TYPE_EVENT = 'event'; + const COMMENT_TYPE_LINK = 'link'; + const COMMENT_TYPE_PROFILE = 'profile'; // Result types const RESULT_HAM = 0; // = PLG_SPAM_NOT_FOUND @@ -124,7 +127,14 @@ private function send($path, array $data) . "User-Agent: {$akismetUA}\r\n" . "\r\n" . $data; - $timeout = isset($_SPX_CONF['timeout']) ? (int) $_SPX_CONF['timeout'] : self::STREAM_TIMEOUT; + + // Set time out + $timeout = self::STREAM_TIMEOUT; + if (isset($_SPX_CONF['timeout']) && is_numeric($_SPX_CONF['timeout'])) { + if ((int) $_SPX_CONF['timeout'] >= 1) { + $timeout = (int) $_SPX_CONF['timeout']; + } + } if (($fs = @fsockopen('ssl://' . $http_host, $port, $errNo, $errStr, $timeout)) !== false) { stream_set_timeout($fs, $timeout); diff --git a/system/lib-comment.php b/system/lib-comment.php index 237848611..891ecf3b5 100644 --- a/system/lib-comment.php +++ b/system/lib-comment.php @@ -2,13 +2,13 @@ /* Reminder: always indent with 4 spaces (no tabs). */ // +---------------------------------------------------------------------------+ -// | Geeklog 2.1 | +// | Geeklog 2.2 | // +---------------------------------------------------------------------------+ // | lib-comment.php | // | | // | Geeklog comment library. | // +---------------------------------------------------------------------------+ -// | Copyright (C) 2000-2012 by the following authors: | +// | Copyright (C) 2000-2017 by the following authors: | // | | // | Authors: Tony Bibbs - tony AT tonybibbs DOT com | // | Mark Limburg - mlimburg AT users DOT sourceforge DOT net | @@ -1364,10 +1364,11 @@ function CMT_saveComment($title, $comment, $sid, $pid, $type, $postmode) } // Let plugins have a chance to check for spam - $spamcheck = '

' . $title . '

' . $comment . '

'; - $result = PLG_checkforSpam($spamcheck, $_CONF['spamx']); + $spamCheck = '

' . $title . '

' . $comment . '

'; + $result = PLG_checkForSpam($spamCheck, $_CONF['spamx'], COM_getCurrentURL(), Geeklog\Akismet::COMMENT_TYPE_COMMENT); + // Now check the result and display message if spam action was taken - if ($result > 0) { + if ($result > PLG_SPAM_NOT_FOUND) { COM_updateSpeedlimit('comment'); // update speed limit nonetheless COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden'); // then tell them to get lost ... } diff --git a/system/lib-plugins.php b/system/lib-plugins.php index 5ab83ee44..dc8290e3b 100644 --- a/system/lib-plugins.php +++ b/system/lib-plugins.php @@ -2,13 +2,13 @@ /* Reminder: always indent with 4 spaces (no tabs). */ // +---------------------------------------------------------------------------+ -// | Geeklog 2.1 | +// | Geeklog 2.2 | // +---------------------------------------------------------------------------+ // | lib-plugins.php | // | | // | This file implements plugin support in Geeklog. | // +---------------------------------------------------------------------------+ -// | Copyright (C) 2000-2011 by the following authors: | +// | Copyright (C) 2000-2017 by the following authors: | // | | // | Authors: Tony Bibbs - tony AT tonybibbs DOT com | // | Blaine Lang - blaine AT portalparts DOT com | @@ -2186,22 +2186,33 @@ function PLG_getWhatsNewComment($type = '', $numReturn = 0, $uid = 0) * Where the former will only display a "spam detected" message while the latter * will also send an HTTP status code 403 with the message. * - * @param string $content Text to be filtered or checked for spam - * @param int $action what to do if spam found - * @return int > 0: spam detected, == 0: no spam detected - * @link http://wiki.geeklog.net/index.php/Filtering_Spam_with_Spam-X - */ -function PLG_checkforSpam($content, $action = -1) + * @param string $comment Text to be filtered or checked for spam + * @param int $action what to do if spam found + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php + * @link http://wiki.geeklog.net/index.php/Filtering_Spam_with_Spam-X + */ +function PLG_checkForSpam($comment, $action = -1, $permanentLink, + $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null) { global $_PLUGINS; foreach ($_PLUGINS as $pi_name) { $function = 'plugin_checkforSpam_' . $pi_name; if (function_exists($function)) { - $result = $function($content, $action); + $result = $function( + $comment, $action, $permanentLink, $commentType, + $commentAuthor, $commentAuthorEmail, $commentAuthorURL + ); if ($result > PLG_SPAM_NOT_FOUND) { // Plugin found a match for spam - $result = PLG_spamAction($content, $action); + $result = PLG_spamAction($comment, $action); return $result; } @@ -2210,10 +2221,10 @@ function PLG_checkforSpam($content, $action = -1) $function = 'CUSTOM_checkforSpam'; if (function_exists($function)) { - $result = $function($content, $action); + $result = $function($comment, $action); if ($result > PLG_SPAM_NOT_FOUND) { // Plugin found a match for spam - $result = PLG_spamAction($content, $action); + $result = PLG_spamAction($comment, $action); return $result; } @@ -2232,7 +2243,7 @@ function PLG_checkforSpam($content, $action = -1) * @param string $content Text to be filtered or checked for spam * @param int $action what to do if spam found * @return int > 0: spam detected, == 0: no spam detected - * @see PLG_checkforSpam + * @see PLG_checkForSpam * @since Geeklog 1.4.1 */ function PLG_spamAction($content, $action = -1) diff --git a/system/lib-trackback.php b/system/lib-trackback.php index 36c0e4107..677f796e9 100644 --- a/system/lib-trackback.php +++ b/system/lib-trackback.php @@ -2,13 +2,13 @@ /* Reminder: always indent with 4 spaces (no tabs). */ // +---------------------------------------------------------------------------+ -// | Geeklog 2.1 | +// | Geeklog 2.2 | // +---------------------------------------------------------------------------+ // | lib-trackback.php | // | | // | Functions needed to handle trackback comments. | // +---------------------------------------------------------------------------+ -// | Copyright (C) 2005-2010 by the following authors: | +// | Copyright (C) 2005-2017 by the following authors: | // | | // | Author: Dirk Haun - dirk AT haun-online DOT de | // +---------------------------------------------------------------------------+ @@ -229,7 +229,10 @@ function TRB_checkForSpam($url, $title = '', $blog = '', $excerpt = '') global $_CONF; $comment = TRB_formatComment($url, $title, $blog, $excerpt); - $result = PLG_checkforSpam($comment, $_CONF['spamx']); + $result = PLG_checkForSpam( + $comment, $_CONF['spamx'], COM_getCurrentURL(), Geeklog\Akismet::COMMENT_TYPE_TRACKBACK, + null, null, $url + ); if ($result > 0) { return TRB_SAVE_SPAM; diff --git a/tests/files/dummy/plugins/calendar/functions.inc b/tests/files/dummy/plugins/calendar/functions.inc index a6f7dd4c1..2f2f74256 100644 --- a/tests/files/dummy/plugins/calendar/functions.inc +++ b/tests/files/dummy/plugins/calendar/functions.inc @@ -10,7 +10,7 @@ // | API method and 2) implements all the common code needed by the Calendar | // | plugin's PHP files. | // +---------------------------------------------------------------------------+ -// | Copyright (C) 2000-2009 by the following authors: | +// | Copyright (C) 2000-2017 by the following authors: | // | | // | Authors: Tony Bibbs - tony AT tonybibbs DOT com | // | Tom Willett - twillett AT users DOT sourceforge DOT net | @@ -472,12 +472,12 @@ function plugin_savesubmission_calendar($A) $A['event_type'] = (isset($A['event_type']) ? $A['event_type'] : ''); // pseudo-formatted event description for the spam check - $spamcheck = COM_createLink($A['title'], $A['url']) . '' + $spamCheck = COM_createLink($A['title'], $A['url']) . '' . $A['location'] . '' . $A['address1'] . '' . $A['address2'] . '' . $A['city'] . ', ' . $A['zipcode'] . '' . $A['description'] . '

'; - $result = PLG_checkforSpam ($spamcheck, $_CONF['spamx']); - if ($result > 0) { + $result = PLG_checkForSpam($spamCheck, $_CONF['spamx'], $A['url'], Geeklog\Akismet::COMMENT_TYPE_EVENT); + if ($result > PLG_SPAM_NOT_FOUND) { COM_updateSpeedlimit ('submit'); COM_displayMessageAndAbort ($result, 'spamx', 403, 'Forbidden'); } diff --git a/tests/files/dummy/plugins/links/functions.inc b/tests/files/dummy/plugins/links/functions.inc index 9c1318166..7ac59ff65 100644 --- a/tests/files/dummy/plugins/links/functions.inc +++ b/tests/files/dummy/plugins/links/functions.inc @@ -10,7 +10,7 @@ // | API method and 2) implements all the common code needed by the Links | // | Plugins' PHP files. | // +---------------------------------------------------------------------------+ -// | Copyright (C) 2000-2009 by the following authors: | +// | Copyright (C) 2000-2017 by the following authors: | // | | // | Authors: Tony Bibbs - tony AT tonybibbs DOT com | // | Mark Limburg - mlimburg AT users.sourceforge DOT net | @@ -922,11 +922,11 @@ function plugin_save_submit_links($A) $retval = ''; // pseudo-formatted link description for the spam check - $spamcheck = '

'. COM_createLink($A['title'], $A['url']) .' (' + $spamCheck = '

'. COM_createLink($A['title'], $A['url']) .' (' . $A['categorydd'] . ')' . $A['description'] . '

'; - $result = PLG_checkforSpam($spamcheck, $_CONF['spamx']); - if ($result > 0) { + $result = PLG_checkForSpam($spamCheck, $_CONF['spamx'], $link, Geeklog\Akismet::COMMENT_TYPE_LINK); + if ($result > PLG_SPAM_NOT_FOUND) { COM_updateSpeedlimit('submit'); COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden'); } diff --git a/tests/files/dummy/system/lib-plugins.php b/tests/files/dummy/system/lib-plugins.php index 307334c2f..2f75e5b53 100644 --- a/tests/files/dummy/system/lib-plugins.php +++ b/tests/files/dummy/system/lib-plugins.php @@ -2013,23 +2013,33 @@ function PLG_getWhatsNew() * Where the former will only display a "spam detected" message while the latter * will also send an HTTP status code 403 with the message. * -* @param string $content Text to be filtered or checked for spam -* @param int $action what to do if spam found -* @return int > 0: spam detected, == 0: no spam detected -* @link http://wiki.geeklog.net/index.php/Filtering_Spam_with_Spam-X -* -*/ -function PLG_checkforSpam($content, $action = -1) + * @param string $comment Text to be filtered or checked for spam + * @param int $action what to do if spam found + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php + * @link http://wiki.geeklog.net/index.php/Filtering_Spam_with_Spam-X +*/ +function PLG_checkforSpam($comment, $action = -1, $permanentLink, + $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null) { global $_PLUGINS; foreach ($_PLUGINS as $pi_name) { $function = 'plugin_checkforSpam_' . $pi_name; - if (function_exists($function)) { - $result = $function($content, $action); - if ($result > 0) { // Plugin found a match for spam - $result = PLG_spamAction($content, $action); + if (function_exists($function)) { + $result = $function( + $comment, $action, $permanentLink, $commentType, + $commentAuthor, $commentAuthorEmail, $commentAuthorURL + ); + if ($result > PLG_SPAM_NOT_FOUND) { // Plugin found a match for spam + $result = PLG_spamAction($comment, $action); return $result; } @@ -2037,17 +2047,18 @@ function PLG_checkforSpam($content, $action = -1) } $function = 'CUSTOM_checkforSpam'; + if (function_exists($function)) { - $result = $function($content, $action); - if ($result > 0) { // Plugin found a match for spam + $result = $function($comment, $action); + if ($result > PLG_SPAM_NOT_FOUND) { // Plugin found a match for spam - $result = PLG_spamAction($content, $action); + $result = PLG_spamAction($comment, $action); return $result; } } - return 0; + return PLG_SPAM_NOT_FOUND; } /** @@ -2061,7 +2072,7 @@ function PLG_checkforSpam($content, $action = -1) * @param string $content Text to be filtered or checked for spam * @param int $action what to do if spam found * @return int > 0: spam detected, == 0: no spam detected -* @see PLG_checkforSpam +* @see PLG_checkForSpam * @since Geeklog 1.4.1 * */