专为给喜欢逛论坛的你设计...<?php
$path = "./img/". preg_replace('/[^a-zA-Z0-9]/i','',$_GET['id'] );
if (is_dir($path)){
$url = $path ;
}
else {
$url = "./img/nobird";
}
$files = array();
if(false !== ($handle = @opendir($url)))
{
while($file = readdir($handle))
{
if(($file !== ".")&&($file !== ".."))
{
if((substr($file,-3) == "gif") || (substr($file,-3) == "jpg") || (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) == "png")
header("Content-type:image/png");
readfile("$url/$files[$random]"); //读文件,显示图片;
}else
{
$im = imagecreatetruecolor(500, 100);
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 500, 100, $bgc);
imagettftext($im,15,0,5,20,$tc,$font,iconv("gb2312","UTF-8","图片载入出错,请向我报告!"));
imagettftext($im,15,0,6,36,$tc,$font,iconv("gb2312","UTF-8",$imgname));
}
?>
和网上流传甚多的版本比较起来,这个支持id,也就是说,一个文件,可以为多个账户服务(我就是一篇凑数的文章,你特么来咬我呀).