summaryrefslogtreecommitdiff
path: root/classes/rpc.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/rpc.php')
-rwxr-xr-xclasses/rpc.php70
1 files changed, 43 insertions, 27 deletions
diff --git a/classes/rpc.php b/classes/rpc.php
index aaaf4f8d5..35125ae04 100755
--- a/classes/rpc.php
+++ b/classes/rpc.php
@@ -121,7 +121,8 @@ class RPC extends Handler_Protected {
else
$label_ids = array_map("intval", clean($_REQUEST["label_ids"] ?? []));
- $counters = is_array($feed_ids) ? Counters::get_conditional($feed_ids, $label_ids) : Counters::get_all();
+ $counters = is_array($feed_ids) && !get_pref(Prefs::DISABLE_CONDITIONAL_COUNTERS) ?
+ Counters::get_conditional($feed_ids, $label_ids) : Counters::get_all();
$reply = [
'counters' => $counters,
@@ -151,7 +152,9 @@ class RPC extends Handler_Protected {
if (count($ids) > 0)
$this->markArticlesById($ids, $cmode);
- print json_encode(["message" => "UPDATE_COUNTERS", "feeds" => Article::_feeds_of($ids)]);
+ print json_encode(["message" => "UPDATE_COUNTERS",
+ "labels" => Article::_labels_of($ids),
+ "feeds" => Article::_feeds_of($ids)]);
}
function publishSelected() {
@@ -161,17 +164,30 @@ class RPC extends Handler_Protected {
if (count($ids) > 0)
$this->publishArticlesById($ids, $cmode);
- print json_encode(["message" => "UPDATE_COUNTERS", "feeds" => Article::_feeds_of($ids)]);
+ print json_encode(["message" => "UPDATE_COUNTERS",
+ "labels" => Article::_labels_of($ids),
+ "feeds" => Article::_feeds_of($ids)]);
}
function sanityCheck() {
$_SESSION["hasSandbox"] = clean($_REQUEST["hasSandbox"]) === "true";
$_SESSION["clientTzOffset"] = clean($_REQUEST["clientTzOffset"]);
+ $client_location = $_REQUEST["clientLocation"];
+
$error = Errors::E_SUCCESS;
+ $error_params = [];
+
+ $client_scheme = parse_url($client_location, PHP_URL_SCHEME);
+ $server_scheme = parse_url(Config::get_self_url(), PHP_URL_SCHEME);
- if (get_schema_version() != SCHEMA_VERSION) {
+ if (Config::is_migration_needed()) {
$error = Errors::E_SCHEMA_MISMATCH;
+ } else if ($client_scheme != $server_scheme) {
+ $error = Errors::E_URL_SCHEME_MISMATCH;
+ $error_params["client_scheme"] = $client_scheme;
+ $error_params["server_scheme"] = $server_scheme;
+ $error_params["self_url_path"] = Config::get_self_url();
}
if ($error == Errors::E_SUCCESS) {
@@ -183,7 +199,7 @@ class RPC extends Handler_Protected {
print json_encode($reply);
} else {
- print Errors::to_json($error);
+ print Errors::to_json($error, $error_params);
}
}
@@ -219,14 +235,12 @@ class RPC extends Handler_Protected {
//print json_encode(array("message" => "UPDATE_COUNTERS"));
}
- function setpanelmode() {
+ function setWidescreen() {
$wide = (int) clean($_REQUEST["wide"]);
- // FIXME should this use SESSION_COOKIE_LIFETIME and be renewed periodically?
- setcookie("ttrss_widescreen", (string)$wide,
- time() + 86400*365);
+ set_pref(Prefs::WIDESCREEN_MODE, $wide);
- print json_encode(array("wide" => $wide));
+ print json_encode(["wide" => $wide]);
}
static function updaterandomfeed_real() {
@@ -237,27 +251,27 @@ class RPC extends Handler_Protected {
if (Config::get(Config::DB_TYPE) == "pgsql") {
$update_limit_qpart = "AND ((
update_interval = 0
- AND p.value != '-1'
+ AND (p.value IS NULL OR p.value != '-1')
AND last_updated < NOW() - CAST((COALESCE(p.value, '$default_interval') || ' minutes') AS INTERVAL)
) OR (
update_interval > 0
AND last_updated < NOW() - CAST((update_interval || ' minutes') AS INTERVAL)
) OR (
update_interval >= 0
- AND p.value != '-1'
+ AND (p.value IS NULL OR p.value != '-1')
AND (last_updated = '1970-01-01 00:00:00' OR last_updated IS NULL)
))";
} else {
$update_limit_qpart = "AND ((
update_interval = 0
- AND p.value != '-1'
+ AND (p.value IS NULL OR p.value != '-1')
AND last_updated < DATE_SUB(NOW(), INTERVAL CONVERT(COALESCE(p.value, '$default_interval'), SIGNED INTEGER) MINUTE)
) OR (
update_interval > 0
AND last_updated < DATE_SUB(NOW(), INTERVAL update_interval MINUTE)
) OR (
update_interval >= 0
- AND p.value != '-1'
+ AND (p.value IS NULL OR p.value != '-1')
AND (last_updated = '1970-01-01 00:00:00' OR last_updated IS NULL)
))";
}
@@ -368,10 +382,10 @@ class RPC extends Handler_Protected {
}
function log() {
- $msg = clean($_REQUEST['msg']);
- $file = basename(clean($_REQUEST['file']));
- $line = (int) clean($_REQUEST['line']);
- $context = clean($_REQUEST['context']);
+ $msg = clean($_REQUEST['msg'] ?? "");
+ $file = basename(clean($_REQUEST['file'] ?? ""));
+ $line = (int) clean($_REQUEST['line'] ?? 0);
+ $context = clean($_REQUEST['context'] ?? "");
if ($msg) {
Logger::log_error(E_USER_WARNING,
@@ -382,12 +396,12 @@ class RPC extends Handler_Protected {
}
function checkforupdates() {
- $rv = [];
+ $rv = ["changeset" => [], "plugins" => []];
- $git_timestamp = false;
- $git_commit = false;
+ $version = Config::get_version(false);
- get_version($git_commit, $git_timestamp);
+ $git_timestamp = $version["timestamp"] ?? false;
+ $git_commit = $version["commit"] ?? false;
if (Config::get(Config::CHECK_FOR_UPDATES) && $_SESSION["access_level"] >= 10 && $git_timestamp) {
$content = @UrlHelper::fetch(["url" => "https://tt-rss.org/version.json"]);
@@ -399,10 +413,12 @@ class RPC extends Handler_Protected {
if ($git_timestamp < (int)$content["changeset"]["timestamp"] &&
$git_commit != $content["changeset"]["id"]) {
- $rv = $content["changeset"];
+ $rv["changeset"] = $content["changeset"];
}
}
}
+
+ $rv["plugins"] = Pref_Prefs::_get_updated_plugins();
}
print json_encode($rv);
@@ -427,8 +443,8 @@ class RPC extends Handler_Protected {
$params["default_view_mode"] = get_pref(Prefs::_DEFAULT_VIEW_MODE);
$params["default_view_limit"] = (int) get_pref(Prefs::_DEFAULT_VIEW_LIMIT);
$params["default_view_order_by"] = get_pref(Prefs::_DEFAULT_VIEW_ORDER_BY);
- $params["bw_limit"] = (int) $_SESSION["bw_limit"];
- $params["is_default_pw"] = Pref_Prefs::isdefaultpassword();
+ $params["bw_limit"] = (int) ($_SESSION["bw_limit"] ?? false);
+ $params["is_default_pw"] = UserHelper::is_default_password();
$params["label_base_index"] = LABEL_BASE_INDEX;
$theme = get_pref(Prefs::USER_CSS_THEME);
@@ -449,11 +465,11 @@ class RPC extends Handler_Protected {
$max_feed_id = $row["mid"];
$num_feeds = $row["nf"];
- $params["self_url_prefix"] = get_self_url_prefix();
+ $params["self_url_prefix"] = Config::get_self_url();
$params["max_feed_id"] = (int) $max_feed_id;
$params["num_feeds"] = (int) $num_feeds;
$params["hotkeys"] = $this->get_hotkeys_map();
- $params["widescreen"] = (int) ($_COOKIE["ttrss_widescreen"] ?? 0);
+ $params["widescreen"] = (int) get_pref(Prefs::WIDESCREEN_MODE);
$params['simple_update'] = Config::get(Config::SIMPLE_UPDATE_MODE);
$params["icon_indicator_white"] = $this->image_to_base64("images/indicator_white.gif");
$params["labels"] = Labels::get_all($_SESSION["uid"]);