:String - Directory to be listed. :Int - Level of subdirectories to be listed. Default = 0 (no subdirectories) :String - Sort data on: 'name'(default), 'size', 'date' of 'type'. :Boolean - Reverse data (true or false(default)) $ld = new ListDir(, , ); $ld->getList(, ); $ld->displayXml(, ); getList:Array - Returns multidimensional array. array (0 => array ( 'name' => 'img', 'type' => 'dir', 'date' => 1234214523, 'list' => array ( 0 => array ( 'name' => 'image.jpg', 'type' => 'file', 'date' => 1233524541, 'size' => 12485 ))), 1 => array ( 'name' => 'index.html', 'type' => 'file', 'date' => 1234214523, 'size' => 245 )); etc... displayXml:Xml - returns xml headers and data. image.jpg index.html */ class ListDir { var $dir; var $level; var $sort_on = 'name'; var $reversed = false; var $list = array(); var $knowntypes = array("css", "doc", "exe", "flv", "gif", "html", "jpg", "mp3", "pdf", "php", "png", "ppt", "psd", "swf", "txt", "xls", "zip"); var $allowedtypes = array(); // -------------------------------- // CONSTRUCTOR // -------------------------------- function ListDir($dir, $level = 0, $types = array()) { $this->dir = $dir; $this->level = $level; $this->allowedtypes = $types; $this->list = $this->_list($dir, 0); } // -------------------------------- // LIST A DIREACTORY // -------------------------------- function _list($dir, $dlevel) { if(substr($dir, -1) != '/') $dir .= '/'; if(!is_dir($dir)) return "$dir is not a directory"; $dlevel++; if($this->level < $dlevel - 1) return array(); $list = array(); if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if($file == '.' || $file == '..') continue; $bestand = array(); $bestand['name'] = $file; $bestand['type'] = filetype($dir . $file); $bestand['date'] = filemtime($dir . $file); $bestand['path'] = $dir; if($bestand['type'] == 'file') { $bestand['size'] = filesize($dir . $file); $ext = pathinfo($file, PATHINFO_EXTENSION); $ext = strtolower($ext); if(in_array($ext, $this->knowntypes)) $bestand['type'] = $ext; if($ext == 'jpeg') $bestand['type'] = 'jpg'; if($bestand['type'] == 'jpg' || $bestand['type'] == 'gif' || $bestand['type'] == 'png'){ list($width, $height, $type, $attr) = getimagesize($dir . $file); $bestand['width'] = $width; $bestand['height'] = $height; } if($bestand['type'] == 'php' || $bestand['type'] == 'inc' || $bestand['type'] == 'mdu') continue; } if(!in_array($bestand['type'], $this->allowedtypes) && !empty($this->allowedtypes)) continue; if($bestand['type'] == 'dir') $bestand['list'] = $this->_list($dir . $file . '/', $dlevel); $list[] = $bestand; } closedir($dh); } return $list; } // -------------------------------- // GET DIRECTORY LIST // -------------------------------- function getList($sort_on = 'name', $reversed = false) { $this->sort_on = $sort_on; $this->reversed = $reversed; $this->_sortList($this->list); return $this->list; } // -------------------------------- // DISPLAY DIRECTORY LIST IN XML // -------------------------------- function displayXML($sort_on = 'name', $reversed = false) { $this->sort_on = $sort_on; $this->reversed = $reversed; $this->_sortList($this->list); header("Content-type: text/xml"); echo($this->_getXML()); exit(); } // -------------------------------- // CREATE XML STING // -------------------------------- function _getXML() { $dir_name = realpath($this->dir); $dir_name = substr( $dir_name, strlen($_SERVER['DOCUMENT_ROOT']) ); $xml = ""; $xml .= ''; $xml .= $this->_xmlDir($this->list); $xml .= ""; return $xml; } // -------------------------------- // XML DIRECTORY // -------------------------------- function _xmlDir(&$list) { $xml = ""; foreach($list as $nr => $file) { if($file['type'] == 'dir'){ $xml .= ""; $xml .= $this->_xmlDir($file['list']); $xml .= "\n"; }else{ $xml .= "\n"; } } return $xml; } // -------------------------------- // SORT DA LIST // -------------------------------- function _sortList(&$list) { usort($list, array('ListDir', 'compare')); // sort sub directories foreach($list as $nr => $file){ if($file['type'] == 'dir'){ $this->_sortList($list[$nr]['list']); } } } function compare($x, $y) { // altijd directories eerst, dan sorteren op $this->sort_on if ( $x['type'] == 'dir' && $y['type'] != 'dir'){ return -1; } elseif( $x['type'] != 'dir' && $y['type'] == 'dir'){ return 1; } else { if ( $x['name'] == $y['name'] ) return 0; return (strtolower($x['name']) < strtolower($y['name'])) ? -1 : 1; /* // $this bestaat niet??? if ( $x[$this->sort_on] == $y[$this->sort_on] ) return 0; elseif ( $x[$this->sort_on] < $y[$this->sort_on] ) return ($this->reversed)? 1:-1; else return ($this->reversed)? -1:1; */ } } } ?> In de mediaIl Senso - Italiaans Restaurant in Den Haag

In de media

IL SENSO ONTVANGT HOOGSTE WAARDERING VAN TOONAANGEVEND ITALIAANS GASTRONOMISCH INSTITUUT

ACADEMIA ITALIANA DELLA CUCINA: Hét Italiaanse instituut dat de gastronomische waarden, tradities en kwaliteit van de Italiaanse keuken en cultuur in den vreemde waarborgt, geeft il Senso de hoogste waardering van bezochte Italiaanse restaurants in Nederland, met een 8.1! Zie het uitgebreide verslag hier.

Nieuwsbrieven