var $y;
var $unique = true;
+ var $valid = false;
var $rules = "Refuser les photos copyrightées, de mineurs, ou ayant
un caractère pornographique, violent, etc... Si une photo est mal
function PhotoReq($_uid, $_data, $_stamp=0)
{
$this->Validate($_uid, true, 'photo', $_stamp);
- $this->_get_image($_data);
+ $this->valid = $this->_get_image($_data);
}
// }}}
}
// }}}
+ // {{{ function isValid()
+
+ function isValid()
+ {
+ return $this->valid;
+ }
+
+ // }}}
// {{{ function get_request()
function get_request($uid)
if (isset($_FILES['userfile']['tmp_name'])) {
$file = $_FILES['userfile']['tmp_name'];
if ($data = file_get_contents($file)) {
- if ($this->_get_image($data)) {
+ if ($this->valid = $this->_get_image($data)) {
return true;
}
} else {
.'/'.S::v('forlife').'.jpg';
if (Env::has('upload')) {
- if (isset($_FILES['userfile']['tmp_name'])
- && !is_uploaded_file($_FILES['userfile']['tmp_name'])) {
+ if (isset($_FILES['userfile']['tmp_name']) && !is_uploaded_file($_FILES['userfile']['tmp_name'])) {
$page->trig('Une erreur s\'est produite lors du transfert du fichier');
- } else {
+ } elseif (strpos(trim(mime_content_type($_FILES['userfile']['tmp_name'])), 'image/') !== 0) {
+ $page->trig('Le fichier que tu as transmis n\'est pas une image.');
+ } else {
$file = is_uploaded_file($_FILES['userfile']['tmp_name'])
? $_FILES['userfile']['tmp_name']
: Env::v('photo');
if ($data = file_get_contents($file)) {
$myphoto = new PhotoReq(S::v('uid'), $data);
- $myphoto->submit();
+ if ($myphoto->isValid()) {
+ $myphoto->submit();
+ }
} else {
$page->trig('Fichier inexistant ou vide');
}
} elseif (Env::has('trombi')) {
$myphoto = new PhotoReq(S::v('uid'),
file_get_contents($trombi_x));
- if ($myphoto) {
+ if ($myphoto->isValid()) {
$myphoto->commit();
$myphoto->clean();
}