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 "