mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-23 00:21:28 +00:00
split backend rpc, various interface improvements
This commit is contained in:
274
backend.php
274
backend.php
@@ -1,5 +1,6 @@
|
||||
<?
|
||||
require_once "sessions.php";
|
||||
require_once "backend-rpc.php";
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Pragma: no-cache");
|
||||
@@ -459,213 +460,7 @@
|
||||
|
||||
|
||||
if ($op == "rpc") {
|
||||
|
||||
$subop = $_GET["subop"];
|
||||
|
||||
if ($subop == "setpref") {
|
||||
if (WEB_DEMO_MODE) {
|
||||
return;
|
||||
}
|
||||
|
||||
print "<rpc-reply>";
|
||||
|
||||
$key = db_escape_string($_GET["key"]);
|
||||
$value = db_escape_string($_GET["value"]);
|
||||
|
||||
set_pref($link, $key, $value);
|
||||
|
||||
print "<param-set key=\"$key\" value=\"$value\"/>";
|
||||
|
||||
print "</rpc-reply>";
|
||||
|
||||
}
|
||||
|
||||
if ($subop == "getLabelCounters") {
|
||||
$aid = $_GET["aid"];
|
||||
print "<rpc-reply>";
|
||||
getLabelCounters($link);
|
||||
if ($aid) {
|
||||
getFeedCounter($link, $aid);
|
||||
}
|
||||
print "</rpc-reply>";
|
||||
}
|
||||
|
||||
if ($subop == "getFeedCounters") {
|
||||
print "<rpc-reply>";
|
||||
getFeedCounters($link);
|
||||
print "</rpc-reply>";
|
||||
}
|
||||
|
||||
if ($subop == "getAllCounters") {
|
||||
print "<rpc-reply>";
|
||||
getAllCounters($link);
|
||||
print "</rpc-reply>";
|
||||
}
|
||||
|
||||
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 "<rpc-reply>";
|
||||
getFeedCounter($link, $feed_id);
|
||||
print "</rpc-reply>";
|
||||
|
||||
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 "<rpc-reply>";
|
||||
|
||||
if ($cid == 0) {
|
||||
|
||||
db_query($link, "INSERT INTO ttrss_scheduled_updates
|
||||
(owner_uid, feed_id, entered) VALUES
|
||||
(".$_SESSION["uid"].", NULL, NOW())");
|
||||
|
||||
// print "<!-- ScheduledOK -->";
|
||||
|
||||
} else {
|
||||
// print "<!-- RequestAlreadyInQueue -->";
|
||||
}
|
||||
|
||||
# print "</rpc-reply>";
|
||||
}
|
||||
|
||||
} else {
|
||||
update_all_feeds($link, $subop == "forceUpdateAllFeeds");
|
||||
}
|
||||
|
||||
$global_unread_caller = sprintf("%d", $_GET["uctr"]);
|
||||
$global_unread = getGlobalUnread($link);
|
||||
|
||||
print "<rpc-reply>";
|
||||
|
||||
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 "</rpc-reply>";
|
||||
|
||||
}
|
||||
|
||||
/* 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 "<rpc-reply>";
|
||||
getAllCounters($link);
|
||||
print "</rpc-reply>";
|
||||
}
|
||||
|
||||
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 "<rpc-reply>";
|
||||
getAllCounters($link);
|
||||
print "</rpc-reply>";
|
||||
}
|
||||
|
||||
if ($subop == "sanityCheck") {
|
||||
if (sanity_check($link)) {
|
||||
print "<error error-code=\"0\"/>";
|
||||
}
|
||||
}
|
||||
|
||||
if ($subop == "globalPurge") {
|
||||
|
||||
print "<rpc-reply>";
|
||||
global_purge_old_posts($link, true);
|
||||
print "</rpc-reply>";
|
||||
|
||||
}
|
||||
|
||||
handle_rpc_request($link);
|
||||
}
|
||||
|
||||
if ($op == "feeds") {
|
||||
@@ -2093,10 +1888,9 @@
|
||||
if (!get_pref($link, 'ENABLE_FEED_CATS')) {
|
||||
print "<tr class=\"title\">
|
||||
<td width='5%' align='center'> </td>
|
||||
<td width='30%'><a href=\"javascript:updateFeedList('title')\">Title</a></td>
|
||||
<td width='30%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td>
|
||||
<td width='15%'><a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a></td>
|
||||
<td width='15%'><a href=\"javascript:updateFeedList('purge_interval')\">Purge Interval</a></td></tr>";
|
||||
<td width='40%'><a href=\"javascript:updateFeedList('title')\">Title</a></td>
|
||||
<td width='45%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td>
|
||||
<td width='15%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">Updated</a></td>";
|
||||
}
|
||||
|
||||
$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 "<tr class=\"title\">
|
||||
<td width='5%' align='center'> </td>
|
||||
<td width='30%'><a href=\"javascript:updateFeedList('title')\">Title</a></td>
|
||||
<td width='30%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td>
|
||||
<td width='15%'><a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a></td>
|
||||
<td width='15%'><a href=\"javascript:updateFeedList('purge_interval')\">Purge Interval</a></td></tr>";
|
||||
<td width='40%'><a href=\"javascript:updateFeedList('title')\">Title</a></td>
|
||||
<td width='45%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td>
|
||||
<td width='15%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">Updated</a></td>";
|
||||
|
||||
$cur_cat_id = $cat_id;
|
||||
}
|
||||
@@ -2171,12 +1968,15 @@
|
||||
$edit_cat . "</a></td>";
|
||||
} */
|
||||
|
||||
print "<td><a href=\"javascript:editFeed($feed_id);\">" .
|
||||
/* print "<td><a href=\"javascript:editFeed($feed_id);\">" .
|
||||
$update_intervals[$line["update_interval"]] . "</a></td>";
|
||||
|
||||
print "<td><a href=\"javascript:editFeed($feed_id);\">" .
|
||||
$purge_intervals[$line["purge_interval"]] . "</a></td>";
|
||||
|
||||
$purge_intervals[$line["purge_interval"]] . "</a></td>"; */
|
||||
|
||||
print "<td align='right'><a href=\"javascript:editFeed($feed_id);\">" .
|
||||
"$last_updated</a></td>";
|
||||
|
||||
print "</tr>";
|
||||
|
||||
++$lnum;
|
||||
@@ -2230,15 +2030,6 @@
|
||||
onclick=\"javascript:categorizeSelectedFeeds()\" value=\"Set category\">";
|
||||
|
||||
}
|
||||
|
||||
if (get_pref($link, 'ENABLE_PREFS_CATCHUP_UNCATCHUP')) {
|
||||
print "
|
||||
<input type=\"submit\" class=\"button\"
|
||||
onclick=\"javascript:readSelectedFeeds(true)\" value=\"Mark as read\">
|
||||
<input type=\"submit\" class=\"button\"
|
||||
onclick=\"javascript:readSelectedFeeds(false)\"
|
||||
value=\"Mark as unread\"> ";
|
||||
}
|
||||
|
||||
print "
|
||||
All feeds: <input type=\"submit\"
|
||||
@@ -2378,7 +2169,6 @@
|
||||
if ($subop == "editSave") {
|
||||
|
||||
$regexp = db_escape_string($_GET["r"]);
|
||||
$descr = db_escape_string($_GET["d"]);
|
||||
$match = db_escape_string($_GET["m"]);
|
||||
$filter_id = db_escape_string($_GET["id"]);
|
||||
$feed_id = db_escape_string($_GET["fid"]);
|
||||
@@ -2392,7 +2182,6 @@
|
||||
|
||||
$result = db_query($link, "UPDATE ttrss_filters SET
|
||||
reg_exp = '$regexp',
|
||||
description = '$descr',
|
||||
feed_id = $feed_id,
|
||||
action_id = '$action_id',
|
||||
filter_type = (SELECT id FROM ttrss_filter_types WHERE
|
||||
@@ -2496,7 +2285,6 @@
|
||||
|
||||
$result = db_query($link, "SELECT
|
||||
ttrss_filters.id AS id,reg_exp,
|
||||
ttrss_filters.description AS description,
|
||||
ttrss_filter_types.name AS filter_type_name,
|
||||
ttrss_filter_types.description AS filter_type_descr,
|
||||
feed_id,
|
||||
@@ -2529,9 +2317,8 @@
|
||||
<td width=\"20%\">Filter expression</td>
|
||||
<td width=\"20%\">Feed</td>
|
||||
<td width=\"15%\">Match</td>
|
||||
<td width=\"15%\">Action</td>
|
||||
<td width=\"30%\">Description</td></tr>";
|
||||
|
||||
<td width=\"15%\">Action</td>";
|
||||
|
||||
$lnum = 0;
|
||||
|
||||
while ($line = db_fetch_assoc($result)) {
|
||||
@@ -2551,14 +2338,11 @@
|
||||
print "<tr class=\"$class\" $this_row_id>";
|
||||
|
||||
$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 "<td align='center'><input onclick='toggleSelectRow(this);'
|
||||
type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>";
|
||||
|
||||
@@ -2573,9 +2357,6 @@
|
||||
|
||||
print "<td><a href=\"javascript:editFilter($filter_id);\">" .
|
||||
$line["action_description"] . "</td>";
|
||||
|
||||
print "<td><a href=\"javascript:editFilter($filter_id);\">" .
|
||||
$line["description"] . "</td>";
|
||||
|
||||
} else if ($filter_id != $edit_filter_id) {
|
||||
|
||||
@@ -2588,7 +2369,6 @@
|
||||
print "<td>".$line["feed_title"]."</td>";
|
||||
print "<td>".$line["filter_type_descr"]."</td>";
|
||||
print "<td>".$line["action_description"]."</td>";
|
||||
print "<td>".$line["description"]."</td>";
|
||||
|
||||
} else {
|
||||
|
||||
@@ -2642,10 +2422,6 @@
|
||||
|
||||
print "</select></td>";
|
||||
|
||||
|
||||
print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
|
||||
"\"></td>";
|
||||
|
||||
print "</td>";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user