All pastes #223320 Raw Edit

Untitled

public text v1 · immutable
#223320 ·published 2006-10-26 21:24 UTC
rendered paste body
<?php 
//verify the folder exists and is readable
$folder=opendir("sigs"); 
while ($file = readdir($folder))
$names[count($names)] = $file; 
closedir($folder);
//place the file names into the array
sort($names);
//remove any non-images from array
$tempvar=0;
for ($i=0;$names[$i];$i++){
$ext=strtolower(substr($names[$i],-4));
if ($ext==".jpg"||$ext==".gif"||$ext=="jpeg"||$ext==".png"){$names1[$tempvar]=$names[$i];$tempvar++;}
}
//random script
srand ((double) microtime() * 10000000);
$rand_keys = array_rand ($names1, 2);
//random image from array
$image=$names1[$rand_keys[0]]; 
//Showing the image
header("Content-Type: image/png");
@readfile("sigs/$image");
?>