<?
#################################
# configuration
#################################
if (!isset($_GET['c']))
{
$cols = 5;
}
else
{
$cols = $_GET['c'];
}
if (!isset($_GET['r']))
{
$rows = 5;
}
else
{
$rows = $_GET['r'];
}
if (!isset($_GET['p']))
{
$page = 1;
}
else
{
$page = $_GET['p'];
}
# on construit une query string a partir des parametre acceptes
$new_query = "&r=".$rows."&c=".$cols;
# le rep d'images ...
if (!isset($_GET['rep']))
{
$imagedir = "images/" ;
}
function isAfile($url)
{
$fp = @fopen("$url","r" );
if ($fp)
return 1;
return 0;
}
$rep=opendir($imagedir);
$out_table = "<table border='1'>";
$cnt = 0;
while ($nom=readdir($rep))
{
if (!ereg("^\.", $nom))
{
echo "<!--".$nom."-->\n";
if ( ($cnt < $page*$cols*$rows) && ($cnt >= ($page-1)*$cols*$rows) )
{
if (!isAfile('th/th_'.$nom))
{
$nom2="images/".$nom;
$handle = imagecreatefromjpeg($nom2);
$x=imagesx($handle);
$y=imagesy($handle);
$k=$x/100;
$y_dest=$y/$k;
$dst_img = imagecreatetruecolor(100,$y_dest);
imagecopyresampled($dst_img, $handle, 0, 0, 0, 0, 100, $y_dest,$x, $y);
imagejpeg($dst_img,"th/th_$nom", 60);
imagedestroy($handle);
imagedestroy($dst_img);
}
if ($cnt%$cols == 0)
{
$out_table .= "<tr>";
}
$out_table .= "<td><a href='".$imagedir.$nom."' target='photos'><img src='th/th_".$nom."'></a><br><small>".$imagedir.$nom."</small></td>";
if ($cnt%$cols == ($cols-1))
{
$out_table .= "</tr>";
}
}
$cnt++;
}
}
$out_table .= "</table>";
$tmp = "pages : ";
for ($i=1;$i<=ceil($cnt/($cols*$rows));$i++)
{
if ($page == $i)
{
$tmp .= " " . $i . " " ;
}
else
{
$tmp .= " <a href='?p=".$i.$new_query."'>".$i."</a> ";
}
}
echo "<center>" . $tmp . $out_table . $tmp . "</center>";
?>
|