@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | if ($options['user'] === 'init') { |
140 | 140 | |
141 | - if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) { |
|
141 | + if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) { |
|
142 | 142 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
143 | 143 | } |
144 | 144 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | if (class_exists('OAuth', false)) { |
149 | 149 | $this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']); |
150 | 150 | } else { |
151 | - if (! class_exists('HTTP_OAuth_Consumer', false)) { |
|
151 | + if (!class_exists('HTTP_OAuth_Consumer', false)) { |
|
152 | 152 | // We're going to try to load in manually |
153 | 153 | include 'HTTP/OAuth/Consumer.php'; |
154 | 154 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - if (! $this->oauth) { |
|
161 | + if (!$this->oauth) { |
|
162 | 162 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
163 | 163 | } |
164 | 164 | |
@@ -179,25 +179,25 @@ discard block |
||
179 | 179 | unset($_SESSION['elFinderDropboxTokens']); |
180 | 180 | } |
181 | 181 | } |
182 | - if (! $html) { |
|
182 | + if (!$html) { |
|
183 | 183 | // get customdata |
184 | 184 | $cdata = ''; |
185 | 185 | $innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user'); |
186 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
187 | - foreach($this->ARGS as $k => $v) { |
|
188 | - if (! in_array($k, $innerKeys)) { |
|
189 | - $cdata .= '&' . $k . '=' . rawurlencode($v); |
|
186 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
187 | + foreach ($this->ARGS as $k => $v) { |
|
188 | + if (!in_array($k, $innerKeys)) { |
|
189 | + $cdata .= '&'.$k.'='.rawurlencode($v); |
|
190 | 190 | } |
191 | 191 | } |
192 | - if (strpos($options['url'], 'http') !== 0 ) { |
|
192 | + if (strpos($options['url'], 'http') !== 0) { |
|
193 | 193 | $options['url'] = $this->getConnectorUrl(); |
194 | 194 | } |
195 | - $callback = $options['url'] |
|
195 | + $callback = $options['url'] |
|
196 | 196 | . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata; |
197 | 197 | |
198 | 198 | try { |
199 | 199 | $tokens = $this->oauth->getRequestToken(); |
200 | - $url= $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
200 | + $url = $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
201 | 201 | } catch (Dropbox_Exception $e) { |
202 | 202 | return array('exit' => true, 'body' => '{msg:errAccess}'); |
203 | 203 | } |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | if (isset($netVolumes[$key])) { |
245 | 245 | $dropboxUid = $netVolumes[$key]['dropboxUid']; |
246 | 246 | } |
247 | - foreach($netVolumes as $volume) { |
|
247 | + foreach ($netVolumes as $volume) { |
|
248 | 248 | if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) { |
249 | 249 | $count++; |
250 | 250 | } |
251 | 251 | } |
252 | 252 | if ($count === 1) { |
253 | 253 | $this->DB->exec('drop table '.$this->DB_TableName); |
254 | - foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
254 | + foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
255 | 255 | unlink($tmb); |
256 | 256 | } |
257 | 257 | } |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * @author Naoki Sawada |
266 | 266 | */ |
267 | 267 | private function getConnectorUrl() { |
268 | - $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://') |
|
268 | + $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://') |
|
269 | 269 | . $_SERVER['SERVER_NAME'] // host |
270 | - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port |
|
271 | - . $_SERVER['REQUEST_URI']; // path & query |
|
270 | + . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']) // port |
|
271 | + . $_SERVER['REQUEST_URI']; // path & query |
|
272 | 272 | list($url) = explode('?', $url); |
273 | 273 | return $url; |
274 | 274 | } |
@@ -304,14 +304,14 @@ discard block |
||
304 | 304 | // make net mount key |
305 | 305 | $this->netMountKey = md5(join('-', array('dropbox', $this->options['path']))); |
306 | 306 | |
307 | - if (! $this->oauth) { |
|
307 | + if (!$this->oauth) { |
|
308 | 308 | if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) { |
309 | 309 | $this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']); |
310 | 310 | } else { |
311 | 311 | if (class_exists('OAuth', false)) { |
312 | 312 | $this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']); |
313 | 313 | } else { |
314 | - if (! class_exists('HTTP_OAuth_Consumer', false)) { |
|
314 | + if (!class_exists('HTTP_OAuth_Consumer', false)) { |
|
315 | 315 | // We're going to try to load in manually |
316 | 316 | include 'HTTP/OAuth/Consumer.php'; |
317 | 317 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | - if (! $this->oauth) { |
|
325 | + if (!$this->oauth) { |
|
326 | 326 | return $this->setError('OAuth extension not loaded.'); |
327 | 327 | } |
328 | 328 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $this->root = $this->options['path'] = $this->_normpath($this->options['path']); |
331 | 331 | |
332 | 332 | if (empty($this->options['alias'])) { |
333 | - $this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
333 | + $this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | $this->rootName = $this->options['alias']; |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | // setup PDO |
388 | - if (! $this->options['PDO_DSN']) { |
|
388 | + if (!$this->options['PDO_DSN']) { |
|
389 | 389 | $this->options['PDO_DSN'] = 'sqlite:'.$this->metaCache.DIRECTORY_SEPARATOR.'.elFinder_dropbox_db_'.md5($this->dropboxUid.$this->options['consumerSecret']); |
390 | 390 | } |
391 | 391 | // DataBase table name |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | // DataBase check or make table |
394 | 394 | try { |
395 | 395 | $this->DB = new PDO($this->options['PDO_DSN'], $this->options['PDO_User'], $this->options['PDO_Pass'], $this->options['PDO_Options']); |
396 | - if (! $this->checkDB()) { |
|
396 | + if (!$this->checkDB()) { |
|
397 | 397 | return $this->setError('Can not make DB table'); |
398 | 398 | } |
399 | 399 | } catch (PDOException $e) { |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | $res = false; |
456 | 456 | } |
457 | 457 | } |
458 | - if (! $res) { |
|
458 | + if (!$res) { |
|
459 | 459 | try { |
460 | 460 | $this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);'); |
461 | 461 | $this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)'); |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | */ |
506 | 506 | private function updateDBdat($path, $dat) { |
507 | 507 | return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat)) |
508 | - . ', isdir=' . ($dat['is_dir']? 1 : 0) |
|
508 | + . ', isdir='.($dat['is_dir'] ? 1 : 0) |
|
509 | 509 | . ' where path='.$this->DB->quote(strtolower($this->_dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path)))); |
510 | 510 | } |
511 | 511 | /*********************************************************************/ |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | */ |
531 | 531 | protected function deltaCheck($refresh = true) { |
532 | 532 | $chk = false; |
533 | - if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
533 | + if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
534 | 534 | $chk = unserialize($chk[0]); |
535 | 535 | } |
536 | 536 | if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) { |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | do { |
555 | 555 | @ ini_set('max_execution_time', 120); |
556 | 556 | $_info = $this->dropbox->delta($cursor); |
557 | - if (! empty($_info['reset'])) { |
|
557 | + if (!empty($_info['reset'])) { |
|
558 | 558 | $this->DB->exec('TRUNCATE table '.$this->DB_TableName); |
559 | 559 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);'); |
560 | 560 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array( |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | } |
568 | 568 | $cursor = $_info['cursor']; |
569 | 569 | |
570 | - foreach($_info['entries'] as $entry) { |
|
570 | + foreach ($_info['entries'] as $entry) { |
|
571 | 571 | $key = strtolower($entry[0]); |
572 | 572 | $pkey = strtolower($this->_dirname($key)); |
573 | 573 | |
@@ -576,22 +576,22 @@ discard block |
||
576 | 576 | $where = 'where path='.$path.' and fname='.$fname; |
577 | 577 | |
578 | 578 | if (empty($entry[1])) { |
579 | - $ptimes[$pkey] = isset($ptimes[$pkey])? max(array($now, $ptimes[$pkey])) : $now; |
|
579 | + $ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($now, $ptimes[$pkey])) : $now; |
|
580 | 580 | $this->DB->exec('delete from '.$this->DB_TableName.' '.$where); |
581 | - ! $delete && $delete = true; |
|
581 | + !$delete && $delete = true; |
|
582 | 582 | continue; |
583 | 583 | } |
584 | 584 | |
585 | - $_itemTime = strtotime(isset($entry[1]['client_mtime'])? $entry[1]['client_mtime'] : $entry[1]['modified']); |
|
586 | - $ptimes[$pkey] = isset($ptimes[$pkey])? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime; |
|
585 | + $_itemTime = strtotime(isset($entry[1]['client_mtime']) ? $entry[1]['client_mtime'] : $entry[1]['modified']); |
|
586 | + $ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime; |
|
587 | 587 | $sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1'; |
588 | - if (! $reset && $this->query($sql)) { |
|
589 | - $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where); |
|
588 | + if (!$reset && $this->query($sql)) { |
|
589 | + $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where); |
|
590 | 590 | } else { |
591 | - $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')'); |
|
591 | + $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')'); |
|
592 | 592 | } |
593 | 593 | } |
594 | - } while (! empty($_info['has_more'])); |
|
594 | + } while (!empty($_info['has_more'])); |
|
595 | 595 | |
596 | 596 | // update time stamp of parent holder |
597 | 597 | foreach ($ptimes as $_p => $_t) { |
@@ -613,14 +613,14 @@ discard block |
||
613 | 613 | } |
614 | 614 | |
615 | 615 | $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\''); |
616 | - if (! $this->DB->commit()) { |
|
616 | + if (!$this->DB->commit()) { |
|
617 | 617 | $e = $this->DB->errorInfo(); |
618 | 618 | return $e[2]; |
619 | 619 | } |
620 | 620 | if ($delete) { |
621 | 621 | $this->DB->exec('vacuum'); |
622 | 622 | } |
623 | - } catch(Dropbox_Exception $e) { |
|
623 | + } catch (Dropbox_Exception $e) { |
|
624 | 624 | return $e->getMessage(); |
625 | 625 | } |
626 | 626 | return true; |
@@ -636,15 +636,14 @@ discard block |
||
636 | 636 | protected function parseRaw($raw) { |
637 | 637 | $stat = array(); |
638 | 638 | |
639 | - $stat['rev'] = isset($raw['rev'])? $raw['rev'] : 'root'; |
|
639 | + $stat['rev'] = isset($raw['rev']) ? $raw['rev'] : 'root'; |
|
640 | 640 | $stat['name'] = basename($raw['path']); |
641 | - $stat['mime'] = $raw['is_dir']? 'directory' : $raw['mime_type']; |
|
641 | + $stat['mime'] = $raw['is_dir'] ? 'directory' : $raw['mime_type']; |
|
642 | 642 | $stat['size'] = $stat['mime'] == 'directory' ? 0 : $raw['bytes']; |
643 | - $stat['ts'] = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) : |
|
644 | - (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
643 | + $stat['ts'] = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
645 | 644 | $stat['dirs'] = 0; |
646 | 645 | if ($raw['is_dir']) { |
647 | - $stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
646 | + $stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
648 | 647 | } |
649 | 648 | |
650 | 649 | if (!empty($raw['url'])) { |
@@ -670,7 +669,7 @@ discard block |
||
670 | 669 | $res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path))); |
671 | 670 | |
672 | 671 | if ($res) { |
673 | - foreach($res as $raw) { |
|
672 | + foreach ($res as $raw) { |
|
674 | 673 | $raw = unserialize($raw); |
675 | 674 | if ($stat = $this->parseRaw($raw)) { |
676 | 675 | $stat = $this->updateCache($raw['path'], $stat); |
@@ -695,10 +694,10 @@ discard block |
||
695 | 694 | protected function doSearch($path, $q, $mimes) { |
696 | 695 | $result = array(); |
697 | 696 | $sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?'); |
698 | - $sth->execute(array('%'.(($path === '/')? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
697 | + $sth->execute(array('%'.(($path === '/') ? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
699 | 698 | $res = $sth->fetchAll(PDO::FETCH_COLUMN); |
700 | 699 | if ($res) { |
701 | - foreach($res as $raw) { |
|
700 | + foreach ($res as $raw) { |
|
702 | 701 | $raw = unserialize($raw); |
703 | 702 | if ($stat = $this->parseRaw($raw)) { |
704 | 703 | if (!isset($this->cache[$raw['path']])) { |
@@ -789,10 +788,10 @@ discard block |
||
789 | 788 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
790 | 789 | |
791 | 790 | // copy image into tmbPath so some drivers does not store files on local fs |
792 | - if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
791 | + if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
793 | 792 | return false; |
794 | 793 | } |
795 | - if (! file_put_contents($tmb, $data)) { |
|
794 | + if (!file_put_contents($tmb, $data)) { |
|
796 | 795 | return false; |
797 | 796 | } |
798 | 797 | |
@@ -805,15 +804,15 @@ discard block |
||
805 | 804 | } |
806 | 805 | |
807 | 806 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
808 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
809 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
807 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
808 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
810 | 809 | |
811 | 810 | } else { |
812 | 811 | |
813 | 812 | if ($this->options['tmbCrop']) { |
814 | 813 | |
815 | 814 | /* Resize and crop if image bigger than thumbnail */ |
816 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
815 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
817 | 816 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
818 | 817 | } |
819 | 818 | |
@@ -827,7 +826,7 @@ discard block |
||
827 | 826 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
828 | 827 | } |
829 | 828 | |
830 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
829 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
831 | 830 | } |
832 | 831 | |
833 | 832 | if (!$result) { |
@@ -884,7 +883,7 @@ discard block |
||
884 | 883 | } |
885 | 884 | } |
886 | 885 | } |
887 | - if (! $url) { |
|
886 | + if (!$url) { |
|
888 | 887 | try { |
889 | 888 | $res = $this->dropbox->share($path, null, false); |
890 | 889 | $url = $res['url']; |
@@ -896,7 +895,7 @@ discard block |
||
896 | 895 | } |
897 | 896 | list($url) = explode('?', $url); |
898 | 897 | $url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url); |
899 | - if (! isset($cache['share']) || $cache['share'] !== $url) { |
|
898 | + if (!isset($cache['share']) || $cache['share'] !== $url) { |
|
900 | 899 | $cache['share'] = $url; |
901 | 900 | $this->updateDBdat($path, $cache); |
902 | 901 | } |
@@ -920,12 +919,12 @@ discard block |
||
920 | 919 | if (function_exists('curl_exec')) { |
921 | 920 | |
922 | 921 | $c = curl_init(); |
923 | - curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); |
|
924 | - curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' ); |
|
925 | - curl_setopt( $c, CURLOPT_HEADER, 1 ); |
|
926 | - curl_setopt( $c, CURLOPT_NOBODY, true ); |
|
927 | - curl_setopt( $c, CURLOPT_URL, $url ); |
|
928 | - $res = curl_exec( $c ); |
|
922 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
|
923 | + curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD'); |
|
924 | + curl_setopt($c, CURLOPT_HEADER, 1); |
|
925 | + curl_setopt($c, CURLOPT_NOBODY, true); |
|
926 | + curl_setopt($c, CURLOPT_URL, $url); |
|
927 | + $res = curl_exec($c); |
|
929 | 928 | |
930 | 929 | } else { |
931 | 930 | |
@@ -941,13 +940,13 @@ discard block |
||
941 | 940 | $result = $request2->send(); |
942 | 941 | $res = array(); |
943 | 942 | $res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase(); |
944 | - foreach($result->getHeader() as $key => $val) { |
|
945 | - $res[] = $key . ': ' . $val; |
|
943 | + foreach ($result->getHeader() as $key => $val) { |
|
944 | + $res[] = $key.': '.$val; |
|
946 | 945 | } |
947 | 946 | $res = join("\r\n", $res); |
948 | - } catch( HTTP_Request2_Exception $e ){ |
|
947 | + } catch (HTTP_Request2_Exception $e) { |
|
949 | 948 | $res = ''; |
950 | - } catch (Exception $e){ |
|
949 | + } catch (Exception $e) { |
|
951 | 950 | $res = ''; |
952 | 951 | } |
953 | 952 | |
@@ -1002,7 +1001,7 @@ discard block |
||
1002 | 1001 | if (DIRECTORY_SEPARATOR !== '/') { |
1003 | 1002 | $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); |
1004 | 1003 | } |
1005 | - $path = '/' . ltrim($path, '/'); |
|
1004 | + $path = '/'.ltrim($path, '/'); |
|
1006 | 1005 | return $path; |
1007 | 1006 | } |
1008 | 1007 | |
@@ -1145,7 +1144,7 @@ discard block |
||
1145 | 1144 | * @return resource|false |
1146 | 1145 | * @author Dmitry (dio) Levashov |
1147 | 1146 | **/ |
1148 | - protected function _fopen($path, $mode='rb') { |
|
1147 | + protected function _fopen($path, $mode = 'rb') { |
|
1149 | 1148 | |
1150 | 1149 | if (($mode == 'rb' || $mode == 'r')) { |
1151 | 1150 | try { |
@@ -1155,7 +1154,7 @@ discard block |
||
1155 | 1154 | fputs($fp, "GET {$url['path']} HTTP/1.0\r\n"); |
1156 | 1155 | fputs($fp, "Host: {$url['host']}\r\n"); |
1157 | 1156 | fputs($fp, "\r\n"); |
1158 | - while(trim(fgets($fp)) !== ''){}; |
|
1157 | + while (trim(fgets($fp)) !== '') {}; |
|
1159 | 1158 | return $fp; |
1160 | 1159 | } catch (Dropbox_Exception $e) { |
1161 | 1160 | return false; |
@@ -1186,7 +1185,7 @@ discard block |
||
1186 | 1185 | * @return bool |
1187 | 1186 | * @author Dmitry (dio) Levashov |
1188 | 1187 | **/ |
1189 | - protected function _fclose($fp, $path='') { |
|
1188 | + protected function _fclose($fp, $path = '') { |
|
1190 | 1189 | @fclose($fp); |
1191 | 1190 | if ($path) { |
1192 | 1191 | @unlink($this->getTempFile($path)); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | ); |
104 | 104 | $this->options = array_merge($this->options, $opts); |
105 | 105 | $this->options['mimeDetect'] = 'internal'; |
106 | - $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
106 | + $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $scheme = parse_url($this->options['host'], PHP_URL_SCHEME); |
164 | 164 | |
165 | 165 | if ($scheme) { |
166 | - $this->options['host'] = substr($this->options['host'], strlen($scheme)+3); |
|
166 | + $this->options['host'] = substr($this->options['host'], strlen($scheme) + 3); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // normalize root path |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | if ($this->encoding) { |
240 | 240 | @ftp_exec($this->connect, 'OPTS UTF8 OFF'); |
241 | 241 | } else { |
242 | - @ftp_exec($this->connect, 'OPTS UTF8 ON' ); |
|
242 | + @ftp_exec($this->connect, 'OPTS UTF8 ON'); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | // switch off extended passive mode - may be usefull for some servers |
246 | - @ftp_exec($this->connect, 'epsv4 off' ); |
|
246 | + @ftp_exec($this->connect, 'epsv4 off'); |
|
247 | 247 | // enter passive mode if required |
248 | 248 | ftp_pasv($this->connect, $this->options['mode'] == 'passive'); |
249 | 249 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $name = $info[8]; |
312 | 312 | |
313 | 313 | if (preg_match('|(.+)\-\>(.+)|', $name, $m)) { |
314 | - $name = trim($m[1]); |
|
314 | + $name = trim($m[1]); |
|
315 | 315 | // check recursive processing |
316 | 316 | if ($this->cacheDirTarget && $this->_joinPath($base, $name) !== $this->cacheDirTarget) { |
317 | 317 | return array(); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $stat['owner'] = $info[2]; |
348 | 348 | $stat['group'] = $info[3]; |
349 | 349 | $stat['perm'] = substr($info[0], 1); |
350 | - $stat['isowner'] = $stat['owner']? ($stat['owner'] == $this->options['user']) : $this->options['owner']; |
|
350 | + $stat['isowner'] = $stat['owner'] ? ($stat['owner'] == $this->options['user']) : $this->options['owner']; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | $perm = $this->parsePermissions($info[0], $stat['owner']); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | $info[4] = 0; |
380 | 380 | $info[0] = 'drwxr-xr-x'; |
381 | 381 | } else { |
382 | - $info[4] = (int)$size; |
|
382 | + $info[4] = (int) $size; |
|
383 | 383 | $info[0] = '-rw-r--r--'; |
384 | 384 | } |
385 | 385 | return $info; |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | protected function parsePermissions($perm, $user = '') { |
396 | 396 | $res = array(); |
397 | 397 | $parts = array(); |
398 | - $owner = $user? ($user == $this->options['user']) : $this->options['owner']; |
|
398 | + $owner = $user ? ($user == $this->options['user']) : $this->options['owner']; |
|
399 | 399 | for ($i = 0, $l = strlen($perm); $i < $l; $i++) { |
400 | 400 | $parts[] = substr($perm, $i, 1); |
401 | 401 | } |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | } |
427 | 427 | } |
428 | 428 | $list = $this->convEncOut($list); |
429 | - $prefix = ($path === $this->separator)? $this->separator : $path . $this->separator; |
|
429 | + $prefix = ($path === $this->separator) ? $this->separator : $path.$this->separator; |
|
430 | 430 | $targets = array(); |
431 | - foreach($list as $stat) { |
|
432 | - $p = $prefix . $stat['name']; |
|
431 | + foreach ($list as $stat) { |
|
432 | + $p = $prefix.$stat['name']; |
|
433 | 433 | if (isset($stat['target'])) { |
434 | 434 | // stat later |
435 | 435 | $targets[$stat['name']] = $stat['target']; |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | } |
442 | 442 | } |
443 | 443 | // stat link targets |
444 | - foreach($targets as $name => $target) { |
|
444 | + foreach ($targets as $name => $target) { |
|
445 | 445 | $stat = array(); |
446 | 446 | $stat['name'] = $name; |
447 | - $p = $prefix . $name; |
|
447 | + $p = $prefix.$name; |
|
448 | 448 | $cacheDirTarget = $this->cacheDirTarget; |
449 | 449 | $this->cacheDirTarget = $this->convEncIn($target, true); |
450 | 450 | if ($tstat = $this->stat($target)) { |
@@ -453,12 +453,12 @@ discard block |
||
453 | 453 | $stat['thash'] = $tstat['hash']; |
454 | 454 | $stat['mime'] = $tstat['mime']; |
455 | 455 | $stat['read'] = $tstat['read']; |
456 | - $stat['write'] = $tstat['write']; |
|
456 | + $stat['write'] = $tstat['write']; |
|
457 | 457 | |
458 | - if (isset($tstat['ts'])) { $stat['ts'] = $tstat['ts']; } |
|
459 | - if (isset($tstat['owner'])) { $stat['owner'] = $tstat['owner']; } |
|
460 | - if (isset($tstat['group'])) { $stat['group'] = $tstat['group']; } |
|
461 | - if (isset($tstat['perm'])) { $stat['perm'] = $tstat['perm']; } |
|
458 | + if (isset($tstat['ts'])) { $stat['ts'] = $tstat['ts']; } |
|
459 | + if (isset($tstat['owner'])) { $stat['owner'] = $tstat['owner']; } |
|
460 | + if (isset($tstat['group'])) { $stat['group'] = $tstat['group']; } |
|
461 | + if (isset($tstat['perm'])) { $stat['perm'] = $tstat['perm']; } |
|
462 | 462 | if (isset($tstat['isowner'])) { $stat['isowner'] = $tstat['isowner']; } |
463 | 463 | } else { |
464 | 464 | |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | $comps = $new_comps; |
572 | 572 | $path = implode($this->separator, $comps); |
573 | 573 | if ($initial_slashes) { |
574 | - $path = str_repeat($this->separator, $initial_slashes) . $path; |
|
574 | + $path = str_repeat($this->separator, $initial_slashes).$path; |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | return $path ? $path : '.'; |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | * @author Dmitry (dio) Levashov |
638 | 638 | **/ |
639 | 639 | protected function _inpath($path, $parent) { |
640 | - return $path == $parent || strpos($path, $parent. $this->separator) === 0; |
|
640 | + return $path == $parent || strpos($path, $parent.$this->separator) === 0; |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | /***************** file stat ********************/ |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | } |
670 | 670 | if (!$this->MLSTsupprt) { |
671 | 671 | //if ($path == $this->root && (empty($this->ARGS['reload']) || !isset($this->ARGS['target']) || strpos($this->ARGS['target'], $this->id) !== 0)) { |
672 | - if ($path == $this->root && ! $this->isMyReload()) { |
|
672 | + if ($path == $this->root && !$this->isMyReload()) { |
|
673 | 673 | return array( |
674 | 674 | 'name' => $this->root, |
675 | 675 | 'mime' => 'directory', |
@@ -677,9 +677,9 @@ discard block |
||
677 | 677 | ); |
678 | 678 | } |
679 | 679 | $this->cacheDir($this->convEncOut($this->_dirname($path))); |
680 | - return $this->convEncIn(isset($this->cache[$outPath])? $this->cache[$outPath] : array()); |
|
680 | + return $this->convEncIn(isset($this->cache[$outPath]) ? $this->cache[$outPath] : array()); |
|
681 | 681 | } |
682 | - $raw = ftp_raw($this->connect, 'MLST ' . $path); |
|
682 | + $raw = ftp_raw($this->connect, 'MLST '.$path); |
|
683 | 683 | if (is_array($raw) && count($raw) > 1 && substr(trim($raw[0]), 0, 1) == 2) { |
684 | 684 | $parts = explode(';', trim($raw[1])); |
685 | 685 | array_pop($parts); |
@@ -709,8 +709,8 @@ discard block |
||
709 | 709 | |
710 | 710 | case 'perm': |
711 | 711 | $val = strtolower($val); |
712 | - $stat['read'] = (int)preg_match('/e|l|r/', $val); |
|
713 | - $stat['write'] = (int)preg_match('/w|m|c/', $val); |
|
712 | + $stat['read'] = (int) preg_match('/e|l|r/', $val); |
|
713 | + $stat['write'] = (int) preg_match('/w|m|c/', $val); |
|
714 | 714 | if (!preg_match('/f|d/', $val)) { |
715 | 715 | $stat['locked'] = 1; |
716 | 716 | } |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | if (!$this->ftpOsUnix) { |
796 | 796 | $info = $this->normalizeRawWindows($str); |
797 | 797 | } |
798 | - $name = isset($info[8])? trim($info[8]) : ''; |
|
798 | + $name = isset($info[8]) ? trim($info[8]) : ''; |
|
799 | 799 | if ($name && $name !== '.' && $name !== '..' && substr(strtolower($info[0]), 0, 1) === 'd') { |
800 | 800 | return true; |
801 | 801 | } |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | * @return resource|false |
851 | 851 | * @author Dmitry (dio) Levashov |
852 | 852 | **/ |
853 | - protected function _fopen($path, $mode='rb') { |
|
853 | + protected function _fopen($path, $mode = 'rb') { |
|
854 | 854 | // try ftp stream wrapper |
855 | 855 | if (ini_get('allow_url_fopen')) { |
856 | 856 | $url = 'ftp://'.$this->options['user'].':'.$this->options['pass'].'@'.$this->options['host'].':'.$this->options['port'].$path; |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | * @return bool |
888 | 888 | * @author Dmitry (dio) Levashov |
889 | 889 | **/ |
890 | - protected function _fclose($fp, $path='') { |
|
890 | + protected function _fclose($fp, $path = '') { |
|
891 | 891 | @fclose($fp); |
892 | 892 | if ($path) { |
893 | 893 | @unlink($this->getTempFile($path)); |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | if (@file_put_contents($local, $content, LOCK_EX) !== false |
1063 | 1063 | && ($fp = @fopen($local, 'rb'))) { |
1064 | 1064 | clearstatcache(); |
1065 | - $res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path)); |
|
1065 | + $res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path)); |
|
1066 | 1066 | @fclose($fp); |
1067 | 1067 | } |
1068 | 1068 | file_exists($local) && @unlink($local); |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | * @return bool |
1088 | 1088 | **/ |
1089 | 1089 | protected function _chmod($path, $mode) { |
1090 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
1090 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
1091 | 1091 | return @ftp_chmod($this->connect, $modeOct, $path); |
1092 | 1092 | } |
1093 | 1093 | |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | $basename = $this->_basename($path); |
1143 | - $localPath = $dir . DIRECTORY_SEPARATOR . $basename; |
|
1143 | + $localPath = $dir.DIRECTORY_SEPARATOR.$basename; |
|
1144 | 1144 | |
1145 | 1145 | if (!ftp_get($this->connect, $localPath, $path, FTP_BINARY)) { |
1146 | 1146 | //cleanup |
@@ -1177,7 +1177,7 @@ discard block |
||
1177 | 1177 | |
1178 | 1178 | // archive contains one item - extract in archive dir |
1179 | 1179 | $name = ''; |
1180 | - $src = $dir . DIRECTORY_SEPARATOR . $filesToProcess[0]; |
|
1180 | + $src = $dir.DIRECTORY_SEPARATOR.$filesToProcess[0]; |
|
1181 | 1181 | if (($extractTo === 'auto' || !$extractTo) && count($filesToProcess) === 1 && is_file($src)) { |
1182 | 1182 | $name = $filesToProcess[0]; |
1183 | 1183 | } else if ($extractTo === 'auto' || $extractTo) { |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | $src = $dir; |
1187 | 1187 | $name = basename($path); |
1188 | 1188 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
1189 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
1189 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
1190 | 1190 | } |
1191 | 1191 | $test = $this->_joinPath(dirname($path), $name); |
1192 | 1192 | if ($this->stat($test)) { |
@@ -1197,7 +1197,7 @@ discard block |
||
1197 | 1197 | if ($name !== '' && is_file($src)) { |
1198 | 1198 | $result = $this->_joinPath(dirname($path), $name); |
1199 | 1199 | |
1200 | - if (! ftp_put($this->connect, $result, $src, FTP_BINARY)) { |
|
1200 | + if (!ftp_put($this->connect, $result, $src, FTP_BINARY)) { |
|
1201 | 1201 | $this->rmdirRecursive($dir); |
1202 | 1202 | return false; |
1203 | 1203 | } |
@@ -1211,19 +1211,19 @@ discard block |
||
1211 | 1211 | } |
1212 | 1212 | $result[] = $dstDir; |
1213 | 1213 | } |
1214 | - foreach($filesToProcess as $name) { |
|
1214 | + foreach ($filesToProcess as $name) { |
|
1215 | 1215 | $name = rtrim($name, DIRECTORY_SEPARATOR); |
1216 | - $src = $dir . DIRECTORY_SEPARATOR . $name; |
|
1216 | + $src = $dir.DIRECTORY_SEPARATOR.$name; |
|
1217 | 1217 | if (is_dir($src)) { |
1218 | 1218 | $p = dirname($name); |
1219 | 1219 | $name = basename($name); |
1220 | - if (! $target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) { |
|
1220 | + if (!$target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) { |
|
1221 | 1221 | $this->rmdirRecursive($dir); |
1222 | 1222 | return false; |
1223 | 1223 | } |
1224 | 1224 | } else { |
1225 | 1225 | $target = $this->_joinPath($dstDir, $name); |
1226 | - if (! ftp_put($this->connect, $target, $src, FTP_BINARY)) { |
|
1226 | + if (!ftp_put($this->connect, $target, $src, FTP_BINARY)) { |
|
1227 | 1227 | $this->rmdirRecursive($dir); |
1228 | 1228 | return false; |
1229 | 1229 | } |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | is_dir($dir) && $this->rmdirRecursive($dir); |
1240 | 1240 | |
1241 | 1241 | $this->clearcache(); |
1242 | - return $result? $result : false; |
|
1242 | + return $result ? $result : false; |
|
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | /** |
@@ -1279,7 +1279,7 @@ discard block |
||
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | //cleanup |
1282 | - if(!$this->rmdirRecursive($tmpDir)) { |
|
1282 | + if (!$this->rmdirRecursive($tmpDir)) { |
|
1283 | 1283 | return false; |
1284 | 1284 | } |
1285 | 1285 | |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | $remoteDirLen = strlen($remote_directory); |
1384 | 1384 | foreach ($contents as $item) { |
1385 | 1385 | $relative_path = substr($item['path'], $remoteDirLen); |
1386 | - $local_path = $dest_local_directory . DIRECTORY_SEPARATOR . $relative_path; |
|
1386 | + $local_path = $dest_local_directory.DIRECTORY_SEPARATOR.$relative_path; |
|
1387 | 1387 | switch ($item['type']) { |
1388 | 1388 | case 'd': |
1389 | 1389 | $success = mkdir($local_path); |
@@ -1414,8 +1414,8 @@ discard block |
||
1414 | 1414 | } else { |
1415 | 1415 | $success = true; |
1416 | 1416 | foreach (array_reverse(elFinderVolumeFTP::listFilesInDirectory($dirPath, false)) as $path) { |
1417 | - $path = $dirPath . DIRECTORY_SEPARATOR . $path; |
|
1418 | - if(is_link($path)) { |
|
1417 | + $path = $dirPath.DIRECTORY_SEPARATOR.$path; |
|
1418 | + if (is_link($path)) { |
|
1419 | 1419 | unlink($path); |
1420 | 1420 | } else if (is_dir($path)) { |
1421 | 1421 | $success = rmdir($path); |
@@ -1426,11 +1426,11 @@ discard block |
||
1426 | 1426 | break; |
1427 | 1427 | } |
1428 | 1428 | } |
1429 | - if($success) { |
|
1429 | + if ($success) { |
|
1430 | 1430 | $success = rmdir($dirPath); |
1431 | 1431 | } |
1432 | 1432 | } |
1433 | - if(!$success) { |
|
1433 | + if (!$success) { |
|
1434 | 1434 | $this->setError(elFinder::ERROR_RM, $dirPath); |
1435 | 1435 | return false; |
1436 | 1436 | } |
@@ -1452,25 +1452,25 @@ discard block |
||
1452 | 1452 | if (!is_dir($dir)) { |
1453 | 1453 | return false; |
1454 | 1454 | } |
1455 | - $excludes = array(".",".."); |
|
1455 | + $excludes = array(".", ".."); |
|
1456 | 1456 | $result = array(); |
1457 | 1457 | $files = scandir($dir); |
1458 | - if(!$files) { |
|
1458 | + if (!$files) { |
|
1459 | 1459 | return array(); |
1460 | 1460 | } |
1461 | - foreach($files as $file) { |
|
1462 | - if(!in_array($file, $excludes)) { |
|
1461 | + foreach ($files as $file) { |
|
1462 | + if (!in_array($file, $excludes)) { |
|
1463 | 1463 | $path = $dir.DIRECTORY_SEPARATOR.$file; |
1464 | - if(is_link($path)) { |
|
1465 | - if($omitSymlinks) { |
|
1464 | + if (is_link($path)) { |
|
1465 | + if ($omitSymlinks) { |
|
1466 | 1466 | continue; |
1467 | 1467 | } else { |
1468 | 1468 | $result[] = $prefix.$file; |
1469 | 1469 | } |
1470 | - } else if(is_dir($path)) { |
|
1470 | + } else if (is_dir($path)) { |
|
1471 | 1471 | $result[] = $prefix.$file.DIRECTORY_SEPARATOR; |
1472 | 1472 | $subs = elFinderVolumeFTP::listFilesInDirectory($path, $omitSymlinks, $prefix.$file.DIRECTORY_SEPARATOR); |
1473 | - if($subs) { |
|
1473 | + if ($subs) { |
|
1474 | 1474 | $result = array_merge($result, $subs); |
1475 | 1475 | } |
1476 | 1476 |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | * @author Dmitry (dio) Levashov |
33 | 33 | **/ |
34 | 34 | public function __construct() { |
35 | - $this->options['alias'] = ''; // alias to replace root dir name |
|
36 | - $this->options['dirMode'] = 0755; // new dirs mode |
|
37 | - $this->options['fileMode'] = 0644; // new files mode |
|
38 | - $this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden) |
|
39 | - $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
35 | + $this->options['alias'] = ''; // alias to replace root dir name |
|
36 | + $this->options['dirMode'] = 0755; // new dirs mode |
|
37 | + $this->options['fileMode'] = 0644; // new files mode |
|
38 | + $this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden) |
|
39 | + $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
40 | 40 | $this->options['rootCssClass'] = 'elfinder-navbar-root-local'; |
41 | 41 | } |
42 | 42 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | protected function init() { |
54 | 54 | // Normalize directory separator for windows |
55 | 55 | if (DIRECTORY_SEPARATOR !== '/') { |
56 | - foreach(array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) { |
|
56 | + foreach (array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) { |
|
57 | 57 | if (!empty($this->options[$key])) { |
58 | 58 | $this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]); |
59 | 59 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | // if no thumbnails url - try detect it |
118 | 118 | if ($root['read'] && !$this->tmbURL && $this->URL) { |
119 | 119 | if (strpos($this->tmbPath, $this->root) === 0) { |
120 | - $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1)); |
|
120 | + $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1)); |
|
121 | 121 | if (preg_match("|[^/?&=]$|", $this->tmbURL)) { |
122 | 122 | $this->tmbURL .= '/'; |
123 | 123 | } |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | if ($mtime != $compare) { |
176 | 176 | return $mtime; |
177 | 177 | } |
178 | - $inotifywait = defined('ELFINER_INOTIFYWAIT_PATH')? ELFINER_INOTIFYWAIT_PATH : 'inotifywait'; |
|
178 | + $inotifywait = defined('ELFINER_INOTIFYWAIT_PATH') ? ELFINER_INOTIFYWAIT_PATH : 'inotifywait'; |
|
179 | 179 | $path = escapeshellarg($path); |
180 | 180 | $standby = max(1, intval($standby)); |
181 | 181 | $cmd = $inotifywait.' '.$path.' -t '.$standby.' -e moved_to,moved_from,move,create,delete,delete_self'; |
182 | 182 | $o = $r = ''; |
183 | - $this->procExec($cmd , $o, $r); |
|
183 | + $this->procExec($cmd, $o, $r); |
|
184 | 184 | if ($r === 0) { |
185 | 185 | // changed |
186 | 186 | clearstatcache(); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | } |
192 | 192 | // error |
193 | 193 | // cache to $_SESSION |
194 | - $sessionClose = true;; |
|
194 | + $sessionClose = true; ; |
|
195 | 195 | try { |
196 | 196 | $sessionStart = session_start(); |
197 | 197 | } catch (Exception $e) { |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @author Dmitry (dio) Levashov |
244 | 244 | **/ |
245 | 245 | protected function _joinPath($dir, $name) { |
246 | - return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; |
|
246 | + return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $comps = $new_comps; |
296 | 296 | $path = implode('/', $comps); |
297 | 297 | if ($initial_slashes) { |
298 | - $path = str_repeat('/', $initial_slashes) . $path; |
|
298 | + $path = str_repeat('/', $initial_slashes).$path; |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | if ($changeSep) { |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | **/ |
367 | 367 | protected function _inpath($path, $parent) { |
368 | 368 | $cwd = getcwd(); |
369 | - $real_path = $this->getFullPath($path, $cwd); |
|
369 | + $real_path = $this->getFullPath($path, $cwd); |
|
370 | 370 | $real_parent = $this->getFullPath($parent, $cwd); |
371 | 371 | if ($real_path && $real_parent) { |
372 | 372 | return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0; |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | $stat = array(); |
426 | 426 | return $stat; |
427 | 427 | } else { |
428 | - $stat['mime'] = 'symlink-broken'; |
|
428 | + $stat['mime'] = 'symlink-broken'; |
|
429 | 429 | $target = readlink($path); |
430 | 430 | $lstat = lstat($path); |
431 | 431 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | $fstat = stat($path); |
442 | 442 | $uid = $fstat['uid']; |
443 | 443 | $gid = $fstat['gid']; |
444 | - $stat['perm'] = substr((string)decoct($fstat['mode']), -4); |
|
444 | + $stat['perm'] = substr((string) decoct($fstat['mode']), -4); |
|
445 | 445 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
446 | 446 | } |
447 | 447 | |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | $stat['mime'] = $dir ? 'directory' : $this->mimetype($path); |
452 | 452 | } |
453 | 453 | //logical rights first |
454 | - $stat['read'] = ($linkreadable || is_readable($path))? null : false; |
|
455 | - $stat['write'] = is_writable($path)? null : false; |
|
454 | + $stat['read'] = ($linkreadable || is_readable($path)) ? null : false; |
|
455 | + $stat['write'] = is_writable($path) ? null : false; |
|
456 | 456 | |
457 | 457 | if (is_null($stat['read'])) { |
458 | 458 | $stat['size'] = $dir ? 0 : $size; |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | |
523 | 523 | if (is_dir($path)) { |
524 | 524 | $path = strtr($path, array('[' => '\\[', ']' => '\\]', '*' => '\\*', '?' => '\\?')); |
525 | - return (bool)glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
525 | + return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
526 | 526 | } |
527 | 527 | return false; |
528 | 528 | } |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | $br = true; |
604 | 604 | } else { |
605 | 605 | $_path = $fpath; |
606 | - $stat['mime'] = 'symlink-broken'; |
|
606 | + $stat['mime'] = 'symlink-broken'; |
|
607 | 607 | $target = readlink($_path); |
608 | 608 | $lstat = lstat($_path); |
609 | 609 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -628,13 +628,13 @@ discard block |
||
628 | 628 | if ($statOwner && !$linkreadable) { |
629 | 629 | $uid = $file->getOwner(); |
630 | 630 | $gid = $file->getGroup(); |
631 | - $stat['perm'] = substr((string)decoct($file->getPerms()), -4); |
|
631 | + $stat['perm'] = substr((string) decoct($file->getPerms()), -4); |
|
632 | 632 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
633 | 633 | } |
634 | 634 | |
635 | 635 | //logical rights first |
636 | - $stat['read'] = ($linkreadable || $file->isReadable())? null : false; |
|
637 | - $stat['write'] = $file->isWritable()? null : false; |
|
636 | + $stat['read'] = ($linkreadable || $file->isReadable()) ? null : false; |
|
637 | + $stat['write'] = $file->isWritable() ? null : false; |
|
638 | 638 | |
639 | 639 | if (is_null($stat['read'])) { |
640 | 640 | $stat['size'] = $dir ? 0 : $size; |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | |
651 | 651 | if ($cache) { |
652 | 652 | $cache = $this->convEncOut($cache, false); |
653 | - foreach($cache as $d) { |
|
653 | + foreach ($cache as $d) { |
|
654 | 654 | $this->updateCache($d[0], $d[1]); |
655 | 655 | } |
656 | 656 | } |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * @return resource|false |
667 | 667 | * @author Dmitry (dio) Levashov |
668 | 668 | **/ |
669 | - protected function _fopen($path, $mode='rb') { |
|
669 | + protected function _fopen($path, $mode = 'rb') { |
|
670 | 670 | return @fopen($path, $mode); |
671 | 671 | } |
672 | 672 | |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | * @return bool |
678 | 678 | * @author Dmitry (dio) Levashov |
679 | 679 | **/ |
680 | - protected function _fclose($fp, $path='') { |
|
680 | + protected function _fclose($fp, $path = '') { |
|
681 | 681 | return @fclose($fp); |
682 | 682 | } |
683 | 683 | |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | $path = $this->_joinPath($dir, $name); |
810 | 810 | |
811 | 811 | $meta = stream_get_meta_data($fp); |
812 | - $uri = isset($meta['uri'])? $meta['uri'] : ''; |
|
812 | + $uri = isset($meta['uri']) ? $meta['uri'] : ''; |
|
813 | 813 | if ($uri && @is_file($uri)) { |
814 | 814 | fclose($fp); |
815 | 815 | $isCmdPaste = ($this->ARGS['cmd'] === 'paste'); |
@@ -873,7 +873,7 @@ discard block |
||
873 | 873 | * @return bool |
874 | 874 | **/ |
875 | 875 | protected function _chmod($path, $mode) { |
876 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
876 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
877 | 877 | $ret = @chmod($path, $modeOct); |
878 | 878 | $ret && clearstatcache(); |
879 | 879 | return $ret; |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | $src = $dir; |
992 | 992 | $name = basename($path); |
993 | 993 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
994 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
994 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
995 | 995 | } |
996 | 996 | $test = dirname($path).DIRECTORY_SEPARATOR.$name; |
997 | 997 | if (file_exists($test) || is_link($test)) { |
@@ -1000,9 +1000,9 @@ discard block |
||
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | if ($name !== '') { |
1003 | - $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
1003 | + $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
1004 | 1004 | |
1005 | - if (! @rename($src, $result)) { |
|
1005 | + if (!@rename($src, $result)) { |
|
1006 | 1006 | $this->delTree($dir); |
1007 | 1007 | return false; |
1008 | 1008 | } |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | $dstDir = dirname($path); |
1011 | 1011 | $res = false; |
1012 | 1012 | $result = array(); |
1013 | - foreach($ls as $name) { |
|
1013 | + foreach ($ls as $name) { |
|
1014 | 1014 | $target = $dstDir.DIRECTORY_SEPARATOR.$name; |
1015 | 1015 | if (is_dir($target)) { |
1016 | 1016 | $this->delTree($target); |
@@ -1102,10 +1102,10 @@ discard block |
||
1102 | 1102 | |
1103 | 1103 | $path = strtr($path, $escaper); |
1104 | 1104 | $_q = strtr($q, $escaper); |
1105 | - $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
1106 | - $match = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'.$_q.'*', GLOB_NOSORT); |
|
1105 | + $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
1106 | + $match = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'.$_q.'*', GLOB_NOSORT); |
|
1107 | 1107 | if ($match) { |
1108 | - foreach($match as $p) { |
|
1108 | + foreach ($match as $p) { |
|
1109 | 1109 | $stat = $this->stat($p); |
1110 | 1110 | |
1111 | 1111 | if (!$stat) { // invalid links |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | $stat['path'] = $this->path($stat['hash']); |
1123 | 1123 | if ($this->URL && !isset($stat['url'])) { |
1124 | 1124 | $path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1)); |
1125 | - $stat['url'] = $this->URL . $path; |
|
1125 | + $stat['url'] = $this->URL.$path; |
|
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | $result[] = $stat; |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | } |
1131 | 1131 | } |
1132 | 1132 | if ($dirs) { |
1133 | - foreach($dirs as $dir) { |
|
1133 | + foreach ($dirs as $dir) { |
|
1134 | 1134 | $stat = $this->stat($dir); |
1135 | 1135 | if ($stat['read'] && !isset($stat['alias'])) { |
1136 | 1136 | @set_time_limit(30); |