From 2e7f046f65bd6d3a9417484bc4d6c9855cf39f7e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 8 Nov 2010 19:36:24 +0300 Subject: [PATCH] make published OPML use common secret key code --- functions.php | 2 +- modules/backend-rpc.php | 6 ++++-- modules/popup-dialog.php | 4 ---- opml.php | 12 +++++------- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/functions.php b/functions.php index 508a36d4..d7e1f258 100644 --- a/functions.php +++ b/functions.php @@ -5763,7 +5763,7 @@ $url_path = get_self_url_prefix(); $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; } diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index cd1bcb84..7ccb3069 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -467,8 +467,10 @@ if ($subop == "regenOPMLKey") { print ""; - 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); print ""; print ""; diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index 77cf46ed..d68bd1db 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -163,10 +163,6 @@ print "
".__('Public OPML URL')."
"; print "
"; - if (!get_pref($link, "_PREFS_PUBLISH_KEY")) - set_pref($link, "_PREFS_PUBLISH_KEY", - sha1(uniqid(rand(), true))); - $url_path = opml_publish_url($link); print __("Your Public OPML URL is:"); diff --git a/opml.php b/opml.php index 35e36d24..98f4a95a 100644 --- a/opml.php +++ b/opml.php @@ -134,15 +134,13 @@ if ($op == "publish"){ $key = db_escape_string($_REQUEST["key"]); - $result = db_query($link, "SELECT login, owner_uid - FROM ttrss_user_prefs, ttrss_users WHERE - pref_name = '_PREFS_PUBLISH_KEY' AND - value = '$key' AND - ttrss_users.id = owner_uid"); + $result = db_query($link, "SELECT owner_uid + FROM ttrss_access_keys WHERE + access_key = '$key' AND feed_id = 'OPML:Publish'"); if (db_num_rows($result) == 1) { - $owner = db_fetch_result($result, 0, "owner_uid"); - return opml_export($link, $owner, true, false); + $owner_uid = db_fetch_result($result, 0, "owner_uid"); + return opml_export($link, $owner_uid, true, false); } else { print "User not found"; } -- 2.39.5