]> andersk Git - sql-web.git/blob - lib/display.lib.php
ecb4e4993fd140931afb05cfbc0574996b0ddb9c
[sql-web.git] / lib / display.lib.php
1 <?php
2
3 ## FORMATTING FUNCTIONS
4
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);
10         
11         return ($bytes<1||$kb<1?$bytes.' B':($mb<1?$kb.' KB':($gb<1?$mb.' MB':$gb.' GB')));
12 }
13
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);
21 }
22
23 function printBar($percent, $txt1 = '', $txt2 = '') {
24         $color1 = 'black';
25         $color2 = 'white';
26         $color3 = 'white';
27         $color4 = 'black';
28         if ($percent>1) {
29                 $percent = $percent/100;
30         } /*
31         } elseif (!is_integer($percent) && $percent<2) {
32                 $percent = $percent*100;
33         } elseif ($percent == 1) {
34                 $percent = 100;
35         } */
36         $per1 = $per2 = ceil($percent*100);
37         $per2 = 100 - $per2;
38         $per1 .= "%";
39         $per2 .= "%";
40         return '<table cellpadding=0 cellspacing=0 width="100%" class="bargraph">
41                                 <tr>
42                                 <td class="bar" align="left" width="'.$per1.'"><div style="position: relative;"><div style="left: 0; display: inline; position: absolute;">&nbsp;'.$txt1.'&nbsp;</div>&nbsp;</div></td>
43                                 <td class="fill" width="'.$per2.'"><div style="position: relative;">&nbsp;<div style="right: 0; display: inline; position: absolute;">'.$txt2.'&nbsp;<em>'.$per1.'</em></div></div></td>
44                                 </tr></table>';
45 }
46
47 ?>
This page took 0.138658 seconds and 3 git commands to generate.