8tH@?"; ?> ", $withinGroup=true) { $newArgument=charsTOHTML($argument); if($withinGroup) $formattedText=""; echo $formattedText; } //Récupération d'une fiche formatée (tableau ou liste énumérée) à partir //de plusieurs lignes séparées à l'intérieur function formatTechData($texte, $itemsSeparator, $inItemSeparator) { $items=explode($itemsSeparator, $texte); for($i=0;$i ".charsTOHTML($temp[1]); } return $formattedTechData; } ?>image s'il existe avec //1- Icone respective à l'extension //2- Lien pour ouverture (ouverture si plugin ou téléchargement) function insertFileLink($path, $target="_blank") { if(($fileToLink=searchFile($path))==FALSE) return ""; //Récupération de l'extension à partir du nom de fichier pour réccupérer l'icone if(($extension=strrchr($fileToLink,"."))!=FALSE) { $extension=substr($extension,1); } if ($extension!=FALSE) { $iconToInsert=searchFile($GLOBALS["data_img_dir"]."/icons/".$extension); } else { $iconToInsert=FALSE; } if($iconToInsert==FALSE) { if(isset($GLOBALS["default_upload_doc"])) { $iconToInsert=searchFile($GLOBALS["data_img_dir"]."/icons/".$GLOBALS["default_upload_doc"]); if($iconToInsert==FALSE) { $imgTag='Cliquer pour télécharger le document complet.'; } else { $imageSize=getimagesize($Site['homeDir'].$iconToInsert); $imgTag='Cliquer pour télécharger le document complet.'; } } else { $imgTag='Cliquer pour télécharger le document complet.'; } } else { $imageSize=getimagesize($Site['homeDir'].$iconToInsert); $imgTag='Cliquer pour télécharger le document complet.'; } return ''.$imgTag.''; } function clean_path($path) { if ( strlen($path) ) { $path = (substr($path,0,1) != "/")?"/".$path:$path; //vérifier si le home_dir est oui ou non associé avec le path if ( substr($path,0,strlen($GLOBALS['home_dir'])) == $GLOBALS['home_dir'] ) { //on l'enlève $path = substr($path,strlen($GLOBALS['home_dir']),strlen($path)-strlen($GLOBALS['home_dir'])); } return $path; } else return NULL; } //Effacer un fichier s'il existe function deleteFile($path) { global $Site; //Le fichier exsiste tel que fourni if(($foundFile=searchFile($path))!=FALSE) { unlink($Site['homeDir'].$foundFile); } } //Fonction obsolète, appelle deleteFile function deleteImage($path) { deleteFile($path); } //fonction obsolète : appele uploadFile function uploadImage($fileName, $fileTMP, $pathTo) { uploadFile($fileName, $fileTMP, $pathTo, "img"); } //Téléchargement des fichiers : //recherche de l'extension sur //1- $path fourni en argument //2- nom de fichier sur le client //3- Extension par défaut dans globals/def.inc.php // Ou pas d'extension function uploadFile($fileName, $fileTMP, $pathTo, $type="doc") { global $Site; deleteFile($pathTo); //recherche de l'extension dans la destination si l'extension est définie par défaut if(($extension=strrchr($pathTo,"."))==FALSE) { //recherche de l'extension dans le nom de fichier sur la machine du client if(($extension=strrchr($fileName,"."))==FALSE) { //Lecture de l'extension par défaut if(isset(${"default_upload_".$type})) { $extension=".".${"default_upload_".$type}; } } } else $pathTo=substr($pathTo, 0, strrpos($pathTo, ".")-1); move_uploaded_file($fileTMP, $Site['homeDir'].$pathTo.$extension); } //Rechercher le fichier sur $path : //1- Fichier existant tel quel //2- Extension non spécifiée : recherche de $path.(La première extension trouvée) //3- Fichier non trouvé function searchFile($path, $log=false) /*{ global $Site; $foundFile=FALSE; //inclure un slash pour indiquer à partir de la racine if(substr($path,0,1)!="/") $path="/".$path; //Obtention du nom de fichier et du nom de dossier $dirName=$Site["homeDir"].dirname($path); $fileName=basename($path); //Le fichier exsiste tel que fourni if(file_exists($dirName."/".$fileName)) { $foundFile=($path); } //Un seul cas d'echec pris en compte : fichier fourni sans extension : else { //echo "Fichier : ".$dirName."/".$fileName."non trouvé"; //Vérifier que le fichier est sans extension if(($extension=strrchr($path,".")==FALSE)) { $found=0; //Le dossier n'existe pas : if(is_dir($dirName)) { //Ouvrir un handle sur le dossier $handle=opendir($dirName); while (($file = readdir($handle)) && ($found==0)) { if($log) echo "
".$file; //Recherche du premier fichier dont le nom-l'extension=fichier à effacer if((strrpos($file,".")!=FALSE)&& ($fileName==substr($file,0,strrpos($file,".")))) { $foundFile=($path.strrchr($file,".")); $found=1; } } closedir($handle); } } } return $foundFile; }*/ { global $Site; $foundFile=FALSE; //inclure un slash pour indiquer à partir de la racine if(substr($path,0,1)!="/") $path="/".$path; //Obtention du nom de fichier et du nom de dossier $dirName=$Site["homeDir"].dirname($path); $fileName=basename($path); //Le fichier exsiste tel que fourni if(file_exists($dirName."/".$fileName)) { $foundFile=($path); } //Un seul cas d'echec pris en compte : fichier fourni sans extension : else { if($log) echo "

Fichier : ".$dirName."/".$fileName." non trouvé"; //Vérifier que le fichier est sans extension if($log) echo "
Début pour ".$path; $fileInfos = pathinfo($fileName); $fileExtension = $fileInfos['extension']; if(strlen($fileExtension)) $fileName = substr($fileName,0,strlen($fileName)-strlen($fileExtension)-1); //Le dossier n'existe pas : if(is_dir($dirName)) { $found=0; $dirHandle = dir($dirName); if($log) echo "
Ouverture du dossier ".$dirName; while (($fileHandle = $dirHandle->read())!==false && $found==0) { unset($fileInfos); if($log) echo "
Itteration ".$fileHandle; $fileInfos = pathinfo($fileHandle); $fileHandleExtension = $fileInfos['extension']; //echo "extension :".$fileHandleExtension." de longueur ".strlen($fileHandleExtension)." sur ".strlen($fileHandle); if(strlen($fileHandleExtension)) $fileHandle = substr($fileHandle,0,strlen($fileHandle)-strlen($fileHandleExtension)-1); //echo "
".$fileHandle." comparé à ".$fileName; if($fileName == $fileHandle) { $foundFile = $path.".".$fileHandleExtension; $found=1; } } $dirHandle->close(); if($log) echo "
Fin avec ".$foundFile.""; } } return $foundFile; } ?>"; } //echo $local_log ; if ($image_file_name) { $image_file_name = clean_path($image_file_name); call_user_func('imagejpeg', $image_to_send, $Site['homeDir'] . $image_file_name, $qualite); return $image_file_name; } else { header("MIME-Version: 1.0"); header("Content-Type: image/jpeg"); header("Content-Transfer-Encoding: 8bit"); call_user_func('imagejpeg', $image_to_send, NULL, $global_quality); } } function insertImage($path, $size, $operation, $optionnal_arguments = "", $atributes = "") { $imageInfos = array(); $imageInfos = howToInsertImage($path, $size, $operation, $optionnal_arguments, $atributes); return ''; } function howToInsertImage($path, $size, $operation, $optionnal_arguments = "", $atributes = "") { global $Site; $argumentsToSend = array(); //V�rification de l'existence du fichier image if (($foundFile = searchFile($path)) != FALSE) $imageToInsert = $foundFile; else $imageToInsert = $GLOBALS["default_image"]; //Determination de la taille de la fen�tre $imageSize = getimagesize($Site['homeDir'] . $imageToInsert); if (!$size) { $size = $imageSize[0] . "x" . $imageSize[1]; } $windowWidth = substr($size, 0, strpos($size, "x")); if (!$windowWidth) $windowWidth = $imageSize[0]; $windowHeight = substr($size, strpos($size, "x") + 1); if (!$windowHeight) $windowHeight = $imageSize[1]; //R�cup�ration des valeurs optionnelles en leur cr�ant des variables locales //D�composition de la chaine compl�te $argumentsArray = explode(" ", $optionnal_arguments); foreach ($argumentsArray as $option) { //effacement des balncs de chaque couple $option = trim($option); //D�composition du couple $option_elements = explode("=", $option); //cr�ation de la variable ${$option_elements[0]} = $option_elements[1]; } //Traitements � faire selon l'opr�tation demand�es if (!$operation) $operation = $GLOBALS["default_process"]; switch ($operation) { //Zoom case "zoom" : //V�rification du zoom if (!$zoom) $zoom = 100; $zoom = abs($zoom); //Multiplication par le facteur zoom $imageSize[0] = floor($imageSize[0] * $zoom / 100); $imageSize[1] = floor($imageSize[1] * $zoom / 100); $ImageHeight = $windowHeight; $ImageWidth = $windowWidth; $argumentsToSend[] = "zoom=" . $zoom; break; //Adaptation comme l'�tirement mais avec sauvegarde des proportions case "adapt" : //Ajustement si la taille de l'image est plus grande que la fen�tre if ($imageSize[0] != $windowWidth) { $imageSize[1] = floor($imageSize[1] * $windowWidth / $imageSize[0]); $imageSize[0] = $windowWidth; } if ($imageSize[1] > $windowHeight) { $imageSize[0] = floor($imageSize[0] * $windowHeight / $imageSize[1]); $imageSize[1] = $windowHeight; } $argumentsToSend[] = "strech=1"; $ImageWidth = $imageSize[0]; $ImageHeight = $imageSize[1]; break; //Etirement case "strech": //Nous fixons la taille de l'image � la taille de la fen�tre //Nous fixons la variable strech � 1 $argumentsToSend[] = "strech=1"; $ImageWidth = $windowWidth; $ImageHeight = $windowHeight; break; //Rien ! ! ! default : case "none" : //Rien n'est fait. $argumentsToSend[] = "zoom=100"; $ImageWidth = $windowWidth; $ImageHeight = $windowHeight; break; } //Nous fixons tout d�bordement � l'int�rieur de la fen�tre //Si l'image est plus petite alors c'est ok //Sinon tronquer voir l'alignement si possible //Si les dimensions sont diff�rentes de celles de la fen�tre alors on appele le script: if ($background_color) $argumentsToSend[] = "background_color=" . $background_color; if ($halign) $argumentsToSend[] = "halign=" . $halign; if ($valign) $argumentsToSend[] = "valign=" . $valign; if ($imageToInsert != $default && ($windowWidth != $imageSize[0] || $windowHeight != $imageSize[1])) { //$imageToInsert = $Site['baseUrl']."/js/images.php?source=".$imageToInsert."&width=".$ImageWidth."&height=".$ImageHeight; $imageToInsert = $Site['baseUrl']."/js/timthumb.php?src=" . $imageToInsert . "&w=" . $ImageWidth . "&h=" . $ImageHeight; if (count($argumentsToSend)) { $argumentsString = join("&", $argumentsToSend); $imageToInsert .= "&" . $argumentsString; } //echo $optionnal_arguments; } elseif ($windowWidth == $imageSize[0] && $windowHeight == $imageSize[1]) { $imageToInsert = $Site['baseUrl'] . $imageToInsert; } return array($imageToInsert, $ImageWidth, $ImageHeight, $atributes); } function processImage($width, $height, $image_source, $optionnal_arguments) { global $Site, $global_quality; define("UNKNOWN", "0"); //R�cup�ration des valeurs optionnelles en leur cr�ant des variables locales //D�composition de la chaine compl�te $argumentsArray = explode(" ", $optionnal_arguments); foreach ($argumentsArray as $option) { //effacement des balncs de chaque couple $option = trim($option); //D�composition du couple $option_elements = explode("=", $option); //cr�ation de la variable ${$option_elements[0]} = $option_elements[1]; } //Positionnement de certaines variable if (!isset($quality)) $quality = $global_quality; if (isset($zoom)) { if ($zoom == 0) unset($zoom); $zoom = abs($zoom); } //Variable de positionnement de l'image dans la fen�tre : if (!isset($valign)) $valign = $GLOBALS["valign"]; if (!isset($halign)) $halign = $GLOBALS["halign"]; //Couleur de fond ? if (!isset($background_color)) $background_color = $GLOBALS["default_bg"]; //Cr�ation de l'image � envoyer $image_to_send = creerImage($width, $height); //R�cup�ration des composantes de la couleur de fond $background_color_integer = hexdec($background_color); //remplissage avec la couleur imagefill($image_to_send, 0, 0, $background_color_integer); //R�cup�ration de l'image source $image_path = searchFile($image_source); //Obtention des infos $image_info = getimagesize($Site['homeDir'] . $image_path); switch ($image_info[2]) { case "1" : $image_type = $function_suffix = "GIF"; break; case "2" : $image_type = "JPG"; $function_suffix = "JPEG"; break; case "3" : $image_type = $function_suffix = "PNG"; break; case "4" : $image_type = $function_suffix = "UNKNOWN"; break; case "5" : $image_type = $function_suffix = "PSD"; break; case "6" : $image_type = $function_suffix = "BMP"; break; case "7" : case "8" : $image_type = $function_suffix = "TIFF"; break; case "9" : $image_type = $function_suffix = "JPC"; break; case "10" : $image_type = $function_suffix = "JP2"; break; case "11" : $image_type = $function_suffix = "JPX"; break; case "12" : $image_type = $function_suffix = "JB2"; break; case "13" : $image_type = $function_suffix = "SWC"; break; case "14" : $image_type = $function_suffix = "IFF"; break; default : $image_type = "UNKNOWN"; } if (function_exists('imagecreatefrom' . strtolower($function_suffix))) { $image = call_user_func('imagecreatefrom' . strtolower($function_suffix), $Site['homeDir'] . $image_path); if ($function_suffix == "PNG" || $function_suffix = "GIF") imagecolortransparent($image_to_send, $background_color_integer); } else { $image = creerImage($image_info[0], $image_info[1]); imagestring($image, 1, 0, 0, "No imagecreatefrom" . strtolower); } if ($image) { imagealphablending($image, true); $xFromPos = 0; $yFromPos = 0; //Si adaptation if ($strech) { //d�sactiver le zoom unset($zoom); //R�cup�ration de l'image ouverte dans une variable temporaire $tmp_image = creerImage($width, $height); imagefill($tmp_image, 0, 0, $background_color_integer); imagecolortransparent($tmp_image, $background_color_integer); imagealphablending($tmp_image, false); imagesavealpha($tmp_image, true); imagecopyresampled($tmp_image, $image, 0, 0, 0, 0, $width, $height, $image_info[0], $image_info[1]); //Destruction et recr�ation de l'image dans la bonne taille /* unset($image); $image = creerImage ($width, $height); imagefill ($image, 0, 0, $background_color_integer); imagealphablending($image,false); imagesavealpha($image,true); imagecolortransparent($image, $background_color_integer); //Copie et r�echantillonage de l'image depuis le contenu original vers le contenu adapt� imagecopyresampled($image, $tmp_image, 0, 0, 0, 0, $width, $height, $image_info[0], $image_info[1]); //destruction de l'image temporaire et ajustement des tailles de l'image unset($tmp_image); */ $image_info[0] = $width; $image_info[1] = $height; } if (isset($zoom)) { //Calcul de la nouvelle taille $zoomedWidth = max(floor($image_info[0] * $zoom / 100), 1); $zoomedHeight = max(floor($image_info[1] * $zoom / 100), 1); //R�cup�ration de l'image ouverte dans une variable temporaire $tmp_image = creerImage($zoomedWidth, $zoomedHeight); imagefill($tmp_image, 0, 0, $background_color_integer); imagecolortransparent($tmp_image, $background_color_integer); imagealphablending($tmp_image, false); imagesavealpha($tmp_image, true); imagecopyresampled($tmp_image, $image, 0, 0, 0, 0, $zoomedWidth, $zoomedHeight, $image_info[0], $image_info[1]); //Destruction et recr�ation de l'image dans la bonne taille /* unset($image); $image = creerImage ($zoomedWidth, $zoomedHeight); /*imagefill ($image, 0, 0, $background_color_integer); imagecolortransparent($image, $background_color_integer); //Copie et r�echantillonage de l'image depuis le contenu original vers le contenu adapt� imagecopyresampled($image, $tmp_image, 0, 0, 0, 0, $zoomedWidth, $zoomedHeight, $image_info[0], $image_info[1]); //destruction de l'image temporaire et ajustement des tailles de l'image unset($tmp_image); */ $image_info[0] = $zoomedWidth; $image_info[1] = $zoomedHeight; switch ($valign) { default : case "top" : break; case "middle": $yDecal = floor(($zoomedHeight - $height) / 2); break; case "bottom": $yDecal = ($zoomedHeight - 1) - $height; break; } switch ($halign) { default : case "left" : break; case "center": $xDecal = floor(($zoomedWidth - $width) / 2); break; case "right": $xDecal = ($zoomedWidth - 1) - $width; break; } //Qui est plus petit ? if ($zoomedWidth > $width) $xFromPos = $xDecal; else $xToPos = abs($xDecal); if ($zoomedHeight > $height) $yFromPos = $yDecal; else $yToPos = abs($yDecal); } imagealphablending($tmp_image, true); imagealphablending($image_to_send, false); imagesavealpha($image_to_send, true); //Copie de l'image trait�e vers l'image finale imagecopy($image_to_send, $tmp_image, $xToPos, $yToPos, $xFromPos, $yFromPos, $image_info[0], $image_info[1]); } //echo $local_log ; if ($image_file_name) { $image_file_name = clean_path($image_file_name); call_user_func('imagejpeg', $image_to_send, $Site['homeDir'] . $image_file_name, $quality); return $image_file_name; } else { header("MIME-Version: 1.0"); header("Content-Type: " . $image_info["mime"]); header("Content-Transfer-Encoding: 8bit"); call_user_func('image' . strtolower($function_suffix), $image_to_send); } } ?>