<?php
/*---------------------------------------------------------------/
/ 123RandomImage v0.0.1 /
/ Based on img.php by inso (
www.shi8.com) found at /
/ the phpbuilder.com code snippet library. /
/ /
/ Copyright (C) 2004 Somebody /
/ Email: microchips [at] gmail.com /
/----------------------------------------------------------------/
/ This program is free software; you can redistribute it and/or /
/ modify it under the terms of the GNU General Public License /
/ as published by the Free Software Foundation; either version 2 /
/ of the License, or (at your option) any later version. /
/ /
/ This program is distributed in the hope that it will be useful,/
/ but WITHOUT ANY WARRANTY; without even the implied warranty of /
/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
/ GNU General Public License for more details. /
/ /
/ You should have received a copy of the GNU General Public /
/ License along with this program; if not, write to the Free /
/ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,/
/ MA 02111-1307, USA. /
/---------------------------------------------------------------*/
//
// Configuration
// Change this to the pathname of the directory where the random images reside. If for example your page is at
//
www.website.com/random.php and all the random images are in the directory
www.website.com/random-imgs/ you
// should leave this as-is. All files with a .gif (boo UNISYS!), .jpg, .jpeg or .png extension in this directory
// will be added to the rotation
$path = './Sign/';
// That's all you need to configure! See
http://whcontrolpanel.sourceforge.net for information on calling it from
// webpage.
$files=array();
if ($handle=opendir("$path")) {
while(false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
substr($file,-3)=='gif';
substr($file,-3)=='jpg';
substr($file,-3)=='jpeg';
substr($file,-3)=='png';
$files[count($files)] = $file;
}
}
}
closedir($handle);
$random=rand(0,count($files)-1);
if(substr($files[$random],-3)=='gif') header("Content-type: image/gif");
elseif(substr($files[$random],-3)=='jpg') header("Content-type: image/jpeg");
elseif(substr($files[$random],-3)=='jpeg') header("Content-type: image/jpeg");
elseif(substr($files[$random],-3)=='png') header("Content-type: image/png");
readfile("$path/$files[$random]");
?>