Completed
Push — 2.x ( 60aec1...88c7e9 )
by Naoki
03:47
created
php/elFinderVolumeDropbox.class.php 1 patch
Spacing   +63 added lines, -64 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		
138 138
 		if ($options['user'] === 'init') {
139 139
 
140
-			if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO')) {
140
+			if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO')) {
141 141
 				return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}');
142 142
 			}
143 143
 			
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 				if (class_exists('OAuth')) {
148 148
 					$this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']);
149 149
 				} else {
150
-					if (! class_exists('HTTP_OAuth_Consumer')) {
150
+					if (!class_exists('HTTP_OAuth_Consumer')) {
151 151
 						// We're going to try to load in manually
152 152
 						include 'HTTP/OAuth/Consumer.php';
153 153
 					}
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 				}
158 158
 			}
159 159
 			
160
-			if (! $this->oauth) {
160
+			if (!$this->oauth) {
161 161
 				return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}');
162 162
 			}
163 163
 
@@ -178,25 +178,25 @@  discard block
 block discarded – undo
178 178
 						unset($_SESSION['elFinderDropboxTokens']);
179 179
 					}
180 180
 				}
181
-				if (! $html) {
181
+				if (!$html) {
182 182
 					// get customdata
183 183
 					$cdata = '';
184 184
 					$innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user');
185
-					$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
186
-					foreach($this->ARGS as $k => $v) {
187
-						if (! in_array($k, $innerKeys)) {
188
-							$cdata .= '&' . $k . '=' . rawurlencode($v);
185
+					$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
186
+					foreach ($this->ARGS as $k => $v) {
187
+						if (!in_array($k, $innerKeys)) {
188
+							$cdata .= '&'.$k.'='.rawurlencode($v);
189 189
 						}
190 190
 					}
191
-					if (strpos($options['url'], 'http') !== 0 ) {
191
+					if (strpos($options['url'], 'http') !== 0) {
192 192
 						$options['url'] = $this->getConnectorUrl();
193 193
 					}
194
-					$callback  = $options['url']
194
+					$callback = $options['url']
195 195
 					           . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata;
196 196
 					
197 197
 					try {
198 198
 						$tokens = $this->oauth->getRequestToken();
199
-						$url= $this->oauth->getAuthorizeUrl(rawurlencode($callback));
199
+						$url = $this->oauth->getAuthorizeUrl(rawurlencode($callback));
200 200
 					} catch (Dropbox_Exception $e) {
201 201
 						return array('exit' => true, 'body' => '{msg:errAccess}');
202 202
 					}
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
 		if (isset($netVolumes[$key])) {
244 244
 			$dropboxUid = $netVolumes[$key]['dropboxUid'];
245 245
 		}
246
-		foreach($netVolumes as $volume) {
246
+		foreach ($netVolumes as $volume) {
247 247
 			if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) {
248 248
 				$count++;
249 249
 			}
250 250
 		}
251 251
 		if ($count === 1) {
252 252
 			$this->DB->exec('drop table '.$this->DB_TableName);
253
-			foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) {
253
+			foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) {
254 254
 				unlink($tmb);
255 255
 			}
256 256
 		}
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 	 * @author Naoki Sawada
265 265
 	 */
266 266
 	private function getConnectorUrl() {
267
-		$url  = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://')
267
+		$url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://')
268 268
 		       . $_SERVER['SERVER_NAME']                                              // host
269
-		      . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT'])  // port
270
-		       . $_SERVER['REQUEST_URI'];                                             // path & query
269
+		      . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT'])  // port
270
+		       . $_SERVER['REQUEST_URI']; // path & query
271 271
 		list($url) = explode('?', $url);
272 272
 		return $url;
273 273
 	}
@@ -303,14 +303,14 @@  discard block
 block discarded – undo
303 303
 		// make net mount key
304 304
 		$this->netMountKey = md5(join('-', array('dropbox', $this->options['path'])));
305 305
 
306
-		if (! $this->oauth) {
306
+		if (!$this->oauth) {
307 307
 			if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) {
308 308
 				$this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']);
309 309
 			} else {
310 310
 				if (class_exists('OAuth')) {
311 311
 					$this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']);
312 312
 				} else {
313
-					if (! class_exists('HTTP_OAuth_Consumer')) {
313
+					if (!class_exists('HTTP_OAuth_Consumer')) {
314 314
 						// We're going to try to load in manually
315 315
 						include 'HTTP/OAuth/Consumer.php';
316 316
 					}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			}
322 322
 		}
323 323
 		
324
-		if (! $this->oauth) {
324
+		if (!$this->oauth) {
325 325
 			return $this->setError('OAuth extension not loaded.');
326 326
 		}
327 327
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		$this->root = $this->options['path'] = $this->_normpath($this->options['path']);
330 330
 
331 331
 		if (empty($this->options['alias'])) {
332
-			$this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com'  : 'Dropbox'.$this->options['path'];
332
+			$this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path'];
333 333
 		}
334 334
 
335 335
 		$this->rootName = $this->options['alias'];
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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) {
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 				$res = false;
445 445
 			}
446 446
 		}
447
-		if (! $res) {
447
+		if (!$res) {
448 448
 			try {
449 449
 				$this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);');
450 450
 				$this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)');
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 	 */
495 495
 	private function updateDBdat($path, $dat) {
496 496
 		return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat))
497
-				. ', isdir=' . ($dat['is_dir']? 1 : 0)
497
+				. ', isdir='.($dat['is_dir'] ? 1 : 0)
498 498
 				. ' where path='.$this->DB->quote(strtolower(dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path))));
499 499
 	}
500 500
 	/*********************************************************************/
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 	 */
520 520
 	protected function deltaCheck($refresh = true) {
521 521
 		$chk = false;
522
-		if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) {
522
+		if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) {
523 523
 			$chk = unserialize($chk[0]);
524 524
 		}
525 525
 		if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) {
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 			do {
542 542
 				@ ini_set('max_execution_time', 120);
543 543
 				$_info = $this->dropbox->delta($cursor);
544
-				if (! empty($_info['reset'])) {
544
+				if (!empty($_info['reset'])) {
545 545
 					$this->DB->exec('TRUNCATE table '.$this->DB_TableName);
546 546
 					$this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);');
547 547
 					$this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array(
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 				}
555 555
 				$cursor = $_info['cursor'];
556 556
 				
557
-				foreach($_info['entries'] as $entry) {
557
+				foreach ($_info['entries'] as $entry) {
558 558
 					$key = strtolower($entry[0]);
559 559
 					$pkey = strtolower(dirname($key));
560 560
 					
@@ -564,27 +564,27 @@  discard block
 block discarded – undo
564 564
 					
565 565
 					if (empty($entry[1])) {
566 566
 						$this->DB->exec('delete from '.$this->DB_TableName.' '.$where);
567
-						! $delete && $delete = true;
567
+						!$delete && $delete = true;
568 568
 						continue;
569 569
 					}
570 570
 
571 571
 					$sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1';
572
-					if (! $reset && $this->query($sql)) {
573
-						$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where);
572
+					if (!$reset && $this->query($sql)) {
573
+						$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where);
574 574
 					} else {
575
-						$this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')');
575
+						$this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')');
576 576
 					}
577 577
 				}
578
-			} while (! empty($_info['has_more']));
578
+			} while (!empty($_info['has_more']));
579 579
 			$this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\'');
580
-			if (! $this->DB->commit()) {
580
+			if (!$this->DB->commit()) {
581 581
 				$e = $this->DB->errorInfo();
582 582
 				return $e[2];
583 583
 			}
584 584
 			if ($delete) {
585 585
 				$this->DB->exec('vacuum');
586 586
 			}
587
-		} catch(Dropbox_Exception $e) {
587
+		} catch (Dropbox_Exception $e) {
588 588
 			return $e->getMessage();
589 589
 		}
590 590
 		return true;
@@ -600,15 +600,14 @@  discard block
 block discarded – undo
600 600
 	protected function parseRaw($raw) {
601 601
 		$stat = array();
602 602
 
603
-		$stat['rev']   = isset($raw['rev'])? $raw['rev'] : 'root';
603
+		$stat['rev']   = isset($raw['rev']) ? $raw['rev'] : 'root';
604 604
 		$stat['name']  = basename($raw['path']);
605
-		$stat['mime']  = $raw['is_dir']? 'directory' : $raw['mime_type'];
605
+		$stat['mime']  = $raw['is_dir'] ? 'directory' : $raw['mime_type'];
606 606
 		$stat['size']  = $stat['mime'] == 'directory' ? 0 : $raw['bytes'];
607
-		$stat['ts']    = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) :
608
-		                (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']);
607
+		$stat['ts']    = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']);
609 608
 		$stat['dirs'] = 0;
610 609
 		if ($raw['is_dir']) {
611
-			$stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path'])));
610
+			$stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path'])));
612 611
 		}
613 612
 		
614 613
 		if (!empty($raw['url'])) {
@@ -634,7 +633,7 @@  discard block
 block discarded – undo
634 633
 		$res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path)));
635 634
 		
636 635
 		if ($res) {
637
-			foreach($res as $raw) {
636
+			foreach ($res as $raw) {
638 637
 				$raw = unserialize($raw);
639 638
 				if ($stat = $this->parseRaw($raw)) {
640 639
 					$stat = $this->updateCache($raw['path'], $stat);
@@ -659,10 +658,10 @@  discard block
 block discarded – undo
659 658
 	protected function doSearch($path, $q, $mimes) {
660 659
 		$result = array();
661 660
 		$sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?');
662
-		$sth->execute(array('%'.(($path === '/')? '' : strtolower($path)), '%'.strtolower($q).'%'));
661
+		$sth->execute(array('%'.(($path === '/') ? '' : strtolower($path)), '%'.strtolower($q).'%'));
663 662
 		$res = $sth->fetchAll(PDO::FETCH_COLUMN);
664 663
 		if ($res) {
665
-			foreach($res as $raw) {
664
+			foreach ($res as $raw) {
666 665
 				$raw = unserialize($raw);
667 666
 				if ($stat = $this->parseRaw($raw)) {
668 667
 					if (!isset($this->cache[$raw['path']])) {
@@ -753,10 +752,10 @@  discard block
 block discarded – undo
753 752
 		$tmb  = $this->tmbPath.DIRECTORY_SEPARATOR.$name;
754 753
 	
755 754
 		// copy image into tmbPath so some drivers does not store files on local fs
756
-		if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) {
755
+		if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) {
757 756
 			return false;
758 757
 		}
759
-		if (! file_put_contents($tmb, $data)) {
758
+		if (!file_put_contents($tmb, $data)) {
760 759
 			return false;
761 760
 		}
762 761
 	
@@ -769,15 +768,15 @@  discard block
 block discarded – undo
769 768
 		}
770 769
 	
771 770
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
772
-		if ($s[0] <= $tmbSize && $s[1]  <= $tmbSize) {
773
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
771
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
772
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
774 773
 	
775 774
 		} else {
776 775
 	
777 776
 			if ($this->options['tmbCrop']) {
778 777
 	
779 778
 				/* Resize and crop if image bigger than thumbnail */
780
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
779
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
781 780
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
782 781
 				}
783 782
 	
@@ -791,7 +790,7 @@  discard block
 block discarded – undo
791 790
 				$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png');
792 791
 			}
793 792
 		
794
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
793
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
795 794
 		}
796 795
 		
797 796
 		if (!$result) {
@@ -848,7 +847,7 @@  discard block
 block discarded – undo
848 847
 					}
849 848
 				}
850 849
 			}
851
-			if (! $url) {
850
+			if (!$url) {
852 851
 				try {
853 852
 					$res = $this->dropbox->share($path, null, false);
854 853
 					$url = $res['url'];
@@ -860,7 +859,7 @@  discard block
 block discarded – undo
860 859
 					}
861 860
 					list($url) = explode('?', $url);
862 861
 					$url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url);
863
-					if (! isset($cache['share']) || $cache['share'] !== $url) {
862
+					if (!isset($cache['share']) || $cache['share'] !== $url) {
864 863
 						$cache['share'] = $url;
865 864
 						$this->updateDBdat($path, $cache);
866 865
 					}
@@ -884,12 +883,12 @@  discard block
 block discarded – undo
884 883
 		if (function_exists('curl_exec')) {
885 884
 
886 885
 			$c = curl_init();
887
-			curl_setopt( $c, CURLOPT_RETURNTRANSFER, true );
888
-			curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' );
889
-			curl_setopt( $c, CURLOPT_HEADER, 1 );
890
-			curl_setopt( $c, CURLOPT_NOBODY, true );
891
-			curl_setopt( $c, CURLOPT_URL, $url );
892
-			$res = curl_exec( $c );
886
+			curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
887
+			curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD');
888
+			curl_setopt($c, CURLOPT_HEADER, 1);
889
+			curl_setopt($c, CURLOPT_NOBODY, true);
890
+			curl_setopt($c, CURLOPT_URL, $url);
891
+			$res = curl_exec($c);
893 892
 			
894 893
 		} else {
895 894
 			
@@ -905,13 +904,13 @@  discard block
 block discarded – undo
905 904
 				$result = $request2->send();
906 905
 				$res = array();
907 906
 				$res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase();
908
-				foreach($result->getHeader() as $key => $val) {
909
-					$res[] = $key . ': ' . $val;
907
+				foreach ($result->getHeader() as $key => $val) {
908
+					$res[] = $key.': '.$val;
910 909
 				}
911 910
 				$res = join("\r\n", $res);
912
-			} catch( HTTP_Request2_Exception $e ){
911
+			} catch (HTTP_Request2_Exception $e) {
913 912
 				$res = '';
914
-			} catch (Exception $e){
913
+			} catch (Exception $e) {
915 914
 				$res = '';
916 915
 			}
917 916
 		
@@ -964,7 +963,7 @@  discard block
 block discarded – undo
964 963
 	 **/
965 964
 	protected function _normpath($path) {
966 965
 		$path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
967
-		$path = '/' . ltrim($path, '/');
966
+		$path = '/'.ltrim($path, '/');
968 967
 		return $path;
969 968
 	}
970 969
 
@@ -1103,7 +1102,7 @@  discard block
 block discarded – undo
1103 1102
 	 * @return resource|false
1104 1103
 	 * @author Dmitry (dio) Levashov
1105 1104
 	 **/
1106
-	protected function _fopen($path, $mode='rb') {
1105
+	protected function _fopen($path, $mode = 'rb') {
1107 1106
 
1108 1107
 		if (($mode == 'rb' || $mode == 'r')) {
1109 1108
 			try {
@@ -1113,7 +1112,7 @@  discard block
 block discarded – undo
1113 1112
  				fputs($fp, "GET {$url['path']} HTTP/1.0\r\n");
1114 1113
  				fputs($fp, "Host: {$url['host']}\r\n");
1115 1114
  				fputs($fp, "\r\n");
1116
- 				while(trim(fgets($fp)) !== ''){};
1115
+ 				while (trim(fgets($fp)) !== '') {};
1117 1116
  				return $fp;
1118 1117
 			} catch (Dropbox_Exception $e) {
1119 1118
 				return false;
@@ -1144,7 +1143,7 @@  discard block
 block discarded – undo
1144 1143
 	 * @return bool
1145 1144
 	 * @author Dmitry (dio) Levashov
1146 1145
 	 **/
1147
-	protected function _fclose($fp, $path='') {
1146
+	protected function _fclose($fp, $path = '') {
1148 1147
 		@fclose($fp);
1149 1148
 		if ($path) {
1150 1149
 			@unlink($this->getTempFile($path));
Please login to merge, or discard this patch.
php/elFinder.class.php 1 patch
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -203,14 +203,14 @@  discard block
 block discarded – undo
203 203
 	const ERROR_INV_PARAMS        = 'errCmdParams';
204 204
 	const ERROR_OPEN              = 'errOpen';
205 205
 	const ERROR_DIR_NOT_FOUND     = 'errFolderNotFound';
206
-	const ERROR_FILE_NOT_FOUND    = 'errFileNotFound';     // 'File not found.'
206
+	const ERROR_FILE_NOT_FOUND    = 'errFileNotFound'; // 'File not found.'
207 207
 	const ERROR_TRGDIR_NOT_FOUND  = 'errTrgFolderNotFound'; // 'Target folder "$1" not found.'
208 208
 	const ERROR_NOT_DIR           = 'errNotFolder';
209 209
 	const ERROR_NOT_FILE          = 'errNotFile';
210 210
 	const ERROR_PERM_DENIED       = 'errPerm';
211
-	const ERROR_LOCKED            = 'errLocked';        // '"$1" is locked and can not be renamed, moved or removed.'
212
-	const ERROR_EXISTS            = 'errExists';        // 'File named "$1" already exists.'
213
-	const ERROR_INVALID_NAME      = 'errInvName';       // 'Invalid file name.'
211
+	const ERROR_LOCKED            = 'errLocked'; // '"$1" is locked and can not be renamed, moved or removed.'
212
+	const ERROR_EXISTS            = 'errExists'; // 'File named "$1" already exists.'
213
+	const ERROR_INVALID_NAME      = 'errInvName'; // 'Invalid file name.'
214 214
 	const ERROR_MKDIR             = 'errMkdir';
215 215
 	const ERROR_MKFILE            = 'errMkfile';
216 216
 	const ERROR_RENAME            = 'errRename';
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
 	const ERROR_COPY_FROM         = 'errCopyFrom';
220 220
 	const ERROR_COPY_TO           = 'errCopyTo';
221 221
 	const ERROR_COPY_ITSELF       = 'errCopyInItself';
222
-	const ERROR_REPLACE           = 'errReplace';          // 'Unable to replace "$1".'
223
-	const ERROR_RM                = 'errRm';               // 'Unable to remove "$1".'
224
-	const ERROR_RM_SRC            = 'errRmSrc';            // 'Unable remove source file(s)'
225
-	const ERROR_MKOUTLINK         = 'errMkOutLink';        // 'Unable to create a link to outside the volume root.'
226
-	const ERROR_UPLOAD            = 'errUpload';           // 'Upload error.'
227
-	const ERROR_UPLOAD_FILE       = 'errUploadFile';       // 'Unable to upload "$1".'
228
-	const ERROR_UPLOAD_NO_FILES   = 'errUploadNoFiles';    // 'No files found for upload.'
229
-	const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize';  // 'Data exceeds the maximum allowed size.'
230
-	const ERROR_UPLOAD_FILE_SIZE  = 'errUploadFileSize';   // 'File exceeds maximum allowed size.'
231
-	const ERROR_UPLOAD_FILE_MIME  = 'errUploadMime';       // 'File type not allowed.'
232
-	const ERROR_UPLOAD_TRANSFER   = 'errUploadTransfer';   // '"$1" transfer error.'
233
-	const ERROR_UPLOAD_TEMP       = 'errUploadTemp';       // 'Unable to make temporary file for upload.'
222
+	const ERROR_REPLACE           = 'errReplace'; // 'Unable to replace "$1".'
223
+	const ERROR_RM                = 'errRm'; // 'Unable to remove "$1".'
224
+	const ERROR_RM_SRC            = 'errRmSrc'; // 'Unable remove source file(s)'
225
+	const ERROR_MKOUTLINK         = 'errMkOutLink'; // 'Unable to create a link to outside the volume root.'
226
+	const ERROR_UPLOAD            = 'errUpload'; // 'Upload error.'
227
+	const ERROR_UPLOAD_FILE       = 'errUploadFile'; // 'Unable to upload "$1".'
228
+	const ERROR_UPLOAD_NO_FILES   = 'errUploadNoFiles'; // 'No files found for upload.'
229
+	const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize'; // 'Data exceeds the maximum allowed size.'
230
+	const ERROR_UPLOAD_FILE_SIZE  = 'errUploadFileSize'; // 'File exceeds maximum allowed size.'
231
+	const ERROR_UPLOAD_FILE_MIME  = 'errUploadMime'; // 'File type not allowed.'
232
+	const ERROR_UPLOAD_TRANSFER   = 'errUploadTransfer'; // '"$1" transfer error.'
233
+	const ERROR_UPLOAD_TEMP       = 'errUploadTemp'; // 'Unable to make temporary file for upload.'
234 234
 	// const ERROR_ACCESS_DENIED     = 'errAccess';
235
-	const ERROR_NOT_REPLACE       = 'errNotReplace';       // Object "$1" already exists at this location and can not be replaced with object of another type.
235
+	const ERROR_NOT_REPLACE       = 'errNotReplace'; // Object "$1" already exists at this location and can not be replaced with object of another type.
236 236
 	const ERROR_SAVE              = 'errSave';
237 237
 	const ERROR_EXTRACT           = 'errExtract';
238 238
 	const ERROR_ARCHIVE           = 'errArchive';
@@ -247,14 +247,14 @@  discard block
 block discarded – undo
247 247
 	const ERROR_NETMOUNT          = 'errNetMount';
248 248
 	const ERROR_NETUNMOUNT        = 'errNetUnMount';
249 249
 	const ERROR_NETMOUNT_NO_DRIVER = 'errNetMountNoDriver';
250
-	const ERROR_NETMOUNT_FAILED       = 'errNetMountFailed';
250
+	const ERROR_NETMOUNT_FAILED = 'errNetMountFailed';
251 251
 
252
-	const ERROR_SESSION_EXPIRES 	= 'errSessionExpires';
252
+	const ERROR_SESSION_EXPIRES = 'errSessionExpires';
253 253
 
254 254
 	const ERROR_CREATING_TEMP_DIR 	= 'errCreatingTempDir';
255 255
 	const ERROR_FTP_DOWNLOAD_FILE 	= 'errFtpDownloadFile';
256
-	const ERROR_FTP_UPLOAD_FILE 	= 'errFtpUploadFile';
257
-	const ERROR_FTP_MKDIR 		= 'errFtpMkdir';
256
+	const ERROR_FTP_UPLOAD_FILE = 'errFtpUploadFile';
257
+	const ERROR_FTP_MKDIR = 'errFtpMkdir';
258 258
 	const ERROR_ARCHIVE_EXEC 	= 'errArchiveExec';
259 259
 	const ERROR_EXTRACT_EXEC 	= 'errExtractExec';
260 260
 
@@ -281,17 +281,17 @@  discard block
 block discarded – undo
281 281
 		
282 282
 		$this->time  = $this->utime();
283 283
 		$this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false);
284
-		$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier'])? (bool)$opts['sessionCloseEarlier'] : true;
284
+		$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier']) ? (bool) $opts['sessionCloseEarlier'] : true;
285 285
 		$this->sessionUseCmds = array_flip($sessionUseCmds);
286 286
 		$this->timeout = (isset($opts['timeout']) ? $opts['timeout'] : 0);
287 287
 		$this->uploadTempPath = (isset($opts['uploadTempPath']) ? $opts['uploadTempPath'] : '');
288
-		$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey'])? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
288
+		$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey']) ? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
289 289
 		$this->callbackWindowURL = (isset($opts['callbackWindowURL']) ? $opts['callbackWindowURL'] : '');
290 290
 		self::$sessionCacheKey = !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches';
291 291
 		
292 292
 		// check session cache
293 293
 		$_optsMD5 = md5(json_encode($opts['roots']));
294
-		if (! isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) {
294
+		if (!isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) {
295 295
 			$_SESSION[self::$sessionCacheKey] = array(
296 296
 				'_optsMD5' => $_optsMD5
297 297
 			);
@@ -310,20 +310,20 @@  discard block
 block discarded – undo
310 310
 			$_reqCmd = isset($_req['cmd']) ? $_req['cmd'] : '';
311 311
 			foreach ($opts['bind'] as $cmd => $handlers) {
312 312
 				$doRegist = (strpos($cmd, '*') !== false);
313
-				if (! $doRegist) {
313
+				if (!$doRegist) {
314 314
 					$_getcmd = create_function('$cmd', 'list($ret) = explode(\'.\', $cmd);return trim($ret);');
315 315
 					$doRegist = ($_reqCmd && in_array($_reqCmd, array_map($_getcmd, explode(' ', $cmd))));
316 316
 				}
317 317
 				if ($doRegist) {
318
-					if (! is_array($handlers) || is_object($handlers[0])) {
318
+					if (!is_array($handlers) || is_object($handlers[0])) {
319 319
 						$handlers = array($handlers);
320 320
 					}
321
-					foreach($handlers as $handler) {
321
+					foreach ($handlers as $handler) {
322 322
 						if ($handler) {
323 323
 							if (is_string($handler) && strpos($handler, '.')) {
324 324
 								list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, '');
325 325
 								if (strcasecmp($_domain, 'plugin') === 0) {
326
-									if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name])? $opts['plugin'][$_name] : array())
326
+									if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name]) ? $opts['plugin'][$_name] : array())
327 327
 											and method_exists($plugin, $_method)) {
328 328
 										$this->bind($cmd, array($plugin, $_method));
329 329
 									}
@@ -410,13 +410,13 @@  discard block
 block discarded – undo
410 410
 	public function bind($cmd, $handler) {
411 411
 		$allCmds = array_keys($this->commands);
412 412
 		$cmds = array();
413
-		foreach(explode(' ', $cmd) as $_cmd) {
413
+		foreach (explode(' ', $cmd) as $_cmd) {
414 414
 			if ($_cmd !== '') {
415 415
 				if ($all = strpos($_cmd, '*') !== false) {
416 416
 					list(, $sub) = array_pad(explode('.', $_cmd), 2, '');
417 417
 					if ($sub) {
418 418
 						$sub = str_replace('\'', '\\\'', $sub);
419
-						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\'' . $sub . '\');');
419
+						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\''.$sub.'\');');
420 420
 						$cmds = array_merge($cmds, array_map($addSub, $allCmds));
421 421
 					} else {
422 422
 						$cmds = array_merge($cmds, $allCmds);
@@ -496,16 +496,16 @@  discard block
 block discarded – undo
496 496
 
497 497
 	private function session_expires() {
498 498
 		
499
-		if (!isset($_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'])) {
500
-			$_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time();
499
+		if (!isset($_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'])) {
500
+			$_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time();
501 501
 			return false;
502 502
 		}
503 503
 
504
-		if ( ($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] > $this->timeout) ) {
504
+		if (($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] > $this->timeout)) {
505 505
 			return true;
506 506
 		}
507 507
 
508
-		$_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time();
508
+		$_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time();
509 509
 		return false;	
510 510
 	}
511 511
 	
@@ -538,9 +538,9 @@  discard block
 block discarded – undo
538 538
 		}
539 539
 
540 540
 		// call pre handlers for this command
541
-		$args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd])? false : $this->sessionCloseEarlier;
541
+		$args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd]) ? false : $this->sessionCloseEarlier;
542 542
 		if (!empty($this->listeners[$cmd.'.pre'])) {
543
-			$volume = isset($args['target'])? $this->volume($args['target']) : false;
543
+			$volume = isset($args['target']) ? $this->volume($args['target']) : false;
544 544
 			foreach ($this->listeners[$cmd.'.pre'] as $handler) {
545 545
 				call_user_func_array($handler, array($cmd, &$args, $this, $volume));
546 546
 			}
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 		// call handlers for this command
563 563
 		if (!empty($this->listeners[$cmd])) {
564 564
 			foreach ($this->listeners[$cmd] as $handler) {
565
-				if (call_user_func_array($handler,array($cmd,&$result,$args,$this))) {
565
+				if (call_user_func_array($handler, array($cmd, &$result, $args, $this))) {
566 566
 					// handler return true to force sync client after command completed
567 567
 					$result['sync'] = true;
568 568
 				}
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 	 * @return string
622 622
 	 * @author Dmitry (dio) Levashov
623 623
 	 **/
624
-	public function realpath($hash)	{
624
+	public function realpath($hash) {
625 625
 		if (($volume = $this->volume($hash)) == false) {
626 626
 			return false;
627 627
 		}
@@ -677,11 +677,11 @@  discard block
 block discarded – undo
677 677
 	 */
678 678
 	protected function getPluginInstance($name, $opts = array()) {
679 679
 		$key = strtolower($name);
680
-		if (! isset($this->plugins[$key])) {
681
-			$p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php';
680
+		if (!isset($this->plugins[$key])) {
681
+			$p_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.'plugin.php';
682 682
 			if (is_file($p_file)) {
683 683
 				require_once $p_file;
684
-				$class = 'elFinderPlugin' . $name;
684
+				$class = 'elFinderPlugin'.$name;
685 685
 				$this->plugins[$key] = new $class($opts);
686 686
 			} else {
687 687
 				$this->plugins[$key] = false;
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
 		
774 774
 		$netVolumes = $this->getNetVolumes();
775 775
 		if ($volume->mount($options)) {
776
-			if (! $key = @ $volume->netMountKey) {
777
-				$key = md5($protocol . '-' . join('-', $options));
776
+			if (!$key = @ $volume->netMountKey) {
777
+				$key = md5($protocol.'-'.join('-', $options));
778 778
 			}
779 779
 			$options['driver'] = $driver;
780 780
 			$options['netkey'] = $key;
@@ -979,10 +979,10 @@  discard block
 block discarded – undo
979 979
 			$dispInlineRegex = $volume->getOption('dispInlineRegex');
980 980
 			$inlineRegex = false;
981 981
 			if ($dispInlineRegex) {
982
-				$inlineRegex = '#' . str_replace('#', '\\#', $dispInlineRegex) . '#';
982
+				$inlineRegex = '#'.str_replace('#', '\\#', $dispInlineRegex).'#';
983 983
 				try {
984 984
 					preg_match($inlineRegex, '');
985
-				} catch(Exception $e) {
985
+				} catch (Exception $e) {
986 986
 					$inlineRegex = false;
987 987
 				}
988 988
 			}
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
 				$inlineRegex = '#^(?:(?:image|text)|application/x-shockwave-flash$)#';
991 991
 			}
992 992
 			$mime = $file['mime'];
993
-			$disp  = preg_match($inlineRegex, $mime)? 'inline' : 'attachment';
993
+			$disp = preg_match($inlineRegex, $mime) ? 'inline' : 'attachment';
994 994
 		}
995 995
 		
996 996
 		$filenameEncoded = rawurlencode($file['name']);
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 		$name   = $args['name'];
1100 1100
 		
1101 1101
 		if (($volume = $this->volume($target)) == false
1102
-		||  ($rm  = $volume->file($target)) == false) {
1102
+		||  ($rm = $volume->file($target)) == false) {
1103 1103
 			return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND));
1104 1104
 		}
1105 1105
 		$rm['realpath'] = $volume->realpath($target);
@@ -1177,9 +1177,9 @@  discard block
 block discarded – undo
1177 1177
 	* @retval false  error
1178 1178
 	* @author Naoki Sawada
1179 1179
 	**/
1180
-	protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) {
1181
-		$method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; 
1182
-		return $this->$method( $url, $timeout, $redirect_max, $ua, $fp );
1180
+	protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) {
1181
+		$method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; 
1182
+		return $this->$method($url, $timeout, $redirect_max, $ua, $fp);
1183 1183
 	}
1184 1184
 	
1185 1185
 	/**
@@ -1195,26 +1195,26 @@  discard block
 block discarded – undo
1195 1195
 	 * @retval false  error
1196 1196
 	 * @author Naoki Sawada
1197 1197
 	 **/
1198
-	 protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){
1198
+	 protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1199 1199
 		$ch = curl_init();
1200
-		curl_setopt( $ch, CURLOPT_URL, $url );
1201
-		curl_setopt( $ch, CURLOPT_HEADER, false );
1200
+		curl_setopt($ch, CURLOPT_URL, $url);
1201
+		curl_setopt($ch, CURLOPT_HEADER, false);
1202 1202
 		if ($outfp) {
1203
-			curl_setopt( $ch, CURLOPT_FILE, $outfp );
1203
+			curl_setopt($ch, CURLOPT_FILE, $outfp);
1204 1204
 		} else {
1205
-			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1206
-			curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true );
1207
-		}
1208
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 );
1209
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout );
1210
-		curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
1211
-		curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
1212
-		curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max);
1213
-		curl_setopt( $ch, CURLOPT_USERAGENT, $ua);
1214
-		$result = curl_exec( $ch );
1205
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1206
+			curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
1207
+		}
1208
+		curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);
1209
+		curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout);
1210
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1211
+		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
1212
+		curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max);
1213
+		curl_setopt($ch, CURLOPT_USERAGENT, $ua);
1214
+		$result = curl_exec($ch);
1215 1215
 		$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
1216
-		curl_close( $ch );
1217
-		return $outfp? $outfp : $result;
1216
+		curl_close($ch);
1217
+		return $outfp ? $outfp : $result;
1218 1218
 	}
1219 1219
 	
1220 1220
 	/**
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 	 * @retval false  error
1231 1231
 	 * @author Naoki Sawada
1232 1232
 	 */
1233
-	protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) {
1233
+	protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1234 1234
 
1235 1235
 		$connect_timeout = 3;
1236 1236
 		$connect_try = 3;
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 		$headers = '';
1242 1242
 		
1243 1243
 		$arr = parse_url($url);
1244
-		if (!$arr){
1244
+		if (!$arr) {
1245 1245
 			// Bad request
1246 1246
 			return false;
1247 1247
 		}
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 		// query
1250 1250
 		$arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : '';
1251 1251
 		// port
1252
-		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80);
1252
+		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80);
1253 1253
 		
1254 1254
 		$url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port'];
1255 1255
 		$url_path = isset($arr['path']) ? $arr['path'] : '/';
@@ -1258,21 +1258,21 @@  discard block
 block discarded – undo
1258 1258
 		$query = $method.' '.$uri." HTTP/1.0\r\n";
1259 1259
 		$query .= "Host: ".$arr['host']."\r\n";
1260 1260
 		if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n";
1261
-		if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n";
1261
+		if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n";
1262 1262
 		
1263 1263
 		$query .= $headers;
1264 1264
 
1265 1265
 		$query .= "\r\n";
1266 1266
 
1267 1267
 		$fp = $connect_try_count = 0;
1268
-		while( !$fp && $connect_try_count < $connect_try ) {
1268
+		while (!$fp && $connect_try_count < $connect_try) {
1269 1269
 	
1270 1270
 			$errno = 0;
1271 1271
 			$errstr = "";
1272 1272
 			$fp = @ fsockopen(
1273 1273
 			$arr['https'].$arr['host'],
1274 1274
 			$arr['port'],
1275
-			$errno,$errstr,$connect_timeout);
1275
+			$errno, $errstr, $connect_timeout);
1276 1276
 			if ($fp) break;
1277 1277
 			$connect_try_count++;
1278 1278
 			if (connection_aborted()) {
@@ -1297,13 +1297,13 @@  discard block
 block discarded – undo
1297 1297
 		
1298 1298
 		$_response = '';
1299 1299
 		$header = '';
1300
-		while($_response !== "\r\n"){
1300
+		while ($_response !== "\r\n") {
1301 1301
 			$_response = fgets($fp, $readsize);
1302 1302
 			$header .= $_response;
1303 1303
 		};
1304 1304
 		
1305
-		$rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1306
-		$rc = (int)$rccd[1];
1305
+		$rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1306
+		$rc = (int) $rccd[1];
1307 1307
 		
1308 1308
 		// Redirect
1309 1309
 		switch ($rc) {
@@ -1312,19 +1312,19 @@  discard block
 block discarded – undo
1312 1312
 			case 302: // Moved Temporarily
1313 1313
 			case 301: // Moved Permanently
1314 1314
 				$matches = array();
1315
-				if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) {
1315
+				if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) {
1316 1316
 					$url = trim($matches[1]);
1317
-					$hash = isset($matches[2])? trim($matches[2]) : '';
1318
-					if (!preg_match('/^https?:\//',$url)) { // no scheme
1317
+					$hash = isset($matches[2]) ? trim($matches[2]) : '';
1318
+					if (!preg_match('/^https?:\//', $url)) { // no scheme
1319 1319
 						if ($url{0} != '/') { // Relative path
1320 1320
 							// to Absolute path
1321
-							$url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url;
1321
+							$url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url;
1322 1322
 						}
1323 1323
 						// add sheme,host
1324 1324
 						$url = $url_base.$url;
1325 1325
 					}
1326 1326
 					fclose($fp);
1327
-					return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp );
1327
+					return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp);
1328 1328
 				}
1329 1329
 		}
1330 1330
 		
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 			$outfp = fopen('php://temp', 'rwb');
1334 1334
 			$body = true;
1335 1335
 		}
1336
-		while(fwrite($outfp, fread($fp, $readsize))) {
1336
+		while (fwrite($outfp, fread($fp, $readsize))) {
1337 1337
 			if ($timeout) {
1338 1338
 				$_status = socket_get_status($fp);
1339 1339
 				if ($_status['timed_out']) {
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
 		
1353 1353
 		fclose($fp);
1354 1354
 		
1355
-		return $outfp? $outfp : $body; // Data
1355
+		return $outfp ? $outfp : $body; // Data
1356 1356
 	}
1357 1357
 	
1358 1358
 	/**
@@ -1363,13 +1363,13 @@  discard block
 block discarded – undo
1363 1363
 	 * @return array
1364 1364
 	 * @author Naoki Sawada
1365 1365
 	 */
1366
-	protected function parse_data_scheme( $str, $extTable ) {
1366
+	protected function parse_data_scheme($str, $extTable) {
1367 1367
 		$data = $name = '';
1368 1368
 		if ($fp = fopen('data://'.substr($str, 5), 'rb')) {
1369 1369
 			if ($data = stream_get_contents($fp)) {
1370 1370
 				$meta = stream_get_meta_data($fp);
1371
-				$ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : '';
1372
-				$name = substr(md5($data), 0, 8) . $ext;
1371
+				$ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : '';
1372
+				$name = substr(md5($data), 0, 8).$ext;
1373 1373
 			}
1374 1374
 			fclose($fp);
1375 1375
 		}
@@ -1433,7 +1433,7 @@  discard block
 block discarded – undo
1433 1433
 			}
1434 1434
 		}
1435 1435
 		
1436
-		return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : '';
1436
+		return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : '';
1437 1437
 	}
1438 1438
 	
1439 1439
 	/**
@@ -1449,26 +1449,26 @@  discard block
 block discarded – undo
1449 1449
 	private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) {
1450 1450
 		if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) {
1451 1451
 			$fname = $m[1];
1452
-			$encname = md5($cid . '_' . $fname);
1453
-			$base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname;
1452
+			$encname = md5($cid.'_'.$fname);
1453
+			$base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname;
1454 1454
 			$clast = intval($m[3]);
1455 1455
 			if (is_null($tmpname)) {
1456 1456
 				ignore_user_abort(true);
1457 1457
 				sleep(10); // wait 10 sec
1458 1458
 				// chunked file upload fail
1459
-				foreach(glob($base . '*') as $cf) {
1459
+				foreach (glob($base.'*') as $cf) {
1460 1460
 					@unlink($cf);
1461 1461
 				}
1462 1462
 				ignore_user_abort(false);
1463 1463
 				return;
1464 1464
 			}
1465 1465
 			
1466
-			$range = isset($_POST['range'])? trim($_POST['range']) : '';
1466
+			$range = isset($_POST['range']) ? trim($_POST['range']) : '';
1467 1467
 			if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) {
1468 1468
 				$start = $ranges[1];
1469 1469
 				$len   = $ranges[2];
1470 1470
 				$size  = $ranges[3];
1471
-				$tmp = $base . '.part';
1471
+				$tmp = $base.'.part';
1472 1472
 				$csize = filesize($tmpname);
1473 1473
 				
1474 1474
 				$tmpExists = is_file($tmp);
@@ -1493,7 +1493,7 @@  discard block
 block discarded – undo
1493 1493
 				} else {
1494 1494
 					// wait until makeing temp file (for anothor session)
1495 1495
 					$cnt = 100; // Time limit 10 sec
1496
-					while(!is_file($base) && --$cnt) {
1496
+					while (!is_file($base) && --$cnt) {
1497 1497
 						usleep(100000); // wait 100ms
1498 1498
 					}
1499 1499
 					if (!$cnt) {
@@ -1528,13 +1528,13 @@  discard block
 block discarded – undo
1528 1528
 				}
1529 1529
 			} else {
1530 1530
 				// old way
1531
-				$part = $base . $m[2];
1531
+				$part = $base.$m[2];
1532 1532
 				if (move_uploaded_file($tmpname, $part)) {
1533 1533
 					@chmod($part, 0600);
1534
-					if ($clast < count(glob($base . '*'))) {
1534
+					if ($clast < count(glob($base.'*'))) {
1535 1535
 						$parts = array();
1536 1536
 						for ($i = 0; $i <= $clast; $i++) {
1537
-							$name = $base . '.' . $i . '_' . $clast;
1537
+							$name = $base.'.'.$i.'_'.$clast;
1538 1538
 							if (is_readable($name)) {
1539 1539
 								$parts[] = $name;
1540 1540
 							} else {
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
 								touch($base);
1548 1548
 								if ($resfile = tempnam($tempDir, 'ELF')) {
1549 1549
 									$target = fopen($resfile, 'wb');
1550
-									foreach($parts as $f) {
1550
+									foreach ($parts as $f) {
1551 1551
 										$fp = fopen($f, 'rb');
1552 1552
 										while (!feof($fp)) {
1553 1553
 											fwrite($target, fread($fp, 8192));
@@ -1588,15 +1588,15 @@  discard block
 block discarded – undo
1588 1588
 			$testDirs[] = rtrim(realpath($volumeTempPath), DIRECTORY_SEPARATOR);
1589 1589
 		}
1590 1590
 		$tempDir = '';
1591
-		$test = DIRECTORY_SEPARATOR . microtime(true);
1592
-		foreach($testDirs as $testDir) {
1591
+		$test = DIRECTORY_SEPARATOR.microtime(true);
1592
+		foreach ($testDirs as $testDir) {
1593 1593
 			if (!$testDir || !is_dir($testDir)) continue;
1594 1594
 			$testFile = $testDir.$test;
1595 1595
 			if (touch($testFile)) {
1596 1596
 				unlink($testFile);
1597 1597
 				$tempDir = $testDir;
1598 1598
 				$gc = time() - 3600;
1599
-				foreach(glob($tempDir . '/ELF*') as $cf) {
1599
+				foreach (glob($tempDir.'/ELF*') as $cf) {
1600 1600
 					if (filemtime($cf) < $gc) {
1601 1601
 						@unlink($cf);
1602 1602
 					}
@@ -1616,7 +1616,7 @@  discard block
 block discarded – undo
1616 1616
 	 **/
1617 1617
 	protected function chmod($args) {
1618 1618
 		$targets = $args['targets'];
1619
-		$mode    = intval((string)$args['mode'], 8);
1619
+		$mode    = intval((string) $args['mode'], 8);
1620 1620
 
1621 1621
 		if (!is_array($targets)) {
1622 1622
 			$targets = array($targets);
@@ -1631,10 +1631,10 @@  discard block
 block discarded – undo
1631 1631
 
1632 1632
 		$files = array();
1633 1633
 		$errors = array();
1634
-		foreach($targets as $target) {
1634
+		foreach ($targets as $target) {
1635 1635
 			$file = $volume->chmod($target, $mode);
1636 1636
 			if ($file) {
1637
-				$files = array_merge($files, is_array($file)? $file : array($file));
1637
+				$files = array_merge($files, is_array($file) ? $file : array($file));
1638 1638
 			} else {
1639 1639
 				$errors = array_merge($errors, $volume->error());
1640 1640
 			}
@@ -1666,15 +1666,15 @@  discard block
 block discarded – undo
1666 1666
 		$files  = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array();
1667 1667
 		$header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8');
1668 1668
 		$result = array_merge(array('added' => array()), $header);
1669
-		$paths  = $args['upload_path']? $args['upload_path'] : array();
1670
-		$chunk  = $args['chunk']? $args['chunk'] : '';
1671
-		$cid    = $args['cid']? (int)$args['cid'] : '';
1669
+		$paths  = $args['upload_path'] ? $args['upload_path'] : array();
1670
+		$chunk  = $args['chunk'] ? $args['chunk'] : '';
1671
+		$cid    = $args['cid'] ? (int) $args['cid'] : '';
1672 1672
 		
1673
-		$renames= array();
1673
+		$renames = array();
1674 1674
 		$suffix = '~';
1675 1675
 		if ($args['renames'] && is_array($args['renames'])) {
1676 1676
 			$renames = array_flip($args['renames']);
1677
-			if (is_string($args['suffix']) && ! preg_match($ngReg, $args['suffix'])) {
1677
+			if (is_string($args['suffix']) && !preg_match($ngReg, $args['suffix'])) {
1678 1678
 				$suffix = $args['suffix'];
1679 1679
 			}
1680 1680
 		}
@@ -1706,7 +1706,7 @@  discard block
 block discarded – undo
1706 1706
 		if (empty($files)) {
1707 1707
 			if (!$args['upload'] && $args['name'] && is_array($args['name'])) {
1708 1708
 				$result['name'] = array();
1709
-				foreach($args['name'] as $_i => $_name) {
1709
+				foreach ($args['name'] as $_i => $_name) {
1710 1710
 					$result['name'][$_i] = preg_replace($ngReg, '_', $_name);
1711 1711
 				}
1712 1712
 				$result = array_merge_recursive($result, $this->ls($args));
@@ -1719,7 +1719,7 @@  discard block
 block discarded – undo
1719 1719
 			}
1720 1720
 			if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) {
1721 1721
 				$names = array();
1722
-				foreach($args['upload'] as $i => $url) {
1722
+				foreach ($args['upload'] as $i => $url) {
1723 1723
 					// check chunked file upload commit
1724 1724
 					if ($args['chunk']) {
1725 1725
 						if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') {
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
 							}
1730 1730
 							return $result;
1731 1731
 						} else {
1732
-							$tmpfname = $tempDir . '/' . $args['chunk'];
1732
+							$tmpfname = $tempDir.'/'.$args['chunk'];
1733 1733
 							$files['tmp_name'][$i] = $tmpfname;
1734 1734
 							$files['name'][$i] = $url;
1735 1735
 							$files['error'][$i] = 0;
@@ -1738,7 +1738,7 @@  discard block
 block discarded – undo
1738 1738
 						}
1739 1739
 					}
1740 1740
 					
1741
-					$tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true));
1741
+					$tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true));
1742 1742
 					
1743 1743
 					$_name = '';
1744 1744
 					// check is data:
@@ -1774,8 +1774,8 @@  discard block
 block discarded – undo
1774 1774
 								list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, '');
1775 1775
 								if ($_b === '') {
1776 1776
 									if ($_ext) {
1777
-										rename($tmpfname, $tmpfname . $_ext);
1778
-										$tmpfname = $tmpfname . $_ext;
1777
+										rename($tmpfname, $tmpfname.$_ext);
1778
+										$tmpfname = $tmpfname.$_ext;
1779 1779
 									}
1780 1780
 									$_b = $this->detectFileExtension($tmpfname);
1781 1781
 									$_name = $_a.$_b;
@@ -1810,7 +1810,7 @@  discard block
 block discarded – undo
1810 1810
 			}
1811 1811
 			
1812 1812
 			$tmpname = $files['tmp_name'][$i];
1813
-			$path = ($paths && !empty($paths[$i]))? $paths[$i] : '';
1813
+			$path = ($paths && !empty($paths[$i])) ? $paths[$i] : '';
1814 1814
 			if ($name === 'blob') {
1815 1815
 				if ($chunk) {
1816 1816
 					if ($tempDir = $this->getTempDir($volume->getTempPath())) {
@@ -1820,7 +1820,7 @@  discard block
 block discarded – undo
1820 1820
 								preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m);
1821 1821
 								$result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname);
1822 1822
 								$result['_chunkfailure'] = true;
1823
-								$this->uploadDebug = 'Upload error: ' . $tmpname;
1823
+								$this->uploadDebug = 'Upload error: '.$tmpname;
1824 1824
 							} else if ($name) {
1825 1825
 								$result['_chunkmerged'] = basename($tmpname);
1826 1826
 								$result['_name'] = $name;
@@ -1834,14 +1834,14 @@  discard block
 block discarded – undo
1834 1834
 				} else {
1835 1835
 					// for form clipboard with Google Chrome
1836 1836
 					$type = $files['type'][$i];
1837
-					$ext = isset($extTable[$type])? '.' . $extTable[$type] : '';
1838
-					$name = substr(md5(basename($tmpname)), 0, 8) . $ext;
1837
+					$ext = isset($extTable[$type]) ? '.'.$extTable[$type] : '';
1838
+					$name = substr(md5(basename($tmpname)), 0, 8).$ext;
1839 1839
 				}
1840 1840
 			}
1841 1841
 			
1842 1842
 			// do hook function 'upload.presave'
1843
-			if (! empty($this->listeners['upload.presave'])) {
1844
-				foreach($this->listeners['upload.presave'] as $handler) {
1843
+			if (!empty($this->listeners['upload.presave'])) {
1844
+				foreach ($this->listeners['upload.presave'] as $handler) {
1845 1845
 					call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume));
1846 1846
 				}
1847 1847
 			}
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
 			if (($fp = fopen($tmpname, 'rb')) == false) {
1850 1850
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER);
1851 1851
 				$this->uploadDebug = 'Upload error: unable open tmp file';
1852
-				if (! is_uploaded_file($tmpname)) {
1852
+				if (!is_uploaded_file($tmpname)) {
1853 1853
 					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]);
1854 1854
 					continue;
1855 1855
 				}
@@ -1871,18 +1871,18 @@  discard block
 block discarded – undo
1871 1871
 					}
1872 1872
 				}
1873 1873
 			}
1874
-			if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1874
+			if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1875 1875
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error());
1876 1876
 				fclose($fp);
1877
-				if (! is_uploaded_file($tmpname)) {
1878
-					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);;
1877
+				if (!is_uploaded_file($tmpname)) {
1878
+					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ;
1879 1879
 					continue;
1880 1880
 				}
1881 1881
 				break;
1882 1882
 			}
1883 1883
 			
1884 1884
 			is_resource($fp) && fclose($fp);
1885
-			if (! is_uploaded_file($tmpname)){
1885
+			if (!is_uploaded_file($tmpname)) {
1886 1886
 				clearstatcache();
1887 1887
 				if (!is_file($tmpname) || @ unlink($tmpname)) {
1888 1888
 					unset($GLOBALS['elFinderTempFiles'][$tmpname]);
@@ -1894,7 +1894,7 @@  discard block
 block discarded – undo
1894 1894
 			}
1895 1895
 		}
1896 1896
 		if ($GLOBALS['elFinderTempFiles']) {
1897
-			foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1897
+			foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1898 1898
 				@ unlink($_temp);
1899 1899
 			}
1900 1900
 		}
@@ -1931,7 +1931,7 @@  discard block
 block discarded – undo
1931 1931
 		$suffix = '~';
1932 1932
 		if (!empty($args['renames'])) {
1933 1933
 			$renames = array_flip($args['renames']);
1934
-			if (is_string($args['suffix']) && ! preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1934
+			if (is_string($args['suffix']) && !preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1935 1935
 				$suffix = $args['suffix'];
1936 1936
 			}
1937 1937
 		}
@@ -1989,9 +1989,9 @@  discard block
 block discarded – undo
1989 1989
 		}
1990 1990
 		
1991 1991
 		if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
1992
-			$mime = isset($file['mime'])? $file['mime'] : '';
1992
+			$mime = isset($file['mime']) ? $file['mime'] : '';
1993 1993
 			if ($mime && strtolower(substr($mime, 0, 4)) === 'text') {
1994
-				if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) {
1994
+				if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) {
1995 1995
 					if (strtolower($enc) !== 'utf-8') {
1996 1996
 						$content = mb_convert_encoding($content, 'UTF-8', $enc);
1997 1997
 					}
@@ -2003,7 +2003,7 @@  discard block
 block discarded – undo
2003 2003
 
2004 2004
 		if ($json === false || strlen($json) < strlen($content)) {
2005 2005
 			if ($args['conv']) {
2006
-				return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
2006
+				return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
2007 2007
 			} else {
2008 2008
 				return array('doconv' => true);
2009 2009
 			}
@@ -2045,7 +2045,7 @@  discard block
 block discarded – undo
2045 2045
 		$target = $args['target'];
2046 2046
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2047 2047
 		$error  = array(self::ERROR_EXTRACT, '#'.$target);
2048
-		$makedir = isset($args['makedir'])? (bool)$args['makedir'] : null;
2048
+		$makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null;
2049 2049
 
2050 2050
 		if (($volume = $this->volume($target)) == false
2051 2051
 		|| ($file = $volume->file($target)) == false) {
@@ -2053,7 +2053,7 @@  discard block
 block discarded – undo
2053 2053
 		}  
2054 2054
 
2055 2055
 		return ($file = $volume->extract($target, $makedir))
2056
-			? array('added' => isset($file['read'])? array($file) : $file)
2056
+			? array('added' => isset($file['read']) ? array($file) : $file)
2057 2057
 			: array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error()));
2058 2058
 	}
2059 2059
 	
@@ -2068,7 +2068,7 @@  discard block
 block discarded – undo
2068 2068
 	protected function archive($args) {
2069 2069
 		$type    = $args['type'];
2070 2070
 		$targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array();
2071
-		$name    = isset($args['name'])? $args['name'] : '';
2071
+		$name    = isset($args['name']) ? $args['name'] : '';
2072 2072
 	
2073 2073
 		if (($volume = $this->volume($targets[0])) == false) {
2074 2074
 			return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND);
@@ -2089,7 +2089,7 @@  discard block
 block discarded – undo
2089 2089
 	protected function search($args) {
2090 2090
 		$q      = trim($args['q']);
2091 2091
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2092
-		$target = !empty($args['target'])? $args['target'] : null;
2092
+		$target = !empty($args['target']) ? $args['target'] : null;
2093 2093
 		$result = array();
2094 2094
 
2095 2095
 		if (!is_null($target)) {
@@ -2153,11 +2153,11 @@  discard block
 block discarded – undo
2153 2153
 		$target = $args['target'];
2154 2154
 		$width  = $args['width'];
2155 2155
 		$height = $args['height'];
2156
-		$x      = (int)$args['x'];
2157
-		$y      = (int)$args['y'];
2156
+		$x      = (int) $args['x'];
2157
+		$y      = (int) $args['y'];
2158 2158
 		$mode   = $args['mode'];
2159 2159
 		$bg     = null;
2160
-		$degree = (int)$args['degree'];
2160
+		$degree = (int) $args['degree'];
2161 2161
 		
2162 2162
 		if (($volume = $this->volume($target)) == false
2163 2163
 		|| ($file = $volume->file($target)) == false) {
@@ -2178,7 +2178,7 @@  discard block
 block discarded – undo
2178 2178
 	**/
2179 2179
 	protected function url($args) {
2180 2180
 		$target = $args['target'];
2181
-		$options = isset($args['options'])? $args['options'] : array();
2181
+		$options = isset($args['options']) ? $args['options'] : array();
2182 2182
 		if (($volume = $this->volume($target)) != false) {
2183 2183
 			$url = $volume->getContentUrl($target, $options);
2184 2184
 			return $url ? array('url' => $url) : array();
@@ -2195,18 +2195,18 @@  discard block
 block discarded – undo
2195 2195
 	 */
2196 2196
 	protected function callback($args) {
2197 2197
 		$checkReg = '/[^a-zA-Z0-9;._-]/';
2198
-		$node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : '';
2199
-		$json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}';
2200
-		$bind  = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : '';
2198
+		$node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : '';
2199
+		$json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}';
2200
+		$bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : '';
2201 2201
 		$done = (!empty($args['done']));
2202 2202
 		
2203
-		while( ob_get_level() ) {
2204
-			if (! ob_end_clean()) {
2203
+		while (ob_get_level()) {
2204
+			if (!ob_end_clean()) {
2205 2205
 				break;
2206 2206
 			}
2207 2207
 		}
2208 2208
 		
2209
-		if ($done || ! $this->callbackWindowURL) {
2209
+		if ($done || !$this->callbackWindowURL) {
2210 2210
 			$script = '';
2211 2211
 			if ($node) {
2212 2212
 				$script .= '
@@ -2248,13 +2248,13 @@  discard block
 block discarded – undo
2248 2248
 			
2249 2249
 		} else {
2250 2250
 			$url = $this->callbackWindowURL;
2251
-			$url .= ((strpos($url, '?') === false)? '?' : '&')
2252
-				 . '&node=' . rawurlencode($node)
2253
-				 . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '')
2254
-				 . ($bind? ('&bind=' .  rawurlencode($bind)) : '')
2251
+			$url .= ((strpos($url, '?') === false) ? '?' : '&')
2252
+				 . '&node='.rawurlencode($node)
2253
+				 . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '')
2254
+				 . ($bind ? ('&bind='.rawurlencode($bind)) : '')
2255 2255
 				 . '&done=1';
2256 2256
 			
2257
-			header('Location: ' . $url);
2257
+			header('Location: '.$url);
2258 2258
 			
2259 2259
 		}
2260 2260
 		exit();
@@ -2324,7 +2324,7 @@  discard block
 block discarded – undo
2324 2324
 	
2325 2325
 	protected function utime() {
2326 2326
 		$time = explode(" ", microtime());
2327
-		return (double)$time[1] + (double)$time[0];
2327
+		return (double) $time[1] + (double) $time[0];
2328 2328
 	}
2329 2329
 	
2330 2330
 	
@@ -2350,7 +2350,7 @@  discard block
 block discarded – undo
2350 2350
 		$imgcnt = 0;
2351 2351
 		$fp = fopen($path, 'rb');
2352 2352
 		@fread($fp, 4);
2353
-		$c = @fread($fp,1);
2353
+		$c = @fread($fp, 1);
2354 2354
 		if (ord($c) != 0x39) {  // GIF89a
2355 2355
 			return false;
2356 2356
 		}
@@ -2358,13 +2358,13 @@  discard block
 block discarded – undo
2358 2358
 		while (!feof($fp)) {
2359 2359
 			do {
2360 2360
 				$c = fread($fp, 1);
2361
-			} while(ord($c) != 0x21 && !feof($fp));
2361
+			} while (ord($c) != 0x21 && !feof($fp));
2362 2362
 	
2363 2363
 			if (feof($fp)) {
2364 2364
 				break;
2365 2365
 			}
2366 2366
 	
2367
-			$c2 = fread($fp,2);
2367
+			$c2 = fread($fp, 2);
2368 2368
 			if (bin2hex($c2) == "f904") {
2369 2369
 				$imgcnt++;
2370 2370
 			}
Please login to merge, or discard this patch.
php/elFinderVolumeDriver.class.php 1 patch
Spacing   +130 added lines, -131 removed lines patch added patch discarded remove patch
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		'utf8fix'      => false,
279 279
 		 //                           й                 ё              Й               Ё              Ø         Å
280 280
 		'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"),
281
-		'utf8replace'  => array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5")
281
+		'utf8replace'  => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5")
282 282
 	);
283 283
 
284 284
 	/**
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	 **/
571 571
 	protected function configure() {
572 572
 		// set ARGS
573
-		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET;
573
+		$this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
574 574
 		// set thumbnails path
575 575
 		$path = $this->options['tmbPath'];
576 576
 		if ($path) {
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		
602 602
 		// check 'statOwner' for command `chmod`
603 603
 		if (empty($this->options['statOwner'])) {
604
-			$this->disabled[] ='chmod';
604
+			$this->disabled[] = 'chmod';
605 605
 		}
606 606
 		
607 607
 		// check 'mimeMap'
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 	 **/
707 707
 	public function mount(array $opts) {
708 708
 		if (!isset($opts['path']) || $opts['path'] === '') {
709
-			return $this->setError('Path undefined.');;
709
+			return $this->setError('Path undefined.'); ;
710 710
 		}
711 711
 		
712 712
 		$this->options = array_merge($this->options, $opts);
@@ -725,14 +725,14 @@  discard block
 block discarded – undo
725 725
 		$argInit = !empty($this->ARGS['init']);
726 726
 		
727 727
 		// session cache
728
-		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
728
+		if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
729 729
 			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
730 730
 		}
731 731
 		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
732 732
 		
733 733
 		// default file attribute
734 734
 		$this->defaults = array(
735
-			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
735
+			'read'    => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true,
736 736
 			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
737 737
 			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
738 738
 			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
@@ -759,8 +759,8 @@  discard block
 block discarded – undo
759 759
 			$this->access = $this->options['accessControl'];
760 760
 		}
761 761
 		
762
-		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
763
-		$this->yesterday = $this->today-86400;
762
+		$this->today     = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
763
+		$this->yesterday = $this->today - 86400;
764 764
 		
765 765
 		// debug($this->attributes);
766 766
 		if (!$this->init()) {
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
 				foreach ($mimecf as $line_num => $line) {
860 860
 					if (!preg_match('/^\s*#/', $line)) {
861 861
 						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
862
-						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
862
+						for ($i = 1, $size = count($mime); $i < $size; $i++) {
863 863
 							if (!isset(self::$mimetypes[$mime[$i]])) {
864 864
 								self::$mimetypes[$mime[$i]] = $mime[0];
865 865
 							}
@@ -911,8 +911,8 @@  discard block
 block discarded – undo
911 911
 				'read'    => false
912 912
 			));
913 913
 		}
914
-		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
915
-		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
914
+		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1;
915
+		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48;
916 916
 		$this->URL      = $this->options['URL'];
917 917
 		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
918 918
 			$this->URL .= '/';
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 	public function options($hash) {
1054 1054
 		$create = $createext = array();
1055 1055
 		if (isset($this->archivers['create']) && is_array($this->archivers['create'])) {
1056
-			foreach($this->archivers['create'] as $m => $v) {
1056
+			foreach ($this->archivers['create'] as $m => $v) {
1057 1057
 				$create[] = $m;
1058 1058
 				$createext[$m] = $v['ext'];
1059 1059
 			}
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
 				'extract'   => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(),
1074 1074
 				'createext' => $createext
1075 1075
 			),
1076
-			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array()
1076
+			'uiCmdMap'        => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array()
1077 1077
 		);
1078 1078
 	}
1079 1079
 	
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 	 * @author Naoki Sawada
1086 1086
 	 */
1087 1087
 	public function getOption($name) {
1088
-		return isset($this->options[$name])? $this->options[$name] : null;
1088
+		return isset($this->options[$name]) ? $this->options[$name] : null;
1089 1089
 	}
1090 1090
 	
1091 1091
 	/**
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 	 */
1098 1098
 	public function getOptionsPlugin($name = '') {
1099 1099
 		if ($name) {
1100
-			return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array();
1100
+			return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array();
1101 1101
 		} else {
1102 1102
 			return $this->options['plugin'];
1103 1103
 		}
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 		$file = $this->stat($path);
1228 1228
 		
1229 1229
 		if ($hash === $this->root()) {
1230
-			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array();
1230
+			$file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array();
1231 1231
 			$file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON
1232 1232
 		}
1233 1233
 		
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 	 * @return array|false
1243 1243
 	 * @author Dmitry (dio) Levashov
1244 1244
 	 **/
1245
-	public function dir($hash, $resolveLink=false) {
1245
+	public function dir($hash, $resolveLink = false) {
1246 1246
 		if (($dir = $this->file($hash)) == false) {
1247 1247
 			return $this->setError(elFinder::ERROR_DIR_NOT_FOUND);
1248 1248
 		}
@@ -1306,14 +1306,14 @@  discard block
 block discarded – undo
1306 1306
 	 * @return array|false
1307 1307
 	 * @author Dmitry (dio) Levashov
1308 1308
 	 **/
1309
-	public function tree($hash='', $deep=0, $exclude='') {
1309
+	public function tree($hash = '', $deep = 0, $exclude = '') {
1310 1310
 		$path = $hash ? $this->decode($hash) : $this->root;
1311 1311
 		
1312 1312
 		if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') {
1313 1313
 			return false;
1314 1314
 		}
1315 1315
 		
1316
-		$dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null);
1316
+		$dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null);
1317 1317
 		array_unshift($dirs, $dir);
1318 1318
 		return $dirs;
1319 1319
 	}
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
 	 * @return array|false
1544 1544
 	 * @author Dmitry (dio) Levashov
1545 1545
 	 **/
1546
-	public function duplicate($hash, $suffix='copy') {
1546
+	public function duplicate($hash, $suffix = 'copy') {
1547 1547
 		if ($this->commandDisabled('duplicate')) {
1548 1548
 			return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED);
1549 1549
 		}
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
 		
1620 1620
 		if ($file) { // file exists
1621 1621
 			// check POST data `overwrite` for 3rd party uploader
1622
-			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1622
+			$overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite'];
1623 1623
 			if ($overwrite) {
1624 1624
 				if (!$file['write']) {
1625 1625
 					return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
 		if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) {
1691 1691
 			return $rmSrc
1692 1692
 				? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test))
1693
-				: $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1693
+				: $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
1694 1694
 		}
1695 1695
 
1696 1696
 		$test = $this->joinPathCE($destination, $name);
@@ -1853,7 +1853,7 @@  discard block
 block discarded – undo
1853 1853
 			return $this->setError(elFinder::ERROR_PERM_DENIED);
1854 1854
 		}
1855 1855
 		$this->clearcache();
1856
-		$this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir;
1856
+		$this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir;
1857 1857
 		
1858 1858
 		if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) {
1859 1859
 			if (is_array($path)) {
@@ -1911,9 +1911,9 @@  discard block
 block discarded – undo
1911 1911
 		if ($name === '') {
1912 1912
 			$name = count($files) == 1 ? $files[0] : 'Archive';
1913 1913
 		} else {
1914
-			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name));
1914
+			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name));
1915 1915
 		}
1916
-		$name .='.' . $archiver['ext'];
1916
+		$name .= '.'.$archiver['ext'];
1917 1917
 		$name = $this->uniqueName($dir, $name, '');
1918 1918
 		$this->clearcache();
1919 1919
 		return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false;
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
 		
1950 1950
 		$path = $this->decode($hash);
1951 1951
 		
1952
-		$work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path);
1952
+		$work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path);
1953 1953
 
1954 1954
 		if (!$work_path || !is_writable($work_path)) {
1955 1955
 			if ($work_path && $path !== $work_path && is_file($work_path)) {
@@ -1964,7 +1964,7 @@  discard block
 block discarded – undo
1964 1964
 			}
1965 1965
 		}
1966 1966
 
1967
-		switch($mode) {
1967
+		switch ($mode) {
1968 1968
 			
1969 1969
 			case 'propresize':
1970 1970
 				$result = $this->imgResize($work_path, $width, $height, true, true);
@@ -2060,7 +2060,7 @@  discard block
 block discarded – undo
2060 2060
 		}
2061 2061
 		return ($q === '' || $this->commandDisabled('search'))
2062 2062
 			? array()
2063
-			: $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes);
2063
+			: $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes);
2064 2064
 	}
2065 2065
 	
2066 2066
 	/**
@@ -2129,9 +2129,9 @@  discard block
 block discarded – undo
2129 2129
 		$path = ltrim($path, $this->separator);
2130 2130
 		$dirs = explode($this->separator, $path);
2131 2131
 		array_pop($dirs);
2132
-		foreach($dirs as $dir) {
2132
+		foreach ($dirs as $dir) {
2133 2133
 			$targetPath = $this->joinPathCE($base, $dir);
2134
-			if (! $_realpath = $this->realpath($this->encode($targetPath))) {
2134
+			if (!$_realpath = $this->realpath($this->encode($targetPath))) {
2135 2135
 				if ($stat = $this->mkdir($targetHash, $dir)) {
2136 2136
 					$result['added'][] = $stat;
2137 2137
 					$targetHash = $stat['hash'];
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
 	 * @author Naoki Sawada
2199 2199
 	 **/
2200 2200
 	protected function dirnameCE($path) {
2201
-		return (!$this->encoding)? $this->_dirname($path) :	$this->convEncOut($this->_dirname($this->convEncIn($path)));
2201
+		return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path)));
2202 2202
 	}
2203 2203
 	
2204 2204
 	/**
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
 	 * @author Naoki Sawada
2210 2210
 	 **/
2211 2211
 	protected function basenameCE($path) {
2212
-		return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2212
+		return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path)));
2213 2213
 	}
2214 2214
 	
2215 2215
 	/**
@@ -2222,7 +2222,7 @@  discard block
 block discarded – undo
2222 2222
 	 * @author Naoki Sawada
2223 2223
 	 **/
2224 2224
 	protected function joinPathCE($dir, $name) {
2225
-		return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2225
+		return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name)));
2226 2226
 	}
2227 2227
 	
2228 2228
 	/**
@@ -2233,7 +2233,7 @@  discard block
 block discarded – undo
2233 2233
 	 * @author Naoki Sawada
2234 2234
 	 **/
2235 2235
 	protected function normpathCE($path) {
2236
-		return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2236
+		return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path)));
2237 2237
 	}
2238 2238
 	
2239 2239
 	/**
@@ -2244,7 +2244,7 @@  discard block
 block discarded – undo
2244 2244
 	 * @author Naoki Sawada
2245 2245
 	 **/
2246 2246
 	protected function relpathCE($path) {
2247
-		return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2247
+		return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path)));
2248 2248
 	}
2249 2249
 	
2250 2250
 	/**
@@ -2255,7 +2255,7 @@  discard block
 block discarded – undo
2255 2255
 	 * @author Naoki Sawada
2256 2256
 	 **/
2257 2257
 	protected function abspathCE($path) {
2258
-		return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path)));
2258
+		return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path)));
2259 2259
 	}
2260 2260
 	
2261 2261
 	/**
@@ -2267,7 +2267,7 @@  discard block
 block discarded – undo
2267 2267
 	 * @author Naoki Sawada
2268 2268
 	 **/
2269 2269
 	protected function inpathCE($path, $parent) {
2270
-		return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2270
+		return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
2271 2271
 	}
2272 2272
 	
2273 2273
 	/**
@@ -2278,8 +2278,8 @@  discard block
 block discarded – undo
2278 2278
 	 * @return resource|false
2279 2279
 	 * @author Naoki Sawada
2280 2280
 	 **/
2281
-	protected function fopenCE($path, $mode='rb') {
2282
-		return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2281
+	protected function fopenCE($path, $mode = 'rb') {
2282
+		return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
2283 2283
 	}
2284 2284
 	
2285 2285
 	/**
@@ -2290,8 +2290,8 @@  discard block
 block discarded – undo
2290 2290
 	 * @return bool
2291 2291
 	 * @author Naoki Sawada
2292 2292
 	 **/
2293
-	protected function fcloseCE($fp, $path='') {
2294
-		return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2293
+	protected function fcloseCE($fp, $path = '') {
2294
+		return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path)));
2295 2295
 	}
2296 2296
 	
2297 2297
 	/**
@@ -2306,7 +2306,7 @@  discard block
 block discarded – undo
2306 2306
 	 * @author Naoki Sawada
2307 2307
 	 **/
2308 2308
 	protected function saveCE($fp, $dir, $name, $stat) {
2309
-		return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2309
+		return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat)));
2310 2310
 	}
2311 2311
 	
2312 2312
 	/**
@@ -2318,7 +2318,7 @@  discard block
 block discarded – undo
2318 2318
 	 **/
2319 2319
 	protected function subdirsCE($path) {
2320 2320
 		if (!isset($this->subdirsCache[$path])) {
2321
-			$this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2321
+			$this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path)));
2322 2322
 		}
2323 2323
 		return $this->subdirsCache[$path];
2324 2324
 	}
@@ -2331,7 +2331,7 @@  discard block
 block discarded – undo
2331 2331
 	 * @author Naoki Sawada
2332 2332
 	 **/
2333 2333
 	protected function scandirCE($path) {
2334
-		return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2334
+		return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path)));
2335 2335
 	}
2336 2336
 	
2337 2337
 	/**
@@ -2344,7 +2344,7 @@  discard block
 block discarded – undo
2344 2344
 	 * @author Naoki Sawada
2345 2345
 	 **/
2346 2346
 	protected function symlinkCE($source, $targetDir, $name) {
2347
-		return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2347
+		return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name)));
2348 2348
 	}
2349 2349
 	
2350 2350
 	/***************** paths *******************/
@@ -2363,7 +2363,7 @@  discard block
 block discarded – undo
2363 2363
 			// cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root
2364 2364
 			$p = $this->relpathCE($path);
2365 2365
 			// if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt
2366
-			if ($p === '')	{
2366
+			if ($p === '') {
2367 2367
 				$p = DIRECTORY_SEPARATOR;
2368 2368
 			}
2369 2369
 
@@ -2396,7 +2396,7 @@  discard block
 block discarded – undo
2396 2396
 			// TODO uncrypt hash and return path
2397 2397
 			$path = $this->uncrypt($h); 
2398 2398
 			// append ROOT to path after it was cut in encode
2399
-			return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2399
+			return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); 
2400 2400
 		}
2401 2401
 	}
2402 2402
 	
@@ -2453,21 +2453,21 @@  discard block
 block discarded – undo
2453 2453
 	 * @author Dmitry (dio) Levashov
2454 2454
 	 **/
2455 2455
 	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) {
2456
-		$ext  = '';
2456
+		$ext = '';
2457 2457
 
2458 2458
 		if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
2459 2459
 			$ext  = '.'.$m[1];
2460
-			$name = substr($name, 0,  strlen($name)-strlen($m[0]));
2460
+			$name = substr($name, 0, strlen($name) - strlen($m[0]));
2461 2461
 		} 
2462 2462
 		
2463 2463
 		if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) {
2464
-			$i    = (int)$m[2];
2465
-			$name = substr($name, 0, strlen($name)-strlen($m[2]));
2464
+			$i    = (int) $m[2];
2465
+			$name = substr($name, 0, strlen($name) - strlen($m[2]));
2466 2466
 		} else {
2467 2467
 			$i     = $start;
2468 2468
 			$name .= $suffix;
2469 2469
 		}
2470
-		$max = $i+100000;
2470
+		$max = $i + 100000;
2471 2471
 
2472 2472
 		while ($i <= $max) {
2473 2473
 			$n = $name.($i > 0 ? $i : '').$ext;
@@ -2491,7 +2491,7 @@  discard block
 block discarded – undo
2491 2491
 	 * @author Naoki Sawada
2492 2492
 	 */
2493 2493
 	public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') {
2494
-		return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2494
+		return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown);
2495 2495
 	}
2496 2496
 	
2497 2497
 	/**
@@ -2504,7 +2504,7 @@  discard block
 block discarded – undo
2504 2504
 	 * @author Naoki Sawada
2505 2505
 	 */
2506 2506
 	public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') {
2507
-		return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2507
+		return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
2508 2508
 	}
2509 2509
 	
2510 2510
 	/**
@@ -2524,7 +2524,7 @@  discard block
 block discarded – undo
2524 2524
 			}
2525 2525
 			if (is_array($var)) {
2526 2526
 				$_ret = array();
2527
-				foreach($var as $_k => $_v) {
2527
+				foreach ($var as $_k => $_v) {
2528 2528
 					$_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_');
2529 2529
 				}
2530 2530
 				$var = $_ret;
@@ -2536,7 +2536,7 @@  discard block
 block discarded – undo
2536 2536
 						$_var = str_replace('?', $unknown, $_var);
2537 2537
 					}
2538 2538
 				}
2539
-				if  ($_var !== false) {
2539
+				if ($_var !== false) {
2540 2540
 					$var = $_var;
2541 2541
 				}
2542 2542
 			}
@@ -2563,7 +2563,7 @@  discard block
 block discarded – undo
2563 2563
 		
2564 2564
 		$key = '';
2565 2565
 		if ($path !== '') {
2566
-			$key = $this->id . '#' . $path;
2566
+			$key = $this->id.'#'.$path;
2567 2567
 			if (isset($cache[$key])) {
2568 2568
 				return $cache[$key];
2569 2569
 			}
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
 		if ($work = $this->getTempFile()) {
2596 2596
 			if ($wfp = fopen($work, 'wb')) {
2597 2597
 				if ($fp = $this->_fopen($path)) {
2598
-					while(!feof($fp)) {
2598
+					while (!feof($fp)) {
2599 2599
 						fwrite($wfp, fread($fp, 8192));
2600 2600
 					}
2601 2601
 					$this->_fclose($fp, $path);
@@ -2639,7 +2639,7 @@  discard block
 block discarded – undo
2639 2639
 			@set_time_limit(30);
2640 2640
 			$stat = $this->stat($this->convEncOut($p));
2641 2641
 			$this->convEncIn();
2642
-			($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p);
2642
+			($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p);
2643 2643
 		}
2644 2644
 		return $this->_rmdir($localpath);
2645 2645
 	}
@@ -2656,7 +2656,7 @@  discard block
 block discarded – undo
2656 2656
 	 * @return bool
2657 2657
 	 * @author Dmitry (dio) Levashov
2658 2658
 	 **/
2659
-	protected function attr($path, $name, $val=null, $isDir=null) {
2659
+	protected function attr($path, $name, $val = null, $isDir = null) {
2660 2660
 		if (!isset($this->defaults[$name])) {
2661 2661
 			return false;
2662 2662
 		}
@@ -2688,7 +2688,7 @@  discard block
 block discarded – undo
2688 2688
 			} 
2689 2689
 		}
2690 2690
 		
2691
-		return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm;
2691
+		return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm;
2692 2692
 	}
2693 2693
 	
2694 2694
 	/**
@@ -2732,7 +2732,7 @@  discard block
 block discarded – undo
2732 2732
 	protected function allowPutMime($mime) {
2733 2733
 		// logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order
2734 2734
 		$allow  = $this->mimeAccepted($mime, $this->uploadAllow, null);
2735
-		$deny   = $this->mimeAccepted($mime, $this->uploadDeny,  null);
2735
+		$deny   = $this->mimeAccepted($mime, $this->uploadDeny, null);
2736 2736
 		$res = true; // default to allow
2737 2737
 		if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny'
2738 2738
 			$res = false; // default is deny
@@ -2803,10 +2803,10 @@  discard block
 block discarded – undo
2803 2803
 			if ($this->rootName) {
2804 2804
 				$stat['name'] = $this->rootName;
2805 2805
 			}
2806
-			if (! empty($this->options['icon'])) {
2806
+			if (!empty($this->options['icon'])) {
2807 2807
 				$stat['icon'] = $this->options['icon'];
2808 2808
 			}
2809
-			if (! empty($this->options['rootCssClass'])) {
2809
+			if (!empty($this->options['rootCssClass'])) {
2810 2810
 				$stat['csscls'] = $this->options['rootCssClass'];
2811 2811
 			}
2812 2812
 		} else {
@@ -2850,7 +2850,7 @@  discard block
 block discarded – undo
2850 2850
 			// lock when parent directory is not writable
2851 2851
 			if (!isset($stat['locked'])) {
2852 2852
 				$parent = $this->dirnameCE($path);
2853
-				$pstat = isset($this->cache[$parent])? $this->cache[$parent] : array();
2853
+				$pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array();
2854 2854
 				if (isset($pstat['write']) && !$pstat['write']) {
2855 2855
 					$stat['locked'] = true;
2856 2856
 				}
@@ -2908,7 +2908,7 @@  discard block
 block discarded – undo
2908 2908
 			}
2909 2909
 			if (!isset($stat['url']) && $this->URL && $this->encoding) {
2910 2910
 				$_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1));
2911
-				$stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true)));
2911
+				$stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true)));
2912 2912
 			}
2913 2913
 		} else {
2914 2914
 			if ($isDir) {
@@ -3151,7 +3151,7 @@  discard block
 block discarded – undo
3151 3151
 	 * @return array
3152 3152
 	 * @author Dmitry (dio) Levashov
3153 3153
 	 **/
3154
-	protected function gettree($path, $deep, $exclude='') {
3154
+	protected function gettree($path, $deep, $exclude = '') {
3155 3155
 		$dirs = array();
3156 3156
 		
3157 3157
 		!isset($this->dirsCache[$path]) && $this->cacheDir($path);
@@ -3162,7 +3162,7 @@  discard block
 block discarded – undo
3162 3162
 			if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') {
3163 3163
 				$dirs[] = $stat;
3164 3164
 				if ($deep > 0 && !empty($stat['dirs'])) {
3165
-					$dirs = array_merge($dirs, $this->gettree($p, $deep-1));
3165
+					$dirs = array_merge($dirs, $this->gettree($p, $deep - 1));
3166 3166
 				}
3167 3167
 			}
3168 3168
 		}
@@ -3182,7 +3182,7 @@  discard block
 block discarded – undo
3182 3182
 	protected function doSearch($path, $q, $mimes) {
3183 3183
 		$result = array();
3184 3184
 
3185
-		foreach($this->scandirCE($path) as $p) {
3185
+		foreach ($this->scandirCE($path) as $p) {
3186 3186
 			@set_time_limit(30);
3187 3187
 			$stat = $this->stat($p);
3188 3188
 
@@ -3203,7 +3203,7 @@  discard block
 block discarded – undo
3203 3203
 					if ($this->encoding) {
3204 3204
 						$path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true)));
3205 3205
 					}
3206
-					$stat['url'] = $this->URL . $path;
3206
+					$stat['url'] = $this->URL.$path;
3207 3207
 				}
3208 3208
 				
3209 3209
 				$result[] = $stat;
@@ -3237,7 +3237,7 @@  discard block
 block discarded – undo
3237 3237
 			if (!$this->inpathCE($target, $this->root)) {
3238 3238
 				return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK);
3239 3239
 			}
3240
-			$stat   = $this->stat($target);
3240
+			$stat = $this->stat($target);
3241 3241
 			$this->clearcache();
3242 3242
 			return $stat && $this->symlinkCE($target, $dst, $name)
3243 3243
 				? $this->joinPathCE($dst, $name)
@@ -3518,15 +3518,15 @@  discard block
 block discarded – undo
3518 3518
 		}
3519 3519
 
3520 3520
 		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
3521
-		if ($s[0] <= $tmbSize && $s[1]	<= $tmbSize) {
3522
-			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3521
+		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
3522
+			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3523 3523
 		} else {
3524 3524
 		
3525 3525
 			if ($this->options['tmbCrop']) {
3526 3526
 		
3527 3527
 				$result = $tmb;
3528 3528
 				/* Resize and crop if image bigger than thumbnail */
3529
-				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3529
+				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
3530 3530
 					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
3531 3531
 				}
3532 3532
 		
@@ -3543,7 +3543,7 @@  discard block
 block discarded – undo
3543 3543
 			}
3544 3544
 		
3545 3545
 			if ($result) {
3546
-				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
3546
+				$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
3547 3547
 			}
3548 3548
 		}
3549 3549
 		
@@ -3584,18 +3584,18 @@  discard block
 block discarded – undo
3584 3584
 			/* Resizing by biggest side */
3585 3585
 			if ($resizeByBiggerSide) {
3586 3586
 				if ($orig_w > $orig_h) {
3587
-					$size_h = round($orig_h * $width / $orig_w);
3587
+					$size_h = round($orig_h*$width/$orig_w);
3588 3588
 					$size_w = $width;
3589 3589
 				} else {
3590
-					$size_w = round($orig_w * $height / $orig_h);
3590
+					$size_w = round($orig_w*$height/$orig_h);
3591 3591
 					$size_h = $height;
3592 3592
 				}
3593 3593
 			} else {
3594 3594
 				if ($orig_w > $orig_h) {
3595
-					$size_w = round($orig_w * $height / $orig_h);
3595
+					$size_w = round($orig_w*$height/$orig_h);
3596 3596
 					$size_h = $height;
3597 3597
 				} else {
3598
-					$size_h = round($orig_h * $width / $orig_w);
3598
+					$size_h = round($orig_h*$width/$orig_w);
3599 3599
 					$size_w = $width;
3600 3600
 				}
3601 3601
 			}
@@ -3613,7 +3613,7 @@  discard block
 block discarded – undo
3613 3613
 				// Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb
3614 3614
 				// resize bench: http://app-mgng.rhcloud.com/9
3615 3615
 				// resize sample: http://www.dylanbeattie.net/magick/filters/result.html
3616
-				$filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3616
+				$filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
3617 3617
 				
3618 3618
 				$ani = ($img->getNumberImages() > 1);
3619 3619
 				if ($ani && is_null($destformat)) {
@@ -3638,11 +3638,11 @@  discard block
 block discarded – undo
3638 3638
 				break;
3639 3639
 
3640 3640
 			case 'gd':
3641
-				$img = self::gdImageCreate($path,$s['mime']);
3641
+				$img = self::gdImageCreate($path, $s['mime']);
3642 3642
 
3643
-				if ($img &&  false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3643
+				if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
3644 3644
 				
3645
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3645
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3646 3646
 					
3647 3647
 					if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
3648 3648
 						return false;
@@ -3718,11 +3718,11 @@  discard block
 block discarded – undo
3718 3718
 				break;
3719 3719
 
3720 3720
 			case 'gd':
3721
-				$img = self::gdImageCreate($path,$s['mime']);
3721
+				$img = self::gdImageCreate($path, $s['mime']);
3722 3722
 
3723
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3723
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3724 3724
 					
3725
-					self::gdImageBackground($tmp,$this->options['tmbBgColor']);
3725
+					self::gdImageBackground($tmp, $this->options['tmbBgColor']);
3726 3726
 
3727 3727
 					$size_w = $width;
3728 3728
 					$size_h = $height;
@@ -3772,8 +3772,8 @@  discard block
 block discarded – undo
3772 3772
 		$result = false;
3773 3773
 
3774 3774
 		/* Coordinates for image over square aligning */
3775
-		$y = ceil(abs($height - $s[1]) / 2); 
3776
-		$x = ceil(abs($width - $s[0]) / 2);
3775
+		$y = ceil(abs($height - $s[1])/2); 
3776
+		$x = ceil(abs($width - $s[0])/2);
3777 3777
 
3778 3778
 		switch ($this->imgLib) {
3779 3779
 			case 'imagick':
@@ -3793,7 +3793,7 @@  discard block
 block discarded – undo
3793 3793
 						$gif->newImage($width, $height, new ImagickPixel($bgcolor));
3794 3794
 						$gif->setImageColorspace($img->getImageColorspace());
3795 3795
 						$gif->setImageFormat('gif');
3796
-						$gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3796
+						$gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3797 3797
 						$gif->setImageDelay($img->getImageDelay());
3798 3798
 						$gif->setImageIterations($img->getImageIterations());
3799 3799
 						$img1->addImage($gif);
@@ -3809,7 +3809,7 @@  discard block
 block discarded – undo
3809 3809
 					$img1->newImage($width, $height, new ImagickPixel($bgcolor));
3810 3810
 					$img1->setImageColorspace($img->getImageColorspace());
3811 3811
 					$img1->setImageFormat($destformat != null ? $destformat : $img->getFormat());
3812
-					$img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y );
3812
+					$img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
3813 3813
 					$result = $img1->writeImage($path);
3814 3814
 				}
3815 3815
 				
@@ -3820,11 +3820,11 @@  discard block
 block discarded – undo
3820 3820
 				break;
3821 3821
 
3822 3822
 			case 'gd':
3823
-				$img = self::gdImageCreate($path,$s['mime']);
3823
+				$img = self::gdImageCreate($path, $s['mime']);
3824 3824
 
3825
-				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
3825
+				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
3826 3826
 
3827
-					self::gdImageBackground($tmp,$bgcolor);
3827
+					self::gdImageBackground($tmp, $bgcolor);
3828 3828
 
3829 3829
 					if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) {
3830 3830
 						return false;
@@ -3855,15 +3855,15 @@  discard block
 block discarded – undo
3855 3855
 	 * @author Troex Nevelin
3856 3856
 	 **/
3857 3857
 	protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null) {
3858
-		if (($s = @getimagesize($path)) == false || $degree % 360 === 0) {
3858
+		if (($s = @getimagesize($path)) == false || $degree%360 === 0) {
3859 3859
 			return false;
3860 3860
 		}
3861 3861
 
3862 3862
 		$result = false;
3863 3863
 
3864 3864
 		// try lossless rotate
3865
-		if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3866
-			$count = ($degree / 90) % 4;
3865
+		if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {
3866
+			$count = ($degree/90)%4;
3867 3867
 			$exiftran = array(
3868 3868
 				1 => '-9',
3869 3869
 				2 => '-1',
@@ -3879,7 +3879,7 @@  discard block
 block discarded – undo
3879 3879
 				'exiftran -i '.$exiftran[$count].' '.$path,
3880 3880
 				'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath
3881 3881
 			);
3882
-			foreach($cmds as $cmd) {
3882
+			foreach ($cmds as $cmd) {
3883 3883
 				if ($this->procExec($cmd) === 0) {
3884 3884
 					$result = true;
3885 3885
 					break;
@@ -3915,12 +3915,12 @@  discard block
 block discarded – undo
3915 3915
 				break;
3916 3916
 
3917 3917
 			case 'gd':
3918
-				$img = self::gdImageCreate($path,$s['mime']);
3918
+				$img = self::gdImageCreate($path, $s['mime']);
3919 3919
 
3920 3920
 				$degree = 360 - $degree;
3921 3921
 				list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
3922 3922
 				$bgcolor = imagecolorallocate($img, $r, $g, $b);
3923
-				$tmp = imageRotate($img, $degree, (int)$bgcolor);
3923
+				$tmp = imageRotate($img, $degree, (int) $bgcolor);
3924 3924
 
3925 3925
 				$result = self::gdImage($tmp, $path, $destformat, $s['mime']);
3926 3926
 
@@ -3945,11 +3945,11 @@  discard block
 block discarded – undo
3945 3945
 	 * @return int     exit code
3946 3946
 	 * @author Alexey Sukhotin
3947 3947
 	 **/
3948
-	protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) {
3948
+	protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) {
3949 3949
 
3950 3950
 		$descriptorspec = array(
3951
-			0 => array("pipe", "r"),  // stdin
3952
-			1 => array("pipe", "w"),  // stdout
3951
+			0 => array("pipe", "r"), // stdin
3952
+			1 => array("pipe", "w"), // stdout
3953 3953
 			2 => array("pipe", "w")   // stderr
3954 3954
 		);
3955 3955
 
@@ -4006,8 +4006,8 @@  discard block
 block discarded – undo
4006 4006
 	 * @param string $mime
4007 4007
 	 * @return gd image resource identifier
4008 4008
 	 */
4009
-	protected function gdImageCreate($path,$mime){
4010
-		switch($mime){
4009
+	protected function gdImageCreate($path, $mime) {
4010
+		switch ($mime) {
4011 4011
 			case 'image/jpeg':
4012 4012
 			return imagecreatefromjpeg($path);
4013 4013
 
@@ -4031,7 +4031,7 @@  discard block
 block discarded – undo
4031 4031
 	 * @param string $destformat The Image type to use for $filename
4032 4032
 	 * @param string $mime The original image mime type
4033 4033
 	 */
4034
-	protected function gdImage($image, $filename, $destformat, $mime ){
4034
+	protected function gdImage($image, $filename, $destformat, $mime) {
4035 4035
 
4036 4036
 		if ($destformat == 'jpg' || ($destformat == null && $mime == 'image/jpeg')) {
4037 4037
 			return imagejpeg($image, $filename, 100);
@@ -4050,13 +4050,13 @@  discard block
 block discarded – undo
4050 4050
 	 * @param resource $image gd image resource
4051 4051
 	 * @param string $bgcolor background color in #rrggbb format
4052 4052
 	 */
4053
-	protected function gdImageBackground($image, $bgcolor){
4053
+	protected function gdImageBackground($image, $bgcolor) {
4054 4054
 
4055
-		if( $bgcolor == 'transparent' ){
4056
-			imagesavealpha($image,true);
4055
+		if ($bgcolor == 'transparent') {
4056
+			imagesavealpha($image, true);
4057 4057
 			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);
4058 4058
 
4059
-		}else{
4059
+		} else {
4060 4060
 			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
4061 4061
 			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
4062 4062
 		}
@@ -4094,13 +4094,13 @@  discard block
 block discarded – undo
4094 4094
 	* @return int|bool
4095 4095
 	* @author Alexey Sukhotin
4096 4096
 	**/
4097
-	protected function stripos($haystack , $needle , $offset = 0) {
4097
+	protected function stripos($haystack, $needle, $offset = 0) {
4098 4098
 		if (function_exists('mb_stripos')) {
4099
-			return mb_stripos($haystack , $needle , $offset);
4099
+			return mb_stripos($haystack, $needle, $offset);
4100 4100
 		} else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) {
4101 4101
 			return mb_strpos(mb_strtolower($haystack), mb_strtolower($needle), $offset);
4102 4102
 		} 
4103
-		return stripos($haystack , $needle , $offset);
4103
+		return stripos($haystack, $needle, $offset);
4104 4104
 	}
4105 4105
 
4106 4106
 	/**
@@ -4150,22 +4150,22 @@  discard block
 block discarded – undo
4150 4150
 			unset($o);
4151 4151
 			$this->procExec('zip -v', $o, $c);
4152 4152
 			if ($c == 0) {
4153
-				$arcs['create']['application/zip']  = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4153
+				$arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
4154 4154
 			}
4155 4155
 			unset($o);
4156 4156
 			$this->procExec('unzip --help', $o, $c);
4157 4157
 			if ($c == 0) {
4158
-				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '',  'ext' => 'zip');
4158
+				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip');
4159 4159
 			}
4160 4160
 			unset($o);
4161 4161
 			$this->procExec('rar --version', $o, $c);
4162 4162
 			if ($c == 0 || $c == 7) {
4163 4163
 				$arcs['create']['application/x-rar']  = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
4164
-				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y',    'ext' => 'rar');
4164
+				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar');
4165 4165
 			} else {
4166 4166
 				unset($o);
4167 4167
 				$test = $this->procExec('unrar', $o, $c);
4168
-				if ($c==0 || $c == 7) {
4168
+				if ($c == 0 || $c == 7) {
4169 4169
 					$arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
4170 4170
 				}
4171 4171
 			}
@@ -4187,7 +4187,7 @@  discard block
 block discarded – undo
4187 4187
 				if (empty($arcs['extract']['application/x-tar'])) {
4188 4188
 					$arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar');
4189 4189
 				}
4190
-			} else if (substr(PHP_OS,0,3) === 'WIN') {
4190
+			} else if (substr(PHP_OS, 0, 3) === 'WIN') {
4191 4191
 				// check `7z` for Windows server.
4192 4192
 				unset($o);
4193 4193
 				$this->procExec('7z', $o, $c);
@@ -4241,22 +4241,22 @@  discard block
 block discarded – undo
4241 4241
 
4242 4242
 		// normalize `/../`
4243 4243
 		$normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#';
4244
-		while(preg_match($normreg, $path)) {
4244
+		while (preg_match($normreg, $path)) {
4245 4245
 			$path = preg_replace($normreg, '$1', $path);
4246 4246
 		}
4247 4247
 		
4248 4248
 		// 'Here'
4249
-		if ($path === '' || $path === '.' . $separator) return $base;
4249
+		if ($path === '' || $path === '.'.$separator) return $base;
4250 4250
 		
4251 4251
 		// Absolute path
4252 4252
 		if ($path[0] === $separator || strpos($path, $systemroot) === 0) {
4253 4253
 			return $path;
4254 4254
 		}
4255 4255
 		
4256
-		$preg_separator = '#' . $sepquoted . '#';
4256
+		$preg_separator = '#'.$sepquoted.'#';
4257 4257
 		
4258 4258
 		// Relative path from 'Here'
4259
-		if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) {
4259
+		if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) {
4260 4260
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4261 4261
 			if ($arrn[0] !== '.') {
4262 4262
 				array_unshift($arrn, '.');
@@ -4270,12 +4270,11 @@  discard block
 block discarded – undo
4270 4270
 			$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
4271 4271
 			$arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY);
4272 4272
 		
4273
-			while (! empty($arrn) && $arrn[0] === '..') {
4273
+			while (!empty($arrn) && $arrn[0] === '..') {
4274 4274
 				array_shift($arrn);
4275 4275
 				array_pop($arrp);
4276 4276
 			}
4277
-			$path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) :
4278
-				(! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot);
4277
+			$path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot);
4279 4278
 		}
4280 4279
 		
4281 4280
 		return $path;
@@ -4293,7 +4292,7 @@  discard block
 block discarded – undo
4293 4292
 			@chmod($dir, 0777);
4294 4293
 			foreach (array_diff(scandir($dir), array('.', '..')) as $file) {
4295 4294
 				@set_time_limit(30);
4296
-				$path = $dir . DIRECTORY_SEPARATOR . $file;
4295
+				$path = $dir.DIRECTORY_SEPARATOR.$file;
4297 4296
 				if (!is_link($dir) && is_dir($path)) {
4298 4297
 					$this->rmdirRecursive($path);
4299 4298
 				} else {
@@ -4380,22 +4379,22 @@  discard block
 block discarded – undo
4380 4379
 		try {
4381 4380
 			if ($start = is_string($zipPath)) {
4382 4381
 				$zip = new ZipArchive();
4383
-				if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) {
4382
+				if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) {
4384 4383
 					$zip = false;
4385 4384
 				}
4386 4385
 			} else {
4387 4386
 				$zip = $zipPath;
4388 4387
 			}
4389 4388
 			if ($zip) {
4390
-				foreach($files as $file) {
4391
-					$path = $dir . DIRECTORY_SEPARATOR . $file;
4389
+				foreach ($files as $file) {
4390
+					$path = $dir.DIRECTORY_SEPARATOR.$file;
4392 4391
 					if (is_dir($path)) {
4393 4392
 						$zip->addEmptyDir($file);
4394 4393
 						$_files = array();
4395 4394
 						if ($handle = opendir($path)) {
4396 4395
 							while (false !== ($entry = readdir($handle))) {
4397 4396
 								if ($entry !== "." && $entry !== "..") {
4398
-									$_files[] = $file . DIRECTORY_SEPARATOR . $entry;
4397
+									$_files[] = $file.DIRECTORY_SEPARATOR.$entry;
4399 4398
 								}
4400 4399
 							}
4401 4400
 							closedir($handle);
@@ -4580,7 +4579,7 @@  discard block
 block discarded – undo
4580 4579
 	 * @return resource|false
4581 4580
 	 * @author Dmitry (dio) Levashov
4582 4581
 	 **/
4583
-	abstract protected function _fopen($path, $mode="rb");
4582
+	abstract protected function _fopen($path, $mode = "rb");
4584 4583
 	
4585 4584
 	/**
4586 4585
 	 * Close opened file
@@ -4590,7 +4589,7 @@  discard block
 block discarded – undo
4590 4589
 	 * @return bool
4591 4590
 	 * @author Dmitry (dio) Levashov
4592 4591
 	 **/
4593
-	abstract protected function _fclose($fp, $path='');
4592
+	abstract protected function _fclose($fp, $path = '');
4594 4593
 	
4595 4594
 	/********************  file/dir manipulations *************************/
4596 4595
 	
Please login to merge, or discard this patch.