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