<?php
/***************************************************************************
- * Copyright (C) 2003-2007 Polytechnique.org *
+ * Copyright (C) 2003-2008 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
{
return array(
'banana' => $this->make_hook('banana', AUTH_COOKIE),
- 'banana/profile' => $this->make_hook('profile', AUTH_MDP),
- 'banana/subscription' => $this->make_hook('subscription', AUTH_COOKIE),
+// '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'),
+ 'forums/bans/service' => $this->make_hook('forums_bans_service', AUTH_PUBLIC)
);
}
FROM auth_user_md5 WHERE promo={?}", $promo);
list($effau, $effid) = $res->fetchOneRow();
if (5*$effau>$effid) { // + de 20% d'inscrits
- $mymail = new PlMailer('mails/forums.promo.tpl');
+ $mymail = new PlMailer('admin/forums-promo.mail.tpl');
$mymail->assign('promo', $promo);
$mymail->send();
}
if (!(Post::has('action') && Post::has('banananame') && Post::has('bananasig')
&& Post::has('bananadisplay') && Post::has('bananamail')
- && Post::has('bananaupdate') && Post::v('action')=="OK" ))
+ && Post::has('bananaupdate') && Post::v('action')=="Enregistrer" ))
{
$req = XDB::query("
- SELECT nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'),
- IF(FIND_IN_SET('automaj',flags),'1','0')
+ SELECT nom, mail, sig,
+ FIND_IN_SET('threads', flags),
+ FIND_IN_SET('automaj', flags),
+ FIND_IN_SET('xface', flags)
FROM forums.profils
WHERE uid = {?}", S::v('uid'));
- if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) {
- $nom = S::v('prenom').' '.S::v('nom');
- $mail = S::v('forlife').'@'.$globals->mail->domain;
- $sig = $nom.' ('.S::v('promo').')';
- $disp = 0;
- $maj = 0;
+ if (!(list($nom, $mail, $sig, $disp, $maj, $xface) = $req->fetchOneRow())) {
+ $nom = S::v('prenom').' '.S::v('nom');
+ $mail = S::v('forlife').'@'.$globals->mail->domain;
+ $sig = $nom.' ('.S::v('promo').')';
+ $disp = 0;
+ $maj = 0;
+ $xface = 0;
}
- $page->assign('nom' , $nom);
- $page->assign('mail', $mail);
- $page->assign('sig' , $sig);
- $page->assign('disp', $disp);
- $page->assign('maj' , $maj);
+ $page->assign('nom' , $nom);
+ $page->assign('mail', $mail);
+ $page->assign('sig', $sig);
+ $page->assign('disp', $disp);
+ $page->assign('maj', $maj);
+ $page->assign('xface', $xface);
} else {
- XDB::execute(
- 'REPLACE INTO forums.profils (uid,sig,mail,nom,flags)
- VALUES ({?},{?},{?},{?},{?})',
- S::v('uid'), Post::v('bananasig'),
- Post::v('bananamail'), Post::v('banananame'),
- (Post::b('bananadisplay') ? 'threads,' : '') .
- (Post::b('bananaupdate') ? 'automaj' : '')
- );
+ $flags = array();
+ if (Post::b('bananadisplay')) {
+ $flags[] = 'threads';
+ }
+ if (Post::b('bananaupdate')) {
+ $flags[] = 'automaj';
+ }
+ if (Post::b('bananaxface')) {
+ $flags[] = 'xface';
+ }
+ XDB::execute("REPLACE INTO forums.profils (uid, sig, mail, nom, flags)
+ VALUES ({?}, {?}, {?}, {?}, {?})",
+ S::v('uid'), Post::v('bananasig'),
+ Post::v('bananamail'), Post::v('banananame'),
+ implode(',', $flags));
}
}
- function handler_subscription(&$page)
- {
- $page->changeTpl('banana/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Forums & PA');
-
- require_once 'banana/forum.inc.php';
- run_banana($page, 'ForumsBanana', Array('action' => 'subscribe'));
- }
-
function handler_rss(&$page, $group, $alias, $hash, $file = null)
{
if (is_null($file)) {
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);
+ }
+
+ function handler_forums_bans_service(&$page, $action = 'list', $id = null)
+ {
+ global $globals;
+
+ $ips = array_flip(explode(' ', $globals->banana->bans_authorized_ips));
+
+ if ($ips && isset($ips[$_SERVER['REMOTE_ADDR']])) {
+
+ $res = XDB::query("SELECT priority, read_perm, write_perm, comment
+ FROM forums.innd AS i
+ INNER JOIN x4dat.aliases AS a ON ( a.id = i.uid AND a.type='a_vie' )
+ INNER JOIN x4dat.aliases AS b ON ( b.id = a.id AND b.type != 'homonyme' )
+ WHERE b.alias = '".addslashes(Env::v('forlife'))."'");
+ $ban = $res->fetchOneAssoc();
+ echo "$res['priority']\n$res['read_perm']\n$res['write_perm']\n$res['comment']\n";
+ }
+ exit();
+ }
+
static function run_banana(&$page, $params = null)
{
$page->changeTpl('banana/index.tpl');