]>
Commit | Line | Data |
---|---|---|
1d3a17c7 | 1 | <?php |
f03a795d AD |
2 | set_include_path(get_include_path() . PATH_SEPARATOR . |
3 | dirname(__FILE__) . "/include"); | |
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 | ||
23 | /* Public calls compatibility shim */ | |
24 | ||
25 | $public_calls = array("globalUpdateFeeds", "rss", "getUnread", "getProfiles", "share", | |
26 | "fbexport", "logout", "pubsub"); | |
27 | ||
28 | if (array_search($op, $public_calls) !== false) { | |
29 | header("Location: public.php?" . $_SERVER['QUERY_STRING']); | |
30 | return; | |
31 | } | |
f9da2388 | 32 | |
fb074239 | 33 | require_once "functions.php"; |
5f0a3741 | 34 | require_once "sessions.php"; |
657770a0 AD |
35 | require_once "sanity_check.php"; |
36 | require_once "config.php"; | |
af106b0e AD |
37 | require_once "db.php"; |
38 | require_once "db-prefs.php"; | |
657770a0 | 39 | |
dc56b3b7 | 40 | no_cache_incantation(); |
8d039718 | 41 | |
7b26a148 | 42 | startup_gettext(); |
dc56b3b7 | 43 | |
7f0acba7 AD |
44 | $script_started = getmicrotime(); |
45 | ||
009646d2 | 46 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
7f0acba7 | 47 | |
5f0a3741 | 48 | if (!init_connection($link)) return; |
3f363052 AD |
49 | |
50 | header("Content-Type: text/plain; charset=utf-8"); | |
262bd8ea | 51 | |
bd202c3f AD |
52 | if (ENABLE_GZIP_OUTPUT) { |
53 | ob_start("ob_gzhandler"); | |
54 | } | |
55 | ||
9c883208 AD |
56 | if (SINGLE_USER_MODE) { |
57 | authenticate_user($link, "admin", null); | |
58 | } | |
59 | ||
5f0a3741 | 60 | // TODO remove and handle within Handlers |
009646d2 | 61 | |
5f0a3741 | 62 | if (!($_SESSION["uid"] && validate_session($link))) { |
1395083e | 63 | if ($op == 'pref-feeds' && $method == 'add') { |
d0f73380 AD |
64 | header("Content-Type: text/html"); |
65 | login_sequence($link); | |
66 | render_login_form($link); | |
67 | } else { | |
68 | header("Content-Type: text/plain"); | |
69 | print json_encode(array("error" => array("code" => 6))); | |
70 | } | |
009646d2 | 71 | return; |
262bd8ea | 72 | } |
1c7f75ed | 73 | |
ad815c71 | 74 | $purge_intervals = array( |
d1db26aa AD |
75 | 0 => __("Use default"), |
76 | -1 => __("Never purge"), | |
77 | 5 => __("1 week old"), | |
78 | 14 => __("2 weeks old"), | |
79 | 31 => __("1 month old"), | |
80 | 60 => __("2 months old"), | |
81 | 90 => __("3 months old")); | |
ad815c71 AD |
82 | |
83 | $update_intervals = array( | |
ecace165 | 84 | 0 => __("Default interval"), |
d1db26aa | 85 | -1 => __("Disable updates"), |
1e7cbe16 | 86 | 15 => __("Each 15 minutes"), |
d1db26aa | 87 | 30 => __("Each 30 minutes"), |
505f2f0e AD |
88 | 60 => __("Hourly"), |
89 | 240 => __("Each 4 hours"), | |
90 | 720 => __("Each 12 hours"), | |
91 | 1440 => __("Daily"), | |
92 | 10080 => __("Weekly")); | |
93 | ||
94 | $update_intervals_nodefault = array( | |
95 | -1 => __("Disable updates"), | |
96 | 15 => __("Each 15 minutes"), | |
97 | 30 => __("Each 30 minutes"), | |
d1db26aa AD |
98 | 60 => __("Hourly"), |
99 | 240 => __("Each 4 hours"), | |
100 | 720 => __("Each 12 hours"), | |
101 | 1440 => __("Daily"), | |
102 | 10080 => __("Weekly")); | |
ad815c71 | 103 | |
16211ddb | 104 | $update_methods = array( |
ecace165 | 105 | 0 => __("Default"), |
0dd9c0cf | 106 | 1 => __("Magpie"), |
009646d2 | 107 | 2 => __("SimplePie"), |
b3009bcd | 108 | 3 => __("Twitter OAuth")); |
16211ddb | 109 | |
78a5c296 | 110 | if (DEFAULT_UPDATE_METHOD == "1") { |
16211ddb AD |
111 | $update_methods[0] .= ' (SimplePie)'; |
112 | } else { | |
113 | $update_methods[0] .= ' (Magpie)'; | |
114 | } | |
115 | ||
3c5783b7 | 116 | $access_level_names = array( |
009646d2 | 117 | 0 => __("User"), |
a88d37e5 | 118 | 5 => __("Power User"), |
d1db26aa | 119 | 10 => __("Administrator")); |
3c5783b7 | 120 | |
ebb948c2 AD |
121 | $error = sanity_check($link); |
122 | ||
2376ad49 | 123 | if ($error['code'] != 0 && $op != "logout") { |
ebb948c2 AD |
124 | print json_encode(array("error" => $error)); |
125 | return; | |
126 | } | |
023fe037 | 127 | |
5f0a3741 AD |
128 | function __autoload($class) { |
129 | $file = "classes/".strtolower(basename($class)).".php"; | |
130 | if (file_exists($file)) { | |
131 | require $file; | |
132 | } | |
133 | } | |
134 | ||
afcfe6ca AD |
135 | $op = str_replace("-", "_", $op); |
136 | ||
d5112468 AD |
137 | if (class_exists($op)) { |
138 | $handler = new $op($link, $_REQUEST); | |
45004d43 | 139 | |
d5112468 | 140 | if ($handler) { |
de8260cb | 141 | if ($handler->before($method)) { |
3f363052 AD |
142 | if ($method && method_exists($handler, $method)) { |
143 | $handler->$method(); | |
144 | } else if (method_exists($handler, 'index')) { | |
145 | $handler->index(); | |
d5112468 | 146 | } |
3f363052 AD |
147 | $handler->after(); |
148 | return; | |
d5112468 AD |
149 | } |
150 | } | |
151 | } | |
152 | ||
5f0a3741 AD |
153 | header("Content-Type: text/plain"); |
154 | print json_encode(array("error" => array("code" => 7))); | |
ba7e88e5 | 155 | |
45004d43 | 156 | // We close the connection to database. |
4b3dff6e | 157 | db_close($link); |
1cd17194 | 158 | ?> |