$id = $this->dbh->escape_string($_REQUEST["id"]);
$_SESSION["profile"] = $id;
- $_SESSION["prefs_cache"] = array();
}
function remprofiles() {
WHERE orig_feed_id = '$id') = 0 AND
id = '$id' AND owner_uid = ".$_SESSION["uid"]);
- $rc = $this->dbh->affected_rows($result);
+ $this->dbh->affected_rows($result);
}
}
$login = $this->dbh->escape_string($_REQUEST['login']);
$pass = trim($_REQUEST['pass']); // escaped later
- $rc = subscribe_to_feed($feed, $cat, $login, $pass);
+ $rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass);
print json_encode(array("result" => $rc));
}
$key = $_REQUEST['key'];
$value = str_replace("\n", "<br/>", $_REQUEST['value']);
- set_pref($key, $value, $_SESSION['uid'], $key != 'USER_STYLESHEET');
+ set_pref($key, $value, false, $key != 'USER_STYLESHEET');
print json_encode(array("param" =>$key, "value" => $value));
}
$mark = "false";
}
- $result = $this->dbh->query("UPDATE ttrss_user_entries SET marked = $mark,
+ $this->dbh->query("UPDATE ttrss_user_entries SET marked = $mark,
last_marked = NOW()
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
function delete() {
$ids = $this->dbh->escape_string($_REQUEST["ids"]);
- $result = $this->dbh->query("DELETE FROM ttrss_user_entries
- WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
+ $this->dbh->query("DELETE FROM ttrss_user_entries
+ WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
purge_orphans();
$result = $this->dbh->query("SELECT feed_url,site_url,title FROM ttrss_archived_feeds
WHERE id = (SELECT orig_feed_id FROM ttrss_user_entries WHERE ref_id = $id
- AND owner_uid = ".$_SESSION["uid"].")");
+ AND owner_uid = ".$_SESSION["uid"].") AND owner_uid = " . $_SESSION["uid"]);
if ($this->dbh->num_rows($result) != 0) {
$feed_url = $this->dbh->escape_string(db_fetch_result($result, 0, "feed_url"));
if ($feed_id) {
$result = $this->dbh->query("SELECT id FROM ttrss_archived_feeds
- WHERE id = '$feed_id'");
+ WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
if ($this->dbh->num_rows($result) == 0) {
+ $result = db_query("SELECT MAX(id) AS id FROM ttrss_archived_feeds");
+ $new_feed_id = (int)db_fetch_result($result, 0, "id") + 1;
+
$this->dbh->query("INSERT INTO ttrss_archived_feeds
(id, owner_uid, title, feed_url, site_url)
- SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
+ SELECT $new_feed_id, owner_uid, title, feed_url, site_url from ttrss_feeds
WHERE id = '$feed_id'");
+ } else {
+ $new_feed_id = $this->dbh->fetch_result($result, 0, "id");
}
$this->dbh->query("UPDATE ttrss_user_entries
- SET orig_feed_id = feed_id, feed_id = NULL
+ SET orig_feed_id = $new_feed_id, feed_id = NULL
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
}
}
function publ() {
$pub = $_REQUEST["pub"];
$id = $this->dbh->escape_string($_REQUEST["id"]);
- $note = trim(strip_tags($this->dbh->escape_string($_REQUEST["note"])));
if ($pub == "1") {
$pub = "true";
$pub = "false";
}
- $result = $this->dbh->query("UPDATE ttrss_user_entries SET
+ $this->dbh->query("UPDATE ttrss_user_entries SET
published = $pub, last_published = NOW()
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
"/public.php?op=rss&id=-2&key=" .
get_feed_access_key(-2, false);
- $p = new Publisher(PUBSUBHUBBUB_HUB);
+ $p = new pubsubhubbub\publisher\Publisher(PUBSUBHUBBUB_HUB);
$pubsub_result = $p->publish_update($rss_link);
}
$reply = array();
- if ($seq) $reply['seq'] = $seq;
+ if (!empty($_REQUEST['seq'])) $reply['seq'] = (int) $_REQUEST['seq'];
if ($last_article_id != getLastArticleId()) {
$reply['counters'] = getAllCounters();
$_SESSION["hasAudio"] = $_REQUEST["hasAudio"] === "true";
$_SESSION["hasSandbox"] = $_REQUEST["hasSandbox"] === "true";
$_SESSION["hasMp3"] = $_REQUEST["hasMp3"] === "true";
+ $_SESSION["clientTzOffset"] = $_REQUEST["clientTzOffset"];
$reply = array();
if ($reply['error']['code'] == 0) {
$reply['init-params'] = make_init_params();
- $reply['runtime-info'] = make_runtime_info();
+ $reply['runtime-info'] = make_runtime_info(true);
}
print json_encode($reply);
}
function updateFeedBrowser() {
+ if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) return;
+
$search = $this->dbh->escape_string($_REQUEST["search"]);
$limit = $this->dbh->escape_string($_REQUEST["limit"]);
$mode = (int) $this->dbh->escape_string($_REQUEST["mode"]);
if ($this->dbh->num_rows($result) == 0) {
$result = $this->dbh->query("INSERT INTO ttrss_feeds
(owner_uid,feed_url,title,cat_id,site_url)
- VALUES ('$id','".$_SESSION["uid"]."',
+ VALUES ('".$_SESSION["uid"]."',
'$feed_url', '$title', NULL, '$site_url')");
}
}
$feed_id = $this->dbh->escape_string($_REQUEST['feed_id']);
$is_cat = $this->dbh->escape_string($_REQUEST['is_cat']) == "true";
$mode = $this->dbh->escape_string($_REQUEST['mode']);
+ $search_query = $this->dbh->escape_string($_REQUEST['search_query']);
+ $search_lang = $this->dbh->escape_string($_REQUEST['search_lang']);
- catchup_feed($feed_id, $is_cat, false, false, $mode);
+ Feeds::catchup_feed($feed_id, $is_cat, false, $mode, [$search_query, $search_lang]);
print json_encode(array("message" => "UPDATE_COUNTERS"));
}
$id = 0;
}
- print_feed_cat_select("cat_id", $id);
- }
-
- // Silent
- function clearArticleKeys() {
- $this->dbh->query("UPDATE ttrss_user_entries SET uuid = '' WHERE
- owner_uid = " . $_SESSION["uid"]);
-
- return;
+ print_feed_cat_select("cat_id", $id, '');
}
function setpanelmode() {
$wide = (int) $_REQUEST["wide"];
setcookie("ttrss_widescreen", $wide,
- time() + SESSION_COOKIE_LIFETIME);
+ time() + COOKIE_LIFETIME_LONG);
print json_encode(array("wide" => $wide));
}
- function updaterandomfeed() {
+ static function updaterandomfeed_real($dbh) {
+
// Test if the feed need a update (update interval exceded).
if (DB_TYPE == "pgsql") {
$update_limit_qpart = "AND ((
$random_qpart = sql_random_function();
+ // we could be invoked from public.php with no active session
+ if ($_SESSION["uid"]) {
+ $owner_check_qpart = "AND ttrss_feeds.owner_uid = '".$_SESSION["uid"]."'";
+ } else {
+ $owner_check_qpart = "";
+ }
+
// We search for feed needing update.
- $result = $this->dbh->query("SELECT ttrss_feeds.feed_url,ttrss_feeds.id
+ $result = $dbh->query("SELECT ttrss_feeds.feed_url,ttrss_feeds.id
FROM
ttrss_feeds, ttrss_users, ttrss_user_prefs
WHERE
ttrss_feeds.owner_uid = ttrss_users.id
AND ttrss_users.id = ttrss_user_prefs.owner_uid
AND ttrss_user_prefs.pref_name = 'DEFAULT_UPDATE_INTERVAL'
- AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]."
- $update_limit_qpart $updstart_thresh_qpart
+ $owner_check_qpart
+ $update_limit_qpart
+ $updstart_thresh_qpart
ORDER BY $random_qpart LIMIT 30");
$feed_id = -1;
$tstart = time();
- while ($line = $this->dbh->fetch_assoc($result)) {
+ while ($line = $dbh->fetch_assoc($result)) {
$feed_id = $line["id"];
if (time() - $tstart < ini_get("max_execution_time") * 0.7) {
// Purge orphans and cleanup tags
purge_orphans();
- cleanup_tags(14, 50000);
+ //cleanup_tags(14, 50000);
if ($num_updated > 0) {
print json_encode(array("message" => "UPDATE_COUNTERS",
}
+ function updaterandomfeed() {
+ RPC::updaterandomfeed_real($this->dbh);
+ }
+
private function markArticlesById($ids, $cmode) {
$tmp_ids = array();
"/public.php?op=rss&id=-2&key=" .
get_feed_access_key(-2, false);
- $p = new Publisher(PUBSUBHUBBUB_HUB);
+ $p = new pubsubhubbub\publisher\Publisher(PUBSUBHUBBUB_HUB);
- $pubsub_result = $p->publish_update($rss_link);
+ /* $pubsub_result = */ $p->publish_update($rss_link);
}
}
}
}
-}
-?>
+ function log() {
+ $msg = $this->dbh->escape_string($_REQUEST['msg']);
+ $file = $this->dbh->escape_string(basename($_REQUEST['file']));
+ $line = (int) $_REQUEST['line'];
+ $context = $this->dbh->escape_string($_REQUEST['context']);
+
+ if ($msg) {
+ Logger::get()->log_error(E_USER_WARNING,
+ $msg, 'client-js:' . $file, $line, $context);
+
+ echo json_encode(array("message" => "HOST_ERROR_LOGGED"));
+ } else {
+ echo json_encode(array("error" => "MESSAGE_NOT_FOUND"));
+ }
+
+ }
+}
\ No newline at end of file