2 // from php manual page
3 function formatBytes($val, $digits = 3, $mode = 'SI', $bB = 'B'){ //$mode == 'SI'|'IEC', $bB == 'b'|'B'
4 $si = array('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y');
5 $iec = array('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi');
6 switch(strtoupper($mode)) {
7 case 'SI' : $factor = 1000; $symbols = $si; break;
8 case 'IEC' : $factor = 1024; $symbols = $iec; break;
9 default : $factor = 1000; $symbols = $si; break;
12 case 'b' : $val *= 8; break;
13 default : $bB = 'B'; break;
15 for($i=0;$i<count($symbols)-1 && $val>=$factor;$i++)
17 $p = strpos($val, '.');
18 if($p !== false && $p > $digits) $val = round($val);
19 elseif($p !== false) $val = round($val, $digits-$p);
20 return round($val, $digits) . ' ' . $symbols[$i] . $bB;
23 // grab the custom params
24 $path = isset($_REQUEST['path'])&&$_REQUEST['path'] == 'extjs' ? '../../../' : '../../';
26 $node = isset($_REQUEST['node']) ? $_REQUEST['node'] : '';
27 $isXml = isset($_REQUEST['isXml']);
29 if(strpos($node, '..') !== false){
30 die('Nice try buddy.');
34 $directory = $path.$node;
35 if (is_dir($directory)){
37 while($f = $d->read()){
38 if($f == '.' || $f == '..' || substr($f, 0, 1) == '.') continue;
40 $filename = $directory . '/' . $f;
41 date_default_timezone_set('America/Los_Angeles');
42 $lastmod = date('M j, Y, g:i a', filemtime($filename));
44 if(is_dir($directory.'/'.$f)){
45 $qtip = 'Type: Folder<br />Last Modified: '.$lastmod;
52 $size = formatBytes(filesize($filename), 2);
53 $qtip = 'Type: JavaScript File<br />Last Modified: '.$lastmod.'<br />Size: '.$size;
66 $xmlDoc = new DOMDocument();
67 $root = $xmlDoc->appendChild($xmlDoc->createElement("nodes"));
68 foreach ($nodes as $node) {
69 $xmlNode = $root->appendChild($xmlDoc->createElement("node"));
70 $xmlNode->appendChild($xmlDoc->createElement("text", $node['text']));
71 $xmlNode->appendChild($xmlDoc->createElement("id", $node['id']));
72 $xmlNode->appendChild($xmlDoc->createElement("cls", $node['cls']));
73 $xmlNode->appendChild($xmlDoc->createElement("leaf", isset($node['leaf'])));
75 header("Content-Type: text/xml");
76 $xmlDoc->formatOutput = true;
77 echo $xmlDoc->saveXml();
79 echo json_encode($nodes);