@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | * Calculate the security key |
| 42 | 42 | */ |
| 43 | 43 | { |
| 44 | - $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
|
| 44 | + $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : ''; |
|
| 45 | 45 | if (!$securityKey || $securityKey === 'auto') { |
| 46 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
| 47 | - $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
|
| 46 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
| 47 | + $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST']))); |
|
| 48 | 48 | } else { |
| 49 | 49 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
| 50 | 50 | } |
@@ -63,10 +63,10 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | $tmp_dir = rtrim($tmp_dir, '/') . DIRECTORY_SEPARATOR; |
| 65 | 65 | |
| 66 | - if (empty($this->config[ 'path' ]) || !is_string($this->config[ 'path' ])) { |
|
| 66 | + if (empty($this->config['path']) || !is_string($this->config['path'])) { |
|
| 67 | 67 | $path = $tmp_dir; |
| 68 | 68 | } else { |
| 69 | - $path = rtrim($this->config[ 'path' ], '/') . DIRECTORY_SEPARATOR; |
|
| 69 | + $path = rtrim($this->config['path'], '/') . DIRECTORY_SEPARATOR; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $path_suffix = $securityKey . DIRECTORY_SEPARATOR . $this->getDriverName(); |
@@ -81,16 +81,16 @@ discard block |
||
| 81 | 81 | * return the temp dir |
| 82 | 82 | */ |
| 83 | 83 | if ($readonly === true) { |
| 84 | - if($this->config[ 'autoTmpFallback' ] && (!@file_exists($full_path) || !@is_writable($full_path))){ |
|
| 84 | + if ($this->config['autoTmpFallback'] && (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 85 | 85 | return $full_path_tmp; |
| 86 | 86 | } |
| 87 | 87 | return $full_path; |
| 88 | - }else{ |
|
| 89 | - if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 88 | + } else { |
|
| 89 | + if (!isset($this->tmp[$full_path_hash]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 90 | 90 | if (!@file_exists($full_path)) { |
| 91 | 91 | @mkdir($full_path, $this->setChmodAuto(), true); |
| 92 | - }else if (!@is_writable($full_path)) { |
|
| 93 | - if (!@chmod($full_path, $this->setChmodAuto()) && $this->config[ 'autoTmpFallback' ]) |
|
| 92 | + } else if (!@is_writable($full_path)) { |
|
| 93 | + if (!@chmod($full_path, $this->setChmodAuto()) && $this->config['autoTmpFallback']) |
|
| 94 | 94 | { |
| 95 | 95 | /** |
| 96 | 96 | * Switch back to tmp dir |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | throw new phpFastCacheIOException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!'); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $this->tmp[ $full_path_hash ] = $full_path; |
|
| 116 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
| 115 | + $this->tmp[$full_path_hash] = $full_path; |
|
| 116 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -180,10 +180,10 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function setChmodAuto() |
| 182 | 182 | { |
| 183 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
| 183 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
| 184 | 184 | return 0777; |
| 185 | 185 | } else { |
| 186 | - return $this->config[ 'default_chmod' ]; |
|
| 186 | + return $this->config['default_chmod']; |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | if ($create === true) { |
| 214 | 214 | if (!is_writable($path)) { |
| 215 | 215 | try { |
| 216 | - if(!chmod($path, 0777)){ |
|
| 216 | + if (!chmod($path, 0777)) { |
|
| 217 | 217 | throw new phpFastCacheIOException('Chmod failed on : ' . $path); |
| 218 | 218 | } |
| 219 | 219 | } catch (phpFastCacheIOException $e) { |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | $this->eventManager->dispatch('CacheWriteFileOnDisk', $this, $file, $secureFileManipulation); |
| 286 | 286 | |
| 287 | - if($secureFileManipulation){ |
|
| 287 | + if ($secureFileManipulation) { |
|
| 288 | 288 | $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5( |
| 289 | 289 | str_shuffle(uniqid($this->getDriverName(), false)) |
| 290 | 290 | . str_shuffle(uniqid($this->getDriverName(), false)) |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | flock($f, LOCK_UN); |
| 297 | 297 | fclose($f); |
| 298 | 298 | |
| 299 | - if(!rename($tmpFilename, $file)){ |
|
| 299 | + if (!rename($tmpFilename, $file)) { |
|
| 300 | 300 | throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file)); |
| 301 | 301 | } |
| 302 | - }else{ |
|
| 302 | + } else { |
|
| 303 | 303 | $f = fopen($file, 'w+'); |
| 304 | 304 | $octetWritten = fwrite($f, $data); |
| 305 | 305 | fclose($f); |