util.php
995 Bytes
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
<?php
class util {
static public function redirect($url) {
header('HTTP/1.1 302 Found');
header('Location: ' . $url);
die();
}
static public function not_found($error='') {
$data['error'] = $error;
View::output("errors/not-found", $data);
die();
}
static public function server_error($error='') {
$data['error'] = $error;
View::output("errors/server-error", $data);
die();
}
static public function service_unavailable() {
View::output("errors/service-unavailable");
die();
}
static public function current_url() {
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) ?
'https' : 'http';
$host = $_SERVER['HTTP_HOST'];
$path = $_SERVER['REQUEST_URI'];
$qs = $_SERVER['QUERY_STRING'];
$url = $protocol . '://' . $host . $path;
if ($qs) $url .= '?' . $qs;
return $url;
}
static public function current_url_enc() {
return urlencode(static::current_url());
}
}