]>
Commit | Line | Data |
---|---|---|
1d3a17c7 | 1 | <?php |
ce885e21 AD |
2 | /* remove ill effects of magic quotes */ |
3 | ||
5fa17372 | 4 | if (get_magic_quotes_gpc()) { |
c0793f64 AD |
5 | function stripslashes_deep($value) { |
6 | $value = is_array($value) ? | |
7 | array_map('stripslashes_deep', $value) : stripslashes($value); | |
8 | return $value; | |
9 | } | |
10 | ||
11 | $_POST = array_map('stripslashes_deep', $_POST); | |
12 | $_GET = array_map('stripslashes_deep', $_GET); | |
13 | $_COOKIE = array_map('stripslashes_deep', $_COOKIE); | |
14 | $_REQUEST = array_map('stripslashes_deep', $_REQUEST); | |
ce885e21 AD |
15 | } |
16 | ||
fb074239 | 17 | require_once "functions.php"; |
36bfab86 | 18 | require_once "sessions.php"; |
c339343b | 19 | require_once "modules/backend-rpc.php"; |
657770a0 AD |
20 | require_once "sanity_check.php"; |
21 | require_once "config.php"; | |
af106b0e AD |
22 | require_once "db.php"; |
23 | require_once "db-prefs.php"; | |
657770a0 | 24 | |
dc56b3b7 | 25 | no_cache_incantation(); |
8d039718 AD |
26 | |
27 | if (ENABLE_TRANSLATIONS == true) { | |
28 | startup_gettext(); | |
29 | } | |
dc56b3b7 | 30 | |
7f0acba7 AD |
31 | $script_started = getmicrotime(); |
32 | ||
33 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); | |
34 | ||
35 | if (!$link) { | |
36 | if (DB_TYPE == "mysql") { | |
37 | print mysql_error(); | |
38 | } | |
39 | // PG seems to display its own errors just fine by default. | |
40 | return; | |
41 | } | |
42 | ||
f29ba148 | 43 | init_connection($link); |
7f0acba7 AD |
44 | |
45 | $op = $_REQUEST["op"]; | |
d9084cf2 | 46 | $subop = $_REQUEST["subop"]; |
fac5e7d1 | 47 | $mode = $_REQUEST["mode"]; |
7f0acba7 | 48 | |
c339343b | 49 | $print_exec_time = false; |
7e3634d9 | 50 | |
fac5e7d1 AD |
51 | if ((!$op || $op == "rpc" || $op == "rss" || |
52 | ($op == "view" && $mode != "zoom") || | |
13e785e0 AD |
53 | $op == "digestSend" || $op == "dlg" || |
54 | $op == "viewfeed" || $op == "publish" || | |
18664970 | 55 | $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) { |
04fedbf5 AD |
56 | header("Content-Type: application/xml; charset=utf-8"); |
57 | ||
58 | if (ENABLE_GZIP_OUTPUT) { | |
59 | ob_start("ob_gzhandler"); | |
60 | } | |
61 | ||
9fdf7824 AD |
62 | } else { |
63 | if (!$_REQUEST["noxml"]) { | |
64 | header("Content-Type: text/html; charset=utf-8"); | |
65 | } else { | |
66 | header("Content-Type: text/plain; charset=utf-8"); | |
67 | } | |
262bd8ea AD |
68 | } |
69 | ||
f3acc32e AD |
70 | if (!$op) { |
71 | header("Content-Type: application/xml"); | |
72 | print_error_xml(7); exit; | |
73 | } | |
9c883208 AD |
74 | |
75 | if (SINGLE_USER_MODE) { | |
76 | authenticate_user($link, "admin", null); | |
77 | } | |
78 | ||
7f0acba7 | 79 | if (!($_SESSION["uid"] && validate_session($link)) && $op != "globalUpdateFeeds" |
d9084cf2 | 80 | && $op != "rss" && $op != "getUnread" && $op != "publish" && $op != "getProfiles") { |
262bd8ea | 81 | |
2e918d9d | 82 | if ($op == "rpc" || $op == "viewfeed" || $op == "view") { |
af106b0e | 83 | print_error_xml(6); die; |
04269460 AD |
84 | } else { |
85 | print " | |
86 | <html><body> | |
87 | <p>Error: Not logged in.</p> | |
88 | <script type=\"text/javascript\"> | |
89 | if (parent.window != 'undefined') { | |
01a87dff | 90 | parent.window.location = \"tt-rss.php\"; |
04269460 | 91 | } else { |
01a87dff | 92 | window.location = \"tt-rss.php\"; |
04269460 AD |
93 | } |
94 | </script> | |
95 | </body></html> | |
96 | "; | |
262bd8ea AD |
97 | } |
98 | exit; | |
99 | } | |
1c7f75ed | 100 | |
ad815c71 | 101 | $purge_intervals = array( |
d1db26aa AD |
102 | 0 => __("Use default"), |
103 | -1 => __("Never purge"), | |
104 | 5 => __("1 week old"), | |
105 | 14 => __("2 weeks old"), | |
106 | 31 => __("1 month old"), | |
107 | 60 => __("2 months old"), | |
108 | 90 => __("3 months old")); | |
ad815c71 AD |
109 | |
110 | $update_intervals = array( | |
ecace165 | 111 | 0 => __("Default interval"), |
d1db26aa | 112 | -1 => __("Disable updates"), |
1e7cbe16 | 113 | 15 => __("Each 15 minutes"), |
d1db26aa | 114 | 30 => __("Each 30 minutes"), |
505f2f0e AD |
115 | 60 => __("Hourly"), |
116 | 240 => __("Each 4 hours"), | |
117 | 720 => __("Each 12 hours"), | |
118 | 1440 => __("Daily"), | |
119 | 10080 => __("Weekly")); | |
120 | ||
121 | $update_intervals_nodefault = array( | |
122 | -1 => __("Disable updates"), | |
123 | 15 => __("Each 15 minutes"), | |
124 | 30 => __("Each 30 minutes"), | |
d1db26aa AD |
125 | 60 => __("Hourly"), |
126 | 240 => __("Each 4 hours"), | |
127 | 720 => __("Each 12 hours"), | |
128 | 1440 => __("Daily"), | |
129 | 10080 => __("Weekly")); | |
ad815c71 | 130 | |
16211ddb | 131 | $update_methods = array( |
ecace165 | 132 | 0 => __("Default"), |
0dd9c0cf AD |
133 | 1 => __("Magpie"), |
134 | 2 => __("SimplePie")); | |
16211ddb | 135 | |
78a5c296 | 136 | if (DEFAULT_UPDATE_METHOD == "1") { |
16211ddb AD |
137 | $update_methods[0] .= ' (SimplePie)'; |
138 | } else { | |
139 | $update_methods[0] .= ' (Magpie)'; | |
140 | } | |
141 | ||
3c5783b7 | 142 | $access_level_names = array( |
d1db26aa | 143 | 0 => __("User"), |
a88d37e5 | 144 | 5 => __("Power User"), |
d1db26aa | 145 | 10 => __("Administrator")); |
3c5783b7 | 146 | |
f27d955a | 147 | require_once "modules/pref-prefs.php"; |
ef8be8ea AD |
148 | require_once "modules/popup-dialog.php"; |
149 | require_once "modules/help.php"; | |
150 | require_once "modules/pref-feeds.php"; | |
151 | require_once "modules/pref-filters.php"; | |
152 | require_once "modules/pref-labels.php"; | |
153 | require_once "modules/pref-users.php"; | |
ef8be8ea | 154 | |
b2804af7 | 155 | if (!sanity_check($link)) { return; } |
023fe037 | 156 | |
45004d43 AD |
157 | switch($op) { // Select action according to $op value. |
158 | case "rpc": | |
159 | // Handle remote procedure calls. | |
160 | handle_rpc_request($link); | |
161 | break; // rpc | |
162 | ||
163 | case "feeds": | |
13e785e0 | 164 | $print_exec_time = true; |
45004d43 | 165 | |
b4e75b2a | 166 | $subop = $_REQUEST["subop"]; |
45004d43 AD |
167 | |
168 | switch($subop) { | |
169 | case "catchupAll": | |
170 | db_query($link, "UPDATE ttrss_user_entries SET | |
171 | last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]); | |
ad0056a8 AD |
172 | ccache_zero_all($link, $_SESSION["uid"]); |
173 | ||
45004d43 AD |
174 | break; |
175 | ||
176 | case "collapse": | |
b4e75b2a | 177 | $cat_id = db_escape_string($_REQUEST["cid"]); |
fcf70c51 AD |
178 | $mode = (int) db_escape_string($_REQUEST['mode']); |
179 | toggle_collapse_cat($link, $cat_id, $mode); | |
45004d43 AD |
180 | return; |
181 | break; | |
9d393c84 AD |
182 | |
183 | case "catsortreset": | |
184 | db_query($link, "UPDATE ttrss_feed_categories | |
185 | SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]); | |
186 | return; | |
187 | break; | |
188 | ||
189 | case "catsort": | |
b4e75b2a | 190 | $corder = db_escape_string($_REQUEST["corder"]); |
9d393c84 AD |
191 | |
192 | $cats = split(",", $corder); | |
193 | ||
194 | for ($i = 0; $i < count($cats); $i++) { | |
195 | $cat_id = $cats[$i]; | |
196 | ||
197 | if ($cat_id > 0) { | |
198 | db_query($link, "UPDATE ttrss_feed_categories | |
199 | SET order_id = '$i' WHERE id = '$cat_id' AND | |
200 | owner_uid = " . $_SESSION["uid"]); | |
201 | } | |
202 | } | |
203 | ||
204 | return; | |
205 | break; | |
206 | ||
45004d43 | 207 | } |
c3b81db0 | 208 | |
9c99281f | 209 | print json_encode(outputFeedList($link)); |
13e785e0 | 210 | |
45004d43 | 211 | break; // feeds |
1cd17194 | 212 | |
45004d43 | 213 | case "view": |
e097e8be | 214 | |
b4e75b2a AD |
215 | $id = db_escape_string($_REQUEST["id"]); |
216 | $cids = split(",", db_escape_string($_REQUEST["cids"])); | |
217 | $mode = db_escape_string($_REQUEST["mode"]); | |
218 | $omode = db_escape_string($_REQUEST["omode"]); | |
e097e8be | 219 | |
8cab2eb9 | 220 | if ($mode != "zoom") print "<reply>"; |
e097e8be | 221 | |
45004d43 AD |
222 | // in prefetch mode we only output requested cids, main article |
223 | // just gets marked as read (it already exists in client cache) | |
e097e8be | 224 | |
45004d43 | 225 | if ($mode == "") { |
e04c18a2 | 226 | outputArticleXML($link, $id, false); |
eedfb635 | 227 | } else if ($mode == "zoom") { |
e04c18a2 | 228 | outputArticleXML($link, $id, false, true, true); |
45004d43 AD |
229 | } else { |
230 | catchupArticleById($link, $id, 0); | |
231 | } | |
e097e8be | 232 | |
a598370d AD |
233 | if (!$_SESSION["bw_limit"]) { |
234 | foreach ($cids as $cid) { | |
235 | if ($cid) { | |
e04c18a2 | 236 | outputArticleXML($link, $cid, false, false); |
a598370d | 237 | } |
45004d43 | 238 | } |
e097e8be | 239 | } |
e097e8be | 240 | |
5225d420 | 241 | /* if ($mode == "prefetch") { |
6a7817c1 AD |
242 | print "<counters><![CDATA["; |
243 | print json_encode(getAllCounters($link, $omode)); | |
244 | print "]]></counters>"; | |
5225d420 | 245 | } */ |
5a94a953 | 246 | |
8cab2eb9 | 247 | if ($mode != "zoom") print "</reply>"; |
45004d43 | 248 | break; // view |
1cd17194 | 249 | |
45004d43 | 250 | case "viewfeed": |
1cd17194 | 251 | |
45004d43 AD |
252 | $print_exec_time = true; |
253 | $timing_info = getmicrotime(); | |
46921916 | 254 | |
45004d43 | 255 | print "<reply>"; |
3de0261a | 256 | |
b4e75b2a | 257 | if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info); |
46921916 | 258 | |
b4e75b2a | 259 | $omode = db_escape_string($_REQUEST["omode"]); |
3de0261a | 260 | |
b4e75b2a AD |
261 | $feed = db_escape_string($_REQUEST["feed"]); |
262 | $subop = db_escape_string($_REQUEST["subop"]); | |
263 | $view_mode = db_escape_string($_REQUEST["view_mode"]); | |
6f068202 | 264 | $limit = (int) get_pref($link, "DEFAULT_ARTICLE_LIMIT"); |
c3fddd05 AD |
265 | @$cat_view = db_escape_string($_REQUEST["cat"]); |
266 | @$next_unread_feed = db_escape_string($_REQUEST["nuf"]); | |
267 | @$offset = db_escape_string($_REQUEST["skip"]); | |
268 | @$vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]); | |
b4e75b2a | 269 | $order_by = db_escape_string($_REQUEST["order_by"]); |
203de776 | 270 | |
fe1087fb AD |
271 | /* Feed -5 is a special case: it is used to display auxiliary information |
272 | * when there's nothing to load - e.g. no stuff in fresh feed */ | |
273 | ||
274 | if ($feed == -5) { | |
275 | generate_dashboard_feed($link); | |
276 | print "</reply>"; | |
277 | return; | |
278 | } | |
279 | ||
51e196de AD |
280 | /* Updating a label ccache means recalculating all of the caches |
281 | * so for performance reasons we don't do that here */ | |
282 | ||
5225d420 AD |
283 | if ($feed >= 0) { |
284 | ccache_update($link, $feed, $_SESSION["uid"], $cat_view); | |
285 | } | |
0737b95a | 286 | |
45004d43 AD |
287 | set_pref($link, "_DEFAULT_VIEW_MODE", $view_mode); |
288 | set_pref($link, "_DEFAULT_VIEW_LIMIT", $limit); | |
7b4d02a8 | 289 | set_pref($link, "_DEFAULT_VIEW_ORDER_BY", $order_by); |
40496720 | 290 | |
45004d43 AD |
291 | if (!$cat_view && preg_match("/^[0-9][0-9]*$/", $feed)) { |
292 | db_query($link, "UPDATE ttrss_feeds SET last_viewed = NOW() | |
293 | WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]); | |
294 | } | |
7466dc6a | 295 | |
1098687a | 296 | if (!$next_unread_feed) { |
6e4f4ce1 | 297 | print "<headlines id=\"$feed\" is_cat=\"$cat_view\">"; |
1098687a | 298 | } else { |
6e4f4ce1 | 299 | print "<headlines id=\"$next_unread_feed\" is_cat=\"$cat_view\">"; |
1098687a | 300 | } |
a5c815d3 AD |
301 | |
302 | $override_order = false; | |
303 | ||
b3990c92 AD |
304 | if (get_pref($link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) { |
305 | $date_sort_field = "updated"; | |
306 | } else { | |
307 | $date_sort_field = "date_entered"; | |
308 | } | |
309 | ||
a5c815d3 AD |
310 | switch ($order_by) { |
311 | case "date": | |
312 | if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) { | |
b3990c92 | 313 | $override_order = "$date_sort_field"; |
a5c815d3 | 314 | } else { |
b3990c92 | 315 | $override_order = "$date_sort_field DESC"; |
a5c815d3 AD |
316 | } |
317 | break; | |
c50e2b30 | 318 | |
a5c815d3 | 319 | case "title": |
7b20c977 | 320 | if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) { |
b3990c92 | 321 | $override_order = "title DESC, $date_sort_field"; |
7b20c977 | 322 | } else { |
b3990c92 | 323 | $override_order = "title, $date_sort_field DESC"; |
7b20c977 | 324 | } |
a5c815d3 | 325 | break; |
d76a3b03 | 326 | |
a5c815d3 | 327 | case "score": |
7b20c977 | 328 | if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) { |
b3990c92 | 329 | $override_order = "score, $date_sort_field"; |
7b20c977 | 330 | } else { |
b3990c92 | 331 | $override_order = "score DESC, $date_sort_field DESC"; |
7b20c977 | 332 | } |
a5c815d3 AD |
333 | break; |
334 | } | |
e19c1824 | 335 | |
905ff52a AD |
336 | if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info); |
337 | ||
a5c815d3 AD |
338 | $ret = outputHeadlinesList($link, $feed, $subop, |
339 | $view_mode, $limit, $cat_view, $next_unread_feed, $offset, | |
340 | $vgroup_last_feed, $override_order); | |
7b4d02a8 | 341 | |
a5c815d3 AD |
342 | $topmost_article_ids = $ret[0]; |
343 | $headlines_count = $ret[1]; | |
344 | $returned_feed = $ret[2]; | |
345 | $disable_cache = $ret[3]; | |
346 | $vgroup_last_feed = $ret[4]; | |
7b4d02a8 | 347 | |
6e4f4ce1 | 348 | print "</headlines>"; |
46921916 | 349 | |
905ff52a AD |
350 | if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info); |
351 | ||
ffbe082d AD |
352 | //print "<headlines-count value=\"$headlines_count\"/>"; |
353 | //print "<vgroup-last-feed value=\"$vgroup_last_feed\"/>"; | |
081e527d | 354 | |
cfcb7d42 | 355 | $headlines_unread = ccache_find($link, $returned_feed, $_SESSION["uid"], |
696a6850 AD |
356 | $cat_view, true); |
357 | ||
358 | if ($headlines_unread == -1) { | |
359 | $headlines_unread = getFeedUnread($link, $returned_feed, $cat_view); | |
360 | ||
361 | } | |
a5c815d3 | 362 | |
ffbe082d AD |
363 | //print "<headlines-unread value=\"$headlines_unread\"/>"; |
364 | //printf("<disable-cache value=\"%d\"/>", $disable_cache); | |
365 | ||
366 | print "<headlines-info><![CDATA["; | |
367 | ||
368 | $info = array("count" => (int) $headlines_count, | |
369 | "vgroup_last_feed" => $vgroup_last_feed, | |
370 | "unread" => (int) $headlines_unread, | |
371 | "disable_cache" => (bool) $disable_cache); | |
372 | ||
373 | print json_encode($info); | |
374 | ||
375 | print "]]></headlines-info>"; | |
a5c815d3 | 376 | |
b4e75b2a | 377 | if ($_REQUEST["debug"]) $timing_info = print_checkpoint("10", $timing_info); |
a5c815d3 AD |
378 | |
379 | if (is_array($topmost_article_ids) && !get_pref($link, 'COMBINED_DISPLAY_MODE') && !$_SESSION["bw_limit"]) { | |
380 | print "<articles>"; | |
381 | foreach ($topmost_article_ids as $id) { | |
382 | outputArticleXML($link, $id, $feed, false); | |
45004d43 | 383 | } |
a5c815d3 | 384 | print "</articles>"; |
961f4c73 | 385 | } |
961f4c73 | 386 | |
b4e75b2a | 387 | if ($_REQUEST["debug"]) $timing_info = print_checkpoint("20", $timing_info); |
46921916 | 388 | |
dd25b0c6 AD |
389 | //if (get_pref($link, 'COMBINED_DISPLAY_MODE') || $subop) { |
390 | if ($subop) { | |
5225d420 AD |
391 | print "<counters><![CDATA["; |
392 | print json_encode(getAllCounters($link, $omode, $feed)); | |
393 | print "]]></counters>"; | |
d36f5607 | 394 | } |
98bea1b1 | 395 | |
b4e75b2a | 396 | if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info); |
46921916 | 397 | |
45004d43 | 398 | print_runtime_info($link); |
03c88bdd | 399 | |
45004d43 AD |
400 | print "</reply>"; |
401 | break; // viewfeed | |
1cd17194 | 402 | |
45004d43 AD |
403 | case "pref-feeds": |
404 | module_pref_feeds($link); | |
405 | break; // pref-feeds | |
a7f22b70 | 406 | |
45004d43 AD |
407 | case "pref-filters": |
408 | module_pref_filters($link); | |
409 | break; // pref-filters | |
a0476535 | 410 | |
45004d43 AD |
411 | case "pref-labels": |
412 | module_pref_labels($link); | |
413 | break; // pref-labels | |
d0000401 | 414 | |
45004d43 AD |
415 | case "pref-prefs": |
416 | module_pref_prefs($link); | |
417 | break; // pref-prefs | |
f27d955a | 418 | |
45004d43 AD |
419 | case "pref-users": |
420 | module_pref_users($link); | |
421 | break; // prefs-users | |
a0476535 | 422 | |
45004d43 AD |
423 | case "help": |
424 | module_help($link); | |
425 | break; // help | |
a0476535 | 426 | |
45004d43 AD |
427 | case "dlg": |
428 | module_popup_dialog($link); | |
429 | break; // dlg | |
a7f22b70 | 430 | |
45004d43 AD |
431 | case "pref-pub-items": |
432 | module_pref_pub_items($link); | |
433 | break; // pref-pub-items | |
e4f4b46f | 434 | |
45004d43 AD |
435 | case "globalUpdateFeeds": |
436 | // update feeds of all users, may be used anonymously | |
e4f4b46f | 437 | |
5cbaf873 | 438 | print "<!--"; |
45004d43 | 439 | // Update all feeds needing a update. |
5cbaf873 AD |
440 | update_daemon_common($link, 0, true, true); |
441 | print " -->"; | |
a7f22b70 | 442 | |
45004d43 AD |
443 | print "<rpc-reply> |
444 | <message msg=\"All feeds updated\"/> | |
445 | </rpc-reply>"; | |
446 | break; // globalUpdateFeeds | |
e5d758e3 | 447 | |
45004d43 AD |
448 | case "pref-feed-browser": |
449 | module_pref_feed_browser($link); | |
450 | break; // pref-feed-browser | |
c6232e43 | 451 | |
45004d43 | 452 | case "rss": |
b4e75b2a | 453 | $feed = db_escape_string($_REQUEST["id"]); |
8801fb01 | 454 | $key = db_escape_string($_REQUEST["key"]); |
b4e75b2a AD |
455 | $is_cat = $_REQUEST["is_cat"] != false; |
456 | $limit = (int)db_escape_string($_REQUEST["limit"]); | |
e1eb2147 | 457 | |
b4e75b2a AD |
458 | $search = db_escape_string($_REQUEST["q"]); |
459 | $match_on = db_escape_string($_REQUEST["m"]); | |
460 | $search_mode = db_escape_string($_REQUEST["smode"]); | |
2f2bd1b3 | 461 | $view_mode = db_escape_string($_REQUEST["view-mode"]); |
18664970 | 462 | |
b4798282 AD |
463 | if (SINGLE_USER_MODE) { |
464 | authenticate_user($link, "admin", null); | |
465 | } | |
466 | ||
8801fb01 AD |
467 | if ($key && !$_SESSION["uid"]) { |
468 | $result = db_query($link, "SELECT owner_uid FROM | |
469 | ttrss_access_keys WHERE access_key = '$key' AND feed_id = '$feed'"); | |
470 | ||
471 | if (db_num_rows($result) == 1) | |
472 | $_SESSION["uid"] = db_fetch_result($result, 0, "owner_uid"); | |
473 | ||
45004d43 | 474 | } |
18664970 | 475 | |
135d4251 | 476 | if ($_SESSION["uid"]) { |
23d72f39 AD |
477 | generate_syndicated_feed($link, 0, $feed, $is_cat, $limit, |
478 | $search, $search_mode, $match_on, $view_mode); | |
45004d43 AD |
479 | } |
480 | break; // rss | |
18664970 | 481 | |
45004d43 | 482 | case "getUnread": |
b4e75b2a | 483 | $login = db_escape_string($_REQUEST["login"]); |
1f7b77d1 | 484 | $fresh = $_REQUEST["fresh"] == "1"; |
f3acc32e | 485 | |
45004d43 | 486 | header("Content-Type: text/plain; charset=utf-8"); |
f3acc32e | 487 | |
45004d43 | 488 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE login = '$login'"); |
7e3634d9 | 489 | |
45004d43 AD |
490 | if (db_num_rows($result) == 1) { |
491 | $uid = db_fetch_result($result, 0, "id"); | |
1f7b77d1 | 492 | |
45004d43 | 493 | print getGlobalUnread($link, $uid); |
1f7b77d1 AD |
494 | |
495 | if ($fresh) { | |
496 | print ";"; | |
497 | print getFeedArticles($link, -3, false, true, $uid); | |
498 | } | |
499 | ||
45004d43 AD |
500 | } else { |
501 | print "-1;User not found"; | |
502 | } | |
7e3634d9 | 503 | |
45004d43 AD |
504 | $print_exec_time = false; |
505 | break; // getUnread | |
9cd7c995 | 506 | |
45004d43 AD |
507 | case "digestTest": |
508 | header("Content-Type: text/plain"); | |
509 | print_r(prepare_headlines_digest($link, $_SESSION["uid"])); | |
510 | $print_exec_time = false; | |
511 | break; // digestTest | |
448b0abd | 512 | |
45004d43 AD |
513 | case "digestSend": |
514 | header("Content-Type: text/plain"); | |
515 | send_headlines_digests($link); | |
516 | $print_exec_time = false; | |
517 | break; // digestSend | |
7e3634d9 | 518 | |
d9084cf2 AD |
519 | case "getProfiles": |
520 | $login = db_escape_string($_REQUEST["login"]); | |
521 | $password = db_escape_string($_REQUEST["password"]); | |
522 | ||
523 | if (authenticate_user($link, $login, $password)) { | |
524 | $result = db_query($link, "SELECT * FROM ttrss_settings_profiles | |
525 | WHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY title"); | |
526 | ||
527 | print "<select style='width: 100%' name='profile'>"; | |
528 | ||
529 | print "<option value='0'>" . __("Default profile") . "</option>"; | |
530 | ||
531 | while ($line = db_fetch_assoc($result)) { | |
532 | $id = $line["id"]; | |
533 | $title = $line["title"]; | |
534 | ||
535 | print "<option value='$id'>$title</option>"; | |
536 | } | |
537 | ||
538 | print "</select>"; | |
539 | ||
540 | $_SESSION = array(); | |
0456176a | 541 | } |
d9084cf2 | 542 | break; |
d9084cf2 | 543 | |
45004d43 | 544 | } // Select action according to $op value. |
f3acc32e | 545 | |
45004d43 | 546 | // We close the connection to database. |
4b3dff6e | 547 | db_close($link); |
1cd17194 | 548 | ?> |
406d9489 | 549 | |
7e3634d9 | 550 | <?php if ($print_exec_time) { ?> |
1d3a17c7 | 551 | <!-- <?php echo sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> --> |
f3acc32e | 552 | <?php } ?> |