<?
//Simple random image generator for use in an avatar or signature.
//Create a directory 'yournewdir' for the images, and drop this script in with the images.
//It will return a raw image when called. Use $maxsize to control image size.
//$where is the new directory path- '/yourpath/yournewdir/'
//Do not enter the whole URL in $where (NOT this part: 'http://yoursite.net') just the file path.
//To use in place of an image, avatar, or sig,
//substitute the URL of this file as the image link: ex "http://yoursite.net/yourpath/yournewdir/avatgen.php"
//For WrongPlanet enter the URL of this file as your avatar.
//If prescreened for image type (uncommon, not necessary for WrongPlanet) rename the file "avatgen.jpg"
// AND create a .htaccess file (Apache) in yournewdir: "AddType application/x-httpd-php .jpg"
//Free to use, modify, and share. Contact
[email protected]. Please retain these directions for others.
$where = '/yoursites/yournewdir';
$i = 0;
$maxsize=6144; //6kb limit
$photos=array();
$temp = opendir($where);
while (false !== ($file = readdir($temp))) {
if (($file != '.') and ($file !='..')){
$tag=strrchr($file,'.');
if (eregi("jpg|gif",$tag)) //check if image
if (filesize($file)<=$maxsize)
$photos[++$i]=$file;
}
}
closedir($temp);
if ($i != 0){ //if any matches
$which=rand(1, $i);
$av = $where.$photos[$which];
readfile($av);
}
else die('');
?>