@@ -47,42 +47,42 @@ discard block |
||
| 47 | 47 | * @var array |
| 48 | 48 | */ |
| 49 | 49 | public static $config = array( |
| 50 | - 'storage' => '', // blank for auto |
|
| 51 | - 'default_chmod' => 0777, // 0777 , 0666, 0644 |
|
| 50 | + 'storage' => '', // blank for auto |
|
| 51 | + 'default_chmod' => 0777, // 0777 , 0666, 0644 |
|
| 52 | 52 | |
| 53 | - 'overwrite' => "", // files, sqlite, etc it will overwrite ur storage and all other caching for waiting u fix ur server |
|
| 54 | - 'allow_search' => false, // turn to true will allow $method search("/regex/") |
|
| 53 | + 'overwrite' => "", // files, sqlite, etc it will overwrite ur storage and all other caching for waiting u fix ur server |
|
| 54 | + 'allow_search' => false, // turn to true will allow $method search("/regex/") |
|
| 55 | 55 | |
| 56 | - 'fallback' => 'files', //Fall back when old driver is not support |
|
| 56 | + 'fallback' => 'files', //Fall back when old driver is not support |
|
| 57 | 57 | |
| 58 | - 'securityKey' => 'auto', |
|
| 59 | - 'htaccess' => true, |
|
| 60 | - 'path' => '', |
|
| 58 | + 'securityKey' => 'auto', |
|
| 59 | + 'htaccess' => true, |
|
| 60 | + 'path' => '', |
|
| 61 | 61 | |
| 62 | - 'memcache' => array( |
|
| 62 | + 'memcache' => array( |
|
| 63 | 63 | array('127.0.0.1', 11211, 1), |
| 64 | - // array("new.host.ip",11211,1), |
|
| 65 | - ), |
|
| 64 | + // array("new.host.ip",11211,1), |
|
| 65 | + ), |
|
| 66 | 66 | |
| 67 | - 'redis' => array( |
|
| 67 | + 'redis' => array( |
|
| 68 | 68 | 'host' => '127.0.0.1', |
| 69 | 69 | 'port' => '', |
| 70 | 70 | 'password' => '', |
| 71 | 71 | 'database' => '', |
| 72 | 72 | 'timeout' => '', |
| 73 | - ), |
|
| 73 | + ), |
|
| 74 | 74 | |
| 75 | - 'ssdb' => array( |
|
| 75 | + 'ssdb' => array( |
|
| 76 | 76 | 'host' => '127.0.0.1', |
| 77 | 77 | 'port' => 8888, |
| 78 | 78 | 'password' => '', |
| 79 | 79 | 'timeout' => '', |
| 80 | - ), |
|
| 80 | + ), |
|
| 81 | 81 | |
| 82 | - 'extensions' => array(), |
|
| 83 | - "cache_method" => 1, // 1 = normal, 2 = phpfastcache, 3 = memory |
|
| 84 | - "limited_memory_each_object" => 4000, // maximum size (bytes) of object store in memory |
|
| 85 | - "compress_data" => false // compress stored data, if the backend supports it |
|
| 82 | + 'extensions' => array(), |
|
| 83 | + "cache_method" => 1, // 1 = normal, 2 = phpfastcache, 3 = memory |
|
| 84 | + "limited_memory_each_object" => 4000, // maximum size (bytes) of object store in memory |
|
| 85 | + "compress_data" => false // compress stored data, if the backend supports it |
|
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -177,12 +177,12 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | $securityKey = array_key_exists('securityKey', |
| 180 | - $config) ? $config[ 'securityKey' ] : ''; |
|
| 180 | + $config) ? $config[ 'securityKey' ] : ''; |
|
| 181 | 181 | if ($securityKey == "" || $securityKey == 'auto') { |
| 182 | 182 | $securityKey = self::$config[ 'securityKey' ]; |
| 183 | 183 | if ($securityKey == 'auto' || $securityKey == '') { |
| 184 | 184 | $securityKey = isset($_SERVER[ 'HTTP_HOST' ]) ? preg_replace('/^www./', |
| 185 | - '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))) : "default"; |
|
| 185 | + '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))) : "default"; |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | if ($securityKey != '') { |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | public static function cleanFileName($filename) |
| 235 | 235 | { |
| 236 | 236 | $regex = array( |
| 237 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
| 238 | - '/\.$/', |
|
| 239 | - '/^\./', |
|
| 237 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
| 238 | + '/\.$/', |
|
| 239 | + '/^\./', |
|
| 240 | 240 | ); |
| 241 | 241 | $replace = array('-', '', ''); |
| 242 | 242 | return trim(preg_replace($regex, $replace, trim($filename)),'-'); |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | protected static function getOS() |
| 262 | 262 | { |
| 263 | 263 | $os = array( |
| 264 | - 'os' => PHP_OS, |
|
| 265 | - 'php' => PHP_SAPI, |
|
| 266 | - 'system' => php_uname(), |
|
| 267 | - 'unique' => md5(php_uname() . PHP_OS . PHP_SAPI), |
|
| 264 | + 'os' => PHP_OS, |
|
| 265 | + 'php' => PHP_SAPI, |
|
| 266 | + 'system' => php_uname(), |
|
| 267 | + 'unique' => md5(php_uname() . PHP_OS . PHP_SAPI), |
|
| 268 | 268 | ); |
| 269 | 269 | return $os; |
| 270 | 270 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | chmod($path, 0777); |
| 299 | 299 | } catch (phpFastCacheDriverException $e) { |
| 300 | 300 | throw new phpFastCacheDriverException('PLEASE CHMOD ' . $path . ' - 0777 OR ANY WRITABLE PERMISSION!', |
| 301 | - 92); |
|
| 301 | + 92); |
|
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | 304 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | if (empty($config)) { |
| 106 | 106 | $config = phpFastCache::$config; |
| 107 | 107 | } |
| 108 | - $config[ 'storage' ] = $storage; |
|
| 108 | + $config['storage'] = $storage; |
|
| 109 | 109 | |
| 110 | 110 | $storage = strtolower($storage); |
| 111 | 111 | if ($storage == '' || $storage == 'auto') { |
@@ -158,31 +158,31 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | $tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(); |
| 160 | 160 | |
| 161 | - if (!isset($config[ 'path' ]) || $config[ 'path' ] == '') { |
|
| 161 | + if (!isset($config['path']) || $config['path'] == '') { |
|
| 162 | 162 | if (self::isPHPModule()) { |
| 163 | 163 | $path = $tmp_dir; |
| 164 | 164 | } else { |
| 165 | - $document_root_path = rtrim($_SERVER[ 'DOCUMENT_ROOT' ], '/') . '/../'; |
|
| 166 | - $path = isset($_SERVER[ 'DOCUMENT_ROOT' ]) && is_writable($document_root_path) |
|
| 165 | + $document_root_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/../'; |
|
| 166 | + $path = isset($_SERVER['DOCUMENT_ROOT']) && is_writable($document_root_path) |
|
| 167 | 167 | ? $document_root_path |
| 168 | 168 | : rtrim(__DIR__, '/') . '/'; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if (self::$config[ 'path' ] != '') { |
|
| 172 | - $path = $config[ 'path' ]; |
|
| 171 | + if (self::$config['path'] != '') { |
|
| 172 | + $path = $config['path']; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | } else { |
| 176 | - $path = $config[ 'path' ]; |
|
| 176 | + $path = $config['path']; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | $securityKey = array_key_exists('securityKey', |
| 180 | - $config) ? $config[ 'securityKey' ] : ''; |
|
| 180 | + $config) ? $config['securityKey'] : ''; |
|
| 181 | 181 | if ($securityKey == "" || $securityKey == 'auto') { |
| 182 | - $securityKey = self::$config[ 'securityKey' ]; |
|
| 182 | + $securityKey = self::$config['securityKey']; |
|
| 183 | 183 | if ($securityKey == 'auto' || $securityKey == '') { |
| 184 | - $securityKey = isset($_SERVER[ 'HTTP_HOST' ]) ? preg_replace('/^www./', |
|
| 185 | - '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))) : "default"; |
|
| 184 | + $securityKey = isset($_SERVER['HTTP_HOST']) ? preg_replace('/^www./', |
|
| 185 | + '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST']))) : "default"; |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | if ($securityKey != '') { |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | $securityKey = self::cleanFileName($securityKey); |
| 193 | 193 | |
| 194 | - $full_path = rtrim($path,'/') . '/' . $securityKey; |
|
| 194 | + $full_path = rtrim($path, '/') . '/' . $securityKey; |
|
| 195 | 195 | $full_pathx = md5($full_path); |
| 196 | 196 | |
| 197 | 197 | |
| 198 | - if ($skip_create_path == false && !isset(self::$tmp[ $full_pathx ])) { |
|
| 198 | + if ($skip_create_path == false && !isset(self::$tmp[$full_pathx])) { |
|
| 199 | 199 | |
| 200 | 200 | if (!@file_exists($full_path) || !@is_writable($full_path)) { |
| 201 | 201 | if (!@file_exists($full_path)) { |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | if (!@is_writable($full_path)) { |
| 205 | 205 | @chmod($full_path, self::__setChmodAuto($config)); |
| 206 | 206 | } |
| 207 | - if(!@is_writable($full_path)) { |
|
| 207 | + if (!@is_writable($full_path)) { |
|
| 208 | 208 | // switch back to tmp dir again if the path is not writeable |
| 209 | - $full_path = rtrim($tmp_dir,'/') . '/' . $securityKey; |
|
| 209 | + $full_path = rtrim($tmp_dir, '/') . '/' . $securityKey; |
|
| 210 | 210 | if (!@file_exists($full_path)) { |
| 211 | 211 | @mkdir($full_path, self::__setChmodAuto($config), true); |
| 212 | 212 | } |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - self::$tmp[ $full_pathx ] = true; |
|
| 223 | - self::htaccessGen($full_path, array_key_exists('htaccess', $config) ? $config[ 'htaccess' ] : false); |
|
| 222 | + self::$tmp[$full_pathx] = true; |
|
| 223 | + self::htaccessGen($full_path, array_key_exists('htaccess', $config) ? $config['htaccess'] : false); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | return realpath($full_path); |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | '/^\./', |
| 240 | 240 | ); |
| 241 | 241 | $replace = array('-', '', ''); |
| 242 | - return trim(preg_replace($regex, $replace, trim($filename)),'-'); |
|
| 242 | + return trim(preg_replace($regex, $replace, trim($filename)), '-'); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -248,10 +248,10 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | public static function __setChmodAuto($config) |
| 250 | 250 | { |
| 251 | - if (!isset($config[ 'default_chmod' ]) || $config[ 'default_chmod' ] == '' || is_null($config[ 'default_chmod' ])) { |
|
| 251 | + if (!isset($config['default_chmod']) || $config['default_chmod'] == '' || is_null($config['default_chmod'])) { |
|
| 252 | 252 | return 0777; |
| 253 | 253 | } else { |
| 254 | - return $config[ 'default_chmod' ]; |
|
| 254 | + return $config['default_chmod']; |
|
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if(!file_exists($path."/.htaccess")) { |
|
| 305 | + if (!file_exists($path . "/.htaccess")) { |
|
| 306 | 306 | // echo "write me"; |
| 307 | 307 | $html = "order deny, allow \r\n |
| 308 | 308 | deny from all \r\n |
@@ -328,9 +328,9 @@ discard block |
||
| 328 | 328 | public static function setup($name, $value = '') |
| 329 | 329 | { |
| 330 | 330 | if (is_array($name)) { |
| 331 | - self::$config = array_merge(self::$config,$name); |
|
| 331 | + self::$config = array_merge(self::$config, $name); |
|
| 332 | 332 | } else { |
| 333 | - self::$config[ $name ] = $value; |
|
| 333 | + self::$config[$name] = $value; |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | |