Completed
Push — 2.x ( 33f847...aa5803 )
by Naoki
04:36
created
php/elFinderVolumeDriver.class.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Base class for elFinder volume.
4
- * Provide 2 layers:
5
- *  1. Public API (commands)
6
- *  2. abstract fs API
7
- *
8
- * All abstract methods begin with "_"
9
- *
10
- * @author Dmitry (dio) Levashov
11
- * @author Troex Nevelin
12
- * @author Alexey Sukhotin
13
- **/
3
+	 * Base class for elFinder volume.
4
+	 * Provide 2 layers:
5
+	 *  1. Public API (commands)
6
+	 *  2. abstract fs API
7
+	 *
8
+	 * All abstract methods begin with "_"
9
+	 *
10
+	 * @author Dmitry (dio) Levashov
11
+	 * @author Troex Nevelin
12
+	 * @author Alexey Sukhotin
13
+	 **/
14 14
 abstract class elFinderVolumeDriver {
15 15
 	
16 16
 	/**
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 		'mimefile'        => '',
193 193
 		// mime type normalize map : Array '[ext]:[detected mime type]' => '[normalized mime]'
194 194
 		'mimeMap'         => array(
195
-		                     'md:application/x-genesis-rom' => 'text/x-markdown',
196
-		                     'md:text/plain'                => 'text/x-markdown',
197
-		                     'markdown:text/plain'          => 'text/x-markdown',
198
-		                     'css:text/x-asm'               => 'text/css'
199
-		                    ),
195
+							 'md:application/x-genesis-rom' => 'text/x-markdown',
196
+							 'md:text/plain'                => 'text/x-markdown',
197
+							 'markdown:text/plain'          => 'text/x-markdown',
198
+							 'css:text/x-asm'               => 'text/css'
199
+							),
200 200
 		// directory for thumbnails
201 201
 		'tmbPath'         => '.tmb',
202 202
 		// mode to create thumbnails dir
@@ -4043,14 +4043,14 @@  discard block
 block discarded – undo
4043 4043
 	// }
4044 4044
 
4045 4045
 	/**
4046
-	* Find position of first occurrence of string in a string with multibyte support
4047
-	*
4048
-	* @param  string  $haystack  The string being checked.
4049
-	* @param  string  $needle    The string to find in haystack.
4050
-	* @param  int     $offset    The search offset. If it is not specified, 0 is used.
4051
-	* @return int|bool
4052
-	* @author Alexey Sukhotin
4053
-	**/
4046
+	 * Find position of first occurrence of string in a string with multibyte support
4047
+	 *
4048
+	 * @param  string  $haystack  The string being checked.
4049
+	 * @param  string  $needle    The string to find in haystack.
4050
+	 * @param  int     $offset    The search offset. If it is not specified, 0 is used.
4051
+	 * @return int|bool
4052
+	 * @author Alexey Sukhotin
4053
+	 **/
4054 4054
 	protected function stripos($haystack , $needle , $offset = 0) {
4055 4055
 		if (function_exists('mb_stripos')) {
4056 4056
 			return mb_stripos($haystack , $needle , $offset);
Please login to merge, or discard this patch.
php/plugins/Watermark/plugin.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -1,55 +1,55 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * elFinder Plugin Watermark
4
- *
5
- * Print watermark on file upload.
6
- *
7
- * ex. binding, configure on connector options
8
- *	$opts = array(
9
- *		'bind' => array(
10
- *			'upload.presave' => array(
11
- *				'Plugin.Watermark.onUpLoadPreSave'
12
- *			)
13
- *		),
14
- *		// global configure (optional)
15
- *		'plugin' => array(
16
- *			'Watermark' => array(
17
- *				'enable'         => true,       // For control by volume driver
18
- *				'source'         => 'logo.png', // Path to Water mark image
19
- *				'marginRight'    => 5,          // Margin right pixel
20
- *				'marginBottom'   => 5,          // Margin bottom pixel
21
- *				'quality'        => 95,         // JPEG image save quality
22
- *				'transparency'   => 70,         // Water mark image transparency ( other than PNG )
23
- *				'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
24
- *				'targetMinPixel' => 200         // Target image minimum pixel size
25
- *			)
26
- *		),
27
- *		// each volume configure (optional)
28
- *		'roots' => array(
29
- *			array(
30
- *				'driver' => 'LocalFileSystem',
31
- *				'path'   => '/path/to/files/',
32
- *				'URL'    => 'http://localhost/to/files/'
33
- *				'plugin' => array(
34
- *					'Watermark' => array(
35
- *			 			'enable'         => true,       // For control by volume driver
36
- *						'source'         => 'logo.png', // Path to Water mark image
37
- *						'marginRight'    => 5,          // Margin right pixel
38
- *						'marginBottom'   => 5,          // Margin bottom pixel
39
- *						'quality'        => 95,         // JPEG image save quality
40
- *						'transparency'   => 70,         // Water mark image transparency ( other than PNG )
41
- *						'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
42
- *						'targetMinPixel' => 200         // Target image minimum pixel size
43
- *					)
44
- *				)
45
- *			)
46
- *		)
47
- *	);
48
- *
49
- * @package elfinder
50
- * @author Naoki Sawada
51
- * @license New BSD
52
- */
3
+	 * elFinder Plugin Watermark
4
+	 *
5
+	 * Print watermark on file upload.
6
+	 *
7
+	 * ex. binding, configure on connector options
8
+	 *	$opts = array(
9
+	 *		'bind' => array(
10
+	 *			'upload.presave' => array(
11
+	 *				'Plugin.Watermark.onUpLoadPreSave'
12
+	 *			)
13
+	 *		),
14
+	 *		// global configure (optional)
15
+	 *		'plugin' => array(
16
+	 *			'Watermark' => array(
17
+	 *				'enable'         => true,       // For control by volume driver
18
+	 *				'source'         => 'logo.png', // Path to Water mark image
19
+	 *				'marginRight'    => 5,          // Margin right pixel
20
+	 *				'marginBottom'   => 5,          // Margin bottom pixel
21
+	 *				'quality'        => 95,         // JPEG image save quality
22
+	 *				'transparency'   => 70,         // Water mark image transparency ( other than PNG )
23
+	 *				'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
24
+	 *				'targetMinPixel' => 200         // Target image minimum pixel size
25
+	 *			)
26
+	 *		),
27
+	 *		// each volume configure (optional)
28
+	 *		'roots' => array(
29
+	 *			array(
30
+	 *				'driver' => 'LocalFileSystem',
31
+	 *				'path'   => '/path/to/files/',
32
+	 *				'URL'    => 'http://localhost/to/files/'
33
+	 *				'plugin' => array(
34
+	 *					'Watermark' => array(
35
+	 *			 			'enable'         => true,       // For control by volume driver
36
+	 *						'source'         => 'logo.png', // Path to Water mark image
37
+	 *						'marginRight'    => 5,          // Margin right pixel
38
+	 *						'marginBottom'   => 5,          // Margin bottom pixel
39
+	 *						'quality'        => 95,         // JPEG image save quality
40
+	 *						'transparency'   => 70,         // Water mark image transparency ( other than PNG )
41
+	 *						'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
42
+	 *						'targetMinPixel' => 200         // Target image minimum pixel size
43
+	 *					)
44
+	 *				)
45
+	 *			)
46
+	 *		)
47
+	 *	);
48
+	 *
49
+	 * @package elfinder
50
+	 * @author Naoki Sawada
51
+	 * @license New BSD
52
+	 */
53 53
 class elFinderPluginWatermark {
54 54
 
55 55
 	private $opts = array();
Please login to merge, or discard this patch.
php/plugins/Normalizer/plugin.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -1,55 +1,55 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * elFinder Plugin Normalizer
4
- * 
5
- * UTF-8 Normalizer of file-name and file-path etc.
6
- * nfc(NFC): Canonical Decomposition followed by Canonical Composition
7
- * nfkc(NFKC): Compatibility Decomposition followed by Canonical
8
- * 
9
- * This plugin require Class "Normalizer" (PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
10
- * or PEAR package "I18N_UnicodeNormalizer"
11
- * 
12
- * ex. binding, configure on connector options
13
- *	$opts = array(
14
- *		'bind' => array(
15
- *			'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre' => array(
16
- *				'Plugin.Normalizer.cmdPreprocess'
17
- *			),
18
- *			'upload.presave' => array(
19
- *				'Plugin.Normalizer.onUpLoadPreSave'
20
- *			)
21
- *		),
22
- *		// global configure (optional)
23
- *		'plugin' => array(
24
- *			'Normalizer' => array(
25
- *				'enable' => true,
26
- *				'nfc'    => true,
27
- *				'nfkc'   => true,
28
- *				'lowercase'   => false
29
- *			)
30
- *		),
31
- *		// each volume configure (optional)
32
- *		'roots' => array(
33
- *			array(
34
- *				'driver' => 'LocalFileSystem',
35
- *				'path'   => '/path/to/files/',
36
- *				'URL'    => 'http://localhost/to/files/'
37
- *				'plugin' => array(
38
- *					'Normalizer' => array(
39
- *						'enable' => true,
40
- *						'nfc'    => true,
41
- *						'nfkc'   => true,
42
- * 						'lowercase'   => false
43
- *					)
44
- *				)
45
- *			)
46
- *		)
47
- *	);
48
- *
49
- * @package elfinder
50
- * @author Naoki Sawada
51
- * @license New BSD
52
- */
3
+  	 * elFinder Plugin Normalizer
4
+  	 * 
5
+  	 * UTF-8 Normalizer of file-name and file-path etc.
6
+  	 * nfc(NFC): Canonical Decomposition followed by Canonical Composition
7
+  	 * nfkc(NFKC): Compatibility Decomposition followed by Canonical
8
+  	 * 
9
+  	 * This plugin require Class "Normalizer" (PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
10
+  	 * or PEAR package "I18N_UnicodeNormalizer"
11
+  	 * 
12
+  	 * ex. binding, configure on connector options
13
+  	 *	$opts = array(
14
+  	 *		'bind' => array(
15
+  	 *			'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre' => array(
16
+  	 *				'Plugin.Normalizer.cmdPreprocess'
17
+  	 *			),
18
+  	 *			'upload.presave' => array(
19
+  	 *				'Plugin.Normalizer.onUpLoadPreSave'
20
+  	 *			)
21
+  	 *		),
22
+  	 *		// global configure (optional)
23
+  	 *		'plugin' => array(
24
+  	 *			'Normalizer' => array(
25
+  	 *				'enable' => true,
26
+  	 *				'nfc'    => true,
27
+  	 *				'nfkc'   => true,
28
+  	 *				'lowercase'   => false
29
+  	 *			)
30
+  	 *		),
31
+  	 *		// each volume configure (optional)
32
+  	 *		'roots' => array(
33
+  	 *			array(
34
+  	 *				'driver' => 'LocalFileSystem',
35
+  	 *				'path'   => '/path/to/files/',
36
+  	 *				'URL'    => 'http://localhost/to/files/'
37
+  	 *				'plugin' => array(
38
+  	 *					'Normalizer' => array(
39
+  	 *						'enable' => true,
40
+  	 *						'nfc'    => true,
41
+  	 *						'nfkc'   => true,
42
+  	 * 						'lowercase'   => false
43
+  	 *					)
44
+  	 *				)
45
+  	 *			)
46
+  	 *		)
47
+  	 *	);
48
+  	 *
49
+  	 * @package elfinder
50
+  	 * @author Naoki Sawada
51
+  	 * @license New BSD
52
+  	 */
53 53
 class elFinderPluginNormalizer
54 54
 {
55 55
 	private $opts = array();
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		$defaults = array(
59 59
 			'enable' => true, // For control by volume driver
60 60
 			'nfc'    => true, // Canonical Decomposition followed by Canonical Composition
61
-			'nfkc'   => true,  // Compatibility Decomposition followed by Canonical
61
+			'nfkc'   => true, // Compatibility Decomposition followed by Canonical
62 62
 			'lowercase'   => false  // Make chars lowercase
63 63
 		);
64 64
 	
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
 	
68 68
 	public function cmdPreprocess($cmd, &$args, $elfinder, $volume) {
69 69
 		$opts = $this->getOpts($volume);
70
-		if (! $opts['enable']) {
70
+		if (!$opts['enable']) {
71 71
 			return false;
72 72
 		}
73 73
 		
74 74
 		if (isset($args['name'])) {
75 75
 			if (is_array($args['name'])) {
76
-				foreach($args['name'] as $i => $name) {
76
+				foreach ($args['name'] as $i => $name) {
77 77
 					$args['name'][$i] = $this->normalize($name, $opts);
78 78
 				}
79 79
 			} else {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	
86 86
 	public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) {
87 87
 		$opts = $this->getOpts($volume);
88
-		if (! $opts['enable']) {
88
+		if (!$opts['enable']) {
89 89
 			return false;
90 90
 		}
91 91
 		
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
 	private function normalize($str, $opts) {
111 111
 		if ($opts['nfc'] || $opts['nfkc']) {
112 112
 			if (class_exists('Normalizer', false)) {
113
-				if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C))
113
+				if ($opts['nfc'] && !Normalizer::isNormalized($str, Normalizer::FORM_C))
114 114
 					$str = Normalizer::normalize($str, Normalizer::FORM_C);
115
-				if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC))
115
+				if ($opts['nfkc'] && !Normalizer::isNormalized($str, Normalizer::FORM_KC))
116 116
 					$str = Normalizer::normalize($str, Normalizer::FORM_KC);
117 117
 			} else {
118
-				if (! class_exists('I18N_UnicodeNormalizer', false)) {
118
+				if (!class_exists('I18N_UnicodeNormalizer', false)) {
119 119
 					@ include_once 'I18N/UnicodeNormalizer.php';
120 120
 				}
121 121
 				if (class_exists('I18N_UnicodeNormalizer', false)) {
Please login to merge, or discard this patch.
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', false)) {
140
+			if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) {
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', false)) {
148 148
 					$this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']);
149 149
 				} else {
150
-					if (! class_exists('HTTP_OAuth_Consumer', false)) {
150
+					if (!class_exists('HTTP_OAuth_Consumer', false)) {
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', false)) {
311 311
 					$this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']);
312 312
 				} else {
313
-					if (! class_exists('HTTP_OAuth_Consumer', false)) {
313
+					if (!class_exists('HTTP_OAuth_Consumer', false)) {
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.