]> git.wh0rd.org Git - tt-rss.git/commitdiff
make published OPML use common secret key code
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 8 Nov 2010 16:36:24 +0000 (19:36 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 8 Nov 2010 16:36:24 +0000 (19:36 +0300)
functions.php
modules/backend-rpc.php
modules/popup-dialog.php
opml.php

index 508a36d4e8de1c22512a261145b0c6fb1c68c9c2..d7e1f258cf6a68720ec0efea1ac7f5b40e042cbb 100644 (file)
 
                $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;
        }
index cd1bcb84bdf46e070f43a9deaf6316144a477d07..7ccb30692bc7c1723c52cb6632be9b4837cb5731 100644 (file)
                if ($subop == "regenOPMLKey") {
 
                        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);            
                        print "<link><![CDATA[$new_link]]></link>";
                        print "</rpc-reply>";
index 77cf46edeac33c3dda4b3b7d077eca50133ab20a..d68bd1db71d5c31a2e905f2fce394754c8e71dc7 100644 (file)
                        print "<div id=\"infoBoxTitle\">".__('Public OPML URL')."</div>";
                        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);
 
                        print __("Your Public OPML URL is:");
index 35e36d24a351035e95a29ec8b000493620d3d172..98f4a95aa2f0c7c59f316d3c6dcef2acfa9ee076 100644 (file)
--- a/opml.php
+++ b/opml.php
        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 "<error>User not found</error>";
                }