@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | * Calculate the security key |
| 52 | 52 | */ |
| 53 | 53 | { |
| 54 | - $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
|
| 54 | + $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : ''; |
|
| 55 | 55 | if (!$securityKey || $securityKey === 'auto') { |
| 56 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
| 57 | - $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
|
| 56 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
| 57 | + $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST']))); |
|
| 58 | 58 | } else { |
| 59 | 59 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
| 60 | 60 | } |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | $tmp_dir = rtrim($tmp_dir, '/') . DIRECTORY_SEPARATOR; |
| 75 | 75 | |
| 76 | - if (empty($this->config[ 'path' ]) || !is_string($this->config[ 'path' ])) { |
|
| 76 | + if (empty($this->config['path']) || !is_string($this->config['path'])) { |
|
| 77 | 77 | $path = $tmp_dir; |
| 78 | 78 | } else { |
| 79 | - $path = rtrim($this->config[ 'path' ], '/') . DIRECTORY_SEPARATOR; |
|
| 79 | + $path = rtrim($this->config['path'], '/') . DIRECTORY_SEPARATOR; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $path_suffix = $securityKey . DIRECTORY_SEPARATOR . $this->getDriverName(); |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | * return the temp dir |
| 92 | 92 | */ |
| 93 | 93 | if ($readonly === true) { |
| 94 | - if($this->config[ 'autoTmpFallback' ] && (!@file_exists($full_path) || !@is_writable($full_path))){ |
|
| 94 | + if ($this->config['autoTmpFallback'] && (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 95 | 95 | return $full_path_tmp; |
| 96 | 96 | } |
| 97 | 97 | return $full_path; |
| 98 | - }else{ |
|
| 99 | - if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 98 | + } else { |
|
| 99 | + if (!isset($this->tmp[$full_path_hash]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 100 | 100 | if (!@file_exists($full_path)) { |
| 101 | 101 | @mkdir($full_path, $this->getDefaultChmod(), true); |
| 102 | - }else if (!@is_writable($full_path)) { |
|
| 103 | - if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config[ 'autoTmpFallback' ]) |
|
| 102 | + } else if (!@is_writable($full_path)) { |
|
| 103 | + if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config['autoTmpFallback']) |
|
| 104 | 104 | { |
| 105 | 105 | /** |
| 106 | 106 | * Switch back to tmp dir |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | throw new phpFastCacheIOException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!'); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $this->tmp[ $full_path_hash ] = $full_path; |
|
| 126 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
| 125 | + $this->tmp[$full_path_hash] = $full_path; |
|
| 126 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
@@ -180,10 +180,10 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | protected function getDefaultChmod() |
| 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); |