From 01b3e1919a5c99d21c0db8c13f1883320940c147 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 29 Mar 2006 04:11:48 +0100 Subject: split backend rpc, various interface improvements --- backend.php | 274 ++++++------------------------------------------------------ 1 file changed, 25 insertions(+), 249 deletions(-) (limited to 'backend.php') diff --git a/backend.php b/backend.php index 8acf26868..43b3b4290 100644 --- a/backend.php +++ b/backend.php @@ -1,5 +1,6 @@ "; - - $key = db_escape_string($_GET["key"]); - $value = db_escape_string($_GET["value"]); - - set_pref($link, $key, $value); - - print ""; - - print ""; - - } - - if ($subop == "getLabelCounters") { - $aid = $_GET["aid"]; - print ""; - getLabelCounters($link); - if ($aid) { - getFeedCounter($link, $aid); - } - print ""; - } - - if ($subop == "getFeedCounters") { - print ""; - getFeedCounters($link); - print ""; - } - - if ($subop == "getAllCounters") { - print ""; - getAllCounters($link); - print ""; - } - - if ($subop == "mark") { - $mark = $_GET["mark"]; - $id = db_escape_string($_GET["id"]); - - if ($mark == "1") { - $mark = "true"; - } else { - $mark = "false"; - } - - // FIXME this needs collision testing - - $result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark - WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); - } - - if ($subop == "updateFeed") { - $feed_id = db_escape_string($_GET["feed"]); - - $result = db_query($link, - "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id' - AND owner_uid = " . $_SESSION["uid"]); - - if (db_num_rows($result) > 0) { - $feed_url = db_fetch_result($result, 0, "feed_url"); - update_rss_feed($link, $feed_url, $feed_id); - } - - print ""; - getFeedCounter($link, $feed_id); - print ""; - - return; - } - - if ($subop == "forceUpdateAllFeeds" || $subop == "updateAllFeeds") { - - if (ENABLE_UPDATE_DAEMON) { - - if ($subop == "forceUpdateAllFeeds") { - - $result = db_query($link, "SELECT count(id) AS cid FROM - ttrss_scheduled_updates WHERE feed_id IS NULL AND - owner_uid = " . $_SESSION["uid"]); - - $cid = db_fetch_result($result, 0, "cid"); - -# print ""; - - if ($cid == 0) { - - db_query($link, "INSERT INTO ttrss_scheduled_updates - (owner_uid, feed_id, entered) VALUES - (".$_SESSION["uid"].", NULL, NOW())"); - -// print ""; - - } else { -// print ""; - } - -# print ""; - } - - } else { - update_all_feeds($link, $subop == "forceUpdateAllFeeds"); - } - - $global_unread_caller = sprintf("%d", $_GET["uctr"]); - $global_unread = getGlobalUnread($link); - - print ""; - - if ($global_unread_caller != $global_unread) { - - $omode = $_GET["omode"]; - - if (!$omode) $omode = "tflc"; - - if (strchr($omode, "l")) getLabelCounters($link); - if (strchr($omode, "f")) getFeedCounters($link); - if (strchr($omode, "t")) getTagCounters($link); - if (strchr($omode, "c")) { - if (get_pref($link, 'ENABLE_FEED_CATS')) { - getCategoryCounters($link); - } - } - } - - getGlobalCounters($link, $global_unread); - - print ""; - - } - - /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ - if ($subop == "catchupSelected") { - - $ids = split(",", db_escape_string($_GET["ids"])); - - $cmode = sprintf("%d", $_GET["cmode"]); - - foreach ($ids as $id) { - - if ($cmode == 0) { - db_query($link, "UPDATE ttrss_user_entries SET - unread = false,last_read = NOW() - WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); - } else if ($cmode == 1) { - db_query($link, "UPDATE ttrss_user_entries SET - unread = true - WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); - } else { - db_query($link, "UPDATE ttrss_user_entries SET - unread = NOT unread,last_read = NOW() - WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); - } - } - print ""; - getAllCounters($link); - print ""; - } - - if ($subop == "markSelected") { - - $ids = split(",", db_escape_string($_GET["ids"])); - - $cmode = sprintf("%d", $_GET["cmode"]); - - foreach ($ids as $id) { - - if ($cmode == 0) { - db_query($link, "UPDATE ttrss_user_entries SET - marked = false - WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); - } else if ($cmode == 1) { - db_query($link, "UPDATE ttrss_user_entries SET - marked = true - WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); - } else { - db_query($link, "UPDATE ttrss_user_entries SET - marked = NOT marked - WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); - } - } - print ""; - getAllCounters($link); - print ""; - } - - if ($subop == "sanityCheck") { - if (sanity_check($link)) { - print ""; - } - } - - if ($subop == "globalPurge") { - - print ""; - global_purge_old_posts($link, true); - print ""; - - } - + handle_rpc_request($link); } if ($op == "feeds") { @@ -2093,10 +1888,9 @@ if (!get_pref($link, 'ENABLE_FEED_CATS')) { print "   - Title - Feed - Update Interval - Purge Interval"; + Title + Feed + Updated"; } $lnum = 0; @@ -2111,14 +1905,18 @@ $edit_title = htmlspecialchars(db_unescape_string($line["title"])); $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"])); $edit_cat = htmlspecialchars(db_unescape_string($line["category"])); - -// if ($line["update_interval"] == "0") $line["update_interval"] = "Default"; -// if ($line["update_interval"] == "-1") $line["update_interval"] = "Disabled"; -// if ($line["purge_interval"] == "0") $line["purge_interval"] = "Default"; -// if ($line["purge_interval"] < 0) $line["purge_interval"] = "Disabled"; if (!$edit_cat) $edit_cat = "Uncategorized"; + $last_updated = $line["last_updated"]; + + if (get_pref($link, 'HEADLINES_SMART_DATE')) { + $last_updated = smart_date_time(strtotime($last_updated)); + } else { + $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); + $last_updated = date($short_date, strtotime($last_updated)); + } + if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) { $lnum = 0; @@ -2126,10 +1924,9 @@ print "   - Title - Feed - Update Interval - Purge Interval"; + Title + Feed + Updated"; $cur_cat_id = $cat_id; } @@ -2171,12 +1968,15 @@ $edit_cat . ""; } */ - print "" . +/* print "" . $update_intervals[$line["update_interval"]] . ""; print "" . - $purge_intervals[$line["purge_interval"]] . ""; - + $purge_intervals[$line["purge_interval"]] . ""; */ + + print "" . + "$last_updated"; + print ""; ++$lnum; @@ -2230,15 +2030,6 @@ onclick=\"javascript:categorizeSelectedFeeds()\" value=\"Set category\">"; } - - if (get_pref($link, 'ENABLE_PREFS_CATCHUP_UNCATCHUP')) { - print " - -  "; - } print "  All feeds: Filter expression Feed Match - Action - Description"; - + Action"; + $lnum = 0; while ($line = db_fetch_assoc($result)) { @@ -2551,14 +2338,11 @@ print ""; $line["regexp"] = htmlspecialchars($line["reg_exp"]); - $line["description"] = htmlspecialchars($line["description"]); if (!$line["feed_title"]) $line["feed_title"] = "All feeds"; if (!$edit_filter_id || $subop != "edit") { - if (!$line["description"]) $line["description"] = "[No description]"; - print ""; @@ -2573,9 +2357,6 @@ print "" . $line["action_description"] . ""; - - print "" . - $line["description"] . ""; } else if ($filter_id != $edit_filter_id) { @@ -2588,7 +2369,6 @@ print "".$line["feed_title"].""; print "".$line["filter_type_descr"].""; print "".$line["action_description"].""; - print "".$line["description"].""; } else { @@ -2642,10 +2422,6 @@ print ""; - - print ""; - print ""; } -- cgit v1.2.3