6 ## FORMATTING FUNCTIONS
8 function sprintSize($bytes, $float=2) {
9 if (is_null($bytes)) return null;
10 $kb = round($bytes / 1024, $float);
11 $mb = round($bytes / 1024 / 1024, $float);
12 $gb = round($bytes / 1024 / 1024 / 1024, $float);
14 return ($bytes<1||$kb<1?$bytes.' B':($mb<1?$kb.' KB':($gb<1?$mb.' MB':$gb.' GB')));
17 function sprintTS($timestamp) {
18 return substr($timestamp,0,4).
19 '-'.substr($timestamp,4,2).
20 '-'.substr($timestamp,6,2).
21 ' '.substr($timestamp,8,2).
22 ':'.substr($timestamp,10,2).
23 ':'.substr($timestamp,12,2);
26 function printBar($percent, $txt1 = '', $txt2 = '') {
32 $percent = $percent/100;
34 } elseif (!is_integer($percent) && $percent<2) {
35 $percent = $percent*100;
36 } elseif ($percent == 1) {
39 $per1 = $per2 = floor($percent*100);
48 /* return '<table cellpadding=0 cellspacing=0 width="100%" class="bargraph">
50 <td class="bar" align="left" width="'.$per1.'"><div style="position: relative;"><div style="left: 0; display: inline; position: absolute;"> '.$txt1.' </div> </div></td>
51 <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>
53 return '<table cellpadding=0 cellspacing=0 width="100%" class="bargraph">
55 <td class="bar" align="left" width="'.$per1.'"><div style="position: relative;"></div></td>
56 <td class="fill" align="right" width="'.$per2.'"><div style="position: relative;"></div></td>
58 </table><table cellpadding=0 cellspacing=0 width="100%">
59 <tr style="height: 1px;">
60 <td class="bar" align="left" width="50%"><div style="position: relative;"><div style="bottom: 3px; left: 5px; position: absolute;">'.$txt1.'</div></div></td>
61 <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>
66 function chars_encode($string) {
69 $chars = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
70 for ($i = 0; $i < count($chars); $i++)
71 $ent[$i] = '&#' . ord($chars[$i]) . ';';
72 if (sizeof($ent) < 1) return '';
73 return implode('',$ent);