X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=classes%2Fhandler%2Fpublic.php;h=dbed3fee6f6b2e578a3f27b7713ba426914c4e2d;hb=253dbd48562f0742befe0335278c4e26ac313efe;hp=bd938cdbb51275ae6b251e2b970d08780833125b;hpb=09bc54c6901c5e4f6ec1d2a8b00fbf450aa258dd;p=tt-rss.git diff --git a/classes/handler/public.php b/classes/handler/public.php old mode 100644 new mode 100755 index bd938cdb..dbed3fee --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -33,6 +33,7 @@ class Handler_Public extends Handler { $date_sort_field = "updated DESC"; break; } + $params = array( "owner_uid" => $owner_uid, "feed" => $feed, @@ -47,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]); @@ -139,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"); @@ -219,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]); @@ -241,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"); @@ -267,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 = ?"); @@ -290,19 +310,19 @@ class Handler_Public extends Handler { } function rss() { - $feed = $_REQUEST["id"]; - $key = $_REQUEST["key"]; - $is_cat = $_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 = $_REQUEST["orig_guid"]; + $format = clean($_REQUEST['format']); + $orig_guid = clean($_REQUEST["orig_guid"]); if (!$format) $format = 'atom'; @@ -338,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); } @@ -359,16 +379,16 @@ class Handler_Public extends Handler { 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"]); @@ -378,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"])); ?> @@ -466,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); @@ -476,8 +496,6 @@ class Handler_Public extends Handler { session_set_cookie_params(0); } - @session_start(); - if (authenticate_user($login, $password)) { $_POST["password"] = ""; @@ -486,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 = ?"); @@ -501,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()); } @@ -516,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"; @@ -532,13 +556,12 @@ 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"; - print stylesheet_tag("css/utility.css"); print stylesheet_tag("css/default.css"); print " @@ -546,7 +569,7 @@ class Handler_Public extends Handler { - + \"Tiny

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

"; @@ -639,7 +662,7 @@ 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 @@ -657,10 +680,10 @@ class Handler_Public extends Handler { 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 @@ -726,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.')); @@ -853,7 +876,7 @@ class Handler_Public extends Handler {
load($plugin, PluginHost::KIND_USER, 0); $host->load_data();