@@ -185,9 +185,9 @@ |
||
185 | 185 | protected static function cleanFileName($filename) |
186 | 186 | { |
187 | 187 | $regex = [ |
188 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
189 | - '/\.$/', |
|
190 | - '/^\./', |
|
188 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
189 | + '/\.$/', |
|
190 | + '/^\./', |
|
191 | 191 | ]; |
192 | 192 | $replace = ['-', '', '']; |
193 | 193 |
@@ -34,30 +34,30 @@ discard block |
||
34 | 34 | { |
35 | 35 | $tmp_dir = rtrim(ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(), '\\/') . DIRECTORY_SEPARATOR . 'phpfastcache'; |
36 | 36 | |
37 | - if (!isset($this->config[ 'path' ]) || $this->config[ 'path' ] == '') { |
|
37 | + if (!isset($this->config['path']) || $this->config['path'] == '') { |
|
38 | 38 | if (self::isPHPModule()) { |
39 | 39 | $path = $tmp_dir; |
40 | 40 | } else { |
41 | - $document_root_path = rtrim($_SERVER[ 'DOCUMENT_ROOT' ], '/') . '/../'; |
|
42 | - $path = isset($_SERVER[ 'DOCUMENT_ROOT' ]) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . '/'; |
|
41 | + $document_root_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/../'; |
|
42 | + $path = isset($_SERVER['DOCUMENT_ROOT']) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . '/'; |
|
43 | 43 | } |
44 | 44 | |
45 | - if ($this->config[ 'path' ] != '') { |
|
46 | - $path = $this->config[ 'path' ]; |
|
45 | + if ($this->config['path'] != '') { |
|
46 | + $path = $this->config['path']; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | } else { |
50 | - $path = $this->config[ 'path' ]; |
|
50 | + $path = $this->config['path']; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | if ($getBasePath === true) { |
54 | 54 | return $path; |
55 | 55 | } |
56 | 56 | |
57 | - $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
|
57 | + $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : ''; |
|
58 | 58 | if (!$securityKey || $securityKey === 'auto') { |
59 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
60 | - $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
|
59 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
60 | + $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST']))); |
|
61 | 61 | } else { |
62 | 62 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
63 | 63 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $full_pathx = md5($full_path); |
74 | 74 | |
75 | 75 | |
76 | - if (!isset($this->tmp[ $full_pathx ])) { |
|
76 | + if (!isset($this->tmp[$full_pathx])) { |
|
77 | 77 | |
78 | 78 | if (!@file_exists($full_path) || !@is_writable($full_path)) { |
79 | 79 | if (!@file_exists($full_path)) { |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - $this->tmp[ $full_pathx ] = true; |
|
101 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
100 | + $this->tmp[$full_pathx] = true; |
|
101 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | return realpath($full_path); |
@@ -171,10 +171,10 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function setChmodAuto() |
173 | 173 | { |
174 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
174 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
175 | 175 | return 0777; |
176 | 176 | } else { |
177 | - return $this->config[ 'default_chmod' ]; |
|
177 | + return $this->config['default_chmod']; |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | if ($create === true) { |
205 | 205 | if (!is_writable($path)) { |
206 | 206 | try { |
207 | - if(!chmod($path, 0777)){ |
|
207 | + if (!chmod($path, 0777)) { |
|
208 | 208 | throw new phpFastCacheDriverException('Chmod failed on : ' . $path); |
209 | 209 | } |
210 | 210 | } catch (phpFastCacheDriverException $e) { |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | * @var array |
52 | 52 | */ |
53 | 53 | protected static $config = [ |
54 | - 'securityKey' => 'auto',// The securityKey that will be used to create sub-directory |
|
55 | - 'htaccess' => true,// Auto-generate .htaccess if tit is missing |
|
56 | - 'default_chmod' => 0777, // 0777 recommended |
|
57 | - 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
58 | - 'fallback' => false, //Fall back when old driver is not support |
|
59 | - 'limited_memory_each_object' => 4096, // maximum size (bytes) of object store in memory |
|
60 | - 'compress_data' => false, // compress stored data, if the backend supports it |
|
54 | + 'securityKey' => 'auto',// The securityKey that will be used to create sub-directory |
|
55 | + 'htaccess' => true,// Auto-generate .htaccess if tit is missing |
|
56 | + 'default_chmod' => 0777, // 0777 recommended |
|
57 | + 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
58 | + 'fallback' => false, //Fall back when old driver is not support |
|
59 | + 'limited_memory_each_object' => 4096, // maximum size (bytes) of object store in memory |
|
60 | + 'compress_data' => false, // compress stored data, if the backend supports it |
|
61 | 61 | ]; |
62 | 62 | |
63 | 63 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | } |
107 | 107 | } else if(++$badPracticeOmeter[$driver] >= 5){ |
108 | - trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
|
108 | + trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
|
109 | 109 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
110 | 110 | } |
111 | 111 | |
@@ -218,21 +218,21 @@ discard block |
||
218 | 218 | public static function getStaticSystemDrivers() |
219 | 219 | { |
220 | 220 | return [ |
221 | - 'Sqlite', |
|
222 | - 'Files', |
|
223 | - 'Apc', |
|
224 | - 'Apcu', |
|
225 | - 'Memcache', |
|
226 | - 'Memcached', |
|
227 | - 'Couchbase', |
|
228 | - 'Mongodb', |
|
229 | - 'Predis', |
|
230 | - 'Redis', |
|
231 | - 'Ssdb', |
|
232 | - 'Leveldb', |
|
233 | - 'Wincache', |
|
234 | - 'Xcache', |
|
235 | - 'Devnull', |
|
221 | + 'Sqlite', |
|
222 | + 'Files', |
|
223 | + 'Apc', |
|
224 | + 'Apcu', |
|
225 | + 'Memcache', |
|
226 | + 'Memcached', |
|
227 | + 'Couchbase', |
|
228 | + 'Mongodb', |
|
229 | + 'Predis', |
|
230 | + 'Redis', |
|
231 | + 'Ssdb', |
|
232 | + 'Leveldb', |
|
233 | + 'Wincache', |
|
234 | + 'Xcache', |
|
235 | + 'Devnull', |
|
236 | 236 | ]; |
237 | 237 | } |
238 | 238 |