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