@@ -129,8 +129,9 @@ discard block |
||
| 129 | 129 | public function file($filename = false, $dirname = false, $data = '', $flags = FILE_APPEND, $context = null) |
| 130 | 130 | { |
| 131 | 131 | if (! empty($filename) && array_key_exists($filename, $this->files) && |
| 132 | - is_object($this->files[$filename])) |
|
| 133 | - return $this->files[$filename]; |
|
| 132 | + is_object($this->files[$filename])) { |
|
| 133 | + return $this->files[$filename]; |
|
| 134 | + } |
|
| 134 | 135 | |
| 135 | 136 | $this->debug(808); |
| 136 | 137 | if (empty($filename)) { |
@@ -169,8 +170,9 @@ discard block |
||
| 169 | 170 | public function infoObject($basename = false, $directory = false) |
| 170 | 171 | { |
| 171 | 172 | if (! empty($basename) && array_key_exists($basename, $this->infos) && is_object( |
| 172 | - $this->infos[$basename])) |
|
| 173 | - return $this->infos[$basename]; |
|
| 173 | + $this->infos[$basename])) { |
|
| 174 | + return $this->infos[$basename]; |
|
| 175 | + } |
|
| 174 | 176 | |
| 175 | 177 | $this->debug(809); |
| 176 | 178 | if (empty($basename)) { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | $this->debug(801); |
| 53 | 53 | $this->setStatus(true); |
| 54 | - if (! $this->setCwd($setCwd)) { |
|
| 54 | + if(!$this->setCwd($setCwd)) { |
|
| 55 | 55 | $append = error_get_last(); |
| 56 | 56 | $this->warning(500, $append['message']); |
| 57 | 57 | } |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | public function dir($directory = false, $dirname = false, $recursive = true, $mode = false, $context = false) |
| 68 | 68 | { |
| 69 | 69 | $response = null; |
| 70 | - if (empty($directory)) { |
|
| 70 | + if(empty($directory)) { |
|
| 71 | 71 | return false; |
| 72 | 72 | } |
| 73 | 73 | // /////////// |
| 74 | 74 | $this->debug(807); |
| 75 | - if (array_key_exists($directory, $this->dirkeys) && |
|
| 75 | + if(array_key_exists($directory, $this->dirkeys) && |
|
| 76 | 76 | array_key_exists($this->dirkeys[$directory], $this->dirs) && |
| 77 | 77 | is_object($this->dirs[$this->dirkeys[$directory]])) { |
| 78 | 78 | $response = $this->dirs[$this->dirkeys[$directory]]; |
| 79 | 79 | $this->response = $this->dirs[$this->dirkeys[$directory]]->response(); |
| 80 | - } elseif (! empty($directory) && ! empty($dirname)) { |
|
| 80 | + } elseif(!empty($directory) && !empty($dirname)) { |
|
| 81 | 81 | |
| 82 | 82 | $dir = $this->makeAbsolute($dirname . DIRECTORY_SEPARATOR . $directory); |
| 83 | 83 | $HID = md5($dir); |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | DirectoryTreeObject::SKIP_DOTS) : new DirectoryPlaceholderObject($dir, $recursive, $mode, |
| 87 | 87 | $context, $this->getLogFile(), $this->getLogLevel(), $this->getUID(), $this->getUsername()); |
| 88 | 88 | |
| 89 | - if ($this->dirs[$HID] instanceof DirectoryPlaceholderObject) { |
|
| 89 | + if($this->dirs[$HID] instanceof DirectoryPlaceholderObject) { |
|
| 90 | 90 | $this->setStatus($this->dirs[$HID]->getStatus()); |
| 91 | 91 | $this->setCode($this->dirs[$HID]->getCode()); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ($this->dirs[$HID] instanceof DirectoryTreeObject) { |
|
| 94 | + if($this->dirs[$HID] instanceof DirectoryTreeObject) { |
|
| 95 | 95 | $this->dirs[$HID]->setFileClass('\HOWI3\libhowi\Filesystem\php5\Objects\FileObject'); |
| 96 | 96 | $this->dirs[$HID]->setInfoClass('\HOWI3\libhowi\Filesystem\php5\Objects\InfoObject'); |
| 97 | 97 | $this->dirs[$HID]->setLogFile($this->getLogFile()); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | } else { |
| 104 | 104 | |
| 105 | 105 | /* We don't need DirectoryPlaceholderObject anymore for this directory */ |
| 106 | - if ($this->isDir($dir)) { |
|
| 106 | + if($this->isDir($dir)) { |
|
| 107 | 107 | |
| 108 | 108 | $this->dirs[$HID] = new DirectoryTreeObject($dir, DirectoryTreeObject::SKIP_DOTS); |
| 109 | 109 | $this->dirs[$HID]->setFileClass('\HOWI3\libhowi\Filesystem\php5\Objects\FileObject'); |
@@ -128,12 +128,12 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function file($filename = false, $dirname = false, $data = '', $flags = FILE_APPEND, $context = null) |
| 130 | 130 | { |
| 131 | - if (! empty($filename) && array_key_exists($filename, $this->files) && |
|
| 131 | + if(!empty($filename) && array_key_exists($filename, $this->files) && |
|
| 132 | 132 | is_object($this->files[$filename])) |
| 133 | 133 | return $this->files[$filename]; |
| 134 | 134 | |
| 135 | 135 | $this->debug(808); |
| 136 | - if (empty($filename)) { |
|
| 136 | + if(empty($filename)) { |
|
| 137 | 137 | $this->notice(601); |
| 138 | 138 | return false; |
| 139 | 139 | } |
@@ -142,16 +142,16 @@ discard block |
||
| 142 | 142 | $real = $dirname . DIRECTORY_SEPARATOR . $filename; |
| 143 | 143 | $real = str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $real); |
| 144 | 144 | |
| 145 | - if (! $this->exists($real) && ! $this->isWritable(dirname($real))) { |
|
| 145 | + if(!$this->exists($real) && !$this->isWritable(dirname($real))) { |
|
| 146 | 146 | $this->warning(503, $real); |
| 147 | 147 | return false; |
| 148 | - } elseif (! $this->exists($real) && $this->isWritable(dirname($real))) { |
|
| 149 | - $result = empty($context) || ! is_resource($context) ? file_put_contents($real, $data, $flags) : file_put_contents( |
|
| 148 | + } elseif(!$this->exists($real) && $this->isWritable(dirname($real))) { |
|
| 149 | + $result = empty($context) || !is_resource($context) ? file_put_contents($real, $data, $flags) : file_put_contents( |
|
| 150 | 150 | $real, $data, $flags, $context); |
| 151 | 151 | $result = $result !== false ? $this->info(703, $real) : $this->warning(504, $real); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if ($this->exists($real)) { |
|
| 154 | + if($this->exists($real)) { |
|
| 155 | 155 | $this->files[$filename] = new FileObject($real, 'r+'); |
| 156 | 156 | $this->files[$filename]->setFileClass('\HOWI3\libhowi\Filesystem\php5\Objects\FileObject'); |
| 157 | 157 | $this->files[$filename]->setInfoClass("\HOWI3\libhowi\Filesystem\php5\Objects\InfoObject"); |
@@ -168,12 +168,12 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function infoObject($basename = false, $directory = false) |
| 170 | 170 | { |
| 171 | - if (! empty($basename) && array_key_exists($basename, $this->infos) && is_object( |
|
| 171 | + if(!empty($basename) && array_key_exists($basename, $this->infos) && is_object( |
|
| 172 | 172 | $this->infos[$basename])) |
| 173 | 173 | return $this->infos[$basename]; |
| 174 | 174 | |
| 175 | 175 | $this->debug(809); |
| 176 | - if (empty($basename)) { |
|
| 176 | + if(empty($basename)) { |
|
| 177 | 177 | $this->notice(602); |
| 178 | 178 | return false; |
| 179 | 179 | } |
@@ -183,10 +183,10 @@ discard block |
||
| 183 | 183 | $real = str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $real); |
| 184 | 184 | |
| 185 | 185 | |
| 186 | - if (! $this->exists($real) && ! $this->isReadable($real)) { |
|
| 186 | + if(!$this->exists($real) && !$this->isReadable($real)) { |
|
| 187 | 187 | $this->warning(504, $real); |
| 188 | 188 | $result = false; |
| 189 | - } elseif ($this->exists($real)) { |
|
| 189 | + } elseif($this->exists($real)) { |
|
| 190 | 190 | $this->infos[$basename] = new InfoObject($real); |
| 191 | 191 | $this->infos[$basename]->setFileClass('\HOWI3\libhowi\Filesystem\php5\Objects\FileObject'); |
| 192 | 192 | $this->infos[$basename]->setInfoClass("\HOWI3\libhowi\Filesystem\php5\Objects\InfoObject"); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function tmp($keyword = 'tmp') |
| 204 | 204 | { |
| 205 | - if (array_key_exists($keyword, $this->tmp) && is_object($this->tmp[$keyword]) && |
|
| 205 | + if(array_key_exists($keyword, $this->tmp) && is_object($this->tmp[$keyword]) && |
|
| 206 | 206 | $this->tmp[$keyword] instanceof \HOWI3\libhowi\Filesystem\Commons\ObjectInterfaces\TmpInterface) { |
| 207 | 207 | return $this->tmp[$keyword]; |
| 208 | 208 | } else { |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public function link($keyword = 'link') |
| 220 | 220 | { |
| 221 | - if (array_key_exists($keyword, $this->link) && is_object($this->link[$keyword]) && |
|
| 221 | + if(array_key_exists($keyword, $this->link) && is_object($this->link[$keyword]) && |
|
| 222 | 222 | $this->link[$keyword] instanceof \HOWI3\libhowi\Filesystem\Commons\ObjectInterfaces\LinkInterface) { |
| 223 | 223 | return $this->link[$keyword]; |
| 224 | 224 | } else { |
@@ -50,10 +50,11 @@ |
||
| 50 | 50 | /** |
| 51 | 51 | * Minimum version of PHP must be atleast 5.5.11 |
| 52 | 52 | */ |
| 53 | - if ($PHP_VERSION_ID <= 50511) |
|
| 54 | - return call_user_func( |
|
| 53 | + if ($PHP_VERSION_ID <= 50511) { |
|
| 54 | + return call_user_func( |
|
| 55 | 55 | function () { |
| 56 | 56 | $self = new self(); |
| 57 | + } |
|
| 57 | 58 | $self->emergency(100); |
| 58 | 59 | return $self; |
| 59 | 60 | }); |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | * |
| 33 | 33 | * @name $FS = FS::load( string $pathname | $ser_cwd_by_caller boolean true = false, PHP_VERSION_ID ); |
| 34 | 34 | * |
| 35 | - * @param string|boolean $pathname|$ser_cwd_by_caller |
|
| 35 | + * @param string|boolean $ser_cwd_by_caller |
|
| 36 | 36 | * Optional: defaults to false. |
| 37 | 37 | * If path is supplied then that will be current working directory. |
| 38 | 38 | * If boolean true is supplied it will try to set current working directory as one |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public static function load($ser_cwd_by_caller = false, $PHP_VERSION_ID = PHP_VERSION_ID) |
| 43 | 43 | { |
| 44 | - if (! empty($ser_cwd_by_caller) && is_bool($ser_cwd_by_caller)) { |
|
| 44 | + if(!empty($ser_cwd_by_caller) && is_bool($ser_cwd_by_caller)) { |
|
| 45 | 45 | $backtrace = debug_backtrace( |
| 46 | 46 | defined("DEBUG_BACKTRACE_IGNORE_ARGS") ? DEBUG_BACKTRACE_IGNORE_ARGS : FALSE); |
| 47 | 47 | $cwd_caller = array_pop($backtrace); |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | /** |
| 51 | 51 | * Minimum version of PHP must be atleast 5.5.11 |
| 52 | 52 | */ |
| 53 | - if ($PHP_VERSION_ID <= 50511) |
|
| 53 | + if($PHP_VERSION_ID <= 50511) |
|
| 54 | 54 | return call_user_func( |
| 55 | - function () { |
|
| 55 | + function() { |
|
| 56 | 56 | $self = new self(); |
| 57 | 57 | $self->emergency(100); |
| 58 | 58 | return $self; |
@@ -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; |
@@ -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\php5\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\php5\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 | |
@@ -58,6 +58,7 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * {@inheritDoc} |
| 60 | 60 | * |
| 61 | + * @return string |
|
| 61 | 62 | */ |
| 62 | 63 | public function getCwd() |
| 63 | 64 | { |
@@ -196,6 +197,7 @@ discard block |
||
| 196 | 197 | * |
| 197 | 198 | * {@inheritDoc} |
| 198 | 199 | * |
| 200 | + * @param integer $timestamp |
|
| 199 | 201 | */ |
| 200 | 202 | public function ct_ago($timestamp, $date_format = 'y,m,d,h,i,s', $sfx = true, $ommit_zero = true, $ago_single = true, $clocale = []) |
| 201 | 203 | { |
@@ -364,6 +366,7 @@ discard block |
||
| 364 | 366 | * |
| 365 | 367 | * {@inheritDoc} |
| 366 | 368 | * |
| 369 | + * @return string |
|
| 367 | 370 | */ |
| 368 | 371 | public function getPath() |
| 369 | 372 | { |
@@ -375,6 +378,7 @@ discard block |
||
| 375 | 378 | * |
| 376 | 379 | * {@inheritDoc} |
| 377 | 380 | * |
| 381 | + * @return string |
|
| 378 | 382 | */ |
| 379 | 383 | public function getPathname() |
| 380 | 384 | { |
@@ -487,6 +491,7 @@ discard block |
||
| 487 | 491 | * |
| 488 | 492 | * {@inheritDoc} |
| 489 | 493 | * |
| 494 | + * @return false|string |
|
| 490 | 495 | */ |
| 491 | 496 | public function isWritable($path = false) |
| 492 | 497 | { |
@@ -591,6 +596,7 @@ discard block |
||
| 591 | 596 | * |
| 592 | 597 | * {@inheritDoc} |
| 593 | 598 | * |
| 599 | + * @return boolean |
|
| 594 | 600 | */ |
| 595 | 601 | public function getFilename($filename = false) |
| 596 | 602 | { |
@@ -37,16 +37,16 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | protected function setCwd($path = false, $validate_dir_name = false) |
| 39 | 39 | { |
| 40 | - if (empty($path)) |
|
| 40 | + if(empty($path)) |
|
| 41 | 41 | $current_working_directory = $this->getCwd(); |
| 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 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function getCwd() |
| 63 | 63 | { |
| 64 | - if (empty($this->cwd)) |
|
| 64 | + if(empty($this->cwd)) |
|
| 65 | 65 | $this->cwd = getcwd(); |
| 66 | 66 | |
| 67 | 67 | return $this->cwd; |
@@ -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( |
@@ -92,16 +92,16 @@ discard block |
||
| 92 | 92 | 'ZB', |
| 93 | 93 | 'YB' |
| 94 | 94 | ); |
| 95 | - if ($this->isDir($filename)) { |
|
| 95 | + if($this->isDir($filename)) { |
|
| 96 | 96 | $path = ((method_exists(get_class($this), 'getPathname')) ? $this->getPathname() : $filename); |
| 97 | - if ($path === '/home/nitrotrigger/tmp/libhowi-filesystem/log/phpunit_test.log') |
|
| 97 | + if($path === '/home/nitrotrigger/tmp/libhowi-filesystem/log/phpunit_test.log') |
|
| 98 | 98 | die('ss'); |
| 99 | 99 | |
| 100 | - foreach (new RecursiveIteratorIterator( |
|
| 100 | + foreach(new RecursiveIteratorIterator( |
|
| 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); |
@@ -110,14 +110,14 @@ discard block |
||
| 110 | 110 | 0, |
| 111 | 111 | 'B' |
| 112 | 112 | ]; |
| 113 | - if ($bytestotal > 0) { |
|
| 113 | + if($bytestotal > 0) { |
|
| 114 | 114 | |
| 115 | 115 | $result = array( |
| 116 | 116 | round(pow(1024, $base - floor($base)), 2), |
| 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,8 +128,8 @@ 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)) { |
|
| 132 | - switch ($timeformat) { |
|
| 131 | + if(!empty($timeformat) && is_int($atime)) { |
|
| 132 | + switch($timeformat) { |
|
| 133 | 133 | case 'ago': |
| 134 | 134 | $atime = $this->ct_ago($atime, 'y,m,d,h,i,s', false, true); |
| 135 | 135 | break; |
@@ -152,8 +152,8 @@ 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)) { |
|
| 156 | - switch ($timeformat) { |
|
| 155 | + if(!empty($timeformat) && is_int($ctime)) { |
|
| 156 | + switch($timeformat) { |
|
| 157 | 157 | case 'ago': |
| 158 | 158 | $ctime = $this->ct_ago($ctime, 'y,m,d,h,i,s', false, true); |
| 159 | 159 | break; |
@@ -176,8 +176,8 @@ 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)) { |
|
| 180 | - switch ($timeformat) { |
|
| 179 | + if(!empty($timeformat) && is_int($mtime)) { |
|
| 180 | + switch($timeformat) { |
|
| 181 | 181 | case 'ago': |
| 182 | 182 | $mtime = $this->ct_ago($mtime, 'y,m,d,h,i,s', false, true); |
| 183 | 183 | break; |
@@ -241,21 +241,21 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | $interval = $date->diff(new DateTime('now')); |
| 243 | 243 | |
| 244 | - for ($df = strtok($date_format, ','); $df !== false; $df = strtok(",")) { |
|
| 244 | + for($df = strtok($date_format, ','); $df !== false; $df = strtok(",")) { |
|
| 245 | 245 | $lkey = ($df !== 'a') ? strtolower($df) : 'days'; |
| 246 | 246 | |
| 247 | - if ($ommit_zero && $interval->$lkey === 0) |
|
| 247 | + if($ommit_zero && $interval->$lkey === 0) |
|
| 248 | 248 | continue; |
| 249 | 249 | |
| 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 | - if (empty($dfs)) |
|
| 258 | + if(empty($dfs)) |
|
| 259 | 259 | $ret = $locale['now']; |
| 260 | 260 | else |
| 261 | 261 | $ret = $interval->format($dfs) . $locale['ago']; |
@@ -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,10 +283,10 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | public function setFileClass($class_name = "\HOWI3\libhowi\Filesystem\php5\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 | - if (is_subclass_of($class_name, 'SplFileObject') || $class_name === 'SplFileObject') { |
|
| 289 | + if(is_subclass_of($class_name, 'SplFileObject') || $class_name === 'SplFileObject') { |
|
| 290 | 290 | parent::setFileClass($class_name); |
| 291 | 291 | return true; |
| 292 | 292 | } |
@@ -300,10 +300,10 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | public function setInfoClass($class_name = "\HOWI3\libhowi\Filesystem\php5\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 | - if (is_subclass_of($class_name, 'SplFileInfo') || $class_name === 'SplFileInfo') { |
|
| 306 | + if(is_subclass_of($class_name, 'SplFileInfo') || $class_name === 'SplFileInfo') { |
|
| 307 | 307 | parent::setInfoClass($class_name); |
| 308 | 308 | return true; |
| 309 | 309 | } |
@@ -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\php5\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,13 +556,13 @@ 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 | - if (preg_match('/^(~\/)/', $path) === 1) { |
|
| 563 | + if(preg_match('/^(~\/)/', $path) === 1) { |
|
| 564 | 564 | $absolute_path = getenv("HOME") . substr($path, 1); |
| 565 | - } elseif (preg_match('/^(.\/|..\/)/', $path) === 1) { |
|
| 565 | + } elseif(preg_match('/^(.\/|..\/)/', $path) === 1) { |
|
| 566 | 566 | $absolute_path = realpath($path); |
| 567 | 567 | } else |
| 568 | 568 | $absolute_path = $this->getCwd() . ($path !== '.' ? DIRECTORY_SEPARATOR . $path : ''); |
@@ -579,12 +579,12 @@ discard block |
||
| 579 | 579 | */ |
| 580 | 580 | public function exists($pathname = false) |
| 581 | 581 | { |
| 582 | - if (empty($pathname)) |
|
| 582 | + if(empty($pathname)) |
|
| 583 | 583 | return false; |
| 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 | } |
@@ -129,8 +129,9 @@ discard block |
||
| 129 | 129 | public function file($filename = false, $dirname = false, $data = '', $flags = FILE_APPEND, $context = null) |
| 130 | 130 | { |
| 131 | 131 | if (! empty($filename) && array_key_exists($filename, $this->files) && |
| 132 | - is_object($this->files[$filename])) |
|
| 133 | - return $this->files[$filename]; |
|
| 132 | + is_object($this->files[$filename])) { |
|
| 133 | + return $this->files[$filename]; |
|
| 134 | + } |
|
| 134 | 135 | |
| 135 | 136 | $this->debug(808); |
| 136 | 137 | if (empty($filename)) { |
@@ -169,8 +170,9 @@ discard block |
||
| 169 | 170 | public function infoObject($basename = false, $directory = false) |
| 170 | 171 | { |
| 171 | 172 | if (! empty($basename) && array_key_exists($basename, $this->infos) && is_object( |
| 172 | - $this->infos[$basename])) |
|
| 173 | - return $this->infos[$basename]; |
|
| 173 | + $this->infos[$basename])) { |
|
| 174 | + return $this->infos[$basename]; |
|
| 175 | + } |
|
| 174 | 176 | |
| 175 | 177 | $this->debug(809); |
| 176 | 178 | if (empty($basename)) { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | $this->debug(801); |
| 53 | 53 | $this->setStatus(true); |
| 54 | - if (! $this->setCwd($setCwd)) { |
|
| 54 | + if(!$this->setCwd($setCwd)) { |
|
| 55 | 55 | $append = error_get_last(); |
| 56 | 56 | $this->warning(500, $append['message']); |
| 57 | 57 | } |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | public function dir($directory = false, $dirname = false, $recursive = true, $mode = false, $context = false) |
| 68 | 68 | { |
| 69 | 69 | $response = null; |
| 70 | - if (empty($directory)) { |
|
| 70 | + if(empty($directory)) { |
|
| 71 | 71 | return false; |
| 72 | 72 | } |
| 73 | 73 | // /////////// |
| 74 | 74 | $this->debug(807); |
| 75 | - if (array_key_exists($directory, $this->dirkeys) && |
|
| 75 | + if(array_key_exists($directory, $this->dirkeys) && |
|
| 76 | 76 | array_key_exists($this->dirkeys[$directory], $this->dirs) && |
| 77 | 77 | is_object($this->dirs[$this->dirkeys[$directory]])) { |
| 78 | 78 | $response = $this->dirs[$this->dirkeys[$directory]]; |
| 79 | 79 | $this->response = $this->dirs[$this->dirkeys[$directory]]->response(); |
| 80 | - } elseif (! empty($directory) && ! empty($dirname)) { |
|
| 80 | + } elseif(!empty($directory) && !empty($dirname)) { |
|
| 81 | 81 | |
| 82 | 82 | $dir = $this->makeAbsolute($dirname . DIRECTORY_SEPARATOR . $directory); |
| 83 | 83 | $HID = md5($dir); |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | DirectoryTreeObject::SKIP_DOTS) : new DirectoryPlaceholderObject($dir, $recursive, $mode, |
| 87 | 87 | $context, $this->getLogFile(), $this->getLogLevel(), $this->getUID(), $this->getUsername()); |
| 88 | 88 | |
| 89 | - if ($this->dirs[$HID] instanceof DirectoryPlaceholderObject) { |
|
| 89 | + if($this->dirs[$HID] instanceof DirectoryPlaceholderObject) { |
|
| 90 | 90 | $this->setStatus($this->dirs[$HID]->getStatus()); |
| 91 | 91 | $this->setCode($this->dirs[$HID]->getCode()); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ($this->dirs[$HID] instanceof DirectoryTreeObject) { |
|
| 94 | + if($this->dirs[$HID] instanceof DirectoryTreeObject) { |
|
| 95 | 95 | $this->dirs[$HID]->setFileClass('\HOWI3\libhowi\Filesystem\php5\Objects\FileObject'); |
| 96 | 96 | $this->dirs[$HID]->setInfoClass('\HOWI3\libhowi\Filesystem\php5\Objects\InfoObject'); |
| 97 | 97 | $this->dirs[$HID]->setLogFile($this->getLogFile()); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | } else { |
| 104 | 104 | |
| 105 | 105 | /* We don't need DirectoryPlaceholderObject anymore for this directory */ |
| 106 | - if ($this->isDir($dir)) { |
|
| 106 | + if($this->isDir($dir)) { |
|
| 107 | 107 | |
| 108 | 108 | $this->dirs[$HID] = new DirectoryTreeObject($dir, DirectoryTreeObject::SKIP_DOTS); |
| 109 | 109 | $this->dirs[$HID]->setFileClass('\HOWI3\libhowi\Filesystem\php5\Objects\FileObject'); |
@@ -128,12 +128,12 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function file($filename = false, $dirname = false, $data = '', $flags = FILE_APPEND, $context = null) |
| 130 | 130 | { |
| 131 | - if (! empty($filename) && array_key_exists($filename, $this->files) && |
|
| 131 | + if(!empty($filename) && array_key_exists($filename, $this->files) && |
|
| 132 | 132 | is_object($this->files[$filename])) |
| 133 | 133 | return $this->files[$filename]; |
| 134 | 134 | |
| 135 | 135 | $this->debug(808); |
| 136 | - if (empty($filename)) { |
|
| 136 | + if(empty($filename)) { |
|
| 137 | 137 | $this->notice(601); |
| 138 | 138 | return false; |
| 139 | 139 | } |
@@ -142,16 +142,16 @@ discard block |
||
| 142 | 142 | $real = $dirname . DIRECTORY_SEPARATOR . $filename; |
| 143 | 143 | $real = str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $real); |
| 144 | 144 | |
| 145 | - if (! $this->exists($real) && ! $this->isWritable(dirname($real))) { |
|
| 145 | + if(!$this->exists($real) && !$this->isWritable(dirname($real))) { |
|
| 146 | 146 | $this->warning(503, $real); |
| 147 | 147 | return false; |
| 148 | - } elseif (! $this->exists($real) && $this->isWritable(dirname($real))) { |
|
| 149 | - $result = empty($context) || ! is_resource($context) ? file_put_contents($real, $data, $flags) : file_put_contents( |
|
| 148 | + } elseif(!$this->exists($real) && $this->isWritable(dirname($real))) { |
|
| 149 | + $result = empty($context) || !is_resource($context) ? file_put_contents($real, $data, $flags) : file_put_contents( |
|
| 150 | 150 | $real, $data, $flags, $context); |
| 151 | 151 | $result = $result !== false ? $this->info(703, $real) : $this->warning(504, $real); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if ($this->exists($real)) { |
|
| 154 | + if($this->exists($real)) { |
|
| 155 | 155 | $this->files[$filename] = new FileObject($real, 'r+'); |
| 156 | 156 | $this->files[$filename]->setFileClass('\HOWI3\libhowi\Filesystem\php5\Objects\FileObject'); |
| 157 | 157 | $this->files[$filename]->setInfoClass("\HOWI3\libhowi\Filesystem\php5\Objects\InfoObject"); |
@@ -168,12 +168,12 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function infoObject($basename = false, $directory = false) |
| 170 | 170 | { |
| 171 | - if (! empty($basename) && array_key_exists($basename, $this->infos) && is_object( |
|
| 171 | + if(!empty($basename) && array_key_exists($basename, $this->infos) && is_object( |
|
| 172 | 172 | $this->infos[$basename])) |
| 173 | 173 | return $this->infos[$basename]; |
| 174 | 174 | |
| 175 | 175 | $this->debug(809); |
| 176 | - if (empty($basename)) { |
|
| 176 | + if(empty($basename)) { |
|
| 177 | 177 | $this->notice(602); |
| 178 | 178 | return false; |
| 179 | 179 | } |
@@ -183,10 +183,10 @@ discard block |
||
| 183 | 183 | $real = str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $real); |
| 184 | 184 | |
| 185 | 185 | |
| 186 | - if (! $this->exists($real) && ! $this->isReadable($real)) { |
|
| 186 | + if(!$this->exists($real) && !$this->isReadable($real)) { |
|
| 187 | 187 | $this->warning(504, $real); |
| 188 | 188 | $result = false; |
| 189 | - } elseif ($this->exists($real)) { |
|
| 189 | + } elseif($this->exists($real)) { |
|
| 190 | 190 | $this->infos[$basename] = new InfoObject($real); |
| 191 | 191 | $this->infos[$basename]->setFileClass('\HOWI3\libhowi\Filesystem\php5\Objects\FileObject'); |
| 192 | 192 | $this->infos[$basename]->setInfoClass("\HOWI3\libhowi\Filesystem\php5\Objects\InfoObject"); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function tmp($keyword = 'tmp') |
| 204 | 204 | { |
| 205 | - if (array_key_exists($keyword, $this->tmp) && is_object($this->tmp[$keyword]) && |
|
| 205 | + if(array_key_exists($keyword, $this->tmp) && is_object($this->tmp[$keyword]) && |
|
| 206 | 206 | $this->tmp[$keyword] instanceof \HOWI3\libhowi\Filesystem\Commons\ObjectInterfaces\TmpInterface) { |
| 207 | 207 | return $this->tmp[$keyword]; |
| 208 | 208 | } else { |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public function link($keyword = 'link') |
| 220 | 220 | { |
| 221 | - if (array_key_exists($keyword, $this->link) && is_object($this->link[$keyword]) && |
|
| 221 | + if(array_key_exists($keyword, $this->link) && is_object($this->link[$keyword]) && |
|
| 222 | 222 | $this->link[$keyword] instanceof \HOWI3\libhowi\Filesystem\Commons\ObjectInterfaces\LinkInterface) { |
| 223 | 223 | return $this->link[$keyword]; |
| 224 | 224 | } else { |
@@ -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 | } |
@@ -49,17 +49,17 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | $pathname = $this->makeAbsolute($pathname); |
| 51 | 51 | $response = false; |
| 52 | - if (is_dir($pathname)) { |
|
| 52 | + if(is_dir($pathname)) { |
|
| 53 | 53 | |
| 54 | 54 | $files = array_diff(scandir($pathname), |
| 55 | 55 | array( |
| 56 | 56 | '.', |
| 57 | 57 | '..' |
| 58 | 58 | )); |
| 59 | - foreach ($files as $file) { |
|
| 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 | |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function getDiskTotalSpace($partition_location = false, $convert = false) |
| 105 | 105 | { |
| 106 | - if (empty($partition_location)) |
|
| 106 | + if(empty($partition_location)) |
|
| 107 | 107 | $partition_location = $this->getCwd(); |
| 108 | 108 | |
| 109 | - if (empty($convert)) |
|
| 109 | + if(empty($convert)) |
|
| 110 | 110 | return disk_total_space($partition_location); |
| 111 | 111 | |
| 112 | 112 | $bytestotal = 0; |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function getDiskFreeSpace($partition_location = false, $convert = false) |
| 139 | 139 | { |
| 140 | - if (empty($partition_location)) |
|
| 140 | + if(empty($partition_location)) |
|
| 141 | 141 | $partition_location = $this->getCwd(); |
| 142 | 142 | |
| 143 | - if (empty($convert)) |
|
| 143 | + if(empty($convert)) |
|
| 144 | 144 | return disk_free_space($partition_location); |
| 145 | 145 | |
| 146 | 146 | $result = [ |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | $base = log($bytestotal, 1024); |
| 165 | 165 | |
| 166 | - if ($bytestotal > 0) { |
|
| 166 | + if($bytestotal > 0) { |
|
| 167 | 167 | $result = array( |
| 168 | 168 | round(pow(1024, $base - floor($base)), 2), |
| 169 | 169 | $suffixes[floor($base)] |
@@ -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 | - if (empty($context)) |
|
| 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); |
@@ -250,11 +250,11 @@ discard block |
||
| 250 | 250 | $this->close($tmp_key); |
| 251 | 251 | $this->close($tmp_key2); |
| 252 | 252 | |
| 253 | - foreach ($iterator = new RecursiveIteratorIterator( |
|
| 254 | - new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), // DirectoryTreeObject::CURRENT_AS_FILEINFO |
|
| 253 | + foreach($iterator = new RecursiveIteratorIterator( |
|
| 254 | + new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), // DirectoryTreeObject::CURRENT_AS_FILEINFO |
|
| 255 | 255 | \RecursiveIteratorIterator::SELF_FIRST) as $item) { |
| 256 | - if ($item->isDir()) { |
|
| 257 | - if (empty($context)) { |
|
| 256 | + if($item->isDir()) { |
|
| 257 | + if(empty($context)) { |
|
| 258 | 258 | mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), |
| 259 | 259 | octdec(str_pad($iterator->getPerms(), 4, 0, STR_PAD_LEFT))); |
| 260 | 260 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), |
| 264 | 264 | octdec(str_pad($iterator->getPerms(), 4, 0, STR_PAD_LEFT)), false, $context); |
| 265 | 265 | } else { |
| 266 | - if (empty($context)) |
|
| 266 | + if(empty($context)) |
|
| 267 | 267 | $this->copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); |
| 268 | 268 | else |
| 269 | 269 | $this->copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), |
@@ -283,13 +283,13 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | public function mv($oldname = false, $newname = false, $context = false) |
| 285 | 285 | { |
| 286 | - if (empty($oldname) || empty($newname)) |
|
| 286 | + if(empty($oldname) || empty($newname)) |
|
| 287 | 287 | return false; |
| 288 | 288 | |
| 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); |
@@ -302,10 +302,10 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | public function namePatternMatch($pattern = false, $string = false, $flags = false) |
| 304 | 304 | { |
| 305 | - if (empty($pattern)) |
|
| 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); |
@@ -359,12 +359,12 @@ discard block |
||
| 359 | 359 | */ |
| 360 | 360 | public function close($keyword = false) |
| 361 | 361 | { |
| 362 | - if (!empty($keyword) && array_key_exists($keyword, $this->dirkeys) && |
|
| 362 | + if(!empty($keyword) && array_key_exists($keyword, $this->dirkeys) && |
|
| 363 | 363 | array_key_exists($this->dirkeys[$keyword], $this->dirs)) { |
| 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; |
@@ -380,13 +380,13 @@ discard block |
||
| 380 | 380 | */ |
| 381 | 381 | public function touch($filename = false, $time = false, $atime = false) |
| 382 | 382 | { |
| 383 | - if (empty($filename)) |
|
| 383 | + if(empty($filename)) |
|
| 384 | 384 | return false; |
| 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 | } |
@@ -419,22 +419,22 @@ discard block |
||
| 419 | 419 | public function createStructure($rootpath, $data_array, $skip_debug = false) |
| 420 | 420 | { |
| 421 | 421 | $absolute_path = $this->makeAbsolute($rootpath); |
| 422 | - if (empty($skip_debug)) |
|
| 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 | - foreach ($data_array as $key => $val) { |
|
| 432 | - if (is_array($val)) |
|
| 433 | - ! $this->createStructure($absolute_path . DIRECTORY_SEPARATOR . $key, $val, true); |
|
| 431 | + foreach($data_array as $key => $val) { |
|
| 432 | + if(is_array($val)) |
|
| 433 | + !$this->createStructure($absolute_path . DIRECTORY_SEPARATOR . $key, $val, true); |
|
| 434 | 434 | else |
| 435 | 435 | touch($absolute_path . DIRECTORY_SEPARATOR . $val); |
| 436 | 436 | } |
| 437 | - if (empty($skip_debug)) |
|
| 437 | + if(empty($skip_debug)) |
|
| 438 | 438 | $this->info(704, $rootpath); |
| 439 | 439 | return true; |
| 440 | 440 | } |
@@ -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(' '); |
@@ -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 | /** |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | { |
| 90 | 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 | } |
@@ -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\php5\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 | } |
@@ -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\php5\Objects\FileObject'); |
@@ -92,27 +92,27 @@ discard block |
||
| 92 | 92 | ]; |
| 93 | 93 | $display = []; |
| 94 | 94 | |
| 95 | - while ($this->valid()) { |
|
| 96 | - if (! $this->isDot()) { |
|
| 97 | - if ($this->isDir() && ! $this->isLink() && ! empty($sort)) |
|
| 95 | + while($this->valid()) { |
|
| 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(); |
| 107 | 107 | |
| 108 | - if ($this->isDir() || $this->isLink()) { |
|
| 108 | + if($this->isDir() || $this->isLink()) { |
|
| 109 | 109 | $this->dirkeys[$this->getFilename()] = $this->getChildren(); |
| 110 | 110 | } |
| 111 | 111 | } |
| 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']); |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | $display = []; |
| 141 | 141 | $lsinfo = []; |
| 142 | 142 | |
| 143 | - while ($this->valid()) { |
|
| 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,27 +153,27 @@ 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']); |
| 173 | 173 | |
| 174 | 174 | $display = array_merge($ls['dir'], $ls['link'], $ls['file']); |
| 175 | 175 | } |
| 176 | - foreach ($display as $row => $type) { |
|
| 176 | + foreach($display as $row => $type) { |
|
| 177 | 177 | $display[$row] = $lsinfo[$row]; |
| 178 | 178 | } |
| 179 | 179 | return $display; |
@@ -192,14 +192,14 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | $ritit = new RecursiveIteratorIterator($DirectoryTreeObject, RecursiveIteratorIterator::CHILD_FIRST); |
| 194 | 194 | $tree = array(); |
| 195 | - foreach ($ritit as $splFileInfo) { |
|
| 195 | + foreach($ritit as $splFileInfo) { |
|
| 196 | 196 | $path = $splFileInfo->isDir() ? array( |
| 197 | 197 | $splFileInfo->getFilename() => array() |
| 198 | 198 | ) : array( |
| 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() |
@@ -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); |
@@ -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(); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function getTmp() |
| 68 | 68 | { |
| 69 | - if (empty($this->tmp_path)) |
|
| 69 | + if(empty($this->tmp_path)) |
|
| 70 | 70 | $this->tmp_path = $this->setTmp(); |
| 71 | 71 | |
| 72 | 72 | $this->debug(805, $this->tmp_path); |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |