]>
Commit | Line | Data |
---|---|---|
1d3a17c7 | 1 | <?php |
107d0cf3 AD |
2 | set_include_path(get_include_path() . PATH_SEPARATOR . "include"); |
3 | ||
ce885e21 AD |
4 | /* remove ill effects of magic quotes */ |
5 | ||
5fa17372 | 6 | if (get_magic_quotes_gpc()) { |
c0793f64 | 7 | function stripslashes_deep($value) { |
009646d2 | 8 | $value = is_array($value) ? |
c0793f64 AD |
9 | array_map('stripslashes_deep', $value) : stripslashes($value); |
10 | return $value; | |
11 | } | |
12 | ||
13 | $_POST = array_map('stripslashes_deep', $_POST); | |
14 | $_GET = array_map('stripslashes_deep', $_GET); | |
15 | $_COOKIE = array_map('stripslashes_deep', $_COOKIE); | |
16 | $_REQUEST = array_map('stripslashes_deep', $_REQUEST); | |
ce885e21 AD |
17 | } |
18 | ||
d5112468 AD |
19 | function __autoload($class) { |
20 | $file = "classes/".strtolower(basename($class)).".php"; | |
21 | if (file_exists($file)) { | |
22 | require $file; | |
23 | } | |
24 | } | |
25 | ||
f9da2388 AD |
26 | $op = $_REQUEST["op"]; |
27 | ||
fb074239 | 28 | require_once "functions.php"; |
f9da2388 | 29 | if ($op != "share") require_once "sessions.php"; |
657770a0 AD |
30 | require_once "sanity_check.php"; |
31 | require_once "config.php"; | |
af106b0e AD |
32 | require_once "db.php"; |
33 | require_once "db-prefs.php"; | |
657770a0 | 34 | |
dc56b3b7 | 35 | no_cache_incantation(); |
8d039718 | 36 | |
7b26a148 | 37 | startup_gettext(); |
dc56b3b7 | 38 | |
7f0acba7 AD |
39 | $script_started = getmicrotime(); |
40 | ||
009646d2 | 41 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
7f0acba7 AD |
42 | |
43 | if (!$link) { | |
44 | if (DB_TYPE == "mysql") { | |
45 | print mysql_error(); | |
46 | } | |
009646d2 | 47 | // PG seems to display its own errors just fine by default. |
7f0acba7 AD |
48 | return; |
49 | } | |
50 | ||
f29ba148 | 51 | init_connection($link); |
7f0acba7 | 52 | |
d5112468 | 53 | $method = strtolower($_REQUEST["method"]); |
fac5e7d1 | 54 | $mode = $_REQUEST["mode"]; |
7f0acba7 | 55 | |
3f363052 | 56 | /* if ((!$op || $op == "rss" || $op == "dlg") && !$_REQUEST["noxml"]) { |
565ca565 AD |
57 | header("Content-Type: application/xml; charset=utf-8"); |
58 | } else { | |
9fdf7824 | 59 | header("Content-Type: text/plain; charset=utf-8"); |
3f363052 AD |
60 | } */ |
61 | ||
62 | header("Content-Type: text/plain; charset=utf-8"); | |
262bd8ea | 63 | |
bd202c3f AD |
64 | if (ENABLE_GZIP_OUTPUT) { |
65 | ob_start("ob_gzhandler"); | |
66 | } | |
67 | ||
9c883208 AD |
68 | if (SINGLE_USER_MODE) { |
69 | authenticate_user($link, "admin", null); | |
70 | } | |
71 | ||
e0d91d84 AD |
72 | $public_calls = array("globalUpdateFeeds", "rss", "getUnread", "getProfiles", "share", |
73 | "fbexport", "logout", "pubsub"); | |
009646d2 | 74 | |
e0d91d84 AD |
75 | if (array_search($op, $public_calls) !== false) { |
76 | ||
77 | handle_public_request($link, $op); | |
78 | return; | |
79 | ||
80 | } else if (!($_SESSION["uid"] && validate_session($link))) { | |
f30ef1fa | 81 | if ($op == 'pref-feeds' && $_REQUEST['method'] == 'add') { |
d0f73380 AD |
82 | header("Content-Type: text/html"); |
83 | login_sequence($link); | |
84 | render_login_form($link); | |
85 | } else { | |
86 | header("Content-Type: text/plain"); | |
87 | print json_encode(array("error" => array("code" => 6))); | |
88 | } | |
009646d2 | 89 | return; |
262bd8ea | 90 | } |
1c7f75ed | 91 | |
ad815c71 | 92 | $purge_intervals = array( |
d1db26aa AD |
93 | 0 => __("Use default"), |
94 | -1 => __("Never purge"), | |
95 | 5 => __("1 week old"), | |
96 | 14 => __("2 weeks old"), | |
97 | 31 => __("1 month old"), | |
98 | 60 => __("2 months old"), | |
99 | 90 => __("3 months old")); | |
ad815c71 AD |
100 | |
101 | $update_intervals = array( | |
ecace165 | 102 | 0 => __("Default interval"), |
d1db26aa | 103 | -1 => __("Disable updates"), |
1e7cbe16 | 104 | 15 => __("Each 15 minutes"), |
d1db26aa | 105 | 30 => __("Each 30 minutes"), |
505f2f0e AD |
106 | 60 => __("Hourly"), |
107 | 240 => __("Each 4 hours"), | |
108 | 720 => __("Each 12 hours"), | |
109 | 1440 => __("Daily"), | |
110 | 10080 => __("Weekly")); | |
111 | ||
112 | $update_intervals_nodefault = array( | |
113 | -1 => __("Disable updates"), | |
114 | 15 => __("Each 15 minutes"), | |
115 | 30 => __("Each 30 minutes"), | |
d1db26aa AD |
116 | 60 => __("Hourly"), |
117 | 240 => __("Each 4 hours"), | |
118 | 720 => __("Each 12 hours"), | |
119 | 1440 => __("Daily"), | |
120 | 10080 => __("Weekly")); | |
ad815c71 | 121 | |
16211ddb | 122 | $update_methods = array( |
ecace165 | 123 | 0 => __("Default"), |
0dd9c0cf | 124 | 1 => __("Magpie"), |
009646d2 | 125 | 2 => __("SimplePie"), |
b3009bcd | 126 | 3 => __("Twitter OAuth")); |
16211ddb | 127 | |
78a5c296 | 128 | if (DEFAULT_UPDATE_METHOD == "1") { |
16211ddb AD |
129 | $update_methods[0] .= ' (SimplePie)'; |
130 | } else { | |
131 | $update_methods[0] .= ' (Magpie)'; | |
132 | } | |
133 | ||
3c5783b7 | 134 | $access_level_names = array( |
009646d2 | 135 | 0 => __("User"), |
a88d37e5 | 136 | 5 => __("Power User"), |
d1db26aa | 137 | 10 => __("Administrator")); |
3c5783b7 | 138 | |
ebb948c2 AD |
139 | $error = sanity_check($link); |
140 | ||
2376ad49 | 141 | if ($error['code'] != 0 && $op != "logout") { |
ebb948c2 AD |
142 | print json_encode(array("error" => $error)); |
143 | return; | |
144 | } | |
023fe037 | 145 | |
d5112468 AD |
146 | if (class_exists($op)) { |
147 | $handler = new $op($link, $_REQUEST); | |
45004d43 | 148 | |
d5112468 AD |
149 | if ($handler) { |
150 | if ($handler->before()) { | |
3f363052 AD |
151 | if ($method && method_exists($handler, $method)) { |
152 | $handler->$method(); | |
153 | } else if (method_exists($handler, 'index')) { | |
154 | $handler->index(); | |
d5112468 | 155 | } |
3f363052 AD |
156 | $handler->after(); |
157 | return; | |
d5112468 AD |
158 | } |
159 | } | |
160 | } | |
161 | ||
162 | switch($op) { // Select action according to $op value. | |
1cd17194 | 163 | |
45004d43 | 164 | case "pref-feeds": |
1c9d14ad | 165 | require_once "modules/pref-feeds.php"; |
45004d43 AD |
166 | module_pref_feeds($link); |
167 | break; // pref-feeds | |
a7f22b70 | 168 | |
45004d43 | 169 | case "pref-filters": |
1c9d14ad | 170 | require_once "modules/pref-filters.php"; |
45004d43 AD |
171 | module_pref_filters($link); |
172 | break; // pref-filters | |
a0476535 | 173 | |
45004d43 | 174 | case "pref-labels": |
1c9d14ad | 175 | require_once "modules/pref-labels.php"; |
45004d43 AD |
176 | module_pref_labels($link); |
177 | break; // pref-labels | |
d0000401 | 178 | |
45004d43 | 179 | case "pref-prefs": |
1c9d14ad | 180 | require_once "modules/pref-prefs.php"; |
45004d43 AD |
181 | module_pref_prefs($link); |
182 | break; // pref-prefs | |
f27d955a | 183 | |
45004d43 | 184 | case "pref-users": |
1c9d14ad | 185 | require_once "modules/pref-users.php"; |
45004d43 AD |
186 | module_pref_users($link); |
187 | break; // prefs-users | |
a0476535 | 188 | |
45004d43 | 189 | case "help": |
1c9d14ad | 190 | require_once "modules/help.php"; |
45004d43 AD |
191 | module_help($link); |
192 | break; // help | |
a0476535 | 193 | |
373266eb | 194 | case "pref-instances": |
1c9d14ad | 195 | require_once "modules/pref-instances.php"; |
373266eb AD |
196 | module_pref_instances($link); |
197 | break; // pref-instances | |
198 | ||
45004d43 | 199 | case "digestTest": |
45004d43 | 200 | print_r(prepare_headlines_digest($link, $_SESSION["uid"])); |
45004d43 | 201 | break; // digestTest |
448b0abd | 202 | |
45004d43 | 203 | case "digestSend": |
45004d43 | 204 | send_headlines_digests($link); |
45004d43 | 205 | break; // digestSend |
7e3634d9 | 206 | |
ba7e88e5 | 207 | case "loading": |
347b467b | 208 | header("Content-type: text/html"); |
009646d2 | 209 | print __("Loading, please wait...") . " " . |
ba7e88e5 | 210 | "<img src='images/indicator_tiny.gif'>"; |
373266eb | 211 | break; // loading |
ba7e88e5 | 212 | |
1ca77e0a AD |
213 | default: |
214 | header("Content-Type: text/plain"); | |
215 | print json_encode(array("error" => array("code" => 7))); | |
373266eb | 216 | break; // fallback |
5ab9791f | 217 | } // Select action according to $op value. |
ba7e88e5 | 218 | |
45004d43 | 219 | // We close the connection to database. |
4b3dff6e | 220 | db_close($link); |
1cd17194 | 221 | ?> |