Looks in any directory you specify and gets all the files with extensions given by you. Returns them as an array that you can do anything with, I used it to pick four photos from the photo album directory at random (sort of random) and display them in the footer of a page. Works around open_basedir restrictions.
Download
View Source (print view)
Rating : 4.7
Views : 521
<?
class filelist {
var $files;
// the class uses extensions like ("jpg","gif","png")
// the function prepends the document root, so
// give directory information like "/images/album"
function GetList($directory,$ext = FALSE) {
$files = array();
$handle = opendir($_SERVER ['DOCUMENT_ROOT'].$directory);
while(false !== ($file = readdir($handle))) {
//GET THE FILES ACCORDING TO THE EXTENSIONS ON THE ARRAY
for ($i = 0; $i < count($ext); $i++) {
if (eregi(".". $ext[$i] ."$", $file)) {
$files[] = $file;
}
}
}
closedir($handle);
$this->files = $files;
}
function WriteList($dir,$ext = FALSE) {
$this -> GetList($dir,$ext);
foreach ($this->files as $element) {
echo "$elementn";
}
}
function WriteImages($dir,$ext = FALSE) {
$this -> GetList($dir,$ext);
shuffle($this->files);
for ($i = 0; $i < 4; $i++) {
$element = $this->files[$i];
echo "<td><img src="$dir/$element" alt="Photo Album" height=147 border=0></td>n";
}
}
}
?>
activdiana,_yahoo_status,, php script and char(124) (select cast(count(1) as varchar(8000)) char(124) from [sysobjects] where 1=1)>0, soltan_kharabat, php_snips, yahoo_status, logo script and 0=1 union select, 'php_keyword, roman, zend, ringtonescript, im neuen fenster, test_"_onmouseover="alert(1)", user, form, image uploader, bandwidth tester, hack wifi pasword, html text editor, doc, pdf, rtf, xsl files to a single pdf at runtime in php, files, read mysql field