source: trunk/www/Base/Global.php

Last change on this file was 93, checked in by chronos, 11 years ago
  • Fixed: System variable as parameter to constructors of descendents of Module class.
  • Removed: End PHP mark "?>" from all files.
  • Property svn:executable set to *
File size: 2.1 KB
Line 
1<?php
2
3$MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listop
4ad', 'Prosinec');
5
6$UnitNames = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB');
7
8function TimeToHumanTime($Value)
9{
10 return(floor($Value / 3600 / 24).' dnů, '.date('H:i:s', $Value - 3600));
11}
12
13function RemoveDiacritic($Text)
14{
15 return(str_replace(
16 array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'),
17 array('a', 'c', 'd', 'e', 'e', 'i', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u', 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z'),
18 $Text));
19}
20
21function GetQueryStringArray()
22{
23 $Result = array();
24 $Parts = explode('&', $_SERVER['QUERY_STRING']);
25 foreach($Parts as $Part)
26 {
27 if($Part != '')
28 {
29 $Item = explode('=', $Part);
30 $Result[$Item[0]] = $Item[1];
31 }
32 }
33 return($Result);
34}
35
36function SetQueryStringArray($QueryStringArray)
37{
38 $Parts = array();
39 foreach($QueryStringArray as $Index => $Item)
40 {
41 $Parts[] = $Index.'='.$Item;
42 }
43 return(implode('&', $Parts));
44}
45
46function ParseCommandLineArgs($argv)
47{
48 array_shift($argv);
49 $out = array();
50 foreach ($argv as $arg)
51 {
52 if(substr($arg,0,2) == '--')
53 {
54 $eqPos = strpos($arg,'=');
55 if($eqPos === false)
56 {
57 $key = substr($arg,2);
58 $out[$key] = isset($out[$key]) ? $out[$key] : true;
59 } else
60 {
61 $key = substr($arg,2,$eqPos-2);
62 $out[$key] = substr($arg,$eqPos+1);
63 }
64 } else if(substr($arg,0,1) == '-')
65 {
66 if(substr($arg,2,1) == '=')
67 {
68 $key = substr($arg,1,1);
69 $out[$key] = substr($arg,3);
70 } else
71 {
72 $chars = str_split(substr($arg,1));
73 foreach($chars as $char)
74 {
75 $key = $char;
76 $out[$key] = isset($out[$key]) ? $out[$key] : true;
77 }
78 }
79 } else
80 {
81 $out[] = $arg;
82 }
83 }
84 return($out);
85}
Note: See TracBrowser for help on using the repository browser.