From a42c55f02b7e313ab61bf826794d0888f2dceae1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Apr 2013 18:34:18 +0400 Subject: [PATCH] fix blank character after opening bracket in function calls --- classes/api.php | 172 +++++----- classes/article.php | 104 +++---- classes/auth/base.php | 8 +- classes/backend.php | 2 +- classes/db/pgsql.php | 4 +- classes/dbupdater.php | 10 +- classes/dlg.php | 18 +- classes/feeds.php | 124 ++++---- classes/handler/public.php | 128 ++++---- classes/logger/sql.php | 2 +- classes/opml.php | 98 +++--- classes/pluginhost.php | 18 +- classes/pref/feeds.php | 268 ++++++++-------- classes/pref/filters.php | 124 ++++---- classes/pref/labels.php | 66 ++-- classes/pref/prefs.php | 54 ++-- classes/pref/system.php | 2 +- classes/pref/users.php | 50 +-- classes/rpc.php | 204 ++++++------ classes/sessionhandler.php | 4 +- include/ccache.php | 78 ++--- include/colors.php | 18 +- include/db-prefs.php | 18 +- include/db.php | 6 +- include/digest.php | 26 +- include/feedbrowser.php | 8 +- include/functions.php | 468 ++++++++++++++-------------- include/labels.php | 70 ++--- include/rssfuncs.php | 190 +++++------ include/sanity_check.php | 2 +- include/sanity_config.php | 2 +- plugins/auth_internal/init.php | 24 +- plugins/auth_remote/init.php | 18 +- plugins/close_button/init.php | 2 +- plugins/digest/init.php | 20 +- plugins/embed_original/init.php | 4 +- plugins/example/init.php | 2 +- plugins/example_vfeed/init.php | 2 +- plugins/googlereaderimport/init.php | 46 +-- plugins/import_export/init.php | 40 +-- plugins/instances/init.php | 66 ++-- plugins/mail/init.php | 10 +- plugins/mailto/init.php | 4 +- plugins/mark_button/init.php | 2 +- plugins/mobile/article.php | 12 +- plugins/mobile/backend.php | 24 +- plugins/mobile/cat.php | 6 +- plugins/mobile/feed.php | 14 +- plugins/mobile/home.php | 8 +- plugins/mobile/index.php | 8 +- plugins/mobile/mobile-functions.php | 90 +++--- plugins/mobile/prefs.php | 14 +- plugins/note/init.php | 10 +- plugins/nsfw/init.php | 2 +- plugins/share/init.php | 14 +- plugins/updater/init.php | 10 +- 56 files changed, 1399 insertions(+), 1399 deletions(-) diff --git a/classes/api.php b/classes/api.php index 10e51191..422fc5a1 100644 --- a/classes/api.php +++ b/classes/api.php @@ -18,7 +18,7 @@ class API extends Handler { return false; } - if ($_SESSION["uid"] && $method != "logout" && !get_pref( '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( $_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( "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( "ENABLE_API_ACCESS", $uid)) { - if (authenticate_user( $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( $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,11 +95,11 @@ class API extends Handler { } function getUnread() { - $feed_id = db_escape_string( $_REQUEST["feed_id"]); - $is_cat = db_escape_string( $_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( $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())); } @@ -111,13 +111,13 @@ class API extends Handler { } function getFeeds() { - $cat_id = db_escape_string( $_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( $_REQUEST["limit"]); - $offset = (int) db_escape_string( $_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( $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( "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( $line["id"], true); + $unread = getFeedUnread($line["id"], true); if ($enable_nested) - $unread += getCategoryChildrenUnread( $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( $cat_id, true); + $unread = getFeedUnread($cat_id, true); if ($unread || !$unread_only) { array_push($cats, array("id" => $cat_id, - "title" => getCategoryTitle( $cat_id), + "title" => getCategoryTitle($cat_id), "unread" => $unread)); } } @@ -180,22 +180,22 @@ class API extends Handler { } function getHeadlines() { - $feed_id = db_escape_string( $_REQUEST["feed_id"]); + $feed_id = db_escape_string($_REQUEST["feed_id"]); if ($feed_id != "") { - $limit = (int)db_escape_string( $_REQUEST["limit"]); + $limit = (int)db_escape_string($_REQUEST["limit"]); if (!$limit || $limit >= 60) $limit = 60; - $offset = (int)db_escape_string( $_REQUEST["skip"]); - $filter = db_escape_string( $_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( $_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( $_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( $_REQUEST["search"]); - $search_mode = db_escape_string( $_REQUEST["search_mode"]); + $search = db_escape_string($_REQUEST["search"]); + $search_mode = db_escape_string($_REQUEST["search_mode"]); - $headlines = $this->api_get_headlines( $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( $_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"]); + $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( "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( $result); + $num_updated = db_affected_rows($result); if ($num_updated > 0 && $field == "unread") { - $result = db_query( "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( $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( -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( $_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( $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( $line['id']); + $attachments = get_article_enclosures($line['id']); $article = array( "id" => $line["id"], "title" => $line["title"], "link" => $line["link"], - "labels" => get_article_labels( $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( "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( $_REQUEST["feed_id"]); + $feed_id = (int) db_escape_string($_REQUEST["feed_id"]); - update_rss_feed( $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( $_REQUEST["feed_id"]); - $is_cat = db_escape_string( $_REQUEST["is_cat"]); + $feed_id = db_escape_string($_REQUEST["feed_id"]); + $is_cat = db_escape_string($_REQUEST["is_cat"]); - catchup_feed( $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( $_REQUEST["pref_name"]); + $pref_name = db_escape_string($_REQUEST["pref_name"]); - print $this->wrap(self::STATUS_OK, array("value" => get_pref( $pref_name))); + print $this->wrap(self::STATUS_OK, array("value" => get_pref($pref_name))); } function getLabels() { - //$article_ids = array_filter(explode(",", db_escape_string( $_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( "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( $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( $_REQUEST["article_ids"])), is_numeric); - $label_id = (int) db_escape_string( $_REQUEST['label_id']); - $assign = (bool) db_escape_string( $_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( label_find_caption( + $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( $id, $label, $_SESSION["uid"]); + label_add_article($id, $label, $_SESSION["uid"]); else - label_remove_article( $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( strip_tags($_REQUEST["title"])); - $url = db_escape_string( strip_tags($_REQUEST["url"])); - $content = db_escape_string( 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( $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( $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( 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( $i); + $unread = getFeedUnread($i); if ($unread || !$unread_only) { - $title = getFeedTitle( $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( "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( $line["id"], true) + - getCategoryChildrenUnread( $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( "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( "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( $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( $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( $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( $line["id"]); - //if (!$labels) $labels = get_article_labels( $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"], @@ -709,13 +709,13 @@ class API extends Handler { } function unsubscribeFeed() { - $feed_id = (int) db_escape_string( $_REQUEST["feed_id"]); + $feed_id = (int) db_escape_string($_REQUEST["feed_id"]); - $result = db_query( "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( $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( $_REQUEST["feed_url"]); - $category_id = (int) db_escape_string( $_REQUEST["category_id"]); - $login = db_escape_string( $_REQUEST["login"]); - $password = db_escape_string( $_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( $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( $_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( "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( "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; diff --git a/classes/article.php b/classes/article.php index 9917d4d0..df850dac 100644 --- a/classes/article.php +++ b/classes/article.php @@ -8,9 +8,9 @@ class Article extends Handler_Protected { } function redirect() { - $id = db_escape_string( $_REQUEST['id']); + $id = db_escape_string($_REQUEST['id']); - $result = db_query( "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( $_REQUEST["id"]); - $cids = explode(",", db_escape_string( $_REQUEST["cids"])); - $mode = db_escape_string( $_REQUEST["mode"]); - $omode = db_escape_string( $_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( $id, false)); + array_push($articles, format_article($id, false)); } else if ($mode == "zoom") { - array_push($articles, format_article( $id, true, true)); + array_push($articles, format_article($id, true, true)); } else if ($mode == "raw") { if ($_REQUEST['html']) { header("Content-Type: text/html"); print ''; } - $article = format_article( $id, false); + $article = format_article($id, false); print $article['content']; return; } - $this->catchupArticleById( $id, 0); + $this->catchupArticleById($id, 0); if (!$_SESSION["bw_limit"]) { foreach ($cids as $cid) { if ($cid) { - array_push($articles, format_article( $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( $id, $cmode) { + private function catchupArticleById($id, $cmode) { if ($cmode == 0) { - db_query( "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( "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( "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( $id); - ccache_update( $feed_id, $_SESSION["uid"]); + $feed_id = getArticleFeed($id); + ccache_update($feed_id, $_SESSION["uid"]); } - static function create_published_article( $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( "BEGIN"); + db_query("BEGIN"); // only check for our user data here, others might have shared this with different content etc - $result = db_query( "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( "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( "UPDATE ttrss_entries SET + db_query("UPDATE ttrss_entries SET content = '$content', content_hash = '$content_hash' WHERE id = '$ref_id'"); - db_query( "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( "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( $ref_id, trim($label), $owner_uid); + label_add_article($ref_id, trim($label), $owner_uid); } } $rc = true; } else { - $result = db_query( "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( "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( "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( $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( "COMMIT"); + db_query("COMMIT"); return $rc; } @@ -178,9 +178,9 @@ class Article extends Handler_Protected { print __("Tags for this article (separated by commas):")."
"; - $param = db_escape_string( $_REQUEST['param']); + $param = db_escape_string($_REQUEST['param']); - $tags = get_article_tags( db_escape_string( $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( $_REQUEST['id']); - $score = (int)db_escape_string( $_REQUEST['score']); + $ids = db_escape_string($_REQUEST['id']); + $score = (int)db_escape_string($_REQUEST['score']); - db_query( "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( $_REQUEST["id"]); + $id = db_escape_string($_REQUEST["id"]); - $tags_str = db_escape_string( $_REQUEST["tags_str"]); + $tags_str = db_escape_string($_REQUEST["tags_str"]); $tags = array_unique(trim_array(explode(",", $tags_str))); - db_query( "BEGIN"); + db_query("BEGIN"); - $result = db_query( "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( "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 ""; if ($tag != '') { - db_query( "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( "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( "COMMIT"); + db_query("COMMIT"); - $tags = get_article_tags( $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( $_REQUEST["search"]); + $search = db_escape_string($_REQUEST["search"]); - $result = db_query( "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( $_REQUEST["ids"])); - $label_id = db_escape_string( $_REQUEST["lid"]); + $ids = explode(",", db_escape_string($_REQUEST["ids"])); + $label_id = db_escape_string($_REQUEST["lid"]); - $label = db_escape_string( label_find_caption( $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( $id, $label, $_SESSION["uid"]); + label_add_article($id, $label, $_SESSION["uid"]); else - label_remove_article( $id, $label, $_SESSION["uid"]); + label_remove_article($id, $label, $_SESSION["uid"]); - $labels = get_article_labels( $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))); diff --git a/classes/auth/base.php b/classes/auth/base.php index 102a1977..782848a7 100644 --- a/classes/auth/base.php +++ b/classes/auth/base.php @@ -15,7 +15,7 @@ class Auth_Base { $user_id = $this->find_user_by_login($login); if (!$user_id) { - $login = db_escape_string( $login); + $login = db_escape_string($login); $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); $pwd_hash = encrypt_password($password, $salt, true); @@ -23,7 +23,7 @@ class Auth_Base { (login,access_level,last_login,created,pwd_hash,salt) VALUES ('$login', 0, null, NOW(), '$pwd_hash','$salt')"; - db_query( $query); + db_query($query); return $this->find_user_by_login($login); @@ -36,9 +36,9 @@ class Auth_Base { } function find_user_by_login($login) { - $login = db_escape_string( $login); + $login = db_escape_string($login); - $result = db_query( "SELECT id FROM ttrss_users WHERE + $result = db_query("SELECT id FROM ttrss_users WHERE login = '$login'"); if (db_num_rows($result) > 0) { diff --git a/classes/backend.php b/classes/backend.php index a0416810..7737df0f 100644 --- a/classes/backend.php +++ b/classes/backend.php @@ -11,7 +11,7 @@ class Backend extends Handler { require_once "digest.php"; - $rv = prepare_headlines_digest( $_SESSION['uid'], 1, 1000); + $rv = prepare_headlines_digest($_SESSION['uid'], 1, 1000); $rv[3] = "
" . $rv[3] . "
"; diff --git a/classes/db/pgsql.php b/classes/db/pgsql.php index 0cb73797..4d860790 100644 --- a/classes/db/pgsql.php +++ b/classes/db/pgsql.php @@ -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( $s); + return pg_escape_string($s); } function query($query, $die_on_error = true) { - $result = pg_query( $query); + $result = pg_query($query); if (!$result) { $query = htmlspecialchars($query); // just in case diff --git a/classes/dbupdater.php b/classes/dbupdater.php index ffcac7cf..a319da03 100644 --- a/classes/dbupdater.php +++ b/classes/dbupdater.php @@ -12,7 +12,7 @@ class DbUpdater { } function getSchemaVersion() { - $result = db_query( "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( "BEGIN"); + db_query("BEGIN"); foreach ($lines as $line) { if (strpos($line, "--") !== 0 && $line) { - db_query( $line); + db_query($line); } } $db_version = $this->getSchemaVersion(); if ($db_version == $version) { - db_query( "COMMIT"); + db_query("COMMIT"); return true; } else { - db_query( "ROLLBACK"); + db_query("ROLLBACK"); return false; } } else { diff --git a/classes/dlg.php b/classes/dlg.php index 99cd7cff..5e14690c 100644 --- a/classes/dlg.php +++ b/classes/dlg.php @@ -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( $_REQUEST["param"]); + $this->param = db_escape_string($_REQUEST["param"]); return true; } return false; @@ -18,15 +18,15 @@ class Dlg extends Handler_Protected { print "
"; $owner_uid = $_SESSION["uid"]; - db_query( "BEGIN"); + db_query("BEGIN"); print ""; print "
"; @@ -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( $query); + $result = db_query($query); $tags = array(); @@ -114,7 +114,7 @@ class Dlg extends Handler_Protected { $tags[$line["tag_name"]] = $line["count"]; } - if( count($tags) == 0 ){ return; } + if(count($tags) == 0 ){ return; } ksort($tags); @@ -171,7 +171,7 @@ class Dlg extends Handler_Protected { print "