function random_image() { $date = getdate(); $path = "gfx/home/"; //matin 8 - 11 h if( $date[hours] > 7 && $date[hours] <= 11 ) $file="matin"; //journee 12 - 20 if($date[hours] >= 12 && $date[hours] <= 20) $file="jour"; //soir 21 - 7 if( ($date[hours] > 20 && $date[hours] <= 23) || ($date[hours] >= 0 && $date[hours] <= 7)) $file="soir"; $dir = opendir($path); $i=0; $files_tab = array(); while($f = readdir($dir)) { if(substr($f,0,strlen($file)) == $file) { $files_tab[$i] = $f; $i++; } } if(count($files_tab) > 1) $n = round(rand(0,count($files_tab)-1)); else $n = 0; if(count($files_tab) <= 0 || !$files_tab[$n] ) return "images/fd_home.jpg"; else return $path.$files_tab[$n]; } echo "
"; echo "
|