]> git.wh0rd.org - tt-rss.git/blobdiff - classes/rpc.php
Merge pull request #417 from DigitalDJ/master
[tt-rss.git] / classes / rpc.php
index 9cc8e704669db4a28d96ff175e2e03d2feb54bb6..b4de44a74ebd298d6dc05fde88c9a6ef9b6be332 100644 (file)
@@ -95,7 +95,7 @@ class RPC extends Handler_Protected {
                                                        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);
                }
        }
 
@@ -138,7 +138,7 @@ class RPC extends Handler_Protected {
                        $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"]);
 
@@ -148,8 +148,8 @@ class RPC extends Handler_Protected {
        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();
 
@@ -258,7 +258,6 @@ class RPC extends Handler_Protected {
        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";
@@ -266,7 +265,7 @@ class RPC extends Handler_Protected {
                        $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"]);
 
@@ -476,7 +475,8 @@ class RPC extends Handler_Protected {
                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 ((
@@ -507,16 +507,24 @@ class RPC extends Handler_Protected {
 
                $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;
@@ -527,7 +535,7 @@ class RPC extends Handler_Protected {
 
                $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) {
@@ -551,6 +559,10 @@ class RPC extends Handler_Protected {
 
        }
 
+       function updaterandomfeed() {
+               RPC::updaterandomfeed_real($this->dbh);
+       }
+
        private function markArticlesById($ids, $cmode) {
 
                $tmp_ids = array();
@@ -607,7 +619,7 @@ class RPC extends Handler_Protected {
 
                        $p = new Publisher(PUBSUBHUBBUB_HUB);
 
-                       $pubsub_result = $p->publish_update($rss_link);
+                       /* $pubsub_result = */ $p->publish_update($rss_link);
                }
        }