@@ -78,15 +78,13 @@ discard block |
||
| 78 | 78 | //check if the server is running under IPv6 |
| 79 | 79 | if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE){ |
| 80 | 80 | $baseUrl = '['.$_SERVER['SERVER_ADDR'].']'; |
| 81 | - } |
|
| 82 | - else{ |
|
| 81 | + } else{ |
|
| 83 | 82 | $baseUrl = $_SERVER['SERVER_ADDR']; |
| 84 | 83 | } |
| 85 | 84 | $port = ((isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] != '80' && ! is_https() || $_SERVER['SERVER_PORT'] != '443' && is_https()) ) ? ':' . $_SERVER['SERVER_PORT'] : ''); |
| 86 | 85 | $baseUrl = (is_https() ? 'https' : 'http').'://' . $baseUrl . $port |
| 87 | 86 | . substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME']))); |
| 88 | - } |
|
| 89 | - else{ |
|
| 87 | + } else{ |
|
| 90 | 88 | $logger->warning('Can not determine the application base URL automatically, use http://localhost as default'); |
| 91 | 89 | $baseUrl = 'http://localhost/'; |
| 92 | 90 | } |
@@ -151,8 +149,7 @@ discard block |
||
| 151 | 149 | $logger->info('Delete config item ['.$item.']'); |
| 152 | 150 | unset(self::$config[$item]); |
| 153 | 151 | return true; |
| 154 | - } |
|
| 155 | - else{ |
|
| 152 | + } else{ |
|
| 156 | 153 | $logger->warning('Config item ['.$item.'] to be deleted does not exists'); |
| 157 | 154 | return false; |
| 158 | 155 | } |
@@ -43,8 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | if(is_object($logger)){ |
| 45 | 45 | $this->logger = $logger; |
| 46 | - } |
|
| 47 | - else{ |
|
| 46 | + } else{ |
|
| 48 | 47 | $this->logger =& class_loader('Log', 'classes'); |
| 49 | 48 | $this->logger->setLogger('Library::ApcCache'); |
| 50 | 49 | } |
@@ -62,8 +61,7 @@ discard block |
||
| 62 | 61 | if($success === false){ |
| 63 | 62 | $this->logger->info('No cache found for the key ['. $key .'], return false'); |
| 64 | 63 | return false; |
| 65 | - } |
|
| 66 | - else{ |
|
| 64 | + } else{ |
|
| 67 | 65 | $cacheInfo = $this->_getCacheInfo($key); |
| 68 | 66 | $expire = time(); |
| 69 | 67 | if($cacheInfo){ |
@@ -89,8 +87,7 @@ discard block |
||
| 89 | 87 | if($result === false){ |
| 90 | 88 | $this->logger->error('Can not write cache data for the key ['. $key .'], return false'); |
| 91 | 89 | return false; |
| 92 | - } |
|
| 93 | - else{ |
|
| 90 | + } else{ |
|
| 94 | 91 | $this->logger->info('Cache data saved for the key ['. $key .']'); |
| 95 | 92 | return true; |
| 96 | 93 | } |
@@ -109,8 +106,7 @@ discard block |
||
| 109 | 106 | if($cacheInfo === false){ |
| 110 | 107 | $this->logger->info('This cache data does not exists skipping'); |
| 111 | 108 | return false; |
| 112 | - } |
|
| 113 | - else{ |
|
| 109 | + } else{ |
|
| 114 | 110 | $this->logger->info('Found cache data for the key [' .$key. '] remove it'); |
| 115 | 111 | return apc_delete($key) === true; |
| 116 | 112 | } |
@@ -134,8 +130,7 @@ discard block |
||
| 134 | 130 | 'ttl' => $cacheInfos['ttl'] |
| 135 | 131 | ); |
| 136 | 132 | return $data; |
| 137 | - } |
|
| 138 | - else{ |
|
| 133 | + } else{ |
|
| 139 | 134 | $this->logger->info('This cache does not exists skipping'); |
| 140 | 135 | return false; |
| 141 | 136 | } |
@@ -159,8 +154,7 @@ discard block |
||
| 159 | 154 | if(empty($cacheInfos['cache_list'])){ |
| 160 | 155 | $this->logger->info('No cache data were found skipping'); |
| 161 | 156 | return false; |
| 162 | - } |
|
| 163 | - else{ |
|
| 157 | + } else{ |
|
| 164 | 158 | $this->logger->info('Found [' . count($cacheInfos) . '] cache data to remove'); |
| 165 | 159 | return apc_clear_cache('user'); |
| 166 | 160 | } |
@@ -48,8 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | if(is_object($logger)){ |
| 50 | 50 | $this->logger = $logger; |
| 51 | - } |
|
| 52 | - else{ |
|
| 51 | + } else{ |
|
| 53 | 52 | $this->logger =& class_loader('Log', 'classes'); |
| 54 | 53 | $this->logger->setLogger('Library::FileCache'); |
| 55 | 54 | } |
@@ -95,8 +94,7 @@ discard block |
||
| 95 | 94 | // Unlinking when the file was expired |
| 96 | 95 | unlink($filePath); |
| 97 | 96 | return false; |
| 98 | - } |
|
| 99 | - else{ |
|
| 97 | + } else{ |
|
| 100 | 98 | $this->logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']'); |
| 101 | 99 | return $data['data']; |
| 102 | 100 | } |
@@ -133,8 +131,7 @@ discard block |
||
| 133 | 131 | $this->logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false'); |
| 134 | 132 | fclose($handle); |
| 135 | 133 | return false; |
| 136 | - } |
|
| 137 | - else{ |
|
| 134 | + } else{ |
|
| 138 | 135 | $this->logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']'); |
| 139 | 136 | fclose($handle); |
| 140 | 137 | chmod($filePath, 0640); |
@@ -156,8 +153,7 @@ discard block |
||
| 156 | 153 | if(! file_exists($filePath)){ |
| 157 | 154 | $this->logger->info('This cache file does not exists skipping'); |
| 158 | 155 | return false; |
| 159 | - } |
|
| 160 | - else{ |
|
| 156 | + } else{ |
|
| 161 | 157 | $this->logger->info('Found cache file [' .$filePath. '] remove it'); |
| 162 | 158 | unlink($filePath); |
| 163 | 159 | return true; |
@@ -179,16 +175,14 @@ discard block |
||
| 179 | 175 | if(! file_exists($filePath)){ |
| 180 | 176 | $this->logger->info('This cache file does not exists skipping'); |
| 181 | 177 | return false; |
| 182 | - } |
|
| 183 | - else{ |
|
| 178 | + } else{ |
|
| 184 | 179 | $this->logger->info('Found cache file [' .$filePath. '] check the validity'); |
| 185 | 180 | $data = file_get_contents($filePath); |
| 186 | 181 | $data = @unserialize($this->compressCacheData ? gzinflate($data) : $data); |
| 187 | 182 | if(! $data){ |
| 188 | 183 | $this->logger->warning('Can not unserialize the cache data for file [' . $filePath . ']'); |
| 189 | 184 | return false; |
| 190 | - } |
|
| 191 | - else{ |
|
| 185 | + } else{ |
|
| 192 | 186 | $this->logger->info('This cache data is OK check for expire'); |
| 193 | 187 | if(isset($data['expire']) && $data['expire'] > time()){ |
| 194 | 188 | $this->logger->info('This cache not yet expired return cache informations'); |
@@ -198,8 +192,7 @@ discard block |
||
| 198 | 192 | 'ttl' => $data['ttl'] |
| 199 | 193 | ); |
| 200 | 194 | return $info; |
| 201 | - } |
|
| 202 | - else{ |
|
| 195 | + } else{ |
|
| 203 | 196 | $this->logger->info('This cache already expired return false'); |
| 204 | 197 | return false; |
| 205 | 198 | } |
@@ -216,8 +209,7 @@ discard block |
||
| 216 | 209 | $list = glob(CACHE_PATH . '*.cache'); |
| 217 | 210 | if(! $list){ |
| 218 | 211 | $this->logger->info('No cache files were found skipping'); |
| 219 | - } |
|
| 220 | - else{ |
|
| 212 | + } else{ |
|
| 221 | 213 | $this->logger->info('Found [' . count($list) . '] cache files to remove if expired'); |
| 222 | 214 | foreach ($list as $file) { |
| 223 | 215 | $this->logger->debug('Processing the cache file [' . $file . ']'); |
@@ -225,12 +217,10 @@ discard block |
||
| 225 | 217 | $data = @unserialize($this->compressCacheData ? gzinflate($data) : $data); |
| 226 | 218 | if(! $data){ |
| 227 | 219 | $this->logger->warning('Can not unserialize the cache data for file [' . $file . ']'); |
| 228 | - } |
|
| 229 | - else if(time() > $data['expire']){ |
|
| 220 | + } else if(time() > $data['expire']){ |
|
| 230 | 221 | $this->logger->info('The cache data for file [' . $file . '] already expired remove it'); |
| 231 | 222 | unlink($file); |
| 232 | - } |
|
| 233 | - else{ |
|
| 223 | + } else{ |
|
| 234 | 224 | $this->logger->info('The cache data for file [' . $file . '] not yet expired skip it'); |
| 235 | 225 | } |
| 236 | 226 | } |
@@ -245,8 +235,7 @@ discard block |
||
| 245 | 235 | $list = glob(CACHE_PATH . '*.cache'); |
| 246 | 236 | if(! $list){ |
| 247 | 237 | $this->logger->info('No cache files were found skipping'); |
| 248 | - } |
|
| 249 | - else{ |
|
| 238 | + } else{ |
|
| 250 | 239 | $this->logger->info('Found [' . count($list) . '] cache files to remove'); |
| 251 | 240 | foreach ($list as $file) { |
| 252 | 241 | $this->logger->debug('Processing the cache file [' . $file . ']'); |
@@ -273,8 +262,7 @@ discard block |
||
| 273 | 262 | |
| 274 | 263 | $this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE'); |
| 275 | 264 | $this->compressCacheData = false; |
| 276 | - } |
|
| 277 | - else{ |
|
| 265 | + } else{ |
|
| 278 | 266 | $this->compressCacheData = $status; |
| 279 | 267 | } |
| 280 | 268 | return $this; |