function PhotoReq($_uid, $_data, $_stamp=0)
{
- global $page;
-
$this->Validate($_uid, true, 'photo', $_stamp);
+ if (!$this->_get_image($_data)) {
+ return ($this = null);
+ }
+ }
+
+ // }}}
+ // {{{ function _get_image()
+
+ function _get_image($_data)
+ {
+ global $page;
// calcul de la taille de l'image
require_once dirname(__FILE__).'/../../classes/VarStream.php';
if (empty($image_infos)) {
$page->trig("Image invalide");
- return ($this = null);
+ return false;
}
list($this->x, $this->y, $this->mimetype) = $image_infos;
case 3: $this->mimetype = "png"; break;
default:
$page->trig("Type d'image invalide");
- return ($this = null);
+ return false;
}
if (strlen($_data) > SIZE_MAX) {
$img = imagecreatefromstring($_data);
if (!$img) {
$page->trig("image trop grande et impossible à retailler automatiquement");
- return ($this = null);
+ return false;
}
$nx = $x = imagesx($img);
unlink($file);
}
$this->data = $_data;
+ return true;
}
// }}}
{ return 'include/form.valid.photos.tpl'; }
// }}}
+ // {{{ function editor()
+
+ function editor()
+ {
+ return 'include/form.valid.edit-photo.tpl';
+ }
+
+ // }}}
+ // {{{ function handle_editor()
+
+ function handle_editor()
+ {
+ if (isset($_FILES['userfile']['tmp_name'])) {
+ $file = $_FILES['userfile']['tmp_name'];
+ if ($data = file_get_contents($file)) {
+ if ($this->_get_image($data)) {
+ return true;
+ }
+ } else {
+ $page->trig('Fichier inexistant ou vide');
+ }
+ }
+ return false;
+ }
+
+ // }}}
// {{{ function _mail_subj
function _mail_subj()
{if $valid->editor()}
<tr>
<td colspan="2" class="center">
- <form action="admin/validate" method="post">
+ <form enctype="multipart/form-data" action="admin/validate" method="post">
<div>
{include file=$valid->editor()}
<input type="hidden" name="uid" value="{$valid->uid}" />
--- /dev/null
+{**************************************************************************}
+{* *}
+{* 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 *}
+{* *}
+{**************************************************************************}
+
+<input name="userfile" type="file" size="20" maxlength="150" />
+
+{* vim:set et sw=2 sts=2 sws=2: *}