]>
git.wh0rd.org - tt-rss.git/blob - backend.php
2 require_once "sessions.php";
4 header("Cache-Control: no-cache, must-revalidate");
5 header("Pragma: no-cache");
8 /* if ($_GET["debug"]) {
9 define('DEFAULT_ERROR_LEVEL', E_ALL);
11 define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
14 error_reporting(DEFAULT_ERROR_LEVEL); */
16 $op = $_REQUEST["op"];
18 define('SCHEMA_VERSION', 11);
20 require_once "sanity_check.php";
21 require_once "config.php";
23 require_once "db.php";
24 require_once "db-prefs.php";
25 require_once "functions.php";
27 $print_exec_time = true;
29 if ((!$op ||
$op == "rpc" ||
$op == "rss" ||
$op == "digestSend" ||
30 $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) {
31 header("Content-Type: application/xml");
35 header("Content-Type: application/xml");
36 print_error_xml(7); exit;
39 if (!$_SESSION["uid"] && $op != "globalUpdateFeeds" && $op != "rss" && $op != "getUnread") {
42 print_error_xml(6); die;
46 <p>Error: Not logged in.</p>
47 <script type=\"text/javascript\">
48 if (parent.window != 'undefined') {
49 parent.window.location = \"login.php\";
51 window.location = \"login.php\";
60 $purge_intervals = array(
67 90 => "3 months old");
69 $update_intervals = array(
71 -1 => "Disable updates",
72 30 => "Each 30 minutes",
74 240 => "Each 4 hours",
75 720 => "Each 12 hours",
79 $access_level_names = array(
81 10 => "Administrator");
83 require_once "modules/popup-dialog.php";
84 require_once "modules/help.php";
85 require_once "modules/pref-feeds.php";
86 require_once "modules/pref-filters.php";
87 require_once "modules/pref-labels.php";
88 require_once "modules/pref-users.php";
89 require_once "modules/pref-prefs.php";
90 require_once "modules/backend-rpc.php";
92 $script_started = getmicrotime();
94 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
97 if (DB_TYPE
== "mysql") {
100 // PG seems to display its own errors just fine by default.
104 if (DB_TYPE
== "pgsql") {
105 pg_query("set client_encoding = 'utf-8'");
108 if (!sanity_check($link)) { return; }
111 handle_rpc_request($link);
114 if ($op == "feeds") {
116 $tags = $_GET["tags"];
118 $subop = $_GET["subop"];
120 if ($subop == "catchupAll") {
121 db_query($link, "UPDATE ttrss_user_entries SET
122 last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);
125 if ($subop == "collapse") {
126 $cat_id = db_escape_string($_GET["cid"]);
128 db_query($link, "UPDATE ttrss_feed_categories SET
129 collapsed = NOT collapsed WHERE id = '$cat_id' AND owner_uid = " .
134 outputFeedList($link, $tags);
140 $id = db_escape_string($_GET["id"]);
141 $feed_id = db_escape_string($_GET["feed"]);
143 $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds
144 WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
146 if (db_num_rows($result) == 1) {
147 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
149 $rtl_content = false;
153 $rtl_tag = "dir=\"RTL\"";
160 $result = db_query($link, "UPDATE ttrss_user_entries
161 SET unread = false,last_read = NOW()
162 WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
164 $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id,
165 SUBSTRING(updated,1,16) as updated,
166 (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url,
169 FROM ttrss_entries,ttrss_user_entries
170 WHERE id = '$id' AND ref_id = id AND owner_uid = " . $_SESSION["uid"]);
176 if (get_pref($link, 'OPEN_LINKS_IN_NEW_WINDOW')) {
177 $link_target = "target=\"_new\"";
180 $line = db_fetch_assoc($result);
182 if ($line["icon_url"]) {
183 $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">";
185 $feed_icon = " ";
188 /* if ($line["comments"] && $line["link"] != $line["comments"]) {
189 $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)";
191 $entry_comments = "";
194 $num_comments = $line["num_comments"];
195 $entry_comments = "";
197 if ($num_comments > 0) {
198 if ($line["comments"]) {
199 $comments_url = $line["comments"];
201 $comments_url = $line["link"];
203 $entry_comments = "<a $link_target href=\"$comments_url\">$num_comments comments</a>";
205 if ($line["comments"] && $line["link"] != $line["comments"]) {
206 $entry_comments = "<a $link_target href=\"".$line["comments"]."\">comments</a>";
210 print "<div class=\"postReply\">";
212 print "<div class=\"postHeader\"><table width=\"100%\">";
214 $entry_author = $line["author"];
217 $entry_author = " - by $entry_author";
221 print "<tr><td width='70%'><a $link_target href=\"" . $line["link"] . "\">" .
222 $line["title"] . "</a>$entry_author</td>";
224 print "<tr><td width='30%'>" . $line["title"] . "$entry_author</td>";
227 $parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT'),
228 strtotime($line["updated"]));
230 print "<td class=\"postDate$rtl_class\">$parsed_updated</td>";
234 $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM
235 ttrss_tags WHERE post_int_id = " . $line["int_id"] . "
243 while ($tmp_line = db_fetch_assoc($tmp_result)) {
245 $tag = $tmp_line["tag_name"];
246 $tag_str = "<a href=\"javascript:parent.viewfeed('$tag')\">$tag</a>, ";
248 if ($num_tags == 5) {
249 $tags_str .= "<a href=\"javascript:showBlockElement('allEntryTags')\">...</a>";
250 } else if ($num_tags < 5) {
251 $tags_str .= $tag_str;
253 $f_tags_str .= $tag_str;
256 $tags_str = preg_replace("/, $/", "", $tags_str);
257 $f_tags_str = preg_replace("/, $/", "", $f_tags_str);
259 // $truncated_link = truncate_string($line["link"], 60);
261 if ($tags_str ||
$entry_comments) {
262 print "<tr><td width='50%'>
264 <td align=\"right\">$tags_str</td></tr>";
267 print "</table></div>";
269 print "<div class=\"postIcon\">" . $feed_icon . "</div>";
270 print "<div class=\"postContent\">";
272 if (db_num_rows($tmp_result) > 5) {
273 print "<div id=\"allEntryTags\">Tags: $f_tags_str</div>";
276 if (get_pref($link, 'OPEN_LINKS_IN_NEW_WINDOW')) {
277 $line["content"] = preg_replace("/href=/i", "target=\"_new\" href=", $line["content"]);
280 $line["content"] = sanitize_rss($line["content"]);
282 print $line["content"] . "</div>";
289 if ($op == "viewfeed") {
291 $feed = db_escape_string($_GET["feed"]);
292 $subop = db_escape_string($_GET["subop"]);
293 $view_mode = db_escape_string($_GET["view_mode"]);
294 $limit = db_escape_string($_GET["limit"]);
295 $cat_view = db_escape_string($_GET["cat"]);
296 $next_unread_feed = db_escape_string($_GET["nuf"]);
298 if ($subop == "undefined") $subop = "";
300 if ($subop == "CatchupSelected") {
301 $ids = split(",", db_escape_string($_GET["ids"]));
302 $cmode = sprintf("%d", $_GET["cmode"]);
304 catchupArticlesById($link, $ids, $cmode);
307 if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) {
308 update_generic_feed($link, $feed, $cat_view);
311 if ($subop == "MarkAllRead") {
312 catchup_feed($link, $feed, $cat_view);
314 if (get_pref($link, 'ON_CATCHUP_SHOW_NEXT_FEED')) {
315 if ($next_unread_feed) {
316 $feed = $next_unread_feed;
322 $result = db_query($link,
323 "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");
325 if (db_num_rows($result) == 0) {
326 print "<div align='center'>
327 Feed not found.</div>";
332 if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {
334 $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds
335 WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
337 if (db_num_rows($result) == 1) {
338 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
340 $rtl_content = false;
344 $rtl_tag = "dir=\"RTL\"";
350 $rtl_content = false;
353 $script_dt_add = get_script_dt_add();
355 /* print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
356 <script type=\"text/javascript\" src=\"prototype.js\"></script>
357 <script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script>
358 <script type=\"text/javascript\" src=\"viewfeed.js?$script_dt_add\"></script>
359 <!--[if gte IE 5.5000]>
360 <script type=\"text/javascript\" src=\"pngfix.js\"></script>
361 <link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss-ie.css\">
363 </head><body $rtl_tag>
364 <script type=\"text/javascript\">
365 if (document.addEventListener) {
366 document.addEventListener(\"DOMContentLoaded\", init, null);
368 window.onload = init;
371 /// START /////////////////////////////////////////////////////////////////////////////////
373 $search = db_escape_string($_GET["query"]);
374 $search_mode = db_escape_string($_GET["search_mode"]);
375 $match_on = db_escape_string($_GET["match_on"]);
381 $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on);
383 $result = $qfh_ret[0];
384 $feed_title = $qfh_ret[1];
385 $feed_site_url = $qfh_ret[2];
386 $last_error = $qfh_ret[3];
388 /// STOP //////////////////////////////////////////////////////////////////////////////////
390 print "<div id=\"headlinesContainer\" $rtl_tag>";
393 print "<div align='center'>
394 Could not display feed (query failed). Please check label match syntax or local configuration.</div>";
398 if (db_num_rows($result) > 0) {
400 print_headline_subtoolbar($link, $feed_site_url, $feed_title, false,
401 $rtl_content, $feed, $cat_view, $search, $match_on, $search_mode);
403 print "<div id=\"headlinesInnerContainer\">";
405 if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
406 print "<table class=\"headlinesList\" id=\"headlinesList\"
407 cellspacing=\"0\" width=\"100%\">";
412 error_reporting (DEFAULT_ERROR_LEVEL
);
416 while ($line = db_fetch_assoc($result)) {
418 $class = ($lnum %
2) ?
"even" : "odd";
421 $feed_id = $line["feed_id"];
423 if ($line["last_read"] == "" &&
424 ($line["unread"] != "t" && $line["unread"] != "1")) {
426 $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\"
429 $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\"
433 if ($line["unread"] == "t" ||
$line["unread"] == "1") {
441 if ($line["marked"] == "t" ||
$line["marked"] == "1") {
442 $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\"
443 alt=\"Reset mark\" onclick='javascript:toggleMark($id)'>";
445 $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\"
446 alt=\"Set mark\" onclick='javascript:toggleMark($id)'>";
449 # $content_link = "<a target=\"_new\" href=\"".$line["link"]."\">" .
450 # $line["title"] . "</a>";
452 $content_link = "<a href=\"javascript:view($id,$feed_id);\">" .
453 $line["title"] . "</a>";
455 # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
456 # $line["title"] . "</a>";
458 if (get_pref($link, 'HEADLINES_SMART_DATE')) {
459 $updated_fmt = smart_date_time(strtotime($line["updated"]));
461 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
462 $updated_fmt = date($short_date, strtotime($line["updated"]));
465 if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) {
466 $content_preview = truncate_string(strip_tags($line["content_preview"]),
470 if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
472 print "<tr class='$class' id='RROW-$id'>";
474 print "<td class='hlUpdatePic'>$update_pic</td>";
476 print "<td class='hlSelectRow'>
477 <input type=\"checkbox\" onclick=\"toggleSelectRow(this)\"
478 class=\"feedCheckBox\" id=\"RCHK-$id\">
481 print "<td class='hlMarkedPic'>$marked_pic</td>";
483 if ($line["feed_title"]) {
484 print "<td class='hlContent'>$content_link</td>";
485 print "<td class='hlFeed'>
486 <a href='javascript:viewfeed($feed_id)'>".
487 $line["feed_title"]."</a> </td>";
489 print "<td class='hlContent' valign='middle'>";
491 print "<a href=\"javascript:view($id,$feed_id);\">" .
494 if (get_pref($link, 'SHOW_CONTENT_PREVIEW') && !$rtl_tag) {
495 if ($content_preview) {
496 print "<span class=\"contentPreview\"> - $content_preview</span>";
504 print "<td class=\"hlUpdated\"><nobr>$updated_fmt </nobr></td>";
511 $add_class = "Unread";
516 print "<div class=\"cdmArticle$add_class\" id=\"RROW-$id\">";
518 print "<div class=\"cdmHeader\">";
520 print "<div style=\"float : right\">$updated_fmt,
521 <a class=\"cdmToggleLink\"
522 href=\"javascript:toggleUnread($id)\">Toggle unread</a>
525 print "<a class=\"title\"
526 onclick=\"javascript:toggleUnread($id, 0)\"
527 target=\"new\" href=\"".$line["link"]."\">".$line["title"]."</a>";
529 if ($line["feed_title"]) {
530 print " (<a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a>)";
535 print "<div class=\"cdmContent\">" . $line["content_preview"] . "</div><br clear=\"all\">";
537 print "<div style=\"float : right\">$marked_pic</div>
538 <div lass=\"cdmFooter\">
539 <input type=\"checkbox\" onclick=\"toggleSelectRowById(this,
540 'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\"></div>";
542 # print "<div align=\"center\"><a class=\"cdmToggleLink\"
543 # href=\"javascript:toggleUnread($id)\">
544 # Toggle unread</a></div>";
553 if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
559 // print_headline_subtoolbar($link,
560 // "javascript:catchupPage()", "Mark page as read", true, $rtl_content);
564 print "<div class='whiteBox'>No articles found.</div>";
570 if ($op == "pref-feeds") {
571 module_pref_feeds($link);
574 if ($op == "pref-filters") {
575 module_pref_filters($link);
578 if ($op == "pref-labels") {
579 module_pref_labels($link);
582 if ($op == "error") {
583 print "<div width=\"100%\" align='center'>";
594 module_popup_dialog($link);
597 // update feeds of all users, may be used anonymously
598 if ($op == "globalUpdateFeeds") {
600 $result = db_query($link, "SELECT id FROM ttrss_users");
602 while ($line = db_fetch_assoc($result)) {
603 $user_id = $line["id"];
604 // print "<!-- updating feeds of uid $user_id -->";
605 update_all_feeds($link, false, $user_id);
609 <message msg=\"All feeds updated\"/>
614 if ($op == "pref-prefs") {
615 module_pref_prefs($link);
618 if ($op == "pref-users") {
619 module_pref_users($link);
622 if ($op == "user-details") {
624 if (WEB_DEMO_MODE ||
$_SESSION["access_level"] < 10) {
628 /* print "<html><head>
629 <title>Tiny Tiny RSS : User Details</title>
630 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
631 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
634 $uid = sprintf("%d", $_GET["id"]);
636 print "<div id=\"infoBoxTitle\">User details</div>";
638 print "<div class='infoBoxContents'>";
640 $result = db_query($link, "SELECT login,
641 SUBSTRING(last_login,1,16) AS last_login,
643 (SELECT COUNT(int_id) FROM ttrss_user_entries
644 WHERE owner_uid = id) AS stored_articles
648 if (db_num_rows($result) == 0) {
649 print "<h1>User not found</h1>";
653 # print "<h1>User Details</h1>";
655 $login = db_fetch_result($result, 0, "login");
657 # print "<h1>$login</h1>";
659 print "<table width='100%'>";
661 $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'),
662 strtotime(db_fetch_result($result, 0, "last_login")));
663 $access_level = db_fetch_result($result, 0, "access_level");
664 $stored_articles = db_fetch_result($result, 0, "stored_articles");
666 # print "<tr><td>Username</td><td>$login</td></tr>";
667 # print "<tr><td>Access level</td><td>$access_level</td></tr>";
668 print "<tr><td>Last logged in</td><td>$last_login</td></tr>";
669 print "<tr><td>Stored articles</td><td>$stored_articles</td></tr>";
671 $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds
672 WHERE owner_uid = '$uid'");
674 $num_feeds = db_fetch_result($result, 0, "num_feeds");
676 print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>";
678 /* $result = db_query($link, "SELECT
679 SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size
680 FROM ttrss_user_entries,ttrss_entries
681 WHERE owner_uid = '$uid' AND ref_id = id");
683 $db_size = round(db_fetch_result($result, 0, "db_size") / 1024);
685 print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */
689 print "<h1>Subscribed feeds</h1>";
691 $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds
692 WHERE owner_uid = '$uid' ORDER BY title");
694 print "<ul class=\"userFeedList\">";
698 while ($line = db_fetch_assoc($result)) {
700 $icon_file = ICONS_URL
."/".$line["id"].".ico";
702 if (file_exists($icon_file) && filesize($icon_file) > 0) {
703 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">";
705 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
708 print "<li class=\"$row_class\">$feed_icon <a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>";
710 $row_class = toggleEvenOdd($row_class);
714 if (db_num_rows($result) < $num_feeds) {
715 // FIXME - add link to show ALL subscribed feeds here somewhere
717 class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\"> ...</li>";
724 print "<div align='center'>
725 <input type='submit' class='button'
726 onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
728 // print "</body></html>";
732 if ($op == "pref-feed-browser") {
734 if (!ENABLE_FEED_BROWSER
) {
735 print "Feed browser is administratively disabled.";
739 $subop = $_REQUEST["subop"];
741 if ($subop == "details") {
742 $id = db_escape_string($_GET["id"]);
744 print "<div class=\"browserFeedInfo\">";
745 print "<b>Feed information:</b>";
746 print "<div class=\"detailsPart\">";
748 $result = db_query($link, "SELECT
750 SUBSTRING(last_updated,1,19) AS last_updated
751 FROM ttrss_feeds WHERE id = '$id'");
753 $feed_url = db_fetch_result($result, 0, "feed_url");
754 $site_url = db_fetch_result($result, 0, "site_url");
755 $last_updated = db_fetch_result($result, 0, "last_updated");
757 if (get_pref($link, 'HEADLINES_SMART_DATE')) {
758 $last_updated = smart_date_time(strtotime($last_updated));
760 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
761 $last_updated = date($short_date, strtotime($last_updated));
764 print "Site: <a target=\"_new\" href='$site_url'>$site_url</a> ".
765 "(<a target=\"_new\" href='$feed_url'>feed</a>), ".
766 "Last updated: $last_updated";
770 $result = db_query($link, "SELECT
773 substring(date_entered,1,19) as date_entered,
774 substring(updated,1,19) as updated
775 FROM ttrss_entries,ttrss_user_entries
776 WHERE ttrss_entries.id = ref_id AND feed_id = '$id'
777 ORDER BY updated DESC LIMIT 5");
779 if (db_num_rows($result) > 0) {
781 print "<b>Last headlines:</b><br>";
783 print "<div class=\"detailsPart\">";
784 print "<ul class=\"compact\">";
785 while ($line = db_fetch_assoc($result)) {
787 if (get_pref($link, 'HEADLINES_SMART_DATE')) {
788 $entry_dt = smart_date_time(strtotime($line["updated"]));
790 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
791 $entry_dt = date($short_date, strtotime($line["updated"]));
794 print "<li><a target=\"_new\" href=\"" . $line["link"] . "\">" . $line["title"] . "</a>" .
795 " <span class=\"insensitive\">($entry_dt)</span></li>";
805 print "<p>This panel shows feeds subscribed by other users of this system, just in case you are interested in some of them too.</p>";
807 $limit = db_escape_string($_GET["limit"]);
809 if (!$limit) $limit = 25;
811 $owner_uid = $_SESSION["uid"];
813 $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers
814 FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
815 WHERE tf.feed_url = ttrss_feeds.feed_url
816 AND owner_uid = '$owner_uid') GROUP BY feed_url
817 ORDER BY subscribers DESC LIMIT $limit");
820 print "<div style=\"float : right\">
821 Top <select id=\"feedBrowserLimit\">";
823 foreach (array(25, 50, 100) as $l) {
824 $issel = ($l == $limit) ?
"selected" : "";
825 print "<option $issel>$l</option>";
829 <input type=\"submit\" class=\"button\"
830 onclick=\"updateBigFeedBrowser()\" value=\"Show\">
833 print "<p id=\"fbrOpToolbar\">Selection:
834 <input type='submit' class='button' onclick=\"feedBrowserSubscribe()\"
835 disabled=\"true\" value=\"Subscribe\">";
837 print "<ul class='nomarks' id='browseBigFeedList'>";
841 while ($line = db_fetch_assoc($result)) {
842 $feed_url = $line["feed_url"];
843 $subscribers = $line["subscribers"];
845 $det_result = db_query($link, "SELECT site_url,title,id
846 FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1");
848 $details = db_fetch_assoc($det_result);
850 $icon_file = ICONS_DIR
. "/" . $details["id"] . ".ico";
852 if (file_exists($icon_file) && filesize($icon_file) > 0) {
853 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL
.
854 "/".$details["id"].".ico\">";
856 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
859 $check_box = "<input onclick='toggleSelectFBListRow(this)' class='feedBrowseCB'
860 type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
862 $class = ($feedctr %
2) ?
"even" : "odd";
864 print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
867 print "<a href=\"javascript:browserToggleExpand('".$details["id"]."')\">" .
868 $details["title"] ."</a> " .
869 "<span class='subscribers'>($subscribers)</span>";
871 print "<div class=\"browserDetails\" id=\"BRDET-" . $details["id"] . "\">";
880 print "<li>No feeds found to subscribe.</li>";
890 $feed = db_escape_string($_GET["id"]);
891 $user = db_escape_string($_GET["user"]);
892 $pass = db_escape_string($_GET["pass"]);
893 $is_cat = $_GET["is_cat"] != false;
895 $search = db_escape_string($_GET["q"]);
896 $match_on = db_escape_string($_GET["m"]);
897 $search_mode = db_escape_string($_GET["smode"]);
899 if (!$_SESSION["uid"] && $user && $pass) {
900 authenticate_user($link, $user, $pass);
903 if ($_SESSION["uid"] ||
904 http_authenticate_user($link)) {
906 generate_syndicated_feed($link, $feed, $is_cat,
907 $search, $search_mode, $match_on);
911 if ($op == "labelFromSearch") {
912 $search = db_escape_string($_GET["search"]);
913 $search_mode = db_escape_string($_GET["smode"]);
914 $match_on = db_escape_string($_GET["match"]);
915 $is_cat = db_escape_string($_GET["is_cat"]);
916 $title = db_escape_string($_GET["title"]);
917 $feed = sprintf("%d", $_GET["feed"]);
919 $label_qparts = array();
921 $search_expr = getSearchSql($search, $match_on);
925 $search_expr .= " AND ttrss_feeds.cat_id = $feed ";
927 $search_expr .= " AND ttrss_feeds.cat_id IS NULL ";
930 if ($search_mode == "all_feeds") {
932 } else if ($search_mode == "this_cat") {
934 $tmp_result = db_query($link, "SELECT cat_id
935 FROM ttrss_feeds WHERE id = '$feed'");
937 $cat_id = db_fetch_result($tmp_result, 0, "cat_id");
940 $search_expr .= " AND ttrss_feeds.cat_id = $cat_id ";
942 $search_expr .= " AND ttrss_feeds.cat_id IS NULL ";
945 $search_expr .= " AND ttrss_feeds.id = $feed ";
950 $search_expr = db_escape_string($search_expr);
955 $result = db_query($link,
956 "INSERT INTO ttrss_labels (sql_exp,description,owner_uid)
957 VALUES ('$search_expr', '$title', '".$_SESSION["uid"]."')");
961 if ($op == "getUnread") {
962 $login = db_escape_string($_GET["login"]);
964 header("Content-Type: text/plain; charset=utf-8");
966 $result = db_query($link, "SELECT id FROM ttrss_users WHERE login = '$login'");
968 if (db_num_rows($result) == 1) {
969 $uid = db_fetch_result($result, 0, "id");
970 print getGlobalUnread($link, $uid);
972 print "-1;User not found";
975 $print_exec_time = false;
978 if ($op == "digestTest") {
979 header("Content-Type: text/plain");
980 print_r(prepare_headlines_digest($link, $_SESSION["uid"]));
981 $print_exec_time = false;
985 if ($op == "digestSend") {
986 header("Content-Type: text/plain");
987 send_headlines_digests($link);
988 $print_exec_time = false;
995 <?php
if ($print_exec_time) { ?
>
996 <!-- <?php
echo sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?
> -->