diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-04-01 21:08:56 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-04-01 21:08:56 +0200 |
commit | 1a93ee423b072ec3bcb0c437cbf9b488bdea245c (patch) | |
tree | 1466dcb1b465f9ead71c4dcbefe380853c5d846b /src/Wallabag/CoreBundle/Tools/Utils.php | |
parent | f98a2a0fc3ae8a5955bb811f083c3d2535f96791 (diff) | |
parent | 7d74a2f32b55fa9c33f5ecff57785e8d9e4de8ae (diff) | |
download | wallabag-1a93ee423b072ec3bcb0c437cbf9b488bdea245c.tar.gz wallabag-1a93ee423b072ec3bcb0c437cbf9b488bdea245c.tar.zst wallabag-1a93ee423b072ec3bcb0c437cbf9b488bdea245c.zip |
Merge pull request #1166 from wallabag/v2-rss
Add RSS feeds
Diffstat (limited to 'src/Wallabag/CoreBundle/Tools/Utils.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Tools/Utils.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Tools/Utils.php b/src/Wallabag/CoreBundle/Tools/Utils.php new file mode 100644 index 00000000..de97c796 --- /dev/null +++ b/src/Wallabag/CoreBundle/Tools/Utils.php | |||
@@ -0,0 +1,27 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Tools; | ||
4 | |||
5 | class Utils | ||
6 | { | ||
7 | /** | ||
8 | * Generate a token used for RSS | ||
9 | * | ||
10 | * @return string | ||
11 | */ | ||
12 | public static function generateToken() | ||
13 | { | ||
14 | if (ini_get('open_basedir') === '') { | ||
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 | |||
25 | return str_replace('+', '', $token); | ||
26 | } | ||
27 | } | ||