Location: PHPKode > projects > Wexplorer > weXplorer/tree.php
<?php
require_once('config.inc.php');

function hasChildDirs($parent){
	$d = dir($parent);
	while (false !== ($entry = $d->read())) {
		 if($entry !='.' && $entry !='..' && is_dir($parent.'/'.$entry))
		 	return true;
	}
	return false;
}

header('Connection: keep-alive');
header('Content-type: text/xml');
// FORCE RELOAD
	// Date in the past
	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
	// always modified
	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
	// HTTP/1.1
	header("Cache-Control: no-store, no-cache, must-revalidate");
	header("Cache-Control: post-check=0, pre-check=0", false);
	// HTTP/1.0
	header("Pragma: no-cache");

echo '<?xml version="1.0"?>';
echo '<tree>';

if(!isset($_GET['folder']))
	$_GET['folder'] = '.';
chdir(expandPath($_GET['folder']));
$d = dir(".");

$dirnames = array();
while (false !== ($entry = $d->read())) {
  if($entry !='.' && $entry !='..' && is_dir($entry)){
	$dirnames[] = $entry;
  }
}
sort($dirnames);
foreach ($dirnames as $entry) {
	$label = $entry;
	$foldername = $_GET['folder']."/".rawurlencode($entry);
  	$foldername = str_replace("//","/",$foldername);
	if(hasChildDirs($entry))
  		echo "\t<tree label=\"$label\" href='javascript:folderSelected(\"$foldername\");' src=\"".ROOT_URL."/tree.php?folder=$foldername\"/>\n";
  	else 
  		echo "\t<tree label=\"$label\" href='javascript:leafSelected(\"$foldername\");' />\n";
}
$d->close();
echo '</tree>';

?>
  
Return current item: Wexplorer