File manager - Edit - /home/missmand/public_html/admin/projet/editProjet.php
Back
<?php include '../lib/init.php'; /** * Initialisation */ use Lib\Utilisateur; use Lib\Tool; use Cocur\Slugify\Slugify; use Lib\Upload; use Lib\Action; use Lib\BreadCrumb; use Imagine\Gd\Imagine; use Imagine\Image\Box; use Imagine\Image\Point; $projetId = Tool::getId($_GET['projet'],BASEADMIN); Utilisateur::ifConnect(); Action::ifIsset($projetId,'projet',BASEADMIN.'projet/managerProjet.php'); $erreur = array(); $succes = array(); /** * Formulaire */ if(isset($_POST['edit'])){ /** * Variables de formulaire */ $nom = $_POST['nom']; $utilisateurNom = $_POST['utilisateurNom']; $utilisateurPrenom = $_POST['utilisateurPrenom']; $utilisateurEmail = $_POST['utilisateurEmail']; $effectif = $_POST['effectif']; $chiffre = $_POST['chiffre']; $adresse = $_POST['adresse']; $telephone = $_POST['telephone']; $email = $_POST['email']; $video = $_POST['video']; $site = $_POST['site']; $twitter = $_POST['twitter']; $facebook = $_POST['facebook']; $linkedin = $_POST['linkedin']; $instagram = $_POST['instagram']; if(isset($_POST['tag'])) $tag = $_POST['tag']; $creation = $_POST['creation']; $resume = $_POST['resume']; $description = $_POST['description']; $dirigeant = $_POST['dirigeant']; $activite = $_POST['activite']; $objectif = $_POST['objectif']; $complementaire = $_POST['complementaire']; $avant = (isset($_POST['avant'])) ? 1 : 0; $accueil = (isset($_POST['accueil'])) ? 1 : 0; $metaTitle = $_POST['metaTitle']; $metaDescription = $_POST['metaDescription']; /** * Erreurs */ if(empty($nom)) array_push($erreur, 'Veuillez compléter le champ "Nom"'); if(empty($utilisateurNom)) array_push($erreur, 'Veuillez compléter le champ "Votre nom"'); if(empty($utilisateurPrenom)) array_push($erreur, 'Veuillez compléter le champ "Votre prénom"'); if(empty($utilisateurEmail)) array_push($erreur, 'Veuillez compléter le champ "Votre adresse email"'); else{ if(!filter_var($utilisateurEmail, FILTER_VALIDATE_EMAIL)) array_push($erreur, 'Le format de l\'email n\'est pas bon'); } if(!empty($creation)){ $creationEn = Tool::dateConvert($creation, 'fr=>en'); if(!DateTime::createFromFormat('Y-m-d', $creationEn)) array_push($erreur, 'Le format de la date de création n\'est pas bon'); } if(!empty($email)){ if(!filter_var($email, FILTER_VALIDATE_EMAIL)) array_push($erreur, 'Le format de l\'email de contact n\'est pas bon'); } if(!empty($site)){ if(!filter_var($site, FILTER_VALIDATE_URL)) array_push($erreur, 'Le format de l\'url du site internet n\'est pas bonne'); } if(!empty($twitter)){ if(!filter_var($twitter, FILTER_VALIDATE_URL)) array_push($erreur, 'Le format de l\'url de twitter n\'est pas bonne'); } if(empty($resume)) array_push($erreur, 'Veuillez compléter le champ "Résumé"'); if(empty($description)) array_push($erreur, 'Veuillez compléter le champ "Description"'); if(empty($dirigeant)) array_push($erreur, 'Veuillez compléter le champ "Dirigeants"'); if(empty($activite)) array_push($erreur, 'Veuillez compléter le champ "Activité / Savoir faire"'); if(empty($metaTitle)) array_push($erreur, 'Veuillez compléter le champ "Méta title"'); if(empty($metaDescription)) array_push($erreur, 'Veuillez compléter le champ "Méta description"'); /* Le logo */ if ($_FILES['logo']['error'] === UPLOAD_ERR_OK){ $logo = Upload::postFichier($_FILES['logo'],'Logo',2000000,array('jpg','jpeg','png'),array('mi',150,150)); } /* L'image 1 */ if ($_FILES['image1']['error'] === UPLOAD_ERR_OK){ $image1 = Upload::postFichier($_FILES['image1'],'L\'image 1',5000000,array('jpg','jpeg','png'),array('mi',640,480)); } /* L'image 2 */ if ($_FILES['image2']['error'] === UPLOAD_ERR_OK){ $image2 = Upload::postFichier($_FILES['image2'],'L\'image 2',5000000,array('jpg','jpeg','png'),array('mi',640,480)); } /* L'image 3 */ if ($_FILES['image3']['error'] === UPLOAD_ERR_OK){ $image3 = Upload::postFichier($_FILES['image3'],'L\'image 3',5000000,array('jpg','jpeg','png'),array('mi',640,480)); } /** * Si aucune erreur alors */ if(empty($erreur)){ $slugify = new Slugify(); /** * Modification du projet en base de donnée */ $sql = $bdd->prepare("UPDATE projet SET projetChanged = :changed, projetNom = :nom, projetSlug = :slug, projetUtilisateurNom = :utilisateurNom, projetUtilisateurPrenom = :utilisateurPrenom, projetUtilisateurEmail = :utilisateurEmail, projetCreation = :creation, projetEffectif = :effectif, projetChiffre = :chiffre, projetAdresse = :adresse, projetTelephone = :telephone, projetEmail = :email, projetVideo = :video, projetSite = :site, projetTwitter = :twitter, projetFacebook = :facebook, projetLinkedin = :linkedin, projetInstagram = :instagram, projetTag = :tag, projetResume = :resume, projetDescription = :description, projetDirigeant = :dirigeant, projetActivite = :activite, projetObjectif = :objectif, projetComplementaire = :complementaire, projetAvant = :avant, projetAccueil = :accueil, projetMetaTitle = :metaTitle, projetMetaDescription = :metaDescription WHERE projetId = :projetId "); $sql->execute(array( 'changed' => Tool::dateTime('Y-m-d H:i'), 'nom' => $_POST['nom'], 'slug' => $slugify->slugify($_POST['nom']), 'utilisateurNom' => $_POST['utilisateurNom'], 'utilisateurPrenom' => $_POST['utilisateurPrenom'], 'utilisateurEmail' => $_POST['utilisateurEmail'], 'creation' => (isset($creationEn)) ? $creationEn : null, 'effectif' => (!empty($_POST['effectif'])) ? $_POST['effectif'] : null, 'chiffre' => (!empty($_POST['chiffre'])) ? $_POST['chiffre'] : null, 'adresse' => (!empty($_POST['adresse'])) ? $_POST['adresse'] : null, 'telephone' => (!empty($_POST['telephone'])) ? $_POST['telephone'] : null, 'email' => (!empty($_POST['email'])) ? $_POST['email'] : null, 'video' => (!empty($_POST['video'])) ? $_POST['video'] : null, 'site' => (!empty($_POST['site'])) ? $_POST['site'] : null, 'twitter' => (!empty($_POST['twitter'])) ? $_POST['twitter'] : null, 'facebook' => (!empty($_POST['facebook'])) ? $_POST['facebook'] : null, 'linkedin' => (!empty($_POST['linkedin'])) ? $_POST['linkedin'] : null, 'instagram' => (!empty($_POST['instagram'])) ? $_POST['instagram'] : null, 'tag' => (!empty($tag)) ? implode(',',$tag) : null, 'resume' => $_POST['resume'], 'description' => $_POST['description'], 'dirigeant' => $_POST['dirigeant'], 'activite' => $_POST['activite'], 'objectif' => (!empty($_POST['objectif'])) ? $_POST['objectif'] : null, 'complementaire' => (!empty($_POST['complementaire'])) ? $_POST['complementaire'] : null, 'avant' => $avant, 'accueil' => $accueil, 'metaTitle' => $_POST['metaTitle'], 'metaDescription' => $_POST['metaDescription'], 'projetId' => $projetId ) ); /* Upload du logo */ if(isset($logo)){ $sql = $bdd->prepare("UPDATE projet SET projetChanged = :changed, projetLogo = :logo WHERE projetId = :projetId "); $sql->execute(array( 'changed' => Tool::dateTime('Y-m-d H:i'), 'logo' => $logo, 'projetId' => $projetId ) ); $imagine = new Imagine(); /* Image de base */ $size = new Box(200,200); $thumb = $imagine->open($_FILES['logo']['tmp_name']) ->thumbnail($size, 'inset'); $thumbSize = $thumb->getSize(); $thumbHeight = $thumbSize->getHeight(); $thumbWidth = $thumbSize->getWidth(); $preserve = $imagine->create($size); $startX = $startY = 0; if($thumbWidth < 200) $startX = (200 - $thumbWidth) / 2; if($thumbHeight < 200) $startY = (200 - $thumbHeight) / 2; $preserve->paste($thumb, new Point($startX, $startY))->save('../../img/projet/logo/'.$logo); } /* Upload de l'image 1 */ if(isset($image1)){ $sql = $bdd->prepare("UPDATE projet SET projetChanged = :changed, projetImage1 = :image WHERE projetId = :projetId "); $sql->execute(array( 'changed' => Tool::dateTime('Y-m-d H:i'), 'image' => $image1, 'projetId' => $projetId ) ); $imagine = new Imagine(); /* Image de base */ $size = new Box(1024,768); $imagine->open($_FILES['image1']['tmp_name']) ->thumbnail($size, 'inset') ->save('../../img/projet/tmp/'.$image1); /* Miniature */ $size = new Box(600,300); $imagine->open($_FILES['image1']['tmp_name']) ->thumbnail($size, 'outbound') ->save('../../img/projet/miniature/'.$image1); } /* Upload de l'image 2 */ if(isset($image2)){ $sql = $bdd->prepare("UPDATE projet SET projetChanged = :changed, projetImage2 = :image WHERE projetId = :projetId "); $sql->execute(array( 'changed' => Tool::dateTime('Y-m-d H:i'), 'image' => $image2, 'projetId' => $projetId ) ); $imagine = new Imagine(); /* Image de base */ $size = new Box(1024,768); $imagine->open($_FILES['image2']['tmp_name']) ->thumbnail($size, 'inset') ->save('../../img/projet/tmp/'.$image2); /* Miniature */ $size = new Box(600,300); $imagine->open($_FILES['image2']['tmp_name']) ->thumbnail($size, 'outbound') ->save('../../img/projet/miniature/'.$image2); } /* Upload de l'image 3 */ if(isset($image3)){ $sql = $bdd->prepare("UPDATE projet SET projetChanged = :changed, projetImage3 = :image WHERE projetId = :projetId "); $sql->execute(array( 'changed' => Tool::dateTime('Y-m-d H:i'), 'image' => $image3, 'projetId' => $projetId ) ); $imagine = new Imagine(); /* Image de base */ $size = new Box(1024,768); $imagine->open($_FILES['image3']['tmp_name']) ->thumbnail($size, 'inset') ->save('../../img/projet/tmp/'.$image3); /* Miniature */ $size = new Box(600,300); $imagine->open($_FILES['image3']['tmp_name']) ->thumbnail($size, 'outbound') ->save('../../img/projet/miniature/'.$image3); } /* Succès */ array_push($succes,'Projet enregistré avec succès'); } } /* Information sur le projet */ $sql = $bdd->query("SELECT * FROM projet WHERE projetId = $projetId "); $data = $sql->fetchObject(); $nom = $data->projetNom; $utilisateurNom = $data->projetUtilisateurNom; $utilisateurPrenom = $data->projetUtilisateurPrenom; $utilisateurEmail = $data->projetUtilisateurEmail; $creation = (!is_null($data->projetCreation)) ? Tool::dateTime('d-m-Y', $data->projetCreation) : null; $effectif = $data->projetEffectif; $chiffre = $data->projetChiffre; $adresse = $data->projetAdresse; $telephone = $data->projetTelephone; $email = $data->projetEmail; $video = $data->projetVideo; $site = $data->projetSite; $twitter = $data->projetTwitter; $facebook = $data->projetFacebook; $linkedin = $data->projetLinkedin; $instagram = $data->projetInstagram; $tag = explode(',',$data->projetTag); $logo = $data->projetLogo; $image1 = $data->projetImage1; $image2 = $data->projetImage2; $image3 = $data->projetImage3; $resume = $data->projetResume; $description = $data->projetDescription; $dirigeant = $data->projetDirigeant; $activite = $data->projetActivite; $objectif = $data->projetObjectif; $complementaire = $data->projetComplementaire; $avant = $data->projetAvant; $accueil = $data->projetAccueil; $metaTitle = $data->projetMetaTitle; $metaDescription = $data->projetMetaDescription; ?> <!doctype html> <html lang="fr"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width; initial-scale=1;"> <title><?= TITLEBACK ?></title> <link rel="icon" type="image/png" href="<?= BASEADMIN ?>img/layout/favicon.png"> <link href="<?= BASEFRONT ?>js/scroll/scroll.css" rel="stylesheet" type="text/css"> <link href="<?= BASEFRONT ?>js/datedropper/datedropper.min.css" rel="stylesheet" type="text/css"> <link href="<?= BASEFRONT ?>js/datedropper/my-style.css" rel="stylesheet" type="text/css"> <link href="<?= BASEFRONT ?>js/sweet/sweet.css" rel="stylesheet" type="text/css"> <link href="<?= BASEADMIN ?>css/app.css" rel="stylesheet" type="text/css"> </head> <body> <main id="main"> <?php include '../include/menu.php'; ?> <div id="container"> <?php include '../include/header.php'; ?> <div id="contentTitre"> <h1>Modifier le projet : <?= $nom ?></h1> </div> <?php BreadCrumb::add(BASEADMIN,array( 'Dashboard' => 'dashboard/dashboard.php', 'Gestion des projets' => 'projet/managerProjet.php', 'Modifier un projet' => '' ) ); ?> <div id="content"> <?php if(!empty($erreur)){ Tool::getMessage($erreur, 'erreur'); } if(!empty($succes)){ Tool::getMessage($succes, 'succes'); } ?> <form action="#header" method="post" enctype="multipart/form-data"> <label>Nom du projet *</label> <input type="text" name="nom" value="<?= $nom ?>" class="form-elem big"> <label>Votre nom *</label> <input type="text" name="utilisateurNom" value="<?= $utilisateurNom ?>" class="form-elem big"> <label>Votre prénom *</label> <input type="text" name="utilisateurPrenom" value="<?= $utilisateurPrenom ?>" class="form-elem big"> <label>Votre adresse email *</label> <input type="text" name="utilisateurEmail" value="<?= $utilisateurEmail ?>" class="form-elem big"> <label>Date de création</label> <input type="text" name="creation" value="<?php echo $creation ?>" class="form-elem big dateDropper" data-lang="fr" data-large-default="true" data-large-mode="true" data-theme="my-style" data-format="d-m-Y" data-init-set="false"> <label>Effectifs</label> <input type="text" name="effectif" value="<?= $effectif ?>" class="form-elem big"> <label>Chiffre d'affaire</label> <input type="text" name="chiffre" value="<?= $chiffre ?>" class="form-elem big"> <label>Adresse</label> <input type="text" name="adresse" value="<?= $adresse ?>" class="form-elem big"> <label>Téléphone</label> <input type="text" name="telephone" value="<?= $telephone ?>" class="form-elem big"> <label>Email de contact</label> <input type="text" name="email" value="<?= $email ?>" class="form-elem big"> <label>Vidéo</label> <input type="text" name="video" value="<?= $video ?>" class="form-elem big"> <div class="form-legende"> Uniquement le code de la vidéo<br>ex : https://www.youtube.com/watch?v=<strong>imtPF2b2Q4M</strong><br>(la partie en gras) </div> <label>Site internet</label> <input type="text" name="site" value="<?= $site ?>" class="form-elem big" placeholder="http://..."> <label>Twitter</label> <input type="text" name="twitter" value="<?= $twitter ?>" class="form-elem big" placeholder="http://..."> <label>Facebook</label> <input type="text" name="facebook" value="<?= $facebook ?>" class="form-elem big" placeholder="http://..."> <label>Linkedin</label> <input type="text" name="linkedin" value="<?= $linkedin ?>" class="form-elem big" placeholder="http://..."> <label>Instagram</label> <input type="text" name="instagram" value="<?= $instagram ?>" class="form-elem big" placeholder="http://..."> <label>Tags</label> <div class="liste big"> <?php $sql = $bdd->query("SELECT * FROM tag ORDER BY tagNom ASC "); while($data = $sql->fetchObject()){ $checked = (in_array($data->tagId, $tag)) ? 'checked' : ''; echo'<p><input type="checkbox" name="tag[]" value="'.$data->tagId.'" '.$checked.'> '.$data->tagNom.'</p>'; } ?> </div> <?php if(!is_null($logo)){ echo'<div id="ajaxImage1">'; echo'<label>Logo actuel</label>'; echo'<div class="form-image big">'; echo'<img src="'.BASEFRONT.'img/projet/logo/'.$logo.'">'; echo'<br>'; echo'<a href="'.BASEADMIN.'projet/deleteImage.php?projet='.$projetId.'&image=logo" class="btn rouge sweetDeleteImage" data-parent="ajaxImage1"><i class="fa fa-trash"></i> Supprimer</a>'; echo'</div>'; echo'</div>'; } ?> <label>Logo</label> <input type="file" name="logo" class="form-elem big"> <div class="form-legende"> Taille minimum: 150px de largeur et 150px de hauteur<br> Poid maximum : 2Mo<br> Format : jpg, jpeg, png </div> <?php if(!is_null($image1)){ echo'<div id="ajaxImage2">'; echo'<label>Image 1 actuelle</label>'; echo'<div class="form-image big">'; echo'<img src="'.BASEFRONT.'img/projet/tmp/'.$image1.'">'; echo'<br>'; echo'<a href="'.BASEADMIN.'projet/deleteImage.php?projet='.$projetId.'&image=image1" class="btn rouge sweetDeleteImage" data-parent="ajaxImage2"><i class="fa fa-trash"></i> Supprimer</a>'; echo'</div>'; echo'</div>'; } ?> <label>L'image 1</label> <input type="file" name="image1" class="form-elem big"> <div class="form-legende"> Taille minimum: 640px de largeur et 480px de hauteur<br> Poid maximum : 5Mo<br> Format : jpg, jpeg, png </div> <?php if(!is_null($image2)){ echo'<div id="ajaxImage3">'; echo'<label>Image 2 actuelle</label>'; echo'<div class="form-image big">'; echo'<img src="'.BASEFRONT.'img/projet/tmp/'.$image2.'">'; echo'<br>'; echo'<a href="'.BASEADMIN.'projet/deleteImage.php?projet='.$projetId.'&image=image2" class="btn rouge sweetDeleteImage" data-parent="ajaxImage3"><i class="fa fa-trash"></i> Supprimer</a>'; echo'</div>'; echo'</div>'; } ?> <label>L'image 2</label> <input type="file" name="image2" class="form-elem big"> <div class="form-legende"> Taille minimum: 640px de largeur et 480px de hauteur<br> Poid maximum : 5Mo<br> Format : jpg, jpeg, png </div> <?php if(!is_null($image3)){ echo'<div id="ajaxImage4">'; echo'<label>Image 3 actuelle</label>'; echo'<div class="form-image big">'; echo'<img src="'.BASEFRONT.'img/projet/tmp/'.$image3.'">'; echo'<br>'; echo'<a href="'.BASEADMIN.'projet/deleteImage.php?projet='.$projetId.'&image=image3" class="btn rouge sweetDeleteImage" data-parent="ajaxImage4"><i class="fa fa-trash"></i> Supprimer</a>'; echo'</div>'; echo'</div>'; } ?> <label>L'image 3</label> <input type="file" name="image3" class="form-elem big"> <div class="form-legende"> Taille minimum: 640px de largeur et 480px de hauteur<br> Poid maximum : 5Mo<br> Format : jpg, jpeg, png </div> <label>Résumé *</label> <textarea name="resume" class="form-elem form-count big"><?= $resume ?></textarea> <div class="form-legende"> nombre de caractères conseillées : <span data-count="80" class="form-legende-count">80</span> </div> <label>Description *</label> <textarea name="description" class="form-elem big wysiwyg"><?= $description ?></textarea><br> <label>Dirigeants *</label> <textarea name="dirigeant" class="form-elem big wysiwyg"><?= $dirigeant ?></textarea><br> <label>Activité / Savoir faire *</label> <textarea name="activite" class="form-elem big wysiwyg"><?= $activite ?></textarea><br> <label>Objectifs / Besoins</label> <textarea name="objectif" class="form-elem big wysiwyg"><?= $objectif ?></textarea><br> <label>Eléments complémentaires</label> <textarea name="complementaire" class="form-elem big wysiwyg"><?= $complementaire ?></textarea><br> <div class="form-checkbox"> <p><input type="checkbox" name="avant" <?= (isset($avant) && $avant) ? 'checked' : '' ?> > Mise en avant liste des projets</p> </div> <div class="form-checkbox"> <p><input type="checkbox" name="accueil" <?= (isset($accueil) && $accueil) ? 'checked' : '' ?> > Mise en avant sur la page d'accueil</p> </div> <div class="form-bloc"> <h3>Référencement</h3> <label>Meta title *</label> <input type="text" name="metaTitle" value="<?= $metaTitle ?>" class="form-elem form-count big"> <div class="form-legende"> nombre de caractères conseillées : <span data-count="70" class="form-legende-count">70</span> </div> <label>Meta description *</label> <input type="text" name="metaDescription" value="<?= $metaDescription ?>" class="form-elem form-count big"> <div class="form-legende"> nombre de caractères conseillées : <span data-count="150" class="form-legende-count">150</span> </div> </div> <br> <button name="edit" type="submit" class="form-submit turquoise medium">Enregistrer</button> </form> </div> </div> </main> <script type="text/javascript" src="<?= BASEFRONT ?>js/jquery/jquery.js"></script> <script type="text/javascript" src="<?= BASEFRONT ?>js/jquery/jquery-ui.js"></script> <script type="text/javascript" src="<?= BASEFRONT ?>js/datedropper/datedropper.min.js"></script> <script type="text/javascript" src="<?= BASEFRONT ?>js/scroll/scroll.js"></script> <script type="text/javascript" src="<?= BASEFRONT ?>js/tinymce/tinymce.min.js"></script> <script type="text/javascript" src="<?= BASEFRONT ?>js/sweet/sweet.js"></script> <script type="text/javascript" src="<?= BASEADMIN ?>js/app.js"></script> <script type="text/javascript"> tinymce.init({ selector: ".wysiwyg", entity_encoding : "raw", encoding: "UTF-8", browser_spellcheck : true, plugins: "link, paste, code ", height:"250px", menubar : false, paste_as_text: true, language : 'fr_FR', content_css : '<?= BASEFRONT ?>js/tinymce/tinymce.css', toolbar: "undo redo | bold italic underline | code" }); </script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings