Exemplo n.º 1
0
<?php

require_once "./lib/config.php";
require_once "./lib/dbclass.php";
require_once "./lib/JSON.php";
$json = new Services_JSON();
$node = isset($_POST['node']) && $_POST['node'] != 0 ? $_POST['node'] : 0;
$sql = "select dir.*, user.user_name \n\t\tfrom `dir_data` dir, `user_data` user\n\t\twhere dir.dir_parent = " . $node . "\n\t\tand dir.dir_owner_id = user.user_id";
$db = new dbClass($db_username, $db_password, $db_database, $db_hostname);
$db->start();
$result = $db->query($sql);
while ($arr = $db->getarray($result)) {
    $qtip = '擁有者:' . $arr['user_name'] . "<br>\n\t\t\t 建立日期:" . $arr['dir_creat_time'];
    $nodes[] = array('text' => $arr['dir_name'], 'id' => $arr['dir_id'], 'qtip' => $qtip, 'cls' => 'folder');
}
echo $json->encode($nodes);
/*
// from php manual page
function formatBytes($val, $digits = 3, $mode = "SI", $bB = "B"){ //$mode == "SI"|"IEC", $bB == "b"|"B"
   $si = array("", "K", "M", "G", "T", "P", "E", "Z", "Y");
   $iec = array("", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi");
   switch(strtoupper($mode)) {
       case "SI" : $factor = 1000; $symbols = $si; break;
       case "IEC" : $factor = 1024; $symbols = $iec; break;
       default : $factor = 1000; $symbols = $si; break;
   }
   switch($bB) {
       case "b" : $val *= 8; break;
       default : $bB = "B"; break;
   }
   for($i=0;$i<count($symbols)-1 && $val>=$factor;$i++)