]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . | |
3 | get_include_path()); | |
4 | ||
5 | /* remove ill effects of magic quotes */ | |
6 | ||
7 | if (get_magic_quotes_gpc()) { | |
8 | function stripslashes_deep($value) { | |
9 | $value = is_array($value) ? | |
10 | array_map('stripslashes_deep', $value) : stripslashes($value); | |
11 | return $value; | |
12 | } | |
13 | ||
14 | $_POST = array_map('stripslashes_deep', $_POST); | |
15 | $_GET = array_map('stripslashes_deep', $_GET); | |
16 | $_COOKIE = array_map('stripslashes_deep', $_COOKIE); | |
17 | $_REQUEST = array_map('stripslashes_deep', $_REQUEST); | |
18 | } | |
19 | ||
20 | $op = $_REQUEST["op"]; | |
21 | @$method = $_REQUEST['subop'] ? $_REQUEST['subop'] : $_REQUEST["method"]; | |
22 | ||
23 | if (!$method) | |
24 | $method = 'index'; | |
25 | else | |
26 | $method = strtolower($method); | |
27 | ||
28 | /* Public calls compatibility shim */ | |
29 | ||
30 | $public_calls = array("globalUpdateFeeds", "rss", "getUnread", "getProfiles", "share", | |
31 | "fbexport", "logout", "pubsub"); | |
32 | ||
33 | if (array_search($op, $public_calls) !== false) { | |
34 | header("Location: public.php?" . $_SERVER['QUERY_STRING']); | |
35 | return; | |
36 | } | |
37 | ||
38 | @$csrf_token = $_REQUEST['csrf_token']; | |
39 | ||
40 | require_once "functions.php"; | |
41 | require_once "sessions.php"; | |
42 | require_once "config.php"; | |
43 | require_once "db.php"; | |
44 | require_once "db-prefs.php"; | |
45 | ||
46 | no_cache_incantation(); | |
47 | ||
48 | startup_gettext(); | |
49 | ||
50 | $script_started = getmicrotime(); | |
51 | ||
52 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); | |
53 | ||
54 | if (!init_connection($link)) return; | |
55 | ||
56 | header("Content-Type: text/plain; charset=utf-8"); | |
57 | ||
58 | if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { | |
59 | ob_start("ob_gzhandler"); | |
60 | } | |
61 | ||
62 | if (SINGLE_USER_MODE) { | |
63 | authenticate_user($link, "admin", null); | |
64 | } | |
65 | ||
66 | $purge_intervals = array( | |
67 | 0 => __("Use default"), | |
68 | -1 => __("Never purge"), | |
69 | 5 => __("1 week old"), | |
70 | 14 => __("2 weeks old"), | |
71 | 31 => __("1 month old"), | |
72 | 60 => __("2 months old"), | |
73 | 90 => __("3 months old")); | |
74 | ||
75 | $update_intervals = array( | |
76 | 0 => __("Default interval"), | |
77 | -1 => __("Disable updates"), | |
78 | 15 => __("Each 15 minutes"), | |
79 | 30 => __("Each 30 minutes"), | |
80 | 60 => __("Hourly"), | |
81 | 240 => __("Each 4 hours"), | |
82 | 720 => __("Each 12 hours"), | |
83 | 1440 => __("Daily"), | |
84 | 10080 => __("Weekly")); | |
85 | ||
86 | $update_intervals_nodefault = array( | |
87 | -1 => __("Disable updates"), | |
88 | 15 => __("Each 15 minutes"), | |
89 | 30 => __("Each 30 minutes"), | |
90 | 60 => __("Hourly"), | |
91 | 240 => __("Each 4 hours"), | |
92 | 720 => __("Each 12 hours"), | |
93 | 1440 => __("Daily"), | |
94 | 10080 => __("Weekly")); | |
95 | ||
96 | $update_methods = array( | |
97 | 0 => __("Default"), | |
98 | 1 => __("Magpie"), | |
99 | 2 => __("SimplePie")); | |
100 | ||
101 | if (DEFAULT_UPDATE_METHOD == "1") { | |
102 | $update_methods[0] .= ' (SimplePie)'; | |
103 | } else { | |
104 | $update_methods[0] .= ' (Magpie)'; | |
105 | } | |
106 | ||
107 | $access_level_names = array( | |
108 | 0 => __("User"), | |
109 | 5 => __("Power User"), | |
110 | 10 => __("Administrator")); | |
111 | ||
112 | #$error = sanity_check($link); | |
113 | ||
114 | #if ($error['code'] != 0 && $op != "logout") { | |
115 | # print json_encode(array("error" => $error)); | |
116 | # return; | |
117 | #} | |
118 | ||
119 | $op = str_replace("-", "_", $op); | |
120 | ||
121 | global $pluginhost; | |
122 | $override = $pluginhost->lookup_handler($op, $method); | |
123 | ||
124 | if (class_exists($op) || $override) { | |
125 | ||
126 | if ($override) { | |
127 | $handler = $override; | |
128 | } else { | |
129 | $handler = new $op($link, $_REQUEST); | |
130 | } | |
131 | ||
132 | if ($handler && implements_interface($handler, 'IHandler')) { | |
133 | if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) { | |
134 | if ($handler->before($method)) { | |
135 | if ($method && method_exists($handler, $method)) { | |
136 | $handler->$method(); | |
137 | } else { | |
138 | if (method_exists($handler, "catchall")) { | |
139 | $handler->catchall($method); | |
140 | } | |
141 | } | |
142 | $handler->after(); | |
143 | return; | |
144 | } else { | |
145 | header("Content-Type: text/plain"); | |
146 | print json_encode(array("error" => array("code" => 6))); | |
147 | return; | |
148 | } | |
149 | } else { | |
150 | header("Content-Type: text/plain"); | |
151 | print json_encode(array("error" => array("code" => 6))); | |
152 | return; | |
153 | } | |
154 | } | |
155 | } | |
156 | ||
157 | header("Content-Type: text/plain"); | |
158 | print json_encode(array("error" => array("code" => 7))); | |
159 | ||
160 | // We close the connection to database. | |
161 | db_close($link); | |
162 | ?> |