0337d704 |
1 | <?php |
2 | /*************************************************************************** |
50a40a33 |
3 | * Copyright (C) 2003-2006 Polytechnique.org * |
0337d704 |
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 | require_once('xorg.inc.php'); |
23 | new_skinned_page('trombino.tpl', AUTH_MDP); |
24 | |
25 | require_once('validations.inc.php'); |
26 | |
27 | $trombi_x = '/home/web/trombino/photos'.Session::get('promo').'/'.Session::get('forlife').'.jpg'; |
28 | |
29 | if (Env::has('upload')) { |
30 | $file = isset($_FILES['userfile']['tmp_name']) ? $_FILES['userfile']['tmp_name'] : Env::get('photo'); |
31 | if ($data = file_get_contents($file)) { |
32 | if ($myphoto = new PhotoReq(Session::getInt('uid'), $data)) { |
33 | $myphoto->submit(); |
34 | } |
35 | } else { |
36 | $page->trig('Fichier inexistant ou vide'); |
37 | } |
38 | } elseif (Env::has('trombi')) { |
39 | $myphoto = new PhotoReq(Session::getInt('uid'), file_get_contents($trombi_x)); |
40 | if ($myphoto) { |
41 | $myphoto->commit(); |
42 | $myphoto->clean(); |
43 | } |
44 | } elseif (Env::get('suppr')) { |
45 | $globals->xdb->execute('DELETE FROM photo WHERE uid = {?}', Session::getInt('uid')); |
46 | $globals->xdb->execute('DELETE FROM requests WHERE user_id = {?} AND type="photo"', Session::getInt('uid')); |
47 | } elseif (Env::get('cancel')) { |
48 | $sql = $globals->xdb->query('DELETE FROM requests WHERE user_id={?} AND type="photo"', Session::getInt('uid')); |
49 | } |
50 | |
51 | $sql = $globals->xdb->query('SELECT COUNT(*) FROM requests WHERE user_id={?} AND type="photo"', Session::getInt('uid')); |
52 | $page->assign('submited', $sql->fetchOneCell()); |
53 | $page->assign('has_trombi_x', file_exists($trombi_x)); |
54 | |
55 | $page->run(); |
56 | |
57 | // Affichage de la page principale |
58 | ?> |