mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-22 03:11:28 +00:00
support for feed http auth
This commit is contained in:
38
backend.php
38
backend.php
@@ -1425,8 +1425,8 @@
|
|||||||
|
|
||||||
if ($op == "pref-feeds") {
|
if ($op == "pref-feeds") {
|
||||||
|
|
||||||
$subop = $_GET["subop"];
|
$subop = $_REQUEST["subop"];
|
||||||
$quiet = $_GET["quiet"];
|
$quiet = $_REQUEST["quiet"];
|
||||||
|
|
||||||
if ($subop == "editfeed") {
|
if ($subop == "editfeed") {
|
||||||
$feed_id = db_escape_string($_GET["id"]);
|
$feed_id = db_escape_string($_GET["id"]);
|
||||||
@@ -1513,6 +1513,22 @@
|
|||||||
print "<td><input id=\"iedit_purgintl\"
|
print "<td><input id=\"iedit_purgintl\"
|
||||||
value=\"$purge_interval\"></td></tr>";
|
value=\"$purge_interval\"></td></tr>";
|
||||||
|
|
||||||
|
// print "<tr><td colspan=\"2\"><b>Authentication</b></td></tr>";
|
||||||
|
|
||||||
|
$row_class = toggleEvenOdd($row_class);
|
||||||
|
$auth_login = db_fetch_result($result, 0, "auth_login");
|
||||||
|
|
||||||
|
print "<tr class='$row_class'><td>Login:</td>";
|
||||||
|
print "<td><input id=\"iedit_login\"
|
||||||
|
value=\"$auth_login\"></td></tr>";
|
||||||
|
|
||||||
|
$row_class = toggleEvenOdd($row_class);
|
||||||
|
$auth_pass = db_fetch_result($result, 0, "auth_pass");
|
||||||
|
|
||||||
|
print "<tr class='$row_class'><td>Password:</td>";
|
||||||
|
print "<td><input type=\"password\" id=\"iedit_pass\"
|
||||||
|
value=\"$auth_pass\"></td></tr>";
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|
||||||
@@ -1525,12 +1541,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($subop == "editSave") {
|
if ($subop == "editSave") {
|
||||||
$feed_title = db_escape_string($_GET["t"]);
|
$feed_title = db_escape_string($_POST["t"]);
|
||||||
$feed_link = db_escape_string($_GET["l"]);
|
$feed_link = db_escape_string($_POST["l"]);
|
||||||
$upd_intl = db_escape_string($_GET["ui"]);
|
$upd_intl = db_escape_string($_POST["ui"]);
|
||||||
$purge_intl = db_escape_string($_GET["pi"]);
|
$purge_intl = db_escape_string($_POST["pi"]);
|
||||||
$feed_id = db_escape_string($_GET["id"]);
|
$feed_id = db_escape_string($_POST["id"]);
|
||||||
$cat_id = db_escape_string($_GET["catid"]);
|
$cat_id = db_escape_string($_POST["catid"]);
|
||||||
|
$auth_login = db_escape_string($_POST["login"]);
|
||||||
|
$auth_pass = db_escape_string($_POST["pass"]);
|
||||||
|
|
||||||
if (strtoupper($upd_intl) == "DEFAULT")
|
if (strtoupper($upd_intl) == "DEFAULT")
|
||||||
$upd_intl = 0;
|
$upd_intl = 0;
|
||||||
@@ -1554,7 +1572,9 @@
|
|||||||
$category_qpart,
|
$category_qpart,
|
||||||
title = '$feed_title', feed_url = '$feed_link',
|
title = '$feed_title', feed_url = '$feed_link',
|
||||||
update_interval = '$upd_intl',
|
update_interval = '$upd_intl',
|
||||||
purge_interval = '$purge_intl'
|
purge_interval = '$purge_intl',
|
||||||
|
auth_login = '$auth_login',
|
||||||
|
auth_pass = '$auth_pass'
|
||||||
WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
|
WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,17 +169,31 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = db_query($link, "SELECT update_interval
|
$result = db_query($link, "SELECT update_interval,auth_login,auth_pass
|
||||||
FROM ttrss_feeds WHERE id = '$feed'");
|
FROM ttrss_feeds WHERE id = '$feed'");
|
||||||
|
|
||||||
|
$auth_login = db_fetch_result($result, 0, "auth_login");
|
||||||
|
$auth_pass = db_fetch_result($result, 0, "auth_pass");
|
||||||
|
|
||||||
$update_interval = db_fetch_result($result, 0, "update_interval");
|
$update_interval = db_fetch_result($result, 0, "update_interval");
|
||||||
|
|
||||||
if ($update_interval < 0) { return; }
|
if ($update_interval < 0) { return; }
|
||||||
|
|
||||||
$feed = db_escape_string($feed);
|
$feed = db_escape_string($feed);
|
||||||
|
|
||||||
|
$fetch_url = $feed_url;
|
||||||
|
|
||||||
|
if ($auth_login && $auth_pass) {
|
||||||
|
$url_parts = array();
|
||||||
|
preg_match("/(^[^:]*):\/\/(.*)/", $fetch_url, $url_parts);
|
||||||
|
|
||||||
|
if ($url_parts[1] && $url_parts[2]) {
|
||||||
|
$fetch_url = $url_parts[1] . "://$auth_login:$auth_pass@" . $url_parts[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
$rss = fetch_rss($feed_url);
|
$rss = fetch_rss($fetch_url);
|
||||||
|
|
||||||
error_reporting (DEFAULT_ERROR_LEVEL);
|
error_reporting (DEFAULT_ERROR_LEVEL);
|
||||||
|
|
||||||
|
|||||||
134
prefs.js
134
prefs.js
@@ -29,21 +29,25 @@ if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
|
|||||||
|
|
||||||
function feedlist_callback() {
|
function feedlist_callback() {
|
||||||
if (xmlhttp.readyState == 4) {
|
if (xmlhttp.readyState == 4) {
|
||||||
var container = document.getElementById('prefContent');
|
try {
|
||||||
container.innerHTML=xmlhttp.responseText;
|
var container = document.getElementById('prefContent');
|
||||||
if (active_feed) {
|
container.innerHTML=xmlhttp.responseText;
|
||||||
var row = document.getElementById("FEEDR-" + active_feed);
|
if (active_feed) {
|
||||||
if (row) {
|
var row = document.getElementById("FEEDR-" + active_feed);
|
||||||
if (!row.className.match("Selected")) {
|
if (row) {
|
||||||
row.className = row.className + "Selected";
|
if (!row.className.match("Selected")) {
|
||||||
}
|
row.className = row.className + "Selected";
|
||||||
}
|
}
|
||||||
var checkbox = document.getElementById("FRCHK-" + active_feed);
|
}
|
||||||
if (checkbox) {
|
var checkbox = document.getElementById("FRCHK-" + active_feed);
|
||||||
checkbox.checked = true;
|
if (checkbox) {
|
||||||
|
checkbox.checked = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
p_notify("");
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("feedlist_callback", e);
|
||||||
}
|
}
|
||||||
p_notify("");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,54 +658,66 @@ function feedCatEditCancel() {
|
|||||||
|
|
||||||
function feedEditSave() {
|
function feedEditSave() {
|
||||||
|
|
||||||
var feed = active_feed;
|
try {
|
||||||
|
|
||||||
if (!xmlhttp_ready(xmlhttp)) {
|
var feed = active_feed;
|
||||||
printLockingError();
|
|
||||||
return
|
if (!xmlhttp_ready(xmlhttp)) {
|
||||||
|
printLockingError();
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var link = document.getElementById("iedit_link").value;
|
||||||
|
var title = document.getElementById("iedit_title").value;
|
||||||
|
var upd_intl = document.getElementById("iedit_updintl").value;
|
||||||
|
var purge_intl = document.getElementById("iedit_purgintl").value;
|
||||||
|
var fcat = document.getElementById("iedit_fcat");
|
||||||
|
|
||||||
|
var fcat_id = fcat[fcat.selectedIndex].id;
|
||||||
|
|
||||||
|
// notify("Saving feed.");
|
||||||
|
|
||||||
|
/* if (upd_intl < 0) {
|
||||||
|
notify("Update interval must be >= 0 (0 = default)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (purge_intl < 0) {
|
||||||
|
notify("Purge days must be >= 0 (0 = default)");
|
||||||
|
return;
|
||||||
|
} */
|
||||||
|
|
||||||
|
if (link.length == 0) {
|
||||||
|
notify("Feed link cannot be blank.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (title.length == 0) {
|
||||||
|
notify("Feed title cannot be blank.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var auth_login = document.getElementById("iedit_login").value;
|
||||||
|
var auth_pass = document.getElementById("iedit_pass").value;
|
||||||
|
|
||||||
|
active_feed = false;
|
||||||
|
|
||||||
|
notify("Saving feed...");
|
||||||
|
|
||||||
|
var query = "op=pref-feeds&subop=editSave&id=" +
|
||||||
|
feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
|
||||||
|
"&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
|
||||||
|
"&catid=" + param_escape(fcat_id) + "&login=" + param_escape(auth_login) +
|
||||||
|
"&pass=" + param_escape(auth_pass);
|
||||||
|
|
||||||
|
xmlhttp.open("POST", "backend.php", true);
|
||||||
|
xmlhttp.onreadystatechange=feedlist_callback;
|
||||||
|
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
xmlhttp.send(query);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("feedEditSave", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
var link = document.getElementById("iedit_link").value;
|
|
||||||
var title = document.getElementById("iedit_title").value;
|
|
||||||
var upd_intl = document.getElementById("iedit_updintl").value;
|
|
||||||
var purge_intl = document.getElementById("iedit_purgintl").value;
|
|
||||||
var fcat = document.getElementById("iedit_fcat");
|
|
||||||
|
|
||||||
var fcat_id = fcat[fcat.selectedIndex].id;
|
|
||||||
|
|
||||||
// notify("Saving feed.");
|
|
||||||
|
|
||||||
/* if (upd_intl < 0) {
|
|
||||||
notify("Update interval must be >= 0 (0 = default)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (purge_intl < 0) {
|
|
||||||
notify("Purge days must be >= 0 (0 = default)");
|
|
||||||
return;
|
|
||||||
} */
|
|
||||||
|
|
||||||
if (link.length == 0) {
|
|
||||||
notify("Feed link cannot be blank.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (title.length == 0) {
|
|
||||||
notify("Feed title cannot be blank.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
active_feed = false;
|
|
||||||
|
|
||||||
notify("Saving feed...");
|
|
||||||
|
|
||||||
xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
|
|
||||||
feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
|
|
||||||
"&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
|
|
||||||
"&catid=" + param_escape(fcat_id), true);
|
|
||||||
xmlhttp.onreadystatechange=feedlist_callback;
|
|
||||||
xmlhttp.send(null);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function feedCatEditSave() {
|
function feedCatEditSave() {
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ a:hover {
|
|||||||
|
|
||||||
#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl,
|
#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl,
|
||||||
#iedit_purgintl, #iedit_ulogin, #iedit_ulevel, #iedit_match, #iedit_feed,
|
#iedit_purgintl, #iedit_ulogin, #iedit_ulevel, #iedit_match, #iedit_feed,
|
||||||
#iedit_fcat, #iedit_filter_action {
|
#iedit_fcat, #iedit_filter_action, #iedit_login, #iedit_pass {
|
||||||
width : 100%;
|
width : 100%;
|
||||||
padding-left : 2px;
|
padding-left : 2px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user