Completed
Pull Request — develop (#747)
by
unknown
07:43
created
manager/includes/controls/phpmailer/PHPMailer.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3968,7 +3968,7 @@
 block discarded – undo
3968 3968
      * @param int|string $options Either a PATHINFO_* constant,
3969 3969
      *                            or a string name to return only the specified piece
3970 3970
      *
3971
-     * @return string|array
3971
+     * @return string
3972 3972
      */
3973 3973
     public static function mb_pathinfo($path, $options = null)
3974 3974
     {
Please login to merge, or discard this patch.
Spacing   +135 added lines, -136 removed lines patch added patch discarded remove patch
@@ -1076,10 +1076,10 @@  discard block
 block discarded – undo
1076 1076
             $list = imap_rfc822_parse_adrlist($addrstr, '');
1077 1077
             foreach ($list as $address) {
1078 1078
                 if ('.SYNTAX-ERROR.' != $address->host) {
1079
-                    if (static::validateAddress($address->mailbox . '@' . $address->host)) {
1079
+                    if (static::validateAddress($address->mailbox.'@'.$address->host)) {
1080 1080
                         $addresses[] = [
1081 1081
                             'name' => (property_exists($address, 'personal') ? $address->personal : ''),
1082
-                            'address' => $address->mailbox . '@' . $address->host,
1082
+                            'address' => $address->mailbox.'@'.$address->host,
1083 1083
                         ];
1084 1084
                     }
1085 1085
                 }
@@ -1225,14 +1225,14 @@  discard block
 block discarded – undo
1225 1225
                  * Feel free to use and redistribute this code. But please keep this copyright notice.
1226 1226
                  */
1227 1227
                 return (bool) preg_match(
1228
-                    '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
1229
-                    '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' .
1230
-                    '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' .
1231
-                    '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' .
1232
-                    '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' .
1233
-                    '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' .
1234
-                    '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' .
1235
-                    '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
1228
+                    '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)'.
1229
+                    '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)'.
1230
+                    '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)'.
1231
+                    '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*'.
1232
+                    '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)'.
1233
+                    '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}'.
1234
+                    '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:'.
1235
+                    '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}'.
1236 1236
                     '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
1237 1237
                     $address
1238 1238
                 );
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
                  * @see http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email)
1244 1244
                  */
1245 1245
                 return (bool) preg_match(
1246
-                    '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' .
1246
+                    '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}'.
1247 1247
                     '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD',
1248 1248
                     $address
1249 1249
                 );
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
                 $errorcode = 0;
1295 1295
                 $punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_UTS46);
1296 1296
                 if (false !== $punycode) {
1297
-                    return substr($address, 0, $pos) . $punycode;
1297
+                    return substr($address, 0, $pos).$punycode;
1298 1298
                 }
1299 1299
             }
1300 1300
         }
@@ -1358,8 +1358,8 @@  discard block
 block discarded – undo
1358 1358
                     and version_compare(PHP_VERSION, '7.1.3', '<')))
1359 1359
         ) {
1360 1360
             trigger_error(
1361
-                'Your version of PHP is affected by a bug that may result in corrupted messages.' .
1362
-                ' To fix it, switch to sending using SMTP, disable the mail.add_x_header option in' .
1361
+                'Your version of PHP is affected by a bug that may result in corrupted messages.'.
1362
+                ' To fix it, switch to sending using SMTP, disable the mail.add_x_header option in'.
1363 1363
                 ' your php.ini, switch to MacOS or Linux, or upgrade your PHP to version 7.0.17+ or 7.1.3+.',
1364 1364
                 E_USER_WARNING
1365 1365
             );
@@ -1443,12 +1443,12 @@  discard block
 block discarded – undo
1443 1443
                 )
1444 1444
             ) {
1445 1445
                 $header_dkim = $this->DKIM_Add(
1446
-                    $this->MIMEHeader . $this->mailHeader,
1446
+                    $this->MIMEHeader.$this->mailHeader,
1447 1447
                     $this->encodeHeader($this->secureHeader($this->Subject)),
1448 1448
                     $this->MIMEBody
1449 1449
                 );
1450
-                $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . static::$LE .
1451
-                    static::normalizeBreaks($header_dkim) . static::$LE;
1450
+                $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ").static::$LE.
1451
+                    static::normalizeBreaks($header_dkim).static::$LE;
1452 1452
             }
1453 1453
 
1454 1454
             return true;
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
                 case 'mail':
1483 1483
                     return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
1484 1484
                 default:
1485
-                    $sendMethod = $this->Mailer . 'Send';
1485
+                    $sendMethod = $this->Mailer.'Send';
1486 1486
                     if (method_exists($this, $sendMethod)) {
1487 1487
                         return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
1488 1488
                     }
@@ -1535,9 +1535,9 @@  discard block
 block discarded – undo
1535 1535
             foreach ($this->SingleToArray as $toAddr) {
1536 1536
                 $mail = @popen($sendmail, 'w');
1537 1537
                 if (!$mail) {
1538
-                    throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
1538
+                    throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL);
1539 1539
                 }
1540
-                fwrite($mail, 'To: ' . $toAddr . "\n");
1540
+                fwrite($mail, 'To: '.$toAddr."\n");
1541 1541
                 fwrite($mail, $header);
1542 1542
                 fwrite($mail, $body);
1543 1543
                 $result = pclose($mail);
@@ -1552,13 +1552,13 @@  discard block
 block discarded – undo
1552 1552
                     []
1553 1553
                 );
1554 1554
                 if (0 !== $result) {
1555
-                    throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
1555
+                    throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL);
1556 1556
                 }
1557 1557
             }
1558 1558
         } else {
1559 1559
             $mail = @popen($sendmail, 'w');
1560 1560
             if (!$mail) {
1561
-                throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
1561
+                throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL);
1562 1562
             }
1563 1563
             fwrite($mail, $header);
1564 1564
             fwrite($mail, $body);
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
                 []
1575 1575
             );
1576 1576
             if (0 !== $result) {
1577
-                throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
1577
+                throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL);
1578 1578
             }
1579 1579
         }
1580 1580
 
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
             $smtp_from = $this->Sender;
1733 1733
         }
1734 1734
         if (!$this->smtp->mail($smtp_from)) {
1735
-            $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError()));
1735
+            $this->setError($this->lang('from_failed').$smtp_from.' : '.implode(',', $this->smtp->getError()));
1736 1736
             throw new Exception($this->ErrorInfo, self::STOP_CRITICAL);
1737 1737
         }
1738 1738
 
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
         }
1754 1754
 
1755 1755
         // Only send the DATA command if we have viable recipients
1756
-        if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) {
1756
+        if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header.$body)) {
1757 1757
             throw new Exception($this->lang('data_not_accepted'), self::STOP_CRITICAL);
1758 1758
         }
1759 1759
 
@@ -1783,10 +1783,10 @@  discard block
 block discarded – undo
1783 1783
         if (count($bad_rcpt) > 0) {
1784 1784
             $errstr = '';
1785 1785
             foreach ($bad_rcpt as $bad) {
1786
-                $errstr .= $bad['to'] . ': ' . $bad['error'];
1786
+                $errstr .= $bad['to'].': '.$bad['error'];
1787 1787
             }
1788 1788
             throw new Exception(
1789
-                $this->lang('recipients_failed') . $errstr,
1789
+                $this->lang('recipients_failed').$errstr,
1790 1790
                 self::STOP_CONTINUE
1791 1791
             );
1792 1792
         }
@@ -1836,7 +1836,7 @@  discard block
 block discarded – undo
1836 1836
                 trim($hostentry),
1837 1837
                 $hostinfo
1838 1838
             )) {
1839
-                static::edebug($this->lang('connect_host') . ' ' . $hostentry);
1839
+                static::edebug($this->lang('connect_host').' '.$hostentry);
1840 1840
                 // Not a valid host entry
1841 1841
                 continue;
1842 1842
             }
@@ -1848,7 +1848,7 @@  discard block
 block discarded – undo
1848 1848
 
1849 1849
             //Check the host name is a valid name or IP address before trying to use it
1850 1850
             if (!static::isValidHost($hostinfo[3])) {
1851
-                static::edebug($this->lang('connect_host') . ' ' . $hostentry);
1851
+                static::edebug($this->lang('connect_host').' '.$hostentry);
1852 1852
                 continue;
1853 1853
             }
1854 1854
             $prefix = '';
@@ -1868,7 +1868,7 @@  discard block
 block discarded – undo
1868 1868
             if ('tls' === $secure or 'ssl' === $secure) {
1869 1869
                 //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled
1870 1870
                 if (!$sslext) {
1871
-                    throw new Exception($this->lang('extension_missing') . 'openssl', self::STOP_CRITICAL);
1871
+                    throw new Exception($this->lang('extension_missing').'openssl', self::STOP_CRITICAL);
1872 1872
                 }
1873 1873
             }
1874 1874
             $host = $hostinfo[3];
@@ -1877,7 +1877,7 @@  discard block
 block discarded – undo
1877 1877
             if ($tport > 0 and $tport < 65536) {
1878 1878
                 $port = $tport;
1879 1879
             }
1880
-            if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) {
1880
+            if ($this->smtp->connect($prefix.$host, $port, $this->Timeout, $options)) {
1881 1881
                 try {
1882 1882
                     if ($this->Helo) {
1883 1883
                         $hello = $this->Helo;
@@ -1994,14 +1994,14 @@  discard block
 block discarded – undo
1994 1994
         ];
1995 1995
         if (empty($lang_path)) {
1996 1996
             // Calculate an absolute path so it can work if CWD is not here
1997
-            $lang_path = __DIR__ . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR;
1997
+            $lang_path = __DIR__.DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR;
1998 1998
         }
1999 1999
         //Validate $langcode
2000 2000
         if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode)) {
2001 2001
             $langcode = 'en';
2002 2002
         }
2003 2003
         $foundlang = true;
2004
-        $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php';
2004
+        $lang_file = $lang_path.'phpmailer.lang-'.$langcode.'.php';
2005 2005
         // There is no English translation file
2006 2006
         if ('en' != $langcode) {
2007 2007
             // Make sure language file path is readable
@@ -2046,7 +2046,7 @@  discard block
 block discarded – undo
2046 2046
             $addresses[] = $this->addrFormat($address);
2047 2047
         }
2048 2048
 
2049
-        return $type . ': ' . implode(', ', $addresses) . static::$LE;
2049
+        return $type.': '.implode(', ', $addresses).static::$LE;
2050 2050
     }
2051 2051
 
2052 2052
     /**
@@ -2063,9 +2063,9 @@  discard block
 block discarded – undo
2063 2063
             return $this->secureHeader($addr[0]);
2064 2064
         }
2065 2065
 
2066
-        return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader(
2066
+        return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase').' <'.$this->secureHeader(
2067 2067
                 $addr[0]
2068
-            ) . '>';
2068
+            ).'>';
2069 2069
     }
2070 2070
 
2071 2071
     /**
@@ -2122,10 +2122,10 @@  discard block
 block discarded – undo
2122 2122
                             }
2123 2123
                             $part = substr($word, 0, $len);
2124 2124
                             $word = substr($word, $len);
2125
-                            $buf .= ' ' . $part;
2126
-                            $message .= $buf . sprintf('=%s', static::$LE);
2125
+                            $buf .= ' '.$part;
2126
+                            $message .= $buf.sprintf('=%s', static::$LE);
2127 2127
                         } else {
2128
-                            $message .= $buf . $soft_break;
2128
+                            $message .= $buf.$soft_break;
2129 2129
                         }
2130 2130
                         $buf = '';
2131 2131
                     }
@@ -2145,7 +2145,7 @@  discard block
 block discarded – undo
2145 2145
                         $word = substr($word, $len);
2146 2146
 
2147 2147
                         if (strlen($word) > 0) {
2148
-                            $message .= $part . sprintf('=%s', static::$LE);
2148
+                            $message .= $part.sprintf('=%s', static::$LE);
2149 2149
                         } else {
2150 2150
                             $buf = $part;
2151 2151
                         }
@@ -2158,13 +2158,13 @@  discard block
 block discarded – undo
2158 2158
                     $buf .= $word;
2159 2159
 
2160 2160
                     if (strlen($buf) > $length and '' != $buf_o) {
2161
-                        $message .= $buf_o . $soft_break;
2161
+                        $message .= $buf_o.$soft_break;
2162 2162
                         $buf = $word;
2163 2163
                     }
2164 2164
                 }
2165 2165
                 $firstword = false;
2166 2166
             }
2167
-            $message .= $buf . static::$LE;
2167
+            $message .= $buf.static::$LE;
2168 2168
         }
2169 2169
 
2170 2170
         return $message;
@@ -2310,7 +2310,7 @@  discard block
 block discarded – undo
2310 2310
         if ('' == $this->XMailer) {
2311 2311
             $result .= $this->headerLine(
2312 2312
                 'X-Mailer',
2313
-                'PHPMailer ' . self::VERSION . ' (https://github.com/PHPMailer/PHPMailer)'
2313
+                'PHPMailer '.self::VERSION.' (https://github.com/PHPMailer/PHPMailer)'
2314 2314
             );
2315 2315
         } else {
2316 2316
             $myXmailer = trim($this->XMailer);
@@ -2320,7 +2320,7 @@  discard block
 block discarded – undo
2320 2320
         }
2321 2321
 
2322 2322
         if ('' != $this->ConfirmReadingTo) {
2323
-            $result .= $this->headerLine('Disposition-Notification-To', '<' . $this->ConfirmReadingTo . '>');
2323
+            $result .= $this->headerLine('Disposition-Notification-To', '<'.$this->ConfirmReadingTo.'>');
2324 2324
         }
2325 2325
 
2326 2326
         // Add custom headers
@@ -2350,23 +2350,23 @@  discard block
 block discarded – undo
2350 2350
         switch ($this->message_type) {
2351 2351
             case 'inline':
2352 2352
                 $result .= $this->headerLine('Content-Type', 'multipart/related;');
2353
-                $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
2353
+                $result .= $this->textLine("\tboundary=\"".$this->boundary[1].'"');
2354 2354
                 break;
2355 2355
             case 'attach':
2356 2356
             case 'inline_attach':
2357 2357
             case 'alt_attach':
2358 2358
             case 'alt_inline_attach':
2359 2359
                 $result .= $this->headerLine('Content-Type', 'multipart/mixed;');
2360
-                $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
2360
+                $result .= $this->textLine("\tboundary=\"".$this->boundary[1].'"');
2361 2361
                 break;
2362 2362
             case 'alt':
2363 2363
             case 'alt_inline':
2364 2364
                 $result .= $this->headerLine('Content-Type', 'multipart/alternative;');
2365
-                $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
2365
+                $result .= $this->textLine("\tboundary=\"".$this->boundary[1].'"');
2366 2366
                 break;
2367 2367
             default:
2368 2368
                 // Catches case 'plain': and case '':
2369
-                $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet);
2369
+                $result .= $this->textLine('Content-Type: '.$this->ContentType.'; charset='.$this->CharSet);
2370 2370
                 $ismultipart = false;
2371 2371
                 break;
2372 2372
         }
@@ -2401,7 +2401,7 @@  discard block
 block discarded – undo
2401 2401
      */
2402 2402
     public function getSentMIMEMessage()
2403 2403
     {
2404
-        return rtrim($this->MIMEHeader . $this->mailHeader, "\n\r") . static::$LE . static::$LE . $this->MIMEBody;
2404
+        return rtrim($this->MIMEHeader.$this->mailHeader, "\n\r").static::$LE.static::$LE.$this->MIMEBody;
2405 2405
     }
2406 2406
 
2407 2407
     /**
@@ -2438,12 +2438,12 @@  discard block
 block discarded – undo
2438 2438
         $body = '';
2439 2439
         //Create unique IDs and preset boundaries
2440 2440
         $this->uniqueid = $this->generateId();
2441
-        $this->boundary[1] = 'b1_' . $this->uniqueid;
2442
-        $this->boundary[2] = 'b2_' . $this->uniqueid;
2443
-        $this->boundary[3] = 'b3_' . $this->uniqueid;
2441
+        $this->boundary[1] = 'b1_'.$this->uniqueid;
2442
+        $this->boundary[2] = 'b2_'.$this->uniqueid;
2443
+        $this->boundary[3] = 'b3_'.$this->uniqueid;
2444 2444
 
2445 2445
         if ($this->sign_key_file) {
2446
-            $body .= $this->getMailMIME() . static::$LE;
2446
+            $body .= $this->getMailMIME().static::$LE;
2447 2447
         }
2448 2448
 
2449 2449
         $this->setWordWrap();
@@ -2476,7 +2476,7 @@  discard block
 block discarded – undo
2476 2476
             $altBodyEncoding = 'quoted-printable';
2477 2477
         }
2478 2478
         //Use this as a preamble in all multipart message types
2479
-        $mimepre = 'This is a multi-part message in MIME format.' . static::$LE;
2479
+        $mimepre = 'This is a multi-part message in MIME format.'.static::$LE;
2480 2480
         switch ($this->message_type) {
2481 2481
             case 'inline':
2482 2482
                 $body .= $mimepre;
@@ -2494,9 +2494,9 @@  discard block
 block discarded – undo
2494 2494
                 break;
2495 2495
             case 'inline_attach':
2496 2496
                 $body .= $mimepre;
2497
-                $body .= $this->textLine('--' . $this->boundary[1]);
2497
+                $body .= $this->textLine('--'.$this->boundary[1]);
2498 2498
                 $body .= $this->headerLine('Content-Type', 'multipart/related;');
2499
-                $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
2499
+                $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"');
2500 2500
                 $body .= static::$LE;
2501 2501
                 $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding);
2502 2502
                 $body .= $this->encodeString($this->Body, $bodyEncoding);
@@ -2525,9 +2525,9 @@  discard block
 block discarded – undo
2525 2525
                 $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding);
2526 2526
                 $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
2527 2527
                 $body .= static::$LE;
2528
-                $body .= $this->textLine('--' . $this->boundary[1]);
2528
+                $body .= $this->textLine('--'.$this->boundary[1]);
2529 2529
                 $body .= $this->headerLine('Content-Type', 'multipart/related;');
2530
-                $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
2530
+                $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"');
2531 2531
                 $body .= static::$LE;
2532 2532
                 $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding);
2533 2533
                 $body .= $this->encodeString($this->Body, $bodyEncoding);
@@ -2538,9 +2538,9 @@  discard block
 block discarded – undo
2538 2538
                 break;
2539 2539
             case 'alt_attach':
2540 2540
                 $body .= $mimepre;
2541
-                $body .= $this->textLine('--' . $this->boundary[1]);
2541
+                $body .= $this->textLine('--'.$this->boundary[1]);
2542 2542
                 $body .= $this->headerLine('Content-Type', 'multipart/alternative;');
2543
-                $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
2543
+                $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"');
2544 2544
                 $body .= static::$LE;
2545 2545
                 $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding);
2546 2546
                 $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
@@ -2558,16 +2558,16 @@  discard block
 block discarded – undo
2558 2558
                 break;
2559 2559
             case 'alt_inline_attach':
2560 2560
                 $body .= $mimepre;
2561
-                $body .= $this->textLine('--' . $this->boundary[1]);
2561
+                $body .= $this->textLine('--'.$this->boundary[1]);
2562 2562
                 $body .= $this->headerLine('Content-Type', 'multipart/alternative;');
2563
-                $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
2563
+                $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"');
2564 2564
                 $body .= static::$LE;
2565 2565
                 $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding);
2566 2566
                 $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
2567 2567
                 $body .= static::$LE;
2568
-                $body .= $this->textLine('--' . $this->boundary[2]);
2568
+                $body .= $this->textLine('--'.$this->boundary[2]);
2569 2569
                 $body .= $this->headerLine('Content-Type', 'multipart/related;');
2570
-                $body .= $this->textLine("\tboundary=\"" . $this->boundary[3] . '"');
2570
+                $body .= $this->textLine("\tboundary=\"".$this->boundary[3].'"');
2571 2571
                 $body .= static::$LE;
2572 2572
                 $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, 'text/html', $bodyEncoding);
2573 2573
                 $body .= $this->encodeString($this->Body, $bodyEncoding);
@@ -2594,12 +2594,12 @@  discard block
 block discarded – undo
2594 2594
         } elseif ($this->sign_key_file) {
2595 2595
             try {
2596 2596
                 if (!defined('PKCS7_TEXT')) {
2597
-                    throw new Exception($this->lang('extension_missing') . 'openssl');
2597
+                    throw new Exception($this->lang('extension_missing').'openssl');
2598 2598
                 }
2599 2599
                 // @TODO would be nice to use php://temp streams here
2600 2600
                 $file = tempnam(sys_get_temp_dir(), 'mail');
2601 2601
                 if (false === file_put_contents($file, $body)) {
2602
-                    throw new Exception($this->lang('signing') . ' Could not write temp file');
2602
+                    throw new Exception($this->lang('signing').' Could not write temp file');
2603 2603
                 }
2604 2604
                 $signed = tempnam(sys_get_temp_dir(), 'signed');
2605 2605
                 //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197
@@ -2607,16 +2607,16 @@  discard block
 block discarded – undo
2607 2607
                     $sign = @openssl_pkcs7_sign(
2608 2608
                         $file,
2609 2609
                         $signed,
2610
-                        'file://' . realpath($this->sign_cert_file),
2611
-                        ['file://' . realpath($this->sign_key_file), $this->sign_key_pass],
2610
+                        'file://'.realpath($this->sign_cert_file),
2611
+                        ['file://'.realpath($this->sign_key_file), $this->sign_key_pass],
2612 2612
                         []
2613 2613
                     );
2614 2614
                 } else {
2615 2615
                     $sign = @openssl_pkcs7_sign(
2616 2616
                         $file,
2617 2617
                         $signed,
2618
-                        'file://' . realpath($this->sign_cert_file),
2619
-                        ['file://' . realpath($this->sign_key_file), $this->sign_key_pass],
2618
+                        'file://'.realpath($this->sign_cert_file),
2619
+                        ['file://'.realpath($this->sign_key_file), $this->sign_key_pass],
2620 2620
                         [],
2621 2621
                         PKCS7_DETACHED,
2622 2622
                         $this->sign_extracerts_file
@@ -2628,11 +2628,11 @@  discard block
 block discarded – undo
2628 2628
                     @unlink($signed);
2629 2629
                     //The message returned by openssl contains both headers and body, so need to split them up
2630 2630
                     $parts = explode("\n\n", $body, 2);
2631
-                    $this->MIMEHeader .= $parts[0] . static::$LE . static::$LE;
2631
+                    $this->MIMEHeader .= $parts[0].static::$LE.static::$LE;
2632 2632
                     $body = $parts[1];
2633 2633
                 } else {
2634 2634
                     @unlink($signed);
2635
-                    throw new Exception($this->lang('signing') . openssl_error_string());
2635
+                    throw new Exception($this->lang('signing').openssl_error_string());
2636 2636
                 }
2637 2637
             } catch (Exception $exc) {
2638 2638
                 $body = '';
@@ -2667,7 +2667,7 @@  discard block
 block discarded – undo
2667 2667
         if ('' == $encoding) {
2668 2668
             $encoding = $this->Encoding;
2669 2669
         }
2670
-        $result .= $this->textLine('--' . $boundary);
2670
+        $result .= $this->textLine('--'.$boundary);
2671 2671
         $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet);
2672 2672
         $result .= static::$LE;
2673 2673
         // RFC1341 part 5 says 7bit is assumed if not specified
@@ -2688,7 +2688,7 @@  discard block
 block discarded – undo
2688 2688
      */
2689 2689
     protected function endBoundary($boundary)
2690 2690
     {
2691
-        return static::$LE . '--' . $boundary . '--' . static::$LE;
2691
+        return static::$LE.'--'.$boundary.'--'.static::$LE;
2692 2692
     }
2693 2693
 
2694 2694
     /**
@@ -2724,7 +2724,7 @@  discard block
 block discarded – undo
2724 2724
      */
2725 2725
     public function headerLine($name, $value)
2726 2726
     {
2727
-        return $name . ': ' . $value . static::$LE;
2727
+        return $name.': '.$value.static::$LE;
2728 2728
     }
2729 2729
 
2730 2730
     /**
@@ -2736,7 +2736,7 @@  discard block
 block discarded – undo
2736 2736
      */
2737 2737
     public function textLine($value)
2738 2738
     {
2739
-        return $value . static::$LE;
2739
+        return $value.static::$LE;
2740 2740
     }
2741 2741
 
2742 2742
     /**
@@ -2758,7 +2758,7 @@  discard block
 block discarded – undo
2758 2758
     {
2759 2759
         try {
2760 2760
             if (!@is_file($path)) {
2761
-                throw new Exception($this->lang('file_access') . $path, self::STOP_CONTINUE);
2761
+                throw new Exception($this->lang('file_access').$path, self::STOP_CONTINUE);
2762 2762
             }
2763 2763
 
2764 2764
             // If a MIME type is not specified, try to work it out from the file name
@@ -2885,7 +2885,7 @@  discard block
 block discarded – undo
2885 2885
                             'Content-Disposition: %s; filename="%s"%s',
2886 2886
                             $disposition,
2887 2887
                             $encoded_name,
2888
-                            static::$LE . static::$LE
2888
+                            static::$LE.static::$LE
2889 2889
                         );
2890 2890
                     } else {
2891 2891
                         if (!empty($encoded_name)) {
@@ -2893,13 +2893,13 @@  discard block
 block discarded – undo
2893 2893
                                 'Content-Disposition: %s; filename=%s%s',
2894 2894
                                 $disposition,
2895 2895
                                 $encoded_name,
2896
-                                static::$LE . static::$LE
2896
+                                static::$LE.static::$LE
2897 2897
                             );
2898 2898
                         } else {
2899 2899
                             $mime[] = sprintf(
2900 2900
                                 'Content-Disposition: %s%s',
2901 2901
                                 $disposition,
2902
-                                static::$LE . static::$LE
2902
+                                static::$LE.static::$LE
2903 2903
                             );
2904 2904
                         }
2905 2905
                     }
@@ -2940,11 +2940,11 @@  discard block
 block discarded – undo
2940 2940
     {
2941 2941
         try {
2942 2942
             if (!file_exists($path)) {
2943
-                throw new Exception($this->lang('file_open') . $path, self::STOP_CONTINUE);
2943
+                throw new Exception($this->lang('file_open').$path, self::STOP_CONTINUE);
2944 2944
             }
2945 2945
             $file_buffer = file_get_contents($path);
2946 2946
             if (false === $file_buffer) {
2947
-                throw new Exception($this->lang('file_open') . $path, self::STOP_CONTINUE);
2947
+                throw new Exception($this->lang('file_open').$path, self::STOP_CONTINUE);
2948 2948
             }
2949 2949
             $file_buffer = $this->encodeString($file_buffer, $encoding);
2950 2950
 
@@ -2991,7 +2991,7 @@  discard block
 block discarded – undo
2991 2991
                 $encoded = $this->encodeQP($str);
2992 2992
                 break;
2993 2993
             default:
2994
-                $this->setError($this->lang('encoding') . $encoding);
2994
+                $this->setError($this->lang('encoding').$encoding);
2995 2995
                 break;
2996 2996
         }
2997 2997
 
@@ -3057,7 +3057,7 @@  discard block
 block discarded – undo
3057 3057
                 $maxlen -= $maxlen % 4;
3058 3058
                 $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
3059 3059
             }
3060
-            $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded);
3060
+            $encoded = preg_replace('/^(.*)$/m', ' =?'.$this->CharSet."?$encoding?\\1?=", $encoded);
3061 3061
         } elseif ($matchcount > 0) {
3062 3062
             //1 or more chars need encoding, use Q-encode
3063 3063
             $encoding = 'Q';
@@ -3065,8 +3065,8 @@  discard block
 block discarded – undo
3065 3065
             $maxlen = static::STD_LINE_LENGTH - $lengthsub - 8 - strlen($this->CharSet);
3066 3066
             $encoded = $this->encodeQ($str, $position);
3067 3067
             $encoded = $this->wrapText($encoded, $maxlen, true);
3068
-            $encoded = str_replace('=' . static::$LE, "\n", trim($encoded));
3069
-            $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded);
3068
+            $encoded = str_replace('='.static::$LE, "\n", trim($encoded));
3069
+            $encoded = preg_replace('/^(.*)$/m', ' =?'.$this->CharSet."?$encoding?\\1?=", $encoded);
3070 3070
         } elseif (strlen($str) > $maxlen) {
3071 3071
             //No chars need encoding, but line is too long, so fold it
3072 3072
             $encoded = trim($this->wrapText($str, $maxlen, false));
@@ -3127,7 +3127,7 @@  discard block
 block discarded – undo
3127 3127
      */
3128 3128
     public function base64EncodeWrapMB($str, $linebreak = null)
3129 3129
     {
3130
-        $start = '=?' . $this->CharSet . '?B?';
3130
+        $start = '=?'.$this->CharSet.'?B?';
3131 3131
         $end = '?=';
3132 3132
         $encoded = '';
3133 3133
         if (null === $linebreak) {
@@ -3150,7 +3150,7 @@  discard block
 block discarded – undo
3150 3150
                 $chunk = base64_encode($chunk);
3151 3151
                 ++$lookBack;
3152 3152
             } while (strlen($chunk) > $length);
3153
-            $encoded .= $chunk . $linebreak;
3153
+            $encoded .= $chunk.$linebreak;
3154 3154
         }
3155 3155
 
3156 3156
         // Chomp the last linefeed
@@ -3203,7 +3203,7 @@  discard block
 block discarded – undo
3203 3203
                 // RFC 2047 section 5.1
3204 3204
                 // Replace every high ascii, control, =, ? and _ characters
3205 3205
                 /** @noinspection SuspiciousAssignmentsInspection */
3206
-                $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
3206
+                $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377'.$pattern;
3207 3207
                 break;
3208 3208
         }
3209 3209
         $matches = [];
@@ -3216,7 +3216,7 @@  discard block
 block discarded – undo
3216 3216
                 array_unshift($matches[0], '=');
3217 3217
             }
3218 3218
             foreach (array_unique($matches[0]) as $char) {
3219
-                $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
3219
+                $encoded = str_replace($char, '='.sprintf('%02X', ord($char)), $encoded);
3220 3220
             }
3221 3221
         }
3222 3222
         // Replace spaces with _ (more readable than =20)
@@ -3241,7 +3241,7 @@  discard block
 block discarded – undo
3241 3241
         $encoding = 'base64',
3242 3242
         $type = '',
3243 3243
         $disposition = 'attachment'
3244
-    ) {
3244
+    ){
3245 3245
         // If a MIME type is not specified, try to work it out from the file name
3246 3246
         if ('' == $type) {
3247 3247
             $type = static::filenameToType($filename);
@@ -3281,7 +3281,7 @@  discard block
 block discarded – undo
3281 3281
     public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline')
3282 3282
     {
3283 3283
         if (!@is_file($path)) {
3284
-            $this->setError($this->lang('file_access') . $path);
3284
+            $this->setError($this->lang('file_access').$path);
3285 3285
 
3286 3286
             return false;
3287 3287
         }
@@ -3335,7 +3335,7 @@  discard block
 block discarded – undo
3335 3335
         $encoding = 'base64',
3336 3336
         $type = '',
3337 3337
         $disposition = 'inline'
3338
-    ) {
3338
+    ){
3339 3339
         // If a MIME type is not specified, try to work it out from the name
3340 3340
         if ('' == $type and !empty($name)) {
3341 3341
             $type = static::filenameToType($name);
@@ -3425,7 +3425,7 @@  discard block
 block discarded – undo
3425 3425
     {
3426 3426
         $this->RecipientsQueue = array_filter(
3427 3427
             $this->RecipientsQueue,
3428
-            function ($params) use ($kind) {
3428
+            function($params) use ($kind) {
3429 3429
                 return $params[0] != $kind;
3430 3430
             }
3431 3431
         );
@@ -3515,15 +3515,15 @@  discard block
 block discarded – undo
3515 3515
         if ('smtp' == $this->Mailer and null !== $this->smtp) {
3516 3516
             $lasterror = $this->smtp->getError();
3517 3517
             if (!empty($lasterror['error'])) {
3518
-                $msg .= $this->lang('smtp_error') . $lasterror['error'];
3518
+                $msg .= $this->lang('smtp_error').$lasterror['error'];
3519 3519
                 if (!empty($lasterror['detail'])) {
3520
-                    $msg .= ' Detail: ' . $lasterror['detail'];
3520
+                    $msg .= ' Detail: '.$lasterror['detail'];
3521 3521
                 }
3522 3522
                 if (!empty($lasterror['smtp_code'])) {
3523
-                    $msg .= ' SMTP code: ' . $lasterror['smtp_code'];
3523
+                    $msg .= ' SMTP code: '.$lasterror['smtp_code'];
3524 3524
                 }
3525 3525
                 if (!empty($lasterror['smtp_code_ex'])) {
3526
-                    $msg .= ' Additional SMTP info: ' . $lasterror['smtp_code_ex'];
3526
+                    $msg .= ' Additional SMTP info: '.$lasterror['smtp_code_ex'];
3527 3527
                 }
3528 3528
             }
3529 3529
         }
@@ -3596,7 +3596,7 @@  discard block
 block discarded – undo
3596 3596
             //Is it a valid IPv4 address?
3597 3597
             return (bool) filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
3598 3598
         }
3599
-        if (filter_var('http://' . $host, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) {
3599
+        if (filter_var('http://'.$host, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) {
3600 3600
             //Is it a syntactically valid hostname?
3601 3601
             return true;
3602 3602
         }
@@ -3622,7 +3622,7 @@  discard block
 block discarded – undo
3622 3622
                 //Include a link to troubleshooting docs on SMTP connection failure
3623 3623
                 //this is by far the biggest cause of support questions
3624 3624
                 //but it's usually not PHPMailer's fault.
3625
-                return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting';
3625
+                return $this->language[$key].' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting';
3626 3626
             }
3627 3627
 
3628 3628
             return $this->language[$key];
@@ -3710,14 +3710,14 @@  discard block
 block discarded – undo
3710 3710
                     }
3711 3711
                     //Hash the decoded data, not the URL so that the same data-URI image used in multiple places
3712 3712
                     //will only be embedded once, even if it used a different encoding
3713
-                    $cid = hash('sha256', $data) . '@phpmailer.0'; // RFC2392 S 2
3713
+                    $cid = hash('sha256', $data).'@phpmailer.0'; // RFC2392 S 2
3714 3714
 
3715 3715
                     if (!$this->cidExists($cid)) {
3716
-                        $this->addStringEmbeddedImage($data, $cid, 'embed' . $imgindex, 'base64', $match[1]);
3716
+                        $this->addStringEmbeddedImage($data, $cid, 'embed'.$imgindex, 'base64', $match[1]);
3717 3717
                     }
3718 3718
                     $message = str_replace(
3719 3719
                         $images[0][$imgindex],
3720
-                        $images[1][$imgindex] . '="cid:' . $cid . '"',
3720
+                        $images[1][$imgindex].'="cid:'.$cid.'"',
3721 3721
                         $message
3722 3722
                     );
3723 3723
                     continue;
@@ -3736,7 +3736,7 @@  discard block
 block discarded – undo
3736 3736
                     if ('.' == $directory) {
3737 3737
                         $directory = '';
3738 3738
                     }
3739
-                    $cid = hash('sha256', $url) . '@phpmailer.0'; // RFC2392 S 2
3739
+                    $cid = hash('sha256', $url).'@phpmailer.0'; // RFC2392 S 2
3740 3740
                     if (strlen($basedir) > 1 and '/' != substr($basedir, -1)) {
3741 3741
                         $basedir .= '/';
3742 3742
                     }
@@ -3744,7 +3744,7 @@  discard block
 block discarded – undo
3744 3744
                         $directory .= '/';
3745 3745
                     }
3746 3746
                     if ($this->addEmbeddedImage(
3747
-                        $basedir . $directory . $filename,
3747
+                        $basedir.$directory.$filename,
3748 3748
                         $cid,
3749 3749
                         $filename,
3750 3750
                         'base64',
@@ -3752,8 +3752,8 @@  discard block
 block discarded – undo
3752 3752
                     )
3753 3753
                     ) {
3754 3754
                         $message = preg_replace(
3755
-                            '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui',
3756
-                            $images[1][$imgindex] . '="cid:' . $cid . '"',
3755
+                            '/'.$images[1][$imgindex].'=["\']'.preg_quote($url, '/').'["\']/Ui',
3756
+                            $images[1][$imgindex].'="cid:'.$cid.'"',
3757 3757
                             $message
3758 3758
                         );
3759 3759
                     }
@@ -4027,7 +4027,7 @@  discard block
 block discarded – undo
4027 4027
 
4028 4028
             return true;
4029 4029
         }
4030
-        $this->setError($this->lang('variable_set') . $name);
4030
+        $this->setError($this->lang('variable_set').$name);
4031 4031
 
4032 4032
         return false;
4033 4033
     }
@@ -4121,7 +4121,7 @@  discard block
 block discarded – undo
4121 4121
             if (((0x21 <= $ord) and ($ord <= 0x3A)) or $ord == 0x3C or ((0x3E <= $ord) and ($ord <= 0x7E))) {
4122 4122
                 $line .= $txt[$i];
4123 4123
             } else {
4124
-                $line .= '=' . sprintf('%02X', $ord);
4124
+                $line .= '='.sprintf('%02X', $ord);
4125 4125
             }
4126 4126
         }
4127 4127
 
@@ -4141,14 +4141,13 @@  discard block
 block discarded – undo
4141 4141
     {
4142 4142
         if (!defined('PKCS7_TEXT')) {
4143 4143
             if ($this->exceptions) {
4144
-                throw new Exception($this->lang('extension_missing') . 'openssl');
4144
+                throw new Exception($this->lang('extension_missing').'openssl');
4145 4145
             }
4146 4146
 
4147 4147
             return '';
4148 4148
         }
4149 4149
         $privKeyStr = !empty($this->DKIM_private_string) ?
4150
-            $this->DKIM_private_string :
4151
-            file_get_contents($this->DKIM_private);
4150
+            $this->DKIM_private_string : file_get_contents($this->DKIM_private);
4152 4151
         if ('' != $this->DKIM_passphrase) {
4153 4152
             $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
4154 4153
         } else {
@@ -4200,7 +4199,7 @@  discard block
 block discarded – undo
4200 4199
             //But then says to delete space before and after the colon.
4201 4200
             //Net result is the same as trimming both ends of the value.
4202 4201
             //by elimination, the same applies to the field name
4203
-            $lines[$key] = trim($heading, " \t") . ':' . trim($value, " \t");
4202
+            $lines[$key] = trim($heading, " \t").':'.trim($value, " \t");
4204 4203
         }
4205 4204
 
4206 4205
         return implode("\r\n", $lines);
@@ -4226,7 +4225,7 @@  discard block
 block discarded – undo
4226 4225
         $body = static::normalizeBreaks($body, "\r\n");
4227 4226
 
4228 4227
         //Reduce multiple trailing line breaks to a single one
4229
-        return rtrim($body, "\r\n") . "\r\n";
4228
+        return rtrim($body, "\r\n")."\r\n";
4230 4229
     }
4231 4230
 
4232 4231
     /**
@@ -4282,33 +4281,33 @@  discard block
 block discarded – undo
4282 4281
         if ('' == $this->DKIM_identity) {
4283 4282
             $ident = '';
4284 4283
         } else {
4285
-            $ident = ' i=' . $this->DKIM_identity . ';';
4286
-        }
4287
-        $dkimhdrs = 'DKIM-Signature: v=1; a=' .
4288
-            $DKIMsignatureType . '; q=' .
4289
-            $DKIMquery . '; l=' .
4290
-            $DKIMlen . '; s=' .
4291
-            $this->DKIM_selector .
4292
-            ";\r\n" .
4293
-            "\tt=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" .
4294
-            "\th=From:To:Date:Subject;\r\n" .
4295
-            "\td=" . $this->DKIM_domain . ';' . $ident . "\r\n" .
4296
-            "\tz=$from\r\n" .
4297
-            "\t|$to\r\n" .
4298
-            "\t|$date\r\n" .
4299
-            "\t|$subject;\r\n" .
4300
-            "\tbh=" . $DKIMb64 . ";\r\n" .
4284
+            $ident = ' i='.$this->DKIM_identity.';';
4285
+        }
4286
+        $dkimhdrs = 'DKIM-Signature: v=1; a='.
4287
+            $DKIMsignatureType.'; q='.
4288
+            $DKIMquery.'; l='.
4289
+            $DKIMlen.'; s='.
4290
+            $this->DKIM_selector.
4291
+            ";\r\n".
4292
+            "\tt=".$DKIMtime.'; c='.$DKIMcanonicalization.";\r\n".
4293
+            "\th=From:To:Date:Subject;\r\n".
4294
+            "\td=".$this->DKIM_domain.';'.$ident."\r\n".
4295
+            "\tz=$from\r\n".
4296
+            "\t|$to\r\n".
4297
+            "\t|$date\r\n".
4298
+            "\t|$subject;\r\n".
4299
+            "\tbh=".$DKIMb64.";\r\n".
4301 4300
             "\tb=";
4302 4301
         $toSign = $this->DKIM_HeaderC(
4303
-            $from_header . "\r\n" .
4304
-            $to_header . "\r\n" .
4305
-            $date_header . "\r\n" .
4306
-            $subject_header . "\r\n" .
4302
+            $from_header."\r\n".
4303
+            $to_header."\r\n".
4304
+            $date_header."\r\n".
4305
+            $subject_header."\r\n".
4307 4306
             $dkimhdrs
4308 4307
         );
4309 4308
         $signed = $this->DKIM_Sign($toSign);
4310 4309
 
4311
-        return static::normalizeBreaks($dkimhdrs . $signed) . static::$LE;
4310
+        return static::normalizeBreaks($dkimhdrs.$signed).static::$LE;
4312 4311
     }
4313 4312
 
4314 4313
     /**
@@ -4321,7 +4320,7 @@  discard block
 block discarded – undo
4321 4320
      */
4322 4321
     public static function hasLineLongerThanMax($str)
4323 4322
     {
4324
-        return (bool) preg_match('/^(.{' . (self::MAX_LINE_LENGTH + strlen(static::$LE)) . ',})/m', $str);
4323
+        return (bool) preg_match('/^(.{'.(self::MAX_LINE_LENGTH + strlen(static::$LE)).',})/m', $str);
4325 4324
     }
4326 4325
 
4327 4326
     /**
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2059,7 +2059,8 @@  discard block
 block discarded – undo
2059 2059
      */
2060 2060
     public function addrFormat($addr)
2061 2061
     {
2062
-        if (empty($addr[1])) { // No name provided
2062
+        if (empty($addr[1])) {
2063
+// No name provided
2063 2064
             return $this->secureHeader($addr[0]);
2064 2065
         }
2065 2066
 
@@ -3425,7 +3426,7 @@  discard block
 block discarded – undo
3425 3426
     {
3426 3427
         $this->RecipientsQueue = array_filter(
3427 3428
             $this->RecipientsQueue,
3428
-            function ($params) use ($kind) {
3429
+            function ($params) use ($kind){
3429 3430
                 return $params[0] != $kind;
3430 3431
             }
3431 3432
         );
Please login to merge, or discard this patch.
manager/includes/controls/phpmailer/POP3.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@
 block discarded – undo
209 209
      * Connect to a POP3 server.
210 210
      *
211 211
      * @param string   $host
212
-     * @param int|bool $port
212
+     * @param integer $port
213 213
      * @param int      $tval
214 214
      *
215 215
      * @return bool
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         $username = '',
150 150
         $password = '',
151 151
         $debug_level = 0
152
-    ) {
152
+    ){
153 153
         $pop = new self();
154 154
 
155 155
         return $pop->authorise($host, $port, $timeout, $username, $password, $debug_level);
@@ -288,11 +288,11 @@  discard block
 block discarded – undo
288 288
         }
289 289
 
290 290
         // Send the Username
291
-        $this->sendString("USER $username" . static::LE);
291
+        $this->sendString("USER $username".static::LE);
292 292
         $pop3_response = $this->getResponse();
293 293
         if ($this->checkResponse($pop3_response)) {
294 294
             // Send the Password
295
-            $this->sendString("PASS $password" . static::LE);
295
+            $this->sendString("PASS $password".static::LE);
296 296
             $pop3_response = $this->getResponse();
297 297
             if ($this->checkResponse($pop3_response)) {
298 298
                 return true;
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
     protected function catchWarning($errno, $errstr, $errfile, $errline)
413 413
     {
414 414
         $this->setError(
415
-            'Connecting to the POP3 server raised a PHP warning:' .
415
+            'Connecting to the POP3 server raised a PHP warning:'.
416 416
             "errno: $errno errstr: $errstr; errfile: $errfile; errline: $errline"
417 417
         );
418 418
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -344,7 +344,8 @@
 block discarded – undo
344 344
     protected function sendString($string)
345 345
     {
346 346
         if ($this->pop_conn) {
347
-            if ($this->do_debug >= 2) { //Show client messages when debug >= 2
347
+            if ($this->do_debug >= 2) {
348
+//Show client messages when debug >= 2
348 349
                 echo 'Client -> Server: ', $string;
349 350
             }
350 351
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -288,11 +288,11 @@
 block discarded – undo
288 288
         }
289 289
 
290 290
         // Send the Username
291
-        $this->sendString("USER $username" . static::LE);
291
+        $this->sendString("user $username" . static::LE);
292 292
         $pop3_response = $this->getResponse();
293 293
         if ($this->checkResponse($pop3_response)) {
294 294
             // Send the Password
295
-            $this->sendString("PASS $password" . static::LE);
295
+            $this->sendString("pass $password" . static::LE);
296 296
             $pop3_response = $this->getResponse();
297 297
             if ($this->checkResponse($pop3_response)) {
298 298
                 return true;
Please login to merge, or discard this patch.
manager/includes/controls/phpmailer/SMTP.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1314,7 +1314,7 @@
 block discarded – undo
1314 1314
      * If no reply has been received yet, it will return null.
1315 1315
      * If no pattern was matched, it will return false.
1316 1316
      *
1317
-     * @return bool|null|string
1317
+     * @return string
1318 1318
      *
1319 1319
      * @see recordLastTransactionID()
1320 1320
      */
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         }
308 308
         // Connect to the SMTP server
309 309
         $this->edebug(
310
-            "Connection: opening to $host:$port, timeout=$timeout, options=" .
310
+            "Connection: opening to $host:$port, timeout=$timeout, options=".
311 311
             (count($options) > 0 ? var_export($options, true) : 'array()'),
312 312
             self::DEBUG_CONNECTION
313 313
         );
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
             $socket_context = stream_context_create($options);
318 318
             set_error_handler([$this, 'errorHandler']);
319 319
             $this->smtp_conn = stream_socket_client(
320
-                $host . ':' . $port,
320
+                $host.':'.$port,
321 321
                 $errno,
322 322
                 $errstr,
323 323
                 $timeout,
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
                 (string) $errstr
351 351
             );
352 352
             $this->edebug(
353
-                'SMTP ERROR: ' . $this->error['error']
353
+                'SMTP ERROR: '.$this->error['error']
354 354
                 . ": $errstr ($errno)",
355 355
                 self::DEBUG_CLIENT
356 356
             );
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
         }
371 371
         // Get any announcement
372 372
         $announce = $this->get_lines();
373
-        $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER);
373
+        $this->edebug('SERVER -> CLIENT: '.$announce, self::DEBUG_SERVER);
374 374
 
375 375
         return true;
376 376
     }
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
         $password,
427 427
         $authtype = null,
428 428
         $OAuth = null
429
-    ) {
429
+    ){
430 430
         if (!$this->server_caps) {
431 431
             $this->setError('Authentication is not allowed before HELO/EHLO');
432 432
 
@@ -443,15 +443,15 @@  discard block
 block discarded – undo
443 443
                 return false;
444 444
             }
445 445
 
446
-            $this->edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL);
446
+            $this->edebug('Auth method requested: '.($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL);
447 447
             $this->edebug(
448
-                'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']),
448
+                'Auth methods available on the server: '.implode(',', $this->server_caps['AUTH']),
449 449
                 self::DEBUG_LOWLEVEL
450 450
             );
451 451
 
452 452
             //If we have requested a specific auth type, check the server supports it before trying others
453 453
             if (!in_array($authtype, $this->server_caps['AUTH'])) {
454
-                $this->edebug('Requested auth method not available: ' . $authtype, self::DEBUG_LOWLEVEL);
454
+                $this->edebug('Requested auth method not available: '.$authtype, self::DEBUG_LOWLEVEL);
455 455
                 $authtype = null;
456 456
             }
457 457
 
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 
470 470
                     return false;
471 471
                 }
472
-                self::edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL);
472
+                self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL);
473 473
             }
474 474
 
475 475
             if (!in_array($authtype, $this->server_caps['AUTH'])) {
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
                 // Send encoded username and password
490 490
                 if (!$this->sendCommand(
491 491
                     'User & Password',
492
-                    base64_encode("\0" . $username . "\0" . $password),
492
+                    base64_encode("\0".$username."\0".$password),
493 493
                     235
494 494
                 )
495 495
                 ) {
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
                 $challenge = base64_decode(substr($this->last_reply, 4));
518 518
 
519 519
                 // Build the response
520
-                $response = $username . ' ' . $this->hmac($challenge, $password);
520
+                $response = $username.' '.$this->hmac($challenge, $password);
521 521
 
522 522
                 // send encoded credentials
523 523
                 return $this->sendCommand('Username', base64_encode($response), 235);
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
                 $oauth = $OAuth->getOauth64();
530 530
 
531 531
                 // Start authentication
532
-                if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) {
532
+                if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 '.$oauth, 235)) {
533 533
                     return false;
534 534
                 }
535 535
                 break;
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
         $k_ipad = $key ^ $ipad;
577 577
         $k_opad = $key ^ $opad;
578 578
 
579
-        return md5($k_opad . pack('H*', md5($k_ipad . $data)));
579
+        return md5($k_opad.pack('H*', md5($k_ipad.$data)));
580 580
     }
581 581
 
582 582
     /**
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
                 }
692 692
                 //If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1
693 693
                 if ($in_headers) {
694
-                    $line = "\t" . $line;
694
+                    $line = "\t".$line;
695 695
                 }
696 696
             }
697 697
             $lines_out[] = $line;
@@ -700,9 +700,9 @@  discard block
 block discarded – undo
700 700
             foreach ($lines_out as $line_out) {
701 701
                 //RFC2821 section 4.5.2
702 702
                 if (!empty($line_out) and $line_out[0] == '.') {
703
-                    $line_out = '.' . $line_out;
703
+                    $line_out = '.'.$line_out;
704 704
                 }
705
-                $this->client_send($line_out . static::LE, 'DATA');
705
+                $this->client_send($line_out.static::LE, 'DATA');
706 706
             }
707 707
         }
708 708
 
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
      */
749 749
     protected function sendHello($hello, $host)
750 750
     {
751
-        $noerror = $this->sendCommand($hello, $hello . ' ' . $host, 250);
751
+        $noerror = $this->sendCommand($hello, $hello.' '.$host, 250);
752 752
         $this->helo_rply = $this->last_reply;
753 753
         if ($noerror) {
754 754
             $this->parseHelloFields($hello);
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 
820 820
         return $this->sendCommand(
821 821
             'MAIL FROM',
822
-            'MAIL FROM:<' . $from . '>' . $useVerp,
822
+            'MAIL FROM:<'.$from.'>'.$useVerp,
823 823
             250
824 824
         );
825 825
     }
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
     {
860 860
         return $this->sendCommand(
861 861
             'RCPT TO',
862
-            'RCPT TO:<' . $address . '>',
862
+            'RCPT TO:<'.$address.'>',
863 863
             [250, 251]
864 864
         );
865 865
     }
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 
899 899
             return false;
900 900
         }
901
-        $this->client_send($commandstring . static::LE, $command);
901
+        $this->client_send($commandstring.static::LE, $command);
902 902
 
903 903
         $this->last_reply = $this->get_lines();
904 904
         // Fetch SMTP code and possible error code explanation
@@ -908,8 +908,8 @@  discard block
 block discarded – undo
908 908
             $code_ex = (count($matches) > 2 ? $matches[2] : null);
909 909
             // Cut off error code from each response line
910 910
             $detail = preg_replace(
911
-                "/{$code}[ -]" .
912
-                ($code_ex ? str_replace('.', '\\.', $code_ex) . ' ' : '') . '/m',
911
+                "/{$code}[ -]".
912
+                ($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '').'/m',
913 913
                 '',
914 914
                 $this->last_reply
915 915
             );
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
             $detail = substr($this->last_reply, 4);
921 921
         }
922 922
 
923
-        $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
923
+        $this->edebug('SERVER -> CLIENT: '.$this->last_reply, self::DEBUG_SERVER);
924 924
 
925 925
         if (!in_array($code, (array) $expect)) {
926 926
             $this->setError(
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
                 $code_ex
931 931
             );
932 932
             $this->edebug(
933
-                'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply,
933
+                'SMTP ERROR: '.$this->error['error'].': '.$this->last_reply,
934 934
                 self::DEBUG_CLIENT
935 935
             );
936 936
 
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
     public function turn()
997 997
     {
998 998
         $this->setError('The SMTP TURN command is not implemented');
999
-        $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT);
999
+        $this->edebug('SMTP NOTICE: '.$this->error['error'], self::DEBUG_CLIENT);
1000 1000
 
1001 1001
         return false;
1002 1002
     }
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
             in_array($command, ['User & Password', 'Username', 'Password'], true)) {
1018 1018
             $this->edebug('CLIENT -> SERVER: <credentials hidden>', self::DEBUG_CLIENT);
1019 1019
         } else {
1020
-            $this->edebug('CLIENT -> SERVER: ' . $data, self::DEBUG_CLIENT);
1020
+            $this->edebug('CLIENT -> SERVER: '.$data, self::DEBUG_CLIENT);
1021 1021
         }
1022 1022
         set_error_handler([$this, 'errorHandler']);
1023 1023
         $result = fwrite($this->smtp_conn, $data);
@@ -1123,14 +1123,14 @@  discard block
 block discarded – undo
1123 1123
             //Must pass vars in here as params are by reference
1124 1124
             if (!stream_select($selR, $selW, $selW, $this->Timelimit)) {
1125 1125
                 $this->edebug(
1126
-                    'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)',
1126
+                    'SMTP -> get_lines(): timed-out ('.$this->Timeout.' sec)',
1127 1127
                     self::DEBUG_LOWLEVEL
1128 1128
                 );
1129 1129
                 break;
1130 1130
             }
1131 1131
             //Deliberate noise suppression - errors are handled afterwards
1132 1132
             $str = @fgets($this->smtp_conn, 515);
1133
-            $this->edebug('SMTP INBOUND: "' . trim($str) . '"', self::DEBUG_LOWLEVEL);
1133
+            $this->edebug('SMTP INBOUND: "'.trim($str).'"', self::DEBUG_LOWLEVEL);
1134 1134
             $data .= $str;
1135 1135
             // If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled),
1136 1136
             // or 4th character is a space, we are done reading, break the loop,
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
             $info = stream_get_meta_data($this->smtp_conn);
1143 1143
             if ($info['timed_out']) {
1144 1144
                 $this->edebug(
1145
-                    'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)',
1145
+                    'SMTP -> get_lines(): timed-out ('.$this->Timeout.' sec)',
1146 1146
                     self::DEBUG_LOWLEVEL
1147 1147
                 );
1148 1148
                 break;
@@ -1150,8 +1150,8 @@  discard block
 block discarded – undo
1150 1150
             // Now check if reads took too long
1151 1151
             if ($endtime and time() > $endtime) {
1152 1152
                 $this->edebug(
1153
-                    'SMTP -> get_lines(): timelimit reached (' .
1154
-                    $this->Timelimit . ' sec)',
1153
+                    'SMTP -> get_lines(): timelimit reached ('.
1154
+                    $this->Timelimit.' sec)',
1155 1155
                     self::DEBUG_LOWLEVEL
1156 1156
                 );
1157 1157
                 break;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
     protected function sendCommand($command, $commandstring, $expect)
889 889
     {
890 890
         if (!$this->connected()) {
891
-            $this->setError("Called $command without being connected");
891
+            $this->setError("called $command without being connected");
892 892
 
893 893
             return false;
894 894
         }
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
      */
971 971
     public function verify($name)
972 972
     {
973
-        return $this->sendCommand('VRFY', "VRFY $name", [250, 251]);
973
+        return $this->sendCommand('VRFY', "vrfy $name", [250, 251]);
974 974
     }
975 975
 
976 976
     /**
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_fastImage.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -183,6 +183,9 @@  discard block
 block discarded – undo
183 183
 	}
184 184
 
185 185
 
186
+	/**
187
+	 * @param integer $n
188
+	 */
186 189
 	private function getChars($n)
187 190
 	{
188 191
 		$response = null;
@@ -225,6 +228,9 @@  discard block
 block discarded – undo
225 228
 	}
226 229
 
227 230
 
231
+	/**
232
+	 * @param false|string $str
233
+	 */
228 234
 	private function readInt($str)
229 235
 	{
230 236
 		$size = unpack("C*", $str);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 					{
151 151
 						$state = 'skipframe';
152 152
 					}
153
-					elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF))))
153
+					elseif (in_array($b, array_merge(range(0xC0, 0xC3), range(0xC5, 0xC7), range(0xC9, 0xCB), range(0xCD, 0xCF))))
154 154
 					{
155 155
 						$state = 'readsize';
156 156
 					}
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		$response = null;
189 189
 
190 190
 		// do we need more data?
191
-		if ($this->strpos + $n -1 >= strlen($this->str))
191
+		if ($this->strpos + $n - 1 >= strlen($this->str))
192 192
 		{
193 193
 			$end = ($this->strpos + $n);
194 194
 
Please login to merge, or discard this patch.
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -13,227 +13,227 @@
 block discarded – undo
13 13
 
14 14
 class fastImage
15 15
 {
16
-	private $strpos = 0;
17
-	private $str;
18
-	private $uri;
19
-	private $type;
20
-	private $handle;
16
+    private $strpos = 0;
17
+    private $str;
18
+    private $uri;
19
+    private $type;
20
+    private $handle;
21 21
 
22
-	public function __construct($uri = null)
23
-	{
24
-		if ($uri) $this->load($uri);
25
-	}
22
+    public function __construct($uri = null)
23
+    {
24
+        if ($uri) $this->load($uri);
25
+    }
26 26
 
27 27
 
28
-	public function load($uri)
29
-	{
30
-		if ($this->handle) $this->close();
31
-
32
-		$this->uri = $uri;
33
-		$this->handle = fopen($uri, 'r');
34
-	}
35
-
36
-
37
-	public function close()
38
-	{
39
-		if (is_resource($this->handle)) fclose($this->handle);
40
-	}
28
+    public function load($uri)
29
+    {
30
+        if ($this->handle) $this->close();
31
+
32
+        $this->uri = $uri;
33
+        $this->handle = fopen($uri, 'r');
34
+    }
35
+
36
+
37
+    public function close()
38
+    {
39
+        if (is_resource($this->handle)) fclose($this->handle);
40
+    }
41 41
 
42 42
 
43
-	public function getSize()
44
-	{
45
-		$this->strpos = 0;
46
-		if ($this->getType())
47
-		{
48
-			return array_values($this->parseSize());
49
-		}
50
-
51
-		return false;
52
-	}
53
-
54
-
55
-	public function getType()
56
-	{
57
-		$this->strpos = 0;
58
-
59
-		if (!$this->type)
60
-		{
61
-			switch ($this->getChars(2))
62
-			{
63
-				case "BM":
64
-					return $this->type = 'bmp';
65
-				case "GI":
66
-					return $this->type = 'gif';
67
-				case chr(0xFF).chr(0xd8):
68
-					return $this->type = 'jpeg';
69
-				case chr(0x89).'P':
70
-					return $this->type = 'png';
71
-				default:
72
-					return false;
73
-			}
74
-		}
75
-
76
-		return $this->type;
77
-	}
78
-
79
-
80
-	private function parseSize()
81
-	{
82
-		$this->strpos = 0;
83
-
84
-		switch ($this->type)
85
-		{
86
-			case 'png':
87
-				return $this->parseSizeForPNG();
88
-			case 'gif':
89
-				return $this->parseSizeForGIF();
90
-			case 'bmp':
91
-				return $this->parseSizeForBMP();
92
-			case 'jpeg':
93
-				return $this->parseSizeForJPEG();
94
-		}
95
-
96
-		return null;
97
-	}
98
-
99
-
100
-	private function parseSizeForPNG()
101
-	{
102
-		$chars = $this->getChars(25);
103
-
104
-		return unpack("N*", substr($chars, 16, 8));
105
-	}
106
-
107
-
108
-	private function parseSizeForGIF()
109
-	{
110
-		$chars = $this->getChars(11);
111
-
112
-		return unpack("S*", substr($chars, 6, 4));
113
-	}
114
-
115
-
116
-	private function parseSizeForBMP()
117
-	{
118
-		$chars = $this->getChars(29);
119
-	 	$chars = substr($chars, 14, 14);
120
-		$type = unpack('C', $chars);
121
-
122
-		return (reset($type) == 40) ? unpack('L*', substr($chars, 4)) : unpack('L*', substr($chars, 4, 8));
123
-	}
124
-
125
-
126
-	private function parseSizeForJPEG()
127
-	{
128
-		$state = null;
129
-
130
-		while (true)
131
-		{
132
-			switch ($state)
133
-			{
134
-				default:
135
-					$this->getChars(2);
136
-					$state = 'started';
137
-					break;
138
-
139
-				case 'started':
140
-					$b = $this->getByte();
141
-					if ($b === false) return false;
142
-
143
-					$state = $b == 0xFF ? 'sof' : 'started';
144
-					break;
145
-
146
-				case 'sof':
147
-					$b = $this->getByte();
148
-					if (in_array($b, range(0xe0, 0xef)))
149
-					{
150
-						$state = 'skipframe';
151
-					}
152
-					elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF))))
153
-					{
154
-						$state = 'readsize';
155
-					}
156
-					elseif ($b == 0xFF)
157
-					{
158
-						$state = 'sof';
159
-					}
160
-					else
161
-					{
162
-						$state = 'skipframe';
163
-					}
164
-					break;
165
-
166
-				case 'skipframe':
167
-					$skip = $this->readInt($this->getChars(2)) - 2;
168
-					$state = 'doskip';
169
-					break;
170
-
171
-				case 'doskip':
172
-					$this->getChars($skip);
173
-					$state = 'started';
174
-					break;
175
-
176
-				case 'readsize':
177
-					$c = $this->getChars(7);
178
-
179
-					return array($this->readInt(substr($c, 5, 2)), $this->readInt(substr($c, 3, 2)));
180
-			}
181
-		}
182
-	}
183
-
184
-
185
-	private function getChars($n)
186
-	{
187
-		$response = null;
188
-
189
-		// do we need more data?
190
-		if ($this->strpos + $n -1 >= strlen($this->str))
191
-		{
192
-			$end = ($this->strpos + $n);
193
-
194
-			while (strlen($this->str) < $end && $response !== false)
195
-			{
196
-				// read more from the file handle
197
-				$need = $end - ftell($this->handle);
198
-
199
-				if ($response = fread($this->handle, $need))
200
-				{
201
-					$this->str .= $response;
202
-				}
203
-				else
204
-				{
205
-					return false;
206
-				}
207
-			}
208
-		}
209
-
210
-		$result = substr($this->str, $this->strpos, $n);
211
-		$this->strpos += $n;
212
-
213
-		// we are dealing with bytes here, so force the encoding
214
-		return mb_convert_encoding($result, "8BIT");
215
-	}
216
-
217
-
218
-	private function getByte()
219
-	{
220
-		$c = $this->getChars(1);
221
-		$b = unpack("C", $c);
222
-
223
-		return reset($b);
224
-	}
225
-
226
-
227
-	private function readInt($str)
228
-	{
229
-		$size = unpack("C*", $str);
230
-
231
-	    	return ($size[1] << 8) + $size[2];
232
-	}
233
-
234
-
235
-	public function __destruct()
236
-	{
237
-		$this->close();
238
-	}
43
+    public function getSize()
44
+    {
45
+        $this->strpos = 0;
46
+        if ($this->getType())
47
+        {
48
+            return array_values($this->parseSize());
49
+        }
50
+
51
+        return false;
52
+    }
53
+
54
+
55
+    public function getType()
56
+    {
57
+        $this->strpos = 0;
58
+
59
+        if (!$this->type)
60
+        {
61
+            switch ($this->getChars(2))
62
+            {
63
+                case "BM":
64
+                    return $this->type = 'bmp';
65
+                case "GI":
66
+                    return $this->type = 'gif';
67
+                case chr(0xFF).chr(0xd8):
68
+                    return $this->type = 'jpeg';
69
+                case chr(0x89).'P':
70
+                    return $this->type = 'png';
71
+                default:
72
+                    return false;
73
+            }
74
+        }
75
+
76
+        return $this->type;
77
+    }
78
+
79
+
80
+    private function parseSize()
81
+    {
82
+        $this->strpos = 0;
83
+
84
+        switch ($this->type)
85
+        {
86
+            case 'png':
87
+                return $this->parseSizeForPNG();
88
+            case 'gif':
89
+                return $this->parseSizeForGIF();
90
+            case 'bmp':
91
+                return $this->parseSizeForBMP();
92
+            case 'jpeg':
93
+                return $this->parseSizeForJPEG();
94
+        }
95
+
96
+        return null;
97
+    }
98
+
99
+
100
+    private function parseSizeForPNG()
101
+    {
102
+        $chars = $this->getChars(25);
103
+
104
+        return unpack("N*", substr($chars, 16, 8));
105
+    }
106
+
107
+
108
+    private function parseSizeForGIF()
109
+    {
110
+        $chars = $this->getChars(11);
111
+
112
+        return unpack("S*", substr($chars, 6, 4));
113
+    }
114
+
115
+
116
+    private function parseSizeForBMP()
117
+    {
118
+        $chars = $this->getChars(29);
119
+            $chars = substr($chars, 14, 14);
120
+        $type = unpack('C', $chars);
121
+
122
+        return (reset($type) == 40) ? unpack('L*', substr($chars, 4)) : unpack('L*', substr($chars, 4, 8));
123
+    }
124
+
125
+
126
+    private function parseSizeForJPEG()
127
+    {
128
+        $state = null;
129
+
130
+        while (true)
131
+        {
132
+            switch ($state)
133
+            {
134
+                default:
135
+                    $this->getChars(2);
136
+                    $state = 'started';
137
+                    break;
138
+
139
+                case 'started':
140
+                    $b = $this->getByte();
141
+                    if ($b === false) return false;
142
+
143
+                    $state = $b == 0xFF ? 'sof' : 'started';
144
+                    break;
145
+
146
+                case 'sof':
147
+                    $b = $this->getByte();
148
+                    if (in_array($b, range(0xe0, 0xef)))
149
+                    {
150
+                        $state = 'skipframe';
151
+                    }
152
+                    elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF))))
153
+                    {
154
+                        $state = 'readsize';
155
+                    }
156
+                    elseif ($b == 0xFF)
157
+                    {
158
+                        $state = 'sof';
159
+                    }
160
+                    else
161
+                    {
162
+                        $state = 'skipframe';
163
+                    }
164
+                    break;
165
+
166
+                case 'skipframe':
167
+                    $skip = $this->readInt($this->getChars(2)) - 2;
168
+                    $state = 'doskip';
169
+                    break;
170
+
171
+                case 'doskip':
172
+                    $this->getChars($skip);
173
+                    $state = 'started';
174
+                    break;
175
+
176
+                case 'readsize':
177
+                    $c = $this->getChars(7);
178
+
179
+                    return array($this->readInt(substr($c, 5, 2)), $this->readInt(substr($c, 3, 2)));
180
+            }
181
+        }
182
+    }
183
+
184
+
185
+    private function getChars($n)
186
+    {
187
+        $response = null;
188
+
189
+        // do we need more data?
190
+        if ($this->strpos + $n -1 >= strlen($this->str))
191
+        {
192
+            $end = ($this->strpos + $n);
193
+
194
+            while (strlen($this->str) < $end && $response !== false)
195
+            {
196
+                // read more from the file handle
197
+                $need = $end - ftell($this->handle);
198
+
199
+                if ($response = fread($this->handle, $need))
200
+                {
201
+                    $this->str .= $response;
202
+                }
203
+                else
204
+                {
205
+                    return false;
206
+                }
207
+            }
208
+        }
209
+
210
+        $result = substr($this->str, $this->strpos, $n);
211
+        $this->strpos += $n;
212
+
213
+        // we are dealing with bytes here, so force the encoding
214
+        return mb_convert_encoding($result, "8BIT");
215
+    }
216
+
217
+
218
+    private function getByte()
219
+    {
220
+        $c = $this->getChars(1);
221
+        $b = unpack("C", $c);
222
+
223
+        return reset($b);
224
+    }
225
+
226
+
227
+    private function readInt($str)
228
+    {
229
+        $size = unpack("C*", $str);
230
+
231
+            return ($size[1] << 8) + $size[2];
232
+    }
233
+
234
+
235
+    public function __destruct()
236
+    {
237
+        $this->close();
238
+    }
239 239
 }
Please login to merge, or discard this patch.
Braces   +26 added lines, -36 removed lines patch added patch discarded remove patch
@@ -21,13 +21,17 @@  discard block
 block discarded – undo
21 21
 
22 22
 	public function __construct($uri = null)
23 23
 	{
24
-		if ($uri) $this->load($uri);
24
+		if ($uri) {
25
+		    $this->load($uri);
26
+		}
25 27
 	}
26 28
 
27 29
 
28 30
 	public function load($uri)
29 31
 	{
30
-		if ($this->handle) $this->close();
32
+		if ($this->handle) {
33
+		    $this->close();
34
+		}
31 35
 
32 36
 		$this->uri = $uri;
33 37
 		$this->handle = fopen($uri, 'r');
@@ -36,15 +40,16 @@  discard block
 block discarded – undo
36 40
 
37 41
 	public function close()
38 42
 	{
39
-		if (is_resource($this->handle)) fclose($this->handle);
43
+		if (is_resource($this->handle)) {
44
+		    fclose($this->handle);
45
+		}
40 46
 	}
41 47
 
42 48
 
43 49
 	public function getSize()
44 50
 	{
45 51
 		$this->strpos = 0;
46
-		if ($this->getType())
47
-		{
52
+		if ($this->getType()) {
48 53
 			return array_values($this->parseSize());
49 54
 		}
50 55
 
@@ -56,10 +61,8 @@  discard block
 block discarded – undo
56 61
 	{
57 62
 		$this->strpos = 0;
58 63
 
59
-		if (!$this->type)
60
-		{
61
-			switch ($this->getChars(2))
62
-			{
64
+		if (!$this->type) {
65
+			switch ($this->getChars(2)) {
63 66
 				case "BM":
64 67
 					return $this->type = 'bmp';
65 68
 				case "GI":
@@ -81,8 +84,7 @@  discard block
 block discarded – undo
81 84
 	{
82 85
 		$this->strpos = 0;
83 86
 
84
-		switch ($this->type)
85
-		{
87
+		switch ($this->type) {
86 88
 			case 'png':
87 89
 				return $this->parseSizeForPNG();
88 90
 			case 'gif':
@@ -127,10 +129,8 @@  discard block
 block discarded – undo
127 129
 	{
128 130
 		$state = null;
129 131
 
130
-		while (true)
131
-		{
132
-			switch ($state)
133
-			{
132
+		while (true) {
133
+			switch ($state) {
134 134
 				default:
135 135
 					$this->getChars(2);
136 136
 					$state = 'started';
@@ -138,27 +138,22 @@  discard block
 block discarded – undo
138 138
 
139 139
 				case 'started':
140 140
 					$b = $this->getByte();
141
-					if ($b === false) return false;
141
+					if ($b === false) {
142
+					    return false;
143
+					}
142 144
 
143 145
 					$state = $b == 0xFF ? 'sof' : 'started';
144 146
 					break;
145 147
 
146 148
 				case 'sof':
147 149
 					$b = $this->getByte();
148
-					if (in_array($b, range(0xe0, 0xef)))
149
-					{
150
+					if (in_array($b, range(0xe0, 0xef))) {
150 151
 						$state = 'skipframe';
151
-					}
152
-					elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF))))
153
-					{
152
+					} elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF)))) {
154 153
 						$state = 'readsize';
155
-					}
156
-					elseif ($b == 0xFF)
157
-					{
154
+					} elseif ($b == 0xFF) {
158 155
 						$state = 'sof';
159
-					}
160
-					else
161
-					{
156
+					} else {
162 157
 						$state = 'skipframe';
163 158
 					}
164 159
 					break;
@@ -187,21 +182,16 @@  discard block
 block discarded – undo
187 182
 		$response = null;
188 183
 
189 184
 		// do we need more data?
190
-		if ($this->strpos + $n -1 >= strlen($this->str))
191
-		{
185
+		if ($this->strpos + $n -1 >= strlen($this->str)) {
192 186
 			$end = ($this->strpos + $n);
193 187
 
194
-			while (strlen($this->str) < $end && $response !== false)
195
-			{
188
+			while (strlen($this->str) < $end && $response !== false) {
196 189
 				// read more from the file handle
197 190
 				$need = $end - ftell($this->handle);
198 191
 
199
-				if ($response = fread($this->handle, $need))
200
-				{
192
+				if ($response = fread($this->handle, $need)) {
201 193
 					$this->str .= $response;
202
-				}
203
-				else
204
-				{
194
+				} else {
205 195
 					return false;
206 196
 				}
207 197
 			}
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_gd.php 4 patches
Doc Comments   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     * The parameter $bigger_size is the bigger dimension (width or height) of calculated sizes.
169 169
     * The other dimension (height or width) will be calculated autamaticaly
170 170
     * @param integer $bigger_size
171
-    * @return array */
171
+    * @return integer[] */
172 172
 
173 173
     public function get_prop_size($bigger_size) {
174 174
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
     * no samo po edno (x ili y) izmerenie
256 256
     * @param integer $width
257 257
     * @param integer $height
258
-    * @return bool */
258
+    * @return gd */
259 259
 
260 260
     public function resize_overflow($width, $height) {
261 261
 
@@ -397,6 +397,12 @@  discard block
 block discarded – undo
397 397
             return false;
398 398
     }
399 399
 
400
+    /**
401
+     * @param integer $x1
402
+     * @param integer $y1
403
+     * @param integer $x2
404
+     * @param integer $y2
405
+     */
400 406
     public function imagefilledrectangle($x1, $y1, $x2, $y2, $color) {
401 407
         $color = $this->gd_color($color);
402 408
         if ($color === false) return false;
Please login to merge, or discard this patch.
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -1,44 +1,44 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc GD extension class
6
-  *   @package KCFinder
7
-  *   @version 2.51
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010, 2011 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc GD extension class
6
+ *   @package KCFinder
7
+ *   @version 2.51
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010, 2011 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class gd {
16 16
 
17
-  /** GD resource
18
-    * @var resource */
17
+    /** GD resource
18
+     * @var resource */
19 19
     protected $image;
20 20
 
21
-  /** Image width
22
-    * @var integer */
21
+    /** Image width
22
+     * @var integer */
23 23
     protected $width;
24 24
 
25
-  /** Image height
26
-    * @var integer */
25
+    /** Image height
26
+     * @var integer */
27 27
     protected $height;
28 28
 
29
-  /** Init error
30
-    * @var bool */
29
+    /** Init error
30
+     * @var bool */
31 31
     public $init_error = false;
32 32
 
33
-  /** Last builded image type constant (IMAGETYPE_XXX)
34
-    * @var integer */
33
+    /** Last builded image type constant (IMAGETYPE_XXX)
34
+     * @var integer */
35 35
     public $type;
36 36
 
37
-  /** Returns an array. Element 0 - GD resource. Element 1 - width. Element 2 - height.
38
-    * Returns FALSE on failure. The only one parameter $image can be an instance of this class,
39
-    * a GD resource, an array(width, height) or path to image file.
40
-    * @param mixed $image
41
-    * @return array */
37
+    /** Returns an array. Element 0 - GD resource. Element 1 - width. Element 2 - height.
38
+     * Returns FALSE on failure. The only one parameter $image can be an instance of this class,
39
+     * a GD resource, an array(width, height) or path to image file.
40
+     * @param mixed $image
41
+     * @return array */
42 42
 
43 43
     protected function build_image($image) {
44 44
 
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
         return $return;
88 88
     }
89 89
 
90
-  /** Parameter $image can be:
91
-    *   1. An instance of this class (copy instance).
92
-    *   2. A GD resource.
93
-    *   3. An array with two elements. First - width, second - height. Create a blank image.
94
-    *   4. A filename string. Get image form file.
95
-    * The non-required parameter $bigger_size is the bigger dimension (width or height) the image
96
-    * will be resized to. The other dimension (height or width) will be calculated autamaticaly
97
-    * @param mixed $image
98
-    * @param integer $bigger_size
99
-    * @return gd */
90
+    /** Parameter $image can be:
91
+     *   1. An instance of this class (copy instance).
92
+     *   2. A GD resource.
93
+     *   3. An array with two elements. First - width, second - height. Create a blank image.
94
+     *   4. A filename string. Get image form file.
95
+     * The non-required parameter $bigger_size is the bigger dimension (width or height) the image
96
+     * will be resized to. The other dimension (height or width) will be calculated autamaticaly
97
+     * @param mixed $image
98
+     * @param integer $bigger_size
99
+     * @return gd */
100 100
 
101 101
     public function __construct($image, $bigger_size=null) {
102 102
         $this->image = $this->width = $this->height = null;
@@ -123,30 +123,30 @@  discard block
 block discarded – undo
123 123
         }
124 124
     }
125 125
 
126
-  /** Returns the GD resource
127
-    * @return resource */
126
+    /** Returns the GD resource
127
+     * @return resource */
128 128
 
129 129
     public function get_image() {
130 130
         return $this->image;
131 131
     }
132 132
 
133
-  /** Returns the image width
134
-    * @return integer */
133
+    /** Returns the image width
134
+     * @return integer */
135 135
 
136 136
     public function get_width() {
137 137
         return $this->width;
138 138
     }
139 139
 
140
-  /** Returns the image height
141
-    * @return integer */
140
+    /** Returns the image height
141
+     * @return integer */
142 142
 
143 143
     public function get_height() {
144 144
         return $this->height;
145 145
     }
146 146
 
147
-  /** Returns calculated proportional width from the given height
148
-    * @param integer $resized_height
149
-    * @return integer */
147
+    /** Returns calculated proportional width from the given height
148
+     * @param integer $resized_height
149
+     * @return integer */
150 150
 
151 151
     public function get_prop_width($resized_height) {
152 152
         $width = intval(($this->width * $resized_height) / $this->height);
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
         return $width;
155 155
     }
156 156
 
157
-  /** Returns calculated proportional height from the given width
158
-    * @param integer $resized_width
159
-    * @return integer */
157
+    /** Returns calculated proportional height from the given width
158
+     * @param integer $resized_width
159
+     * @return integer */
160 160
 
161 161
     public function get_prop_height($resized_width) {
162 162
         $height = intval(($this->height * $resized_width) / $this->width);
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
         return $height;
165 165
     }
166 166
 
167
-  /** Returns an array with calculated proportional width & height.
168
-    * The parameter $bigger_size is the bigger dimension (width or height) of calculated sizes.
169
-    * The other dimension (height or width) will be calculated autamaticaly
170
-    * @param integer $bigger_size
171
-    * @return array */
167
+    /** Returns an array with calculated proportional width & height.
168
+     * The parameter $bigger_size is the bigger dimension (width or height) of calculated sizes.
169
+     * The other dimension (height or width) will be calculated autamaticaly
170
+     * @param integer $bigger_size
171
+     * @return array */
172 172
 
173 173
     public function get_prop_size($bigger_size) {
174 174
 
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
         return array($width, $height);
187 187
     }
188 188
 
189
-  /** Resize image. Returns TRUE on success or FALSE on failure
190
-    * @param integer $width
191
-    * @param integer $height
192
-    * @return bool */
189
+    /** Resize image. Returns TRUE on success or FALSE on failure
190
+     * @param integer $width
191
+     * @param integer $height
192
+     * @return bool */
193 193
 
194 194
     public function resize($width, $height) {
195 195
         if (!$width) $width = 1;
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
         );
204 204
     }
205 205
 
206
-  /** Resize the given image source (GD, gd object or image file path) to fit in the own image.
207
-    * The outside ares will be cropped out. Returns TRUE on success or FALSE on failure
208
-    * @param mixed $src
209
-    * @return bool */
206
+    /** Resize the given image source (GD, gd object or image file path) to fit in the own image.
207
+     * The outside ares will be cropped out. Returns TRUE on success or FALSE on failure
208
+     * @param mixed $src
209
+     * @return bool */
210 210
 
211 211
     public function resize_crop($src) {
212 212
         $image_details = $this->build_image($src);
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
             return false;
234 234
     }
235 235
 
236
-  /** Resize image to fit in given resolution. Returns TRUE on success or FALSE on failure
237
-    * @param integer $width
238
-    * @param integer $height
239
-    * @return bool */
236
+    /** Resize image to fit in given resolution. Returns TRUE on success or FALSE on failure
237
+     * @param integer $width
238
+     * @param integer $height
239
+     * @return bool */
240 240
 
241 241
     public function resize_fit($width, $height) {
242 242
         if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height)))
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
         return $this->resize($width, $height);
251 251
     }
252 252
 
253
-  /** Neka si predstavim vyobrazhaem pravoygylnik s razmeri $width i $height.
254
-    * Izobrazhenieto shte se preorazmeri taka che to shte izliza ot tozi pravoygylnik,
255
-    * no samo po edno (x ili y) izmerenie
256
-    * @param integer $width
257
-    * @param integer $height
258
-    * @return bool */
253
+    /** Neka si predstavim vyobrazhaem pravoygylnik s razmeri $width i $height.
254
+     * Izobrazhenieto shte se preorazmeri taka che to shte izliza ot tozi pravoygylnik,
255
+     * no samo po edno (x ili y) izmerenie
256
+     * @param integer $width
257
+     * @param integer $height
258
+     * @return bool */
259 259
 
260 260
     public function resize_overflow($width, $height) {
261 261
 
@@ -368,30 +368,30 @@  discard block
 block discarded – undo
368 368
 
369 369
 
370 370
 
371
-			/*** gif transparent fix - 1.10.2013 ***/
371
+            /*** gif transparent fix - 1.10.2013 ***/
372 372
 
373
-			$transindex = imagecolortransparent($src);
374
-			$palletsize = imagecolorstotal($src);
375
-			if($transindex >= 0 && $transindex < $palletsize) {
376
-				$transcol = imagecolorsforindex($src, $transindex);
373
+            $transindex = imagecolortransparent($src);
374
+            $palletsize = imagecolorstotal($src);
375
+            if($transindex >= 0 && $transindex < $palletsize) {
376
+                $transcol = imagecolorsforindex($src, $transindex);
377 377
 
378
-			/*** end gif transparent fix ***/
378
+            /*** end gif transparent fix ***/
379 379
 
380
-				$transindex = imagecolorallocatealpha($this->image, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
381
-				imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex);
382
-				imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
383
-				imagecolortransparent($this->image, $transindex);
384
-				for($y=0; $y<$dst_h; ++$y)
385
-					for($x=0; $x<$dst_w; ++$x)
386
-						if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
387
-				imagetruecolortopalette($this->image, true, 255);
388
-			}
389
-			else {
390
-				$transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
391
-				imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transparent);
392
-				imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
393
-			}
394
-			return $this->image;
380
+                $transindex = imagecolorallocatealpha($this->image, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
381
+                imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex);
382
+                imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
383
+                imagecolortransparent($this->image, $transindex);
384
+                for($y=0; $y<$dst_h; ++$y)
385
+                    for($x=0; $x<$dst_w; ++$x)
386
+                        if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
387
+                imagetruecolortopalette($this->image, true, 255);
388
+            }
389
+            else {
390
+                $transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
391
+                imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transparent);
392
+                imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
393
+            }
394
+            return $this->image;
395 395
 
396 396
         } else
397 397
             return false;
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
     public function imagegif($filename=null) {
420 420
         if (is_null($filename) && !headers_sent())
421 421
             header("Content-Type: image/gif");
422
-			@imagesavealpha($this->image, true);
422
+            @imagesavealpha($this->image, true);
423 423
         return imagegif($this->image, $filename);
424 424
     }
425 425
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class gd {
15
+class gd{
16 16
 
17 17
   /** GD resource
18 18
     * @var resource */
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     * @param mixed $image
41 41
     * @return array */
42 42
 
43
-    protected function build_image($image) {
43
+    protected function build_image($image){
44 44
 
45 45
         if ($image instanceof gd) {
46 46
             $width = $image->get_width();
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 
59 59
         } elseif (false !== (list($width, $height, $type) = @getimagesize($image))) {
60 60
             $image =
61
-                ($type == IMAGETYPE_GIF)      ? @imagecreatefromgif($image)  : (
62
-                ($type == IMAGETYPE_WBMP)     ? @imagecreatefromwbmp($image) : (
63
-                ($type == IMAGETYPE_JPEG)     ? @imagecreatefromjpeg($image) : (
61
+                ($type == IMAGETYPE_GIF) ? @imagecreatefromgif($image) : (
62
+                ($type == IMAGETYPE_WBMP) ? @imagecreatefromwbmp($image) : (
63
+                ($type == IMAGETYPE_JPEG) ? @imagecreatefromjpeg($image) : (
64 64
                 ($type == IMAGETYPE_JPEG2000) ? @imagecreatefromjpeg($image) : (
65
-                ($type == IMAGETYPE_PNG)      ? @imagecreatefrompng($image)  : (
66
-                ($type == IMAGETYPE_XBM)      ? @imagecreatefromxbm($image)  : false
65
+                ($type == IMAGETYPE_PNG) ? @imagecreatefrompng($image) : (
66
+                ($type == IMAGETYPE_XBM) ? @imagecreatefromxbm($image) : false
67 67
             )))));
68 68
 
69 69
             if ($type == IMAGETYPE_PNG)
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     * @param integer $bigger_size
99 99
     * @return gd */
100 100
 
101
-    public function __construct($image, $bigger_size=null) {
101
+    public function __construct($image, $bigger_size = null){
102 102
         $this->image = $this->width = $this->height = null;
103 103
 
104 104
         $image_details = $this->build_image($image);
@@ -126,21 +126,21 @@  discard block
 block discarded – undo
126 126
   /** Returns the GD resource
127 127
     * @return resource */
128 128
 
129
-    public function get_image() {
129
+    public function get_image(){
130 130
         return $this->image;
131 131
     }
132 132
 
133 133
   /** Returns the image width
134 134
     * @return integer */
135 135
 
136
-    public function get_width() {
136
+    public function get_width(){
137 137
         return $this->width;
138 138
     }
139 139
 
140 140
   /** Returns the image height
141 141
     * @return integer */
142 142
 
143
-    public function get_height() {
143
+    public function get_height(){
144 144
         return $this->height;
145 145
     }
146 146
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     * @param integer $resized_height
149 149
     * @return integer */
150 150
 
151
-    public function get_prop_width($resized_height) {
151
+    public function get_prop_width($resized_height){
152 152
         $width = intval(($this->width * $resized_height) / $this->height);
153 153
         if (!$width) $width = 1;
154 154
         return $width;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     * @param integer $resized_width
159 159
     * @return integer */
160 160
 
161
-    public function get_prop_height($resized_width) {
161
+    public function get_prop_height($resized_width){
162 162
         $height = intval(($this->height * $resized_width) / $this->width);
163 163
         if (!$height) $height = 1;
164 164
         return $height;
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     * @param integer $bigger_size
171 171
     * @return array */
172 172
 
173
-    public function get_prop_size($bigger_size) {
173
+    public function get_prop_size($bigger_size){
174 174
 
175 175
         if ($this->width > $this->height) {
176 176
             $width = $bigger_size;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     * @param integer $height
192 192
     * @return bool */
193 193
 
194
-    public function resize($width, $height) {
194
+    public function resize($width, $height){
195 195
         if (!$width) $width = 1;
196 196
         if (!$height) $height = 1;
197 197
         return (
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
     * @param mixed $src
209 209
     * @return bool */
210 210
 
211
-    public function resize_crop($src) {
211
+    public function resize_crop($src){
212 212
         $image_details = $this->build_image($src);
213 213
 
214 214
         if ($image_details !== false) {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     * @param integer $height
239 239
     * @return bool */
240 240
 
241
-    public function resize_fit($width, $height) {
241
+    public function resize_fit($width, $height){
242 242
         if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height)))
243 243
             return true;
244 244
         if (!$width || (($height / $width) < ($this->height / $this->width)))
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     * @param integer $height
258 258
     * @return bool */
259 259
 
260
-    public function resize_overflow($width, $height) {
260
+    public function resize_overflow($width, $height){
261 261
 
262 262
         $big = (($this->width / $this->height) > ($width / $height))
263 263
             ? ($this->width * $height) / $this->height
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         return $return;
276 276
     }
277 277
 
278
-    public function gd_color() {
278
+    public function gd_color(){
279 279
         $args = func_get_args();
280 280
 
281 281
         $expr_rgb = '/^rgb\(\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\)$/i';
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
         return imagecolorallocate($this->image, $r, $g, $b);
318 318
     }
319 319
 
320
-    public function fill_color($color) {
320
+    public function fill_color($color){
321 321
         return $this->imagefilledrectangle(0, 0, $this->width - 1, $this->height - 1, $color);
322 322
     }
323 323
 
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
 
327 327
     public function imagecopy(
328 328
         $src,
329
-        $dst_x=0, $dst_y=0,
330
-        $src_x=0, $src_y=0,
331
-        $dst_w=null, $dst_h=null,
332
-        $src_w=null, $src_h=null
333
-    ) {
329
+        $dst_x = 0, $dst_y = 0,
330
+        $src_x = 0, $src_y = 0,
331
+        $dst_w = null, $dst_h = null,
332
+        $src_w = null, $src_h = null
333
+    ){
334 334
         $image_details = $this->build_image($src);
335 335
 
336 336
         if ($image_details !== false) {
@@ -348,11 +348,11 @@  discard block
 block discarded – undo
348 348
 
349 349
     public function imagecopyresampled(
350 350
         $src,
351
-        $dst_x=0, $dst_y=0,
352
-        $src_x=0, $src_y=0,
353
-        $dst_w=null, $dst_h=null,
354
-        $src_w=null, $src_h=null
355
-    ) {
351
+        $dst_x = 0, $dst_y = 0,
352
+        $src_x = 0, $src_y = 0,
353
+        $dst_w = null, $dst_h = null,
354
+        $src_w = null, $src_h = null
355
+    ){
356 356
         $image_details = $this->build_image($src);
357 357
 
358 358
         if ($image_details !== false) {
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
             if (is_null($src_w)) $src_w = $src_width - $src_x;
364 364
             if (is_null($src_h)) $src_h = $src_height - $src_y;
365 365
             imagealphablending($this->image, false);
366
-            imagesavealpha($this->image,true);
366
+            imagesavealpha($this->image, true);
367 367
 
368 368
 
369 369
 
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 
373 373
 			$transindex = imagecolortransparent($src);
374 374
 			$palletsize = imagecolorstotal($src);
375
-			if($transindex >= 0 && $transindex < $palletsize) {
375
+			if ($transindex >= 0 && $transindex < $palletsize) {
376 376
 				$transcol = imagecolorsforindex($src, $transindex);
377 377
 
378 378
 			/*** end gif transparent fix ***/
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
 				imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex);
382 382
 				imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
383 383
 				imagecolortransparent($this->image, $transindex);
384
-				for($y=0; $y<$dst_h; ++$y)
385
-					for($x=0; $x<$dst_w; ++$x)
386
-						if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
384
+				for ($y = 0; $y < $dst_h; ++$y)
385
+					for ($x = 0; $x < $dst_w; ++$x)
386
+						if (((imagecolorat($this->image, $x, $y) >> 24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
387 387
 				imagetruecolortopalette($this->image, true, 255);
388 388
 			}
389 389
 			else {
@@ -397,26 +397,26 @@  discard block
 block discarded – undo
397 397
             return false;
398 398
     }
399 399
 
400
-    public function imagefilledrectangle($x1, $y1, $x2, $y2, $color) {
400
+    public function imagefilledrectangle($x1, $y1, $x2, $y2, $color){
401 401
         $color = $this->gd_color($color);
402 402
         if ($color === false) return false;
403 403
         return imagefilledrectangle($this->image, $x1, $y1, $x2, $y2, $color);
404 404
     }
405 405
 
406
-    public function imagepng($filename=null, $quality=null, $filters=null) {
406
+    public function imagepng($filename = null, $quality = null, $filters = null){
407 407
         if (is_null($filename) && !headers_sent())
408 408
             header("Content-Type: image/png");
409 409
         @imagesavealpha($this->image, true);
410 410
         return imagepng($this->image, $filename, $quality, $filters);
411 411
     }
412 412
 
413
-    public function imagejpeg($filename=null, $quality=75) {
413
+    public function imagejpeg($filename = null, $quality = 75){
414 414
         if (is_null($filename) && !headers_sent())
415 415
             header("Content-Type: image/jpeg");
416 416
         return imagejpeg($this->image, $filename, $quality);
417 417
     }
418 418
 
419
-    public function imagegif($filename=null) {
419
+    public function imagegif($filename = null){
420 420
         if (is_null($filename) && !headers_sent())
421 421
             header("Content-Type: image/gif");
422 422
 			@imagesavealpha($this->image, true);
Please login to merge, or discard this patch.
Braces   +157 added lines, -92 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class gd {
15
+class gd
16
+{
16 17
 
17 18
   /** GD resource
18 19
     * @var resource */
@@ -40,23 +41,24 @@  discard block
 block discarded – undo
40 41
     * @param mixed $image
41 42
     * @return array */
42 43
 
43
-    protected function build_image($image) {
44
+    protected function build_image($image)
45
+    {
44 46
 
45
-        if ($image instanceof gd) {
47
+        if ($image instanceof gd) {
46 48
             $width = $image->get_width();
47 49
             $height = $image->get_height();
48 50
             $image = $image->get_image();
49 51
 
50
-        } elseif (is_resource($image) && (get_resource_type($image) == "gd")) {
52
+        } elseif (is_resource($image) && (get_resource_type($image) == "gd")) {
51 53
             $width = @imagesx($image);
52 54
             $height = @imagesy($image);
53 55
 
54
-        } elseif (is_array($image)) {
56
+        } elseif (is_array($image)) {
55 57
             list($key, $width) = each($image);
56 58
             list($key, $height) = each($image);
57 59
             $image = imagecreatetruecolor($width, $height);
58 60
 
59
-        } elseif (false !== (list($width, $height, $type) = @getimagesize($image))) {
61
+        } elseif (false !== (list($width, $height, $type) = @getimagesize($image))) {
60 62
             $image =
61 63
                 ($type == IMAGETYPE_GIF)      ? @imagecreatefromgif($image)  : (
62 64
                 ($type == IMAGETYPE_WBMP)     ? @imagecreatefromwbmp($image) : (
@@ -66,8 +68,9 @@  discard block
 block discarded – undo
66 68
                 ($type == IMAGETYPE_XBM)      ? @imagecreatefromxbm($image)  : false
67 69
             )))));
68 70
 
69
-            if ($type == IMAGETYPE_PNG)
70
-                imagealphablending($image, false);
71
+            if ($type == IMAGETYPE_PNG) {
72
+                            imagealphablending($image, false);
73
+            }
71 74
         }
72 75
 
73 76
         $return = (
@@ -81,8 +84,9 @@  discard block
 block discarded – undo
81 84
             ? array($image, $width, $height)
82 85
             : false;
83 86
 
84
-        if (($return !== false) && isset($type))
85
-            $this->type = $type;
87
+        if (($return !== false) && isset($type)) {
88
+                    $this->type = $type;
89
+        }
86 90
 
87 91
         return $return;
88 92
     }
@@ -98,20 +102,22 @@  discard block
 block discarded – undo
98 102
     * @param integer $bigger_size
99 103
     * @return gd */
100 104
 
101
-    public function __construct($image, $bigger_size=null) {
105
+    public function __construct($image, $bigger_size=null)
106
+    {
102 107
         $this->image = $this->width = $this->height = null;
103 108
 
104 109
         $image_details = $this->build_image($image);
105 110
 
106
-        if ($image_details !== false)
107
-            list($this->image, $this->width, $this->height) = $image_details;
108
-        else
109
-            $this->init_error = true;
111
+        if ($image_details !== false) {
112
+                    list($this->image, $this->width, $this->height) = $image_details;
113
+        } else {
114
+                    $this->init_error = true;
115
+        }
110 116
 
111 117
         if (!is_null($this->image) &&
112 118
             !is_null($bigger_size) &&
113 119
             (preg_match('/^[1-9][0-9]*$/', $bigger_size) !== false)
114
-        ) {
120
+        ) {
115 121
             $image = $this->image;
116 122
             list($width, $height) = $this->get_prop_size($bigger_size);
117 123
             $this->image = imagecreatetruecolor($width, $height);
@@ -126,21 +132,24 @@  discard block
 block discarded – undo
126 132
   /** Returns the GD resource
127 133
     * @return resource */
128 134
 
129
-    public function get_image() {
135
+    public function get_image()
136
+    {
130 137
         return $this->image;
131 138
     }
132 139
 
133 140
   /** Returns the image width
134 141
     * @return integer */
135 142
 
136
-    public function get_width() {
143
+    public function get_width()
144
+    {
137 145
         return $this->width;
138 146
     }
139 147
 
140 148
   /** Returns the image height
141 149
     * @return integer */
142 150
 
143
-    public function get_height() {
151
+    public function get_height()
152
+    {
144 153
         return $this->height;
145 154
     }
146 155
 
@@ -148,9 +157,12 @@  discard block
 block discarded – undo
148 157
     * @param integer $resized_height
149 158
     * @return integer */
150 159
 
151
-    public function get_prop_width($resized_height) {
160
+    public function get_prop_width($resized_height)
161
+    {
152 162
         $width = intval(($this->width * $resized_height) / $this->height);
153
-        if (!$width) $width = 1;
163
+        if (!$width) {
164
+            $width = 1;
165
+        }
154 166
         return $width;
155 167
     }
156 168
 
@@ -158,9 +170,12 @@  discard block
 block discarded – undo
158 170
     * @param integer $resized_width
159 171
     * @return integer */
160 172
 
161
-    public function get_prop_height($resized_width) {
173
+    public function get_prop_height($resized_width)
174
+    {
162 175
         $height = intval(($this->height * $resized_width) / $this->width);
163
-        if (!$height) $height = 1;
176
+        if (!$height) {
177
+            $height = 1;
178
+        }
164 179
         return $height;
165 180
     }
166 181
 
@@ -170,18 +185,20 @@  discard block
 block discarded – undo
170 185
     * @param integer $bigger_size
171 186
     * @return array */
172 187
 
173
-    public function get_prop_size($bigger_size) {
188
+    public function get_prop_size($bigger_size)
189
+    {
174 190
 
175
-        if ($this->width > $this->height) {
191
+        if ($this->width > $this->height) {
176 192
             $width = $bigger_size;
177 193
             $height = $this->get_prop_height($width);
178 194
 
179
-        } elseif ($this->height > $this->width) {
195
+        } elseif ($this->height > $this->width) {
180 196
             $height = $bigger_size;
181 197
             $width = $this->get_prop_width($height);
182 198
 
183
-        } else
184
-            $width = $height = $bigger_size;
199
+        } else {
200
+                    $width = $height = $bigger_size;
201
+        }
185 202
 
186 203
         return array($width, $height);
187 204
     }
@@ -191,9 +208,14 @@  discard block
 block discarded – undo
191 208
     * @param integer $height
192 209
     * @return bool */
193 210
 
194
-    public function resize($width, $height) {
195
-        if (!$width) $width = 1;
196
-        if (!$height) $height = 1;
211
+    public function resize($width, $height)
212
+    {
213
+        if (!$width) {
214
+            $width = 1;
215
+        }
216
+        if (!$height) {
217
+            $height = 1;
218
+        }
197 219
         return (
198 220
             (false !== ($img = new gd(array($width, $height)))) &&
199 221
             $img->imagecopyresampled($this) &&
@@ -208,19 +230,20 @@  discard block
 block discarded – undo
208 230
     * @param mixed $src
209 231
     * @return bool */
210 232
 
211
-    public function resize_crop($src) {
233
+    public function resize_crop($src)
234
+    {
212 235
         $image_details = $this->build_image($src);
213 236
 
214
-        if ($image_details !== false) {
237
+        if ($image_details !== false) {
215 238
             list($src, $src_width, $src_height) = $image_details;
216 239
 
217
-            if (($src_width / $src_height) > ($this->width / $this->height)) {
240
+            if (($src_width / $src_height) > ($this->width / $this->height)) {
218 241
                 $src_w = $this->get_prop_width($src_height);
219 242
                 $src_h = $src_height;
220 243
                 $src_x = intval(($src_width - $src_w) / 2);
221 244
                 $src_y = 0;
222 245
 
223
-            } else {
246
+            } else {
224 247
                 $src_w = $src_width;
225 248
                 $src_h = $this->get_prop_height($src_width);
226 249
                 $src_x = 0;
@@ -229,8 +252,9 @@  discard block
 block discarded – undo
229 252
 
230 253
             return imagecopyresampled($this->image, $src, 0, 0, $src_x, $src_y, $this->width, $this->height, $src_w, $src_h);
231 254
 
232
-        } else
233
-            return false;
255
+        } else {
256
+                    return false;
257
+        }
234 258
     }
235 259
 
236 260
   /** Resize image to fit in given resolution. Returns TRUE on success or FALSE on failure
@@ -238,15 +262,22 @@  discard block
 block discarded – undo
238 262
     * @param integer $height
239 263
     * @return bool */
240 264
 
241
-    public function resize_fit($width, $height) {
242
-        if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height)))
243
-            return true;
244
-        if (!$width || (($height / $width) < ($this->height / $this->width)))
245
-            $width = intval(($this->width * $height) / $this->height);
246
-        elseif (!$height || (($width / $height) < ($this->width / $this->height)))
247
-            $height = intval(($this->height * $width) / $this->width);
248
-        if (!$width) $width = 1;
249
-        if (!$height) $height = 1;
265
+    public function resize_fit($width, $height)
266
+    {
267
+        if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height))) {
268
+                    return true;
269
+        }
270
+        if (!$width || (($height / $width) < ($this->height / $this->width))) {
271
+                    $width = intval(($this->width * $height) / $this->height);
272
+        } elseif (!$height || (($width / $height) < ($this->width / $this->height))) {
273
+                    $height = intval(($this->height * $width) / $this->width);
274
+        }
275
+        if (!$width) {
276
+            $width = 1;
277
+        }
278
+        if (!$height) {
279
+            $height = 1;
280
+        }
250 281
         return $this->resize($width, $height);
251 282
     }
252 283
 
@@ -257,7 +288,8 @@  discard block
 block discarded – undo
257 288
     * @param integer $height
258 289
     * @return bool */
259 290
 
260
-    public function resize_overflow($width, $height) {
291
+    public function resize_overflow($width, $height)
292
+    {
261 293
 
262 294
         $big = (($this->width / $this->height) > ($width / $height))
263 295
             ? ($this->width * $height) / $this->height
@@ -266,7 +298,7 @@  discard block
 block discarded – undo
266 298
 
267 299
         $return = ($img = new gd($this->image, $big));
268 300
 
269
-        if ($return) {
301
+        if ($return) {
270 302
             $this->image = $img->get_image();
271 303
             $this->width = $img->get_width();
272 304
             $this->height = $img->get_height();
@@ -275,7 +307,8 @@  discard block
 block discarded – undo
275 307
         return $return;
276 308
     }
277 309
 
278
-    public function gd_color() {
310
+    public function gd_color()
311
+    {
279 312
         $args = func_get_args();
280 313
 
281 314
         $expr_rgb = '/^rgb\(\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\)$/i';
@@ -283,22 +316,23 @@  discard block
 block discarded – undo
283 316
         $expr_hex2 = '/^\#?([0-9a-f])([0-9a-f])([0-9a-f])$/i';
284 317
         $expr_byte = '/^([01]?\d?\d|2[0-4]\d|25[0-5])$/';
285 318
 
286
-        if (!isset($args[0]))
287
-            return false;
319
+        if (!isset($args[0])) {
320
+                    return false;
321
+        }
288 322
 
289
-        if (count($args[0]) == 3) {
323
+        if (count($args[0]) == 3) {
290 324
             list($r, $g, $b) = $args[0];
291 325
 
292
-        } elseif (preg_match($expr_rgb, $args[0])) {
326
+        } elseif (preg_match($expr_rgb, $args[0])) {
293 327
             list($r, $g, $b) = explode(" ", preg_replace($expr_rgb, "$1 $2 $3", $args[0]));
294 328
 
295
-        } elseif (preg_match($expr_hex1, $args[0])) {
329
+        } elseif (preg_match($expr_hex1, $args[0])) {
296 330
             list($r, $g, $b) = explode(" ", preg_replace($expr_hex1, "$1 $2 $3", $args[0]));
297 331
             $r = hexdec($r);
298 332
             $g = hexdec($g);
299 333
             $b = hexdec($b);
300 334
 
301
-        } elseif (preg_match($expr_hex2, $args[0])) {
335
+        } elseif (preg_match($expr_hex2, $args[0])) {
302 336
             list($r, $g, $b) = explode(" ", preg_replace($expr_hex2, "$1$1 $2$2 $3$3", $args[0]));
303 337
             $r = hexdec($r);
304 338
             $g = hexdec($g);
@@ -308,16 +342,18 @@  discard block
 block discarded – undo
308 342
             preg_match($expr_byte, $args[0]) &&
309 343
             preg_match($expr_byte, $args[1]) &&
310 344
             preg_match($expr_byte, $args[2])
311
-        ) {
345
+        ) {
312 346
             list($r, $g, $b) = $args;
313 347
 
314
-        } else
315
-            return false;
348
+        } else {
349
+                    return false;
350
+        }
316 351
 
317 352
         return imagecolorallocate($this->image, $r, $g, $b);
318 353
     }
319 354
 
320
-    public function fill_color($color) {
355
+    public function fill_color($color)
356
+    {
321 357
         return $this->imagefilledrectangle(0, 0, $this->width - 1, $this->height - 1, $color);
322 358
     }
323 359
 
@@ -330,20 +366,29 @@  discard block
 block discarded – undo
330 366
         $src_x=0, $src_y=0,
331 367
         $dst_w=null, $dst_h=null,
332 368
         $src_w=null, $src_h=null
333
-    ) {
369
+    ) {
334 370
         $image_details = $this->build_image($src);
335 371
 
336
-        if ($image_details !== false) {
372
+        if ($image_details !== false) {
337 373
             list($src, $src_width, $src_height) = $image_details;
338 374
 
339
-            if (is_null($dst_w)) $dst_w = $this->width - $dst_x;
340
-            if (is_null($dst_h)) $dst_h = $this->height - $dst_y;
341
-            if (is_null($src_w)) $src_w = $src_width - $src_x;
342
-            if (is_null($src_h)) $src_h = $src_height - $src_y;
375
+            if (is_null($dst_w)) {
376
+                $dst_w = $this->width - $dst_x;
377
+            }
378
+            if (is_null($dst_h)) {
379
+                $dst_h = $this->height - $dst_y;
380
+            }
381
+            if (is_null($src_w)) {
382
+                $src_w = $src_width - $src_x;
383
+            }
384
+            if (is_null($src_h)) {
385
+                $src_h = $src_height - $src_y;
386
+            }
343 387
             return imagecopy($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h);
344 388
 
345
-        } else
346
-            return false;
389
+        } else {
390
+                    return false;
391
+        }
347 392
     }
348 393
 
349 394
     public function imagecopyresampled(
@@ -352,16 +397,24 @@  discard block
 block discarded – undo
352 397
         $src_x=0, $src_y=0,
353 398
         $dst_w=null, $dst_h=null,
354 399
         $src_w=null, $src_h=null
355
-    ) {
400
+    ) {
356 401
         $image_details = $this->build_image($src);
357 402
 
358
-        if ($image_details !== false) {
403
+        if ($image_details !== false) {
359 404
             list($src, $src_width, $src_height) = $image_details;
360 405
 
361
-            if (is_null($dst_w)) $dst_w = $this->width - $dst_x;
362
-            if (is_null($dst_h)) $dst_h = $this->height - $dst_y;
363
-            if (is_null($src_w)) $src_w = $src_width - $src_x;
364
-            if (is_null($src_h)) $src_h = $src_height - $src_y;
406
+            if (is_null($dst_w)) {
407
+                $dst_w = $this->width - $dst_x;
408
+            }
409
+            if (is_null($dst_h)) {
410
+                $dst_h = $this->height - $dst_y;
411
+            }
412
+            if (is_null($src_w)) {
413
+                $src_w = $src_width - $src_x;
414
+            }
415
+            if (is_null($src_h)) {
416
+                $src_h = $src_height - $src_y;
417
+            }
365 418
             imagealphablending($this->image, false);
366 419
             imagesavealpha($this->image,true);
367 420
 
@@ -372,7 +425,7 @@  discard block
 block discarded – undo
372 425
 
373 426
 			$transindex = imagecolortransparent($src);
374 427
 			$palletsize = imagecolorstotal($src);
375
-			if($transindex >= 0 && $transindex < $palletsize) {
428
+			if($transindex >= 0 && $transindex < $palletsize) {
376 429
 				$transcol = imagecolorsforindex($src, $transindex);
377 430
 
378 431
 			/*** end gif transparent fix ***/
@@ -381,44 +434,56 @@  discard block
 block discarded – undo
381 434
 				imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex);
382 435
 				imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
383 436
 				imagecolortransparent($this->image, $transindex);
384
-				for($y=0; $y<$dst_h; ++$y)
385
-					for($x=0; $x<$dst_w; ++$x)
386
-						if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
437
+				for($y=0; $y<$dst_h; ++$y) {
438
+									for($x=0;
439
+				}
440
+				$x<$dst_w; ++$x) {
441
+											if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
442
+					}
387 443
 				imagetruecolortopalette($this->image, true, 255);
388
-			}
389
-			else {
444
+			} else {
390 445
 				$transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
391 446
 				imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transparent);
392 447
 				imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
393 448
 			}
394 449
 			return $this->image;
395 450
 
396
-        } else
397
-            return false;
451
+        } else {
452
+                    return false;
453
+        }
398 454
     }
399 455
 
400
-    public function imagefilledrectangle($x1, $y1, $x2, $y2, $color) {
456
+    public function imagefilledrectangle($x1, $y1, $x2, $y2, $color)
457
+    {
401 458
         $color = $this->gd_color($color);
402
-        if ($color === false) return false;
459
+        if ($color === false) {
460
+            return false;
461
+        }
403 462
         return imagefilledrectangle($this->image, $x1, $y1, $x2, $y2, $color);
404 463
     }
405 464
 
406
-    public function imagepng($filename=null, $quality=null, $filters=null) {
407
-        if (is_null($filename) && !headers_sent())
408
-            header("Content-Type: image/png");
465
+    public function imagepng($filename=null, $quality=null, $filters=null)
466
+    {
467
+        if (is_null($filename) && !headers_sent()) {
468
+                    header("Content-Type: image/png");
469
+        }
409 470
         @imagesavealpha($this->image, true);
410 471
         return imagepng($this->image, $filename, $quality, $filters);
411 472
     }
412 473
 
413
-    public function imagejpeg($filename=null, $quality=75) {
414
-        if (is_null($filename) && !headers_sent())
415
-            header("Content-Type: image/jpeg");
474
+    public function imagejpeg($filename=null, $quality=75)
475
+    {
476
+        if (is_null($filename) && !headers_sent()) {
477
+                    header("Content-Type: image/jpeg");
478
+        }
416 479
         return imagejpeg($this->image, $filename, $quality);
417 480
     }
418 481
 
419
-    public function imagegif($filename=null) {
420
-        if (is_null($filename) && !headers_sent())
421
-            header("Content-Type: image/gif");
482
+    public function imagegif($filename=null)
483
+    {
484
+        if (is_null($filename) && !headers_sent()) {
485
+                    header("Content-Type: image/gif");
486
+        }
422 487
 			@imagesavealpha($this->image, true);
423 488
         return imagegif($this->image, $filename);
424 489
     }
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_image.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -179,7 +179,6 @@
 block discarded – undo
179 179
 
180 180
 /** Resize and crop the image to fit in given resolution. Returns TRUE on
181 181
   * success or FALSE on failure
182
-  * @param mixed $src
183 182
   * @param integer $offset
184 183
   * @return bool */
185 184
     abstract public function resizeCrop($width, $height, $offset=false);
Please login to merge, or discard this patch.
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -1,45 +1,45 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Abstract image driver class
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc Abstract image driver class
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 abstract class image {
16 16
     const DEFAULT_JPEG_QUALITY = 75;
17 17
 
18 18
 /** Image resource or object
19
-  * @var mixed */
19
+ * @var mixed */
20 20
     protected $image;
21 21
 
22 22
 /** Image width in pixels
23
-  * @var integer */
23
+ * @var integer */
24 24
     protected $width;
25 25
 
26 26
 /** Image height in pixels
27
-  * @var integer */
27
+ * @var integer */
28 28
     protected $height;
29 29
 
30 30
 /** Init error
31
-  * @var bool */
31
+ * @var bool */
32 32
     protected $initError = false;
33 33
 
34 34
 /** Driver specific options
35
-  * @var array */
35
+ * @var array */
36 36
     protected $options = array();
37 37
 
38 38
 
39 39
 /** Magic method which allows read-only access to all protected or private
40
-  * class properties
41
-  * @param string $property
42
-  * @return mixed */
40
+ * class properties
41
+ * @param string $property
42
+ * @return mixed */
43 43
 
44 44
     final public function __get($property) {
45 45
         return property_exists($this, $property) ? $this->$property : null;
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 
48 48
 
49 49
 /** Constructor. Parameter $image should be:
50
-  *   1. An instance of image driver class (copy instance).
51
-  *   2. An image represented by the type of the $image property
52
-  *      (resource or object).
53
-  *   3. An array with two elements. First - width, second - height.
54
-  *      Creates a blank image.
55
-  *   4. A filename string. Get image form file.
56
-  * Second parameter is used by pass some specific image driver options
57
-  * @param mixed $image
58
-  * @param array $options */
50
+ *   1. An instance of image driver class (copy instance).
51
+ *   2. An image represented by the type of the $image property
52
+ *      (resource or object).
53
+ *   3. An array with two elements. First - width, second - height.
54
+ *      Creates a blank image.
55
+ *   4. A filename string. Get image form file.
56
+ * Second parameter is used by pass some specific image driver options
57
+ * @param mixed $image
58
+ * @param array $options */
59 59
 
60 60
     public function __construct($image, array $options=array()) {
61 61
         $this->image = $this->width = $this->height = null;
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
 
71 71
 
72 72
 /** Factory pattern to load selected driver. $image and $options are passed
73
-  * to the constructor of the image driver
74
-  * @param string $driver
75
-  * @param mixed $image
76
-  * @return object */
73
+ * to the constructor of the image driver
74
+ * @param string $driver
75
+ * @param mixed $image
76
+ * @return object */
77 77
 
78 78
     final static function factory($driver, $image, array $options=array()) {
79 79
         $class = "image_$driver";
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 
83 83
 
84 84
 /** Checks if the drivers in the array parameter could be used. Returns first
85
-  * found one
86
-  * @param array $drivers
87
-  * @return string */
85
+ * found one
86
+ * @param array $drivers
87
+ * @return string */
88 88
 
89 89
     final static function getDriver(array $drivers=array('gd')) {
90 90
         foreach ($drivers as $driver) {
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 
102 102
 
103 103
 /** Returns an array. Element 0 - image resource. Element 1 - width. Element 2 - height.
104
-  * Returns FALSE on failure.
105
-  * @param mixed $image
106
-  * @return array */
104
+ * Returns FALSE on failure.
105
+ * @param mixed $image
106
+ * @return array */
107 107
 
108 108
     final protected function buildImage($image) {
109 109
         $class = get_class($this);
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 
127 127
 
128 128
 /** Returns calculated proportional width from the given height
129
-  * @param integer $resizedHeight
130
-  * @return integer */
129
+ * @param integer $resizedHeight
130
+ * @return integer */
131 131
 
132 132
     final public function getPropWidth($resizedHeight) {
133 133
         $width = round(($this->width * $resizedHeight) / $this->height);
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 
138 138
 
139 139
 /** Returns calculated proportional height from the given width
140
-  * @param integer $resizedWidth
141
-  * @return integer */
140
+ * @param integer $resizedWidth
141
+ * @return integer */
142 142
 
143 143
     final public function getPropHeight($resizedWidth) {
144 144
         $height = round(($this->height * $resizedWidth) / $this->width);
@@ -148,45 +148,45 @@  discard block
 block discarded – undo
148 148
 
149 149
 
150 150
 /** Checks if PHP needs some extra extensions to use the image driver. This
151
-  * static method should be implemented into driver classes like abstract
152
-  * methods
153
-  * @return bool */
151
+ * static method should be implemented into driver classes like abstract
152
+ * methods
153
+ * @return bool */
154 154
     static function available() { return false; }
155 155
 
156 156
 /** Checks if file is an image. This static method should be implemented into
157
-  * driver classes like abstract methods
158
-  * @param string $file
159
-  * @return bool */
157
+ * driver classes like abstract methods
158
+ * @param string $file
159
+ * @return bool */
160 160
     static function checkImage($file) { return false; }
161 161
 
162 162
 /** Resize image. Should return TRUE on success or FALSE on failure
163
-  * @param integer $width
164
-  * @param integer $height
165
-  * @return bool */
163
+ * @param integer $width
164
+ * @param integer $height
165
+ * @return bool */
166 166
     abstract public function resize($width, $height);
167 167
 
168 168
 /** Resize image to fit in given resolution. Should returns TRUE on success
169
-  * or FALSE on failure. If $background is set, the image size will be
170
-  * $width x $height and the empty spaces (if any) will be filled with defined
171
-  * color. Background color examples: "#5f5", "#ff67ca", array(255, 255, 255)
172
-  * @param integer $width
173
-  * @param integer $height
174
-  * @param mixed $background
175
-  * @return bool */
169
+ * or FALSE on failure. If $background is set, the image size will be
170
+ * $width x $height and the empty spaces (if any) will be filled with defined
171
+ * color. Background color examples: "#5f5", "#ff67ca", array(255, 255, 255)
172
+ * @param integer $width
173
+ * @param integer $height
174
+ * @param mixed $background
175
+ * @return bool */
176 176
     abstract public function resizeFit($width, $height, $background=false);
177 177
 
178 178
 /** Resize and crop the image to fit in given resolution. Returns TRUE on
179
-  * success or FALSE on failure
180
-  * @param mixed $src
181
-  * @param integer $offset
182
-  * @return bool */
179
+ * success or FALSE on failure
180
+ * @param mixed $src
181
+ * @param integer $offset
182
+ * @return bool */
183 183
     abstract public function resizeCrop($width, $height, $offset=false);
184 184
 
185 185
 
186 186
 /** Rotate image
187
-  * @param integer $angle
188
-  * @param string $background
189
-  * @return bool */
187
+ * @param integer $angle
188
+ * @param string $background
189
+ * @return bool */
190 190
     abstract public function rotate($angle, $background="#000000");
191 191
 
192 192
     abstract public function flipHorizontal();
@@ -194,44 +194,44 @@  discard block
 block discarded – undo
194 194
     abstract public function flipVertical();
195 195
 
196 196
 /** Apply a PNG or GIF watermark to the image. $top and $left parameters sets
197
-  * the offset of the watermark in pixels. Boolean and NULL values are possible
198
-  * too. In default case (FALSE, FALSE) the watermark should be applyed to
199
-  * the bottom right corner. NULL values means center aligning. If the
200
-  * watermark is bigger than the image or it's partialy or fully outside the
201
-  * image, it shoudn't be applied
202
-  * @param string $file
203
-  * @param mixed $top
204
-  * @param mixed $left
205
-  * @return bool */
197
+ * the offset of the watermark in pixels. Boolean and NULL values are possible
198
+ * too. In default case (FALSE, FALSE) the watermark should be applyed to
199
+ * the bottom right corner. NULL values means center aligning. If the
200
+ * watermark is bigger than the image or it's partialy or fully outside the
201
+ * image, it shoudn't be applied
202
+ * @param string $file
203
+ * @param mixed $top
204
+ * @param mixed $left
205
+ * @return bool */
206 206
     abstract public function watermark($file, $left=false, $top=false);
207 207
 
208 208
 /** Should output the image. Second parameter is used to pass some options like
209
-  *   'file' - if is set, the output will be written to a file
210
-  *   'quality' - compression quality
211
-  * It's possible to use extra specific options required by image type ($type)
212
-  * @param string $type
213
-  * @param array $options
214
-  * @return bool */
209
+ *   'file' - if is set, the output will be written to a file
210
+ *   'quality' - compression quality
211
+ * It's possible to use extra specific options required by image type ($type)
212
+ * @param string $type
213
+ * @param array $options
214
+ * @return bool */
215 215
     abstract public function output($type='jpeg', array $options=array());
216 216
 
217 217
 /** This method should create a blank image with selected size. Should returns
218
-  * resource or object related to the created image, which will be passed to
219
-  * $image property
220
-  * @param integer $width
221
-  * @param integer $height
222
-  * @return mixed */
218
+ * resource or object related to the created image, which will be passed to
219
+ * $image property
220
+ * @param integer $width
221
+ * @param integer $height
222
+ * @return mixed */
223 223
     abstract protected function getBlankImage($width, $height);
224 224
 
225 225
 /** This method should create an image from source image. Only first parameter
226
-  * ($image) is input. Its type should be filename string or a type of the
227
-  * $image property. See the constructor reference for details. The
228
-  * parametters $width and $height are output only. Should returns resource or
229
-  * object related to the created image, which will be passed to $image
230
-  * property
231
-  * @param mixed $image
232
-  * @param integer $width
233
-  * @param integer $height
234
-  * @return mixed */
226
+ * ($image) is input. Its type should be filename string or a type of the
227
+ * $image property. See the constructor reference for details. The
228
+ * parametters $width and $height are output only. Should returns resource or
229
+ * object related to the created image, which will be passed to $image
230
+ * property
231
+ * @param mixed $image
232
+ * @param integer $width
233
+ * @param integer $height
234
+ * @return mixed */
235 235
     abstract protected function getImage($image, &$width, &$height);
236 236
 
237 237
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-abstract class image {
15
+abstract class image{
16 16
     const DEFAULT_JPEG_QUALITY = 75;
17 17
 
18 18
 /** Image resource or object
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
   * @param string $property
42 42
   * @return mixed */
43 43
 
44
-    final public function __get($property) {
44
+    final public function __get($property){
45 45
         return property_exists($this, $property) ? $this->$property : null;
46 46
     }
47 47
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
   * @param mixed $image
58 58
   * @param array $options */
59 59
 
60
-    public function __construct($image, array $options=array()) {
60
+    public function __construct($image, array $options = array()){
61 61
         $this->image = $this->width = $this->height = null;
62 62
         $imageDetails = $this->buildImage($image);
63 63
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
   * @param mixed $image
76 76
   * @return object */
77 77
 
78
-    final static function factory($driver, $image, array $options=array()) {
78
+    final static function factory($driver, $image, array $options = array()){
79 79
         $class = "image_$driver";
80 80
         return new $class($image, $options);
81 81
     }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
   * @param array $drivers
87 87
   * @return string */
88 88
 
89
-    final static function getDriver(array $drivers=array('gd')) {
89
+    final static function getDriver(array $drivers = array('gd')){
90 90
         foreach ($drivers as $driver) {
91 91
             if (!preg_match('/^[a-z0-9\_]+$/i', $driver))
92 92
                 continue;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
   * @param mixed $image
106 106
   * @return array */
107 107
 
108
-    final protected function buildImage($image) {
108
+    final protected function buildImage($image){
109 109
         $class = get_class($this);
110 110
         if ($image instanceof $class) {
111 111
             $width = $image->width;
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
   * @param integer $resizedHeight
130 130
   * @return integer */
131 131
 
132
-    final public function getPropWidth($resizedHeight) {
132
+    final public function getPropWidth($resizedHeight){
133 133
         $width = round(($this->width * $resizedHeight) / $this->height);
134 134
         if (!$width) $width = 1;
135 135
         return $width;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
   * @param integer $resizedWidth
141 141
   * @return integer */
142 142
 
143
-    final public function getPropHeight($resizedWidth) {
143
+    final public function getPropHeight($resizedWidth){
144 144
         $height = round(($this->height * $resizedWidth) / $this->width);
145 145
         if (!$height) $height = 1;
146 146
         return $height;
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
   * static method should be implemented into driver classes like abstract
152 152
   * methods
153 153
   * @return bool */
154
-    static function available() { return false; }
154
+    static function available(){ return false; }
155 155
 
156 156
 /** Checks if file is an image. This static method should be implemented into
157 157
   * driver classes like abstract methods
158 158
   * @param string $file
159 159
   * @return bool */
160
-    static function checkImage($file) { return false; }
160
+    static function checkImage($file){ return false; }
161 161
 
162 162
 /** Resize image. Should return TRUE on success or FALSE on failure
163 163
   * @param integer $width
@@ -173,21 +173,21 @@  discard block
 block discarded – undo
173 173
   * @param integer $height
174 174
   * @param mixed $background
175 175
   * @return bool */
176
-    abstract public function resizeFit($width, $height, $background=false);
176
+    abstract public function resizeFit($width, $height, $background = false);
177 177
 
178 178
 /** Resize and crop the image to fit in given resolution. Returns TRUE on
179 179
   * success or FALSE on failure
180 180
   * @param mixed $src
181 181
   * @param integer $offset
182 182
   * @return bool */
183
-    abstract public function resizeCrop($width, $height, $offset=false);
183
+    abstract public function resizeCrop($width, $height, $offset = false);
184 184
 
185 185
 
186 186
 /** Rotate image
187 187
   * @param integer $angle
188 188
   * @param string $background
189 189
   * @return bool */
190
-    abstract public function rotate($angle, $background="#000000");
190
+    abstract public function rotate($angle, $background = "#000000");
191 191
 
192 192
     abstract public function flipHorizontal();
193 193
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
   * @param mixed $top
204 204
   * @param mixed $left
205 205
   * @return bool */
206
-    abstract public function watermark($file, $left=false, $top=false);
206
+    abstract public function watermark($file, $left = false, $top = false);
207 207
 
208 208
 /** Should output the image. Second parameter is used to pass some options like
209 209
   *   'file' - if is set, the output will be written to a file
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
   * @param string $type
213 213
   * @param array $options
214 214
   * @return bool */
215
-    abstract public function output($type='jpeg', array $options=array());
215
+    abstract public function output($type = 'jpeg', array $options = array());
216 216
 
217 217
 /** This method should create a blank image with selected size. Should returns
218 218
   * resource or object related to the created image, which will be passed to
Please login to merge, or discard this patch.
Braces   +42 added lines, -21 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-abstract class image {
15
+abstract class image
16
+{
16 17
     const DEFAULT_JPEG_QUALITY = 75;
17 18
 
18 19
 /** Image resource or object
@@ -41,7 +42,8 @@  discard block
 block discarded – undo
41 42
   * @param string $property
42 43
   * @return mixed */
43 44
 
44
-    final public function __get($property) {
45
+    final public function __get($property)
46
+    {
45 47
         return property_exists($this, $property) ? $this->$property : null;
46 48
     }
47 49
 
@@ -57,14 +59,16 @@  discard block
 block discarded – undo
57 59
   * @param mixed $image
58 60
   * @param array $options */
59 61
 
60
-    public function __construct($image, array $options=array()) {
62
+    public function __construct($image, array $options=array())
63
+    {
61 64
         $this->image = $this->width = $this->height = null;
62 65
         $imageDetails = $this->buildImage($image);
63 66
 
64
-        if ($imageDetails !== false)
65
-            list($this->image, $this->width, $this->height) = $imageDetails;
66
-        else
67
-            $this->initError = true;
67
+        if ($imageDetails !== false) {
68
+                    list($this->image, $this->width, $this->height) = $imageDetails;
69
+        } else {
70
+                    $this->initError = true;
71
+        }
68 72
         $this->options = $options;
69 73
     }
70 74
 
@@ -75,7 +79,8 @@  discard block
 block discarded – undo
75 79
   * @param mixed $image
76 80
   * @return object */
77 81
 
78
-    final static function factory($driver, $image, array $options=array()) {
82
+    final static function factory($driver, $image, array $options=array())
83
+    {
79 84
         $class = "image_$driver";
80 85
         return new $class($image, $options);
81 86
     }
@@ -86,14 +91,18 @@  discard block
 block discarded – undo
86 91
   * @param array $drivers
87 92
   * @return string */
88 93
 
89
-    final static function getDriver(array $drivers=array('gd')) {
94
+    final static function getDriver(array $drivers=array('gd'))
95
+    {
90 96
         foreach ($drivers as $driver) {
91
-            if (!preg_match('/^[a-z0-9\_]+$/i', $driver))
92
-                continue;
97
+            if (!preg_match('/^[a-z0-9\_]+$/i', $driver)) {
98
+                            continue;
99
+            }
93 100
             $class = "image_$driver";
94 101
             if (class_exists($class) && method_exists($class, "available")) {
95 102
                 eval("\$avail = $class::available();");
96
-                if ($avail) return $driver;
103
+                if ($avail) {
104
+                    return $driver;
105
+                }
97 106
             }
98 107
         }
99 108
         return false;
@@ -105,7 +114,8 @@  discard block
 block discarded – undo
105 114
   * @param mixed $image
106 115
   * @return array */
107 116
 
108
-    final protected function buildImage($image) {
117
+    final protected function buildImage($image)
118
+    {
109 119
         $class = get_class($this);
110 120
         if ($image instanceof $class) {
111 121
             $width = $image->width;
@@ -117,8 +127,9 @@  discard block
 block discarded – undo
117 127
             $height = $image[1];
118 128
             $img = $this->getBlankImage($width, $height);
119 129
 
120
-        } else
121
-            $img = $this->getImage($image, $width, $height);
130
+        } else {
131
+                    $img = $this->getImage($image, $width, $height);
132
+        }
122 133
         return ($img !== false)
123 134
             ? array($img, $width, $height)
124 135
             : false;
@@ -129,9 +140,12 @@  discard block
 block discarded – undo
129 140
   * @param integer $resizedHeight
130 141
   * @return integer */
131 142
 
132
-    final public function getPropWidth($resizedHeight) {
143
+    final public function getPropWidth($resizedHeight)
144
+    {
133 145
         $width = round(($this->width * $resizedHeight) / $this->height);
134
-        if (!$width) $width = 1;
146
+        if (!$width) {
147
+            $width = 1;
148
+        }
135 149
         return $width;
136 150
     }
137 151
 
@@ -140,9 +154,12 @@  discard block
 block discarded – undo
140 154
   * @param integer $resizedWidth
141 155
   * @return integer */
142 156
 
143
-    final public function getPropHeight($resizedWidth) {
157
+    final public function getPropHeight($resizedWidth)
158
+    {
144 159
         $height = round(($this->height * $resizedWidth) / $this->width);
145
-        if (!$height) $height = 1;
160
+        if (!$height) {
161
+            $height = 1;
162
+        }
146 163
         return $height;
147 164
     }
148 165
 
@@ -151,13 +168,17 @@  discard block
 block discarded – undo
151 168
   * static method should be implemented into driver classes like abstract
152 169
   * methods
153 170
   * @return bool */
154
-    static function available() { return false; }
171
+    static function available()
172
+    {
173
+return false; }
155 174
 
156 175
 /** Checks if file is an image. This static method should be implemented into
157 176
   * driver classes like abstract methods
158 177
   * @param string $file
159 178
   * @return bool */
160
-    static function checkImage($file) { return false; }
179
+    static function checkImage($file)
180
+    {
181
+return false; }
161 182
 
162 183
 /** Resize image. Should return TRUE on success or FALSE on failure
163 184
   * @param integer $width
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_image_gd.php 4 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -327,6 +327,11 @@
 block discarded – undo
327 327
         return imagecolorallocate($this->image, $r, $g, $b);
328 328
     }
329 329
 
330
+    /**
331
+     * @param integer $x1
332
+     * @param integer $y1
333
+     * @param boolean $color
334
+     */
330 335
     protected function imageFilledRectangle($x1, $y1, $x2, $y2, $color) {
331 336
         $color = $this->gdColor($color);
332 337
         if ($color === false) return false;
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc GD image driver class
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc GD image driver class
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class image_gd extends image {
16 16
 
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class image_gd extends image {
15
+class image_gd extends image{
16 16
 
17 17
 
18 18
     // ABSTRACT PUBLIC METHODS
19 19
 
20
-    public function resize($width, $height) {
20
+    public function resize($width, $height){
21 21
         if (!$width) $width = 1;
22 22
         if (!$height) $height = 1;
23 23
         return (
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         );
30 30
     }
31 31
 
32
-    public function resizeFit($width, $height, $background=false) {
32
+    public function resizeFit($width, $height, $background = false){
33 33
         if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height)))
34 34
             return true;
35 35
         if (!$width || (($height / $width) < ($this->height / $this->width))) {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         }
68 68
     }
69 69
 
70
-    public function resizeCrop($width, $height, $offset=false) {
70
+    public function resizeCrop($width, $height, $offset = false){
71 71
 
72 72
         if (($this->width / $this->height) > ($width / $height)) {
73 73
             $h = $height;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         return $return;
118 118
     }
119 119
 
120
-    public function rotate($angle, $background="#000000") {
120
+    public function rotate($angle, $background = "#000000"){
121 121
         $angle = -$angle;
122 122
         $img = @imagerotate($this->image, $angle, $this->gdColor($background));
123 123
         if ($img === false)
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         return true;
129 129
     }
130 130
 
131
-    public function flipHorizontal() {
131
+    public function flipHorizontal(){
132 132
         $img = imagecreatetruecolor($this->width, $this->height);
133 133
             imagealphablending($img, false);
134 134
             imagesavealpha($img, true);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         return true;
140 140
     }
141 141
 
142
-    public function flipVertical() {
142
+    public function flipVertical(){
143 143
         $img = imagecreatetruecolor($this->width, $this->height);
144 144
             imagealphablending($img, false);
145 145
             imagesavealpha($img, true);
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         return true;
151 151
     }
152 152
 
153
-    public function watermark($file, $left=false, $top=false) {
153
+    public function watermark($file, $left = false, $top = false){
154 154
         $info = getimagesize($file);
155 155
         list($w, $h, $t) = $info;
156 156
         if (!in_array($t, array(IMAGETYPE_PNG, IMAGETYPE_GIF)))
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         return true;
188 188
     }
189 189
 
190
-    public function output($type='jpeg', array $options=array()) {
190
+    public function output($type = 'jpeg', array $options = array()){
191 191
         $method = "output_$type";
192 192
         if (!method_exists($this, $method))
193 193
             return false;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
     // ABSTRACT PROTECTED METHODS
199 199
 
200
-    protected function getBlankImage($width, $height) {
200
+    protected function getBlankImage($width, $height){
201 201
         $img = @imagecreatetruecolor($width, $height);
202 202
 //        imagealphablending($img, false);
203 203
 //        imagesavealpha($img, true);
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         return $img;
208 208
     }
209 209
 
210
-    protected function getImage($image, &$width, &$height) {
210
+    protected function getImage($image, &$width, &$height){
211 211
 
212 212
         if (is_resource($image) && (get_resource_type($image) == "gd")) {
213 213
             $width = @imagesx($image);
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
             (false !== (list($width, $height, $t) = @getimagesize($image)))
219 219
         ) {
220 220
             $image =
221
-                ($t == IMAGETYPE_GIF)  ? @imagecreatefromgif($image)  : (
221
+                ($t == IMAGETYPE_GIF) ? @imagecreatefromgif($image) : (
222 222
                 ($t == IMAGETYPE_WBMP) ? @imagecreatefromwbmp($image) : (
223 223
                 ($t == IMAGETYPE_JPEG) ? @imagecreatefromjpeg($image) : (
224
-                ($t == IMAGETYPE_PNG)  ? @imagecreatefrompng($image)  : (
225
-                ($t == IMAGETYPE_XBM)  ? @imagecreatefromxbm($image)  : false
224
+                ($t == IMAGETYPE_PNG) ? @imagecreatefrompng($image) : (
225
+                ($t == IMAGETYPE_XBM) ? @imagecreatefromxbm($image) : false
226 226
             ))));
227 227
 
228 228
             return $image;
@@ -234,22 +234,22 @@  discard block
 block discarded – undo
234 234
 
235 235
     // PSEUDO-ABSTRACT STATIC METHODS
236 236
 
237
-    static function available() {
237
+    static function available(){
238 238
         return function_exists("imagecreatefromjpeg");
239 239
     }
240 240
 
241
-    static function checkImage($file) {
241
+    static function checkImage($file){
242 242
         if (!is_string($file) ||
243 243
             ((false === (list($width, $height, $t) = @getimagesize($file))))
244 244
         )
245 245
             return false;
246 246
 
247 247
         $img =
248
-            ($t == IMAGETYPE_GIF)  ? @imagecreatefromgif($file)  : (
248
+            ($t == IMAGETYPE_GIF) ? @imagecreatefromgif($file) : (
249 249
             ($t == IMAGETYPE_WBMP) ? @imagecreatefromwbmp($file) : (
250 250
             ($t == IMAGETYPE_JPEG) ? @imagecreatefromjpeg($file) : (
251
-            ($t == IMAGETYPE_PNG)  ? @imagecreatefrompng($file)  : (
252
-            ($t == IMAGETYPE_XBM)  ? @imagecreatefromxbm($file)  : false
251
+            ($t == IMAGETYPE_PNG) ? @imagecreatefrompng($file) : (
252
+            ($t == IMAGETYPE_XBM) ? @imagecreatefromxbm($file) : false
253 253
         ))));
254 254
 
255 255
         return ($img !== false);
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 
259 259
     // OWN METHODS
260 260
 
261
-    protected function output_png(array $options=array()) {
261
+    protected function output_png(array $options = array()){
262 262
         $file = isset($options['file']) ? $options['file'] : null;
263 263
         $quality = isset($options['quality']) ? $options['quality'] : null;
264 264
         $filters = isset($options['filters']) ? $options['filters'] : null;
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
         return imagepng($this->image, $file, $quality, $filters);
269 269
     }
270 270
 
271
-    protected function output_jpeg(array $options=array()) {
271
+    protected function output_jpeg(array $options = array()){
272 272
         $file = isset($options['file']) ? $options['file'] : null;
273 273
         $quality = isset($options['quality'])
274 274
             ? $options['quality']
@@ -278,14 +278,14 @@  discard block
 block discarded – undo
278 278
         return imagejpeg($this->image, $file, $quality);
279 279
     }
280 280
 
281
-    protected function output_gif(array $options=array()) {
281
+    protected function output_gif(array $options = array()){
282 282
         $file = isset($options['file']) ? $options['file'] : null;
283 283
         if (isset($options['file']) && !headers_sent())
284 284
             header("Content-Type: image/gif");
285 285
         return imagegif($this->image, $file);
286 286
     }
287 287
 
288
-    protected function gdColor() {
288
+    protected function gdColor(){
289 289
         $args = func_get_args();
290 290
 
291 291
         $exprRGB = '/^rgb\(\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\)$/i';
@@ -327,15 +327,15 @@  discard block
 block discarded – undo
327 327
         return imagecolorallocate($this->image, $r, $g, $b);
328 328
     }
329 329
 
330
-    protected function imageFilledRectangle($x1, $y1, $x2, $y2, $color) {
330
+    protected function imageFilledRectangle($x1, $y1, $x2, $y2, $color){
331 331
         $color = $this->gdColor($color);
332 332
         if ($color === false) return false;
333 333
         return imageFilledRectangle($this->image, $x1, $y1, $x2, $y2, $color);
334 334
     }
335 335
 
336 336
     protected function imageCopyResampled(
337
-        $src, $dstX=0, $dstY=0, $srcX=0, $srcY=0, $dstW=null, $dstH=null, $srcW=null, $srcH=null
338
-    ) {
337
+        $src, $dstX = 0, $dstY = 0, $srcX = 0, $srcY = 0, $dstW = null, $dstH = null, $srcW = null, $srcH = null
338
+    ){
339 339
         $imageDetails = $this->buildImage($src);
340 340
 
341 341
         if ($imageDetails === false)
Please login to merge, or discard this patch.
Braces   +148 added lines, -85 removed lines patch added patch discarded remove patch
@@ -12,14 +12,20 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class image_gd extends image {
15
+class image_gd extends image
16
+{
16 17
 
17 18
 
18 19
     // ABSTRACT PUBLIC METHODS
19 20
 
20
-    public function resize($width, $height) {
21
-        if (!$width) $width = 1;
22
-        if (!$height) $height = 1;
21
+    public function resize($width, $height)
22
+    {
23
+        if (!$width) {
24
+            $width = 1;
25
+        }
26
+        if (!$height) {
27
+            $height = 1;
28
+        }
23 29
         return (
24 30
             (false !== ($img = new image_gd(array($width, $height)))) &&
25 31
             $img->imageCopyResampled($this) &&
@@ -29,9 +35,11 @@  discard block
 block discarded – undo
29 35
         );
30 36
     }
31 37
 
32
-    public function resizeFit($width, $height, $background=false) {
33
-        if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height)))
34
-            return true;
38
+    public function resizeFit($width, $height, $background=false)
39
+    {
40
+        if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height))) {
41
+                    return true;
42
+        }
35 43
         if (!$width || (($height / $width) < ($this->height / $this->width))) {
36 44
             $h = $height;
37 45
             $w = round(($this->width * $h) / $this->height);
@@ -42,13 +50,16 @@  discard block
 block discarded – undo
42 50
             $w = $width;
43 51
             $h = $height;
44 52
         }
45
-        if (!$w) $w = 1;
46
-        if (!$h) $h = 1;
47
-
48
-        if ($background === false)
49
-            return $this->resize($w, $h);
53
+        if (!$w) {
54
+            $w = 1;
55
+        }
56
+        if (!$h) {
57
+            $h = 1;
58
+        }
50 59
 
51
-        else {
60
+        if ($background === false) {
61
+                    return $this->resize($w, $h);
62
+        } else {
52 63
             $img = new image_gd(array($width, $height));
53 64
             $x = round(($width - $w) / 2);
54 65
             $y = round(($height - $h) / 2);
@@ -56,8 +67,9 @@  discard block
 block discarded – undo
56 67
             if ((false === $this->resize($w, $h)) ||
57 68
                 (false === $img->imageFilledRectangle(0, 0, $width, $height, $background)) ||
58 69
                 (false === $img->imageCopyResampled($this->image, $x, $y, 0, 0, $w, $h))
59
-            )
60
-                return false;
70
+            ) {
71
+                            return false;
72
+            }
61 73
 
62 74
             $this->image = $img->image;
63 75
             $this->width = $width;
@@ -67,41 +79,52 @@  discard block
 block discarded – undo
67 79
         }
68 80
     }
69 81
 
70
-    public function resizeCrop($width, $height, $offset=false) {
82
+    public function resizeCrop($width, $height, $offset=false)
83
+    {
71 84
 
72 85
         if (($this->width / $this->height) > ($width / $height)) {
73 86
             $h = $height;
74 87
             $w = ($this->width * $h) / $this->height;
75 88
             $y = 0;
76 89
             if ($offset !== false) {
77
-                if ($offset > 0)
78
-                    $offset = -$offset;
79
-                if (($w + $offset) <= $width)
80
-                    $offset = $width - $w;
90
+                if ($offset > 0) {
91
+                                    $offset = -$offset;
92
+                }
93
+                if (($w + $offset) <= $width) {
94
+                                    $offset = $width - $w;
95
+                }
81 96
                 $x = $offset;
82
-            } else
83
-                $x = ($width - $w) / 2;
97
+            } else {
98
+                            $x = ($width - $w) / 2;
99
+            }
84 100
 
85 101
         } else {
86 102
             $w = $width;
87 103
             $h = ($this->height * $w) / $this->width;
88 104
             $x = 0;
89 105
             if ($offset !== false) {
90
-                if ($offset > 0)
91
-                    $offset = -$offset;
92
-                if (($h + $offset) <= $height)
93
-                    $offset = $height - $h;
106
+                if ($offset > 0) {
107
+                                    $offset = -$offset;
108
+                }
109
+                if (($h + $offset) <= $height) {
110
+                                    $offset = $height - $h;
111
+                }
94 112
                 $y = $offset;
95
-            } else
96
-                $y = ($height - $h) / 2;
113
+            } else {
114
+                            $y = ($height - $h) / 2;
115
+            }
97 116
         }
98 117
 
99 118
         $x = round($x);
100 119
         $y = round($y);
101 120
         $w = round($w);
102 121
         $h = round($h);
103
-        if (!$w) $w = 1;
104
-        if (!$h) $h = 1;
122
+        if (!$w) {
123
+            $w = 1;
124
+        }
125
+        if (!$h) {
126
+            $h = 1;
127
+        }
105 128
 
106 129
         $return = (
107 130
             (false !== ($img = new image_gd(array($width, $height))))) &&
@@ -117,50 +140,59 @@  discard block
 block discarded – undo
117 140
         return $return;
118 141
     }
119 142
 
120
-    public function rotate($angle, $background="#000000") {
143
+    public function rotate($angle, $background="#000000")
144
+    {
121 145
         $angle = -$angle;
122 146
         $img = @imagerotate($this->image, $angle, $this->gdColor($background));
123
-        if ($img === false)
124
-            return false;
147
+        if ($img === false) {
148
+                    return false;
149
+        }
125 150
         $this->width = imagesx($img);
126 151
         $this->height = imagesy($img);
127 152
         $this->image = $img;
128 153
         return true;
129 154
     }
130 155
 
131
-    public function flipHorizontal() {
156
+    public function flipHorizontal()
157
+    {
132 158
         $img = imagecreatetruecolor($this->width, $this->height);
133 159
             imagealphablending($img, false);
134 160
             imagesavealpha($img, true);
135
-        if (imagecopyresampled($img, $this->image, 0, 0, ($this->width - 1), 0, $this->width, $this->height, -$this->width, $this->height))
136
-            $this->image = $img;
137
-        else
138
-            return false;
161
+        if (imagecopyresampled($img, $this->image, 0, 0, ($this->width - 1), 0, $this->width, $this->height, -$this->width, $this->height)) {
162
+                    $this->image = $img;
163
+        } else {
164
+                    return false;
165
+        }
139 166
         return true;
140 167
     }
141 168
 
142
-    public function flipVertical() {
169
+    public function flipVertical()
170
+    {
143 171
         $img = imagecreatetruecolor($this->width, $this->height);
144 172
             imagealphablending($img, false);
145 173
             imagesavealpha($img, true);
146
-        if (imagecopyresampled($img, $this->image, 0, 0, 0, ($this->height - 1), $this->width, $this->height, $this->width, -$this->height))
147
-            $this->image = $img;
148
-        else
149
-            return false;
174
+        if (imagecopyresampled($img, $this->image, 0, 0, 0, ($this->height - 1), $this->width, $this->height, $this->width, -$this->height)) {
175
+                    $this->image = $img;
176
+        } else {
177
+                    return false;
178
+        }
150 179
         return true;
151 180
     }
152 181
 
153
-    public function watermark($file, $left=false, $top=false) {
182
+    public function watermark($file, $left=false, $top=false)
183
+    {
154 184
         $info = getimagesize($file);
155 185
         list($w, $h, $t) = $info;
156
-        if (!in_array($t, array(IMAGETYPE_PNG, IMAGETYPE_GIF)))
157
-            return false;
186
+        if (!in_array($t, array(IMAGETYPE_PNG, IMAGETYPE_GIF))) {
187
+                    return false;
188
+        }
158 189
         $imagecreate = ($t == IMAGETYPE_PNG) ? "imagecreatefrompng" : "imagecreatefromgif";
159 190
 
160 191
         if (!@imagealphablending($this->image, true) ||
161 192
             (false === ($wm = @$imagecreate($file)))
162
-        )
163
-            return false;
193
+        ) {
194
+                    return false;
195
+        }
164 196
 
165 197
         $w = imagesx($wm);
166 198
         $h = imagesy($wm);
@@ -176,28 +208,33 @@  discard block
 block discarded – undo
176 208
         if ((($x + $w) > $this->width) ||
177 209
             (($y + $h) > $this->height) ||
178 210
             ($x < 0) || ($y < 0)
179
-        )
180
-            return false;
211
+        ) {
212
+                    return false;
213
+        }
181 214
 
182
-        if (($wm === false) || !@imagecopy($this->image, $wm, $x, $y, 0, 0, $w, $h))
183
-            return false;
215
+        if (($wm === false) || !@imagecopy($this->image, $wm, $x, $y, 0, 0, $w, $h)) {
216
+                    return false;
217
+        }
184 218
 
185 219
         @imagealphablending($this->image, false);
186 220
         @imagesavealpha($this->image, true);
187 221
         return true;
188 222
     }
189 223
 
190
-    public function output($type='jpeg', array $options=array()) {
224
+    public function output($type='jpeg', array $options=array())
225
+    {
191 226
         $method = "output_$type";
192
-        if (!method_exists($this, $method))
193
-            return false;
227
+        if (!method_exists($this, $method)) {
228
+                    return false;
229
+        }
194 230
         return $this->$method($options);
195 231
     }
196 232
 
197 233
 
198 234
     // ABSTRACT PROTECTED METHODS
199 235
 
200
-    protected function getBlankImage($width, $height) {
236
+    protected function getBlankImage($width, $height)
237
+    {
201 238
         $img = @imagecreatetruecolor($width, $height);
202 239
 //        imagealphablending($img, false);
203 240
 //        imagesavealpha($img, true);
@@ -207,7 +244,8 @@  discard block
 block discarded – undo
207 244
         return $img;
208 245
     }
209 246
 
210
-    protected function getImage($image, &$width, &$height) {
247
+    protected function getImage($image, &$width, &$height)
248
+    {
211 249
 
212 250
         if (is_resource($image) && (get_resource_type($image) == "gd")) {
213 251
             $width = @imagesx($image);
@@ -227,22 +265,26 @@  discard block
 block discarded – undo
227 265
 
228 266
             return $image;
229 267
 
230
-        } else
231
-            return false;
268
+        } else {
269
+                    return false;
270
+        }
232 271
     }
233 272
 
234 273
 
235 274
     // PSEUDO-ABSTRACT STATIC METHODS
236 275
 
237
-    static function available() {
276
+    static function available()
277
+    {
238 278
         return function_exists("imagecreatefromjpeg");
239 279
     }
240 280
 
241
-    static function checkImage($file) {
281
+    static function checkImage($file)
282
+    {
242 283
         if (!is_string($file) ||
243 284
             ((false === (list($width, $height, $t) = @getimagesize($file))))
244
-        )
245
-            return false;
285
+        ) {
286
+                    return false;
287
+        }
246 288
 
247 289
         $img =
248 290
             ($t == IMAGETYPE_GIF)  ? @imagecreatefromgif($file)  : (
@@ -258,34 +300,41 @@  discard block
 block discarded – undo
258 300
 
259 301
     // OWN METHODS
260 302
 
261
-    protected function output_png(array $options=array()) {
303
+    protected function output_png(array $options=array())
304
+    {
262 305
         $file = isset($options['file']) ? $options['file'] : null;
263 306
         $quality = isset($options['quality']) ? $options['quality'] : null;
264 307
         $filters = isset($options['filters']) ? $options['filters'] : null;
265
-        if (($file === null) && !headers_sent())
266
-            header("Content-Type: image/png");
308
+        if (($file === null) && !headers_sent()) {
309
+                    header("Content-Type: image/png");
310
+        }
267 311
         @imagesavealpha($this->image, true);
268 312
         return imagepng($this->image, $file, $quality, $filters);
269 313
     }
270 314
 
271
-    protected function output_jpeg(array $options=array()) {
315
+    protected function output_jpeg(array $options=array())
316
+    {
272 317
         $file = isset($options['file']) ? $options['file'] : null;
273 318
         $quality = isset($options['quality'])
274 319
             ? $options['quality']
275 320
             : self::DEFAULT_JPEG_QUALITY;
276
-        if (($file === null) && !headers_sent())
277
-            header("Content-Type: image/jpeg");
321
+        if (($file === null) && !headers_sent()) {
322
+                    header("Content-Type: image/jpeg");
323
+        }
278 324
         return imagejpeg($this->image, $file, $quality);
279 325
     }
280 326
 
281
-    protected function output_gif(array $options=array()) {
327
+    protected function output_gif(array $options=array())
328
+    {
282 329
         $file = isset($options['file']) ? $options['file'] : null;
283
-        if (isset($options['file']) && !headers_sent())
284
-            header("Content-Type: image/gif");
330
+        if (isset($options['file']) && !headers_sent()) {
331
+                    header("Content-Type: image/gif");
332
+        }
285 333
         return imagegif($this->image, $file);
286 334
     }
287 335
 
288
-    protected function gdColor() {
336
+    protected function gdColor()
337
+    {
289 338
         $args = func_get_args();
290 339
 
291 340
         $exprRGB = '/^rgb\(\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\)$/i';
@@ -293,8 +342,9 @@  discard block
 block discarded – undo
293 342
         $exprHex2 = '/^\#?([0-9a-f])([0-9a-f])([0-9a-f])$/i';
294 343
         $exprByte = '/^([01]?\d?\d|2[0-4]\d|25[0-5])$/';
295 344
 
296
-        if (!isset($args[0]))
297
-            return false;
345
+        if (!isset($args[0])) {
346
+                    return false;
347
+        }
298 348
 
299 349
         if (count($args[0]) == 3) {
300 350
             list($r, $g, $b) = $args[0];
@@ -321,15 +371,19 @@  discard block
 block discarded – undo
321 371
         ) {
322 372
             list($r, $g, $b) = $args;
323 373
 
324
-        } else
325
-            return false;
374
+        } else {
375
+                    return false;
376
+        }
326 377
 
327 378
         return imagecolorallocate($this->image, $r, $g, $b);
328 379
     }
329 380
 
330
-    protected function imageFilledRectangle($x1, $y1, $x2, $y2, $color) {
381
+    protected function imageFilledRectangle($x1, $y1, $x2, $y2, $color)
382
+    {
331 383
         $color = $this->gdColor($color);
332
-        if ($color === false) return false;
384
+        if ($color === false) {
385
+            return false;
386
+        }
333 387
         return imageFilledRectangle($this->image, $x1, $y1, $x2, $y2, $color);
334 388
     }
335 389
 
@@ -338,15 +392,24 @@  discard block
 block discarded – undo
338 392
     ) {
339 393
         $imageDetails = $this->buildImage($src);
340 394
 
341
-        if ($imageDetails === false)
342
-            return false;
395
+        if ($imageDetails === false) {
396
+                    return false;
397
+        }
343 398
 
344 399
         list($src, $srcWidth, $srcHeight) = $imageDetails;
345 400
 
346
-        if (is_null($dstW)) $dstW = $this->width - $dstW;
347
-        if (is_null($dstH)) $dstH = $this->height - $dstY;
348
-        if (is_null($srcW)) $srcW = $srcWidth - $srcX;
349
-        if (is_null($srcH)) $srcH = $srcHeight - $srcY;
401
+        if (is_null($dstW)) {
402
+            $dstW = $this->width - $dstW;
403
+        }
404
+        if (is_null($dstH)) {
405
+            $dstH = $this->height - $dstY;
406
+        }
407
+        if (is_null($srcW)) {
408
+            $srcW = $srcWidth - $srcX;
409
+        }
410
+        if (is_null($srcH)) {
411
+            $srcH = $srcHeight - $srcY;
412
+        }
350 413
         return imageCopyResampled($this->image, $src, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH);
351 414
     }
352 415
 }
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_zipFolder.php 5 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -18,6 +18,9 @@  discard block
 block discarded – undo
18 18
     protected $root;
19 19
     protected $ignored;
20 20
 
21
+    /**
22
+     * @param string $folder
23
+     */
21 24
     function __construct($file, $folder, $ignored=null) {
22 25
         $this->zip = new ZipArchive();
23 26
 
@@ -39,6 +42,9 @@  discard block
 block discarded – undo
39 42
         $this->zip->close();
40 43
     }
41 44
 
45
+    /**
46
+     * @param string $folder
47
+     */
42 48
     function zip($folder, $parent=null) {
43 49
         $full_path = "{$this->root}$parent$folder";
44 50
         $zip_path = "$parent$folder";
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project. The class are taken from
4
-  * http://www.php.net/manual/en/function.ziparchive-addemptydir.php
5
-  *
6
-  *      @desc Directory to ZIP file archivator
7
-  *   @package KCFinder
8
-  *   @version 2.54
9
-  *    @author Pavel Tzonkov <[email protected]>
10
-  * @copyright 2010-2014 KCFinder Project
11
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
12
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
13
-  *      @link http://kcfinder.sunhater.com
14
-  */
4
+ * http://www.php.net/manual/en/function.ziparchive-addemptydir.php
5
+ *
6
+ *      @desc Directory to ZIP file archivator
7
+ *   @package KCFinder
8
+ *   @version 2.54
9
+ *    @author Pavel Tzonkov <[email protected]>
10
+ * @copyright 2010-2014 KCFinder Project
11
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
12
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
13
+ *      @link http://kcfinder.sunhater.com
14
+ */
15 15
 
16 16
 class zipFolder {
17 17
     protected $zip;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,12 +13,12 @@  discard block
 block discarded – undo
13 13
   *      @link http://kcfinder.sunhater.com
14 14
   */
15 15
 
16
-class zipFolder {
16
+class zipFolder{
17 17
     protected $zip;
18 18
     protected $root;
19 19
     protected $ignored;
20 20
 
21
-    function __construct($file, $folder, $ignored=null) {
21
+    function __construct($file, $folder, $ignored = null){
22 22
         $this->zip = new ZipArchive();
23 23
 
24 24
         $this->ignored = is_array($ignored)
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $this->zip->close();
40 40
     }
41 41
 
42
-    function zip($folder, $parent=null) {
42
+    function zip($folder, $parent = null){
43 43
         $full_path = "{$this->root}$parent$folder";
44 44
         $zip_path = "$parent$folder";
45 45
         $this->zip->addEmptyDir($zip_path);
Please login to merge, or discard this patch.
Braces   +17 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,20 +13,23 @@  discard block
 block discarded – undo
13 13
   *      @link http://kcfinder.sunhater.com
14 14
   */
15 15
 
16
-class zipFolder {
16
+class zipFolder
17
+{
17 18
     protected $zip;
18 19
     protected $root;
19 20
     protected $ignored;
20 21
 
21
-    function __construct($file, $folder, $ignored=null) {
22
+    function __construct($file, $folder, $ignored=null)
23
+    {
22 24
         $this->zip = new ZipArchive();
23 25
 
24 26
         $this->ignored = is_array($ignored)
25 27
             ? $ignored
26 28
             : ($ignored ? array($ignored) : array());
27 29
 
28
-        if ($this->zip->open($file, ZIPARCHIVE::CREATE) !== TRUE)
29
-            throw new Exception("cannot open <$file>\n");
30
+        if ($this->zip->open($file, ZIPARCHIVE::CREATE) !== TRUE) {
31
+                    throw new Exception("cannot open <$file>\n");
32
+        }
30 33
 
31 34
         $folder = rtrim($folder, '/');
32 35
 
@@ -39,19 +42,22 @@  discard block
 block discarded – undo
39 42
         $this->zip->close();
40 43
     }
41 44
 
42
-    function zip($folder, $parent=null) {
45
+    function zip($folder, $parent=null)
46
+    {
43 47
         $full_path = "{$this->root}$parent$folder";
44 48
         $zip_path = "$parent$folder";
45 49
         $this->zip->addEmptyDir($zip_path);
46 50
         $dir = new DirectoryIterator($full_path);
47
-        foreach ($dir as $file)
48
-            if (!$file->isDot()) {
51
+        foreach ($dir as $file) {
52
+                    if (!$file->isDot()) {
49 53
                 $filename = $file->getFilename();
54
+        }
50 55
                 if (!in_array($filename, $this->ignored)) {
51
-                    if ($file->isDir())
52
-                        $this->zip($filename, "$zip_path/");
53
-                    else
54
-                        $this->zip->addFile("$full_path/$filename", "$zip_path/$filename");
56
+                    if ($file->isDir()) {
57
+                                            $this->zip($filename, "$zip_path/");
58
+                    } else {
59
+                                            $this->zip->addFile("$full_path/$filename", "$zip_path/$filename");
60
+                    }
55 61
                 }
56 62
             }
57 63
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
             ? $ignored
26 26
             : ($ignored ? array($ignored) : array());
27 27
 
28
-        if ($this->zip->open($file, ZIPARCHIVE::CREATE) !== TRUE)
28
+        if ($this->zip->open($file, ZIPARCHIVE::CREATE) !== true)
29 29
             throw new Exception("cannot open <$file>\n");
30 30
 
31 31
         $folder = rtrim($folder, '/');
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/helper_file.php 4 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -102,7 +102,6 @@  discard block
 block discarded – undo
102 102
 
103 103
   /** Checks if the given file is really writable. The standard PHP function
104 104
     * is_writable() does not work properly on Windows servers.
105
-    * @param string $dir
106 105
     * @return bool */
107 106
 
108 107
     static function isWritable($filename) {
@@ -114,7 +113,6 @@  discard block
 block discarded – undo
114 113
     }
115 114
 
116 115
   /** Get the extension from filename
117
-    * @param string $file
118 116
     * @param bool $toLower
119 117
     * @return string */
120 118
 
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc File helper class
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc File helper class
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class file {
16 16
 
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
         'zip'   => 'application/x-zip'
101 101
     );
102 102
 
103
-  /** Checks if the given file is really writable. The standard PHP function
104
-    * is_writable() does not work properly on Windows servers.
105
-    * @param string $dir
106
-    * @return bool */
103
+    /** Checks if the given file is really writable. The standard PHP function
104
+     * is_writable() does not work properly on Windows servers.
105
+     * @param string $dir
106
+     * @return bool */
107 107
 
108 108
     static function isWritable($filename) {
109 109
         $filename = path::normalize($filename);
@@ -113,26 +113,26 @@  discard block
 block discarded – undo
113 113
         return true;
114 114
     }
115 115
 
116
-  /** Get the extension from filename
117
-    * @param string $file
118
-    * @param bool $toLower
119
-    * @return string */
116
+    /** Get the extension from filename
117
+     * @param string $file
118
+     * @param bool $toLower
119
+     * @return string */
120 120
 
121 121
     static function getExtension($filename, $toLower=true) {
122 122
         return preg_match('/^.*\.([^\.]*)$/s', $filename, $patt)
123 123
             ? ($toLower ? strtolower($patt[1]) : $patt[1]) : "";
124 124
     }
125 125
 
126
-  /** Get MIME type of the given filename. If Fileinfo PHP extension is
127
-    * available the MIME type will be fetched by the file's content. The
128
-    * second parameter is optional and defines the magic file path. If you
129
-    * skip it, the default one will be loaded.
130
-    * If Fileinfo PHP extension is not available the MIME type will be fetched
131
-    * by filename extension regarding $MIME property. If the file extension
132
-    * does not exist there, returned type will be application/octet-stream
133
-    * @param string $filename
134
-    * @param string $magic
135
-    * @return string */
126
+    /** Get MIME type of the given filename. If Fileinfo PHP extension is
127
+     * available the MIME type will be fetched by the file's content. The
128
+     * second parameter is optional and defines the magic file path. If you
129
+     * skip it, the default one will be loaded.
130
+     * If Fileinfo PHP extension is not available the MIME type will be fetched
131
+     * by filename extension regarding $MIME property. If the file extension
132
+     * does not exist there, returned type will be application/octet-stream
133
+     * @param string $filename
134
+     * @param string $magic
135
+     * @return string */
136 136
 
137 137
     static function getMimeType($filename, $magic=null) {
138 138
         if (class_exists("finfo")) {
@@ -149,26 +149,26 @@  discard block
 block discarded – undo
149 149
         return isset(self::$MIME[$ext]) ? self::$MIME[$ext] : "application/octet-stream";
150 150
     }
151 151
 
152
-  /** Get inexistant filename based on the given filename. If you skip $dir
153
-    * parameter the directory will be fetched from $filename and returned
154
-    * value will be full filename path. The third parameter is optional and
155
-    * defines the template, the filename will be renamed to. Default template
156
-    * is {name}({sufix}){ext}. Examples:
157
-    *
158
-    *   file::getInexistantFilename("/my/directory/myfile.txt");
159
-    *   If myfile.txt does not exist - returns the same path to the file
160
-    *   otherwise returns "/my/directory/myfile(1).txt"
161
-    *
162
-    *   file::getInexistantFilename("myfile.txt", "/my/directory");
163
-    *   returns "myfile.txt" or "myfile(1).txt" or "myfile(2).txt" etc...
164
-    *
165
-    *   file::getInexistantFilename("myfile.txt", "/dir", "{name}[{sufix}]{ext}");
166
-    *   returns "myfile.txt" or "myfile[1].txt" or "myfile[2].txt" etc...
167
-    *
168
-    * @param string $filename
169
-    * @param string $dir
170
-    * @param string $tpl
171
-    * @return string */
152
+    /** Get inexistant filename based on the given filename. If you skip $dir
153
+     * parameter the directory will be fetched from $filename and returned
154
+     * value will be full filename path. The third parameter is optional and
155
+     * defines the template, the filename will be renamed to. Default template
156
+     * is {name}({sufix}){ext}. Examples:
157
+     *
158
+     *   file::getInexistantFilename("/my/directory/myfile.txt");
159
+     *   If myfile.txt does not exist - returns the same path to the file
160
+     *   otherwise returns "/my/directory/myfile(1).txt"
161
+     *
162
+     *   file::getInexistantFilename("myfile.txt", "/my/directory");
163
+     *   returns "myfile.txt" or "myfile(1).txt" or "myfile(2).txt" etc...
164
+     *
165
+     *   file::getInexistantFilename("myfile.txt", "/dir", "{name}[{sufix}]{ext}");
166
+     *   returns "myfile.txt" or "myfile[1].txt" or "myfile[2].txt" etc...
167
+     *
168
+     * @param string $filename
169
+     * @param string $dir
170
+     * @param string $tpl
171
+     * @return string */
172 172
 
173 173
     static function getInexistantFilename($filename, $dir=null, $tpl=null) {
174 174
         if ($tpl === null)  $tpl = "{name}({sufix}){ext}";
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class file {
15
+class file{
16 16
 
17 17
     static $MIME = array(
18 18
         'ai'    => 'application/postscript',
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     * @param string $dir
106 106
     * @return bool */
107 107
 
108
-    static function isWritable($filename) {
108
+    static function isWritable($filename){
109 109
         $filename = path::normalize($filename);
110 110
         if (!is_file($filename) || (false === ($fp = @fopen($filename, 'a+'))))
111 111
             return false;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     * @param bool $toLower
119 119
     * @return string */
120 120
 
121
-    static function getExtension($filename, $toLower=true) {
121
+    static function getExtension($filename, $toLower = true){
122 122
         return preg_match('/^.*\.([^\.]*)$/s', $filename, $patt)
123 123
             ? ($toLower ? strtolower($patt[1]) : $patt[1]) : "";
124 124
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     * @param string $magic
135 135
     * @return string */
136 136
 
137
-    static function getMimeType($filename, $magic=null) {
137
+    static function getMimeType($filename, $magic = null){
138 138
         if (class_exists("finfo")) {
139 139
             $finfo = ($magic === null)
140 140
                 ? new finfo(FILEINFO_MIME)
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     * @param string $tpl
171 171
     * @return string */
172 172
 
173
-    static function getInexistantFilename($filename, $dir=null, $tpl=null) {
173
+    static function getInexistantFilename($filename, $dir = null, $tpl = null){
174 174
         if ($tpl === null)  $tpl = "{name}({sufix}){ext}";
175 175
         $fullPath = ($dir === null);
176 176
         if ($fullPath)
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
         $tpl = str_replace('{ext}', (strlen($ext) ? ".$ext" : ""), $tpl);
189 189
         $i = 1; $file = "$dir/$filename";
190 190
         while (file_exists($file))
191
-            $file = "$dir/" . str_replace('{sufix}', $i++, $tpl);
191
+            $file = "$dir/".str_replace('{sufix}', $i++, $tpl);
192 192
 
193 193
         return $fullPath
194 194
             ? $file
195 195
             : (strlen($fdir)
196
-                ? "$fdir/" . basename($file)
196
+                ? "$fdir/".basename($file)
197 197
                 : basename($file));
198 198
     }
199 199
 
Please login to merge, or discard this patch.
Braces   +22 added lines, -13 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class file {
15
+class file
16
+{
16 17
 
17 18
     static $MIME = array(
18 19
         'ai'    => 'application/postscript',
@@ -105,10 +106,12 @@  discard block
 block discarded – undo
105 106
     * @param string $dir
106 107
     * @return bool */
107 108
 
108
-    static function isWritable($filename) {
109
+    static function isWritable($filename)
110
+    {
109 111
         $filename = path::normalize($filename);
110
-        if (!is_file($filename) || (false === ($fp = @fopen($filename, 'a+'))))
111
-            return false;
112
+        if (!is_file($filename) || (false === ($fp = @fopen($filename, 'a+')))) {
113
+                    return false;
114
+        }
112 115
         fclose($fp);
113 116
         return true;
114 117
     }
@@ -118,7 +121,8 @@  discard block
 block discarded – undo
118 121
     * @param bool $toLower
119 122
     * @return string */
120 123
 
121
-    static function getExtension($filename, $toLower=true) {
124
+    static function getExtension($filename, $toLower=true)
125
+    {
122 126
         return preg_match('/^.*\.([^\.]*)$/s', $filename, $patt)
123 127
             ? ($toLower ? strtolower($patt[1]) : $patt[1]) : "";
124 128
     }
@@ -134,7 +138,8 @@  discard block
 block discarded – undo
134 138
     * @param string $magic
135 139
     * @return string */
136 140
 
137
-    static function getMimeType($filename, $magic=null) {
141
+    static function getMimeType($filename, $magic=null)
142
+    {
138 143
         if (class_exists("finfo")) {
139 144
             $finfo = ($magic === null)
140 145
                 ? new finfo(FILEINFO_MIME)
@@ -170,12 +175,15 @@  discard block
 block discarded – undo
170 175
     * @param string $tpl
171 176
     * @return string */
172 177
 
173
-    static function getInexistantFilename($filename, $dir=null, $tpl=null) {
174
-        if ($tpl === null)  $tpl = "{name}({sufix}){ext}";
178
+    static function getInexistantFilename($filename, $dir=null, $tpl=null)
179
+    {
180
+        if ($tpl === null) {
181
+            $tpl = "{name}({sufix}){ext}";
182
+        }
175 183
         $fullPath = ($dir === null);
176
-        if ($fullPath)
177
-            $dir = path::normalize(dirname($filename));
178
-        else {
184
+        if ($fullPath) {
185
+                    $dir = path::normalize(dirname($filename));
186
+        } else {
179 187
             $fdir = dirname($filename);
180 188
             $dir = strlen($fdir)
181 189
                 ? path::normalize("$dir/$fdir")
@@ -187,8 +195,9 @@  discard block
 block discarded – undo
187 195
         $tpl = str_replace('{name}', $name, $tpl);
188 196
         $tpl = str_replace('{ext}', (strlen($ext) ? ".$ext" : ""), $tpl);
189 197
         $i = 1; $file = "$dir/$filename";
190
-        while (file_exists($file))
191
-            $file = "$dir/" . str_replace('{sufix}', $i++, $tpl);
198
+        while (file_exists($file)) {
199
+                    $file = "$dir/" . str_replace('{sufix}', $i++, $tpl);
200
+        }
192 201
 
193 202
         return $fullPath
194 203
             ? $file
Please login to merge, or discard this patch.