2 ) { // Use 2 instead of 0 to account for . and .. "directories" $php_file_tree = "" . htmlspecialchars($this_file) . ""; $php_file_tree .= php_file_tree_dir("$directory/$this_file", $return_link ,$extensions, false); $php_file_tree .= ""; } else { // File // Get extension (prepend 'ext-' to prevent invalid classes from extensions that begin with numbers) $ext = "ext-" . substr($this_file, strrpos($this_file, ".") + 1); $link = str_replace("[link]", "$directory/" . urlencode($this_file), $return_link); $lastModified = date('M d Y',filemtime($link)); $php_file_tree .= "
  • " . htmlspecialchars($this_file) . " ".$lastModified."
  • "; } } } $php_file_tree .= ""; } return $php_file_tree; } // For PHP4 compatibility function php4_scandir($dir) { $dh = opendir($dir); while( false !== ($filename = readdir($dh)) ) { $files[] = $filename; } sort($files); return($files); } // This links the user to http://example.com/?file=filename.ext //echo php_file_tree($_SERVER['DOCUMENT_ROOT'], "http://example.com/?file=[link]/"); // This links the user to http://example.com/?file=filename.ext and only shows image files $allowed_extensions = array("html"); echo php_file_tree("./", "[link]", $allowed_extensions); // This displays a JavaScript alert stating which file the user clicked on //echo php_file_tree("./", "javascript:alert('You clicked on [link]');"); footer(); ?>