diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-10-08 15:05:50 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2017-10-08 15:05:50 +0200 |
commit | b14dfc23dd8c4ab1c2cf5788c205a19bff0c1f84 (patch) | |
tree | b6bd2d066410bc8e6a09bbd057df728b5de1493e /application/FileUtils.php | |
parent | 2c049b673acdd10125db9c3c271eef5bd3f5fc17 (diff) | |
parent | ecccb14e2ab4e5f372ea9946b29995c3c7122a5c (diff) | |
download | Shaarli-b14dfc23dd8c4ab1c2cf5788c205a19bff0c1f84.tar.gz Shaarli-b14dfc23dd8c4ab1c2cf5788c205a19bff0c1f84.tar.zst Shaarli-b14dfc23dd8c4ab1c2cf5788c205a19bff0c1f84.zip |
Merge tag 'v0.9.2' into latest
Release v0.9.2
Diffstat (limited to 'application/FileUtils.php')
-rw-r--r-- | application/FileUtils.php | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/application/FileUtils.php b/application/FileUtils.php index a167f642..918cb83b 100644 --- a/application/FileUtils.php +++ b/application/FileUtils.php | |||
@@ -50,7 +50,8 @@ class FileUtils | |||
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Read data from a file containing Shaarli database format content. | 52 | * Read data from a file containing Shaarli database format content. |
53 | * If the file isn't readable or doesn't exists, default data will be returned. | 53 | * |
54 | * If the file isn't readable or doesn't exist, default data will be returned. | ||
54 | * | 55 | * |
55 | * @param string $file File path. | 56 | * @param string $file File path. |
56 | * @param mixed $default The default value to return if the file isn't readable. | 57 | * @param mixed $default The default value to return if the file isn't readable. |
@@ -61,16 +62,21 @@ class FileUtils | |||
61 | { | 62 | { |
62 | // Note that gzinflate is faster than gzuncompress. | 63 | // Note that gzinflate is faster than gzuncompress. |
63 | // See: http://www.php.net/manual/en/function.gzdeflate.php#96439 | 64 | // See: http://www.php.net/manual/en/function.gzdeflate.php#96439 |
64 | if (is_readable($file)) { | 65 | if (! is_readable($file)) { |
65 | return unserialize( | 66 | return $default; |
66 | gzinflate( | 67 | } |
67 | base64_decode( | 68 | |
68 | substr(file_get_contents($file), strlen(self::$phpPrefix), -strlen(self::$phpSuffix)) | 69 | $data = file_get_contents($file); |
69 | ) | 70 | if ($data == '') { |
70 | ) | 71 | return $default; |
71 | ); | ||
72 | } | 72 | } |
73 | 73 | ||
74 | return $default; | 74 | return unserialize( |
75 | gzinflate( | ||
76 | base64_decode( | ||
77 | substr($data, strlen(self::$phpPrefix), -strlen(self::$phpSuffix)) | ||
78 | ) | ||
79 | ) | ||
80 | ); | ||
75 | } | 81 | } |
76 | } | 82 | } |