]> git.wh0rd.org Git - tt-rss.git/commitdiff
remove $link
authorAndrew Dolgov <fox@fakecake.org>
Wed, 17 Apr 2013 12:23:15 +0000 (16:23 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Wed, 17 Apr 2013 12:48:41 +0000 (16:48 +0400)
80 files changed:
backend.php
classes/api.php
classes/article.php
classes/auth/base.php
classes/backend.php
classes/db.php
classes/db/pgsql.php
classes/dbupdater.php
classes/dlg.php
classes/feeds.php
classes/handler.php
classes/handler/public.php
classes/logger/sql.php
classes/opml.php
classes/plugin.php
classes/pluginhost.php
classes/pref/feeds.php
classes/pref/filters.php
classes/pref/labels.php
classes/pref/prefs.php
classes/pref/system.php
classes/pref/users.php
classes/rpc.php
include/ccache.php
include/db-prefs.php
include/db.php
include/digest.php
include/feedbrowser.php
include/functions.php
include/labels.php
include/rssfuncs.php
include/sanity_check.php
include/sessions.php
index.php
opml.php
plugins/af_buttersafe/init.php
plugins/af_explosm/init.php
plugins/af_gocomics/init.php
plugins/af_pennyarcade/init.php
plugins/af_redditimgur/init.php
plugins/af_unburn/init.php
plugins/auth_internal/init.php
plugins/auth_remote/init.php
plugins/bookmarklets/init.php
plugins/close_button/init.php
plugins/digest/digest_body.php
plugins/digest/init.php
plugins/embed_original/init.php
plugins/example/init.php
plugins/example_api/init.php
plugins/example_article/init.php
plugins/example_feed/init.php
plugins/example_routing/init.php
plugins/example_vfeed/init.php
plugins/googlereaderimport/init.php
plugins/googlereaderkeys/init.php
plugins/import_export/init.php
plugins/instances/init.php
plugins/mail/init.php
plugins/mailto/init.php
plugins/mark_button/init.php
plugins/mobile/article.php
plugins/mobile/backend.php
plugins/mobile/cat.php
plugins/mobile/feed.php
plugins/mobile/home.php
plugins/mobile/index.php
plugins/mobile/init.php
plugins/mobile/mobile-functions.php
plugins/mobile/prefs.php
plugins/note/init.php
plugins/nsfw/init.php
plugins/share/init.php
plugins/swap_jk/init.php
plugins/updater/init.php
prefs.php
public.php
register.php
update.php
update_daemon2.php

index b583d379e46fbbe726655adbfe7698ecb10a7027..b06cca2d24e0dbe6f185ecfc23bd01c0df1b4eb7 100644 (file)
@@ -50,7 +50,7 @@
 
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
 
-       if (!init_plugins($link)) return;
+       if (!init_plugins()) return;
 
        header("Content-Type: text/json; charset=utf-8");
 
        }
 
        if (SINGLE_USER_MODE) {
-               authenticate_user($link, "admin", null);
+               authenticate_user( "admin", null);
        }
 
        if ($_SESSION["uid"]) {
-               if (!validate_session($link)) {
+               if (!validate_session()) {
                        header("Content-Type: text/json");
                        print json_encode(array("error" => array("code" => 6)));
                        return;
                }
-               load_user_plugins($link, $_SESSION["uid"]);
+               load_user_plugins( $_SESSION["uid"]);
        }
 
        $purge_intervals = array(
                5 => __("Power User"),
                10 => __("Administrator"));
 
-       #$error = sanity_check($link);
+       #$error = sanity_check();
 
        #if ($error['code'] != 0 && $op != "logout") {
        #       print json_encode(array("error" => $error));
                if ($override) {
                        $handler = $override;
                } else {
-                       $handler = new $op($link, $_REQUEST);
+                       $handler = new $op(Db::get(), $_REQUEST);
                }
 
                if ($handler && implements_interface($handler, 'IHandler')) {
        print json_encode(array("error" => array("code" => 7)));
 
        // We close the connection to database.
-       db_close($link);
+       db_close();
 ?>
index 958256be4cddb6ec3d101186ec73c9a32a5e8b08..10e511919dec7e79929631ff7ce21bdb995aeefa 100644 (file)
@@ -18,7 +18,7 @@ class API extends Handler {
                                return false;
                        }
 
-                       if ($_SESSION["uid"] && $method != "logout" && !get_pref($this->link, 'ENABLE_API_ACCESS')) {
+                       if ($_SESSION["uid"] && $method != "logout" && !get_pref( 'ENABLE_API_ACCESS')) {
                                print $this->wrap(self::STATUS_ERR, array("error" => 'API_DISABLED'));
                                return false;
                        }
@@ -50,13 +50,13 @@ class API extends Handler {
                @session_destroy();
                @session_start();
 
-               $login = db_escape_string($this->link, $_REQUEST["user"]);
+               $login = db_escape_string( $_REQUEST["user"]);
                $password = $_REQUEST["password"];
                $password_base64 = base64_decode($_REQUEST["password"]);
 
                if (SINGLE_USER_MODE) $login = "admin";
 
-               $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE login = '$login'");
+               $result = db_query( "SELECT id FROM ttrss_users WHERE login = '$login'");
 
                if (db_num_rows($result) != 0) {
                        $uid = db_fetch_result($result, 0, "id");
@@ -69,11 +69,11 @@ class API extends Handler {
                        return;
                }
 
-               if (get_pref($this->link, "ENABLE_API_ACCESS", $uid)) {
-                       if (authenticate_user($this->link, $login, $password)) {               // try login with normal password
+               if (get_pref( "ENABLE_API_ACCESS", $uid)) {
+                       if (authenticate_user( $login, $password)) {               // try login with normal password
                                print $this->wrap(self::STATUS_OK, array("session_id" => session_id(),
                                        "api_level" => self::API_LEVEL));
-                       } else if (authenticate_user($this->link, $login, $password_base64)) { // else try with base64_decoded password
+                       } else if (authenticate_user( $login, $password_base64)) { // else try with base64_decoded password
                                print $this->wrap(self::STATUS_OK,      array("session_id" => session_id(),
                                        "api_level" => self::API_LEVEL));
                        } else {                                                         // else we are not logged in
@@ -95,29 +95,29 @@ class API extends Handler {
        }
 
        function getUnread() {
-               $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]);
-               $is_cat = db_escape_string($this->link, $_REQUEST["is_cat"]);
+               $feed_id = db_escape_string( $_REQUEST["feed_id"]);
+               $is_cat = db_escape_string( $_REQUEST["is_cat"]);
 
                if ($feed_id) {
-                       print $this->wrap(self::STATUS_OK, array("unread" => getFeedUnread($this->link, $feed_id, $is_cat)));
+                       print $this->wrap(self::STATUS_OK, array("unread" => getFeedUnread( $feed_id, $is_cat)));
                } else {
-                       print $this->wrap(self::STATUS_OK, array("unread" => getGlobalUnread($this->link)));
+                       print $this->wrap(self::STATUS_OK, array("unread" => getGlobalUnread()));
                }
        }
 
        /* Method added for ttrss-reader for Android */
        function getCounters() {
-               print $this->wrap(self::STATUS_OK, getAllCounters($this->link));
+               print $this->wrap(self::STATUS_OK, getAllCounters());
        }
 
        function getFeeds() {
-               $cat_id = db_escape_string($this->link, $_REQUEST["cat_id"]);
+               $cat_id = db_escape_string( $_REQUEST["cat_id"]);
                $unread_only = sql_bool_to_bool($_REQUEST["unread_only"]);
-               $limit = (int) db_escape_string($this->link, $_REQUEST["limit"]);
-               $offset = (int) db_escape_string($this->link, $_REQUEST["offset"]);
+               $limit = (int) db_escape_string( $_REQUEST["limit"]);
+               $offset = (int) db_escape_string( $_REQUEST["offset"]);
                $include_nested = sql_bool_to_bool($_REQUEST["include_nested"]);
 
-               $feeds = $this->api_get_feeds($this->link, $cat_id, $unread_only, $limit, $offset, $include_nested);
+               $feeds = $this->api_get_feeds( $cat_id, $unread_only, $limit, $offset, $include_nested);
 
                print $this->wrap(self::STATUS_OK, $feeds);
        }
@@ -134,7 +134,7 @@ class API extends Handler {
                else
                        $nested_qpart = "true";
 
-               $result = db_query($this->link, "SELECT
+               $result = db_query( "SELECT
                                id, title, order_id, (SELECT COUNT(id) FROM
                                ttrss_feeds WHERE
                                ttrss_feed_categories.id IS NOT NULL AND cat_id = ttrss_feed_categories.id) AS num_feeds,
@@ -149,10 +149,10 @@ class API extends Handler {
 
                while ($line = db_fetch_assoc($result)) {
                        if ($include_empty || $line["num_feeds"] > 0 || $line["num_cats"] > 0) {
-                               $unread = getFeedUnread($this->link, $line["id"], true);
+                               $unread = getFeedUnread( $line["id"], true);
 
                                if ($enable_nested)
-                                       $unread += getCategoryChildrenUnread($this->link, $line["id"]);
+                                       $unread += getCategoryChildrenUnread( $line["id"]);
 
                                if ($unread || !$unread_only) {
                                        array_push($cats, array("id" => $line["id"],
@@ -166,11 +166,11 @@ class API extends Handler {
 
                foreach (array(-2,-1,0) as $cat_id) {
                        if ($include_empty || !$this->isCategoryEmpty($cat_id)) {
-                               $unread = getFeedUnread($this->link, $cat_id, true);
+                               $unread = getFeedUnread( $cat_id, true);
 
                                if ($unread || !$unread_only) {
                                        array_push($cats, array("id" => $cat_id,
-                                               "title" => getCategoryTitle($this->link, $cat_id),
+                                               "title" => getCategoryTitle( $cat_id),
                                                "unread" => $unread));
                                }
                        }
@@ -180,22 +180,22 @@ class API extends Handler {
        }
 
        function getHeadlines() {
-               $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]);
+               $feed_id = db_escape_string( $_REQUEST["feed_id"]);
                if ($feed_id != "") {
 
-                       $limit = (int)db_escape_string($this->link, $_REQUEST["limit"]);
+                       $limit = (int)db_escape_string( $_REQUEST["limit"]);
 
                        if (!$limit || $limit >= 60) $limit = 60;
 
-                       $offset = (int)db_escape_string($this->link, $_REQUEST["skip"]);
-                       $filter = db_escape_string($this->link, $_REQUEST["filter"]);
+                       $offset = (int)db_escape_string( $_REQUEST["skip"]);
+                       $filter = db_escape_string( $_REQUEST["filter"]);
                        $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]);
                        $show_excerpt = sql_bool_to_bool($_REQUEST["show_excerpt"]);
                        $show_content = sql_bool_to_bool($_REQUEST["show_content"]);
                        /* all_articles, unread, adaptive, marked, updated */
-                       $view_mode = db_escape_string($this->link, $_REQUEST["view_mode"]);
+                       $view_mode = db_escape_string( $_REQUEST["view_mode"]);
                        $include_attachments = sql_bool_to_bool($_REQUEST["include_attachments"]);
-                       $since_id = (int)db_escape_string($this->link, $_REQUEST["since_id"]);
+                       $since_id = (int)db_escape_string( $_REQUEST["since_id"]);
                        $include_nested = sql_bool_to_bool($_REQUEST["include_nested"]);
                        $sanitize_content = true;
 
@@ -211,10 +211,10 @@ class API extends Handler {
 
                        /* do not rely on params below */
 
-                       $search = db_escape_string($this->link, $_REQUEST["search"]);
-                       $search_mode = db_escape_string($this->link, $_REQUEST["search_mode"]);
+                       $search = db_escape_string( $_REQUEST["search"]);
+                       $search_mode = db_escape_string( $_REQUEST["search_mode"]);
 
-                       $headlines = $this->api_get_headlines($this->link, $feed_id, $limit, $offset,
+                       $headlines = $this->api_get_headlines( $feed_id, $limit, $offset,
                                $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order,
                                $include_attachments, $since_id, $search, $search_mode,
                                $include_nested, $sanitize_content);
@@ -226,10 +226,10 @@ class API extends Handler {
        }
 
        function updateArticle() {
-               $article_ids = array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_ids"])), is_numeric);
-               $mode = (int) db_escape_string($this->link, $_REQUEST["mode"]);
-               $data = db_escape_string($this->link, $_REQUEST["data"]);
-               $field_raw = (int)db_escape_string($this->link, $_REQUEST["field"]);
+               $article_ids = array_filter(explode(",", db_escape_string( $_REQUEST["article_ids"])), is_numeric);
+               $mode = (int) db_escape_string( $_REQUEST["mode"]);
+               $data = db_escape_string( $_REQUEST["data"]);
+               $field_raw = (int)db_escape_string( $_REQUEST["field"]);
 
                $field = "";
                $set_to = "";
@@ -269,16 +269,16 @@ class API extends Handler {
 
                        $article_ids = join(", ", $article_ids);
 
-                       $result = db_query($this->link, "UPDATE ttrss_user_entries SET $field = $set_to $additional_fields WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]);
+                       $result = db_query( "UPDATE ttrss_user_entries SET $field = $set_to $additional_fields WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]);
 
-                       $num_updated = db_affected_rows($this->link, $result);
+                       $num_updated = db_affected_rows( $result);
 
                        if ($num_updated > 0 && $field == "unread") {
-                               $result = db_query($this->link, "SELECT DISTINCT feed_id FROM ttrss_user_entries
+                               $result = db_query( "SELECT DISTINCT feed_id FROM ttrss_user_entries
                                        WHERE ref_id IN ($article_ids)");
 
                                while ($line = db_fetch_assoc($result)) {
-                                       ccache_update($this->link, $line["feed_id"], $_SESSION["uid"]);
+                                       ccache_update( $line["feed_id"], $_SESSION["uid"]);
                                }
                        }
 
@@ -286,7 +286,7 @@ class API extends Handler {
                                if (PUBSUBHUBBUB_HUB) {
                                        $rss_link = get_self_url_prefix() .
                                                "/public.php?op=rss&id=-2&key=" .
-                                               get_feed_access_key($this->link, -2, false);
+                                               get_feed_access_key( -2, false);
 
                                        $p = new Publisher(PUBSUBHUBBUB_HUB);
                                        $pubsub_result = $p->publish_update($rss_link);
@@ -304,7 +304,7 @@ class API extends Handler {
 
        function getArticle() {
 
-               $article_id = join(",", array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_id"])), is_numeric));
+               $article_id = join(",", array_filter(explode(",", db_escape_string( $_REQUEST["article_id"])), is_numeric));
 
                $query = "SELECT id,title,link,content,cached_content,feed_id,comments,int_id,
                        marked,unread,published,score,
@@ -314,7 +314,7 @@ class API extends Handler {
                        WHERE   id IN ($article_id) AND ref_id = id AND owner_uid = " .
                                $_SESSION["uid"] ;
 
-               $result = db_query($this->link, $query);
+               $result = db_query( $query);
 
                $articles = array();
 
@@ -322,13 +322,13 @@ class API extends Handler {
 
                        while ($line = db_fetch_assoc($result)) {
 
-                               $attachments = get_article_enclosures($this->link, $line['id']);
+                               $attachments = get_article_enclosures( $line['id']);
 
                                $article = array(
                                        "id" => $line["id"],
                                        "title" => $line["title"],
                                        "link" => $line["link"],
-                                       "labels" => get_article_labels($this->link, $line['id']),
+                                       "labels" => get_article_labels( $line['id']),
                                        "unread" => sql_bool_to_bool($line["unread"]),
                                        "marked" => sql_bool_to_bool($line["marked"]),
                                        "published" => sql_bool_to_bool($line["published"]),
@@ -363,7 +363,7 @@ class API extends Handler {
 
                $config["daemon_is_running"] = file_is_locked("update_daemon.lock");
 
-               $result = db_query($this->link, "SELECT COUNT(*) AS cf FROM
+               $result = db_query( "SELECT COUNT(*) AS cf FROM
                        ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
 
                $num_feeds = db_fetch_result($result, 0, "cf");
@@ -376,41 +376,41 @@ class API extends Handler {
        function updateFeed() {
                require_once "include/rssfuncs.php";
 
-               $feed_id = (int) db_escape_string($this->link, $_REQUEST["feed_id"]);
+               $feed_id = (int) db_escape_string( $_REQUEST["feed_id"]);
 
-               update_rss_feed($this->link, $feed_id, true);
+               update_rss_feed( $feed_id, true);
 
                print $this->wrap(self::STATUS_OK, array("status" => "OK"));
        }
 
        function catchupFeed() {
-               $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]);
-               $is_cat = db_escape_string($this->link, $_REQUEST["is_cat"]);
+               $feed_id = db_escape_string( $_REQUEST["feed_id"]);
+               $is_cat = db_escape_string( $_REQUEST["is_cat"]);
 
-               catchup_feed($this->link, $feed_id, $is_cat);
+               catchup_feed( $feed_id, $is_cat);
 
                print $this->wrap(self::STATUS_OK, array("status" => "OK"));
        }
 
        function getPref() {
-               $pref_name = db_escape_string($this->link, $_REQUEST["pref_name"]);
+               $pref_name = db_escape_string( $_REQUEST["pref_name"]);
 
-               print $this->wrap(self::STATUS_OK, array("value" => get_pref($this->link, $pref_name)));
+               print $this->wrap(self::STATUS_OK, array("value" => get_pref( $pref_name)));
        }
 
        function getLabels() {
-               //$article_ids = array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_ids"])), is_numeric);
+               //$article_ids = array_filter(explode(",", db_escape_string( $_REQUEST["article_ids"])), is_numeric);
 
                $article_id = (int)$_REQUEST['article_id'];
 
                $rv = array();
 
-               $result = db_query($this->link, "SELECT id, caption, fg_color, bg_color
+               $result = db_query( "SELECT id, caption, fg_color, bg_color
                        FROM ttrss_labels2
                        WHERE owner_uid = '".$_SESSION['uid']."' ORDER BY caption");
 
                if ($article_id)
-                       $article_labels = get_article_labels($this->link, $article_id);
+                       $article_labels = get_article_labels( $article_id);
                else
                        $article_labels = array();
 
@@ -437,11 +437,11 @@ class API extends Handler {
 
        function setArticleLabel() {
 
-               $article_ids = array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_ids"])), is_numeric);
-               $label_id = (int) db_escape_string($this->link, $_REQUEST['label_id']);
-               $assign = (bool) db_escape_string($this->link, $_REQUEST['assign']) == "true";
+               $article_ids = array_filter(explode(",", db_escape_string( $_REQUEST["article_ids"])), is_numeric);
+               $label_id = (int) db_escape_string( $_REQUEST['label_id']);
+               $assign = (bool) db_escape_string( $_REQUEST['assign']) == "true";
 
-               $label = db_escape_string($this->link, label_find_caption($this->link,
+               $label = db_escape_string( label_find_caption(
                        $label_id, $_SESSION["uid"]));
 
                $num_updated = 0;
@@ -451,9 +451,9 @@ class API extends Handler {
                        foreach ($article_ids as $id) {
 
                                if ($assign)
-                                       label_add_article($this->link, $id, $label, $_SESSION["uid"]);
+                                       label_add_article( $id, $label, $_SESSION["uid"]);
                                else
-                                       label_remove_article($this->link, $id, $label, $_SESSION["uid"]);
+                                       label_remove_article( $id, $label, $_SESSION["uid"]);
 
                                ++$num_updated;
 
@@ -481,25 +481,25 @@ class API extends Handler {
        }
 
        function shareToPublished() {
-               $title = db_escape_string($this->link, strip_tags($_REQUEST["title"]));
-               $url = db_escape_string($this->link, strip_tags($_REQUEST["url"]));
-               $content = db_escape_string($this->link, strip_tags($_REQUEST["content"]));
+               $title = db_escape_string( strip_tags($_REQUEST["title"]));
+               $url = db_escape_string( strip_tags($_REQUEST["url"]));
+               $content = db_escape_string( strip_tags($_REQUEST["content"]));
 
-               if (Article::create_published_article($this->link, $title, $url, $content, "", $_SESSION["uid"])) {
+               if (Article::create_published_article( $title, $url, $content, "", $_SESSION["uid"])) {
                        print $this->wrap(self::STATUS_OK, array("status" => 'OK'));
                } else {
                        print $this->wrap(self::STATUS_ERR, array("error" => 'Publishing failed'));
                }
        }
 
-       static function api_get_feeds($link, $cat_id, $unread_only, $limit, $offset, $include_nested = false) {
+       static function api_get_feeds( $cat_id, $unread_only, $limit, $offset, $include_nested = false) {
 
                        $feeds = array();
 
                        /* Labels */
 
                        if ($cat_id == -4 || $cat_id == -2) {
-                               $counters = getLabelCounters($link, true);
+                               $counters = getLabelCounters( true);
 
                                foreach (array_values($counters) as $cv) {
 
@@ -523,10 +523,10 @@ class API extends Handler {
 
                        if ($cat_id == -4 || $cat_id == -1) {
                                foreach (array(-1, -2, -3, -4, -6, 0) as $i) {
-                                       $unread = getFeedUnread($link, $i);
+                                       $unread = getFeedUnread( $i);
 
                                        if ($unread || !$unread_only) {
-                                               $title = getFeedTitle($link, $i);
+                                               $title = getFeedTitle( $i);
 
                                                $row = array(
                                                                "id" => $i,
@@ -543,14 +543,14 @@ class API extends Handler {
                        /* Child cats */
 
                        if ($include_nested && $cat_id) {
-                               $result = db_query($link, "SELECT
+                               $result = db_query( "SELECT
                                        id, title FROM ttrss_feed_categories
                                        WHERE parent_cat = '$cat_id' AND owner_uid = " . $_SESSION["uid"] .
                                " ORDER BY id, title");
 
                                while ($line = db_fetch_assoc($result)) {
-                                       $unread = getFeedUnread($link, $line["id"], true) +
-                                               getCategoryChildrenUnread($link, $line["id"]);
+                                       $unread = getFeedUnread( $line["id"], true) +
+                                               getCategoryChildrenUnread( $line["id"]);
 
                                        if ($unread || !$unread_only) {
                                                $row = array(
@@ -573,7 +573,7 @@ class API extends Handler {
                        }
 
                        if ($cat_id == -4 || $cat_id == -3) {
-                               $result = db_query($link, "SELECT
+                               $result = db_query( "SELECT
                                        id, feed_url, cat_id, title, order_id, ".
                                                SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
                                                FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] .
@@ -585,7 +585,7 @@ class API extends Handler {
                                else
                                        $cat_qpart = "cat_id IS NULL";
 
-                               $result = db_query($link, "SELECT
+                               $result = db_query( "SELECT
                                        id, feed_url, cat_id, title, order_id, ".
                                                SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
                                                FROM ttrss_feeds WHERE
@@ -595,7 +595,7 @@ class API extends Handler {
 
                        while ($line = db_fetch_assoc($result)) {
 
-                               $unread = getFeedUnread($link, $line["id"]);
+                               $unread = getFeedUnread( $line["id"]);
 
                                $has_icon = feed_has_icon($line['id']);
 
@@ -619,13 +619,13 @@ class API extends Handler {
                return $feeds;
        }
 
-       static function api_get_headlines($link, $feed_id, $limit, $offset,
+       static function api_get_headlines( $feed_id, $limit, $offset,
                                $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order,
                                $include_attachments, $since_id,
                                $search = "", $search_mode = "",
                                $include_nested = false, $sanitize_content = true) {
 
-                       $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit,
+                       $qfh_ret = queryFeedHeadlines( $feed_id, $limit,
                                $view_mode, $is_cat, $search, $search_mode,
                                $order, $offset, 0, false, $since_id, $include_nested);
 
@@ -641,8 +641,8 @@ class API extends Handler {
                                $tags = explode(",", $line["tag_cache"]);
                                $labels = json_decode($line["label_cache"], true);
 
-                               //if (!$tags) $tags = get_article_tags($link, $line["id"]);
-                               //if (!$labels) $labels = get_article_labels($link, $line["id"]);
+                               //if (!$tags) $tags = get_article_tags( $line["id"]);
+                               //if (!$labels) $labels = get_article_labels( $line["id"]);
 
                                $headline_row = array(
                                                "id" => (int)$line["id"],
@@ -658,7 +658,7 @@ class API extends Handler {
                                        );
 
                                        if ($include_attachments)
-                                               $headline_row['attachments'] = get_article_enclosures($link,
+                                               $headline_row['attachments'] = get_article_enclosures(
                                                        $line['id']);
 
                                if ($show_excerpt) {
@@ -673,7 +673,7 @@ class API extends Handler {
                                        }
 
                                        if ($sanitize_content) {
-                                               $headline_row["content"] = sanitize($link,
+                                               $headline_row["content"] = sanitize(
                                                        $line["content_preview"],
                                                        sql_bool_to_bool($line['hide_images']),
                                                        false, $line["site_url"]);
@@ -709,13 +709,13 @@ class API extends Handler {
        }
 
        function unsubscribeFeed() {
-               $feed_id = (int) db_escape_string($this->link, $_REQUEST["feed_id"]);
+               $feed_id = (int) db_escape_string( $_REQUEST["feed_id"]);
 
-               $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
+               $result = db_query( "SELECT id FROM ttrss_feeds WHERE
                        id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]);
 
                if (db_num_rows($result) != 0) {
-                       Pref_Feeds::remove_feed($this->link, $feed_id, $_SESSION["uid"]);
+                       Pref_Feeds::remove_feed( $feed_id, $_SESSION["uid"]);
                        print $this->wrap(self::STATUS_OK, array("status" => "OK"));
                } else {
                        print $this->wrap(self::STATUS_ERR, array("error" => "FEED_NOT_FOUND"));
@@ -723,13 +723,13 @@ class API extends Handler {
        }
 
        function subscribeToFeed() {
-               $feed_url = db_escape_string($this->link, $_REQUEST["feed_url"]);
-               $category_id = (int) db_escape_string($this->link, $_REQUEST["category_id"]);
-               $login = db_escape_string($this->link, $_REQUEST["login"]);
-               $password = db_escape_string($this->link, $_REQUEST["password"]);
+               $feed_url = db_escape_string( $_REQUEST["feed_url"]);
+               $category_id = (int) db_escape_string( $_REQUEST["category_id"]);
+               $login = db_escape_string( $_REQUEST["login"]);
+               $password = db_escape_string( $_REQUEST["password"]);
 
                if ($feed_url) {
-                       $rc = subscribe_to_feed($this->link, $feed_url, $category_id,
+                       $rc = subscribe_to_feed( $feed_url, $category_id,
                                $login, $password, false);
 
                        print $this->wrap(self::STATUS_OK, array("status" => $rc));
@@ -741,7 +741,7 @@ class API extends Handler {
        function getFeedTree() {
                $include_empty = sql_bool_to_bool($_REQUEST['include_empty']);
 
-               $pf = new Pref_Feeds($this->link, $_REQUEST);
+               $pf = new Pref_Feeds( $_REQUEST);
 
                $_REQUEST['mode'] = 2;
                $_REQUEST['force_show_empty'] = $include_empty;
@@ -760,13 +760,13 @@ class API extends Handler {
        private function isCategoryEmpty($id) {
 
                if ($id == -2) {
-                       $result = db_query($this->link, "SELECT COUNT(*) AS count FROM ttrss_labels2
+                       $result = db_query( "SELECT COUNT(*) AS count FROM ttrss_labels2
                                WHERE owner_uid = " . $_SESSION["uid"]);
 
                        return db_fetch_result($result, 0, "count") == 0;
 
                } else if ($id == 0) {
-                       $result = db_query($this->link, "SELECT COUNT(*) AS count FROM ttrss_feeds
+                       $result = db_query( "SELECT COUNT(*) AS count FROM ttrss_feeds
                                WHERE cat_id IS NULL AND owner_uid = " . $_SESSION["uid"]);
 
                        return db_fetch_result($result, 0, "count") == 0;
index f31a225d1da39731a1495cf7a296769555e27412..9917d4d0614942ff137309b42f1ab40c9101c8f7 100644 (file)
@@ -8,9 +8,9 @@ class Article extends Handler_Protected {
        }
 
        function redirect() {
-               $id = db_escape_string($this->link, $_REQUEST['id']);
+               $id = db_escape_string( $_REQUEST['id']);
 
-               $result = db_query($this->link, "SELECT link FROM ttrss_entries, ttrss_user_entries
+               $result = db_query( "SELECT link FROM ttrss_entries, ttrss_user_entries
                                                WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."'
                                                LIMIT 1");
 
@@ -27,10 +27,10 @@ class Article extends Handler_Protected {
        }
 
        function view() {
-               $id = db_escape_string($this->link, $_REQUEST["id"]);
-               $cids = explode(",", db_escape_string($this->link, $_REQUEST["cids"]));
-               $mode = db_escape_string($this->link, $_REQUEST["mode"]);
-               $omode = db_escape_string($this->link, $_REQUEST["omode"]);
+               $id = db_escape_string( $_REQUEST["id"]);
+               $cids = explode(",", db_escape_string( $_REQUEST["cids"]));
+               $mode = db_escape_string( $_REQUEST["mode"]);
+               $omode = db_escape_string( $_REQUEST["omode"]);
 
                // in prefetch mode we only output requested cids, main article
                // just gets marked as read (it already exists in client cache)
@@ -38,26 +38,26 @@ class Article extends Handler_Protected {
                $articles = array();
 
                if ($mode == "") {
-                       array_push($articles, format_article($this->link, $id, false));
+                       array_push($articles, format_article( $id, false));
                } else if ($mode == "zoom") {
-                       array_push($articles, format_article($this->link, $id, true, true));
+                       array_push($articles, format_article( $id, true, true));
                } else if ($mode == "raw") {
                        if ($_REQUEST['html']) {
                                header("Content-Type: text/html");
                                print '<link rel="stylesheet" type="text/css" href="tt-rss.css"/>';
                        }
 
-                       $article = format_article($this->link, $id, false);
+                       $article = format_article( $id, false);
                        print $article['content'];
                        return;
                }
 
-               $this->catchupArticleById($this->link, $id, 0);
+               $this->catchupArticleById( $id, 0);
 
                if (!$_SESSION["bw_limit"]) {
                        foreach ($cids as $cid) {
                                if ($cid) {
-                                       array_push($articles, format_article($this->link, $cid, false, false));
+                                       array_push($articles, format_article( $cid, false, false));
                                }
                        }
                }
@@ -65,27 +65,27 @@ class Article extends Handler_Protected {
                print json_encode($articles);
        }
 
-       private function catchupArticleById($link, $id, $cmode) {
+       private function catchupArticleById( $id, $cmode) {
 
                if ($cmode == 0) {
-                       db_query($link, "UPDATE ttrss_user_entries SET
+                       db_query( "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
+                       db_query( "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
+                       db_query( "UPDATE ttrss_user_entries SET
                        unread = NOT unread,last_read = NOW()
                        WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
                }
 
-               $feed_id = getArticleFeed($link, $id);
-               ccache_update($link, $feed_id, $_SESSION["uid"]);
+               $feed_id = getArticleFeed( $id);
+               ccache_update( $feed_id, $_SESSION["uid"]);
        }
 
-       static function create_published_article($link, $title, $url, $content, $labels_str,
+       static function create_published_article( $title, $url, $content, $labels_str,
                        $owner_uid) {
 
                $guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid); // include owner_uid to prevent global GUID clash
@@ -104,30 +104,30 @@ class Article extends Handler_Protected {
 
                if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) return false;
 
-               db_query($link, "BEGIN");
+               db_query( "BEGIN");
 
                // only check for our user data here, others might have shared this with different content etc
-               $result = db_query($link, "SELECT id FROM ttrss_entries, ttrss_user_entries WHERE
+               $result = db_query( "SELECT id FROM ttrss_entries, ttrss_user_entries WHERE
                        link = '$url' AND ref_id = id AND owner_uid = '$owner_uid' LIMIT 1");
 
                if (db_num_rows($result) != 0) {
                        $ref_id = db_fetch_result($result, 0, "id");
 
-                       $result = db_query($link, "SELECT int_id FROM ttrss_user_entries WHERE
+                       $result = db_query( "SELECT int_id FROM ttrss_user_entries WHERE
                                ref_id = '$ref_id' AND owner_uid = '$owner_uid' LIMIT 1");
 
                        if (db_num_rows($result) != 0) {
                                $int_id = db_fetch_result($result, 0, "int_id");
 
-                               db_query($link, "UPDATE ttrss_entries SET
+                               db_query( "UPDATE ttrss_entries SET
                                        content = '$content', content_hash = '$content_hash' WHERE id = '$ref_id'");
 
-                               db_query($link, "UPDATE ttrss_user_entries SET published = true,
+                               db_query( "UPDATE ttrss_user_entries SET published = true,
                                                last_published = NOW() WHERE
                                                int_id = '$int_id' AND owner_uid = '$owner_uid'");
                        } else {
 
-                               db_query($link, "INSERT INTO ttrss_user_entries
+                               db_query( "INSERT INTO ttrss_user_entries
                                        (ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache,
                                                last_read, note, unread, last_published)
                                        VALUES
@@ -136,24 +136,24 @@ class Article extends Handler_Protected {
 
                        if (count($labels) != 0) {
                                foreach ($labels as $label) {
-                                       label_add_article($link, $ref_id, trim($label), $owner_uid);
+                                       label_add_article( $ref_id, trim($label), $owner_uid);
                                }
                        }
 
                        $rc = true;
 
                } else {
-                       $result = db_query($link, "INSERT INTO ttrss_entries
+                       $result = db_query( "INSERT INTO ttrss_entries
                                (title, guid, link, updated, content, content_hash, date_entered, date_updated)
                                VALUES
                                ('$title', '$guid', '$url', NOW(), '$content', '$content_hash', NOW(), NOW())");
 
-                       $result = db_query($link, "SELECT id FROM ttrss_entries WHERE guid = '$guid'");
+                       $result = db_query( "SELECT id FROM ttrss_entries WHERE guid = '$guid'");
 
                        if (db_num_rows($result) != 0) {
                                $ref_id = db_fetch_result($result, 0, "id");
 
-                               db_query($link, "INSERT INTO ttrss_user_entries
+                               db_query( "INSERT INTO ttrss_user_entries
                                        (ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache,
                                                last_read, note, unread, last_published)
                                        VALUES
@@ -161,7 +161,7 @@ class Article extends Handler_Protected {
 
                                if (count($labels) != 0) {
                                        foreach ($labels as $label) {
-                                               label_add_article($link, $ref_id, trim($label), $owner_uid);
+                                               label_add_article( $ref_id, trim($label), $owner_uid);
                                        }
                                }
 
@@ -169,7 +169,7 @@ class Article extends Handler_Protected {
                        }
                }
 
-               db_query($link, "COMMIT");
+               db_query( "COMMIT");
 
                return $rc;
        }
@@ -178,9 +178,9 @@ class Article extends Handler_Protected {
 
                print __("Tags for this article (separated by commas):")."<br>";
 
-               $param = db_escape_string($this->link, $_REQUEST['param']);
+               $param = db_escape_string( $_REQUEST['param']);
 
-               $tags = get_article_tags($this->link, db_escape_string($this->link, $param));
+               $tags = get_article_tags( db_escape_string( $param));
 
                $tags_str = join(", ", $tags);
 
@@ -209,10 +209,10 @@ class Article extends Handler_Protected {
        }
 
        function setScore() {
-               $ids = db_escape_string($this->link, $_REQUEST['id']);
-               $score = (int)db_escape_string($this->link, $_REQUEST['score']);
+               $ids = db_escape_string( $_REQUEST['id']);
+               $score = (int)db_escape_string( $_REQUEST['score']);
 
-               db_query($this->link, "UPDATE ttrss_user_entries SET
+               db_query( "UPDATE ttrss_user_entries SET
                        score = '$score' WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
 
                print json_encode(array("id" => $id,
@@ -222,14 +222,14 @@ class Article extends Handler_Protected {
 
        function setArticleTags() {
 
-               $id = db_escape_string($this->link, $_REQUEST["id"]);
+               $id = db_escape_string( $_REQUEST["id"]);
 
-               $tags_str = db_escape_string($this->link, $_REQUEST["tags_str"]);
+               $tags_str = db_escape_string( $_REQUEST["tags_str"]);
                $tags = array_unique(trim_array(explode(",", $tags_str)));
 
-               db_query($this->link, "BEGIN");
+               db_query( "BEGIN");
 
-               $result = db_query($this->link, "SELECT int_id FROM ttrss_user_entries WHERE
+               $result = db_query( "SELECT int_id FROM ttrss_user_entries WHERE
                                ref_id = '$id' AND owner_uid = '".$_SESSION["uid"]."' LIMIT 1");
 
                if (db_num_rows($result) == 1) {
@@ -238,7 +238,7 @@ class Article extends Handler_Protected {
 
                        $int_id = db_fetch_result($result, 0, "int_id");
 
-                       db_query($this->link, "DELETE FROM ttrss_tags WHERE
+                       db_query( "DELETE FROM ttrss_tags WHERE
                                post_int_id = $int_id AND owner_uid = '".$_SESSION["uid"]."'");
 
                        foreach ($tags as $tag) {
@@ -255,7 +255,7 @@ class Article extends Handler_Protected {
                                //                                      print "<!-- $id : $int_id : $tag -->";
 
                                if ($tag != '') {
-                                       db_query($this->link, "INSERT INTO ttrss_tags
+                                       db_query( "INSERT INTO ttrss_tags
                                                                (post_int_id, owner_uid, tag_name) VALUES ('$int_id', '".$_SESSION["uid"]."', '$tag')");
                                }
 
@@ -267,14 +267,14 @@ class Article extends Handler_Protected {
                        sort($tags_to_cache);
                        $tags_str = join(",", $tags_to_cache);
 
-                       db_query($this->link, "UPDATE ttrss_user_entries
+                       db_query( "UPDATE ttrss_user_entries
                                SET tag_cache = '$tags_str' WHERE ref_id = '$id'
                                                AND owner_uid = " . $_SESSION["uid"]);
                }
 
-               db_query($this->link, "COMMIT");
+               db_query( "COMMIT");
 
-               $tags = get_article_tags($this->link, $id);
+               $tags = get_article_tags( $id);
                $tags_str = format_tags_string($tags, $id);
                $tags_str_full = join(", ", $tags);
 
@@ -286,9 +286,9 @@ class Article extends Handler_Protected {
 
 
        function completeTags() {
-               $search = db_escape_string($this->link, $_REQUEST["search"]);
+               $search = db_escape_string( $_REQUEST["search"]);
 
-               $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags
+               $result = db_query( "SELECT DISTINCT tag_name FROM ttrss_tags
                                WHERE owner_uid = '".$_SESSION["uid"]."' AND
                                tag_name LIKE '$search%' ORDER BY tag_name
                                LIMIT 10");
@@ -311,10 +311,10 @@ class Article extends Handler_Protected {
        private function labelops($assign) {
                $reply = array();
 
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
-               $label_id = db_escape_string($this->link, $_REQUEST["lid"]);
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
+               $label_id = db_escape_string( $_REQUEST["lid"]);
 
-               $label = db_escape_string($this->link, label_find_caption($this->link, $label_id,
+               $label = db_escape_string( label_find_caption( $label_id,
                $_SESSION["uid"]));
 
                $reply["info-for-headlines"] = array();
@@ -324,11 +324,11 @@ class Article extends Handler_Protected {
                        foreach ($ids as $id) {
 
                                if ($assign)
-                                       label_add_article($this->link, $id, $label, $_SESSION["uid"]);
+                                       label_add_article( $id, $label, $_SESSION["uid"]);
                                else
-                                       label_remove_article($this->link, $id, $label, $_SESSION["uid"]);
+                                       label_remove_article( $id, $label, $_SESSION["uid"]);
 
-                               $labels = get_article_labels($this->link, $id, $_SESSION["uid"]);
+                               $labels = get_article_labels( $id, $_SESSION["uid"]);
 
                                array_push($reply["info-for-headlines"],
                                array("id" => $id, "labels" => format_article_labels($labels, $id)));
index ad7ff36461b8d338c1eba7e4e37dcc772327fdd7..c2a6bd70450fb2306dcd48d7c704b93dd398db49 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 class Auth_Base {
-       protected $link;
+       protected $dbh;
 
-       function __construct($link) {
-               $this->link = $link;
+       function __construct($dbh) {
+               $this->dbh = $dbh;
        }
 
        function check_password($owner_uid, $password) {
@@ -21,7 +21,7 @@ class Auth_Base {
                        $user_id = $this->find_user_by_login($login);
 
                        if (!$user_id) {
-                               $login = db_escape_string($this->link, $login);
+                               $login = db_escape_string( $login);
                                $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
                                $pwd_hash = encrypt_password($password, $salt, true);
 
@@ -29,7 +29,7 @@ class Auth_Base {
                                                (login,access_level,last_login,created,pwd_hash,salt)
                                                VALUES ('$login', 0, null, NOW(), '$pwd_hash','$salt')";
 
-                               db_query($this->link, $query);
+                               db_query( $query);
 
                                return $this->find_user_by_login($login);
 
@@ -42,9 +42,9 @@ class Auth_Base {
        }
 
        function find_user_by_login($login) {
-               $login = db_escape_string($this->link, $login);
+               $login = db_escape_string( $login);
 
-               $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE
+               $result = db_query( "SELECT id FROM ttrss_users WHERE
                        login = '$login'");
 
                if (db_num_rows($result) > 0) {
index c03d583dba6bd355cb6f4d4b2f51c0049726f8f2..a0416810886a6145e355484dfc8226031c317b22 100644 (file)
@@ -11,7 +11,7 @@ class Backend extends Handler {
 
                require_once "digest.php";
 
-               $rv = prepare_headlines_digest($this->link, $_SESSION['uid'], 1, 1000);
+               $rv = prepare_headlines_digest( $_SESSION['uid'], 1, 1000);
 
                $rv[3] = "<pre>" . $rv[3] . "</pre>";
 
@@ -19,8 +19,8 @@ class Backend extends Handler {
        }
 
        private function display_main_help() {
-               $info = get_hotkeys_info($this->link);
-               $imap = get_hotkeys_map($this->link);
+               $info = get_hotkeys_info();
+               $imap = get_hotkeys_map();
                $omap = array();
 
                foreach ($imap[1] as $sequence => $action) {
index c3b6270962a30d44c7951d7d3251b0b73dcc9383..6dc31a22e065808923c1dd5dcf3397867cc65cf3 100644 (file)
@@ -36,7 +36,7 @@ class Db implements IDb {
 
        function connect($host, $user, $pass, $db, $port) {
                //return $this->adapter->connect($host, $user, $pass, $db, $port);
-               return $this->link;
+               return ;
        }
 
        function escape_string($s, $strip_tags = true) {
index bafd54ab247a70856ece313bd234a5a3f0ccadb6..0cb737978aef800c0b622becb29b561e87f65171 100644 (file)
@@ -31,11 +31,11 @@ class Db_Pgsql implements IDb {
        function escape_string($s, $strip_tags = true) {
                if ($strip_tags) $s = strip_tags($s);
 
-               return pg_escape_string($this->link, $s);
+               return pg_escape_string( $s);
        }
 
        function query($query, $die_on_error = true) {
-               $result = pg_query($this->link, $query);
+               $result = pg_query( $query);
 
                if (!$result) {
                        $query = htmlspecialchars($query); // just in case
index a9a7132735f268c3e94138ab626c97bd5d322331..ffcac7cf7cc3e7a686480b8476df60d5535bbf43 100644 (file)
@@ -1,18 +1,18 @@
 <?php
 class DbUpdater {
 
-       private $link;
+       private $dbh;
        private $db_type;
        private $need_version;
 
-       function __construct($link, $db_type, $need_version) {
-               $this->link = $link;
+       function __construct($dbh, $db_type, $need_version) {
+               $this->dbh = $dbh;
                $this->db_type = $db_type;
                $this->need_version = (int) $need_version;
        }
 
        function getSchemaVersion() {
-               $result = db_query($this->link, "SELECT schema_version FROM ttrss_version");
+               $result = db_query( "SELECT schema_version FROM ttrss_version");
                return (int) db_fetch_result($result, 0, "schema_version");
        }
 
@@ -37,21 +37,21 @@ class DbUpdater {
 
                        if (is_array($lines)) {
 
-                               db_query($this->link, "BEGIN");
+                               db_query( "BEGIN");
 
                                foreach ($lines as $line) {
                                        if (strpos($line, "--") !== 0 && $line) {
-                                               db_query($this->link, $line);
+                                               db_query( $line);
                                        }
                                }
 
                                $db_version = $this->getSchemaVersion();
 
                                if ($db_version == $version) {
-                                       db_query($this->link, "COMMIT");
+                                       db_query( "COMMIT");
                                        return true;
                                } else {
-                                       db_query($this->link, "ROLLBACK");
+                                       db_query( "ROLLBACK");
                                        return false;
                                }
                        } else {
index e56560a47cdf2090fab88fda04afca23a3db8787..99cd7cffa7545de47446bd06b1226e47ef5b7298 100644 (file)
@@ -6,7 +6,7 @@ class Dlg extends Handler_Protected {
                if (parent::before($method)) {
                        header("Content-Type: text/html"); # required for iframe
 
-                       $this->param = db_escape_string($this->link, $_REQUEST["param"]);
+                       $this->param = db_escape_string( $_REQUEST["param"]);
                        return true;
                }
                return false;
@@ -18,15 +18,15 @@ class Dlg extends Handler_Protected {
                print "<div class=\"prefFeedOPMLHolder\">";
                $owner_uid = $_SESSION["uid"];
 
-               db_query($this->link, "BEGIN");
+               db_query( "BEGIN");
 
                print "<ul class='nomarks'>";
 
-               $opml = new Opml($this->link, $_REQUEST);
+               $opml = new Opml( $_REQUEST);
 
                $opml->opml_import($_SESSION["uid"]);
 
-               db_query($this->link, "COMMIT");
+               db_query( "COMMIT");
 
                print "</ul>";
                print "</div>";
@@ -43,7 +43,7 @@ class Dlg extends Handler_Protected {
        }
 
        function pubOPMLUrl() {
-               $url_path = Opml::opml_publish_url($this->link);
+               $url_path = Opml::opml_publish_url();
 
                print __("Your Public OPML URL is:");
 
@@ -106,7 +106,7 @@ class Dlg extends Handler_Protected {
                        FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]."
                        GROUP BY tag_name ORDER BY count DESC LIMIT 50";
 
-               $result = db_query($this->link, $query);
+               $result = db_query( $query);
 
                $tags = array();
 
@@ -171,7 +171,7 @@ class Dlg extends Handler_Protected {
                print "<label for=\"tag_mode_all\">".__("All tags.")."</input>";
 
                print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
-               $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
+               $result = db_query( "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
                        AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
 
                while ($row = db_fetch_assoc($result)) {
@@ -195,10 +195,10 @@ class Dlg extends Handler_Protected {
        function generatedFeed() {
 
                $this->params = explode(":", $this->param, 3);
-               $feed_id = db_escape_string($this->link, $this->params[0]);
+               $feed_id = db_escape_string( $this->params[0]);
                $is_cat = (bool) $this->params[1];
 
-               $key = get_feed_access_key($this->link, $feed_id, $is_cat);
+               $key = get_feed_access_key( $feed_id, $is_cat);
 
                $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
 
@@ -223,7 +223,7 @@ class Dlg extends Handler_Protected {
 
        function newVersion() {
 
-               $version_data = check_for_update($this->link);
+               $version_data = check_for_update();
                $version = $version_data['version'];
                $id = $version_data['version_id'];
 
index 6ee5bad0b8626606255338c8d8ec6f5e3ae47e7d..1c3ad58c58ae65b6d8a796cfcc0843220ff1dcb5 100644 (file)
@@ -164,7 +164,7 @@ class Feeds extends Handler_Protected {
                if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
                        // Update the feed if required with some basic flood control
 
-                       $result = db_query($this->link,
+                       $result = db_query(
                                "SELECT cache_images,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
                                        FROM ttrss_feeds WHERE id = '$feed'");
 
@@ -174,22 +174,22 @@ class Feeds extends Handler_Protected {
 
                                        if (!$cache_images && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {
                                                include "rssfuncs.php";
-                                               update_rss_feed($this->link, $feed, true, true);
+                                               update_rss_feed( $feed, true, true);
                                        } else {
-                                               db_query($this->link, "UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
+                                               db_query( "UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
                                                        WHERE id = '$feed'");
                                        }
                                }
                }
 
                if ($method_split[0] == "MarkAllReadGR")  {
-                       catchup_feed($this->link, $method_split[1], false);
+                       catchup_feed( $method_split[1], false);
                }
 
                // FIXME: might break tag display?
 
                if (is_numeric($feed) && $feed > 0 && !$cat_view) {
-                       $result = db_query($this->link,
+                       $result = db_query(
                                "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");
 
                        if (db_num_rows($result) == 0) {
@@ -197,13 +197,13 @@ class Feeds extends Handler_Protected {
                        }
                }
 
-               @$search = db_escape_string($this->link, $_REQUEST["query"]);
+               @$search = db_escape_string( $_REQUEST["query"]);
 
                if ($search) {
                        $disable_cache = true;
                }
 
-               @$search_mode = db_escape_string($this->link, $_REQUEST["search_mode"]);
+               @$search_mode = db_escape_string( $_REQUEST["search_mode"]);
 
                if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
 
@@ -219,7 +219,7 @@ class Feeds extends Handler_Protected {
                        $handler = $pluginhost->get_feed_handler(
                                PluginHost::feed_to_pfeed_id($feed));
 
-               //      function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) {
+               //      function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) {
 
                        if ($handler) {
                                $options = array(
@@ -240,7 +240,7 @@ class Feeds extends Handler_Protected {
                        }
 
                } else {
-                       $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view,
+                       $qfh_ret = queryFeedHeadlines( $feed, $limit, $view_mode, $cat_view,
                                $search, $search_mode, $override_order, $offset, 0,
                                false, 0, $include_children);
                }
@@ -261,13 +261,13 @@ class Feeds extends Handler_Protected {
 
                $headlines_count = db_num_rows($result);
 
-               /* if (get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {
+               /* if (get_pref( 'COMBINED_DISPLAY_MODE')) {
                        $button_plugins = array();
                        foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
                                $pclass = "button_" . trim($p);
 
                                if (class_exists($pclass)) {
-                                       $plugin = new $pclass($link);
+                                       $plugin = new $pclass();
                                        array_push($button_plugins, $plugin);
                                }
                        }
@@ -282,11 +282,11 @@ class Feeds extends Handler_Protected {
                        $num_unread = 0;
                        $cur_feed_title = '';
 
-                       $fresh_intl = get_pref($this->link, "FRESH_ARTICLE_MAX_AGE") * 60 * 60;
+                       $fresh_intl = get_pref( "FRESH_ARTICLE_MAX_AGE") * 60 * 60;
 
                        if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
 
-                       $expand_cdm = get_pref($this->link, 'CDM_EXPANDED');
+                       $expand_cdm = get_pref( 'CDM_EXPANDED');
 
                        while ($line = db_fetch_assoc($result)) {
                                $class = ($lnum % 2) ? "even" : "odd";
@@ -307,7 +307,7 @@ class Feeds extends Handler_Protected {
                                        }
                                }
 
-                               if (!is_array($labels)) $labels = get_article_labels($this->link, $id);
+                               if (!is_array($labels)) $labels = get_article_labels( $id);
 
                                $labels_str = "<span id=\"HLLCTR-$id\">";
                                $labels_str .= format_article_labels($labels, $id);
@@ -357,11 +357,11 @@ class Feeds extends Handler_Protected {
 #                              $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
 #                                      $line["title"] . "</a>";
 
-                               $updated_fmt = make_local_datetime($this->link, $line["updated"], false);
+                               $updated_fmt = make_local_datetime( $line["updated"], false);
                                $date_entered_fmt = T_sprintf("Imported at %s",
-                                       make_local_datetime($this->link, $line["date_entered"], false));
+                                       make_local_datetime( $line["date_entered"], false));
 
-                               if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {
+                               if (get_pref( 'SHOW_CONTENT_PREVIEW')) {
                                        $content_preview = truncate_string(strip_tags($line["content_preview"]),
                                                100);
                                }
@@ -429,9 +429,9 @@ class Feeds extends Handler_Protected {
                                        $row_background = "";
                                }
 
-                               if (!get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {
+                               if (!get_pref( 'COMBINED_DISPLAY_MODE')) {
 
-                                       if (get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {
+                                       if (get_pref( 'VFEED_GROUP_BY_FEED')) {
                                                if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
 
                                                        $cur_feed_title = $line["feed_title"];
@@ -472,7 +472,7 @@ class Feeds extends Handler_Protected {
                                                onclick=\"\">" .
                                                truncate_string($line["title"], 200);
 
-                                       if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {
+                                       if (get_pref( 'SHOW_CONTENT_PREVIEW')) {
                                                if ($content_preview) {
                                                        $reply['content'] .= "<span class=\"contentPreview\"> - $content_preview</span>";
                                                }
@@ -486,7 +486,7 @@ class Feeds extends Handler_Protected {
 
                                        $reply['content'] .= "<span class=\"hlUpdated\">";
 
-                                       if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {
+                                       if (!get_pref( 'VFEED_GROUP_BY_FEED')) {
                                                if (@$line["feed_title"]) {
                                                        $reply['content'] .= "<div class=\"hlFeed\">
                                                                <a href=\"#\" onclick=\"viewfeed($feed_id)\">".
@@ -502,7 +502,7 @@ class Feeds extends Handler_Protected {
 
                                        $reply['content'] .= $score_pic;
 
-                                       if ($line["feed_title"] && !get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {
+                                       if ($line["feed_title"] && !get_pref( 'VFEED_GROUP_BY_FEED')) {
 
                                                $reply['content'] .= "<span onclick=\"viewfeed($feed_id)\"
                                                        style=\"cursor : pointer\"
@@ -515,17 +515,17 @@ class Feeds extends Handler_Protected {
 
                                } else {
 
-                                       $line["tags"] = get_article_tags($this->link, $id, $_SESSION["uid"], $line["tag_cache"]);
+                                       $line["tags"] = get_article_tags( $id, $_SESSION["uid"], $line["tag_cache"]);
                                        unset($line["tag_cache"]);
 
-                                       $line["content"] = sanitize($this->link, $line["content_preview"],
+                                       $line["content"] = sanitize( $line["content_preview"],
                                                        sql_bool_to_bool($line['hide_images']), false, $entry_site_url);
 
                                        foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE_CDM) as $p) {
                                                $line = $p->hook_render_article_cdm($line);
                                        }
 
-                                       if (get_pref($this->link, 'VFEED_GROUP_BY_FEED') && $line["feed_title"]) {
+                                       if (get_pref( 'VFEED_GROUP_BY_FEED') && $line["feed_title"]) {
                                                if ($feed_id != $vgroup_last_feed) {
 
                                                        $cur_feed_title = $line["feed_title"];
@@ -594,7 +594,7 @@ class Feeds extends Handler_Protected {
                                                id=\"CEXC-$id\" class=\"cdmExcerpt\"> - $content_preview</span>";
                                        $reply['content'] .= "</span>";
 
-                                       if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {
+                                       if (!get_pref( 'VFEED_GROUP_BY_FEED')) {
                                                if (@$line["feed_title"]) {
                                                        $reply['content'] .= "<div class=\"hlFeed\">
                                                                <a href=\"#\" onclick=\"viewfeed($feed_id)\">".
@@ -609,7 +609,7 @@ class Feeds extends Handler_Protected {
                                        $reply['content'] .= "<div style=\"vertical-align : middle\">";
                                        $reply['content'] .= "$score_pic";
 
-                                       if (!get_pref($this->link, "VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
+                                       if (!get_pref( "VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
                                                $reply['content'] .= "<span style=\"cursor : pointer\"
                                                        title=\"".htmlspecialchars($line["feed_title"])."\"
                                                        onclick=\"viewfeed($feed_id)\">$feed_icon_img</span>";
@@ -633,7 +633,7 @@ class Feeds extends Handler_Protected {
 
                        if ($line["orig_feed_id"]) {
 
-                               $tmp_result = db_query($this->link, "SELECT * FROM ttrss_archived_feeds
+                               $tmp_result = db_query( "SELECT * FROM ttrss_archived_feeds
                                        WHERE id = ".$line["orig_feed_id"]);
 
                                                if (db_num_rows($tmp_result) != 0) {
@@ -673,7 +673,7 @@ class Feeds extends Handler_Protected {
 
                                        $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
 
-                                       $reply['content'] .= format_article_enclosures($this->link, $id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"]));
+                                       $reply['content'] .= format_article_enclosures( $id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"]));
 
                                        $reply['content'] .= "</div>";
 
@@ -757,15 +757,15 @@ class Feeds extends Handler_Protected {
 
                                $reply['content'] .= "<p><span class=\"insensitive\">";
 
-                               $result = db_query($this->link, "SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
+                               $result = db_query( "SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
                                        WHERE owner_uid = " . $_SESSION['uid']);
 
                                $last_updated = db_fetch_result($result, 0, "last_updated");
-                               $last_updated = make_local_datetime($this->link, $last_updated, false);
+                               $last_updated = make_local_datetime( $last_updated, false);
 
                                $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
 
-                               $result = db_query($this->link, "SELECT COUNT(id) AS num_errors
+                               $result = db_query( "SELECT COUNT(id) AS num_errors
                                        FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
 
                                $num_errors = db_fetch_result($result, 0, "num_errors");
@@ -786,9 +786,9 @@ class Feeds extends Handler_Protected {
        }
 
        function catchupAll() {
-               db_query($this->link, "UPDATE ttrss_user_entries SET
+               db_query( "UPDATE ttrss_user_entries SET
                                                last_read = NOW(), unread = false WHERE unread = true AND owner_uid = " . $_SESSION["uid"]);
-               ccache_zero_all($this->link, $_SESSION["uid"]);
+               ccache_zero_all( $_SESSION["uid"]);
        }
 
        function view() {
@@ -798,17 +798,17 @@ class Feeds extends Handler_Protected {
 
                if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
 
-               $omode = db_escape_string($this->link, $_REQUEST["omode"]);
+               $omode = db_escape_string( $_REQUEST["omode"]);
 
-               $feed = db_escape_string($this->link, $_REQUEST["feed"]);
-               $method = db_escape_string($this->link, $_REQUEST["m"]);
-               $view_mode = db_escape_string($this->link, $_REQUEST["view_mode"]);
+               $feed = db_escape_string( $_REQUEST["feed"]);
+               $method = db_escape_string( $_REQUEST["m"]);
+               $view_mode = db_escape_string( $_REQUEST["view_mode"]);
                $limit = 30;
                @$cat_view = $_REQUEST["cat"] == "true";
-               @$next_unread_feed = db_escape_string($this->link, $_REQUEST["nuf"]);
-               @$offset = db_escape_string($this->link, $_REQUEST["skip"]);
-               @$vgroup_last_feed = db_escape_string($this->link, $_REQUEST["vgrlf"]);
-               $order_by = db_escape_string($this->link, $_REQUEST["order_by"]);
+               @$next_unread_feed = db_escape_string( $_REQUEST["nuf"]);
+               @$offset = db_escape_string( $_REQUEST["skip"]);
+               @$vgroup_last_feed = db_escape_string( $_REQUEST["vgrlf"]);
+               $order_by = db_escape_string( $_REQUEST["order_by"]);
 
                if (is_numeric($feed)) $feed = (int) $feed;
 
@@ -816,7 +816,7 @@ class Feeds extends Handler_Protected {
                 * when there's nothing to load - e.g. no stuff in fresh feed */
 
                if ($feed == -5) {
-                       print json_encode($this->generate_dashboard_feed($this->link));
+                       print json_encode($this->generate_dashboard_feed());
                        return;
                }
 
@@ -824,18 +824,18 @@ class Feeds extends Handler_Protected {
 
                if ($feed < LABEL_BASE_INDEX) {
                        $label_feed = feed_to_label_id($feed);
-                       $result = db_query($this->link, "SELECT id FROM ttrss_labels2 WHERE
+                       $result = db_query( "SELECT id FROM ttrss_labels2 WHERE
                                                        id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);
                } else if (!$cat_view && is_numeric($feed) && $feed > 0) {
-                       $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
+                       $result = db_query( "SELECT id FROM ttrss_feeds WHERE
                                                        id = '$feed' AND owner_uid = " . $_SESSION['uid']);
                } else if ($cat_view && is_numeric($feed) && $feed > 0) {
-                       $result = db_query($this->link, "SELECT id FROM ttrss_feed_categories WHERE
+                       $result = db_query( "SELECT id FROM ttrss_feed_categories WHERE
                                                        id = '$feed' AND owner_uid = " . $_SESSION['uid']);
                }
 
                if ($result && db_num_rows($result) == 0) {
-                       print json_encode($this->generate_error_feed($this->link, __("Feed not found.")));
+                       print json_encode($this->generate_error_feed( __("Feed not found.")));
                        return;
                }
 
@@ -843,21 +843,21 @@ class Feeds extends Handler_Protected {
                 * so for performance reasons we don't do that here */
 
                if ($feed >= 0) {
-                       ccache_update($this->link, $feed, $_SESSION["uid"], $cat_view);
+                       ccache_update( $feed, $_SESSION["uid"], $cat_view);
                }
 
-               set_pref($this->link, "_DEFAULT_VIEW_MODE", $view_mode);
-               set_pref($this->link, "_DEFAULT_VIEW_ORDER_BY", $order_by);
+               set_pref( "_DEFAULT_VIEW_MODE", $view_mode);
+               set_pref( "_DEFAULT_VIEW_ORDER_BY", $order_by);
 
                /* bump login timestamp if needed */
                if (time() - $_SESSION["last_login_update"] > 3600) {
-                       db_query($this->link, "UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
+                       db_query( "UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
                                $_SESSION["uid"]);
                        $_SESSION["last_login_update"] = time();
                }
 
                if (!$cat_view && is_numeric($feed) && $feed > 0) {
-                       db_query($this->link, "UPDATE ttrss_feeds SET last_viewed = NOW()
+                       db_query( "UPDATE ttrss_feeds SET last_viewed = NOW()
                                                        WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
                }
 
@@ -907,13 +907,13 @@ class Feeds extends Handler_Protected {
 
                if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
 
-               $reply['runtime-info'] = make_runtime_info($this->link);
+               $reply['runtime-info'] = make_runtime_info();
 
                print json_encode($reply);
 
        }
 
-       private function generate_dashboard_feed($link) {
+       private function generate_dashboard_feed() {
                $reply = array();
 
                $reply['headlines']['id'] = -5;
@@ -924,15 +924,15 @@ class Feeds extends Handler_Protected {
 
                $reply['headlines']['content'] .= "<p><span class=\"insensitive\">";
 
-               $result = db_query($link, "SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
+               $result = db_query( "SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
                        WHERE owner_uid = " . $_SESSION['uid']);
 
                $last_updated = db_fetch_result($result, 0, "last_updated");
-               $last_updated = make_local_datetime($link, $last_updated, false);
+               $last_updated = make_local_datetime( $last_updated, false);
 
                $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
 
-               $result = db_query($link, "SELECT COUNT(id) AS num_errors
+               $result = db_query( "SELECT COUNT(id) AS num_errors
                        FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
 
                $num_errors = db_fetch_result($result, 0, "num_errors");
@@ -952,7 +952,7 @@ class Feeds extends Handler_Protected {
                return $reply;
        }
 
-       private function generate_error_feed($link, $error) {
+       private function generate_error_feed( $error) {
                $reply = array();
 
                $reply['headlines']['id'] = -6;
@@ -986,9 +986,9 @@ class Feeds extends Handler_Protected {
 
                print "<hr/>";
 
-               if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
+               if (get_pref( 'ENABLE_FEED_CATS')) {
                        print __('Place in category:') . " ";
-                       print_feed_cat_select($this->link, "cat", false, 'dojoType="dijit.form.Select"');
+                       print_feed_cat_select( "cat", false, 'dojoType="dijit.form.Select"');
                }
 
                print "</div>";
@@ -1044,7 +1044,7 @@ class Feeds extends Handler_Protected {
        function feedBrowser() {
                if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) return;
 
-               $browser_search = db_escape_string($this->link, $_REQUEST["search"]);
+               $browser_search = db_escape_string( $_REQUEST["search"]);
 
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"updateFeedBrowser\">";
@@ -1081,7 +1081,7 @@ class Feeds extends Handler_Protected {
                require_once "feedbrowser.php";
 
                print "<ul class='browseFeedList' id='browseFeedList'>";
-               print make_feed_browser($this->link, $search, 25);
+               print make_feed_browser( $search, 25);
                print "</ul>";
 
                print "<div align='center'>
@@ -1092,7 +1092,7 @@ class Feeds extends Handler_Protected {
        }
 
        function search() {
-               $this->params = explode(":", db_escape_string($this->link, $_REQUEST["param"]), 2);
+               $this->params = explode(":", db_escape_string( $_REQUEST["param"]), 2);
 
                $active_feed_id = sprintf("%d", $this->params[0]);
                $is_cat = $this->params[1] != "false";
@@ -1110,12 +1110,12 @@ class Feeds extends Handler_Protected {
                print "<select name=\"search_mode\" dojoType=\"dijit.form.Select\">
                        <option value=\"all_feeds\">".__('All feeds')."</option>";
 
-               $feed_title = getFeedTitle($this->link, $active_feed_id);
+               $feed_title = getFeedTitle( $active_feed_id);
 
                if (!$is_cat) {
-                       $feed_cat_title = getFeedCatTitle($this->link, $active_feed_id);
+                       $feed_cat_title = getFeedCatTitle( $active_feed_id);
                } else {
-                       $feed_cat_title = getCategoryTitle($this->link, $active_feed_id);
+                       $feed_cat_title = getCategoryTitle( $active_feed_id);
                }
 
                if ($active_feed_id && !$is_cat) {
@@ -1128,7 +1128,7 @@ class Feeds extends Handler_Protected {
                        $cat_preselected = "selected=\"1\"";
                }
 
-               if (get_pref($this->link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
+               if (get_pref( 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
                        print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
                } else {
                        //print "<option disabled>".__('This category')."</option>";
index 68b16eac199f608149ade09ae3e4c51a0ebb5569..d8e2a3025cfb47d329577391f6791868bbe47b28 100644 (file)
@@ -1,10 +1,10 @@
 <?php
 class Handler implements IHandler {
-       protected $link;
+       protected $dbh;
        protected $args;
 
-       function __construct($link, $args) {
-               $this->link = $link;
+       function __construct($dbh, $args) {
+               $this->dbh = $dbh;
                $this->args = $args;
        }
 
index e95f118bbd381c910c31a8462f04fabd80f9f513..1e96bef0034585e7bdfb90a0e45d92e44f7e33d9 100644 (file)
@@ -21,7 +21,7 @@ class Handler_Public extends Handler {
                else if ($feed == -1)
                        $date_sort_field = "last_marked DESC";
 
-               $qfh_ret = queryFeedHeadlines($this->link, $feed,
+               $qfh_ret = queryFeedHeadlines( $feed,
                        1, $view_mode, $is_cat, $search, $search_mode,
                        $date_sort_field, $offset, $owner_uid,
                        false, 0, false, true);
@@ -41,7 +41,7 @@ class Handler_Public extends Handler {
                        header("Last-Modified: $last_modified", true);
                }
 
-               $qfh_ret = queryFeedHeadlines($this->link, $feed,
+               $qfh_ret = queryFeedHeadlines( $feed,
                        $limit, $view_mode, $is_cat, $search, $search_mode,
                        $date_sort_field, $offset, $owner_uid,
                        false, 0, false, true);
@@ -54,7 +54,7 @@ class Handler_Public extends Handler {
 
                $feed_self_url = get_self_url_prefix() .
                        "/public.php?op=rss&id=-2&key=" .
-                       get_feed_access_key($this->link, -2, false, $owner_uid);
+                       get_feed_access_key( -2, false, $owner_uid);
 
                if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
 
@@ -82,7 +82,7 @@ class Handler_Public extends Handler {
                                $tpl->setVariable('ARTICLE_EXCERPT',
                                        truncate_string(strip_tags($line["content_preview"]), 100, '...'), true);
 
-                               $content = sanitize($this->link, $line["content_preview"], false, $owner_uid);
+                               $content = sanitize( $line["content_preview"], false, $owner_uid);
 
                                if ($line['note']) {
                                        $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
@@ -99,14 +99,14 @@ class Handler_Public extends Handler {
 
                                $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
 
-                               $tags = get_article_tags($this->link, $line["id"], $owner_uid);
+                               $tags = get_article_tags( $line["id"], $owner_uid);
 
                                foreach ($tags as $tag) {
                                        $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
                                        $tpl->addBlock('category');
                                }
 
-                               $enclosures = get_article_enclosures($this->link, $line["id"]);
+                               $enclosures = get_article_enclosures( $line["id"]);
 
                                foreach ($enclosures as $e) {
                                        $type = htmlspecialchars($e['content_type']);
@@ -158,13 +158,13 @@ class Handler_Public extends Handler {
                                $article['link']        = $line['link'];
                                $article['title'] = $line['title'];
                                $article['excerpt'] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
-                               $article['content'] = sanitize($this->link, $line["content_preview"], false, $owner_uid);
+                               $article['content'] = sanitize( $line["content_preview"], false, $owner_uid);
                                $article['updated'] = date('c', strtotime($line["updated"]));
 
                                if ($line['note']) $article['note'] = $line['note'];
                                if ($article['author']) $article['author'] = $line['author'];
 
-                               $tags = get_article_tags($this->link, $line["id"], $owner_uid);
+                               $tags = get_article_tags( $line["id"], $owner_uid);
 
                                if (count($tags) > 0) {
                                        $article['tags'] = array();
@@ -174,7 +174,7 @@ class Handler_Public extends Handler {
                                        }
                                }
 
-                               $enclosures = get_article_enclosures($this->link, $line["id"]);
+                               $enclosures = get_article_enclosures( $line["id"]);
 
                                if (count($enclosures) > 0) {
                                        $article['enclosures'] = array();
@@ -201,19 +201,19 @@ class Handler_Public extends Handler {
        }
 
        function getUnread() {
-               $login = db_escape_string($this->link, $_REQUEST["login"]);
+               $login = db_escape_string( $_REQUEST["login"]);
                $fresh = $_REQUEST["fresh"] == "1";
 
-               $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE login = '$login'");
+               $result = db_query( "SELECT id FROM ttrss_users WHERE login = '$login'");
 
                if (db_num_rows($result) == 1) {
                        $uid = db_fetch_result($result, 0, "id");
 
-                       print getGlobalUnread($this->link, $uid);
+                       print getGlobalUnread( $uid);
 
                        if ($fresh) {
                                print ";";
-                               print getFeedArticles($this->link, -3, false, true, $uid);
+                               print getFeedArticles( -3, false, true, $uid);
                        }
 
                } else {
@@ -223,9 +223,9 @@ class Handler_Public extends Handler {
        }
 
        function getProfiles() {
-               $login = db_escape_string($this->link, $_REQUEST["login"]);
+               $login = db_escape_string( $_REQUEST["login"]);
 
-               $result = db_query($this->link, "SELECT * FROM ttrss_settings_profiles,ttrss_users
+               $result = db_query( "SELECT * FROM ttrss_settings_profiles,ttrss_users
                        WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title");
 
                print "<select dojoType='dijit.form.Select' style='width : 220px; margin : 0px' name='profile'>";
@@ -243,9 +243,9 @@ class Handler_Public extends Handler {
        }
 
        function pubsub() {
-               $mode = db_escape_string($this->link, $_REQUEST['hub_mode']);
-               $feed_id = (int) db_escape_string($this->link, $_REQUEST['id']);
-               $feed_url = db_escape_string($this->link, $_REQUEST['hub_topic']);
+               $mode = db_escape_string( $_REQUEST['hub_mode']);
+               $feed_id = (int) db_escape_string( $_REQUEST['id']);
+               $feed_url = db_escape_string( $_REQUEST['hub_topic']);
 
                if (!PUBSUBHUBBUB_ENABLED) {
                        header('HTTP/1.0 404 Not Found');
@@ -255,7 +255,7 @@ class Handler_Public extends Handler {
 
                // TODO: implement hub_verifytoken checking
 
-               $result = db_query($this->link, "SELECT feed_url FROM ttrss_feeds
+               $result = db_query( "SELECT feed_url FROM ttrss_feeds
                        WHERE id = '$feed_id'");
 
                if (db_num_rows($result) != 0) {
@@ -265,7 +265,7 @@ class Handler_Public extends Handler {
                        if ($check_feed_url && ($check_feed_url == $feed_url || !$feed_url)) {
                                if ($mode == "subscribe") {
 
-                                       db_query($this->link, "UPDATE ttrss_feeds SET pubsub_state = 2
+                                       db_query( "UPDATE ttrss_feeds SET pubsub_state = 2
                                                WHERE id = '$feed_id'");
 
                                        print $_REQUEST['hub_challenge'];
@@ -273,7 +273,7 @@ class Handler_Public extends Handler {
 
                                } else if ($mode == "unsubscribe") {
 
-                                       db_query($this->link, "UPDATE ttrss_feeds SET pubsub_state = 0
+                                       db_query( "UPDATE ttrss_feeds SET pubsub_state = 0
                                                WHERE id = '$feed_id'");
 
                                        print $_REQUEST['hub_challenge'];
@@ -282,9 +282,9 @@ class Handler_Public extends Handler {
                                } else if (!$mode) {
 
                                        // Received update ping, schedule feed update.
-                                       //update_rss_feed($this->link, $feed_id, true, true);
+                                       //update_rss_feed( $feed_id, true, true);
 
-                                       db_query($this->link, "UPDATE ttrss_feeds SET
+                                       db_query( "UPDATE ttrss_feeds SET
                                                last_update_started = '1970-01-01',
                                                last_updated = '1970-01-01' WHERE id = '$feed_id'");
 
@@ -306,9 +306,9 @@ class Handler_Public extends Handler {
        }
 
        function share() {
-               $uuid = db_escape_string($this->link, $_REQUEST["key"]);
+               $uuid = db_escape_string( $_REQUEST["key"]);
 
-               $result = db_query($this->link, "SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
+               $result = db_query( "SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
                        uuid = '$uuid'");
 
                if (db_num_rows($result) != 0) {
@@ -317,7 +317,7 @@ class Handler_Public extends Handler {
                        $id = db_fetch_result($result, 0, "ref_id");
                        $owner_uid = db_fetch_result($result, 0, "owner_uid");
 
-                       $article = format_article($this->link, $id, false, true, $owner_uid);
+                       $article = format_article( $id, false, true, $owner_uid);
 
                        print_r($article['content']);
 
@@ -328,28 +328,28 @@ class Handler_Public extends Handler {
        }
 
        function rss() {
-               $feed = db_escape_string($this->link, $_REQUEST["id"]);
-               $key = db_escape_string($this->link, $_REQUEST["key"]);
+               $feed = db_escape_string( $_REQUEST["id"]);
+               $key = db_escape_string( $_REQUEST["key"]);
                $is_cat = $_REQUEST["is_cat"] != false;
-               $limit = (int)db_escape_string($this->link, $_REQUEST["limit"]);
-               $offset = (int)db_escape_string($this->link, $_REQUEST["offset"]);
+               $limit = (int)db_escape_string( $_REQUEST["limit"]);
+               $offset = (int)db_escape_string( $_REQUEST["offset"]);
 
-               $search = db_escape_string($this->link, $_REQUEST["q"]);
-               $search_mode = db_escape_string($this->link, $_REQUEST["smode"]);
-               $view_mode = db_escape_string($this->link, $_REQUEST["view-mode"]);
+               $search = db_escape_string( $_REQUEST["q"]);
+               $search_mode = db_escape_string( $_REQUEST["smode"]);
+               $view_mode = db_escape_string( $_REQUEST["view-mode"]);
 
-               $format = db_escape_string($this->link, $_REQUEST['format']);
+               $format = db_escape_string( $_REQUEST['format']);
 
                if (!$format) $format = 'atom';
 
                if (SINGLE_USER_MODE) {
-                       authenticate_user($this->link, "admin", null);
+                       authenticate_user( "admin", null);
                }
 
                $owner_id = false;
 
                if ($key) {
-                       $result = db_query($this->link, "SELECT owner_uid FROM
+                       $result = db_query( "SELECT owner_uid FROM
                                ttrss_access_keys WHERE access_key = '$key' AND feed_id = '$feed'");
 
                        if (db_num_rows($result) == 1)
@@ -367,15 +367,15 @@ class Handler_Public extends Handler {
        function globalUpdateFeeds() {
                include "rssfuncs.php";
                // Update all feeds needing a update.
-               update_daemon_common($this->link, 0, true, false);
+               update_daemon_common( 0, true, false);
 
                // Update feedbrowser
-               update_feedbrowser_cache($this->link);
+               update_feedbrowser_cache();
 
                // Purge orphans and cleanup tags
-               purge_orphans($this->link);
+               purge_orphans();
 
-               cleanup_tags($this->link, 14, 50000);
+               cleanup_tags( 14, 50000);
 
                global $pluginhost;
                $pluginhost->run_hooks($pluginhost::HOOK_UPDATE_TASK, "hook_update_task", $op);
@@ -384,7 +384,7 @@ class Handler_Public extends Handler {
 
        function sharepopup() {
                if (SINGLE_USER_MODE) {
-                       login_sequence($this->link);
+                       login_sequence();
                }
 
                header('Content-Type: text/html; charset=utf-8');
@@ -402,12 +402,12 @@ class Handler_Public extends Handler {
 
                        if ($action == 'share') {
 
-                               $title = db_escape_string($this->link, strip_tags($_REQUEST["title"]));
-                               $url = db_escape_string($this->link, strip_tags($_REQUEST["url"]));
-                               $content = db_escape_string($this->link, strip_tags($_REQUEST["content"]));
-                               $labels = db_escape_string($this->link, strip_tags($_REQUEST["labels"]));
+                               $title = db_escape_string( strip_tags($_REQUEST["title"]));
+                               $url = db_escape_string( strip_tags($_REQUEST["url"]));
+                               $content = db_escape_string( strip_tags($_REQUEST["content"]));
+                               $labels = db_escape_string( strip_tags($_REQUEST["labels"]));
 
-                               Article::create_published_article($this->link, $title, $url, $content, $labels,
+                               Article::create_published_article( $title, $url, $content, $labels,
                                        $_SESSION["uid"]);
 
                                print "<script type='text/javascript'>";
@@ -513,7 +513,7 @@ class Handler_Public extends Handler {
 
                if (!SINGLE_USER_MODE) {
 
-                       $login = db_escape_string($this->link, $_POST["login"]);
+                       $login = db_escape_string( $_POST["login"]);
                        $password = $_POST["password"];
                        $remember_me = $_POST["remember_me"];
 
@@ -525,18 +525,18 @@ class Handler_Public extends Handler {
 
                        @session_start();
 
-                       if (authenticate_user($this->link, $login, $password)) {
+                       if (authenticate_user( $login, $password)) {
                                $_POST["password"] = "";
 
                                $_SESSION["language"] = $_POST["language"];
-                               $_SESSION["ref_schema_version"] = get_schema_version($this->link, true);
+                               $_SESSION["ref_schema_version"] = get_schema_version( true);
                                $_SESSION["bw_limit"] = !!$_POST["bw_limit"];
 
                                if ($_POST["profile"]) {
 
-                                       $profile = db_escape_string($this->link, $_POST["profile"]);
+                                       $profile = db_escape_string( $_POST["profile"]);
 
-                                       $result = db_query($this->link, "SELECT id FROM ttrss_settings_profiles
+                                       $result = db_query( "SELECT id FROM ttrss_settings_profiles
                                                WHERE id = '$profile' AND owner_uid = " . $_SESSION["uid"]);
 
                                        if (db_num_rows($result) != 0) {
@@ -558,12 +558,12 @@ class Handler_Public extends Handler {
 
        function subscribe() {
                if (SINGLE_USER_MODE) {
-                       login_sequence($this->link);
+                       login_sequence();
                }
 
                if ($_SESSION["uid"]) {
 
-                       $feed_url = db_escape_string($this->link, trim($_REQUEST["feed_url"]));
+                       $feed_url = db_escape_string( trim($_REQUEST["feed_url"]));
 
                        header('Content-Type: text/html; charset=utf-8');
                        print "<html>
@@ -577,7 +577,7 @@ class Handler_Public extends Handler {
                                        alt=\"Tiny Tiny RSS\"/>
                                        <h1>".__("Subscribe to feed...")."</h1><div class='content'>";
 
-                       $rc = subscribe_to_feed($this->link, $feed_url);
+                       $rc = subscribe_to_feed( $feed_url);
 
                        switch ($rc['code']) {
                        case 0:
@@ -625,7 +625,7 @@ class Handler_Public extends Handler {
                        $tt_uri = get_self_url_prefix();
 
                        if ($rc['code'] <= 2){
-                               $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
+                               $result = db_query( "SELECT id FROM ttrss_feeds WHERE
                                        feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
 
                                $feed_id = db_fetch_result($result, 0, "id");
@@ -651,21 +651,21 @@ class Handler_Public extends Handler {
                        print "</div></body></html>";
 
                } else {
-                       render_login_form($this->link);
+                       render_login_form();
                }
        }
 
        function subscribe2() {
-               $feed_url = db_escape_string($this->link, trim($_REQUEST["feed_url"]));
-               $cat_id = db_escape_string($this->link, $_REQUEST["cat_id"]);
-               $from = db_escape_string($this->link, $_REQUEST["from"]);
+               $feed_url = db_escape_string( trim($_REQUEST["feed_url"]));
+               $cat_id = db_escape_string( $_REQUEST["cat_id"]);
+               $from = db_escape_string( $_REQUEST["from"]);
 
                /* only read authentication information from POST */
 
-               $auth_login = db_escape_string($this->link, trim($_POST["auth_login"]));
-               $auth_pass = db_escape_string($this->link, trim($_POST["auth_pass"]));
+               $auth_login = db_escape_string( trim($_POST["auth_login"]));
+               $auth_pass = db_escape_string( trim($_POST["auth_pass"]));
 
-               $rc = subscribe_to_feed($this->link, $feed_url, $cat_id, $auth_login, $auth_pass);
+               $rc = subscribe_to_feed( $feed_url, $cat_id, $auth_login, $auth_pass);
 
                switch ($rc) {
                case 1:
@@ -712,7 +712,7 @@ class Handler_Public extends Handler {
                $tt_uri = get_self_url_prefix();
 
                if ($rc <= 2){
-                       $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
+                       $result = db_query( "SELECT id FROM ttrss_feeds WHERE
                                feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
 
                        $feed_id = db_fetch_result($result, 0, "id");
@@ -788,9 +788,9 @@ class Handler_Public extends Handler {
                        print "</form>";
                } else if ($method == 'do') {
 
-                       $login = db_escape_string($this->link, $_POST["login"]);
-                       $email = db_escape_string($this->link, $_POST["email"]);
-                       $test = db_escape_string($this->link, $_POST["test"]);
+                       $login = db_escape_string( $_POST["login"]);
+                       $email = db_escape_string( $_POST["email"]);
+                       $test = db_escape_string( $_POST["test"]);
 
                        if (($test != 4 && $test != 'four') || !$email || !$login) {
                                print_error(__('Some of the required form parameters are missing or incorrect.'));
@@ -802,13 +802,13 @@ class Handler_Public extends Handler {
 
                        } else {
 
-                               $result = db_query($this->link, "SELECT id FROM ttrss_users
+                               $result = db_query( "SELECT id FROM ttrss_users
                                        WHERE login = '$login' AND email = '$email'");
 
                                if (db_num_rows($result) != 0) {
                                        $id = db_fetch_result($result, 0, "id");
 
-                                       Pref_Users::resetUserPassword($this->link, $id, false);
+                                       Pref_Users::resetUserPassword( $id, false);
 
                                        print "<p>";
 
@@ -840,7 +840,7 @@ class Handler_Public extends Handler {
        function dbupdate() {
                if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
                        $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
-                       render_login_form($link);
+                       render_login_form();
                        exit;
                }
 
@@ -869,7 +869,7 @@ class Handler_Public extends Handler {
 
                        <?php
                                @$op = $_REQUEST["subop"];
-                               $updater = new DbUpdater($this->link, DB_TYPE, SCHEMA_VERSION);
+                               $updater = new DbUpdater( DB_TYPE, SCHEMA_VERSION);
 
                                if ($op == "performupdate") {
                                        if ($updater->isUpdateRequired()) {
index b0e0b0db5e1f05eac78112931c14715ad5049052..387478c10fd36de12d39bec72bf0ac75cdf1f23f 100644 (file)
@@ -12,7 +12,7 @@ class Logger_SQL {
                        $file = Db::get()->escape_string($file);
                        $line = Db::get()->escape_string($line);
                        $context = ''; // backtrace is a lot of data which is not really critical to store
-                       //$context = db_escape_string($this->link, serialize($context));
+                       //$context = db_escape_string( serialize($context));
 
                        $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : "NULL";
 
index 2ecae42379ca5de4a7ad5a105fda8ecaf5d29f83..a800880e46ec9530f1580d46648e5b0804ba192a 100644 (file)
@@ -32,7 +32,7 @@ class Opml extends Handler_Protected {
                        <div class=\"floatingLogo\"><img src=\"images/logo_small.png\"></div>
                        <h1>".__('OPML Utility')."</h1><div class='content'>";
 
-               add_feed_category($this->link, "Imported feeds");
+               add_feed_category( "Imported feeds");
 
                $this->opml_notice(__("Importing OPML..."));
                $this->opml_import($owner_uid);
@@ -66,14 +66,14 @@ class Opml extends Handler_Protected {
                $out = "";
 
                if ($cat_id) {
-                       $result = db_query($this->link, "SELECT title FROM ttrss_feed_categories WHERE id = '$cat_id'
+                       $result = db_query( "SELECT title FROM ttrss_feed_categories WHERE id = '$cat_id'
                                AND owner_uid = '$owner_uid'");
                        $cat_title = htmlspecialchars(db_fetch_result($result, 0, "title"));
                }
 
                if ($cat_title) $out .= "<outline text=\"$cat_title\">\n";
 
-               $result = db_query($this->link, "SELECT id,title
+               $result = db_query( "SELECT id,title
                        FROM ttrss_feed_categories WHERE
                        $cat_qpart AND owner_uid = '$owner_uid' ORDER BY order_id, title");
 
@@ -82,7 +82,7 @@ class Opml extends Handler_Protected {
                        $out .= $this->opml_export_category($owner_uid, $line["id"], $hide_private_feeds);
                }
 
-               $feeds_result = db_query($this->link, "select title, feed_url, site_url
+               $feeds_result = db_query( "select title, feed_url, site_url
                                from ttrss_feeds where $feed_cat_qpart AND owner_uid = '$owner_uid' AND $hide_qpart
                                order by order_id, title");
 
@@ -131,7 +131,7 @@ class Opml extends Handler_Protected {
                if ($include_settings) {
                        $out .= "<outline text=\"tt-rss-prefs\" schema-version=\"".SCHEMA_VERSION."\">";
 
-                       $result = db_query($this->link, "SELECT pref_name, value FROM ttrss_user_prefs WHERE
+                       $result = db_query( "SELECT pref_name, value FROM ttrss_user_prefs WHERE
                           profile IS NULL AND owner_uid = " . $_SESSION["uid"] . " ORDER BY pref_name");
 
                        while ($line = db_fetch_assoc($result)) {
@@ -145,7 +145,7 @@ class Opml extends Handler_Protected {
 
                        $out .= "<outline text=\"tt-rss-labels\" schema-version=\"".SCHEMA_VERSION."\">";
 
-                       $result = db_query($this->link, "SELECT * FROM ttrss_labels2 WHERE
+                       $result = db_query( "SELECT * FROM ttrss_labels2 WHERE
                                owner_uid = " . $_SESSION['uid']);
 
                        while ($line = db_fetch_assoc($result)) {
@@ -161,7 +161,7 @@ class Opml extends Handler_Protected {
 
                        $out .= "<outline text=\"tt-rss-filters\" schema-version=\"".SCHEMA_VERSION."\">";
 
-                       $result = db_query($this->link, "SELECT * FROM ttrss_filters2
+                       $result = db_query( "SELECT * FROM ttrss_filters2
                                WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY id");
 
                        while ($line = db_fetch_assoc($result)) {
@@ -172,7 +172,7 @@ class Opml extends Handler_Protected {
                                $line["rules"] = array();
                                $line["actions"] = array();
 
-                               $tmp_result = db_query($this->link, "SELECT * FROM ttrss_filters2_rules
+                               $tmp_result = db_query( "SELECT * FROM ttrss_filters2_rules
                                        WHERE filter_id = ".$line["id"]);
 
                                while ($tmp_line = db_fetch_assoc($tmp_result)) {
@@ -182,7 +182,7 @@ class Opml extends Handler_Protected {
                                        $cat_filter = sql_bool_to_bool($tmp_line["cat_filter"]);
 
                                        if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) {
-                                               $tmp_line["feed"] = getFeedTitle($this->link,
+                                               $tmp_line["feed"] = getFeedTitle(
                                                        $cat_filter ? $tmp_line["cat_id"] : $tmp_line["feed_id"],
                                                        $cat_filter);
                                        } else {
@@ -197,7 +197,7 @@ class Opml extends Handler_Protected {
                                        array_push($line["rules"], $tmp_line);
                                }
 
-                               $tmp_result = db_query($this->link, "SELECT * FROM ttrss_filters2_actions
+                               $tmp_result = db_query( "SELECT * FROM ttrss_filters2_actions
                                        WHERE filter_id = ".$line["id"]);
 
                                while ($tmp_line = db_fetch_assoc($tmp_result)) {
@@ -253,16 +253,16 @@ class Opml extends Handler_Protected {
        private function opml_import_feed($doc, $node, $cat_id, $owner_uid) {
                $attrs = $node->attributes;
 
-               $feed_title = db_escape_string($this->link, mb_substr($attrs->getNamedItem('text')->nodeValue, 0, 250));
-               if (!$feed_title) $feed_title = db_escape_string($this->link, mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250));
+               $feed_title = db_escape_string( mb_substr($attrs->getNamedItem('text')->nodeValue, 0, 250));
+               if (!$feed_title) $feed_title = db_escape_string( mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250));
 
-               $feed_url = db_escape_string($this->link, mb_substr($attrs->getNamedItem('xmlUrl')->nodeValue, 0, 250));
-               if (!$feed_url) $feed_url = db_escape_string($this->link, mb_substr($attrs->getNamedItem('xmlURL')->nodeValue, 0, 250));
+               $feed_url = db_escape_string( mb_substr($attrs->getNamedItem('xmlUrl')->nodeValue, 0, 250));
+               if (!$feed_url) $feed_url = db_escape_string( mb_substr($attrs->getNamedItem('xmlURL')->nodeValue, 0, 250));
 
-               $site_url = db_escape_string($this->link, mb_substr($attrs->getNamedItem('htmlUrl')->nodeValue, 0, 250));
+               $site_url = db_escape_string( mb_substr($attrs->getNamedItem('htmlUrl')->nodeValue, 0, 250));
 
                if ($feed_url && $feed_title) {
-                       $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
+                       $result = db_query( "SELECT id FROM ttrss_feeds WHERE
                                feed_url = '$feed_url' AND owner_uid = '$owner_uid'");
 
                        if (db_num_rows($result) == 0) {
@@ -275,7 +275,7 @@ class Opml extends Handler_Protected {
                                        (title, feed_url, owner_uid, cat_id, site_url, order_id) VALUES
                                        ('$feed_title', '$feed_url', '$owner_uid',
                                        $cat_id, '$site_url', 0)";
-                               db_query($this->link, $query);
+                               db_query( $query);
 
                        } else {
                                $this->opml_notice(T_sprintf("Duplicate feed: %s", $feed_title));
@@ -285,15 +285,15 @@ class Opml extends Handler_Protected {
 
        private function opml_import_label($doc, $node, $owner_uid) {
                $attrs = $node->attributes;
-               $label_name = db_escape_string($this->link, $attrs->getNamedItem('label-name')->nodeValue);
+               $label_name = db_escape_string( $attrs->getNamedItem('label-name')->nodeValue);
 
                if ($label_name) {
-                       $fg_color = db_escape_string($this->link, $attrs->getNamedItem('label-fg-color')->nodeValue);
-                       $bg_color = db_escape_string($this->link, $attrs->getNamedItem('label-bg-color')->nodeValue);
+                       $fg_color = db_escape_string( $attrs->getNamedItem('label-fg-color')->nodeValue);
+                       $bg_color = db_escape_string( $attrs->getNamedItem('label-bg-color')->nodeValue);
 
-                       if (!label_find_id($this->link, $label_name, $_SESSION['uid'])) {
+                       if (!label_find_id( $label_name, $_SESSION['uid'])) {
                                $this->opml_notice(T_sprintf("Adding label %s", htmlspecialchars($label_name)));
-                               label_create($this->link, $label_name, $fg_color, $bg_color, $owner_uid);
+                               label_create( $label_name, $fg_color, $bg_color, $owner_uid);
                        } else {
                                $this->opml_notice(T_sprintf("Duplicate label: %s", htmlspecialchars($label_name)));
                        }
@@ -302,22 +302,22 @@ class Opml extends Handler_Protected {
 
        private function opml_import_preference($doc, $node, $owner_uid) {
                $attrs = $node->attributes;
-               $pref_name = db_escape_string($this->link, $attrs->getNamedItem('pref-name')->nodeValue);
+               $pref_name = db_escape_string( $attrs->getNamedItem('pref-name')->nodeValue);
 
                if ($pref_name) {
-                       $pref_value = db_escape_string($this->link, $attrs->getNamedItem('value')->nodeValue);
+                       $pref_value = db_escape_string( $attrs->getNamedItem('value')->nodeValue);
 
                        $this->opml_notice(T_sprintf("Setting preference key %s to %s",
                                $pref_name, $pref_value));
 
-                       set_pref($this->link, $pref_name, $pref_value);
+                       set_pref( $pref_name, $pref_value);
                }
        }
 
        private function opml_import_filter($doc, $node, $owner_uid) {
                $attrs = $node->attributes;
 
-               $filter_type = db_escape_string($this->link, $attrs->getNamedItem('filter-type')->nodeValue);
+               $filter_type = db_escape_string( $attrs->getNamedItem('filter-type')->nodeValue);
 
                if ($filter_type == '2') {
                        $filter = json_decode($node->nodeValue, true);
@@ -326,12 +326,12 @@ class Opml extends Handler_Protected {
                                $match_any_rule = bool_to_sql_bool($filter["match_any_rule"]);
                                $enabled = bool_to_sql_bool($filter["enabled"]);
 
-                               db_query($this->link, "BEGIN");
+                               db_query( "BEGIN");
 
-                               db_query($this->link, "INSERT INTO ttrss_filters2 (match_any_rule,enabled,owner_uid)
+                               db_query( "INSERT INTO ttrss_filters2 (match_any_rule,enabled,owner_uid)
                                        VALUES ($match_any_rule, $enabled,".$_SESSION["uid"].")");
 
-                               $result = db_query($this->link, "SELECT MAX(id) AS id FROM ttrss_filters2 WHERE
+                               $result = db_query( "SELECT MAX(id) AS id FROM ttrss_filters2 WHERE
                                        owner_uid = ".$_SESSION["uid"]);
                                $filter_id = db_fetch_result($result, 0, "id");
 
@@ -343,14 +343,14 @@ class Opml extends Handler_Protected {
                                                $cat_id = "NULL";
 
                                                if (!$rule["cat_filter"]) {
-                                                       $tmp_result = db_query($this->link, "SELECT id FROM ttrss_feeds
-                                                               WHERE title = '".db_escape_string($this->link, $rule["feed"])."' AND owner_uid = ".$_SESSION["uid"]);
+                                                       $tmp_result = db_query( "SELECT id FROM ttrss_feeds
+                                                               WHERE title = '".db_escape_string( $rule["feed"])."' AND owner_uid = ".$_SESSION["uid"]);
                                                        if (db_num_rows($tmp_result) > 0) {
                                                                $feed_id = db_fetch_result($tmp_result, 0, "id");
                                                        }
                                                } else {
-                                                       $tmp_result = db_query($this->link, "SELECT id FROM ttrss_feed_categories
-                                                               WHERE title = '".db_escape_string($this->link, $rule["feed"])."' AND owner_uid = ".$_SESSION["uid"]);
+                                                       $tmp_result = db_query( "SELECT id FROM ttrss_feed_categories
+                                                               WHERE title = '".db_escape_string( $rule["feed"])."' AND owner_uid = ".$_SESSION["uid"]);
 
                                                        if (db_num_rows($tmp_result) > 0) {
                                                                $cat_id = db_fetch_result($tmp_result, 0, "id");
@@ -358,24 +358,24 @@ class Opml extends Handler_Protected {
                                                }
 
                                                $cat_filter = bool_to_sql_bool($rule["cat_filter"]);
-                                               $reg_exp = db_escape_string($this->link, $rule["reg_exp"]);
+                                               $reg_exp = db_escape_string( $rule["reg_exp"]);
                                                $filter_type = (int)$rule["filter_type"];
 
-                                               db_query($this->link, "INSERT INTO ttrss_filters2_rules (feed_id,cat_id,filter_id,filter_type,reg_exp,cat_filter)
+                                               db_query( "INSERT INTO ttrss_filters2_rules (feed_id,cat_id,filter_id,filter_type,reg_exp,cat_filter)
                                                        VALUES ($feed_id, $cat_id, $filter_id, $filter_type, '$reg_exp', $cat_filter)");
                                        }
 
                                        foreach ($filter["actions"] as $action) {
 
                                                $action_id = (int)$action["action_id"];
-                                               $action_param = db_escape_string($this->link, $action["action_param"]);
+                                               $action_param = db_escape_string( $action["action_param"]);
 
-                                               db_query($this->link, "INSERT INTO ttrss_filters2_actions (filter_id,action_id,action_param)
+                                               db_query( "INSERT INTO ttrss_filters2_actions (filter_id,action_id,action_param)
                                                        VALUES ($filter_id, $action_id, '$action_param')");
                                        }
                                }
 
-                               db_query($this->link, "COMMIT");
+                               db_query( "COMMIT");
                        }
                }
        }
@@ -383,22 +383,22 @@ class Opml extends Handler_Protected {
        private function opml_import_category($doc, $root_node, $owner_uid, $parent_id) {
                $body = $doc->getElementsByTagName('body');
 
-               $default_cat_id = (int) get_feed_category($this->link, 'Imported feeds', false);
+               $default_cat_id = (int) get_feed_category( 'Imported feeds', false);
 
                if ($root_node) {
-                       $cat_title = db_escape_string($this->link, mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250));
+                       $cat_title = db_escape_string( mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250));
 
                        if (!$cat_title)
-                               $cat_title = db_escape_string($this->link, mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250));
+                               $cat_title = db_escape_string( mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250));
 
                        if (!in_array($cat_title, array("tt-rss-filters", "tt-rss-labels", "tt-rss-prefs"))) {
-                               $cat_id = get_feed_category($this->link, $cat_title, $parent_id);
-                               db_query($this->link, "BEGIN");
+                               $cat_id = get_feed_category( $cat_title, $parent_id);
+                               db_query( "BEGIN");
                                if ($cat_id === false) {
-                                       add_feed_category($this->link, $cat_title, $parent_id);
-                                       $cat_id = get_feed_category($this->link, $cat_title, $parent_id);
+                                       add_feed_category( $cat_title, $parent_id);
+                                       $cat_id = get_feed_category( $cat_title, $parent_id);
                                }
-                               db_query($this->link, "COMMIT");
+                               db_query( "COMMIT");
                        } else {
                                $cat_id = 0;
                        }
@@ -418,12 +418,12 @@ class Opml extends Handler_Protected {
                foreach ($outlines as $node) {
                        if ($node->hasAttributes() && strtolower($node->tagName) == "outline") {
                                $attrs = $node->attributes;
-                               $node_cat_title = db_escape_string($this->link, $attrs->getNamedItem('text')->nodeValue);
+                               $node_cat_title = db_escape_string( $attrs->getNamedItem('text')->nodeValue);
 
                                if (!$node_cat_title)
-                                       $node_cat_title = db_escape_string($this->link, $attrs->getNamedItem('title')->nodeValue);
+                                       $node_cat_title = db_escape_string( $attrs->getNamedItem('title')->nodeValue);
 
-                               $node_feed_url = db_escape_string($this->link, $attrs->getNamedItem('xmlUrl')->nodeValue);
+                               $node_feed_url = db_escape_string( $attrs->getNamedItem('xmlUrl')->nodeValue);
 
                                if ($node_cat_title && !$node_feed_url) {
                                        $this->opml_import_category($doc, $node, $owner_uid, $cat_id);
@@ -504,11 +504,11 @@ class Opml extends Handler_Protected {
                print "$msg<br/>";
        }
 
-       static function opml_publish_url($link){
+       static function opml_publish_url(){
 
                $url_path = get_self_url_prefix();
                $url_path .= "/opml.php?op=publish&key=" .
-                       get_feed_access_key($link, 'OPML:Publish', false, $_SESSION["uid"]);
+                       get_feed_access_key( 'OPML:Publish', false, $_SESSION["uid"]);
 
                return $url_path;
        }
index e655a2062ef998726ef148a3ed25fbac999f536a..60f127633428021ebaf77fdf9847d32c698d2223 100644 (file)
@@ -1,10 +1,10 @@
 <?php
 class Plugin {
-       private $link;
+       private $dbh;
        private $host;
 
        function init($host) {
-               $this->link = $host->get_link();
+               $this->dbh = $host->get_dbh();
                $this->host = $host;
        }
 
index bbfa2ca2a72f1fec1a0fdd19330cc70c305b72c0..36c3dfbb33079ec2de4c705ebb3aa76f8138fbd0 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 class PluginHost {
-       private $link;
+       private $dbh;
        private $hooks = array();
        private $plugins = array();
        private $handlers = array();
@@ -35,9 +35,8 @@ class PluginHost {
        const KIND_SYSTEM = 2;
        const KIND_USER = 3;
 
-       function __construct($link) {
-               $this->link = $link;
-
+       function __construct($dbh) {
+               $this->dbh = $dbh;
                $this->storage = $_SESSION["plugin_storage"];
 
                if (!$this->storage) $this->storage = array();
@@ -48,8 +47,8 @@ class PluginHost {
                $this->plugins[$name] = $plugin;
        }
 
-       function get_link() {
-               return $this->link;
+       function get_dbh() {
+               return $this->dbh;
        }
 
        function get_plugins() {
@@ -223,9 +222,9 @@ class PluginHost {
 
        function load_data($force = false) {
                if ($this->owner_uid && (!$_SESSION["plugin_storage"] || $force))  {
-                       $plugin = db_escape_string($this->link, $plugin);
+                       $plugin = db_escape_string( $plugin);
 
-                       $result = db_query($this->link, "SELECT name, content FROM ttrss_plugin_storage
+                       $result = db_query( "SELECT name, content FROM ttrss_plugin_storage
                                WHERE owner_uid = '".$this->owner_uid."'");
 
                        while ($line = db_fetch_assoc($result)) {
@@ -238,29 +237,29 @@ class PluginHost {
 
        private function save_data($plugin) {
                if ($this->owner_uid) {
-                       $plugin = db_escape_string($this->link, $plugin);
+                       $plugin = db_escape_string( $plugin);
 
-                       db_query($this->link, "BEGIN");
+                       db_query( "BEGIN");
 
-                       $result = db_query($this->link,"SELECT id FROM ttrss_plugin_storage WHERE
+                       $result = db_query("SELECT id FROM ttrss_plugin_storage WHERE
                                owner_uid= '".$this->owner_uid."' AND name = '$plugin'");
 
                        if (!isset($this->storage[$plugin]))
                                $this->storage[$plugin] = array();
 
-                       $content = db_escape_string($this->link, serialize($this->storage[$plugin]));
+                       $content = db_escape_string( serialize($this->storage[$plugin]));
 
                        if (db_num_rows($result) != 0) {
-                               db_query($this->link, "UPDATE ttrss_plugin_storage SET content = '$content'
+                               db_query( "UPDATE ttrss_plugin_storage SET content = '$content'
                                        WHERE owner_uid= '".$this->owner_uid."' AND name = '$plugin'");
 
                        } else {
-                               db_query($this->link, "INSERT INTO ttrss_plugin_storage
+                               db_query( "INSERT INTO ttrss_plugin_storage
                                        (name,owner_uid,content) VALUES
                                        ('$plugin','".$this->owner_uid."','$content')");
                        }
 
-                       db_query($this->link, "COMMIT");
+                       db_query( "COMMIT");
                }
        }
 
@@ -299,7 +298,7 @@ class PluginHost {
 
                        unset($this->storage[$idx]);
 
-                       db_query($this->link, "DELETE FROM ttrss_plugin_storage WHERE name = '$idx'
+                       db_query( "DELETE FROM ttrss_plugin_storage WHERE name = '$idx'
                                AND owner_uid = " . $this->owner_uid);
 
                        $_SESSION["plugin_storage"] = $this->storage;
index 9dc51555614794e79a666d1d1f5e25a2aff96bfd..27e03f0e2db0f4a9f876a7ca9e738789c90d54d7 100644 (file)
@@ -15,11 +15,11 @@ class Pref_Feeds extends Handler_Protected {
        }
 
        function renamecat() {
-               $title = db_escape_string($this->link, $_REQUEST['title']);
-               $id = db_escape_string($this->link, $_REQUEST['id']);
+               $title = db_escape_string( $_REQUEST['title']);
+               $id = db_escape_string( $_REQUEST['id']);
 
                if ($title) {
-                       db_query($this->link, "UPDATE ttrss_feed_categories SET
+                       db_query( "UPDATE ttrss_feed_categories SET
                                title = '$title' WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
                }
                return;
@@ -37,11 +37,11 @@ class Pref_Feeds extends Handler_Protected {
                // first one is set by API
                $show_empty_cats = $_REQUEST['force_show_empty'] ||
                        ($_REQUEST['mode'] != 2 && !$search &&
-                               get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS'));
+                               get_pref( '_PREFS_SHOW_EMPTY_CATS'));
 
                $items = array();
 
-               $result = db_query($this->link, "SELECT id, title FROM ttrss_feed_categories
+               $result = db_query( "SELECT id, title FROM ttrss_feed_categories
                                WHERE owner_uid = " . $_SESSION["uid"] . " AND parent_cat = '$cat_id' ORDER BY order_id, title");
 
                while ($line = db_fetch_assoc($result)) {
@@ -65,7 +65,7 @@ class Pref_Feeds extends Handler_Protected {
 
                }
 
-               $feed_result = db_query($this->link, "SELECT id, title, last_error,
+               $feed_result = db_query( "SELECT id, title, last_error,
                        ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
                        FROM ttrss_feeds
                        WHERE cat_id = '$cat_id' AND owner_uid = ".$_SESSION["uid"].
@@ -80,7 +80,7 @@ class Pref_Feeds extends Handler_Protected {
                        $feed['unread'] = 0;
                        $feed['error'] = $feed_line['last_error'];
                        $feed['icon'] = getFeedIcon($feed_line['id']);
-                       $feed['param'] = make_local_datetime($this->link,
+                       $feed['param'] = make_local_datetime(
                                $feed_line['last_updated'], true);
 
                        array_push($items, $feed);
@@ -108,7 +108,7 @@ class Pref_Feeds extends Handler_Protected {
                $root['items'] = array();
                $root['type'] = 'category';
 
-               $enable_cats = get_pref($this->link, 'ENABLE_FEED_CATS');
+               $enable_cats = get_pref( 'ENABLE_FEED_CATS');
 
                if ($_REQUEST['mode'] == 2) {
 
@@ -154,12 +154,12 @@ class Pref_Feeds extends Handler_Protected {
                                $root['items'] = array_merge($root['items'], $cat['items']);
                        }
 
-                       $result = db_query($this->link, "SELECT * FROM
+                       $result = db_query( "SELECT * FROM
                                ttrss_labels2 WHERE owner_uid = ".$_SESSION['uid']." ORDER by caption");
 
                        if (db_num_rows($result) > 0) {
 
-                               if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
+                               if (get_pref( 'ENABLE_FEED_CATS')) {
                                        $cat = $this->feedlist_init_cat(-2);
                                } else {
                                        $cat['items'] = array();
@@ -188,9 +188,9 @@ class Pref_Feeds extends Handler_Protected {
                if ($enable_cats) {
                        $show_empty_cats = $_REQUEST['force_show_empty'] ||
                                ($_REQUEST['mode'] != 2 && !$search &&
-                               get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS'));
+                               get_pref( '_PREFS_SHOW_EMPTY_CATS'));
 
-                       $result = db_query($this->link, "SELECT id, title FROM ttrss_feed_categories
+                       $result = db_query( "SELECT id, title FROM ttrss_feed_categories
                                WHERE owner_uid = " . $_SESSION["uid"] . " AND parent_cat IS NULL ORDER BY order_id, title");
 
                        while ($line = db_fetch_assoc($result)) {
@@ -226,7 +226,7 @@ class Pref_Feeds extends Handler_Protected {
                        $cat['unread'] = 0;
                        $cat['child_unread'] = 0;
 
-                       $feed_result = db_query($this->link, "SELECT id, title,last_error,
+                       $feed_result = db_query( "SELECT id, title,last_error,
                                ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
                                FROM ttrss_feeds
                                WHERE cat_id IS NULL AND owner_uid = ".$_SESSION["uid"].
@@ -240,7 +240,7 @@ class Pref_Feeds extends Handler_Protected {
                                $feed['checkbox'] = false;
                                $feed['error'] = $feed_line['last_error'];
                                $feed['icon'] = getFeedIcon($feed_line['id']);
-                               $feed['param'] = make_local_datetime($this->link,
+                               $feed['param'] = make_local_datetime(
                                        $feed_line['last_updated'], true);
                                $feed['unread'] = 0;
                                $feed['type'] = 'feed';
@@ -257,7 +257,7 @@ class Pref_Feeds extends Handler_Protected {
                        $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
 
                } else {
-                       $feed_result = db_query($this->link, "SELECT id, title, last_error,
+                       $feed_result = db_query( "SELECT id, title, last_error,
                                ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
                                FROM ttrss_feeds
                                WHERE owner_uid = ".$_SESSION["uid"].
@@ -271,7 +271,7 @@ class Pref_Feeds extends Handler_Protected {
                                $feed['checkbox'] = false;
                                $feed['error'] = $feed_line['last_error'];
                                $feed['icon'] = getFeedIcon($feed_line['id']);
-                               $feed['param'] = make_local_datetime($this->link,
+                               $feed['param'] = make_local_datetime(
                                        $feed_line['last_updated'], true);
                                $feed['unread'] = 0;
                                $feed['type'] = 'feed';
@@ -296,20 +296,20 @@ class Pref_Feeds extends Handler_Protected {
        }
 
        function catsortreset() {
-               db_query($this->link, "UPDATE ttrss_feed_categories
+               db_query( "UPDATE ttrss_feed_categories
                                SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]);
                return;
        }
 
        function feedsortreset() {
-               db_query($this->link, "UPDATE ttrss_feeds
+               db_query( "UPDATE ttrss_feeds
                                SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]);
                return;
        }
 
        function togglehiddenfeedcats() {
-               set_pref($this->link, '_PREFS_SHOW_EMPTY_CATS',
-                       (get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS') ? 'false' : 'true'));
+               set_pref( '_PREFS_SHOW_EMPTY_CATS',
+                       (get_pref( '_PREFS_SHOW_EMPTY_CATS') ? 'false' : 'true'));
        }
 
        private function process_category_order(&$data_map, $item_id, $parent_id = false, $nest_level = 0) {
@@ -326,12 +326,12 @@ class Pref_Feeds extends Handler_Protected {
                if ($item_id != 'root') {
                        if ($parent_id && $parent_id != 'root') {
                                $parent_bare_id = substr($parent_id, strpos($parent_id, ':')+1);
-                               $parent_qpart = db_escape_string($this->link, $parent_bare_id);
+                               $parent_qpart = db_escape_string( $parent_bare_id);
                        } else {
                                $parent_qpart = 'NULL';
                        }
 
-                       db_query($this->link, "UPDATE ttrss_feed_categories
+                       db_query( "UPDATE ttrss_feed_categories
                                SET parent_cat = $parent_qpart WHERE id = '$bare_item_id' AND
                                owner_uid = " . $_SESSION["uid"]);
                }
@@ -352,12 +352,12 @@ class Pref_Feeds extends Handler_Protected {
                                        if (strpos($id, "FEED") === 0) {
 
                                                $cat_id = ($item_id != "root") ?
-                                                       db_escape_string($this->link, $bare_item_id) : "NULL";
+                                                       db_escape_string( $bare_item_id) : "NULL";
 
                                                $cat_qpart = ($cat_id != 0) ? "cat_id = '$cat_id'" :
                                                        "cat_id = NULL";
 
-                                               db_query($this->link, "UPDATE ttrss_feeds
+                                               db_query( "UPDATE ttrss_feeds
                                                        SET order_id = $order_id, $cat_qpart
                                                        WHERE id = '$bare_id' AND
                                                                owner_uid = " . $_SESSION["uid"]);
@@ -367,12 +367,12 @@ class Pref_Feeds extends Handler_Protected {
                                                        $nest_level+1);
 
                                                if ($item_id != 'root') {
-                                                       $parent_qpart = db_escape_string($this->link, $bare_id);
+                                                       $parent_qpart = db_escape_string( $bare_id);
                                                } else {
                                                        $parent_qpart = 'NULL';
                                                }
 
-                                               db_query($this->link, "UPDATE ttrss_feed_categories
+                                               db_query( "UPDATE ttrss_feed_categories
                                                                SET order_id = '$order_id' WHERE id = '$bare_id' AND
                                                                owner_uid = " . $_SESSION["uid"]);
                                        }
@@ -424,7 +424,7 @@ class Pref_Feeds extends Handler_Protected {
                                ++$cat_order_id;
 
                                if ($bare_id > 0) {
-                                       db_query($this->link, "UPDATE ttrss_feed_categories
+                                       db_query( "UPDATE ttrss_feed_categories
                                                SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
                                                owner_uid = " . $_SESSION["uid"]);
                                }
@@ -441,7 +441,7 @@ class Pref_Feeds extends Handler_Protected {
                                                else
                                                        $cat_query = "cat_id = NULL";
 
-                                               db_query($this->link, "UPDATE ttrss_feeds
+                                               db_query( "UPDATE ttrss_feeds
                                                        SET order_id = '$feed_order_id',
                                                        $cat_query
                                                        WHERE id = '$feed_id' AND
@@ -457,15 +457,15 @@ class Pref_Feeds extends Handler_Protected {
        }
 
        function removeicon() {
-               $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]);
+               $feed_id = db_escape_string( $_REQUEST["feed_id"]);
 
-               $result = db_query($this->link, "SELECT id FROM ttrss_feeds
+               $result = db_query( "SELECT id FROM ttrss_feeds
                        WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]);
 
                if (db_num_rows($result) != 0) {
                        @unlink(ICONS_DIR . "/$feed_id.ico");
 
-                       db_query($this->link, "UPDATE ttrss_feeds SET favicon_avg_color = NULL
+                       db_query( "UPDATE ttrss_feeds SET favicon_avg_color = NULL
                                where id = '$feed_id'");
                }
 
@@ -491,12 +491,12 @@ class Pref_Feeds extends Handler_Protected {
                }
 
                $icon_file = $tmp_file;
-               $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]);
+               $feed_id = db_escape_string( $_REQUEST["feed_id"]);
 
                if (is_file($icon_file) && $feed_id) {
                        if (filesize($icon_file) < 20000) {
 
-                               $result = db_query($this->link, "SELECT id FROM ttrss_feeds
+                               $result = db_query( "SELECT id FROM ttrss_feeds
                                        WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]);
 
                                if (db_num_rows($result) != 0) {
@@ -505,10 +505,10 @@ class Pref_Feeds extends Handler_Protected {
 
                                                require_once "colors.php";
 
-                                               $favicon_color = db_escape_string($this->link,
+                                               $favicon_color = db_escape_string(
                                                        calculate_avg_color(ICONS_DIR . "/$feed_id.ico"));
 
-                                               db_query($this->link, "UPDATE ttrss_feeds SET
+                                               db_query( "UPDATE ttrss_feeds SET
                                                        favicon_avg_color = '$favicon_color'
                                                        WHERE id = '$feed_id'");
 
@@ -536,9 +536,9 @@ class Pref_Feeds extends Handler_Protected {
                global $purge_intervals;
                global $update_intervals;
 
-               $feed_id = db_escape_string($this->link, $_REQUEST["id"]);
+               $feed_id = db_escape_string( $_REQUEST["id"]);
 
-               $result = db_query($this->link,
+               $result = db_query(
                        "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND
                                owner_uid = " . $_SESSION["uid"]);
 
@@ -585,7 +585,7 @@ class Pref_Feeds extends Handler_Protected {
 
                /* Category */
 
-               if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
+               if (get_pref( 'ENABLE_FEED_CATS')) {
 
                        $cat_id = db_fetch_result($result, 0, "cat_id");
 
@@ -593,7 +593,7 @@ class Pref_Feeds extends Handler_Protected {
 
                        print __('Place in category:') . " ";
 
-                       print_feed_cat_select($this->link, "cat_id", $cat_id,
+                       print_feed_cat_select( "cat_id", $cat_id,
                                'dojoType="dijit.form.Select"');
                }
 
@@ -782,7 +782,7 @@ class Pref_Feeds extends Handler_Protected {
                global $purge_intervals;
                global $update_intervals;
 
-               $feed_ids = db_escape_string($this->link, $_REQUEST["ids"]);
+               $feed_ids = db_escape_string( $_REQUEST["ids"]);
 
                print_notice("Enable the options you wish to apply using checkboxes on the right:");
 
@@ -816,13 +816,13 @@ class Pref_Feeds extends Handler_Protected {
 
                /* Category */
 
-               if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
+               if (get_pref( 'ENABLE_FEED_CATS')) {
 
                        print "<br/>";
 
                        print __('Place in category:') . " ";
 
-                       print_feed_cat_select($this->link, "cat_id", $cat_id,
+                       print_feed_cat_select( "cat_id", $cat_id,
                                'disabled="1" dojoType="dijit.form.Select"');
 
                        $this->batch_edit_cbox("cat_id");
@@ -938,27 +938,27 @@ class Pref_Feeds extends Handler_Protected {
 
        function editsaveops($batch) {
 
-               $feed_title = db_escape_string($this->link, trim($_POST["title"]));
-               $feed_link = db_escape_string($this->link, trim($_POST["feed_url"]));
-               $upd_intl = (int) db_escape_string($this->link, $_POST["update_interval"]);
-               $purge_intl = (int) db_escape_string($this->link, $_POST["purge_interval"]);
-               $feed_id = (int) db_escape_string($this->link, $_POST["id"]); /* editSave */
-               $feed_ids = db_escape_string($this->link, $_POST["ids"]); /* batchEditSave */
-               $cat_id = (int) db_escape_string($this->link, $_POST["cat_id"]);
-               $auth_login = db_escape_string($this->link, trim($_POST["auth_login"]));
+               $feed_title = db_escape_string( trim($_POST["title"]));
+               $feed_link = db_escape_string( trim($_POST["feed_url"]));
+               $upd_intl = (int) db_escape_string( $_POST["update_interval"]);
+               $purge_intl = (int) db_escape_string( $_POST["purge_interval"]);
+               $feed_id = (int) db_escape_string( $_POST["id"]); /* editSave */
+               $feed_ids = db_escape_string( $_POST["ids"]); /* batchEditSave */
+               $cat_id = (int) db_escape_string( $_POST["cat_id"]);
+               $auth_login = db_escape_string( trim($_POST["auth_login"]));
                $auth_pass = trim($_POST["auth_pass"]);
-               $private = checkbox_to_sql_bool(db_escape_string($this->link, $_POST["private"]));
+               $private = checkbox_to_sql_bool(db_escape_string( $_POST["private"]));
                $include_in_digest = checkbox_to_sql_bool(
-                       db_escape_string($this->link, $_POST["include_in_digest"]));
+                       db_escape_string( $_POST["include_in_digest"]));
                $cache_images = checkbox_to_sql_bool(
-                       db_escape_string($this->link, $_POST["cache_images"]));
+                       db_escape_string( $_POST["cache_images"]));
                $hide_images = checkbox_to_sql_bool(
-                       db_escape_string($this->link, $_POST["hide_images"]));
+                       db_escape_string( $_POST["hide_images"]));
                $always_display_enclosures = checkbox_to_sql_bool(
-                       db_escape_string($this->link, $_POST["always_display_enclosures"]));
+                       db_escape_string( $_POST["always_display_enclosures"]));
 
                $mark_unread_on_update = checkbox_to_sql_bool(
-                       db_escape_string($this->link, $_POST["mark_unread_on_update"]));
+                       db_escape_string( $_POST["mark_unread_on_update"]));
 
                if (strlen(FEED_CRYPT_KEY) > 0) {
                        require_once "crypt.php";
@@ -968,9 +968,9 @@ class Pref_Feeds extends Handler_Protected {
                        $auth_pass_encrypted = 'false';
                }
 
-               $auth_pass = db_escape_string($this->link, $auth_pass);
+               $auth_pass = db_escape_string( $auth_pass);
 
-               if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
+               if (get_pref( 'ENABLE_FEED_CATS')) {
                        if ($cat_id && $cat_id != 0) {
                                $category_qpart = "cat_id = '$cat_id',";
                                $category_qpart_nocomma = "cat_id = '$cat_id'";
@@ -985,7 +985,7 @@ class Pref_Feeds extends Handler_Protected {
 
                if (!$batch) {
 
-                       $result = db_query($this->link, "UPDATE ttrss_feeds SET
+                       $result = db_query( "UPDATE ttrss_feeds SET
                                $category_qpart
                                title = '$feed_title', feed_url = '$feed_link',
                                update_interval = '$upd_intl',
@@ -1010,7 +1010,7 @@ class Pref_Feeds extends Handler_Protected {
                                }
                        }
 
-                       db_query($this->link, "BEGIN");
+                       db_query( "BEGIN");
 
                        foreach (array_keys($feed_data) as $k) {
 
@@ -1073,23 +1073,23 @@ class Pref_Feeds extends Handler_Protected {
                                }
 
                                if ($qpart) {
-                                       db_query($this->link,
+                                       db_query(
                                                "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids)
                                                AND owner_uid = " . $_SESSION["uid"]);
                                        print "<br/>";
                                }
                        }
 
-                       db_query($this->link, "COMMIT");
+                       db_query( "COMMIT");
                }
                return;
        }
 
        function resetPubSub() {
 
-               $ids = db_escape_string($this->link, $_REQUEST["ids"]);
+               $ids = db_escape_string( $_REQUEST["ids"]);
 
-               db_query($this->link, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ($ids)
+               db_query( "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ($ids)
                        AND owner_uid = " . $_SESSION["uid"]);
 
                return;
@@ -1097,30 +1097,30 @@ class Pref_Feeds extends Handler_Protected {
 
        function remove() {
 
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
 
                foreach ($ids as $id) {
-                       Pref_Feeds::remove_feed($this->link, $id, $_SESSION["uid"]);
+                       Pref_Feeds::remove_feed( $id, $_SESSION["uid"]);
                }
 
                return;
        }
 
        function clear() {
-               $id = db_escape_string($this->link, $_REQUEST["id"]);
-               $this->clear_feed_articles($this->link, $id);
+               $id = db_escape_string( $_REQUEST["id"]);
+               $this->clear_feed_articles( $id);
        }
 
        function rescore() {
                require_once "rssfuncs.php";
 
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
 
                foreach ($ids as $id) {
 
-                       $filters = load_filters($this->link, $id, $_SESSION["uid"], 6);
+                       $filters = load_filters( $id, $_SESSION["uid"], 6);
 
-                       $result = db_query($this->link, "SELECT
+                       $result = db_query( "SELECT
                                title, content, link, ref_id, author,".
                                SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated
                                FROM
@@ -1133,7 +1133,7 @@ class Pref_Feeds extends Handler_Protected {
 
                        while ($line = db_fetch_assoc($result)) {
 
-                               $tags = get_article_tags($this->link, $line["ref_id"]);
+                               $tags = get_article_tags( $line["ref_id"]);
 
                                $article_filters = get_article_filters($filters, $line['title'],
                                        $line['content'], $line['link'], strtotime($line['updated']),
@@ -1148,15 +1148,15 @@ class Pref_Feeds extends Handler_Protected {
 
                        foreach (array_keys($scores) as $s) {
                                if ($s > 1000) {
-                                       db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s',
+                                       db_query( "UPDATE ttrss_user_entries SET score = '$s',
                                                marked = true WHERE
                                                ref_id IN (" . join(',', $scores[$s]) . ")");
                                } else if ($s < -500) {
-                                       db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s',
+                                       db_query( "UPDATE ttrss_user_entries SET score = '$s',
                                                unread = false WHERE
                                                ref_id IN (" . join(',', $scores[$s]) . ")");
                                } else {
-                                       db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
+                                       db_query( "UPDATE ttrss_user_entries SET score = '$s' WHERE
                                                ref_id IN (" . join(',', $scores[$s]) . ")");
                                }
                        }
@@ -1168,16 +1168,16 @@ class Pref_Feeds extends Handler_Protected {
 
        function rescoreAll() {
 
-               $result = db_query($this->link,
+               $result = db_query(
                        "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']);
 
                while ($feed_line = db_fetch_assoc($result)) {
 
                        $id = $feed_line["id"];
 
-                       $filters = load_filters($this->link, $id, $_SESSION["uid"], 6);
+                       $filters = load_filters( $id, $_SESSION["uid"], 6);
 
-                       $tmp_result = db_query($this->link, "SELECT
+                       $tmp_result = db_query( "SELECT
                                title, content, link, ref_id, author,".
                                        SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated
                                        FROM
@@ -1190,7 +1190,7 @@ class Pref_Feeds extends Handler_Protected {
 
                        while ($line = db_fetch_assoc($tmp_result)) {
 
-                               $tags = get_article_tags($this->link, $line["ref_id"]);
+                               $tags = get_article_tags( $line["ref_id"]);
 
                                $article_filters = get_article_filters($filters, $line['title'],
                                        $line['content'], $line['link'], strtotime($line['updated']),
@@ -1205,11 +1205,11 @@ class Pref_Feeds extends Handler_Protected {
 
                        foreach (array_keys($scores) as $s) {
                                if ($s > 1000) {
-                                       db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s',
+                                       db_query( "UPDATE ttrss_user_entries SET score = '$s',
                                                marked = true WHERE
                                                ref_id IN (" . join(',', $scores[$s]) . ")");
                                } else {
-                                       db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
+                                       db_query( "UPDATE ttrss_user_entries SET score = '$s' WHERE
                                                ref_id IN (" . join(',', $scores[$s]) . ")");
                                }
                        }
@@ -1220,9 +1220,9 @@ class Pref_Feeds extends Handler_Protected {
        }
 
        function categorize() {
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
 
-               $cat_id = db_escape_string($this->link, $_REQUEST["cat_id"]);
+               $cat_id = db_escape_string( $_REQUEST["cat_id"]);
 
                if ($cat_id == 0) {
                        $cat_id_qpart = 'NULL';
@@ -1230,30 +1230,30 @@ class Pref_Feeds extends Handler_Protected {
                        $cat_id_qpart = "'$cat_id'";
                }
 
-               db_query($this->link, "BEGIN");
+               db_query( "BEGIN");
 
                foreach ($ids as $id) {
 
-                       db_query($this->link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
+                       db_query( "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
                                WHERE id = '$id'
                                AND owner_uid = " . $_SESSION["uid"]);
 
                }
 
-               db_query($this->link, "COMMIT");
+               db_query( "COMMIT");
        }
 
        function removeCat() {
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
                foreach ($ids as $id) {
-                       $this->remove_feed_category($this->link, $id, $_SESSION["uid"]);
+                       $this->remove_feed_category( $id, $_SESSION["uid"]);
                }
        }
 
        function addCat() {
-               $feed_cat = db_escape_string($this->link, trim($_REQUEST["cat"]));
+               $feed_cat = db_escape_string( trim($_REQUEST["cat"]));
 
-               add_feed_category($this->link, $feed_cat);
+               add_feed_category( $feed_cat);
        }
 
        function index() {
@@ -1261,7 +1261,7 @@ class Pref_Feeds extends Handler_Protected {
                print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
                print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds')."\">";
 
-               $result = db_query($this->link, "SELECT COUNT(id) AS num_errors
+               $result = db_query( "SELECT COUNT(id) AS num_errors
                        FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
 
                $num_errors = db_fetch_result($result, 0, "num_errors");
@@ -1279,7 +1279,7 @@ class Pref_Feeds extends Handler_Protected {
                        $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
                }
 
-               $result = db_query($this->link, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
+               $result = db_query( "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
                                        (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
                                                ttrss_entries.id = ref_id AND
                                                        ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
@@ -1293,7 +1293,7 @@ class Pref_Feeds extends Handler_Protected {
                                        __("Inactive feeds") . "</button>";
                }
 
-               $feed_search = db_escape_string($this->link, $_REQUEST["search"]);
+               $feed_search = db_escape_string( $_REQUEST["search"]);
 
                if (array_key_exists("search", $_REQUEST)) {
                        $_SESSION["prefs_feed_search"] = $feed_search;
@@ -1336,7 +1336,7 @@ class Pref_Feeds extends Handler_Protected {
                        .__('Unsubscribe')."</div> ";
                print "</div></div>";
 
-               if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
+               if (get_pref( 'ENABLE_FEED_CATS')) {
                        print "<div dojoType=\"dijit.form.DropDownButton\">".
                                        "<span>" . __('Categories')."</span>";
                        print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
@@ -1522,14 +1522,14 @@ class Pref_Feeds extends Handler_Protected {
                $cat_id = (int) $cat_id;
 
                if ($cat_id > 0) {
-                       $cat_unread = ccache_find($this->link, $cat_id, $_SESSION["uid"], true);
+                       $cat_unread = ccache_find( $cat_id, $_SESSION["uid"], true);
                } else if ($cat_id == 0 || $cat_id == -2) {
-                       $cat_unread = getCategoryUnread($this->link, $cat_id);
+                       $cat_unread = getCategoryUnread( $cat_id);
                }
 
                $obj['id'] = 'CAT:' . $cat_id;
                $obj['items'] = array();
-               $obj['name'] = getCategoryTitle($this->link, $cat_id);
+               $obj['name'] = getCategoryTitle( $cat_id);
                $obj['type'] = 'category';
                $obj['unread'] = (int) $cat_unread;
                $obj['bare_id'] = $cat_id;
@@ -1542,10 +1542,10 @@ class Pref_Feeds extends Handler_Protected {
                $feed_id = (int) $feed_id;
 
                if (!$title)
-                       $title = getFeedTitle($this->link, $feed_id, false);
+                       $title = getFeedTitle( $feed_id, false);
 
                if ($unread === false)
-                       $unread = getFeedUnread($this->link, $feed_id, false);
+                       $unread = getFeedUnread( $feed_id, false);
 
                $obj['id'] = 'FEED:' . $feed_id;
                $obj['name'] = $title;
@@ -1567,7 +1567,7 @@ class Pref_Feeds extends Handler_Protected {
                        $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
                }
 
-               $result = db_query($this->link, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
+               $result = db_query( "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
                                ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
                        FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
                                (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
@@ -1621,7 +1621,7 @@ class Pref_Feeds extends Handler_Protected {
                                htmlspecialchars($line["title"])."</a>";
 
                        print "</td><td class=\"insensitive\" align='right'>";
-                       print make_local_datetime($this->link, $line['last_article'], false);
+                       print make_local_datetime( $line['last_article'], false);
                        print "</td>";
                        print "</tr>";
 
@@ -1648,7 +1648,7 @@ class Pref_Feeds extends Handler_Protected {
                print "<h2>" . __("These feeds have not been updated because of errors:") .
                        "</h2>";
 
-               $result = db_query($this->link, "SELECT id,title,feed_url,last_error,site_url
+               $result = db_query( "SELECT id,title,feed_url,last_error,site_url
                FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
 
                print "<div dojoType=\"dijit.Toolbar\">";
@@ -1722,53 +1722,53 @@ class Pref_Feeds extends Handler_Protected {
         * @param integer $id The id of the feed to purge.
         * @return void
         */
-       private function clear_feed_articles($link, $id) {
+       private function clear_feed_articles($id) {
 
                if ($id != 0) {
-                       $result = db_query($link, "DELETE FROM ttrss_user_entries
+                       $result = db_query( "DELETE FROM ttrss_user_entries
                        WHERE feed_id = '$id' AND marked = false AND owner_uid = " . $_SESSION["uid"]);
                } else {
-                       $result = db_query($link, "DELETE FROM ttrss_user_entries
+                       $result = db_query( "DELETE FROM ttrss_user_entries
                        WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION["uid"]);
                }
 
-               $result = db_query($link, "DELETE FROM ttrss_entries WHERE
+               $result = db_query( "DELETE FROM ttrss_entries WHERE
                        (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0");
 
-               ccache_update($link, $id, $_SESSION['uid']);
+               ccache_update( $id, $_SESSION['uid']);
        } // function clear_feed_articles
 
-       private function remove_feed_category($link, $id, $owner_uid) {
+       private function remove_feed_category( $id, $owner_uid) {
 
-               db_query($link, "DELETE FROM ttrss_feed_categories
+               db_query( "DELETE FROM ttrss_feed_categories
                        WHERE id = '$id' AND owner_uid = $owner_uid");
 
-               ccache_remove($link, $id, $owner_uid, true);
+               ccache_remove( $id, $owner_uid, true);
        }
 
-       static function remove_feed($link, $id, $owner_uid) {
+       static function remove_feed( $id, $owner_uid) {
 
                if ($id > 0) {
 
                        /* save starred articles in Archived feed */
 
-                       db_query($link, "BEGIN");
+                       db_query( "BEGIN");
 
                        /* prepare feed if necessary */
 
-                       $result = db_query($link, "SELECT feed_url FROM ttrss_feeds WHERE id = $id
+                       $result = db_query( "SELECT feed_url FROM ttrss_feeds WHERE id = $id
                                AND owner_uid = $owner_uid");
 
-                       $feed_url = db_escape_string($link, db_fetch_result($result, 0, "feed_url"));
+                       $feed_url = db_escape_string( db_fetch_result($result, 0, "feed_url"));
 
-                       $result = db_query($link, "SELECT id FROM ttrss_archived_feeds
+                       $result = db_query( "SELECT id FROM ttrss_archived_feeds
                                WHERE feed_url = '$feed_url' AND owner_uid = $owner_uid");
 
                        if (db_num_rows($result) == 0) {
-                               $result = db_query($link, "SELECT MAX(id) AS id FROM ttrss_archived_feeds");
+                               $result = db_query( "SELECT MAX(id) AS id FROM ttrss_archived_feeds");
                                $new_feed_id = (int)db_fetch_result($result, 0, "id") + 1;
 
-                               db_query($link, "INSERT INTO ttrss_archived_feeds
+                               db_query( "INSERT INTO ttrss_archived_feeds
                                        (id, owner_uid, title, feed_url, site_url)
                                SELECT $new_feed_id, owner_uid, title, feed_url, site_url from ttrss_feeds
                                WHERE id = '$id'");
@@ -1778,31 +1778,31 @@ class Pref_Feeds extends Handler_Protected {
                                $archive_id = db_fetch_result($result, 0, "id");
                        }
 
-                       db_query($link, "UPDATE ttrss_user_entries SET feed_id = NULL,
+                       db_query( "UPDATE ttrss_user_entries SET feed_id = NULL,
                                orig_feed_id = '$archive_id' WHERE feed_id = '$id' AND
                                        marked = true AND owner_uid = $owner_uid");
 
                        /* Remove access key for the feed */
 
-                       db_query($link, "DELETE FROM ttrss_access_keys WHERE
+                       db_query( "DELETE FROM ttrss_access_keys WHERE
                                feed_id = '$id' AND owner_uid = $owner_uid");
 
                        /* remove the feed */
 
-                       db_query($link, "DELETE FROM ttrss_feeds
+                       db_query( "DELETE FROM ttrss_feeds
                                        WHERE id = '$id' AND owner_uid = $owner_uid");
 
-                       db_query($link, "COMMIT");
+                       db_query( "COMMIT");
 
                        if (file_exists(ICONS_DIR . "/$id.ico")) {
                                unlink(ICONS_DIR . "/$id.ico");
                        }
 
-                       ccache_remove($link, $id, $owner_uid);
+                       ccache_remove( $id, $owner_uid);
 
                } else {
-                       label_remove($link, feed_to_label_id($id), $owner_uid);
-                       //ccache_remove($link, $id, $owner_uid); don't think labels are cached
+                       label_remove( feed_to_label_id($id), $owner_uid);
+                       //ccache_remove( $id, $owner_uid); don't think labels are cached
                }
        }
 
@@ -1813,9 +1813,9 @@ class Pref_Feeds extends Handler_Protected {
                print "<table width='100%'><tr><td>
                        ".__("Add one valid RSS feed per line (no feed detection is done)")."
                </td><td align='right'>";
-               if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
+               if (get_pref( 'ENABLE_FEED_CATS')) {
                        print __('Place in category:') . " ";
-                       print_feed_cat_select($this->link, "cat", false, 'dojoType="dijit.form.Select"');
+                       print_feed_cat_select( "cat", false, 'dojoType="dijit.form.Select"');
                }
                print "</td></tr><tr><td colspan='2'>";
                print "<textarea
@@ -1855,17 +1855,17 @@ class Pref_Feeds extends Handler_Protected {
        }
 
        function batchAddFeeds() {
-               $cat_id = db_escape_string($this->link, $_REQUEST['cat']);
+               $cat_id = db_escape_string( $_REQUEST['cat']);
                $feeds = explode("\n", $_REQUEST['feeds']);
-               $login = db_escape_string($this->link, $_REQUEST['login']);
+               $login = db_escape_string( $_REQUEST['login']);
                $pass = trim($_REQUEST['pass']);
 
                foreach ($feeds as $feed) {
-                       $feed = db_escape_string($this->link, trim($feed));
+                       $feed = db_escape_string( trim($feed));
 
                        if (validate_feed_url($feed)) {
 
-                               db_query($this->link, "BEGIN");
+                               db_query( "BEGIN");
 
                                if ($cat_id == "0" || !$cat_id) {
                                        $cat_qpart = "NULL";
@@ -1873,7 +1873,7 @@ class Pref_Feeds extends Handler_Protected {
                                        $cat_qpart = "'$cat_id'";
                                }
 
-                               $result = db_query($this->link,
+                               $result = db_query(
                                        "SELECT id FROM ttrss_feeds
                                        WHERE feed_url = '$feed' AND owner_uid = ".$_SESSION["uid"]);
 
@@ -1885,66 +1885,66 @@ class Pref_Feeds extends Handler_Protected {
                                        $auth_pass_encrypted = 'false';
                                }
 
-                               $pass = db_escape_string($this->link, $pass);
+                               $pass = db_escape_string( $pass);
 
                                if (db_num_rows($result) == 0) {
-                                       $result = db_query($this->link,
+                                       $result = db_query(
                                                "INSERT INTO ttrss_feeds
                                                        (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method,auth_pass_encrypted)
                                                VALUES ('".$_SESSION["uid"]."', '$feed',
                                                        '[Unknown]', $cat_qpart, '$login', '$pass', 0, $auth_pass_encrypted)");
                                }
 
-                               db_query($this->link, "COMMIT");
+                               db_query( "COMMIT");
                        }
                }
        }
 
        function regenOPMLKey() {
-               $this->update_feed_access_key($this->link, 'OPML:Publish',
+               $this->update_feed_access_key( 'OPML:Publish',
                false, $_SESSION["uid"]);
 
-               $new_link = Opml::opml_publish_url($this->link);
+               $new_link = Opml::opml_publish_url();
 
                print json_encode(array("link" => $new_link));
        }
 
        function regenFeedKey() {
-               $feed_id = db_escape_string($this->link, $_REQUEST['id']);
-               $is_cat = db_escape_string($this->link, $_REQUEST['is_cat']) == "true";
+               $feed_id = db_escape_string( $_REQUEST['id']);
+               $is_cat = db_escape_string( $_REQUEST['is_cat']) == "true";
 
-               $new_key = $this->update_feed_access_key($this->link, $feed_id, $is_cat);
+               $new_key = $this->update_feed_access_key( $feed_id, $is_cat);
 
                print json_encode(array("link" => $new_key));
        }
 
 
-       private function update_feed_access_key($link, $feed_id, $is_cat, $owner_uid = false) {
+       private function update_feed_access_key( $feed_id, $is_cat, $owner_uid = false) {
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
 
                $sql_is_cat = bool_to_sql_bool($is_cat);
 
-               $result = db_query($link, "SELECT access_key FROM ttrss_access_keys
+               $result = db_query( "SELECT access_key FROM ttrss_access_keys
                        WHERE feed_id = '$feed_id'      AND is_cat = $sql_is_cat
                        AND owner_uid = " . $owner_uid);
 
                if (db_num_rows($result) == 1) {
-                       $key = db_escape_string($this->link, sha1(uniqid(rand(), true)));
+                       $key = db_escape_string( sha1(uniqid(rand(), true)));
 
-                       db_query($link, "UPDATE ttrss_access_keys SET access_key = '$key'
+                       db_query( "UPDATE ttrss_access_keys SET access_key = '$key'
                                WHERE feed_id = '$feed_id' AND is_cat = $sql_is_cat
                                AND owner_uid = " . $owner_uid);
 
                        return $key;
 
                } else {
-                       return get_feed_access_key($link, $feed_id, $is_cat, $owner_uid);
+                       return get_feed_access_key( $feed_id, $is_cat, $owner_uid);
                }
        }
 
        // Silent
        function clearKeys() {
-               db_query($this->link, "DELETE FROM ttrss_access_keys WHERE
+               db_query( "DELETE FROM ttrss_access_keys WHERE
                        owner_uid = " . $_SESSION["uid"]);
        }
 
index 586626dd73afd2cf1be972ca1f489c5d12613b51..12c2f271c28d9c303f1e18c20b04fdc636aa6b47 100644 (file)
@@ -9,7 +9,7 @@ class Pref_Filters extends Handler_Protected {
        }
 
        function filtersortreset() {
-               db_query($this->link, "UPDATE ttrss_filters2
+               db_query( "UPDATE ttrss_filters2
                                SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]);
                return;
        }
@@ -31,7 +31,7 @@ class Pref_Filters extends Handler_Protected {
 
                                if ($filter_id > 0) {
 
-                                       db_query($this->link, "UPDATE ttrss_filters2 SET
+                                       db_query( "UPDATE ttrss_filters2 SET
                                                order_id = $index WHERE id = '$filter_id' AND
                                                owner_uid = " .$_SESSION["uid"]);
 
@@ -49,13 +49,13 @@ class Pref_Filters extends Handler_Protected {
 
                $filter["enabled"] = true;
                $filter["match_any_rule"] = sql_bool_to_bool(
-                       checkbox_to_sql_bool(db_escape_string($this->link, $_REQUEST["match_any_rule"])));
+                       checkbox_to_sql_bool(db_escape_string( $_REQUEST["match_any_rule"])));
                $filter["inverse"] = sql_bool_to_bool(
-                       checkbox_to_sql_bool(db_escape_string($this->link, $_REQUEST["inverse"])));
+                       checkbox_to_sql_bool(db_escape_string( $_REQUEST["inverse"])));
 
                $filter["rules"] = array();
 
-               $result = db_query($this->link, "SELECT id,name FROM ttrss_filter_types");
+               $result = db_query( "SELECT id,name FROM ttrss_filter_types");
 
                $filter_types = array();
                while ($line = db_fetch_assoc($result)) {
@@ -83,9 +83,9 @@ class Pref_Filters extends Handler_Protected {
                        }
                }
 
-               $feed_title = getFeedTitle($this->link, $feed);
+               $feed_title = getFeedTitle( $feed);
 
-               $qfh_ret = queryFeedHeadlines($this->link, -4, 30, "", false, false, false,
+               $qfh_ret = queryFeedHeadlines( -4, 30, "", false, false, false,
                        "date_entered DESC", 0, $_SESSION["uid"], $filter);
 
                $result = $qfh_ret[0];
@@ -101,7 +101,7 @@ class Pref_Filters extends Handler_Protected {
                while ($line = db_fetch_assoc($result)) {
 
                        $entry_timestamp = strtotime($line["updated"]);
-                       $entry_tags = get_article_tags($this->link, $line["id"], $_SESSION["uid"]);
+                       $entry_tags = get_article_tags( $line["id"], $_SESSION["uid"]);
 
                        $content_preview = truncate_string(
                                strip_tags($line["content_preview"]), 100, '...');
@@ -158,7 +158,7 @@ class Pref_Filters extends Handler_Protected {
 
                $filter_search = $_SESSION["prefs_filter_search"];
 
-               $result = db_query($this->link, "SELECT *,
+               $result = db_query( "SELECT *,
                        (SELECT action_param FROM ttrss_filters2_actions
                                WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1) AS action_param,
                        (SELECT action_id FROM ttrss_filters2_actions
@@ -194,7 +194,7 @@ class Pref_Filters extends Handler_Protected {
 
                        $match_ok = false;
                        if ($filter_search) {
-                               $rules_result = db_query($this->link,
+                               $rules_result = db_query(
                                        "SELECT reg_exp FROM ttrss_filters2_rules WHERE filter_id = ".$line["id"]);
 
                                while ($rule_line = db_fetch_assoc($rules_result)) {
@@ -206,8 +206,8 @@ class Pref_Filters extends Handler_Protected {
                        }
 
                        if ($line['action_id'] == 7) {
-                               $label_result = db_query($this->link, "SELECT fg_color, bg_color
-                                       FROM ttrss_labels2 WHERE caption = '".db_escape_string($this->link, $line['action_param'])."' AND
+                               $label_result = db_query( "SELECT fg_color, bg_color
+                                       FROM ttrss_labels2 WHERE caption = '".db_escape_string( $line['action_param'])."' AND
                                                owner_uid = " . $_SESSION["uid"]);
 
                                if (db_num_rows($label_result) > 0) {
@@ -248,9 +248,9 @@ class Pref_Filters extends Handler_Protected {
 
        function edit() {
 
-               $filter_id = db_escape_string($this->link, $_REQUEST["id"]);
+               $filter_id = db_escape_string( $_REQUEST["id"]);
 
-               $result = db_query($this->link,
+               $result = db_query(
                        "SELECT * FROM ttrss_filters2 WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]);
 
                $enabled = sql_bool_to_bool(db_fetch_result($result, 0, "enabled"));
@@ -294,7 +294,7 @@ class Pref_Filters extends Handler_Protected {
 
                print "<ul id='filterDlg_Matches'>";
 
-               $rules_result = db_query($this->link, "SELECT * FROM ttrss_filters2_rules
+               $rules_result = db_query( "SELECT * FROM ttrss_filters2_rules
                        WHERE filter_id = '$filter_id' ORDER BY reg_exp, id");
 
                while ($line = db_fetch_assoc($rules_result)) {
@@ -342,7 +342,7 @@ class Pref_Filters extends Handler_Protected {
 
                print "<ul id='filterDlg_Actions'>";
 
-               $actions_result = db_query($this->link, "SELECT * FROM ttrss_filters2_actions
+               $actions_result = db_query( "SELECT * FROM ttrss_filters2_actions
                        WHERE filter_id = '$filter_id' ORDER BY id");
 
                while ($line = db_fetch_assoc($actions_result)) {
@@ -417,17 +417,17 @@ class Pref_Filters extends Handler_Protected {
 
                if (strpos($feed_id, "CAT:") === 0) {
                        $feed_id = (int) substr($feed_id, 4);
-                       $feed = getCategoryTitle($this->link, $feed_id);
+                       $feed = getCategoryTitle( $feed_id);
                } else {
                        $feed_id = (int) $feed_id;
 
                        if ($rule["feed_id"])
-                               $feed = getFeedTitle($this->link, (int)$rule["feed_id"]);
+                               $feed = getFeedTitle( (int)$rule["feed_id"]);
                        else
                                $feed = __("All feeds");
                }
 
-               $result = db_query($this->link, "SELECT description FROM ttrss_filter_types
+               $result = db_query( "SELECT description FROM ttrss_filter_types
                        WHERE id = ".(int)$rule["filter_type"]);
                $filter_type = db_fetch_result($result, 0, "description");
 
@@ -440,7 +440,7 @@ class Pref_Filters extends Handler_Protected {
        }
 
        private function getActionName($action) {
-               $result = db_query($this->link, "SELECT description FROM
+               $result = db_query( "SELECT description FROM
                        ttrss_filter_actions WHERE id = " .(int)$action["action_id"]);
 
                $title = __(db_fetch_result($result, 0, "description"));
@@ -463,13 +463,13 @@ class Pref_Filters extends Handler_Protected {
 
 #              print_r($_REQUEST);
 
-               $filter_id = db_escape_string($this->link, $_REQUEST["id"]);
-               $enabled = checkbox_to_sql_bool(db_escape_string($this->link, $_REQUEST["enabled"]));
-               $match_any_rule = checkbox_to_sql_bool(db_escape_string($this->link, $_REQUEST["match_any_rule"]));
-               $inverse = checkbox_to_sql_bool(db_escape_string($this->link, $_REQUEST["inverse"]));
-               $title = db_escape_string($this->link, $_REQUEST["title"]);
+               $filter_id = db_escape_string( $_REQUEST["id"]);
+               $enabled = checkbox_to_sql_bool(db_escape_string( $_REQUEST["enabled"]));
+               $match_any_rule = checkbox_to_sql_bool(db_escape_string( $_REQUEST["match_any_rule"]));
+               $inverse = checkbox_to_sql_bool(db_escape_string( $_REQUEST["inverse"]));
+               $title = db_escape_string( $_REQUEST["title"]);
 
-               $result = db_query($this->link, "UPDATE ttrss_filters2 SET enabled = $enabled,
+               $result = db_query( "UPDATE ttrss_filters2 SET enabled = $enabled,
                        match_any_rule = $match_any_rule,
                        inverse = $inverse,
                        title = '$title'
@@ -482,17 +482,17 @@ class Pref_Filters extends Handler_Protected {
 
        function remove() {
 
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
 
                foreach ($ids as $id) {
-                       db_query($this->link, "DELETE FROM ttrss_filters2 WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]);
+                       db_query( "DELETE FROM ttrss_filters2 WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]);
                }
        }
 
        private function saveRulesAndActions($filter_id) {
 
-               db_query($this->link, "DELETE FROM ttrss_filters2_rules WHERE filter_id = '$filter_id'");
-               db_query($this->link, "DELETE FROM ttrss_filters2_actions WHERE filter_id = '$filter_id'");
+               db_query( "DELETE FROM ttrss_filters2_rules WHERE filter_id = '$filter_id'");
+               db_query( "DELETE FROM ttrss_filters2_actions WHERE filter_id = '$filter_id'");
 
                if ($filter_id) {
                        /* create rules */
@@ -521,11 +521,11 @@ class Pref_Filters extends Handler_Protected {
                        foreach ($rules as $rule) {
                                if ($rule) {
 
-                                       $reg_exp = strip_tags(db_escape_string($this->link, trim($rule["reg_exp"])));
+                                       $reg_exp = strip_tags(db_escape_string( trim($rule["reg_exp"])));
                                        $inverse = isset($rule["inverse"]) ? "true" : "false";
 
-                                       $filter_type = (int) db_escape_string($this->link, trim($rule["filter_type"]));
-                                       $feed_id = db_escape_string($this->link, trim($rule["feed_id"]));
+                                       $filter_type = (int) db_escape_string( trim($rule["filter_type"]));
+                                       $feed_id = db_escape_string( trim($rule["feed_id"]));
 
                                        if (strpos($feed_id, "CAT:") === 0) {
 
@@ -546,16 +546,16 @@ class Pref_Filters extends Handler_Protected {
                                                (filter_id, reg_exp,filter_type,feed_id,cat_id,cat_filter,inverse) VALUES
                                                ('$filter_id', '$reg_exp', '$filter_type', $feed_id, $cat_id, $cat_filter, $inverse)";
 
-                                       db_query($this->link, $query);
+                                       db_query( $query);
                                }
                        }
 
                        foreach ($actions as $action) {
                                if ($action) {
 
-                                       $action_id = (int) db_escape_string($this->link, $action["action_id"]);
-                                       $action_param = db_escape_string($this->link, $action["action_param"]);
-                                       $action_param_label = db_escape_string($this->link, $action["action_param_label"]);
+                                       $action_id = (int) db_escape_string( $action["action_id"]);
+                                       $action_param = db_escape_string( $action["action_param"]);
+                                       $action_param_label = db_escape_string( $action["action_param_label"]);
 
                                        if ($action_id == 7) {
                                                $action_param = $action_param_label;
@@ -569,7 +569,7 @@ class Pref_Filters extends Handler_Protected {
                                                (filter_id, action_id, action_param) VALUES
                                                ('$filter_id', '$action_id', '$action_param')";
 
-                                       db_query($this->link, $query);
+                                       db_query( $query);
                                }
                        }
                }
@@ -586,35 +586,35 @@ class Pref_Filters extends Handler_Protected {
 
                $enabled = checkbox_to_sql_bool($_REQUEST["enabled"]);
                $match_any_rule = checkbox_to_sql_bool($_REQUEST["match_any_rule"]);
-               $title = db_escape_string($this->link, $_REQUEST["title"]);
+               $title = db_escape_string( $_REQUEST["title"]);
 
-               db_query($this->link, "BEGIN");
+               db_query( "BEGIN");
 
                /* create base filter */
 
-               $result = db_query($this->link, "INSERT INTO ttrss_filters2
+               $result = db_query( "INSERT INTO ttrss_filters2
                        (owner_uid, match_any_rule, enabled, title) VALUES
                        (".$_SESSION["uid"].",$match_any_rule,$enabled, '$title')");
 
-               $result = db_query($this->link, "SELECT MAX(id) AS id FROM ttrss_filters2
+               $result = db_query( "SELECT MAX(id) AS id FROM ttrss_filters2
                        WHERE owner_uid = ".$_SESSION["uid"]);
 
                $filter_id = db_fetch_result($result, 0, "id");
 
                $this->saveRulesAndActions($filter_id);
 
-               db_query($this->link, "COMMIT");
+               db_query( "COMMIT");
        }
 
        function index() {
 
-               $sort = db_escape_string($this->link, $_REQUEST["sort"]);
+               $sort = db_escape_string( $_REQUEST["sort"]);
 
                if (!$sort || $sort == "undefined") {
                        $sort = "reg_exp";
                }
 
-               $filter_search = db_escape_string($this->link, $_REQUEST["search"]);
+               $filter_search = db_escape_string( $_REQUEST["search"]);
 
                if (array_key_exists("search", $_REQUEST)) {
                        $_SESSION["prefs_filter_search"] = $filter_search;
@@ -626,7 +626,7 @@ class Pref_Filters extends Handler_Protected {
                print "<div id=\"pref-filter-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">";
                print "<div id=\"pref-filter-toolbar\" dojoType=\"dijit.Toolbar\">";
 
-               $filter_search = db_escape_string($this->link, $_REQUEST["search"]);
+               $filter_search = db_escape_string( $_REQUEST["search"]);
 
                if (array_key_exists("search", $_REQUEST)) {
                        $_SESSION["prefs_filter_search"] = $filter_search;
@@ -832,7 +832,7 @@ class Pref_Filters extends Handler_Protected {
 
                print "<form name='filter_new_rule_form' id='filter_new_rule_form'>";
 
-               $result = db_query($this->link, "SELECT id,description
+               $result = db_query( "SELECT id,description
                        FROM ttrss_filter_types WHERE id != 5 ORDER BY description");
 
                $filter_types = array();
@@ -864,7 +864,7 @@ class Pref_Filters extends Handler_Protected {
                print __("in") . " ";
 
                print "<span id='filterDlg_feeds'>";
-               print_feed_select($this->link, "feed_id",
+               print_feed_select( "feed_id",
                        $cat_filter ? "CAT:$feed_id" : $feed_id,
                        'dojoType="dijit.form.FilteringSelect"');
                print "</span>";
@@ -888,7 +888,7 @@ class Pref_Filters extends Handler_Protected {
                $action = json_decode($_REQUEST["action"], true);
 
                if ($action) {
-                       $action_param = db_escape_string($this->link, $action["action_param"]);
+                       $action_param = db_escape_string( $action["action_param"]);
                        $action_id = (int)$action["action_id"];
                } else {
                        $action_param = "";
@@ -904,7 +904,7 @@ class Pref_Filters extends Handler_Protected {
                print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"
                        onchange=\"filterDlgCheckAction(this)\">";
 
-               $result = db_query($this->link, "SELECT id,description FROM ttrss_filter_actions
+               $result = db_query( "SELECT id,description FROM ttrss_filter_actions
                        ORDER BY name");
 
                while ($line = db_fetch_assoc($result)) {
@@ -928,7 +928,7 @@ class Pref_Filters extends Handler_Protected {
                        id=\"filterDlg_actionParam\" style=\"$param_hidden\"
                        name=\"action_param\" value=\"$action_param\">";
 
-               print_label_select($this->link, "action_param_label", $action_param,
+               print_label_select( "action_param_label", $action_param,
                        "id=\"filterDlg_actionParamLabel\" style=\"$label_param_hidden\"
                        dojoType=\"dijit.form.Select\"");
 
@@ -953,7 +953,7 @@ class Pref_Filters extends Handler_Protected {
 
        private function getFilterName($id) {
 
-               $result = db_query($this->link,
+               $result = db_query(
                        "SELECT title,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions
                                FROM ttrss_filters2 AS f LEFT JOIN ttrss_filters2_rules AS r
                                        ON (r.filter_id = f.id)
@@ -968,7 +968,7 @@ class Pref_Filters extends Handler_Protected {
 
                $title = sprintf(_ngettext("%s (%d rule)", "%s (%d rules)", $num_rules), $title, $num_rules);
 
-               $result = db_query($this->link,
+               $result = db_query(
                        "SELECT * FROM ttrss_filters2_actions WHERE filter_id = '$id' ORDER BY id LIMIT 1");
 
                $actions = "";
@@ -987,22 +987,22 @@ class Pref_Filters extends Handler_Protected {
        }
 
        function join() {
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
 
                if (count($ids) > 1) {
                        $base_id = array_shift($ids);
                        $ids_str = join(",", $ids);
 
-                       db_query($this->link, "BEGIN");
-                       db_query($this->link, "UPDATE ttrss_filters2_rules
+                       db_query( "BEGIN");
+                       db_query( "UPDATE ttrss_filters2_rules
                                SET filter_id = '$base_id' WHERE filter_id IN ($ids_str)");
-                       db_query($this->link, "UPDATE ttrss_filters2_actions
+                       db_query( "UPDATE ttrss_filters2_actions
                                SET filter_id = '$base_id' WHERE filter_id IN ($ids_str)");
 
-                       db_query($this->link, "DELETE FROM ttrss_filters2 WHERE id IN ($ids_str)");
-                       db_query($this->link, "UPDATE ttrss_filters2 SET match_any_rule = true WHERE id = '$base_id'");
+                       db_query( "DELETE FROM ttrss_filters2 WHERE id IN ($ids_str)");
+                       db_query( "UPDATE ttrss_filters2 SET match_any_rule = true WHERE id = '$base_id'");
 
-                       db_query($this->link, "COMMIT");
+                       db_query( "COMMIT");
 
                        $this->optimizeFilter($base_id);
 
@@ -1010,8 +1010,8 @@ class Pref_Filters extends Handler_Protected {
        }
 
        private function optimizeFilter($id) {
-               db_query($this->link, "BEGIN");
-               $result = db_query($this->link, "SELECT * FROM ttrss_filters2_actions
+               db_query( "BEGIN");
+               $result = db_query( "SELECT * FROM ttrss_filters2_actions
                        WHERE filter_id = '$id'");
 
                $tmp = array();
@@ -1030,11 +1030,11 @@ class Pref_Filters extends Handler_Protected {
 
                if (count($dupe_ids) > 0) {
                        $ids_str = join(",", $dupe_ids);
-                       db_query($this->link, "DELETE FROM ttrss_filters2_actions
+                       db_query( "DELETE FROM ttrss_filters2_actions
                                WHERE id IN ($ids_str)");
                }
 
-               $result = db_query($this->link, "SELECT * FROM ttrss_filters2_rules
+               $result = db_query( "SELECT * FROM ttrss_filters2_rules
                        WHERE filter_id = '$id'");
 
                $tmp = array();
@@ -1053,11 +1053,11 @@ class Pref_Filters extends Handler_Protected {
 
                if (count($dupe_ids) > 0) {
                        $ids_str = join(",", $dupe_ids);
-                       db_query($this->link, "DELETE FROM ttrss_filters2_rules
+                       db_query( "DELETE FROM ttrss_filters2_rules
                                WHERE id IN ($ids_str)");
                }
 
-               db_query($this->link, "COMMIT");
+               db_query( "COMMIT");
        }
 }
 ?>
index 15fa7b20b1bbdbd2239fe29ac1687e1ce5318921..e0b118e81686877e762885809c75def2a0f21a7d 100644 (file)
@@ -8,9 +8,9 @@ class Pref_Labels extends Handler_Protected {
        }
 
        function edit() {
-               $label_id = db_escape_string($this->link, $_REQUEST['id']);
+               $label_id = db_escape_string( $_REQUEST['id']);
 
-               $result = db_query($this->link, "SELECT * FROM ttrss_labels2 WHERE
+               $result = db_query( "SELECT * FROM ttrss_labels2 WHERE
                        id = '$label_id' AND owner_uid = " . $_SESSION["uid"]);
 
                $line = db_fetch_assoc($result);
@@ -90,7 +90,7 @@ class Pref_Labels extends Handler_Protected {
                $root['name'] = __('Labels');
                $root['items'] = array();
 
-               $result = db_query($this->link, "SELECT *
+               $result = db_query( "SELECT *
                        FROM ttrss_labels2
                        WHERE owner_uid = ".$_SESSION["uid"]."
                        ORDER BY caption");
@@ -118,29 +118,29 @@ class Pref_Labels extends Handler_Protected {
        }
 
        function colorset() {
-               $kind = db_escape_string($this->link, $_REQUEST["kind"]);
-               $ids = explode(',', db_escape_string($this->link, $_REQUEST["ids"]));
-               $color = db_escape_string($this->link, $_REQUEST["color"]);
-               $fg = db_escape_string($this->link, $_REQUEST["fg"]);
-               $bg = db_escape_string($this->link, $_REQUEST["bg"]);
+               $kind = db_escape_string( $_REQUEST["kind"]);
+               $ids = explode(',', db_escape_string( $_REQUEST["ids"]));
+               $color = db_escape_string( $_REQUEST["color"]);
+               $fg = db_escape_string( $_REQUEST["fg"]);
+               $bg = db_escape_string( $_REQUEST["bg"]);
 
                foreach ($ids as $id) {
 
                        if ($kind == "fg" || $kind == "bg") {
-                               db_query($this->link, "UPDATE ttrss_labels2 SET
+                               db_query( "UPDATE ttrss_labels2 SET
                                        ${kind}_color = '$color' WHERE id = '$id'
                                        AND owner_uid = " . $_SESSION["uid"]);
                        } else {
-                               db_query($this->link, "UPDATE ttrss_labels2 SET
+                               db_query( "UPDATE ttrss_labels2 SET
                                        fg_color = '$fg', bg_color = '$bg' WHERE id = '$id'
                                        AND owner_uid = " . $_SESSION["uid"]);
                        }
 
-                       $caption = db_escape_string($this->link, label_find_caption($this->link, $id, $_SESSION["uid"]));
+                       $caption = db_escape_string( label_find_caption($id, $_SESSION["uid"]));
 
                        /* Remove cached data */
 
-                       db_query($this->link, "UPDATE ttrss_user_entries SET label_cache = ''
+                       db_query( "UPDATE ttrss_user_entries SET label_cache = ''
                                WHERE label_cache LIKE '%$caption%' AND owner_uid = " . $_SESSION["uid"]);
 
                }
@@ -149,18 +149,18 @@ class Pref_Labels extends Handler_Protected {
        }
 
        function colorreset() {
-               $ids = explode(',', db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(',', db_escape_string( $_REQUEST["ids"]));
 
                foreach ($ids as $id) {
-                       db_query($this->link, "UPDATE ttrss_labels2 SET
+                       db_query( "UPDATE ttrss_labels2 SET
                                fg_color = '', bg_color = '' WHERE id = '$id'
                                AND owner_uid = " . $_SESSION["uid"]);
 
-                       $caption = db_escape_string($this->link, label_find_caption($this->link, $id, $_SESSION["uid"]));
+                       $caption = db_escape_string( label_find_caption($id, $_SESSION["uid"]));
 
                        /* Remove cached data */
 
-                       db_query($this->link, "UPDATE ttrss_user_entries SET label_cache = ''
+                       db_query( "UPDATE ttrss_user_entries SET label_cache = ''
                                WHERE label_cache LIKE '%$caption%' AND owner_uid = " . $_SESSION["uid"]);
                }
 
@@ -168,31 +168,31 @@ class Pref_Labels extends Handler_Protected {
 
        function save() {
 
-               $id = db_escape_string($this->link, $_REQUEST["id"]);
-               $caption = db_escape_string($this->link, trim($_REQUEST["caption"]));
+               $id = db_escape_string( $_REQUEST["id"]);
+               $caption = db_escape_string( trim($_REQUEST["caption"]));
 
-               db_query($this->link, "BEGIN");
+               db_query( "BEGIN");
 
-               $result = db_query($this->link, "SELECT caption FROM ttrss_labels2
+               $result = db_query( "SELECT caption FROM ttrss_labels2
                        WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]);
 
                if (db_num_rows($result) != 0) {
                        $old_caption = db_fetch_result($result, 0, "caption");
 
-                       $result = db_query($this->link, "SELECT id FROM ttrss_labels2
+                       $result = db_query( "SELECT id FROM ttrss_labels2
                                WHERE caption = '$caption' AND owner_uid = ". $_SESSION["uid"]);
 
                        if (db_num_rows($result) == 0) {
                                if ($caption) {
-                                       $result = db_query($this->link, "UPDATE ttrss_labels2 SET
+                                       $result = db_query( "UPDATE ttrss_labels2 SET
                                                caption = '$caption' WHERE id = '$id' AND
                                                owner_uid = " . $_SESSION["uid"]);
 
                                        /* Update filters that reference label being renamed */
 
-                                       $old_caption = db_escape_string($this->link, $old_caption);
+                                       $old_caption = db_escape_string( $old_caption);
 
-                                       db_query($this->link, "UPDATE ttrss_filters2_actions SET
+                                       db_query( "UPDATE ttrss_filters2_actions SET
                                                action_param = '$caption' WHERE action_param = '$old_caption'
                                                AND action_id = 7
                                                AND filter_id IN (SELECT id FROM ttrss_filters2 WHERE owner_uid = ".$_SESSION["uid"].")");
@@ -206,28 +206,28 @@ class Pref_Labels extends Handler_Protected {
                        }
                }
 
-               db_query($this->link, "COMMIT");
+               db_query( "COMMIT");
 
                return;
        }
 
        function remove() {
 
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
 
                foreach ($ids as $id) {
-                       label_remove($this->link, $id, $_SESSION["uid"]);
+                       label_remove( $id, $_SESSION["uid"]);
                }
 
        }
 
        function add() {
-               $caption = db_escape_string($this->link, $_REQUEST["caption"]);
-               $output = db_escape_string($this->link, $_REQUEST["output"]);
+               $caption = db_escape_string( $_REQUEST["caption"]);
+               $output = db_escape_string( $_REQUEST["output"]);
 
                if ($caption) {
 
-                       if (label_create($this->link, $caption)) {
+                       if (label_create( $caption)) {
                                if (!$output) {
                                        print T_sprintf("Created label <b>%s</b>", htmlspecialchars($caption));
                                }
@@ -238,7 +238,7 @@ class Pref_Labels extends Handler_Protected {
 
                                print "<rpc-reply><payload>";
 
-                               print_label_select($this->link, "select_label",
+                               print_label_select( "select_label",
                                        $caption, "");
 
                                print "</payload></rpc-reply>";
@@ -250,13 +250,13 @@ class Pref_Labels extends Handler_Protected {
 
        function index() {
 
-               $sort = db_escape_string($this->link, $_REQUEST["sort"]);
+               $sort = db_escape_string( $_REQUEST["sort"]);
 
                if (!$sort || $sort == "undefined") {
                        $sort = "caption";
                }
 
-               $label_search = db_escape_string($this->link, $_REQUEST["search"]);
+               $label_search = db_escape_string( $_REQUEST["search"]);
 
                if (array_key_exists("search", $_REQUEST)) {
                        $_SESSION["prefs_label_search"] = $label_search;
index 2f316b48b6e1ade6413f66d7f6050baf8f4b5324..faab69235504c66097fc3baf1717f91f4ea19ef5 100644 (file)
@@ -103,13 +103,13 @@ class Pref_Prefs extends Handler_Protected {
 
                foreach (array_keys($_POST) as $pref_name) {
 
-                       $pref_name = db_escape_string($this->link, $pref_name);
-                       $value = db_escape_string($this->link, $_POST[$pref_name]);
+                       $pref_name = db_escape_string( $pref_name);
+                       $value = db_escape_string( $_POST[$pref_name]);
 
                        if ($pref_name == 'DIGEST_PREFERRED_TIME') {
-                               if (get_pref($this->link, 'DIGEST_PREFERRED_TIME') != $value) {
+                               if (get_pref( 'DIGEST_PREFERRED_TIME') != $value) {
 
-                                       db_query($this->link, "UPDATE ttrss_users SET
+                                       db_query( "UPDATE ttrss_users SET
                                                last_digest_sent = NULL WHERE id = " . $_SESSION['uid']);
 
                                }
@@ -124,7 +124,7 @@ class Pref_Prefs extends Handler_Protected {
                                        $need_reload = true;
                                }
                        } else {
-                               set_pref($this->link, $pref_name, $value);
+                               set_pref( $pref_name, $value);
                        }
 
                }
@@ -138,9 +138,9 @@ class Pref_Prefs extends Handler_Protected {
 
        function getHelp() {
 
-               $pref_name = db_escape_string($this->link, $_REQUEST["pn"]);
+               $pref_name = db_escape_string( $_REQUEST["pn"]);
 
-               $result = db_query($this->link, "SELECT help_text FROM ttrss_prefs
+               $result = db_query( "SELECT help_text FROM ttrss_prefs
                        WHERE pref_name = '$pref_name'");
 
                if (db_num_rows($result) > 0) {
@@ -153,12 +153,12 @@ class Pref_Prefs extends Handler_Protected {
 
        function changeemail() {
 
-               $email = db_escape_string($this->link, $_POST["email"]);
-               $full_name = db_escape_string($this->link, $_POST["full_name"]);
+               $email = db_escape_string( $_POST["email"]);
+               $full_name = db_escape_string( $_POST["full_name"]);
 
                $active_uid = $_SESSION["uid"];
 
-               db_query($this->link, "UPDATE ttrss_users SET email = '$email',
+               db_query( "UPDATE ttrss_users SET email = '$email',
                        full_name = '$full_name' WHERE id = '$active_uid'");
 
                print __("Your personal data has been saved.");
@@ -176,10 +176,10 @@ class Pref_Prefs extends Handler_Protected {
                        $profile_qpart = "profile IS NULL";
                }
 
-               db_query($this->link, "DELETE FROM ttrss_user_prefs
+               db_query( "DELETE FROM ttrss_user_prefs
                        WHERE $profile_qpart AND owner_uid = ".$_SESSION["uid"]);
 
-               initialize_user_prefs($this->link, $_SESSION["uid"], $_SESSION["profile"]);
+               initialize_user_prefs( $_SESSION["uid"], $_SESSION["profile"]);
 
                echo __("Your preferences are now set to default values.");
        }
@@ -225,7 +225,7 @@ class Pref_Prefs extends Handler_Protected {
 
                print "<h2>" . __("Personal data") . "</h2>";
 
-               $result = db_query($this->link, "SELECT email,full_name,otp_enabled,
+               $result = db_query( "SELECT email,full_name,otp_enabled,
                        access_level FROM ttrss_users
                        WHERE id = ".$_SESSION["uid"]);
 
@@ -270,7 +270,7 @@ class Pref_Prefs extends Handler_Protected {
 
                        print "<h2>" . __("Password") . "</h2>";
 
-                       $result = db_query($this->link, "SELECT id FROM ttrss_users
+                       $result = db_query( "SELECT id FROM ttrss_users
                                WHERE id = ".$_SESSION["uid"]." AND pwd_hash
                                = 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'");
 
@@ -480,10 +480,10 @@ class Pref_Prefs extends Handler_Protected {
                }
 
                if ($_SESSION["profile"]) {
-                       initialize_user_prefs($this->link, $_SESSION["uid"], $_SESSION["profile"]);
+                       initialize_user_prefs( $_SESSION["uid"], $_SESSION["profile"]);
                        $profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
                } else {
-                       initialize_user_prefs($this->link, $_SESSION["uid"]);
+                       initialize_user_prefs( $_SESSION["uid"]);
                        $profile_qpart = "profile IS NULL";
                }
 
@@ -494,7 +494,7 @@ class Pref_Prefs extends Handler_Protected {
 
                $access_query = 'true';
 
-               $result = db_query($this->link, "SELECT DISTINCT
+               $result = db_query( "SELECT DISTINCT
                        ttrss_user_prefs.pref_name,value,type_name,
                        ttrss_prefs_sections.order_id,
                        def_value,section_id
@@ -767,9 +767,9 @@ class Pref_Prefs extends Handler_Protected {
                                <td width='10%'>".__('Author')."</td></tr>";
 
                $system_enabled = array_map("trim", explode(",", PLUGINS));
-               $user_enabled = array_map("trim", explode(",", get_pref($this->link, "_ENABLED_PLUGINS")));
+               $user_enabled = array_map("trim", explode(",", get_pref( "_ENABLED_PLUGINS")));
 
-               $tmppluginhost = new PluginHost($this->link);
+               $tmppluginhost = new PluginHost();
                $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"]);
                $tmppluginhost->load_data(true);
 
@@ -897,7 +897,7 @@ class Pref_Prefs extends Handler_Protected {
                require_once "lib/otphp/lib/totp.php";
                require_once "lib/phpqrcode/phpqrcode.php";
 
-               $result = db_query($this->link, "SELECT login,salt,otp_enabled
+               $result = db_query( "SELECT login,salt,otp_enabled
                        FROM ttrss_users
                        WHERE id = ".$_SESSION["uid"]);
 
@@ -926,7 +926,7 @@ class Pref_Prefs extends Handler_Protected {
 
                if ($authenticator->check_password($_SESSION["uid"], $password)) {
 
-                       $result = db_query($this->link, "SELECT salt
+                       $result = db_query( "SELECT salt
                                FROM ttrss_users
                                WHERE id = ".$_SESSION["uid"]);
 
@@ -938,7 +938,7 @@ class Pref_Prefs extends Handler_Protected {
                        $otp_check = $topt->now();
 
                        if ($otp == $otp_check) {
-                               db_query($this->link, "UPDATE ttrss_users SET otp_enabled = true WHERE
+                               db_query( "UPDATE ttrss_users SET otp_enabled = true WHERE
                                        id = " . $_SESSION["uid"]);
 
                                print "OK";
@@ -952,14 +952,14 @@ class Pref_Prefs extends Handler_Protected {
        }
 
        function otpdisable() {
-               $password = db_escape_string($this->link, $_REQUEST["password"]);
+               $password = db_escape_string( $_REQUEST["password"]);
 
                global $pluginhost;
                $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
 
                if ($authenticator->check_password($_SESSION["uid"], $password)) {
 
-                       db_query($this->link, "UPDATE ttrss_users SET otp_enabled = false WHERE
+                       db_query( "UPDATE ttrss_users SET otp_enabled = false WHERE
                                id = " . $_SESSION["uid"]);
 
                        print "OK";
@@ -975,18 +975,18 @@ class Pref_Prefs extends Handler_Protected {
                else
                        $plugins = "";
 
-               set_pref($this->link, "_ENABLED_PLUGINS", $plugins);
+               set_pref( "_ENABLED_PLUGINS", $plugins);
        }
 
        function clearplugindata() {
-               $name = db_escape_string($this->link, $_REQUEST["name"]);
+               $name = db_escape_string( $_REQUEST["name"]);
 
                global $pluginhost;
                $pluginhost->clear_data($pluginhost->get_plugin($name));
        }
 
        function customizeCSS() {
-               $value = get_pref($this->link, "USER_STYLESHEET");
+               $value = get_pref( "USER_STYLESHEET");
 
                $value = str_replace("<br/>", "\n", $value);
 
@@ -1034,7 +1034,7 @@ class Pref_Prefs extends Handler_Protected {
 
                print "</div>";
 
-               $result = db_query($this->link, "SELECT title,id FROM ttrss_settings_profiles
+               $result = db_query( "SELECT title,id FROM ttrss_settings_profiles
                        WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
 
                print "<div class=\"prefProfileHolder\">";
index 2957b7b96ed62681bed6ec352cfefd66d07204db..0282b2d736423ce9c418c2b7a91c128c648396b3 100644 (file)
@@ -2,10 +2,6 @@
 
 class Pref_System extends Handler_Protected {
 
-       function __construct($link, $args) {
-               parent::__construct($link, $args);
-       }
-
        function before($method) {
                if (parent::before($method)) {
                        if ($_SESSION["access_level"] < 10) {
@@ -28,7 +24,7 @@ class Pref_System extends Handler_Protected {
                print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
                print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Error Log')."\">";
 
-               $result = db_query($this->link, "SELECT errno, errstr, filename, lineno,
+               $result = db_query( "SELECT errno, errstr, filename, lineno,
                        created_at, login FROM ttrss_error_log
                        LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id)
                        ORDER BY ttrss_error_log.id DESC
@@ -57,7 +53,7 @@ class Pref_System extends Handler_Protected {
                        print "<td class='login'>" . $line["login"] . "</td>";
 
                        print "<td class='timestamp'>" .
-                               make_local_datetime($this->link,
+                               make_local_datetime(
                                $line["created_at"], false) . "</td>";
 
                        print "</tr>";
index bd2fff735346e624da8a2553132f1001d10fd1d5..a9c3689fdeaf2ca2ebc6136595905cc9e539ea11 100644 (file)
@@ -21,7 +21,7 @@ class Pref_Users extends Handler_Protected {
 
                        $uid = sprintf("%d", $_REQUEST["id"]);
 
-                       $result = db_query($this->link, "SELECT login,
+                       $result = db_query( "SELECT login,
                                ".SUBSTRING_FOR_DATE."(last_login,1,16) AS last_login,
                                access_level,
                                (SELECT COUNT(int_id) FROM ttrss_user_entries
@@ -41,10 +41,10 @@ class Pref_Users extends Handler_Protected {
 
                        print "<table width='100%'>";
 
-                       $last_login = make_local_datetime($this->link,
+                       $last_login = make_local_datetime(
                                db_fetch_result($result, 0, "last_login"), true);
 
-                       $created = make_local_datetime($this->link,
+                       $created = make_local_datetime(
                                db_fetch_result($result, 0, "created"), true);
 
                        $access_level = db_fetch_result($result, 0, "access_level");
@@ -53,7 +53,7 @@ class Pref_Users extends Handler_Protected {
                        print "<tr><td>".__('Registered')."</td><td>$created</td></tr>";
                        print "<tr><td>".__('Last logged in')."</td><td>$last_login</td></tr>";
 
-                       $result = db_query($this->link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds
+                       $result = db_query( "SELECT COUNT(id) as num_feeds FROM ttrss_feeds
                                WHERE owner_uid = '$uid'");
 
                        $num_feeds = db_fetch_result($result, 0, "num_feeds");
@@ -64,7 +64,7 @@ class Pref_Users extends Handler_Protected {
 
                        print "<h1>".__('Subscribed feeds')."</h1>";
 
-                       $result = db_query($this->link, "SELECT id,title,site_url FROM ttrss_feeds
+                       $result = db_query( "SELECT id,title,site_url FROM ttrss_feeds
                                WHERE owner_uid = '$uid' ORDER BY title");
 
                        print "<ul class=\"userFeedList\">";
@@ -105,14 +105,14 @@ class Pref_Users extends Handler_Protected {
                function edit() {
                        global $access_level_names;
 
-                       $id = db_escape_string($this->link, $_REQUEST["id"]);
+                       $id = db_escape_string( $_REQUEST["id"]);
                        print "<form id=\"user_edit_form\" onsubmit='return false'>";
 
                        print "<input type=\"hidden\" name=\"id\" value=\"$id\">";
                        print "<input type=\"hidden\" name=\"op\" value=\"pref-users\">";
                        print "<input type=\"hidden\" name=\"method\" value=\"editSave\">";
 
-                       $result = db_query($this->link, "SELECT * FROM ttrss_users WHERE id = '$id'");
+                       $result = db_query( "SELECT * FROM ttrss_users WHERE id = '$id'");
 
                        $login = db_fetch_result($result, 0, "login");
                        $access_level = db_fetch_result($result, 0, "access_level");
@@ -181,10 +181,10 @@ class Pref_Users extends Handler_Protected {
                }
 
                function editSave() {
-                       $login = db_escape_string($this->link, trim($_REQUEST["login"]));
-                       $uid = db_escape_string($this->link, $_REQUEST["id"]);
+                       $login = db_escape_string( trim($_REQUEST["login"]));
+                       $uid = db_escape_string( $_REQUEST["id"]);
                        $access_level = (int) $_REQUEST["access_level"];
-                       $email = db_escape_string($this->link, trim($_REQUEST["email"]));
+                       $email = db_escape_string( trim($_REQUEST["email"]));
                        $password = $_REQUEST["password"];
 
                        if ($password) {
@@ -195,42 +195,42 @@ class Pref_Users extends Handler_Protected {
                                $pass_query_part = "";
                        }
 
-                       db_query($this->link, "UPDATE ttrss_users SET $pass_query_part login = '$login',
+                       db_query( "UPDATE ttrss_users SET $pass_query_part login = '$login',
                                access_level = '$access_level', email = '$email', otp_enabled = false
                                WHERE id = '$uid'");
 
                }
 
                function remove() {
-                       $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+                       $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
 
                        foreach ($ids as $id) {
                                if ($id != $_SESSION["uid"] && $id != 1) {
-                                       db_query($this->link, "DELETE FROM ttrss_tags WHERE owner_uid = '$id'");
-                                       db_query($this->link, "DELETE FROM ttrss_feeds WHERE owner_uid = '$id'");
-                                       db_query($this->link, "DELETE FROM ttrss_users WHERE id = '$id'");
+                                       db_query( "DELETE FROM ttrss_tags WHERE owner_uid = '$id'");
+                                       db_query( "DELETE FROM ttrss_feeds WHERE owner_uid = '$id'");
+                                       db_query( "DELETE FROM ttrss_users WHERE id = '$id'");
                                }
                        }
                }
 
                function add() {
 
-                       $login = db_escape_string($this->link, trim($_REQUEST["login"]));
+                       $login = db_escape_string( trim($_REQUEST["login"]));
                        $tmp_user_pwd = make_password(8);
                        $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
                        $pwd_hash = encrypt_password($tmp_user_pwd, $salt, true);
 
-                       $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE
+                       $result = db_query( "SELECT id FROM ttrss_users WHERE
                                login = '$login'");
 
                        if (db_num_rows($result) == 0) {
 
-                               db_query($this->link, "INSERT INTO ttrss_users
+                               db_query( "INSERT INTO ttrss_users
                                        (login,pwd_hash,access_level,last_login,created, salt)
                                        VALUES ('$login', '$pwd_hash', 0, null, NOW(), '$salt')");
 
 
-                               $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE
+                               $result = db_query( "SELECT id FROM ttrss_users WHERE
                                        login = '$login' AND pwd_hash = '$pwd_hash'");
 
                                if (db_num_rows($result) == 1) {
@@ -240,7 +240,7 @@ class Pref_Users extends Handler_Protected {
                                        print format_notice(T_sprintf("Added user <b>%s</b> with password <b>%s</b>",
                                                $login, $tmp_user_pwd));
 
-                                       initialize_user($this->link, $new_uid);
+                                       initialize_user( $new_uid);
 
                                } else {
 
@@ -304,8 +304,8 @@ class Pref_Users extends Handler_Protected {
                }
 
                function resetPass() {
-                       $uid = db_escape_string($this->link, $_REQUEST["id"]);
-                       Pref_Users::resetUserPassword($this->link, $uid, true);
+                       $uid = db_escape_string( $_REQUEST["id"]);
+                       Pref_Users::resetUserPassword( $uid, true);
                }
 
                function index() {
@@ -317,7 +317,7 @@ class Pref_Users extends Handler_Protected {
 
                        print "<div id=\"pref-user-toolbar\" dojoType=\"dijit.Toolbar\">";
 
-                       $user_search = db_escape_string($this->link, $_REQUEST["search"]);
+                       $user_search = db_escape_string( $_REQUEST["search"]);
 
                        if (array_key_exists("search", $_REQUEST)) {
                                $_SESSION["prefs_user_search"] = $user_search;
@@ -332,7 +332,7 @@ class Pref_Users extends Handler_Protected {
                                        __('Search')."</button>
                                </div>";
 
-                       $sort = db_escape_string($this->link, $_REQUEST["sort"]);
+                       $sort = db_escape_string( $_REQUEST["sort"]);
 
                        if (!$sort || $sort == "undefined") {
                                $sort = "login";
@@ -381,7 +381,7 @@ class Pref_Users extends Handler_Protected {
                                $user_search_query = "";
                        }
 
-                       $result = db_query($this->link, "SELECT
+                       $result = db_query( "SELECT
                                        id,login,access_level,email,
                                        ".SUBSTRING_FOR_DATE."(last_login,1,16) as last_login,
                                        ".SUBSTRING_FOR_DATE."(created,1,16) as created
@@ -416,8 +416,8 @@ class Pref_Users extends Handler_Protected {
 
                                $line["login"] = htmlspecialchars($line["login"]);
 
-                               $line["created"] = make_local_datetime($this->link, $line["created"], false);
-                               $line["last_login"] = make_local_datetime($this->link, $line["last_login"], false);
+                               $line["created"] = make_local_datetime( $line["created"], false);
+                               $line["last_login"] = make_local_datetime( $line["last_login"], false);
 
                                print "<td align='center'><input onclick='toggleSelectRow2(this);'
                                        dojoType=\"dijit.form.CheckBox\" type=\"checkbox\"
index b6d552868939a6ab736591d0eac69a4536638988..c46d61d3072772c24e7b63eebee3af4828aeb841 100644 (file)
@@ -8,18 +8,18 @@ class RPC extends Handler_Protected {
        }
 
        function setprofile() {
-               $id = db_escape_string($this->link, $_REQUEST["id"]);
+               $id = db_escape_string( $_REQUEST["id"]);
 
                $_SESSION["profile"] = $id;
                $_SESSION["prefs_cache"] = array();
        }
 
        function remprofiles() {
-               $ids = explode(",", db_escape_string($this->link, trim($_REQUEST["ids"])));
+               $ids = explode(",", db_escape_string( trim($_REQUEST["ids"])));
 
                foreach ($ids as $id) {
                        if ($_SESSION["profile"] != $id) {
-                               db_query($this->link, "DELETE FROM ttrss_settings_profiles WHERE id = '$id' AND
+                               db_query( "DELETE FROM ttrss_settings_profiles WHERE id = '$id' AND
                                                        owner_uid = " . $_SESSION["uid"]);
                        }
                }
@@ -27,38 +27,38 @@ class RPC extends Handler_Protected {
 
        // Silent
        function addprofile() {
-               $title = db_escape_string($this->link, trim($_REQUEST["title"]));
+               $title = db_escape_string( trim($_REQUEST["title"]));
                if ($title) {
-                       db_query($this->link, "BEGIN");
+                       db_query( "BEGIN");
 
-                       $result = db_query($this->link, "SELECT id FROM ttrss_settings_profiles
+                       $result = db_query( "SELECT id FROM ttrss_settings_profiles
                                WHERE title = '$title' AND owner_uid = " . $_SESSION["uid"]);
 
                        if (db_num_rows($result) == 0) {
 
-                               db_query($this->link, "INSERT INTO ttrss_settings_profiles (title, owner_uid)
+                               db_query( "INSERT INTO ttrss_settings_profiles (title, owner_uid)
                                                        VALUES ('$title', ".$_SESSION["uid"] .")");
 
-                               $result = db_query($this->link, "SELECT id FROM ttrss_settings_profiles WHERE
+                               $result = db_query( "SELECT id FROM ttrss_settings_profiles WHERE
                                        title = '$title'");
 
                                if (db_num_rows($result) != 0) {
                                        $profile_id = db_fetch_result($result, 0, "id");
 
                                        if ($profile_id) {
-                                               initialize_user_prefs($this->link, $_SESSION["uid"], $profile_id);
+                                               initialize_user_prefs( $_SESSION["uid"], $profile_id);
                                        }
                                }
                        }
 
-                       db_query($this->link, "COMMIT");
+                       db_query( "COMMIT");
                }
        }
 
        // Silent
        function saveprofile() {
-               $id = db_escape_string($this->link, $_REQUEST["id"]);
-               $title = db_escape_string($this->link, trim($_REQUEST["value"]));
+               $id = db_escape_string( $_REQUEST["id"]);
+               $title = db_escape_string( trim($_REQUEST["value"]));
 
                if ($id == 0) {
                        print __("Default profile");
@@ -66,55 +66,55 @@ class RPC extends Handler_Protected {
                }
 
                if ($title) {
-                       db_query($this->link, "BEGIN");
+                       db_query( "BEGIN");
 
-                       $result = db_query($this->link, "SELECT id FROM ttrss_settings_profiles
+                       $result = db_query( "SELECT id FROM ttrss_settings_profiles
                                WHERE title = '$title' AND owner_uid =" . $_SESSION["uid"]);
 
                        if (db_num_rows($result) == 0) {
-                               db_query($this->link, "UPDATE ttrss_settings_profiles
+                               db_query( "UPDATE ttrss_settings_profiles
                                                        SET title = '$title' WHERE id = '$id' AND
                                                        owner_uid = " . $_SESSION["uid"]);
                                print $title;
                        } else {
-                               $result = db_query($this->link, "SELECT title FROM ttrss_settings_profiles
+                               $result = db_query( "SELECT title FROM ttrss_settings_profiles
                                                        WHERE id = '$id' AND owner_uid =" . $_SESSION["uid"]);
                                print db_fetch_result($result, 0, "title");
                        }
 
-                       db_query($this->link, "COMMIT");
+                       db_query( "COMMIT");
                }
        }
 
        // Silent
        function remarchive() {
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
 
                foreach ($ids as $id) {
-                       $result = db_query($this->link, "DELETE FROM ttrss_archived_feeds WHERE
+                       $result = db_query( "DELETE FROM ttrss_archived_feeds WHERE
                (SELECT COUNT(*) FROM ttrss_user_entries
                                                        WHERE orig_feed_id = '$id') = 0 AND
                id = '$id' AND owner_uid = ".$_SESSION["uid"]);
 
-                       $rc = db_affected_rows($this->link, $result);
+                       $rc = db_affected_rows( $result);
                }
        }
 
        function addfeed() {
-               $feed = db_escape_string($this->link, $_REQUEST['feed']);
-               $cat = db_escape_string($this->link, $_REQUEST['cat']);
-               $login = db_escape_string($this->link, $_REQUEST['login']);
+               $feed = db_escape_string( $_REQUEST['feed']);
+               $cat = db_escape_string( $_REQUEST['cat']);
+               $login = db_escape_string( $_REQUEST['login']);
                $pass = trim($_REQUEST['pass']); // escaped later
 
-               $rc = subscribe_to_feed($this->link, $feed, $cat, $login, $pass);
+               $rc = subscribe_to_feed( $feed, $cat, $login, $pass);
 
                print json_encode(array("result" => $rc));
        }
 
        function togglepref() {
-               $key = db_escape_string($this->link, $_REQUEST["key"]);
-               set_pref($this->link, $key, !get_pref($this->link, $key));
-               $value = get_pref($this->link, $key);
+               $key = db_escape_string( $_REQUEST["key"]);
+               set_pref( $key, !get_pref( $key));
+               $value = get_pref( $key);
 
                print json_encode(array("param" =>$key, "value" => $value));
        }
@@ -124,14 +124,14 @@ class RPC extends Handler_Protected {
                $key = $_REQUEST['key'];
                $value = str_replace("\n", "<br/>", $_REQUEST['value']);
 
-               set_pref($this->link, $key, $value, $_SESSION['uid'], $key != 'USER_STYLESHEET');
+               set_pref( $key, $value, $_SESSION['uid'], $key != 'USER_STYLESHEET');
 
                print json_encode(array("param" =>$key, "value" => $value));
        }
 
        function mark() {
                $mark = $_REQUEST["mark"];
-               $id = db_escape_string($this->link, $_REQUEST["id"]);
+               $id = db_escape_string( $_REQUEST["id"]);
 
                if ($mark == "1") {
                        $mark = "true";
@@ -139,7 +139,7 @@ class RPC extends Handler_Protected {
                        $mark = "false";
                }
 
-               $result = db_query($this->link, "UPDATE ttrss_user_entries SET marked = $mark,
+               $result = db_query( "UPDATE ttrss_user_entries SET marked = $mark,
                                        last_marked = NOW()
                                        WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
 
@@ -147,12 +147,12 @@ class RPC extends Handler_Protected {
        }
 
        function delete() {
-               $ids = db_escape_string($this->link, $_REQUEST["ids"]);
+               $ids = db_escape_string( $_REQUEST["ids"]);
 
-               $result = db_query($this->link, "DELETE FROM ttrss_user_entries
+               $result = db_query( "DELETE FROM ttrss_user_entries
                WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
 
-               purge_orphans($this->link);
+               purge_orphans();
 
                print json_encode(array("message" => "UPDATE_COUNTERS"));
        }
@@ -161,26 +161,26 @@ class RPC extends Handler_Protected {
                $ids = explode(",", $_REQUEST["ids"]);
 
                foreach ($ids as $id) {
-                       $id = db_escape_string($this->link, trim($id));
-                       db_query($this->link, "BEGIN");
+                       $id = db_escape_string( trim($id));
+                       db_query( "BEGIN");
 
-                       $result = db_query($this->link, "SELECT feed_url,site_url,title FROM ttrss_archived_feeds
+                       $result = db_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"].")");
 
                        if (db_num_rows($result) != 0) {
-                               $feed_url = db_escape_string($this->link, db_fetch_result($result, 0, "feed_url"));
-                               $site_url = db_escape_string($this->link, db_fetch_result($result, 0, "site_url"));
-                               $title = db_escape_string($this->link, db_fetch_result($result, 0, "title"));
+                               $feed_url = db_escape_string( db_fetch_result($result, 0, "feed_url"));
+                               $site_url = db_escape_string( db_fetch_result($result, 0, "site_url"));
+                               $title = db_escape_string( db_fetch_result($result, 0, "title"));
 
-                               $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_url'
+                               $result = db_query( "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_url'
                                        AND owner_uid = " .$_SESSION["uid"]);
 
                                if (db_num_rows($result) == 0) {
 
                                        if (!$title) $title = '[Unknown]';
 
-                                       $result = db_query($this->link,
+                                       $result = db_query(
                                                "INSERT INTO ttrss_feeds
                                                        (owner_uid,feed_url,site_url,title,cat_id,auth_login,auth_pass,update_method)
                                                        VALUES (".$_SESSION["uid"].",
@@ -189,7 +189,7 @@ class RPC extends Handler_Protected {
                                                        '$title',
                                                        NULL, '', '', 0)");
 
-                                       $result = db_query($this->link,
+                                       $result = db_query(
                                                "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_url'
                                                AND owner_uid = ".$_SESSION["uid"]);
 
@@ -202,32 +202,32 @@ class RPC extends Handler_Protected {
                                }
 
                                if ($feed_id) {
-                                       $result = db_query($this->link, "UPDATE ttrss_user_entries
+                                       $result = db_query( "UPDATE ttrss_user_entries
                                                SET feed_id = '$feed_id', orig_feed_id = NULL
                                                WHERE ref_id = $id AND owner_uid = " . $_SESSION["uid"]);
                                }
                        }
 
-                       db_query($this->link, "COMMIT");
+                       db_query( "COMMIT");
                }
 
                print json_encode(array("message" => "UPDATE_COUNTERS"));
        }
 
        function archive() {
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
 
                foreach ($ids as $id) {
-                       $this->archive_article($this->link, $id, $_SESSION["uid"]);
+                       $this->archive_article( $id, $_SESSION["uid"]);
                }
 
                print json_encode(array("message" => "UPDATE_COUNTERS"));
        }
 
-       private function archive_article($link, $id, $owner_uid) {
-               db_query($link, "BEGIN");
+       private function archive_article( $id, $owner_uid) {
+               db_query( "BEGIN");
 
-               $result = db_query($link, "SELECT feed_id FROM ttrss_user_entries
+               $result = db_query( "SELECT feed_id FROM ttrss_user_entries
                        WHERE ref_id = '$id' AND owner_uid = $owner_uid");
 
                if (db_num_rows($result) != 0) {
@@ -237,29 +237,29 @@ class RPC extends Handler_Protected {
                        $feed_id = (int) db_fetch_result($result, 0, "feed_id");
 
                        if ($feed_id) {
-                               $result = db_query($link, "SELECT id FROM ttrss_archived_feeds
+                               $result = db_query( "SELECT id FROM ttrss_archived_feeds
                                        WHERE id = '$feed_id'");
 
                                if (db_num_rows($result) == 0) {
-                                       db_query($link, "INSERT INTO ttrss_archived_feeds
+                                       db_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
                                        WHERE id = '$feed_id'");
                                }
 
-                               db_query($link, "UPDATE ttrss_user_entries
+                               db_query( "UPDATE ttrss_user_entries
                                        SET orig_feed_id = feed_id, feed_id = NULL
                                        WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
                        }
                }
 
-               db_query($link, "COMMIT");
+               db_query( "COMMIT");
        }
 
        function publ() {
                $pub = $_REQUEST["pub"];
-               $id = db_escape_string($this->link, $_REQUEST["id"]);
-               $note = trim(strip_tags(db_escape_string($this->link, $_REQUEST["note"])));
+               $id = db_escape_string( $_REQUEST["id"]);
+               $note = trim(strip_tags(db_escape_string( $_REQUEST["note"])));
 
                if ($pub == "1") {
                        $pub = "true";
@@ -267,7 +267,7 @@ class RPC extends Handler_Protected {
                        $pub = "false";
                }
 
-               $result = db_query($this->link, "UPDATE ttrss_user_entries SET
+               $result = db_query( "UPDATE ttrss_user_entries SET
                        published = $pub, last_published = NOW()
                        WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
 
@@ -276,7 +276,7 @@ class RPC extends Handler_Protected {
                if (PUBSUBHUBBUB_HUB) {
                        $rss_link = get_self_url_prefix() .
                                "/public.php?op=rss&id=-2&key=" .
-                               get_feed_access_key($this->link, -2, false);
+                               get_feed_access_key( -2, false);
 
                        $p = new Publisher(PUBSUBHUBBUB_HUB);
 
@@ -294,39 +294,39 @@ class RPC extends Handler_Protected {
 
                if ($seq) $reply['seq'] = $seq;
 
-               if ($last_article_id != getLastArticleId($this->link)) {
-                       $reply['counters'] = getAllCounters($this->link);
+               if ($last_article_id != getLastArticleId()) {
+                       $reply['counters'] = getAllCounters();
                }
 
-               $reply['runtime-info'] = make_runtime_info($this->link);
+               $reply['runtime-info'] = make_runtime_info();
 
                print json_encode($reply);
        }
 
        /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
        function catchupSelected() {
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
                $cmode = sprintf("%d", $_REQUEST["cmode"]);
 
-               catchupArticlesById($this->link, $ids, $cmode);
+               catchupArticlesById( $ids, $cmode);
 
                print json_encode(array("message" => "UPDATE_COUNTERS", "ids" => $ids));
        }
 
        function markSelected() {
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
                $cmode = sprintf("%d", $_REQUEST["cmode"]);
 
-               $this->markArticlesById($this->link, $ids, $cmode);
+               $this->markArticlesById( $ids, $cmode);
 
                print json_encode(array("message" => "UPDATE_COUNTERS"));
        }
 
        function publishSelected() {
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
                $cmode = sprintf("%d", $_REQUEST["cmode"]);
 
-               $this->publishArticlesById($this->link, $ids, $cmode);
+               $this->publishArticlesById( $ids, $cmode);
 
                print json_encode(array("message" => "UPDATE_COUNTERS"));
        }
@@ -338,20 +338,20 @@ class RPC extends Handler_Protected {
 
                $reply = array();
 
-               $reply['error'] = sanity_check($this->link);
+               $reply['error'] = sanity_check();
 
                if ($reply['error']['code'] == 0) {
-                       $reply['init-params'] = make_init_params($this->link);
-                       $reply['runtime-info'] = make_runtime_info($this->link);
+                       $reply['init-params'] = make_init_params();
+                       $reply['runtime-info'] = make_runtime_info();
                }
 
                print json_encode($reply);
        }
 
        function completeLabels() {
-               $search = db_escape_string($this->link, $_REQUEST["search"]);
+               $search = db_escape_string( $_REQUEST["search"]);
 
-               $result = db_query($this->link, "SELECT DISTINCT caption FROM
+               $result = db_query( "SELECT DISTINCT caption FROM
                                ttrss_labels2
                                WHERE owner_uid = '".$_SESSION["uid"]."' AND
                                LOWER(caption) LIKE LOWER('$search%') ORDER BY caption
@@ -365,29 +365,29 @@ class RPC extends Handler_Protected {
        }
 
        function purge() {
-               $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"]));
+               $ids = explode(",", db_escape_string( $_REQUEST["ids"]));
                $days = sprintf("%d", $_REQUEST["days"]);
 
                foreach ($ids as $id) {
 
-                       $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
+                       $result = db_query( "SELECT id FROM ttrss_feeds WHERE
                                id = '$id' AND owner_uid = ".$_SESSION["uid"]);
 
                        if (db_num_rows($result) == 1) {
-                               purge_feed($this->link, $id, $days);
+                               purge_feed( $id, $days);
                        }
                }
        }
 
        function updateFeedBrowser() {
-               $search = db_escape_string($this->link, $_REQUEST["search"]);
-               $limit = db_escape_string($this->link, $_REQUEST["limit"]);
-               $mode = (int) db_escape_string($this->link, $_REQUEST["mode"]);
+               $search = db_escape_string( $_REQUEST["search"]);
+               $limit = db_escape_string( $_REQUEST["limit"]);
+               $mode = (int) db_escape_string( $_REQUEST["mode"]);
 
                require_once "feedbrowser.php";
 
                print json_encode(array("content" =>
-                       make_feed_browser($this->link, $search, $limit, $mode),
+                       make_feed_browser( $search, $limit, $mode),
                                "mode" => $mode));
        }
 
@@ -402,14 +402,14 @@ class RPC extends Handler_Protected {
                if ($mode == 1) {
                        foreach ($payload as $feed) {
 
-                               $title = db_escape_string($this->link, $feed[0]);
-                               $feed_url = db_escape_string($this->link, $feed[1]);
+                               $title = db_escape_string( $feed[0]);
+                               $feed_url = db_escape_string( $feed[1]);
 
-                               $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
+                               $result = db_query( "SELECT id FROM ttrss_feeds WHERE
                                        feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
 
                                if (db_num_rows($result) == 0) {
-                                       $result = db_query($this->link, "INSERT INTO ttrss_feeds
+                                       $result = db_query( "INSERT INTO ttrss_feeds
                                                                        (owner_uid,feed_url,title,cat_id,site_url)
                                                                        VALUES ('".$_SESSION["uid"]."',
                                                                        '$feed_url', '$title', NULL, '')");
@@ -418,19 +418,19 @@ class RPC extends Handler_Protected {
                } else if ($mode == 2) {
                        // feed archive
                        foreach ($payload as $id) {
-                               $result = db_query($this->link, "SELECT * FROM ttrss_archived_feeds
+                               $result = db_query( "SELECT * FROM ttrss_archived_feeds
                                        WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
 
                                if (db_num_rows($result) != 0) {
-                                       $site_url = db_escape_string($this->link, db_fetch_result($result, 0, "site_url"));
-                                       $feed_url = db_escape_string($this->link, db_fetch_result($result, 0, "feed_url"));
-                                       $title = db_escape_string($this->link, db_fetch_result($result, 0, "title"));
+                                       $site_url = db_escape_string( db_fetch_result($result, 0, "site_url"));
+                                       $feed_url = db_escape_string( db_fetch_result($result, 0, "feed_url"));
+                                       $title = db_escape_string( db_fetch_result($result, 0, "title"));
 
-                                       $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
+                                       $result = db_query( "SELECT id FROM ttrss_feeds WHERE
                                                feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
 
                                        if (db_num_rows($result) == 0) {
-                                               $result = db_query($this->link, "INSERT INTO ttrss_feeds
+                                               $result = db_query( "INSERT INTO ttrss_feeds
                                                                                (owner_uid,feed_url,title,cat_id,site_url)
                                                                        VALUES ('$id','".$_SESSION["uid"]."',
                                                                        '$feed_url', '$title', NULL, '$site_url')");
@@ -441,21 +441,21 @@ class RPC extends Handler_Protected {
        }
 
        function catchupFeed() {
-               $feed_id = db_escape_string($this->link, $_REQUEST['feed_id']);
-               $is_cat = db_escape_string($this->link, $_REQUEST['is_cat']) == "true";
-               $mode = db_escape_string($this->link, $_REQUEST['mode']);
+               $feed_id = db_escape_string( $_REQUEST['feed_id']);
+               $is_cat = db_escape_string( $_REQUEST['is_cat']) == "true";
+               $mode = db_escape_string( $_REQUEST['mode']);
 
-               catchup_feed($this->link, $feed_id, $is_cat, false, false, $mode);
+               catchup_feed( $feed_id, $is_cat, false, false, $mode);
 
                print json_encode(array("message" => "UPDATE_COUNTERS"));
        }
 
        function quickAddCat() {
-               $cat = db_escape_string($this->link, $_REQUEST["cat"]);
+               $cat = db_escape_string( $_REQUEST["cat"]);
 
-               add_feed_category($this->link, $cat);
+               add_feed_category( $cat);
 
-               $result = db_query($this->link, "SELECT id FROM ttrss_feed_categories WHERE
+               $result = db_query( "SELECT id FROM ttrss_feed_categories WHERE
                        title = '$cat' AND owner_uid = " . $_SESSION["uid"]);
 
                if (db_num_rows($result) == 1) {
@@ -464,12 +464,12 @@ class RPC extends Handler_Protected {
                        $id = 0;
                }
 
-               print_feed_cat_select($this->link, "cat_id", $id);
+               print_feed_cat_select( "cat_id", $id);
        }
 
        // Silent
        function clearArticleKeys() {
-               db_query($this->link, "UPDATE ttrss_user_entries SET uuid = '' WHERE
+               db_query( "UPDATE ttrss_user_entries SET uuid = '' WHERE
                        owner_uid = " . $_SESSION["uid"]);
 
                return;
@@ -516,7 +516,7 @@ class RPC extends Handler_Protected {
                $random_qpart = sql_random_function();
 
                // We search for feed needing update.
-               $result = db_query($this->link, "SELECT ttrss_feeds.feed_url,ttrss_feeds.id
+               $result = db_query( "SELECT ttrss_feeds.feed_url,ttrss_feeds.id
                        FROM
                                ttrss_feeds, ttrss_users, ttrss_user_prefs
                        WHERE
@@ -539,7 +539,7 @@ class RPC extends Handler_Protected {
                        $feed_id = $line["id"];
 
                        if (time() - $tstart < ini_get("max_execution_time") * 0.7) {
-                               update_rss_feed($this->link, $feed_id, true);
+                               update_rss_feed( $feed_id, true);
                                ++$num_updated;
                        } else {
                                break;
@@ -547,8 +547,8 @@ class RPC extends Handler_Protected {
                }
 
                // Purge orphans and cleanup tags
-               purge_orphans($this->link);
-               cleanup_tags($this->link, 14, 50000);
+               purge_orphans();
+               cleanup_tags( 14, 50000);
 
                if ($num_updated > 0) {
                        print json_encode(array("message" => "UPDATE_COUNTERS",
@@ -559,7 +559,7 @@ class RPC extends Handler_Protected {
 
        }
 
-       private function markArticlesById($link, $ids, $cmode) {
+       private function markArticlesById( $ids, $cmode) {
 
                $tmp_ids = array();
 
@@ -570,21 +570,21 @@ class RPC extends Handler_Protected {
                $ids_qpart = join(" OR ", $tmp_ids);
 
                if ($cmode == 0) {
-                       db_query($link, "UPDATE ttrss_user_entries SET
+                       db_query( "UPDATE ttrss_user_entries SET
                        marked = false, last_marked = NOW()
                        WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
                } else if ($cmode == 1) {
-                       db_query($link, "UPDATE ttrss_user_entries SET
+                       db_query( "UPDATE ttrss_user_entries SET
                        marked = true, last_marked = NOW()
                        WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
                } else {
-                       db_query($link, "UPDATE ttrss_user_entries SET
+                       db_query( "UPDATE ttrss_user_entries SET
                        marked = NOT marked,last_marked = NOW()
                        WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
                }
        }
 
-       private function publishArticlesById($link, $ids, $cmode) {
+       private function publishArticlesById( $ids, $cmode) {
 
                $tmp_ids = array();
 
@@ -595,15 +595,15 @@ class RPC extends Handler_Protected {
                $ids_qpart = join(" OR ", $tmp_ids);
 
                if ($cmode == 0) {
-                       db_query($link, "UPDATE ttrss_user_entries SET
+                       db_query( "UPDATE ttrss_user_entries SET
                        published = false,last_published = NOW()
                        WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
                } else if ($cmode == 1) {
-                       db_query($link, "UPDATE ttrss_user_entries SET
+                       db_query( "UPDATE ttrss_user_entries SET
                        published = true,last_published = NOW()
                        WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
                } else {
-                       db_query($link, "UPDATE ttrss_user_entries SET
+                       db_query( "UPDATE ttrss_user_entries SET
                        published = NOT published,last_published = NOW()
                        WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
                }
@@ -611,7 +611,7 @@ class RPC extends Handler_Protected {
                if (PUBSUBHUBBUB_HUB) {
                        $rss_link = get_self_url_prefix() .
                                "/public.php?op=rss&id=-2&key=" .
-                               get_feed_access_key($link, -2, false);
+                               get_feed_access_key( -2, false);
 
                        $p = new Publisher(PUBSUBHUBBUB_HUB);
 
@@ -620,9 +620,9 @@ class RPC extends Handler_Protected {
        }
 
        function getlinktitlebyid() {
-               $id = db_escape_string($this->link, $_REQUEST['id']);
+               $id = db_escape_string( $_REQUEST['id']);
 
-               $result = db_query($this->link, "SELECT link, title FROM ttrss_entries, ttrss_user_entries
+               $result = db_query( "SELECT link, title FROM ttrss_entries, ttrss_user_entries
                        WHERE ref_id = '$id' AND ref_id = id AND owner_uid = ". $_SESSION["uid"]);
 
                if (db_num_rows($result) != 0) {
index c53b1a08c140558e8cb3050637ad55880998bb30..10e70ffe3002bd9da71f46f7faffc8aca06ceca2 100644 (file)
@@ -1,19 +1,19 @@
 <?php
-       /* function ccache_zero($link, $feed_id, $owner_uid) {
-               db_query($link, "UPDATE ttrss_counters_cache SET
+       /* function ccache_zero( $feed_id, $owner_uid) {
+               db_query( "UPDATE ttrss_counters_cache SET
                        value = 0, updated = NOW() WHERE
                        feed_id = '$feed_id' AND owner_uid = '$owner_uid'");
        } */
 
-       function ccache_zero_all($link, $owner_uid) {
-               db_query($link, "UPDATE ttrss_counters_cache SET
+       function ccache_zero_all( $owner_uid) {
+               db_query( "UPDATE ttrss_counters_cache SET
                        value = 0 WHERE owner_uid = '$owner_uid'");
 
-               db_query($link, "UPDATE ttrss_cat_counters_cache SET
+               db_query( "UPDATE ttrss_cat_counters_cache SET
                        value = 0 WHERE owner_uid = '$owner_uid'");
        }
 
-       function ccache_remove($link, $feed_id, $owner_uid, $is_cat = false) {
+       function ccache_remove( $feed_id, $owner_uid, $is_cat = false) {
 
                if (!$is_cat) {
                        $table = "ttrss_counters_cache";
                        $table = "ttrss_cat_counters_cache";
                }
 
-               db_query($link, "DELETE FROM $table WHERE
+               db_query( "DELETE FROM $table WHERE
                        feed_id = '$feed_id' AND owner_uid = '$owner_uid'");
 
        }
 
-       function ccache_update_all($link, $owner_uid) {
+       function ccache_update_all( $owner_uid) {
 
-               if (get_pref($link, 'ENABLE_FEED_CATS', $owner_uid)) {
+               if (get_pref( 'ENABLE_FEED_CATS', $owner_uid)) {
 
-                       $result = db_query($link, "SELECT feed_id FROM ttrss_cat_counters_cache
+                       $result = db_query( "SELECT feed_id FROM ttrss_cat_counters_cache
                                WHERE feed_id > 0 AND owner_uid = '$owner_uid'");
 
                        while ($line = db_fetch_assoc($result)) {
-                               ccache_update($link, $line["feed_id"], $owner_uid, true);
+                               ccache_update( $line["feed_id"], $owner_uid, true);
                        }
 
                        /* We have to manually include category 0 */
 
-                       ccache_update($link, 0, $owner_uid, true);
+                       ccache_update( 0, $owner_uid, true);
 
                } else {
-                       $result = db_query($link, "SELECT feed_id FROM ttrss_counters_cache
+                       $result = db_query( "SELECT feed_id FROM ttrss_counters_cache
                                WHERE feed_id > 0 AND owner_uid = '$owner_uid'");
 
                        while ($line = db_fetch_assoc($result)) {
-                               print ccache_update($link, $line["feed_id"], $owner_uid);
+                               print ccache_update( $line["feed_id"], $owner_uid);
 
                        }
 
                }
        }
 
-       function ccache_find($link, $feed_id, $owner_uid, $is_cat = false,
+       function ccache_find( $feed_id, $owner_uid, $is_cat = false,
                $no_update = false) {
 
                if (!is_numeric($feed_id)) return;
@@ -61,7 +61,7 @@
                if (!$is_cat) {
                        $table = "ttrss_counters_cache";
                        /* if ($feed_id > 0) {
-                               $tmp_result = db_query($link, "SELECT owner_uid FROM ttrss_feeds
+                               $tmp_result = db_query( "SELECT owner_uid FROM ttrss_feeds
                                        WHERE id = '$feed_id'");
                                $owner_uid = db_fetch_result($tmp_result, 0, "owner_uid");
                        } */
@@ -75,7 +75,7 @@
                        $date_qpart = "updated > DATE_SUB(NOW(), INTERVAL 15 MINUTE)";
                }
 
-               $result = db_query($link, "SELECT value FROM $table
+               $result = db_query( "SELECT value FROM $table
                        WHERE owner_uid = '$owner_uid' AND feed_id = '$feed_id'
                        LIMIT 1");
 
                        if ($no_update) {
                                return -1;
                        } else {
-                               return ccache_update($link, $feed_id, $owner_uid, $is_cat);
+                               return ccache_update( $feed_id, $owner_uid, $is_cat);
                        }
                }
 
        }
 
-       function ccache_update($link, $feed_id, $owner_uid, $is_cat = false,
+       function ccache_update( $feed_id, $owner_uid, $is_cat = false,
                $update_pcat = true) {
 
                if (!is_numeric($feed_id)) return;
 
                /* if (!$is_cat && $feed_id > 0) {
-                       $tmp_result = db_query($link, "SELECT owner_uid FROM ttrss_feeds
+                       $tmp_result = db_query( "SELECT owner_uid FROM ttrss_feeds
                                WHERE id = '$feed_id'");
                        $owner_uid = db_fetch_result($tmp_result, 0, "owner_uid");
                } */
 
-               $prev_unread = ccache_find($link, $feed_id, $owner_uid, $is_cat, true);
+               $prev_unread = ccache_find( $feed_id, $owner_uid, $is_cat, true);
 
                /* When updating a label, all we need to do is recalculate feed counters
                 * because labels are not cached */
 
                if ($feed_id < 0) {
-                       ccache_update_all($link, $owner_uid);
+                       ccache_update_all( $owner_uid);
                        return;
                }
 
 
                        /* Recalculate counters for child feeds */
 
-                       $result = db_query($link, "SELECT id FROM ttrss_feeds
+                       $result = db_query( "SELECT id FROM ttrss_feeds
                                                WHERE owner_uid = '$owner_uid' AND $cat_qpart");
 
                        while ($line = db_fetch_assoc($result)) {
-                               ccache_update($link, $line["id"], $owner_uid, false, false);
+                               ccache_update( $line["id"], $owner_uid, false, false);
                        }
 
-                       $result = db_query($link, "SELECT SUM(value) AS sv
+                       $result = db_query( "SELECT SUM(value) AS sv
                                FROM ttrss_counters_cache, ttrss_feeds
                                WHERE id = feed_id AND $cat_qpart AND
                                ttrss_feeds.owner_uid = '$owner_uid'");
                        $unread = (int) db_fetch_result($result, 0, "sv");
 
                } else {
-                       $unread = (int) getFeedArticles($link, $feed_id, $is_cat, true, $owner_uid);
+                       $unread = (int) getFeedArticles( $feed_id, $is_cat, true, $owner_uid);
                }
 
-               db_query($link, "BEGIN");
+               db_query( "BEGIN");
 
-               $result = db_query($link, "SELECT feed_id FROM $table
+               $result = db_query( "SELECT feed_id FROM $table
                        WHERE owner_uid = '$owner_uid' AND feed_id = '$feed_id' LIMIT 1");
 
                if (db_num_rows($result) == 1) {
-                       db_query($link, "UPDATE $table SET
+                       db_query( "UPDATE $table SET
                                value = '$unread', updated = NOW() WHERE
                                feed_id = '$feed_id' AND owner_uid = '$owner_uid'");
 
                } else {
-                       db_query($link, "INSERT INTO $table
+                       db_query( "INSERT INTO $table
                                (feed_id, value, owner_uid, updated)
                                VALUES
                                ($feed_id, $unread, $owner_uid, NOW())");
                }
 
-               db_query($link, "COMMIT");
+               db_query( "COMMIT");
 
                if ($feed_id > 0 && $prev_unread != $unread) {
 
 
                                if ($update_pcat) {
 
-                                       $result = db_query($link, "SELECT cat_id FROM ttrss_feeds
+                                       $result = db_query( "SELECT cat_id FROM ttrss_feeds
                                                WHERE owner_uid = '$owner_uid' AND id = '$feed_id'");
 
                                        $cat_id = (int) db_fetch_result($result, 0, "cat_id");
 
-                                       ccache_update($link, $cat_id, $owner_uid, true);
+                                       ccache_update( $cat_id, $owner_uid, true);
 
                                }
                        }
                } else if ($feed_id < 0) {
-                       ccache_update_all($link, $owner_uid);
+                       ccache_update_all( $owner_uid);
                }
 
                return $unread;
        }
 
-       /* function ccache_cleanup($link, $owner_uid) {
+       /* function ccache_cleanup( $owner_uid) {
 
                if (DB_TYPE == "pgsql") {
-                       db_query($link, "DELETE FROM ttrss_counters_cache AS c1 WHERE
+                       db_query( "DELETE FROM ttrss_counters_cache AS c1 WHERE
                                (SELECT count(*) FROM ttrss_counters_cache AS c2
                                        WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1
                                        AND owner_uid = '$owner_uid'");
 
-                       db_query($link, "DELETE FROM ttrss_cat_counters_cache AS c1 WHERE
+                       db_query( "DELETE FROM ttrss_cat_counters_cache AS c1 WHERE
                                (SELECT count(*) FROM ttrss_cat_counters_cache AS c2
                                        WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1
                                        AND owner_uid = '$owner_uid'");
                } else {
-                       db_query($link, "DELETE c1 FROM
+                       db_query( "DELETE c1 FROM
                                        ttrss_counters_cache AS c1,
                                        ttrss_counters_cache AS c2
                                WHERE
                                        c1.owner_uid = c2.owner_uid AND
                                        c1.feed_id = c2.feed_id");
 
-                       db_query($link, "DELETE c1 FROM
+                       db_query( "DELETE c1 FROM
                                        ttrss_cat_counters_cache AS c1,
                                        ttrss_cat_counters_cache AS c2
                                WHERE
index 1ee3d609a5f4867d98aac5e9250af2ba0f1404a4..d786e53494b8332de784755b51b06c46e6773cd8 100644 (file)
@@ -7,7 +7,7 @@
                        $_SESSION["prefs_cache"] = array();
        }
 
-       function cache_prefs($link) {
+       function cache_prefs() {
                $profile = false;
 
                $user_id = $_SESSION["uid"];
@@ -19,9 +19,9 @@
                        $profile_qpart = "profile IS NULL AND";
                }
 
-               if (get_schema_version($link) < 63) $profile_qpart = "";
+               if (get_schema_version() < 63) $profile_qpart = "";
 
-               $result = db_query($link, "SELECT
+               $result = db_query( "SELECT
                        value,ttrss_prefs_types.type_name as type_name,ttrss_prefs.pref_name AS pref_name
                        FROM
                                ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types
@@ -42,9 +42,9 @@
                }
        }
 
-       function get_pref($link, $pref_name, $user_id = false, $die_on_error = false) {
+       function get_pref( $pref_name, $user_id = false, $die_on_error = false) {
 
-               $pref_name = db_escape_string($link, $pref_name);
+               $pref_name = db_escape_string( $pref_name);
                $prefs_cache = true;
                $profile = false;
 
@@ -69,9 +69,9 @@
                        $profile_qpart = "profile IS NULL AND";
                }
 
-               if (get_schema_version($link) < 63) $profile_qpart = "";
+               if (get_schema_version() < 63) $profile_qpart = "";
 
-               $result = db_query($link, "SELECT
+               $result = db_query( "SELECT
                        value,ttrss_prefs_types.type_name as type_name
                        FROM
                                ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types
                }
        }
 
-       function set_pref($link, $pref_name, $value, $user_id = false, $strip_tags = true) {
-               $pref_name = db_escape_string($link, $pref_name);
-               $value = db_escape_string($link, $value, $strip_tags);
+       function set_pref( $pref_name, $value, $user_id = false, $strip_tags = true) {
+               $pref_name = db_escape_string( $pref_name);
+               $value = db_escape_string( $value, $strip_tags);
 
                if (!$user_id) {
                        $user_id = $_SESSION["uid"];
                        $profile_qpart = "AND profile IS NULL";
                }
 
-               if (get_schema_version($link) < 63) $profile_qpart = "";
+               if (get_schema_version() < 63) $profile_qpart = "";
 
                $type_name = "";
                $current_value = "";
                }
 
                if (!$type_name) {
-                       $result = db_query($link, "SELECT type_name
+                       $result = db_query( "SELECT type_name
                                FROM ttrss_prefs,ttrss_prefs_types
                                WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id");
 
                                $value = 'UTC';
                        }
 
-                       db_query($link, "UPDATE ttrss_user_prefs SET
+                       db_query( "UPDATE ttrss_user_prefs SET
                                value = '$value' WHERE pref_name = '$pref_name'
                                        $profile_qpart
                                        AND owner_uid = " . $_SESSION["uid"]);
index cfa4ccda5b17948031b1d2e2a607998d516f89f8..11e7312ad1ee04ff646ec5f521e5fb0ceed9aa44 100644 (file)
@@ -4,11 +4,11 @@ function db_connect($host, $user, $pass, $db) {
        return Db::get()->connect($host, $user, $pass, $db, 0);
 }
 
-function db_escape_string($link, $s, $strip_tags = true) {
+function db_escape_string( $s, $strip_tags = true) {
        return Db::get()->escape_string($s, $strip_tags);
 }
 
-function db_query($link, $query, $die_on_error = true) {
+function db_query( $query, $die_on_error = true) {
        return Db::get()->query($query, $die_on_error);
 }
 
@@ -25,15 +25,15 @@ function db_fetch_result($result, $row, $param) {
        return Db::get()->fetch_result($result, $row, $param);
 }
 
-function db_close($link) {
+function db_close() {
        return Db::get()->close();
 }
 
-function db_affected_rows($link, $result) {
+function db_affected_rows( $result) {
        return Db::get()->affected_rows($result);
 }
 
-function db_last_error($link) {
+function db_last_error() {
        return Db::get()->last_error();
 }
 
index 34b69909474226cbd733b7d6fe7c1cbdc73f9a25..a3f414271a3ae3902ffa56e13bdde4a3b90d0209 100644 (file)
@@ -6,7 +6,7 @@
         * @param integer $limit The maximum number of articles by digest.
         * @return boolean Return false if digests are not enabled.
         */
-       function send_headlines_digests($link, $debug = false) {
+       function send_headlines_digests( $debug = false) {
 
                require_once 'classes/ttrssmailer.php';
 
                        $interval_query = "last_digest_sent < DATE_SUB(NOW(), INTERVAL 1 DAY)";
                }
 
-               $result = db_query($link, "SELECT id,email FROM ttrss_users
+               $result = db_query( "SELECT id,email FROM ttrss_users
                                WHERE email != '' AND (last_digest_sent IS NULL OR $interval_query)");
 
                while ($line = db_fetch_assoc($result)) {
 
-                       if (get_pref($link, 'DIGEST_ENABLE', $line['id'], false)) {
-                               $preferred_ts = strtotime(get_pref($link, 'DIGEST_PREFERRED_TIME', $line['id'], '00:00'));
+                       if (get_pref( 'DIGEST_ENABLE', $line['id'], false)) {
+                               $preferred_ts = strtotime(get_pref( 'DIGEST_PREFERRED_TIME', $line['id'], '00:00'));
 
                                // try to send digests within 2 hours of preferred time
                                if ($preferred_ts && time() >= $preferred_ts &&
 
                                        if ($debug) _debug("Sending digest for UID:" . $line['id'] . " - " . $line["email"]);
 
-                                       $do_catchup = get_pref($link, 'DIGEST_CATCHUP', $line['id'], false);
+                                       $do_catchup = get_pref( 'DIGEST_CATCHUP', $line['id'], false);
 
                                        global $tz_offset;
 
                                        // reset tz_offset global to prevent tz cache clash between users
                                        $tz_offset = -1;
 
-                                       $tuple = prepare_headlines_digest($link, $line["id"], 1, $limit);
+                                       $tuple = prepare_headlines_digest( $line["id"], 1, $limit);
                                        $digest = $tuple[0];
                                        $headlines_count = $tuple[1];
                                        $affected_ids = $tuple[2];
 
                                                if ($rc && $do_catchup) {
                                                        if ($debug) _debug("Marking affected articles as read...");
-                                                       catchupArticlesById($link, $affected_ids, 0, $line["id"]);
+                                                       catchupArticlesById( $affected_ids, 0, $line["id"]);
                                                }
                                        } else {
                                                if ($debug) _debug("No headlines");
                                        }
 
-                                       db_query($link, "UPDATE ttrss_users SET last_digest_sent = NOW()
+                                       db_query( "UPDATE ttrss_users SET last_digest_sent = NOW()
                                                WHERE id = " . $line["id"]);
 
                                }
@@ -77,7 +77,7 @@
 
        }
 
-       function prepare_headlines_digest($link, $user_id, $days = 1, $limit = 1000) {
+       function prepare_headlines_digest( $user_id, $days = 1, $limit = 1000) {
 
                require_once "lib/MiniTemplator.class.php";
 
@@ -87,7 +87,7 @@
                $tpl->readTemplateFromFile("templates/digest_template_html.txt");
                $tpl_t->readTemplateFromFile("templates/digest_template.txt");
 
-               $user_tz_string = get_pref($link, 'USER_TIMEZONE', $user_id);
+               $user_tz_string = get_pref( 'USER_TIMEZONE', $user_id);
                $local_ts = convert_timestamp(time(), 'UTC', $user_tz_string);
 
                $tpl->setVariable('CUR_DATE', date('Y/m/d', $local_ts));
                        $interval_query = "ttrss_entries.date_updated > DATE_SUB(NOW(), INTERVAL $days DAY)";
                }
 
-               $result = db_query($link, "SELECT ttrss_entries.title,
+               $result = db_query( "SELECT ttrss_entries.title,
                                ttrss_feeds.title AS feed_title,
                                COALESCE(ttrss_feed_categories.title, '".__('Uncategorized')."') AS cat_title,
                                date_updated,
 
                        array_push($affected_ids, $line["ref_id"]);
 
-                       $updated = make_local_datetime($link, $line['last_updated'], false,
+                       $updated = make_local_datetime( $line['last_updated'], false,
                                $user_id);
 
 /*                     if ($line["score"] != 0) {
                                $line["title"] .= " (".$line['score'].")";
                        } */
 
-                       if (get_pref($link, 'ENABLE_FEED_CATS', $user_id)) {
+                       if (get_pref( 'ENABLE_FEED_CATS', $user_id)) {
                                $line['feed_title'] = $line['cat_title'] . " / " . $line['feed_title'];
                        }
 
index e5ee4a70d6f96472a2711cee556bfc193a3608ce..7bafe68acec7100844d1dd6ef7989d695c680a40 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-       function make_feed_browser($link, $search, $limit, $mode = 1) {
+       function make_feed_browser( $search, $limit, $mode = 1) {
 
                $owner_uid = $_SESSION["uid"];
                $rv = '';
                }
 
                if ($mode == 1) {
-                       /* $result = db_query($link, "SELECT feed_url, subscribers FROM
+                       /* $result = db_query( "SELECT feed_url, subscribers FROM
                         ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
                        WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
                        AND owner_uid = '$owner_uid') $search_qpart
                        ORDER BY subscribers DESC LIMIT $limit"); */
 
-                       $result = db_query($link, "SELECT feed_url, site_url, title, SUM(subscribers) AS subscribers FROM
+                       $result = db_query( "SELECT feed_url, site_url, title, SUM(subscribers) AS subscribers FROM
                                                (SELECT feed_url, site_url, title, subscribers FROM ttrss_feedbrowser_cache UNION ALL
                                                        SELECT feed_url, site_url, title, subscribers FROM ttrss_linked_feeds) AS qqq
                                                WHERE
@@ -28,7 +28,7 @@
                                                GROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT $limit");
 
                } else if ($mode == 2) {
-                       $result = db_query($link, "SELECT *,
+                       $result = db_query( "SELECT *,
                                                (SELECT COUNT(*) FROM ttrss_user_entries WHERE
                                                        orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
                                                FROM
index f0d5e85faf8325250ae1dc24d16b21f2ebfeabe3..971c61e2f4e5e54bd9d81c1105f84ee66fd95e1e 100644 (file)
         * @access public
         * @return void
         */
-       function purge_feed($link, $feed_id, $purge_interval, $debug = false) {
+       function purge_feed( $feed_id, $purge_interval, $debug = false) {
 
-               if (!$purge_interval) $purge_interval = feed_purge_interval($link, $feed_id);
+               if (!$purge_interval) $purge_interval = feed_purge_interval( $feed_id);
 
                $rows = -1;
 
-               $result = db_query($link,
+               $result = db_query(
                        "SELECT owner_uid FROM ttrss_feeds WHERE id = '$feed_id'");
 
                $owner_uid = false;
 
                if ($purge_interval == -1 || !$purge_interval) {
                        if ($owner_uid) {
-                               ccache_update($link, $feed_id, $owner_uid);
+                               ccache_update( $feed_id, $owner_uid);
                        }
                        return;
                }
                if (!$owner_uid) return;
 
                if (FORCE_ARTICLE_PURGE == 0) {
-                       $purge_unread = get_pref($link, "PURGE_UNREAD_ARTICLES",
+                       $purge_unread = get_pref( "PURGE_UNREAD_ARTICLES",
                                $owner_uid, false);
                } else {
                        $purge_unread = true;
                if (!$purge_unread) $query_limit = " unread = false AND ";
 
                if (DB_TYPE == "pgsql") {
-                       $pg_version = get_pgsql_version($link);
+                       $pg_version = get_pgsql_version();
 
                        if (preg_match("/^7\./", $pg_version) || preg_match("/^8\.0/", $pg_version)) {
 
-                               $result = db_query($link, "DELETE FROM ttrss_user_entries WHERE
+                               $result = db_query( "DELETE FROM ttrss_user_entries WHERE
                                        ttrss_entries.id = ref_id AND
                                        marked = false AND
                                        feed_id = '$feed_id' AND
 
                        } else {
 
-                               $result = db_query($link, "DELETE FROM ttrss_user_entries
+                               $result = db_query( "DELETE FROM ttrss_user_entries
                                        USING ttrss_entries
                                        WHERE ttrss_entries.id = ref_id AND
                                        marked = false AND
 
                } else {
 
-/*                     $result = db_query($link, "DELETE FROM ttrss_user_entries WHERE
+/*                     $result = db_query( "DELETE FROM ttrss_user_entries WHERE
                                marked = false AND feed_id = '$feed_id' AND
                                (SELECT date_updated FROM ttrss_entries WHERE
                                        id = ref_id) < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)"); */
 
-                       $result = db_query($link, "DELETE FROM ttrss_user_entries
+                       $result = db_query( "DELETE FROM ttrss_user_entries
                                USING ttrss_user_entries, ttrss_entries
                                WHERE ttrss_entries.id = ref_id AND
                                marked = false AND
                                $query_limit
                                ttrss_entries.date_updated < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
 
-                       $rows = mysql_affected_rows($link);
+                       $rows = mysql_affected_rows();
 
                }
 
-               ccache_update($link, $feed_id, $owner_uid);
+               ccache_update( $feed_id, $owner_uid);
 
                if ($debug) {
                        _debug("Purged feed $feed_id ($purge_interval): deleted $rows articles");
                return $rows;
        } // function purge_feed
 
-       function feed_purge_interval($link, $feed_id) {
+       function feed_purge_interval( $feed_id) {
 
-               $result = db_query($link, "SELECT purge_interval, owner_uid FROM ttrss_feeds
+               $result = db_query( "SELECT purge_interval, owner_uid FROM ttrss_feeds
                        WHERE id = '$feed_id'");
 
                if (db_num_rows($result) == 1) {
                        $purge_interval = db_fetch_result($result, 0, "purge_interval");
                        $owner_uid = db_fetch_result($result, 0, "owner_uid");
 
-                       if ($purge_interval == 0) $purge_interval = get_pref($link,
+                       if ($purge_interval == 0) $purge_interval = get_pref(
                                'PURGE_OLD_DAYS', $owner_uid);
 
                        return $purge_interval;
                }
        }
 
-       function purge_orphans($link, $do_output = false) {
+       function purge_orphans( $do_output = false) {
 
                // purge orphaned posts in main content table
-               $result = db_query($link, "DELETE FROM ttrss_entries WHERE
+               $result = db_query( "DELETE FROM ttrss_entries WHERE
                        (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0");
 
                if ($do_output) {
-                       $rows = db_affected_rows($link, $result);
+                       $rows = db_affected_rows( $result);
                        _debug("Purged $rows orphaned posts.");
                }
        }
 
-       function get_feed_update_interval($link, $feed_id) {
-               $result = db_query($link, "SELECT owner_uid, update_interval FROM
+       function get_feed_update_interval( $feed_id) {
+               $result = db_query( "SELECT owner_uid, update_interval FROM
                        ttrss_feeds WHERE id = '$feed_id'");
 
                if (db_num_rows($result) == 1) {
                        if ($update_interval != 0) {
                                return $update_interval;
                        } else {
-                               return get_pref($link, 'DEFAULT_UPDATE_INTERVAL', $owner_uid, false);
+                               return get_pref( 'DEFAULT_UPDATE_INTERVAL', $owner_uid, false);
                        }
 
                } else {
                return $favicon_url;
        } // function get_favicon_url
 
-       function check_feed_favicon($site_url, $feed, $link) {
+       function check_feed_favicon($site_url, $feed) {
 #              print "FAVICON [$site_url]: $favicon_url\n";
 
                $icon_file = ICONS_DIR . "/$feed.ico";
                }
        }
 
-       function initialize_user_prefs($link, $uid, $profile = false) {
+       function initialize_user_prefs( $uid, $profile = false) {
 
-               $uid = db_escape_string($link, $uid);
+               $uid = db_escape_string( $uid);
 
                if (!$profile) {
                        $profile = "NULL";
                        $profile_qpart = "AND profile = '$profile'";
                }
 
-               if (get_schema_version($link) < 63) $profile_qpart = "";
+               if (get_schema_version() < 63) $profile_qpart = "";
 
-               db_query($link, "BEGIN");
+               db_query( "BEGIN");
 
-               $result = db_query($link, "SELECT pref_name,def_value FROM ttrss_prefs");
+               $result = db_query( "SELECT pref_name,def_value FROM ttrss_prefs");
 
-               $u_result = db_query($link, "SELECT pref_name
+               $u_result = db_query( "SELECT pref_name
                        FROM ttrss_user_prefs WHERE owner_uid = '$uid' $profile_qpart");
 
                $active_prefs = array();
                        if (array_search($line["pref_name"], $active_prefs) === FALSE) {
 //                             print "adding " . $line["pref_name"] . "<br>";
 
-                               $line["def_value"] = db_escape_string($link, $line["def_value"]);
-                               $line["pref_name"] = db_escape_string($link, $line["pref_name"]);
+                               $line["def_value"] = db_escape_string( $line["def_value"]);
+                               $line["pref_name"] = db_escape_string( $line["pref_name"]);
 
-                               if (get_schema_version($link) < 63) {
-                                       db_query($link, "INSERT INTO ttrss_user_prefs
+                               if (get_schema_version() < 63) {
+                                       db_query( "INSERT INTO ttrss_user_prefs
                                                (owner_uid,pref_name,value) VALUES
                                                ('$uid', '".$line["pref_name"]."','".$line["def_value"]."')");
 
                                } else {
-                                       db_query($link, "INSERT INTO ttrss_user_prefs
+                                       db_query( "INSERT INTO ttrss_user_prefs
                                                (owner_uid,pref_name,value, profile) VALUES
                                                ('$uid', '".$line["pref_name"]."','".$line["def_value"]."', $profile)");
                                }
                        }
                }
 
-               db_query($link, "COMMIT");
+               db_query( "COMMIT");
 
        }
 
                return "";
        }
 
-       function authenticate_user($link, $login, $password, $check_only = false) {
+       function authenticate_user( $login, $password, $check_only = false) {
 
                if (!SINGLE_USER_MODE) {
                        $user_id = false;
                                $_SESSION["uid"] = $user_id;
                                $_SESSION["version"] = VERSION;
 
-                               $result = db_query($link, "SELECT login,access_level,pwd_hash FROM ttrss_users
+                               $result = db_query( "SELECT login,access_level,pwd_hash FROM ttrss_users
                                        WHERE id = '$user_id'");
 
                                $_SESSION["name"] = db_fetch_result($result, 0, "login");
                                $_SESSION["access_level"] = db_fetch_result($result, 0, "access_level");
                                $_SESSION["csrf_token"] = sha1(uniqid(rand(), true));
 
-                               db_query($link, "UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
+                               db_query( "UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
                                        $_SESSION["uid"]);
 
                                $_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"];
 
                                $_SESSION["last_version_check"] = time();
 
-                               initialize_user_prefs($link, $_SESSION["uid"]);
+                               initialize_user_prefs( $_SESSION["uid"]);
 
                                return true;
                        }
 
                        $_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"];
 
-                       initialize_user_prefs($link, $_SESSION["uid"]);
+                       initialize_user_prefs( $_SESSION["uid"]);
 
                        return true;
                }
 
        // user preferences are checked on every login, not here
 
-       function initialize_user($link, $uid) {
+       function initialize_user( $uid) {
 
-               db_query($link, "insert into ttrss_feeds (owner_uid,title,feed_url)
+               db_query( "insert into ttrss_feeds (owner_uid,title,feed_url)
                        values ('$uid', 'Tiny Tiny RSS: New Releases',
                        'http://tt-rss.org/releases.rss')");
 
-               db_query($link, "insert into ttrss_feeds (owner_uid,title,feed_url)
+               db_query( "insert into ttrss_feeds (owner_uid,title,feed_url)
                        values ('$uid', 'Tiny Tiny RSS: Forum',
                                'http://tt-rss.org/forum/rss.php')");
        }
                return $csrf_token == $_SESSION['csrf_token'];
        }
 
-       function load_user_plugins($link, $owner_uid) {
+       function load_user_plugins( $owner_uid) {
                if ($owner_uid) {
-                       $plugins = get_pref($link, "_ENABLED_PLUGINS", $owner_uid);
+                       $plugins = get_pref( "_ENABLED_PLUGINS", $owner_uid);
 
                        global $pluginhost;
                        $pluginhost->load($plugins, $pluginhost::KIND_USER, $owner_uid);
 
-                       if (get_schema_version($link) > 100) {
+                       if (get_schema_version() > 100) {
                                $pluginhost->load_data();
                        }
                }
        }
 
-       function login_sequence($link) {
+       function login_sequence() {
                $_SESSION["prefs_cache"] = false;
 
                if (SINGLE_USER_MODE) {
                        @session_start();
-                       authenticate_user($link, "admin", null);
-                       cache_prefs($link);
-                       load_user_plugins($link, $_SESSION["uid"]);
+                       authenticate_user( "admin", null);
+                       cache_prefs();
+                       load_user_plugins( $_SESSION["uid"]);
                } else {
-                       if (!validate_session($link)) $_SESSION["uid"] = false;
+                       if (!validate_session()) $_SESSION["uid"] = false;
 
                        if (!$_SESSION["uid"]) {
 
-                               if (AUTH_AUTO_LOGIN && authenticate_user($link, null, null)) {
-                                   $_SESSION["ref_schema_version"] = get_schema_version($link, true);
+                               if (AUTH_AUTO_LOGIN && authenticate_user( null, null)) {
+                                   $_SESSION["ref_schema_version"] = get_schema_version( true);
                                } else {
-                                        authenticate_user($link, null, null, true);
+                                        authenticate_user( null, null, true);
                                }
 
                                if (!$_SESSION["uid"]) {
                                        @session_destroy();
                                        setcookie(session_name(), '', time()-42000, '/');
 
-                                       render_login_form($link);
+                                       render_login_form();
                                        exit;
                                }
 
                        } else {
                                /* bump login timestamp */
-                               db_query($link, "UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
+                               db_query( "UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
                                        $_SESSION["uid"]);
                                $_SESSION["last_login_update"] = time();
                        }
                        }
 
                        if ($_SESSION["uid"]) {
-                               cache_prefs($link);
-                               load_user_plugins($link, $_SESSION["uid"]);
+                               cache_prefs();
+                               load_user_plugins( $_SESSION["uid"]);
 
                                /* cleanup ccache */
 
-                               db_query($link, "DELETE FROM ttrss_counters_cache WHERE owner_uid = ".
+                               db_query( "DELETE FROM ttrss_counters_cache WHERE owner_uid = ".
                                        $_SESSION["uid"] . " AND
                                                (SELECT COUNT(id) FROM ttrss_feeds WHERE
                                                        ttrss_feeds.id = feed_id) = 0");
 
-                               db_query($link, "DELETE FROM ttrss_cat_counters_cache WHERE owner_uid = ".
+                               db_query( "DELETE FROM ttrss_cat_counters_cache WHERE owner_uid = ".
                                        $_SESSION["uid"] . " AND
                                                (SELECT COUNT(id) FROM ttrss_feed_categories WHERE
                                                        ttrss_feed_categories.id = feed_id) = 0");
                return $dt->format('U') + $dest_tz->getOffset($dt);
        }
 
-       function make_local_datetime($link, $timestamp, $long, $owner_uid = false,
+       function make_local_datetime( $timestamp, $long, $owner_uid = false,
                                        $no_smart_dt = false) {
 
                if (!$owner_uid) $owner_uid = $_SESSION['uid'];
 
                if ($tz_offset == -1) {
 
-                       $user_tz_string = get_pref($link, 'USER_TIMEZONE', $owner_uid);
+                       $user_tz_string = get_pref( 'USER_TIMEZONE', $owner_uid);
 
                        try {
                                $user_tz = new DateTimeZone($user_tz_string);
                $user_timestamp = $dt->format('U') + $tz_offset;
 
                if (!$no_smart_dt) {
-                       return smart_date_time($link, $user_timestamp,
+                       return smart_date_time( $user_timestamp,
                                $tz_offset, $owner_uid);
                } else {
                        if ($long)
-                               $format = get_pref($link, 'LONG_DATE_FORMAT', $owner_uid);
+                               $format = get_pref( 'LONG_DATE_FORMAT', $owner_uid);
                        else
-                               $format = get_pref($link, 'SHORT_DATE_FORMAT', $owner_uid);
+                               $format = get_pref( 'SHORT_DATE_FORMAT', $owner_uid);
 
                        return date($format, $user_timestamp);
                }
        }
 
-       function smart_date_time($link, $timestamp, $tz_offset = 0, $owner_uid = false) {
+       function smart_date_time( $timestamp, $tz_offset = 0, $owner_uid = false) {
                if (!$owner_uid) $owner_uid = $_SESSION['uid'];
 
                if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) {
                        return date("G:i", $timestamp);
                } else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) {
-                       $format = get_pref($link, 'SHORT_DATE_FORMAT', $owner_uid);
+                       $format = get_pref( 'SHORT_DATE_FORMAT', $owner_uid);
                        return date($format, $timestamp);
                } else {
-                       $format = get_pref($link, 'LONG_DATE_FORMAT', $owner_uid);
+                       $format = get_pref( 'LONG_DATE_FORMAT', $owner_uid);
                        return date($format, $timestamp);
                }
        }
        // Session caching removed due to causing wrong redirects to upgrade
        // script when get_schema_version() is called on an obsolete session
        // created on a previous schema version.
-       function get_schema_version($link, $nocache = false) {
+       function get_schema_version( $nocache = false) {
                global $schema_version;
 
                if (!$schema_version) {
-                       $result = db_query($link, "SELECT schema_version FROM ttrss_version");
+                       $result = db_query( "SELECT schema_version FROM ttrss_version");
                        $version = db_fetch_result($result, 0, "schema_version");
                        $schema_version = $version;
                        return $version;
                }
        }
 
-       function sanity_check($link) {
+       function sanity_check() {
                require_once 'errors.php';
 
                $error_code = 0;
-               $schema_version = get_schema_version($link, true);
+               $schema_version = get_schema_version( true);
 
                if ($schema_version != SCHEMA_VERSION) {
                        $error_code = 5;
                }
 
                if (DB_TYPE == "mysql") {
-                       $result = db_query($link, "SELECT true", false);
+                       $result = db_query( "SELECT true", false);
                        if (db_num_rows($result) != 1) {
                                $error_code = 10;
                        }
                }
 
-               if (db_escape_string($link, "testTEST") != "testTEST") {
+               if (db_escape_string( "testTEST") != "testTEST") {
                        $error_code = 12;
                }
 
                }
        }
 
-       function catchup_feed($link, $feed, $cat_view, $owner_uid = false, $max_id = false, $mode = 'all') {
+       function catchup_feed( $feed, $cat_view, $owner_uid = false, $max_id = false, $mode = 'all') {
 
                        if (!$owner_uid) $owner_uid = $_SESSION['uid'];
 
                                        if ($feed >= 0) {
 
                                                if ($feed > 0) {
-                                                       $children = getChildCategories($link, $feed, $owner_uid);
+                                                       $children = getChildCategories( $feed, $owner_uid);
                                                        array_push($children, $feed);
 
                                                        $children = join(",", $children);
                                                        $cat_qpart = "cat_id IS NULL";
                                                }
 
-                                               db_query($link, "UPDATE ttrss_user_entries
+                                               db_query( "UPDATE ttrss_user_entries
                                                        SET unread = false, last_read = NOW() WHERE ref_id IN
                                                                (SELECT id FROM
                                                                        (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
 
                                        } else if ($feed == -2) {
 
-                                               db_query($link, "UPDATE ttrss_user_entries
+                                               db_query( "UPDATE ttrss_user_entries
                                                        SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*)
                                                                FROM ttrss_user_labels2 WHERE article_id = ref_id) > 0
                                                                AND unread = true AND $date_qpart AND owner_uid = $owner_uid");
 
                                } else if ($feed > 0) {
 
-                                       db_query($link, "UPDATE ttrss_user_entries
+                                       db_query( "UPDATE ttrss_user_entries
                                                SET unread = false, last_read = NOW() WHERE ref_id IN
                                                        (SELECT id FROM
                                                                (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
                                } else if ($feed < 0 && $feed > LABEL_BASE_INDEX) { // special, like starred
 
                                        if ($feed == -1) {
-                                               db_query($link, "UPDATE ttrss_user_entries
+                                               db_query( "UPDATE ttrss_user_entries
                                                        SET unread = false, last_read = NOW() WHERE ref_id IN
                                                                (SELECT id FROM
                                                                        (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
                                        }
 
                                        if ($feed == -2) {
-                                               db_query($link, "UPDATE ttrss_user_entries
+                                               db_query( "UPDATE ttrss_user_entries
                                                        SET unread = false, last_read = NOW() WHERE ref_id IN
                                                                (SELECT id FROM
                                                                        (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
 
                                        if ($feed == -3) {
 
-                                               $intl = get_pref($link, "FRESH_ARTICLE_MAX_AGE");
+                                               $intl = get_pref( "FRESH_ARTICLE_MAX_AGE");
 
                                                if (DB_TYPE == "pgsql") {
                                                        $match_part = "date_entered > NOW() - INTERVAL '$intl hour' ";
                                                                INTERVAL $intl HOUR) ";
                                                }
 
-                                               db_query($link, "UPDATE ttrss_user_entries
+                                               db_query( "UPDATE ttrss_user_entries
                                                        SET unread = false, last_read = NOW() WHERE ref_id IN
                                                                (SELECT id FROM
                                                                        (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
                                        }
 
                                        if ($feed == -4) {
-                                               db_query($link, "UPDATE ttrss_user_entries
+                                               db_query( "UPDATE ttrss_user_entries
                                                        SET unread = false, last_read = NOW() WHERE ref_id IN
                                                                (SELECT id FROM
                                                                        (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
 
                                        $label_id = feed_to_label_id($feed);
 
-                                       db_query($link, "UPDATE ttrss_user_entries
+                                       db_query( "UPDATE ttrss_user_entries
                                                SET unread = false, last_read = NOW() WHERE ref_id IN
                                                        (SELECT id FROM
                                                                (SELECT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_user_labels2 WHERE ref_id = id
 
                                }
 
-                               ccache_update($link, $feed, $owner_uid, $cat_view);
+                               ccache_update( $feed, $owner_uid, $cat_view);
 
                        } else { // tag
-                               db_query($link, "UPDATE ttrss_user_entries
+                               db_query( "UPDATE ttrss_user_entries
                                        SET unread = false, last_read = NOW() WHERE ref_id IN
                                                (SELECT id FROM
                                                        (SELECT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_tags WHERE ref_id = ttrss_entries.id
                        }
        }
 
-       function getAllCounters($link) {
-               $data = getGlobalCounters($link);
+       function getAllCounters() {
+               $data = getGlobalCounters();
 
-               $data = array_merge($data, getVirtCounters($link));
-               $data = array_merge($data, getLabelCounters($link));
-               $data = array_merge($data, getFeedCounters($link, $active_feed));
-               $data = array_merge($data, getCategoryCounters($link));
+               $data = array_merge($data, getVirtCounters());
+               $data = array_merge($data, getLabelCounters());
+               $data = array_merge($data, getFeedCounters( $active_feed));
+               $data = array_merge($data, getCategoryCounters());
 
                return $data;
        }
 
-       function getCategoryTitle($link, $cat_id) {
+       function getCategoryTitle( $cat_id) {
 
                if ($cat_id == -1) {
                        return __("Special");
                        return __("Labels");
                } else {
 
-                       $result = db_query($link, "SELECT title FROM ttrss_feed_categories WHERE
+                       $result = db_query( "SELECT title FROM ttrss_feed_categories WHERE
                                id = '$cat_id'");
 
                        if (db_num_rows($result) == 1) {
        }
 
 
-       function getCategoryCounters($link) {
+       function getCategoryCounters() {
                $ret_arr = array();
 
                /* Labels category */
 
                $cv = array("id" => -2, "kind" => "cat",
-                       "counter" => getCategoryUnread($link, -2));
+                       "counter" => getCategoryUnread( -2));
 
                array_push($ret_arr, $cv);
 
-               $result = db_query($link, "SELECT id AS cat_id, value AS unread,
+               $result = db_query( "SELECT id AS cat_id, value AS unread,
                        (SELECT COUNT(id) FROM ttrss_feed_categories AS c2
                                WHERE c2.parent_cat = ttrss_feed_categories.id) AS num_children
                        FROM ttrss_feed_categories, ttrss_cat_counters_cache
                        $line["cat_id"] = (int) $line["cat_id"];
 
                        if ($line["num_children"] > 0) {
-                               $child_counter = getCategoryChildrenUnread($link, $line["cat_id"], $_SESSION["uid"]);
+                               $child_counter = getCategoryChildrenUnread( $line["cat_id"], $_SESSION["uid"]);
                        } else {
                                $child_counter = 0;
                        }
                /* Special case: NULL category doesn't actually exist in the DB */
 
                $cv = array("id" => 0, "kind" => "cat",
-                       "counter" => (int) ccache_find($link, 0, $_SESSION["uid"], true));
+                       "counter" => (int) ccache_find( 0, $_SESSION["uid"], true));
 
                array_push($ret_arr, $cv);
 
        }
 
        // only accepts real cats (>= 0)
-       function getCategoryChildrenUnread($link, $cat, $owner_uid = false) {
+       function getCategoryChildrenUnread( $cat, $owner_uid = false) {
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
 
-               $result = db_query($link, "SELECT id FROM ttrss_feed_categories WHERE parent_cat = '$cat'
+               $result = db_query( "SELECT id FROM ttrss_feed_categories WHERE parent_cat = '$cat'
                                AND owner_uid = $owner_uid");
 
                $unread = 0;
 
                while ($line = db_fetch_assoc($result)) {
-                       $unread += getCategoryUnread($link, $line["id"], $owner_uid);
-                       $unread += getCategoryChildrenUnread($link, $line["id"], $owner_uid);
+                       $unread += getCategoryUnread( $line["id"], $owner_uid);
+                       $unread += getCategoryChildrenUnread( $line["id"], $owner_uid);
                }
 
                return $unread;
        }
 
-       function getCategoryUnread($link, $cat, $owner_uid = false) {
+       function getCategoryUnread( $cat, $owner_uid = false) {
 
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
 
                                $cat_query = "cat_id IS NULL";
                        }
 
-                       $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE $cat_query
+                       $result = db_query( "SELECT id FROM ttrss_feeds WHERE $cat_query
                                        AND owner_uid = " . $owner_uid);
 
                        $cat_feeds = array();
 
                        $match_part = implode(" OR ", $cat_feeds);
 
-                       $result = db_query($link, "SELECT COUNT(int_id) AS unread
+                       $result = db_query( "SELECT COUNT(int_id) AS unread
                                FROM ttrss_user_entries
                                WHERE   unread = true AND ($match_part)
                                AND owner_uid = " . $owner_uid);
 
                        return $unread;
                } else if ($cat == -1) {
-                       return getFeedUnread($link, -1) + getFeedUnread($link, -2) + getFeedUnread($link, -3) + getFeedUnread($link, 0);
+                       return getFeedUnread( -1) + getFeedUnread($link, -2) + getFeedUnread($link, -3) + getFeedUnread($link, 0);
                } else if ($cat == -2) {
 
-                       $result = db_query($link, "
+                       $result = db_query( "
                                SELECT COUNT(unread) AS unread FROM
                                        ttrss_user_entries, ttrss_user_labels2
                                WHERE article_id = ref_id AND unread = true
                }
        }
 
-       function getFeedUnread($link, $feed, $is_cat = false) {
-               return getFeedArticles($link, $feed, $is_cat, true, $_SESSION["uid"]);
+       function getFeedUnread( $feed, $is_cat = false) {
+               return getFeedArticles( $feed, $is_cat, true, $_SESSION["uid"]);
        }
 
-       function getLabelUnread($link, $label_id, $owner_uid = false) {
+       function getLabelUnread( $label_id, $owner_uid = false) {
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
 
-               $result = db_query($link, "SELECT COUNT(ref_id) AS unread FROM ttrss_user_entries, ttrss_user_labels2
+               $result = db_query( "SELECT COUNT(ref_id) AS unread FROM ttrss_user_entries, ttrss_user_labels2
                        WHERE owner_uid = '$owner_uid' AND unread = true AND label_id = '$label_id' AND article_id = ref_id");
 
                if (db_num_rows($result) != 0) {
                }
        }
 
-       function getFeedArticles($link, $feed, $is_cat = false, $unread_only = false,
+       function getFeedArticles( $feed, $is_cat = false, $unread_only = false,
                $owner_uid = false) {
 
                $n_feed = (int) $feed;
                }
 
                if ($is_cat) {
-                       return getCategoryUnread($link, $n_feed, $owner_uid);
+                       return getCategoryUnread( $n_feed, $owner_uid);
                } else if ($n_feed == -6) {
                        return 0;
                } else if ($feed != "0" && $n_feed == 0) {
 
-                       $feed = db_escape_string($link, $feed);
+                       $feed = db_escape_string( $feed);
 
-                       $result = db_query($link, "SELECT SUM((SELECT COUNT(int_id)
+                       $result = db_query( "SELECT SUM((SELECT COUNT(int_id)
                                FROM ttrss_user_entries,ttrss_entries WHERE int_id = post_int_id
                                        AND ref_id = id AND $unread_qpart)) AS count FROM ttrss_tags
                                WHERE owner_uid = $owner_uid AND tag_name = '$feed'");
                } else if ($n_feed == -3) {
                        $match_part = "unread = true AND score >= 0";
 
-                       $intl = get_pref($link, "FRESH_ARTICLE_MAX_AGE", $owner_uid);
+                       $intl = get_pref( "FRESH_ARTICLE_MAX_AGE", $owner_uid);
 
                        if (DB_TYPE == "pgsql") {
                                $match_part .= " AND updated > NOW() - INTERVAL '$intl hour' ";
 
                        $label_id = feed_to_label_id($feed);
 
-                       return getLabelUnread($link, $label_id, $owner_uid);
+                       return getLabelUnread( $label_id, $owner_uid);
 
                }
 
 
                        //echo "[$feed/$query]\n";
 
-                       $result = db_query($link, $query);
+                       $result = db_query( $query);
 
                } else {
 
-                       $result = db_query($link, "SELECT COUNT(post_int_id) AS unread
+                       $result = db_query( "SELECT COUNT(post_int_id) AS unread
                                FROM ttrss_tags,ttrss_user_entries,ttrss_entries
                                WHERE tag_name = '$feed' AND post_int_id = int_id AND ref_id = ttrss_entries.id
                                AND $unread_qpart AND ttrss_tags.owner_uid = " . $owner_uid);
                return $unread;
        }
 
-       function getGlobalUnread($link, $user_id = false) {
+       function getGlobalUnread( $user_id = false) {
 
                if (!$user_id) {
                        $user_id = $_SESSION["uid"];
                }
 
-               $result = db_query($link, "SELECT SUM(value) AS c_id FROM ttrss_counters_cache
+               $result = db_query( "SELECT SUM(value) AS c_id FROM ttrss_counters_cache
                        WHERE owner_uid = '$user_id' AND feed_id > 0");
 
                $c_id = db_fetch_result($result, 0, "c_id");
                return $c_id;
        }
 
-       function getGlobalCounters($link, $global_unread = -1) {
+       function getGlobalCounters( $global_unread = -1) {
                $ret_arr = array();
 
                if ($global_unread == -1) {
-                       $global_unread = getGlobalUnread($link);
+                       $global_unread = getGlobalUnread();
                }
 
                $cv = array("id" => "global-unread",
 
                array_push($ret_arr, $cv);
 
-               $result = db_query($link, "SELECT COUNT(id) AS fn FROM
+               $result = db_query( "SELECT COUNT(id) AS fn FROM
                        ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
 
                $subscribed_feeds = db_fetch_result($result, 0, "fn");
                return $ret_arr;
        }
 
-       function getVirtCounters($link) {
+       function getVirtCounters() {
 
                $ret_arr = array();
 
                for ($i = 0; $i >= -4; $i--) {
 
-                       $count = getFeedUnread($link, $i);
+                       $count = getFeedUnread( $i);
 
                        $cv = array("id" => $i,
                                "counter" => (int) $count);
 
-//                     if (get_pref($link, 'EXTENDED_FEEDLIST'))
-//                             $cv["xmsg"] = getFeedArticles($link, $i)." ".__("total");
+//                     if (get_pref( 'EXTENDED_FEEDLIST'))
+//                             $cv["xmsg"] = getFeedArticles( $i)." ".__("total");
 
                        array_push($ret_arr, $cv);
                }
                return $ret_arr;
        }
 
-       function getLabelCounters($link, $descriptions = false) {
+       function getLabelCounters( $descriptions = false) {
 
                $ret_arr = array();
 
                $owner_uid = $_SESSION["uid"];
 
-               $result = db_query($link, "SELECT id,caption,COUNT(unread) AS unread
+               $result = db_query( "SELECT id,caption,COUNT(unread) AS unread
                        FROM ttrss_labels2 LEFT JOIN ttrss_user_labels2 ON
                                (ttrss_labels2.id = label_id)
                                LEFT JOIN ttrss_user_entries ON (ref_id = article_id AND unread = true
                        if ($descriptions)
                                $cv["description"] = $label_name;
 
-//                     if (get_pref($link, 'EXTENDED_FEEDLIST'))
-//                             $cv["xmsg"] = getFeedArticles($link, $id)." ".__("total");
+//                     if (get_pref( 'EXTENDED_FEEDLIST'))
+//                             $cv["xmsg"] = getFeedArticles( $id)." ".__("total");
 
                        array_push($ret_arr, $cv);
                }
                return $ret_arr;
        }
 
-       function getFeedCounters($link, $active_feed = false) {
+       function getFeedCounters( $active_feed = false) {
 
                $ret_arr = array();
 
                                AND ttrss_counters_cache.owner_uid = ttrss_feeds.owner_uid
                                AND ttrss_counters_cache.feed_id = id";
 
-               $result = db_query($link, $query);
+               $result = db_query( $query);
                $fctrs_modified = false;
 
                while ($line = db_fetch_assoc($result)) {
                        $count = $line["count"];
                        $last_error = htmlspecialchars($line["last_error"]);
 
-                       $last_updated = make_local_datetime($link, $line['last_updated'], false);
+                       $last_updated = make_local_datetime( $line['last_updated'], false);
 
                        $has_img = feed_has_icon($id);
 
                        if ($last_error)
                                $cv["error"] = $last_error;
 
-//                     if (get_pref($link, 'EXTENDED_FEEDLIST'))
-//                             $cv["xmsg"] = getFeedArticles($link, $id)." ".__("total");
+//                     if (get_pref( 'EXTENDED_FEEDLIST'))
+//                             $cv["xmsg"] = getFeedArticles( $id)." ".__("total");
 
                        if ($active_feed && $id == $active_feed)
                                $cv["title"] = truncate_string($line["title"], 30);
                return $ret_arr;
        }
 
-       function get_pgsql_version($link) {
-               $result = db_query($link, "SELECT version() AS version");
+       function get_pgsql_version() {
+               $result = db_query( "SELECT version() AS version");
                $version = explode(" ", db_fetch_result($result, 0, "version"));
                return $version[1];
        }
         *                     to get all possible feeds.
         *                 5 - Couldn't download the URL content.
         */
-       function subscribe_to_feed($link, $url, $cat_id = 0,
+       function subscribe_to_feed( $url, $cat_id = 0,
                        $auth_login = '', $auth_pass = '') {
 
                global $fetch_last_error;
                        $cat_qpart = "'$cat_id'";
                }
 
-               $result = db_query($link,
+               $result = db_query(
                        "SELECT id FROM ttrss_feeds
                        WHERE feed_url = '$url' AND owner_uid = ".$_SESSION["uid"]);
 
                        $auth_pass_encrypted = 'false';
                }
 
-               $auth_pass = db_escape_string($link, $auth_pass);
+               $auth_pass = db_escape_string( $auth_pass);
 
                if (db_num_rows($result) == 0) {
-                       $result = db_query($link,
+                       $result = db_query(
                                "INSERT INTO ttrss_feeds
                                        (owner_uid,feed_url,title,cat_id, auth_login,auth_pass,update_method,auth_pass_encrypted)
                                VALUES ('".$_SESSION["uid"]."', '$url',
                                '[Unknown]', $cat_qpart, '$auth_login', '$auth_pass', 0, $auth_pass_encrypted)");
 
-                       $result = db_query($link,
+                       $result = db_query(
                                "SELECT id FROM ttrss_feeds WHERE feed_url = '$url'
                                        AND owner_uid = " . $_SESSION["uid"]);
 
                        $feed_id = db_fetch_result($result, 0, "id");
 
                        if ($feed_id) {
-                               update_rss_feed($link, $feed_id, true);
+                               update_rss_feed( $feed_id, true);
                        }
 
                        return array("code" => 1);
                }
        }
 
-       function print_feed_select($link, $id, $default_id = "",
+       function print_feed_select( $id, $default_id = "",
                $attributes = "", $include_all_feeds = true,
                $root_id = false, $nest_level = 0) {
 
                        }
                }
 
-               if (get_pref($link, 'ENABLE_FEED_CATS')) {
+               if (get_pref( 'ENABLE_FEED_CATS')) {
 
                        if ($root_id)
                                $parent_qpart = "parent_cat = '$root_id'";
                        else
                                $parent_qpart = "parent_cat IS NULL";
 
-                       $result = db_query($link, "SELECT id,title,
+                       $result = db_query( "SELECT id,title,
                                (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE
                                        c2.parent_cat = ttrss_feed_categories.id) AS num_children
                                FROM ttrss_feed_categories
                                        $line["id"], htmlspecialchars($line["title"]));
 
                                if ($line["num_children"] > 0)
-                                       print_feed_select($link, $id, $default_id, $attributes,
+                                       print_feed_select( $id, $default_id, $attributes,
                                                $include_all_feeds, $line["id"], $nest_level+1);
 
-                               $feed_result = db_query($link, "SELECT id,title FROM ttrss_feeds
+                               $feed_result = db_query( "SELECT id,title FROM ttrss_feeds
                                        WHERE cat_id = '".$line["id"]."' AND owner_uid = ".$_SESSION["uid"] . " ORDER BY title");
 
                                while ($fline = db_fetch_assoc($feed_result)) {
                                printf("<option $is_selected value='CAT:0'>%s</option>",
                                        __("Uncategorized"));
 
-                               $feed_result = db_query($link, "SELECT id,title FROM ttrss_feeds
+                               $feed_result = db_query( "SELECT id,title FROM ttrss_feeds
                                        WHERE cat_id IS NULL AND owner_uid = ".$_SESSION["uid"] . " ORDER BY title");
 
                                while ($fline = db_fetch_assoc($feed_result)) {
                        }
 
                } else {
-                       $result = db_query($link, "SELECT id,title FROM ttrss_feeds
+                       $result = db_query( "SELECT id,title FROM ttrss_feeds
                                WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
 
                        while ($line = db_fetch_assoc($result)) {
                }
        }
 
-       function print_feed_cat_select($link, $id, $default_id,
+       function print_feed_cat_select( $id, $default_id,
                $attributes, $include_all_cats = true, $root_id = false, $nest_level = 0) {
 
                        if (!$root_id) {
                        else
                                $parent_qpart = "parent_cat IS NULL";
 
-                       $result = db_query($link, "SELECT id,title,
+                       $result = db_query( "SELECT id,title,
                                (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE
                                        c2.parent_cat = ttrss_feed_categories.id) AS num_children
                                FROM ttrss_feed_categories
                                                $line["id"], htmlspecialchars($line["title"]));
 
                                if ($line["num_children"] > 0)
-                                       print_feed_cat_select($link, $id, $default_id, $attributes,
+                                       print_feed_cat_select( $id, $default_id, $attributes,
                                                $include_all_cats, $line["id"], $nest_level+1);
                        }
 
                return ($val == "on") ? "true" : "false";
        }
 
-       function getFeedCatTitle($link, $id) {
+       function getFeedCatTitle( $id) {
                if ($id == -1) {
                        return __("Special");
                } else if ($id < LABEL_BASE_INDEX) {
                        return __("Labels");
                } else if ($id > 0) {
-                       $result = db_query($link, "SELECT ttrss_feed_categories.title
+                       $result = db_query( "SELECT ttrss_feed_categories.title
                                FROM ttrss_feeds, ttrss_feed_categories WHERE ttrss_feeds.id = '$id' AND
                                        cat_id = ttrss_feed_categories.id");
                        if (db_num_rows($result) == 1) {
                return false;
        }
 
-       function getFeedTitle($link, $id, $cat = false) {
+       function getFeedTitle( $id, $cat = false) {
                if ($cat) {
-                       return getCategoryTitle($link, $id);
+                       return getCategoryTitle( $id);
                } else if ($id == -1) {
                        return __("Starred articles");
                } else if ($id == -2) {
                        return __("Recently read");
                } else if ($id < LABEL_BASE_INDEX) {
                        $label_id = feed_to_label_id($id);
-                       $result = db_query($link, "SELECT caption FROM ttrss_labels2 WHERE id = '$label_id'");
+                       $result = db_query( "SELECT caption FROM ttrss_labels2 WHERE id = '$label_id'");
                        if (db_num_rows($result) == 1) {
                                return db_fetch_result($result, 0, "caption");
                        } else {
                        }
 
                } else if (is_numeric($id) && $id > 0) {
-                       $result = db_query($link, "SELECT title FROM ttrss_feeds WHERE id = '$id'");
+                       $result = db_query( "SELECT title FROM ttrss_feeds WHERE id = '$id'");
                        if (db_num_rows($result) == 1) {
                                return db_fetch_result($result, 0, "title");
                        } else {
                }
        }
 
-       function make_init_params($link) {
+       function make_init_params() {
                $params = array();
 
                foreach (array("ON_CATCHUP_SHOW_NEXT_FEED", "HIDE_READ_FEEDS",
                        "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE",
                        "HIDE_READ_SHOWS_SPECIAL", "COMBINED_DISPLAY_MODE") as $param) {
 
-                                $params[strtolower($param)] = (int) get_pref($link, $param);
+                                $params[strtolower($param)] = (int) get_pref( $param);
                 }
 
                $params["icons_url"] = ICONS_URL;
                $params["cookie_lifetime"] = SESSION_COOKIE_LIFETIME;
-               $params["default_view_mode"] = get_pref($link, "_DEFAULT_VIEW_MODE");
-               $params["default_view_limit"] = (int) get_pref($link, "_DEFAULT_VIEW_LIMIT");
-               $params["default_view_order_by"] = get_pref($link, "_DEFAULT_VIEW_ORDER_BY");
+               $params["default_view_mode"] = get_pref( "_DEFAULT_VIEW_MODE");
+               $params["default_view_limit"] = (int) get_pref( "_DEFAULT_VIEW_LIMIT");
+               $params["default_view_order_by"] = get_pref( "_DEFAULT_VIEW_ORDER_BY");
                $params["bw_limit"] = (int) $_SESSION["bw_limit"];
                $params["label_base_index"] = (int) LABEL_BASE_INDEX;
 
-               $result = db_query($link, "SELECT MAX(id) AS mid, COUNT(*) AS nf FROM
+               $result = db_query( "SELECT MAX(id) AS mid, COUNT(*) AS nf FROM
                        ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
 
                $max_feed_id = db_fetch_result($result, 0, "mid");
                $params["max_feed_id"] = (int) $max_feed_id;
                $params["num_feeds"] = (int) $num_feeds;
 
-               $params["collapsed_feedlist"] = (int) get_pref($link, "_COLLAPSED_FEEDLIST");
-               $params["hotkeys"] = get_hotkeys_map($link);
+               $params["collapsed_feedlist"] = (int) get_pref( "_COLLAPSED_FEEDLIST");
+               $params["hotkeys"] = get_hotkeys_map();
 
                $params["csrf_token"] = $_SESSION["csrf_token"];
                $params["widescreen"] = (int) $_COOKIE["ttrss_widescreen"];
                return $params;
        }
 
-       function get_hotkeys_info($link) {
+       function get_hotkeys_info() {
                $hotkeys = array(
                        __("Navigation") => array(
                                "next_feed" => __("Open next feed"),
                return $hotkeys;
        }
 
-       function get_hotkeys_map($link) {
+       function get_hotkeys_map() {
                $hotkeys = array(
 //                     "navigation" => array(
                                "k" => "next_feed",
                                "^(191)|Ctrl+/" => "help_dialog",
                        );
 
-               if (get_pref($link, 'COMBINED_DISPLAY_MODE')) {
+               if (get_pref( 'COMBINED_DISPLAY_MODE')) {
                        $hotkeys["^(38)|Ctrl-up"] = "prev_article_noscroll";
                        $hotkeys["^(40)|Ctrl-down"] = "next_article_noscroll";
                }
                return array($prefixes, $hotkeys);
        }
 
-       function make_runtime_info($link) {
+       function make_runtime_info() {
                $data = array();
 
-               $result = db_query($link, "SELECT MAX(id) AS mid, COUNT(*) AS nf FROM
+               $result = db_query( "SELECT MAX(id) AS mid, COUNT(*) AS nf FROM
                        ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
 
                $max_feed_id = db_fetch_result($result, 0, "mid");
                $data["max_feed_id"] = (int) $max_feed_id;
                $data["num_feeds"] = (int) $num_feeds;
 
-               $data['last_article_id'] = getLastArticleId($link);
-               $data['cdm_expanded'] = get_pref($link, 'CDM_EXPANDED');
+               $data['last_article_id'] = getLastArticleId();
+               $data['cdm_expanded'] = get_pref( 'CDM_EXPANDED');
 
                $data['dep_ts'] = calculate_dep_timestamp();
                $data['reload_on_ts_change'] = !defined('_NO_RELOAD_ON_TS_CHANGE');
                }
 
                if ($_SESSION["last_version_check"] + 86400 + rand(-1000, 1000) < time()) {
-                               $new_version_details = @check_for_update($link);
+                               $new_version_details = @check_for_update();
 
                                $data['new_version_available'] = (int) ($new_version_details != false);
 
                return $data;
        }
 
-       function search_to_sql($link, $search) {
+       function search_to_sql( $search) {
 
                $search_query_part = "";
 
                        case "title":
                                if ($commandpair[1]) {
                                        array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE '%".
-                                               db_escape_string($link, mb_strtolower($commandpair[1]))."%'))");
+                                               db_escape_string( mb_strtolower($commandpair[1]))."%'))");
                                } else {
                                        array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%')
                                                        OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
                        case "author":
                                if ($commandpair[1]) {
                                        array_push($query_keywords, "($not (LOWER(author) LIKE '%".
-                                               db_escape_string($link, mb_strtolower($commandpair[1]))."%'))");
+                                               db_escape_string( mb_strtolower($commandpair[1]))."%'))");
                                } else {
                                        array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%')
                                                        OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
                                                array_push($query_keywords, "($not (note IS NULL OR note = ''))");
                                        else
                                                array_push($query_keywords, "($not (LOWER(note) LIKE '%".
-                                                       db_escape_string($link, mb_strtolower($commandpair[1]))."%'))");
+                                                       db_escape_string( mb_strtolower($commandpair[1]))."%'))");
                                } else {
                                        array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%')
                                                        OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
                        default:
                                if (strpos($k, "@") === 0) {
 
-                                       $user_tz_string = get_pref($link, 'USER_TIMEZONE', $_SESSION['uid']);
+                                       $user_tz_string = get_pref( 'USER_TIMEZONE', $_SESSION['uid']);
                                        $orig_ts = strtotime(substr($k, 1));
                                        $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC'));
 
                return $search_query_part;
        }
 
-       function getParentCategories($link, $cat, $owner_uid) {
+       function getParentCategories( $cat, $owner_uid) {
                $rv = array();
 
-               $result = db_query($link, "SELECT parent_cat FROM ttrss_feed_categories
+               $result = db_query( "SELECT parent_cat FROM ttrss_feed_categories
                        WHERE id = '$cat' AND parent_cat IS NOT NULL AND owner_uid = $owner_uid");
 
                while ($line = db_fetch_assoc($result)) {
                        array_push($rv, $line["parent_cat"]);
-                       $rv = array_merge($rv, getParentCategories($link, $line["parent_cat"], $owner_uid));
+                       $rv = array_merge($rv, getParentCategories( $line["parent_cat"], $owner_uid));
                }
 
                return $rv;
        }
 
-       function getChildCategories($link, $cat, $owner_uid) {
+       function getChildCategories( $cat, $owner_uid) {
                $rv = array();
 
-               $result = db_query($link, "SELECT id FROM ttrss_feed_categories
+               $result = db_query( "SELECT id FROM ttrss_feed_categories
                        WHERE parent_cat = '$cat' AND owner_uid = $owner_uid");
 
                while ($line = db_fetch_assoc($result)) {
                        array_push($rv, $line["id"]);
-                       $rv = array_merge($rv, getChildCategories($link, $line["id"], $owner_uid));
+                       $rv = array_merge($rv, getChildCategories( $line["id"], $owner_uid));
                }
 
                return $rv;
        }
 
-       function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) {
+       function queryFeedHeadlines( $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) {
 
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
 
                                                $search_query_part = "ref_id = -1 AND ";
 
                                } else {
-                                       $search_query_part = search_to_sql($link, $search);
+                                       $search_query_part = search_to_sql( $search);
                                        $search_query_part .= " AND ";
                                }
 
 
                                $override_order = "updated DESC";
 
-                               $filter_query_part = filter_to_sql($link, $filter, $owner_uid);
+                               $filter_query_part = filter_to_sql( $filter, $owner_uid);
 
                                // Try to check if SQL regexp implementation chokes on a valid regexp
-                               $result = db_query($link, "SELECT true AS true_val FROM ttrss_entries,
+                               $result = db_query( "SELECT true AS true_val FROM ttrss_entries,
                                        ttrss_user_entries, ttrss_feeds, ttrss_feed_categories
                                        WHERE $filter_query_part LIMIT 1", false);
 
                                        $view_query_part = " ";
                                } else if ($feed != -1) {
 
-                                       $unread = getFeedUnread($link, $feed, $cat_view);
+                                       $unread = getFeedUnread( $feed, $cat_view);
 
                                        if ($cat_view && $feed > 0 && $include_children)
-                                               $unread += getCategoryChildrenUnread($link, $feed);
+                                               $unread += getCategoryChildrenUnread( $feed);
 
                                        if ($unread > 0)
                                $view_query_part = " unread = true AND ";
 
                                if ($feed > 0) {
                                        if ($include_children) {
-                                               $subcats = getChildCategories($link, $feed, $owner_uid);
+                                               $subcats = getChildCategories( $feed, $owner_uid);
                                                array_push($subcats, $feed);
                                                $cats_qpart = join(",", $subcats);
                                        } else {
                                        if ($feed > 0) {
                                                if ($include_children) {
                                                        # sub-cats
-                                                       $subcats = getChildCategories($link, $feed, $owner_uid);
+                                                       $subcats = getChildCategories( $feed, $owner_uid);
 
                                                        array_push($subcats, $feed);
                                                        $query_strategy_part = "cat_id IN (".
                        } else if ($feed == -3) { // fresh virtual feed
                                $query_strategy_part = "unread = true AND score >= 0";
 
-                               $intl = get_pref($link, "FRESH_ARTICLE_MAX_AGE", $owner_uid);
+                               $intl = get_pref( "FRESH_ARTICLE_MAX_AGE", $owner_uid);
 
                                if (DB_TYPE == "pgsql") {
                                        $query_strategy_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
                                $feed_title = T_sprintf("Search results: %s", $search);
                        } else {
                                if ($cat_view) {
-                                       $feed_title = getCategoryTitle($link, $feed);
+                                       $feed_title = getCategoryTitle( $feed);
                                } else {
                                        if (is_numeric($feed) && $feed > 0) {
-                                               $result = db_query($link, "SELECT title,site_url,last_error
+                                               $result = db_query( "SELECT title,site_url,last_error
                                                        FROM ttrss_feeds WHERE id = '$feed' AND owner_uid = $owner_uid");
 
                                                $feed_title = db_fetch_result($result, 0, "title");
                                                $feed_site_url = db_fetch_result($result, 0, "site_url");
                                                $last_error = db_fetch_result($result, 0, "last_error");
                                        } else {
-                                               $feed_title = getFeedTitle($link, $feed);
+                                               $feed_title = getFeedTitle( $feed);
                                        }
                                }
                        }
                                }
 
                                // proper override_order applied above
-                               if ($vfeed_query_part && !$ignore_vfeed_group && get_pref($link, 'VFEED_GROUP_BY_FEED', $owner_uid)) {
+                               if ($vfeed_query_part && !$ignore_vfeed_group && get_pref( 'VFEED_GROUP_BY_FEED', $owner_uid)) {
                                        if (!$override_order) {
                                                $order_by = "ttrss_feeds.title, $order_by";
                                        } else {
 
                                if ($_REQUEST["debug"]) print $query;
 
-                               $result = db_query($link, $query);
+                               $result = db_query( $query);
 
                        } else {
                                // browsing by tag
                                // $tag_sql = "tag_name = '$feed'";   DEFAULT way
 
                                //                              error_log("[". $select_qpart . "][" . $from_qpart . "][" .$where_qpart . "]");
-                               $result = db_query($link, $select_qpart . $from_qpart . $where_qpart);
+                               $result = db_query( $select_qpart . $from_qpart . $where_qpart);
                        }
 
                        return array($result, $feed_title, $feed_site_url, $last_error);
 
        }
 
-       function sanitize($link, $str, $force_remove_images = false, $owner = false, $site_url = false) {
+       function sanitize( $str, $force_remove_images = false, $owner = false, $site_url = false) {
                if (!$owner) $owner = $_SESSION["uid"];
 
                $res = trim($str); if (!$res) return '';
                                }
 
                                if ($entry->nodeName == 'img') {
-                                       if (($owner && get_pref($link, "STRIP_IMAGES", $owner)) ||
+                                       if (($owner && get_pref( "STRIP_IMAGES", $owner)) ||
                                                        $force_remove_images || $_SESSION["bw_limit"]) {
 
                                                $p = $doc->createElement('p');
                return $doc;
        }
 
-       function check_for_update($link) {
+       function check_for_update() {
                if (CHECK_FOR_NEW_VERSION && $_SESSION['access_level'] >= 10) {
                        $version_url = "http://tt-rss.org/version.php?ver=" . VERSION .
                                "&iid=" . sha1(SELF_URL_PATH);
                return false;
        }
 
-       function catchupArticlesById($link, $ids, $cmode, $owner_uid = false) {
+       function catchupArticlesById( $ids, $cmode, $owner_uid = false) {
 
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
                if (count($ids) == 0) return;
                $ids_qpart = join(" OR ", $tmp_ids);
 
                if ($cmode == 0) {
-                       db_query($link, "UPDATE ttrss_user_entries SET
+                       db_query( "UPDATE ttrss_user_entries SET
                        unread = false,last_read = NOW()
                        WHERE ($ids_qpart) AND owner_uid = $owner_uid");
                } else if ($cmode == 1) {
-                       db_query($link, "UPDATE ttrss_user_entries SET
+                       db_query( "UPDATE ttrss_user_entries SET
                        unread = true
                        WHERE ($ids_qpart) AND owner_uid = $owner_uid");
                } else {
-                       db_query($link, "UPDATE ttrss_user_entries SET
+                       db_query( "UPDATE ttrss_user_entries SET
                        unread = NOT unread,last_read = NOW()
                        WHERE ($ids_qpart) AND owner_uid = $owner_uid");
                }
 
                /* update ccache */
 
-               $result = db_query($link, "SELECT DISTINCT feed_id FROM ttrss_user_entries
+               $result = db_query( "SELECT DISTINCT feed_id FROM ttrss_user_entries
                        WHERE ($ids_qpart) AND owner_uid = $owner_uid");
 
                while ($line = db_fetch_assoc($result)) {
-                       ccache_update($link, $line["feed_id"], $owner_uid);
+                       ccache_update( $line["feed_id"], $owner_uid);
                }
        }
 
-       function get_article_tags($link, $id, $owner_uid = 0, $tag_cache = false) {
+       function get_article_tags( $id, $owner_uid = 0, $tag_cache = false) {
 
-               $a_id = db_escape_string($link, $id);
+               $a_id = db_escape_string( $id);
 
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
 
                /* check cache first */
 
                if ($tag_cache === false) {
-                       $result = db_query($link, "SELECT tag_cache FROM ttrss_user_entries
+                       $result = db_query( "SELECT tag_cache FROM ttrss_user_entries
                                WHERE ref_id = '$id' AND owner_uid = $owner_uid");
 
                        $tag_cache = db_fetch_result($result, 0, "tag_cache");
 
                        /* do it the hard way */
 
-                       $tmp_result = db_query($link, $query);
+                       $tmp_result = db_query( $query);
 
                        while ($tmp_line = db_fetch_assoc($tmp_result)) {
                                array_push($tags, $tmp_line["tag_name"]);
 
                        /* update the cache */
 
-                       $tags_str = db_escape_string($link, join(",", $tags));
+                       $tags_str = db_escape_string( join(",", $tags));
 
-                       db_query($link, "UPDATE ttrss_user_entries
+                       db_query( "UPDATE ttrss_user_entries
                                SET tag_cache = '$tags_str' WHERE ref_id = '$id'
                                AND owner_uid = $owner_uid");
                }
                return true;
        }
 
-       function render_login_form($link) {
+       function render_login_form() {
                header('Cache-Control: public');
 
                require_once "login_form.php";
                return vsprintf(__(array_shift($args)), $args);
        }
 
-       function format_inline_player($link, $url, $ctype) {
+       function format_inline_player( $url, $ctype) {
 
                $entry = "";
 
 
        }
 
-       function format_article($link, $id, $mark_as_read = true, $zoom_mode = false, $owner_uid = false) {
+       function format_article( $id, $mark_as_read = true, $zoom_mode = false, $owner_uid = false) {
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
 
                $rv = array();
                /* we can figure out feed_id from article id anyway, why do we
                 * pass feed_id here? let's ignore the argument :( */
 
-               $result = db_query($link, "SELECT feed_id FROM ttrss_user_entries
+               $result = db_query( "SELECT feed_id FROM ttrss_user_entries
                        WHERE ref_id = '$id'");
 
                $feed_id = (int) db_fetch_result($result, 0, "feed_id");
                //if (!$zoom_mode) { print "<article id='$id'><![CDATA["; };
 
                if ($mark_as_read) {
-                       $result = db_query($link, "UPDATE ttrss_user_entries
+                       $result = db_query( "UPDATE ttrss_user_entries
                                SET unread = false,last_read = NOW()
                                WHERE ref_id = '$id' AND owner_uid = $owner_uid");
 
-                       ccache_update($link, $feed_id, $owner_uid);
+                       ccache_update( $feed_id, $owner_uid);
                }
 
-               $result = db_query($link, "SELECT id,title,link,content,feed_id,comments,int_id,
+               $result = db_query( "SELECT id,title,link,content,feed_id,comments,int_id,
                        ".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
                        (SELECT site_url FROM ttrss_feeds WHERE id = feed_id) as site_url,
                        (SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) as hide_images,
 
                        $tag_cache = $line["tag_cache"];
 
-                       $line["tags"] = get_article_tags($link, $id, $owner_uid, $line["tag_cache"]);
+                       $line["tags"] = get_article_tags( $id, $owner_uid, $line["tag_cache"]);
                        unset($line["tag_cache"]);
 
-                       $line["content"] = sanitize($link, $line["content"], false, $owner_uid, $line["site_url"]);
+                       $line["content"] = sanitize( $line["content"], false, $owner_uid,       $line["site_url"]);
 
                        global $pluginhost;
 
                                $entry_author = __(" - ") . $entry_author;
                        }
 
-                       $parsed_updated = make_local_datetime($link, $line["updated"], true,
+                       $parsed_updated = make_local_datetime( $line["updated"], true,
                                $owner_uid, true);
 
                        $rv['content'] .= "<div class=\"postDate\">$parsed_updated</div>";
 
                        if ($line["orig_feed_id"]) {
 
-                               $tmp_result = db_query($link, "SELECT * FROM ttrss_archived_feeds
+                               $tmp_result = db_query( "SELECT * FROM ttrss_archived_feeds
                                        WHERE id = ".$line["orig_feed_id"]);
 
                                if (db_num_rows($tmp_result) != 0) {
                        $rv['content'] .= "<div class=\"postContent\">";
 
                        $rv['content'] .= $line["content"];
-                       $rv['content'] .= format_article_enclosures($link, $id,
+                       $rv['content'] .= format_article_enclosures( $id,
                                sql_bool_to_bool($line["always_display_enclosures"]),
                                $line["content"],
                                sql_bool_to_bool($line["hide_images"]));
                }
        } // function encrypt_password
 
-       function load_filters($link, $feed_id, $owner_uid, $action_id = false) {
+       function load_filters( $feed_id, $owner_uid, $action_id = false) {
                $filters = array();
 
-               $cat_id = (int)getFeedCategory($link, $feed_id);
+               $cat_id = (int)getFeedCategory( $feed_id);
 
-               $result = db_query($link, "SELECT * FROM ttrss_filters2 WHERE
+               $result = db_query( "SELECT * FROM ttrss_filters2 WHERE
                        owner_uid = $owner_uid AND enabled = true ORDER BY order_id, title");
 
                $check_cats = join(",", array_merge(
-                       getParentCategories($link, $cat_id, $owner_uid),
+                       getParentCategories( $cat_id, $owner_uid),
                        array($cat_id)));
 
                while ($line = db_fetch_assoc($result)) {
                        $filter_id = $line["id"];
 
-                       $result2 = db_query($link, "SELECT
+                       $result2 = db_query( "SELECT
                                r.reg_exp, r.inverse, r.feed_id, r.cat_id, r.cat_filter, t.name AS type_name
                                FROM ttrss_filters2_rules AS r,
                                ttrss_filter_types AS t
                                array_push($rules, $rule);
                        }
 
-                       $result2 = db_query($link, "SELECT a.action_param,t.name AS type_name
+                       $result2 = db_query( "SELECT a.action_param,t.name AS type_name
                                FROM ttrss_filters2_actions AS a,
                                ttrss_filter_actions AS t
                                WHERE
                return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0;
        }
 
-       function init_plugins($link) {
+       function init_plugins() {
                global $pluginhost;
 
-               $pluginhost = new PluginHost($link);
+               $pluginhost = new PluginHost(Db::get());
                $pluginhost->load(PLUGINS, $pluginhost::KIND_ALL);
 
                return true;
        }
 
 
-       function get_feed_category($link, $feed_cat, $parent_cat_id = false) {
+       function get_feed_category( $feed_cat, $parent_cat_id = false) {
                if ($parent_cat_id) {
                        $parent_qpart = "parent_cat = '$parent_cat_id'";
                        $parent_insert = "'$parent_cat_id'";
                        $parent_insert = "NULL";
                }
 
-               $result = db_query($link,
+               $result = db_query(
                        "SELECT id FROM ttrss_feed_categories
                        WHERE $parent_qpart AND title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
 
                }
        }
 
-       function add_feed_category($link, $feed_cat, $parent_cat_id = false) {
+       function add_feed_category( $feed_cat, $parent_cat_id = false) {
 
                if (!$feed_cat) return false;
 
-               db_query($link, "BEGIN");
+               db_query( "BEGIN");
 
                if ($parent_cat_id) {
                        $parent_qpart = "parent_cat = '$parent_cat_id'";
 
                $feed_cat = mb_substr($feed_cat, 0, 250);
 
-               $result = db_query($link,
+               $result = db_query(
                        "SELECT id FROM ttrss_feed_categories
                        WHERE $parent_qpart AND title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
 
                if (db_num_rows($result) == 0) {
 
-                       $result = db_query($link,
+                       $result = db_query(
                                "INSERT INTO ttrss_feed_categories (owner_uid,title,parent_cat)
                                VALUES ('".$_SESSION["uid"]."', '$feed_cat', $parent_insert)");
 
-                       db_query($link, "COMMIT");
+                       db_query( "COMMIT");
 
                        return true;
                }
                return false;
        }
 
-       function getArticleFeed($link, $id) {
-               $result = db_query($link, "SELECT feed_id FROM ttrss_user_entries
+       function getArticleFeed( $id) {
+               $result = db_query( "SELECT feed_id FROM ttrss_user_entries
                        WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
 
                if (db_num_rows($result) != 0) {
 
        }
 
-       function get_article_enclosures($link, $id) {
+       function get_article_enclosures( $id) {
 
                $query = "SELECT * FROM ttrss_enclosures
                        WHERE post_id = '$id' AND content_url != ''";
 
                $rv = array();
 
-               $result = db_query($link, $query);
+               $result = db_query( $query);
 
                if (db_num_rows($result) > 0) {
                        while ($line = db_fetch_assoc($result)) {
                return $rv;
        }
 
-       function save_email_address($link, $email) {
+       function save_email_address( $email) {
                // FIXME: implement persistent storage of emails
 
                if (!$_SESSION['stored_emails'])
        }
 
 
-       function get_feed_access_key($link, $feed_id, $is_cat, $owner_uid = false) {
+       function get_feed_access_key( $feed_id, $is_cat, $owner_uid = false) {
 
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
 
                $sql_is_cat = bool_to_sql_bool($is_cat);
 
-               $result = db_query($link, "SELECT access_key FROM ttrss_access_keys
+               $result = db_query( "SELECT access_key FROM ttrss_access_keys
                        WHERE feed_id = '$feed_id'      AND is_cat = $sql_is_cat
                        AND owner_uid = " . $owner_uid);
 
                if (db_num_rows($result) == 1) {
                        return db_fetch_result($result, 0, "access_key");
                } else {
-                       $key = db_escape_string($link, sha1(uniqid(rand(), true)));
+                       $key = db_escape_string( sha1(uniqid(rand(), true)));
 
-                       $result = db_query($link, "INSERT INTO ttrss_access_keys
+                       $result = db_query( "INSERT INTO ttrss_access_keys
                                (access_key, feed_id, is_cat, owner_uid)
                                VALUES ('$key', '$feed_id', $sql_is_cat, '$owner_uid')");
 
                return is_html(fetch_file_contents($url, false, $login, $pass));
        }
 
-       function print_label_select($link, $name, $value, $attributes = "") {
+       function print_label_select( $name, $value, $attributes = "") {
 
-               $result = db_query($link, "SELECT caption FROM ttrss_labels2
+               $result = db_query( "SELECT caption FROM ttrss_labels2
                        WHERE owner_uid = '".$_SESSION["uid"]."' ORDER BY caption");
 
                print "<select default=\"$value\" name=\"" . htmlspecialchars($name) .
 
        }
 
-       function format_article_enclosures($link, $id, $always_display_enclosures,
+       function format_article_enclosures( $id, $always_display_enclosures,
                                        $article_content, $hide_images = false) {
 
-               $result = get_article_enclosures($link, $id);
+               $result = get_article_enclosures( $id);
                $rv = '';
 
                if (count($result) > 0) {
 
                                $filename = substr($url, strrpos($url, "/")+1);
 
-                               $player = format_inline_player($link, $url, $ctype);
+                               $player = format_inline_player( $url, $ctype);
 
                                if ($player) array_push($entries_inline, $player);
 
                                array_push($entries, $entry);
                        }
 
-                       if ($_SESSION['uid'] && !get_pref($link, "STRIP_IMAGES") && !$_SESSION["bw_limit"]) {
+                       if ($_SESSION['uid'] && !get_pref( "STRIP_IMAGES") && !$_SESSION["bw_limit"]) {
                                if ($always_display_enclosures ||
                                                        !preg_match("/<img/i", $article_content)) {
 
                return $rv;
        }
 
-       function getLastArticleId($link) {
-               $result = db_query($link, "SELECT MAX(ref_id) AS id FROM ttrss_user_entries
+       function getLastArticleId() {
+               $result = db_query( "SELECT MAX(ref_id) AS id FROM ttrss_user_entries
                        WHERE owner_uid = " . $_SESSION["uid"]);
 
                if (db_num_rows($result) == 1) {
                return $ids;
        }
 
-       function cleanup_tags($link, $days = 14, $limit = 1000) {
+       function cleanup_tags( $days = 14, $limit = 1000) {
 
                if (DB_TYPE == "pgsql") {
                        $interval_query = "date_updated < NOW() - INTERVAL '$days days'";
                                WHERE post_int_id = int_id AND $interval_query AND
                                ref_id = ttrss_entries.id AND tag_cache != '' LIMIT $limit_part";
 
-                       $result = db_query($link, $query);
+                       $result = db_query( $query);
 
                        $ids = array();
 
                        if (count($ids) > 0) {
                                $ids = join(",", $ids);
 
-                               $tmp_result = db_query($link, "DELETE FROM ttrss_tags WHERE id IN ($ids)");
-                               $tags_deleted += db_affected_rows($link, $tmp_result);
+                               $tmp_result = db_query( "DELETE FROM ttrss_tags WHERE id IN ($ids)");
+                               $tags_deleted += db_affected_rows( $tmp_result);
                        } else {
                                break;
                        }
                return $tags_deleted;
        }
 
-       function print_user_stylesheet($link) {
-               $value = get_pref($link, 'USER_STYLESHEET');
+       function print_user_stylesheet() {
+               $value = get_pref( 'USER_STYLESHEET');
 
                if ($value) {
                        print "<style type=\"text/css\">";
                        return $html;
        }
 
-       function filter_to_sql($link, $filter, $owner_uid) {
+       function filter_to_sql( $filter, $owner_uid) {
                $query = array();
 
                if (DB_TYPE == "pgsql")
 
                        if ($regexp_valid) {
 
-                               $rule['reg_exp'] = db_escape_string($link, $rule['reg_exp']);
+                               $rule['reg_exp'] = db_escape_string( $rule['reg_exp']);
 
                                        switch ($rule["type"]) {
                                        case "title":
                                if (isset($rule['inverse'])) $qpart = "NOT ($qpart)";
 
                                if (isset($rule["feed_id"]) && $rule["feed_id"] > 0) {
-                                       $qpart .= " AND feed_id = " . db_escape_string($link, $rule["feed_id"]);
+                                       $qpart .= " AND feed_id = " . db_escape_string( $rule["feed_id"]);
                                }
 
                                if (isset($rule["cat_id"])) {
 
                                        if ($rule["cat_id"] > 0) {
-                                               $children = getChildCategories($link, $rule["cat_id"], $owner_uid);
+                                               $children = getChildCategories( $rule["cat_id"], $owner_uid);
                                                array_push($children, $rule["cat_id"]);
 
                                                $children = join(",", $children);
        return $tempname;
        }
 
-       function getFeedCategory($link, $feed) {
-               $result = db_query($link, "SELECT cat_id FROM ttrss_feeds
+       function getFeedCategory( $feed) {
+               $result = db_query( "SELECT cat_id FROM ttrss_feeds
                        WHERE id = '$feed'");
 
                if (db_num_rows($result) > 0) {
index 655b51555e219698932c39974ad5e56cc8aa62cc..fc23fca935ce63f511600978fae8d70232a6f33c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
-       function label_find_id($link, $label, $owner_uid) {
-               $result = db_query($link,
+       function label_find_id( $label, $owner_uid) {
+               $result = db_query(
                        "SELECT id FROM ttrss_labels2 WHERE caption = '$label'
                                AND owner_uid = '$owner_uid' LIMIT 1");
 
                }
        }
 
-       function get_article_labels($link, $id, $owner_uid = false) {
+       function get_article_labels( $id, $owner_uid = false) {
                $rv = array();
 
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
 
-               $result = db_query($link, "SELECT label_cache FROM
+               $result = db_query( "SELECT label_cache FROM
                        ttrss_user_entries WHERE ref_id = '$id' AND owner_uid = " .
                        $owner_uid);
 
@@ -33,7 +33,7 @@
                        }
                }
 
-               $result = db_query($link,
+               $result = db_query(
                        "SELECT DISTINCT label_id,caption,fg_color,bg_color
                                FROM ttrss_labels2, ttrss_user_labels2
                        WHERE id = label_id
                }
 
                if (count($rv) > 0)
-                       label_update_cache($link, $owner_uid, $id, $rv);
+                       label_update_cache( $owner_uid, $id, $rv);
                else
-                       label_update_cache($link, $owner_uid, $id, array("no-labels" => 1));
+                       label_update_cache( $owner_uid, $id, array("no-labels" => 1));
 
                return $rv;
        }
 
 
-       function label_find_caption($link, $label, $owner_uid) {
-               $result = db_query($link,
+       function label_find_caption( $label, $owner_uid) {
+               $result = db_query(
                        "SELECT caption FROM ttrss_labels2 WHERE id = '$label'
                                AND owner_uid = '$owner_uid' LIMIT 1");
 
                }
        }
 
-       function get_all_labels($link, $owner_uid) {
+       function get_all_labels( $owner_uid) {
                $rv = array();
 
-               $result = db_query($link, "SELECT fg_color, bg_color, caption FROM ttrss_labels2 WHERE owner_uid = " . $owner_uid);
+               $result = db_query( "SELECT fg_color, bg_color, caption FROM ttrss_labels2 WHERE owner_uid = " . $owner_uid);
 
                while ($line = db_fetch_assoc($result)) {
                        array_push($rv, $line);
                return $rv;
        }
 
-       function label_update_cache($link, $owner_uid, $id, $labels = false, $force = false) {
+       function label_update_cache( $owner_uid, $id, $labels = false, $force = false) {
 
                if ($force)
-                       label_clear_cache($link, $id);
+                       label_clear_cache( $id);
 
                if (!$labels)
-                       $labels = get_article_labels($link, $id);
+                       $labels = get_article_labels( $id);
 
-               $labels = db_escape_string($link, json_encode($labels));
+               $labels = db_escape_string( json_encode($labels));
 
-               db_query($link, "UPDATE ttrss_user_entries SET
+               db_query( "UPDATE ttrss_user_entries SET
                        label_cache = '$labels' WHERE ref_id = '$id' AND  owner_uid = '$owner_uid'");
 
        }
 
-       function label_clear_cache($link, $id) {
+       function label_clear_cache( $id) {
 
-               db_query($link, "UPDATE ttrss_user_entries SET
+               db_query( "UPDATE ttrss_user_entries SET
                        label_cache = '' WHERE ref_id = '$id'");
 
        }
 
-       function label_remove_article($link, $id, $label, $owner_uid) {
+       function label_remove_article( $id, $label, $owner_uid) {
 
-               $label_id = label_find_id($link, $label, $owner_uid);
+               $label_id = label_find_id( $label, $owner_uid);
 
                if (!$label_id) return;
 
-               $result = db_query($link,
+               $result = db_query(
                        "DELETE FROM ttrss_user_labels2
                        WHERE
                                label_id = '$label_id' AND
                                article_id = '$id'");
 
-               label_clear_cache($link, $id);
+               label_clear_cache( $id);
        }
 
-       function label_add_article($link, $id, $label, $owner_uid) {
+       function label_add_article( $id, $label, $owner_uid) {
 
-               $label_id = label_find_id($link, $label, $owner_uid);
+               $label_id = label_find_id( $label, $owner_uid);
 
                if (!$label_id) return;
 
-               $result = db_query($link,
+               $result = db_query(
                        "SELECT
                                article_id FROM ttrss_labels2, ttrss_user_labels2
                        WHERE
                        LIMIT 1");
 
                if (db_num_rows($result) == 0) {
-                       db_query($link, "INSERT INTO ttrss_user_labels2
+                       db_query( "INSERT INTO ttrss_user_labels2
                                (label_id, article_id) VALUES ('$label_id', '$id')");
                }
 
-               label_clear_cache($link, $id);
+               label_clear_cache( $id);
 
        }
 
-       function label_remove($link, $id, $owner_uid) {
+       function label_remove( $id, $owner_uid) {
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
 
-               db_query($link, "BEGIN");
+               db_query( "BEGIN");
 
-               $result = db_query($link, "SELECT caption FROM ttrss_labels2
+               $result = db_query( "SELECT caption FROM ttrss_labels2
                        WHERE id = '$id'");
 
                $caption = db_fetch_result($result, 0, "caption");
 
-               $result = db_query($link, "DELETE FROM ttrss_labels2 WHERE id = '$id'
+               $result = db_query( "DELETE FROM ttrss_labels2 WHERE id = '$id'
                        AND owner_uid = " . $owner_uid);
 
-               if (db_affected_rows($link, $result) != 0 && $caption) {
+               if (db_affected_rows( $result) != 0 && $caption) {
 
                        /* Remove access key for the label */
 
                        $ext_id = LABEL_BASE_INDEX - 1 - $id;
 
-                       db_query($link, "DELETE FROM ttrss_access_keys WHERE
+                       db_query( "DELETE FROM ttrss_access_keys WHERE
                                feed_id = '$ext_id' AND owner_uid = $owner_uid");
 
                        /* Remove cached data */
 
-                       db_query($link, "UPDATE ttrss_user_entries SET label_cache = ''
+                       db_query( "UPDATE ttrss_user_entries SET label_cache = ''
                                WHERE label_cache LIKE '%$caption%' AND owner_uid = " . $owner_uid);
 
                }
 
-               db_query($link, "COMMIT");
+               db_query( "COMMIT");
        }
 
-       function label_create($link, $caption, $fg_color = '', $bg_color = '', $owner_uid = false) {
+       function label_create( $caption, $fg_color = '', $bg_color = '', $owner_uid = false) {
 
                if (!$owner_uid) $owner_uid = $_SESSION['uid'];
 
-               db_query($link, "BEGIN");
+               db_query( "BEGIN");
 
                $result = false;
 
-               $result = db_query($link, "SELECT id FROM ttrss_labels2
+               $result = db_query( "SELECT id FROM ttrss_labels2
                        WHERE caption = '$caption' AND owner_uid = $owner_uid");
 
                if (db_num_rows($result) == 0) {
-                       $result = db_query($link,
+                       $result = db_query(
                                "INSERT INTO ttrss_labels2 (caption,owner_uid,fg_color,bg_color)
                                        VALUES ('$caption', '$owner_uid', '$fg_color', '$bg_color')");
 
-                       $result = db_affected_rows($link, $result) != 0;
+                       $result = db_affected_rows( $result) != 0;
                }
 
-               db_query($link, "COMMIT");
+               db_query( "COMMIT");
 
                return $result;
        }
index 9ea2662fccd0ea07cef1b0e3f6a3344469dc0f02..14f4f0b7810507757a010d9a17c91303ed7a13b9 100644 (file)
@@ -3,32 +3,32 @@
        define('DAEMON_FEED_LIMIT', 100);
        define('DAEMON_SLEEP_INTERVAL', 60);
 
-       function update_feedbrowser_cache($link) {
+       function update_feedbrowser_cache() {
 
-               $result = db_query($link, "SELECT feed_url, site_url, title, COUNT(id) AS subscribers
+               $result = db_query( "SELECT feed_url, site_url, title, COUNT(id) AS subscribers
                        FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
                                WHERE tf.feed_url = ttrss_feeds.feed_url
                                AND (private IS true OR auth_login != '' OR auth_pass != '' OR feed_url LIKE '%:%@%/%'))
                                GROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT 1000");
 
-               db_query($link, "BEGIN");
+               db_query( "BEGIN");
 
-               db_query($link, "DELETE FROM ttrss_feedbrowser_cache");
+               db_query( "DELETE FROM ttrss_feedbrowser_cache");
 
                $count = 0;
 
                while ($line = db_fetch_assoc($result)) {
-                       $subscribers = db_escape_string($link, $line["subscribers"]);
-                       $feed_url = db_escape_string($link, $line["feed_url"]);
-                       $title = db_escape_string($link, $line["title"]);
-                       $site_url = db_escape_string($link, $line["site_url"]);
+                       $subscribers = db_escape_string( $line["subscribers"]);
+                       $feed_url = db_escape_string( $line["feed_url"]);
+                       $title = db_escape_string( $line["title"]);
+                       $site_url = db_escape_string( $line["site_url"]);
 
-                       $tmp_result = db_query($link, "SELECT subscribers FROM
+                       $tmp_result = db_query( "SELECT subscribers FROM
                                ttrss_feedbrowser_cache WHERE feed_url = '$feed_url'");
 
                        if (db_num_rows($tmp_result) == 0) {
 
-                               db_query($link, "INSERT INTO ttrss_feedbrowser_cache
+                               db_query( "INSERT INTO ttrss_feedbrowser_cache
                                        (feed_url, site_url, title, subscribers) VALUES ('$feed_url',
                                                '$site_url', '$title', '$subscribers')");
 
@@ -38,7 +38,7 @@
 
                }
 
-               db_query($link, "COMMIT");
+               db_query( "COMMIT");
 
                return $count;
 
         * @param boolean $debug Set to false to disable debug output. Default to true.
         * @return void
         */
-       function update_daemon_common($link, $limit = DAEMON_FEED_LIMIT, $from_http = false, $debug = true) {
+       function update_daemon_common( $limit = DAEMON_FEED_LIMIT, $from_http = false, $debug = true) {
                // Process all other feeds using last_updated and interval parameters
 
-               $schema_version = get_schema_version($link);
+               $schema_version = get_schema_version();
 
                if ($schema_version != SCHEMA_VERSION) {
                        die("Schema version is wrong, please upgrade the database.\n");
                $random_qpart = sql_random_function();
 
                // We search for feed needing update.
-               $result = db_query($link, "SELECT DISTINCT ttrss_feeds.feed_url,$random_qpart
+               $result = db_query( "SELECT DISTINCT ttrss_feeds.feed_url,$random_qpart
                        FROM
                                ttrss_feeds, ttrss_users, ttrss_user_prefs
                        WHERE
                // Here is a little cache magic in order to minimize risk of double feed updates.
                $feeds_to_update = array();
                while ($line = db_fetch_assoc($result)) {
-                       array_push($feeds_to_update, db_escape_string($link, $line['feed_url']));
+                       array_push($feeds_to_update, db_escape_string( $line['feed_url']));
                }
 
                // We update the feed last update started date before anything else.
                        $feeds_quoted = array();
 
                        foreach ($feeds_to_update as $feed) {
-                               array_push($feeds_quoted, "'" . db_escape_string($link, $feed) . "'");
+                               array_push($feeds_quoted, "'" . db_escape_string( $feed) . "'");
                        }
 
-                       db_query($link, sprintf("UPDATE ttrss_feeds SET last_update_started = NOW()
+                       db_query( sprintf("UPDATE ttrss_feeds SET last_update_started = NOW()
                                WHERE feed_url IN (%s)", implode(',', $feeds_quoted)));
                }
 
                expire_cached_files($debug);
                expire_lock_files($debug);
-               expire_error_log($link, $debug);
+               expire_error_log( $debug);
 
                $nf = 0;
 
                foreach ($feeds_to_update as $feed) {
                        if($debug) _debug("Base feed: $feed");
 
-                       //update_rss_feed($link, $line["id"], true);
+                       //update_rss_feed( $line["id"], true);
 
                        // since we have the data cached, we can deal with other feeds with the same url
 
-                       $tmp_result = db_query($link, "SELECT DISTINCT ttrss_feeds.id,last_updated
+                       $tmp_result = db_query( "SELECT DISTINCT ttrss_feeds.id,last_updated
                        FROM ttrss_feeds, ttrss_users, ttrss_user_prefs WHERE
                                ttrss_user_prefs.owner_uid = ttrss_feeds.owner_uid AND
                                ttrss_users.id = ttrss_user_prefs.owner_uid AND
                                ttrss_user_prefs.pref_name = 'DEFAULT_UPDATE_INTERVAL' AND
-                               feed_url = '".db_escape_string($link, $feed)."' AND
+                               feed_url = '".db_escape_string( $feed)."' AND
                                (ttrss_feeds.update_interval > 0 OR
                                        ttrss_user_prefs.value != '-1')
                                $login_thresh_qpart
                        if (db_num_rows($tmp_result) > 0) {
                                while ($tline = db_fetch_assoc($tmp_result)) {
                                        if($debug) _debug(" => " . $tline["last_updated"] . ", " . $tline["id"]);
-                                       update_rss_feed($link, $tline["id"], true);
+                                       update_rss_feed( $tline["id"], true);
                                        ++$nf;
                                }
                        }
                require_once "digest.php";
 
                // Send feed digests by email if needed.
-               send_headlines_digests($link, $debug);
+               send_headlines_digests( $debug);
 
                return $nf;
 
        } // function update_daemon_common
 
        // ignore_daemon is not used
-       function update_rss_feed($link, $feed, $ignore_daemon = false, $no_cache = false,
+       function update_rss_feed( $feed, $ignore_daemon = false, $no_cache = false,
                $override_url = false) {
 
                require_once "lib/simplepie/simplepie.inc";
                        _debug("update_rss_feed: start");
                }
 
-               $result = db_query($link, "SELECT id,update_interval,auth_login,
+               $result = db_query( "SELECT id,update_interval,auth_login,
                        feed_url,auth_pass,cache_images,last_updated,
                        mark_unread_on_update, owner_uid,
                        pubsub_state, auth_pass_encrypted
                $auth_pass_encrypted = sql_bool_to_bool(db_fetch_result($result,
                        0, "auth_pass_encrypted"));
 
-               db_query($link, "UPDATE ttrss_feeds SET last_update_started = NOW()
+               db_query( "UPDATE ttrss_feeds SET last_update_started = NOW()
                        WHERE id = '$feed'");
 
                $auth_login = db_fetch_result($result, 0, "auth_login");
                $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
                $fetch_url = db_fetch_result($result, 0, "feed_url");
 
-               $feed = db_escape_string($link, $feed);
+               $feed = db_escape_string( $feed);
 
                if ($override_url) $fetch_url = $override_url;
 
 
                // Ignore cache if new feed or manual update.
                $cache_age = ($no_cache || is_null($last_updated) || $last_updated == '1970-01-01 00:00:00') ?
-                       30 : get_feed_update_interval($link, $feed) * 60;
+                       30 : get_feed_update_interval( $feed) * 60;
 
                if ($debug_enabled) {
                        _debug("update_rss_feed: cache filename: $cache_filename exists: " . file_exists($cache_filename));
 
                                // If-Modified-Since
                                if ($fetch_last_error_code != 304) {
-                                       $error_escaped = db_escape_string($link, $fetch_last_error);
+                                       $error_escaped = db_escape_string( $fetch_last_error);
                                } else {
                                        if ($debug_enabled) {
                                                _debug("update_rss_feed: source claims data not modified, nothing to do.");
                                        }
                                }
 
-                               db_query($link,
+                               db_query(
                                        "UPDATE ttrss_feeds SET last_error = '$error_escaped',
                                                last_updated = NOW() WHERE id = '$feed'");
 
                        }
                }
 
-               $pluginhost = new PluginHost($link);
+               $pluginhost = new PluginHost();
                $pluginhost->set_debug($debug_enabled);
-               $user_plugins = get_pref($link, "_ENABLED_PLUGINS", $owner_uid);
+               $user_plugins = get_pref( "_ENABLED_PLUGINS", $owner_uid);
 
                $pluginhost->load(PLUGINS, $pluginhost::KIND_ALL);
                $pluginhost->load($user_plugins, $pluginhost::KIND_USER, $owner_uid);
 
 //             print_r($rss);
 
-               $feed = db_escape_string($link, $feed);
+               $feed = db_escape_string( $feed);
 
                if (!$rss->error()) {
 
                                _debug("update_rss_feed: processing feed data...");
                        }
 
-//                     db_query($link, "BEGIN");
+//                     db_query( "BEGIN");
 
                        if (DB_TYPE == "pgsql") {
                                $favicon_interval_qpart = "favicon_last_checked < NOW() - INTERVAL '12 hour'";
                                $favicon_interval_qpart = "favicon_last_checked < DATE_SUB(NOW(), INTERVAL 12 HOUR)";
                        }
 
-                       $result = db_query($link, "SELECT title,site_url,owner_uid,
+                       $result = db_query( "SELECT title,site_url,owner_uid,
                                (favicon_last_checked IS NULL OR $favicon_interval_qpart) AS
                                                favicon_needs_check
                                FROM ttrss_feeds WHERE id = '$feed'");
 
                        $owner_uid = db_fetch_result($result, 0, "owner_uid");
 
-                       $site_url = db_escape_string($link, mb_substr(rewrite_relative_url($fetch_url, $rss->get_link()), 0, 245));
+                       $site_url = db_escape_string( mb_substr(rewrite_relative_url($fetch_url, $rss->get_link()), 0, 245));
 
                        if ($favicon_needs_check || $force_refetch) {
                                if ($debug_enabled) {
                                if (file_exists($favicon_file)) {
                                                require_once "colors.php";
 
-                                               $favicon_color = db_escape_string($link,
+                                               $favicon_color = db_escape_string(
                                                        calculate_avg_color($favicon_file));
 
                                                $favicon_colorstring = ",favicon_avg_color = '".$favicon_color."'";
                                }
 
-                               db_query($link, "UPDATE ttrss_feeds SET favicon_last_checked = NOW()
+                               db_query( "UPDATE ttrss_feeds SET favicon_last_checked = NOW()
                                        $favicon_colorstring
                                        WHERE id = '$feed'");
                        }
 
                        if (!$registered_title || $registered_title == "[Unknown]") {
 
-                               $feed_title = db_escape_string($link, $rss->get_title());
+                               $feed_title = db_escape_string( $rss->get_title());
 
                                if ($debug_enabled) {
                                        _debug("update_rss_feed: registering title: $feed_title");
                                }
 
-                               db_query($link, "UPDATE ttrss_feeds SET
+                               db_query( "UPDATE ttrss_feeds SET
                                        title = '$feed_title' WHERE id = '$feed'");
                        }
 
                        if ($site_url && $orig_site_url != $site_url) {
-                               db_query($link, "UPDATE ttrss_feeds SET
+                               db_query( "UPDATE ttrss_feeds SET
                                        site_url = '$site_url' WHERE id = '$feed'");
                        }
 
                                _debug("update_rss_feed: loading filters & labels...");
                        }
 
-                       $filters = load_filters($link, $feed, $owner_uid);
-                       $labels = get_all_labels($link, $owner_uid);
+                       $filters = load_filters( $feed, $owner_uid);
+                       $labels = get_all_labels( $owner_uid);
 
                        if ($debug_enabled) {
                                //print_r($filters);
                                        _debug("update_rss_feed: no articles found.");
                                }
 
-                               db_query($link, "UPDATE ttrss_feeds
+                               db_query( "UPDATE ttrss_feeds
                                        SET last_updated = NOW(), last_error = '' WHERE id = '$feed'");
 
                                return; // no articles
                                        if ($debug_enabled)
                                                _debug("update_rss_feed: feed hub url found, subscribe request sent.");
 
-                                       db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 1
+                                       db_query( "UPDATE ttrss_feeds SET pubsub_state = 1
                                                WHERE id = '$feed'");
                                }
                        }
 
                                $entry_guid = "$owner_uid,$entry_guid";
 
-                               $entry_guid_hashed = db_escape_string($link, 'SHA1:' . sha1($entry_guid));
+                               $entry_guid_hashed = db_escape_string( 'SHA1:' . sha1($entry_guid));
 
                                if ($debug_enabled) {
                                        _debug("update_rss_feed: guid $entry_guid / $entry_guid_hashed");
                                        $entry_author = $entry_author_item->get_name();
                                        if (!$entry_author) $entry_author = $entry_author_item->get_email();
 
-                                       $entry_author = db_escape_string($link, $entry_author);
+                                       $entry_author = db_escape_string( $entry_author);
                                }
 
-                               $entry_guid = db_escape_string($link, mb_substr($entry_guid, 0, 245));
+                               $entry_guid = db_escape_string( mb_substr($entry_guid, 0, 245));
 
-                               $entry_comments = db_escape_string($link, mb_substr($entry_comments, 0, 245));
-                               $entry_author = db_escape_string($link, mb_substr($entry_author, 0, 245));
+                               $entry_comments = db_escape_string( mb_substr($entry_comments, 0, 245));
+                               $entry_author = db_escape_string( mb_substr($entry_author, 0, 245));
 
                                $num_comments = $item->get_item_tags('http://purl.org/rss/1.0/modules/slash/', 'comments');
 
                                }
 
                                // FIXME not sure if owner_uid is a good idea here, we may have a base entry without user entry (?)
-                               $result = db_query($link, "SELECT plugin_data,title,content,link,tag_cache,author FROM ttrss_entries, ttrss_user_entries
-                                       WHERE ref_id = id AND (guid = '".db_escape_string($link, $entry_guid)."' OR guid = '$entry_guid_hashed') AND owner_uid = $owner_uid");
+                               $result = db_query( "SELECT plugin_data,title,content,link,tag_cache,author FROM ttrss_entries, ttrss_user_entries
+                                       WHERE ref_id = id AND (guid = '".db_escape_string( $entry_guid)."' OR guid = '$entry_guid_hashed') AND owner_uid = $owner_uid");
 
                                if (db_num_rows($result) != 0) {
                                        $entry_plugin_data = db_fetch_result($result, 0, "plugin_data");
                                }
 
                                $entry_tags = $article["tags"];
-                               $entry_guid = db_escape_string($link, $entry_guid);
-                               $entry_title = db_escape_string($link, $article["title"]);
-                               $entry_author = db_escape_string($link, $article["author"]);
-                               $entry_link = db_escape_string($link, $article["link"]);
-                               $entry_plugin_data = db_escape_string($link, $article["plugin_data"]);
+                               $entry_guid = db_escape_string( $entry_guid);
+                               $entry_title = db_escape_string( $article["title"]);
+                               $entry_author = db_escape_string( $article["author"]);
+                               $entry_link = db_escape_string( $article["link"]);
+                               $entry_plugin_data = db_escape_string( $article["plugin_data"]);
                                $entry_content = $article["content"]; // escaped below
 
 
                                if ($cache_images && is_writable(CACHE_DIR . '/images'))
                                        cache_images($entry_content, $site_url, $debug_enabled);
 
-                               $entry_content = db_escape_string($link, $entry_content, false);
+                               $entry_content = db_escape_string( $entry_content, false);
 
                                $content_hash = "SHA1:" . sha1($entry_content);
 
-                               db_query($link, "BEGIN");
+                               db_query( "BEGIN");
 
-                               $result = db_query($link, "SELECT id FROM       ttrss_entries
+                               $result = db_query( "SELECT id FROM     ttrss_entries
                                        WHERE (guid = '$entry_guid' OR guid = '$entry_guid_hashed')");
 
                                if (db_num_rows($result) == 0) {
 
                                        // base post entry does not exist, create it
 
-                                       $result = db_query($link,
+                                       $result = db_query(
                                                "INSERT INTO ttrss_entries
                                                        (title,
                                                        guid,
 
                                        $base_entry_id = db_fetch_result($result, 0, "id");
 
-                                       db_query($link, "UPDATE ttrss_entries SET date_updated = NOW()
+                                       db_query( "UPDATE ttrss_entries SET date_updated = NOW()
                                                WHERE id = '$base_entry_id'");
 
-                                       $article_labels = get_article_labels($link, $base_entry_id, $owner_uid);
+                                       $article_labels = get_article_labels( $base_entry_id, $owner_uid);
                                }
 
                                // now it should exist, if not - bad luck then
 
-                               $result = db_query($link, "SELECT
+                               $result = db_query( "SELECT
                                                id,content_hash,no_orig_date,title,plugin_data,guid,
                                                ".SUBSTRING_FOR_DATE."(date_updated,1,19) as date_updated,
                                                ".SUBSTRING_FOR_DATE."(updated,1,19) as updated,
                                        if ($stored_guid != $entry_guid_hashed) {
                                                if ($debug_enabled) _debug("upgrading compat guid to hashed one");
 
-                                               db_query($link, "UPDATE ttrss_entries SET guid = '$entry_guid_hashed' WHERE
+                                               db_query( "UPDATE ttrss_entries SET guid = '$entry_guid_hashed' WHERE
                                                        id = '$ref_id'");
                                        } */
 
                                        // check for user post link to main table
 
                                        // do we allow duplicate posts with same GUID in different feeds?
-                                       if (get_pref($link, "ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
+                                       if (get_pref( "ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
                                                $dupcheck_qpart = "AND (feed_id = '$feed' OR feed_id IS NULL)";
                                        } else {
                                                $dupcheck_qpart = "";
                                        }
 
                                        if (find_article_filter($article_filters, "filter")) {
-                                               db_query($link, "COMMIT"); // close transaction in progress
+                                               db_query( "COMMIT"); // close transaction in progress
                                                continue;
                                        }
 
 
 //                                     if ($_REQUEST["xdebug"]) print "$query\n";
 
-                                       $result = db_query($link, $query);
+                                       $result = db_query( $query);
 
                                        // okay it doesn't exist - create user entry
                                        if (db_num_rows($result) == 0) {
 
                                                if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_DUPLICATE_THRESHOLD')) {
 
-                                                       $result = db_query($link, "SELECT COUNT(*) AS similar FROM
+                                                       $result = db_query( "SELECT COUNT(*) AS similar FROM
                                                                        ttrss_entries,ttrss_user_entries
                                                                WHERE ref_id = id AND updated >= NOW() - INTERVAL '7 day'
                                                                        AND similarity(title, '$entry_title') >= "._NGRAM_TITLE_DUPLICATE_THRESHOLD."
                                                $last_marked = ($marked == 'true') ? 'NOW()' : 'NULL';
                                                $last_published = ($published == 'true') ? 'NOW()' : 'NULL';
 
-                                               $result = db_query($link,
+                                               $result = db_query(
                                                        "INSERT INTO ttrss_user_entries
                                                                (ref_id, owner_uid, feed_id, unread, last_read, marked,
                                                                published, score, tag_cache, label_cache, uuid,
                                                if (PUBSUBHUBBUB_HUB && $published == 'true') {
                                                        $rss_link = get_self_url_prefix() .
                                                                "/public.php?op=rss&id=-2&key=" .
-                                                               get_feed_access_key($link, -2, false, $owner_uid);
+                                                               get_feed_access_key( -2, false, $owner_uid);
 
                                                        $p = new Publisher(PUBSUBHUBBUB_HUB);
 
                                                        $pubsub_result = $p->publish_update($rss_link);
                                                }
 
-                                               $result = db_query($link,
+                                               $result = db_query(
                                                        "SELECT int_id FROM ttrss_user_entries WHERE
                                                                ref_id = '$ref_id' AND owner_uid = '$owner_uid' AND
                                                                feed_id = '$feed' LIMIT 1");
                                                $update_insignificant = false;
                                        }
 
-                                       if (db_escape_string($link, $orig_title) != $entry_title) {
+                                       if (db_escape_string( $orig_title) != $entry_title) {
                                                $post_needs_update = true;
                                                $update_insignificant = false;
                                        }
 
 //                                             print "<!-- post $orig_title needs update : $post_needs_update -->";
 
-                                               db_query($link, "UPDATE ttrss_entries
+                                               db_query( "UPDATE ttrss_entries
                                                        SET title = '$entry_title', content = '$entry_content',
                                                                content_hash = '$content_hash',
                                                                updated = '$entry_timestamp_fmt',
 
                                                if (!$update_insignificant) {
                                                        if ($mark_unread_on_update) {
-                                                               db_query($link, "UPDATE ttrss_user_entries
+                                                               db_query( "UPDATE ttrss_user_entries
                                                                        SET last_read = null, unread = true WHERE ref_id = '$ref_id'");
                                                        }
                                                }
                                        }
                                }
 
-                               db_query($link, "COMMIT");
+                               db_query( "COMMIT");
 
                                if ($debug_enabled) {
                                        _debug("update_rss_feed: assigning labels...");
                                }
 
-                               assign_article_to_label_filters($link, $entry_ref_id, $article_filters,
+                               assign_article_to_label_filters( $entry_ref_id, $article_filters,
                                        $owner_uid, $article_labels);
 
                                if ($debug_enabled) {
                                        print_r($enclosures);
                                }
 
-                               db_query($link, "BEGIN");
+                               db_query( "BEGIN");
 
                                foreach ($enclosures as $enc) {
-                                       $enc_url = db_escape_string($link, $enc[0]);
-                                       $enc_type = db_escape_string($link, $enc[1]);
-                                       $enc_dur = db_escape_string($link, $enc[2]);
+                                       $enc_url = db_escape_string( $enc[0]);
+                                       $enc_type = db_escape_string( $enc[1]);
+                                       $enc_dur = db_escape_string( $enc[2]);
 
-                                       $result = db_query($link, "SELECT id FROM ttrss_enclosures
+                                       $result = db_query( "SELECT id FROM ttrss_enclosures
                                                WHERE content_url = '$enc_url' AND post_id = '$entry_ref_id'");
 
                                        if (db_num_rows($result) == 0) {
-                                               db_query($link, "INSERT INTO ttrss_enclosures
+                                               db_query( "INSERT INTO ttrss_enclosures
                                                        (content_url, content_type, title, duration, post_id) VALUES
                                                        ('$enc_url', '$enc_type', '', '$enc_dur', '$entry_ref_id')");
                                        }
                                }
 
-                               db_query($link, "COMMIT");
+                               db_query( "COMMIT");
 
                                // check for manual tags (we have to do it here since they're loaded from filters)
 
 
                                // Skip boring tags
 
-                               $boring_tags = trim_array(explode(",", mb_strtolower(get_pref($link,
+                               $boring_tags = trim_array(explode(",", mb_strtolower(get_pref(
                                        'BLACKLISTED_TAGS', $owner_uid, ''), 'utf-8')));
 
                                $filtered_tags = array();
 
                                if (count($filtered_tags) > 0) {
 
-                                       db_query($link, "BEGIN");
+                                       db_query( "BEGIN");
 
                                        foreach ($filtered_tags as $tag) {
 
                                                $tag = sanitize_tag($tag);
-                                               $tag = db_escape_string($link, $tag);
+                                               $tag = db_escape_string( $tag);
 
                                                if (!tag_is_valid($tag)) continue;
 
-                                               $result = db_query($link, "SELECT id FROM ttrss_tags
+                                               $result = db_query( "SELECT id FROM ttrss_tags
                                                        WHERE tag_name = '$tag' AND post_int_id = '$entry_int_id' AND
                                                        owner_uid = '$owner_uid' LIMIT 1");
 
                                                        if ($result && db_num_rows($result) == 0) {
 
-                                                               db_query($link, "INSERT INTO ttrss_tags
+                                                               db_query( "INSERT INTO ttrss_tags
                                                                        (owner_uid,tag_name,post_int_id)
                                                                        VALUES ('$owner_uid','$tag', '$entry_int_id')");
                                                        }
 
                                        $tags_to_cache = array_unique($tags_to_cache);
 
-                                       $tags_str = db_escape_string($link, join(",", $tags_to_cache));
+                                       $tags_str = db_escape_string( join(",", $tags_to_cache));
 
-                                       db_query($link, "UPDATE ttrss_user_entries
+                                       db_query( "UPDATE ttrss_user_entries
                                                SET tag_cache = '$tags_str' WHERE ref_id = '$entry_ref_id'
                                                AND owner_uid = $owner_uid");
 
-                                       db_query($link, "COMMIT");
+                                       db_query( "COMMIT");
                                }
 
-                               if (get_pref($link, "AUTO_ASSIGN_LABELS", $owner_uid, false)) {
+                               if (get_pref( "AUTO_ASSIGN_LABELS", $owner_uid, false)) {
                                        if ($debug_enabled) {
                                                _debug("update_rss_feed: auto-assigning labels...");
                                        }
 
                                                if ($caption && preg_match("/\b$caption\b/i", "$tags_str " . strip_tags($entry_content) . " $entry_title")) {
                                                        if (!labels_contains_caption($article_labels, $caption)) {
-                                                               label_add_article($link, $entry_ref_id, $caption, $owner_uid);
+                                                               label_add_article( $entry_ref_id, $caption, $owner_uid);
                                                        }
                                                }
                                        }
                                if ($debug_enabled) {
                                        _debug("update_rss_feed: new feed, catching it up...");
                                }
-                               catchup_feed($link, $feed, false, $owner_uid);
+                               catchup_feed( $feed, false, $owner_uid);
                        }
 
                        if ($debug_enabled) {
                                _debug("purging feed...");
                        }
 
-                       purge_feed($link, $feed, 0, $debug_enabled);
+                       purge_feed( $feed, 0, $debug_enabled);
 
-                       db_query($link, "UPDATE ttrss_feeds
+                       db_query( "UPDATE ttrss_feeds
                                SET last_updated = NOW(), last_error = '' WHERE id = '$feed'");
 
-//                     db_query($link, "COMMIT");
+//                     db_query( "COMMIT");
 
                } else {
 
-                       $error_msg = db_escape_string($link, mb_substr($rss->error(), 0, 245));
+                       $error_msg = db_escape_string( mb_substr($rss->error(), 0, 245));
 
                        if ($debug_enabled) {
                                _debug("update_rss_feed: error fetching feed: $error_msg");
                        }
 
-                       db_query($link,
+                       db_query(
                                "UPDATE ttrss_feeds SET last_error = '$error_msg',
                                        last_updated = NOW() WHERE id = '$feed'");
                }
                return $doc->saveXML($node);
        }
 
-       function expire_error_log($link, $debug) {
+       function expire_error_log( $debug) {
                if ($debug) _debug("Removing old error log entries...");
 
                if (DB_TYPE == "pgsql") {
-                       db_query($link, "DELETE FROM ttrss_error_log
+                       db_query( "DELETE FROM ttrss_error_log
                                WHERE created_at < NOW() - INTERVAL '7 days'");
                } else {
-                       db_query($link, "DELETE FROM ttrss_error_log
+                       db_query( "DELETE FROM ttrss_error_log
                                WHERE created_at < DATE_SUB(NOW(), INTERVAL 7 DAY)");
                }
 
                return $params;
        }
 
-       function get_article_filters($filters, $title, $content, $link, $timestamp, $author, $tags) {
+       function get_article_filters($filters, $title, $content,  $timestamp, $author, $tags) {
                $matches = array();
 
                foreach ($filters as $filter) {
                return false;
        }
 
-       function assign_article_to_label_filters($link, $id, $filters, $owner_uid, $article_labels) {
+       function assign_article_to_label_filters( $id, $filters, $owner_uid, $article_labels) {
                foreach ($filters as $f) {
                        if ($f["type"] == "label") {
                                if (!labels_contains_caption($article_labels, $f["param"])) {
-                                       label_add_article($link, $id, $f["param"], $owner_uid);
+                                       label_add_article( $id, $f["param"], $owner_uid);
                                }
                        }
                }
index 29de4ff5e8762c115de0aae94317576de0b781e5..0477efd5077fb37d81ea5a7385fe1e061c0b0fe5 100644 (file)
@@ -21,7 +21,7 @@
                return $url_path;
        }
 
-       function initial_sanity_check($link) {
+       function initial_sanity_check() {
 
                $errors = array();
 
                        }
 
                        if (SINGLE_USER_MODE) {
-                               $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
+                               $result = db_query( "SELECT id FROM ttrss_users WHERE id = 1");
 
-                               if ($link) {
-                                       $result = db_query($link, "SELECT id FROM ttrss_users WHERE id = 1");
-
-                                       if (db_num_rows($result) != 1) {
-                                               array_push($errors, "SINGLE_USER_MODE is enabled in config.php but default admin account is not found.");
-                                       }
+                               if (db_num_rows($result) != 1) {
+                                       array_push($errors, "SINGLE_USER_MODE is enabled in config.php but default admin account is not found.");
                                }
                        }
 
                }
        }
 
-       initial_sanity_check($link);
+       initial_sanity_check();
 
 ?>
index f6e8bfe615067595371724671c7b42bd08a5a8ad..c4876489fa3165a486909a45158539cda583acce 100644 (file)
@@ -36,7 +36,7 @@
                }
        }
 
-       function validate_session($link) {
+       function validate_session() {
                if (SINGLE_USER_MODE) return true;
 
                if (VERSION != $_SESSION["version"]) return false;
index 66e236dae28664e781243d8603f767b831d0a2fe..cb95b96f0219afdc4fe7e359e3a0a41597588611 100644 (file)
--- a/index.php
+++ b/index.php
@@ -32,7 +32,7 @@
 
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
 
-       if (!init_plugins($link)) return;
+       if (!init_plugins()) return;
 
        global $pluginhost;
 
@@ -49,7 +49,7 @@
                }
        }
 
-       login_sequence($link);
+       login_sequence();
 
        header('Content-Type: text/html; charset=utf-8');
 
        <?php echo stylesheet_tag("cdm.css"); ?>
 
        <?php if ($_SESSION["uid"]) {
-               $theme = get_pref($link, "USER_CSS_THEME", $_SESSION["uid"], false);
+               $theme = get_pref( "USER_CSS_THEME", $_SESSION["uid"], false);
                if ($theme) {
                        echo stylesheet_tag("themes/$theme");
                }
        }
        ?>
 
-       <?php print_user_stylesheet($link) ?>
+       <?php print_user_stylesheet() ?>
 
        <style type="text/css">
        <?php
 </div>
 </div>
 
-<?php db_close($link); ?>
+<?php db_close(); ?>
 
 </body>
 </html>
index 709cfd4ccb79fbffc9e23ad10f14f243255d4e51..c8fbf1c394c20a0d32d44c762c7fac98351aa2a2 100644 (file)
--- a/opml.php
+++ b/opml.php
 
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
 
-       if (!init_plugins($link)) return;
+       if (!init_plugins()) return;
 
        $op = $_REQUEST['op'];
 
        if ($op == "publish"){
-               $key = db_escape_string($link, $_REQUEST["key"]);
+               $key = db_escape_string( $_REQUEST["key"]);
 
-               $result = db_query($link, "SELECT owner_uid
+               $result = db_query( "SELECT owner_uid
                                FROM ttrss_access_keys WHERE
                                access_key = '$key' AND feed_id = 'OPML:Publish'");
 
                if (db_num_rows($result) == 1) {
                        $owner_uid = db_fetch_result($result, 0, "owner_uid");
 
-                       $opml = new Opml($link, $_REQUEST);
+                       $opml = new Opml( $_REQUEST);
                        $opml->opml_export("", $owner_uid, true, false);
 
                } else {
@@ -34,6 +34,6 @@
                }
        }
 
-       db_close($link);
+       db_close();
 
 ?>
index c9f6505cddbb89e1f2f28e6ad60246063e521e05..e1a01b3dd2094a2a9fa4a2fffa372eda079a4996 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 class Af_Buttersafe extends Plugin {
 
-       private $link;
        private $host;
 
        function about() {
@@ -11,7 +10,6 @@ class Af_Buttersafe extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
index 2a8fab491416bd43c308ec76c2d63f7623c190d7..b5e34657ca1f16d17837bde9b22812e79817ad60 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 class Af_Explosm extends Plugin {
 
-       private $link;
        private $host;
 
        function about() {
@@ -11,7 +10,6 @@ class Af_Explosm extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
index 466ec9687a34f525ffa8fa8081dad2df54b8351b..39dd0c8520cfe011f24fdeb909cc48dedf39e504 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 class Af_GoComics extends Plugin {
-
-       private $link;
        private $host;
 
        function about() {
@@ -11,7 +9,6 @@ class Af_GoComics extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
index 06c1230a6f718ccdc845c98a00677576d37a46a4..d897d85ca363edad823cde1d12517b408a3ad1c7 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 class Af_PennyArcade extends Plugin {
 
-       private $link;
        private $host;
 
        function about() {
@@ -11,7 +10,6 @@ class Af_PennyArcade extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
@@ -22,11 +20,11 @@ class Af_PennyArcade extends Plugin {
 
                if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE) {
                        if (strpos($article["plugin_data"], "pennyarcade,$owner_uid:") === FALSE) {
-                               
+
                                if ($debug_enabled) {
                                        _debug("af_pennyarcade: Processing comic");
                                }
-                               
+
                                $doc = new DOMDocument();
                                $doc->loadHTML(fetch_file_contents($article["link"]));
 
@@ -49,7 +47,7 @@ class Af_PennyArcade extends Plugin {
                                $article["content"] = $article["stored"]["content"];
                        }
                }
-       
+
                if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "News Post:") !== FALSE) {
                        if (strpos($article["plugin_data"], "pennyarcade,$owner_uid:") === FALSE) {
                                if ($debug_enabled) {
@@ -57,22 +55,22 @@ class Af_PennyArcade extends Plugin {
                                }
                                $doc = new DOMDocument();
                                $doc->loadHTML(fetch_file_contents($article["link"]));
-                               
+
                                if ($doc) {
                                        $xpath = new DOMXPath($doc);
                                        $entries = $xpath->query('(//div[@class="post"])');
-                                       
+
                                        $basenode = false;
-                                       
+
                                        foreach ($entries as $entry) {
                                                $basenode = $entry;
                                        }
-                                       
+
                                        $uninteresting = $xpath->query('(//div[@class="heading"])');
                                        foreach ($uninteresting as $i) {
                                                $i->parentNode->removeChild($i);
                                        }
-                                       
+
                                        if ($basenode){
                                                $article["content"] = $doc->saveXML($basenode);
                                                $article["plugin_data"] = "pennyarcade,$owner_uid:" . $article["plugin_data"];
index f2d5c7b674906712e634e7f6d1ad8f72b1abfda4..d5b3e5c20642903a25b9317faf737ded14589ea6 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 class Af_RedditImgur extends Plugin {
-
-       private $link;
        private $host;
 
        function about() {
@@ -11,7 +9,6 @@ class Af_RedditImgur extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
index f3cc1eefa5f89f471dd5e4d9809139ce9f8c88e1..67939f80e35d5529e41018b0d72253c90fbef0df 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 class Af_Unburn extends Plugin {
-
-       private $link;
        private $host;
 
        function about() {
@@ -11,7 +9,6 @@ class Af_Unburn extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
index e2b02b05da32f4e1a375d2728b3bec75c31871c3..b6d8e97dcd3f6063992fde40f96c8d9c72895255 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 class Auth_Internal extends Plugin implements IAuthModule {
-
-       private $link;
        private $host;
 
        function about() {
@@ -12,7 +10,6 @@ class Auth_Internal extends Plugin implements IAuthModule {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_AUTH_USER, $this);
@@ -22,12 +19,12 @@ class Auth_Internal extends Plugin implements IAuthModule {
 
                $pwd_hash1 = encrypt_password($password);
                $pwd_hash2 = encrypt_password($password, $login);
-               $login = db_escape_string($this->link, $login);
-               $otp = db_escape_string($this->link, $_REQUEST["otp"]);
+               $login = db_escape_string( $login);
+               $otp = db_escape_string( $_REQUEST["otp"]);
 
-               if (get_schema_version($this->link) > 96) {
+               if (get_schema_version() > 96) {
                        if (!defined('AUTH_DISABLE_OTP') || !AUTH_DISABLE_OTP) {
-                               $result = db_query($this->link, "SELECT otp_enabled,salt FROM ttrss_users WHERE
+                               $result = db_query( "SELECT otp_enabled,salt FROM ttrss_users WHERE
                                        login = '$login'");
 
                                if (db_num_rows($result) > 0) {
@@ -75,9 +72,9 @@ class Auth_Internal extends Plugin implements IAuthModule {
                        }
                }
 
-               if (get_schema_version($this->link) > 87) {
+               if (get_schema_version() > 87) {
 
-                       $result = db_query($this->link, "SELECT salt FROM ttrss_users WHERE
+                       $result = db_query( "SELECT salt FROM ttrss_users WHERE
                                login = '$login'");
 
                        if (db_num_rows($result) != 1) {
@@ -95,7 +92,7 @@ class Auth_Internal extends Plugin implements IAuthModule {
 
                                // verify and upgrade password to new salt base
 
-                               $result = db_query($this->link, $query);
+                               $result = db_query( $query);
 
                                if (db_num_rows($result) == 1) {
                                        // upgrade password to MODE2
@@ -103,7 +100,7 @@ class Auth_Internal extends Plugin implements IAuthModule {
                                        $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
                                        $pwd_hash = encrypt_password($password, $salt, true);
 
-                                       db_query($this->link, "UPDATE ttrss_users SET
+                                       db_query( "UPDATE ttrss_users SET
                                                pwd_hash = '$pwd_hash', salt = '$salt' WHERE login = '$login'");
 
                                        $query = "SELECT id
@@ -131,7 +128,7 @@ class Auth_Internal extends Plugin implements IAuthModule {
                                        pwd_hash = '$pwd_hash2')";
                }
 
-               $result = db_query($this->link, $query);
+               $result = db_query( $query);
 
                if (db_num_rows($result) == 1) {
                        return db_fetch_result($result, 0, "id");
@@ -141,9 +138,9 @@ class Auth_Internal extends Plugin implements IAuthModule {
        }
 
        function check_password($owner_uid, $password) {
-               $owner_uid = db_escape_string($this->link, $owner_uid);
+               $owner_uid = db_escape_string( $owner_uid);
 
-               $result = db_query($this->link, "SELECT salt,login FROM ttrss_users WHERE
+               $result = db_query( "SELECT salt,login FROM ttrss_users WHERE
                        id = '$owner_uid'");
 
                $salt = db_fetch_result($result, 0, "salt");
@@ -164,20 +161,20 @@ class Auth_Internal extends Plugin implements IAuthModule {
                                id = '$owner_uid' AND pwd_hash = '$password_hash'";
                }
 
-               $result = db_query($this->link, $query);
+               $result = db_query( $query);
 
                return db_num_rows($result) != 0;
        }
 
        function change_password($owner_uid, $old_password, $new_password) {
-               $owner_uid = db_escape_string($this->link, $owner_uid);
+               $owner_uid = db_escape_string( $owner_uid);
 
                if ($this->check_password($owner_uid, $old_password)) {
 
                        $new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
                        $new_password_hash = encrypt_password($new_password, $new_salt, true);
 
-                       db_query($this->link, "UPDATE ttrss_users SET
+                       db_query( "UPDATE ttrss_users SET
                                pwd_hash = '$new_password_hash', salt = '$new_salt', otp_enabled = false
                                        WHERE id = '$owner_uid'");
 
index 7e4638fb2b9ac67a638be1e9bb95ec6b5cdcd316..f0da1afc8b51ee9d0dc685f5b19d46a291d60ff6 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 class Auth_Remote extends Plugin implements IAuthModule {
 
-       private $link;
        private $host;
        private $base;
 
@@ -13,23 +12,22 @@ class Auth_Remote extends Plugin implements IAuthModule {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
-               $this->base = new Auth_Base($this->link);
+               $this->base = new Auth_Base();
 
                $host->add_hook($host::HOOK_AUTH_USER, $this);
        }
 
        function get_login_by_ssl_certificate() {
-               $cert_serial = db_escape_string($this->link, get_ssl_certificate_id());
+               $cert_serial = db_escape_string( get_ssl_certificate_id());
 
                if ($cert_serial) {
-                       $result = db_query($this->link, "SELECT login FROM ttrss_user_prefs, ttrss_users
+                       $result = db_query( "SELECT login FROM ttrss_user_prefs, ttrss_users
                                WHERE pref_name = 'SSL_CERT_SERIAL' AND value = '$cert_serial' AND
                                owner_uid = ttrss_users.id");
 
                        if (db_num_rows($result) != 0) {
-                               return db_escape_string($this->link, db_fetch_result($result, 0, "login"));
+                               return db_escape_string( db_fetch_result($result, 0, "login"));
                        }
                }
 
@@ -38,10 +36,10 @@ class Auth_Remote extends Plugin implements IAuthModule {
 
 
        function authenticate($login, $password) {
-               $try_login = db_escape_string($this->link, $_SERVER["REMOTE_USER"]);
+               $try_login = db_escape_string( $_SERVER["REMOTE_USER"]);
 
                // php-cgi
-               if (!$try_login) $try_login = db_escape_string($this->link, $_SERVER["REDIRECT_REMOTE_USER"]);
+               if (!$try_login) $try_login = db_escape_string( $_SERVER["REDIRECT_REMOTE_USER"]);
 
                if (!$try_login) $try_login = $this->get_login_by_ssl_certificate();
 #              if (!$try_login) $try_login = "test_qqq";
@@ -60,15 +58,15 @@ class Auth_Remote extends Plugin implements IAuthModule {
                                        // update user name
                                        $fullname = $_SERVER['HTTP_USER_NAME'] ? $_SERVER['HTTP_USER_NAME'] : $_SERVER['AUTHENTICATE_CN'];
                                        if ($fullname){
-                                               $fullname = db_escape_string($this->link, $fullname);
-                                               db_query($this->link, "UPDATE ttrss_users SET full_name = '$fullname' WHERE id = " .
+                                               $fullname = db_escape_string( $fullname);
+                                               db_query( "UPDATE ttrss_users SET full_name = '$fullname' WHERE id = " .
                                                        $user_id);
                                        }
                                        // update user mail
                                        $email = $_SERVER['HTTP_USER_MAIL'] ? $_SERVER['HTTP_USER_MAIL'] : $_SERVER['AUTHENTICATE_MAIL'];
                                        if ($email){
-                                               $email = db_escape_string($this->link, $email);
-                                               db_query($this->link, "UPDATE ttrss_users SET email = '$email' WHERE id = " .
+                                               $email = db_escape_string( $email);
+                                               db_query( "UPDATE ttrss_users SET email = '$email' WHERE id = " .
                                                        $user_id);
                                        }
                                }
index 22f4f05a7aa64b56f854b01c1c660d4d8963b94c..be0da83c9d878aaf3f619a124735a7c62bfdf279 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 class Bookmarklets extends Plugin {
-  private $link;
   private $host;
 
   function about() {
@@ -10,7 +9,6 @@ class Bookmarklets extends Plugin {
   }
 
   function init($host) {
-    $this->link = $host->get_link();
     $this->host = $host;
 
     $host->add_hook($host::HOOK_PREFS_TAB, $this);
index ff2027bc78cd7c98351b018c8bc13adfd79f6b5b..6fdd96f557272baea79c4797be5cb54603cd7b99 100644 (file)
@@ -1,10 +1,8 @@
 <?php
 class Close_Button extends Plugin {
-       private $link;
        private $host;
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
@@ -17,7 +15,7 @@ class Close_Button extends Plugin {
        }
 
        function hook_article_button($line) {
-               if (!get_pref($this->link, "COMBINED_DISPLAY_MODE")) {
+               if (!get_pref( "COMBINED_DISPLAY_MODE")) {
                        $rv = "<img src=\"plugins/close_button/button.png\"
                                class='tagsPic' style=\"cursor : pointer\"
                                onclick=\"closeArticlePanel()\"
index e7434fe70053157712467fdfddcf3188037b8dc9..18932e53615972771d24104e96cbaa21e160a691 100644 (file)
@@ -1,5 +1,3 @@
-<?php global $link; ?>
-
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
@@ -25,7 +23,7 @@
 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 
-       <?php print_user_stylesheet($link) ?>
+       <?php print_user_stylesheet(); ?>
 
        <link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
 
index e65ae13d72c309be647aa5844c9e9e0c37b5eabc..5b84fec16bc02ca1ca714acf507badf6cfd298f3 100644 (file)
@@ -1,8 +1,6 @@
 <?php
 // TODO: digest should register digest specific hotkey actions within tt-rss
 class Digest extends Plugin implements IHandler {
-
-       private $link;
        private $host;
 
        function about() {
@@ -13,7 +11,6 @@ class Digest extends Plugin implements IHandler {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_handler("digest", "*", $this);
@@ -22,10 +19,7 @@ class Digest extends Plugin implements IHandler {
        function index() {
                header("Content-type: text/html; charset=utf-8");
 
-               login_sequence($this->link);
-
-               global $link;
-               $link = $this->link;
+               login_sequence();
 
                require_once dirname(__FILE__) . "/digest_body.php";
        }
@@ -47,13 +41,13 @@ class Digest extends Plugin implements IHandler {
        }
 
        function digestgetcontents() {
-               $article_id = db_escape_string($this->link, $_REQUEST['article_id']);
+               $article_id = db_escape_string( $_REQUEST['article_id']);
 
-               $result = db_query($this->link, "SELECT content,title,link,marked,published
+               $result = db_query( "SELECT content,title,link,marked,published
                        FROM ttrss_entries, ttrss_user_entries
                        WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']);
 
-               $content = sanitize($this->link, db_fetch_result($result, 0, "content"));
+               $content = sanitize( db_fetch_result($result, 0, "content"));
                $title = strip_tags(db_fetch_result($result, 0, "title"));
                $article_url = htmlspecialchars(db_fetch_result($result, 0, "link"));
                $marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked"));
@@ -61,15 +55,15 @@ class Digest extends Plugin implements IHandler {
 
                print json_encode(array("article" =>
                        array("id" => $article_id, "url" => $article_url,
-                               "tags" => get_article_tags($this->link, $article_id),
+                               "tags" => get_article_tags( $article_id),
                                "marked" => $marked, "published" => $published,
                                "title" => $title, "content" => $content)));
        }
 
        function digestupdate() {
-               $feed_id = db_escape_string($this->link, $_REQUEST['feed_id']);
-               $offset = db_escape_string($this->link, $_REQUEST['offset']);
-               $seq = db_escape_string($this->link, $_REQUEST['seq']);
+               $feed_id = db_escape_string( $_REQUEST['feed_id']);
+               $offset = db_escape_string( $_REQUEST['offset']);
+               $seq = db_escape_string( $_REQUEST['seq']);
 
                if (!$feed_id) $feed_id = -4;
                if (!$offset) $offset = 0;
@@ -78,18 +72,18 @@ class Digest extends Plugin implements IHandler {
 
                $reply['seq'] = $seq;
 
-               $headlines = API::api_get_headlines($this->link, $feed_id, 30, $offset,
+               $headlines = API::api_get_headlines( $feed_id, 30, $offset,
                                '', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0);
 
                $reply['headlines'] = array();
-               $reply['headlines']['title'] = getFeedTitle($this->link, $feed_id);
+               $reply['headlines']['title'] = getFeedTitle( $feed_id);
                $reply['headlines']['content'] = $headlines;
 
                print json_encode($reply);
        }
 
        function digestinit() {
-               $tmp_feeds = API::api_get_feeds($this->link, -4, true, false, 0);
+               $tmp_feeds = API::api_get_feeds( -4, true, false, 0);
 
                $params = array();
                $feeds = array();
@@ -99,7 +93,7 @@ class Digest extends Plugin implements IHandler {
                }
 
                if ($_REQUEST["init"] == 1) {
-                       $params["hotkeys"] = get_hotkeys_map($this->link);
+                       $params["hotkeys"] = get_hotkeys_map();
                }
                $params["feeds"] = $feeds;
 
index 0e0eb9603de1112097c09dedb0921152b2525a24..f91acda7c8139d67949be371eacb217214bf85c0 100644 (file)
@@ -1,10 +1,8 @@
 <?php
 class Embed_Original extends Plugin {
-       private $link;
        private $host;
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
@@ -36,9 +34,9 @@ class Embed_Original extends Plugin {
        }
 
        function getUrl() {
-               $id = db_escape_string($this->link, $_REQUEST['id']);
+               $id = db_escape_string( $_REQUEST['id']);
 
-               $result = db_query($this->link, "SELECT link
+               $result = db_query( "SELECT link
                                FROM ttrss_entries, ttrss_user_entries
                                WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
 
index 333efd92da7705c8760e3daa033f2adf3834c06b..8deee84b49e0aa20718149948b2790a14c73b97e 100644 (file)
@@ -2,8 +2,6 @@
 class Example extends Plugin {
 
        // Demonstrates how to add a separate panel to the preferences screen and inject Javascript/save data using Dojo forms.
-
-       private $link;
        private $host;
 
        function about() {
@@ -15,14 +13,13 @@ class Example extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_PREFS_TAB, $this);
        }
 
        function save() {
-               $example_value = db_escape_string($this->link, $_POST["example_value"]);
+               $example_value = db_escape_string( $_POST["example_value"]);
 
                $this->host->set($this, "example", $example_value);
 
index a5f34b8652d92cb8982bb97ba89961bad9b99913..9e0ad18b92aab222136fa702400c1b70d6116893 100644 (file)
@@ -6,7 +6,6 @@ class Example_Api extends Plugin {
        // 1. status (STATUS_OK or STATUS_ERR)
        // 2. arbitrary payload
 
-       private $link;
        private $host;
 
        function about() {
@@ -18,7 +17,6 @@ class Example_Api extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_api_method("example_testmethod", $this);
index 05f95a40a0e40fdb9c60ead34b6089becdf43dbb..000be7c4c79a951511320fd770dd65f1d77e2d4b 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 class Example_Article extends Plugin {
 
-       private $link;
        private $host;
 
        function about() {
@@ -12,7 +11,6 @@ class Example_Article extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
index af14d3ff3fc9936b6b5a9d87a24877979c24b38c..19d089667152161179d85066187e6dded2b05e44 100644 (file)
@@ -4,7 +4,6 @@ class Example_Feed extends Plugin {
        // Demonstrates how to query data from the parsed feed object (SimplePie)
        // don't enable unless debugging feed through f D hotkey or manually.
 
-       private $link;
        private $host;
 
        function about() {
@@ -15,7 +14,6 @@ class Example_Feed extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_FEED_PARSED, $this);
index 31c5b6f284f67a1a7e29681bd400b4054df1d9f9..0ae446e336d9ed595ac7d90105fa60944e36ef8b 100644 (file)
@@ -12,7 +12,6 @@ class Example_Routing extends Plugin implements IHandler {
        // Any system method may be masked by plugins. You can mask
        // entire handler by supplying "*" instead of a method name.
 
-       private $link;
        private $host;
 
        function about() {
@@ -23,7 +22,6 @@ class Example_Routing extends Plugin implements IHandler {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_handler("test", "example", $this);
index e646809a4db185f37f9ce1904e42589c1e475f69..e7efa757b4229f3c9d928b02d3d759f1cf7bc93a 100644 (file)
@@ -6,7 +6,6 @@ class Example_VFeed extends Plugin {
 
        // Not implemented yet: stuff for 3 panel mode
 
-       private $link;
        private $host;
        private $dummy_id;
 
@@ -18,7 +17,6 @@ class Example_VFeed extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $this->dummy_id = $host->add_feed(-1, 'Dummy feed', 'images/pub_set.svg', $this);
@@ -29,7 +27,7 @@ class Example_VFeed extends Plugin {
        }
 
        function get_headlines($feed_id, $options) {
-               $qfh_ret = queryFeedHeadlines($this->link, -4,
+               $qfh_ret = queryFeedHeadlines( -4,
                        $options['limit'],
                        $options['view_mode'], $options['cat_view'],
                        $options['search'],
index d25d3288f4cebc423db34e6b7f431f2338174853..8986f469c99927f5f5c6fec0699da405ccd06176 100644 (file)
@@ -1,8 +1,5 @@
 <?php
 class GoogleReaderImport extends Plugin {
-
-
-       private $link;
        private $host;
 
        function about() {
@@ -14,7 +11,6 @@ class GoogleReaderImport extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_command("greader-import",
@@ -34,11 +30,11 @@ class GoogleReaderImport extends Plugin {
 
                _debug("please enter your username:");
 
-               $username = db_escape_string($this->link, trim(read_stdin()));
+               $username = db_escape_string( trim(read_stdin()));
 
                _debug("looking up user: $username...");
 
-               $result = db_query($this->link, "SELECT id FROM ttrss_users
+               $result = db_query( "SELECT id FROM ttrss_users
                        WHERE login = '$username'");
 
                if (db_num_rows($result) == 0) {
@@ -59,7 +55,7 @@ class GoogleReaderImport extends Plugin {
 
        function import($file = false, $owner_uid = 0) {
 
-               purge_orphans($this->link);
+               purge_orphans();
 
                if (!$file) {
                        header("Content-Type: text/html");
@@ -115,30 +111,30 @@ class GoogleReaderImport extends Plugin {
                                foreach ($doc['items'] as $item) {
 //                                     print_r($item);
 
-                                       $guid = db_escape_string($this->link, mb_substr($item['id'], 0, 250));
-                                       $title = db_escape_string($this->link, $item['title']);
+                                       $guid = db_escape_string( mb_substr($item['id'], 0, 250));
+                                       $title = db_escape_string( $item['title']);
                                        $updated = date('Y-m-d h:i:s', $item['updated']);
                                        $link = '';
                                        $content = '';
-                                       $author = db_escape_string($this->link, $item['author']);
+                                       $author = db_escape_string( $item['author']);
                                        $tags = array();
                                        $orig_feed_data = array();
 
                                        if (is_array($item['alternate'])) {
                                                foreach ($item['alternate'] as $alt) {
                                                        if (isset($alt['type']) && $alt['type'] == 'text/html') {
-                                                               $link = db_escape_string($this->link, $alt['href']);
+                                                               $link = db_escape_string( $alt['href']);
                                                        }
                                                }
                                        }
 
                                        if (is_array($item['summary'])) {
-                                               $content = db_escape_string($this->link,
+                                               $content = db_escape_string(
                                                        $item['summary']['content'], false);
                                        }
 
                                        if (is_array($item['content'])) {
-                                               $content = db_escape_string($this->link,
+                                               $content = db_escape_string(
                                                        $item['content']['content'], false);
                                        }
 
@@ -153,14 +149,14 @@ class GoogleReaderImport extends Plugin {
                                        if (is_array($item['origin'])) {
                                                if (strpos($item['origin']['streamId'], 'feed/') === 0) {
 
-                                                       $orig_feed_data['feed_url'] = db_escape_string($this->link,
+                                                       $orig_feed_data['feed_url'] = db_escape_string(
                                                                mb_substr(preg_replace("/^feed\//",
                                                                        "", $item['origin']['streamId']), 0, 200));
 
-                                                       $orig_feed_data['title'] = db_escape_string($this->link,
+                                                       $orig_feed_data['title'] = db_escape_string(
                                                                mb_substr($item['origin']['title'], 0, 200));
 
-                                                       $orig_feed_data['site_url'] = db_escape_string($this->link,
+                                                       $orig_feed_data['site_url'] = db_escape_string(
                                                                mb_substr($item['origin']['htmlUrl'], 0, 200));
                                                }
                                        }
@@ -168,7 +164,7 @@ class GoogleReaderImport extends Plugin {
                                        $processed++;
 
                                        $imported += (int) $this->create_article($owner_uid, $guid, $title,
-                                               $updated, $link, $content, $author, $sql_set_marked, $tags,
+                                               $updated,  $content, $author, $sql_set_marked, $tags,
                                                $orig_feed_data);
 
                                        if ($file && $processed % 25 == 0) {
@@ -200,7 +196,7 @@ class GoogleReaderImport extends Plugin {
        }
 
        // expects ESCAPED data
-       private function create_article($owner_uid, $guid, $title, $updated, $link, $content, $author, $marked, $tags, $orig_feed_data) {
+       private function create_article($owner_uid, $guid, $title, $updated,  $content, $author, $marked, $tags, $orig_feed_data) {
 
                if (!$guid) $guid = sha1($link);
 
@@ -210,9 +206,9 @@ class GoogleReaderImport extends Plugin {
 
                $content_hash = sha1($content);
 
-               if (filter_var($link, FILTER_VALIDATE_URL) === FALSE) return false;
+               if (filter_var( FILTER_VALIDATE_URL) === FALSE) return false;
 
-               db_query($this->link, "BEGIN");
+               db_query( "BEGIN");
 
                $feed_id = 'NULL';
 
@@ -223,7 +219,7 @@ class GoogleReaderImport extends Plugin {
                // before dealing with archived feeds we must check ttrss_feeds to maintain id consistency
 
                if ($orig_feed_data['feed_url'] && $create_archived_feeds) {
-                               $result = db_query($this->link,
+                               $result = db_query(
                                        "SELECT id FROM ttrss_feeds WHERE feed_url = '".$orig_feed_data['feed_url']."'
                                                AND owner_uid = $owner_uid");
 
@@ -234,7 +230,7 @@ class GoogleReaderImport extends Plugin {
 
                                if (!$orig_feed_data['title']) $orig_feed_data['title'] = '[Unknown]';
 
-                               $result = db_query($this->link,
+                               $result = db_query(
                                        "INSERT INTO ttrss_feeds
                                                (owner_uid,feed_url,site_url,title,cat_id,auth_login,auth_pass,update_method)
                                                VALUES ($owner_uid,
@@ -243,7 +239,7 @@ class GoogleReaderImport extends Plugin {
                                                '".$orig_feed_data['title']."',
                                                NULL, '', '', 0)");
 
-                               $result = db_query($this->link,
+                               $result = db_query(
                                        "SELECT id FROM ttrss_feeds WHERE feed_url = '".$orig_feed_data['feed_url']."'
                                                AND owner_uid = $owner_uid");
 
@@ -258,18 +254,18 @@ class GoogleReaderImport extends Plugin {
                        // locate archived entry to file entries in, we don't want to file them in actual feeds because of purging
                        // maybe file marked in real feeds because eh
 
-                       $result = db_query($this->link, "SELECT id FROM ttrss_archived_feeds WHERE
+                       $result = db_query( "SELECT id FROM ttrss_archived_feeds WHERE
                                feed_url = '".$orig_feed_data['feed_url']."' AND owner_uid = $owner_uid");
 
                        if (db_num_rows($result) != 0) {
                                $orig_feed_id = db_fetch_result($result, 0, "id");
                        } else {
-                               db_query($this->link, "INSERT INTO ttrss_archived_feeds
+                               db_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
                                                        WHERE id = '$feed_id'");
 
-                               $result = db_query($this->link, "SELECT id FROM ttrss_archived_feeds WHERE
+                               $result = db_query( "SELECT id FROM ttrss_archived_feeds WHERE
                                        feed_url = '".$orig_feed_data['feed_url']."' AND owner_uid = $owner_uid");
 
                                if (db_num_rows($result) != 0) {
@@ -280,32 +276,32 @@ class GoogleReaderImport extends Plugin {
 
                // delete temporarily inserted feed
                if ($feed_id && $feed_inserted) {
-                               db_query($this->link, "DELETE FROM ttrss_feeds WHERE id = $feed_id");
+                               db_query( "DELETE FROM ttrss_feeds WHERE id = $feed_id");
                }
 
                if (!$orig_feed_id) $orig_feed_id = 'NULL';
 
-               $result = db_query($this->link, "SELECT id FROM ttrss_entries, ttrss_user_entries WHERE
+               $result = db_query( "SELECT id FROM ttrss_entries, ttrss_user_entries WHERE
                        guid = '$guid' AND ref_id = id AND owner_uid = '$owner_uid' LIMIT 1");
 
                if (db_num_rows($result) == 0) {
-                       $result = db_query($this->link, "INSERT INTO ttrss_entries
+                       $result = db_query( "INSERT INTO ttrss_entries
                                (title, guid, link, updated, content, content_hash, date_entered, date_updated, author)
                                VALUES
                                ('$title', '$guid', '$link', '$updated', '$content', '$content_hash', NOW(), NOW(), '$author')");
 
-                       $result = db_query($this->link, "SELECT id FROM ttrss_entries WHERE guid = '$guid'");
+                       $result = db_query( "SELECT id FROM ttrss_entries WHERE guid = '$guid'");
 
                        if (db_num_rows($result) != 0) {
                                $ref_id = db_fetch_result($result, 0, "id");
 
-                               db_query($this->link, "INSERT INTO ttrss_user_entries
+                               db_query( "INSERT INTO ttrss_user_entries
                                        (ref_id, uuid, feed_id, orig_feed_id, owner_uid, marked, tag_cache, label_cache,
                                                last_read, note, unread, last_marked)
                                        VALUES
                                        ('$ref_id', '', NULL, $orig_feed_id, $owner_uid, $marked, '', '', NOW(), '', false, NOW())");
 
-                               $result = db_query($this->link, "SELECT int_id FROM ttrss_user_entries, ttrss_entries
+                               $result = db_query( "SELECT int_id FROM ttrss_user_entries, ttrss_entries
                                        WHERE owner_uid = $owner_uid AND ref_id = id AND ref_id = $ref_id");
 
                                if (db_num_rows($result) != 0 && is_array($tags)) {
@@ -315,16 +311,16 @@ class GoogleReaderImport extends Plugin {
 
                                        foreach ($tags as $tag) {
 
-                                               $tag = db_escape_string($this->link, sanitize_tag($tag));
+                                               $tag = db_escape_string( sanitize_tag($tag));
 
                                                if (!tag_is_valid($tag)) continue;
 
-                                               $result = db_query($this->link, "SELECT id FROM ttrss_tags
+                                               $result = db_query( "SELECT id FROM ttrss_tags
                                                        WHERE tag_name = '$tag' AND post_int_id = '$entry_int_id' AND
                                                        owner_uid = '$owner_uid' LIMIT 1");
 
                                                        if ($result && db_num_rows($result) == 0) {
-                                                               db_query($this->link, "INSERT INTO ttrss_tags
+                                                               db_query( "INSERT INTO ttrss_tags
                                                                        (owner_uid,tag_name,post_int_id)
                                                                        VALUES ('$owner_uid','$tag', '$entry_int_id')");
                                                        }
@@ -335,9 +331,9 @@ class GoogleReaderImport extends Plugin {
                                        /* update the cache */
 
                                        $tags_to_cache = array_unique($tags_to_cache);
-                                       $tags_str = db_escape_string($this->link, join(",", $tags_to_cache));
+                                       $tags_str = db_escape_string( join(",", $tags_to_cache));
 
-                                       db_query($this->link, "UPDATE ttrss_user_entries
+                                       db_query( "UPDATE ttrss_user_entries
                                                SET tag_cache = '$tags_str' WHERE ref_id = '$ref_id'
                                                AND owner_uid = $owner_uid");
                                }
@@ -346,7 +342,7 @@ class GoogleReaderImport extends Plugin {
                        }
                }
 
-               db_query($this->link, "COMMIT");
+               db_query( "COMMIT");
 
                return $rc;
        }
index afdc58ec7674b7a53d3e501e7a05b550d2412851..27428a4884ecbf4ab25d62f6fc51baace7db6e80 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 class GoogleReaderKeys extends Plugin {
-
-       private $link;
        private $host;
 
        function about() {
@@ -11,7 +9,6 @@ class GoogleReaderKeys extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_HOTKEY_MAP, $this);
index a01a612a40b1fad9575365bbe8e12d73686ded6d..981a2b58151f9839a5a29badaef698d1b9a8409d 100644 (file)
@@ -1,11 +1,8 @@
 <?php
 class Import_Export extends Plugin implements IHandler {
-
-       private $link;
        private $host;
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_PREFS_TAB, $this);
@@ -29,11 +26,11 @@ class Import_Export extends Plugin implements IHandler {
 
                _debug("please enter your username:");
 
-               $username = db_escape_string($this->link, trim(read_stdin()));
+               $username = db_escape_string( trim(read_stdin()));
 
                _debug("importing $filename for user $username...\n");
 
-               $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE login = '$username'");
+               $result = db_query( "SELECT id FROM ttrss_users WHERE login = '$username'");
 
                if (db_num_rows($result) == 0) {
                        print "error: could not find user $username.\n";
@@ -42,11 +39,11 @@ class Import_Export extends Plugin implements IHandler {
 
                $owner_uid = db_fetch_result($result, 0, "id");
 
-               $this->perform_data_import($this->link, $filename, $owner_uid);
+               $this->perform_data_import( $filename, $owner_uid);
        }
 
        function save() {
-               $example_value = db_escape_string($this->link, $_POST["example_value"]);
+               $example_value = db_escape_string( $_POST["example_value"]);
 
                echo "Value set to $example_value (not really)";
        }
@@ -120,12 +117,12 @@ class Import_Export extends Plugin implements IHandler {
        }
 
        function exportrun() {
-               $offset = (int) db_escape_string($this->link, $_REQUEST['offset']);
+               $offset = (int) db_escape_string( $_REQUEST['offset']);
                $exported = 0;
                $limit = 250;
 
                if ($offset < 10000 && is_writable(CACHE_DIR . "/export")) {
-                       $result = db_query($this->link, "SELECT
+                       $result = db_query( "SELECT
                                        ttrss_entries.guid,
                                        ttrss_entries.title,
                                        content,
@@ -184,7 +181,7 @@ class Import_Export extends Plugin implements IHandler {
                print json_encode(array("exported" => $exported));
        }
 
-       function perform_data_import($link, $filename, $owner_uid) {
+       function perform_data_import( $filename, $owner_uid) {
 
                $num_imported = 0;
                $num_processed = 0;
@@ -237,7 +234,7 @@ class Import_Export extends Plugin implements IHandler {
 
                                        foreach ($article_node->childNodes as $child) {
                                                if ($child->nodeName != 'label_cache')
-                                                       $article[$child->nodeName] = db_escape_string($this->link, $child->nodeValue);
+                                                       $article[$child->nodeName] = db_escape_string( $child->nodeValue);
                                                else
                                                        $article[$child->nodeName] = $child->nodeValue;
                                        }
@@ -248,16 +245,16 @@ class Import_Export extends Plugin implements IHandler {
 
                                                ++$num_processed;
 
-                                               //db_query($link, "BEGIN");
+                                               //db_query( "BEGIN");
 
                                                //print 'GUID:' . $article['guid'] . "\n";
 
-                                               $result = db_query($link, "SELECT id FROM ttrss_entries
+                                               $result = db_query( "SELECT id FROM ttrss_entries
                                                        WHERE guid = '".$article['guid']."'");
 
                                                if (db_num_rows($result) == 0) {
 
-                                                       $result = db_query($link,
+                                                       $result = db_query(
                                                                "INSERT INTO ttrss_entries
                                                                        (title,
                                                                        guid,
@@ -285,7 +282,7 @@ class Import_Export extends Plugin implements IHandler {
                                                                        '0',
                                                                        '')");
 
-                                                       $result = db_query($link, "SELECT id FROM ttrss_entries
+                                                       $result = db_query( "SELECT id FROM ttrss_entries
                                                                WHERE guid = '".$article['guid']."'");
 
                                                        if (db_num_rows($result) != 0) {
@@ -306,7 +303,7 @@ class Import_Export extends Plugin implements IHandler {
                                                        $feed = 'NULL';
 
                                                        if ($feed_url && $feed_title) {
-                                                               $result = db_query($link, "SELECT id FROM ttrss_feeds
+                                                               $result = db_query( "SELECT id FROM ttrss_feeds
                                                                        WHERE feed_url = '$feed_url' AND owner_uid = '$owner_uid'");
 
                                                                if (db_num_rows($result) != 0) {
@@ -314,10 +311,10 @@ class Import_Export extends Plugin implements IHandler {
                                                                } else {
                                                                        // try autocreating feed in Uncategorized...
 
-                                                                       $result = db_query($link, "INSERT INTO ttrss_feeds (owner_uid,
+                                                                       $result = db_query( "INSERT INTO ttrss_feeds (owner_uid,
                                                                                feed_url, title) VALUES ($owner_uid, '$feed_url', '$feed_title')");
 
-                                                                       $result = db_query($link, "SELECT id FROM ttrss_feeds
+                                                                       $result = db_query( "SELECT id FROM ttrss_feeds
                                                                                WHERE feed_url = '$feed_url' AND owner_uid = '$owner_uid'");
 
                                                                        if (db_num_rows($result) != 0) {
@@ -335,7 +332,7 @@ class Import_Export extends Plugin implements IHandler {
 
                                                        //print "$ref_id / $feed / " . $article['title'] . "\n";
 
-                                                       $result = db_query($link, "SELECT int_id FROM ttrss_user_entries
+                                                       $result = db_query( "SELECT int_id FROM ttrss_user_entries
                                                                WHERE ref_id = '$ref_id' AND owner_uid = '$owner_uid' AND $feed_qpart");
 
                                                        if (db_num_rows($result) == 0) {
@@ -345,14 +342,14 @@ class Import_Export extends Plugin implements IHandler {
                                                                $score = (int) $article['score'];
 
                                                                $tag_cache = $article['tag_cache'];
-                                                               $label_cache = db_escape_string($this->link, $article['label_cache']);
+                                                               $label_cache = db_escape_string( $article['label_cache']);
                                                                $note = $article['note'];
 
                                                                //print "Importing " . $article['title'] . "<br/>";
 
                                                                ++$num_imported;
 
-                                                               $result = db_query($link,
+                                                               $result = db_query(
                                                                        "INSERT INTO ttrss_user_entries
                                                                        (ref_id, owner_uid, feed_id, unread, last_read, marked,
                                                                                published, score, tag_cache, label_cache, uuid, note)
@@ -365,15 +362,15 @@ class Import_Export extends Plugin implements IHandler {
                                                                if (is_array($label_cache) && $label_cache["no-labels"] != 1) {
                                                                        foreach ($label_cache as $label) {
 
-                                                                               label_create($link, $label[1],
+                                                                               label_create( $label[1],
                                                                                        $label[2], $label[3], $owner_uid);
 
-                                                                               label_add_article($link, $ref_id, $label[1], $owner_uid);
+                                                                               label_add_article( $ref_id, $label[1], $owner_uid);
 
                                                                        }
                                                                }
 
-                                                               //db_query($link, "COMMIT");
+                                                               //db_query( "COMMIT");
                                                        }
                                                }
                                        }
@@ -441,7 +438,7 @@ class Import_Export extends Plugin implements IHandler {
                }
 
                if (is_file($tmp_file)) {
-                       $this->perform_data_import($this->link, $tmp_file, $_SESSION['uid']);
+                       $this->perform_data_import( $tmp_file, $_SESSION['uid']);
                        unlink($tmp_file);
                } else {
                        print_error(__('No file uploaded.'));
index 7f822c7bffc8ea26f01a1f995c6432ed84f66a09..12ae072800c89eac088ef93b879b5bd61f34dac3 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 class Instances extends Plugin implements IHandler {
-
-       private $link;
        private $host;
 
        private $status_codes = array(
@@ -18,7 +16,6 @@ class Instances extends Plugin implements IHandler {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_PREFS_TABS, $this);
@@ -30,7 +27,7 @@ class Instances extends Plugin implements IHandler {
 
        function hook_update_task($args) {
                _debug("Get linked feeds...");
-               $this->get_linked_feeds($this->link);
+               $this->get_linked_feeds();
        }
 
        // Status codes:
@@ -40,7 +37,7 @@ class Instances extends Plugin implements IHandler {
        // 2   - did not receive valid data
        // >10 - server error, code + 10 (e.g. 16 means server error 6)
 
-       function get_linked_feeds($link, $instance_id = false) {
+       function get_linked_feeds( $instance_id = false) {
                if ($instance_id)
                        $instance_qpart = "id = '$instance_id' AND ";
                else
@@ -52,7 +49,7 @@ class Instances extends Plugin implements IHandler {
                        $date_qpart = "last_connected < DATE_SUB(NOW(), INTERVAL 6 HOUR)";
                }
 
-               $result = db_query($link, "SELECT id, access_key, access_url FROM ttrss_linked_instances
+               $result = db_query( "SELECT id, access_key, access_url FROM ttrss_linked_instances
                        WHERE $instance_qpart $date_qpart ORDER BY last_connected");
 
                while ($line = db_fetch_assoc($result)) {
@@ -80,7 +77,7 @@ class Instances extends Plugin implements IHandler {
 
                                                // access denied
                                                if ($status == 16) {
-                                                       db_query($link, "DELETE FROM ttrss_linked_feeds
+                                                       db_query( "DELETE FROM ttrss_linked_feeds
                                                                WHERE instance_id = '$id'");
                                                }
                                        } else {
@@ -88,16 +85,16 @@ class Instances extends Plugin implements IHandler {
 
                                                if (count($feeds['feeds']) > 0) {
 
-                                                       db_query($link, "DELETE FROM ttrss_linked_feeds
+                                                       db_query( "DELETE FROM ttrss_linked_feeds
                                                                WHERE instance_id = '$id'");
 
                                                        foreach ($feeds['feeds'] as $feed) {
-                                                               $feed_url = db_escape_string($this->link, $feed['feed_url']);
-                                                               $title = db_escape_string($this->link, $feed['title']);
-                                                               $subscribers = db_escape_string($this->link, $feed['subscribers']);
-                                                               $site_url = db_escape_string($this->link, $feed['site_url']);
+                                                               $feed_url = db_escape_string( $feed['feed_url']);
+                                                               $title = db_escape_string( $feed['title']);
+                                                               $subscribers = db_escape_string( $feed['subscribers']);
+                                                               $site_url = db_escape_string( $feed['site_url']);
 
-                                                               db_query($link, "INSERT INTO ttrss_linked_feeds
+                                                               db_query( "INSERT INTO ttrss_linked_feeds
                                                                        (feed_url, site_url, title, subscribers, instance_id, created, updated)
                                                                VALUES
                                                                        ('$feed_url', '$site_url', '$title', '$subscribers', '$id', NOW(), NOW())");
@@ -122,7 +119,7 @@ class Instances extends Plugin implements IHandler {
 
                        _debug("Status: $status");
 
-                       db_query($link, "UPDATE ttrss_linked_instances SET
+                       db_query( "UPDATE ttrss_linked_instances SET
                                last_status_out = '$status', last_connected = NOW() WHERE id = '$id'");
 
                }
@@ -130,7 +127,7 @@ class Instances extends Plugin implements IHandler {
 
 
        function get_feeds() {
-               $this->get_linked_feeds($this->link, false);
+               $this->get_linked_feeds( false);
        }
 
        function get_prefs_js() {
@@ -167,37 +164,37 @@ class Instances extends Plugin implements IHandler {
        }
 
        function remove() {
-               $ids = db_escape_string($this->link, $_REQUEST['ids']);
+               $ids = db_escape_string( $_REQUEST['ids']);
 
-               db_query($this->link, "DELETE FROM ttrss_linked_instances WHERE
+               db_query( "DELETE FROM ttrss_linked_instances WHERE
                        id IN ($ids)");
        }
 
        function add() {
-               $id = db_escape_string($this->link, $_REQUEST["id"]);
-               $access_url = db_escape_string($this->link, $_REQUEST["access_url"]);
-               $access_key = db_escape_string($this->link, $_REQUEST["access_key"]);
+               $id = db_escape_string( $_REQUEST["id"]);
+               $access_url = db_escape_string( $_REQUEST["access_url"]);
+               $access_key = db_escape_string( $_REQUEST["access_key"]);
 
-               db_query($this->link, "BEGIN");
+               db_query( "BEGIN");
 
-               $result = db_query($this->link, "SELECT id FROM ttrss_linked_instances
+               $result = db_query( "SELECT id FROM ttrss_linked_instances
                        WHERE access_url = '$access_url'");
 
                if (db_num_rows($result) == 0) {
-                       db_query($this->link, "INSERT INTO ttrss_linked_instances
+                       db_query( "INSERT INTO ttrss_linked_instances
                                (access_url, access_key, last_connected, last_status_in, last_status_out)
                                VALUES
                                ('$access_url', '$access_key', '1970-01-01', -1, -1)");
 
                }
 
-               db_query($this->link, "COMMIT");
+               db_query( "COMMIT");
        }
 
        function edit() {
-               $id = db_escape_string($this->link, $_REQUEST["id"]);
+               $id = db_escape_string( $_REQUEST["id"]);
 
-               $result = db_query($this->link, "SELECT * FROM ttrss_linked_instances WHERE
+               $result = db_query( "SELECT * FROM ttrss_linked_instances WHERE
                        id = '$id'");
 
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\"  name=\"id\" value=\"$id\">";
@@ -253,11 +250,11 @@ class Instances extends Plugin implements IHandler {
        }
 
        function editSave() {
-               $id = db_escape_string($this->link, $_REQUEST["id"]);
-               $access_url = db_escape_string($this->link, $_REQUEST["access_url"]);
-               $access_key = db_escape_string($this->link, $_REQUEST["access_key"]);
+               $id = db_escape_string( $_REQUEST["id"]);
+               $access_url = db_escape_string( $_REQUEST["access_url"]);
+               $access_key = db_escape_string( $_REQUEST["access_key"]);
 
-               db_query($this->link, "UPDATE ttrss_linked_instances SET
+               db_query( "UPDATE ttrss_linked_instances SET
                        access_key = '$access_key', access_url = '$access_url',
                        last_connected = '1970-01-01'
                        WHERE id = '$id'");
@@ -277,7 +274,7 @@ class Instances extends Plugin implements IHandler {
 
                print "<div id=\"pref-instance-toolbar\" dojoType=\"dijit.Toolbar\">";
 
-               $sort = db_escape_string($this->link, $_REQUEST["sort"]);
+               $sort = db_escape_string( $_REQUEST["sort"]);
 
                if (!$sort || $sort == "undefined") {
                        $sort = "access_url";
@@ -298,7 +295,7 @@ class Instances extends Plugin implements IHandler {
 
                print "</div>"; #toolbar
 
-               $result = db_query($this->link, "SELECT *,
+               $result = db_query( "SELECT *,
                        (SELECT COUNT(*) FROM ttrss_linked_feeds
                                WHERE instance_id = ttrss_linked_instances.id) AS num_feeds
                        FROM ttrss_linked_instances
@@ -327,7 +324,7 @@ class Instances extends Plugin implements IHandler {
                        $id = $line['id'];
                        $this_row_id = "id=\"LIRR-$id\"";
 
-                       $line["last_connected"] = make_local_datetime($this->link, $line["last_connected"], false);
+                       $line["last_connected"] = make_local_datetime( $line["last_connected"], false);
 
                        print "<tr class=\"$class\" $this_row_id>";
 
@@ -364,17 +361,17 @@ class Instances extends Plugin implements IHandler {
 
        function fbexport() {
 
-               $access_key = db_escape_string($this->link, $_POST["key"]);
+               $access_key = db_escape_string( $_POST["key"]);
 
                // TODO: rate limit checking using last_connected
-               $result = db_query($this->link, "SELECT id FROM ttrss_linked_instances
+               $result = db_query( "SELECT id FROM ttrss_linked_instances
                        WHERE access_key = '$access_key'");
 
                if (db_num_rows($result) == 1) {
 
                        $instance_id = db_fetch_result($result, 0, "id");
 
-                       $result = db_query($this->link, "SELECT feed_url, site_url, title, subscribers
+                       $result = db_query( "SELECT feed_url, site_url, title, subscribers
                                FROM ttrss_feedbrowser_cache ORDER BY subscribers DESC LIMIT 100");
 
                        $feeds = array();
@@ -383,7 +380,7 @@ class Instances extends Plugin implements IHandler {
                                array_push($feeds, $line);
                        }
 
-                       db_query($this->link, "UPDATE ttrss_linked_instances SET
+                       db_query( "UPDATE ttrss_linked_instances SET
                                last_status_in = 1 WHERE id = '$instance_id'");
 
                        print json_encode(array("feeds" => $feeds));
index 574dc1ef3dae8242ff963252df995739b690edf3..7adf36fe4540121c75f5c2cb3f375185d7d08f3d 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 class Mail extends Plugin {
 
-       private $link;
        private $host;
 
        function about() {
@@ -11,7 +10,6 @@ class Mail extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
@@ -30,13 +28,13 @@ class Mail extends Plugin {
 
        function emailArticle() {
 
-               $param = db_escape_string($this->link, $_REQUEST['param']);
+               $param = db_escape_string( $_REQUEST['param']);
 
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">";
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"mail\">";
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"sendEmail\">";
 
-               $result = db_query($this->link, "SELECT email, full_name FROM ttrss_users WHERE
+               $result = db_query( "SELECT email, full_name FROM ttrss_users WHERE
                        id = " . $_SESSION["uid"]);
 
                $user_email = htmlspecialchars(db_fetch_result($result, 0, "email"));
@@ -58,7 +56,7 @@ class Mail extends Plugin {
                $tpl->setVariable('USER_EMAIL', $user_email, true);
                $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
 
-               $result = db_query($this->link, "SELECT link, content, title
+               $result = db_query( "SELECT link, content, title
                        FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
                        id IN ($param) AND owner_uid = " . $_SESSION["uid"]);
 
@@ -149,7 +147,7 @@ class Mail extends Plugin {
                if (!$rc) {
                        $reply['error'] =  $mail->ErrorInfo;
                } else {
-                       save_email_address($this->link, db_escape_string($this->link, $destination));
+                       save_email_address( db_escape_string($destination));
                        $reply['message'] = "UPDATE_COUNTERS";
                }
 
@@ -157,7 +155,7 @@ class Mail extends Plugin {
        }
 
        function completeEmails() {
-               $search = db_escape_string($this->link, $_REQUEST["search"]);
+               $search = db_escape_string( $_REQUEST["search"]);
 
                print "<ul>";
 
index 6c7478b687c38d47bf56daedf2a4770b5582fc48..81b2758b863999d40cb1aaaa494ba4205d61812b 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 class MailTo extends Plugin {
-
-       private $link;
        private $host;
 
        function about() {
@@ -11,7 +9,6 @@ class MailTo extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
@@ -30,7 +27,7 @@ class MailTo extends Plugin {
 
        function emailArticle() {
 
-               $param = db_escape_string($this->link, $_REQUEST['param']);
+               $param = db_escape_string( $_REQUEST['param']);
 
                require_once "lib/MiniTemplator.class.php";
 
@@ -44,7 +41,7 @@ class MailTo extends Plugin {
                $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
 
 
-               $result = db_query($this->link, "SELECT link, content, title
+               $result = db_query( "SELECT link, content, title
                        FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
                        id IN ($param) AND owner_uid = " . $_SESSION["uid"]);
 
index 4cf1c5949db0b7a1c4c7adf3dc407ed9ec6f3451..1ed2ea43899db2ad7c0ff73c667ab53d168814fe 100644 (file)
@@ -1,10 +1,8 @@
 <?php
 class Mark_Button extends Plugin {
-       private $link;
        private $host;
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
@@ -20,7 +18,7 @@ class Mark_Button extends Plugin {
                $marked_pic = "";
                $id = $line["id"];
 
-               if (get_pref($this->link, "COMBINED_DISPLAY_MODE")) {
+               if (get_pref( "COMBINED_DISPLAY_MODE")) {
                        if (sql_bool_to_bool($line["marked"])) {
                                $marked_pic = "<img
                                        src=\"images/mark_set.svg\"
index c73c0fca50bd82d3a40d70dbbdf1724125f41e40..17fc39395d34b275d5cfcdee7cafb22cef4acc7d 100644 (file)
 
        init_plugins($link);
 
-       login_sequence($link, true);
+       login_sequence( true);
 
-       $id = db_escape_string($link, $_REQUEST["id"]);
-       $feed_id = db_escape_string($link, $_REQUEST["feed"]);
-       $cat_id = db_escape_string($link, $_REQUEST["cat"]);
-       $is_cat = db_escape_string($link, $_REQUEST["is_cat"]);
+       $id = db_escape_string( $_REQUEST["id"]);
+       $feed_id = db_escape_string( $_REQUEST["feed"]);
+       $cat_id = db_escape_string( $_REQUEST["cat"]);
+       $is_cat = db_escape_string( $_REQUEST["is_cat"]);
 
-       render_article($link, $id, $feed_id, $cat_id, $is_cat);
+       render_article( $id, $feed_id, $cat_id, $is_cat);
 ?>
 
index dc657ed40ec89043ce488b03af9bcd576828165d..a62f462d5e7356bbccb3eadd56b7572392cfa1f0 100644 (file)
 
        switch ($op) {
        case "toggleMarked":
-               $cmode = db_escape_string($link, $_REQUEST["mark"]);
-               $id = db_escape_string($link, $_REQUEST["id"]);
+               $cmode = db_escape_string( $_REQUEST["mark"]);
+               $id = db_escape_string( $_REQUEST["id"]);
 
-               markArticlesById($link, array($id), $cmode);
+               markArticlesById( array($id), $cmode);
                break;
        case "togglePublished":
-               $cmode = db_escape_string($link, $_REQUEST["pub"]);
-               $id = db_escape_string($link, $_REQUEST["id"]);
+               $cmode = db_escape_string( $_REQUEST["pub"]);
+               $id = db_escape_string( $_REQUEST["id"]);
 
-               publishArticlesById($link, array($id), $cmode);
+               publishArticlesById( array($id), $cmode);
                break;
        case "toggleUnread":
-               $cmode = db_escape_string($link, $_REQUEST["unread"]);
-               $id = db_escape_string($link, $_REQUEST["id"]);
+               $cmode = db_escape_string( $_REQUEST["unread"]);
+               $id = db_escape_string( $_REQUEST["id"]);
 
-               catchupArticlesById($link, array($id), $cmode);
+               catchupArticlesById( array($id), $cmode);
                break;
 
        case "setPref":
-               $id = db_escape_string($link, $_REQUEST["id"]);
-               $value = db_escape_string($link, $_REQUEST["to"]);
-               mobile_set_pref($link, $id, $value);
+               $id = db_escape_string( $_REQUEST["id"]);
+               $value = db_escape_string( $_REQUEST["to"]);
+               mobile_set_pref( $id, $value);
                print_r($_SESSION);
                break;
        default:
index acd7f6f341be81a1b4f5d6aac856a15a4fde7ed6..ec5bbf3d9a9dd76e13dd37c97e65cf42da0c3dc5 100644 (file)
 
        init_plugins($link);
 
-       login_sequence($link, true);
+       login_sequence( true);
 
-       $cat_id = db_escape_string($link, $_REQUEST["id"]);
+       $cat_id = db_escape_string( $_REQUEST["id"]);
 
-       render_category($link, $cat_id);
+       render_category( $cat_id);
 ?>
 
index 22590f195e7283735d850832fa4906a5d88ee857..08e916e215103398f9cf99c24b10c413b4696ff2 100644 (file)
 
        init_plugins($link);
 
-       login_sequence($link, true);
+       login_sequence( true);
 
-       $feed_id = db_escape_string($link, $_REQUEST["id"]);
-       $cat_id = db_escape_string($link, $_REQUEST["cat"]);
-       $offset = (int) db_escape_string($link, $_REQUEST["skip"]);
-       $search = db_escape_string($link, $_REQUEST["search"]);
-       $is_cat = (bool) db_escape_string($link, $_REQUEST["is_cat"]);
+       $feed_id = db_escape_string( $_REQUEST["id"]);
+       $cat_id = db_escape_string( $_REQUEST["cat"]);
+       $offset = (int) db_escape_string( $_REQUEST["skip"]);
+       $search = db_escape_string( $_REQUEST["search"]);
+       $is_cat = (bool) db_escape_string( $_REQUEST["is_cat"]);
 
-       render_headlines_list($link, $feed_id, $cat_id, $offset, $search, $is_cat);
+       render_headlines_list( $feed_id, $cat_id, $offset, $search, $is_cat);
 ?>
 
index f0ebf6a111cfb5ab756ed692bcc0127cd2dafee0..57b18cd854efbcf44e0dc2b17639127552e67400 100644 (file)
 
        init_plugins($link);
 
-       login_sequence($link, true);
+       login_sequence( true);
 
-       $use_cats = mobile_get_pref($link, 'ENABLE_CATS');
-       $offset = (int) db_escape_string($link, $_REQUEST["skip"]);
+       $use_cats = mobile_get_pref( 'ENABLE_CATS');
+       $offset = (int) db_escape_string( $_REQUEST["skip"]);
 
        if ($use_cats) {
                render_categories_list($link);
        } else {
-               render_flat_feed_list($link, $offset);
+               render_flat_feed_list( $offset);
        }
 ?>
index 3fd496d0464cea26ac8d973646037f2ca029a830..8202f4043eb159423d4fc1fb23a8fb3889152766 100644 (file)
@@ -20,7 +20,7 @@
 
        init_plugins($link);
 
-       login_sequence($link, true);
+       login_sequence( true);
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     </div>
 
        <?php
-       $use_cats = mobile_get_pref($link, 'ENABLE_CATS');
-       $offset = (int) db_escape_string($link, $_REQUEST["skip"]);
+       $use_cats = mobile_get_pref( 'ENABLE_CATS');
+       $offset = (int) db_escape_string( $_REQUEST["skip"]);
 
        if ($use_cats) {
                render_categories_list($link);
        } else {
-               render_flat_feed_list($link, $offset);
+               render_flat_feed_list( $offset);
        }
        ?>
 
index 0ebbcced12559e32efbd28191abe1c33c0727961..ad2d1cdd95c70ce8b37fd5bbd7b482887fca75bb 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 class Mobile extends Plugin implements IHandler {
-
-       private $link;
        private $host;
 
        function about() {
@@ -12,7 +10,6 @@ class Mobile extends Plugin implements IHandler {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_handler("mobile", "index", $this);
index 8e5cb7010a7049cb9f4abb3b13fcfad4117dde87..0395ee7a54c5b7eb99c3c3f6bbe2f024670ed0e5 100644 (file)
@@ -8,34 +8,34 @@
 
        /* TODO replace with interface to db-prefs */
 
-       function mobile_pref_toggled($link, $id) {
-               if (get_pref($link, "_MOBILE_$id"))
+       function mobile_pref_toggled( $id) {
+               if (get_pref( "_MOBILE_$id"))
                        return "true";
                else
                        return "";
        }
 
-       function mobile_get_pref($link, $id) {
+       function mobile_get_pref( $id) {
                //return $_SESSION["mobile-prefs"][$id];
-               return get_pref($link, "_MOBILE_$id");
+               return get_pref( "_MOBILE_$id");
        }
 
-       function mobile_set_pref($link, $id, $value) {
+       function mobile_set_pref( $id, $value) {
                //$_SESSION["mobile-prefs"][$id] = $value;
-               return set_pref($link, "_MOBILE_$id", $value);
+               return set_pref( "_MOBILE_$id", $value);
        }
 
        function mobile_feed_has_icon($id) {
                return file_exists("../../".ICONS_DIR."/$id.ico");
        }
 
-       function render_flat_feed_list($link, $offset) {
+       function render_flat_feed_list( $offset) {
                $owner_uid = $_SESSION["uid"];
                $limit = 0;
 
                if (!$offset) $offset = 0;
 
-               if (mobile_get_pref($link, "SORT_FEEDS_UNREAD")) {
+               if (mobile_get_pref( "SORT_FEEDS_UNREAD")) {
                        $order_by = "unread DESC, title";
                } else {
                        $order_by = "title";
@@ -47,7 +47,7 @@
                        $limit_qpart = "";
                }
 
-               $result = db_query($link, "SELECT id,
+               $result = db_query( "SELECT id,
                                title,
                        (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
                                WHERE feed_id = ttrss_feeds.id AND unread = true
@@ -85,7 +85,7 @@
                                        $icon_url = "../../images/blank_icon.gif";
                                }
 
-                               if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
+                               if ($unread > 0 || !mobile_get_pref( "HIDE_READ")) {
                                        print "<li class='$class'><a href='feed.php?id=$id'>" .
                                                "<img class='tinyIcon' src='$icon_url'/>".
                                                $line["title"] . "</a></li>";
 
        }
 
-       function render_category($link, $cat_id, $offset) {
+       function render_category( $cat_id, $offset) {
                $owner_uid = $_SESSION["uid"];
 
                if ($cat_id >= 0) {
                                $cat_query = "cat_id IS NULL";
                        }
 
-                       if (mobile_get_pref($link, "SORT_FEEDS_UNREAD")) {
+                       if (mobile_get_pref( "SORT_FEEDS_UNREAD")) {
                                $order_by = "unread DESC, title";
                        } else {
                                $order_by = "title";
                        }
 
-                       $result = db_query($link, "SELECT id,
+                       $result = db_query( "SELECT id,
                                title,
                        (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
                                WHERE feed_id = ttrss_feeds.id AND unread = true
                                $cat_query
                        ORDER BY $order_by");
 
-                       $title = getCategoryTitle($link, $cat_id);
+                       $title = getCategoryTitle( $cat_id);
 
                        print "<ul id='cat-$cat_id' title='$title' myBackLabel='".__("Home")."'
                                myBackHref='home.php'>";
                                        $icon_url = "../../images/blank_icon.gif";
                                }
 
-                               if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
+                               if ($unread > 0 || !mobile_get_pref( "HIDE_READ")) {
                                        print "<li class='$class'><a href='feed.php?id=$id&cat=$cat_id'>" .
                                                "<img class='tinyIcon' src='$icon_url'/>".
                                                $line["title"] . "</a></li>";
                                myBackHref='home.php'>";
 
                        foreach (array(-4, -3, -1, -2, 0) as $id) {
-                               $title = getFeedTitle($link, $id);
-                               $unread = getFeedUnread($link, $id, false);
+                               $title = getFeedTitle( $id);
+                               $unread = getFeedUnread( $id, false);
                                $icon = getFeedIcon($id);
 
                                if ($unread > 0) {
                                        $class = 'oldItem';
                                }
 
-                               if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
+                               if ($unread > 0 || !mobile_get_pref( "HIDE_READ")) {
                                        print "<li class='$class'>
                                                <a href='feed.php?id=$id&cat=-1'>
                                                <img class='tinyIcon' src='../$icon'/>$title</a></li>";
                        print "<ul id='cat--2' title='$title' myBackLabel='".__("Home")."'
                                myBackHref='home.php'>";
 
-                       $result = db_query($link, "SELECT id, caption FROM ttrss_labels2
+                       $result = db_query( "SELECT id, caption FROM ttrss_labels2
                                WHERE owner_uid = '$owner_uid'");
 
                        $label_data = array();
 
                                $id = label_to_feed_id($line["id"]);
 
-                               $unread = getFeedUnread($link, $id);
+                               $unread = getFeedUnread( $id);
                                $title = $line["caption"];
 
                                if ($unread > 0) {
                                        $class = 'oldItem';
                                }
 
-                               if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
+                               if ($unread > 0 || !mobile_get_pref( "HIDE_READ")) {
                                        print "<li class='$class'>
                                                <a href='feed.php?id=$id&cat=-2'>$title</a></li>";
                                }
        function render_categories_list($link) {
                $owner_uid = $_SESSION["uid"];
 
-               $cat_browse = mobile_get_pref($link, "BROWSE_CATS");
+               $cat_browse = mobile_get_pref( "BROWSE_CATS");
 
                print '<ul id="home" title="'.__('Home').'" selected="true"
                        myBackLabel="'.__('Logout').'" myBackHref="logout.php" myBackTarget="_self">';
 //             print "<li><a href='#searchForm'>Search...</a></li>";
 
                foreach (array(-1, -2) as $id) {
-                       $title = getCategoryTitle($link, $id);
-                       $unread = getFeedUnread($link, $id, true);
+                       $title = getCategoryTitle( $id);
+                       $unread = getFeedUnread( $id, true);
                        if ($unread > 0) {
                                $title = $title . " ($unread)";
                                $class = '';
                                print "<li class='$class'><a href='feed.php?id=$id&is_cat=true'>$title</a></li>";
                }
 
-               $result = db_query($link, "SELECT
+               $result = db_query( "SELECT
                                ttrss_feed_categories.id,
                                ttrss_feed_categories.title,
                                COUNT(ttrss_feeds.id) AS num_feeds
 
                        if ($line["num_feeds"] > 0) {
 
-                               $unread = getFeedUnread($link, $line["id"], true);
+                               $unread = getFeedUnread( $line["id"], true);
                                $id = $line["id"];
 
                                if ($unread > 0) {
                                        $class = 'oldItem';
                                }
 
-                               if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
+                               if ($unread > 0 || !mobile_get_pref( "HIDE_READ")) {
 
                                        if ($cat_browse)
                                                print "<li class='$class'><a href='cat.php?id=$id'>" .
                }
 
 
-               $result = db_query($link, "SELECT COUNT(*) AS nf FROM ttrss_feeds WHERE
+               $result = db_query( "SELECT COUNT(*) AS nf FROM ttrss_feeds WHERE
                        cat_id IS NULL and owner_uid = '$owner_uid'");
 
                $num_feeds = db_fetch_result($result, 0, "nf");
 
                if ($num_feeds > 0) {
-                       $unread = getFeedUnread($link, 0, true);
+                       $unread = getFeedUnread( 0, true);
                        $title = "Uncategorized";
 
                        if ($unread > 0) {
                                $class = 'oldItem';
                        }
 
-                       if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
+                       if ($unread > 0 || !mobile_get_pref( "HIDE_READ")) {
                                if ($cat_browse)
                                        print "<li class='$class'><a href='cat.php?id=0'>$title</a></li>";
                                else
                print "</ul>";
        }
 
-       function render_headlines_list($link, $feed_id, $cat_id, $offset, $search,
+       function render_headlines_list( $feed_id, $cat_id, $offset, $search,
                $is_cat = false) {
 
                $feed_id = $feed_id;
                $limit = 15;
                $filter = '';
 
-               if (!mobile_get_pref($link, "HIDE_READ"))
+               if (!mobile_get_pref( "HIDE_READ"))
                        $view_mode = "all_articles";
                else
                        $view_mode = 'adaptive';
                        $search_mode = '';
                }
 
-               $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit,
+               $qfh_ret = queryFeedHeadlines( $feed_id, $limit,
                        $view_mode, $is_cat, $search, $search_mode,
-                       "score DESC, date_entered ".(mobile_get_pref($link, 'REVERSE_HEADLINES') ? 'ASC' : 'DESC'), $offset);
+                       "score DESC, date_entered ".(mobile_get_pref( 'REVERSE_HEADLINES') ? 'ASC' : 'DESC'), $offset);
 
                $result = $qfh_ret[0];
                $feed_title = $qfh_ret[1];
                          </form>";
 
                        if ($cat_id) {
-                               $cat_title = getCategoryTitle($link, $cat_id);
+                               $cat_title = getCategoryTitle( $cat_id);
 
                                print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\"
                                        myBackLabel='$cat_title' myBackHref='cat.php?id=$cat_id'>";
 //             print "<a target='_replace' href='feed.php?id=$feed_id&cat=$cat_id&skip=0'>Next $limit articles...</a>";
 
                $next_offset = $offset + $num_headlines;
-               $num_unread = getFeedUnread($link, $feed_id, $is_cat);
+               $num_unread = getFeedUnread( $feed_id, $is_cat);
 
                /* FIXME needs normal implementation */
 
 
        }
 
-       function render_article($link, $id, $feed_id, $cat_id, $is_cat) {
+       function render_article( $id, $feed_id, $cat_id, $is_cat) {
 
                $query = "SELECT title,link,content,feed_id,comments,int_id,
                        marked,unread,published,
                        WHERE   id = '$id' AND ref_id = id AND owner_uid = " .
                                $_SESSION["uid"] ;
 
-               $result = db_query($link, $query);
+               $result = db_query( $query);
 
                if (db_num_rows($result) != 0) {
 
                        $line = db_fetch_assoc($result);
 
-                       $tmp_result = db_query($link, "UPDATE ttrss_user_entries
+                       $tmp_result = db_query( "UPDATE ttrss_user_entries
                                SET unread = false,last_read = NOW()
                                WHERE ref_id = '$id'
                                AND owner_uid = " . $_SESSION["uid"]);
 
-                       $updated_fmt = make_local_datetime($link, $line['updated'], false);
+                       $updated_fmt = make_local_datetime( $line['updated'], false);
 
                        $title = $line["title"];
                        $article_link = $line["link"];
 
                        if (!$is_cat)
-                               $feed_title = getFeedTitle($link, $feed_id);
+                               $feed_title = getFeedTitle( $feed_id);
                        else
-                               $feed_title = getCategoryTitle($link, $feed_id);
+                               $feed_title = getCategoryTitle( $feed_id);
 
                        print "<div class=\"panel\" id=\"article-$id\" title=\"$title\"
                                selected=\"true\"
                                myBackLabel='$feed_title' myBackHref='feed.php?id=$feed_id&cat=$cat_id&is_cat=$is_cat'>";
 
                        if ($line['feed_id'] != $feed_id) {
-                               $real_feed_title = getFeedTitle($link, $line['feed_id']);
+                               $real_feed_title = getFeedTitle( $line['feed_id']);
                                $real_feed_id = $line['feed_id'];
                                $feed_link = "(<a href=\"feed.php?id=$real_feed_id\">$real_feed_title</a>)";
                        }
 
 //                     print "</fieldset>";
 
-                       $content = sanitize($link, $line["content"]);
+                       $content = sanitize( $line["content"]);
                        $content = preg_replace("/href=/i", "target=\"_blank\" href=", $content);
 
-                       if (!mobile_get_pref($link, "SHOW_IMAGES")) {
+                       if (!mobile_get_pref( "SHOW_IMAGES")) {
                                $content = preg_replace('/<img[^>]+>/is', '', $content);
                        }
 
index e6d4a7b40d7eac2542d3e9a8e42d41c373ade525..78b6e8a7bf13bb0245cd6c69a450ba45310e0d3f 100644 (file)
@@ -22,7 +22,7 @@
 
        init_plugins($link);
 
-       login_sequence($link, true);
+       login_sequence( true);
 ?>
 
 <div class="panel" id="prefs" selected="yes" title="Preferences"
 
 <div class="row">
        <label><?php echo __('Enable categories') ?></label>
-       <div class="toggle" id="ENABLE_CATS" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled($link, "ENABLE_CATS") ?>"><span class="thumb"></span><span class="toggleOn"><?php echo __('ON') ?></span><span class="toggleOff"><?php echo __('OFF') ?></span></div>
+       <div class="toggle" id="ENABLE_CATS" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled( "ENABLE_CATS") ?>"><span class="thumb"></span><span class="toggleOn"><?php echo __('ON') ?></span><span class="toggleOff"><?php echo __('OFF') ?></span></div>
 </div>
 
 <div class="row">
        <label><?php echo __('Browse categories like folders') ?></label>
-       <div class="toggle" id="BROWSE_CATS" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled($link, "BROWSE_CATS") ?>"><span class="thumb"></span><span class="toggleOn"><?php echo __('ON') ?></span><span class="toggleOff"><?php echo __('OFF') ?></span></div>
+       <div class="toggle" id="BROWSE_CATS" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled( "BROWSE_CATS") ?>"><span class="thumb"></span><span class="toggleOn"><?php echo __('ON') ?></span><span class="toggleOff"><?php echo __('OFF') ?></span></div>
 </div>
 
 
 <div class="row">
        <label><?php echo __('Show images in posts') ?></label>
-       <div class="toggle" id="SHOW_IMAGES" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled($link, "SHOW_IMAGES") ?>"><span class="thumb"></span><span class="toggleOn"><?php echo __('ON') ?></span><span class="toggleOff"><?php echo __('OFF') ?></span></div>
+       <div class="toggle" id="SHOW_IMAGES" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled( "SHOW_IMAGES") ?>"><span class="thumb"></span><span class="toggleOn"><?php echo __('ON') ?></span><span class="toggleOff"><?php echo __('OFF') ?></span></div>
 </div>
 
 <div class="row">
        <label><?php echo __('Hide read articles and feeds') ?></label>
-       <div class="toggle" id="HIDE_READ" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled($link, "HIDE_READ") ?>"><span class="thumb"></span><span class="toggleOn"><?php echo __('ON') ?></span><span class="toggleOff"><?php echo __('OFF') ?></span></div>
+       <div class="toggle" id="HIDE_READ" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled( "HIDE_READ") ?>"><span class="thumb"></span><span class="toggleOn"><?php echo __('ON') ?></span><span class="toggleOff"><?php echo __('OFF') ?></span></div>
 </div>
 
 <div class="row">
        <label><?php echo __('Sort feeds by unread count') ?></label>
-       <div class="toggle" id="SORT_FEEDS_UNREAD" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled($link, "SORT_FEEDS_UNREAD") ?>"><span class="thumb"></span><span class="toggleOn"><?php echo __('ON') ?></span><span class="toggleOff"><?php echo __('OFF') ?></span></div>
+       <div class="toggle" id="SORT_FEEDS_UNREAD" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled( "SORT_FEEDS_UNREAD") ?>"><span class="thumb"></span><span class="toggleOn"><?php echo __('ON') ?></span><span class="toggleOff"><?php echo __('OFF') ?></span></div>
 </div>
 
 <div class="row">
        <label><?php echo __('Reverse headline order (oldest first)') ?></label>
-       <div class="toggle" id="REVERSE_HEADLINES" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled($link, "REVERSE_HEADLINES") ?>"><span class="thumb"></span><span class="toggleOn"><?php echo __('ON') ?></span><span class="toggleOff"><?php echo __('OFF') ?></span></div>
+       <div class="toggle" id="REVERSE_HEADLINES" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled( "REVERSE_HEADLINES") ?>"><span class="thumb"></span><span class="toggleOn"><?php echo __('ON') ?></span><span class="toggleOff"><?php echo __('OFF') ?></span></div>
 </div>
 
 </fieldset>
index 7e8cfb57ffefd1327beaaed825423e2718a40983..a5396e5a43e98dd0654e2fefc21dcf3d3dd37ff3 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 class Note extends Plugin {
-       private $link;
        private $host;
 
        function about() {
@@ -10,7 +9,6 @@ class Note extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
@@ -29,9 +27,9 @@ class Note extends Plugin {
        }
 
        function edit() {
-               $param = db_escape_string($this->link, $_REQUEST['param']);
+               $param = db_escape_string( $_REQUEST['param']);
 
-               $result = db_query($this->link, "SELECT note FROM ttrss_user_entries WHERE
+               $result = db_query( "SELECT note FROM ttrss_user_entries WHERE
                        ref_id = '$param' AND owner_uid = " . $_SESSION['uid']);
 
                $note = db_fetch_result($result, 0, "note");
@@ -58,10 +56,10 @@ class Note extends Plugin {
        }
 
        function setNote() {
-               $id = db_escape_string($this->link, $_REQUEST["id"]);
-               $note = trim(strip_tags(db_escape_string($this->link, $_REQUEST["note"])));
+               $id = db_escape_string( $_REQUEST["id"]);
+               $note = trim(strip_tags(db_escape_string( $_REQUEST["note"])));
 
-               db_query($this->link, "UPDATE ttrss_user_entries SET note = '$note'
+               db_query( "UPDATE ttrss_user_entries SET note = '$note'
                        WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
 
                $formatted_note = format_article_note($id, $note);
index 247d56a1e7e68bf740864c07543ad8763b8fa472..92b5f65b220ba60f162142093994a261b53abd8c 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 class NSFW extends Plugin {
-
-       private $link;
        private $host;
 
        function about() {
@@ -12,7 +10,6 @@ class NSFW extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
@@ -91,7 +88,7 @@ class NSFW extends Plugin {
        }
 
        function save() {
-               $tags = explode(",", db_escape_string($this->link, $_POST["tags"]));
+               $tags = explode(",", db_escape_string( $_POST["tags"]));
                $tags = array_map("trim", $tags);
                $tags = array_map("mb_strtolower", $tags);
                $tags = join(", ", $tags);
index 4d7e0437c5457b17bd5c523d2375918da45c1947..b9e030d3712eb67a992ae7517ff58e7811f916b7 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 class Share extends Plugin {
-       private $link;
        private $host;
 
        function about() {
@@ -10,7 +9,6 @@ class Share extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
@@ -28,9 +26,9 @@ class Share extends Plugin {
        }
 
        function shareArticle() {
-               $param = db_escape_string($this->link, $_REQUEST['param']);
+               $param = db_escape_string( $_REQUEST['param']);
 
-               $result = db_query($this->link, "SELECT uuid, ref_id FROM ttrss_user_entries WHERE int_id = '$param'
+               $result = db_query( "SELECT uuid, ref_id FROM ttrss_user_entries WHERE int_id = '$param'
                        AND owner_uid = " . $_SESSION['uid']);
 
                if (db_num_rows($result) == 0) {
@@ -41,8 +39,8 @@ class Share extends Plugin {
                        $ref_id = db_fetch_result($result, 0, "ref_id");
 
                        if (!$uuid) {
-                               $uuid = db_escape_string($this->link, sha1(uniqid(rand(), true)));
-                               db_query($this->link, "UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$param'
+                               $uuid = db_escape_string( sha1(uniqid(rand(), true)));
+                               db_query( "UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$param'
                                        AND owner_uid = " . $_SESSION['uid']);
                        }
 
@@ -55,10 +53,10 @@ class Share extends Plugin {
                        print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
                        print "</div>";
 
-                       /* if (!label_find_id($this->link, __('Shared'), $_SESSION["uid"]))
-                               label_create($this->link, __('Shared'), $_SESSION["uid"]);
+                       /* if (!label_find_id( __('Shared'), $_SESSION["uid"]))
+                               label_create( __('Shared'), $_SESSION["uid"]);
 
-                       label_add_article($this->link, $ref_id, __('Shared'), $_SESSION['uid']); */
+                       label_add_article( $ref_id, __('Shared'), $_SESSION['uid']); */
                }
 
                print "<div align='center'>";
index 34b09bd77fbec34c6b91345496348bb94565a26f..73fb820072d3e68b014b807adbcba9fc99b86d37 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 class Swap_JK extends Plugin {
 
-       private $link;
        private $host;
 
        function about() {
@@ -11,7 +10,6 @@ class Swap_JK extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_HOTKEY_MAP, $this);
index 6bfaa82c44bab66eef403c1ad047b6639f8fbbc9..856a0cbf9a7977e42744e437535d07b398829b21 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 class Updater extends Plugin {
 
-       private $link;
        private $host;
 
        function about() {
@@ -12,7 +11,6 @@ class Updater extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_PREFS_TAB, $this);
@@ -22,7 +20,7 @@ class Updater extends Plugin {
                        $this);
        }
 
-       function update_self_step($link, $step, $params, $force = false) {
+       function update_self_step( $step, $params, $force = false) {
                // __FILE__ is in plugins/updater so we need to go one level up
                $work_dir = dirname(dirname(dirname(__FILE__)));
                $parent_dir = dirname($work_dir);
@@ -279,13 +277,13 @@ class Updater extends Plugin {
                return array("step" => $step, "stop" => $stop, "params" => $params, "log" => $log);
        }
 
-       function update_self_cli($link, $force = false) {
+       function update_self_cli( $force = false) {
                $step = 0;
                $stop = false;
                $params = array();
 
                while (!$stop) {
-                       $rc = $this->update_self_step($link, $step, $params, $force);
+                       $rc = $this->update_self_step( $step, $params, $force);
 
                        $params = $rc['params'];
                        $stop = $rc['stop'];
@@ -309,7 +307,7 @@ class Updater extends Plugin {
                if ($input != 'yes' && $input != 'force')
                        exit;
 
-               $this->update_self_cli($link, $input == 'force');
+               $this->update_self_cli( $input == 'force');
        }
 
        function get_prefs_js() {
@@ -323,7 +321,7 @@ class Updater extends Plugin {
                        print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Update Tiny Tiny RSS')."\">";
 
                        if ($_SESSION["pref_last_version_check"] + 86400 + rand(-1000, 1000) < time()) {
-                               $_SESSION["version_data"] = @check_for_update($this->link);
+                               $_SESSION["version_data"] = @check_for_update();
                                $_SESSION["pref_last_version_check"] = time();
                        }
 
@@ -378,7 +376,7 @@ class Updater extends Plugin {
                $force = (bool) $_REQUEST["force"];
 
                if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE) && CHECK_FOR_NEW_VERSION) {
-                       print   json_encode($this->update_self_step($this->link, $step, $params, $force));
+                       print   json_encode($this->update_self_step( $step, $params, $force));
                }
        }
 
index 7a7d2842cc99f4dd2f9a0834768363a3891a7d97..54d5ebad8cf7c47b4ba98759941ed92f5e8a9cc8 100644 (file)
--- a/prefs.php
+++ b/prefs.php
@@ -22,9 +22,9 @@
 
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
 
-       if (!init_plugins($link)) return;
+       if (!init_plugins()) return;
 
-       login_sequence($link);
+       login_sequence();
 
        header('Content-Type: text/html; charset=utf-8');
 ?>
        <?php echo stylesheet_tag("prefs.css"); ?>
 
        <?php if ($_SESSION["uid"]) {
-               $theme = get_pref($link, "USER_CSS_THEME", $_SESSION["uid"], false);
+               $theme = get_pref( "USER_CSS_THEME", $_SESSION["uid"], false);
                if ($theme) {
                        echo stylesheet_tag("themes/$theme");
                }
        }
        ?>
 
-       <?php print_user_stylesheet($link) ?>
+       <?php print_user_stylesheet() ?>
 
        <link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
        <link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png" />
 
 </div>
 
-<?php db_close($link); ?>
+<?php db_close(); ?>
 
 </body>
 </html>
index ae6ae44b20b322a9f55a2c3dbfc3d8811c1cba48..fa8ea29b8f4623f9dceb037d6ff5bc49a62c5ee3 100644 (file)
@@ -31,7 +31,7 @@
 
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
 
-       if (!init_plugins($link)) return;
+       if (!init_plugins()) return;
 
        if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) {
                ob_start("ob_gzhandler");
@@ -45,7 +45,7 @@
        if ($override) {
                $handler = $override;
        } else {
-               $handler = new Handler_Public($link, $_REQUEST);
+               $handler = new Handler_Public( $_REQUEST);
        }
 
        if (implements_interface($handler, "IHandler") && $handler->before($method)) {
@@ -62,5 +62,5 @@
        print json_encode(array("error" => array("code" => 7)));
 
        // We close the connection to database.
-       db_close($link);
+       db_close();
 ?>
index d7c60d4f01674886ab78c5d2ec926a56d61b2e27..a8fdb483aec1c476f6f9c098a81a745d09f12326 100644 (file)
@@ -19,7 +19,7 @@
 
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
 
-       if (!init_plugins($link)) return;
+       if (!init_plugins()) return;
 
        if ($_REQUEST["format"] == "feed") {
                header("Content-Type: text/xml");
@@ -32,7 +32,7 @@
                        <link rel=\"alternate\" href=\"".htmlspecialchars(SELF_URL_PATH)."\"/>";
 
                if (ENABLE_REGISTRATION) {
-                       $result = db_query($link, "SELECT COUNT(*) AS cu FROM ttrss_users");
+                       $result = db_query( "SELECT COUNT(*) AS cu FROM ttrss_users");
                        $num_users = db_fetch_result($result, 0, "cu");
 
                        $num_users = REG_MAX_USERS - $num_users;
        /* Remove users which didn't login after receiving their registration information */
 
        if (DB_TYPE == "pgsql") {
-               db_query($link, "DELETE FROM ttrss_users WHERE last_login IS NULL
+               db_query( "DELETE FROM ttrss_users WHERE last_login IS NULL
                                AND created < NOW() - INTERVAL '1 day' AND access_level = 0");
        } else {
-               db_query($link, "DELETE FROM ttrss_users WHERE last_login IS NULL
+               db_query( "DELETE FROM ttrss_users WHERE last_login IS NULL
                                AND created < DATE_SUB(NOW(), INTERVAL 1 DAY) AND access_level = 0");
        }
 
@@ -74,9 +74,9 @@
        if ($action == "check") {
                header("Content-Type: application/xml");
 
-               $login = trim(db_escape_string($link, $_REQUEST['login']));
+               $login = trim(db_escape_string( $_REQUEST['login']));
 
-               $result = db_query($link, "SELECT id FROM ttrss_users WHERE
+               $result = db_query( "SELECT id FROM ttrss_users WHERE
                        LOWER(login) = LOWER('$login')");
 
                $is_registered = db_num_rows($result) > 0;
 ?>
 
 <?php if (REG_MAX_USERS > 0) {
-               $result = db_query($link, "SELECT COUNT(*) AS cu FROM ttrss_users");
+               $result = db_query( "SELECT COUNT(*) AS cu FROM ttrss_users");
                $num_users = db_fetch_result($result, 0, "cu");
 } ?>
 
        <?php } else if ($action == "do_register") { ?>
 
        <?php
-               $login = mb_strtolower(trim(db_escape_string($link, $_REQUEST["login"])));
-               $email = trim(db_escape_string($link, $_REQUEST["email"]));
-               $test = trim(db_escape_string($link, $_REQUEST["turing_test"]));
+               $login = mb_strtolower(trim(db_escape_string( $_REQUEST["login"])));
+               $email = trim(db_escape_string( $_REQUEST["email"]));
+               $test = trim(db_escape_string( $_REQUEST["turing_test"]));
 
                if (!$login || !$email || !$test) {
                        print_error(__("Your registration information is incomplete."));
 
                if ($test == "four" || $test == "4") {
 
-                       $result = db_query($link, "SELECT id FROM ttrss_users WHERE
+                       $result = db_query( "SELECT id FROM ttrss_users WHERE
                                login = '$login'");
 
                        $is_registered = db_num_rows($result) > 0;
                                $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
                                $pwd_hash = encrypt_password($password, $salt, true);
 
-                               db_query($link, "INSERT INTO ttrss_users
+                               db_query( "INSERT INTO ttrss_users
                                        (login,pwd_hash,access_level,last_login, email, created, salt)
                                        VALUES ('$login', '$pwd_hash', 0, null, '$email', NOW(), '$salt')");
 
-                               $result = db_query($link, "SELECT id FROM ttrss_users WHERE
+                               $result = db_query( "SELECT id FROM ttrss_users WHERE
                                        login = '$login' AND pwd_hash = '$pwd_hash'");
 
                                if (db_num_rows($result) != 1) {
 
                                        $new_uid = db_fetch_result($result, 0, "id");
 
-                                       initialize_user($link, $new_uid);
+                                       initialize_user( $new_uid);
 
                                        $reg_text = "Hi!\n".
                                                "\n".
index d9009f9652e47e134dd5b41427e0a91eeea81790..abbe6c577bc5d496859674fc2806989de9205160 100755 (executable)
        if (!defined('PHP_EXECUTABLE'))
                define('PHP_EXECUTABLE', '/usr/bin/php');
 
-       // Create a database connection.
-       $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
-
-       init_plugins($link);
+       init_plugins();
 
        $longopts = array("feeds",
                        "feedbrowser",
@@ -91,7 +88,7 @@
        }
 
        if (!isset($options['update-schema'])) {
-               $schema_version = get_schema_version($link);
+               $schema_version = get_schema_version();
 
                if ($schema_version != SCHEMA_VERSION) {
                        die("Schema version is wrong, please upgrade the database.\n");
        if (isset($options["force-update"])) {
                _debug("marking all feeds as needing update...");
 
-               db_query($link, "UPDATE ttrss_feeds SET last_update_started = '1970-01-01',
+               db_query( "UPDATE ttrss_feeds SET last_update_started = '1970-01-01',
                                last_updated = '1970-01-01'");
        }
 
        if (isset($options["feeds"])) {
                // Update all feeds needing a update.
-               update_daemon_common($link);
+               update_daemon_common();
 
                // Update feedbrowser
-               $count = update_feedbrowser_cache($link);
+               $count = update_feedbrowser_cache();
                _debug("Feedbrowser updated, $count feeds processed.");
 
                // Purge orphans and cleanup tags
-               purge_orphans($link, true);
+               purge_orphans( true);
 
-               $rc = cleanup_tags($link, 14, 50000);
+               $rc = cleanup_tags( 14, 50000);
                _debug("Cleaned $rc cached tags.");
 
                global $pluginhost;
        }
 
        if (isset($options["feedbrowser"])) {
-               $count = update_feedbrowser_cache($link);
+               $count = update_feedbrowser_cache();
                print "Finished, $count feeds processed.\n";
        }
 
                // or regenerate feedbrowser cache
 
                if (rand(0,100) > 30) {
-                       update_daemon_common($link);
+                       update_daemon_common();
                } else {
-                       $count = update_feedbrowser_cache($link);
+                       $count = update_feedbrowser_cache();
                        _debug("Feedbrowser updated, $count feeds processed.");
 
-                       purge_orphans($link, true);
+                       purge_orphans( true);
 
-                       $rc = cleanup_tags($link, 14, 50000);
+                       $rc = cleanup_tags( 14, 50000);
 
                        _debug("Cleaned $rc cached tags.");
 
        }
 
        if (isset($options["cleanup-tags"])) {
-               $rc = cleanup_tags($link, 14, 50000);
+               $rc = cleanup_tags( 14, 50000);
                _debug("$rc tags deleted.\n");
        }
 
                _debug("clearing existing indexes...");
 
                if (DB_TYPE == "pgsql") {
-                       $result = db_query($link, "SELECT relname FROM
+                       $result = db_query( "SELECT relname FROM
                                pg_catalog.pg_class WHERE relname LIKE 'ttrss_%'
                                        AND relname NOT LIKE '%_pkey'
                                AND relkind = 'i'");
                } else {
-                       $result = db_query($link, "SELECT index_name,table_name FROM
+                       $result = db_query( "SELECT index_name,table_name FROM
                                information_schema.statistics WHERE index_name LIKE 'ttrss_%'");
                }
 
                                        $line['table_name']." DROP INDEX ".$line['index_name'];
                                _debug($statement);
                        }
-                       db_query($link, $statement, false);
+                       db_query( $statement, false);
                }
 
                _debug("reading indexes from schema for: " . DB_TYPE);
                                        $statement = "CREATE INDEX $index ON $table";
 
                                        _debug($statement);
-                                       db_query($link, $statement);
+                                       db_query( $statement);
                                }
                        }
                        fclose($fp);
 
                _debug("converting filters...");
 
-               db_query($link, "DELETE FROM ttrss_filters2");
+               db_query( "DELETE FROM ttrss_filters2");
 
-               $result = db_query($link, "SELECT * FROM ttrss_filters ORDER BY id");
+               $result = db_query( "SELECT * FROM ttrss_filters ORDER BY id");
 
                while ($line = db_fetch_assoc($result)) {
                        $owner_uid = $line["owner_uid"];
                                $_REQUEST = $filter;
                                $_SESSION["uid"] = $owner_uid;
 
-                               $filters = new Pref_Filters($link, $_REQUEST);
+                               $filters = new Pref_Filters( $_REQUEST);
                                $filters->add();
                        }
                }
        if (isset($options["update-schema"])) {
                _debug("checking for updates (" . DB_TYPE . ")...");
 
-               $updater = new DbUpdater($link, DB_TYPE, SCHEMA_VERSION);
+               $updater = new DbUpdater( DB_TYPE, SCHEMA_VERSION);
 
                if ($updater->isUpdateRequired()) {
                        _debug("schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION);
        }
 
        if (isset($options["list-plugins"])) {
-               $tmppluginhost = new PluginHost($link);
+               $tmppluginhost = new PluginHost();
                $tmppluginhost->load_all($tmppluginhost::KIND_ALL);
                $enabled = array_map("trim", explode(",", PLUGINS));
 
 
        $pluginhost->run_commands($options);
 
-       db_close($link);
-
        if ($lock_handle != false) {
                fclose($lock_handle);
        }
index 6d13add0051135c4e65858184ba7ecfc13a11926..f5e031c9ea977f59db8433663f46ed29a50003ca 100755 (executable)
                        "Maybe another daemon is already running.\n");
        }
 
-       // Testing database connection.
-       // It is unnecessary to start the fork loop if database is not ok.
-       $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
+       init_plugins();
 
-       if (!init_plugins($link)) die("Can't initialize db connection.\n");
+       $schema_version = get_schema_version();
 
-       $schema_version = get_schema_version($link);
-
-       db_close($link);
+       db_close();
 
        if ($schema_version != SCHEMA_VERSION) {
                die("Schema version is wrong, please upgrade the database.\n");
 
                        /* Check if schema version changed */
 
-                       $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
-                       if (!init_plugins($link)) die("Can't initialize db connection.\n");
-                       $test_schema_version = get_schema_version($link);
-                       db_close($link);
+                       init_plugins();
+                       $test_schema_version = get_schema_version();
 
                        if ($test_schema_version != $schema_version) {
                                echo "Expected schema version: $schema_version, got: $test_schema_version\n";
 
                                        $start_timestamp = time();
 
-                                       $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
-
-                                       if (!init_plugins($link)) return;
+                                       if (!init_plugins()) return;
 
                                        // We disable stamp file, since it is of no use in a multiprocess update.
                                        // not really, tho for the time being -fox
 
                                        _debug("Waiting before update [$j]..");
                                        sleep($j*5);
-                                       $nf = update_daemon_common($link);
+                                       $nf = update_daemon_common();
 
                                        if (rand(0,100) > 50) {
-                                               $count = update_feedbrowser_cache($link);
+                                               $count = update_feedbrowser_cache();
                                                _debug("Feedbrowser updated, $count feeds processed.");
 
-                                               purge_orphans($link, true);
+                                               purge_orphans( true);
 
-                                               $rc = cleanup_tags($link, 14, 50000);
+                                               $rc = cleanup_tags( 14, 50000);
 
                                                _debug("Cleaned $rc cached tags.");
 
                                                }
                                        }
 
-                                       db_close($link);
+                                       db_close();
 
                                        // We are in a fork.
                                        // We wait a little before exiting to avoid to be faster than our parent process.