diff --git a/.idea/alica.iml b/.idea/alica.iml old mode 100755 new mode 100644 index 9a8e33d..816484e --- a/.idea/alica.iml +++ b/.idea/alica.iml @@ -2,9 +2,7 @@ - - - + diff --git a/php/public/uploads/11560Adidas 3D LOGO.jpg b/php/public/uploads/11560Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/11560Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/11596Adidas 3D LOGO.jpg b/php/public/uploads/11596Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/11596Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/12228Adidas 3D LOGO.jpg b/php/public/uploads/12228Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/12228Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/13822Adidas 3D LOGO.jpg b/php/public/uploads/13822Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/13822Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/14330Adidas 3D LOGO.jpg b/php/public/uploads/14330Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/14330Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/17005 .png b/php/public/uploads/17005 .png new file mode 100644 index 0000000..955bdb3 Binary files /dev/null and b/php/public/uploads/17005 .png differ diff --git a/php/public/uploads/18355 .png b/php/public/uploads/18355 .png new file mode 100644 index 0000000..955bdb3 Binary files /dev/null and b/php/public/uploads/18355 .png differ diff --git a/php/public/uploads/18652Adidas 3D LOGO.jpg b/php/public/uploads/18652Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/18652Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/19023Adidas 3D LOGO.jpg b/php/public/uploads/19023Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/19023Adidas 3D LOGO.jpg differ diff --git a/php/src/config/Validation.php b/php/src/config/Validation.php index 4f19746..9eb69c2 100755 --- a/php/src/config/Validation.php +++ b/php/src/config/Validation.php @@ -59,4 +59,21 @@ class Validation public function verifierEmail(string $str):bool{ return filter_var($str, FILTER_VALIDATE_EMAIL); } + + + public static function validateImage($img) : bool + { + if(isset($_FILES[$img])) + { + $typesMime = array('image/jpeg', 'image/png','image/jpg', 'image/bmp','image/webp'); + $file = $_FILES[$img]["tmp_name"]; + + $mime = mime_content_type($file); + $maxFileSize = 10 * 1024 * 1024; // 10MB Taille max acceptée + if (in_array($mime, $typesMime) && $_FILES[$img]["size"] <= $maxFileSize) { + return true; + } + } + return false; + } } diff --git a/php/src/controleur/UtilisateurControleur.php b/php/src/controleur/UtilisateurControleur.php index d7031d3..a49690a 100755 --- a/php/src/controleur/UtilisateurControleur.php +++ b/php/src/controleur/UtilisateurControleur.php @@ -5,6 +5,7 @@ namespace App\controleur; use App\config\Validation; use App\gateway\Connection; use App\gateway\ImageGateway; +use App\gateway\ImageSaver; use App\gateway\OffreGateway; use App\metier\Image; use App\modele\NiveauEtudes; @@ -177,11 +178,13 @@ class UtilisateurControleur { if(isset($_FILES["image"])) { - $imgMdl = new ImageModele; - $img = $imgMdl->publierImage(); + //$imgMdl = new ImageModele; + //$img = $imgMdl->publierImage(); + + $img = ImageSaver::SaveImage('image'); $mdl = new \App\modele\UtilisateurModele(); - $mdl->ajouterEvenement($img); + $mdl->ajouterEvenement($img[1]); global $twig; $twig->addExtension(new TwigExtensions()); diff --git a/php/src/gateway/EvenementGateway.php b/php/src/gateway/EvenementGateway.php index 0f3dd96..ee2f5c7 100755 --- a/php/src/gateway/EvenementGateway.php +++ b/php/src/gateway/EvenementGateway.php @@ -23,15 +23,21 @@ class EvenementGateway public function insertEvenement(Evenement $evenement) { - $query='INSERT INTO Evenement VALUES (:i, :o, :t, :d, :date, :nb, :img)'; + echo "img :"; + echo $evenement->getImage(); + echo "
"; + + //id organisateur titre description image date nbPlaceMax + $query='INSERT INTO Evenement VALUES (:i, :o, :t, :d, :img,:date, :nb)'; $this->con->executeQuery($query, array( ':i' => array($evenement->getId(), \PDO::PARAM_INT), ':o' => array($evenement->getOrganisateurId(), \PDO::PARAM_INT), ':t' => array($evenement->getTitre(), \PDO::PARAM_STR), ':d' => array($evenement->getDescription(), \PDO::PARAM_STR), + ':img' => array($evenement->getImage(), \PDO::PARAM_STR), ':date' => array($evenement->getDate(), \PDO::PARAM_STR), - ':nb' => array($evenement->getNbPlaceMax(), \PDO::PARAM_INT), - ':img' => array($evenement->getImageId(), \PDO::PARAM_INT) + ':nb' => array($evenement->getNbPlaceMax(), \PDO::PARAM_INT) + )); } diff --git a/php/src/gateway/ImageSaver.php b/php/src/gateway/ImageSaver.php new file mode 100644 index 0000000..2e0540b --- /dev/null +++ b/php/src/gateway/ImageSaver.php @@ -0,0 +1,31 @@ + array($offre->getOffreurId(), \PDO::PARAM_STR), ':t' => array($offre->getNom(), \PDO::PARAM_STR), ':d' => array($offre->getDescription(), \PDO::PARAM_STR), - 'img' => array($offre->getImgId(), \PDO::PARAM_INT), + 'img' => array($offre->getImg(), \PDO::PARAM_STR), ':ty' => array($offre->getTypeContrat(), \PDO::PARAM_STR), ':v' => array($offre->getVille(), \PDO::PARAM_STR), ':e' => array($offre->getEntreprise(), \PDO::PARAM_STR), diff --git a/php/src/metier/Evenement.php b/php/src/metier/Evenement.php index 97feef3..1e9de41 100755 --- a/php/src/metier/Evenement.php +++ b/php/src/metier/Evenement.php @@ -37,7 +37,8 @@ class Evenement /** * @var Image Image de l'evenement */ - private Image $image; + //private Image $image; + private string $image; /** * @param int $id @@ -48,7 +49,7 @@ class Evenement * @param int $nbPlaceMax * @param Image $image */ - public function __construct(int $id, int $organisateur, string $titre, string $description, string $date, int $nbPlaceMax, Image $image) + public function __construct(int $id, int $organisateur, string $titre, string $description, string $date, int $nbPlaceMax, string $image) { $this->id = $id; $this->organisateur = $organisateur; @@ -107,18 +108,10 @@ class Evenement return $this->nbPlaceMax; } - /** - * @return Image - */ - public function getImage(): Image - { - return $this->image; - } - /** * @return int */ - public function getImageId(): int + public function getImage(): string { return $this->image->getId(); } diff --git a/php/src/modele/UtilisateurModele.php b/php/src/modele/UtilisateurModele.php index 92a16fb..3f3de7c 100755 --- a/php/src/modele/UtilisateurModele.php +++ b/php/src/modele/UtilisateurModele.php @@ -71,14 +71,17 @@ class UtilisateurModele foreach($data as $row) { - $imgRaw = $gateImage->obtenirParId($row['image']); - $img = new Image( - intval($imgRaw[0]["id"]), - $imgRaw[0]['nom'], - $imgRaw[0]['taille'], - $imgRaw[0]['type'], - $imgRaw[0]['blob'] - ); + // $imgRaw = $gateImage->obtenirParId($row['image']); + // $img = new Image( + // intval($imgRaw[0]["id"]), + // $imgRaw[0]['nom'], + // $imgRaw[0]['taille'], + // $imgRaw[0]['type'], + // $imgRaw[0]['blob'] + // ); + + echo "row img",$row['image']; + echo "
"; $evenement[] = new \App\metier\Evenement( $row['id'], @@ -87,13 +90,13 @@ class UtilisateurModele $row['description'], $row['date'], $row['nbPlaceMax'], - $img + $row['image'] ); } return $evenement; } - public function ajouterEvenement(Image $img) + public function ajouterEvenement(string $img) { global $dsn, $username, $password;