2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 class BananaModule
extends PLModule
27 'banana' => $this->make_hook('banana', AUTH_COOKIE
),
28 'banana/profile' => $this->make_hook('profile', AUTH_MDP
),
29 'banana/xface' => $this->make_hook('xface', AUTH_PUBLIC
),
33 function handler_banana(&$page)
35 $page->changeTpl('banana/index.tpl');
36 $page->addCssLink('css/banana/style.css');
37 $page->assign('xorg_title','Polytechnique.org - Forums & PA');
39 require_once 'banana.inc.php';
41 $res = PlatalBanana
::run();
42 $page->assign_by_ref('banana', $banana);
43 $page->assign('banana_res', $res);
48 function handler_profile(&$page)
52 $page->changeTpl('banana/profile.tpl');
54 if (!(Post
::has('action') && Post
::has('banananame') && Post
::has('bananasig')
55 && Post
::has('bananadisplay') && Post
::has('bananamail')
56 && Post
::has('bananaupdate') && Post
::get('action')=="OK" ))
58 $req = $globals->xdb
->query("
59 SELECT nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'),
60 IF(FIND_IN_SET('automaj',flags),'1','0')
62 WHERE uid = {?}", Session
::getInt('uid'));
63 if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) {
64 $nom = Session
::get('prenom').' '.Session
::get('nom');
65 $mail = Session
::get('forlife').'@'.$globals->mail
->domain
;
66 $sig = $nom.' ('.Session
::getInt('promo').')';
70 $page->assign('nom' , $nom);
71 $page->assign('mail', $mail);
72 $page->assign('sig' , $sig);
73 $page->assign('disp', $disp);
74 $page->assign('maj' , $maj);
76 $globals->xdb
->execute(
77 'REPLACE INTO forums.profils (uid,sig,mail,nom,flags)
78 VALUES ({?},{?},{?},{?},{?})',
79 Session
::getInt('uid'), Post
::get('bananasig'), Post
::get('bananamail'), Post
::get('banananame'),
80 (Post
::getBool('bananadisplay') ?
'threads,' : '') . (Post
::getBool('bananaupdate') ?
'automaj' : '')
87 function handler_xface(&$page)
89 header('Content-Type: image/jpeg');
90 passthru('echo '.escapeshellarg(base64_decode($_REQUEST['face'])).
91 '|uncompface -X |convert xbm:- jpg:-');