diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-10-07 12:22:54 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2017-10-07 12:22:54 +0200 |
commit | 80b15f5d2db8b90fd9b29f94e6bd8652340df4f0 (patch) | |
tree | b4826cbb03c64b0e5ffb6d0a72f21e0f6b9d9ac8 /application/FileUtils.php | |
parent | 1ea88ae7d1b7fb13e18f543e7c2ad99c4ccde19a (diff) | |
parent | a01437f9e1e4fb5a098877b243828bf6f4936562 (diff) | |
download | Shaarli-80b15f5d2db8b90fd9b29f94e6bd8652340df4f0.tar.gz Shaarli-80b15f5d2db8b90fd9b29f94e6bd8652340df4f0.tar.zst Shaarli-80b15f5d2db8b90fd9b29f94e6bd8652340df4f0.zip |
Merge branch 'master' into v0.9
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 | } |