]> git.wh0rd.org Git - tt-rss.git/commitdiff
add one catchall function to make uniqids/keyhashes/etc used by tt-rss
authorAndrew Dolgov <noreply@fakecake.org>
Mon, 3 Aug 2015 16:21:06 +0000 (19:21 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Mon, 3 Aug 2015 16:21:06 +0000 (19:21 +0300)
classes/pref/feeds.php
include/functions.php
include/functions2.php
plugins/instances/init.php
plugins/share/init.php

index d70c1a26add83d7d2e88751c58b4d24946a4e8cc..efa2c2af9b4b11bcaae94b1011cd92dc5d7fd924 100644 (file)
@@ -1893,7 +1893,7 @@ class Pref_Feeds extends Handler_Protected {
                        AND owner_uid = " . $owner_uid);
 
                if ($this->dbh->num_rows($result) == 1) {
-                       $key = $this->dbh->escape_string(uniqid(base_convert(rand(), 10, 36)));
+                       $key = $this->dbh->escape_string(uniqid_short());
 
                        $this->dbh->query("UPDATE ttrss_access_keys SET access_key = '$key'
                                WHERE feed_id = '$feed_id' AND is_cat = $sql_is_cat
index c27455220bd77a43e39e05cb74d93f9a121f3b66..cecfaeada71199bf70384ab2b574e2c64dd0fa5c 100644 (file)
 
                                $_SESSION["name"] = db_fetch_result($result, 0, "login");
                                $_SESSION["access_level"] = db_fetch_result($result, 0, "access_level");
-                               $_SESSION["csrf_token"] = uniqid(rand(), true);
+                               $_SESSION["csrf_token"] = uniqid_short();
 
                                db_query("UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
                                        $_SESSION["uid"]);
                        $_SESSION["auth_module"] = false;
 
                        if (!$_SESSION["csrf_token"]) {
-                               $_SESSION["csrf_token"] = uniqid(rand(), true);
+                               $_SESSION["csrf_token"] = uniqid_short();
                        }
 
                        $_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"];
                }
        }
 
+       function uniqid_short() {
+               return uniqid(base_convert(rand(), 10, 36));
+       }
+
        // TODO: less dumb splitting
        require_once "functions2.php";
 
index 32c97aee41255be9d57c943a54d1f0ecd7d10103..df876851761943fb48feace2af7bb88956ff1dfe 100644 (file)
                if (db_num_rows($result) == 1) {
                        return db_fetch_result($result, 0, "access_key");
                } else {
-                       $key = db_escape_string(uniqid(base_convert(rand(), 10, 36)));
+                       $key = db_escape_string(uniqid_short());
 
                        $result = db_query("INSERT INTO ttrss_access_keys
                                (access_key, feed_id, is_cat, owner_uid)
index b23f45a0184331a15ee0637dedb8878eedfc2b65..947bc2a16e921dac1f080961aa16c655708515cc 100644 (file)
@@ -407,7 +407,7 @@ class Instances extends Plugin implements IHandler {
 
                print "<hr/>";
 
-               $access_key = uniqid(rand(), true);
+               $access_key = uniqid_short();
 
                /* Access key */
 
@@ -439,7 +439,7 @@ class Instances extends Plugin implements IHandler {
        }
 
        function genHash() {
-               $hash = uniqid(base_convert(rand(), 10, 36));
+               $hash = uniqid_short();
 
                print json_encode(array("hash" => $hash));
        }
index 899677c32e5d5bc40010f430c4b521acb2b2c1b0..bcc081897adde79b43dc29840935f096e21bf5ab 100644 (file)
@@ -60,7 +60,7 @@ class Share extends Plugin {
        function newkey() {
                $id = db_escape_string($_REQUEST['id']);
 
-               $uuid = db_escape_string(uniqid(base_convert(rand(), 10, 36)));
+               $uuid = db_escape_string(uniqid_short());
 
                db_query("UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$id'
                        AND owner_uid = " . $_SESSION['uid']);
@@ -91,7 +91,7 @@ class Share extends Plugin {
                        $ref_id = db_fetch_result($result, 0, "ref_id");
 
                        if (!$uuid) {
-                               $uuid = db_escape_string(uniqid(base_convert(rand(), 10, 36)));
+                               $uuid = db_escape_string(uniqid_short());
                                db_query("UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$param'
                                        AND owner_uid = " . $_SESSION['uid']);
                        }