2 // from php manual page
\r
3 function formatBytes($val, $digits = 3, $mode = 'SI', $bB = 'B'){ //$mode == 'SI'|'IEC', $bB == 'b'|'B'
\r
4 $si = array('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y');
\r
5 $iec = array('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi');
\r
6 switch(strtoupper($mode)) {
\r
7 case 'SI' : $factor = 1000; $symbols = $si; break;
\r
8 case 'IEC' : $factor = 1024; $symbols = $iec; break;
\r
9 default : $factor = 1000; $symbols = $si; break;
\r
12 case 'b' : $val *= 8; break;
\r
13 default : $bB = 'B'; break;
\r
15 for($i=0;$i<count($symbols)-1 && $val>=$factor;$i++)
\r
17 $p = strpos($val, '.');
\r
18 if($p !== false && $p > $digits) $val = round($val);
\r
19 elseif($p !== false) $val = round($val, $digits-$p);
\r
20 return round($val, $digits) . ' ' . $symbols[$i] . $bB;
\r
23 // grab the custom params
\r
24 $path = isset($_REQUEST['path'])&&$_REQUEST['path'] == 'extjs' ? '../../../' : '../../';
\r
26 $node = isset($_REQUEST['node']) ? $_REQUEST['node'] : '';
\r
28 if(strpos($node, '..') !== false){
\r
29 die('Nice try buddy.');
\r
33 $directory = $path.$node;
\r
34 if (is_dir($directory)){
\r
35 $d = dir($directory);
\r
36 while($f = $d->read()){
\r
37 if($f == '.' || $f == '..' || substr($f, 0, 1) == '.') continue;
\r
39 $filename = $directory . '/' . $f;
\r
40 $lastmod = date('M j, Y, g:i a', filemtime($filename));
\r
42 if(is_dir($directory.'/'.$f)){
\r
43 $qtip = 'Type: Folder<br />Last Modified: '.$lastmod;
\r
46 'id' => $node.'/'.$f,
\r
51 $size = formatBytes(filesize($filename), 2);
\r
52 $qtip = 'Type: JavaScript File<br />Last Modified: '.$lastmod.'<br />Size: '.$size;
\r
55 'id' => $node.'/'.$f,
\r
58 //'qtipTitle' => $f,
\r
66 echo json_encode($nodes);