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