1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| <body onLoad="rotate();">
<?php
$directory_name = "agenda/upload/";
$extensions_ok = array ( ".jpg","jpeg",".gif",".png");
$folder = opendir ($directory_name);
$i = 0;
$photos = array();
while ($file = readdir ($folder))
{
if (in_array(strtolower(substr($file, -4)),$extensions_ok))
$photos[] = $directory_name."/".$file;
}
closedir ($folder);
$count_photos = count ($photos);
?>
<script type="text/javascript">
var rotate_delay = 4000; // delais en microseconde (4000 = 4 secs)
var current = -1;
var photos = [<?php for($i=0;$i<$count_photos;$i++)
{
echo "\"".$photos[$i]."\"";
if($i!=$count_photos-1) echo ",";
}
?>];
function next() {
if (current<photos.length - 1)
++current;
else current = 0;
}
function rotate() {
if(photos.length > 0)
{
next();
document.images.slides.src = photos[current];
window.setTimeout("rotate()", rotate_delay);
}
}
</script> |
Partager