@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function setLifeTime($time) |
78 | 78 | { |
79 | - $this->lifetime = (int)$time; |
|
79 | + $this->lifetime = (int) $time; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return false; |
122 | 122 | |
123 | 123 | |
124 | - $lastmodified = (int)$lastmodified; |
|
124 | + $lastmodified = (int) $lastmodified; |
|
125 | 125 | |
126 | 126 | if($lastmodified <= 0 || $lastmodified > filemtime($cache)) |
127 | 127 | return false; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function __construct($source) |
57 | 57 | { |
58 | - $this->source = (string)$source; |
|
58 | + $this->source = (string) $source; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | |
77 | 77 | foreach($translationUnit as $k => $unit) |
78 | 78 | { |
79 | - $source = (string)$unit['source']; |
|
80 | - $translations[$source][] = (string)$unit['target']; |
|
81 | - $translations[$source][] = (string)$k; |
|
82 | - $translations[$source][] = array_key_exists('note', $unit) ? (string)$unit['note'] : ''; |
|
79 | + $source = (string) $unit['source']; |
|
80 | + $translations[$source][] = (string) $unit['target']; |
|
81 | + $translations[$source][] = (string) $k; |
|
82 | + $translations[$source][] = array_key_exists('note', $unit) ? (string) $unit['note'] : ''; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | return $translations; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | { |
134 | 134 | if(isset($variants[$i]{0})) |
135 | 135 | { |
136 | - $variant .= ($variant)?'_' . $variants[$i]:$variants[$i]; |
|
136 | + $variant .= ($variant) ? '_' . $variants[$i] : $variants[$i]; |
|
137 | 137 | $catalogues[] = $catalogue . $this->dataSeparator . $variant . $this->dataExt; |
138 | 138 | } |
139 | 139 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | { |
160 | 160 | if(isset($variants[$i]{0})) |
161 | 161 | { |
162 | - $variant .= ($variant)?'_' . $variants[$i]:$variants[$i]; |
|
162 | + $variant .= ($variant) ? '_' . $variants[$i] : $variants[$i]; |
|
163 | 163 | $catalogues[] = $variant . '/' . $catalogue . $this->dataExt; |
164 | 164 | } |
165 | 165 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function getCatalogues($dir = null, $variant = null) |
188 | 188 | { |
189 | - $dir = $dir?$dir:$this->source; |
|
189 | + $dir = $dir ? $dir : $this->source; |
|
190 | 190 | $files = scandir($dir); |
191 | 191 | $catalogue = []; |
192 | 192 |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function __construct($options = [null]) |
235 | 235 | { |
236 | - $availableOptions = [ 'automaticSerialization', |
|
236 | + $availableOptions = ['automaticSerialization', |
|
237 | 237 | 'fileNameProtection', |
238 | 238 | 'memoryCaching', |
239 | 239 | 'onlyMemoryCaching', |
@@ -269,35 +269,35 @@ discard block |
||
269 | 269 | $this->_id = $id; |
270 | 270 | $this->_group = $group; |
271 | 271 | $data = false; |
272 | - if ($this->_caching) { |
|
272 | + if($this->_caching) { |
|
273 | 273 | $this->_setFileName($id, $group); |
274 | - if ($this->_memoryCaching) { |
|
275 | - if (isset($this->_memoryCachingArray[$this->_file])) { |
|
276 | - if ($this->_automaticSerialization) { |
|
274 | + if($this->_memoryCaching) { |
|
275 | + if(isset($this->_memoryCachingArray[$this->_file])) { |
|
276 | + if($this->_automaticSerialization) { |
|
277 | 277 | return unserialize( |
278 | 278 | $this->_memoryCachingArray[$this->_file]); |
279 | 279 | } else { |
280 | 280 | return $this->_memoryCachingArray[$this->_file]; |
281 | 281 | } |
282 | 282 | } else { |
283 | - if ($this->_onlyMemoryCaching) { |
|
283 | + if($this->_onlyMemoryCaching) { |
|
284 | 284 | return false; |
285 | 285 | } |
286 | 286 | } |
287 | 287 | } |
288 | - if ($doNotTestCacheValidity) { |
|
289 | - if (file_exists($this->_file)) { |
|
288 | + if($doNotTestCacheValidity) { |
|
289 | + if(file_exists($this->_file)) { |
|
290 | 290 | $data = $this->_read(); |
291 | 291 | } |
292 | 292 | } else { |
293 | - if (@filemtime($this->_file) > $this->_refreshTime) { |
|
293 | + if(@filemtime($this->_file) > $this->_refreshTime) { |
|
294 | 294 | $data = $this->_read(); |
295 | 295 | } |
296 | 296 | } |
297 | - if (($data) and ($this->_memoryCaching)) { |
|
297 | + if(($data) and ($this->_memoryCaching)) { |
|
298 | 298 | $this->_memoryCacheAdd($this->_file, $data); |
299 | 299 | } |
300 | - if ($this->_automaticSerialization && is_string($data)) { |
|
300 | + if($this->_automaticSerialization && is_string($data)) { |
|
301 | 301 | $data = unserialize($data); |
302 | 302 | } |
303 | 303 | return $data; |
@@ -317,21 +317,21 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function save($data, $id = null, $group = 'default') |
319 | 319 | { |
320 | - if ($this->_caching) { |
|
321 | - if ($this->_automaticSerialization) { |
|
320 | + if($this->_caching) { |
|
321 | + if($this->_automaticSerialization) { |
|
322 | 322 | $data = serialize($data); |
323 | 323 | } |
324 | - if (isset($id)) { |
|
324 | + if(isset($id)) { |
|
325 | 325 | $this->_setFileName($id, $group); |
326 | 326 | } |
327 | - if ($this->_memoryCaching) { |
|
327 | + if($this->_memoryCaching) { |
|
328 | 328 | $this->_memoryCacheAdd($this->_file, $data); |
329 | - if ($this->_onlyMemoryCaching) { |
|
329 | + if($this->_onlyMemoryCaching) { |
|
330 | 330 | return true; |
331 | 331 | } |
332 | 332 | } |
333 | - if ($this->_writeControl) { |
|
334 | - if (!$this->_writeAndControl($data)) { |
|
333 | + if($this->_writeControl) { |
|
334 | + if(!$this->_writeAndControl($data)) { |
|
335 | 335 | @touch($this->_file, time() - 2 * abs($this->_lifeTime)); |
336 | 336 | return false; |
337 | 337 | } else { |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | public function remove($id, $group = 'default') |
356 | 356 | { |
357 | 357 | $this->_setFileName($id, $group); |
358 | - if (!@unlink($this->_file)) { |
|
358 | + if(!@unlink($this->_file)) { |
|
359 | 359 | $this->raiseError('TCache_Lite : Unable to remove cache !', -3); |
360 | 360 | return false; |
361 | 361 | } |
@@ -374,33 +374,33 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function clean($group = false) |
376 | 376 | { |
377 | - if ($this->_fileNameProtection) { |
|
377 | + if($this->_fileNameProtection) { |
|
378 | 378 | $motif = ($group) ? 'cache_' . md5($group) . '_' : 'cache_'; |
379 | 379 | } else { |
380 | 380 | $motif = ($group) ? 'cache_' . $group . '_' : 'cache_'; |
381 | 381 | } |
382 | - if ($this->_memoryCaching) { |
|
383 | - while (list($key, $value) = each($this->_memoryCaching)) { |
|
384 | - if (strpos($key, $motif, 0)) { |
|
382 | + if($this->_memoryCaching) { |
|
383 | + while(list($key, $value) = each($this->_memoryCaching)) { |
|
384 | + if(strpos($key, $motif, 0)) { |
|
385 | 385 | unset($this->_memoryCaching[$key]); |
386 | 386 | $this->_memoryCachingCounter = |
387 | 387 | $this->_memoryCachingCounter - 1; |
388 | 388 | } |
389 | 389 | } |
390 | - if ($this->_onlyMemoryCaching) { |
|
390 | + if($this->_onlyMemoryCaching) { |
|
391 | 391 | return true; |
392 | 392 | } |
393 | 393 | } |
394 | - if (!($dh = opendir($this->_cacheDir))) { |
|
394 | + if(!($dh = opendir($this->_cacheDir))) { |
|
395 | 395 | $this->raiseError('TCache_Lite : Unable to open cache directory !'); |
396 | 396 | return false; |
397 | 397 | } |
398 | - while ($file = readdir($dh)) { |
|
399 | - if (($file != '.') && ($file != '..')) { |
|
398 | + while($file = readdir($dh)) { |
|
399 | + if(($file != '.') && ($file != '..')) { |
|
400 | 400 | $file = $this->_cacheDir . $file; |
401 | - if (is_file($file)) { |
|
402 | - if (strpos($file, $motif, 0)) { |
|
403 | - if (!@unlink($file)) { |
|
401 | + if(is_file($file)) { |
|
402 | + if(strpos($file, $motif, 0)) { |
|
403 | + if(!@unlink($file)) { |
|
404 | 404 | $this->raiseError('Cache_Lite : Unable to remove cache !', -3); |
405 | 405 | return false; |
406 | 406 | } |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | */ |
430 | 430 | public function saveMemoryCachingState($id, $group = 'default') |
431 | 431 | { |
432 | - if ($this->_caching) { |
|
432 | + if($this->_caching) { |
|
433 | 433 | $array = [ |
434 | 434 | 'counter' => $this->_memoryCachingCounter, |
435 | 435 | 'array' => $this->_memoryCachingState |
@@ -446,8 +446,8 @@ discard block |
||
446 | 446 | public function getMemoryCachingState($id, $group = 'default', |
447 | 447 | $doNotTestCacheValidity = false) |
448 | 448 | { |
449 | - if ($this->_caching) { |
|
450 | - if ($data = $this->get($id, $group, $doNotTestCacheValidity)) |
|
449 | + if($this->_caching) { |
|
450 | + if($data = $this->get($id, $group, $doNotTestCacheValidity)) |
|
451 | 451 | { |
452 | 452 | $array = unserialize($data); |
453 | 453 | $this->_memoryCachingCounter = $array['counter']; |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | public function _memoryCacheAdd($id, $data) |
493 | 493 | { |
494 | 494 | $this->_memoryCachingArray[$this->_file] = $data; |
495 | - if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) { |
|
495 | + if($this->_memoryCachingCounter >= $this->_memoryCachingLimit) { |
|
496 | 496 | list($key, $value) = each($this->_memoryCachingArray); |
497 | 497 | unset($this->_memoryCachingArray[$key]); |
498 | 498 | } else { |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | */ |
510 | 510 | public function _setFileName($id, $group) |
511 | 511 | { |
512 | - if ($this->_fileNameProtection) { |
|
512 | + if($this->_fileNameProtection) { |
|
513 | 513 | $this->_file = ($this->_cacheDir . 'cache_' . md5($group) . '_' |
514 | 514 | . md5($id)); |
515 | 515 | } else { |
@@ -531,21 +531,21 @@ discard block |
||
531 | 531 | public function _read() |
532 | 532 | { |
533 | 533 | $fp = @fopen($this->_file, "rb"); |
534 | - if ($this->_fileLocking) @flock($fp, LOCK_SH); |
|
535 | - if ($fp) { |
|
534 | + if($this->_fileLocking) @flock($fp, LOCK_SH); |
|
535 | + if($fp) { |
|
536 | 536 | // because the filesize can be cached by PHP itself... |
537 | 537 | clearstatcache(); |
538 | 538 | $length = @filesize($this->_file); |
539 | - if ($this->_readControl) { |
|
539 | + if($this->_readControl) { |
|
540 | 540 | $hashControl = @fread($fp, 32); |
541 | 541 | $length = $length - 32; |
542 | 542 | } |
543 | 543 | $data = @fread($fp, $length); |
544 | - if ($this->_fileLocking) @flock($fp, LOCK_UN); |
|
544 | + if($this->_fileLocking) @flock($fp, LOCK_UN); |
|
545 | 545 | @fclose($fp); |
546 | - if ($this->_readControl) { |
|
546 | + if($this->_readControl) { |
|
547 | 547 | $hashData = $this->_hash($data, $this->_readControlType); |
548 | - if ($hashData != $hashControl) { |
|
548 | + if($hashData != $hashControl) { |
|
549 | 549 | @touch($this->_file, time() - 2 * abs($this->_lifeTime)); |
550 | 550 | return false; |
551 | 551 | } |
@@ -566,14 +566,14 @@ discard block |
||
566 | 566 | public function _write($data) |
567 | 567 | { |
568 | 568 | $fp = @fopen($this->_file, "wb"); |
569 | - if ($fp) { |
|
570 | - if ($this->_fileLocking) @flock($fp, LOCK_EX); |
|
571 | - if ($this->_readControl) { |
|
569 | + if($fp) { |
|
570 | + if($this->_fileLocking) @flock($fp, LOCK_EX); |
|
571 | + if($this->_readControl) { |
|
572 | 572 | @fwrite($fp, $this->_hash($data, $this->_readControlType), 32); |
573 | 573 | } |
574 | 574 | $len = strlen($data); |
575 | 575 | @fwrite($fp, $data, $len); |
576 | - if ($this->_fileLocking) @flock($fp, LOCK_UN); |
|
576 | + if($this->_fileLocking) @flock($fp, LOCK_UN); |
|
577 | 577 | @fclose($fp); |
578 | 578 | return true; |
579 | 579 | } |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | */ |
607 | 607 | public function _hash($data, $controlType) |
608 | 608 | { |
609 | - switch ($controlType) { |
|
609 | + switch($controlType) { |
|
610 | 610 | case 'md5': |
611 | 611 | return md5($data); |
612 | 612 | case 'crc32': |
@@ -126,7 +126,7 @@ |
||
126 | 126 | */ |
127 | 127 | public static function &factory($type, $source = '.', $filename = '') |
128 | 128 | { |
129 | - $types = ['XLIFF','PHP','gettext','Database']; |
|
129 | + $types = ['XLIFF', 'PHP', 'gettext', 'Database']; |
|
130 | 130 | |
131 | 131 | if(empty($filename) && !in_array($type, $types)) |
132 | 132 | throw new Exception('Invalid type "' . $type . '", valid types are ' . |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | { |
238 | 238 | if(!empty($culture)) |
239 | 239 | { |
240 | - if (!preg_match('/^[_\\w]+$/', $culture)) |
|
240 | + if(!preg_match('/^[_\\w]+$/', $culture)) |
|
241 | 241 | throw new Exception('Invalid culture supplied: ' . $culture); |
242 | 242 | } |
243 | 243 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $value = $index[$i]; |
356 | 356 | if($i < $k - 1 && isset($array[$value])) |
357 | 357 | $array = $array[$value]; |
358 | - elseif ($i == $k - 1 && isset($array[$value])) |
|
358 | + elseif($i == $k - 1 && isset($array[$value])) |
|
359 | 359 | return $array[$value]; |
360 | 360 | } |
361 | 361 | } |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | $elements = $this->findInfo('NumberElements'); |
486 | 486 | $patterns = $this->findInfo('NumberPatterns'); |
487 | 487 | $currencies = $this->getCurrencies(); |
488 | - $data = [ 'NumberElements' => $elements, |
|
488 | + $data = ['NumberElements' => $elements, |
|
489 | 489 | 'NumberPatterns' => $patterns, |
490 | 490 | 'Currencies' => $currencies]; |
491 | 491 | |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | $neutral = []; |
536 | 536 | $specific = []; |
537 | 537 | |
538 | - while (false !== ($entry = $dir->read())) |
|
538 | + while(false !== ($entry = $dir->read())) |
|
539 | 539 | { |
540 | 540 | if(is_file($dataDir . $entry) |
541 | 541 | && substr($entry, -4) == $dataExt |
@@ -246,7 +246,7 @@ |
||
246 | 246 | $catalogue = $this->getCatalogue(); |
247 | 247 | if(empty($catalogue) && isset($config['catalogue'])) |
248 | 248 | $catalogue = $config['catalogue']; |
249 | - if (empty($catalogue)) $catalogue = 'messages'; |
|
249 | + if(empty($catalogue)) $catalogue = 'messages'; |
|
250 | 250 | Translation::init($catalogue); |
251 | 251 | |
252 | 252 | $key = $this->getKey(); |
@@ -82,11 +82,11 @@ |
||
82 | 82 | if($config !== null) |
83 | 83 | { |
84 | 84 | if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
85 | - $translation = isset($config['translate'])?$config['translate']:null; |
|
85 | + $translation = isset($config['translate']) ? $config['translate'] : null; |
|
86 | 86 | else |
87 | 87 | { |
88 | 88 | $t = $config->getElementByTagName('translation'); |
89 | - $translation = ($t)?$t->getAttributes():null; |
|
89 | + $translation = ($t) ? $t->getAttributes() : null; |
|
90 | 90 | } |
91 | 91 | if($translation) |
92 | 92 | $this->setTranslationConfiguration($translation); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | $this->_close(); |
71 | 71 | // ----- Look for a local copy to delete |
72 | - if ($this->_temp_tarname != '') |
|
72 | + if($this->_temp_tarname != '') |
|
73 | 73 | @unlink($this->_temp_tarname); |
74 | 74 | } |
75 | 75 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $v_result = true; |
116 | 116 | $v_list_detail = []; |
117 | 117 | |
118 | - if ($v_result = $this->_openRead()) { |
|
118 | + if($v_result = $this->_openRead()) { |
|
119 | 119 | $v_result = $this->_extractList($p_path, $v_list_detail, |
120 | 120 | "complete", 0, $p_remove_path); |
121 | 121 | $this->_close(); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | private function _isArchive($p_filename = null) |
133 | 133 | { |
134 | - if ($p_filename == null) { |
|
134 | + if($p_filename == null) { |
|
135 | 135 | $p_filename = $this->_tarname; |
136 | 136 | } |
137 | 137 | clearstatcache(); |
@@ -140,24 +140,24 @@ discard block |
||
140 | 140 | |
141 | 141 | private function _openRead() |
142 | 142 | { |
143 | - if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') { |
|
143 | + if(strtolower(substr($this->_tarname, 0, 7)) == 'http://') { |
|
144 | 144 | |
145 | 145 | // ----- Look if a local copy need to be done |
146 | - if ($this->_temp_tarname == '') { |
|
146 | + if($this->_temp_tarname == '') { |
|
147 | 147 | $this->_temp_tarname = uniqid('tar') . '.tmp'; |
148 | - if (!$v_file_from = @fopen($this->_tarname, 'rb')) { |
|
148 | + if(!$v_file_from = @fopen($this->_tarname, 'rb')) { |
|
149 | 149 | $this->_error('Unable to open in read mode \'' |
150 | 150 | . $this->_tarname . '\''); |
151 | 151 | $this->_temp_tarname = ''; |
152 | 152 | return false; |
153 | 153 | } |
154 | - if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) { |
|
154 | + if(!$v_file_to = @fopen($this->_temp_tarname, 'wb')) { |
|
155 | 155 | $this->_error('Unable to open in write mode \'' |
156 | 156 | . $this->_temp_tarname . '\''); |
157 | 157 | $this->_temp_tarname = ''; |
158 | 158 | return false; |
159 | 159 | } |
160 | - while ($v_data = @fread($v_file_from, 1024)) |
|
160 | + while($v_data = @fread($v_file_from, 1024)) |
|
161 | 161 | @fwrite($v_file_to, $v_data); |
162 | 162 | @fclose($v_file_from); |
163 | 163 | @fclose($v_file_to); |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | $this->_file = @fopen($v_filename, "rb"); |
174 | 174 | |
175 | - if ($this->_file == 0) { |
|
175 | + if($this->_file == 0) { |
|
176 | 176 | $this->_error('Unable to open in read mode \'' . $v_filename . '\''); |
177 | 177 | return false; |
178 | 178 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | private function _close() |
184 | 184 | { |
185 | 185 | //if (isset($this->_file)) { |
186 | - if (is_resource($this->_file)) |
|
186 | + if(is_resource($this->_file)) |
|
187 | 187 | { |
188 | 188 | @fclose($this->_file); |
189 | 189 | $this->_file = 0; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | // ----- Look if a local copy need to be erase |
193 | 193 | // Note that it might be interesting to keep the url for a time : ToDo |
194 | - if ($this->_temp_tarname != '') { |
|
194 | + if($this->_temp_tarname != '') { |
|
195 | 195 | @unlink($this->_temp_tarname); |
196 | 196 | $this->_temp_tarname = ''; |
197 | 197 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $this->_close(); |
205 | 205 | |
206 | 206 | // ----- Look for a local copy |
207 | - if ($this->_temp_tarname != '') { |
|
207 | + if($this->_temp_tarname != '') { |
|
208 | 208 | // ----- Remove the local copy but not the remote tarname |
209 | 209 | @unlink($this->_temp_tarname); |
210 | 210 | $this->_temp_tarname = ''; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | private function _readBlock() |
221 | 221 | { |
222 | 222 | $v_block = null; |
223 | - if (is_resource($this->_file)) { |
|
223 | + if(is_resource($this->_file)) { |
|
224 | 224 | $v_block = @fread($this->_file, 512); |
225 | 225 | } |
226 | 226 | return $v_block; |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | |
229 | 229 | private function _jumpBlock($p_len = null) |
230 | 230 | { |
231 | - if (is_resource($this->_file)) { |
|
232 | - if ($p_len === null) |
|
231 | + if(is_resource($this->_file)) { |
|
232 | + if($p_len === null) |
|
233 | 233 | $p_len = 1; |
234 | 234 | |
235 | 235 | @fseek($this->_file, @ftell($this->_file) + ($p_len * 512)); |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | |
240 | 240 | private function _readHeader($v_binary_data, &$v_header) |
241 | 241 | { |
242 | - if (strlen($v_binary_data) == 0) { |
|
242 | + if(strlen($v_binary_data) == 0) { |
|
243 | 243 | $v_header['filename'] = ''; |
244 | 244 | return true; |
245 | 245 | } |
246 | 246 | |
247 | - if (strlen($v_binary_data) != 512) { |
|
247 | + if(strlen($v_binary_data) != 512) { |
|
248 | 248 | $v_header['filename'] = ''; |
249 | 249 | $this->_error('Invalid block size : ' . strlen($v_binary_data)); |
250 | 250 | return false; |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | // ----- Calculate the checksum |
254 | 254 | $v_checksum = 0; |
255 | 255 | // ..... First part of the header |
256 | - for ($i = 0; $i < 148; $i++) |
|
256 | + for($i = 0; $i < 148; $i++) |
|
257 | 257 | $v_checksum += ord(substr($v_binary_data, $i, 1)); |
258 | 258 | // ..... Ignore the checksum value and replace it by ' ' (space) |
259 | - for ($i = 148; $i < 156; $i++) |
|
259 | + for($i = 148; $i < 156; $i++) |
|
260 | 260 | $v_checksum += ord(' '); |
261 | 261 | // ..... Last part of the header |
262 | - for ($i = 156; $i < 512; $i++) |
|
262 | + for($i = 156; $i < 512; $i++) |
|
263 | 263 | $v_checksum += ord(substr($v_binary_data, $i, 1)); |
264 | 264 | |
265 | 265 | $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | |
270 | 270 | // ----- Extract the checksum |
271 | 271 | $v_header['checksum'] = OctDec(trim($v_data['checksum'])); |
272 | - if ($v_header['checksum'] != $v_checksum) { |
|
272 | + if($v_header['checksum'] != $v_checksum) { |
|
273 | 273 | $v_header['filename'] = ''; |
274 | 274 | |
275 | 275 | // ----- Look for last block (empty block) |
276 | - if (($v_checksum == 256) && ($v_header['checksum'] == 0)) |
|
276 | + if(($v_checksum == 256) && ($v_header['checksum'] == 0)) |
|
277 | 277 | return true; |
278 | 278 | |
279 | 279 | $this->_error('Invalid checksum for file "' . $v_data['filename'] |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $v_header['gid'] = OctDec(trim($v_data['gid'])); |
290 | 290 | $v_header['size'] = OctDec(trim($v_data['size'])); |
291 | 291 | $v_header['mtime'] = OctDec(trim($v_data['mtime'])); |
292 | - if (($v_header['typeflag'] = $v_data['typeflag']) == "5") { |
|
292 | + if(($v_header['typeflag'] = $v_data['typeflag']) == "5") { |
|
293 | 293 | $v_header['size'] = 0; |
294 | 294 | } |
295 | 295 | return true; |
@@ -299,11 +299,11 @@ discard block |
||
299 | 299 | { |
300 | 300 | $v_filename = ''; |
301 | 301 | $n = floor($v_header['size'] / 512); |
302 | - for ($i = 0; $i < $n; $i++) { |
|
302 | + for($i = 0; $i < $n; $i++) { |
|
303 | 303 | $v_content = $this->_readBlock(); |
304 | 304 | $v_filename .= $v_content; |
305 | 305 | } |
306 | - if (($v_header['size'] % 512) != 0) { |
|
306 | + if(($v_header['size'] % 512) != 0) { |
|
307 | 307 | $v_content = $this->_readBlock(); |
308 | 308 | $v_filename .= $v_content; |
309 | 309 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | // ----- Read the next header |
312 | 312 | $v_binary_data = $this->_readBlock(); |
313 | 313 | |
314 | - if (!$this->_readHeader($v_binary_data, $v_header)) |
|
314 | + if(!$this->_readHeader($v_binary_data, $v_header)) |
|
315 | 315 | return false; |
316 | 316 | |
317 | 317 | $v_header['filename'] = $v_filename; |
@@ -328,18 +328,18 @@ discard block |
||
328 | 328 | $v_listing = false; |
329 | 329 | |
330 | 330 | $p_path = $this->_translateWinPath($p_path, false); |
331 | - if ($p_path == '' || (substr($p_path, 0, 1) != '/' |
|
331 | + if($p_path == '' || (substr($p_path, 0, 1) != '/' |
|
332 | 332 | && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) { |
333 | 333 | $p_path = "./" . $p_path; |
334 | 334 | } |
335 | 335 | $p_remove_path = $this->_translateWinPath($p_remove_path); |
336 | 336 | |
337 | 337 | // ----- Look for path to remove format (should end by /) |
338 | - if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) |
|
338 | + if(($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) |
|
339 | 339 | $p_remove_path .= '/'; |
340 | 340 | $p_remove_path_size = strlen($p_remove_path); |
341 | 341 | |
342 | - switch ($p_mode) { |
|
342 | + switch($p_mode) { |
|
343 | 343 | case "complete" : |
344 | 344 | $v_extract_all = true; |
345 | 345 | $v_listing = false; |
@@ -359,33 +359,33 @@ discard block |
||
359 | 359 | |
360 | 360 | clearstatcache(); |
361 | 361 | |
362 | - while (strlen($v_binary_data = $this->_readBlock()) != 0) |
|
362 | + while(strlen($v_binary_data = $this->_readBlock()) != 0) |
|
363 | 363 | { |
364 | 364 | $v_extract_file = false; |
365 | 365 | $v_extraction_stopped = 0; |
366 | 366 | |
367 | - if (!$this->_readHeader($v_binary_data, $v_header)) |
|
367 | + if(!$this->_readHeader($v_binary_data, $v_header)) |
|
368 | 368 | return false; |
369 | 369 | |
370 | - if ($v_header['filename'] == '') { |
|
370 | + if($v_header['filename'] == '') { |
|
371 | 371 | continue; |
372 | 372 | } |
373 | 373 | |
374 | 374 | // ----- Look for long filename |
375 | - if ($v_header['typeflag'] == 'L') { |
|
376 | - if (!$this->_readLongHeader($v_header)) |
|
375 | + if($v_header['typeflag'] == 'L') { |
|
376 | + if(!$this->_readLongHeader($v_header)) |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | - if ((!$v_extract_all) && (is_array($p_file_list))) { |
|
380 | + if((!$v_extract_all) && (is_array($p_file_list))) { |
|
381 | 381 | // ----- By default no unzip if the file is not found |
382 | 382 | $v_extract_file = false; |
383 | 383 | |
384 | - for ($i = 0; $i < count($p_file_list); $i++) { |
|
384 | + for($i = 0; $i < count($p_file_list); $i++) { |
|
385 | 385 | // ----- Look if it is a directory |
386 | - if (substr($p_file_list[$i], -1) == '/') { |
|
386 | + if(substr($p_file_list[$i], -1) == '/') { |
|
387 | 387 | // ----- Look if the directory is in the filename path |
388 | - if ((strlen($v_header['filename']) > strlen($p_file_list[$i])) |
|
388 | + if((strlen($v_header['filename']) > strlen($p_file_list[$i])) |
|
389 | 389 | && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) |
390 | 390 | == $p_file_list[$i])) { |
391 | 391 | $v_extract_file = true; |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | } |
395 | 395 | |
396 | 396 | // ----- It is a file, so compare the file names |
397 | - elseif ($p_file_list[$i] == $v_header['filename']) { |
|
397 | + elseif($p_file_list[$i] == $v_header['filename']) { |
|
398 | 398 | $v_extract_file = true; |
399 | 399 | break; |
400 | 400 | } |
@@ -404,58 +404,58 @@ discard block |
||
404 | 404 | } |
405 | 405 | |
406 | 406 | // ----- Look if this file need to be extracted |
407 | - if (($v_extract_file) && (!$v_listing)) |
|
407 | + if(($v_extract_file) && (!$v_listing)) |
|
408 | 408 | { |
409 | - if (($p_remove_path != '') |
|
409 | + if(($p_remove_path != '') |
|
410 | 410 | && (substr($v_header['filename'], 0, $p_remove_path_size) |
411 | 411 | == $p_remove_path)) |
412 | 412 | $v_header['filename'] = substr($v_header['filename'], |
413 | 413 | $p_remove_path_size); |
414 | - if (($p_path != './') && ($p_path != '/')) { |
|
415 | - while (substr($p_path, -1) == '/') |
|
414 | + if(($p_path != './') && ($p_path != '/')) { |
|
415 | + while(substr($p_path, -1) == '/') |
|
416 | 416 | $p_path = substr($p_path, 0, strlen($p_path) - 1); |
417 | 417 | |
418 | - if (substr($v_header['filename'], 0, 1) == '/') |
|
418 | + if(substr($v_header['filename'], 0, 1) == '/') |
|
419 | 419 | $v_header['filename'] = $p_path . $v_header['filename']; |
420 | 420 | else |
421 | 421 | $v_header['filename'] = $p_path . '/' . $v_header['filename']; |
422 | 422 | } |
423 | - if (file_exists($v_header['filename'])) { |
|
424 | - if ((@is_dir($v_header['filename'])) |
|
423 | + if(file_exists($v_header['filename'])) { |
|
424 | + if((@is_dir($v_header['filename'])) |
|
425 | 425 | && ($v_header['typeflag'] == '')) { |
426 | 426 | $this->_error('File ' . $v_header['filename'] |
427 | 427 | . ' already exists as a directory'); |
428 | 428 | return false; |
429 | 429 | } |
430 | - if (($this->_isArchive($v_header['filename'])) |
|
430 | + if(($this->_isArchive($v_header['filename'])) |
|
431 | 431 | && ($v_header['typeflag'] == "5")) { |
432 | 432 | $this->_error('Directory ' . $v_header['filename'] |
433 | 433 | . ' already exists as a file'); |
434 | 434 | return false; |
435 | 435 | } |
436 | - if (!is_writable($v_header['filename'])) { |
|
436 | + if(!is_writable($v_header['filename'])) { |
|
437 | 437 | $this->_error('File ' . $v_header['filename'] |
438 | 438 | . ' already exists and is write protected'); |
439 | 439 | return false; |
440 | 440 | } |
441 | - if (filemtime($v_header['filename']) > $v_header['mtime']) { |
|
441 | + if(filemtime($v_header['filename']) > $v_header['mtime']) { |
|
442 | 442 | // To be completed : An error or silent no replace ? |
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | 446 | // ----- Check the directory availability and create it if necessary |
447 | - elseif (($v_result |
|
447 | + elseif(($v_result |
|
448 | 448 | = $this->_dirCheck(($v_header['typeflag'] == "5" |
449 | - ?$v_header['filename'] |
|
449 | + ? $v_header['filename'] |
|
450 | 450 | :dirname($v_header['filename'])))) != 1) { |
451 | 451 | $this->_error('Unable to create path for ' . $v_header['filename']); |
452 | 452 | return false; |
453 | 453 | } |
454 | 454 | |
455 | - if ($v_extract_file) { |
|
456 | - if ($v_header['typeflag'] == "5") { |
|
457 | - if (!@file_exists($v_header['filename'])) { |
|
458 | - if (!@mkdir($v_header['filename'], PRADO_CHMOD)) { |
|
455 | + if($v_extract_file) { |
|
456 | + if($v_header['typeflag'] == "5") { |
|
457 | + if(!@file_exists($v_header['filename'])) { |
|
458 | + if(!@mkdir($v_header['filename'], PRADO_CHMOD)) { |
|
459 | 459 | $this->_error('Unable to create directory {' |
460 | 460 | . $v_header['filename'] . '}'); |
461 | 461 | return false; |
@@ -463,17 +463,17 @@ discard block |
||
463 | 463 | chmod($v_header['filename'], PRADO_CHMOD); |
464 | 464 | } |
465 | 465 | } else { |
466 | - if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { |
|
466 | + if(($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { |
|
467 | 467 | $this->_error('Error while opening {' . $v_header['filename'] |
468 | 468 | . '} in write binary mode'); |
469 | 469 | return false; |
470 | 470 | } else { |
471 | 471 | $n = floor($v_header['size'] / 512); |
472 | - for ($i = 0; $i < $n; $i++) { |
|
472 | + for($i = 0; $i < $n; $i++) { |
|
473 | 473 | $v_content = $this->_readBlock(); |
474 | 474 | fwrite($v_dest_file, $v_content, 512); |
475 | 475 | } |
476 | - if (($v_header['size'] % 512) != 0) { |
|
476 | + if(($v_header['size'] % 512) != 0) { |
|
477 | 477 | $v_content = $this->_readBlock(); |
478 | 478 | fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); |
479 | 479 | } |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | |
489 | 489 | // ----- Check the file size |
490 | 490 | clearstatcache(); |
491 | - if (filesize($v_header['filename']) != $v_header['size']) { |
|
491 | + if(filesize($v_header['filename']) != $v_header['size']) { |
|
492 | 492 | $this->_error('Extracted file ' . $v_header['filename'] |
493 | 493 | . ' does not have the correct file size \'' |
494 | 494 | . filesize($v_header['filename']) |
@@ -511,12 +511,12 @@ discard block |
||
511 | 511 | $v_end_of_file = @feof($this->_file); |
512 | 512 | */ |
513 | 513 | |
514 | - if ($v_listing || $v_extract_file || $v_extraction_stopped) { |
|
514 | + if($v_listing || $v_extract_file || $v_extraction_stopped) { |
|
515 | 515 | // ----- Log extracted files |
516 | - if (($v_file_dir = dirname($v_header['filename'])) |
|
516 | + if(($v_file_dir = dirname($v_header['filename'])) |
|
517 | 517 | == $v_header['filename']) |
518 | 518 | $v_file_dir = ''; |
519 | - if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) |
|
519 | + if((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) |
|
520 | 520 | $v_file_dir = '/'; |
521 | 521 | |
522 | 522 | $p_list_detail[$v_nb++] = $v_header; |
@@ -536,17 +536,17 @@ discard block |
||
536 | 536 | */ |
537 | 537 | protected function _dirCheck($p_dir) |
538 | 538 | { |
539 | - if ((@is_dir($p_dir)) || ($p_dir == '')) |
|
539 | + if((@is_dir($p_dir)) || ($p_dir == '')) |
|
540 | 540 | return true; |
541 | 541 | |
542 | 542 | $p_parent_dir = dirname($p_dir); |
543 | 543 | |
544 | - if (($p_parent_dir != $p_dir) && |
|
544 | + if(($p_parent_dir != $p_dir) && |
|
545 | 545 | ($p_parent_dir != '') && |
546 | 546 | (!$this->_dirCheck($p_parent_dir))) |
547 | 547 | return false; |
548 | 548 | |
549 | - if (!@mkdir($p_dir, PRADO_CHMOD)) { |
|
549 | + if(!@mkdir($p_dir, PRADO_CHMOD)) { |
|
550 | 550 | $this->_error("Unable to create directory '$p_dir'"); |
551 | 551 | return false; |
552 | 552 | } |
@@ -557,14 +557,14 @@ discard block |
||
557 | 557 | |
558 | 558 | protected function _translateWinPath($p_path, $p_remove_disk_letter = true) |
559 | 559 | { |
560 | - if (substr(PHP_OS, 0, 3) == 'WIN') { |
|
560 | + if(substr(PHP_OS, 0, 3) == 'WIN') { |
|
561 | 561 | // ----- Look for potential disk letter |
562 | - if (($p_remove_disk_letter) |
|
562 | + if(($p_remove_disk_letter) |
|
563 | 563 | && (($v_position = strpos($p_path, ':')) != false)) { |
564 | 564 | $p_path = substr($p_path, $v_position + 1); |
565 | 565 | } |
566 | 566 | // ----- Change potential windows directory separator |
567 | - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { |
|
567 | + if((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { |
|
568 | 568 | $p_path = strtr($p_path, '\\', '/'); |
569 | 569 | } |
570 | 570 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | return $data[$field]; |
64 | 64 | |
65 | 65 | $tmp = $data; |
66 | - foreach (explode(".", $field) as $f) |
|
66 | + foreach(explode(".", $field) as $f) |
|
67 | 67 | $tmp = $tmp[$f]; |
68 | 68 | return $tmp; |
69 | 69 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | if(strpos($field, '.') === false) // simple field |
73 | 73 | { |
74 | 74 | if(method_exists($data, 'get' . $field)) |
75 | - return call_user_func([$data,'get' . $field]); |
|
75 | + return call_user_func([$data, 'get' . $field]); |
|
76 | 76 | else |
77 | 77 | return $data->{$field}; |
78 | 78 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
88 | - catch(Exception $e) |
|
88 | + catch (Exception $e) |
|
89 | 89 | { |
90 | 90 | throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid', $field, $e->getMessage()); |
91 | 91 | } |