@@ -24,10 +24,10 @@ |
||
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); |
@@ -34,7 +34,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 { |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $dirs = array(); |
312 | 312 | if ($path != $this->root) { |
313 | 313 | $inpath = array(intval($path)); |
314 | - while($inpath) { |
|
314 | + while ($inpath) { |
|
315 | 315 | $in = '('.join(',', $inpath).')'; |
316 | 316 | $inpath = array(); |
317 | 317 | $sql = 'SELECT f.id FROM %s AS f WHERE f.parent_id IN '.$in.' AND `mime` = \'directory\''; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | |
331 | 331 | if ($mimes) { |
332 | 332 | $whrs = array(); |
333 | - foreach($mimes as $mime) { |
|
333 | + foreach ($mimes as $mime) { |
|
334 | 334 | if (strpos($mime, '/') === false) { |
335 | 335 | $whrs[] = sprintf('f.mime LIKE "%s/%%"', $this->db->real_escape_string($mime)); |
336 | 336 | } else { |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $whr = sprintf('f.name RLIKE "%s"', $this->db->real_escape_string($q)); |
343 | 343 | } |
344 | 344 | if ($dirs) { |
345 | - $whr = '(' . $whr . ') AND (`parent_id` IN (' . join(',', $dirs) . '))'; |
|
345 | + $whr = '('.$whr.') AND (`parent_id` IN ('.join(',', $dirs).'))'; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | $sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, 0 AS dirs |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | * @return resource|false |
588 | 588 | * @author Dmitry (dio) Levashov |
589 | 589 | **/ |
590 | - protected function _fopen($path, $mode='rb') { |
|
590 | + protected function _fopen($path, $mode = 'rb') { |
|
591 | 591 | $fp = $this->tmbPath |
592 | 592 | ? @fopen($this->getTempFile($path), 'w+') |
593 | 593 | : @tmpfile(); |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | * @return bool |
615 | 615 | * @author Dmitry (dio) Levashov |
616 | 616 | **/ |
617 | - protected function _fclose($fp, $path='') { |
|
617 | + protected function _fclose($fp, $path = '') { |
|
618 | 618 | @fclose($fp); |
619 | 619 | if ($path) { |
620 | 620 | @unlink($this->getTempFile($path)); |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | $this->clearcache(); |
747 | 747 | |
748 | 748 | $mime = $stat['mime']; |
749 | - $w = !empty($stat['width']) ? $stat['width'] : 0; |
|
749 | + $w = !empty($stat['width']) ? $stat['width'] : 0; |
|
750 | 750 | $h = !empty($stat['height']) ? $stat['height'] : 0; |
751 | 751 | |
752 | 752 | $id = $this->_joinPath($dir, $name); |
@@ -61,8 +61,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -57,13 +57,13 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -49,8 +49,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -58,9 +58,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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)) { |
@@ -52,12 +52,12 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | if ($options['user'] === 'init') { |
140 | 140 | |
141 | - if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) { |
|
141 | + if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) { |
|
142 | 142 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
143 | 143 | } |
144 | 144 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | if (class_exists('OAuth', false)) { |
149 | 149 | $this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']); |
150 | 150 | } else { |
151 | - if (! class_exists('HTTP_OAuth_Consumer', false)) { |
|
151 | + if (!class_exists('HTTP_OAuth_Consumer', false)) { |
|
152 | 152 | // We're going to try to load in manually |
153 | 153 | include 'HTTP/OAuth/Consumer.php'; |
154 | 154 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - if (! $this->oauth) { |
|
161 | + if (!$this->oauth) { |
|
162 | 162 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
163 | 163 | } |
164 | 164 | |
@@ -179,25 +179,25 @@ discard block |
||
179 | 179 | unset($_SESSION['elFinderDropboxTokens']); |
180 | 180 | } |
181 | 181 | } |
182 | - if (! $html) { |
|
182 | + if (!$html) { |
|
183 | 183 | // get customdata |
184 | 184 | $cdata = ''; |
185 | 185 | $innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user'); |
186 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
187 | - foreach($this->ARGS as $k => $v) { |
|
188 | - if (! in_array($k, $innerKeys)) { |
|
189 | - $cdata .= '&' . $k . '=' . rawurlencode($v); |
|
186 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
187 | + foreach ($this->ARGS as $k => $v) { |
|
188 | + if (!in_array($k, $innerKeys)) { |
|
189 | + $cdata .= '&'.$k.'='.rawurlencode($v); |
|
190 | 190 | } |
191 | 191 | } |
192 | - if (strpos($options['url'], 'http') !== 0 ) { |
|
192 | + if (strpos($options['url'], 'http') !== 0) { |
|
193 | 193 | $options['url'] = $this->getConnectorUrl(); |
194 | 194 | } |
195 | - $callback = $options['url'] |
|
195 | + $callback = $options['url'] |
|
196 | 196 | . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata; |
197 | 197 | |
198 | 198 | try { |
199 | 199 | $tokens = $this->oauth->getRequestToken(); |
200 | - $url= $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
200 | + $url = $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
201 | 201 | } catch (Dropbox_Exception $e) { |
202 | 202 | return array('exit' => true, 'body' => '{msg:errAccess}'); |
203 | 203 | } |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | if (isset($netVolumes[$key])) { |
245 | 245 | $dropboxUid = $netVolumes[$key]['dropboxUid']; |
246 | 246 | } |
247 | - foreach($netVolumes as $volume) { |
|
247 | + foreach ($netVolumes as $volume) { |
|
248 | 248 | if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) { |
249 | 249 | $count++; |
250 | 250 | } |
251 | 251 | } |
252 | 252 | if ($count === 1) { |
253 | 253 | $this->DB->exec('drop table '.$this->DB_TableName); |
254 | - foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
254 | + foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
255 | 255 | unlink($tmb); |
256 | 256 | } |
257 | 257 | } |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * @author Naoki Sawada |
266 | 266 | */ |
267 | 267 | private function getConnectorUrl() { |
268 | - $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://') |
|
268 | + $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://') |
|
269 | 269 | . $_SERVER['SERVER_NAME'] // host |
270 | - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port |
|
271 | - . $_SERVER['REQUEST_URI']; // path & query |
|
270 | + . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']) // port |
|
271 | + . $_SERVER['REQUEST_URI']; // path & query |
|
272 | 272 | list($url) = explode('?', $url); |
273 | 273 | return $url; |
274 | 274 | } |
@@ -304,14 +304,14 @@ discard block |
||
304 | 304 | // make net mount key |
305 | 305 | $this->netMountKey = md5(join('-', array('dropbox', $this->options['path']))); |
306 | 306 | |
307 | - if (! $this->oauth) { |
|
307 | + if (!$this->oauth) { |
|
308 | 308 | if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) { |
309 | 309 | $this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']); |
310 | 310 | } else { |
311 | 311 | if (class_exists('OAuth', false)) { |
312 | 312 | $this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']); |
313 | 313 | } else { |
314 | - if (! class_exists('HTTP_OAuth_Consumer', false)) { |
|
314 | + if (!class_exists('HTTP_OAuth_Consumer', false)) { |
|
315 | 315 | // We're going to try to load in manually |
316 | 316 | include 'HTTP/OAuth/Consumer.php'; |
317 | 317 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | - if (! $this->oauth) { |
|
325 | + if (!$this->oauth) { |
|
326 | 326 | return $this->setError('OAuth extension not loaded.'); |
327 | 327 | } |
328 | 328 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $this->root = $this->options['path'] = $this->_normpath($this->options['path']); |
331 | 331 | |
332 | 332 | if (empty($this->options['alias'])) { |
333 | - $this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
333 | + $this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | $this->rootName = $this->options['alias']; |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | // setup PDO |
388 | - if (! $this->options['PDO_DSN']) { |
|
388 | + if (!$this->options['PDO_DSN']) { |
|
389 | 389 | $this->options['PDO_DSN'] = 'sqlite:'.$this->metaCache.DIRECTORY_SEPARATOR.'.elFinder_dropbox_db_'.md5($this->dropboxUid.$this->options['consumerSecret']); |
390 | 390 | } |
391 | 391 | // DataBase table name |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | // DataBase check or make table |
394 | 394 | try { |
395 | 395 | $this->DB = new PDO($this->options['PDO_DSN'], $this->options['PDO_User'], $this->options['PDO_Pass'], $this->options['PDO_Options']); |
396 | - if (! $this->checkDB()) { |
|
396 | + if (!$this->checkDB()) { |
|
397 | 397 | return $this->setError('Can not make DB table'); |
398 | 398 | } |
399 | 399 | } catch (PDOException $e) { |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | $res = false; |
456 | 456 | } |
457 | 457 | } |
458 | - if (! $res) { |
|
458 | + if (!$res) { |
|
459 | 459 | try { |
460 | 460 | $this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);'); |
461 | 461 | $this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)'); |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | */ |
506 | 506 | private function updateDBdat($path, $dat) { |
507 | 507 | return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat)) |
508 | - . ', isdir=' . ($dat['is_dir']? 1 : 0) |
|
508 | + . ', isdir='.($dat['is_dir'] ? 1 : 0) |
|
509 | 509 | . ' where path='.$this->DB->quote(strtolower($this->_dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path)))); |
510 | 510 | } |
511 | 511 | /*********************************************************************/ |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | */ |
531 | 531 | protected function deltaCheck($refresh = true) { |
532 | 532 | $chk = false; |
533 | - if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
533 | + if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
534 | 534 | $chk = unserialize($chk[0]); |
535 | 535 | } |
536 | 536 | if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) { |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | do { |
555 | 555 | @ ini_set('max_execution_time', 120); |
556 | 556 | $_info = $this->dropbox->delta($cursor); |
557 | - if (! empty($_info['reset'])) { |
|
557 | + if (!empty($_info['reset'])) { |
|
558 | 558 | $this->DB->exec('TRUNCATE table '.$this->DB_TableName); |
559 | 559 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);'); |
560 | 560 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array( |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | } |
568 | 568 | $cursor = $_info['cursor']; |
569 | 569 | |
570 | - foreach($_info['entries'] as $entry) { |
|
570 | + foreach ($_info['entries'] as $entry) { |
|
571 | 571 | $key = strtolower($entry[0]); |
572 | 572 | $pkey = strtolower($this->_dirname($key)); |
573 | 573 | |
@@ -576,22 +576,22 @@ discard block |
||
576 | 576 | $where = 'where path='.$path.' and fname='.$fname; |
577 | 577 | |
578 | 578 | if (empty($entry[1])) { |
579 | - $ptimes[$pkey] = isset($ptimes[$pkey])? max(array($now, $ptimes[$pkey])) : $now; |
|
579 | + $ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($now, $ptimes[$pkey])) : $now; |
|
580 | 580 | $this->DB->exec('delete from '.$this->DB_TableName.' '.$where); |
581 | - ! $delete && $delete = true; |
|
581 | + !$delete && $delete = true; |
|
582 | 582 | continue; |
583 | 583 | } |
584 | 584 | |
585 | - $_itemTime = strtotime(isset($entry[1]['client_mtime'])? $entry[1]['client_mtime'] : $entry[1]['modified']); |
|
586 | - $ptimes[$pkey] = isset($ptimes[$pkey])? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime; |
|
585 | + $_itemTime = strtotime(isset($entry[1]['client_mtime']) ? $entry[1]['client_mtime'] : $entry[1]['modified']); |
|
586 | + $ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime; |
|
587 | 587 | $sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1'; |
588 | - if (! $reset && $this->query($sql)) { |
|
589 | - $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where); |
|
588 | + if (!$reset && $this->query($sql)) { |
|
589 | + $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where); |
|
590 | 590 | } else { |
591 | - $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')'); |
|
591 | + $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')'); |
|
592 | 592 | } |
593 | 593 | } |
594 | - } while (! empty($_info['has_more'])); |
|
594 | + } while (!empty($_info['has_more'])); |
|
595 | 595 | |
596 | 596 | // update time stamp of parent holder |
597 | 597 | foreach ($ptimes as $_p => $_t) { |
@@ -613,14 +613,14 @@ discard block |
||
613 | 613 | } |
614 | 614 | |
615 | 615 | $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\''); |
616 | - if (! $this->DB->commit()) { |
|
616 | + if (!$this->DB->commit()) { |
|
617 | 617 | $e = $this->DB->errorInfo(); |
618 | 618 | return $e[2]; |
619 | 619 | } |
620 | 620 | if ($delete) { |
621 | 621 | $this->DB->exec('vacuum'); |
622 | 622 | } |
623 | - } catch(Dropbox_Exception $e) { |
|
623 | + } catch (Dropbox_Exception $e) { |
|
624 | 624 | return $e->getMessage(); |
625 | 625 | } |
626 | 626 | return true; |
@@ -636,15 +636,14 @@ discard block |
||
636 | 636 | protected function parseRaw($raw) { |
637 | 637 | $stat = array(); |
638 | 638 | |
639 | - $stat['rev'] = isset($raw['rev'])? $raw['rev'] : 'root'; |
|
639 | + $stat['rev'] = isset($raw['rev']) ? $raw['rev'] : 'root'; |
|
640 | 640 | $stat['name'] = basename($raw['path']); |
641 | - $stat['mime'] = $raw['is_dir']? 'directory' : $raw['mime_type']; |
|
641 | + $stat['mime'] = $raw['is_dir'] ? 'directory' : $raw['mime_type']; |
|
642 | 642 | $stat['size'] = $stat['mime'] == 'directory' ? 0 : $raw['bytes']; |
643 | - $stat['ts'] = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) : |
|
644 | - (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
643 | + $stat['ts'] = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
645 | 644 | $stat['dirs'] = 0; |
646 | 645 | if ($raw['is_dir']) { |
647 | - $stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
646 | + $stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
648 | 647 | } |
649 | 648 | |
650 | 649 | if (!empty($raw['url'])) { |
@@ -670,7 +669,7 @@ discard block |
||
670 | 669 | $res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path))); |
671 | 670 | |
672 | 671 | if ($res) { |
673 | - foreach($res as $raw) { |
|
672 | + foreach ($res as $raw) { |
|
674 | 673 | $raw = unserialize($raw); |
675 | 674 | if ($stat = $this->parseRaw($raw)) { |
676 | 675 | $stat = $this->updateCache($raw['path'], $stat); |
@@ -695,10 +694,10 @@ discard block |
||
695 | 694 | protected function doSearch($path, $q, $mimes) { |
696 | 695 | $result = array(); |
697 | 696 | $sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?'); |
698 | - $sth->execute(array('%'.(($path === '/')? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
697 | + $sth->execute(array('%'.(($path === '/') ? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
699 | 698 | $res = $sth->fetchAll(PDO::FETCH_COLUMN); |
700 | 699 | if ($res) { |
701 | - foreach($res as $raw) { |
|
700 | + foreach ($res as $raw) { |
|
702 | 701 | $raw = unserialize($raw); |
703 | 702 | if ($stat = $this->parseRaw($raw)) { |
704 | 703 | if (!isset($this->cache[$raw['path']])) { |
@@ -789,10 +788,10 @@ discard block |
||
789 | 788 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
790 | 789 | |
791 | 790 | // copy image into tmbPath so some drivers does not store files on local fs |
792 | - if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
791 | + if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
793 | 792 | return false; |
794 | 793 | } |
795 | - if (! file_put_contents($tmb, $data)) { |
|
794 | + if (!file_put_contents($tmb, $data)) { |
|
796 | 795 | return false; |
797 | 796 | } |
798 | 797 | |
@@ -805,15 +804,15 @@ discard block |
||
805 | 804 | } |
806 | 805 | |
807 | 806 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
808 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
809 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
807 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
808 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
810 | 809 | |
811 | 810 | } else { |
812 | 811 | |
813 | 812 | if ($this->options['tmbCrop']) { |
814 | 813 | |
815 | 814 | /* Resize and crop if image bigger than thumbnail */ |
816 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
815 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
817 | 816 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
818 | 817 | } |
819 | 818 | |
@@ -827,7 +826,7 @@ discard block |
||
827 | 826 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
828 | 827 | } |
829 | 828 | |
830 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
829 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
831 | 830 | } |
832 | 831 | |
833 | 832 | if (!$result) { |
@@ -884,7 +883,7 @@ discard block |
||
884 | 883 | } |
885 | 884 | } |
886 | 885 | } |
887 | - if (! $url) { |
|
886 | + if (!$url) { |
|
888 | 887 | try { |
889 | 888 | $res = $this->dropbox->share($path, null, false); |
890 | 889 | $url = $res['url']; |
@@ -896,7 +895,7 @@ discard block |
||
896 | 895 | } |
897 | 896 | list($url) = explode('?', $url); |
898 | 897 | $url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url); |
899 | - if (! isset($cache['share']) || $cache['share'] !== $url) { |
|
898 | + if (!isset($cache['share']) || $cache['share'] !== $url) { |
|
900 | 899 | $cache['share'] = $url; |
901 | 900 | $this->updateDBdat($path, $cache); |
902 | 901 | } |
@@ -920,12 +919,12 @@ discard block |
||
920 | 919 | if (function_exists('curl_exec')) { |
921 | 920 | |
922 | 921 | $c = curl_init(); |
923 | - curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); |
|
924 | - curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' ); |
|
925 | - curl_setopt( $c, CURLOPT_HEADER, 1 ); |
|
926 | - curl_setopt( $c, CURLOPT_NOBODY, true ); |
|
927 | - curl_setopt( $c, CURLOPT_URL, $url ); |
|
928 | - $res = curl_exec( $c ); |
|
922 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
|
923 | + curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD'); |
|
924 | + curl_setopt($c, CURLOPT_HEADER, 1); |
|
925 | + curl_setopt($c, CURLOPT_NOBODY, true); |
|
926 | + curl_setopt($c, CURLOPT_URL, $url); |
|
927 | + $res = curl_exec($c); |
|
929 | 928 | |
930 | 929 | } else { |
931 | 930 | |
@@ -941,13 +940,13 @@ discard block |
||
941 | 940 | $result = $request2->send(); |
942 | 941 | $res = array(); |
943 | 942 | $res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase(); |
944 | - foreach($result->getHeader() as $key => $val) { |
|
945 | - $res[] = $key . ': ' . $val; |
|
943 | + foreach ($result->getHeader() as $key => $val) { |
|
944 | + $res[] = $key.': '.$val; |
|
946 | 945 | } |
947 | 946 | $res = join("\r\n", $res); |
948 | - } catch( HTTP_Request2_Exception $e ){ |
|
947 | + } catch (HTTP_Request2_Exception $e) { |
|
949 | 948 | $res = ''; |
950 | - } catch (Exception $e){ |
|
949 | + } catch (Exception $e) { |
|
951 | 950 | $res = ''; |
952 | 951 | } |
953 | 952 | |
@@ -1002,7 +1001,7 @@ discard block |
||
1002 | 1001 | if (DIRECTORY_SEPARATOR !== '/') { |
1003 | 1002 | $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); |
1004 | 1003 | } |
1005 | - $path = '/' . ltrim($path, '/'); |
|
1004 | + $path = '/'.ltrim($path, '/'); |
|
1006 | 1005 | return $path; |
1007 | 1006 | } |
1008 | 1007 | |
@@ -1145,7 +1144,7 @@ discard block |
||
1145 | 1144 | * @return resource|false |
1146 | 1145 | * @author Dmitry (dio) Levashov |
1147 | 1146 | **/ |
1148 | - protected function _fopen($path, $mode='rb') { |
|
1147 | + protected function _fopen($path, $mode = 'rb') { |
|
1149 | 1148 | |
1150 | 1149 | if (($mode == 'rb' || $mode == 'r')) { |
1151 | 1150 | try { |
@@ -1155,7 +1154,7 @@ discard block |
||
1155 | 1154 | fputs($fp, "GET {$url['path']} HTTP/1.0\r\n"); |
1156 | 1155 | fputs($fp, "Host: {$url['host']}\r\n"); |
1157 | 1156 | fputs($fp, "\r\n"); |
1158 | - while(trim(fgets($fp)) !== ''){}; |
|
1157 | + while (trim(fgets($fp)) !== '') {}; |
|
1159 | 1158 | return $fp; |
1160 | 1159 | } catch (Dropbox_Exception $e) { |
1161 | 1160 | return false; |
@@ -1186,7 +1185,7 @@ discard block |
||
1186 | 1185 | * @return bool |
1187 | 1186 | * @author Dmitry (dio) Levashov |
1188 | 1187 | **/ |
1189 | - protected function _fclose($fp, $path='') { |
|
1188 | + protected function _fclose($fp, $path = '') { |
|
1190 | 1189 | @fclose($fp); |
1191 | 1190 | if ($path) { |
1192 | 1191 | @unlink($this->getTempFile($path)); |