-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·121 lines (119 loc) · 3.67 KB
/
index.php
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
/**
*
* main functional area of Senorsen's code of film_dub.
* @author Senorsen
*
*/
define('SEN_DIR', __DIR__);
require "bmpparse.php";
require "film_config.php";
require "film_common.php";
require "resizeimage.php";
require "dispatch.php";
set_error_handler("customError");
try {
/*
main block
*/
$actions = array(
'ajax' => array(
'submit_signup',
'submit_poster',
'postervote',
'myadmin',
),
'common' => array('',
'setQSCToken',
'goLogin',
'main',
'dub',
'forum',
'show',
'poster',
'map',
'truffaut',
'timeline',
'myadmin',
'posterParse',
'getposter',
'uploadany',
'posterVoteParse',
),
'ajax_type' => array(
'json',
'jsonp',
'pjax'
)
);
// Automatically add views to common type
$views_add = getdir(SEN_DIR . '/view');
foreach ($views_add as $value) {
if (!in_array($value, $actions['common'])) {
array_push($actions['common'], $value);
}
}
if (!isset($callback)) {
$callback = 'callback';
}
if (!defined('SEN_SHELL')) {
if (isset($_GET['q'])) {
// q存在时将覆盖在action的♂上边。
$_REQUEST['action'] = $_GET['q'];
}
if (isset($_REQUEST['ajax']) && is_string($_REQUEST['ajax'])) {
if (!checkToken() || !in_array($_REQUEST['ajax'], $actions['ajax_type'])) {
errorPage('奇怪的错误,不知道是为什么,想报告给我嘛?~');
} else {
$ajax = $_REQUEST['ajax'];
}
} else {
$ajax = FALSE;
}
if (isset($_REQUEST['action']) && is_string($_REQUEST['action'])) {
if ($ajax === FALSE) {
if (!in_array($_REQUEST['action'], $actions['common'])) {
header("HTTP/1.1 404 Not Found");
errorPage('噗,这个页面并没有被定义。<br>如果您认为这是个错误,欢迎向我来报告哟~~');
} else {
$action = $_REQUEST['action'];
}
} else {
if (!in_array($_REQUEST['action'], $actions['ajax'])) {
header("HTTP/1.1 404 Not Found");
errorPage("ajax_action未找到。。。困死了");
} else {
$action = $_REQUEST['action'];
if (isset($_REQUEST['callback']) && is_string($_REQUEST['callback'])) {
$callback = $_REQUEST['callback'];
}
}
}
} else {
if ($ajax != FALSE) {
errorPage('好像有点小错误吧。。。。噗。。。天哪噜。。。');
} else {
$action = 'main';
}
}
$args = $_REQUEST;
unset($args['ajax']);
unset($args['action']);
unset($args['random_token']);
unset($args['callback']);
}
$dispatch = new Dispatch($args, $db, $global_config);
$ret = null;
if (method_exists($dispatch, $action)) {
// the saf
eval('$ret = $dispatch->' . $action . '($args);');
}
if ($action == '') {
$action = 'main';
}
view_handler($ajax, $action, (object)$ret, $callback);
// happy ending.
} catch (Exception $e) {
errorPage('index.php 出现错误啦! =_= 噗。。。<br>', $e);
// 本来想记录错误到数据库的,不过想想还是算了吧。
}