<?php 
#This script has been developed by Nenad Motika [nmotika@bezveze.com]
#Please feel free to use it and to contact me for any reason 

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header("Pragma: no-cache"); // HTTP/1.0

//read folder
$folder=opendir(".");
while (
$file readdir($folder)) {
  
$names[count($names)] = $file
}
closedir($folder);

//sort file names in array
sort($names);

//remove any non-images from array
$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++;
  }
}

//random
#srand((double) microtime() * 10000000);
$rand_keys array_rand($names12);

//random image from array
$slika=$names1[$rand_keys[0]];

//image dimensions
$dimensions GetImageSize($slika);

#if (isset($pic)) {
  
header('Content-type: image/'.strtolower(substr($slika,-3)));
  
header ("Location: $slika");
  exit;
#} else {
#  echo "<img src=\"$slika\" $dimensions[3]>";
#}
?>