aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tools/Utils.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-01-22 09:36:50 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-01-22 09:36:50 +0100
commit6c32aaae95caf6fcd6740fa1a78f8af31bb6370f (patch)
tree87a1f573e7b405f34588a91f87b9196810cdaa7a /src/Wallabag/CoreBundle/Tools/Utils.php
parent9aa66d6244935fe86a5598fbdbe518cf6204af2e (diff)
parent23afdf3a70a5035cb58b76138a8627701ba55273 (diff)
downloadwallabag-6c32aaae95caf6fcd6740fa1a78f8af31bb6370f.tar.gz
wallabag-6c32aaae95caf6fcd6740fa1a78f8af31bb6370f.tar.zst
wallabag-6c32aaae95caf6fcd6740fa1a78f8af31bb6370f.zip
Merge pull request #1614 from wallabag/v2-few-fixes
Few fixes
Diffstat (limited to 'src/Wallabag/CoreBundle/Tools/Utils.php')
-rw-r--r--src/Wallabag/CoreBundle/Tools/Utils.php15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/Wallabag/CoreBundle/Tools/Utils.php b/src/Wallabag/CoreBundle/Tools/Utils.php
index a16baca9..0c783110 100644
--- a/src/Wallabag/CoreBundle/Tools/Utils.php
+++ b/src/Wallabag/CoreBundle/Tools/Utils.php
@@ -7,20 +7,13 @@ class Utils
7 /** 7 /**
8 * Generate a token used for RSS. 8 * Generate a token used for RSS.
9 * 9 *
10 * @param int $length Length of the token
11 *
10 * @return string 12 * @return string
11 */ 13 */
12 public static function generateToken() 14 public static function generateToken($length = 15)
13 { 15 {
14 if (ini_get('open_basedir') === '') { 16 $token = substr(base64_encode(random_bytes($length)), 0, $length);
15 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
16 // alternative to /dev/urandom for Windows
17 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
18 } else {
19 $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15);
20 }
21 } else {
22 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
23 }
24 17
25 // remove character which can broken the url 18 // remove character which can broken the url
26 return str_replace(array('+', '/'), '', $token); 19 return str_replace(array('+', '/'), '', $token);