<?php

// This is the directory where your images are.
$ad_dir '/home/virtual/site176/fst/var/www/html/mainwebsite_html/wordpress/wp-content/uploads/2009/02/girls';

// No need to change anything else

// Map file extensions to content-types
$ext = array();
$ext['gif'] = 'image/gif';
$ext['jpg'] = 'image/jpeg';
$ext['jpeg'] = 'image/jpeg';
$ext['png'] = 'image/png';


// Loop the ad folder, add any files found to an array
$ads = array();
if(
$handle opendir($ad_dir)) {
  while(
false !== ($file readdir($handle))) {
    if(
$file != "." && $file != "..") {
      
array_push($ads$file);
    }
  }
  
closedir($handle);
}

// Randomize the array
shuffle($ads);
$img "$ad_dir/$ads[0]";

// Get the content-type
$file_info pathinfo($img);
$content_type "Content-type: " .$ext[$file_info['extension']];

// Send the image data
header($content_type);
readfile($img);
?>