<?php
  function getRepertoire($rep) { $tab = explode ("/", $rep); $nomRep = array_pop($tab); return $nomRep; }  function formatmess($mess) { $mess = base64_decode($mess);  return $mess; }  function getExtension($file) { $tab = explode (".", $file); $fichier = array_pop($tab); return $fichier; }  function getPathBaseApplication() { $path = realpath("../../index.php"); $result = substr($path,0,(strlen($path) - 9)); return $result; }   function formatterDateFromBase($dateBD) { $year	= substr($dateBD,0,4); $month= substr($dateBD,5,2); $day	= substr($dateBD,8,2); $now	= $day."/".$month."/".$year; return $now; }   function formatterDateTimeFromBase($dateBD) { $year	= substr($dateBD,0,4); $month= substr($dateBD,5,2); $day	= substr($dateBD,8,2); $heure= substr($dateBD,11,2); $min	= substr($dateBD,14,2); $now	= $day."/".$month."/".$year." à ".$heure.":".$min; return $now; }  function getNomMiniature($img) { $tab = explode ("/", $img); $nomImg = array_pop($tab); $nomImg = "petit_".$nomImg; return $nomImg; } function formatterDateToBase($dateIHM) { $day	= substr($dateIHM,0,2); $month= substr($dateIHM,3,2); $year	= substr($dateIHM,6,4); $now	= $year."-".$month."-".$day; return $now; } function formateNbPhotos($nb,$txt,$isAll) { if (($nb == $txt) && ($isAll != "all")) { $str = "<b>[".$txt."]</b>"; } else if (($nb == $txt) && ($isAll == "all")) { $str = "<b>[Toutes]</b>"; } else if (($nb != $txt) && ($isAll == "all")) { $str = "[Toutes]"; } else { $str = "[".$txt."]"; } return $str; }  function getValeurIni($cle) { $result = ""; $fichierConf = "../access/fotoweb.conf"; if (file_exists($fichierConf)) { $fcontents = file($fichierConf); while ( list( $numero_ligne, $ligne ) = each( $fcontents ) ) { $tab = explode (":", $ligne); $cleTab = array_shift($tab); if ($cleTab == $cle) { $result = trim(array_pop($tab)); break; } } if ($result == "") { $result = "<clé non trouvée>"; } } else { $result = "FICHIER D INITIALISATION NON TROUVE"; } return $result; } function getmicrotime()	{ list($usec, $sec) = explode(" ", microtime()); return ((float) $usec + (float) $sec); } function resizeToFile ($sourcefile,$targetfile,$panoramique ) {  $originalSize = getimagesize("$sourcefile"); $originalWidth = $originalSize[0]; $originalHeight  = $originalSize[1]; $source_id = imageCreateFromJPEG("$sourcefile");  if ($panoramique) { $destinationWidth = getValeurIni("thumbnailWidthPano"); $destinationHeight = getValeurIni("thumbnailHeightPano"); } else { if ($originalWidth > $originalHeight) { $destinationWidth = getValeurIni("thumbnailWidth"); $destinationHeight = getValeurIni("thumbnailHeight"); } else { $destinationWidth = getValeurIni("thumbnailHeight"); $destinationHeight = getValeurIni("thumbnailWidth"); } } $imageObject = imagecreatetruecolor($destinationWidth, $destinationHeight);  $target_pic = imagecopyresampled($imageObject,$source_id,0,0,0,0,$destinationWidth,$destinationHeight,$originalWidth,$originalHeight);  $jpegqual = getValeurIni("thumbnailQuality");  imagejpeg ($imageObject,"$targetfile",$jpegqual);  return true; }  function formateNumPage($numPageEnCours,$txt) { if ($numPageEnCours == $txt) { $str = "<b>[".$txt."]</b>"; } else { $str = "[".$txt."]"; } return $str; }   function get_IP() { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])){ $IP    = $_SERVER['HTTP_X_FORWARDED_FOR']; }  elseif(isset($_SERVER['HTTP_CLIENT_IP'])) { $IP    = $_SERVER['HTTP_CLIENT_IP']; }  else { $IP    = $_SERVER['REMOTE_ADDR']; }  return $IP; } function writeIndexPHP($rep) {  $rep=$rep."/index.php";  copy("index.php",$rep);   } ?> 