芝麻web文件管理V1.00
编辑当前文件:/home/asmplong/www/sdfoiuhzufgh/admin/traitement_maj.php
prepare('INSERT INTO site_utilisateur(utilisateur_nom, utilisateur_mdp, utilisateur_statut, utilisateur_date) VALUES(:nom, :mdp, :statut, NOW())'); $req->execute(array( 'nom' => $newLogin, 'mdp' => $mdpHach, 'statut' => $_POST['statutCrea'])); $req->closeCursor(); log_utilisateur($eventCreaUtilisateur, '../'); } /* ------------------------------------------------------------------------ *\ \* ------------------------------ MAJ TABLE ------------------------------- */ if (isset($_POST['contenuModif'])) { $contenu = preg_replace('#(
#iU', '$1 alt="$3">', $contenu)); } if (isset($_POST['table']) AND $_POST['table'] != 'contact' AND $_POST['table'] != 'partenaire' AND isset($_POST['contenuModif'])) { $titre = addslashes($_POST['titre']); $nomCrea= $_SESSION['login']; $etat = $_POST['etat']; $nomModif = $_SESSION['login']; if (!isset($_POST['ordre'])) { $ordre = null; } else { $ordre = $_POST['ordre']; } if ($id == '0') // Création d'une nouvelle entrée { if ($table=='presentation') { $req1=$bdd->query('SELECT COUNT(*) AS nbrId FROM site_'. $table .''); $nbrId=$req1->fetch(); $nbrId=$nbrId['nbrId']+1; $req1->closeCursor(); } else { $nbrId = null; } $req2=$bdd->prepare('INSERT INTO site_'.$table.'('.$table.'_titre, '.$table.'_contenu, '.$table.'_ordre, '.$table.'_etat, '.$table.'_nom_createur, '.$table.'_date_creation) VALUES (:titre, :contenu, :ordre, :etat, :nom, NOW())'); $req2->execute(array( 'titre' => $titre, 'contenu' => $contenu, 'ordre' => $nbrId, 'etat' => $etat, 'nom' => $nomCrea)); $req3 = $bdd->query('SELECT site_'.$table.'_id FROM '.$table.' ORDER BY '.$table.'_id DESC LIMIT 0,1'); while ($result = $req3->fetch()) { $lastId=$result[$table.'_id']; } $req3->closeCursor(); $cheminDossier='../images/'.$table.'/'.$lastId; mkdir($cheminDossier); $eventMajBdd = 'Création de l\'id '.$lastId.' de la table '.$table.' (titre : '.$titre.')'; $req2->closeCursor(); } else // MAJ d'une entrée existante { $req4=$bdd->prepare('UPDATE site_'.$table.' SET '.$table.'_titre=:titre, '.$table.'_contenu=:contenu, '.$table.'_ordre=:ordre, '.$table.'_etat=:etat, '.$table.'_nom_modif=:nom, '.$table.'_date_modif=NOW() WHERE '.$table.'_id=:id'); $req4->execute(array( 'titre' => $titre, 'contenu' => $contenu, 'ordre' => $ordre, 'etat' => $etat, 'nom' => $nomModif, 'id' => $id)); $eventMajBdd = 'Maj de l\'id '.$id.' de la table '.$table.' (titre : '.$titre.')'; $req4->closeCursor(); } log_utilisateur($eventMajBdd, '../'); } /* ------------------------------------------------------------------------ *\ \* --------------------- MAJ DIRECTE DEPUIS LA LISTE ---------------------- */ if (isset($_GET['modif_directe'])) { $req5=$bdd->query('SELECT '.$table.'_id FROM site_'.$table.' ORDER BY '.$table.'_id DESC LIMIT 0,1'); $lastId = $req5->fetch(); $lastId = $lastId[$table.'_id']; $req5->closeCursor(); $liste_etat = $_POST['etat']; $liste_titre = $_POST['titre']; if ($table == 'presentation') { $liste_ordre = $_POST['ordre']; } else { $liste_ordre = null; } for ($i=1; $i <= $lastId; $i++) { if (isset($liste_etat[$i])) { $req6=$bdd->prepare('UPDATE site_'.$table.' SET '.$table.'_ordre=:ordre, '.$table.'_etat=:etat, '.$table.'_titre=:titre WHERE '.$table.'_id=:id'); $req6->execute(array( 'ordre' => $liste_ordre[$i], 'etat' => $liste_etat[$i], 'titre' => $liste_titre[$i], 'id' => $i)); $req6->closeCursor(); $eventMajDirecteBdd = 'Maj directe de la table '.$table; } } log_utilisateur($eventMajDirecteBdd, '../'); } /* ------------------------------------------------------------------------ *\ \* ------------------- MAJ TABLE CONTACT ET PARTENAIRE -------------------- */ if (isset($table) AND $table == 'contact' || $table == 'partenaire') { $req7=$bdd->prepare('UPDATE site_'.$table.' SET '.$table.'_contenu=:contenu, '.$table.'_date_modif=NOW() WHERE '.$table.'_id=:id'); $req7->execute(array( 'contenu' => $contenu, 'id' => $id)); $req7->closeCursor(); $eventMajContact = 'Maj de la table '.$table; log_utilisateur($eventMajContact, '../'); } /* ------------------------------------------------------------------------ *\ \* ----------------------------- UPLOAD PHOTO ----------------------------- */ if (isset($_FILES['photo'])) { $tailleFichier = $_POST['dimensionPhoto']; $sourceUpload = imagecreatefromjpeg($_FILES['photo']['tmp_name']); $largPhoto = $sourceUpload; $hautPhoto = $sourceUpload; if ($_FILES['photo']['error'] == FALSE) { if ($_FILES['photo']['size'] <= 1000000) // = 1 mo { $infosfichier=pathinfo($_FILES['photo']['name']); $extension_photo=strtolower($infosfichier['extension']); $extensions_autorisees = array('jpg', 'jpeg', 'gif', 'png'); // Extension autorisées if (in_array($extension_photo, $extensions_autorisees)) { $nom_photo = strtolower(strtr($_FILES['photo']['name'], 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy')); $nom_photo = str_replace(' ', '_', $nom_photo); $chemin_photo = '../images/'. $table .'/'. $id .'/'. $nom_photo; if (!file_exists($chemin_photo)) { /*move_uploaded_file($_FILES['photo']['tmp_name'], $chemin_photo);*/ if ($extension_photo == 'jpg' | $extension_photo == 'jpeg') { $source = imagecreatefromjpeg($_FILES['photo']['tmp_name']); } if ($extension_photo == 'png') { $source = imagecreatefrompng($_FILES['photo']['tmp_name']); } $largeur_source = imagesx($source); $hauteur_source = imagesy($source); if ($largeur_source > $hauteur_source){ // Photo paysage if ($tailleFichier == 'petit'){ $largeur_miniature = '300'; $hauteur_miniature = '200'; } if ($tailleFichier == 'moyen'){ $largeur_miniature = '450'; $hauteur_miniature = '300'; } if ($tailleFichier == 'grand'){ $largeur_miniature = '600'; $hauteur_miniature = '400'; } } else { // Photo portrait if ($tailleFichier == 'petit'){ $largeur_miniature = '133'; $hauteur_miniature = '200'; } if ($tailleFichier == 'moyen'){ $largeur_miniature = '200'; $hauteur_miniature = '300'; } if ($tailleFichier == 'grand'){ $largeur_miniature = '266'; $hauteur_miniature = '400'; } } $miniature = imagecreatetruecolor($largeur_miniature, $hauteur_miniature); // On crée la miniature imagecopyresampled($miniature, $source, 0, 0, 0, 0, $largeur_miniature, $hauteur_miniature, $largeur_source, $hauteur_source); // On enregistre la miniature sous le nom de la $destination imagejpeg($miniature, $chemin_photo); $eventUploadPhoto = 'Upload photo - Réussite : '.$chemin_photo; $_SESSION['alert'] = ''; } else { $eventUploadPhoto = 'Upload photo - Erreur : fichier '.$chemin_photo.' déjà existant'; $_SESSION['alert'] = 'Erreur : Un fichier portant le même nom existe déjà'; } } else { $eventUploadPhoto = 'Upload photo - Erreur : extension '.$extension_photo.' non autorisée'; $_SESSION['alert'] = 'Erreur : Merci de charger un fichier portant l\'une de ces extensions :'; foreach ($extensions_autorisees as $variable) { $_SESSION['alert'] .= ' '.$variable; } } } else { $tailleFichier = $_FILES['photo']['size']/1000000; $eventUploadPhoto = 'Upload photo - Erreur : taille du fichier dépasse la limite autorisée d\'1mo (taille du fichier : '.$tailleFichier.' mo)'; $_SESSION['alert'] = 'Erreur : La taille du fichier doit être inférieur à 1mo (votre fichier fait actuellement '.$tailleFichier.'mo)'; } } else { $eventUploadPhoto = 'Upload photo - Erreur : '.$_FILES['photo']['error'].'. Contacter l\'administrateur'; $_SESSION['alert'] = 'Erreur : '.$_FILES['photo']['error'].'. Merci de contacter l\'administrateur'; } addLogEvent($eventUploadPhoto, 'upload'); log_utilisateur($eventUploadPhoto, '../'); } /* ------------------------------------------------------------------------ *\ \* --------------------------- SUPPRESION PHOTO --------------------------- */ if (isset($_GET['url'])) { unlink($_GET['url']); $eventSupprPhoto = 'Suppression photo '.$_GET['url']; log_utilisateur($eventSupprPhoto, '../'); } /* ------------------------------------------------------------------------ *\ \* ---------------------- CREATION VIGNETTE ENCADRANT --------------------- */ if ((isset($_FILES['photoEncadrant'])) AND (isset($_POST['nomEncadrant']))) { $image_source = $_FILES['photoEncadrant']['tmp_name']; $infoPhoto = pathinfo($_FILES['photoEncadrant']['name']); $extensionPhoto = $infoPhoto['extension']; // On charge d'abord les images /* --------------REDIMENSIONNEMENT DES IMAGES-------------- */ /* On redimenssione la photo pour avoir une largeur de 90px */ if ($extensionPhoto == 'png') { $source = imagecreatefrompng($image_source); } if ($extensionPhoto == 'jpeg' | $extensionPhoto == 'jpg') { $source = imagecreatefromjpeg($image_source); } $destination = imagecreatetruecolor(99, 128); // On crée la miniature vide // Les fonctions imagesx et imagesy renvoient la largeur et la hauteur d'une image $largeur_source = imagesx($source); $hauteur_source = imagesy($source); $largeur_destination = imagesx($destination); $hauteur_destination = imagesy($destination); // On crée la miniature imagecopyresampled($destination, $source, 0, 0, 0, 0, $largeur_destination, $hauteur_destination, $largeur_source, $hauteur_source); /* ----------------SUPERPOSITION DES IMAGES---------------- */ function creaVignetteEncadrant ($source2, $destination2, $nom, $niveau, $id, $table, $domaine){ // Les fonctions imagesx et imagesy renvoient la largeur et la hauteur d'une image $largeur_source2 = imagesx($source2); $hauteur_source2 = imagesy($source2); $largeur_destination2 = imagesx($destination2); $hauteur_destination2 = imagesy($destination2); // On veut placer le logo en bas à droite, on calcule les coordonnées où on doit placer le logo sur la photo $destination2_x = 72; $destination2_y = 158 - $hauteur_source2; // On met le logo (source) dans la photo (destination) imagecopymerge($destination2, $source2, $destination2_x, $destination2_y, 0, 0, $largeur_source2, $hauteur_source2, 100); /* ----------------------AJOUT DU NOM---------------------- */ $bleu = imagecolorallocate($destination2, 42, 141, 222); $blanc = imagecolorallocate($destination2, 255, 255, 255); $noir = imagecolorallocate($destination2, 0, 0, 0); $police = "../css/police/SF_Cartoonist_Hand-webfont/SF_Cartoonist_Hand-webfont.ttf"; $taillePoliceNom = 18; $tailleBoiteNom = imagettfbbox($taillePoliceNom, 0, $police, $nom); $largeurTextNom = ceil(($largeur_destination2 - $tailleBoiteNom[2]) / 2); $hauteurTextNom = 25; $angleTextNom = 0; imagettftext($destination2, $taillePoliceNom, $angleTextNom, $largeurTextNom, $hauteurTextNom, $bleu, $police, $nom); $taillePoliceNiveau = 16; $angleTextNiveau = 25; $largeurTextNiveau = 78; $hauteurTextNiveau = 206; imagettftext($destination2, $taillePoliceNiveau, $angleTextNiveau, $largeurTextNiveau, $hauteurTextNiveau, $blanc, $police, $niveau); /* ---------------ENREGISTREMENT DE L'IMAGE---------------- */ // On enregistre l'image de destination qui a été fusionnée avec le logo $nomEnregistrement = strtolower(strtr($nom, 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy')); $nomEnregistrement = str_replace(' ', '_', $nomEnregistrement); $nomEnregistrement = $nomEnregistrement. imagejpeg($destination2, "../images/".$table."/".$id."/". $nomEnregistrement ."_".$domaine.".jpg"); } $source2 = $destination; // photo d'identité $nom = $_POST['nomEncadrant']; if ($_POST['niveauTech'] != '') { $destination2 = imagecreatefrompng("../images/masque_encadrant_tech.png"); $niveau = $_POST['niveauTech']; creaVignetteEncadrant ($source2, $destination2, $nom, $niveau, $id, $table, 'tech'); $eventCreaEncadrant = 'Pour '.$nom.' : création vignette niveau '.$niveau; } else { $eventCreaEncadrant = 'Pour '.$nom.' : Tech = N/A'; } if ($_POST['niveauBio'] != '') { $destination2 = imagecreatefrompng("../images/masque_encadrant_bio.png"); $niveau = $_POST['niveauBio']; creaVignetteEncadrant ($source2, $destination2, $nom, $niveau, $id, $table, 'bio'); $eventCreaEncadrant = $eventCreaEncadrant.' / création vignette niveau '.$niveau; } else { $eventCreaEncadrant = $eventCreaEncadrant.' / Bio = N/A'; } if ($_POST['niveauAud'] != '') { $destination2 = imagecreatefrompng("../images/masque_encadrant_audio.png"); $niveau = $_POST['niveauAud']; creaVignetteEncadrant ($source2, $destination2, $nom, $niveau, $id, $table, 'audio'); $eventCreaEncadrant = $eventCreaEncadrant.' / création vignette niveau '.$niveau; } else { $eventCreaEncadrant = $eventCreaEncadrant.' / Audio = N/A'; } if ($_POST['niveauMed'] != '') { $destination2 = imagecreatefrompng("../images/masque_encadrant_med.png"); $niveau = ''; creaVignetteEncadrant ($source2, $destination2, $nom, $niveau, $id, $table, 'med'); $eventCreaEncadrant = $eventCreaEncadrant.' / création vignette niveau Médical'; } else { $eventCreaEncadrant = $eventCreaEncadrant.' / Med = N/A'; } log_utilisateur($eventCreaEncadrant, '../'); } ?>