25-02-2010, 22:29 | #1 |
Absinthe
Join Date: Jan 2007
Location: Chester
Posts: 2,345
|
PHP Random Image Script
Code:
<?php $fileList = array(); $folder = "."; $handle = opendir($folder); while ( false !== ( $file = readdir($handle) ) ) { if ( substr($file, -4) == ".gif" || substr($file, -4) == ".jpg" ) { $fileList[count($fileList)] = $file; } } closedir($handle); $randNum = rand( 0, (sizeOf($fileList) -1) ); if ( substr($fileList[$randNum], -4) == ".gif" ) { header ("Content-type: image/gif"); } elseif ( substr($fileList[$randNum], -4) == ".jpg" ) { header ("Content-type: image/jpeg"); } readfile($fileList[$randNum]); ?> http://www.shuwarriors.net I'm no programmer so don't know enough about php - is there a way to limit the amount of times 1 image can be posted - or some other kind of fix? thanks. |