From: thomas.deniau@polytechnique.org Date: Mon, 17 Mar 2008 13:23:53 +0000 (+0100) Subject: Mise en place d'un systeme de bannissement SQL des fora. X-Git-Tag: xorg/0.9.16~108 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=669cb0e010526f24b234de22753cbfbb24971522;p=platal.git Mise en place d'un systeme de bannissement SQL des fora. Ce systeme a trois composantes : - Consultation d'une base SQL par inn dans le nnrpd_access.pl - Manipulation de la base de données via plat/al - Webservice integre a plat/al pour avoir les permissions d'un utilisateur (utilise par le BR pour bannir les utilisateurs des groupes de xorg.* feedes sur Frankiz) Ce commit realise le deuxieme item. La base SQL est creee par le script d'upgrade correspondant. On peut modifier cette base - Sur une nouvelle page admin/forums - Sur le "edit" de chaque utilisateur. A noter : la modification de PLTableEditor pour pouvoir editer correctement des IPs stockees comme des entiers (avec INET_ATON() dans MySQL), a condition que le champ COMMENT des colonnes en question soit 'ip_address'. --- diff --git a/ChangeLog b/ChangeLog index 21cbede..0313ea2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,9 @@ New: * Lists: - Unsure mails are moderated -FRU + * Forums: + - Ban system -THD + Bug/Wish: * Emails: @@ -1166,6 +1169,7 @@ ACRONYMS: * OG : Olivier Guillaumin * PIK: Fabien Laborde (pika) * SHK: Jeremy Lainé (Sharky) + * THD: Thomas Deniau (Totom) * VP : Vincent Palatin * XdX: Alexandre Hô (XandreX) * VZA: Vincent Zanotti (vinZ2) diff --git a/classes/pltableeditor.php b/classes/pltableeditor.php index 7637238..7cfc2e8 100644 --- a/classes/pltableeditor.php +++ b/classes/pltableeditor.php @@ -63,7 +63,7 @@ class PLTableEditor $this->sortfield = $idfield; $this->idfield_editable = $editid; $this->whereclause = '1'; - $r = XDB::iterator("SHOW COLUMNS FROM $table"); + $r = XDB::iterator("SHOW FULL COLUMNS FROM $table"); $this->vars = array(); while ($a = $r->next()) { // desc will be the title of the column @@ -97,6 +97,9 @@ class PLTableEditor elseif (substr($a['Type'],0,10) == 'timestamp(' || $a['Type'] == 'datetime') { $a['Type'] = 'timestamp'; } + elseif ($a['Comment'] == 'ip_address') { + $a['Type']='ip_address'; + } $this->vars[$a['Field']] = $a; } @@ -133,6 +136,10 @@ class PLTableEditor $date =& $entry[$field]; $date = preg_replace('/([0-9]{4})-?([0-9]{2})-?([0-9]{2})/', '\3/\2/\1', $date); } + if ($descr['Type'] == 'ip_address') { + $ip = & $entry[$field]; + $ip = long2ip($ip); + } } return $entry; } @@ -197,7 +204,7 @@ class PLTableEditor $page->trig($this->delete_message); } else { $page->trig("L'entrée ".$id." a été supprimée."); - } + } } else { $page->trig("Impossible de supprimer l'entrée."); } @@ -254,6 +261,9 @@ class PLTableEditor elseif ($descr['Type'] == 'date') { $val = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/', '\3-\2-\1', $val); } + elseif ($descr['Type'] == 'ip_address') { + $val = ip2long($val); + } $val = "'".addslashes($val)."'"; } else { $cancel = true; @@ -272,7 +282,7 @@ class PLTableEditor $id = XDB::insertId(); } } else - $page->trig("Impossible de mette à jour."); + $page->trig("Impossible de mettre à jour."); if (!$this->auto_return) { return $this->apply($page, 'edit', $id); } diff --git a/modules/admin.php b/modules/admin.php index 01878a7..af011ea 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -612,6 +612,21 @@ class AdminModule extends PLModule $mailer->assign("deletion", true); $mailer->send(); break; + + case "b_edit": + XDB::execute("DELETE FROM forums.innd WHERE uid = {?}", $mr['user_id']); + if (Env::v('write_perm') != "" || Env::v('read_perm') != "" || Env::v('commentaire') != "" ) { + XDB::execute("INSERT INTO forums.innd + SET ipmin = '0', + ipmax = '4294967295', + write_perm = {?}, + read_perm = {?}, + comment = {?}, + priority = '200', + uid = {?}", + Env::v('write_perm'), Env::v('read_perm'), Env::v('comment'), $mr['user_id']); + } + break; } } @@ -640,6 +655,13 @@ class AdminModule extends PLModule } $page->assign('mr',$mr); + + // Bans forums + $res = XDB::query("SELECT write_perm, read_perm, comment + FROM forums.innd + WHERE uid = {?}", $mr['user_id']); + $bans = $res->fetchOneAssoc(); + $page->assign('bans', $bans); } } @@ -921,6 +943,7 @@ class AdminModule extends PLModule $table_editor->describe('ext','extension du screenshot',false); $table_editor->apply($page, $action, $id); } + function handler_postfix_blacklist(&$page, $action = 'list', $id = null) { $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Blacklist'); $page->assign('title', 'Blacklist de postfix'); diff --git a/modules/banana.php b/modules/banana.php index c23749d..ad09a9b 100644 --- a/modules/banana.php +++ b/modules/banana.php @@ -28,6 +28,7 @@ class BananaModule extends PLModule // 'banana/profile' => $this->make_hook('profile', AUTH_MDP), // 'banana/subscribe' => $this->make_hook('subscription', AUTH_COOKIE), 'banana/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS), + 'admin/forums' => $this->make_hook('forums_bans', AUTH_MDP, 'admin'), ); } @@ -146,6 +147,21 @@ class BananaModule extends PLModule exit; } + function handler_forums_bans(&$page, $action = 'list', $id = null) + { + $page->assign('xorg_title','Polytechnique.org - Administration - Bannissements des forums'); + $page->assign('title', 'Gestion des mises au ban'); + $table_editor = new PLTableEditor('admin/forums','forums.innd','id_innd'); + $table_editor->describe('ipmin','min plage IP',true); + $table_editor->describe('ipmax','max plage IP',true); + $table_editor->describe('uid','utilisateur',true); + $table_editor->describe('write_perm','perm. poster',true); + $table_editor->describe('read_perm','perm. lire',true); + $table_editor->describe('priority','priorite',true); + $table_editor->describe('comment','commentaire',true); + $table_editor->apply($page, $action, $id); + } + static function run_banana(&$page, $params = null) { $page->changeTpl('banana/index.tpl'); diff --git a/templates/admin/index.tpl b/templates/admin/index.tpl index 3e56fad..fe4dd82 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -160,6 +160,12 @@ Gestion des sondages + + + Forums :   + Gestion des mises au ban + + {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/admin/utilisateurs.tpl b/templates/admin/utilisateurs.tpl index 38a0d5a..33859af 100644 --- a/templates/admin/utilisateurs.tpl +++ b/templates/admin/utilisateurs.tpl @@ -70,7 +70,7 @@ {if $mr}

-Derniére connexion le {$lastlogin|date_format:"%d %B %Y, %T"} +Dernière connexion le {$lastlogin|date_format:"%d %B %Y, %T"} depuis {$host}

@@ -103,6 +103,15 @@ function clean_fwd(fwd) { document.forms.fwds.clean_fwd.value = fwd; document.forms.fwds.submit(); } +function ban_write() +{ + document.forms.bans.write_perm.value = "!xorg.*"; +} +function ban_read() +{ + document.forms.bans.read_perm.value = "!xorg.*"; +} + // ]]> {/literal} @@ -211,7 +220,7 @@ function clean_fwd(fwd) { - + Surveillance @@ -307,6 +316,53 @@ Pour ceci changer ses permissions en 'disabled'. +
+ + + + + + + + + + + + + + + + + + + + + +
+ Permissions sur les forums +
+ Poster : + + + + Bannir +
+ Lire : + + + + Bannir +
+ Commentaire + + + +
+ + +
+
+

* à ne modifier qu'avec l'accord express de l'utilisateur !!!

diff --git a/templates/payment/retour_paypal.tpl b/templates/payment/retour_paypal.tpl index 666ca23..40df8fe 100644 --- a/templates/payment/retour_paypal.tpl +++ b/templates/payment/retour_paypal.tpl @@ -21,7 +21,7 @@ {**************************************************************************} -

Télépaiments

+

Télépaiements

{if $erreur}

Aucun paiement n'a été effectué.

diff --git a/upgrade/0.9.16/08_forums.sql b/upgrade/0.9.16/08_forums.sql new file mode 100644 index 0000000..f208a2a --- /dev/null +++ b/upgrade/0.9.16/08_forums.sql @@ -0,0 +1,13 @@ +CREATE TABLE `forums.innd` ( + `id_innd` int(10) unsigned NOT NULL auto_increment, + `ipmin` int(10) unsigned default '0' COMMENT 'ip_address', + `ipmax` int(10) unsigned default '4294967295' COMMENT 'ip_address', + `uid` smallint(5) unsigned default NULL, + `read_perm` varchar(100) default '!*', + `write_perm` varchar(100) default '!*', + `priority` tinyint(1) unsigned default '255', + `comment` text, + PRIMARY KEY (`id_innd`) +) DEFAULT CHARSET=utf8; + +INSERT INTO `forums.innd` VALUES (1,0,4294967295,NULL,'xorg.*,!xorg.prive.*','xorg.*,!xorg.prive.*,!xorg.pa.emploi',0,'par defaut pour tous');