Browse Source

fix blank character after opening bracket in function calls

Andrew Dolgov 7 years ago
parent
commit
a42c55f02b
56 changed files with 1306 additions and 1306 deletions
  1. 86 86
      classes/api.php
  2. 52 52
      classes/article.php
  3. 4 4
      classes/auth/base.php
  4. 1 1
      classes/backend.php
  5. 2 2
      classes/db/pgsql.php
  6. 5 5
      classes/dbupdater.php
  7. 9 9
      classes/dlg.php
  8. 62 62
      classes/feeds.php
  9. 64 64
      classes/handler/public.php
  10. 1 1
      classes/logger/sql.php
  11. 49 49
      classes/opml.php
  12. 9 9
      classes/pluginhost.php
  13. 134 134
      classes/pref/feeds.php
  14. 62 62
      classes/pref/filters.php
  15. 33 33
      classes/pref/labels.php
  16. 27 27
      classes/pref/prefs.php
  17. 1 1
      classes/pref/system.php
  18. 25 25
      classes/pref/users.php
  19. 102 102
      classes/rpc.php
  20. 2 2
      classes/sessionhandler.php
  21. 39 39
      include/ccache.php
  22. 9 9
      include/colors.php
  23. 9 9
      include/db-prefs.php
  24. 3 3
      include/db.php
  25. 13 13
      include/digest.php
  26. 4 4
      include/feedbrowser.php
  27. 141 141
      include/functions.php
  28. 35 35
      include/labels.php
  29. 95 95
      include/rssfuncs.php
  30. 1 1
      include/sanity_check.php
  31. 1 1
      include/sanity_config.php
  32. 12 12
      plugins/auth_internal/init.php
  33. 9 9
      plugins/auth_remote/init.php
  34. 1 1
      plugins/close_button/init.php
  35. 10 10
      plugins/digest/init.php
  36. 2 2
      plugins/embed_original/init.php
  37. 1 1
      plugins/example/init.php
  38. 1 1
      plugins/example_vfeed/init.php
  39. 23 23
      plugins/googlereaderimport/init.php
  40. 20 20
      plugins/import_export/init.php
  41. 33 33
      plugins/instances/init.php
  42. 5 5
      plugins/mail/init.php
  43. 2 2
      plugins/mailto/init.php
  44. 1 1
      plugins/mark_button/init.php
  45. 6 6
      plugins/mobile/article.php
  46. 12 12
      plugins/mobile/backend.php
  47. 3 3
      plugins/mobile/cat.php
  48. 7 7
      plugins/mobile/feed.php
  49. 4 4
      plugins/mobile/home.php
  50. 4 4
      plugins/mobile/index.php
  51. 45 45
      plugins/mobile/mobile-functions.php
  52. 7 7
      plugins/mobile/prefs.php
  53. 5 5
      plugins/note/init.php
  54. 1 1
      plugins/nsfw/init.php
  55. 7 7
      plugins/share/init.php
  56. 5 5
      plugins/updater/init.php

+ 86 - 86
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;

+ 52 - 52
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 '<link rel="stylesheet" type="text/css" href="tt-rss.css"/>';
 			}
 
-			$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):")."<br>";
 
-		$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 "<!-- $id : $int_id : $tag -->";
 
 				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)));

+ 4 - 4
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) {

+ 1 - 1
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] = "<pre>" . $rv[3] . "</pre>";
 

+ 2 - 2
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

+ 5 - 5
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 {

+ 9 - 9
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 "<div class=\"prefFeedOPMLHolder\">";
 		$owner_uid = $_SESSION["uid"];
 
-		db_query( "BEGIN");
+		db_query("BEGIN");
 
 		print "<ul class='nomarks'>";
 
-		$opml = new Opml( $_REQUEST);
+		$opml = new Opml($_REQUEST);
 
 		$opml->opml_import($_SESSION["uid"]);
 
-		db_query( "COMMIT");
+		db_query("COMMIT");
 
 		print "</ul>";
 		print "</div>";
@@ -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 "<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( "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->params[0]);
+		$feed_id = db_escape_string($this->params[0]);
 		$is_cat = (bool) $this->params[1];
 
-		$key = get_feed_access_key( $feed_id, $is_cat);
+		$key = get_feed_access_key($feed_id, $is_cat);
 
 		$url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
 

+ 62 - 62
classes/feeds.php

@@ -174,16 +174,16 @@ class Feeds extends Handler_Protected {
 
 					if (!$cache_images && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {
 						include "rssfuncs.php";
-						update_rss_feed( $feed, true, true);
+						update_rss_feed($feed, true, true);
 					} else {
-						db_query( "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( $method_split[1], false);
+			catchup_feed($method_split[1], false);
 		}
 
 		// FIXME: might break tag display?
@@ -197,18 +197,18 @@ class Feeds extends Handler_Protected {
 			}
 		}
 
-		@$search = db_escape_string( $_REQUEST["query"]);
+		@$search = db_escape_string($_REQUEST["query"]);
 
 		if ($search) {
 			$disable_cache = true;
 		}
 
-		@$search_mode = db_escape_string( $_REQUEST["search_mode"]);
+		@$search_mode = db_escape_string($_REQUEST["search_mode"]);
 
 		if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
 
 //		error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");
-		if( $search_mode == '' && $method != '' ){
+		if($search_mode == '' && $method != '' ){
 		    $search_mode = $method;
 		}
 //		error_log("search_mode: " . $search_mode);
@@ -240,7 +240,7 @@ class Feeds extends Handler_Protected {
 			}
 
 		} else {
-			$qfh_ret = queryFeedHeadlines( $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,7 +261,7 @@ class Feeds extends Handler_Protected {
 
 		$headlines_count = db_num_rows($result);
 
-		/* if (get_pref( 'COMBINED_DISPLAY_MODE')) {
+		/* if (get_pref('COMBINED_DISPLAY_MODE')) {
 			$button_plugins = array();
 			foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
 				$pclass = "button_" . trim($p);
@@ -282,11 +282,11 @@ class Feeds extends Handler_Protected {
 			$num_unread = 0;
 			$cur_feed_title = '';
 
-			$fresh_intl = get_pref( "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( '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( $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( $line["updated"], false);
+				$updated_fmt = make_local_datetime($line["updated"], false);
 				$date_entered_fmt = T_sprintf("Imported at %s",
-					make_local_datetime( $line["date_entered"], false));
+					make_local_datetime($line["date_entered"], false));
 
-				if (get_pref( 'SHOW_CONTENT_PREVIEW')) {
+				if (get_pref('SHOW_CONTENT_PREVIEW')) {
 					$content_preview = truncate_string(strip_tags($line["content_preview"]),
 						100);
 				}
@@ -423,15 +423,15 @@ class Feeds extends Handler_Protected {
 
 					/* $row_background = "background-image : -moz-linear-gradient(left, rgba(255, 255, 255, 0) 50%, rgba($rgba, 0.2) 100%);".
 						"background-image : linear-gradient(to right, rgba(255, 255, 255, 0) 50%, rgba($rgba, 0.2) 100%);";
-						"background-image : -webkit-gradient(linear, left top, right top, color-stop( 50%, rgba(255,255,255,0)),
+						"background-image : -webkit-gradient(linear, left top, right top, color-stop(50%, rgba(255,255,255,0)),
 							color-stop(100%, rgba($rgba, 0.2)));"; */
 				} else {
 					$row_background = "";
 				}
 
-				if (!get_pref( 'COMBINED_DISPLAY_MODE')) {
+				if (!get_pref('COMBINED_DISPLAY_MODE')) {
 
-					if (get_pref( '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( '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( '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( '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( $id, $_SESSION["uid"], $line["tag_cache"]);
+					$line["tags"] = get_article_tags($id, $_SESSION["uid"], $line["tag_cache"]);
 					unset($line["tag_cache"]);
 
-					$line["content"] = sanitize( $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( '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( '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( "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( "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( $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( "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( $last_updated, false);
+				$last_updated = make_local_datetime($last_updated, false);
 
 				$reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
 
-				$result = db_query( "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( "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( $_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( $_REQUEST["omode"]);
+		$omode = db_escape_string($_REQUEST["omode"]);
 
-		$feed = db_escape_string( $_REQUEST["feed"]);
-		$method = db_escape_string( $_REQUEST["m"]);
-		$view_mode = db_escape_string( $_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( $_REQUEST["nuf"]);
-		@$offset = db_escape_string( $_REQUEST["skip"]);
-		@$vgroup_last_feed = db_escape_string( $_REQUEST["vgrlf"]);
-		$order_by = db_escape_string( $_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;
 
@@ -824,18 +824,18 @@ class Feeds extends Handler_Protected {
 
 		if ($feed < LABEL_BASE_INDEX) {
 			$label_feed = feed_to_label_id($feed);
-			$result = db_query( "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( "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( "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( __("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( $feed, $_SESSION["uid"], $cat_view);
+			ccache_update($feed, $_SESSION["uid"], $cat_view);
 		}
 
-		set_pref( "_DEFAULT_VIEW_MODE", $view_mode);
-		set_pref( "_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( "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( "UPDATE ttrss_feeds SET last_viewed = NOW()
+			db_query("UPDATE ttrss_feeds SET last_viewed = NOW()
 							WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
 		}
 
@@ -924,15 +924,15 @@ class Feeds extends Handler_Protected {
 
 		$reply['headlines']['content'] .= "<p><span class=\"insensitive\">";
 
-		$result = db_query( "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( $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( "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( $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( 'ENABLE_FEED_CATS')) {
+		if (get_pref('ENABLE_FEED_CATS')) {
 			print __('Place in category:') . " ";
-			print_feed_cat_select( "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( $_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( $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( $_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( $active_feed_id);
+		$feed_title = getFeedTitle($active_feed_id);
 
 		if (!$is_cat) {
-			$feed_cat_title = getFeedCatTitle( $active_feed_id);
+			$feed_cat_title = getFeedCatTitle($active_feed_id);
 		} else {
-			$feed_cat_title = getCategoryTitle( $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( '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>";

+ 64 - 64
classes/handler/public.php

@@ -21,7 +21,7 @@ class Handler_Public extends Handler {
 		else if ($feed == -1)
 			$date_sort_field = "last_marked DESC";
 
-		$qfh_ret = queryFeedHeadlines( $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( $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( -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( $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( $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( $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( $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( $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( $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( $_REQUEST["login"]);
+		$login = db_escape_string($_REQUEST["login"]);
 		$fresh = $_REQUEST["fresh"] == "1";
 
-		$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) == 1) {
 			$uid = db_fetch_result($result, 0, "id");
 
-			print getGlobalUnread( $uid);
+			print getGlobalUnread($uid);
 
 			if ($fresh) {
 				print ";";
-				print getFeedArticles( -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( $_REQUEST["login"]);
+		$login = db_escape_string($_REQUEST["login"]);
 
-		$result = db_query( "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( $_REQUEST['hub_mode']);
-		$feed_id = (int) db_escape_string( $_REQUEST['id']);
-		$feed_url = db_escape_string( $_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( "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( "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( "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( $feed_id, true, true);
+					//update_rss_feed($feed_id, true, true);
 
-					db_query( "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( $_REQUEST["key"]);
+		$uuid = db_escape_string($_REQUEST["key"]);
 
-		$result = db_query( "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( $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( $_REQUEST["id"]);
-		$key = db_escape_string( $_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( $_REQUEST["limit"]);
-		$offset = (int)db_escape_string( $_REQUEST["offset"]);
+		$limit = (int)db_escape_string($_REQUEST["limit"]);
+		$offset = (int)db_escape_string($_REQUEST["offset"]);
 
-		$search = db_escape_string( $_REQUEST["q"]);
-		$search_mode = db_escape_string( $_REQUEST["smode"]);
-		$view_mode = db_escape_string( $_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( $_REQUEST['format']);
+		$format = db_escape_string($_REQUEST['format']);
 
 		if (!$format) $format = 'atom';
 
 		if (SINGLE_USER_MODE) {
-			authenticate_user( "admin", null);
+			authenticate_user("admin", null);
 		}
 
 		$owner_id = false;
 
 		if ($key) {
-			$result = db_query( "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,7 +367,7 @@ class Handler_Public extends Handler {
 	function globalUpdateFeeds() {
 		include "rssfuncs.php";
 		// Update all feeds needing a update.
-		update_daemon_common( 0, true, false);
+		update_daemon_common(0, true, false);
 
 		// Update feedbrowser
 		update_feedbrowser_cache();
@@ -375,7 +375,7 @@ class Handler_Public extends Handler {
 		// Purge orphans and cleanup tags
 		purge_orphans();
 
-		cleanup_tags( 14, 50000);
+		cleanup_tags(14, 50000);
 
 		global $pluginhost;
 		$pluginhost->run_hooks($pluginhost::HOOK_UPDATE_TASK, "hook_update_task", $op);
@@ -402,12 +402,12 @@ class Handler_Public extends Handler {
 
 			if ($action == 'share') {
 
-				$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"]));
+				$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( $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( $_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( $login, $password)) {
+			if (authenticate_user($login, $password)) {
 				$_POST["password"] = "";
 
 				$_SESSION["language"] = $_POST["language"];
-				$_SESSION["ref_schema_version"] = get_schema_version( true);
+				$_SESSION["ref_schema_version"] = get_schema_version(true);
 				$_SESSION["bw_limit"] = !!$_POST["bw_limit"];
 
 				if ($_POST["profile"]) {
 
-					$profile = db_escape_string( $_POST["profile"]);
+					$profile = db_escape_string($_POST["profile"]);
 
-					$result = db_query( "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) {
@@ -563,7 +563,7 @@ class Handler_Public extends Handler {
 
 		if ($_SESSION["uid"]) {
 
-			$feed_url = db_escape_string( 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( $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( "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");
@@ -656,16 +656,16 @@ class Handler_Public extends Handler {
 	}
 
 	function subscribe2() {
-		$feed_url = db_escape_string( trim($_REQUEST["feed_url"]));
-		$cat_id = db_escape_string( $_REQUEST["cat_id"]);
-		$from = db_escape_string( $_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( trim($_POST["auth_login"]));
-		$auth_pass = db_escape_string( 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( $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( "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( $_POST["login"]);
-			$email = db_escape_string( $_POST["email"]);
-			$test = db_escape_string( $_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( "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( $id, false);
+					Pref_Users::resetUserPassword($id, false);
 
 					print "<p>";
 
@@ -869,7 +869,7 @@ class Handler_Public extends Handler {
 
 			<?php
 				@$op = $_REQUEST["subop"];
-				$updater = new DbUpdater( DB_TYPE, SCHEMA_VERSION);
+				$updater = new DbUpdater(DB_TYPE, SCHEMA_VERSION);
 
 				if ($op == "performupdate") {
 					if ($updater->isUpdateRequired()) {

+ 1 - 1
classes/logger/sql.php

@@ -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( serialize($context));
+			//$context = db_escape_string(serialize($context));
 
 			$owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : "NULL";
 

+ 49 - 49
classes/opml.php

@@ -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( "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( "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( "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( "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( "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( "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( "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( "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)) {
@@ -197,7 +197,7 @@ class Opml extends Handler_Protected {
 					array_push($line["rules"], $tmp_line);
 				}
 
-				$tmp_result = db_query( "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( 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_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( mb_substr($attrs->getNamedItem('xmlUrl')->nodeValue, 0, 250));
-		if (!$feed_url) $feed_url = db_escape_string( 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( 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( "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( $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( $attrs->getNamedItem('label-name')->nodeValue);
+		$label_name = db_escape_string($attrs->getNamedItem('label-name')->nodeValue);
 
 		if ($label_name) {
-			$fg_color = db_escape_string( $attrs->getNamedItem('label-fg-color')->nodeValue);
-			$bg_color = db_escape_string( $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( $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( $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( $attrs->getNamedItem('pref-name')->nodeValue);
+		$pref_name = db_escape_string($attrs->getNamedItem('pref-name')->nodeValue);
 
 		if ($pref_name) {
-			$pref_value = db_escape_string( $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( $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( $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( "BEGIN");
+				db_query("BEGIN");
 
-				db_query( "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( "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( "SELECT id FROM ttrss_feeds
-								WHERE title = '".db_escape_string( $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( "SELECT id FROM ttrss_feed_categories
-								WHERE title = '".db_escape_string( $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( $rule["reg_exp"]);
+						$reg_exp = db_escape_string($rule["reg_exp"]);
 						$filter_type = (int)$rule["filter_type"];
 
-						db_query( "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( $action["action_param"]);
+						$action_param = db_escape_string($action["action_param"]);
 
-						db_query( "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( "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( 'Imported feeds', false);
+		$default_cat_id = (int) get_feed_category('Imported feeds', false);
 
 		if ($root_node) {
-			$cat_title = db_escape_string( 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( 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( $cat_title, $parent_id);
-				db_query( "BEGIN");
+				$cat_id = get_feed_category($cat_title, $parent_id);
+				db_query("BEGIN");
 				if ($cat_id === false) {
-					add_feed_category( $cat_title, $parent_id);
-					$cat_id = get_feed_category( $cat_title, $parent_id);
+					add_feed_category($cat_title, $parent_id);
+					$cat_id = get_feed_category($cat_title, $parent_id);
 				}
-				db_query( "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( $attrs->getNamedItem('text')->nodeValue);
+				$node_cat_title = db_escape_string($attrs->getNamedItem('text')->nodeValue);
 
 				if (!$node_cat_title)
-					$node_cat_title = db_escape_string( $attrs->getNamedItem('title')->nodeValue);
+					$node_cat_title = db_escape_string($attrs->getNamedItem('title')->nodeValue);
 
-				$node_feed_url = db_escape_string( $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);
@@ -508,7 +508,7 @@ class Opml extends Handler_Protected {
 
 		$url_path = get_self_url_prefix();
 		$url_path .= "/opml.php?op=publish&key=" .
-			get_feed_access_key( 'OPML:Publish', false, $_SESSION["uid"]);
+			get_feed_access_key('OPML:Publish', false, $_SESSION["uid"]);
 
 		return $url_path;
 	}

+ 9 - 9
classes/pluginhost.php

@@ -222,9 +222,9 @@ class PluginHost {
 
 	function load_data($force = false) {
 		if ($this->owner_uid && (!$_SESSION["plugin_storage"] || $force))  {
-			$plugin = db_escape_string( $plugin);
+			$plugin = db_escape_string($plugin);
 
-			$result = db_query( "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)) {
@@ -237,9 +237,9 @@ class PluginHost {
 
 	private function save_data($plugin) {
 		if ($this->owner_uid) {
-			$plugin = db_escape_string( $plugin);
+			$plugin = db_escape_string($plugin);
 
-			db_query( "BEGIN");
+			db_query("BEGIN");
 
 			$result = db_query("SELECT id FROM ttrss_plugin_storage WHERE
 				owner_uid= '".$this->owner_uid."' AND name = '$plugin'");
@@ -247,19 +247,19 @@ class PluginHost {
 			if (!isset($this->storage[$plugin]))
 				$this->storage[$plugin] = array();
 
-			$content = db_escape_string( serialize($this->storage[$plugin]));
+			$content = db_escape_string(serialize($this->storage[$plugin]));
 
 			if (db_num_rows($result) != 0) {
-				db_query( "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( "INSERT INTO ttrss_plugin_storage
+				db_query("INSERT INTO ttrss_plugin_storage
 					(name,owner_uid,content) VALUES
 					('$plugin','".$this->owner_uid."','$content')");
 			}
 
-			db_query( "COMMIT");
+			db_query("COMMIT");
 		}
 	}
 
@@ -298,7 +298,7 @@ class PluginHost {
 
 			unset($this->storage[$idx]);
 
-			db_query( "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;

+ 134 - 134
classes/pref/feeds.php

@@ -15,11 +15,11 @@ class Pref_Feeds extends Handler_Protected {
 	}
 
 	function renamecat() {
-		$title = db_escape_string( $_REQUEST['title']);
-		$id = db_escape_string( $_REQUEST['id']);
+		$title = db_escape_string($_REQUEST['title']);
+		$id = db_escape_string($_REQUEST['id']);
 
 		if ($title) {
-			db_query( "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( '_PREFS_SHOW_EMPTY_CATS'));
+				get_pref('_PREFS_SHOW_EMPTY_CATS'));
 
 		$items = array();
 
-		$result = db_query( "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( "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"].
@@ -108,7 +108,7 @@ class Pref_Feeds extends Handler_Protected {
 		$root['items'] = array();
 		$root['type'] = 'category';
 
-		$enable_cats = get_pref( '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( "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( '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( '_PREFS_SHOW_EMPTY_CATS'));
+				get_pref('_PREFS_SHOW_EMPTY_CATS'));
 
-			$result = db_query( "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( "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"].
@@ -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( "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"].
@@ -296,20 +296,20 @@ class Pref_Feeds extends Handler_Protected {
 	}
 
 	function catsortreset() {
-		db_query( "UPDATE ttrss_feed_categories
+		db_query("UPDATE ttrss_feed_categories
 				SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]);
 		return;
 	}
 
 	function feedsortreset() {
-		db_query( "UPDATE ttrss_feeds
+		db_query("UPDATE ttrss_feeds
 				SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]);
 		return;
 	}
 
 	function togglehiddenfeedcats() {
-		set_pref( '_PREFS_SHOW_EMPTY_CATS',
-			(get_pref( '_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( $parent_bare_id);
+				$parent_qpart = db_escape_string($parent_bare_id);
 			} else {
 				$parent_qpart = 'NULL';
 			}
 
-			db_query( "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( $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( "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( $bare_id);
+							$parent_qpart = db_escape_string($bare_id);
 						} else {
 							$parent_qpart = 'NULL';
 						}
 
-						db_query( "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( "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( "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( $_REQUEST["feed_id"]);
+		$feed_id = db_escape_string($_REQUEST["feed_id"]);
 
-		$result = db_query( "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( "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( $_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( "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) {
@@ -508,7 +508,7 @@ class Pref_Feeds extends Handler_Protected {
 						$favicon_color = db_escape_string(
 							calculate_avg_color(ICONS_DIR . "/$feed_id.ico"));
 
-						db_query( "UPDATE ttrss_feeds SET
+						db_query("UPDATE ttrss_feeds SET
 							favicon_avg_color = '$favicon_color'
 							WHERE id = '$feed_id'");
 
@@ -536,7 +536,7 @@ class Pref_Feeds extends Handler_Protected {
 		global $purge_intervals;
 		global $update_intervals;
 
-		$feed_id = db_escape_string( $_REQUEST["id"]);
+		$feed_id = db_escape_string($_REQUEST["id"]);
 
 		$result = db_query(
 			"SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND
@@ -585,7 +585,7 @@ class Pref_Feeds extends Handler_Protected {
 
 		/* Category */
 
-		if (get_pref( '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( "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( $_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( 'ENABLE_FEED_CATS')) {
+		if (get_pref('ENABLE_FEED_CATS')) {
 
 			print "<br/>";
 
 			print __('Place in category:') . " ";
 
-			print_feed_cat_select( "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( 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"]));
+		$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( $_POST["private"]));
+		$private = checkbox_to_sql_bool(db_escape_string($_POST["private"]));
 		$include_in_digest = checkbox_to_sql_bool(
-			db_escape_string( $_POST["include_in_digest"]));
+			db_escape_string($_POST["include_in_digest"]));
 		$cache_images = checkbox_to_sql_bool(
-			db_escape_string( $_POST["cache_images"]));
+			db_escape_string($_POST["cache_images"]));
 		$hide_images = checkbox_to_sql_bool(
-			db_escape_string( $_POST["hide_images"]));
+			db_escape_string($_POST["hide_images"]));
 		$always_display_enclosures = checkbox_to_sql_bool(
-			db_escape_string( $_POST["always_display_enclosures"]));
+			db_escape_string($_POST["always_display_enclosures"]));
 
 		$mark_unread_on_update = checkbox_to_sql_bool(
-			db_escape_string( $_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( $auth_pass);
+		$auth_pass = db_escape_string($auth_pass);
 
-		if (get_pref( '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( "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( "BEGIN");
+			db_query("BEGIN");
 
 			foreach (array_keys($feed_data) as $k) {
 
@@ -1080,16 +1080,16 @@ class Pref_Feeds extends Handler_Protected {
 				}
 			}
 
-			db_query( "COMMIT");
+			db_query("COMMIT");
 		}
 		return;
 	}
 
 	function resetPubSub() {
 
-		$ids = db_escape_string( $_REQUEST["ids"]);
+		$ids = db_escape_string($_REQUEST["ids"]);
 
-		db_query( "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( $_REQUEST["ids"]));
+		$ids = explode(",", db_escape_string($_REQUEST["ids"]));
 
 		foreach ($ids as $id) {
-			Pref_Feeds::remove_feed( $id, $_SESSION["uid"]);
+			Pref_Feeds::remove_feed($id, $_SESSION["uid"]);
 		}
 
 		return;
 	}
 
 	function clear() {
-		$id = db_escape_string( $_REQUEST["id"]);
-		$this->clear_feed_articles( $id);
+		$id = db_escape_string($_REQUEST["id"]);
+		$this->clear_feed_articles($id);
 	}
 
 	function rescore() {
 		require_once "rssfuncs.php";
 
-		$ids = explode(",", db_escape_string( $_REQUEST["ids"]));
+		$ids = explode(",", db_escape_string($_REQUEST["ids"]));
 
 		foreach ($ids as $id) {
 
-			$filters = load_filters( $id, $_SESSION["uid"], 6);
+			$filters = load_filters($id, $_SESSION["uid"], 6);
 
-			$result = db_query( "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( $line["ref_id"]);
+				$tags = get_article_tags($line["ref_id"]);