diff options
Diffstat (limited to 'plugins/RegisterThrottle')
10 files changed, 198 insertions, 61 deletions
diff --git a/plugins/RegisterThrottle/RegisterThrottlePlugin.php b/plugins/RegisterThrottle/RegisterThrottlePlugin.php index b6e9a9026..0078d3c60 100644 --- a/plugins/RegisterThrottle/RegisterThrottlePlugin.php +++ b/plugins/RegisterThrottle/RegisterThrottlePlugin.php @@ -58,6 +58,19 @@ class RegisterThrottlePlugin extends Plugin 3600 => 3); // per hour /** + * Disallow registration if a silenced user has registered from + * this IP address. + */ + + public $silenced = true; + + /** + * Whether we're enabled; prevents recursion. + */ + + static private $enabled = true; + + /** * Database schema setup * * We store user registrations in a table registration_ip. @@ -138,6 +151,18 @@ class RegisterThrottlePlugin extends Plugin } } + // Check for silenced users + + if ($this->silenced) { + $ids = Registration_ip::usersByIP($ipaddress); + foreach ($ids as $id) { + $profile = Profile::staticGet('id', $id); + if ($profile && $profile->isSilenced()) { + throw new Exception(_m("A banned user has registered from this address.")); + } + } + } + return true; } @@ -245,4 +270,59 @@ class RegisterThrottlePlugin extends Plugin return null; } } + + /** + * When silencing a user, silence all other users registered from that IP + * address. + * + * @param Profile $profile Person getting a new role + * @param string $role Role being assigned like 'moderator' or 'silenced' + * + * @return boolean hook value + */ + + function onEndGrantRole($profile, $role) + { + if (!self::$enabled) { + return true; + } + + if ($role != Profile_role::SILENCED) { + return true; + } + + if (!$this->silenced) { + return true; + } + + $ri = Registration_ip::staticGet('user_id', $profile->id); + + if (empty($ri)) { + return true; + } + + $ids = Registration_ip::usersByIP($ri->ipaddress); + + foreach ($ids as $id) { + + if ($id == $profile->id) { + continue; + } + + $other = Profile::staticGet('id', $id); + + if (empty($other)) { + continue; + } + + if ($other->isSilenced()) { + continue; + } + + $old = self::$enabled; + self::$enabled = false; + $other->silence(); + self::$enabled = $old; + } + } } diff --git a/plugins/RegisterThrottle/Registration_ip.php b/plugins/RegisterThrottle/Registration_ip.php index 5c7396b9b..2486e36b4 100644 --- a/plugins/RegisterThrottle/Registration_ip.php +++ b/plugins/RegisterThrottle/Registration_ip.php @@ -111,8 +111,33 @@ class Registration_ip extends Memcached_DataObject * * @return array magic three-false array that stops auto-incrementing. */ + function sequenceKey() { return array(false, false, false); } + + /** + * Get the users who've registered with this ip address. + * + * @param Array $ipaddress IP address to check for + * + * @return Array IDs of users who registered with this address. + */ + + static function usersByIP($ipaddress) + { + $ids = array(); + + $ri = new Registration_ip(); + $ri->ipaddress = $ipaddress; + + if ($ri->find()) { + while ($ri->fetch()) { + $ids[] = $ri->user_id; + } + } + + return $ids; + } } diff --git a/plugins/RegisterThrottle/locale/RegisterThrottle.pot b/plugins/RegisterThrottle/locale/RegisterThrottle.pot index 6c66ccfca..0e38e9290 100644 --- a/plugins/RegisterThrottle/locale/RegisterThrottle.pot +++ b/plugins/RegisterThrottle/locale/RegisterThrottle.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-10-09 14:04+0000\n" +"POT-Creation-Date: 2010-10-23 18:02+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" @@ -16,18 +16,22 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: RegisterThrottlePlugin.php:121 RegisterThrottlePlugin.php:160 +#: RegisterThrottlePlugin.php:134 RegisterThrottlePlugin.php:185 msgid "Cannot find IP address." msgstr "" -#: RegisterThrottlePlugin.php:136 +#: RegisterThrottlePlugin.php:149 msgid "Too many registrations. Take a break and try again later." msgstr "" -#: RegisterThrottlePlugin.php:166 +#: RegisterThrottlePlugin.php:161 +msgid "A banned user has registered from this address." +msgstr "" + +#: RegisterThrottlePlugin.php:191 msgid "Cannot find user after successful registration." msgstr "" -#: RegisterThrottlePlugin.php:199 +#: RegisterThrottlePlugin.php:224 msgid "Throttles excessive registration from a single IP address." msgstr "" diff --git a/plugins/RegisterThrottle/locale/de/LC_MESSAGES/RegisterThrottle.po b/plugins/RegisterThrottle/locale/de/LC_MESSAGES/RegisterThrottle.po index 62a286f75..04666cd3b 100644 --- a/plugins/RegisterThrottle/locale/de/LC_MESSAGES/RegisterThrottle.po +++ b/plugins/RegisterThrottle/locale/de/LC_MESSAGES/RegisterThrottle.po @@ -9,31 +9,35 @@ msgid "" msgstr "" "Project-Id-Version: StatusNet - RegisterThrottle\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-10-18 18:35+0000\n" -"PO-Revision-Date: 2010-10-18 18:43:46+0000\n" +"POT-Creation-Date: 2010-10-23 18:02+0000\n" +"PO-Revision-Date: 2010-10-23 18:05:52+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-09 14:36:51+0000\n" -"X-Generator: MediaWiki 1.17alpha (r74952); Translate extension (2010-09-17)\n" +"X-POT-Import-Date: 2010-10-18 20:30:56+0000\n" +"X-Generator: MediaWiki 1.17alpha (r75280); 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-registerthrottle\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: RegisterThrottlePlugin.php:121 RegisterThrottlePlugin.php:160 +#: RegisterThrottlePlugin.php:134 RegisterThrottlePlugin.php:185 msgid "Cannot find IP address." msgstr "Kann IP-Addresse nicht finden." -#: RegisterThrottlePlugin.php:136 +#: RegisterThrottlePlugin.php:149 msgid "Too many registrations. Take a break and try again later." msgstr "" "Zu viele Registrierungen. Mach eine Pause and versuche es später noch einmal." -#: RegisterThrottlePlugin.php:166 +#: RegisterThrottlePlugin.php:161 +msgid "A banned user has registered from this address." +msgstr "" + +#: RegisterThrottlePlugin.php:191 msgid "Cannot find user after successful registration." msgstr "Kann Benutzer nach erfolgreicher Registrierung nicht finden." -#: RegisterThrottlePlugin.php:199 +#: RegisterThrottlePlugin.php:224 msgid "Throttles excessive registration from a single IP address." msgstr "Drosselt exzessive Registrierungen einer einzelnen IP-Adresse." diff --git a/plugins/RegisterThrottle/locale/fr/LC_MESSAGES/RegisterThrottle.po b/plugins/RegisterThrottle/locale/fr/LC_MESSAGES/RegisterThrottle.po index 16b8e1e5a..ac8949dfd 100644 --- a/plugins/RegisterThrottle/locale/fr/LC_MESSAGES/RegisterThrottle.po +++ b/plugins/RegisterThrottle/locale/fr/LC_MESSAGES/RegisterThrottle.po @@ -10,32 +10,36 @@ msgid "" msgstr "" "Project-Id-Version: StatusNet - RegisterThrottle\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-10-03 19:53+0000\n" -"PO-Revision-Date: 2010-10-03 19:57:19+0000\n" +"POT-Creation-Date: 2010-10-23 18:02+0000\n" +"PO-Revision-Date: 2010-10-23 18:05:52+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:39:03+0000\n" -"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-POT-Import-Date: 2010-10-18 20:30:56+0000\n" +"X-Generator: MediaWiki 1.17alpha (r75280); 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-registerthrottle\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: RegisterThrottlePlugin.php:121 RegisterThrottlePlugin.php:160 +#: RegisterThrottlePlugin.php:134 RegisterThrottlePlugin.php:185 msgid "Cannot find IP address." msgstr "Impossible de trouver l’adresse IP." -#: RegisterThrottlePlugin.php:136 +#: RegisterThrottlePlugin.php:149 msgid "Too many registrations. Take a break and try again later." msgstr "" "Inscriptions trop nombreuses. Faites une pause et essayez à nouveau plus " "tard." -#: RegisterThrottlePlugin.php:166 +#: RegisterThrottlePlugin.php:161 +msgid "A banned user has registered from this address." +msgstr "" + +#: RegisterThrottlePlugin.php:191 msgid "Cannot find user after successful registration." msgstr "Impossible de trouver l’utilisateur après un enregistrement réussi." -#: RegisterThrottlePlugin.php:199 +#: RegisterThrottlePlugin.php:224 msgid "Throttles excessive registration from a single IP address." msgstr "Évite les inscriptions excessives depuis une même adresse IP." diff --git a/plugins/RegisterThrottle/locale/ia/LC_MESSAGES/RegisterThrottle.po b/plugins/RegisterThrottle/locale/ia/LC_MESSAGES/RegisterThrottle.po index 14053a82d..42fdac46a 100644 --- a/plugins/RegisterThrottle/locale/ia/LC_MESSAGES/RegisterThrottle.po +++ b/plugins/RegisterThrottle/locale/ia/LC_MESSAGES/RegisterThrottle.po @@ -9,30 +9,34 @@ msgid "" msgstr "" "Project-Id-Version: StatusNet - RegisterThrottle\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-10-03 19:53+0000\n" -"PO-Revision-Date: 2010-10-03 19:57:19+0000\n" +"POT-Creation-Date: 2010-10-23 18:02+0000\n" +"PO-Revision-Date: 2010-10-23 18:05:52+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:39:03+0000\n" -"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-POT-Import-Date: 2010-10-18 20:30:56+0000\n" +"X-Generator: MediaWiki 1.17alpha (r75280); 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-registerthrottle\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: RegisterThrottlePlugin.php:121 RegisterThrottlePlugin.php:160 +#: RegisterThrottlePlugin.php:134 RegisterThrottlePlugin.php:185 msgid "Cannot find IP address." msgstr "Non pote trovar adresse IP." -#: RegisterThrottlePlugin.php:136 +#: RegisterThrottlePlugin.php:149 msgid "Too many registrations. Take a break and try again later." msgstr "Troppo de registrationes. Face un pausa e reproba plus tarde." -#: RegisterThrottlePlugin.php:166 +#: RegisterThrottlePlugin.php:161 +msgid "A banned user has registered from this address." +msgstr "" + +#: RegisterThrottlePlugin.php:191 msgid "Cannot find user after successful registration." msgstr "Non pote trovar usator post registration succedite." -#: RegisterThrottlePlugin.php:199 +#: RegisterThrottlePlugin.php:224 msgid "Throttles excessive registration from a single IP address." msgstr "Inhibi le creation de contos excessive ab un sol adresse IP." diff --git a/plugins/RegisterThrottle/locale/mk/LC_MESSAGES/RegisterThrottle.po b/plugins/RegisterThrottle/locale/mk/LC_MESSAGES/RegisterThrottle.po index de54757dc..eda82abc5 100644 --- a/plugins/RegisterThrottle/locale/mk/LC_MESSAGES/RegisterThrottle.po +++ b/plugins/RegisterThrottle/locale/mk/LC_MESSAGES/RegisterThrottle.po @@ -9,30 +9,34 @@ msgid "" msgstr "" "Project-Id-Version: StatusNet - RegisterThrottle\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-10-03 19:53+0000\n" -"PO-Revision-Date: 2010-10-03 19:57:19+0000\n" +"POT-Creation-Date: 2010-10-23 18:02+0000\n" +"PO-Revision-Date: 2010-10-23 18:05:52+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:39:03+0000\n" -"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-POT-Import-Date: 2010-10-18 20:30:56+0000\n" +"X-Generator: MediaWiki 1.17alpha (r75280); 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-registerthrottle\n" "Plural-Forms: nplurals=2; plural=(n == 1 || n%10 == 1) ? 0 : 1;\n" -#: RegisterThrottlePlugin.php:121 RegisterThrottlePlugin.php:160 +#: RegisterThrottlePlugin.php:134 RegisterThrottlePlugin.php:185 msgid "Cannot find IP address." msgstr "Не можам да ја пронајдам IP-адресата." -#: RegisterThrottlePlugin.php:136 +#: RegisterThrottlePlugin.php:149 msgid "Too many registrations. Take a break and try again later." msgstr "Премногу регистрации. Направете пауза и обидете се подоцна." -#: RegisterThrottlePlugin.php:166 +#: RegisterThrottlePlugin.php:161 +msgid "A banned user has registered from this address." +msgstr "" + +#: RegisterThrottlePlugin.php:191 msgid "Cannot find user after successful registration." msgstr "Не можам да го пронајдам корисникот по успешната регистрација." -#: RegisterThrottlePlugin.php:199 +#: RegisterThrottlePlugin.php:224 msgid "Throttles excessive registration from a single IP address." msgstr "Истиснува прекумерни регистрации од една IP-адреса." diff --git a/plugins/RegisterThrottle/locale/nl/LC_MESSAGES/RegisterThrottle.po b/plugins/RegisterThrottle/locale/nl/LC_MESSAGES/RegisterThrottle.po index 7d1a7c593..59f2f8c49 100644 --- a/plugins/RegisterThrottle/locale/nl/LC_MESSAGES/RegisterThrottle.po +++ b/plugins/RegisterThrottle/locale/nl/LC_MESSAGES/RegisterThrottle.po @@ -10,30 +10,34 @@ msgid "" msgstr "" "Project-Id-Version: StatusNet - RegisterThrottle\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-10-03 19:53+0000\n" -"PO-Revision-Date: 2010-10-03 19:57:19+0000\n" +"POT-Creation-Date: 2010-10-23 18:02+0000\n" +"PO-Revision-Date: 2010-10-23 18:05:52+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:39:03+0000\n" -"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-POT-Import-Date: 2010-10-18 20:30:56+0000\n" +"X-Generator: MediaWiki 1.17alpha (r75280); 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-registerthrottle\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: RegisterThrottlePlugin.php:121 RegisterThrottlePlugin.php:160 +#: RegisterThrottlePlugin.php:134 RegisterThrottlePlugin.php:185 msgid "Cannot find IP address." msgstr "Het IP-adres kon niet gevonden worden." -#: RegisterThrottlePlugin.php:136 +#: RegisterThrottlePlugin.php:149 msgid "Too many registrations. Take a break and try again later." msgstr "Te veel registraties. Wacht even en probeer het later opnieuw." -#: RegisterThrottlePlugin.php:166 +#: RegisterThrottlePlugin.php:161 +msgid "A banned user has registered from this address." +msgstr "" + +#: RegisterThrottlePlugin.php:191 msgid "Cannot find user after successful registration." msgstr "Het was niet mogelijk de gebruiker te vinden na registratie." -#: RegisterThrottlePlugin.php:199 +#: RegisterThrottlePlugin.php:224 msgid "Throttles excessive registration from a single IP address." msgstr "Beperkt excessieve aantallen registraties vanaf één IP-adres." diff --git a/plugins/RegisterThrottle/locale/tl/LC_MESSAGES/RegisterThrottle.po b/plugins/RegisterThrottle/locale/tl/LC_MESSAGES/RegisterThrottle.po index 8826451a8..2cca3ee82 100644 --- a/plugins/RegisterThrottle/locale/tl/LC_MESSAGES/RegisterThrottle.po +++ b/plugins/RegisterThrottle/locale/tl/LC_MESSAGES/RegisterThrottle.po @@ -9,31 +9,35 @@ msgid "" msgstr "" "Project-Id-Version: StatusNet - RegisterThrottle\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-10-03 19:53+0000\n" -"PO-Revision-Date: 2010-10-03 19:57:19+0000\n" +"POT-Creation-Date: 2010-10-23 18:02+0000\n" +"PO-Revision-Date: 2010-10-23 18:05:52+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:39:03+0000\n" -"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-POT-Import-Date: 2010-10-18 20:30:56+0000\n" +"X-Generator: MediaWiki 1.17alpha (r75280); 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-registerthrottle\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: RegisterThrottlePlugin.php:121 RegisterThrottlePlugin.php:160 +#: RegisterThrottlePlugin.php:134 RegisterThrottlePlugin.php:185 msgid "Cannot find IP address." msgstr "Hindi matagpuan ang tirahan ng IP." -#: RegisterThrottlePlugin.php:136 +#: RegisterThrottlePlugin.php:149 msgid "Too many registrations. Take a break and try again later." msgstr "Napakaraming mga pagpapatala. Magpahinga muna at subukan uli mamaya." -#: RegisterThrottlePlugin.php:166 +#: RegisterThrottlePlugin.php:161 +msgid "A banned user has registered from this address." +msgstr "" + +#: RegisterThrottlePlugin.php:191 msgid "Cannot find user after successful registration." msgstr "Hindi matagpuan ang tagagamit pagkatapos ng matagumpay na pagpapatala." -#: RegisterThrottlePlugin.php:199 +#: RegisterThrottlePlugin.php:224 msgid "Throttles excessive registration from a single IP address." msgstr "" "Naglilipat-lipat ng labis na pagpapatala mula sa isang nag-iisang tirahan ng " diff --git a/plugins/RegisterThrottle/locale/uk/LC_MESSAGES/RegisterThrottle.po b/plugins/RegisterThrottle/locale/uk/LC_MESSAGES/RegisterThrottle.po index 03ddc80e1..83d0b3c44 100644 --- a/plugins/RegisterThrottle/locale/uk/LC_MESSAGES/RegisterThrottle.po +++ b/plugins/RegisterThrottle/locale/uk/LC_MESSAGES/RegisterThrottle.po @@ -9,31 +9,35 @@ msgid "" msgstr "" "Project-Id-Version: StatusNet - RegisterThrottle\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-10-03 19:53+0000\n" -"PO-Revision-Date: 2010-10-03 19:57:19+0000\n" +"POT-Creation-Date: 2010-10-23 18:02+0000\n" +"PO-Revision-Date: 2010-10-23 18:05:52+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:39:03+0000\n" -"X-Generator: MediaWiki 1.17alpha (r74231); Translate extension (2010-09-17)\n" +"X-POT-Import-Date: 2010-10-18 20:30:56+0000\n" +"X-Generator: MediaWiki 1.17alpha (r75280); 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-registerthrottle\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" -#: RegisterThrottlePlugin.php:121 RegisterThrottlePlugin.php:160 +#: RegisterThrottlePlugin.php:134 RegisterThrottlePlugin.php:185 msgid "Cannot find IP address." msgstr "Не вдається знайти IP-адресу." -#: RegisterThrottlePlugin.php:136 +#: RegisterThrottlePlugin.php:149 msgid "Too many registrations. Take a break and try again later." msgstr "Забагато реєстрацій. Випийте поки що кави і повертайтесь пізніше." -#: RegisterThrottlePlugin.php:166 +#: RegisterThrottlePlugin.php:161 +msgid "A banned user has registered from this address." +msgstr "" + +#: RegisterThrottlePlugin.php:191 msgid "Cannot find user after successful registration." msgstr "Не вдається знайти користувача після успішної реєстрації." -#: RegisterThrottlePlugin.php:199 +#: RegisterThrottlePlugin.php:224 msgid "Throttles excessive registration from a single IP address." msgstr "Цей додаток обмежує кількість реєстрацій з певної IP-адреси." |