Skip to main content

more:
add_dir("."); $this->add_dir(".."); $this->add_dir("styles"); // $this->add_dir("images"); $this->add_dir("search"); $this->add_file("header.asp"); $this->add_file("footer.asp"); $this->add_file("favicon.ico"); } /** * this function adds a file name to the filter * so files with this name will not be displayed. */ function add_file($name) { $this->files_reg[]='/^'.$name.'$/'; } /** * adds a directory name to the filter so we are not * going to display directories with this name. */ function add_dir($name) { $this->dirs_reg[]='/^'.$name.'$/'; } /** * adds an extension to the filter. We are not going * to display files with this extension. * (ej. exe) */ function add_extension($name) { $this->files_reg[]='/^.*\.'.$name.'$/'; } /** * add a regular expression filter for files */ function add_file_reg($reg) { $this->files_reg[]=$reg; } /** * add a regular expression filter for directories */ function add_dir_reg($reg) { $this->dirs_reg[]=$reg; } /** * returns true if the filename or extension is in the filter */ function in_file_filter($name) { foreach($this->files_reg as $reg) { if (@preg_match($reg,$name)) return true; } return false; } /** * returns true if the name is in the directory filter */ function in_dir_filter($name) { foreach($this->dirs_reg as $reg) { if (@preg_match($reg,$name)) return true; } return false; } } class Dir { var $dirs; var $files; /** * class constructor. * inits the $dirs and $files arrays. */ function Dir($wd, $filter) { $cwd = getcwd(); if(!@chdir($wd)) return false; if(!($handle = @opendir("."))) return false; while ($file = readdir($handle)) { if(is_dir($file) && !$filter->in_dir_filter($file)) { $this->dirs[] = $file; } else if(is_file($file) && !$filter->in_file_filter($file)) { $this->files[] = $file; } } chdir($cwd); } /** * returns true if the current directory is empty * or false if it has files in it. */ function is_empty() { if(!is_array($this->dirs) && !is_array($this->files)) return true; return false; } /** * returns an array with the names of the directorys * contained in the current dir. */ function get_dirs() { if(is_array($this->dirs)) sort($this->dirs); return $this->dirs; } /** * retrurn an array with the names of the files * contained in the current dir. */ function get_files() { if(is_array($this->files)) sort($this->files); return $this->files; } } class maphp { var $empty_dirs; // display empty dirs? var $filter; function maphp($filter=null) { $this->show_empty_dirs(true); if(null==$filter) $this->set_filter(new filter()); } /** * if set to true maphp will display empty directories. * if we set it to false empty directories will not be * displayed on the list. */ function show_empty_dirs($bool) { $this->empty_dirs=$bool; } /** * set a filter for the current list */ function set_filter($filter) { $this->filter=$filter; } /** * Returns the path string in which non-alphanumeric characters except -_. * have been replaced with a percent (%) sign followed by two hex digits. */ function encode_path($path) { $tmp = explode("/",$path); for($i=0;$iencode_path($path); echo "
  • $cur
  • \n"; } } } /** * scan all directories on current path and * output html code. */ function scan_dirs($path,$adirs) { if(is_array($adirs)) { foreach($adirs as $cur) { /* * display empty directories only if * $this->empty_dirs is true. */ $d = new Dir("$path/$cur",$this->filter); if($d->is_empty() && !$this->empty_dirs) continue; $items = count($d->get_dirs()) + count($d->get_files()); $upath = $this->encode_path($path); echo "
  • \n"; echo "$cur\n"; echo "
      \n"; $this->scan("$cur","$path/$cur"); echo "
    \n"; echo "
  • \n"; } } } /** * scan the files and directories in the current path. * it calls the scan_dirs and scan_files functions. */ function scan($dir=".",$path=".") { $directory = new Dir($path,$this->filter); if(!$directory) return false; $adirs = $directory->get_dirs(); $afiles = $directory->get_files(); $this->scan_dirs($path,$adirs); $this->scan_files($path,$afiles); } /** * setup the html list and start scan. */ function run($path=".") { echo "
    "; echo "
      "; echo "
    • "; // output server name echo ""; echo $_SERVER['SERVER_NAME']; echo " "; echo "
        "; if (is_dir($path)) { $d = new Dir($path,$this->filter); if($d && !$d->is_empty()) $this->scan($path,$path); else echo "This directory is empty!"; } else { echo "Path does not exist!"; } echo "
      "; echo "
    • "; echo "
    "; echo "
    "; } } ?>

    HDRU Publications

    Search the HDRU Publications:         MORE>>
    stupid left side crap here add_dir($cwd); $filter->add_dir_reg("/^\..*$/"); $filter->add_extension("inc"); $filter->add_file_reg("/^\..*$/"); $filter->add_file_reg("/^.*~$/"); $linktarget = "_blank"; $explorer = new maphp(); $explorer->set_filter($filter); $explorer->run("./pubs"); ?>