<?php
$ishome=""; // Pour le script : pas touche :)
if(@empty($idalbum)){$idalbum="0";}
echo "<center><font size='8' color='$GrosTitrecoul'>$GrosTitre</font></center>";
echo "
<br /><br /><center>
<table border='0'>
<tr>
";
$counter=$columns;
$nbfiles = 0;
$currfile = "";
$filestab[0] = "";
$handle=opendir($Photos);
if (! is_dir($thumb_dir))
{
mkdir($thumb_dir, 0777);
}
if (! is_dir($desc_dir))
{
mkdir($desc_dir, 0777);
}
@define('UPPATHPHOTOS','photos/');
for ($i=0; $currfile = readdir($handle);$i++)
{
$Tofs[$i] = $currfile;
}
sort($Tofs);
for ($i=0; isset($Tofs[$i]); $i++)
{
$Tof = $Tofs[$i];
$currfile = "$Photos$Tof";
// We get the extension of the current file and keep only image files
$extension= strtolower(substr( strrchr( $currfile, "." ), 1 ));
if ($extension== "gif" || $extension== "jpg" || $extension== "jpeg" || $extension== "png")
{
$nbfiles++;
$currfile = trim($currfile);
$filestab[$nbfiles] = $currfile;
if ($ishome == "")
{
$size = GetImageSize($currfile);
$rtioh = $size[0] / $Hdim;
$rtiol = $size[1] / $Ldim;
if ($rtioh > $rtiol) {
$rtiog = $rtioh;
}
else {
$rtiog = $rtiol;
}
$dimH = $size[0] / $rtiog;
$dimL = $size[1] / $rtiog;
$width = $dimH;
$height = $dimL;
$format = $size[2]; //1 = GIF, 2 = JPG, 3 = PNG, 5 = PSD, 6 = BMP
$currthumbfile = $thumb_dir . "/" . $thumb_prefix . $Tof;
if (! file_exists($currthumbfile))
{
//Chemin des images
//Augmente la limite de mémoire pour les grosses images
ini_set ( "memory_limit", "20M");
//Taille de l'image
$img_size = getimagesize($currfile);
//On stocke les données sur le fichier
$file = array(
'hauteur' => $img_size[1],
'largeur' => $img_size[0]
);
//Nouvelle taille de limage
$width_handler = $file['largeur'] - $Ldim;
$height_handler = $file['hauteur'] - $Hdim;
$size_handler = ($width_handler > $height_handler) ? $file['largeur'] : $file['hauteur'];
$max_handler = ($width_handler > $height_handler) ? $Ldim : $Hdim;
$new_width = ($file['largeur'] / $size_handler) * $max_handler;
$new_height = ($file['hauteur'] / $size_handler) * $max_handler;
// Type d'image
switch ($extension)
{
case 'jpg' : $open = 'imagecreatefromjpeg';
$write = 'imagejpeg';
break;
case 'jpeg' : $open = 'imagecreatefromjpeg';
$write = 'imagejpeg';
break;
case 'bmp' : $open = 'imagecreatefromwbmp';
$write = 'imagewbmp';
break;
case 'png' : $open = 'imagecreatefrompng';
$write = 'imagepng';
break;
case 'gif' : $open = 'imagecreatefromgif';
$write = 'imagegif';
break;
default : message('Erreur Fatale');
break;
}
$dest_file = $currthumbfile;
$src_w = $file['largeur'];
$src_h = $file['hauteur'];
$dst_im = ImageCreateTrueColor($new_width,$new_height);
$src_im = $open($currfile);
ImageCopyResampled($dst_im,$src_im,0,0,0,0,$new_width,$new_height,$src_w,$src_h);
$write($dst_im,$dest_file);
ImageDestroy($dst_im);
}
$currfile = str_replace(" ","%20",$currfile); // Allow filenames with space characters
$currfile = str_replace("é","%E9",$currfile); // Allow filenames with space characters
$currfile = str_replace("è","%E8",$currfile); // Allow filenames with space characters
$currfile = str_replace("à","%E0",$currfile); // Allow filenames with space characters
// $currfile = str_replace("ë","%EB",$currfile); // Allow filenames with space characters
// $currfile = str_replace("ï","%EF",$currfile); // Allow filenames with space characters
$currthumbfile = str_replace(" ","%20",$currthumbfile); // Allow filenames with space characters
$currthumbfile = str_replace("é","%E9",$currthumbfile); // Allow filenames with space characters
$currthumbfile = str_replace("è","%E8",$currthumbfile); // Allow filenames with space characters
$currthumbfile = str_replace("à","%E0",$currthumbfile); // Allow filenames with space characters
// $currthumbfile = str_replace("ë","%EB",$currthumbfile); // Allow filenames with space characters
// $currthumbfile = str_replace("ï","%EF",$currthumbfile); // Allow filenames with space characters
?>
<td valign='top'>
<a class="smoothbox" rel="galerie<?php echo $idalbum;?>" href="<?php echo $currfile; ?>" target="_blank" style="border:0;" title="<?php echo $Tof; ?>">
<img border="0" src="<?php echo $currthumbfile; ?>" width="<?php echo "$width";?>" height="<?php echo "$height";?>"<?php
$currfile = str_replace("%20"," ",$currfile); // Clean display of filenames with space characters
$currfile = str_replace("%E9","é",$currfile); // Clean display of filenames with space characters
$currfile = str_replace("%E8","è",$currfile); // Clean display of filenames with space characters
$currfile = str_replace("%E0","à",$currfile); // Clean display of filenames with space characters
// $currfile = str_replace("%EB","ë",$currfile); // Clean display of filenames with space characters
// $currfile = str_replace("%EF","ï",$currfile); // Clean display of filenames with space characters
echo " alt=\"Agrandir $currfile\" />
</a>
<br />";
echo "<font color=\"$txtcoul\" size=\"-1\"><b>";
if ($Fichier == 1) {
echo "Fichier : ".$Tof."<br />";
}
if ($Taille == 1) {
$filesize = filesize($currfile);
echo "Taille : ";
echo floor($filesize / 1024);
echo "Ko<br />";
}
if ($Descri == 1) {
echo "Longueur : $size[0]<br />Hauteur : $size[1]<br />";
}
if (! is_file($desc_dir . "/" . $Tof.".txt"))
{
$inF = fopen($desc_dir . "/" . $Tof.".txt","w");
fclose($inF);
}
$inF = fopen($desc_dir . "/" . $Tof.".txt","r");
$ptr = ftell($inF);
$donnees = fgets($inF,255);
fclose($inF);
if($donnees != "")
{
echo "Description : </b>";
include $desc_dir . "/" . $Tof.".txt";
}
else
{
echo "</b>";
}
echo "</font>";
$currfile = str_replace(" ","%20",$currfile); //Clean display of filenames with space characters
$currfile = str_replace("é","%E9",$currfile); //Clean display of filenames with space characters
$currfile = str_replace("è","%E8",$currfile); //Clean display of filenames with space characters
$currfile = str_replace("à","%E0",$currfile); //Clean display of filenames with space characters
// $currfile = str_replace("ë","%EB",$currfile); //Clean display of filenames with space characters
// $currfile = str_replace("ï","%EF",$currfile); //Clean display of filenames with space characters
echo "</td>";
$counter--;
if ($counter == 0)
{
$counter = $columns;
echo "</tr><tr>";
}
}
}
}
closedir($handle);
if ($counter == $columns)
{
echo "<td> </td>";
}
?>
</tr>
</table></center>
|