f585e5a4 |
1 | <?php |
2 | /*************************************************************************** |
3 | * Copyright (C) 2003-2006 Polytechnique.org * |
4 | * http://opensource.polytechnique.org/ * |
5 | * * |
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. * |
10 | * * |
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. * |
15 | * * |
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 * |
18 | * Foundation, Inc., * |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
20 | ***************************************************************************/ |
21 | |
22 | class BananaModule extends PLModule |
23 | { |
24 | function handlers() |
25 | { |
26 | return array( |
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), |
30 | ); |
31 | } |
32 | |
33 | function handler_banana(&$page) |
34 | { |
35 | $page->changeTpl('banana/index.tpl'); |
36 | $page->addCssLink('css/banana/style.css'); |
37 | $page->assign('xorg_title','Polytechnique.org - Forums & PA'); |
38 | |
39 | require_once 'banana.inc.php'; |
40 | |
41 | $res = PlatalBanana::run(); |
42 | $page->assign_by_ref('banana', $banana); |
43 | $page->assign('banana_res', $res); |
44 | |
45 | return PL_OK; |
46 | } |
47 | |
48 | function handler_profile(&$page) |
49 | { |
50 | global $globals; |
51 | |
52 | $page->changeTpl('banana/profile.tpl'); |
53 | |
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" )) |
57 | { |
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') |
61 | FROM forums.profils |
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').')'; |
67 | $disp = 0; |
68 | $maj = 0; |
69 | } |
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); |
75 | } else { |
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' : '') |
81 | ); |
82 | } |
83 | |
84 | return PL_OK; |
85 | } |
86 | |
87 | function handler_xface(&$page) |
88 | { |
89 | header('Content-Type: image/jpeg'); |
90 | passthru('echo '.escapeshellarg(base64_decode($_REQUEST['face'])). |
91 | '|uncompface -X |convert xbm:- jpg:-'); |
92 | exit; |
93 | } |
94 | } |
95 | |
96 | ?> |