<?php
function getNomMiniature($img) { $tab = explode ("/", $img); $nomImg = array_pop($tab); $nomImg = "petit_".$nomImg; return $nomImg; }  function getRemoteUser() { $strVar = getValeurIni("remoteUser"); $user=''; eval("if (isset($strVar)) \$user=$strVar;" ); return $user; }  function getRepertoire($rep) { $tab = explode ("/", $rep); $nomRep = array_pop($tab); return $nomRep; }  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 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 = ""; if (file_exists('access/fotoweb.conf')) { $fcontents = file('access/fotoweb.conf'); 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) {  $originalSize = getimagesize("$sourcefile"); $originalWidth = $originalSize[0]; $originalHeight  = $originalSize[1]; $source_id = imageCreateFromJPEG("$sourcefile");  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);  ImageDestroy($imageObject);  return true; }  function arrayShuffle($array) { srand ((float)microtime()*1000000); shuffle($array);  return $array; }   function formateNumPage($numPageEnCours,$txt) { if ($numPageEnCours == $txt) { $str = "<b>[".$txt."]</b>"; } else { $str = "[".$txt."]"; } return $str; }   function checkIsMasterLogin() { $pwd = $_SESSION['SESS_PWD']; $login = $_SESSION['SESS_LOGIN'];  if ($pwd!="") {  $fcontents = file('access/.htpasswd'); while ( list( $numero_ligne, $ligne ) = each( $fcontents ) ) { $tab = explode (":", $ligne); $utilisateur = array_shift($tab); if ($utilisateur == $login) { $trouveUtilisateur = true; $password = trim(array_pop($tab)); if ($password == $pwd) { $trouvePwd = true; break; } } } if (isset($trouveUtilisateur)) if (isset($trouvePwd))  if ($login != getValeurIni("monLogin"))  return true;  else 	return false; else  return false;  } else return false;   }   function formatMess($mess) { $mess = base64_decode($mess);  return $mess; } function formatteMessage($tabMot) { $strResult = ""; $mot = array_shift($tabMot); while ($mot != null) { if (strlen($mot) > 30) { $mot1 = substr($mot,0,15); $mot2 = substr($mot,15,strlen($mot)); array_unshift($tabMot,$mot1,$mot2); } else { $strResult .= $mot . " "; } $mot = array_shift($tabMot); } return $strResult; }  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; } ?> 