@@ -35,7 +35,8 @@ |
||
35 | 35 | ), $class); |
36 | 36 | |
37 | 37 | $class_file = LIBHOWI_ROOT . $library . '.inc'; |
38 | - if (file_exists($class_file)) |
|
39 | - require_once ($class_file); |
|
40 | -} |
|
38 | + if (file_exists($class_file)) { |
|
39 | + require_once ($class_file); |
|
40 | + } |
|
41 | + } |
|
41 | 42 | spl_autoload_register('libhowi_autoloder'); |
@@ -302,5 +302,5 @@ |
||
302 | 302 | * @param array $data_array |
303 | 303 | * @return bool true on success fase on failure |
304 | 304 | */ |
305 | - public function createStructure($rootpath,$data_array); |
|
305 | + public function createStructure($rootpath, $data_array); |
|
306 | 306 | } |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | |
187 | 187 | $this->response->setCode($code); |
188 | 188 | $this->response->setTime(); |
189 | - $this->response->setMsg($this->{$LEVEL}[$code] . (! empty($append_msg) ? ' - ' . $append_msg : '')); |
|
189 | + $this->response->setMsg($this->{$LEVEL}[$code] . (!empty($append_msg) ? ' - ' . $append_msg : '')); |
|
190 | 190 | $this->response->setUID($this->getUID()); |
191 | 191 | $this->response->setUsername($this->getUsername()); |
192 | 192 | $this->response->setContext($context); |
193 | 193 | $this->response->setLevel($LEVEL); |
194 | 194 | |
195 | 195 | $logging = $this->getLogFile(); |
196 | - if (! empty($logging) && ! empty($to_file)) |
|
196 | + if (!empty($logging) && !empty($to_file)) |
|
197 | 197 | $this->logToFile($LEVEL); |
198 | 198 | } |
199 | 199 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $message .= '[msg] ' . $this->getMsg() . ' [/msg]' . "\n"; |
212 | 212 | |
213 | 213 | $logging = $this->getLogFile(); |
214 | - if (empty($logging) || ! is_dir(dirname($logging))) |
|
214 | + if (empty($logging) || !is_dir(dirname($logging))) |
|
215 | 215 | return false; |
216 | 216 | return file_put_contents($logging, $message, FILE_APPEND); |
217 | 217 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | public function setLogFile($filepath = false) |
236 | 236 | { |
237 | 237 | $logfilepath = $this->makeAbsolute($filepath); |
238 | - if (empty($filepath) || ! $this->isWritable(dirname($logfilepath))) { |
|
238 | + if (empty($filepath) || !$this->isWritable(dirname($logfilepath))) { |
|
239 | 239 | $this->error(400, 'setLogFile'); |
240 | 240 | return false; |
241 | 241 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | */ |
327 | 327 | public function getCode() |
328 | 328 | { |
329 | - return ! is_object($this->response) ? 0 : $this->response->getCode(); |
|
329 | + return !is_object($this->response) ? 0 : $this->response->getCode(); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -193,8 +193,9 @@ discard block |
||
193 | 193 | $this->response->setLevel($LEVEL); |
194 | 194 | |
195 | 195 | $logging = $this->getLogFile(); |
196 | - if (! empty($logging) && ! empty($to_file)) |
|
197 | - $this->logToFile($LEVEL); |
|
196 | + if (! empty($logging) && ! empty($to_file)) { |
|
197 | + $this->logToFile($LEVEL); |
|
198 | + } |
|
198 | 199 | } |
199 | 200 | |
200 | 201 | /** |
@@ -211,8 +212,9 @@ discard block |
||
211 | 212 | $message .= '[msg] ' . $this->getMsg() . ' [/msg]' . "\n"; |
212 | 213 | |
213 | 214 | $logging = $this->getLogFile(); |
214 | - if (empty($logging) || ! is_dir(dirname($logging))) |
|
215 | - return false; |
|
215 | + if (empty($logging) || ! is_dir(dirname($logging))) { |
|
216 | + return false; |
|
217 | + } |
|
216 | 218 | return file_put_contents($logging, $message, FILE_APPEND); |
217 | 219 | } |
218 | 220 | |
@@ -364,8 +366,9 @@ discard block |
||
364 | 366 | */ |
365 | 367 | public function setStatus($status) |
366 | 368 | { |
367 | - if (is_object($this->response)) |
|
368 | - $this->response->setStatus($status); |
|
369 | + if (is_object($this->response)) { |
|
370 | + $this->response->setStatus($status); |
|
371 | + } |
|
369 | 372 | } |
370 | 373 | |
371 | 374 | /** |
@@ -375,8 +378,9 @@ discard block |
||
375 | 378 | */ |
376 | 379 | public function setCode($code) |
377 | 380 | { |
378 | - if (is_object($this->response)) |
|
379 | - $this->response->setCode($code); |
|
381 | + if (is_object($this->response)) { |
|
382 | + $this->response->setCode($code); |
|
383 | + } |
|
380 | 384 | } |
381 | 385 | |
382 | 386 | /** |
@@ -389,8 +393,9 @@ discard block |
||
389 | 393 | public function emergency($code = 1, $append_msg = false, $context = false) |
390 | 394 | { |
391 | 395 | $to_file = true; |
392 | - if ($this->getLogLevel() < 1) |
|
393 | - $to_file = false; |
|
396 | + if ($this->getLogLevel() < 1) { |
|
397 | + $to_file = false; |
|
398 | + } |
|
394 | 399 | |
395 | 400 | $this->addTrace('EMERGENCY', $code, $context, $append_msg, $to_file); |
396 | 401 | } |
@@ -409,8 +414,9 @@ discard block |
||
409 | 414 | public function alert($code = 2, $append_msg = false, $context = false) |
410 | 415 | { |
411 | 416 | $to_file = true; |
412 | - if ($this->getLogLevel() < 2) |
|
413 | - $to_file = false; |
|
417 | + if ($this->getLogLevel() < 2) { |
|
418 | + $to_file = false; |
|
419 | + } |
|
414 | 420 | $this->addTrace('ALERT', $code, $context, $append_msg, $to_file); |
415 | 421 | } |
416 | 422 | |
@@ -427,8 +433,9 @@ discard block |
||
427 | 433 | public function critical($code = 3, $append_msg = false, $context = false) |
428 | 434 | { |
429 | 435 | $to_file = true; |
430 | - if ($this->getLogLevel() < 3) |
|
431 | - $to_file = false; |
|
436 | + if ($this->getLogLevel() < 3) { |
|
437 | + $to_file = false; |
|
438 | + } |
|
432 | 439 | $this->addTrace('CRITICAL', $code, $context, $append_msg, $to_file); |
433 | 440 | } |
434 | 441 | |
@@ -445,8 +452,9 @@ discard block |
||
445 | 452 | public function error($code = 4, $append_msg = false, $context = false) |
446 | 453 | { |
447 | 454 | $to_file = true; |
448 | - if ($this->getLogLevel() < 4) |
|
449 | - $to_file = false; |
|
455 | + if ($this->getLogLevel() < 4) { |
|
456 | + $to_file = false; |
|
457 | + } |
|
450 | 458 | $this->addTrace('ERROR', $code, $context, $append_msg, $to_file); |
451 | 459 | } |
452 | 460 | |
@@ -464,8 +472,9 @@ discard block |
||
464 | 472 | public function warning($code = 5, $append_msg = false, $context = false) |
465 | 473 | { |
466 | 474 | $to_file = true; |
467 | - if ($this->getLogLevel() < 5) |
|
468 | - $to_file = false; |
|
475 | + if ($this->getLogLevel() < 5) { |
|
476 | + $to_file = false; |
|
477 | + } |
|
469 | 478 | $this->addTrace('WARNING', $code, $context, $append_msg, $to_file); |
470 | 479 | } |
471 | 480 | |
@@ -481,8 +490,9 @@ discard block |
||
481 | 490 | public function notice($code = 6, $append_msg = false, $context = false) |
482 | 491 | { |
483 | 492 | $to_file = true; |
484 | - if ($this->getLogLevel() < 6) |
|
485 | - $to_file = false; |
|
493 | + if ($this->getLogLevel() < 6) { |
|
494 | + $to_file = false; |
|
495 | + } |
|
486 | 496 | $this->addTrace('NOTICE', $code, $context, $append_msg, $to_file); |
487 | 497 | } |
488 | 498 | |
@@ -500,8 +510,9 @@ discard block |
||
500 | 510 | public function info($code = 7, $append_msg = false, $context = false) |
501 | 511 | { |
502 | 512 | $to_file = true; |
503 | - if ($this->getLogLevel() < 7) |
|
504 | - $to_file = false; |
|
513 | + if ($this->getLogLevel() < 7) { |
|
514 | + $to_file = false; |
|
515 | + } |
|
505 | 516 | $this->addTrace('INFO', $code, $context, $append_msg, $to_file); |
506 | 517 | } |
507 | 518 | |
@@ -517,8 +528,9 @@ discard block |
||
517 | 528 | public function debug($code = 8, $append_msg = false, $context = false) |
518 | 529 | { |
519 | 530 | $to_file = true; |
520 | - if ($this->getLogLevel() < 8) |
|
521 | - $to_file = false; |
|
531 | + if ($this->getLogLevel() < 8) { |
|
532 | + $to_file = false; |
|
533 | + } |
|
522 | 534 | $this->addTrace('DEBUG', $code, $context, $append_msg, $to_file); |
523 | 535 | } |
524 | 536 | } |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | )); |
59 | 59 | foreach ($files as $file) { |
60 | 60 | |
61 | - (is_dir("$pathname/$file") ? $this->rm("$pathname/$file", $shred) : (! empty($shred) && |
|
62 | - ! $this->isLink($pathname . DIRECTORY_SEPARATOR . $file) ? exec( |
|
61 | + (is_dir("$pathname/$file") ? $this->rm("$pathname/$file", $shred) : (!empty($shred) && |
|
62 | + !$this->isLink($pathname . DIRECTORY_SEPARATOR . $file) ? exec( |
|
63 | 63 | "shred -fzu $pathname" . DIRECTORY_SEPARATOR . "$file") : $this->rm( |
64 | 64 | $pathname . DIRECTORY_SEPARATOR . $file, $shred))); |
65 | 65 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } else { |
71 | 71 | $this->info(702, $pathname); |
72 | 72 | $this->response()->setStatus($response); |
73 | - (! empty($shred) && ! $this->isLink($pathname) ? exec("shred -fzu $pathname") : unlink($pathname)); |
|
73 | + (!empty($shred) && !$this->isLink($pathname) ? exec("shred -fzu $pathname") : unlink($pathname)); |
|
74 | 74 | } |
75 | 75 | return $response; |
76 | 76 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function scandir($path = false) |
84 | 84 | { |
85 | - return ! empty($path) && is_dir($this->makeAbsolute($path)) ? scandir($this->makeAbsolute($path)) : false; |
|
85 | + return !empty($path) && is_dir($this->makeAbsolute($path)) ? scandir($this->makeAbsolute($path)) : false; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function stat($filename = false) |
94 | 94 | { |
95 | - return ! empty($filename) && file_exists($this->makeAbsolute($filename)) ? stat( |
|
95 | + return !empty($filename) && file_exists($this->makeAbsolute($filename)) ? stat( |
|
96 | 96 | $this->makeAbsolute($filename)) : false; |
97 | 97 | } |
98 | 98 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function chgrp($filename = false, $group = false) |
181 | 181 | { |
182 | - return ! empty($filename) && $this->exists($this->makeAbsolute($filename)) ? chgrp( |
|
182 | + return !empty($filename) && $this->exists($this->makeAbsolute($filename)) ? chgrp( |
|
183 | 183 | $this->makeAbsolute($filename), $group) : false; |
184 | 184 | } |
185 | 185 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | public function chmod($filename = false, $mode = false) |
192 | 192 | { |
193 | 193 | $filename = $this->makeAbsolute($filename); |
194 | - if (file_exists($filename) && ! empty($mode) && is_int($mode)) |
|
194 | + if (file_exists($filename) && !empty($mode) && is_int($mode)) |
|
195 | 195 | return chmod($filename, octdec(str_pad($mode, 4, 0, STR_PAD_LEFT))); |
196 | 196 | else |
197 | 197 | return false; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | public function chown($filename = false, $user = false) |
206 | 206 | { |
207 | 207 | $filename = $this->makeAbsolute($filename); |
208 | - if (file_exists($filename) && ! empty($user)) |
|
208 | + if (file_exists($filename) && !empty($user)) |
|
209 | 209 | return chown($filename, $user); |
210 | 210 | else |
211 | 211 | return false; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | */ |
219 | 219 | public function clearstatcache($clear_realpath_cache = false, $filename = false) |
220 | 220 | { |
221 | - if (! empty($filename) && ! empty($clear_realpath_cache)) |
|
221 | + if (!empty($filename) && !empty($clear_realpath_cache)) |
|
222 | 222 | clearstatcache($clear_realpath_cache, $this->makeAbsolute($filename)); |
223 | 223 | else |
224 | 224 | clearstatcache(); |
@@ -234,13 +234,13 @@ discard block |
||
234 | 234 | $source = $this->makeAbsolute($source); |
235 | 235 | $dest = $this->makeAbsolute($dest); |
236 | 236 | |
237 | - if (! empty($source) && ! empty($dest) && ! is_dir($source)) { |
|
237 | + if (!empty($source) && !empty($dest) && !is_dir($source)) { |
|
238 | 238 | |
239 | 239 | if (empty($context)) |
240 | 240 | return copy($source, $dest); |
241 | 241 | else |
242 | 242 | return copy($source, $dest, $context); |
243 | - } elseif ((! empty($source) && ! empty($dest)) && is_dir($source) && ! file_exists($dest)) { |
|
243 | + } elseif ((!empty($source) && !empty($dest)) && is_dir($source) && !file_exists($dest)) { |
|
244 | 244 | |
245 | 245 | $tmp_key = basename($source); |
246 | 246 | $tmp_key2 = basename($dest); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $this->close($tmp_key2); |
252 | 252 | |
253 | 253 | foreach ($iterator = new RecursiveIteratorIterator( |
254 | - new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), // DirectoryTreeObject::CURRENT_AS_FILEINFO |
|
254 | + new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), // DirectoryTreeObject::CURRENT_AS_FILEINFO |
|
255 | 255 | \RecursiveIteratorIterator::SELF_FIRST) as $item) { |
256 | 256 | if ($item->isDir()) { |
257 | 257 | if (empty($context)) { |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $oldname = $this->makeAbsolute($oldname); |
290 | 290 | $newname = $this->makeAbsolute($newname); |
291 | 291 | |
292 | - if (! empty($context)) |
|
292 | + if (!empty($context)) |
|
293 | 293 | return rename($oldname, $newname, $context); |
294 | 294 | |
295 | 295 | return rename($oldname, $newname); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | if (empty($pattern)) |
306 | 306 | return false; |
307 | 307 | |
308 | - if (! empty($flags)) |
|
308 | + if (!empty($flags)) |
|
309 | 309 | return fnmatch($pattern, $string, $flags); |
310 | 310 | else |
311 | 311 | return fnmatch($pattern, $string); |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | unset($this->dirs[$this->dirkeys[$keyword]]); |
365 | 365 | unset($this->dirkeys[$keyword]); |
366 | 366 | return true; |
367 | - } elseif(!empty($keyword) && array_key_exists($keyword,$this->files)) { |
|
367 | + } elseif (!empty($keyword) && array_key_exists($keyword, $this->files)) { |
|
368 | 368 | $this->files[$keyword] = null; |
369 | 369 | unset($this->files[$keyword]); |
370 | 370 | return true; |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | |
386 | 386 | $filename = $this->makeAbsolute($filename); |
387 | 387 | |
388 | - $time = ! empty($time) ? $time : time(); |
|
389 | - $atime = ! empty($atime) ? $atime : time(); |
|
388 | + $time = !empty($time) ? $time : time(); |
|
389 | + $atime = !empty($atime) ? $atime : time(); |
|
390 | 390 | |
391 | 391 | return touch($filename, $time, $atime); |
392 | 392 | } |
@@ -421,16 +421,16 @@ discard block |
||
421 | 421 | $absolute_path = $this->makeAbsolute($rootpath); |
422 | 422 | if (empty($skip_debug)) |
423 | 423 | $this->debug(810); |
424 | - if (empty($rootpath) || ! is_array($data_array) || |
|
425 | - (! $this->isWritable($absolute_path) && ! $this->isWritable(dirname($absolute_path)))) |
|
424 | + if (empty($rootpath) || !is_array($data_array) || |
|
425 | + (!$this->isWritable($absolute_path) && !$this->isWritable(dirname($absolute_path)))) |
|
426 | 426 | return $this->warning(506) && false; |
427 | 427 | |
428 | - if (! $this->isDir($absolute_path)) |
|
428 | + if (!$this->isDir($absolute_path)) |
|
429 | 429 | mkdir($absolute_path, 0755, true); |
430 | 430 | |
431 | 431 | foreach ($data_array as $key => $val) { |
432 | 432 | if (is_array($val)) |
433 | - ! $this->createStructure($absolute_path . DIRECTORY_SEPARATOR . $key, $val, true); |
|
433 | + !$this->createStructure($absolute_path . DIRECTORY_SEPARATOR . $key, $val, true); |
|
434 | 434 | else |
435 | 435 | touch($absolute_path . DIRECTORY_SEPARATOR . $val); |
436 | 436 | } |
@@ -103,11 +103,13 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getDiskTotalSpace($partition_location = false, $convert = false) |
105 | 105 | { |
106 | - if (empty($partition_location)) |
|
107 | - $partition_location = $this->getCwd(); |
|
106 | + if (empty($partition_location)) { |
|
107 | + $partition_location = $this->getCwd(); |
|
108 | + } |
|
108 | 109 | |
109 | - if (empty($convert)) |
|
110 | - return disk_total_space($partition_location); |
|
110 | + if (empty($convert)) { |
|
111 | + return disk_total_space($partition_location); |
|
112 | + } |
|
111 | 113 | |
112 | 114 | $bytestotal = 0; |
113 | 115 | $suffixes = array( |
@@ -137,11 +139,13 @@ discard block |
||
137 | 139 | */ |
138 | 140 | public function getDiskFreeSpace($partition_location = false, $convert = false) |
139 | 141 | { |
140 | - if (empty($partition_location)) |
|
141 | - $partition_location = $this->getCwd(); |
|
142 | + if (empty($partition_location)) { |
|
143 | + $partition_location = $this->getCwd(); |
|
144 | + } |
|
142 | 145 | |
143 | - if (empty($convert)) |
|
144 | - return disk_free_space($partition_location); |
|
146 | + if (empty($convert)) { |
|
147 | + return disk_free_space($partition_location); |
|
148 | + } |
|
145 | 149 | |
146 | 150 | $result = [ |
147 | 151 | 0, |
@@ -191,10 +195,11 @@ discard block |
||
191 | 195 | public function chmod($filename = false, $mode = false) |
192 | 196 | { |
193 | 197 | $filename = $this->makeAbsolute($filename); |
194 | - if (file_exists($filename) && ! empty($mode) && is_int($mode)) |
|
195 | - return chmod($filename, octdec(str_pad($mode, 4, 0, STR_PAD_LEFT))); |
|
196 | - else |
|
197 | - return false; |
|
198 | + if (file_exists($filename) && ! empty($mode) && is_int($mode)) { |
|
199 | + return chmod($filename, octdec(str_pad($mode, 4, 0, STR_PAD_LEFT))); |
|
200 | + } else { |
|
201 | + return false; |
|
202 | + } |
|
198 | 203 | } |
199 | 204 | |
200 | 205 | /** |
@@ -205,10 +210,11 @@ discard block |
||
205 | 210 | public function chown($filename = false, $user = false) |
206 | 211 | { |
207 | 212 | $filename = $this->makeAbsolute($filename); |
208 | - if (file_exists($filename) && ! empty($user)) |
|
209 | - return chown($filename, $user); |
|
210 | - else |
|
211 | - return false; |
|
213 | + if (file_exists($filename) && ! empty($user)) { |
|
214 | + return chown($filename, $user); |
|
215 | + } else { |
|
216 | + return false; |
|
217 | + } |
|
212 | 218 | } |
213 | 219 | |
214 | 220 | /** |
@@ -218,10 +224,11 @@ discard block |
||
218 | 224 | */ |
219 | 225 | public function clearstatcache($clear_realpath_cache = false, $filename = false) |
220 | 226 | { |
221 | - if (! empty($filename) && ! empty($clear_realpath_cache)) |
|
222 | - clearstatcache($clear_realpath_cache, $this->makeAbsolute($filename)); |
|
223 | - else |
|
224 | - clearstatcache(); |
|
227 | + if (! empty($filename) && ! empty($clear_realpath_cache)) { |
|
228 | + clearstatcache($clear_realpath_cache, $this->makeAbsolute($filename)); |
|
229 | + } else { |
|
230 | + clearstatcache(); |
|
231 | + } |
|
225 | 232 | } |
226 | 233 | |
227 | 234 | /** |
@@ -236,10 +243,11 @@ discard block |
||
236 | 243 | |
237 | 244 | if (! empty($source) && ! empty($dest) && ! is_dir($source)) { |
238 | 245 | |
239 | - if (empty($context)) |
|
240 | - return copy($source, $dest); |
|
241 | - else |
|
242 | - return copy($source, $dest, $context); |
|
246 | + if (empty($context)) { |
|
247 | + return copy($source, $dest); |
|
248 | + } else { |
|
249 | + return copy($source, $dest, $context); |
|
250 | + } |
|
243 | 251 | } elseif ((! empty($source) && ! empty($dest)) && is_dir($source) && ! file_exists($dest)) { |
244 | 252 | |
245 | 253 | $tmp_key = basename($source); |
@@ -257,23 +265,24 @@ discard block |
||
257 | 265 | if (empty($context)) { |
258 | 266 | mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), |
259 | 267 | octdec(str_pad($iterator->getPerms(), 4, 0, STR_PAD_LEFT))); |
260 | - } |
|
261 | - |
|
262 | - else |
|
263 | - mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), |
|
268 | + } else { |
|
269 | + mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), |
|
264 | 270 | octdec(str_pad($iterator->getPerms(), 4, 0, STR_PAD_LEFT)), false, $context); |
271 | + } |
|
265 | 272 | } else { |
266 | - if (empty($context)) |
|
267 | - $this->copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); |
|
268 | - else |
|
269 | - $this->copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), |
|
273 | + if (empty($context)) { |
|
274 | + $this->copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); |
|
275 | + } else { |
|
276 | + $this->copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), |
|
270 | 277 | $context); |
278 | + } |
|
271 | 279 | } |
272 | 280 | } |
273 | 281 | |
274 | 282 | return true; |
275 | - } else |
|
276 | - return false; |
|
283 | + } else { |
|
284 | + return false; |
|
285 | + } |
|
277 | 286 | } |
278 | 287 | |
279 | 288 | /** |
@@ -283,14 +292,16 @@ discard block |
||
283 | 292 | */ |
284 | 293 | public function mv($oldname = false, $newname = false, $context = false) |
285 | 294 | { |
286 | - if (empty($oldname) || empty($newname)) |
|
287 | - return false; |
|
295 | + if (empty($oldname) || empty($newname)) { |
|
296 | + return false; |
|
297 | + } |
|
288 | 298 | |
289 | 299 | $oldname = $this->makeAbsolute($oldname); |
290 | 300 | $newname = $this->makeAbsolute($newname); |
291 | 301 | |
292 | - if (! empty($context)) |
|
293 | - return rename($oldname, $newname, $context); |
|
302 | + if (! empty($context)) { |
|
303 | + return rename($oldname, $newname, $context); |
|
304 | + } |
|
294 | 305 | |
295 | 306 | return rename($oldname, $newname); |
296 | 307 | } |
@@ -302,13 +313,15 @@ discard block |
||
302 | 313 | */ |
303 | 314 | public function namePatternMatch($pattern = false, $string = false, $flags = false) |
304 | 315 | { |
305 | - if (empty($pattern)) |
|
306 | - return false; |
|
316 | + if (empty($pattern)) { |
|
317 | + return false; |
|
318 | + } |
|
307 | 319 | |
308 | - if (! empty($flags)) |
|
309 | - return fnmatch($pattern, $string, $flags); |
|
310 | - else |
|
311 | - return fnmatch($pattern, $string); |
|
320 | + if (! empty($flags)) { |
|
321 | + return fnmatch($pattern, $string, $flags); |
|
322 | + } else { |
|
323 | + return fnmatch($pattern, $string); |
|
324 | + } |
|
312 | 325 | } |
313 | 326 | |
314 | 327 | /** |
@@ -380,8 +393,9 @@ discard block |
||
380 | 393 | */ |
381 | 394 | public function touch($filename = false, $time = false, $atime = false) |
382 | 395 | { |
383 | - if (empty($filename)) |
|
384 | - return false; |
|
396 | + if (empty($filename)) { |
|
397 | + return false; |
|
398 | + } |
|
385 | 399 | |
386 | 400 | $filename = $this->makeAbsolute($filename); |
387 | 401 | |
@@ -419,23 +433,28 @@ discard block |
||
419 | 433 | public function createStructure($rootpath, $data_array, $skip_debug = false) |
420 | 434 | { |
421 | 435 | $absolute_path = $this->makeAbsolute($rootpath); |
422 | - if (empty($skip_debug)) |
|
423 | - $this->debug(810); |
|
436 | + if (empty($skip_debug)) { |
|
437 | + $this->debug(810); |
|
438 | + } |
|
424 | 439 | if (empty($rootpath) || ! is_array($data_array) || |
425 | - (! $this->isWritable($absolute_path) && ! $this->isWritable(dirname($absolute_path)))) |
|
426 | - return $this->warning(506) && false; |
|
440 | + (! $this->isWritable($absolute_path) && ! $this->isWritable(dirname($absolute_path)))) { |
|
441 | + return $this->warning(506) && false; |
|
442 | + } |
|
427 | 443 | |
428 | - if (! $this->isDir($absolute_path)) |
|
429 | - mkdir($absolute_path, 0755, true); |
|
444 | + if (! $this->isDir($absolute_path)) { |
|
445 | + mkdir($absolute_path, 0755, true); |
|
446 | + } |
|
430 | 447 | |
431 | 448 | foreach ($data_array as $key => $val) { |
432 | - if (is_array($val)) |
|
433 | - ! $this->createStructure($absolute_path . DIRECTORY_SEPARATOR . $key, $val, true); |
|
434 | - else |
|
435 | - touch($absolute_path . DIRECTORY_SEPARATOR . $val); |
|
449 | + if (is_array($val)) { |
|
450 | + ! $this->createStructure($absolute_path . DIRECTORY_SEPARATOR . $key, $val, true); |
|
451 | + } else { |
|
452 | + touch($absolute_path . DIRECTORY_SEPARATOR . $val); |
|
453 | + } |
|
454 | + } |
|
455 | + if (empty($skip_debug)) { |
|
456 | + $this->info(704, $rootpath); |
|
436 | 457 | } |
437 | - if (empty($skip_debug)) |
|
438 | - $this->info(704, $rootpath); |
|
439 | 458 | return true; |
440 | 459 | } |
441 | 460 | } |
@@ -248,7 +248,7 @@ |
||
248 | 248 | continue; |
249 | 249 | |
250 | 250 | $fparam = $df . (empty($sfx) ? $locale[$lkey][0] : ' ' . |
251 | - (($interval->$lkey === 1) ? $locale[$lkey][1] : $locale[$lkey][2])); |
|
251 | + (($interval->$lkey === 1) ? $locale[$lkey][1] : $locale[$lkey][2])); |
|
252 | 252 | |
253 | 253 | if (! empty($ago_single) && ! empty($dfs)) |
254 | 254 | break; |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | else |
43 | 43 | $current_working_directory = $this->makeAbsolute($path); |
44 | 44 | |
45 | - if (! empty($validate_dir_name) && (basename($current_working_directory) !== $validate_dir_name)) |
|
45 | + if (!empty($validate_dir_name) && (basename($current_working_directory) !== $validate_dir_name)) |
|
46 | 46 | return false; |
47 | 47 | |
48 | - if (! is_dir($current_working_directory) || ! is_readable($current_working_directory) || |
|
49 | - ! chdir($current_working_directory)) { |
|
48 | + if (!is_dir($current_working_directory) || !is_readable($current_working_directory) || |
|
49 | + !chdir($current_working_directory)) { |
|
50 | 50 | $this->alert(200, false, $current_working_directory); |
51 | 51 | return false; |
52 | 52 | } |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function getSize($convert = false, $filename = false) |
76 | 76 | { |
77 | - $filename = ! empty($filename) ? $this->makeAbsolute($filename) : false; |
|
77 | + $filename = !empty($filename) ? $this->makeAbsolute($filename) : false; |
|
78 | 78 | $bytestotal = empty($filename) ? ((method_exists(get_parent_class($this), 'getSize')) ? parent::getSize() : false) : filesize( |
79 | 79 | $filename); |
80 | 80 | |
81 | - if (! $this->isDir($filename) && empty($convert)) |
|
81 | + if (!$this->isDir($filename) && empty($convert)) |
|
82 | 82 | return $bytestotal; |
83 | 83 | |
84 | 84 | $suffixes = array( |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS)) as $object) { |
102 | 102 | $bytestotal += $object->getSize(); |
103 | 103 | } |
104 | - if (! $convert) |
|
104 | + if (!$convert) |
|
105 | 105 | return $bytestotal; |
106 | 106 | } |
107 | 107 | $base = log($bytestotal, 1024); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $suffixes[floor($base)] |
118 | 118 | ); |
119 | 119 | } |
120 | - return ! empty($convert) ? $result : $result[0]; |
|
120 | + return !empty($convert) ? $result : $result[0]; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | public function getATime($timeformat = false, $pathname = false) |
129 | 129 | { |
130 | 130 | $atime = empty($pathname) ? parent::getATime() : fileatime($this->makeAbsolute($pathname)); |
131 | - if (! empty($timeformat) && is_int($atime)) { |
|
131 | + if (!empty($timeformat) && is_int($atime)) { |
|
132 | 132 | switch ($timeformat) { |
133 | 133 | case 'ago': |
134 | 134 | $atime = $this->ct_ago($atime, 'y,m,d,h,i,s', false, true); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | public function getCTime($timeformat = false, $pathname = false) |
153 | 153 | { |
154 | 154 | $ctime = empty($pathname) ? parent::getCTime() : filectime($this->makeAbsolute($pathname)); |
155 | - if (! empty($timeformat) && is_int($ctime)) { |
|
155 | + if (!empty($timeformat) && is_int($ctime)) { |
|
156 | 156 | switch ($timeformat) { |
157 | 157 | case 'ago': |
158 | 158 | $ctime = $this->ct_ago($ctime, 'y,m,d,h,i,s', false, true); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | public function getMTime($timeformat = false, $pathname = false) |
177 | 177 | { |
178 | 178 | $mtime = empty($pathname) ? parent::getMTime() : filemtime($this->makeAbsolute($pathname)); |
179 | - if (! empty($timeformat) && is_int($mtime)) { |
|
179 | + if (!empty($timeformat) && is_int($mtime)) { |
|
180 | 180 | switch ($timeformat) { |
181 | 181 | case 'ago': |
182 | 182 | $mtime = $this->ct_ago($mtime, 'y,m,d,h,i,s', false, true); |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | $fparam = $df . (empty($sfx) ? $locale[$lkey][0] : ' ' . |
251 | 251 | (($interval->$lkey === 1) ? $locale[$lkey][1] : $locale[$lkey][2])); |
252 | 252 | |
253 | - if (! empty($ago_single) && ! empty($dfs)) |
|
253 | + if (!empty($ago_single) && !empty($dfs)) |
|
254 | 254 | break; |
255 | 255 | else |
256 | - $dfs = ! empty($dfs) ? $dfs . "%$fparam " : "%$fparam "; |
|
256 | + $dfs = !empty($dfs) ? $dfs . "%$fparam " : "%$fparam "; |
|
257 | 257 | } |
258 | 258 | if (empty($dfs)) |
259 | 259 | $ret = $locale['now']; |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | */ |
270 | 270 | public function openFile($open_mode = "r", $use_include_path = false, $context = null) |
271 | 271 | { |
272 | - if (! method_exists(get_parent_class($this), 'openFile')) |
|
272 | + if (!method_exists(get_parent_class($this), 'openFile')) |
|
273 | 273 | return false; |
274 | 274 | |
275 | - return ! $this->isDir() ? (! empty($context) ? parent::openFile($open_mode, $use_include_path, |
|
275 | + return !$this->isDir() ? (!empty($context) ? parent::openFile($open_mode, $use_include_path, |
|
276 | 276 | $context) : parent::openFile($open_mode, $use_include_path)) : false; |
277 | 277 | } |
278 | 278 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | */ |
284 | 284 | public function setFileClass($class_name = "\HOWI3\libhowi\Filesystem\php7\Objects\FileObject") |
285 | 285 | { |
286 | - if (! method_exists(get_parent_class($this), 'setFileClass')) |
|
286 | + if (!method_exists(get_parent_class($this), 'setFileClass')) |
|
287 | 287 | return false; |
288 | 288 | |
289 | 289 | if (is_subclass_of($class_name, 'SplFileObject') || $class_name === 'SplFileObject') { |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public function setInfoClass($class_name = "\HOWI3\libhowi\Filesystem\php7\Objects\InfoObject") |
302 | 302 | { |
303 | - if (! method_exists(get_parent_class($this), 'setInfoClass')) |
|
303 | + if (!method_exists(get_parent_class($this), 'setInfoClass')) |
|
304 | 304 | return false; |
305 | 305 | |
306 | 306 | if (is_subclass_of($class_name, 'SplFileInfo') || $class_name === 'SplFileInfo') { |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function getOwnerName($filename = false) |
319 | 319 | { |
320 | - $userID = empty($filename) && method_exists(get_parent_class($this), 'getOwner') ? parent::getOwner() : (! empty( |
|
320 | + $userID = empty($filename) && method_exists(get_parent_class($this), 'getOwner') ? parent::getOwner() : (!empty( |
|
321 | 321 | $filename) ? fileowner($this->makeAbsolute($filename)) : false); |
322 | - $user = ! empty($userID) ? posix_getpwuid($userID) : false; |
|
322 | + $user = !empty($userID) ? posix_getpwuid($userID) : false; |
|
323 | 323 | return is_array($user) && array_key_exists('name', $user) ? $user['name'] : false; |
324 | 324 | } |
325 | 325 | |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | { |
333 | 333 | $groupID = empty($filename) ? ((method_exists(get_parent_class($this), 'getGroup')) ? parent::getGroup() : false) : filegroup( |
334 | 334 | $this->makeAbsolute($filename)); |
335 | - $group = ! empty($groupID) ? posix_getgrgid($groupID) : false; |
|
336 | - return ! empty($group) && array_key_exists('name', $group) ? $group['name'] : false; |
|
335 | + $group = !empty($groupID) ? posix_getgrgid($groupID) : false; |
|
336 | + return !empty($group) && array_key_exists('name', $group) ? $group['name'] : false; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function getRealpath($filename = false) |
345 | 345 | { |
346 | - return ! empty($filename) ? realpath($this->makeAbsolute($filename)) : ((method_exists( |
|
346 | + return !empty($filename) ? realpath($this->makeAbsolute($filename)) : ((method_exists( |
|
347 | 347 | get_parent_class($this), 'getRealpath')) ? parent::getRealpath() : false); |
348 | 348 | } |
349 | 349 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | public function getPathInfo($filename = false, $flags = false, |
356 | 356 | $class_name = '\HOWI3\libhowi\Filesystem\php7\Objects\InfoObject') |
357 | 357 | { |
358 | - return ! empty($filename) ? empty($flags) ? pathinfo($this->makeAbsolute($filename)) : pathinfo( |
|
358 | + return !empty($filename) ? empty($flags) ? pathinfo($this->makeAbsolute($filename)) : pathinfo( |
|
359 | 359 | $this->makeAbsolute($filename), $flags) : (method_exists(get_parent_class($this), 'getPathInfo') ? parent::getPathInfo( |
360 | 360 | $class_name) : false); |
361 | 361 | } |
@@ -421,9 +421,9 @@ discard block |
||
421 | 421 | */ |
422 | 422 | public function getBasename($suffix = false, $pathname = false) |
423 | 423 | { |
424 | - $pathname = ! empty($pathname) ? $pathname : ($this->isDot() ? $this->getPath() : false); |
|
425 | - $suffix = ! empty($suffix) ? $suffix : ''; |
|
426 | - return ! empty($pathname) || ! method_exists(get_parent_class($this), 'getBasename') ? basename( |
|
424 | + $pathname = !empty($pathname) ? $pathname : ($this->isDot() ? $this->getPath() : false); |
|
425 | + $suffix = !empty($suffix) ? $suffix : ''; |
|
426 | + return !empty($pathname) || !method_exists(get_parent_class($this), 'getBasename') ? basename( |
|
427 | 427 | $pathname, $suffix) : parent::getBasename($suffix); |
428 | 428 | } |
429 | 429 | |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | { |
437 | 437 | $perms = empty($filename) ? ((method_exists(get_parent_class($this), 'getPerms')) ? parent::getPerms() : false) : fileperms( |
438 | 438 | $this->makeAbsolute($filename)); |
439 | - return ! empty($perms) ? (int) ltrim(substr(sprintf('%o', $perms), - 4), '0') : false; |
|
439 | + return !empty($perms) ? (int) ltrim(substr(sprintf('%o', $perms), - 4), '0') : false; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | */ |
447 | 447 | public function getType($filename = false) |
448 | 448 | { |
449 | - return ! empty($filename) ? filetype($this->makeAbsolute($filename)) : ((method_exists( |
|
449 | + return !empty($filename) ? filetype($this->makeAbsolute($filename)) : ((method_exists( |
|
450 | 450 | get_parent_class($this), 'getType')) ? parent::getType() : false); |
451 | 451 | } |
452 | 452 | |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | */ |
524 | 524 | public function isExecutable($filename = false) |
525 | 525 | { |
526 | - return ! empty($filename) ? is_executable($this->makeAbsolute($filename)) : ((method_exists( |
|
526 | + return !empty($filename) ? is_executable($this->makeAbsolute($filename)) : ((method_exists( |
|
527 | 527 | get_parent_class($this), 'isExecutable')) ? parent::isExecutable() : false); |
528 | 528 | } |
529 | 529 | |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | */ |
535 | 535 | public function isFile($filename = false) |
536 | 536 | { |
537 | - return ! empty($filename) ? is_file($this->makeAbsolute($filename)) : ((method_exists( |
|
537 | + return !empty($filename) ? is_file($this->makeAbsolute($filename)) : ((method_exists( |
|
538 | 538 | get_parent_class($this), 'isFile')) ? parent::isFile() : false); |
539 | 539 | } |
540 | 540 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | */ |
546 | 546 | public function isLink($filename = false) |
547 | 547 | { |
548 | - return ! empty($filename) ? is_link($this->makeAbsolute($filename)) : ((method_exists( |
|
548 | + return !empty($filename) ? is_link($this->makeAbsolute($filename)) : ((method_exists( |
|
549 | 549 | get_parent_class($this), 'isLink')) ? parent::isLink() : false); |
550 | 550 | } |
551 | 551 | |
@@ -556,9 +556,9 @@ discard block |
||
556 | 556 | */ |
557 | 557 | public function makeAbsolute($path = false) |
558 | 558 | { |
559 | - if (! empty($path) && $this->isAbsolute($path)) |
|
559 | + if (!empty($path) && $this->isAbsolute($path)) |
|
560 | 560 | $absolute_path = $path; |
561 | - elseif (! empty($path) && $this->isRelative($path)) { |
|
561 | + elseif (!empty($path) && $this->isRelative($path)) { |
|
562 | 562 | |
563 | 563 | if (preg_match('/^(~\/)/', $path) === 1) { |
564 | 564 | $absolute_path = getenv("HOME") . substr($path, 1); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | |
585 | 585 | $pathname = $this->makeAbsolute($pathname); |
586 | 586 | |
587 | - return ! empty($pathname) ? file_exists($pathname) : false; |
|
587 | + return !empty($pathname) ? file_exists($pathname) : false; |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | /** |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | */ |
595 | 595 | public function getFilename($filename = false) |
596 | 596 | { |
597 | - return ! empty($filename) ? basename($this->makeAbsolute($filename)) : ((method_exists( |
|
597 | + return !empty($filename) ? basename($this->makeAbsolute($filename)) : ((method_exists( |
|
598 | 598 | get_parent_class($this), 'getFilename')) ? parent::getFilename() : false); |
599 | 599 | } |
600 | 600 | |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | */ |
606 | 606 | public function getExtension($filename = false) |
607 | 607 | { |
608 | - return ! empty($filename) ? pathinfo($this->makeAbsolute($filename), PATHINFO_EXTENSION) : ((method_exists( |
|
608 | + return !empty($filename) ? pathinfo($this->makeAbsolute($filename), PATHINFO_EXTENSION) : ((method_exists( |
|
609 | 609 | get_parent_class($this), 'getExtension')) ? parent::getExtension() : false); |
610 | 610 | } |
611 | 611 | } |
@@ -37,13 +37,15 @@ discard block |
||
37 | 37 | */ |
38 | 38 | protected function setCwd($path = false, $validate_dir_name = false) |
39 | 39 | { |
40 | - if (empty($path)) |
|
41 | - $current_working_directory = $this->getCwd(); |
|
42 | - else |
|
43 | - $current_working_directory = $this->makeAbsolute($path); |
|
40 | + if (empty($path)) { |
|
41 | + $current_working_directory = $this->getCwd(); |
|
42 | + } else { |
|
43 | + $current_working_directory = $this->makeAbsolute($path); |
|
44 | + } |
|
44 | 45 | |
45 | - if (! empty($validate_dir_name) && (basename($current_working_directory) !== $validate_dir_name)) |
|
46 | - return false; |
|
46 | + if (! empty($validate_dir_name) && (basename($current_working_directory) !== $validate_dir_name)) { |
|
47 | + return false; |
|
48 | + } |
|
47 | 49 | |
48 | 50 | if (! is_dir($current_working_directory) || ! is_readable($current_working_directory) || |
49 | 51 | ! chdir($current_working_directory)) { |
@@ -61,8 +63,9 @@ discard block |
||
61 | 63 | */ |
62 | 64 | public function getCwd() |
63 | 65 | { |
64 | - if (empty($this->cwd)) |
|
65 | - $this->cwd = getcwd(); |
|
66 | + if (empty($this->cwd)) { |
|
67 | + $this->cwd = getcwd(); |
|
68 | + } |
|
66 | 69 | |
67 | 70 | return $this->cwd; |
68 | 71 | } |
@@ -78,8 +81,9 @@ discard block |
||
78 | 81 | $bytestotal = empty($filename) ? ((method_exists(get_parent_class($this), 'getSize')) ? parent::getSize() : false) : filesize( |
79 | 82 | $filename); |
80 | 83 | |
81 | - if (! $this->isDir($filename) && empty($convert)) |
|
82 | - return $bytestotal; |
|
84 | + if (! $this->isDir($filename) && empty($convert)) { |
|
85 | + return $bytestotal; |
|
86 | + } |
|
83 | 87 | |
84 | 88 | $suffixes = array( |
85 | 89 | 'B', |
@@ -94,15 +98,17 @@ discard block |
||
94 | 98 | ); |
95 | 99 | if ($this->isDir($filename)) { |
96 | 100 | $path = ((method_exists(get_class($this), 'getPathname')) ? $this->getPathname() : $filename); |
97 | - if ($path === '/home/nitrotrigger/tmp/libhowi-filesystem/log/phpunit_test.log') |
|
98 | - die('ss'); |
|
101 | + if ($path === '/home/nitrotrigger/tmp/libhowi-filesystem/log/phpunit_test.log') { |
|
102 | + die('ss'); |
|
103 | + } |
|
99 | 104 | |
100 | 105 | foreach (new RecursiveIteratorIterator( |
101 | 106 | new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS)) as $object) { |
102 | 107 | $bytestotal += $object->getSize(); |
103 | 108 | } |
104 | - if (! $convert) |
|
105 | - return $bytestotal; |
|
109 | + if (! $convert) { |
|
110 | + return $bytestotal; |
|
111 | + } |
|
106 | 112 | } |
107 | 113 | $base = log($bytestotal, 1024); |
108 | 114 | |
@@ -244,21 +250,24 @@ discard block |
||
244 | 250 | for ($df = strtok($date_format, ','); $df !== false; $df = strtok(",")) { |
245 | 251 | $lkey = ($df !== 'a') ? strtolower($df) : 'days'; |
246 | 252 | |
247 | - if ($ommit_zero && $interval->$lkey === 0) |
|
248 | - continue; |
|
253 | + if ($ommit_zero && $interval->$lkey === 0) { |
|
254 | + continue; |
|
255 | + } |
|
249 | 256 | |
250 | 257 | $fparam = $df . (empty($sfx) ? $locale[$lkey][0] : ' ' . |
251 | 258 | (($interval->$lkey === 1) ? $locale[$lkey][1] : $locale[$lkey][2])); |
252 | 259 | |
253 | - if (! empty($ago_single) && ! empty($dfs)) |
|
254 | - break; |
|
255 | - else |
|
256 | - $dfs = ! empty($dfs) ? $dfs . "%$fparam " : "%$fparam "; |
|
260 | + if (! empty($ago_single) && ! empty($dfs)) { |
|
261 | + break; |
|
262 | + } else { |
|
263 | + $dfs = ! empty($dfs) ? $dfs . "%$fparam " : "%$fparam "; |
|
264 | + } |
|
265 | + } |
|
266 | + if (empty($dfs)) { |
|
267 | + $ret = $locale['now']; |
|
268 | + } else { |
|
269 | + $ret = $interval->format($dfs) . $locale['ago']; |
|
257 | 270 | } |
258 | - if (empty($dfs)) |
|
259 | - $ret = $locale['now']; |
|
260 | - else |
|
261 | - $ret = $interval->format($dfs) . $locale['ago']; |
|
262 | 271 | return $ret; |
263 | 272 | } |
264 | 273 | |
@@ -269,8 +278,9 @@ discard block |
||
269 | 278 | */ |
270 | 279 | public function openFile($open_mode = "r", $use_include_path = false, $context = null) |
271 | 280 | { |
272 | - if (! method_exists(get_parent_class($this), 'openFile')) |
|
273 | - return false; |
|
281 | + if (! method_exists(get_parent_class($this), 'openFile')) { |
|
282 | + return false; |
|
283 | + } |
|
274 | 284 | |
275 | 285 | return ! $this->isDir() ? (! empty($context) ? parent::openFile($open_mode, $use_include_path, |
276 | 286 | $context) : parent::openFile($open_mode, $use_include_path)) : false; |
@@ -283,8 +293,9 @@ discard block |
||
283 | 293 | */ |
284 | 294 | public function setFileClass($class_name = "\HOWI3\libhowi\Filesystem\php7\Objects\FileObject") |
285 | 295 | { |
286 | - if (! method_exists(get_parent_class($this), 'setFileClass')) |
|
287 | - return false; |
|
296 | + if (! method_exists(get_parent_class($this), 'setFileClass')) { |
|
297 | + return false; |
|
298 | + } |
|
288 | 299 | |
289 | 300 | if (is_subclass_of($class_name, 'SplFileObject') || $class_name === 'SplFileObject') { |
290 | 301 | parent::setFileClass($class_name); |
@@ -300,8 +311,9 @@ discard block |
||
300 | 311 | */ |
301 | 312 | public function setInfoClass($class_name = "\HOWI3\libhowi\Filesystem\php7\Objects\InfoObject") |
302 | 313 | { |
303 | - if (! method_exists(get_parent_class($this), 'setInfoClass')) |
|
304 | - return false; |
|
314 | + if (! method_exists(get_parent_class($this), 'setInfoClass')) { |
|
315 | + return false; |
|
316 | + } |
|
305 | 317 | |
306 | 318 | if (is_subclass_of($class_name, 'SplFileInfo') || $class_name === 'SplFileInfo') { |
307 | 319 | parent::setInfoClass($class_name); |
@@ -556,16 +568,17 @@ discard block |
||
556 | 568 | */ |
557 | 569 | public function makeAbsolute($path = false) |
558 | 570 | { |
559 | - if (! empty($path) && $this->isAbsolute($path)) |
|
560 | - $absolute_path = $path; |
|
561 | - elseif (! empty($path) && $this->isRelative($path)) { |
|
571 | + if (! empty($path) && $this->isAbsolute($path)) { |
|
572 | + $absolute_path = $path; |
|
573 | + } elseif (! empty($path) && $this->isRelative($path)) { |
|
562 | 574 | |
563 | 575 | if (preg_match('/^(~\/)/', $path) === 1) { |
564 | 576 | $absolute_path = getenv("HOME") . substr($path, 1); |
565 | 577 | } elseif (preg_match('/^(.\/|..\/)/', $path) === 1) { |
566 | 578 | $absolute_path = realpath($path); |
567 | - } else |
|
568 | - $absolute_path = $this->getCwd() . ($path !== '.' ? DIRECTORY_SEPARATOR . $path : ''); |
|
579 | + } else { |
|
580 | + $absolute_path = $this->getCwd() . ($path !== '.' ? DIRECTORY_SEPARATOR . $path : ''); |
|
581 | + } |
|
569 | 582 | } else { |
570 | 583 | $absolute_path = $path; |
571 | 584 | } |
@@ -579,8 +592,9 @@ discard block |
||
579 | 592 | */ |
580 | 593 | public function exists($pathname = false) |
581 | 594 | { |
582 | - if (empty($pathname)) |
|
583 | - return false; |
|
595 | + if (empty($pathname)) { |
|
596 | + return false; |
|
597 | + } |
|
584 | 598 | |
585 | 599 | $pathname = $this->makeAbsolute($pathname); |
586 | 600 |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function c($basename = false) |
49 | 49 | { |
50 | - if (! empty($basename) && array_key_exists($basename, $this->dirkeys)) |
|
50 | + if (!empty($basename) && array_key_exists($basename, $this->dirkeys)) |
|
51 | 51 | $c = $this->dirkeys[$basename]; |
52 | - elseif (! empty($basename) && is_dir($this->getPath() . DIRECTORY_SEPARATOR . $basename)) { |
|
52 | + elseif (!empty($basename) && is_dir($this->getPath() . DIRECTORY_SEPARATOR . $basename)) { |
|
53 | 53 | $c = new DirectoryTreeObject($this->getPath() . DIRECTORY_SEPARATOR . $basename, |
54 | 54 | DirectoryTreeObject::SKIP_DOTS); |
55 | 55 | $c->setFileClass('\HOWI3\libhowi\Filesystem\php7\Objects\FileObject'); |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | $display = []; |
94 | 94 | |
95 | 95 | while ($this->valid()) { |
96 | - if (! $this->isDot()) { |
|
97 | - if ($this->isDir() && ! $this->isLink() && ! empty($sort)) |
|
96 | + if (!$this->isDot()) { |
|
97 | + if ($this->isDir() && !$this->isLink() && !empty($sort)) |
|
98 | 98 | $ls['dir'][$this->getFilename()] = $this->getType(); |
99 | 99 | |
100 | - elseif ($this->isLink() && ! empty($sort)) |
|
100 | + elseif ($this->isLink() && !empty($sort)) |
|
101 | 101 | $ls['link'][$this->getFilename()] = $this->getType(); |
102 | 102 | |
103 | - elseif ($this->isFile() && ! empty($sort)) |
|
103 | + elseif ($this->isFile() && !empty($sort)) |
|
104 | 104 | $ls['file'][$this->getFilename()] = $this->getType(); |
105 | 105 | else |
106 | 106 | $display[$this->getFilename()] = $this->getType(); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | $this->next(); |
114 | 114 | } |
115 | - if (! empty($sort)) { |
|
115 | + if (!empty($sort)) { |
|
116 | 116 | |
117 | 117 | ksort($ls['dir']); |
118 | 118 | ksort($ls['link']); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | while ($this->valid()) { |
144 | 144 | |
145 | - if (! $this->isDot()) { |
|
145 | + if (!$this->isDot()) { |
|
146 | 146 | $cname = $this->getFilename(); |
147 | 147 | $lsinfo[$cname] = new \stdClass(); |
148 | 148 | $lsinfo[$cname]->name = $this->getFilename(); |
@@ -153,20 +153,20 @@ discard block |
||
153 | 153 | $lsinfo[$cname]->tchange = $this->getCTime($timeformat); |
154 | 154 | $lsinfo[$cname]->tmodify = $this->getMTime($timeformat); |
155 | 155 | |
156 | - if ($this->isDir() && ! $this->isLink() && ! empty($sort)) |
|
156 | + if ($this->isDir() && !$this->isLink() && !empty($sort)) |
|
157 | 157 | $ls['dir'][$cname] = $lsinfo[$cname]->type; |
158 | 158 | |
159 | - elseif ($this->isLink() && ! empty($sort)) |
|
159 | + elseif ($this->isLink() && !empty($sort)) |
|
160 | 160 | $ls['link'][$cname] = $lsinfo[$cname]->type; |
161 | 161 | |
162 | - elseif ($this->isFile() && ! empty($sort)) |
|
162 | + elseif ($this->isFile() && !empty($sort)) |
|
163 | 163 | $ls['file'][$cname] = $lsinfo[$cname]->type; |
164 | 164 | else |
165 | 165 | $display[$cname] = $lsinfo[$cname]->type; |
166 | 166 | } |
167 | 167 | $this->next(); |
168 | 168 | } |
169 | - if (! empty($sort)) { |
|
169 | + if (!empty($sort)) { |
|
170 | 170 | ksort($ls['dir']); |
171 | 171 | ksort($ls['link']); |
172 | 172 | ksort($ls['file']); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $splFileInfo->getFilename() |
200 | 200 | ); |
201 | 201 | |
202 | - for ($depth = $ritit->getDepth() - 1; $depth >= 0; $depth --) { |
|
202 | + for ($depth = $ritit->getDepth() - 1; $depth >= 0; $depth--) { |
|
203 | 203 | $path = array( |
204 | 204 | $ritit->getSubIterator($depth) |
205 | 205 | ->current() |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function c($basename = false) |
49 | 49 | { |
50 | - if (! empty($basename) && array_key_exists($basename, $this->dirkeys)) |
|
51 | - $c = $this->dirkeys[$basename]; |
|
52 | - elseif (! empty($basename) && is_dir($this->getPath() . DIRECTORY_SEPARATOR . $basename)) { |
|
50 | + if (! empty($basename) && array_key_exists($basename, $this->dirkeys)) { |
|
51 | + $c = $this->dirkeys[$basename]; |
|
52 | + } elseif (! empty($basename) && is_dir($this->getPath() . DIRECTORY_SEPARATOR . $basename)) { |
|
53 | 53 | $c = new DirectoryTreeObject($this->getPath() . DIRECTORY_SEPARATOR . $basename, |
54 | 54 | DirectoryTreeObject::SKIP_DOTS); |
55 | 55 | $c->setFileClass('\HOWI3\libhowi\Filesystem\php7\Objects\FileObject'); |
@@ -58,10 +58,9 @@ discard block |
||
58 | 58 | $c->setLogLevel($this->getLogLevel()); |
59 | 59 | $c->setUID($this->getUID()); |
60 | 60 | $c->setUsername($this->getUsername()); |
61 | - } |
|
62 | - |
|
63 | - else |
|
64 | - $c = false; |
|
61 | + } else { |
|
62 | + $c = false; |
|
63 | + } |
|
65 | 64 | |
66 | 65 | return $this->dirkeys[$basename] = $c; |
67 | 66 | } |
@@ -94,16 +93,15 @@ discard block |
||
94 | 93 | |
95 | 94 | while ($this->valid()) { |
96 | 95 | if (! $this->isDot()) { |
97 | - if ($this->isDir() && ! $this->isLink() && ! empty($sort)) |
|
98 | - $ls['dir'][$this->getFilename()] = $this->getType(); |
|
99 | - |
|
100 | - elseif ($this->isLink() && ! empty($sort)) |
|
101 | - $ls['link'][$this->getFilename()] = $this->getType(); |
|
102 | - |
|
103 | - elseif ($this->isFile() && ! empty($sort)) |
|
104 | - $ls['file'][$this->getFilename()] = $this->getType(); |
|
105 | - else |
|
106 | - $display[$this->getFilename()] = $this->getType(); |
|
96 | + if ($this->isDir() && ! $this->isLink() && ! empty($sort)) { |
|
97 | + $ls['dir'][$this->getFilename()] = $this->getType(); |
|
98 | + } elseif ($this->isLink() && ! empty($sort)) { |
|
99 | + $ls['link'][$this->getFilename()] = $this->getType(); |
|
100 | + } elseif ($this->isFile() && ! empty($sort)) { |
|
101 | + $ls['file'][$this->getFilename()] = $this->getType(); |
|
102 | + } else { |
|
103 | + $display[$this->getFilename()] = $this->getType(); |
|
104 | + } |
|
107 | 105 | |
108 | 106 | if ($this->isDir() || $this->isLink()) { |
109 | 107 | $this->dirkeys[$this->getFilename()] = $this->getChildren(); |
@@ -153,16 +151,15 @@ discard block |
||
153 | 151 | $lsinfo[$cname]->tchange = $this->getCTime($timeformat); |
154 | 152 | $lsinfo[$cname]->tmodify = $this->getMTime($timeformat); |
155 | 153 | |
156 | - if ($this->isDir() && ! $this->isLink() && ! empty($sort)) |
|
157 | - $ls['dir'][$cname] = $lsinfo[$cname]->type; |
|
158 | - |
|
159 | - elseif ($this->isLink() && ! empty($sort)) |
|
160 | - $ls['link'][$cname] = $lsinfo[$cname]->type; |
|
161 | - |
|
162 | - elseif ($this->isFile() && ! empty($sort)) |
|
163 | - $ls['file'][$cname] = $lsinfo[$cname]->type; |
|
164 | - else |
|
165 | - $display[$cname] = $lsinfo[$cname]->type; |
|
154 | + if ($this->isDir() && ! $this->isLink() && ! empty($sort)) { |
|
155 | + $ls['dir'][$cname] = $lsinfo[$cname]->type; |
|
156 | + } elseif ($this->isLink() && ! empty($sort)) { |
|
157 | + $ls['link'][$cname] = $lsinfo[$cname]->type; |
|
158 | + } elseif ($this->isFile() && ! empty($sort)) { |
|
159 | + $ls['file'][$cname] = $lsinfo[$cname]->type; |
|
160 | + } else { |
|
161 | + $display[$cname] = $lsinfo[$cname]->type; |
|
162 | + } |
|
166 | 163 | } |
167 | 164 | $this->next(); |
168 | 165 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function flock($operation, &$wouldblock = NULL) |
50 | 50 | { |
51 | - return ! $wouldblock ? parent::flock($operation) : parent::flock($operation, $wouldblock); |
|
51 | + return !$wouldblock ? parent::flock($operation) : parent::flock($operation, $wouldblock); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function dummyScale($size) |
89 | 89 | { |
90 | - if(!is_int($size) || $this->getSize() > $size) return false; |
|
90 | + if (!is_int($size) || $this->getSize() > $size) return false; |
|
91 | 91 | |
92 | - $this->fseek($size ,SEEK_SET); |
|
92 | + $this->fseek($size, SEEK_SET); |
|
93 | 93 | $this->fwrite(' '); |
94 | 94 | return true; |
95 | 95 | } |
@@ -87,7 +87,9 @@ |
||
87 | 87 | */ |
88 | 88 | public function dummyScale($size) |
89 | 89 | { |
90 | - if(!is_int($size) || $this->getSize() > $size) return false; |
|
90 | + if(!is_int($size) || $this->getSize() > $size) { |
|
91 | + return false; |
|
92 | + } |
|
91 | 93 | |
92 | 94 | $this->fseek($size ,SEEK_SET); |
93 | 95 | $this->fwrite(' '); |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function setTmp($path = false) |
44 | 44 | { |
45 | - if (! empty($path)) { |
|
45 | + if (!empty($path)) { |
|
46 | 46 | $tmp = $this->makeAbsolute($path); |
47 | 47 | $isWritable = $this->isWritable($tmp); |
48 | 48 | $this->tmp_path = $isWritable ? $tmp : $this->tmp_path; |
49 | 49 | |
50 | - ! empty($isWritable) ? $this->debug(803) : $this->warning(501, $tmp); |
|
50 | + !empty($isWritable) ? $this->debug(803) : $this->warning(501, $tmp); |
|
51 | 51 | $this->response()->setStatus($isWritable); |
52 | 52 | } else { |
53 | 53 | $this->tmp_path = sys_get_temp_dir(); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | { |
101 | 101 | $this->debug(807); |
102 | 102 | $tmpfie = tmpfile(); |
103 | - $this->response()->setStatus(! empty($tmpfie) ? true : false); |
|
103 | + $this->response()->setStatus(!empty($tmpfie) ? true : false); |
|
104 | 104 | return $tmpfie; |
105 | 105 | } |
106 | 106 | } |
@@ -66,8 +66,9 @@ |
||
66 | 66 | */ |
67 | 67 | public function getTmp() |
68 | 68 | { |
69 | - if (empty($this->tmp_path)) |
|
70 | - $this->tmp_path = $this->setTmp(); |
|
69 | + if (empty($this->tmp_path)) { |
|
70 | + $this->tmp_path = $this->setTmp(); |
|
71 | + } |
|
71 | 72 | |
72 | 73 | $this->debug(805, $this->tmp_path); |
73 | 74 | $this->response()->setStatus(true); |
@@ -53,23 +53,23 @@ discard block |
||
53 | 53 | public function __construct($pathname = false, $recursive = true, $mode = false, $context = false, $logfile = false, |
54 | 54 | $loglevel = false, $UID = false, $username = false) |
55 | 55 | { |
56 | - if (! empty($logfile) && file_exists($logfile) && ! empty($loglevel)) { |
|
56 | + if (!empty($logfile) && file_exists($logfile) && !empty($loglevel)) { |
|
57 | 57 | $this->setLogfile($logfile); |
58 | 58 | $this->setLoglevel($loglevel); |
59 | 59 | $this->setUID($UID); |
60 | 60 | $this->setUsername($username); |
61 | 61 | } |
62 | 62 | |
63 | - $pathname = (! empty($pathname) ? $this->makeAbsolute($pathname) : $this->path); |
|
63 | + $pathname = (!empty($pathname) ? $this->makeAbsolute($pathname) : $this->path); |
|
64 | 64 | |
65 | 65 | $HID = md5($pathname); |
66 | 66 | |
67 | 67 | $this->dirsetPath($pathname, $HID); |
68 | - $this->dirsetMode(! empty($mode) ? $mode : $this->mode, $HID); |
|
68 | + $this->dirsetMode(!empty($mode) ? $mode : $this->mode, $HID); |
|
69 | 69 | |
70 | - $this->dirsetRecursive(! empty($recursive) ? true : false, $HID); |
|
70 | + $this->dirsetRecursive(!empty($recursive) ? true : false, $HID); |
|
71 | 71 | |
72 | - $context = ! empty($context) ? $this->dirsetContext($context, $HID) : false; |
|
72 | + $context = !empty($context) ? $this->dirsetContext($context, $HID) : false; |
|
73 | 73 | |
74 | 74 | $this->info(701, $pathname); |
75 | 75 | $this->response()->setStatus($this->dirCreate($HID)); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function dirsetPath($pathname = false, $HID = false) |
84 | 84 | { |
85 | - if (! empty($pathname) && is_string($pathname) && ! empty($HID)) { |
|
85 | + if (!empty($pathname) && is_string($pathname) && !empty($HID)) { |
|
86 | 86 | |
87 | 87 | $this->path = $this->makeAbsolute($pathname); |
88 | 88 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function dirsetMode($mode = false, $HID = false) |
102 | 102 | { |
103 | - if (! empty($HID) && ! empty($mode) && is_int($mode)) { |
|
103 | + if (!empty($HID) && !empty($mode) && is_int($mode)) { |
|
104 | 104 | $this->mode = $mode; |
105 | 105 | return true; |
106 | 106 | } else { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function dirsetRecursive($recursive = false, $HID = false) |
119 | 119 | { |
120 | - if (! empty($HID) && is_bool($recursive)) { |
|
120 | + if (!empty($HID) && is_bool($recursive)) { |
|
121 | 121 | $this->recursive = $recursive; |
122 | 122 | return true; |
123 | 123 | } else { |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function dirsetContext($context = false, $HID = false) |
136 | 136 | { |
137 | - if (! empty($HID) && is_resource($context)) { |
|
137 | + if (!empty($HID) && is_resource($context)) { |
|
138 | 138 | $this->context = $context; |
139 | 139 | return true; |
140 | 140 | } |
@@ -152,16 +152,16 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function dirCreate($HID = false) |
154 | 154 | { |
155 | - if ((! is_dir(dirname($this->path)) && $this->recursive === false) || |
|
156 | - is_dir(dirname($this->path)) && ! $this->isWritable(dirname($this->path))) { |
|
155 | + if ((!is_dir(dirname($this->path)) && $this->recursive === false) || |
|
156 | + is_dir(dirname($this->path)) && !$this->isWritable(dirname($this->path))) { |
|
157 | 157 | $this->warning(502, $this->path); |
158 | 158 | $result = false; |
159 | 159 | } else { |
160 | - if (! empty($HID) && ! $this->exists($this->path) && ! empty($this->context)) { |
|
160 | + if (!empty($HID) && !$this->exists($this->path) && !empty($this->context)) { |
|
161 | 161 | $result = mkdir($this->path, octdec(str_pad($this->mode, 4, 0, STR_PAD_LEFT)), |
162 | 162 | $this->recursive, $this->context); |
163 | 163 | } |
164 | - if (! empty($HID) && ! $this->exists($this->path) && empty($this->context)) { |
|
164 | + if (!empty($HID) && !$this->exists($this->path) && empty($this->context)) { |
|
165 | 165 | |
166 | 166 | $result = mkdir($this->path, octdec(str_pad($this->mode, 4, 0, STR_PAD_LEFT)), true); |
167 | 167 | } |
@@ -137,9 +137,7 @@ |
||
137 | 137 | if (! empty($HID) && is_resource($context)) { |
138 | 138 | $this->context = $context; |
139 | 139 | return true; |
140 | - } |
|
141 | - |
|
142 | - else { |
|
140 | + } else { |
|
143 | 141 | $this->debug(802, 'DirectoryTrait->dirsetContext'); |
144 | 142 | return false; |
145 | 143 | } |