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