From 187abfe732fe62cf4b30847665dab30903d00d99 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 3 Dec 2017 09:35:59 +0300 Subject: [PATCH] main classes: remove sql_bool_to_bool() kludge --- classes/article.php | 8 +++++--- classes/feeds.php | 12 ++++++------ classes/handler/public.php | 7 ++----- classes/opml.php | 9 +-------- classes/pref/feeds.php | 14 +++++++------- classes/pref/prefs.php | 4 ++-- classes/rssutils.php | 14 +++++++------- 7 files changed, 30 insertions(+), 38 deletions(-) diff --git a/classes/article.php b/classes/article.php index 869e746c..0352e1b9 100644 --- a/classes/article.php +++ b/classes/article.php @@ -8,6 +8,8 @@ class Article extends Handler_Protected { } function redirect() { + $id = $_REQUEST['id']; + $sth = $this->pdo->prepare("SELECT link FROM ttrss_entries, ttrss_user_entries WHERE id = ? AND id = ref_id AND owner_uid = ? LIMIT 1"); @@ -601,7 +603,7 @@ class Article extends Handler_Protected { unset($line["tag_cache"]); $line["content"] = sanitize($line["content"], - sql_bool_to_bool($line['hide_images']), + $line['hide_images'], $owner_uid, $line["site_url"], false, $line["id"]); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE) as $p) { @@ -754,9 +756,9 @@ class Article extends Handler_Protected { if (!$zoom_mode) { $rv['content'] .= Article::format_article_enclosures($id, - sql_bool_to_bool($line["always_display_enclosures"]), + $line["always_display_enclosures"], $line["content"], - sql_bool_to_bool($line["hide_images"])); + $line["hide_images"]); } $rv['content'] .= ""; diff --git a/classes/feeds.php b/classes/feeds.php index f2244ae8..ffb2fc5c 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -199,7 +199,7 @@ class Feeds extends Handler_Protected { if ($row = $sth->fetch()) { $last_updated = strtotime($row["last_updated"]); - $cache_images = sql_bool_to_bool($row["cache_images"]); + $cache_images = $row["cache_images"]; if (!$cache_images && time() - $last_updated > 120) { RSSUtils::update_rss_feed($feed, true); @@ -360,12 +360,12 @@ class Feeds extends Handler_Protected { $class = ""; - if (sql_bool_to_bool($line["unread"])) { + if ($line["unread"]) { $class .= " Unread"; ++$num_unread; } - if (sql_bool_to_bool($line["marked"])) { + if ($line["marked"]) { $marked_pic = "\"Unstar"; } - if (sql_bool_to_bool($line["published"])) { + if ($line["published"]) { $published_pic = "\"Unpublish"; @@ -528,7 +528,7 @@ class Feeds extends Handler_Protected { $tags = false; $line["content"] = sanitize($line["content"], - sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]); + $line['hide_images'], false, $entry_site_url, $highlight_words, $line["id"]); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) { $line = $p->hook_render_article_cdm($line); @@ -690,7 +690,7 @@ class Feeds extends Handler_Protected { $tmp_content .= "
"; - $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]); + $always_display_enclosures = $line["always_display_enclosures"]; $tmp_content .= Article::format_article_enclosures($id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"])); $tmp_content .= "
"; // cdmIntermediate diff --git a/classes/handler/public.php b/classes/handler/public.php index f36ee8b1..8b513df6 100644 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -15,14 +15,11 @@ class Handler_Public extends Handler { if (!$limit) $limit = 60; $date_sort_field = "date_entered DESC, updated DESC"; - $date_check_field = "date_entered"; if ($feed == -2 && !$is_cat) { $date_sort_field = "last_published DESC"; - $date_check_field = "last_published"; } else if ($feed == -1 && !$is_cat) { $date_sort_field = "last_marked DESC"; - $date_check_field = "last_marked"; } switch ($order) { @@ -295,7 +292,7 @@ class Handler_Public extends Handler { function rss() { $feed = $_REQUEST["id"]; $key = $_REQUEST["key"]; - $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]); + $is_cat = $_REQUEST["is_cat"]; $limit = (int)$_REQUEST["limit"]; $offset = (int)$_REQUEST["offset"]; @@ -305,7 +302,7 @@ class Handler_Public extends Handler { $start_ts = $_REQUEST["ts"]; $format = $_REQUEST['format']; - $orig_guid = sql_bool_to_bool($_REQUEST["orig_guid"]); + $orig_guid = $_REQUEST["orig_guid"]; if (!$format) $format = 'atom'; diff --git a/classes/opml.php b/classes/opml.php index 5f70558b..98ea21a5 100644 --- a/classes/opml.php +++ b/classes/opml.php @@ -173,10 +173,6 @@ class Opml extends Handler_Protected { $sth->execute([$owner_uid]); while ($line = $sth->fetch()) { - foreach (array('enabled', 'match_any_rule', 'inverse') as $b) { - $line[$b] = sql_bool_to_bool($line[$b]); - } - $line["rules"] = array(); $line["actions"] = array(); @@ -188,7 +184,7 @@ class Opml extends Handler_Protected { unset($tmp_line["id"]); unset($tmp_line["filter_id"]); - $cat_filter = sql_bool_to_bool($tmp_line["cat_filter"]); + $cat_filter = $tmp_line["cat_filter"]; if (!$tmp_line["match_on"]) { if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) { @@ -222,9 +218,6 @@ class Opml extends Handler_Protected { unset($tmp_line["match_on"]); } - $tmp_line["cat_filter"] = sql_bool_to_bool($tmp_line["cat_filter"]); - $tmp_line["inverse"] = sql_bool_to_bool($tmp_line["inverse"]); - unset($tmp_line["feed_id"]); unset($tmp_line["cat_id"]); diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index fcd2aeda..9f7ada24 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -510,7 +510,7 @@ class Pref_Feeds extends Handler_Protected { print '
'; - $auth_pass_encrypted = sql_bool_to_bool($row["auth_pass_encrypted"]); + $auth_pass_encrypted = $row["auth_pass_encrypted"]; $title = htmlspecialchars($row["title"]); @@ -644,7 +644,7 @@ class Pref_Feeds extends Handler_Protected { //print "
".__("Options")."
"; print "
"; - $private = sql_bool_to_bool($row["private"]); + $private = $row["private"]; if ($private) { $checked = "checked=\"1\""; @@ -655,7 +655,7 @@ class Pref_Feeds extends Handler_Protected { print " "; - $include_in_digest = sql_bool_to_bool($row["include_in_digest"]); + $include_in_digest = $row["include_in_digest"]; if ($include_in_digest) { $checked = "checked=\"1\""; @@ -668,7 +668,7 @@ class Pref_Feeds extends Handler_Protected { $checked> "; - $always_display_enclosures = sql_bool_to_bool($row["always_display_enclosures"]); + $always_display_enclosures = $row["always_display_enclosures"]; if ($always_display_enclosures) { $checked = "checked"; @@ -680,7 +680,7 @@ class Pref_Feeds extends Handler_Protected { name=\"always_display_enclosures\" $checked> "; - $hide_images = sql_bool_to_bool($row["hide_images"]); + $hide_images = $row["hide_images"]; if ($hide_images) { $checked = "checked=\"1\""; @@ -693,7 +693,7 @@ class Pref_Feeds extends Handler_Protected { $checked> "; - $cache_images = sql_bool_to_bool($row["cache_images"]); + $cache_images = $row["cache_images"]; if ($cache_images) { $checked = "checked=\"1\""; @@ -706,7 +706,7 @@ class Pref_Feeds extends Handler_Protected { $checked> "; - $mark_unread_on_update = sql_bool_to_bool($row["mark_unread_on_update"]); + $mark_unread_on_update = $row["mark_unread_on_update"]; if ($mark_unread_on_update) { $checked = "checked"; diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index ab39b1e2..ff778cbc 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -207,7 +207,7 @@ class Pref_Prefs extends Handler_Protected { $email = htmlspecialchars($row["email"]); $full_name = htmlspecialchars($row["full_name"]); - $otp_enabled = sql_bool_to_bool($row["otp_enabled"]); + $otp_enabled = $row["otp_enabled"]; print "".__('Full name').""; print "encode(sha1($row["salt"])); diff --git a/classes/rssutils.php b/classes/rssutils.php index a511a74c..696b8604 100644 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -221,7 +221,7 @@ class RSSUtils { $owner_uid = $row["owner_uid"]; - $auth_pass_encrypted = sql_bool_to_bool($row["auth_pass_encrypted"]); + $auth_pass_encrypted = $row["auth_pass_encrypted"]; $auth_login = $row["auth_login"]; $auth_pass = $row["auth_pass"]; @@ -341,8 +341,8 @@ class RSSUtils { if ($row = $sth->fetch()) { $owner_uid = $row["owner_uid"]; - $mark_unread_on_update = sql_bool_to_bool($row["mark_unread_on_update"]); - $auth_pass_encrypted = sql_bool_to_bool($row["auth_pass_encrypted"]); + $mark_unread_on_update = $row["mark_unread_on_update"]; + $auth_pass_encrypted = $row["auth_pass_encrypted"]; $sth = $pdo->prepare("UPDATE ttrss_feeds SET last_update_started = NOW() WHERE id = ?"); @@ -358,7 +358,7 @@ class RSSUtils { $stored_last_modified = $row["last_modified"]; $last_unconditional = $row["last_unconditional"]; - $cache_images = sql_bool_to_bool($row["cache_images"]); + $cache_images = $row["cache_images"]; $fetch_url = $row["feed_url"]; $feed_language = mb_strtolower($row["feed_language"]); if (!$feed_language) $feed_language = 'english'; @@ -515,7 +515,7 @@ class RSSUtils { $sth->execute([$feed]); if ($row = $sth->fetch()) { - $favicon_needs_check = sql_bool_to_bool($row["favicon_needs_check"]); + $favicon_needs_check = $row["favicon_needs_check"]; $favicon_avg_color = $row["favicon_avg_color"]; $owner_uid = $row["owner_uid"]; } else { @@ -883,7 +883,7 @@ class RSSUtils { $entry_current_hash, $date_feed_processed, $entry_comments, - $num_comments, + (int)$num_comments, $entry_plugin_data, $entry_language, $entry_author]); @@ -995,7 +995,7 @@ class RSSUtils { WHERE id = ?"); $sth->execute([$entry_title, $entry_content, $entry_current_hash, $entry_timestamp_fmt, - $num_comments, $entry_plugin_data, $entry_author, $entry_language, $ref_id]); + (int)$num_comments, $entry_plugin_data, $entry_author, $entry_language, $ref_id]); // update aux data $sth = $pdo->prepare("UPDATE ttrss_user_entries -- 2.39.2