3 ## FORMATTING FUNCTIONS
5 function sprintSize($bytes, $float=2) {
6 if (is_null($bytes)) return null;
7 $kb = round($bytes / 1024, $float);
8 $mb = round($bytes / 1024 / 1024, $float);
9 $gb = round($bytes / 1024 / 1024 / 1024, $float);
11 return ($bytes<1||$kb<1?$bytes.' B':($mb<1?$kb.' KB':($gb<1?$mb.' MB':$gb.' GB')));
14 function sprintTS($timestamp) {
15 return substr($timestamp,0,4).
16 '-'.substr($timestamp,4,2).
17 '-'.substr($timestamp,6,2).
18 ' '.substr($timestamp,8,2).
19 ':'.substr($timestamp,10,2).
20 ':'.substr($timestamp,12,2);
23 function printBar($percent, $txt1 = '', $txt2 = '') {
29 $percent = $percent/100;
31 } elseif (!is_integer($percent) && $percent<2) {
32 $percent = $percent*100;
33 } elseif ($percent == 1) {
36 $per1 = $per2 = floor($percent*100);
45 /* return '<table cellpadding=0 cellspacing=0 width="100%" class="bargraph">
47 <td class="bar" align="left" width="'.$per1.'"><div style="position: relative;"><div style="left: 0; display: inline; position: absolute;"> '.$txt1.' </div> </div></td>
48 <td class="fill" align="left" width="'.$per2.'"><div style="position: relative;"> <div style="right: 0; display: inline; position: absolute;">'.$txt2.' <em>'.$per1.'</em></div></div></td>
50 return '<table cellpadding=0 cellspacing=0 width="100%" class="bargraph">
52 <td class="bar" align="left" width="'.$per1.'"><div style="position: relative;"></div></td>
53 <td class="fill" align="right" width="'.$per2.'"><div style="position: relative;"></div></td>
55 </table><table cellpadding=0 cellspacing=0 width="100%">
56 <tr style="height: 1px;">
57 <td class="bar" align="left" width="50%"><div style="position: relative;"><div style="bottom: 3px; left: 5px; position: absolute;">'.$txt1.'</div></div></td>
58 <td class="fill" align="right" width="50%"><div style="position: relative;"><div style="bottom: 3px; right: 3px; position: absolute;">'.$txt2.' <em>'.$per1.'</em></div></div></td>