32f10a2cee0e945ce37a5e61239cec81b540d713
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 require_once('xorg.inc.php');
23 new_skinned_page('trombino.tpl', AUTH_MDP
);
25 require_once('validations.inc.php');
27 $trombi_x = '/home/web/trombino/photos'.Session
::get('promo').'/'.Session
::get('forlife').'.jpg';
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)) {
36 $page->trig('Fichier inexistant ou vide');
38 } elseif (Env
::has('trombi')) {
39 $myphoto = new PhotoReq(Session
::getInt('uid'), file_get_contents($trombi_x));
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'));
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));
57 // Affichage de la page principale