X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=classes%2Fhandler%2Fpublic.php;h=dbed3fee6f6b2e578a3f27b7713ba426914c4e2d;hb=253dbd48562f0742befe0335278c4e26ac313efe;hp=ec41ddb87b8d8e6c06cfdd0187f46fc19c3dce70;hpb=d2957a271831b88da26bb273367353b35acace37;p=tt-rss.git diff --git a/classes/handler/public.php b/classes/handler/public.php old mode 100644 new mode 100755 index ec41ddb8..dbed3fee --- 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) { @@ -40,7 +37,7 @@ class Handler_Public extends Handler { $params = array( "owner_uid" => $owner_uid, "feed" => $feed, - "limit" => 1, + "limit" => $limit, "view_mode" => $view_mode, "cat_view" => $is_cat, "search" => $search, @@ -51,40 +48,27 @@ class Handler_Public extends Handler { "start_ts" => $start_ts ); - $qfh_ret = Feeds::queryFeedHeadlines($params); + if (!$is_cat && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { - $result = $qfh_ret[0]; + $user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); - if ($this->dbh->num_rows($result) != 0) { + $tmppluginhost = new PluginHost(); + $tmppluginhost->load(PLUGINS, PluginHost::KIND_ALL); + $tmppluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid); + $tmppluginhost->load_data(); - $ts = strtotime($this->dbh->fetch_result($result, 0, $date_check_field)); + $handler = $tmppluginhost->get_feed_handler( + PluginHost::feed_to_pfeed_id($feed)); - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && - strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $ts) { - header('HTTP/1.0 304 Not Modified'); - return; + if ($handler) { + $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), + $options); } - $last_modified = gmdate("D, d M Y H:i:s", $ts) . " GMT"; - header("Last-Modified: $last_modified", true); + } else { + $qfh_ret = Feeds::queryFeedHeadlines($params); } - $params = array( - "owner_uid" => $owner_uid, - "feed" => $feed, - "limit" => $limit, - "view_mode" => $view_mode, - "cat_view" => $is_cat, - "search" => $search, - "override_order" => $date_sort_field, - "include_children" => true, - "ignore_vfeed_group" => true, - "offset" => $offset, - "start_ts" => $start_ts - ); - - $qfh_ret = Feeds::queryFeedHeadlines($params); - $result = $qfh_ret[0]; $feed_title = htmlspecialchars($qfh_ret[1]); $feed_site_url = $qfh_ret[2]; @@ -106,7 +90,7 @@ class Handler_Public extends Handler { $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true); $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true); - while ($line = $this->dbh->fetch_assoc($result)) { + while ($line = $result->fetch()) { $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content"]), 100, '...')); @@ -175,7 +159,7 @@ class Handler_Public extends Handler { $tpl->addBlock('feed'); $tpl->generateOutputToString($tmp); - if (@!$_REQUEST["noxml"]) { + if (@!clean($_REQUEST["noxml"])) { header("Content-Type: text/xml; charset=utf-8"); } else { header("Content-Type: text/plain; charset=utf-8"); @@ -194,7 +178,7 @@ class Handler_Public extends Handler { $feed['articles'] = array(); - while ($line = $this->dbh->fetch_assoc($result)) { + while ($line = $result->fetch()) { $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...')); @@ -255,13 +239,14 @@ class Handler_Public extends Handler { } function getUnread() { - $login = $this->dbh->escape_string($_REQUEST["login"]); - $fresh = $_REQUEST["fresh"] == "1"; + $login = clean($_REQUEST["login"]); + $fresh = clean($_REQUEST["fresh"]) == "1"; - $result = $this->dbh->query("SELECT id FROM ttrss_users WHERE login = '$login'"); + $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?"); + $sth->execute([$login]); - if ($this->dbh->num_rows($result) == 1) { - $uid = $this->dbh->fetch_result($result, 0, "id"); + if ($row = $sth->fetch()) { + $uid = $row["id"]; print Feeds::getGlobalUnread($uid); @@ -273,20 +258,20 @@ class Handler_Public extends Handler { } else { print "-1;User not found"; } - } function getProfiles() { - $login = $this->dbh->escape_string($_REQUEST["login"]); + $login = clean($_REQUEST["login"]); - $result = $this->dbh->query("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users - WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title"); + $sth = $this->pdo->prepare("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users + WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = ? ORDER BY title"); + $sth->execute([$login]); print ""; + print ""; print ""; print "
"; print ""; - print ""; + print ""; print "
"; print "
"; print ""; - print ""; + print ""; print "
"; print "

"; @@ -752,9 +749,9 @@ class Handler_Public extends Handler { print ""; } else if ($method == 'do') { - $login = $this->dbh->escape_string($_POST["login"]); - $email = $this->dbh->escape_string($_POST["email"]); - $test = $this->dbh->escape_string($_POST["test"]); + $login = clean($_POST["login"]); + $email = clean($_POST["email"]); + $test = clean($_POST["test"]); if (($test != 4 && $test != 'four') || !$email || !$login) { print_error(__('Some of the required form parameters are missing or incorrect.')); @@ -768,11 +765,12 @@ class Handler_Public extends Handler { print_notice("Password reset instructions are being sent to your email address."); - $result = $this->dbh->query("SELECT id FROM ttrss_users - WHERE login = '$login' AND email = '$email'"); + $sth = $this->pdo->prepare("SELECT id FROM ttrss_users + WHERE login = ? AND email = ?"); + $sth->execute([$login, $email]); - if ($this->dbh->num_rows($result) != 0) { - $id = $this->dbh->fetch_result($result, 0, "id"); + if ($row = $sth->fetch()) { + $id = $row["id"]; if ($id) { $resetpass_token = sha1(get_random_bytes(128)); @@ -803,11 +801,13 @@ class Handler_Public extends Handler { if (!$rc) print_error($mail->ErrorInfo); - $resetpass_token_full = $this->dbh->escape_string(time() . ":" . $resetpass_token); + $resetpass_token_full = time() . ":" . $resetpass_token; + + $sth = $this->pdo->prepare("UPDATE ttrss_users + SET resetpass_token = ? + WHERE login = ? AND email = ?"); - $result = $this->dbh->query("UPDATE ttrss_users - SET resetpass_token = '$resetpass_token_full' - WHERE login = '$login' AND email = '$email'"); + $sth->execute([$resetpass_token_full, $login, $email]); //Pref_Users::resetUserPassword($id, false); @@ -854,7 +854,7 @@ class Handler_Public extends Handler { Database Updater - + @@ -862,7 +862,7 @@ class Handler_Public extends Handler { span.ok { color : #009000; font-weight : bold; } span.err { color : #ff0000; font-weight : bold; } - +