1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<?php
namespace System;
class Request
{
public static function getUrl()
{
$urlString = preg_replace('/\?.*$/', '', $_SERVER['REQUEST_URI']);
strtok($urlString, '/');
while( ($url[] = strtok('/')) !== false); //loops until strtok, called above, returns false
array_pop($url); // Removes the false the above line had added
$url = isset($url[0]) ? $url : array( DEFAULT_REQUEST );
return $url;
}
public static function disconnect($url)
//Disconnects from the client and allows script to run in background
{
set_time_limit(0);
ignore_user_abort(1);
header(
sprintf(
"Location: %s",
$url
)
);
header(
sprintf(
"Content-Length: %s",
ob_get_length()
)
);
header('Connection: close');
ob_end_flush();
ob_flush();
flush();
session_write_close();
}
}
|