From 3ab417c2775b95e5ad4896b0a2c54ef19550f4c4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 12 Apr 2013 15:02:44 +0400 Subject: remove label gradients --- classes/feeds.php | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'classes/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index 6427559e1..c3b5225a1 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -9,18 +9,6 @@ class Feeds extends Handler_Protected { return array_search($method, $csrf_ignored) !== false; } - private function make_gradient($end, $class) { - $start = $class == "even" ? "#f0f0f0" : "#ffffff"; - - return "style='background: linear-gradient(left , $start 6%, $end 100%); - background: -o-linear-gradient(left , $start 6%, $end 100%); - background: -moz-linear-gradient(left , $start 6%, $end 100%); - background: -webkit-linear-gradient(left , $start 6%, $end 100%); - background: -ms-linear-gradient(left , $start 6%, $end 100%); - background: -webkit-gradient(linear, left top, right top, - color-stop(0.06, $start), color-stop(1, $end));'"; - } - private function format_headline_subtoolbar($feed_site_url, $feed_title, $feed_id, $is_cat, $search, $search_mode, $view_mode, $error) { @@ -304,7 +292,6 @@ class Feeds extends Handler_Protected { $feed_id = $line["feed_id"]; $label_cache = $line["label_cache"]; $labels = false; - $label_row_style = ""; if ($label_cache) { $label_cache = json_decode($label_cache, true); @@ -319,22 +306,6 @@ class Feeds extends Handler_Protected { if (!is_array($labels)) $labels = get_article_labels($this->link, $id); - if (count($labels) > 0) { - for ($i = 0; $i < min(4, count($labels)); $i++) { - $bg = rgb2hsl(_color_unpack($labels[$i][3])); - - if ($bg && $bg[1] > 0) { - $bg[1] = 0.1; - $bg[2] = 1; - - $bg = _color_pack(hsl2rgb($bg)); - $label_row_style = $this->make_gradient($bg, $class);; - - break; - } - } - } - $labels_str = ""; $labels_str .= format_article_labels($labels, $id); $labels_str .= ""; @@ -450,7 +421,7 @@ class Feeds extends Handler_Protected { $mouseover_attrs = "onmouseover='postMouseIn(event, $id)' onmouseout='postMouseOut($id)'"; - $reply['content'] .= "
"; + $reply['content'] .= "
"; $reply['content'] .= "
"; -- cgit v1.2.3-54-g00ecf From 884f2aee91b18080938f862a980c3a9b2b95484f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Apr 2013 12:57:52 +0400 Subject: use mdash as a separator between title and author --- classes/feeds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index c3b5225a1..2f8dcb5ec 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -385,7 +385,7 @@ class Feeds extends Handler_Protected { $entry_author = $line["author"]; if ($entry_author) { - $entry_author = " - $entry_author"; + $entry_author = " — $entry_author"; } $has_feed_icon = feed_has_icon($feed_id); -- cgit v1.2.3-54-g00ecf From e43a9c4a01bf095b740e35711c79f6a0ca3374ba Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Apr 2013 13:16:14 +0400 Subject: add a %d articles selected element --- classes/feeds.php | 1 + js/functions.js | 6 ++++++ js/viewfeed.js | 24 ++++++++++++++++++++++++ tt-rss.css | 3 +++ 4 files changed, 34 insertions(+) (limited to 'classes/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index 2f8dcb5ec..c7b7a83e6 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -49,6 +49,7 @@ class Feeds extends Handler_Protected { // right part $reply .= ""; + $reply .= ""; $reply .= ""; if ($feed_site_url) { diff --git a/js/functions.js b/js/functions.js index 07eed2ad9..9336433ca 100644 --- a/js/functions.js +++ b/js/functions.js @@ -368,6 +368,9 @@ function toggleSelectRow2(sender, row, is_cdm) { row.addClassName('Selected'); else row.removeClassName('Selected'); + + if (typeof updateSelectedPrompt != undefined) + updateSelectedPrompt(); } @@ -379,6 +382,9 @@ function toggleSelectRow(sender, row) { row.addClassName('Selected'); else row.removeClassName('Selected'); + + if (typeof updateSelectedPrompt != undefined) + updateSelectedPrompt(); } function checkboxToggleElement(elem, id) { diff --git a/js/viewfeed.js b/js/viewfeed.js index da5ded64f..519ab3449 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -639,11 +639,33 @@ function toggleSelected(id, force_on) { if (cb) cb.attr("checked", true); } } + + updateSelectedPrompt(); } catch (e) { exception_error("toggleSelected", e); } } +function updateSelectedPrompt() { + try { + var count = getSelectedArticleIds2().size(); + var elem = $("selected_prompt"); + + if (elem) { + elem.innerHTML = ngettext("%d article selected", + "%d articles selected", count).replace("%d", count); + + if (count > 0) + Element.show(elem); + else + Element.hide(elem); + } + + } catch (e) { + exception_error("updateSelectedPrompt", e); + } +} + function toggleUnread_afh(effect) { try { @@ -960,6 +982,8 @@ function selectArticles(mode) { } }); + updateSelectedPrompt(); + } catch (e) { exception_error("selectArticles", e); } diff --git a/tt-rss.css b/tt-rss.css index 6067ca7d6..d2e854d8f 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -1019,3 +1019,6 @@ div.hl.active a.title { color : #4684ff; } +#selected_prompt { + margin-right : 25px; +} -- cgit v1.2.3-54-g00ecf From 2cfbb448fb197837c063c377c042beb3ba704a52 Mon Sep 17 00:00:00 2001 From: moontear Date: Mon, 15 Apr 2013 12:28:52 +0200 Subject: Added average color calculation of feeds' favicons for banded display. --- classes/feeds.php | 5 +- include/functions.php | 42 +++ include/rssfuncs.php | 11 +- lib/floIcon.php | 843 ++++++++++++++++++++++++++++++++++++++++++ schema/versions/mysql/117.sql | 7 + 5 files changed, 903 insertions(+), 5 deletions(-) create mode 100644 lib/floIcon.php create mode 100644 schema/versions/mysql/117.sql (limited to 'classes/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index c7b7a83e6..64d1d8786 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -528,8 +528,9 @@ class Feeds extends Handler_Protected { $reply['content'] .= "
"; - $reply['content'] .= "
"; - + //setting feed headline background color, needs to change text color based on dark/light + $favColor = explode("|", $line['favicon_avg_color']); + $reply['content'] .= "
"; $reply['content'] .= "
"; $reply['content'] .= "readICO($iconFile); + //TODO: error logging + if(count($ico->images)==0) + return null; + else { + $image = @$ico->images[count($ico->images)-1]->getImageResource(); + } + $type = "ico"; + } + elseif(strtolower($imgInfo['mime'])=='image/png') { + $image = imagecreatefrompng($iconFile); + $type = 'png'; + } + elseif(strtolower($imgInfo['mime'])=='image/jpeg') { + $image = imagecreatefromjpeg($iconFile); + $type = 'jpg'; + } + elseif(strtolower($imgInfo['mime'])=='image/gif') { + $image = imagecreatefromgif($iconFile); + $type = 'gif'; + } + //TODO: error logging + if (is_null($image)) + return null; + $width = imagesx($image); + $height = imagesy($image); + $pixel = imagecreatetruecolor(1, 1); + imagecopyresampled($pixel, $image, 0, 0, 0, 0, 1, 1, $width, $height); + $rgb = imagecolorat($pixel, 0, 0); + $color = imagecolorsforindex($pixel, $rgb); + return $color; + } function print_select($id, $default, $values, $attributes = "") { print " Date: Mon, 15 Apr 2013 15:27:35 +0400 Subject: implement basic moz gradient for feedicon color --- classes/feeds.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'classes/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index 22c3497d4..07cc427a9 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -150,6 +150,8 @@ class Feeds extends Handler_Protected { $reply = array(); + $rgba_cache = array(); + $timing_info = microtime(true); $topmost_article_ids = array(); @@ -530,7 +532,22 @@ class Feeds extends Handler_Protected { //setting feed headline background color, needs to change text color based on dark/light $fav_color = $line['favicon_avg_color']; - $reply['content'] .= "
"; + + require_once "colors.php"; + + if ($fav_color) { + if (!isset($rgba_cache[$feed_id])) + $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)); + + $rgba = $rgba_cache[$feed_id]; + + $row_background = "background-image : -moz-linear-gradient(left, rgba(255, 255, 255, 0) 50%, rgba($rgba, 0.2) 95%"; + + } else { + $row_background = ""; + } + + $reply['content'] .= "
"; $reply['content'] .= "
"; $reply['content'] .= " Date: Mon, 15 Apr 2013 15:34:47 +0400 Subject: use w3c gradient definition --- classes/feeds.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'classes/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index 07cc427a9..10877bad5 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -541,7 +541,13 @@ class Feeds extends Handler_Protected { $rgba = $rgba_cache[$feed_id]; - $row_background = "background-image : -moz-linear-gradient(left, rgba(255, 255, 255, 0) 50%, rgba($rgba, 0.2) 95%"; + // W3C definition seems to work in FF and Chrome + $row_background = "background-image : linear-gradient(to right, rgba(255, 255, 255, 0) 50%, rgba($rgba, 0.2) 100%);"; + + /* $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)), + color-stop(100%, rgba($rgba, 0.2)));"; */ } else { $row_background = ""; -- cgit v1.2.3-54-g00ecf From bfaf90e364e883790af2b354cfbb9db250a5a516 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Apr 2013 15:38:05 +0400 Subject: add row backgrounds in normal mode --- classes/feeds.php | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'classes/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index 10877bad5..79edca5d9 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -401,6 +401,28 @@ class Feeds extends Handler_Protected { $entry_site_url = $line["site_url"]; + //setting feed headline background color, needs to change text color based on dark/light + $fav_color = $line['favicon_avg_color']; + + require_once "colors.php"; + + if ($fav_color) { + if (!isset($rgba_cache[$feed_id])) + $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)); + + $rgba = $rgba_cache[$feed_id]; + + // W3C definition seems to work in FF and Chrome + $row_background = "background-image : linear-gradient(to right, rgba(255, 255, 255, 0) 50%, rgba($rgba, 0.2) 100%);"; + + /* $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)), + color-stop(100%, rgba($rgba, 0.2)));"; */ + } else { + $row_background = ""; + } + if (!get_pref($this->link, 'COMBINED_DISPLAY_MODE')) { if (get_pref($this->link, 'VFEED_GROUP_BY_FEED')) { @@ -424,7 +446,7 @@ class Feeds extends Handler_Protected { $mouseover_attrs = "onmouseover='postMouseIn(event, $id)' onmouseout='postMouseOut($id)'"; - $reply['content'] .= "
"; + $reply['content'] .= "
"; $reply['content'] .= "
"; @@ -530,29 +552,6 @@ class Feeds extends Handler_Protected { $reply['content'] .= "
"; - //setting feed headline background color, needs to change text color based on dark/light - $fav_color = $line['favicon_avg_color']; - - require_once "colors.php"; - - if ($fav_color) { - if (!isset($rgba_cache[$feed_id])) - $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)); - - $rgba = $rgba_cache[$feed_id]; - - // W3C definition seems to work in FF and Chrome - $row_background = "background-image : linear-gradient(to right, rgba(255, 255, 255, 0) 50%, rgba($rgba, 0.2) 100%);"; - - /* $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)), - color-stop(100%, rgba($rgba, 0.2)));"; */ - - } else { - $row_background = ""; - } - $reply['content'] .= "
"; $reply['content'] .= "
"; -- cgit v1.2.3-54-g00ecf From e7480cc13b55162510001b5b9d91af289606a9f1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Apr 2013 15:56:08 +0400 Subject: do not color predominantly white/black rows --- classes/feeds.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'classes/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index 79edca5d9..81729aacc 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -407,13 +407,22 @@ class Feeds extends Handler_Protected { require_once "colors.php"; if ($fav_color) { - if (!isset($rgba_cache[$feed_id])) - $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)); + if (!isset($rgba_cache[$feed_id])) { + $hsl = rgb2hsl(_color_unpack($fav_color)); + + if ($hsl[1] < 0.1) + $hsl[2] = 1; + else if ($hsl[2] < 0.25) + $hsl[2] = 0.25; + + $rgba_cache[$feed_id] = join(",", hsl2rgb($hsl)); + + } $rgba = $rgba_cache[$feed_id]; // W3C definition seems to work in FF and Chrome - $row_background = "background-image : linear-gradient(to right, rgba(255, 255, 255, 0) 50%, rgba($rgba, 0.2) 100%);"; + $row_background = "background-image : linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba($rgba, 0.3) 100%);"; /* $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%);"; -- cgit v1.2.3-54-g00ecf From 12a6bd28ace16ff20f1f920831cffe1041b36d5c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Apr 2013 17:07:06 +0400 Subject: remove hsl stuff from classes/feeds, we take care of this when choosing the color --- classes/feeds.php | 10 +--------- include/rssfuncs.php | 2 ++ 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'classes/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index 81729aacc..6d15c99e8 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -408,15 +408,7 @@ class Feeds extends Handler_Protected { if ($fav_color) { if (!isset($rgba_cache[$feed_id])) { - $hsl = rgb2hsl(_color_unpack($fav_color)); - - if ($hsl[1] < 0.1) - $hsl[2] = 1; - else if ($hsl[2] < 0.25) - $hsl[2] = 0.25; - - $rgba_cache[$feed_id] = join(",", hsl2rgb($hsl)); - + $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)); } $rgba = $rgba_cache[$feed_id]; diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 0d55dce36..250534bd7 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -417,6 +417,8 @@ $favicon_color = db_escape_string($link, calculate_avg_color($favicon_file)); + if ($debug_enabled) _debug("color: $favicon_color"); + $favicon_colorstring = ",favicon_avg_color = '".$favicon_color."'"; } -- cgit v1.2.3-54-g00ecf From 86f7d2a9f2b6468a34b20d7a26c7cfc3afbe00ee Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Apr 2013 18:09:48 +0400 Subject: make gradient less visible on read headlines --- classes/feeds.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'classes/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index 6d15c99e8..6ee5bad0b 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -413,8 +413,13 @@ class Feeds extends Handler_Protected { $rgba = $rgba_cache[$feed_id]; + if (sql_bool_to_bool($line["unread"])) + $endalpha = '0.3'; + else + $endalpha = '0.1'; + // W3C definition seems to work in FF and Chrome - $row_background = "background-image : linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba($rgba, 0.3) 100%);"; + $row_background = "background-image : linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba($rgba, $endalpha) 100%);"; /* $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%);"; -- cgit v1.2.3-54-g00ecf From 6322ac79a020ab584d412d782d62b2ee77d7c6cf Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Apr 2013 16:23:15 +0400 Subject: remove $link --- backend.php | 14 +- classes/api.php | 180 ++++++------ classes/article.php | 104 +++---- classes/auth/base.php | 14 +- classes/backend.php | 6 +- classes/db.php | 2 +- classes/db/pgsql.php | 4 +- classes/dbupdater.php | 16 +- classes/dlg.php | 20 +- classes/feeds.php | 134 ++++----- classes/handler.php | 6 +- classes/handler/public.php | 140 ++++----- classes/logger/sql.php | 2 +- classes/opml.php | 102 +++---- classes/plugin.php | 4 +- classes/pluginhost.php | 31 +- classes/pref/feeds.php | 290 +++++++++---------- classes/pref/filters.php | 132 ++++----- classes/pref/labels.php | 66 ++--- classes/pref/prefs.php | 56 ++-- classes/pref/system.php | 8 +- classes/pref/users.php | 54 ++-- classes/rpc.php | 224 +++++++-------- include/ccache.php | 78 ++--- include/db-prefs.php | 26 +- include/db.php | 10 +- include/digest.php | 26 +- include/feedbrowser.php | 8 +- include/functions.php | 550 ++++++++++++++++++------------------ include/labels.php | 82 +++--- include/rssfuncs.php | 212 +++++++------- include/sanity_check.php | 14 +- include/sessions.php | 2 +- index.php | 10 +- opml.php | 10 +- plugins/af_buttersafe/init.php | 2 - plugins/af_explosm/init.php | 2 - plugins/af_gocomics/init.php | 3 - plugins/af_pennyarcade/init.php | 18 +- plugins/af_redditimgur/init.php | 3 - plugins/af_unburn/init.php | 3 - plugins/auth_internal/init.php | 31 +- plugins/auth_remote/init.php | 22 +- plugins/bookmarklets/init.php | 2 - plugins/close_button/init.php | 4 +- plugins/digest/digest_body.php | 4 +- plugins/digest/init.php | 30 +- plugins/embed_original/init.php | 6 +- plugins/example/init.php | 5 +- plugins/example_api/init.php | 2 - plugins/example_article/init.php | 2 - plugins/example_feed/init.php | 2 - plugins/example_routing/init.php | 2 - plugins/example_vfeed/init.php | 4 +- plugins/googlereaderimport/init.php | 72 +++-- plugins/googlereaderkeys/init.php | 3 - plugins/import_export/init.php | 47 ++- plugins/instances/init.php | 71 +++-- plugins/mail/init.php | 12 +- plugins/mailto/init.php | 7 +- plugins/mark_button/init.php | 4 +- plugins/mobile/article.php | 12 +- plugins/mobile/backend.php | 24 +- plugins/mobile/cat.php | 6 +- plugins/mobile/feed.php | 14 +- plugins/mobile/home.php | 8 +- plugins/mobile/index.php | 8 +- plugins/mobile/init.php | 3 - plugins/mobile/mobile-functions.php | 90 +++--- plugins/mobile/prefs.php | 14 +- plugins/note/init.php | 12 +- plugins/nsfw/init.php | 5 +- plugins/share/init.php | 16 +- plugins/swap_jk/init.php | 2 - plugins/updater/init.php | 14 +- prefs.php | 10 +- public.php | 6 +- register.php | 28 +- update.php | 49 ++-- update_daemon2.php | 30 +- 80 files changed, 1624 insertions(+), 1727 deletions(-) (limited to 'classes/feeds.php') diff --git a/backend.php b/backend.php index b583d379e..b06cca2d2 100644 --- a/backend.php +++ b/backend.php @@ -50,7 +50,7 @@ $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - if (!init_plugins($link)) return; + if (!init_plugins()) return; header("Content-Type: text/json; charset=utf-8"); @@ -59,16 +59,16 @@ } if (SINGLE_USER_MODE) { - authenticate_user($link, "admin", null); + authenticate_user( "admin", null); } if ($_SESSION["uid"]) { - if (!validate_session($link)) { + if (!validate_session()) { header("Content-Type: text/json"); print json_encode(array("error" => array("code" => 6))); return; } - load_user_plugins($link, $_SESSION["uid"]); + load_user_plugins( $_SESSION["uid"]); } $purge_intervals = array( @@ -106,7 +106,7 @@ 5 => __("Power User"), 10 => __("Administrator")); - #$error = sanity_check($link); + #$error = sanity_check(); #if ($error['code'] != 0 && $op != "logout") { # print json_encode(array("error" => $error)); @@ -123,7 +123,7 @@ if ($override) { $handler = $override; } else { - $handler = new $op($link, $_REQUEST); + $handler = new $op(Db::get(), $_REQUEST); } if ($handler && implements_interface($handler, 'IHandler')) { @@ -155,5 +155,5 @@ print json_encode(array("error" => array("code" => 7))); // We close the connection to database. - db_close($link); + db_close(); ?> diff --git a/classes/api.php b/classes/api.php index 958256be4..10e511919 100644 --- a/classes/api.php +++ b/classes/api.php @@ -18,7 +18,7 @@ class API extends Handler { return false; } - if ($_SESSION["uid"] && $method != "logout" && !get_pref($this->link, 'ENABLE_API_ACCESS')) { + if ($_SESSION["uid"] && $method != "logout" && !get_pref( 'ENABLE_API_ACCESS')) { print $this->wrap(self::STATUS_ERR, array("error" => 'API_DISABLED')); return false; } @@ -50,13 +50,13 @@ class API extends Handler { @session_destroy(); @session_start(); - $login = db_escape_string($this->link, $_REQUEST["user"]); + $login = db_escape_string( $_REQUEST["user"]); $password = $_REQUEST["password"]; $password_base64 = base64_decode($_REQUEST["password"]); if (SINGLE_USER_MODE) $login = "admin"; - $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE login = '$login'"); + $result = db_query( "SELECT id FROM ttrss_users WHERE login = '$login'"); if (db_num_rows($result) != 0) { $uid = db_fetch_result($result, 0, "id"); @@ -69,11 +69,11 @@ class API extends Handler { return; } - if (get_pref($this->link, "ENABLE_API_ACCESS", $uid)) { - if (authenticate_user($this->link, $login, $password)) { // try login with normal password + if (get_pref( "ENABLE_API_ACCESS", $uid)) { + if (authenticate_user( $login, $password)) { // try login with normal password print $this->wrap(self::STATUS_OK, array("session_id" => session_id(), "api_level" => self::API_LEVEL)); - } else if (authenticate_user($this->link, $login, $password_base64)) { // else try with base64_decoded password + } else if (authenticate_user( $login, $password_base64)) { // else try with base64_decoded password print $this->wrap(self::STATUS_OK, array("session_id" => session_id(), "api_level" => self::API_LEVEL)); } else { // else we are not logged in @@ -95,29 +95,29 @@ class API extends Handler { } function getUnread() { - $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]); - $is_cat = db_escape_string($this->link, $_REQUEST["is_cat"]); + $feed_id = db_escape_string( $_REQUEST["feed_id"]); + $is_cat = db_escape_string( $_REQUEST["is_cat"]); if ($feed_id) { - print $this->wrap(self::STATUS_OK, array("unread" => getFeedUnread($this->link, $feed_id, $is_cat))); + print $this->wrap(self::STATUS_OK, array("unread" => getFeedUnread( $feed_id, $is_cat))); } else { - print $this->wrap(self::STATUS_OK, array("unread" => getGlobalUnread($this->link))); + print $this->wrap(self::STATUS_OK, array("unread" => getGlobalUnread())); } } /* Method added for ttrss-reader for Android */ function getCounters() { - print $this->wrap(self::STATUS_OK, getAllCounters($this->link)); + print $this->wrap(self::STATUS_OK, getAllCounters()); } function getFeeds() { - $cat_id = db_escape_string($this->link, $_REQUEST["cat_id"]); + $cat_id = db_escape_string( $_REQUEST["cat_id"]); $unread_only = sql_bool_to_bool($_REQUEST["unread_only"]); - $limit = (int) db_escape_string($this->link, $_REQUEST["limit"]); - $offset = (int) db_escape_string($this->link, $_REQUEST["offset"]); + $limit = (int) db_escape_string( $_REQUEST["limit"]); + $offset = (int) db_escape_string( $_REQUEST["offset"]); $include_nested = sql_bool_to_bool($_REQUEST["include_nested"]); - $feeds = $this->api_get_feeds($this->link, $cat_id, $unread_only, $limit, $offset, $include_nested); + $feeds = $this->api_get_feeds( $cat_id, $unread_only, $limit, $offset, $include_nested); print $this->wrap(self::STATUS_OK, $feeds); } @@ -134,7 +134,7 @@ class API extends Handler { else $nested_qpart = "true"; - $result = db_query($this->link, "SELECT + $result = db_query( "SELECT id, title, order_id, (SELECT COUNT(id) FROM ttrss_feeds WHERE ttrss_feed_categories.id IS NOT NULL AND cat_id = ttrss_feed_categories.id) AS num_feeds, @@ -149,10 +149,10 @@ class API extends Handler { while ($line = db_fetch_assoc($result)) { if ($include_empty || $line["num_feeds"] > 0 || $line["num_cats"] > 0) { - $unread = getFeedUnread($this->link, $line["id"], true); + $unread = getFeedUnread( $line["id"], true); if ($enable_nested) - $unread += getCategoryChildrenUnread($this->link, $line["id"]); + $unread += getCategoryChildrenUnread( $line["id"]); if ($unread || !$unread_only) { array_push($cats, array("id" => $line["id"], @@ -166,11 +166,11 @@ class API extends Handler { foreach (array(-2,-1,0) as $cat_id) { if ($include_empty || !$this->isCategoryEmpty($cat_id)) { - $unread = getFeedUnread($this->link, $cat_id, true); + $unread = getFeedUnread( $cat_id, true); if ($unread || !$unread_only) { array_push($cats, array("id" => $cat_id, - "title" => getCategoryTitle($this->link, $cat_id), + "title" => getCategoryTitle( $cat_id), "unread" => $unread)); } } @@ -180,22 +180,22 @@ class API extends Handler { } function getHeadlines() { - $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]); + $feed_id = db_escape_string( $_REQUEST["feed_id"]); if ($feed_id != "") { - $limit = (int)db_escape_string($this->link, $_REQUEST["limit"]); + $limit = (int)db_escape_string( $_REQUEST["limit"]); if (!$limit || $limit >= 60) $limit = 60; - $offset = (int)db_escape_string($this->link, $_REQUEST["skip"]); - $filter = db_escape_string($this->link, $_REQUEST["filter"]); + $offset = (int)db_escape_string( $_REQUEST["skip"]); + $filter = db_escape_string( $_REQUEST["filter"]); $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]); $show_excerpt = sql_bool_to_bool($_REQUEST["show_excerpt"]); $show_content = sql_bool_to_bool($_REQUEST["show_content"]); /* all_articles, unread, adaptive, marked, updated */ - $view_mode = db_escape_string($this->link, $_REQUEST["view_mode"]); + $view_mode = db_escape_string( $_REQUEST["view_mode"]); $include_attachments = sql_bool_to_bool($_REQUEST["include_attachments"]); - $since_id = (int)db_escape_string($this->link, $_REQUEST["since_id"]); + $since_id = (int)db_escape_string( $_REQUEST["since_id"]); $include_nested = sql_bool_to_bool($_REQUEST["include_nested"]); $sanitize_content = true; @@ -211,10 +211,10 @@ class API extends Handler { /* do not rely on params below */ - $search = db_escape_string($this->link, $_REQUEST["search"]); - $search_mode = db_escape_string($this->link, $_REQUEST["search_mode"]); + $search = db_escape_string( $_REQUEST["search"]); + $search_mode = db_escape_string( $_REQUEST["search_mode"]); - $headlines = $this->api_get_headlines($this->link, $feed_id, $limit, $offset, + $headlines = $this->api_get_headlines( $feed_id, $limit, $offset, $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order, $include_attachments, $since_id, $search, $search_mode, $include_nested, $sanitize_content); @@ -226,10 +226,10 @@ class API extends Handler { } function updateArticle() { - $article_ids = array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_ids"])), is_numeric); - $mode = (int) db_escape_string($this->link, $_REQUEST["mode"]); - $data = db_escape_string($this->link, $_REQUEST["data"]); - $field_raw = (int)db_escape_string($this->link, $_REQUEST["field"]); + $article_ids = array_filter(explode(",", db_escape_string( $_REQUEST["article_ids"])), is_numeric); + $mode = (int) db_escape_string( $_REQUEST["mode"]); + $data = db_escape_string( $_REQUEST["data"]); + $field_raw = (int)db_escape_string( $_REQUEST["field"]); $field = ""; $set_to = ""; @@ -269,16 +269,16 @@ class API extends Handler { $article_ids = join(", ", $article_ids); - $result = db_query($this->link, "UPDATE ttrss_user_entries SET $field = $set_to $additional_fields WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]); + $result = db_query( "UPDATE ttrss_user_entries SET $field = $set_to $additional_fields WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]); - $num_updated = db_affected_rows($this->link, $result); + $num_updated = db_affected_rows( $result); if ($num_updated > 0 && $field == "unread") { - $result = db_query($this->link, "SELECT DISTINCT feed_id FROM ttrss_user_entries + $result = db_query( "SELECT DISTINCT feed_id FROM ttrss_user_entries WHERE ref_id IN ($article_ids)"); while ($line = db_fetch_assoc($result)) { - ccache_update($this->link, $line["feed_id"], $_SESSION["uid"]); + ccache_update( $line["feed_id"], $_SESSION["uid"]); } } @@ -286,7 +286,7 @@ class API extends Handler { if (PUBSUBHUBBUB_HUB) { $rss_link = get_self_url_prefix() . "/public.php?op=rss&id=-2&key=" . - get_feed_access_key($this->link, -2, false); + get_feed_access_key( -2, false); $p = new Publisher(PUBSUBHUBBUB_HUB); $pubsub_result = $p->publish_update($rss_link); @@ -304,7 +304,7 @@ class API extends Handler { function getArticle() { - $article_id = join(",", array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_id"])), is_numeric)); + $article_id = join(",", array_filter(explode(",", db_escape_string( $_REQUEST["article_id"])), is_numeric)); $query = "SELECT id,title,link,content,cached_content,feed_id,comments,int_id, marked,unread,published,score, @@ -314,7 +314,7 @@ class API extends Handler { WHERE id IN ($article_id) AND ref_id = id AND owner_uid = " . $_SESSION["uid"] ; - $result = db_query($this->link, $query); + $result = db_query( $query); $articles = array(); @@ -322,13 +322,13 @@ class API extends Handler { while ($line = db_fetch_assoc($result)) { - $attachments = get_article_enclosures($this->link, $line['id']); + $attachments = get_article_enclosures( $line['id']); $article = array( "id" => $line["id"], "title" => $line["title"], "link" => $line["link"], - "labels" => get_article_labels($this->link, $line['id']), + "labels" => get_article_labels( $line['id']), "unread" => sql_bool_to_bool($line["unread"]), "marked" => sql_bool_to_bool($line["marked"]), "published" => sql_bool_to_bool($line["published"]), @@ -363,7 +363,7 @@ class API extends Handler { $config["daemon_is_running"] = file_is_locked("update_daemon.lock"); - $result = db_query($this->link, "SELECT COUNT(*) AS cf FROM + $result = db_query( "SELECT COUNT(*) AS cf FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]); $num_feeds = db_fetch_result($result, 0, "cf"); @@ -376,41 +376,41 @@ class API extends Handler { function updateFeed() { require_once "include/rssfuncs.php"; - $feed_id = (int) db_escape_string($this->link, $_REQUEST["feed_id"]); + $feed_id = (int) db_escape_string( $_REQUEST["feed_id"]); - update_rss_feed($this->link, $feed_id, true); + update_rss_feed( $feed_id, true); print $this->wrap(self::STATUS_OK, array("status" => "OK")); } function catchupFeed() { - $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]); - $is_cat = db_escape_string($this->link, $_REQUEST["is_cat"]); + $feed_id = db_escape_string( $_REQUEST["feed_id"]); + $is_cat = db_escape_string( $_REQUEST["is_cat"]); - catchup_feed($this->link, $feed_id, $is_cat); + catchup_feed( $feed_id, $is_cat); print $this->wrap(self::STATUS_OK, array("status" => "OK")); } function getPref() { - $pref_name = db_escape_string($this->link, $_REQUEST["pref_name"]); + $pref_name = db_escape_string( $_REQUEST["pref_name"]); - print $this->wrap(self::STATUS_OK, array("value" => get_pref($this->link, $pref_name))); + print $this->wrap(self::STATUS_OK, array("value" => get_pref( $pref_name))); } function getLabels() { - //$article_ids = array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_ids"])), is_numeric); + //$article_ids = array_filter(explode(",", db_escape_string( $_REQUEST["article_ids"])), is_numeric); $article_id = (int)$_REQUEST['article_id']; $rv = array(); - $result = db_query($this->link, "SELECT id, caption, fg_color, bg_color + $result = db_query( "SELECT id, caption, fg_color, bg_color FROM ttrss_labels2 WHERE owner_uid = '".$_SESSION['uid']."' ORDER BY caption"); if ($article_id) - $article_labels = get_article_labels($this->link, $article_id); + $article_labels = get_article_labels( $article_id); else $article_labels = array(); @@ -437,11 +437,11 @@ class API extends Handler { function setArticleLabel() { - $article_ids = array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_ids"])), is_numeric); - $label_id = (int) db_escape_string($this->link, $_REQUEST['label_id']); - $assign = (bool) db_escape_string($this->link, $_REQUEST['assign']) == "true"; + $article_ids = array_filter(explode(",", db_escape_string( $_REQUEST["article_ids"])), is_numeric); + $label_id = (int) db_escape_string( $_REQUEST['label_id']); + $assign = (bool) db_escape_string( $_REQUEST['assign']) == "true"; - $label = db_escape_string($this->link, label_find_caption($this->link, + $label = db_escape_string( label_find_caption( $label_id, $_SESSION["uid"])); $num_updated = 0; @@ -451,9 +451,9 @@ class API extends Handler { foreach ($article_ids as $id) { if ($assign) - label_add_article($this->link, $id, $label, $_SESSION["uid"]); + label_add_article( $id, $label, $_SESSION["uid"]); else - label_remove_article($this->link, $id, $label, $_SESSION["uid"]); + label_remove_article( $id, $label, $_SESSION["uid"]); ++$num_updated; @@ -481,25 +481,25 @@ class API extends Handler { } function shareToPublished() { - $title = db_escape_string($this->link, strip_tags($_REQUEST["title"])); - $url = db_escape_string($this->link, strip_tags($_REQUEST["url"])); - $content = db_escape_string($this->link, strip_tags($_REQUEST["content"])); + $title = db_escape_string( strip_tags($_REQUEST["title"])); + $url = db_escape_string( strip_tags($_REQUEST["url"])); + $content = db_escape_string( strip_tags($_REQUEST["content"])); - if (Article::create_published_article($this->link, $title, $url, $content, "", $_SESSION["uid"])) { + if (Article::create_published_article( $title, $url, $content, "", $_SESSION["uid"])) { print $this->wrap(self::STATUS_OK, array("status" => 'OK')); } else { print $this->wrap(self::STATUS_ERR, array("error" => 'Publishing failed')); } } - static function api_get_feeds($link, $cat_id, $unread_only, $limit, $offset, $include_nested = false) { + static function api_get_feeds( $cat_id, $unread_only, $limit, $offset, $include_nested = false) { $feeds = array(); /* Labels */ if ($cat_id == -4 || $cat_id == -2) { - $counters = getLabelCounters($link, true); + $counters = getLabelCounters( true); foreach (array_values($counters) as $cv) { @@ -523,10 +523,10 @@ class API extends Handler { if ($cat_id == -4 || $cat_id == -1) { foreach (array(-1, -2, -3, -4, -6, 0) as $i) { - $unread = getFeedUnread($link, $i); + $unread = getFeedUnread( $i); if ($unread || !$unread_only) { - $title = getFeedTitle($link, $i); + $title = getFeedTitle( $i); $row = array( "id" => $i, @@ -543,14 +543,14 @@ class API extends Handler { /* Child cats */ if ($include_nested && $cat_id) { - $result = db_query($link, "SELECT + $result = db_query( "SELECT id, title FROM ttrss_feed_categories WHERE parent_cat = '$cat_id' AND owner_uid = " . $_SESSION["uid"] . " ORDER BY id, title"); while ($line = db_fetch_assoc($result)) { - $unread = getFeedUnread($link, $line["id"], true) + - getCategoryChildrenUnread($link, $line["id"]); + $unread = getFeedUnread( $line["id"], true) + + getCategoryChildrenUnread( $line["id"]); if ($unread || !$unread_only) { $row = array( @@ -573,7 +573,7 @@ class API extends Handler { } if ($cat_id == -4 || $cat_id == -3) { - $result = db_query($link, "SELECT + $result = db_query( "SELECT id, feed_url, cat_id, title, order_id, ". SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] . @@ -585,7 +585,7 @@ class API extends Handler { else $cat_qpart = "cat_id IS NULL"; - $result = db_query($link, "SELECT + $result = db_query( "SELECT id, feed_url, cat_id, title, order_id, ". SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated FROM ttrss_feeds WHERE @@ -595,7 +595,7 @@ class API extends Handler { while ($line = db_fetch_assoc($result)) { - $unread = getFeedUnread($link, $line["id"]); + $unread = getFeedUnread( $line["id"]); $has_icon = feed_has_icon($line['id']); @@ -619,13 +619,13 @@ class API extends Handler { return $feeds; } - static function api_get_headlines($link, $feed_id, $limit, $offset, + static function api_get_headlines( $feed_id, $limit, $offset, $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order, $include_attachments, $since_id, $search = "", $search_mode = "", $include_nested = false, $sanitize_content = true) { - $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit, + $qfh_ret = queryFeedHeadlines( $feed_id, $limit, $view_mode, $is_cat, $search, $search_mode, $order, $offset, 0, false, $since_id, $include_nested); @@ -641,8 +641,8 @@ class API extends Handler { $tags = explode(",", $line["tag_cache"]); $labels = json_decode($line["label_cache"], true); - //if (!$tags) $tags = get_article_tags($link, $line["id"]); - //if (!$labels) $labels = get_article_labels($link, $line["id"]); + //if (!$tags) $tags = get_article_tags( $line["id"]); + //if (!$labels) $labels = get_article_labels( $line["id"]); $headline_row = array( "id" => (int)$line["id"], @@ -658,7 +658,7 @@ class API extends Handler { ); if ($include_attachments) - $headline_row['attachments'] = get_article_enclosures($link, + $headline_row['attachments'] = get_article_enclosures( $line['id']); if ($show_excerpt) { @@ -673,7 +673,7 @@ class API extends Handler { } if ($sanitize_content) { - $headline_row["content"] = sanitize($link, + $headline_row["content"] = sanitize( $line["content_preview"], sql_bool_to_bool($line['hide_images']), false, $line["site_url"]); @@ -709,13 +709,13 @@ class API extends Handler { } function unsubscribeFeed() { - $feed_id = (int) db_escape_string($this->link, $_REQUEST["feed_id"]); + $feed_id = (int) db_escape_string( $_REQUEST["feed_id"]); - $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE + $result = db_query( "SELECT id FROM ttrss_feeds WHERE id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]); if (db_num_rows($result) != 0) { - Pref_Feeds::remove_feed($this->link, $feed_id, $_SESSION["uid"]); + Pref_Feeds::remove_feed( $feed_id, $_SESSION["uid"]); print $this->wrap(self::STATUS_OK, array("status" => "OK")); } else { print $this->wrap(self::STATUS_ERR, array("error" => "FEED_NOT_FOUND")); @@ -723,13 +723,13 @@ class API extends Handler { } function subscribeToFeed() { - $feed_url = db_escape_string($this->link, $_REQUEST["feed_url"]); - $category_id = (int) db_escape_string($this->link, $_REQUEST["category_id"]); - $login = db_escape_string($this->link, $_REQUEST["login"]); - $password = db_escape_string($this->link, $_REQUEST["password"]); + $feed_url = db_escape_string( $_REQUEST["feed_url"]); + $category_id = (int) db_escape_string( $_REQUEST["category_id"]); + $login = db_escape_string( $_REQUEST["login"]); + $password = db_escape_string( $_REQUEST["password"]); if ($feed_url) { - $rc = subscribe_to_feed($this->link, $feed_url, $category_id, + $rc = subscribe_to_feed( $feed_url, $category_id, $login, $password, false); print $this->wrap(self::STATUS_OK, array("status" => $rc)); @@ -741,7 +741,7 @@ class API extends Handler { function getFeedTree() { $include_empty = sql_bool_to_bool($_REQUEST['include_empty']); - $pf = new Pref_Feeds($this->link, $_REQUEST); + $pf = new Pref_Feeds( $_REQUEST); $_REQUEST['mode'] = 2; $_REQUEST['force_show_empty'] = $include_empty; @@ -760,13 +760,13 @@ class API extends Handler { private function isCategoryEmpty($id) { if ($id == -2) { - $result = db_query($this->link, "SELECT COUNT(*) AS count FROM ttrss_labels2 + $result = db_query( "SELECT COUNT(*) AS count FROM ttrss_labels2 WHERE owner_uid = " . $_SESSION["uid"]); return db_fetch_result($result, 0, "count") == 0; } else if ($id == 0) { - $result = db_query($this->link, "SELECT COUNT(*) AS count FROM ttrss_feeds + $result = db_query( "SELECT COUNT(*) AS count FROM ttrss_feeds WHERE cat_id IS NULL AND owner_uid = " . $_SESSION["uid"]); return db_fetch_result($result, 0, "count") == 0; diff --git a/classes/article.php b/classes/article.php index f31a225d1..9917d4d06 100644 --- a/classes/article.php +++ b/classes/article.php @@ -8,9 +8,9 @@ class Article extends Handler_Protected { } function redirect() { - $id = db_escape_string($this->link, $_REQUEST['id']); + $id = db_escape_string( $_REQUEST['id']); - $result = db_query($this->link, "SELECT link FROM ttrss_entries, ttrss_user_entries + $result = db_query( "SELECT link FROM ttrss_entries, ttrss_user_entries WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."' LIMIT 1"); @@ -27,10 +27,10 @@ class Article extends Handler_Protected { } function view() { - $id = db_escape_string($this->link, $_REQUEST["id"]); - $cids = explode(",", db_escape_string($this->link, $_REQUEST["cids"])); - $mode = db_escape_string($this->link, $_REQUEST["mode"]); - $omode = db_escape_string($this->link, $_REQUEST["omode"]); + $id = db_escape_string( $_REQUEST["id"]); + $cids = explode(",", db_escape_string( $_REQUEST["cids"])); + $mode = db_escape_string( $_REQUEST["mode"]); + $omode = db_escape_string( $_REQUEST["omode"]); // in prefetch mode we only output requested cids, main article // just gets marked as read (it already exists in client cache) @@ -38,26 +38,26 @@ class Article extends Handler_Protected { $articles = array(); if ($mode == "") { - array_push($articles, format_article($this->link, $id, false)); + array_push($articles, format_article( $id, false)); } else if ($mode == "zoom") { - array_push($articles, format_article($this->link, $id, true, true)); + array_push($articles, format_article( $id, true, true)); } else if ($mode == "raw") { if ($_REQUEST['html']) { header("Content-Type: text/html"); print ''; } - $article = format_article($this->link, $id, false); + $article = format_article( $id, false); print $article['content']; return; } - $this->catchupArticleById($this->link, $id, 0); + $this->catchupArticleById( $id, 0); if (!$_SESSION["bw_limit"]) { foreach ($cids as $cid) { if ($cid) { - array_push($articles, format_article($this->link, $cid, false, false)); + array_push($articles, format_article( $cid, false, false)); } } } @@ -65,27 +65,27 @@ class Article extends Handler_Protected { print json_encode($articles); } - private function catchupArticleById($link, $id, $cmode) { + private function catchupArticleById( $id, $cmode) { if ($cmode == 0) { - db_query($link, "UPDATE ttrss_user_entries SET + db_query( "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); } else if ($cmode == 1) { - db_query($link, "UPDATE ttrss_user_entries SET + db_query( "UPDATE ttrss_user_entries SET unread = true WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); } else { - db_query($link, "UPDATE ttrss_user_entries SET + db_query( "UPDATE ttrss_user_entries SET unread = NOT unread,last_read = NOW() WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); } - $feed_id = getArticleFeed($link, $id); - ccache_update($link, $feed_id, $_SESSION["uid"]); + $feed_id = getArticleFeed( $id); + ccache_update( $feed_id, $_SESSION["uid"]); } - static function create_published_article($link, $title, $url, $content, $labels_str, + static function create_published_article( $title, $url, $content, $labels_str, $owner_uid) { $guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid); // include owner_uid to prevent global GUID clash @@ -104,30 +104,30 @@ class Article extends Handler_Protected { if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) return false; - db_query($link, "BEGIN"); + db_query( "BEGIN"); // only check for our user data here, others might have shared this with different content etc - $result = db_query($link, "SELECT id FROM ttrss_entries, ttrss_user_entries WHERE + $result = db_query( "SELECT id FROM ttrss_entries, ttrss_user_entries WHERE link = '$url' AND ref_id = id AND owner_uid = '$owner_uid' LIMIT 1"); if (db_num_rows($result) != 0) { $ref_id = db_fetch_result($result, 0, "id"); - $result = db_query($link, "SELECT int_id FROM ttrss_user_entries WHERE + $result = db_query( "SELECT int_id FROM ttrss_user_entries WHERE ref_id = '$ref_id' AND owner_uid = '$owner_uid' LIMIT 1"); if (db_num_rows($result) != 0) { $int_id = db_fetch_result($result, 0, "int_id"); - db_query($link, "UPDATE ttrss_entries SET + db_query( "UPDATE ttrss_entries SET content = '$content', content_hash = '$content_hash' WHERE id = '$ref_id'"); - db_query($link, "UPDATE ttrss_user_entries SET published = true, + db_query( "UPDATE ttrss_user_entries SET published = true, last_published = NOW() WHERE int_id = '$int_id' AND owner_uid = '$owner_uid'"); } else { - db_query($link, "INSERT INTO ttrss_user_entries + db_query( "INSERT INTO ttrss_user_entries (ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache, last_read, note, unread, last_published) VALUES @@ -136,24 +136,24 @@ class Article extends Handler_Protected { if (count($labels) != 0) { foreach ($labels as $label) { - label_add_article($link, $ref_id, trim($label), $owner_uid); + label_add_article( $ref_id, trim($label), $owner_uid); } } $rc = true; } else { - $result = db_query($link, "INSERT INTO ttrss_entries + $result = db_query( "INSERT INTO ttrss_entries (title, guid, link, updated, content, content_hash, date_entered, date_updated) VALUES ('$title', '$guid', '$url', NOW(), '$content', '$content_hash', NOW(), NOW())"); - $result = db_query($link, "SELECT id FROM ttrss_entries WHERE guid = '$guid'"); + $result = db_query( "SELECT id FROM ttrss_entries WHERE guid = '$guid'"); if (db_num_rows($result) != 0) { $ref_id = db_fetch_result($result, 0, "id"); - db_query($link, "INSERT INTO ttrss_user_entries + db_query( "INSERT INTO ttrss_user_entries (ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache, last_read, note, unread, last_published) VALUES @@ -161,7 +161,7 @@ class Article extends Handler_Protected { if (count($labels) != 0) { foreach ($labels as $label) { - label_add_article($link, $ref_id, trim($label), $owner_uid); + label_add_article( $ref_id, trim($label), $owner_uid); } } @@ -169,7 +169,7 @@ class Article extends Handler_Protected { } } - db_query($link, "COMMIT"); + db_query( "COMMIT"); return $rc; } @@ -178,9 +178,9 @@ class Article extends Handler_Protected { print __("Tags for this article (separated by commas):")."
"; - $param = db_escape_string($this->link, $_REQUEST['param']); + $param = db_escape_string( $_REQUEST['param']); - $tags = get_article_tags($this->link, db_escape_string($this->link, $param)); + $tags = get_article_tags( db_escape_string( $param)); $tags_str = join(", ", $tags); @@ -209,10 +209,10 @@ class Article extends Handler_Protected { } function setScore() { - $ids = db_escape_string($this->link, $_REQUEST['id']); - $score = (int)db_escape_string($this->link, $_REQUEST['score']); + $ids = db_escape_string( $_REQUEST['id']); + $score = (int)db_escape_string( $_REQUEST['score']); - db_query($this->link, "UPDATE ttrss_user_entries SET + db_query( "UPDATE ttrss_user_entries SET score = '$score' WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]); print json_encode(array("id" => $id, @@ -222,14 +222,14 @@ class Article extends Handler_Protected { function setArticleTags() { - $id = db_escape_string($this->link, $_REQUEST["id"]); + $id = db_escape_string( $_REQUEST["id"]); - $tags_str = db_escape_string($this->link, $_REQUEST["tags_str"]); + $tags_str = db_escape_string( $_REQUEST["tags_str"]); $tags = array_unique(trim_array(explode(",", $tags_str))); - db_query($this->link, "BEGIN"); + db_query( "BEGIN"); - $result = db_query($this->link, "SELECT int_id FROM ttrss_user_entries WHERE + $result = db_query( "SELECT int_id FROM ttrss_user_entries WHERE ref_id = '$id' AND owner_uid = '".$_SESSION["uid"]."' LIMIT 1"); if (db_num_rows($result) == 1) { @@ -238,7 +238,7 @@ class Article extends Handler_Protected { $int_id = db_fetch_result($result, 0, "int_id"); - db_query($this->link, "DELETE FROM ttrss_tags WHERE + db_query( "DELETE FROM ttrss_tags WHERE post_int_id = $int_id AND owner_uid = '".$_SESSION["uid"]."'"); foreach ($tags as $tag) { @@ -255,7 +255,7 @@ class Article extends Handler_Protected { // print ""; if ($tag != '') { - db_query($this->link, "INSERT INTO ttrss_tags + db_query( "INSERT INTO ttrss_tags (post_int_id, owner_uid, tag_name) VALUES ('$int_id', '".$_SESSION["uid"]."', '$tag')"); } @@ -267,14 +267,14 @@ class Article extends Handler_Protected { sort($tags_to_cache); $tags_str = join(",", $tags_to_cache); - db_query($this->link, "UPDATE ttrss_user_entries + db_query( "UPDATE ttrss_user_entries SET tag_cache = '$tags_str' WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); } - db_query($this->link, "COMMIT"); + db_query( "COMMIT"); - $tags = get_article_tags($this->link, $id); + $tags = get_article_tags( $id); $tags_str = format_tags_string($tags, $id); $tags_str_full = join(", ", $tags); @@ -286,9 +286,9 @@ class Article extends Handler_Protected { function completeTags() { - $search = db_escape_string($this->link, $_REQUEST["search"]); + $search = db_escape_string( $_REQUEST["search"]); - $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags + $result = db_query( "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = '".$_SESSION["uid"]."' AND tag_name LIKE '$search%' ORDER BY tag_name LIMIT 10"); @@ -311,10 +311,10 @@ class Article extends Handler_Protected { private function labelops($assign) { $reply = array(); - $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"])); - $label_id = db_escape_string($this->link, $_REQUEST["lid"]); + $ids = explode(",", db_escape_string( $_REQUEST["ids"])); + $label_id = db_escape_string( $_REQUEST["lid"]); - $label = db_escape_string($this->link, label_find_caption($this->link, $label_id, + $label = db_escape_string( label_find_caption( $label_id, $_SESSION["uid"])); $reply["info-for-headlines"] = array(); @@ -324,11 +324,11 @@ class Article extends Handler_Protected { foreach ($ids as $id) { if ($assign) - label_add_article($this->link, $id, $label, $_SESSION["uid"]); + label_add_article( $id, $label, $_SESSION["uid"]); else - label_remove_article($this->link, $id, $label, $_SESSION["uid"]); + label_remove_article( $id, $label, $_SESSION["uid"]); - $labels = get_article_labels($this->link, $id, $_SESSION["uid"]); + $labels = get_article_labels( $id, $_SESSION["uid"]); array_push($reply["info-for-headlines"], array("id" => $id, "labels" => format_article_labels($labels, $id))); diff --git a/classes/auth/base.php b/classes/auth/base.php index ad7ff3646..c2a6bd704 100644 --- a/classes/auth/base.php +++ b/classes/auth/base.php @@ -1,9 +1,9 @@ link = $link; + function __construct($dbh) { + $this->dbh = $dbh; } function check_password($owner_uid, $password) { @@ -21,7 +21,7 @@ class Auth_Base { $user_id = $this->find_user_by_login($login); if (!$user_id) { - $login = db_escape_string($this->link, $login); + $login = db_escape_string( $login); $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); $pwd_hash = encrypt_password($password, $salt, true); @@ -29,7 +29,7 @@ class Auth_Base { (login,access_level,last_login,created,pwd_hash,salt) VALUES ('$login', 0, null, NOW(), '$pwd_hash','$salt')"; - db_query($this->link, $query); + db_query( $query); return $this->find_user_by_login($login); @@ -42,9 +42,9 @@ class Auth_Base { } function find_user_by_login($login) { - $login = db_escape_string($this->link, $login); + $login = db_escape_string( $login); - $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE + $result = db_query( "SELECT id FROM ttrss_users WHERE login = '$login'"); if (db_num_rows($result) > 0) { diff --git a/classes/backend.php b/classes/backend.php index c03d583db..a04168108 100644 --- a/classes/backend.php +++ b/classes/backend.php @@ -11,7 +11,7 @@ class Backend extends Handler { require_once "digest.php"; - $rv = prepare_headlines_digest($this->link, $_SESSION['uid'], 1, 1000); + $rv = prepare_headlines_digest( $_SESSION['uid'], 1, 1000); $rv[3] = "
" . $rv[3] . "
"; @@ -19,8 +19,8 @@ class Backend extends Handler { } private function display_main_help() { - $info = get_hotkeys_info($this->link); - $imap = get_hotkeys_map($this->link); + $info = get_hotkeys_info(); + $imap = get_hotkeys_map(); $omap = array(); foreach ($imap[1] as $sequence => $action) { diff --git a/classes/db.php b/classes/db.php index c3b627096..6dc31a22e 100644 --- a/classes/db.php +++ b/classes/db.php @@ -36,7 +36,7 @@ class Db implements IDb { function connect($host, $user, $pass, $db, $port) { //return $this->adapter->connect($host, $user, $pass, $db, $port); - return $this->link; + return ; } function escape_string($s, $strip_tags = true) { diff --git a/classes/db/pgsql.php b/classes/db/pgsql.php index bafd54ab2..0cb737978 100644 --- a/classes/db/pgsql.php +++ b/classes/db/pgsql.php @@ -31,11 +31,11 @@ class Db_Pgsql implements IDb { function escape_string($s, $strip_tags = true) { if ($strip_tags) $s = strip_tags($s); - return pg_escape_string($this->link, $s); + return pg_escape_string( $s); } function query($query, $die_on_error = true) { - $result = pg_query($this->link, $query); + $result = pg_query( $query); if (!$result) { $query = htmlspecialchars($query); // just in case diff --git a/classes/dbupdater.php b/classes/dbupdater.php index a9a713273..ffcac7cf7 100644 --- a/classes/dbupdater.php +++ b/classes/dbupdater.php @@ -1,18 +1,18 @@ link = $link; + function __construct($dbh, $db_type, $need_version) { + $this->dbh = $dbh; $this->db_type = $db_type; $this->need_version = (int) $need_version; } function getSchemaVersion() { - $result = db_query($this->link, "SELECT schema_version FROM ttrss_version"); + $result = db_query( "SELECT schema_version FROM ttrss_version"); return (int) db_fetch_result($result, 0, "schema_version"); } @@ -37,21 +37,21 @@ class DbUpdater { if (is_array($lines)) { - db_query($this->link, "BEGIN"); + db_query( "BEGIN"); foreach ($lines as $line) { if (strpos($line, "--") !== 0 && $line) { - db_query($this->link, $line); + db_query( $line); } } $db_version = $this->getSchemaVersion(); if ($db_version == $version) { - db_query($this->link, "COMMIT"); + db_query( "COMMIT"); return true; } else { - db_query($this->link, "ROLLBACK"); + db_query( "ROLLBACK"); return false; } } else { diff --git a/classes/dlg.php b/classes/dlg.php index e56560a47..99cd7cffa 100644 --- a/classes/dlg.php +++ b/classes/dlg.php @@ -6,7 +6,7 @@ class Dlg extends Handler_Protected { if (parent::before($method)) { header("Content-Type: text/html"); # required for iframe - $this->param = db_escape_string($this->link, $_REQUEST["param"]); + $this->param = db_escape_string( $_REQUEST["param"]); return true; } return false; @@ -18,15 +18,15 @@ class Dlg extends Handler_Protected { print "
"; $owner_uid = $_SESSION["uid"]; - db_query($this->link, "BEGIN"); + db_query( "BEGIN"); print "
    "; - $opml = new Opml($this->link, $_REQUEST); + $opml = new Opml( $_REQUEST); $opml->opml_import($_SESSION["uid"]); - db_query($this->link, "COMMIT"); + db_query( "COMMIT"); print "
"; print "
"; @@ -43,7 +43,7 @@ class Dlg extends Handler_Protected { } function pubOPMLUrl() { - $url_path = Opml::opml_publish_url($this->link); + $url_path = Opml::opml_publish_url(); print __("Your Public OPML URL is:"); @@ -106,7 +106,7 @@ class Dlg extends Handler_Protected { FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]." GROUP BY tag_name ORDER BY count DESC LIMIT 50"; - $result = db_query($this->link, $query); + $result = db_query( $query); $tags = array(); @@ -171,7 +171,7 @@ class Dlg extends Handler_Protected { print "