]>
Commit | Line | Data |
---|---|---|
1d3a17c7 | 1 | <?php |
88e8fb3a AD |
2 | set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
3 | get_include_path()); | |
107d0cf3 | 4 | |
ce885e21 AD |
5 | /* remove ill effects of magic quotes */ |
6 | ||
5fa17372 | 7 | if (get_magic_quotes_gpc()) { |
c0793f64 | 8 | function stripslashes_deep($value) { |
009646d2 | 9 | $value = is_array($value) ? |
c0793f64 AD |
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); | |
ce885e21 AD |
18 | } |
19 | ||
f9da2388 | 20 | $op = $_REQUEST["op"]; |
5f0a3741 AD |
21 | @$method = $_REQUEST['subop'] ? $_REQUEST['subop'] : $_REQUEST["method"]; |
22 | ||
8484ce22 AD |
23 | if (!$method) |
24 | $method = 'index'; | |
25 | else | |
26 | $method = strtolower($method); | |
27 | ||
5f0a3741 AD |
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 | } | |
f9da2388 | 37 | |
66b042fc | 38 | @$csrf_token = $_REQUEST['csrf_token']; |
8484ce22 | 39 | |
fb074239 | 40 | require_once "functions.php"; |
5f0a3741 | 41 | require_once "sessions.php"; |
657770a0 | 42 | require_once "config.php"; |
af106b0e AD |
43 | require_once "db.php"; |
44 | require_once "db-prefs.php"; | |
657770a0 | 45 | |
dc56b3b7 | 46 | no_cache_incantation(); |
8d039718 | 47 | |
7b26a148 | 48 | startup_gettext(); |
dc56b3b7 | 49 | |
7f0acba7 AD |
50 | $script_started = getmicrotime(); |
51 | ||
009646d2 | 52 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
7f0acba7 | 53 | |
5f0a3741 | 54 | if (!init_connection($link)) return; |
3f363052 AD |
55 | |
56 | header("Content-Type: text/plain; charset=utf-8"); | |
262bd8ea | 57 | |
6a79e8af | 58 | if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { |
bd202c3f AD |
59 | ob_start("ob_gzhandler"); |
60 | } | |
61 | ||
9c883208 AD |
62 | if (SINGLE_USER_MODE) { |
63 | authenticate_user($link, "admin", null); | |
64 | } | |
65 | ||
ad815c71 | 66 | $purge_intervals = array( |
d1db26aa AD |
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")); | |
ad815c71 AD |
74 | |
75 | $update_intervals = array( | |
ecace165 | 76 | 0 => __("Default interval"), |
d1db26aa | 77 | -1 => __("Disable updates"), |
1e7cbe16 | 78 | 15 => __("Each 15 minutes"), |
d1db26aa | 79 | 30 => __("Each 30 minutes"), |
505f2f0e AD |
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"), | |
d1db26aa AD |
90 | 60 => __("Hourly"), |
91 | 240 => __("Each 4 hours"), | |
92 | 720 => __("Each 12 hours"), | |
93 | 1440 => __("Daily"), | |
94 | 10080 => __("Weekly")); | |
ad815c71 | 95 | |
16211ddb | 96 | $update_methods = array( |
ecace165 | 97 | 0 => __("Default"), |
0dd9c0cf | 98 | 1 => __("Magpie"), |
304aadb9 | 99 | 2 => __("SimplePie")); |
16211ddb | 100 | |
78a5c296 | 101 | if (DEFAULT_UPDATE_METHOD == "1") { |
16211ddb AD |
102 | $update_methods[0] .= ' (SimplePie)'; |
103 | } else { | |
104 | $update_methods[0] .= ' (Magpie)'; | |
105 | } | |
106 | ||
3c5783b7 | 107 | $access_level_names = array( |
009646d2 | 108 | 0 => __("User"), |
a88d37e5 | 109 | 5 => __("Power User"), |
d1db26aa | 110 | 10 => __("Administrator")); |
3c5783b7 | 111 | |
545ca067 | 112 | #$error = sanity_check($link); |
ebb948c2 | 113 | |
545ca067 AD |
114 | #if ($error['code'] != 0 && $op != "logout") { |
115 | # print json_encode(array("error" => $error)); | |
116 | # return; | |
117 | #} | |
023fe037 | 118 | |
afcfe6ca AD |
119 | $op = str_replace("-", "_", $op); |
120 | ||
d5112468 AD |
121 | if (class_exists($op)) { |
122 | $handler = new $op($link, $_REQUEST); | |
45004d43 | 123 | |
143d1b31 | 124 | if ($handler && is_subclass_of($handler, 'Handler')) { |
8484ce22 AD |
125 | if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) { |
126 | if ($handler->before($method)) { | |
127 | if ($method && method_exists($handler, $method)) { | |
128 | $handler->$method(); | |
19c73507 AD |
129 | } else { |
130 | if (method_exists($handler, "catchall")) { | |
131 | $handler->catchall($method); | |
132 | } | |
8484ce22 AD |
133 | } |
134 | $handler->after(); | |
135 | return; | |
97acbaf1 AD |
136 | } else { |
137 | header("Content-Type: text/plain"); | |
138 | print json_encode(array("error" => array("code" => 6))); | |
139 | return; | |
d5112468 | 140 | } |
8484ce22 AD |
141 | } else { |
142 | header("Content-Type: text/plain"); | |
143 | print json_encode(array("error" => array("code" => 6))); | |
3f363052 | 144 | return; |
d5112468 AD |
145 | } |
146 | } | |
147 | } | |
148 | ||
5f0a3741 AD |
149 | header("Content-Type: text/plain"); |
150 | print json_encode(array("error" => array("code" => 7))); | |
ba7e88e5 | 151 | |
45004d43 | 152 | // We close the connection to database. |
4b3dff6e | 153 | db_close($link); |
1cd17194 | 154 | ?> |