<?php
/*
* gallerie.php
*
* Licence WTFPL http://sam.zoy.org/wtfpl/
*/
?>
<?php
// ici le chemin vers le dossier de photos
// ce dossier doit être accessible au serveur web
$folder = './photos';
// ici l'extension des photos
$extension = '.jpg';
?>
<?php
function ScanDirectory($Directory, $Extension)
{
$MyDirectory = opendir($Directory) or die('Erreur');
$photo_array = array();
while($Entry = @readdir($MyDirectory))
{
if (strstr($Entry, '.') == $Extension)
{
$photo_array[] = $Entry;
}
}
closedir($MyDirectory);
return $photo_array;
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<! ici le titre de la page >
<title>gallerie</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
<table title="Content" id="content" cellspacing=20>
<tr>
<?php
// récupération des fichiers
$photos = ScanDirectory($folder, $extension);
// parcour des fichiers et affichage dans le tableau
foreach ($photos as $photo)
{
echo '<td>';
echo "<img src = \"$folder/$photo\">";
echo '</td>';
}
?>
</tr>
</table>
</body>
</html>