@@ -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,20 +63,20 @@ 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 | if (self::isPHPModule()) { |
| 68 | 68 | $path = $tmp_dir; |
| 69 | 69 | } else { |
| 70 | - $document_root_path = rtrim($_SERVER[ 'DOCUMENT_ROOT' ], '/') . '/../'; |
|
| 71 | - $path = isset($_SERVER[ 'DOCUMENT_ROOT' ]) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . DIRECTORY_SEPARATOR; |
|
| 70 | + $document_root_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/../'; |
|
| 71 | + $path = isset($_SERVER['DOCUMENT_ROOT']) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . DIRECTORY_SEPARATOR; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ($this->config[ 'path' ] != '') { |
|
| 75 | - $path = $this->config[ 'path' ]; |
|
| 74 | + if ($this->config['path'] != '') { |
|
| 75 | + $path = $this->config['path']; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | } else { |
| 79 | - $path = $this->config[ 'path' ]; |
|
| 79 | + $path = $this->config['path']; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $full_path = rtrim($path, '/') |
@@ -93,19 +93,19 @@ discard block |
||
| 93 | 93 | * return the temp dir |
| 94 | 94 | */ |
| 95 | 95 | if ($readonly === true) { |
| 96 | - if($this->config[ 'autoTmpFallback' ] && (@file_exists($full_path) || !@is_writable($full_path))){ |
|
| 96 | + if ($this->config['autoTmpFallback'] && (@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 97 | 97 | return $tmp_dir; |
| 98 | 98 | } |
| 99 | 99 | return $full_path; |
| 100 | - }else{ |
|
| 101 | - if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 100 | + } else { |
|
| 101 | + if (!isset($this->tmp[$full_path_hash]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 102 | 102 | if (!@file_exists($full_path)) { |
| 103 | 103 | @mkdir($full_path, $this->setChmodAuto(), true); |
| 104 | - }else if (!@is_writable($full_path)) { |
|
| 104 | + } else if (!@is_writable($full_path)) { |
|
| 105 | 105 | @chmod($full_path, $this->setChmodAuto()); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if ($this->config[ 'autoTmpFallback' ] && !@is_writable($full_path)) { |
|
| 108 | + if ($this->config['autoTmpFallback'] && !@is_writable($full_path)) { |
|
| 109 | 109 | /** |
| 110 | 110 | * Switch back to tmp dir |
| 111 | 111 | * again if the path is not writable |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | throw new phpFastCacheIOException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!'); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $this->tmp[ $full_path_hash ] = $full_path; |
|
| 129 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
| 128 | + $this->tmp[$full_path_hash] = $full_path; |
|
| 129 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
@@ -193,10 +193,10 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function setChmodAuto() |
| 195 | 195 | { |
| 196 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
| 196 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
| 197 | 197 | return 0777; |
| 198 | 198 | } else { |
| 199 | - return $this->config[ 'default_chmod' ]; |
|
| 199 | + return $this->config['default_chmod']; |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | if ($create === true) { |
| 227 | 227 | if (!is_writable($path)) { |
| 228 | 228 | try { |
| 229 | - if(!chmod($path, 0777)){ |
|
| 229 | + if (!chmod($path, 0777)) { |
|
| 230 | 230 | throw new phpFastCacheIOException('Chmod failed on : ' . $path); |
| 231 | 231 | } |
| 232 | 232 | } catch (phpFastCacheIOException $e) { |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | $this->eventManager->dispatch('CacheWriteFileOnDisk', $this, $file, $secureFileManipulation); |
| 299 | 299 | |
| 300 | - if($secureFileManipulation){ |
|
| 300 | + if ($secureFileManipulation) { |
|
| 301 | 301 | $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5( |
| 302 | 302 | str_shuffle(uniqid($this->getDriverName(), false)) |
| 303 | 303 | . str_shuffle(uniqid($this->getDriverName(), false)) |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | flock($f, LOCK_UN); |
| 310 | 310 | fclose($f); |
| 311 | 311 | |
| 312 | - if(!rename($tmpFilename, $file)){ |
|
| 312 | + if (!rename($tmpFilename, $file)) { |
|
| 313 | 313 | throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file)); |
| 314 | 314 | } |
| 315 | - }else{ |
|
| 315 | + } else { |
|
| 316 | 316 | $f = fopen($file, 'w+'); |
| 317 | 317 | $octetWritten = fwrite($f, $data); |
| 318 | 318 | fclose($f); |