From f27de5153111f07ecfa6204baa2b77c93b48a09d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 25 Apr 2007 16:00:08 +0100 Subject: [PATCH] add auth support to subscribe-to-feed dialog --- functions.js | 11 ++++++++++- functions.php | 10 ++++++---- modules/popup-dialog.php | 13 +++++++++++++ modules/pref-feeds.php | 13 +++++++++---- tt-rss.css | 4 ++++ 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/functions.js b/functions.js index 7fe79c9a8..b26f75fd8 100644 --- a/functions.js +++ b/functions.js @@ -1252,11 +1252,18 @@ function getRelativeFeedId(list, id, direction, unread_only) { } } -function showBlockElement(id) { +function showBlockElement(id, h_id) { var elem = document.getElementById(id); if (elem) { elem.style.display = "block"; + + if (h_id) { + elem = document.getElementById(h_id); + if (elem) { + elem.style.display = "none"; + } + } } else { alert("[showBlockElement] can't find element with id " + id); } @@ -1437,6 +1444,8 @@ function qaddFeed() { var query = Form.serialize("feed_add_form"); + debug("subscribe q: " + query); + /* xmlhttp.open("GET", "backend.php?" + query, true); xmlhttp.onreadystatechange=dlg_frefresh_callback; xmlhttp.send(null); */ diff --git a/functions.php b/functions.php index 4044639a5..dee0d08c3 100644 --- a/functions.php +++ b/functions.php @@ -2023,7 +2023,8 @@ print ""; } - function subscribe_to_feed($link, $feed_link, $cat_id = 0) { + function subscribe_to_feed($link, $feed_link, $cat_id = 0, + $auth_login = '', $auth_pass = '') { # check for feed:http://url $feed_link = trim(preg_replace("/^feed:/", "", $feed_link)); @@ -2048,13 +2049,14 @@ if (db_num_rows($result) == 0) { $result = db_query($link, - "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) + "INSERT INTO ttrss_feeds + (owner_uid,feed_url,title,cat_id, auth_login,auth_pass) VALUES ('".$_SESSION["uid"]."', '$feed_link', - '[Unknown]', $cat_qpart)"); + '[Unknown]', $cat_qpart, '$auth_login', '$auth_pass')"); $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link' - AND owner_uid = " . $_SESSION["uid"]); + AND owner_uid = " . $_SESSION["uid"]); $feed_id = db_fetch_result($result, 0, "id"); diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index b69d36e2f..7eab1bae7 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -72,6 +72,19 @@ print ""; */ print ""; + + print "

+ Click here if this feed requires authentication.
"; + + print "
+ + + +
Login:
Password:
+
"; + print ""; print "
diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index 61fc2167c..c11ce2aa3 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -425,9 +425,14 @@ if (!WEB_DEMO_MODE) { - $feed_url = db_escape_string(trim($_POST["feed_url"])); - $cat_id = db_escape_string($_POST["cat_id"]); - $p_from = db_escape_string($_POST["from"]); + $feed_url = db_escape_string(trim($_REQUEST["feed_url"])); + $cat_id = db_escape_string($_REQUEST["cat_id"]); + $p_from = db_escape_string($_REQUEST["from"]); + + /* only read authentication information from POST */ + + $auth_login = db_escape_string(trim($_POST["auth_login"])); + $auth_pass = db_escape_string(trim($_POST["auth_pass"])); if ($p_from != 'tt-rss') { print " @@ -442,7 +447,7 @@
"; } - if (subscribe_to_feed($link, $feed_url, $cat_id)) { + if (subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass)) { print_notice(T_sprintf("Subscribed to %s.", $feed_url)); } else { print_warning(T_sprintf("Already subscribed to %s.", $feed_url)); diff --git a/tt-rss.css b/tt-rss.css index 94a99b304..0162638ba 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -1502,3 +1502,7 @@ a.helpLinkPic { a.helpLinkPic img { border-width : 0px; } + +#fadd_login_container { + display : none; +}