1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
| <?php
include ('../inc/connexion.php');
$id_langue = $_REQUEST['id_langue'];
$title_ref = $_REQUEST['title_ref'];
$descript = $_REQUEST['descript'];
$kyword = $_REQUEST['kyword'];
$alternativ_logo = $_REQUEST['alternativ_logo'];
$title_logo = $_REQUEST['title_logo'];
$titre_societe = $_REQUEST['titre_societe'];
$texte_societe = $_REQUEST['texte_societe'];
$alt_image_1 = $_REQUEST['alt_image_1'];
$title_image_1 = $_REQUEST['title_image_1'];
$alt_image_2 = $_REQUEST['alt_image_2'];
$title_image_2 = $_REQUEST['title_image_2'];
$lien_mentions = $_REQUEST['lien_mentions'];
$mentions = $_REQUEST['mentions'];
$lien_plan = $_REQUEST['lien_plan'];
$plan = $_REQUEST['plan'];
$lien_contact = $_REQUEST['lien_contact'];
$contact = $_REQUEST['contact'];
foreach($_REQUEST['upload'] as $term){
function redimenssioner_image($file, $w, $h){
list($width,$height) = getimagesize($file);
// si plus grand le paramètre ?
if($width >= $w || $height >= $h){
// si paysage
if($width >= $height){
$dst_w = $w;
$dst_h = ($w * $height)/$width;
// si après calcul height2 dépasse $h
if($dst_h >= $h){
$dst_w = ($width * $h)/$height;
$dst_h = $h;
}
}
// si portrait
else{
$dst_w = ($width * $h)/$height;
$dst_h = $h;
}
}
// sinon remet pareil
else{
$dst_w = $width;
$dst_h = $height;
}
// récupération de la taille
$size = @GetImageSize($file);
$src_w = $size[0];
$src_h = $size[1];
// redimensionnement de l'image (garde le ratio)
if($src_w < $dst_w && $src_h < $dst_h){
$dst_w = $src_w;
$dst_h = $src_h;
}
else @$dst_h = round(($dst_w / $src_w) * $src_h);
$dst_img = ImageCreateTrueColor($dst_w, $dst_h);
$src_img = ImageCreateFromJpeg($file);
// crée la copie redimensionnée
@ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
// --> jpg
@ImageJpeg($dst_img, $file,70);
// destruction des images temporaires
@ImageDestroy($dst_img);
@ImageDestroy($src_img);
}
function redim_coupe_image($img_src, $img_dest, $dst_w, $dst_h){
$size = GetImageSize($img_src);
$src_w = $size[0];
$src_h = $size[1];
$qualite = 90;
copy($img_src, $img_dest);
// si carré
if($src_w == $src_h){
$test_h = round(($dst_w / $src_w) * $src_h);
$test_w = round(($dst_h / $src_h) * $src_w);
// Si Height final non precise (0)
if(!$dst_h)$dst_h = $test_h;
// Sinon si Width final non precise (0)
elseif(!$dst_w)$dst_w = $test_w;
// Sinon teste quel redimensionnement tient dans la zone
elseif($test_h>$dst_h)$dst_w = $test_w;
else $dst_h = $test_h;
$dst_img = ImageCreateTrueColor($dst_w, $dst_h);
$src_img = ImageCreateFromJpeg($img_dest);
// crée la copie redimensionnée
@ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
@ImageJpeg($dst_img, $img_dest,$qualite);
@ImageDestroy($dst_img);
@ImageDestroy($src_img);
}
else{
// paysage
if($src_w > $src_h){
$dst_w_temp = round(($src_w * $dst_h) / $src_h);
$dst_h_temp = $dst_h;
// si après calcul, c'est pas assez, on refait...
if($dst_w_temp < $dst_w){
$dst_w_temp = $dst_w;
$dst_h_temp = floor(($dst_w * $src_h) / $src_w);
}
}
else{
// si portrait
$dst_w_temp = $dst_w;
$dst_h_temp = floor(($dst_w * $src_h) / $src_w);
// si après calcul, c'est pas assez, on refait...
if($dst_h_temp < $dst_h){
$dst_w_temp = round(($src_w * $dst_h) / $src_h);
$dst_h_temp = $dst_h;
}
}
$dst_img = ImageCreateTrueColor($dst_w_temp, $dst_h_temp);
$src_img = ImageCreateFromJpeg($img_dest);
@ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $dst_w_temp, $dst_h_temp, $src_w, $src_h);
@ImageJpeg($dst_img, $img_dest);
@ImageDestroy($dst_img);
@ImageDestroy($src_img);
// Lit les dimensions de l'image deja redim
$size = GetImageSize($img_dest);
$src_w = $size[0];
$src_h = $size[1];
$source = imagecreatefromjpeg($img_dest); // celle qui sera copiée
unlink($img_dest); //on detruit l'image temp
$dest_x = 0; // On colle l'image sur l'autre a 0 en abscisse
$dest_y = 0; // On colle l'image sur l'autre a 0 en ordonnee
$src_departx = ($src_w - $dst_w)/2; // on part de (largeur d'origine - largeur desire)/2 => Permet de centrer
$src_departy = ($src_h - $dst_h)/2; // on part de (hauteur d'origine - hauteur desire)/2 => Permet de centrer
$destination = imagecreatetruecolor($dst_w,$dst_h);// on creer une image de la taille du cadre à copier
//$src_departx = 0;
imagecopy($destination, $source, $dest_x, $dest_y, $src_departx, $src_departy, $dst_w, $dst_h);
imagejpeg($destination, $img_dest,$qualite);
}
}
$dossier_img = 'jpg/';
$resize_w = 450;
$resize_h = 180;
$resizeth_w = 40;
$resizeth_h = 40;
for($i=0; $i<count($_FILES['upload']['name']); $i++) {
//Get the temp file path
$tmpFilePath = $_FILES['upload']['tmp_name'][$i];
//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "./jpg/" . $_FILES['upload']['name'][$i];
$ex=explode (".",$_FILES['upload']['name']);
$c=count ($ex);
$exten=$ex[$c-1];
$image = substr($_FILES['upload']['name'],0,-4);
$image = nettoie_nom_fichier($image);
$image .= '.jpg';
$file = $dossier_img.$image;
echo $file;
move_uploaded_file($_FILES['upload']['tmp_name'],$file);
redimenssioner_image($file,$resize_w,$resize_h);
$file_th = $dossier_img.'th-'.$image;
redim_coupe_image($file,$file_th,$resizeth_w,$resizeth_h);
}
}
}
$requete='UPDATE accueilBDD SET title_ref = "'.$title_ref.'", descript = "'.$descript.'", kyword = "'.$kyword.'", alternativ_logo = "'.$alternativ_logo.'", title_logo = "'.$title_logo.'", titre_societe = "'.$titre_societe.'", texte_societe = "'.$texte_societe.'", alt_image_1 = "'.$alt_image_1.'", title_image_1 = "'.$title_image_1.'", alt_image_2 = "'.$alt_image_2.'", title_image_2 = "'.$title_image_2.'", lien_mentions = "'.$lien_mentions.'", mentions = "'.$mentions.'", lien_plan = "'.$lien_plan.'", plan = "'.$plan.'", lien_contact = "'.$lien_contact.'", contact = "'.$contact.'" WHERE id='.$id_langue;
mysqli_query($bdd, "SET NAMES UTF8");
$resultatsqli=mysqli_query($bdd, $requete) or die ('Erreur lors de la mise à jour: '.var_export($requete, true).' <br />'.mysqli_error($bdd));
?> |
Partager