make published OPML use common secret key code

This commit is contained in:
Andrew Dolgov 2010-11-08 19:36:24 +03:00
parent f29033f86c
commit 2e7f046f65
4 changed files with 10 additions and 14 deletions

View File

@ -5763,7 +5763,7 @@
$url_path = get_self_url_prefix(); $url_path = get_self_url_prefix();
$url_path .= "/opml.php?op=publish&key=" . $url_path .= "/opml.php?op=publish&key=" .
get_pref($link, "_PREFS_PUBLISH_KEY", $_SESSION["uid"]); get_feed_access_key($link, 'OPML:Publish', false, $_SESSION["uid"]);
return $url_path; return $url_path;
} }

View File

@ -467,8 +467,10 @@
if ($subop == "regenOPMLKey") { if ($subop == "regenOPMLKey") {
print "<rpc-reply>"; print "<rpc-reply>";
set_pref($link, "_PREFS_PUBLISH_KEY",
sha1(uniqid(rand(), true)), $_SESSION["uid"]); update_feed_access_key($link, 'OPML:Publish',
false, $_SESSION["uid"]);
$new_link = opml_publish_url($link); $new_link = opml_publish_url($link);
print "<link><![CDATA[$new_link]]></link>"; print "<link><![CDATA[$new_link]]></link>";
print "</rpc-reply>"; print "</rpc-reply>";

View File

@ -163,10 +163,6 @@
print "<div id=\"infoBoxTitle\">".__('Public OPML URL')."</div>"; print "<div id=\"infoBoxTitle\">".__('Public OPML URL')."</div>";
print "<div class=\"infoBoxContents\">"; print "<div class=\"infoBoxContents\">";
if (!get_pref($link, "_PREFS_PUBLISH_KEY"))
set_pref($link, "_PREFS_PUBLISH_KEY",
sha1(uniqid(rand(), true)));
$url_path = opml_publish_url($link); $url_path = opml_publish_url($link);
print __("Your Public OPML URL is:"); print __("Your Public OPML URL is:");

View File

@ -134,15 +134,13 @@
if ($op == "publish"){ if ($op == "publish"){
$key = db_escape_string($_REQUEST["key"]); $key = db_escape_string($_REQUEST["key"]);
$result = db_query($link, "SELECT login, owner_uid $result = db_query($link, "SELECT owner_uid
FROM ttrss_user_prefs, ttrss_users WHERE FROM ttrss_access_keys WHERE
pref_name = '_PREFS_PUBLISH_KEY' AND access_key = '$key' AND feed_id = 'OPML:Publish'");
value = '$key' AND
ttrss_users.id = owner_uid");
if (db_num_rows($result) == 1) { if (db_num_rows($result) == 1) {
$owner = db_fetch_result($result, 0, "owner_uid"); $owner_uid = db_fetch_result($result, 0, "owner_uid");
return opml_export($link, $owner, true, false); return opml_export($link, $owner_uid, true, false);
} else { } else {
print "<error>User not found</error>"; print "<error>User not found</error>";
} }