]>
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 | |
404e2e36 | 40 | require_once "autoload.php"; |
5f0a3741 | 41 | require_once "sessions.php"; |
23419d11 | 42 | require_once "functions.php"; |
657770a0 | 43 | require_once "config.php"; |
af106b0e AD |
44 | require_once "db.php"; |
45 | require_once "db-prefs.php"; | |
657770a0 | 46 | |
7b26a148 | 47 | startup_gettext(); |
dc56b3b7 | 48 | |
1ebf3b97 | 49 | $script_started = microtime(true); |
7f0acba7 | 50 | |
6322ac79 | 51 | if (!init_plugins()) return; |
3f363052 | 52 | |
7d1a91d5 | 53 | header("Content-Type: text/json; charset=utf-8"); |
262bd8ea | 54 | |
6a79e8af | 55 | if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { |
bd202c3f AD |
56 | ob_start("ob_gzhandler"); |
57 | } | |
58 | ||
9c883208 | 59 | if (SINGLE_USER_MODE) { |
6322ac79 | 60 | authenticate_user( "admin", null); |
9c883208 AD |
61 | } |
62 | ||
de612e7a | 63 | if ($_SESSION["uid"]) { |
6322ac79 | 64 | if (!validate_session()) { |
ccfa9080 | 65 | header("Content-Type: text/json"); |
27f7b593 | 66 | print error_json(6); |
ccfa9080 AD |
67 | return; |
68 | } | |
6322ac79 | 69 | load_user_plugins( $_SESSION["uid"]); |
de612e7a AD |
70 | } |
71 | ||
ad815c71 | 72 | $purge_intervals = array( |
d1db26aa AD |
73 | 0 => __("Use default"), |
74 | -1 => __("Never purge"), | |
75 | 5 => __("1 week old"), | |
76 | 14 => __("2 weeks old"), | |
77 | 31 => __("1 month old"), | |
78 | 60 => __("2 months old"), | |
79 | 90 => __("3 months old")); | |
ad815c71 AD |
80 | |
81 | $update_intervals = array( | |
ecace165 | 82 | 0 => __("Default interval"), |
d1db26aa | 83 | -1 => __("Disable updates"), |
c43f3e46 AD |
84 | 15 => __("15 minutes"), |
85 | 30 => __("30 minutes"), | |
505f2f0e | 86 | 60 => __("Hourly"), |
c43f3e46 AD |
87 | 240 => __("4 hours"), |
88 | 720 => __("12 hours"), | |
505f2f0e AD |
89 | 1440 => __("Daily"), |
90 | 10080 => __("Weekly")); | |
91 | ||
92 | $update_intervals_nodefault = array( | |
93 | -1 => __("Disable updates"), | |
c43f3e46 AD |
94 | 15 => __("15 minutes"), |
95 | 30 => __("30 minutes"), | |
d1db26aa | 96 | 60 => __("Hourly"), |
c43f3e46 AD |
97 | 240 => __("4 hours"), |
98 | 720 => __("12 hours"), | |
d1db26aa AD |
99 | 1440 => __("Daily"), |
100 | 10080 => __("Weekly")); | |
ad815c71 | 101 | |
3c5783b7 | 102 | $access_level_names = array( |
009646d2 | 103 | 0 => __("User"), |
a88d37e5 | 104 | 5 => __("Power User"), |
d1db26aa | 105 | 10 => __("Administrator")); |
3c5783b7 | 106 | |
afcfe6ca AD |
107 | $op = str_replace("-", "_", $op); |
108 | ||
1ffe3391 | 109 | $override = PluginHost::getInstance()->lookup_handler($op, $method); |
45004d43 | 110 | |
8dcb2b47 AD |
111 | if (class_exists($op) || $override) { |
112 | ||
113 | if ($override) { | |
114 | $handler = $override; | |
115 | } else { | |
1f294435 | 116 | $handler = new $op($_REQUEST); |
8dcb2b47 AD |
117 | } |
118 | ||
119 | if ($handler && implements_interface($handler, 'IHandler')) { | |
8484ce22 AD |
120 | if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) { |
121 | if ($handler->before($method)) { | |
122 | if ($method && method_exists($handler, $method)) { | |
123 | $handler->$method(); | |
19c73507 AD |
124 | } else { |
125 | if (method_exists($handler, "catchall")) { | |
126 | $handler->catchall($method); | |
127 | } | |
8484ce22 AD |
128 | } |
129 | $handler->after(); | |
130 | return; | |
97acbaf1 | 131 | } else { |
7d1a91d5 | 132 | header("Content-Type: text/json"); |
27f7b593 | 133 | print error_json(6); |
97acbaf1 | 134 | return; |
d5112468 | 135 | } |
8484ce22 | 136 | } else { |
7d1a91d5 | 137 | header("Content-Type: text/json"); |
27f7b593 | 138 | print error_json(6); |
3f363052 | 139 | return; |
d5112468 AD |
140 | } |
141 | } | |
142 | } | |
143 | ||
7d1a91d5 | 144 | header("Content-Type: text/json"); |
27f7b593 | 145 | print error_json(13); |
ba7e88e5 | 146 | |
1cd17194 | 147 | ?> |