diff options
Diffstat (limited to 'plugins/BlogspamNet')
11 files changed, 414 insertions, 0 deletions
diff --git a/plugins/BlogspamNet/BlogspamNetPlugin.php b/plugins/BlogspamNet/BlogspamNetPlugin.php new file mode 100644 index 000000000..51a86b4f3 --- /dev/null +++ b/plugins/BlogspamNet/BlogspamNetPlugin.php @@ -0,0 +1,155 @@ +<?php +/** + * StatusNet, the distributed open-source microblogging tool + * + * Plugin to check submitted notices with blogspam.net + * + * PHP version 5 + * + * LICENCE: This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @category Plugin + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @author Brion Vibber <brion@status.net> + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +define('BLOGSPAMNETPLUGIN_VERSION', '0.1'); + +/** + * Plugin to check submitted notices with blogspam.net + * + * When new notices are saved, we check their text with blogspam.net (or + * a compatible service). + * + * Blogspam.net is supposed to catch blog comment spam, and I found that + * some of its tests (min/max size, bayesian match) gave a lot of false positives. + * So, I've turned those tests off by default. This may not get as many + * hits, but it's better than nothing. + * + * @category Plugin + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see Event + */ +class BlogspamNetPlugin extends Plugin +{ + var $baseUrl = 'http://test.blogspam.net:8888/'; + + function __construct($url=null) + { + parent::__construct(); + if ($url) { + $this->baseUrl = $url; + } + } + + function onStartNoticeSave($notice) + { + $args = $this->testArgs($notice); + common_debug("Blogspamnet args = " . print_r($args, TRUE)); + $requestBody = xmlrpc_encode_request('testComment', array($args)); + + $request = new HTTPClient($this->baseUrl, HTTPClient::METHOD_POST); + $request->setHeader('Content-Type', 'text/xml'); + $request->setBody($requestBody); + $httpResponse = $request->send(); + + $response = xmlrpc_decode($httpResponse->getBody()); + if (xmlrpc_is_fault($response)) { + throw new ServerException("$response[faultString] ($response[faultCode])", 500); + } else { + common_debug("Blogspamnet results = " . $response); + if (preg_match('/^ERROR(:(.*))?$/', $response, $match)) { + throw new ServerException(sprintf(_("Error from %s: %s"), $this->baseUrl, $match[2]), 500); + } else if (preg_match('/^SPAM(:(.*))?$/', $response, $match)) { + throw new ClientException(sprintf(_("Spam checker results: %s"), $match[2]), 400); + } else if (preg_match('/^OK$/', $response)) { + // don't do anything + } else { + throw new ServerException(sprintf(_("Unexpected response from %s: %s"), $this->baseUrl, $response), 500); + } + } + return true; + } + + function testArgs($notice) + { + $args = array(); + $args['comment'] = $notice->content; + $args['ip'] = $this->getClientIP(); + + if (isset($_SERVER) && array_key_exists('HTTP_USER_AGENT', $_SERVER)) { + $args['agent'] = $_SERVER['HTTP_USER_AGENT']; + } + + $profile = $notice->getProfile(); + + if ($profile && $profile->homepage) { + $args['link'] = $profile->homepage; + } + + if ($profile && $profile->fullname) { + $args['name'] = $profile->fullname; + } else { + $args['name'] = $profile->nickname; + } + + $args['site'] = common_root_url(); + $args['version'] = $this->userAgent(); + + $args['options'] = "max-size=" . common_config('site','textlimit') . ",min-size=0,min-words=0,exclude=bayasian"; + + return $args; + } + + function getClientIP() + { + if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { + // Note: order matters here; use proxy-forwarded stuff first + foreach (array('HTTP_X_FORWARDED_FOR', 'CLIENT-IP', 'REMOTE_ADDR') as $k) { + if (isset($_SERVER[$k])) { + return $_SERVER[$k]; + } + } + } + return '127.0.0.1'; + } + + function userAgent() + { + return 'BlogspamNetPlugin/'.BLOGSPAMNETPLUGIN_VERSION . ' StatusNet/' . STATUSNET_VERSION; + } + + function onPluginVersion(&$versions) + { + $versions[] = array('name' => 'BlogspamNet', + 'version' => BLOGSPAMNETPLUGIN_VERSION, + 'author' => 'Evan Prodromou, Brion Vibber', + 'homepage' => 'http://status.net/wiki/Plugin:BlogspamNet', + 'rawdescription' => + _m('Plugin to check submitted notices with blogspam.net.')); + return true; + } +} diff --git a/plugins/BlogspamNet/locale/BlogspamNet.pot b/plugins/BlogspamNet/locale/BlogspamNet.pot new file mode 100644 index 000000000..ac2da9e72 --- /dev/null +++ b/plugins/BlogspamNet/locale/BlogspamNet.pot @@ -0,0 +1,21 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-10-03 19:53+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: BlogspamNetPlugin.php:152 +msgid "Plugin to check submitted notices with blogspam.net." +msgstr "" diff --git a/plugins/BlogspamNet/locale/de/LC_MESSAGES/BlogspamNet.po b/plugins/BlogspamNet/locale/de/LC_MESSAGES/BlogspamNet.po new file mode 100644 index 000000000..5f6939023 --- /dev/null +++ b/plugins/BlogspamNet/locale/de/LC_MESSAGES/BlogspamNet.po @@ -0,0 +1,26 @@ +# Translation of StatusNet - BlogspamNet to German (Deutsch) +# Expored from translatewiki.net +# +# Author: The Evil IP address +# -- +# This file is distributed under the same license as the StatusNet package. +# +msgid "" +msgstr "" +"Project-Id-Version: StatusNet - BlogspamNet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-10-03 19:53+0000\n" +"PO-Revision-Date: 2010-10-03 19:56:27+0000\n" +"Language-Team: German <http://translatewiki.net/wiki/Portal:de>\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POT-Import-Date: 2010-10-01 20:37:55+0000\n" +"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-Translation-Project: translatewiki.net at http://translatewiki.net\n" +"X-Language-Code: de\n" +"X-Message-Group: #out-statusnet-plugin-blogspamnet\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: BlogspamNetPlugin.php:152 +msgid "Plugin to check submitted notices with blogspam.net." +msgstr "Plugin zur Überprüfung von Nachrichten mit blogspam.net." diff --git a/plugins/BlogspamNet/locale/es/LC_MESSAGES/BlogspamNet.po b/plugins/BlogspamNet/locale/es/LC_MESSAGES/BlogspamNet.po new file mode 100644 index 000000000..d8d773e50 --- /dev/null +++ b/plugins/BlogspamNet/locale/es/LC_MESSAGES/BlogspamNet.po @@ -0,0 +1,26 @@ +# Translation of StatusNet - BlogspamNet to Spanish (Español) +# Expored from translatewiki.net +# +# Author: Translationista +# -- +# This file is distributed under the same license as the StatusNet package. +# +msgid "" +msgstr "" +"Project-Id-Version: StatusNet - BlogspamNet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-10-03 19:53+0000\n" +"PO-Revision-Date: 2010-10-03 19:56:27+0000\n" +"Language-Team: Spanish <http://translatewiki.net/wiki/Portal:es>\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POT-Import-Date: 2010-10-01 20:37:55+0000\n" +"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-Translation-Project: translatewiki.net at http://translatewiki.net\n" +"X-Language-Code: es\n" +"X-Message-Group: #out-statusnet-plugin-blogspamnet\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: BlogspamNetPlugin.php:152 +msgid "Plugin to check submitted notices with blogspam.net." +msgstr "Extensión para revisar los mensajes enviados con blogspam.net." diff --git a/plugins/BlogspamNet/locale/fr/LC_MESSAGES/BlogspamNet.po b/plugins/BlogspamNet/locale/fr/LC_MESSAGES/BlogspamNet.po new file mode 100644 index 000000000..e55731db1 --- /dev/null +++ b/plugins/BlogspamNet/locale/fr/LC_MESSAGES/BlogspamNet.po @@ -0,0 +1,26 @@ +# Translation of StatusNet - BlogspamNet to French (Français) +# Expored from translatewiki.net +# +# Author: Peter17 +# -- +# This file is distributed under the same license as the StatusNet package. +# +msgid "" +msgstr "" +"Project-Id-Version: StatusNet - BlogspamNet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-10-03 19:53+0000\n" +"PO-Revision-Date: 2010-10-03 19:56:27+0000\n" +"Language-Team: French <http://translatewiki.net/wiki/Portal:fr>\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POT-Import-Date: 2010-10-01 20:37:55+0000\n" +"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-Translation-Project: translatewiki.net at http://translatewiki.net\n" +"X-Language-Code: fr\n" +"X-Message-Group: #out-statusnet-plugin-blogspamnet\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: BlogspamNetPlugin.php:152 +msgid "Plugin to check submitted notices with blogspam.net." +msgstr "Extension pour vérifier avec blogspam.net les avis soumis." diff --git a/plugins/BlogspamNet/locale/ia/LC_MESSAGES/BlogspamNet.po b/plugins/BlogspamNet/locale/ia/LC_MESSAGES/BlogspamNet.po new file mode 100644 index 000000000..c3ffd5697 --- /dev/null +++ b/plugins/BlogspamNet/locale/ia/LC_MESSAGES/BlogspamNet.po @@ -0,0 +1,26 @@ +# Translation of StatusNet - BlogspamNet to Interlingua (Interlingua) +# Expored from translatewiki.net +# +# Author: McDutchie +# -- +# This file is distributed under the same license as the StatusNet package. +# +msgid "" +msgstr "" +"Project-Id-Version: StatusNet - BlogspamNet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-10-03 19:53+0000\n" +"PO-Revision-Date: 2010-10-03 19:56:27+0000\n" +"Language-Team: Interlingua <http://translatewiki.net/wiki/Portal:ia>\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POT-Import-Date: 2010-10-01 20:37:55+0000\n" +"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-Translation-Project: translatewiki.net at http://translatewiki.net\n" +"X-Language-Code: ia\n" +"X-Message-Group: #out-statusnet-plugin-blogspamnet\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: BlogspamNetPlugin.php:152 +msgid "Plugin to check submitted notices with blogspam.net." +msgstr "Plug-in pro verificar notas submittite contra blogspam.net." diff --git a/plugins/BlogspamNet/locale/mk/LC_MESSAGES/BlogspamNet.po b/plugins/BlogspamNet/locale/mk/LC_MESSAGES/BlogspamNet.po new file mode 100644 index 000000000..40a7b3737 --- /dev/null +++ b/plugins/BlogspamNet/locale/mk/LC_MESSAGES/BlogspamNet.po @@ -0,0 +1,26 @@ +# Translation of StatusNet - BlogspamNet to Macedonian (Македонски) +# Expored from translatewiki.net +# +# Author: Bjankuloski06 +# -- +# This file is distributed under the same license as the StatusNet package. +# +msgid "" +msgstr "" +"Project-Id-Version: StatusNet - BlogspamNet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-10-03 19:53+0000\n" +"PO-Revision-Date: 2010-10-03 19:56:27+0000\n" +"Language-Team: Macedonian <http://translatewiki.net/wiki/Portal:mk>\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POT-Import-Date: 2010-10-01 20:37:55+0000\n" +"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-Translation-Project: translatewiki.net at http://translatewiki.net\n" +"X-Language-Code: mk\n" +"X-Message-Group: #out-statusnet-plugin-blogspamnet\n" +"Plural-Forms: nplurals=2; plural=(n == 1 || n%10 == 1) ? 0 : 1;\n" + +#: BlogspamNetPlugin.php:152 +msgid "Plugin to check submitted notices with blogspam.net." +msgstr "Приклучок за проверка на поднесените забелешки со blogspam.net." diff --git a/plugins/BlogspamNet/locale/nl/LC_MESSAGES/BlogspamNet.po b/plugins/BlogspamNet/locale/nl/LC_MESSAGES/BlogspamNet.po new file mode 100644 index 000000000..9b0b138cc --- /dev/null +++ b/plugins/BlogspamNet/locale/nl/LC_MESSAGES/BlogspamNet.po @@ -0,0 +1,26 @@ +# Translation of StatusNet - BlogspamNet to Dutch (Nederlands) +# Expored from translatewiki.net +# +# Author: Siebrand +# -- +# This file is distributed under the same license as the StatusNet package. +# +msgid "" +msgstr "" +"Project-Id-Version: StatusNet - BlogspamNet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-10-03 19:53+0000\n" +"PO-Revision-Date: 2010-10-03 19:56:27+0000\n" +"Language-Team: Dutch <http://translatewiki.net/wiki/Portal:nl>\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POT-Import-Date: 2010-10-01 20:37:55+0000\n" +"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-Translation-Project: translatewiki.net at http://translatewiki.net\n" +"X-Language-Code: nl\n" +"X-Message-Group: #out-statusnet-plugin-blogspamnet\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: BlogspamNetPlugin.php:152 +msgid "Plugin to check submitted notices with blogspam.net." +msgstr "Plug-in om mededelingen te controleren tegen blogspam.net." diff --git a/plugins/BlogspamNet/locale/tl/LC_MESSAGES/BlogspamNet.po b/plugins/BlogspamNet/locale/tl/LC_MESSAGES/BlogspamNet.po new file mode 100644 index 000000000..26d20bc5c --- /dev/null +++ b/plugins/BlogspamNet/locale/tl/LC_MESSAGES/BlogspamNet.po @@ -0,0 +1,28 @@ +# Translation of StatusNet - BlogspamNet to Tagalog (Tagalog) +# Expored from translatewiki.net +# +# Author: AnakngAraw +# -- +# This file is distributed under the same license as the StatusNet package. +# +msgid "" +msgstr "" +"Project-Id-Version: StatusNet - BlogspamNet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-10-03 19:53+0000\n" +"PO-Revision-Date: 2010-10-03 19:56:27+0000\n" +"Language-Team: Tagalog <http://translatewiki.net/wiki/Portal:tl>\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POT-Import-Date: 2010-10-01 20:37:55+0000\n" +"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-Translation-Project: translatewiki.net at http://translatewiki.net\n" +"X-Language-Code: tl\n" +"X-Message-Group: #out-statusnet-plugin-blogspamnet\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: BlogspamNetPlugin.php:152 +msgid "Plugin to check submitted notices with blogspam.net." +msgstr "" +"Pamasak upang masuri ang ipinasang mga pabatid sa pamamagitan ng blogspam." +"net." diff --git a/plugins/BlogspamNet/locale/uk/LC_MESSAGES/BlogspamNet.po b/plugins/BlogspamNet/locale/uk/LC_MESSAGES/BlogspamNet.po new file mode 100644 index 000000000..c59c80adb --- /dev/null +++ b/plugins/BlogspamNet/locale/uk/LC_MESSAGES/BlogspamNet.po @@ -0,0 +1,27 @@ +# Translation of StatusNet - BlogspamNet to Ukrainian (Українська) +# Expored from translatewiki.net +# +# Author: Boogie +# -- +# This file is distributed under the same license as the StatusNet package. +# +msgid "" +msgstr "" +"Project-Id-Version: StatusNet - BlogspamNet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-10-03 19:53+0000\n" +"PO-Revision-Date: 2010-10-03 19:56:27+0000\n" +"Language-Team: Ukrainian <http://translatewiki.net/wiki/Portal:uk>\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POT-Import-Date: 2010-10-01 20:37:55+0000\n" +"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-Translation-Project: translatewiki.net at http://translatewiki.net\n" +"X-Language-Code: uk\n" +"X-Message-Group: #out-statusnet-plugin-blogspamnet\n" +"Plural-Forms: nplurals=3; plural=(n%10 == 1 && n%100 != 11) ? 0 : ( (n%10 >= " +"2 && n%10 <= 4 && (n%100 < 10 || n%100 >= 20)) ? 1 : 2 );\n" + +#: BlogspamNetPlugin.php:152 +msgid "Plugin to check submitted notices with blogspam.net." +msgstr "Додаток для перевірки вказаних повідомлень на blogspam.net." diff --git a/plugins/BlogspamNet/locale/zh_CN/LC_MESSAGES/BlogspamNet.po b/plugins/BlogspamNet/locale/zh_CN/LC_MESSAGES/BlogspamNet.po new file mode 100644 index 000000000..e8dff72d0 --- /dev/null +++ b/plugins/BlogspamNet/locale/zh_CN/LC_MESSAGES/BlogspamNet.po @@ -0,0 +1,27 @@ +# Translation of StatusNet - BlogspamNet to Simplified Chinese (中文(简体)) +# Expored from translatewiki.net +# +# Author: ZhengYiFeng +# -- +# This file is distributed under the same license as the StatusNet package. +# +msgid "" +msgstr "" +"Project-Id-Version: StatusNet - BlogspamNet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-10-03 19:53+0000\n" +"PO-Revision-Date: 2010-10-03 19:56:27+0000\n" +"Language-Team: Simplified Chinese <http://translatewiki.net/wiki/Portal:zh-" +"hans>\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POT-Import-Date: 2010-10-01 20:37:55+0000\n" +"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-Translation-Project: translatewiki.net at http://translatewiki.net\n" +"X-Language-Code: zh-hans\n" +"X-Message-Group: #out-statusnet-plugin-blogspamnet\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#: BlogspamNetPlugin.php:152 +msgid "Plugin to check submitted notices with blogspam.net." +msgstr "通过 blogspam.net 检查发布的消息的插件。" |