dispatcher.inc.php
1.36 KB
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
49
50
51
52
53
54
55
<?php
class KTDispatcher {
var $event_var = "action";
function dispatch () {
$method = 'do_main';
if (array_key_exists($this->event_var, $_REQUEST)) {
$event = $_REQUEST[$this->event_var];
if (method_exists($this, 'do_' . $event)) {
$method = 'do_' . $event;
}
}
$ret = $this->$method();
$this->handleOutput($ret);
}
function errorRedirectTo($event, $error_message) {
/* $method = 'do_main';
if (method_exists($this, 'do_' . $event)) {
$method = 'do_' . $event;
}*/
$_SESSION['KTErrorMessage'][] = $error_message;
exit(redirect($_SERVER["PHP_SELF"] . '?action=' . $event));
//return $this->$method();
}
function redirectTo($event, $sQuery) {
exit(redirect($_SERVER["PHP_SELF"] . '?action=' . $event . "&" . $sQuery));
}
function errorRedirectToMain($error_message) {
return $this->errorRedirectTo('main', $error_message);
}
function handleOutput($sOutput) {
print $sOutput;
}
}
class KTAdminDispatcher extends KTDispatcher {
function permissionDenied () {
print "Permission denied";
}
function dispatch () {
if (!checkSession()) {
exit($this->permissionDenied());
}
return parent::dispatch();
}
}
?>