diff options
author | tcit <tcit@tcit.fr> | 2014-03-26 17:19:57 +0100 |
---|---|---|
committer | tcit <tcit@tcit.fr> | 2014-03-26 17:19:57 +0100 |
commit | ad03eb6286f07074ffa8bd25950359cd670f3526 (patch) | |
tree | ce675c342b784c8f7e37340d4d23105626d8db71 /inc | |
parent | cc60cbbbabba932648cfe35ca1ae8b7ddba1186c (diff) | |
download | wallabag-ad03eb6286f07074ffa8bd25950359cd670f3526.tar.gz wallabag-ad03eb6286f07074ffa8bd25950359cd670f3526.tar.zst wallabag-ad03eb6286f07074ffa8bd25950359cd670f3526.zip |
Fix of #580 : Add some random for Windows hosts
Diffstat (limited to 'inc')
-rwxr-xr-x | inc/poche/Poche.class.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index c7aa71e8..a8cd5871 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -1122,7 +1122,13 @@ class Poche | |||
1122 | public function generateToken() | 1122 | public function generateToken() |
1123 | { | 1123 | { |
1124 | if (ini_get('open_basedir') === '') { | 1124 | if (ini_get('open_basedir') === '') { |
1125 | $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15); | 1125 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
1126 | echo 'This is a server using Windows!'; | ||
1127 | // alternative to /dev/urandom for Windows | ||
1128 | $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); | ||
1129 | } else { | ||
1130 | $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15); | ||
1131 | } | ||
1126 | } | 1132 | } |
1127 | else { | 1133 | else { |
1128 | $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); | 1134 | $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); |