X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=classes%2Fhandler%2Fpublic.php;h=dbed3fee6f6b2e578a3f27b7713ba426914c4e2d;hb=253dbd48562f0742befe0335278c4e26ac313efe;hp=f36ee8b1aebdbacaa8e6004c7d415e205e8822a3;hpb=4ee398a41e2176d4a5c997920db35cb6bed12f2e;p=tt-rss.git diff --git a/classes/handler/public.php b/classes/handler/public.php old mode 100644 new mode 100755 index f36ee8b1..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) { @@ -36,6 +33,7 @@ class Handler_Public extends Handler { $date_sort_field = "updated DESC"; break; } + $params = array( "owner_uid" => $owner_uid, "feed" => $feed, @@ -50,7 +48,26 @@ 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) { + + $user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); + + $tmppluginhost = new PluginHost(); + $tmppluginhost->load(PLUGINS, PluginHost::KIND_ALL); + $tmppluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid); + $tmppluginhost->load_data(); + + $handler = $tmppluginhost->get_feed_handler( + PluginHost::feed_to_pfeed_id($feed)); + + if ($handler) { + $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), + $options); + } + + } else { + $qfh_ret = Feeds::queryFeedHeadlines($params); + } $result = $qfh_ret[0]; $feed_title = htmlspecialchars($qfh_ret[1]); @@ -142,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"); @@ -222,8 +239,8 @@ class Handler_Public extends Handler { } function getUnread() { - $login = $_REQUEST["login"]; - $fresh = $_REQUEST["fresh"] == "1"; + $login = clean($_REQUEST["login"]); + $fresh = clean($_REQUEST["fresh"]) == "1"; $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?"); $sth->execute([$login]); @@ -244,7 +261,7 @@ class Handler_Public extends Handler { } function getProfiles() { - $login = $_REQUEST["login"]; + $login = clean($_REQUEST["login"]); $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"); @@ -270,7 +287,7 @@ class Handler_Public extends Handler { } function share() { - $uuid = $_REQUEST["key"]; + $uuid = clean($_REQUEST["key"]); $sth = $this->pdo->prepare("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE uuid = ?"); @@ -293,19 +310,19 @@ class Handler_Public extends Handler { } function rss() { - $feed = $_REQUEST["id"]; - $key = $_REQUEST["key"]; - $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]); - $limit = (int)$_REQUEST["limit"]; - $offset = (int)$_REQUEST["offset"]; + $feed = clean($_REQUEST["id"]); + $key = clean($_REQUEST["key"]); + $is_cat = clean($_REQUEST["is_cat"]); + $limit = (int)clean($_REQUEST["limit"]); + $offset = (int)clean($_REQUEST["offset"]); - $search = $_REQUEST["q"]; - $view_mode = $_REQUEST["view-mode"]; - $order = $_REQUEST["order"]; - $start_ts = $_REQUEST["ts"]; + $search = clean($_REQUEST["q"]); + $view_mode = clean($_REQUEST["view-mode"]); + $order = clean($_REQUEST["order"]); + $start_ts = clean($_REQUEST["ts"]); - $format = $_REQUEST['format']; - $orig_guid = sql_bool_to_bool($_REQUEST["orig_guid"]); + $format = clean($_REQUEST['format']); + $orig_guid = clean($_REQUEST["orig_guid"]); if (!$format) $format = 'atom'; @@ -341,7 +358,7 @@ class Handler_Public extends Handler { } function globalUpdateFeeds() { - RPC::updaterandomfeed_real($this->dbh); + RPC::updaterandomfeed_real(); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", false); } @@ -356,23 +373,22 @@ class Handler_Public extends Handler { "; - echo stylesheet_tag("css/utility.css"); echo stylesheet_tag("css/default.css"); echo javascript_tag("lib/prototype.js"); echo javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,controls"); print " - "; + "; - $action = $_REQUEST["action"]; + $action = clean($_REQUEST["action"]); if ($_SESSION["uid"]) { if ($action == 'share') { - $title = strip_tags($_REQUEST["title"]); - $url = strip_tags($_REQUEST["url"]); - $content = strip_tags($_REQUEST["content"]); - $labels = strip_tags($_REQUEST["labels"]); + $title = strip_tags(clean($_REQUEST["title"])); + $url = strip_tags(clean($_REQUEST["url"])); + $content = strip_tags(clean($_REQUEST["content"])); + $labels = strip_tags(clean($_REQUEST["labels"])); Article::create_published_article($title, $url, $content, $labels, $_SESSION["uid"]); @@ -382,8 +398,8 @@ class Handler_Public extends Handler { print ""; } else { - $title = htmlspecialchars($_REQUEST["title"]); - $url = htmlspecialchars($_REQUEST["url"]); + $title = htmlspecialchars(clean($_REQUEST["title"])); + $url = htmlspecialchars(clean($_REQUEST["url"])); ?> @@ -470,9 +486,9 @@ class Handler_Public extends Handler { function login() { if (!SINGLE_USER_MODE) { - $login = $_POST["login"]; - $password = $_POST["password"]; - $remember_me = $_POST["remember_me"]; + $login = clean($_POST["login"]); + $password = clean($_POST["password"]); + $remember_me = clean($_POST["remember_me"]); if ($remember_me) { session_set_cookie_params(SESSION_COOKIE_LIFETIME); @@ -480,8 +496,6 @@ class Handler_Public extends Handler { session_set_cookie_params(0); } - @session_start(); - if (authenticate_user($login, $password)) { $_POST["password"] = ""; @@ -490,11 +504,11 @@ class Handler_Public extends Handler { } $_SESSION["ref_schema_version"] = get_schema_version(true); - $_SESSION["bw_limit"] = !!$_POST["bw_limit"]; + $_SESSION["bw_limit"] = !!clean($_POST["bw_limit"]); - if ($_POST["profile"]) { + if (clean($_POST["profile"])) { - $profile = $_POST["profile"]; + $profile = clean($_POST["profile"]); $sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles WHERE id = ? AND owner_uid = ?"); @@ -505,12 +519,18 @@ class Handler_Public extends Handler { } } } else { - $_SESSION["login_error_msg"] = __("Incorrect username or password"); + + // start an empty session to deliver login error message + @session_start(); + + if (!isset($_SESSION["login_error_msg"])) + $_SESSION["login_error_msg"] = __("Incorrect username or password"); + user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING); } - if ($_REQUEST['return']) { - header("Location: " . $_REQUEST['return']); + if (clean($_REQUEST['return'])) { + header("Location: " . clean($_REQUEST['return'])); } else { header("Location: " . get_self_url_prefix()); } @@ -520,7 +540,7 @@ class Handler_Public extends Handler { /* function subtest() { header("Content-type: text/plain; charset=utf-8"); - $url = $_REQUEST["url"]; + $url = clean($_REQUEST["url"]); print "$url\n\n"; @@ -536,19 +556,20 @@ class Handler_Public extends Handler { if ($_SESSION["uid"]) { - $feed_url = trim($_REQUEST["feed_url"]); + $feed_url = trim(clean($_REQUEST["feed_url"])); header('Content-Type: text/html; charset=utf-8'); print " - Tiny Tiny RSS - - - - + Tiny Tiny RSS"; + print stylesheet_tag("css/default.css"); + + print " + + - + \"Tiny

".__("Subscribe to feed...")."

"; @@ -641,27 +662,28 @@ class Handler_Public extends Handler { function forgotpass() { startup_gettext(); - @$hash = $_REQUEST["hash"]; + @$hash = clean($_REQUEST["hash"]); header('Content-Type: text/html; charset=utf-8'); print "Tiny Tiny RSS "; - echo stylesheet_tag("css/utility.css"); + echo stylesheet_tag("lib/dijit/themes/claro/claro.css"); + echo stylesheet_tag("css/default.css"); echo javascript_tag("lib/prototype.js"); print " - "; + "; print ''; print "

".__("Password recovery")."

"; print "
"; - @$method = $_POST['method']; + @$method = clean($_POST['method']); if ($hash) { - $login = $_REQUEST["login"]; + $login = clean($_REQUEST["login"]); if ($login) { $sth = $this->pdo->prepare("SELECT id, resetpass_token FROM ttrss_users @@ -708,17 +730,17 @@ class Handler_Public extends Handler { print "
"; print ""; - print ""; + print ""; print "
"; print "
"; print ""; - print ""; + print ""; print "
"; print "
"; print ""; - print ""; + print ""; print "
"; print "

"; @@ -727,9 +749,9 @@ class Handler_Public extends Handler { print ""; } else if ($method == 'do') { - $login = $_POST["login"]; - $email = $_POST["email"]; - $test = $_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.')); @@ -832,7 +854,7 @@ class Handler_Public extends Handler { Database Updater - + @@ -840,7 +862,7 @@ class Handler_Public extends Handler { span.ok { color : #009000; font-weight : bold; } span.err { color : #ff0000; font-weight : bold; } - +