1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * The file written by Mário César Kolling <mario.kolling@serpro.gov.br> * |
---|
6 | * -------------------------------------------- * |
---|
7 | * This program is free software; you can redistribute it and/or modify it * |
---|
8 | * under the terms of the GNU General Public License as published by the * |
---|
9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
10 | * option) any later version. * |
---|
11 | \**************************************************************************/ |
---|
12 | |
---|
13 | class common_functions |
---|
14 | { |
---|
15 | function borkb($size, $enclosed = NULL) |
---|
16 | { |
---|
17 | if (!$size) |
---|
18 | $size = 0; |
---|
19 | |
---|
20 | if ($enclosed) |
---|
21 | { |
---|
22 | $left = '('; |
---|
23 | $right = ')'; |
---|
24 | } |
---|
25 | |
---|
26 | if ($size < 1024) |
---|
27 | $rstring = $left . $size . ' B' . $right; |
---|
28 | else if ($size < 1048576) |
---|
29 | $rstring = $left . round($size/1024) . ' KB' . $right; |
---|
30 | else if ($size < 1073741824) |
---|
31 | $rstring = $left . round($size/1024/1024) . ' MB' . $right; |
---|
32 | else |
---|
33 | $rstring = $left . round($size/1024/1024/1024) . ' GB' . $right; |
---|
34 | |
---|
35 | return $rstring; |
---|
36 | } |
---|
37 | |
---|
38 | function complete_string($str = "", $length = 10, $align = "R", $char = " ") { |
---|
39 | if( $str == null ) |
---|
40 | $str = ""; |
---|
41 | else |
---|
42 | if( strlen($str) > $length ) { |
---|
43 | return substr($str, 0, $length); |
---|
44 | } else if( strlen($str) == $length ) { |
---|
45 | return $str; |
---|
46 | } |
---|
47 | |
---|
48 | $char = substr($char, 0, 1); |
---|
49 | $complete_str = ""; |
---|
50 | |
---|
51 | while( strlen($str) + strlen($complete_str) < $length ) |
---|
52 | $complete_str .= $char; |
---|
53 | |
---|
54 | if( $align == "L" ) |
---|
55 | return $str . $complete_str; |
---|
56 | else |
---|
57 | return $complete_str . $str; |
---|
58 | } |
---|
59 | |
---|
60 | function strach_string($string,$size) { |
---|
61 | return strlen($string)>$size ? substr($string,0,$size)."...": |
---|
62 | $string; |
---|
63 | } |
---|
64 | |
---|
65 | } //end common class |
---|
66 | |
---|
67 | |
---|
68 | ?> |
---|