1 | <?php
|
---|
2 |
|
---|
3 | /* @var $System System */
|
---|
4 | $System = NULL;
|
---|
5 | /* @var $Database Database */
|
---|
6 | $Database = NULL;
|
---|
7 |
|
---|
8 | include_once(dirname(__FILE__).'/../Packages/Package.php');
|
---|
9 | include_once(dirname(__FILE__).'/../Packages/Common/Common.php');
|
---|
10 | include_once(dirname(__FILE__).'/Page.php');
|
---|
11 | include_once(dirname(__FILE__).'/Table.php');
|
---|
12 | include_once(dirname(__FILE__).'/Form/Form.php');
|
---|
13 | include_once(dirname(__FILE__).'/Setup/Setup.php');
|
---|
14 | include_once(dirname(__FILE__).'/VCL/General.php');
|
---|
15 | include_once(dirname(__FILE__).'/VCL/Database.php');
|
---|
16 |
|
---|
17 | //define('NEW_PERMISSION', '1');
|
---|
18 |
|
---|
19 | $MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen',
|
---|
20 | 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
|
---|
21 |
|
---|
22 | $UnitNames = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB');
|
---|
23 | $YesNo = array(false => 'Ne', true => 'Ano');
|
---|
24 |
|
---|
25 | function HumanSize($Value)
|
---|
26 | {
|
---|
27 | global $UnitNames;
|
---|
28 |
|
---|
29 | $UnitIndex = 0;
|
---|
30 | while($Value > 1024)
|
---|
31 | {
|
---|
32 | $Value = round($Value / 1024, 3);
|
---|
33 | $UnitIndex++;
|
---|
34 | }
|
---|
35 | return($Value.' '.$UnitNames[$UnitIndex]);
|
---|
36 | }
|
---|
37 |
|
---|
38 | function GetMicrotime()
|
---|
39 | {
|
---|
40 | list($Usec, $Sec) = explode(' ', microtime());
|
---|
41 | return ((float)$Usec + (float)$Sec);
|
---|
42 | }
|
---|
43 |
|
---|
44 | function ShowArray($Pole)
|
---|
45 | {
|
---|
46 | echo('<pre style="font-size: 8pt;">');
|
---|
47 | print_r($Pole);
|
---|
48 | echo('</pre>');
|
---|
49 | }
|
---|
50 |
|
---|
51 | function HumanDate($Time)
|
---|
52 | {
|
---|
53 | if($Time != '') {
|
---|
54 | $Date = explode(' ', $Time);
|
---|
55 | $Parts = explode('-', $Date[0]);
|
---|
56 | if($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);
|
---|
57 | else return(' ');
|
---|
58 | } else return(' ');
|
---|
59 | }
|
---|
60 |
|
---|
61 | // Show page listing numbers
|
---|
62 | function PagesList($URL, $Page, $TotalCount, $CountPerPage)
|
---|
63 | {
|
---|
64 | $Count = ceil($TotalCount / $CountPerPage);
|
---|
65 | $Around = 10;
|
---|
66 | $Result = '';
|
---|
67 | if($Count>1)
|
---|
68 | {
|
---|
69 | if($Page>0)
|
---|
70 | {
|
---|
71 | $Result.= '<a href="'.$URL.'0"><<</a> ';
|
---|
72 | $Result.= '<a href="'.$URL.($Page-1).'"><</a> ';
|
---|
73 | }
|
---|
74 | $PagesMax = $Count-1;
|
---|
75 | $PagesMin = 0;
|
---|
76 | if($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around;
|
---|
77 | if($PagesMin<($Page-$Around))
|
---|
78 | {
|
---|
79 | $Result.= ' .. ';
|
---|
80 | $PagesMin = $Page-$Around;
|
---|
81 | }
|
---|
82 | for($i=$PagesMin;$i<=$PagesMax;$i++)
|
---|
83 | {
|
---|
84 | if($i==$Page) $Result.= '<strong>';
|
---|
85 | $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> ';
|
---|
86 | if($i==$Page) $Result.= '</strong>';
|
---|
87 | }
|
---|
88 | if($PagesMax<($Count-1)) $Result .= ' .. ';
|
---|
89 | if($Page<($Count-1))
|
---|
90 | {
|
---|
91 | $Result.= '<a href="'.$URL.($Page+1).'">></a> ';
|
---|
92 | $Result.= '<a href="'.$URL.($Count-1).'">>></a>';
|
---|
93 | }
|
---|
94 | }
|
---|
95 | return($Result);
|
---|
96 | }
|
---|
97 |
|
---|
98 | function ExtractTime($Time)
|
---|
99 | {
|
---|
100 | return(array(
|
---|
101 | 'Year' => date('Y', $Time),
|
---|
102 | 'Month' => date('n', $Time),
|
---|
103 | 'Day' => date('j', $Time),
|
---|
104 | 'Hour' => date('h', $Time),
|
---|
105 | 'Minute' => date('i', $Time),
|
---|
106 | 'Second' => date('s', $Time)
|
---|
107 | ));
|
---|
108 | }
|
---|
109 |
|
---|
110 | function GetQueryStringArray($QueryString)
|
---|
111 | {
|
---|
112 | $Result = array();
|
---|
113 | $Parts = explode('&', $QueryString);
|
---|
114 | foreach($Parts as $Part)
|
---|
115 | {
|
---|
116 | if($Part != '')
|
---|
117 | {
|
---|
118 | if(!strpos($Part, '=')) $Part .= '=';
|
---|
119 | $Item = explode('=', $Part);
|
---|
120 | $Result[$Item[0]] = $Item[1];
|
---|
121 | }
|
---|
122 | }
|
---|
123 | return($Result);
|
---|
124 | }
|
---|
125 |
|
---|
126 | function SetQueryStringArray($QueryStringArray)
|
---|
127 | {
|
---|
128 | $Parts = array();
|
---|
129 | foreach($QueryStringArray as $Index => $Item)
|
---|
130 | {
|
---|
131 | $Parts[] = $Index.'='.$Item;
|
---|
132 | }
|
---|
133 | return(implode('&', $Parts));
|
---|
134 | }
|
---|
135 |
|
---|
136 | class Paging
|
---|
137 | {
|
---|
138 | var $TotalCount;
|
---|
139 | var $ItemPerPage;
|
---|
140 | var $Around;
|
---|
141 | var $SQLLimit;
|
---|
142 | var $Page;
|
---|
143 |
|
---|
144 | function __construct()
|
---|
145 | {
|
---|
146 | global $System;
|
---|
147 |
|
---|
148 | $this->ItemPerPage = $System->Config['Web']['ItemsPerPage'];
|
---|
149 | $this->Around = $System->Config['Web']['VisiblePagingItems'];
|
---|
150 | }
|
---|
151 |
|
---|
152 | function Show()
|
---|
153 | {
|
---|
154 | $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
|
---|
155 |
|
---|
156 | $Result = '';
|
---|
157 | if(array_key_exists('all', $QueryItems))
|
---|
158 | {
|
---|
159 | $PageCount = 1;
|
---|
160 | $ItemPerPage = $this->TotalCount;
|
---|
161 | } else
|
---|
162 | {
|
---|
163 | $ItemPerPage = $this->ItemPerPage;
|
---|
164 | $Around = round($this->Around / 2);
|
---|
165 | $PageCount = floor($this->TotalCount / $ItemPerPage) + 1;
|
---|
166 | }
|
---|
167 |
|
---|
168 | if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
|
---|
169 | if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
|
---|
170 | if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
|
---|
171 | if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
|
---|
172 | $CurrentPage = $_SESSION['Page'];
|
---|
173 |
|
---|
174 | $Result .= 'Počet položek: <strong>'.$this->TotalCount.'</strong> Stránky: ';
|
---|
175 |
|
---|
176 | $Result = '';
|
---|
177 | if($PageCount > 1)
|
---|
178 | {
|
---|
179 | if($CurrentPage > 0)
|
---|
180 | {
|
---|
181 | $QueryItems['page'] = 0;
|
---|
182 | $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><<</a> ';
|
---|
183 | $QueryItems['page'] = ($CurrentPage - 1);
|
---|
184 | $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><</a> ';
|
---|
185 | }
|
---|
186 | $PagesMax = $PageCount - 1;
|
---|
187 | $PagesMin = 0;
|
---|
188 | if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
|
---|
189 | if($PagesMin < ($CurrentPage - $Around))
|
---|
190 | {
|
---|
191 | $Result.= ' ... ';
|
---|
192 | $PagesMin = $CurrentPage - $Around;
|
---|
193 | }
|
---|
194 | for($i = $PagesMin; $i <= $PagesMax; $i++)
|
---|
195 | {
|
---|
196 | if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
|
---|
197 | else {
|
---|
198 | $QueryItems['page'] = $i;
|
---|
199 | $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> ';
|
---|
200 | }
|
---|
201 | }
|
---|
202 | if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
|
---|
203 | if($CurrentPage < ($PageCount - 1))
|
---|
204 | {
|
---|
205 | $QueryItems['page'] = ($CurrentPage + 1);
|
---|
206 | $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">></a> ';
|
---|
207 | $QueryItems['page'] = ($PageCount - 1);
|
---|
208 | $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">>></a>';
|
---|
209 | }
|
---|
210 | }
|
---|
211 | $QueryItems['all'] = '1';
|
---|
212 | if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
|
---|
213 |
|
---|
214 | $Result = '<div style="text-align: center">'.$Result.'</div>';
|
---|
215 | $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage;
|
---|
216 | $this->Page = $CurrentPage;
|
---|
217 | return($Result);
|
---|
218 | }
|
---|
219 | }
|
---|
220 |
|
---|
221 | function GetPageList($TotalCount)
|
---|
222 | {
|
---|
223 | global $System;
|
---|
224 |
|
---|
225 | $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
|
---|
226 |
|
---|
227 | $Result = '';
|
---|
228 | if(array_key_exists('all', $QueryItems))
|
---|
229 | {
|
---|
230 | $PageCount = 1;
|
---|
231 | $ItemPerPage = $TotalCount;
|
---|
232 | } else
|
---|
233 | {
|
---|
234 | $ItemPerPage = $System->Config['Web']['ItemsPerPage'];
|
---|
235 | $Around = round($System->Config['Web']['VisiblePagingItems'] / 2);
|
---|
236 | $PageCount = floor($TotalCount / $ItemPerPage) + 1;
|
---|
237 | }
|
---|
238 |
|
---|
239 | if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
|
---|
240 | if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
|
---|
241 | if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
|
---|
242 | if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
|
---|
243 | $CurrentPage = $_SESSION['Page'];
|
---|
244 |
|
---|
245 |
|
---|
246 | $Result .= 'Počet položek: <strong>'.$TotalCount.'</strong> Stránky: ';
|
---|
247 |
|
---|
248 | $Result = '';
|
---|
249 | if($PageCount > 1)
|
---|
250 | {
|
---|
251 | if($CurrentPage > 0)
|
---|
252 | {
|
---|
253 | $QueryItems['page'] = 0;
|
---|
254 | $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><<</a> ';
|
---|
255 | $QueryItems['page'] = ($CurrentPage - 1);
|
---|
256 | $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><</a> ';
|
---|
257 | }
|
---|
258 | $PagesMax = $PageCount - 1;
|
---|
259 | $PagesMin = 0;
|
---|
260 | if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
|
---|
261 | if($PagesMin < ($CurrentPage - $Around))
|
---|
262 | {
|
---|
263 | $Result.= ' ... ';
|
---|
264 | $PagesMin = $CurrentPage - $Around;
|
---|
265 | }
|
---|
266 | for($i = $PagesMin; $i <= $PagesMax; $i++)
|
---|
267 | {
|
---|
268 | if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
|
---|
269 | else {
|
---|
270 | $QueryItems['page'] = $i;
|
---|
271 | $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> ';
|
---|
272 | }
|
---|
273 | }
|
---|
274 | if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
|
---|
275 | if($CurrentPage < ($PageCount - 1))
|
---|
276 | {
|
---|
277 | $QueryItems['page'] = ($CurrentPage + 1);
|
---|
278 | $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">></a> ';
|
---|
279 | $QueryItems['page'] = ($PageCount - 1);
|
---|
280 | $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">>></a>';
|
---|
281 | }
|
---|
282 | }
|
---|
283 | $QueryItems['all'] = '1';
|
---|
284 | if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
|
---|
285 |
|
---|
286 | $Result = '<div style="text-align: center">'.$Result.'</div>';
|
---|
287 | return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,
|
---|
288 | 'Page' => $CurrentPage,
|
---|
289 | 'Output' => $Result,
|
---|
290 | ));
|
---|
291 | }
|
---|
292 |
|
---|
293 | $OrderDirSQL = array('ASC', 'DESC');
|
---|
294 | $OrderArrowImage = array('sort_asc.png', 'sort_desc.png');
|
---|
295 |
|
---|
296 | function GetOrderTableHeader($Columns, $DefaultColumn, $DefaultOrder = 0)
|
---|
297 | {
|
---|
298 | global $OrderDirSQL, $OrderArrowImage, $Config, $System;
|
---|
299 |
|
---|
300 | if(array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
|
---|
301 | if(array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir'];
|
---|
302 | if(!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn;
|
---|
303 | if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder;
|
---|
304 |
|
---|
305 | // Check OrderCol
|
---|
306 | $Found = false;
|
---|
307 | foreach($Columns as $Column)
|
---|
308 | {
|
---|
309 | if($Column['Name'] == $_SESSION['OrderCol'])
|
---|
310 | {
|
---|
311 | $Found = true;
|
---|
312 | break;
|
---|
313 | }
|
---|
314 | }
|
---|
315 | if($Found == false)
|
---|
316 | {
|
---|
317 | $_SESSION['OrderCol'] = $DefaultColumn;
|
---|
318 | $_SESSION['OrderDir'] = $DefaultOrder;
|
---|
319 | }
|
---|
320 | // Check OrderDir
|
---|
321 | if(($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0;
|
---|
322 |
|
---|
323 | $Result = '';
|
---|
324 | $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
|
---|
325 | foreach($Columns as $Index => $Column)
|
---|
326 | {
|
---|
327 | $QueryItems['OrderCol'] = $Column['Name'];
|
---|
328 | $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir'];
|
---|
329 | if($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.$System->Link('/images/'.$OrderArrowImage[$_SESSION['OrderDir']]).'" alt="order arrow">';
|
---|
330 | else $ArrowImage = '';
|
---|
331 | if($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';
|
---|
332 | else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column['Title'].$ArrowImage.'</a></th>';
|
---|
333 | }
|
---|
334 | return(array(
|
---|
335 | 'SQL' => ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$OrderDirSQL[$_SESSION['OrderDir']],
|
---|
336 | 'Output' => '<tr>'.$Result.'</tr>',
|
---|
337 | 'Column' => $_SESSION['OrderCol'],
|
---|
338 | 'Direction' => $_SESSION['OrderDir'],
|
---|
339 | ));
|
---|
340 | }
|
---|
341 |
|
---|
342 | function GetRemoteAddress()
|
---|
343 | {
|
---|
344 | if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
|
---|
345 | else $IP = '0.0.0.0';
|
---|
346 | return($IP);
|
---|
347 | }
|
---|
348 |
|
---|
349 | function IsInternetAddr()
|
---|
350 | {
|
---|
351 | global $Config;
|
---|
352 |
|
---|
353 | $Result = true;
|
---|
354 | $RemoteAddr = GetRemoteAddress();
|
---|
355 | foreach($Config['Web']['IntranetSubnets'] as $Subnet)
|
---|
356 | {
|
---|
357 | if(substr($RemoteAddr, 0, strlen($Subnet)) == $Subnet)
|
---|
358 | {
|
---|
359 | $Result = false;
|
---|
360 | break;
|
---|
361 | }
|
---|
362 | }
|
---|
363 | return($Result);
|
---|
364 | }
|
---|
365 |
|
---|
366 | function GetMemberByIP($IP)
|
---|
367 | {
|
---|
368 | global $Database;
|
---|
369 |
|
---|
370 | $DbResult = $Database->query('SELECT Id FROM Member WHERE '.
|
---|
371 | '(SELECT Member FROM NetworkDevice WHERE (SELECT Device FROM NetworkInterface '.
|
---|
372 | 'WHERE LocalIP = "'.$IP.'") = NetworkDevice.Id) = Member.Id');
|
---|
373 | if($DbResult->num_rows > 0)
|
---|
374 | {
|
---|
375 | $DbRow = $DbResult->fetch_assoc();
|
---|
376 | return($DbRow['Id']);
|
---|
377 | } else return('');
|
---|
378 | }
|
---|
379 |
|
---|
380 | function CommandExist($Command)
|
---|
381 | {
|
---|
382 | $Result = shell_exec('which '.$Command);
|
---|
383 | return(!empty($Result));
|
---|
384 | }
|
---|
385 |
|
---|
386 | function RemoveDiacritic($Text)
|
---|
387 | {
|
---|
388 | return(str_replace(
|
---|
389 | array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů',
|
---|
390 | 'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'),
|
---|
391 | array('a', 'c', 'd', 'e', 'e', 'i', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u',
|
---|
392 | 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z'),
|
---|
393 | $Text));
|
---|
394 | }
|
---|
395 |
|
---|
396 | function RouterOSIdent($Name)
|
---|
397 | {
|
---|
398 | return(strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-',
|
---|
399 | 'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y',
|
---|
400 | 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd',
|
---|
401 | 'ť' => 't', 'ň' => 'n', 'ó' => 'o',
|
---|
402 | 'Č' => 'c', 'Š' => 's', 'Ě' => 'e', 'Ř' => 'r', 'Ž' => 'z', 'Ý' => 'y',
|
---|
403 | 'Á' => 'a', 'Í' => 'i', 'É' => 'e', 'Ů' => 'u', 'Ú' => 'u', 'Ď' => 'd',
|
---|
404 | 'Ť' => 't', 'Ň' => 'n', 'Ó' => 'o',
|
---|
405 | )));
|
---|
406 | }
|
---|
407 |
|
---|
408 | function NotBlank($Text)
|
---|
409 | {
|
---|
410 | if($Text == '') return(' ');
|
---|
411 | else return($Text);
|
---|
412 | }
|
---|
413 |
|
---|
414 | function strip_cdata($string)
|
---|
415 | {
|
---|
416 | preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches);
|
---|
417 | return str_replace($matches[0], $matches[1], $string);
|
---|
418 | }
|
---|
419 |
|
---|
420 | function html2txt($document)
|
---|
421 | {
|
---|
422 | $search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript
|
---|
423 | '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
|
---|
424 | '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
|
---|
425 | '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA
|
---|
426 | );
|
---|
427 | $text = preg_replace($search, '', $document);
|
---|
428 | return $text;
|
---|
429 | }
|
---|
430 |
|
---|
431 | function ProcessURL()
|
---|
432 | {
|
---|
433 | if(array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
|
---|
434 | $PathString = $_SERVER['REDIRECT_QUERY_STRING'];
|
---|
435 | else $PathString = '';
|
---|
436 | if(substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
|
---|
437 | $PathItems = explode('/', $PathString);
|
---|
438 | if(array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))
|
---|
439 | $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
|
---|
440 | else $_SERVER['QUERY_STRING'] = '';
|
---|
441 | parse_str($_SERVER['QUERY_STRING'], $_GET);
|
---|
442 | return($PathItems);
|
---|
443 | }
|
---|
444 |
|
---|
445 | function RepeatFunction($Period, $Callback)
|
---|
446 | {
|
---|
447 | while(1)
|
---|
448 | {
|
---|
449 | $StartTime = time();
|
---|
450 | call_user_func($Callback);
|
---|
451 | $EndTime = time();
|
---|
452 | $Delay = $Period - ($EndTime - $StartTime);
|
---|
453 | if($Delay < 0) $Delay = 0;
|
---|
454 |
|
---|
455 | echo('Waiting '.$Delay.' seconds...'."\n");
|
---|
456 | sleep($Delay);
|
---|
457 | }
|
---|
458 | }
|
---|
459 |
|
---|
460 | function pack_array($v, $a)
|
---|
461 | {
|
---|
462 | return call_user_func_array('pack', array_merge(array($v), (array)$a));
|
---|
463 | }
|
---|
464 |
|
---|