Completed
Push — 2.x ( 68308b...d4db0b )
by Naoki
05:34
created
php/chars-test.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@
 block discarded – undo
24 24
 
25 25
 //                     й                 ё              Й               Ё              Ø         Å
26 26
 $patterns = array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a");
27
-$replace  = array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5");
27
+$replace  = array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5");
28 28
 
29 29
 
30
-foreach(scandir($path) as $f) {
30
+foreach (scandir($path) as $f) {
31 31
 	if ($f != '.' && $f != '..' && substr($f, 0, 1) != '.') {
32 32
 		
33 33
 		// echo mb_detect_encoding($f);
Please login to merge, or discard this patch.
php/elFinderConnector.class.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @return void
35 35
 	 * @author Dmitry (dio) Levashov
36 36
 	 **/
37
-	public function __construct($elFinder, $debug=false) {
37
+	public function __construct($elFinder, $debug = false) {
38 38
 		
39 39
 		$this->elFinder = $elFinder;
40 40
 		if ($debug) {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		if ($isPost && !$src && $rawPostData = @file_get_contents('php://input')) {
55 55
 			// for support IE XDomainRequest()
56 56
 			$parts = explode('&', $rawPostData);
57
-			foreach($parts as $part) {
57
+			foreach ($parts as $part) {
58 58
 				list($key, $value) = array_pad(explode('=', $part), 2, '');
59 59
 				$key = rawurldecode($key);
60 60
 				if (substr($key, -2) === '[]') {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 **/
122 122
 	protected function output(array $data) {
123 123
 		// clear output buffer
124
-		while(@ob_get_level()){ @ob_end_clean(); }
124
+		while (@ob_get_level()) { @ob_end_clean(); }
125 125
 		
126 126
 		$header = isset($data['header']) ? $data['header'] : $this->header;
127 127
 		unset($data['header']);
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
 							$psize = $end - $start + 1;
163 163
 							
164 164
 							header('HTTP/1.1 206 Partial Content');
165
-							header('Content-Length: ' . $psize);
166
-							header('Content-Range: bytes ' . $start . '-' . $end . '/' . $size);
165
+							header('Content-Length: '.$psize);
166
+							header('Content-Range: bytes '.$start.'-'.$end.'/'.$size);
167 167
 							
168 168
 							fseek($fp, $start);
169 169
 						}
170 170
 					}
171 171
 				}
172
-				if (is_null($psize)){
172
+				if (is_null($psize)) {
173 173
 					rewind($fp);
174 174
 				}
175 175
 			} else {
Please login to merge, or discard this patch.
php/elFinderVolumeS3.class.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 **/
62 62
 	protected function _dirname($path) {
63 63
 	
64
-		$newpath =  preg_replace("/\/$/", "", $path);
65
-		$dn = substr($path, 0, strrpos($newpath, '/')) ;
64
+		$newpath = preg_replace("/\/$/", "", $path);
65
+		$dn = substr($path, 0, strrpos($newpath, '/'));
66 66
 		
67 67
 		if (substr($dn, 0, 1) != '/') {
68 68
 		 $dn = "/$dn";
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 * @author Troex Nevelin
106 106
 	 **/
107 107
 	protected function _normpath($path) {
108
-		$tmp =  preg_replace("/^\//", "", $path);
109
-		$tmp =  preg_replace("/\/\//", "/", $tmp);
110
-		$tmp =  preg_replace("/\/$/", "", $tmp);
108
+		$tmp = preg_replace("/^\//", "", $path);
109
+		$tmp = preg_replace("/\/\//", "/", $tmp);
110
+		$tmp = preg_replace("/\/$/", "", $tmp);
111 111
 		return $tmp;
112 112
 	}
113 113
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 			$newpath = "/$newpath";
129 129
 		}
130 130
 		
131
-		$newpath =  preg_replace("/\/$/", "", $newpath);
131
+		$newpath = preg_replace("/\/$/", "", $newpath);
132 132
 	
133
-		$ret = ($newpath == $this->root) ? '' : substr($newpath, strlen($this->root)+1);
133
+		$ret = ($newpath == $this->root) ? '' : substr($newpath, strlen($this->root) + 1);
134 134
 		
135 135
 		return $ret;
136 136
 	}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		$np = $this->_normpath($path);
232 232
 		
233 233
 		try {
234
-			$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np , 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false));
234
+			$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np, 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false));
235 235
 		} catch (Exception $e) {
236 236
 		
237 237
 		}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		if (!isset($obj) || ($obj->GetObjectResponse->Status->Code != 200)) {
240 240
 			$np .= '/';
241 241
 			try {
242
-				$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np , 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false));
242
+				$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np, 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false));
243 243
 			} catch (Exception $e) {
244 244
 		
245 245
 			}
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
 	 **/
342 342
 	protected function _scandir($path) {
343 343
 		
344
-		$s3path = preg_replace("/^\//", "", $path) . '/';
344
+		$s3path = preg_replace("/^\//", "", $path).'/';
345 345
 		
346 346
 		$files = $this->s3->ListBucket(array('Bucket' => $this->options['bucket'], 'delimiter' => '/', 'Prefix' => $s3path))->ListBucketResponse->Contents;
347 347
 	
348 348
 		$finalfiles = array();
349 349
 		
350 350
 		foreach ($files as $file) {
351
-			if (preg_match("|^" . $s3path . "[^/]*/?$|", $file->Key)) {
351
+			if (preg_match("|^".$s3path."[^/]*/?$|", $file->Key)) {
352 352
 				$fname = preg_replace("/\/$/", "", $file->Key);
353 353
 				$fname = $file->Key;
354 354
 				
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 * @author Dmitry (dio) Levashov,
374 374
 	 * @author Alexey Sukhotin
375 375
 	 **/
376
-	protected function _fopen($path, $mode="rb") {
376
+	protected function _fopen($path, $mode = "rb") {
377 377
 	
378 378
 		$tn = $this->getTempFile($path);
379 379
 	
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
 		if ($fp) {
386 386
 
387 387
 			try {
388
-				$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path) , 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true));
389
-			}	catch (Exception $e) {
388
+				$obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path), 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true));
389
+			} catch (Exception $e) {
390 390
 		
391 391
 			}
392 392
 				
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 * @return bool
411 411
 	 * @author Dmitry (dio) Levashov
412 412
 	 **/
413
-	protected function _fclose($fp, $path='') {
413
+	protected function _fclose($fp, $path = '') {
414 414
 		@fclose($fp);
415 415
 		if ($path) {
416 416
 			@unlink($this->getTempFile($path));
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 		$newkey = "$newkey/$name/";
436 436
 
437 437
 		try {
438
-			$obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey , 'ContentLength' => 0, 'Data' => ''));
438
+			$obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey, 'ContentLength' => 0, 'Data' => ''));
439 439
 		} catch (Exception $e) {
440 440
 		
441 441
 		}
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 		$newkey = "$newkey/$name";
463 463
 
464 464
 		try {
465
-			$obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey , 'ContentLength' => 0, 'Data' => '', 'Metadata' => array(array('Name' => 'Content-Type', 'Value' => 'text/plain'))));
465
+			$obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey, 'ContentLength' => 0, 'Data' => '', 'Metadata' => array(array('Name' => 'Content-Type', 'Value' => 'text/plain'))));
466 466
 		} catch (Exception $e) {
467 467
 		
468 468
 		}
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	 * @author Dmitry (dio) Levashov
564 564
 	 **/
565 565
 	protected function _rmdir($path) {
566
-		return $this->_unlink($path . '/');
566
+		return $this->_unlink($path.'/');
567 567
 	}
568 568
 
569 569
 	/**
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 		/* Getting list of S3 web service functions which requires signing */
683 683
 		$funcs = $this->__getFunctions();
684 684
 		
685
-		$funcnames  = array();
685
+		$funcnames = array();
686 686
 		
687 687
 		foreach ($funcs as $func) {
688 688
 			preg_match("/\S+\s+([^\)]+)\(/", $func, $m);
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 			'Timestamp' => gmdate('Y-m-d\TH:i:s.000\Z'),
724 724
 		);
725 725
 
726
-		$sign_str = 'AmazonS3' . $operation . $params['Timestamp'];
726
+		$sign_str = 'AmazonS3'.$operation.$params['Timestamp'];
727 727
 		
728 728
 		$params['Signature'] = base64_encode(hash_hmac('sha1', $sign_str, $this->secretkey, TRUE));
729 729
 		
Please login to merge, or discard this patch.
php/plugins/Watermark/plugin.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 
58 58
 	public function __construct($opts) {
59 59
 		$defaults = array(
60
-			'enable'         => true,       // For control by volume driver
60
+			'enable'         => true, // For control by volume driver
61 61
 			'source'         => 'logo.png', // Path to Water mark image
62
-			'marginRight'    => 5,          // Margin right pixel
63
-			'marginBottom'   => 5,          // Margin bottom pixel
64
-			'quality'        => 95,         // JPEG image save quality
65
-			'transparency'   => 70,         // Water mark image transparency ( other than PNG )
66
-			'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
62
+			'marginRight'    => 5, // Margin right pixel
63
+			'marginBottom'   => 5, // Margin bottom pixel
64
+			'quality'        => 95, // JPEG image save quality
65
+			'transparency'   => 70, // Water mark image transparency ( other than PNG )
66
+			'targetType'     => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP, // Target image formats ( bit-field )
67 67
 			'targetMinPixel' => 200         // Target image minimum pixel size
68 68
 		);
69 69
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			$opts = array_merge($this->opts, $volOpts);
80 80
 		}
81 81
 		
82
-		if (! $opts['enable']) {
82
+		if (!$opts['enable']) {
83 83
 			return false;
84 84
 		}
85 85
 		
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 		}
95 95
 		
96 96
 		// check water mark image
97
-		if (! file_exists($opts['source'])) {
98
-			$opts['source'] = dirname(__FILE__) . "/" . $opts['source'];
97
+		if (!file_exists($opts['source'])) {
98
+			$opts['source'] = dirname(__FILE__)."/".$opts['source'];
99 99
 		}
100 100
 		if (is_readable($opts['source'])) {
101 101
 			$watermarkImgInfo = @getimagesize($opts['source']);
102
-			if (! $watermarkImgInfo) {
102
+			if (!$watermarkImgInfo) {
103 103
 				return false;
104 104
 			}
105 105
 		} else {
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 			IMAGETYPE_PNG => IMG_PNG,
120 120
 			IMAGETYPE_WBMP => IMG_WBMP,
121 121
 		);
122
-		if (! ($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) {
122
+		if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) {
123 123
 			return false;
124 124
 		}
125 125
 		
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
 				break;
193 193
 			case 'image/jpeg':
194 194
 				if (@imagetypes() & IMG_JPG) {
195
-					$oWatermarkImg = @imagecreatefromjpeg($watermark) ;
195
+					$oWatermarkImg = @imagecreatefromjpeg($watermark);
196 196
 				} else {
197 197
 					$ermsg = 'JPEG images are not supported';
198 198
 				}
199 199
 				break;
200 200
 			case 'image/png':
201 201
 				if (@imagetypes() & IMG_PNG) {
202
-					$oWatermarkImg = @imagecreatefrompng($watermark) ;
202
+					$oWatermarkImg = @imagecreatefrompng($watermark);
203 203
 				} else {
204 204
 					$ermsg = 'PNG images are not supported';
205 205
 				}
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 				break;
218 218
 		}
219 219
 		
220
-		if (! $ermsg) {
220
+		if (!$ermsg) {
221 221
 			switch ($srcImgInfo['mime']) {
222 222
 				case 'image/gif':
223 223
 					if (@imagetypes() & IMG_GIF) {
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
 					break;
229 229
 				case 'image/jpeg':
230 230
 					if (@imagetypes() & IMG_JPG) {
231
-						$oSrcImg = @imagecreatefromjpeg($src) ;
231
+						$oSrcImg = @imagecreatefromjpeg($src);
232 232
 					} else {
233 233
 						$ermsg = 'JPEG images are not supported';
234 234
 					}
235 235
 					break;
236 236
 				case 'image/png':
237 237
 					if (@imagetypes() & IMG_PNG) {
238
-						$oSrcImg = @imagecreatefrompng($src) ;
238
+						$oSrcImg = @imagecreatefrompng($src);
239 239
 					} else {
240 240
 						$ermsg = 'PNG images are not supported';
241 241
 					}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 		if ($srcImgInfo['mime'] === 'image/png') {
262 262
 			if (function_exists('imagecolorallocatealpha')) {
263 263
 				$bg = imagecolorallocatealpha($oSrcImg, 255, 255, 255, 127);
264
-				imagefill($oSrcImg, 0, 0 , $bg);
264
+				imagefill($oSrcImg, 0, 0, $bg);
265 265
 			}
266 266
 		}
267 267
 		
Please login to merge, or discard this patch.
php/plugins/Sanitizer/plugin.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	
50 50
 	public function __construct($opts) {
51 51
 		$defaults = array(
52
-			'enable'   => true,  // For control by volume driver
53
-			'targets'  => array('\\','/',':','*','?','"','<','>','|'), // target chars
52
+			'enable'   => true, // For control by volume driver
53
+			'targets'  => array('\\', '/', ':', '*', '?', '"', '<', '>', '|'), // target chars
54 54
 			'replace'  => '_'    // replace to this
55 55
 		);
56 56
 	
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	
60 60
 	public function cmdPreprocess($cmd, &$args, $elfinder, $volume) {
61 61
 		$opts = $this->getOpts($volume);
62
-		if (! $opts['enable']) {
62
+		if (!$opts['enable']) {
63 63
 			return false;
64 64
 		}
65 65
 	
66 66
 		if (isset($args['name'])) {
67 67
 			if (is_array($args['name'])) {
68
-				foreach($args['name'] as $i => $name) {
68
+				foreach ($args['name'] as $i => $name) {
69 69
 					$args['name'][$i] = $this->sanitizeFileName($name, $opts);
70 70
 				}
71 71
 			} else {
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 	public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) {
79 79
 		$opts = $this->getOpts($volume);
80
-		if (! $opts['enable']) {
80
+		if (!$opts['enable']) {
81 81
 			return false;
82 82
 		}
83 83
 	
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 	
102 102
 	private function sanitizeFileName($filename, $opts, $allows = array()) {
103
-		$targets = $allows? array_diff($opts['targets'], $allows) : $opts['targets'];
103
+		$targets = $allows ? array_diff($opts['targets'], $allows) : $opts['targets'];
104 104
 		return str_replace($targets, $opts['replace'], $filename);
105 105
   	}
106 106
 }
Please login to merge, or discard this patch.
php/plugins/Normalizer/plugin.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 	
59 59
 	public function __construct($opts) {
60 60
 		$defaults = array(
61
-			'enable'    => true,  // For control by volume driver
62
-			'nfc'       => true,  // Canonical Decomposition followed by Canonical Composition
63
-			'nfkc'      => true,  // Compatibility Decomposition followed by Canonical
61
+			'enable'    => true, // For control by volume driver
62
+			'nfc'       => true, // Canonical Decomposition followed by Canonical Composition
63
+			'nfkc'      => true, // Compatibility Decomposition followed by Canonical
64 64
 			'lowercase' => false, // Make chars lowercase
65 65
 			'convmap'   => array()// Convert map ('FROM' => 'TO') array
66 66
 		);
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 	
71 71
 	public function cmdPreprocess($cmd, &$args, $elfinder, $volume) {
72 72
 		$opts = $this->getOpts($volume);
73
-		if (! $opts['enable']) {
73
+		if (!$opts['enable']) {
74 74
 			return false;
75 75
 		}
76 76
 		
77 77
 		if (isset($args['name'])) {
78 78
 			if (is_array($args['name'])) {
79
-				foreach($args['name'] as $i => $name) {
79
+				foreach ($args['name'] as $i => $name) {
80 80
 					$args['name'][$i] = $this->normalize($name, $opts);
81 81
 				}
82 82
 			} else {
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	
89 89
 	public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) {
90 90
 		$opts = $this->getOpts($volume);
91
-		if (! $opts['enable']) {
91
+		if (!$opts['enable']) {
92 92
 			return false;
93 93
 		}
94 94
 		
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 	private function normalize($str, $opts) {
114 114
 		if ($opts['nfc'] || $opts['nfkc']) {
115 115
 			if (class_exists('Normalizer', false)) {
116
-				if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C))
116
+				if ($opts['nfc'] && !Normalizer::isNormalized($str, Normalizer::FORM_C))
117 117
 					$str = Normalizer::normalize($str, Normalizer::FORM_C);
118
-				if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC))
118
+				if ($opts['nfkc'] && !Normalizer::isNormalized($str, Normalizer::FORM_KC))
119 119
 					$str = Normalizer::normalize($str, Normalizer::FORM_KC);
120 120
 			} else {
121
-				if (! class_exists('I18N_UnicodeNormalizer', false)) {
121
+				if (!class_exists('I18N_UnicodeNormalizer', false)) {
122 122
 					@ include_once 'I18N/UnicodeNormalizer.php';
123 123
 				}
124 124
 				if (class_exists('I18N_UnicodeNormalizer', false)) {
Please login to merge, or discard this patch.
php/plugins/AutoResize/plugin.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 
53 53
 	public function __construct($opts) {
54 54
 		$defaults = array(
55
-			'enable'         => true,       // For control by volume driver
56
-			'maxWidth'       => 1024,       // Path to Water mark image
57
-			'maxHeight'      => 1024,       // Margin right pixel
58
-			'quality'        => 95,         // JPEG image save quality
59
-			'preserveExif'   => false,      // Preserve EXIF data (Imagick only)
60
-			'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field )
55
+			'enable'         => true, // For control by volume driver
56
+			'maxWidth'       => 1024, // Path to Water mark image
57
+			'maxHeight'      => 1024, // Margin right pixel
58
+			'quality'        => 95, // JPEG image save quality
59
+			'preserveExif'   => false, // Preserve EXIF data (Imagick only)
60
+			'targetType'     => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP // Target image formats ( bit-field )
61 61
 		);
62 62
 
63 63
 		$this->opts = array_merge($defaults, $opts);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			$opts = array_merge($this->opts, $volOpts);
72 72
 		}
73 73
 		
74
-		if (! $opts['enable']) {
74
+		if (!$opts['enable']) {
75 75
 			return false;
76 76
 		}
77 77
 		
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 				IMAGETYPE_PNG => IMG_PNG,
88 88
 				IMAGETYPE_WBMP => IMG_WBMP,
89 89
 		);
90
-		if (! ($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) {
90
+		if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) {
91 91
 			return false;
92 92
 		}
93 93
 		
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	}
100 100
 	
101 101
 	private function resize($src, $srcImgInfo, $maxWidth, $maxHeight, $quality, $preserveExif) {
102
-		$zoom = min(($maxWidth/$srcImgInfo[0]),($maxHeight/$srcImgInfo[1]));
103
-		$width = round($srcImgInfo[0] * $zoom);
104
-		$height = round($srcImgInfo[1] * $zoom);
102
+		$zoom = min(($maxWidth/$srcImgInfo[0]), ($maxHeight/$srcImgInfo[1]));
103
+		$width = round($srcImgInfo[0]*$zoom);
104
+		$height = round($srcImgInfo[1]*$zoom);
105 105
 		
106 106
 		if (class_exists('Imagick', false)) {
107 107
 			return $this->resize_imagick($src, $width, $height, $quality, $preserveExif);
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
 				break;
122 122
 			case 'image/jpeg':
123 123
 				if (@imagetypes() & IMG_JPG) {
124
-					$oSrcImg = @imagecreatefromjpeg($src) ;
124
+					$oSrcImg = @imagecreatefromjpeg($src);
125 125
 				} else {
126 126
 					$ermsg = 'JPEG images are not supported';
127 127
 				}
128 128
 				break;
129 129
 			case 'image/png':
130 130
 				if (@imagetypes() & IMG_PNG) {
131
-					$oSrcImg = @imagecreatefrompng($src) ;
131
+					$oSrcImg = @imagecreatefrompng($src);
132 132
 				} else {
133 133
 					$ermsg = 'PNG images are not supported';
134 134
 				}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 				break;
147 147
 		}
148 148
 		
149
-		if ($oSrcImg &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
149
+		if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) {
150 150
 			
151 151
 			if (!imagecopyresampled($tmp, $oSrcImg, 0, 0, 0, 0, $width, $height, $srcImgInfo[0], $srcImgInfo[1])) {
152 152
 				return false;
Please login to merge, or discard this patch.
php/elFinderVolumeFTP.class.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		);
104 104
 		$this->options = array_merge($this->options, $opts); 
105 105
 		$this->options['mimeDetect'] = 'internal';
106
-		$this->options['maxArcFilesSize'] = 0;     // max allowed archive files size (0 - no limit)
106
+		$this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit)
107 107
 	}
108 108
 	
109 109
 	/**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		$scheme = parse_url($this->options['host'], PHP_URL_SCHEME);
164 164
 
165 165
 		if ($scheme) {
166
-			$this->options['host'] = substr($this->options['host'], strlen($scheme)+3);
166
+			$this->options['host'] = substr($this->options['host'], strlen($scheme) + 3);
167 167
 		}
168 168
 
169 169
 		// normalize root path
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
 		if ($this->encoding) {
240 240
 			@ftp_exec($this->connect, 'OPTS UTF8 OFF');
241 241
 		} else {
242
-			@ftp_exec($this->connect, 'OPTS UTF8 ON' );
242
+			@ftp_exec($this->connect, 'OPTS UTF8 ON');
243 243
 		}
244 244
 		
245 245
 		// switch off extended passive mode - may be usefull for some servers
246
-		@ftp_exec($this->connect, 'epsv4 off' );
246
+		@ftp_exec($this->connect, 'epsv4 off');
247 247
 		// enter passive mode if required
248 248
 		ftp_pasv($this->connect, $this->options['mode'] == 'passive');
249 249
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 		$name = $info[8];
312 312
 		
313 313
 		if (preg_match('|(.+)\-\>(.+)|', $name, $m)) {
314
-			$name   = trim($m[1]);
314
+			$name = trim($m[1]);
315 315
 			// check recursive processing
316 316
 			if ($this->cacheDirTarget && $this->_joinPath($base, $name) !== $this->cacheDirTarget) {
317 317
 				return array();
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 			$stat['owner'] = $info[2];
348 348
 			$stat['group'] = $info[3];
349 349
 			$stat['perm']  = substr($info[0], 1);
350
-			$stat['isowner'] = $stat['owner']? ($stat['owner'] == $this->options['user']) : $this->options['owner'];
350
+			$stat['isowner'] = $stat['owner'] ? ($stat['owner'] == $this->options['user']) : $this->options['owner'];
351 351
 		}
352 352
 		
353 353
 		$perm = $this->parsePermissions($info[0], $stat['owner']);
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 			$info[4] = 0;
380 380
 			$info[0] = 'drwxr-xr-x';
381 381
 		} else {
382
-			$info[4] = (int)$size;
382
+			$info[4] = (int) $size;
383 383
 			$info[0] = '-rw-r--r--';
384 384
 		}
385 385
 		return $info;
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	protected function parsePermissions($perm, $user = '') {
396 396
 		$res   = array();
397 397
 		$parts = array();
398
-		$owner = $user? ($user == $this->options['user']) : $this->options['owner'];
398
+		$owner = $user ? ($user == $this->options['user']) : $this->options['owner'];
399 399
 		for ($i = 0, $l = strlen($perm); $i < $l; $i++) {
400 400
 			$parts[] = substr($perm, $i, 1);
401 401
 		}
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
 			}
427 427
 		}
428 428
 		$list = $this->convEncOut($list);
429
-		$prefix = ($path === $this->separator)? $this->separator : $path . $this->separator;
429
+		$prefix = ($path === $this->separator) ? $this->separator : $path.$this->separator;
430 430
 		$targets = array();
431
-		foreach($list as $stat) {
432
-			$p = $prefix . $stat['name'];
431
+		foreach ($list as $stat) {
432
+			$p = $prefix.$stat['name'];
433 433
 			if (isset($stat['target'])) {
434 434
 				// stat later
435 435
 				$targets[$stat['name']] = $stat['target'];
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
 			}
442 442
 		}
443 443
 		// stat link targets
444
-		foreach($targets as $name => $target) {
444
+		foreach ($targets as $name => $target) {
445 445
 			$stat = array();
446 446
 			$stat['name'] = $name;
447
-			$p = $prefix . $name;
447
+			$p = $prefix.$name;
448 448
 			$cacheDirTarget = $this->cacheDirTarget;
449 449
 			$this->cacheDirTarget = $this->convEncIn($target, true);
450 450
 			if ($tstat = $this->stat($target)) {
@@ -453,12 +453,12 @@  discard block
 block discarded – undo
453 453
 				$stat['thash'] = $tstat['hash'];
454 454
 				$stat['mime']  = $tstat['mime'];
455 455
 				$stat['read']  = $tstat['read'];
456
-				$stat['write']  = $tstat['write'];
456
+				$stat['write'] = $tstat['write'];
457 457
 				
458
-				if (isset($tstat['ts']))      { $stat['ts']      = $tstat['ts']; }
459
-				if (isset($tstat['owner']))   { $stat['owner']   = $tstat['owner']; }
460
-				if (isset($tstat['group']))   { $stat['group']   = $tstat['group']; }
461
- 				if (isset($tstat['perm']))    { $stat['perm']    = $tstat['perm']; }
458
+				if (isset($tstat['ts'])) { $stat['ts']      = $tstat['ts']; }
459
+				if (isset($tstat['owner'])) { $stat['owner']   = $tstat['owner']; }
460
+				if (isset($tstat['group'])) { $stat['group']   = $tstat['group']; }
461
+ 				if (isset($tstat['perm'])) { $stat['perm']    = $tstat['perm']; }
462 462
  				if (isset($tstat['isowner'])) { $stat['isowner'] = $tstat['isowner']; }
463 463
 			} else {
464 464
 				
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 		$comps = $new_comps;
572 572
 		$path = implode($this->separator, $comps);
573 573
 		if ($initial_slashes) {
574
-			$path = str_repeat($this->separator, $initial_slashes) . $path;
574
+			$path = str_repeat($this->separator, $initial_slashes).$path;
575 575
 		}
576 576
 		
577 577
 		return $path ? $path : '.';
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 	 * @author Dmitry (dio) Levashov
638 638
 	 **/
639 639
 	protected function _inpath($path, $parent) {
640
-		return $path == $parent || strpos($path, $parent. $this->separator) === 0;
640
+		return $path == $parent || strpos($path, $parent.$this->separator) === 0;
641 641
 	}
642 642
 	
643 643
 	/***************** file stat ********************/
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 		}
670 670
 		if (!$this->MLSTsupprt) {
671 671
 			//if ($path == $this->root && (empty($this->ARGS['reload']) || !isset($this->ARGS['target']) || strpos($this->ARGS['target'], $this->id) !== 0)) {
672
-			if ($path == $this->root && ! $this->isMyReload()) {
672
+			if ($path == $this->root && !$this->isMyReload()) {
673 673
 				return array(
674 674
 					'name' => $this->root,
675 675
 					'mime' => 'directory',
@@ -677,9 +677,9 @@  discard block
 block discarded – undo
677 677
 				);
678 678
 			}
679 679
 			$this->cacheDir($this->convEncOut($this->_dirname($path)));
680
-			return $this->convEncIn(isset($this->cache[$outPath])? $this->cache[$outPath] : array());
680
+			return $this->convEncIn(isset($this->cache[$outPath]) ? $this->cache[$outPath] : array());
681 681
 		}
682
-		$raw = ftp_raw($this->connect, 'MLST ' . $path);
682
+		$raw = ftp_raw($this->connect, 'MLST '.$path);
683 683
 		if (is_array($raw) && count($raw) > 1 && substr(trim($raw[0]), 0, 1) == 2) {
684 684
 			$parts = explode(';', trim($raw[1]));
685 685
 			array_pop($parts);
@@ -709,8 +709,8 @@  discard block
 block discarded – undo
709 709
 
710 710
 					case 'perm':
711 711
 						$val = strtolower($val);
712
-						$stat['read']  = (int)preg_match('/e|l|r/', $val);
713
-						$stat['write'] = (int)preg_match('/w|m|c/', $val);
712
+						$stat['read']  = (int) preg_match('/e|l|r/', $val);
713
+						$stat['write'] = (int) preg_match('/w|m|c/', $val);
714 714
 						if (!preg_match('/f|d/', $val)) {
715 715
 							$stat['locked'] = 1;
716 716
 						}
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 			if (!$this->ftpOsUnix) {
796 796
 				$info = $this->normalizeRawWindows($str);
797 797
 			}
798
-			$name = isset($info[8])? trim($info[8]) : '';
798
+			$name = isset($info[8]) ? trim($info[8]) : '';
799 799
 			if ($name && $name !== '.' && $name !== '..' && substr(strtolower($info[0]), 0, 1) === 'd') {
800 800
 				return true;
801 801
 			}
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 	 * @return resource|false
851 851
 	 * @author Dmitry (dio) Levashov
852 852
 	 **/
853
-	protected function _fopen($path, $mode='rb') {
853
+	protected function _fopen($path, $mode = 'rb') {
854 854
 		// try ftp stream wrapper
855 855
 		if (ini_get('allow_url_fopen')) {
856 856
 			$url = 'ftp://'.$this->options['user'].':'.$this->options['pass'].'@'.$this->options['host'].':'.$this->options['port'].$path;
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	 * @return bool
888 888
 	 * @author Dmitry (dio) Levashov
889 889
 	 **/
890
-	protected function _fclose($fp, $path='') {
890
+	protected function _fclose($fp, $path = '') {
891 891
 		@fclose($fp);
892 892
 		if ($path) {
893 893
 			@unlink($this->getTempFile($path));
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 			if (@file_put_contents($local, $content, LOCK_EX) !== false
1063 1063
 			&& ($fp = @fopen($local, 'rb'))) {
1064 1064
 				clearstatcache();
1065
-				$res  = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path));
1065
+				$res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path));
1066 1066
 				@fclose($fp);
1067 1067
 			}
1068 1068
 			file_exists($local) && @unlink($local);
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 	 * @return bool
1088 1088
 	 **/
1089 1089
 	protected function _chmod($path, $mode) {
1090
-		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode));
1090
+		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode));
1091 1091
 		return @ftp_chmod($this->connect, $modeOct, $path);
1092 1092
 	}
1093 1093
 
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 		}
1141 1141
 
1142 1142
 		$basename = $this->_basename($path);
1143
-		$localPath = $dir . DIRECTORY_SEPARATOR . $basename;
1143
+		$localPath = $dir.DIRECTORY_SEPARATOR.$basename;
1144 1144
 
1145 1145
 		if (!ftp_get($this->connect, $localPath, $path, FTP_BINARY)) {
1146 1146
 			//cleanup
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 		
1178 1178
 		// archive contains one item - extract in archive dir
1179 1179
 		$name = '';
1180
-		$src = $dir . DIRECTORY_SEPARATOR . $filesToProcess[0];
1180
+		$src = $dir.DIRECTORY_SEPARATOR.$filesToProcess[0];
1181 1181
 		if (($extractTo === 'auto' || !$extractTo) && count($filesToProcess) === 1 && is_file($src)) {
1182 1182
 			$name = $filesToProcess[0];
1183 1183
 		} else if ($extractTo === 'auto' || $extractTo) {
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 			$src = $dir;
1187 1187
 			$name = basename($path);
1188 1188
 			if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
1189
-				$name = substr($name, 0,  strlen($name)-strlen($m[0]));
1189
+				$name = substr($name, 0, strlen($name) - strlen($m[0]));
1190 1190
 			}
1191 1191
 			$test = $this->_joinPath(dirname($path), $name);
1192 1192
 			if ($this->stat($test)) {
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 		if ($name !== '' && is_file($src)) {
1198 1198
 			$result = $this->_joinPath(dirname($path), $name);
1199 1199
 
1200
-			if (! ftp_put($this->connect, $result, $src, FTP_BINARY)) {
1200
+			if (!ftp_put($this->connect, $result, $src, FTP_BINARY)) {
1201 1201
 				$this->rmdirRecursive($dir);
1202 1202
 				return false;
1203 1203
 			}
@@ -1211,19 +1211,19 @@  discard block
 block discarded – undo
1211 1211
 				}
1212 1212
 				$result[] = $dstDir;
1213 1213
 			}
1214
-			foreach($filesToProcess as $name) {
1214
+			foreach ($filesToProcess as $name) {
1215 1215
 				$name = rtrim($name, DIRECTORY_SEPARATOR);
1216
-				$src = $dir . DIRECTORY_SEPARATOR . $name;
1216
+				$src = $dir.DIRECTORY_SEPARATOR.$name;
1217 1217
 				if (is_dir($src)) {
1218 1218
 					$p = dirname($name);
1219 1219
 					$name = basename($name);
1220
-					if (! $target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) {
1220
+					if (!$target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) {
1221 1221
 						$this->rmdirRecursive($dir);
1222 1222
 						return false;
1223 1223
 					}
1224 1224
 				} else {
1225 1225
 					$target = $this->_joinPath($dstDir, $name);
1226
-					if (! ftp_put($this->connect, $target, $src, FTP_BINARY)) {
1226
+					if (!ftp_put($this->connect, $target, $src, FTP_BINARY)) {
1227 1227
 						$this->rmdirRecursive($dir);
1228 1228
 						return false;
1229 1229
 					}
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
 		is_dir($dir) && $this->rmdirRecursive($dir);
1240 1240
 		
1241 1241
 		$this->clearcache();
1242
-		return $result? $result : false;
1242
+		return $result ? $result : false;
1243 1243
 	}
1244 1244
 
1245 1245
 	/**
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
 		}
1280 1280
 
1281 1281
 		//cleanup
1282
-		if(!$this->rmdirRecursive($tmpDir)) {
1282
+		if (!$this->rmdirRecursive($tmpDir)) {
1283 1283
 			return false;
1284 1284
 		}
1285 1285
 
@@ -1383,7 +1383,7 @@  discard block
 block discarded – undo
1383 1383
 		$remoteDirLen = strlen($remote_directory);
1384 1384
 		foreach ($contents as $item) {
1385 1385
 			$relative_path = substr($item['path'], $remoteDirLen);
1386
-			$local_path = $dest_local_directory . DIRECTORY_SEPARATOR . $relative_path;
1386
+			$local_path = $dest_local_directory.DIRECTORY_SEPARATOR.$relative_path;
1387 1387
 			switch ($item['type']) {
1388 1388
 				case 'd':
1389 1389
 					$success = mkdir($local_path);
@@ -1414,8 +1414,8 @@  discard block
 block discarded – undo
1414 1414
 		} else {
1415 1415
 			$success = true;
1416 1416
 			foreach (array_reverse(elFinderVolumeFTP::listFilesInDirectory($dirPath, false)) as $path) {
1417
-				$path = $dirPath . DIRECTORY_SEPARATOR . $path;
1418
-				if(is_link($path)) {
1417
+				$path = $dirPath.DIRECTORY_SEPARATOR.$path;
1418
+				if (is_link($path)) {
1419 1419
 					unlink($path);
1420 1420
 				} else if (is_dir($path)) {
1421 1421
 					$success = rmdir($path);
@@ -1426,11 +1426,11 @@  discard block
 block discarded – undo
1426 1426
 					break;
1427 1427
 				}
1428 1428
 			}
1429
-			if($success) {
1429
+			if ($success) {
1430 1430
 				$success = rmdir($dirPath);
1431 1431
 			}
1432 1432
 		}
1433
-		if(!$success) {
1433
+		if (!$success) {
1434 1434
 			$this->setError(elFinder::ERROR_RM, $dirPath);
1435 1435
 			return false;
1436 1436
 		}
@@ -1452,25 +1452,25 @@  discard block
 block discarded – undo
1452 1452
 		if (!is_dir($dir)) {
1453 1453
 			return false;
1454 1454
 		}
1455
-		$excludes = array(".","..");
1455
+		$excludes = array(".", "..");
1456 1456
 		$result = array();
1457 1457
 		$files = scandir($dir);
1458
-		if(!$files) {
1458
+		if (!$files) {
1459 1459
 			return array();
1460 1460
 		}
1461
-		foreach($files as $file) {
1462
-			if(!in_array($file, $excludes)) {
1461
+		foreach ($files as $file) {
1462
+			if (!in_array($file, $excludes)) {
1463 1463
 				$path = $dir.DIRECTORY_SEPARATOR.$file;
1464
-				if(is_link($path)) {
1465
-					if($omitSymlinks) {
1464
+				if (is_link($path)) {
1465
+					if ($omitSymlinks) {
1466 1466
 						continue;
1467 1467
 					} else {
1468 1468
 						$result[] = $prefix.$file;
1469 1469
 					}
1470
-				} else if(is_dir($path)) {
1470
+				} else if (is_dir($path)) {
1471 1471
 					$result[] = $prefix.$file.DIRECTORY_SEPARATOR;
1472 1472
 					$subs = elFinderVolumeFTP::listFilesInDirectory($path, $omitSymlinks, $prefix.$file.DIRECTORY_SEPARATOR);
1473
-					if($subs) {
1473
+					if ($subs) {
1474 1474
 						$result = array_merge($result, $subs);
1475 1475
 					}
1476 1476
 					
Please login to merge, or discard this patch.
php/elFinder.class.php 1 patch
Spacing   +163 added lines, -163 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,17 +247,17 @@  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
-	const ERROR_SEARCH_TIMEOUT    = 'errSearchTimeout';    // 'Timed out while searching "$1". Search result is partial.'
260
+	const ERROR_SEARCH_TIMEOUT = 'errSearchTimeout'; // 'Timed out while searching "$1". Search result is partial.'
261 261
 
262 262
 	/**
263 263
 	 * Constructor
@@ -284,17 +284,17 @@  discard block
 block discarded – undo
284 284
 		
285 285
 		$this->time  = $this->utime();
286 286
 		$this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false);
287
-		$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier'])? (bool)$opts['sessionCloseEarlier'] : true;
287
+		$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier']) ? (bool) $opts['sessionCloseEarlier'] : true;
288 288
 		$this->sessionUseCmds = array_flip($sessionUseCmds);
289 289
 		$this->timeout = (isset($opts['timeout']) ? $opts['timeout'] : 0);
290 290
 		$this->uploadTempPath = (isset($opts['uploadTempPath']) ? $opts['uploadTempPath'] : '');
291
-		$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey'])? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
291
+		$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey']) ? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
292 292
 		$this->callbackWindowURL = (isset($opts['callbackWindowURL']) ? $opts['callbackWindowURL'] : '');
293 293
 		self::$sessionCacheKey = !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches';
294 294
 		
295 295
 		// check session cache
296 296
 		$_optsMD5 = md5(json_encode($opts['roots']));
297
-		if (! isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) {
297
+		if (!isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) {
298 298
 			$_SESSION[self::$sessionCacheKey] = array(
299 299
 				'_optsMD5' => $_optsMD5
300 300
 			);
@@ -313,20 +313,20 @@  discard block
 block discarded – undo
313 313
 			$_reqCmd = isset($_req['cmd']) ? $_req['cmd'] : '';
314 314
 			foreach ($opts['bind'] as $cmd => $handlers) {
315 315
 				$doRegist = (strpos($cmd, '*') !== false);
316
-				if (! $doRegist) {
316
+				if (!$doRegist) {
317 317
 					$_getcmd = create_function('$cmd', 'list($ret) = explode(\'.\', $cmd);return trim($ret);');
318 318
 					$doRegist = ($_reqCmd && in_array($_reqCmd, array_map($_getcmd, explode(' ', $cmd))));
319 319
 				}
320 320
 				if ($doRegist) {
321
-					if (! is_array($handlers) || is_object($handlers[0])) {
321
+					if (!is_array($handlers) || is_object($handlers[0])) {
322 322
 						$handlers = array($handlers);
323 323
 					}
324
-					foreach($handlers as $handler) {
324
+					foreach ($handlers as $handler) {
325 325
 						if ($handler) {
326 326
 							if (is_string($handler) && strpos($handler, '.')) {
327 327
 								list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, '');
328 328
 								if (strcasecmp($_domain, 'plugin') === 0) {
329
-									if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name])? $opts['plugin'][$_name] : array())
329
+									if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name]) ? $opts['plugin'][$_name] : array())
330 330
 											and method_exists($plugin, $_method)) {
331 331
 										$this->bind($cmd, array($plugin, $_method));
332 332
 									}
@@ -413,13 +413,13 @@  discard block
 block discarded – undo
413 413
 	public function bind($cmd, $handler) {
414 414
 		$allCmds = array_keys($this->commands);
415 415
 		$cmds = array();
416
-		foreach(explode(' ', $cmd) as $_cmd) {
416
+		foreach (explode(' ', $cmd) as $_cmd) {
417 417
 			if ($_cmd !== '') {
418 418
 				if ($all = strpos($_cmd, '*') !== false) {
419 419
 					list(, $sub) = array_pad(explode('.', $_cmd), 2, '');
420 420
 					if ($sub) {
421 421
 						$sub = str_replace('\'', '\\\'', $sub);
422
-						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\'' . $sub . '\');');
422
+						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\''.$sub.'\');');
423 423
 						$cmds = array_merge($cmds, array_map($addSub, $allCmds));
424 424
 					} else {
425 425
 						$cmds = array_merge($cmds, $allCmds);
@@ -499,16 +499,16 @@  discard block
 block discarded – undo
499 499
 
500 500
 	private function session_expires() {
501 501
 		
502
-		if (!isset($_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'])) {
503
-			$_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time();
502
+		if (!isset($_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'])) {
503
+			$_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time();
504 504
 			return false;
505 505
 		}
506 506
 
507
-		if ( ($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] > $this->timeout) ) {
507
+		if (($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] > $this->timeout)) {
508 508
 			return true;
509 509
 		}
510 510
 
511
-		$_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time();
511
+		$_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time();
512 512
 		return false;	
513 513
 	}
514 514
 	
@@ -541,9 +541,9 @@  discard block
 block discarded – undo
541 541
 		}
542 542
 
543 543
 		// call pre handlers for this command
544
-		$args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd])? false : $this->sessionCloseEarlier;
544
+		$args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd]) ? false : $this->sessionCloseEarlier;
545 545
 		if (!empty($this->listeners[$cmd.'.pre'])) {
546
-			$volume = isset($args['target'])? $this->volume($args['target']) : false;
546
+			$volume = isset($args['target']) ? $this->volume($args['target']) : false;
547 547
 			foreach ($this->listeners[$cmd.'.pre'] as $handler) {
548 548
 				call_user_func_array($handler, array($cmd, &$args, $this, $volume));
549 549
 			}
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 		// unlock session data for multiple access
553 553
 		$this->sessionCloseEarlier && $args['sessionCloseEarlier'] && session_id() && session_write_close();
554 554
 		
555
-		if (substr(PHP_OS,0,3) === 'WIN') {
555
+		if (substr(PHP_OS, 0, 3) === 'WIN') {
556 556
 			// set time out
557 557
 			if (($_max_execution_time = ini_get('max_execution_time')) && $_max_execution_time < 300) {
558 558
 				@set_time_limit(300);
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 		// call handlers for this command
572 572
 		if (!empty($this->listeners[$cmd])) {
573 573
 			foreach ($this->listeners[$cmd] as $handler) {
574
-				if (call_user_func_array($handler,array($cmd,&$result,$args,$this))) {
574
+				if (call_user_func_array($handler, array($cmd, &$result, $args, $this))) {
575 575
 					// handler return true to force sync client after command completed
576 576
 					$result['sync'] = true;
577 577
 				}
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 	 * @return string
631 631
 	 * @author Dmitry (dio) Levashov
632 632
 	 **/
633
-	public function realpath($hash)	{
633
+	public function realpath($hash) {
634 634
 		if (($volume = $this->volume($hash)) == false) {
635 635
 			return false;
636 636
 		}
@@ -686,11 +686,11 @@  discard block
 block discarded – undo
686 686
 	 */
687 687
 	protected function getPluginInstance($name, $opts = array()) {
688 688
 		$key = strtolower($name);
689
-		if (! isset($this->plugins[$key])) {
690
-			$p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php';
689
+		if (!isset($this->plugins[$key])) {
690
+			$p_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.'plugin.php';
691 691
 			if (is_file($p_file)) {
692 692
 				require_once $p_file;
693
-				$class = 'elFinderPlugin' . $name;
693
+				$class = 'elFinderPlugin'.$name;
694 694
 				$this->plugins[$key] = new $class($opts);
695 695
 			} else {
696 696
 				$this->plugins[$key] = false;
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
 		
788 788
 		$netVolumes = $this->getNetVolumes();
789 789
 		if ($volume->mount($options)) {
790
-			if (! $key = @ $volume->netMountKey) {
791
-				$key = md5($protocol . '-' . join('-', $options));
790
+			if (!$key = @ $volume->netMountKey) {
791
+				$key = md5($protocol.'-'.join('-', $options));
792 792
 			}
793 793
 			$options['driver'] = $driver;
794 794
 			$options['netkey'] = $key;
@@ -857,14 +857,14 @@  discard block
 block discarded – undo
857 857
 		}
858 858
 		// long polling mode
859 859
 		if ($args['compare']) {
860
-			$sleep = max(1, (int)$volume->getOption('lsPlSleep'));
861
-			$limit = max(1, (int)$volume->getOption('plStandby') / $sleep) + 1;
860
+			$sleep = max(1, (int) $volume->getOption('lsPlSleep'));
861
+			$limit = max(1, (int) $volume->getOption('plStandby')/$sleep) + 1;
862 862
 			$timelimit = ini_get('max_execution_time');
863 863
 			$compare = $args['compare'];
864 864
 			do {
865 865
 				$timelimit && @ set_time_limit($timelimit + $sleep);
866 866
 				$_mtime = 0;
867
-				foreach($ls as $_f) {
867
+				foreach ($ls as $_f) {
868 868
 					$_mtime = max($_mtime, $_f['ts']);
869 869
 				}
870 870
 				$compare = strval(count($ls)).':'.strval($_mtime);
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 						break;
879 879
 					}
880 880
 				}
881
-			} while($limit);
881
+			} while ($limit);
882 882
 			if ($ls === false) {
883 883
 				return array('error' => $this->error(self::ERROR_OPEN, $cwd['name'], $volume->error()));
884 884
 			}
@@ -1021,24 +1021,24 @@  discard block
 block discarded – undo
1021 1021
 		}
1022 1022
 
1023 1023
 		// allow change MIME type by 'file.pre' callback functions
1024
-		$mime = isset($args['mime'])? $args['mime'] : $file['mime'];
1024
+		$mime = isset($args['mime']) ? $args['mime'] : $file['mime'];
1025 1025
 		if ($download) {
1026 1026
 			$disp = 'attachment';
1027 1027
 		} else {
1028 1028
 			$dispInlineRegex = $volume->getOption('dispInlineRegex');
1029 1029
 			$inlineRegex = false;
1030 1030
 			if ($dispInlineRegex) {
1031
-				$inlineRegex = '#' . str_replace('#', '\\#', $dispInlineRegex) . '#';
1031
+				$inlineRegex = '#'.str_replace('#', '\\#', $dispInlineRegex).'#';
1032 1032
 				try {
1033 1033
 					preg_match($inlineRegex, '');
1034
-				} catch(Exception $e) {
1034
+				} catch (Exception $e) {
1035 1035
 					$inlineRegex = false;
1036 1036
 				}
1037 1037
 			}
1038 1038
 			if (!$inlineRegex) {
1039 1039
 				$inlineRegex = '#^(?:(?:image|text)|application/x-shockwave-flash$)#';
1040 1040
 			}
1041
-			$disp  = preg_match($inlineRegex, $mime)? 'inline' : 'attachment';
1041
+			$disp = preg_match($inlineRegex, $mime) ? 'inline' : 'attachment';
1042 1042
 		}
1043 1043
 		
1044 1044
 		$filenameEncoded = rawurlencode($file['name']);
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 		$name   = $args['name'];
1148 1148
 		
1149 1149
 		if (($volume = $this->volume($target)) == false
1150
-		||  ($rm  = $volume->file($target)) == false) {
1150
+		||  ($rm = $volume->file($target)) == false) {
1151 1151
 			return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND));
1152 1152
 		}
1153 1153
 		$rm['realpath'] = $volume->realpath($target);
@@ -1225,9 +1225,9 @@  discard block
 block discarded – undo
1225 1225
 	* @retval false  error
1226 1226
 	* @author Naoki Sawada
1227 1227
 	**/
1228
-	protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) {
1229
-		$method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; 
1230
-		return $this->$method( $url, $timeout, $redirect_max, $ua, $fp );
1228
+	protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) {
1229
+		$method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; 
1230
+		return $this->$method($url, $timeout, $redirect_max, $ua, $fp);
1231 1231
 	}
1232 1232
 	
1233 1233
 	/**
@@ -1243,26 +1243,26 @@  discard block
 block discarded – undo
1243 1243
 	 * @retval false  error
1244 1244
 	 * @author Naoki Sawada
1245 1245
 	 **/
1246
-	 protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){
1246
+	 protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1247 1247
 		$ch = curl_init();
1248
-		curl_setopt( $ch, CURLOPT_URL, $url );
1249
-		curl_setopt( $ch, CURLOPT_HEADER, false );
1248
+		curl_setopt($ch, CURLOPT_URL, $url);
1249
+		curl_setopt($ch, CURLOPT_HEADER, false);
1250 1250
 		if ($outfp) {
1251
-			curl_setopt( $ch, CURLOPT_FILE, $outfp );
1251
+			curl_setopt($ch, CURLOPT_FILE, $outfp);
1252 1252
 		} else {
1253
-			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1254
-			curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true );
1255
-		}
1256
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 );
1257
-		curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout );
1258
-		curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
1259
-		curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
1260
-		curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max);
1261
-		curl_setopt( $ch, CURLOPT_USERAGENT, $ua);
1262
-		$result = curl_exec( $ch );
1253
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1254
+			curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
1255
+		}
1256
+		curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);
1257
+		curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout);
1258
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1259
+		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
1260
+		curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max);
1261
+		curl_setopt($ch, CURLOPT_USERAGENT, $ua);
1262
+		$result = curl_exec($ch);
1263 1263
 		$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
1264
-		curl_close( $ch );
1265
-		return $outfp? $outfp : $result;
1264
+		curl_close($ch);
1265
+		return $outfp ? $outfp : $result;
1266 1266
 	}
1267 1267
 	
1268 1268
 	/**
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 	 * @retval false  error
1279 1279
 	 * @author Naoki Sawada
1280 1280
 	 */
1281
-	protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) {
1281
+	protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) {
1282 1282
 
1283 1283
 		$connect_timeout = 3;
1284 1284
 		$connect_try = 3;
@@ -1289,7 +1289,7 @@  discard block
 block discarded – undo
1289 1289
 		$headers = '';
1290 1290
 		
1291 1291
 		$arr = parse_url($url);
1292
-		if (!$arr){
1292
+		if (!$arr) {
1293 1293
 			// Bad request
1294 1294
 			return false;
1295 1295
 		}
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 		// query
1298 1298
 		$arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : '';
1299 1299
 		// port
1300
-		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80);
1300
+		$arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80);
1301 1301
 		
1302 1302
 		$url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port'];
1303 1303
 		$url_path = isset($arr['path']) ? $arr['path'] : '/';
@@ -1306,21 +1306,21 @@  discard block
 block discarded – undo
1306 1306
 		$query = $method.' '.$uri." HTTP/1.0\r\n";
1307 1307
 		$query .= "Host: ".$arr['host']."\r\n";
1308 1308
 		if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n";
1309
-		if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n";
1309
+		if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n";
1310 1310
 		
1311 1311
 		$query .= $headers;
1312 1312
 
1313 1313
 		$query .= "\r\n";
1314 1314
 
1315 1315
 		$fp = $connect_try_count = 0;
1316
-		while( !$fp && $connect_try_count < $connect_try ) {
1316
+		while (!$fp && $connect_try_count < $connect_try) {
1317 1317
 	
1318 1318
 			$errno = 0;
1319 1319
 			$errstr = "";
1320 1320
 			$fp = @ fsockopen(
1321 1321
 			$arr['https'].$arr['host'],
1322 1322
 			$arr['port'],
1323
-			$errno,$errstr,$connect_timeout);
1323
+			$errno, $errstr, $connect_timeout);
1324 1324
 			if ($fp) break;
1325 1325
 			$connect_try_count++;
1326 1326
 			if (connection_aborted()) {
@@ -1345,13 +1345,13 @@  discard block
 block discarded – undo
1345 1345
 		
1346 1346
 		$_response = '';
1347 1347
 		$header = '';
1348
-		while($_response !== "\r\n"){
1348
+		while ($_response !== "\r\n") {
1349 1349
 			$_response = fgets($fp, $readsize);
1350 1350
 			$header .= $_response;
1351 1351
 		};
1352 1352
 		
1353
-		$rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1354
-		$rc = (int)$rccd[1];
1353
+		$rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...')
1354
+		$rc = (int) $rccd[1];
1355 1355
 		
1356 1356
 		// Redirect
1357 1357
 		switch ($rc) {
@@ -1360,19 +1360,19 @@  discard block
 block discarded – undo
1360 1360
 			case 302: // Moved Temporarily
1361 1361
 			case 301: // Moved Permanently
1362 1362
 				$matches = array();
1363
-				if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) {
1363
+				if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) {
1364 1364
 					$url = trim($matches[1]);
1365
-					$hash = isset($matches[2])? trim($matches[2]) : '';
1366
-					if (!preg_match('/^https?:\//',$url)) { // no scheme
1365
+					$hash = isset($matches[2]) ? trim($matches[2]) : '';
1366
+					if (!preg_match('/^https?:\//', $url)) { // no scheme
1367 1367
 						if ($url{0} != '/') { // Relative path
1368 1368
 							// to Absolute path
1369
-							$url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url;
1369
+							$url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url;
1370 1370
 						}
1371 1371
 						// add sheme,host
1372 1372
 						$url = $url_base.$url;
1373 1373
 					}
1374 1374
 					fclose($fp);
1375
-					return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp );
1375
+					return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp);
1376 1376
 				}
1377 1377
 		}
1378 1378
 		
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 			$outfp = fopen('php://temp', 'rwb');
1382 1382
 			$body = true;
1383 1383
 		}
1384
-		while(fwrite($outfp, fread($fp, $readsize))) {
1384
+		while (fwrite($outfp, fread($fp, $readsize))) {
1385 1385
 			if ($timeout) {
1386 1386
 				$_status = socket_get_status($fp);
1387 1387
 				if ($_status['timed_out']) {
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 		
1401 1401
 		fclose($fp);
1402 1402
 		
1403
-		return $outfp? $outfp : $body; // Data
1403
+		return $outfp ? $outfp : $body; // Data
1404 1404
 	}
1405 1405
 	
1406 1406
 	/**
@@ -1411,13 +1411,13 @@  discard block
 block discarded – undo
1411 1411
 	 * @return array
1412 1412
 	 * @author Naoki Sawada
1413 1413
 	 */
1414
-	protected function parse_data_scheme( $str, $extTable ) {
1414
+	protected function parse_data_scheme($str, $extTable) {
1415 1415
 		$data = $name = '';
1416 1416
 		if ($fp = fopen('data://'.substr($str, 5), 'rb')) {
1417 1417
 			if ($data = stream_get_contents($fp)) {
1418 1418
 				$meta = stream_get_meta_data($fp);
1419
-				$ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : '';
1420
-				$name = substr(md5($data), 0, 8) . $ext;
1419
+				$ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : '';
1420
+				$name = substr(md5($data), 0, 8).$ext;
1421 1421
 			}
1422 1422
 			fclose($fp);
1423 1423
 		}
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
 			}
1482 1482
 		}
1483 1483
 		
1484
-		return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : '';
1484
+		return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : '';
1485 1485
 	}
1486 1486
 	
1487 1487
 	/**
@@ -1503,12 +1503,12 @@  discard block
 block discarded – undo
1503 1503
 			$testDirs[] = sys_get_temp_dir();
1504 1504
 		}
1505 1505
 		$tempDir = '';
1506
-		foreach($testDirs as $testDir) {
1506
+		foreach ($testDirs as $testDir) {
1507 1507
 			if (!$testDir || !is_dir($testDir)) continue;
1508 1508
 			if (is_writable($testDir)) {
1509 1509
 				$tempDir = $testDir;
1510 1510
 				$gc = time() - 3600;
1511
-				foreach(glob($tempDir . DIRECTORY_SEPARATOR .'ELF*') as $cf) {
1511
+				foreach (glob($tempDir.DIRECTORY_SEPARATOR.'ELF*') as $cf) {
1512 1512
 					if (filemtime($cf) < $gc) {
1513 1513
 						@unlink($cf);
1514 1514
 					}
@@ -1528,7 +1528,7 @@  discard block
 block discarded – undo
1528 1528
 	 **/
1529 1529
 	protected function chmod($args) {
1530 1530
 		$targets = $args['targets'];
1531
-		$mode    = intval((string)$args['mode'], 8);
1531
+		$mode    = intval((string) $args['mode'], 8);
1532 1532
 
1533 1533
 		if (!is_array($targets)) {
1534 1534
 			$targets = array($targets);
@@ -1543,10 +1543,10 @@  discard block
 block discarded – undo
1543 1543
 
1544 1544
 		$files = array();
1545 1545
 		$errors = array();
1546
-		foreach($targets as $target) {
1546
+		foreach ($targets as $target) {
1547 1547
 			$file = $volume->chmod($target, $mode);
1548 1548
 			if ($file) {
1549
-				$files = array_merge($files, is_array($file)? $file : array($file));
1549
+				$files = array_merge($files, is_array($file) ? $file : array($file));
1550 1550
 			} else {
1551 1551
 				$errors = array_merge($errors, $volume->error());
1552 1552
 			}
@@ -1577,26 +1577,26 @@  discard block
 block discarded – undo
1577 1577
 	private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) {
1578 1578
 		if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) {
1579 1579
 			$fname = $m[1];
1580
-			$encname = md5($cid . '_' . $fname);
1581
-			$base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname;
1580
+			$encname = md5($cid.'_'.$fname);
1581
+			$base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname;
1582 1582
 			$clast = intval($m[3]);
1583 1583
 			if (is_null($tmpname)) {
1584 1584
 				ignore_user_abort(true);
1585 1585
 				sleep(10); // wait 10 sec
1586 1586
 				// chunked file upload fail
1587
-				foreach(glob($base . '*') as $cf) {
1587
+				foreach (glob($base.'*') as $cf) {
1588 1588
 					@unlink($cf);
1589 1589
 				}
1590 1590
 				ignore_user_abort(false);
1591 1591
 				return;
1592 1592
 			}
1593 1593
 			
1594
-			$range = isset($_POST['range'])? trim($_POST['range']) : '';
1594
+			$range = isset($_POST['range']) ? trim($_POST['range']) : '';
1595 1595
 			if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) {
1596 1596
 				$start = $ranges[1];
1597 1597
 				$len   = $ranges[2];
1598 1598
 				$size  = $ranges[3];
1599
-				$tmp = $base . '.part';
1599
+				$tmp = $base.'.part';
1600 1600
 				$csize = filesize($tmpname);
1601 1601
 				
1602 1602
 				$tmpExists = is_file($tmp);
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
 				} else {
1623 1623
 					// wait until makeing temp file (for anothor session)
1624 1624
 					$cnt = 1200; // Time limit 120 sec
1625
-					while(!is_file($base) && --$cnt) {
1625
+					while (!is_file($base) && --$cnt) {
1626 1626
 						usleep(100000); // wait 100ms
1627 1627
 					}
1628 1628
 					if (!$cnt) {
@@ -1657,13 +1657,13 @@  discard block
 block discarded – undo
1657 1657
 				}
1658 1658
 			} else {
1659 1659
 				// old way
1660
-				$part = $base . $m[2];
1660
+				$part = $base.$m[2];
1661 1661
 				if (move_uploaded_file($tmpname, $part)) {
1662 1662
 					@chmod($part, 0600);
1663
-					if ($clast < count(glob($base . '*'))) {
1663
+					if ($clast < count(glob($base.'*'))) {
1664 1664
 						$parts = array();
1665 1665
 						for ($i = 0; $i <= $clast; $i++) {
1666
-							$name = $base . '.' . $i . '_' . $clast;
1666
+							$name = $base.'.'.$i.'_'.$clast;
1667 1667
 							if (is_readable($name)) {
1668 1668
 								$parts[] = $name;
1669 1669
 							} else {
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
 								touch($base);
1677 1677
 								if ($resfile = tempnam($tempDir, 'ELF')) {
1678 1678
 									$target = fopen($resfile, 'wb');
1679
-									foreach($parts as $f) {
1679
+									foreach ($parts as $f) {
1680 1680
 										$fp = fopen($f, 'rb');
1681 1681
 										while (!feof($fp)) {
1682 1682
 											fwrite($target, fread($fp, 8192));
@@ -1712,15 +1712,15 @@  discard block
 block discarded – undo
1712 1712
 		$files  = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array();
1713 1713
 		$header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8');
1714 1714
 		$result = array_merge(array('added' => array()), $header);
1715
-		$paths  = $args['upload_path']? $args['upload_path'] : array();
1716
-		$chunk  = $args['chunk']? $args['chunk'] : '';
1717
-		$cid    = $args['cid']? (int)$args['cid'] : '';
1715
+		$paths  = $args['upload_path'] ? $args['upload_path'] : array();
1716
+		$chunk  = $args['chunk'] ? $args['chunk'] : '';
1717
+		$cid    = $args['cid'] ? (int) $args['cid'] : '';
1718 1718
 		
1719
-		$renames= array();
1719
+		$renames = array();
1720 1720
 		$suffix = '~';
1721 1721
 		if ($args['renames'] && is_array($args['renames'])) {
1722 1722
 			$renames = array_flip($args['renames']);
1723
-			if (is_string($args['suffix']) && ! preg_match($ngReg, $args['suffix'])) {
1723
+			if (is_string($args['suffix']) && !preg_match($ngReg, $args['suffix'])) {
1724 1724
 				$suffix = $args['suffix'];
1725 1725
 			}
1726 1726
 		}
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 			if (!$args['upload'] && $args['name'] && is_array($args['name'])) {
1754 1754
 				$error = '';
1755 1755
 				$result['name'] = array();
1756
-				foreach($args['name'] as $_i => $_name) {
1756
+				foreach ($args['name'] as $_i => $_name) {
1757 1757
 					if (!$volume->isUploadableByName($_name)) {
1758 1758
 						$error = $this->error(self::ERROR_UPLOAD_FILE, $_name, self::ERROR_UPLOAD_FILE_MIME);
1759 1759
 						break;
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 			}
1775 1775
 			if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) {
1776 1776
 				$names = array();
1777
-				foreach($args['upload'] as $i => $url) {
1777
+				foreach ($args['upload'] as $i => $url) {
1778 1778
 					// check chunked file upload commit
1779 1779
 					if ($args['chunk']) {
1780 1780
 						if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') {
@@ -1784,7 +1784,7 @@  discard block
 block discarded – undo
1784 1784
 							}
1785 1785
 							return $result;
1786 1786
 						} else {
1787
-							$tmpfname = $tempDir . '/' . $args['chunk'];
1787
+							$tmpfname = $tempDir.'/'.$args['chunk'];
1788 1788
 							$files['tmp_name'][$i] = $tmpfname;
1789 1789
 							$files['name'][$i] = $url;
1790 1790
 							$files['error'][$i] = 0;
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
 						}
1794 1794
 					}
1795 1795
 					
1796
-					$tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true));
1796
+					$tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true));
1797 1797
 					
1798 1798
 					$_name = '';
1799 1799
 					// check is data:
@@ -1829,8 +1829,8 @@  discard block
 block discarded – undo
1829 1829
 								list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, '');
1830 1830
 								if ($_b === '') {
1831 1831
 									if ($_ext) {
1832
-										rename($tmpfname, $tmpfname . $_ext);
1833
-										$tmpfname = $tmpfname . $_ext;
1832
+										rename($tmpfname, $tmpfname.$_ext);
1833
+										$tmpfname = $tmpfname.$_ext;
1834 1834
 									}
1835 1835
 									$_b = $this->detectFileExtension($tmpfname);
1836 1836
 									$_name = $_a.$_b;
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
 			}
1866 1866
 			
1867 1867
 			$tmpname = $files['tmp_name'][$i];
1868
-			$path = ($paths && !empty($paths[$i]))? $paths[$i] : '';
1868
+			$path = ($paths && !empty($paths[$i])) ? $paths[$i] : '';
1869 1869
 			if ($name === 'blob') {
1870 1870
 				if ($chunk) {
1871 1871
 					if ($tempDir = $this->getTempDir($volume->getTempPath())) {
@@ -1875,7 +1875,7 @@  discard block
 block discarded – undo
1875 1875
 								preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m);
1876 1876
 								$result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname);
1877 1877
 								$result['_chunkfailure'] = true;
1878
-								$this->uploadDebug = 'Upload error: ' . $tmpname;
1878
+								$this->uploadDebug = 'Upload error: '.$tmpname;
1879 1879
 							} else if ($name) {
1880 1880
 								$result['_chunkmerged'] = basename($tmpname);
1881 1881
 								$result['_name'] = $name;
@@ -1889,14 +1889,14 @@  discard block
 block discarded – undo
1889 1889
 				} else {
1890 1890
 					// for form clipboard with Google Chrome
1891 1891
 					$type = $files['type'][$i];
1892
-					$ext = isset($extTable[$type])? '.' . $extTable[$type] : '';
1893
-					$name = substr(md5(basename($tmpname)), 0, 8) . $ext;
1892
+					$ext = isset($extTable[$type]) ? '.'.$extTable[$type] : '';
1893
+					$name = substr(md5(basename($tmpname)), 0, 8).$ext;
1894 1894
 				}
1895 1895
 			}
1896 1896
 			
1897 1897
 			// do hook function 'upload.presave'
1898
-			if (! empty($this->listeners['upload.presave'])) {
1899
-				foreach($this->listeners['upload.presave'] as $handler) {
1898
+			if (!empty($this->listeners['upload.presave'])) {
1899
+				foreach ($this->listeners['upload.presave'] as $handler) {
1900 1900
 					call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume));
1901 1901
 				}
1902 1902
 			}
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
 			if (($fp = fopen($tmpname, 'rb')) == false) {
1905 1905
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER);
1906 1906
 				$this->uploadDebug = 'Upload error: unable open tmp file';
1907
-				if (! is_uploaded_file($tmpname)) {
1907
+				if (!is_uploaded_file($tmpname)) {
1908 1908
 					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]);
1909 1909
 					continue;
1910 1910
 				}
@@ -1926,18 +1926,18 @@  discard block
 block discarded – undo
1926 1926
 					}
1927 1927
 				}
1928 1928
 			}
1929
-			if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1929
+			if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) {
1930 1930
 				$result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error());
1931 1931
 				fclose($fp);
1932
-				if (! is_uploaded_file($tmpname)) {
1933
-					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);;
1932
+				if (!is_uploaded_file($tmpname)) {
1933
+					if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ;
1934 1934
 					continue;
1935 1935
 				}
1936 1936
 				break;
1937 1937
 			}
1938 1938
 			
1939 1939
 			is_resource($fp) && fclose($fp);
1940
-			if (! is_uploaded_file($tmpname)){
1940
+			if (!is_uploaded_file($tmpname)) {
1941 1941
 				clearstatcache();
1942 1942
 				if (!is_file($tmpname) || @ unlink($tmpname)) {
1943 1943
 					unset($GLOBALS['elFinderTempFiles'][$tmpname]);
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
 			}
1950 1950
 		}
1951 1951
 		if ($GLOBALS['elFinderTempFiles']) {
1952
-			foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1952
+			foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) {
1953 1953
 				@ unlink($_temp);
1954 1954
 			}
1955 1955
 		}
@@ -1986,7 +1986,7 @@  discard block
 block discarded – undo
1986 1986
 		$suffix = '~';
1987 1987
 		if (!empty($args['renames'])) {
1988 1988
 			$renames = array_flip($args['renames']);
1989
-			if (is_string($args['suffix']) && ! preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1989
+			if (is_string($args['suffix']) && !preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) {
1990 1990
 				$suffix = $args['suffix'];
1991 1991
 			}
1992 1992
 		}
@@ -2044,9 +2044,9 @@  discard block
 block discarded – undo
2044 2044
 		}
2045 2045
 		
2046 2046
 		if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
2047
-			$mime = isset($file['mime'])? $file['mime'] : '';
2047
+			$mime = isset($file['mime']) ? $file['mime'] : '';
2048 2048
 			if ($mime && strtolower(substr($mime, 0, 4)) === 'text') {
2049
-				if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) {
2049
+				if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) {
2050 2050
 					if (strtolower($enc) !== 'utf-8') {
2051 2051
 						$content = mb_convert_encoding($content, 'UTF-8', $enc);
2052 2052
 					}
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
 
2059 2059
 		if ($json === false || strlen($json) < strlen($content)) {
2060 2060
 			if ($args['conv']) {
2061
-				return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
2061
+				return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
2062 2062
 			} else {
2063 2063
 				return array('doconv' => true);
2064 2064
 			}
@@ -2100,7 +2100,7 @@  discard block
 block discarded – undo
2100 2100
 		$target = $args['target'];
2101 2101
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2102 2102
 		$error  = array(self::ERROR_EXTRACT, '#'.$target);
2103
-		$makedir = isset($args['makedir'])? (bool)$args['makedir'] : null;
2103
+		$makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null;
2104 2104
 
2105 2105
 		if (($volume = $this->volume($target)) == false
2106 2106
 		|| ($file = $volume->file($target)) == false) {
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
 		}  
2109 2109
 
2110 2110
 		return ($file = $volume->extract($target, $makedir))
2111
-			? array('added' => isset($file['read'])? array($file) : $file)
2111
+			? array('added' => isset($file['read']) ? array($file) : $file)
2112 2112
 			: array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error()));
2113 2113
 	}
2114 2114
 	
@@ -2123,7 +2123,7 @@  discard block
 block discarded – undo
2123 2123
 	protected function archive($args) {
2124 2124
 		$type    = $args['type'];
2125 2125
 		$targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array();
2126
-		$name    = isset($args['name'])? $args['name'] : '';
2126
+		$name    = isset($args['name']) ? $args['name'] : '';
2127 2127
 	
2128 2128
 		if (($volume = $this->volume($targets[0])) == false) {
2129 2129
 			return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND);
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
 	protected function search($args) {
2145 2145
 		$q      = trim($args['q']);
2146 2146
 		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
2147
-		$target = !empty($args['target'])? $args['target'] : null;
2147
+		$target = !empty($args['target']) ? $args['target'] : null;
2148 2148
 		$result = array();
2149 2149
 		$errors = array();
2150 2150
 
@@ -2183,7 +2183,7 @@  discard block
 block discarded – undo
2183 2183
 			$compare = intval($args['compare']);
2184 2184
 			$hash = $args['targets'][0];
2185 2185
 			if ($volume = $this->volume($hash)) {
2186
-				$standby = (int)$volume->getOption('plStandby');
2186
+				$standby = (int) $volume->getOption('plStandby');
2187 2187
 				$_compare = false;
2188 2188
 				if (($syncCheckFunc = $volume->getOption('syncCheckFunc')) && is_callable($syncCheckFunc)) {
2189 2189
 					$_compare = call_user_func_array($syncCheckFunc, array($volume->realpath($hash), $standby, $compare, $volume, $this));
@@ -2191,8 +2191,8 @@  discard block
 block discarded – undo
2191 2191
 				if ($_compare !== false) {
2192 2192
 					$compare = $_compare;
2193 2193
 				} else {
2194
-					$sleep = max(1, (int)$volume->getOption('tsPlSleep'));
2195
-					$limit = max(1, $standby / $sleep) + 1;
2194
+					$sleep = max(1, (int) $volume->getOption('tsPlSleep'));
2195
+					$limit = max(1, $standby/$sleep) + 1;
2196 2196
 					$timelimit = ini_get('max_execution_time');
2197 2197
 					do {
2198 2198
 						$timelimit && @ set_time_limit($timelimit + $sleep);
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
 						if (--$limit) {
2210 2210
 							sleep($sleep);
2211 2211
 						}
2212
-					} while($limit);
2212
+					} while ($limit);
2213 2213
 				}
2214 2214
 			}
2215 2215
 		} else {
@@ -2257,12 +2257,12 @@  discard block
 block discarded – undo
2257 2257
 		$target = $args['target'];
2258 2258
 		$width  = $args['width'];
2259 2259
 		$height = $args['height'];
2260
-		$x      = (int)$args['x'];
2261
-		$y      = (int)$args['y'];
2260
+		$x      = (int) $args['x'];
2261
+		$y      = (int) $args['y'];
2262 2262
 		$mode   = $args['mode'];
2263 2263
 		$bg     = null;
2264
-		$degree = (int)$args['degree'];
2265
-		$quality= (int)$args['quality'];
2264
+		$degree = (int) $args['degree'];
2265
+		$quality = (int) $args['quality'];
2266 2266
 		
2267 2267
 		if (($volume = $this->volume($target)) == false
2268 2268
 		|| ($file = $volume->file($target)) == false) {
@@ -2283,7 +2283,7 @@  discard block
 block discarded – undo
2283 2283
 	**/
2284 2284
 	protected function url($args) {
2285 2285
 		$target = $args['target'];
2286
-		$options = isset($args['options'])? $args['options'] : array();
2286
+		$options = isset($args['options']) ? $args['options'] : array();
2287 2287
 		if (($volume = $this->volume($target)) != false) {
2288 2288
 			$url = $volume->getContentUrl($target, $options);
2289 2289
 			return $url ? array('url' => $url) : array();
@@ -2300,18 +2300,18 @@  discard block
 block discarded – undo
2300 2300
 	 */
2301 2301
 	protected function callback($args) {
2302 2302
 		$checkReg = '/[^a-zA-Z0-9;._-]/';
2303
-		$node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : '';
2304
-		$json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}';
2305
-		$bind  = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : '';
2303
+		$node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : '';
2304
+		$json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}';
2305
+		$bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : '';
2306 2306
 		$done = (!empty($args['done']));
2307 2307
 		
2308
-		while( ob_get_level() ) {
2309
-			if (! ob_end_clean()) {
2308
+		while (ob_get_level()) {
2309
+			if (!ob_end_clean()) {
2310 2310
 				break;
2311 2311
 			}
2312 2312
 		}
2313 2313
 		
2314
-		if ($done || ! $this->callbackWindowURL) {
2314
+		if ($done || !$this->callbackWindowURL) {
2315 2315
 			$script = '';
2316 2316
 			if ($node) {
2317 2317
 				$script .= '
@@ -2353,13 +2353,13 @@  discard block
 block discarded – undo
2353 2353
 			
2354 2354
 		} else {
2355 2355
 			$url = $this->callbackWindowURL;
2356
-			$url .= ((strpos($url, '?') === false)? '?' : '&')
2357
-				 . '&node=' . rawurlencode($node)
2358
-				 . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '')
2359
-				 . ($bind? ('&bind=' .  rawurlencode($bind)) : '')
2356
+			$url .= ((strpos($url, '?') === false) ? '?' : '&')
2357
+				 . '&node='.rawurlencode($node)
2358
+				 . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '')
2359
+				 . ($bind ? ('&bind='.rawurlencode($bind)) : '')
2360 2360
 				 . '&done=1';
2361 2361
 			
2362
-			header('Location: ' . $url);
2362
+			header('Location: '.$url);
2363 2363
 			
2364 2364
 		}
2365 2365
 		exit();
@@ -2429,7 +2429,7 @@  discard block
 block discarded – undo
2429 2429
 	
2430 2430
 	protected function utime() {
2431 2431
 		$time = explode(" ", microtime());
2432
-		return (double)$time[1] + (double)$time[0];
2432
+		return (double) $time[1] + (double) $time[0];
2433 2433
 	}
2434 2434
 	
2435 2435
 	
@@ -2455,7 +2455,7 @@  discard block
 block discarded – undo
2455 2455
 		$imgcnt = 0;
2456 2456
 		$fp = fopen($path, 'rb');
2457 2457
 		@fread($fp, 4);
2458
-		$c = @fread($fp,1);
2458
+		$c = @fread($fp, 1);
2459 2459
 		if (ord($c) != 0x39) {  // GIF89a
2460 2460
 			return false;
2461 2461
 		}
@@ -2463,13 +2463,13 @@  discard block
 block discarded – undo
2463 2463
 		while (!feof($fp)) {
2464 2464
 			do {
2465 2465
 				$c = fread($fp, 1);
2466
-			} while(ord($c) != 0x21 && !feof($fp));
2466
+			} while (ord($c) != 0x21 && !feof($fp));
2467 2467
 	
2468 2468
 			if (feof($fp)) {
2469 2469
 				break;
2470 2470
 			}
2471 2471
 	
2472
-			$c2 = fread($fp,2);
2472
+			$c2 = fread($fp, 2);
2473 2473
 			if (bin2hex($c2) == "f904") {
2474 2474
 				$imgcnt++;
2475 2475
 			}
Please login to merge, or discard this patch.