<? //--------------------------------------- //folder config // whatfolder is the images in? $folderdir = "./img"; //---------------------------------------- //do not edit below this line $folder=opendir($folderdir); while ($file = readdir($folder)) $names[count($names)] = $file; closedir($folder); sort($names); $tempvar=0; for ($i=0;$names[$i];$i++){ $ext=strtolower(substr($names[$i],-4)); if ($ext==".jpg"||$ext==".gif"||$ext=="jpeg"||$ext==".png"){$names1[$tempvar]=$names[$i];$tempvar++;} } srand ((double) microtime() * 10000000); $rand_keys = array_rand ($names1, 2); $slika=$names1[$rand_keys[0]]; $customa = "$folderdir/$slika"; $ext=strtolower(substr($customa,-4)); $ext = str_replace(".", "", $ext); Header ("Content-type: image/$ext"); $imgsize = getimagesize($customa); $imgheight = round($imgsize[1]); $imgwidth = round($imgsize[0]); if ($ext=='png'){ $im =imagecreatefrompng("$customa"); imagepng($im); }else if ($ext=='gif'){ $im =imagecreatefromgif("$customa"); imagegif($im); }else if ($ext=='jpeg'||$ext=='jpg'){ $im =imagecreatefromjpeg("$customa"); imagejpeg($im); } ImageDestroy ($im); ?>