+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once('xorg.inc.php');
-new_skinned_page('trombino.tpl', AUTH_MDP);
-
-require_once('validations.inc.php');
-
-$trombi_x = '/home/web/trombino/photos'.Session::get('promo').'/'.Session::get('forlife').'.jpg';
-
-if (Env::has('upload')) {
- $file = isset($_FILES['userfile']['tmp_name']) ? $_FILES['userfile']['tmp_name'] : Env::get('photo');
- if ($data = file_get_contents($file)) {
- if ($myphoto = new PhotoReq(Session::getInt('uid'), $data)) {
- $myphoto->submit();
- }
- } else {
- $page->trig('Fichier inexistant ou vide');
- }
-} elseif (Env::has('trombi')) {
- $myphoto = new PhotoReq(Session::getInt('uid'), file_get_contents($trombi_x));
- if ($myphoto) {
- $myphoto->commit();
- $myphoto->clean();
- }
-} elseif (Env::get('suppr')) {
- $globals->xdb->execute('DELETE FROM photo WHERE uid = {?}', Session::getInt('uid'));
- $globals->xdb->execute('DELETE FROM requests WHERE user_id = {?} AND type="photo"', Session::getInt('uid'));
-} elseif (Env::get('cancel')) {
- $sql = $globals->xdb->query('DELETE FROM requests WHERE user_id={?} AND type="photo"', Session::getInt('uid'));
-}
-
-$sql = $globals->xdb->query('SELECT COUNT(*) FROM requests WHERE user_id={?} AND type="photo"', Session::getInt('uid'));
-$page->assign('submited', $sql->fetchOneCell());
-$page->assign('has_trombi_x', file_exists($trombi_x));
-
-$page->run();
-
-// Affichage de la page principale
-?>
function handlers()
{
return array(
- 'photo' => $this->make_hook('photo', AUTH_PUBLIC),
- 'trombi' => $this->make_hook('trombi', AUTH_COOKIE),
+ 'photo' => $this->make_hook('photo', AUTH_PUBLIC),
+ 'photo/change' => $this->make_hook('photo_change', AUTH_MDP),
+ 'trombi' => $this->make_hook('trombi', AUTH_COOKIE),
);
}
echo $data;
} else {
Header('Content-type: image/png');
- echo file_get_contents(dirname(__FILE__).'../htdocs/images/none.png');
+ echo file_get_contents(dirname(__FILE__).'/../htdocs/images/none.png');
}
}
exit;
}
+ function handler_photo_change(&$page)
+ {
+ global $globals;
+
+ $page->changeTpl('trombino.tpl');
+
+ require_once('validations.inc.php');
+
+ $trombi_x = '/home/web/trombino/photos'.Session::get('promo')
+ .'/'.Session::get('forlife').'.jpg';
+
+ if (Env::has('upload')) {
+ $file = isset($_FILES['userfile']['tmp_name'])
+ ? $_FILES['userfile']['tmp_name']
+ : Env::get('photo');
+ if ($data = file_get_contents($file)) {
+ if ($myphoto = new PhotoReq(Session::getInt('uid'), $data)) {
+ $myphoto->submit();
+ }
+ } else {
+ $page->trig('Fichier inexistant ou vide');
+ }
+ } elseif (Env::has('trombi')) {
+ $myphoto = new PhotoReq(Session::getInt('uid'),
+ file_get_contents($trombi_x));
+ if ($myphoto) {
+ $myphoto->commit();
+ $myphoto->clean();
+ }
+ } elseif (Env::get('suppr')) {
+ $globals->xdb->execute('DELETE FROM photo WHERE uid = {?}',
+ Session::getInt('uid'));
+ $globals->xdb->execute('DELETE FROM requests
+ WHERE user_id = {?} AND type="photo"',
+ Session::getInt('uid'));
+ } elseif (Env::get('cancel')) {
+ $sql = $globals->xdb->query('DELETE FROM requests
+ WHERE user_id={?} AND type="photo"',
+ Session::getInt('uid'));
+ }
+
+ $sql = $globals->xdb->query('SELECT COUNT(*) FROM requests
+ WHERE user_id={?} AND type="photo"',
+ Session::getInt('uid'));
+ $page->assign('submited', $sql->fetchOneCell());
+ $page->assign('has_trombi_x', file_exists($trombi_x));
+
+ return PL_OK;
+ }
+
function handler_trombi(&$page, $promo = null)
{
require_once 'trombi.inc.php';
{if $photo_incitation}
<p>
Tu n'as pas mis de photo de toi sur ta fiche, c'est dommage.
- Clique <a href="{rel}/trombino.php">ici</a> si tu souhaites en ajouter une.
+ Clique <a href="{rel}/photo/change">ici</a> si tu souhaites en ajouter une.
</p>
{/if}
d'identité (dans un fichier au format JPEG, PNG ou GIF).<br />
<div class="center">
<span class="lien">
- <a href="trombino.php">Éditer ta photo</a>
+ <a href="{rel}/photo/change">Éditer ta photo</a>
</span>
</div>
</td>
<h1>Trombinoscope</h1>
-<form enctype="multipart/form-data" action="{$smarty.server.REQUEST_URI}" method="post">
+<form enctype="multipart/form-data" action="{rel}/photo/change" method="post">
<table class="flags" cellspacing="0" summary="Flags">
<tr>
<td class="rouge"><input type="radio" checked="checked" /></td>