<?php
/*******************************************************************************
* PHP AVATAR ROTATOR
* VERSION 2
*******************************************************************************/
$path = "/avatars/"; // Path to your avatar folder relative to the root directory of your site
/******************************************************************************
* DO NOT EDIT BELOW THIS LINE!
******************************************************************************/
$dir = $_SERVER['DOCUMENT_ROOT'].$path;
$avatars = array();
// Open avatar directory and read its contents into an array
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (filetype($dir.$file) == "file" && getimagesize($dir.$file)) {
array_push($avatars, $file);
}
}
closedir($dh);
}
}
// Create random avatar
$img = $dir.$avatars[rand(0, count($avatars)-1)];
$info = getimagesize($img);
if ($info[2] == 2)
header('Content-Type: image/jpeg');
elseif ($info[2] == 3)
header('Content-Type: image/png');
else
header('Content-Type: image/gif');
readfile($img);
?>