aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Tools.class.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2014-07-12 19:01:11 +0200
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2014-07-12 19:01:11 +0200
commit2f26729c841a68669a1baf799091cb2c6c9f585a (patch)
treee1e388bb73c7533aad85bf1f672f867b62b247e4 /inc/poche/Tools.class.php
parentb6a3c8866a4cb88b009e7ba45c5e223e0fdae188 (diff)
downloadwallabag-2f26729c841a68669a1baf799091cb2c6c9f585a.tar.gz
wallabag-2f26729c841a68669a1baf799091cb2c6c9f585a.tar.zst
wallabag-2f26729c841a68669a1baf799091cb2c6c9f585a.zip
Refactor
Diffstat (limited to 'inc/poche/Tools.class.php')
-rwxr-xr-xinc/poche/Tools.class.php41
1 files changed, 36 insertions, 5 deletions
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php
index 762e4446..63137d76 100755
--- a/inc/poche/Tools.class.php
+++ b/inc/poche/Tools.class.php
@@ -10,11 +10,6 @@
10 10
11final class Tools 11final class Tools
12{ 12{
13 private function __construct()
14 {
15
16 }
17
18 /** 13 /**
19 * Initialize PHP environment 14 * Initialize PHP environment
20 */ 15 */
@@ -393,4 +388,40 @@ final class Tools
393 return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest'; 388 return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest';
394 } 389 }
395 390
391 /*
392 * Empty cache folder
393 */
394 public static function emptyCache()
395 {
396 $files = new RecursiveIteratorIterator(
397 new RecursiveDirectoryIterator(CACHE, RecursiveDirectoryIterator::SKIP_DOTS),
398 RecursiveIteratorIterator::CHILD_FIRST
399 );
400
401 foreach ($files as $fileInfo) {
402 $todo = ($fileInfo->isDir() ? 'rmdir' : 'unlink');
403 $todo($fileInfo->getRealPath());
404 }
405
406 Tools::logm('empty cache');
407 Tools::redirect();
408 }
409
410 public static function generateToken()
411 {
412 if (ini_get('open_basedir') === '') {
413 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
414 // alternative to /dev/urandom for Windows
415 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
416 } else {
417 $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15);
418 }
419 }
420 else {
421 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
422 }
423
424 return str_replace('+', '', $token);
425 }
426
396} 427}