GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( e9dabe...266fe5 )
by Thorsten
10:09 queued 35s
created
phpmyfaq/inc/PMF/Mail.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -932,7 +932,7 @@
 block discarded – undo
932 932
         }
933 933
         
934 934
         if (false === filter_var($address, FILTER_VALIDATE_EMAIL)) {
935
-          return false;
935
+            return false;
936 936
         }
937 937
         
938 938
         return true;
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         $this->headers     = [];
241 241
         $this->message     = '';
242 242
         $this->messageAlt  = '';
243
-        $this->messageId   = '<'.$_SERVER['REQUEST_TIME'] . '.'. md5(microtime()) . '@' . self::getServerName() . '>';
243
+        $this->messageId   = '<'.$_SERVER['REQUEST_TIME'].'.'.md5(microtime()).'@'.self::getServerName().'>';
244 244
         $this->priority    = 3; // 3 -> Normal
245 245
         $this->subject     = '';
246 246
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         $this->_bcc        = [];
250 250
         $this->_cc         = [];
251 251
         $this->_from       = [];
252
-        $this->_mailer     = 'phpMyFAQ on PHP/' . PHP_VERSION;
252
+        $this->_mailer     = 'phpMyFAQ on PHP/'.PHP_VERSION;
253 253
         $this->_notifyTo   = [];
254 254
         $this->_replyTo    = [];
255 255
         $this->_returnPath = [];
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         $this->_to         = [];
258 258
 
259 259
         // Set phpMyFAQ related data
260
-        $this->_mailer = 'phpMyFAQ/' . $this->_config->get('main.currentVersion');
260
+        $this->_mailer = 'phpMyFAQ/'.$this->_config->get('main.currentVersion');
261 261
         $this->setFrom($this->_config->get('main.administrationMail'));
262 262
     }
263 263
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
             
305 305
             // Wrap the displayed name in quotes (to fix problems with commas etc),
306 306
             // and escape any existing quotes
307
-            $name = '"' . str_replace('"', '\"', $name) . '"';
307
+            $name = '"'.str_replace('"', '\"', $name).'"';
308 308
         }
309 309
 
310 310
         // Add the e-mail address into the target array
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 
433 433
         // Disposition-Notification-To, RFC 3798
434 434
         $notifyTos = [];
435
-        foreach($this->_notifyTo as $address => $name) {
435
+        foreach ($this->_notifyTo as $address => $name) {
436 436
             $notifyTos[] = (empty($name) ? '' : $name.' ').'<'.$address.'>';
437 437
         }
438 438
         $notifyTo = implode(',', $notifyTos);
@@ -442,17 +442,17 @@  discard block
 block discarded – undo
442 442
 
443 443
         // From
444 444
         foreach ($this->_from as $address => $name) {
445
-            $this->headers['From'] = (empty($name) ? '' : $name.' ') . '<' . $address . '>';
445
+            $this->headers['From'] = (empty($name) ? '' : $name.' ').'<'.$address.'>';
446 446
         }
447 447
 
448 448
         // CC
449 449
         foreach ($this->_cc as $address => $name) {
450
-            $this->headers['CC'] = (empty($name) ? '' : $name.' ') . '<' . $address . '>';
450
+            $this->headers['CC'] = (empty($name) ? '' : $name.' ').'<'.$address.'>';
451 451
         }
452 452
 
453 453
         // BCC
454 454
         foreach ($this->_bcc as $address => $name) {
455
-            $this->headers['BCC'] = (empty($name) ? '' : $name.' ') . '<' . $address . '>';
455
+            $this->headers['BCC'] = (empty($name) ? '' : $name.' ').'<'.$address.'>';
456 456
         }
457 457
 
458 458
         // Message-Id
@@ -463,21 +463,21 @@  discard block
 block discarded – undo
463 463
 
464 464
         // Reply-To
465 465
         $this->headers['Reply-To'] = $this->headers['From'];
466
-        foreach($this->_replyTo as $address => $name) {
466
+        foreach ($this->_replyTo as $address => $name) {
467 467
             $this->headers['Reply-To'] = (empty($name) ? '' : $name.' ').'<'.$address.'>';
468 468
         }
469 469
 
470 470
         // Return-Path
471
-        foreach($this->_from as $address => $name) {
471
+        foreach ($this->_from as $address => $name) {
472 472
             $this->headers['Return-Path'] = '<'.$address.'>';
473 473
         }
474
-        foreach($this->_returnPath as $address => $name) {
474
+        foreach ($this->_returnPath as $address => $name) {
475 475
             $this->headers['Return-Path'] = '<'.$address.'>';
476 476
         }
477 477
 
478 478
         // Sender
479 479
         $this->headers['Sender'] = $this->headers['From'];
480
-        foreach($this->_sender as $address => $name) {
480
+        foreach ($this->_sender as $address => $name) {
481 481
             $this->headers['Sender'] = (empty($name) ? '' : $name.' ').'<'.$address.'>';
482 482
         }
483 483
 
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
      */          
622 622
     public static function createBoundary()
623 623
     {
624
-        return '-----'  .md5(microtime());
624
+        return '-----'.md5(microtime());
625 625
     }
626 626
 
627 627
     /**
@@ -637,9 +637,9 @@  discard block
 block discarded – undo
637 637
         // Assure that anything among CRLF, CR will be replaced with just LF
638 638
         $text = str_replace(
639 639
             array(
640
-                "\r\n",// CRLF
640
+                "\r\n", // CRLF
641 641
                 "\r", // CR
642
-                "\n",// LF
642
+                "\n", // LF
643 643
             ),
644 644
             "\n", // LF
645 645
             $text
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 
765 765
         // Prepare the recipients
766 766
         $to = [];
767
-        foreach($this->_to as $address => $name) {
767
+        foreach ($this->_to as $address => $name) {
768 768
             $to[] = (empty($name) ? '' : $name.' ').'<'.$address.'>';
769 769
         }
770 770
         $recipients = implode(',', $to);
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
         $this->_createBody();
781 781
 
782 782
         // Send the email adopting to the given MUA
783
-        $mua  = self::getMUA($this->agent);
783
+        $mua = self::getMUA($this->agent);
784 784
         switch ($this->agent) {
785 785
             case 'built-in':
786 786
                 $sent = $mua->send($recipients, $this->headers, $this->body);
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
             return false;
927 927
         }
928 928
         
929
-        $unsafe = array ("\r", "\n");
929
+        $unsafe = array("\r", "\n");
930 930
         if ($address !== str_replace($unsafe, '', $address)) {
931 931
             return false;
932 932
         }
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
     public function safeEmail($email)
981 981
     {
982 982
         if ($this->_config->get('spam.enableSafeEmail')) {
983
-            return str_replace ( array ('@', '.' ), array ('_AT_', '_DOT_' ), $email );
983
+            return str_replace(array('@', '.'), array('_AT_', '_DOT_'), $email);
984 984
         } else {
985 985
             return $email;
986 986
         }
Please login to merge, or discard this patch.
phpmyfaq/inc/PMF/Mail/IMUA.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
  * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
32 32
  * @link      http://www.phpmyfaq.de
33 33
  * @since     2009-09-11
34
-  */ 
34
+ */ 
35 35
 interface PMF_Mail_IMUA
36 36
 {
37 37
     /**
Please login to merge, or discard this patch.
phpmyfaq/inc/PMF/DB/Pgsql.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -119,11 +119,11 @@
 block discarded – undo
119 119
     }
120 120
 
121 121
     /**
122
-    * Escapes a string for use in a query
123
-    *
124
-    * @param   string
125
-    * @return  string
126
-    */
122
+     * Escapes a string for use in a query
123
+     *
124
+     * @param   string
125
+     * @return  string
126
+     */
127 127
     public function escape($string)
128 128
     {
129 129
         return pg_escape_string($this->conn, $string);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      *
69 69
      * @return boolean true, if connected, otherwise false
70 70
      */
71
-    public function connect ($host, $user, $password, $database = '')
71
+    public function connect($host, $user, $password, $database = '')
72 72
     {
73 73
         $connectionString = sprintf(
74 74
             'host=%s port=5432 dbname=%s user=%s password=%s',
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
     {
167 167
         $ret = [];
168 168
         if (false === $result) {
169
-            throw new Exception('Error while fetching result: ' . $this->error());
169
+            throw new Exception('Error while fetching result: '.$this->error());
170 170
         }
171 171
         
172 172
         while ($row = $this->fetchObject($result)) {
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * @param string $password Password
67 67
      * @param string $database Database name
68 68
      *
69
-     * @return boolean true, if connected, otherwise false
69
+     * @return null|boolean true, if connected, otherwise false
70 70
      */
71 71
     public function connect ($host, $user, $password, $database = '')
72 72
     {
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     /**
133 133
      * Fetch a result row as an object
134 134
      *
135
-     * @param   mixed $result
135
+     * @param   resource $result
136 136
      * @return  mixed
137 137
      */
138 138
     public function fetchObject($result)
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     /**
191 191
      * Logs the queries
192 192
      *
193
-     * @return  integer
193
+     * @return  string
194 194
      */
195 195
     public function log()
196 196
     {
@@ -201,6 +201,7 @@  discard block
 block discarded – undo
201 201
      * Returns just one row
202 202
      *
203 203
      * @param  string
204
+     * @param string $query
204 205
      * @return string
205 206
      */
206 207
     private function getOne($query)
@@ -285,7 +286,7 @@  discard block
 block discarded – undo
285 286
      *
286 287
      * @param string $prefix Table prefix
287 288
      *
288
-     * @return array
289
+     * @return string[]
289 290
      */
290 291
     public function getTableNames($prefix = '')
291 292
     {
Please login to merge, or discard this patch.
phpmyfaq/inc/PMF/Pagination.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -218,23 +218,23 @@
 block discarded – undo
218 218
         }
219 219
        
220 220
         if (isset($options['firstPageLinkTpl'])) {
221
-           $this->firstPageLinkTpl = $options['firstPageLinkTpl'];
221
+            $this->firstPageLinkTpl = $options['firstPageLinkTpl'];
222 222
         }
223 223
         
224 224
         if (isset($options['lastPageLinkTpl'])) {
225
-           $this->lastPageLinkTpl = $options['lastPageLinkTpl'];
225
+            $this->lastPageLinkTpl = $options['lastPageLinkTpl'];
226 226
         }
227 227
         
228 228
         if (isset($options['layoutTpl'])) {
229
-           $this->layoutTpl = $options['layoutTpl'];
229
+            $this->layoutTpl = $options['layoutTpl'];
230 230
         }
231 231
         
232 232
         if (isset($options['pageParamName'])) {
233
-           $this->pageParamName = $options['pageParamName'];
233
+            $this->pageParamName = $options['pageParamName'];
234 234
         }
235 235
 
236 236
         if (isset($options['seoName'])) {
237
-           $this->seoName = $options['seoName'];
237
+            $this->seoName = $options['seoName'];
238 238
         }
239 239
 
240 240
         if (isset($options['useRewrite']) && isset($options['rewriteUrl'])) {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         
260 260
         if (!empty($url)) {
261 261
             $match = [];
262
-            if (PMF_String::preg_match('$&(amp;|)' . $this->pageParamName . '=(\d+)$', $url, $match)) {
262
+            if (PMF_String::preg_match('$&(amp;|)'.$this->pageParamName.'=(\d+)$', $url, $match)) {
263 263
                 $page = isset($match[2]) ? $match[2] : $page;
264 264
             }
265 265
         }
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
     public function render()
276 276
     {
277 277
         $content   = [];
278
-        $pages     = ceil($this->total / $this->perPage);
279
-        $adjacents = floor($this->adjacents / 2) >= 1 ? floor($this->adjacents / 2) : 1;
278
+        $pages     = ceil($this->total/$this->perPage);
279
+        $adjacents = floor($this->adjacents/2) >= 1 ? floor($this->adjacents/2) : 1;
280 280
         
281 281
         for ($page = 1; $page <= $pages; $page++) {
282 282
             
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 
361 361
         } else {
362 362
 
363
-            $cleanedUrl = PMF_String::preg_replace(array('$&(amp;|)' . $this->pageParamName . '=(\d+)$'), '', $url);
363
+            $cleanedUrl = PMF_String::preg_replace(array('$&(amp;|)'.$this->pageParamName.'=(\d+)$'), '', $url);
364 364
             $url        = sprintf('%s&amp;%s=%d', $cleanedUrl, $this->pageParamName, $page);
365 365
 
366 366
         }
Please login to merge, or discard this patch.
phpmyfaq/inc/libs/tcpdf/tcpdf_filters.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * ASCIIHexDecode
146 146
 	 * Decodes data encoded in an ASCII hexadecimal representation, reproducing the original binary data.
147 147
 	 * @param $data (string) Data to decode.
148
-	 * @return Decoded data string.
148
+	 * @return string data string.
149 149
 	 * @public
150 150
 	 * @since 1.0.000 (2011-05-23)
151 151
 	 */
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 * ASCII85Decode
186 186
 	 * Decodes data encoded in an ASCII base-85 representation, reproducing the original binary data.
187 187
 	 * @param $data (string) Data to decode.
188
-	 * @return Decoded data string.
188
+	 * @return string data string.
189 189
 	 * @public
190 190
 	 * @since 1.0.000 (2011-05-23)
191 191
 	 */
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 * LZWDecode
270 270
 	 * Decompresses data encoded using the LZW (Lempel-Ziv-Welch) adaptive compression method, reproducing the original text or binary data.
271 271
 	 * @param $data (string) Data to decode.
272
-	 * @return Decoded data string.
272
+	 * @return string data string.
273 273
 	 * @public
274 274
 	 * @since 1.0.000 (2011-05-23)
275 275
 	 */
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	 * FlateDecode
351 351
 	 * Decompresses data encoded using the zlib/deflate compression method, reproducing the original text or binary data.
352 352
 	 * @param $data (string) Data to decode.
353
-	 * @return Decoded data string.
353
+	 * @return string data string.
354 354
 	 * @public
355 355
 	 * @since 1.0.000 (2011-05-23)
356 356
 	 */
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 
464 464
 	/**
465 465
 	 * This method is automatically called in case of fatal error; it simply outputs the message and halts the execution.
466
-	 * @param $msg (string) The error message
466
+	 * @param string $msg (string) The error message
467 467
 	 * @public
468 468
 	 * @since 1.0.000 (2011-05-23)
469 469
 	 */
Please login to merge, or discard this patch.
Indentation   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -52,425 +52,425 @@
 block discarded – undo
52 52
  */
53 53
 class TCPDF_FILTERS {
54 54
 
55
-	/**
56
-	 * Define a list of available filter decoders.
57
-	 * @private
58
-	 */
59
-	private $available_filters = array('ASCIIHexDecode', 'ASCII85Decode', 'LZWDecode', 'FlateDecode', 'RunLengthDecode');
55
+    /**
56
+     * Define a list of available filter decoders.
57
+     * @private
58
+     */
59
+    private $available_filters = array('ASCIIHexDecode', 'ASCII85Decode', 'LZWDecode', 'FlateDecode', 'RunLengthDecode');
60 60
 
61 61
 // -----------------------------------------------------------------------------
62 62
 
63
-	/**
64
-	 * Get a list of available decoding filters.
65
-	 * @return (array) Array of available filter decoders.
66
-	 * @public
67
-	 * @since 1.0.000 (2011-05-23)
68
-	 */
69
-	public function getAvailableFilters() {
70
-		return $this->available_filters;
71
-	}
63
+    /**
64
+     * Get a list of available decoding filters.
65
+     * @return (array) Array of available filter decoders.
66
+     * @public
67
+     * @since 1.0.000 (2011-05-23)
68
+     */
69
+    public function getAvailableFilters() {
70
+        return $this->available_filters;
71
+    }
72 72
 
73
-	/**
74
-	 * Decode data using the specified filter type.
75
-	 * @param $filter (string) Filter name.
76
-	 * @param $data (string) Data to decode.
77
-	 * @return Decoded data string.
78
-	 * @public
79
-	 * @since 1.0.000 (2011-05-23)
80
-	 */
81
-	public function decodeFilter($filter, $data) {
82
-		switch ($filter) {
83
-			case 'ASCIIHexDecode': {
84
-				return $this->decodeFilterASCIIHexDecode($data);
85
-				break;
86
-			}
87
-			case 'ASCII85Decode': {
88
-				return $this->decodeFilterASCII85Decode($data);
89
-				break;
90
-			}
91
-			case 'LZWDecode': {
92
-				return $this->decodeFilterLZWDecode($data);
93
-				break;
94
-			}
95
-			case 'FlateDecode': {
96
-				return $this->decodeFilterFlateDecode($data);
97
-				break;
98
-			}
99
-			case 'RunLengthDecode': {
100
-				return $this->decodeFilterRunLengthDecode($data);
101
-				break;
102
-			}
103
-			case 'CCITTFaxDecode': {
104
-				return $this->decodeFilterCCITTFaxDecode($data);
105
-				break;
106
-			}
107
-			case 'JBIG2Decode': {
108
-				return $this->decodeFilterJBIG2Decode($data);
109
-				break;
110
-			}
111
-			case 'DCTDecode': {
112
-				return $this->decodeFilterDCTDecode($data);
113
-				break;
114
-			}
115
-			case 'JPXDecode': {
116
-				return $this->decodeFilterJPXDecode($data);
117
-				break;
118
-			}
119
-			case 'Crypt': {
120
-				return $this->decodeFilterCrypt($data);
121
-				break;
122
-			}
123
-			default: {
124
-				return decodeFilterStandard($data);
125
-				break;
126
-			}
127
-		}
128
-	}
73
+    /**
74
+     * Decode data using the specified filter type.
75
+     * @param $filter (string) Filter name.
76
+     * @param $data (string) Data to decode.
77
+     * @return Decoded data string.
78
+     * @public
79
+     * @since 1.0.000 (2011-05-23)
80
+     */
81
+    public function decodeFilter($filter, $data) {
82
+        switch ($filter) {
83
+            case 'ASCIIHexDecode': {
84
+                return $this->decodeFilterASCIIHexDecode($data);
85
+                break;
86
+            }
87
+            case 'ASCII85Decode': {
88
+                return $this->decodeFilterASCII85Decode($data);
89
+                break;
90
+            }
91
+            case 'LZWDecode': {
92
+                return $this->decodeFilterLZWDecode($data);
93
+                break;
94
+            }
95
+            case 'FlateDecode': {
96
+                return $this->decodeFilterFlateDecode($data);
97
+                break;
98
+            }
99
+            case 'RunLengthDecode': {
100
+                return $this->decodeFilterRunLengthDecode($data);
101
+                break;
102
+            }
103
+            case 'CCITTFaxDecode': {
104
+                return $this->decodeFilterCCITTFaxDecode($data);
105
+                break;
106
+            }
107
+            case 'JBIG2Decode': {
108
+                return $this->decodeFilterJBIG2Decode($data);
109
+                break;
110
+            }
111
+            case 'DCTDecode': {
112
+                return $this->decodeFilterDCTDecode($data);
113
+                break;
114
+            }
115
+            case 'JPXDecode': {
116
+                return $this->decodeFilterJPXDecode($data);
117
+                break;
118
+            }
119
+            case 'Crypt': {
120
+                return $this->decodeFilterCrypt($data);
121
+                break;
122
+            }
123
+            default: {
124
+                return decodeFilterStandard($data);
125
+                break;
126
+            }
127
+        }
128
+    }
129 129
 
130
-	// --- FILTERS (PDF 32000-2008 - 7.4 Filters) ------------------------------
130
+    // --- FILTERS (PDF 32000-2008 - 7.4 Filters) ------------------------------
131 131
 
132
-	/**
133
-	 * Standard
134
-	 * Default decoding filter (leaves data unchanged).
135
-	 * @param $data (string) Data to decode.
136
-	 * @return Decoded data string.
137
-	 * @public
138
-	 * @since 1.0.000 (2011-05-23)
139
-	 */
140
-	public function decodeFilterStandard($data) {
141
-		return $data;
142
-	}
132
+    /**
133
+     * Standard
134
+     * Default decoding filter (leaves data unchanged).
135
+     * @param $data (string) Data to decode.
136
+     * @return Decoded data string.
137
+     * @public
138
+     * @since 1.0.000 (2011-05-23)
139
+     */
140
+    public function decodeFilterStandard($data) {
141
+        return $data;
142
+    }
143 143
 
144
-	/**
145
-	 * ASCIIHexDecode
146
-	 * Decodes data encoded in an ASCII hexadecimal representation, reproducing the original binary data.
147
-	 * @param $data (string) Data to decode.
148
-	 * @return Decoded data string.
149
-	 * @public
150
-	 * @since 1.0.000 (2011-05-23)
151
-	 */
152
-	public function decodeFilterASCIIHexDecode($data) {
153
-		// intialize string to return
154
-		$decoded = '';
155
-		// all white-space characters shall be ignored
156
-		$data = preg_replace('/[\s]/', '', $data);
157
-		// check for EOD character: GREATER-THAN SIGN (3Eh)
158
-		$eod = strpos($data, '>');
159
-		if ($eod !== false) {
160
-			// remove EOD and extra data (if any)
161
-			$data = substr($data, 0, $eod);
162
-			$eod = true;
163
-		}
164
-		// get data length
165
-		$data_length = strlen($data);
166
-		if (($data_length % 2) != 0) {
167
-			// odd number of hexadecimal digits
168
-			if ($eod) {
169
-				// EOD shall behave as if a 0 (zero) followed the last digit
170
-				$data = substr($data, 0, -1).'0'.substr($data, -1);
171
-			} else {
172
-				$this->Error('decodeASCIIHex: invalid code');
173
-			}
174
-		}
175
-		// check for invalid characters
176
-		if (preg_match('/[^a-fA-F\d]/', $data) > 0) {
177
-			$this->Error('decodeASCIIHex: invalid code');
178
-		}
179
-		// get one byte of binary data for each pair of ASCII hexadecimal digits
180
-		$decoded = pack('H*', $data);
181
-		return $decoded;
182
-	}
144
+    /**
145
+     * ASCIIHexDecode
146
+     * Decodes data encoded in an ASCII hexadecimal representation, reproducing the original binary data.
147
+     * @param $data (string) Data to decode.
148
+     * @return Decoded data string.
149
+     * @public
150
+     * @since 1.0.000 (2011-05-23)
151
+     */
152
+    public function decodeFilterASCIIHexDecode($data) {
153
+        // intialize string to return
154
+        $decoded = '';
155
+        // all white-space characters shall be ignored
156
+        $data = preg_replace('/[\s]/', '', $data);
157
+        // check for EOD character: GREATER-THAN SIGN (3Eh)
158
+        $eod = strpos($data, '>');
159
+        if ($eod !== false) {
160
+            // remove EOD and extra data (if any)
161
+            $data = substr($data, 0, $eod);
162
+            $eod = true;
163
+        }
164
+        // get data length
165
+        $data_length = strlen($data);
166
+        if (($data_length % 2) != 0) {
167
+            // odd number of hexadecimal digits
168
+            if ($eod) {
169
+                // EOD shall behave as if a 0 (zero) followed the last digit
170
+                $data = substr($data, 0, -1).'0'.substr($data, -1);
171
+            } else {
172
+                $this->Error('decodeASCIIHex: invalid code');
173
+            }
174
+        }
175
+        // check for invalid characters
176
+        if (preg_match('/[^a-fA-F\d]/', $data) > 0) {
177
+            $this->Error('decodeASCIIHex: invalid code');
178
+        }
179
+        // get one byte of binary data for each pair of ASCII hexadecimal digits
180
+        $decoded = pack('H*', $data);
181
+        return $decoded;
182
+    }
183 183
 
184
-	/**
185
-	 * ASCII85Decode
186
-	 * Decodes data encoded in an ASCII base-85 representation, reproducing the original binary data.
187
-	 * @param $data (string) Data to decode.
188
-	 * @return Decoded data string.
189
-	 * @public
190
-	 * @since 1.0.000 (2011-05-23)
191
-	 */
192
-	public function decodeFilterASCII85Decode($data) {
193
-		// intialize string to return
194
-		$decoded = '';
195
-		// all white-space characters shall be ignored
196
-		$data = preg_replace('/[\s]/', '', $data);
197
-		// remove start sequence 2-character sequence <~ (3Ch)(7Eh)
198
-		if (strpos($data, '<~') !== false) {
199
-			// remove EOD and extra data (if any)
200
-			$data = substr($data, 2);
201
-		}
202
-		// check for EOD: 2-character sequence ~> (7Eh)(3Eh)
203
-		$eod = strpos($data, '~>');
204
-		if ($eod !== false) {
205
-			// remove EOD and extra data (if any)
206
-			$data = substr($data, 0, $eod);
207
-		}
208
-		// data length
209
-		$data_length = strlen($data);
210
-		// check for invalid characters
211
-		if (preg_match('/[^\x21-\x75,\x74]/', $data) > 0) {
212
-			$this->Error('decodeASCII85: invalid code');
213
-		}
214
-		// z sequence
215
-		$zseq = chr(0).chr(0).chr(0).chr(0);
216
-		// position inside a group of 4 bytes (0-3)
217
-		$group_pos = 0;
218
-		$tuple = 0;
219
-		$pow85 = array((85*85*85*85), (85*85*85), (85*85), 85, 1);
220
-		$last_pos = ($data_length - 1);
221
-		// for each byte
222
-		for ($i = 0; $i < $data_length; ++$i) {
223
-			// get char value
224
-			$char = ord($data[$i]);
225
-			if ($char == 122) { // 'z'
226
-				if ($group_pos == 0) {
227
-					$decoded .= $zseq;
228
-				} else {
229
-					$this->Error('decodeASCII85: invalid code');
230
-				}
231
-			} else {
232
-				// the value represented by a group of 5 characters should never be greater than 2^32 - 1
233
-				$tuple += (($char - 33) * $pow85[$group_pos]);
234
-				if ($group_pos == 4) {
235
-					$decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8).chr($tuple);
236
-					$tuple = 0;
237
-					$group_pos = 0;
238
-				} else {
239
-					++$group_pos;
240
-				}
241
-			}
242
-		}
243
-		if ($group_pos > 1) {
244
-			$tuple += $pow85[($group_pos - 1)];
245
-		}
246
-		// last tuple (if any)
247
-		switch ($group_pos) {
248
-			case 4: {
249
-				$decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8);
250
-				break;
251
-			}
252
-			case 3: {
253
-				$decoded .= chr($tuple >> 24).chr($tuple >> 16);
254
-				break;
255
-			}
256
-			case 2: {
257
-				$decoded .= chr($tuple >> 24);
258
-				break;
259
-			}
260
-			case 1: {
261
-				$this->Error('decodeASCII85: invalid code');
262
-				break;
263
-			}
264
-		}
265
-		return $decoded;
266
-	}
184
+    /**
185
+     * ASCII85Decode
186
+     * Decodes data encoded in an ASCII base-85 representation, reproducing the original binary data.
187
+     * @param $data (string) Data to decode.
188
+     * @return Decoded data string.
189
+     * @public
190
+     * @since 1.0.000 (2011-05-23)
191
+     */
192
+    public function decodeFilterASCII85Decode($data) {
193
+        // intialize string to return
194
+        $decoded = '';
195
+        // all white-space characters shall be ignored
196
+        $data = preg_replace('/[\s]/', '', $data);
197
+        // remove start sequence 2-character sequence <~ (3Ch)(7Eh)
198
+        if (strpos($data, '<~') !== false) {
199
+            // remove EOD and extra data (if any)
200
+            $data = substr($data, 2);
201
+        }
202
+        // check for EOD: 2-character sequence ~> (7Eh)(3Eh)
203
+        $eod = strpos($data, '~>');
204
+        if ($eod !== false) {
205
+            // remove EOD and extra data (if any)
206
+            $data = substr($data, 0, $eod);
207
+        }
208
+        // data length
209
+        $data_length = strlen($data);
210
+        // check for invalid characters
211
+        if (preg_match('/[^\x21-\x75,\x74]/', $data) > 0) {
212
+            $this->Error('decodeASCII85: invalid code');
213
+        }
214
+        // z sequence
215
+        $zseq = chr(0).chr(0).chr(0).chr(0);
216
+        // position inside a group of 4 bytes (0-3)
217
+        $group_pos = 0;
218
+        $tuple = 0;
219
+        $pow85 = array((85*85*85*85), (85*85*85), (85*85), 85, 1);
220
+        $last_pos = ($data_length - 1);
221
+        // for each byte
222
+        for ($i = 0; $i < $data_length; ++$i) {
223
+            // get char value
224
+            $char = ord($data[$i]);
225
+            if ($char == 122) { // 'z'
226
+                if ($group_pos == 0) {
227
+                    $decoded .= $zseq;
228
+                } else {
229
+                    $this->Error('decodeASCII85: invalid code');
230
+                }
231
+            } else {
232
+                // the value represented by a group of 5 characters should never be greater than 2^32 - 1
233
+                $tuple += (($char - 33) * $pow85[$group_pos]);
234
+                if ($group_pos == 4) {
235
+                    $decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8).chr($tuple);
236
+                    $tuple = 0;
237
+                    $group_pos = 0;
238
+                } else {
239
+                    ++$group_pos;
240
+                }
241
+            }
242
+        }
243
+        if ($group_pos > 1) {
244
+            $tuple += $pow85[($group_pos - 1)];
245
+        }
246
+        // last tuple (if any)
247
+        switch ($group_pos) {
248
+            case 4: {
249
+                $decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8);
250
+                break;
251
+            }
252
+            case 3: {
253
+                $decoded .= chr($tuple >> 24).chr($tuple >> 16);
254
+                break;
255
+            }
256
+            case 2: {
257
+                $decoded .= chr($tuple >> 24);
258
+                break;
259
+            }
260
+            case 1: {
261
+                $this->Error('decodeASCII85: invalid code');
262
+                break;
263
+            }
264
+        }
265
+        return $decoded;
266
+    }
267 267
 
268
-	/**
269
-	 * LZWDecode
270
-	 * Decompresses data encoded using the LZW (Lempel-Ziv-Welch) adaptive compression method, reproducing the original text or binary data.
271
-	 * @param $data (string) Data to decode.
272
-	 * @return Decoded data string.
273
-	 * @public
274
-	 * @since 1.0.000 (2011-05-23)
275
-	 */
276
-	public function decodeFilterLZWDecode($data) {
277
-		// intialize string to return
278
-		$decoded = '';
279
-		// data length
280
-		$data_length = strlen($data);
281
-		// convert string to binary string
282
-		$bitstring = '';
283
-		for ($i = 0; $i < $data_length; ++$i) {
284
-			$bitstring .= sprintf('%08b', ord($data{$i}));
285
-		}
286
-		// get the number of bits
287
-		$data_length = strlen($bitstring);
288
-		// initialize code length in bits
289
-		$bitlen = 9;
290
-		// initialize dictionary index
291
-		$dix = 258;
292
-		// initialize the dictionary (with the first 256 entries).
293
-		$dictionary = array();
294
-		for ($i = 0; $i < 256; ++$i) {
295
-			$dictionary[$i] = chr($i);
296
-		}
297
-		// previous val
298
-		$prev_index = 0;
299
-		// while we encounter EOD marker (257), read code_length bits
300
-		while (($data_length > 0) AND (($index = bindec(substr($bitstring, 0, $bitlen))) != 257)) {
301
-			// remove read bits from string
302
-			$bitstring = substr($bitstring, $bitlen);
303
-			// update number of bits
304
-			$data_length -= $bitlen;
305
-			if ($index == 256) { // clear-table marker
306
-				// reset code length in bits
307
-				$bitlen = 9;
308
-				// reset dictionary index
309
-				$dix = 258;
310
-				$prev_index = 256;
311
-				// reset the dictionary (with the first 256 entries).
312
-				$dictionary = array();
313
-				for ($i = 0; $i < 256; ++$i) {
314
-					$dictionary[$i] = chr($i);
315
-				}
316
-			} elseif ($prev_index == 256) {
317
-				// first entry
318
-				$decoded .= $dictionary[$index];
319
-				$prev_index = $index;
320
-			} else {
321
-				// check if index exist in the dictionary
322
-				if ($index < $dix) {
323
-					// index exist on dictionary
324
-					$decoded .= $dictionary[$index];
325
-					$dic_val = $dictionary[$prev_index].$dictionary[$index]{0};
326
-					// store current index
327
-					$prev_index = $index;
328
-				} else {
329
-					// index do not exist on dictionary
330
-					$dic_val = $dictionary[$prev_index].$dictionary[$prev_index]{0};
331
-					$decoded .= $dic_val;
332
-				}
333
-				// update dictionary
334
-				$dictionary[$dix] = $dic_val;
335
-				++$dix;
336
-				// change bit length by case
337
-				if ($dix == 2047) {
338
-					$bitlen = 12;
339
-				} elseif ($dix == 1023) {
340
-					$bitlen = 11;
341
-				} elseif ($dix == 511) {
342
-					$bitlen = 10;
343
-				}
344
-			}
345
-		}
346
-		return $decoded;
347
-	}
268
+    /**
269
+     * LZWDecode
270
+     * Decompresses data encoded using the LZW (Lempel-Ziv-Welch) adaptive compression method, reproducing the original text or binary data.
271
+     * @param $data (string) Data to decode.
272
+     * @return Decoded data string.
273
+     * @public
274
+     * @since 1.0.000 (2011-05-23)
275
+     */
276
+    public function decodeFilterLZWDecode($data) {
277
+        // intialize string to return
278
+        $decoded = '';
279
+        // data length
280
+        $data_length = strlen($data);
281
+        // convert string to binary string
282
+        $bitstring = '';
283
+        for ($i = 0; $i < $data_length; ++$i) {
284
+            $bitstring .= sprintf('%08b', ord($data{$i}));
285
+        }
286
+        // get the number of bits
287
+        $data_length = strlen($bitstring);
288
+        // initialize code length in bits
289
+        $bitlen = 9;
290
+        // initialize dictionary index
291
+        $dix = 258;
292
+        // initialize the dictionary (with the first 256 entries).
293
+        $dictionary = array();
294
+        for ($i = 0; $i < 256; ++$i) {
295
+            $dictionary[$i] = chr($i);
296
+        }
297
+        // previous val
298
+        $prev_index = 0;
299
+        // while we encounter EOD marker (257), read code_length bits
300
+        while (($data_length > 0) AND (($index = bindec(substr($bitstring, 0, $bitlen))) != 257)) {
301
+            // remove read bits from string
302
+            $bitstring = substr($bitstring, $bitlen);
303
+            // update number of bits
304
+            $data_length -= $bitlen;
305
+            if ($index == 256) { // clear-table marker
306
+                // reset code length in bits
307
+                $bitlen = 9;
308
+                // reset dictionary index
309
+                $dix = 258;
310
+                $prev_index = 256;
311
+                // reset the dictionary (with the first 256 entries).
312
+                $dictionary = array();
313
+                for ($i = 0; $i < 256; ++$i) {
314
+                    $dictionary[$i] = chr($i);
315
+                }
316
+            } elseif ($prev_index == 256) {
317
+                // first entry
318
+                $decoded .= $dictionary[$index];
319
+                $prev_index = $index;
320
+            } else {
321
+                // check if index exist in the dictionary
322
+                if ($index < $dix) {
323
+                    // index exist on dictionary
324
+                    $decoded .= $dictionary[$index];
325
+                    $dic_val = $dictionary[$prev_index].$dictionary[$index]{0};
326
+                    // store current index
327
+                    $prev_index = $index;
328
+                } else {
329
+                    // index do not exist on dictionary
330
+                    $dic_val = $dictionary[$prev_index].$dictionary[$prev_index]{0};
331
+                    $decoded .= $dic_val;
332
+                }
333
+                // update dictionary
334
+                $dictionary[$dix] = $dic_val;
335
+                ++$dix;
336
+                // change bit length by case
337
+                if ($dix == 2047) {
338
+                    $bitlen = 12;
339
+                } elseif ($dix == 1023) {
340
+                    $bitlen = 11;
341
+                } elseif ($dix == 511) {
342
+                    $bitlen = 10;
343
+                }
344
+            }
345
+        }
346
+        return $decoded;
347
+    }
348 348
 
349
-	/**
350
-	 * FlateDecode
351
-	 * Decompresses data encoded using the zlib/deflate compression method, reproducing the original text or binary data.
352
-	 * @param $data (string) Data to decode.
353
-	 * @return Decoded data string.
354
-	 * @public
355
-	 * @since 1.0.000 (2011-05-23)
356
-	 */
357
-	public function decodeFilterFlateDecode($data) {
358
-		// intialize string to return
359
-		$decoded = gzuncompress($data);
360
-		if ($decoded === false) {
361
-			$this->Error('decodeFlate: invalid code');
362
-		}
363
-		return $decoded;
364
-	}
349
+    /**
350
+     * FlateDecode
351
+     * Decompresses data encoded using the zlib/deflate compression method, reproducing the original text or binary data.
352
+     * @param $data (string) Data to decode.
353
+     * @return Decoded data string.
354
+     * @public
355
+     * @since 1.0.000 (2011-05-23)
356
+     */
357
+    public function decodeFilterFlateDecode($data) {
358
+        // intialize string to return
359
+        $decoded = gzuncompress($data);
360
+        if ($decoded === false) {
361
+            $this->Error('decodeFlate: invalid code');
362
+        }
363
+        return $decoded;
364
+    }
365 365
 
366
-	/**
367
-	 * RunLengthDecode
368
-	 * Decompresses data encoded using a byte-oriented run-length encoding algorithm.
369
-	 * @param $data (string) Data to decode.
370
-	 * @public
371
-	 * @since 1.0.000 (2011-05-23)
372
-	 */
373
-	public function decodeFilterRunLengthDecode($data) {
374
-		// intialize string to return
375
-		$decoded = '';
376
-		// data length
377
-		$data_length = strlen($data);
378
-		$i = 0;
379
-		while($i < $data_length) {
380
-			// get current byte value
381
-			$byte = ord($data{$i});
382
-			if ($byte == 128) {
383
-				// a length value of 128 denote EOD
384
-				break;
385
-			} elseif ($byte < 128) {
386
-				// if the length byte is in the range 0 to 127
387
-				// the following length + 1 (1 to 128) bytes shall be copied literally during decompression
388
-				$decoded .= substr($data, ($i + 1), ($byte + 1));
389
-				// move to next block
390
-				$i += ($byte + 2);
391
-			} else {
392
-				// if length is in the range 129 to 255,
393
-				// the following single byte shall be copied 257 - length (2 to 128) times during decompression
394
-				$decoded .= str_repeat($data{($i + 1)}, (257 - $byte));
395
-				// move to next block
396
-				$i += 2;
397
-			}
398
-		}
399
-		return $decoded;
400
-	}
366
+    /**
367
+     * RunLengthDecode
368
+     * Decompresses data encoded using a byte-oriented run-length encoding algorithm.
369
+     * @param $data (string) Data to decode.
370
+     * @public
371
+     * @since 1.0.000 (2011-05-23)
372
+     */
373
+    public function decodeFilterRunLengthDecode($data) {
374
+        // intialize string to return
375
+        $decoded = '';
376
+        // data length
377
+        $data_length = strlen($data);
378
+        $i = 0;
379
+        while($i < $data_length) {
380
+            // get current byte value
381
+            $byte = ord($data{$i});
382
+            if ($byte == 128) {
383
+                // a length value of 128 denote EOD
384
+                break;
385
+            } elseif ($byte < 128) {
386
+                // if the length byte is in the range 0 to 127
387
+                // the following length + 1 (1 to 128) bytes shall be copied literally during decompression
388
+                $decoded .= substr($data, ($i + 1), ($byte + 1));
389
+                // move to next block
390
+                $i += ($byte + 2);
391
+            } else {
392
+                // if length is in the range 129 to 255,
393
+                // the following single byte shall be copied 257 - length (2 to 128) times during decompression
394
+                $decoded .= str_repeat($data{($i + 1)}, (257 - $byte));
395
+                // move to next block
396
+                $i += 2;
397
+            }
398
+        }
399
+        return $decoded;
400
+    }
401 401
 
402
-	/**
403
-	 * CCITTFaxDecode (NOT IMPLEMETED)
404
-	 * Decompresses data encoded using the CCITT facsimile standard, reproducing the original data (typically monochrome image data at 1 bit per pixel).
405
-	 * @param $data (string) Data to decode.
406
-	 * @return Decoded data string.
407
-	 * @public
408
-	 * @since 1.0.000 (2011-05-23)
409
-	 */
410
-	public function decodeFilterCCITTFaxDecode($data) {
411
-		return $data;
412
-	}
402
+    /**
403
+     * CCITTFaxDecode (NOT IMPLEMETED)
404
+     * Decompresses data encoded using the CCITT facsimile standard, reproducing the original data (typically monochrome image data at 1 bit per pixel).
405
+     * @param $data (string) Data to decode.
406
+     * @return Decoded data string.
407
+     * @public
408
+     * @since 1.0.000 (2011-05-23)
409
+     */
410
+    public function decodeFilterCCITTFaxDecode($data) {
411
+        return $data;
412
+    }
413 413
 
414
-	/**
415
-	 * JBIG2Decode (NOT IMPLEMETED)
416
-	 * Decompresses data encoded using the JBIG2 standard, reproducing the original monochrome (1 bit per pixel) image data (or an approximation of that data).
417
-	 * @param $data (string) Data to decode.
418
-	 * @return Decoded data string.
419
-	 * @public
420
-	 * @since 1.0.000 (2011-05-23)
421
-	 */
422
-	public function decodeFilterJBIG2Decode($data) {
423
-		return $data;
424
-	}
414
+    /**
415
+     * JBIG2Decode (NOT IMPLEMETED)
416
+     * Decompresses data encoded using the JBIG2 standard, reproducing the original monochrome (1 bit per pixel) image data (or an approximation of that data).
417
+     * @param $data (string) Data to decode.
418
+     * @return Decoded data string.
419
+     * @public
420
+     * @since 1.0.000 (2011-05-23)
421
+     */
422
+    public function decodeFilterJBIG2Decode($data) {
423
+        return $data;
424
+    }
425 425
 
426
-	/**
427
-	 * DCTDecode (NOT IMPLEMETED)
428
-	 * Decompresses data encoded using a DCT (discrete cosine transform) technique based on the JPEG standard, reproducing image sample data that approximates the original data.
429
-	 * @param $data (string) Data to decode.
430
-	 * @return Decoded data string.
431
-	 * @public
432
-	 * @since 1.0.000 (2011-05-23)
433
-	 */
434
-	public function decodeFilterDCTDecode($data) {
435
-		return $data;
436
-	}
426
+    /**
427
+     * DCTDecode (NOT IMPLEMETED)
428
+     * Decompresses data encoded using a DCT (discrete cosine transform) technique based on the JPEG standard, reproducing image sample data that approximates the original data.
429
+     * @param $data (string) Data to decode.
430
+     * @return Decoded data string.
431
+     * @public
432
+     * @since 1.0.000 (2011-05-23)
433
+     */
434
+    public function decodeFilterDCTDecode($data) {
435
+        return $data;
436
+    }
437 437
 
438
-	/**
439
-	 * JPXDecode (NOT IMPLEMETED)
440
-	 * Decompresses data encoded using the wavelet-based JPEG2000 standard, reproducing the original image data.
441
-	 * @param $data (string) Data to decode.
442
-	 * @return Decoded data string.
443
-	 * @public
444
-	 * @since 1.0.000 (2011-05-23)
445
-	 */
446
-	public function decodeFilterJPXDecode($data) {
447
-		return $data;
448
-	}
438
+    /**
439
+     * JPXDecode (NOT IMPLEMETED)
440
+     * Decompresses data encoded using the wavelet-based JPEG2000 standard, reproducing the original image data.
441
+     * @param $data (string) Data to decode.
442
+     * @return Decoded data string.
443
+     * @public
444
+     * @since 1.0.000 (2011-05-23)
445
+     */
446
+    public function decodeFilterJPXDecode($data) {
447
+        return $data;
448
+    }
449 449
 
450
-	/**
451
-	 * Crypt (NOT IMPLEMETED)
452
-	 * Decrypts data encrypted by a security handler, reproducing the data as it was before encryption.
453
-	 * @param $data (string) Data to decode.
454
-	 * @return Decoded data string.
455
-	 * @public
456
-	 * @since 1.0.000 (2011-05-23)
457
-	 */
458
-	public function decodeFilterCrypt($data) {
459
-		return $data;
460
-	}
450
+    /**
451
+     * Crypt (NOT IMPLEMETED)
452
+     * Decrypts data encrypted by a security handler, reproducing the data as it was before encryption.
453
+     * @param $data (string) Data to decode.
454
+     * @return Decoded data string.
455
+     * @public
456
+     * @since 1.0.000 (2011-05-23)
457
+     */
458
+    public function decodeFilterCrypt($data) {
459
+        return $data;
460
+    }
461 461
 
462
-	// --- END FILTERS SECTION -------------------------------------------------
462
+    // --- END FILTERS SECTION -------------------------------------------------
463 463
 
464
-	/**
465
-	 * This method is automatically called in case of fatal error; it simply outputs the message and halts the execution.
466
-	 * @param $msg (string) The error message
467
-	 * @public
468
-	 * @since 1.0.000 (2011-05-23)
469
-	 */
470
-	public function Error($msg) {
471
-		// exit program and print error
472
-		die('<strong>TCPDF_FILTERS ERROR: </strong>'.$msg);
473
-	}
464
+    /**
465
+     * This method is automatically called in case of fatal error; it simply outputs the message and halts the execution.
466
+     * @param $msg (string) The error message
467
+     * @public
468
+     * @since 1.0.000 (2011-05-23)
469
+     */
470
+    public function Error($msg) {
471
+        // exit program and print error
472
+        die('<strong>TCPDF_FILTERS ERROR: </strong>'.$msg);
473
+    }
474 474
 
475 475
 } // END OF TCPDF_FILTERS CLASS
476 476
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		}
162 162
 		// get data length
163 163
 		$data_length = strlen($data);
164
-		if (($data_length % 2) != 0) {
164
+		if (($data_length%2) != 0) {
165 165
 			// odd number of hexadecimal digits
166 166
 			if ($eod) {
167 167
 				// EOD shall behave as if a 0 (zero) followed the last digit
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 				}
229 229
 			} else {
230 230
 				// the value represented by a group of 5 characters should never be greater than 2^32 - 1
231
-				$tuple += (($char - 33) * $pow85[$group_pos]);
231
+				$tuple += (($char - 33)*$pow85[$group_pos]);
232 232
 				if ($group_pos == 4) {
233 233
 					$decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8).chr($tuple);
234 234
 					$tuple = 0;
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 		// data length
375 375
 		$data_length = strlen($data);
376 376
 		$i = 0;
377
-		while($i < $data_length) {
377
+		while ($i < $data_length) {
378 378
 			// get current byte value
379 379
 			$byte = ord($data{$i});
380 380
 			if ($byte == 128) {
Please login to merge, or discard this patch.
phpmyfaq/inc/libs/tcpdf/tcpdf_parser.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -487,7 +487,7 @@
 block discarded – undo
487 487
 
488 488
 	/**
489 489
 	 * This method is automatically called in case of fatal error; it simply outputs the message and halts the execution.
490
-	 * @param $msg (string) The error message
490
+	 * @param string $msg (string) The error message
491 491
 	 * @public
492 492
 	 * @since 1.0.000 (2011-05-23)
493 493
 	 */
Please login to merge, or discard this patch.
Indentation   +427 added lines, -427 removed lines patch added patch discarded remove patch
@@ -55,446 +55,446 @@
 block discarded – undo
55 55
  */
56 56
 class TCPDF_PARSER {
57 57
 
58
-	/**
59
-	 * Raw content of the PDF document.
60
-	 * @private
61
-	 */
62
-	private $pdfdata = '';
58
+    /**
59
+     * Raw content of the PDF document.
60
+     * @private
61
+     */
62
+    private $pdfdata = '';
63 63
 
64
-	/**
65
-	 * XREF data.
66
-	 * @protected
67
-	 */
68
-	protected $xref = array();
64
+    /**
65
+     * XREF data.
66
+     * @protected
67
+     */
68
+    protected $xref = array();
69 69
 
70
-	/**
71
-	 * Array of PDF objects.
72
-	 * @protected
73
-	 */
74
-	protected $objects = array();
70
+    /**
71
+     * Array of PDF objects.
72
+     * @protected
73
+     */
74
+    protected $objects = array();
75 75
 
76
-	/**
77
-	 * Class object for decoding filters.
78
-	 * @private
79
-	 */
80
-	private $FilterDecoders;
76
+    /**
77
+     * Class object for decoding filters.
78
+     * @private
79
+     */
80
+    private $FilterDecoders;
81 81
 
82 82
 // -----------------------------------------------------------------------------
83 83
 
84
-	/**
85
-	 * Parse a PDF document an return an array of objects.
86
-	 * @param $data (string) PDF data to parse.
87
-	 * @public
88
-	 * @since 1.0.000 (2011-05-24)
89
-	 */
90
-	public function __construct($data) {
91
-		if (empty($data)) {
92
-			$this->Error('Empty PDF data.');
93
-		}
94
-		$this->pdfdata = $data;
95
-		// get length
96
-		$pdflen = strlen($this->pdfdata);
97
-		// initialize class for decoding filters
98
-		$this->FilterDecoders = new TCPDF_FILTERS();
99
-		// get xref and trailer data
100
-		$this->xref = $this->getXrefData();
101
-		// parse all document objects
102
-		$this->objects = array();
103
-		foreach ($this->xref['xref'] as $obj => $offset) {
104
-			if (!isset($this->objects[$obj])) {
105
-				$this->objects[$obj] = $this->getIndirectObject($obj, $offset, true);
106
-			}
107
-		}
108
-		// release some memory
109
-		unset($this->pdfdata);
110
-		$this->pdfdata = '';
111
-	}
84
+    /**
85
+     * Parse a PDF document an return an array of objects.
86
+     * @param $data (string) PDF data to parse.
87
+     * @public
88
+     * @since 1.0.000 (2011-05-24)
89
+     */
90
+    public function __construct($data) {
91
+        if (empty($data)) {
92
+            $this->Error('Empty PDF data.');
93
+        }
94
+        $this->pdfdata = $data;
95
+        // get length
96
+        $pdflen = strlen($this->pdfdata);
97
+        // initialize class for decoding filters
98
+        $this->FilterDecoders = new TCPDF_FILTERS();
99
+        // get xref and trailer data
100
+        $this->xref = $this->getXrefData();
101
+        // parse all document objects
102
+        $this->objects = array();
103
+        foreach ($this->xref['xref'] as $obj => $offset) {
104
+            if (!isset($this->objects[$obj])) {
105
+                $this->objects[$obj] = $this->getIndirectObject($obj, $offset, true);
106
+            }
107
+        }
108
+        // release some memory
109
+        unset($this->pdfdata);
110
+        $this->pdfdata = '';
111
+    }
112 112
 
113
-	/**
114
-	 * Return an array of parsed PDF document objects.
115
-	 * @return (array) Array of parsed PDF document objects.
116
-	 * @public
117
-	 * @since 1.0.000 (2011-06-26)
118
-	 */
119
-	public function getParsedData() {
120
-		return array($this->xref, $this->objects);
121
-	}
113
+    /**
114
+     * Return an array of parsed PDF document objects.
115
+     * @return (array) Array of parsed PDF document objects.
116
+     * @public
117
+     * @since 1.0.000 (2011-06-26)
118
+     */
119
+    public function getParsedData() {
120
+        return array($this->xref, $this->objects);
121
+    }
122 122
 
123
-	/**
124
-	 * Get xref (cross-reference table) and trailer data from PDF document data.
125
-	 * @param $offset (int) xref offset (if know).
126
-	 * @param $xref (array) previous xref array (if any).
127
-	 * @return Array containing xref and trailer data.
128
-	 * @protected
129
-	 * @since 1.0.000 (2011-05-24)
130
-	 */
131
-	protected function getXrefData($offset=0, $xref=array()) {
132
-		// find last startxref
133
-		if (preg_match_all('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_SET_ORDER, $offset) == 0) {
134
-			$this->Error('Unable to find startxref');
135
-		}
136
-		$matches = array_pop($matches);
137
-		$startxref = $matches[1];
138
-		// check xref position
139
-		if (strpos($this->pdfdata, 'xref', $startxref) != $startxref) {
140
-			$this->Error('Unable to find xref');
141
-		}
142
-		// extract xref data (object indexes and offsets)
143
-		$offset = $startxref + 5;
144
-		// initialize object number
145
-		$obj_num = 0;
146
-		while (preg_match('/^([0-9]+)[\s]([0-9]+)[\s]?([nf]?)/im', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
147
-			$offset = (strlen($matches[0][0]) + $matches[0][1]);
148
-			if ($matches[3][0] == 'n') {
149
-				// create unique object index: [object number]_[generation number]
150
-				$index = $obj_num.'_'.intval($matches[2][0]);
151
-				// check if object already exist
152
-				if (!isset($xref['xref'][$index])) {
153
-					// store object offset position
154
-					$xref['xref'][$index] = intval($matches[1][0]);
155
-				}
156
-				++$obj_num;
157
-				$offset += 2;
158
-			} elseif ($matches[3][0] == 'f') {
159
-				++$obj_num;
160
-				$offset += 2;
161
-			} else {
162
-				// object number (index)
163
-				$obj_num = intval($matches[1][0]);
164
-			}
165
-		}
166
-		// get trailer data
167
-		if (preg_match('/trailer[\s]*<<(.*)>>[\s]*[\r\n]+startxref[\s]*[\r\n]+/isU', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
168
-			$trailer_data = $matches[1][0];
169
-			if (!isset($xref['trailer'])) {
170
-				// get only the last updated version
171
-				$xref['trailer'] = array();
172
-				// parse trailer_data
173
-				if (preg_match('/Size[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) {
174
-					$xref['trailer']['size'] = intval($matches[1]);
175
-				}
176
-				if (preg_match('/Root[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
177
-					$xref['trailer']['root'] = intval($matches[1]).'_'.intval($matches[2]);
178
-				}
179
-				if (preg_match('/Encrypt[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
180
-					$xref['trailer']['encrypt'] = intval($matches[1]).'_'.intval($matches[2]);
181
-				}
182
-				if (preg_match('/Info[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
183
-					$xref['trailer']['info'] = intval($matches[1]).'_'.intval($matches[2]);
184
-				}
185
-				if (preg_match('/ID[\s]*[\[][\s]*[<]([^>]*)[>][\s]*[<]([^>]*)[>]/i', $trailer_data, $matches) > 0) {
186
-					$xref['trailer']['id'] = array();
187
-					$xref['trailer']['id'][0] = $matches[1];
188
-					$xref['trailer']['id'][1] = $matches[2];
189
-				}
190
-			}
191
-			if (preg_match('/Prev[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) {
192
-				// get previous xref
193
-				$xref = getXrefData(substr($this->pdfdata, 0, $startxref), intval($matches[1]), $xref);
194
-			}
195
-		} else {
196
-			$this->Error('Unable to find trailer');
197
-		}
198
-		return $xref;
199
-	}
123
+    /**
124
+     * Get xref (cross-reference table) and trailer data from PDF document data.
125
+     * @param $offset (int) xref offset (if know).
126
+     * @param $xref (array) previous xref array (if any).
127
+     * @return Array containing xref and trailer data.
128
+     * @protected
129
+     * @since 1.0.000 (2011-05-24)
130
+     */
131
+    protected function getXrefData($offset=0, $xref=array()) {
132
+        // find last startxref
133
+        if (preg_match_all('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_SET_ORDER, $offset) == 0) {
134
+            $this->Error('Unable to find startxref');
135
+        }
136
+        $matches = array_pop($matches);
137
+        $startxref = $matches[1];
138
+        // check xref position
139
+        if (strpos($this->pdfdata, 'xref', $startxref) != $startxref) {
140
+            $this->Error('Unable to find xref');
141
+        }
142
+        // extract xref data (object indexes and offsets)
143
+        $offset = $startxref + 5;
144
+        // initialize object number
145
+        $obj_num = 0;
146
+        while (preg_match('/^([0-9]+)[\s]([0-9]+)[\s]?([nf]?)/im', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
147
+            $offset = (strlen($matches[0][0]) + $matches[0][1]);
148
+            if ($matches[3][0] == 'n') {
149
+                // create unique object index: [object number]_[generation number]
150
+                $index = $obj_num.'_'.intval($matches[2][0]);
151
+                // check if object already exist
152
+                if (!isset($xref['xref'][$index])) {
153
+                    // store object offset position
154
+                    $xref['xref'][$index] = intval($matches[1][0]);
155
+                }
156
+                ++$obj_num;
157
+                $offset += 2;
158
+            } elseif ($matches[3][0] == 'f') {
159
+                ++$obj_num;
160
+                $offset += 2;
161
+            } else {
162
+                // object number (index)
163
+                $obj_num = intval($matches[1][0]);
164
+            }
165
+        }
166
+        // get trailer data
167
+        if (preg_match('/trailer[\s]*<<(.*)>>[\s]*[\r\n]+startxref[\s]*[\r\n]+/isU', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
168
+            $trailer_data = $matches[1][0];
169
+            if (!isset($xref['trailer'])) {
170
+                // get only the last updated version
171
+                $xref['trailer'] = array();
172
+                // parse trailer_data
173
+                if (preg_match('/Size[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) {
174
+                    $xref['trailer']['size'] = intval($matches[1]);
175
+                }
176
+                if (preg_match('/Root[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
177
+                    $xref['trailer']['root'] = intval($matches[1]).'_'.intval($matches[2]);
178
+                }
179
+                if (preg_match('/Encrypt[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
180
+                    $xref['trailer']['encrypt'] = intval($matches[1]).'_'.intval($matches[2]);
181
+                }
182
+                if (preg_match('/Info[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
183
+                    $xref['trailer']['info'] = intval($matches[1]).'_'.intval($matches[2]);
184
+                }
185
+                if (preg_match('/ID[\s]*[\[][\s]*[<]([^>]*)[>][\s]*[<]([^>]*)[>]/i', $trailer_data, $matches) > 0) {
186
+                    $xref['trailer']['id'] = array();
187
+                    $xref['trailer']['id'][0] = $matches[1];
188
+                    $xref['trailer']['id'][1] = $matches[2];
189
+                }
190
+            }
191
+            if (preg_match('/Prev[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) {
192
+                // get previous xref
193
+                $xref = getXrefData(substr($this->pdfdata, 0, $startxref), intval($matches[1]), $xref);
194
+            }
195
+        } else {
196
+            $this->Error('Unable to find trailer');
197
+        }
198
+        return $xref;
199
+    }
200 200
 
201
-	/**
202
-	 * Get object type, raw value and offset to next object
203
-	 * @param $offset (int) Object offset.
204
-	 * @return array containing object type, raw value and offset to next object
205
-	 * @protected
206
-	 * @since 1.0.000 (2011-06-20)
207
-	 */
208
-	protected function getRawObject($offset=0) {
209
-		$objtype = ''; // object type to be returned
210
-		$objval = ''; // object value to be returned
211
-		// skip initial white space chars: \x00 null (NUL), \x09 horizontal tab (HT), \x0A line feed (LF), \x0C form feed (FF), \x0D carriage return (CR), \x20 space (SP)
212
-		$offset += strspn($this->pdfdata, "\x00\x09\x0a\x0c\x0d\x20", $offset);
213
-		// get first char
214
-		$char = $this->pdfdata{$offset};
215
-		// get object type
216
-		switch ($char) {
217
-			case '%': { // \x25 PERCENT SIGN
218
-				// skip comment and search for next token
219
-				$next = strcspn($this->pdfdata, "\r\n", $offset);
220
-				if ($next > 0) {
221
-					$offset += $next;
222
-					return $this->getRawObject($this->pdfdata, $offset);
223
-				}
224
-				break;
225
-			}
226
-			case '/': { // \x2F SOLIDUS
227
-				// name object
228
-				$objtype = $char;
229
-				++$offset;
230
-				if (preg_match('/^([^\x00\x09\x0a\x0c\x0d\x20\s\x28\x29\x3c\x3e\x5b\x5d\x7b\x7d\x2f\x25]+)/', substr($this->pdfdata, $offset, 256), $matches) == 1) {
231
-					$objval = $matches[1]; // unescaped value
232
-					$offset += strlen($objval);
233
-				}
234
-				break;
235
-			}
236
-			case '(':   // \x28 LEFT PARENTHESIS
237
-			case ')': { // \x29 RIGHT PARENTHESIS
238
-				// literal string object
239
-				$objtype = $char;
240
-				++$offset;
241
-				$strpos = $offset;
242
-				if ($char == '(') {
243
-					$open_bracket = 1;
244
-					while ($open_bracket > 0) {
245
-						if (!isset($this->pdfdata{$strpos})) {
246
-							break;
247
-						}
248
-						$ch = $this->pdfdata{$strpos};
249
-						switch ($ch) {
250
-							case '\\': { // REVERSE SOLIDUS (5Ch) (Backslash)
251
-								// skip next character
252
-								++$strpos;
253
-								break;
254
-							}
255
-							case '(': { // LEFT PARENHESIS (28h)
256
-								++$open_bracket;
257
-								break;
258
-							}
259
-							case ')': { // RIGHT PARENTHESIS (29h)
260
-								--$open_bracket;
261
-								break;
262
-							}
263
-						}
264
-						++$strpos;
265
-					}
266
-					$objval = substr($this->pdfdata, $offset, ($strpos - $offset - 1));
267
-					$offset = $strpos;
268
-				}
269
-				break;
270
-			}
271
-			case '[':   // \x5B LEFT SQUARE BRACKET
272
-			case ']': { // \x5D RIGHT SQUARE BRACKET
273
-				// array object
274
-				$objtype = $char;
275
-				++$offset;
276
-				if ($char == '[') {
277
-					// get array content
278
-					$objval = array();
279
-					do {
280
-						// get element
281
-						$element = $this->getRawObject($offset);
282
-						$offset = $element[2];
283
-						$objval[] = $element;
284
-					} while ($element[0] != ']');
285
-					// remove closing delimiter
286
-					array_pop($objval);
287
-				}
288
-				break;
289
-			}
290
-			case '<':   // \x3C LESS-THAN SIGN
291
-			case '>': { // \x3E GREATER-THAN SIGN
292
-				if (isset($this->pdfdata{($offset + 1)}) AND ($this->pdfdata{($offset + 1)} == $char)) {
293
-					// dictionary object
294
-					$objtype = $char.$char;
295
-					$offset += 2;
296
-					if ($char == '<') {
297
-						// get array content
298
-						$objval = array();
299
-						do {
300
-							// get element
301
-							$element = $this->getRawObject($offset);
302
-							$offset = $element[2];
303
-							$objval[] = $element;
304
-						} while ($element[0] != '>>');
305
-						// remove closing delimiter
306
-						array_pop($objval);
307
-					}
308
-				} else {
309
-					// hexadecimal string object
310
-					$objtype = $char;
311
-					++$offset;
312
-					if (($char == '<') AND (preg_match('/^([0-9A-Fa-f]+)[>]/iU', substr($this->pdfdata, $offset), $matches) == 1)) {
313
-						$objval = $matches[1];
314
-						$offset += strlen($matches[0]);
315
-					}
316
-				}
317
-				break;
318
-			}
319
-			default: {
320
-				if (substr($this->pdfdata, $offset, 6) == 'endobj') {
321
-					// indirect object
322
-					$objtype = 'endobj';
323
-					$offset += 6;
324
-				} elseif (substr($this->pdfdata, $offset, 4) == 'null') {
325
-					// null object
326
-					$objtype = 'null';
327
-					$offset += 4;
328
-					$objval = 'null';
329
-				} elseif (substr($this->pdfdata, $offset, 4) == 'true') {
330
-					// boolean true object
331
-					$objtype = 'boolean';
332
-					$offset += 4;
333
-					$objval = 'true';
334
-				} elseif (substr($this->pdfdata, $offset, 5) == 'false') {
335
-					// boolean false object
336
-					$objtype = 'boolean';
337
-					$offset += 5;
338
-					$objval = 'false';
339
-				} elseif (substr($this->pdfdata, $offset, 6) == 'stream') {
340
-					// start stream object
341
-					$objtype = 'stream';
342
-					$offset += 6;
343
-					if (preg_match('/^[\r\n]+(.*)[\r\n]*endstream/isU', substr($this->pdfdata, $offset), $matches) == 1) {
344
-						$objval = $matches[1];
345
-						$offset += strlen($matches[0]);
346
-					}
347
-				} elseif (substr($this->pdfdata, $offset, 9) == 'endstream') {
348
-					// end stream object
349
-					$objtype = 'endstream';
350
-					$offset += 9;
351
-				} elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+R/iU', substr($this->pdfdata, $offset, 33), $matches) == 1) {
352
-					// indirect object reference
353
-					$objtype = 'ojbref';
354
-					$offset += strlen($matches[0]);
355
-					$objval = intval($matches[1]).'_'.intval($matches[2]);
356
-				} elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+obj/iU', substr($this->pdfdata, $offset, 33), $matches) == 1) {
357
-					// object start
358
-					$objtype = 'ojb';
359
-					$objval = intval($matches[1]).'_'.intval($matches[2]);
360
-					$offset += strlen ($matches[0]);
361
-				} elseif (($numlen = strspn($this->pdfdata, '+-.0123456789', $offset)) > 0) {
362
-					// numeric object
363
-					$objtype = 'numeric';
364
-					$objval = substr($this->pdfdata, $offset, $numlen);
365
-					$offset += $numlen;
366
-				}
367
-				break;
368
-			}
369
-		}
370
-		return array($objtype, $objval, $offset);
371
-	}
201
+    /**
202
+     * Get object type, raw value and offset to next object
203
+     * @param $offset (int) Object offset.
204
+     * @return array containing object type, raw value and offset to next object
205
+     * @protected
206
+     * @since 1.0.000 (2011-06-20)
207
+     */
208
+    protected function getRawObject($offset=0) {
209
+        $objtype = ''; // object type to be returned
210
+        $objval = ''; // object value to be returned
211
+        // skip initial white space chars: \x00 null (NUL), \x09 horizontal tab (HT), \x0A line feed (LF), \x0C form feed (FF), \x0D carriage return (CR), \x20 space (SP)
212
+        $offset += strspn($this->pdfdata, "\x00\x09\x0a\x0c\x0d\x20", $offset);
213
+        // get first char
214
+        $char = $this->pdfdata{$offset};
215
+        // get object type
216
+        switch ($char) {
217
+            case '%': { // \x25 PERCENT SIGN
218
+                // skip comment and search for next token
219
+                $next = strcspn($this->pdfdata, "\r\n", $offset);
220
+                if ($next > 0) {
221
+                    $offset += $next;
222
+                    return $this->getRawObject($this->pdfdata, $offset);
223
+                }
224
+                break;
225
+            }
226
+            case '/': { // \x2F SOLIDUS
227
+                // name object
228
+                $objtype = $char;
229
+                ++$offset;
230
+                if (preg_match('/^([^\x00\x09\x0a\x0c\x0d\x20\s\x28\x29\x3c\x3e\x5b\x5d\x7b\x7d\x2f\x25]+)/', substr($this->pdfdata, $offset, 256), $matches) == 1) {
231
+                    $objval = $matches[1]; // unescaped value
232
+                    $offset += strlen($objval);
233
+                }
234
+                break;
235
+            }
236
+            case '(':   // \x28 LEFT PARENTHESIS
237
+            case ')': { // \x29 RIGHT PARENTHESIS
238
+                // literal string object
239
+                $objtype = $char;
240
+                ++$offset;
241
+                $strpos = $offset;
242
+                if ($char == '(') {
243
+                    $open_bracket = 1;
244
+                    while ($open_bracket > 0) {
245
+                        if (!isset($this->pdfdata{$strpos})) {
246
+                            break;
247
+                        }
248
+                        $ch = $this->pdfdata{$strpos};
249
+                        switch ($ch) {
250
+                            case '\\': { // REVERSE SOLIDUS (5Ch) (Backslash)
251
+                                // skip next character
252
+                                ++$strpos;
253
+                                break;
254
+                            }
255
+                            case '(': { // LEFT PARENHESIS (28h)
256
+                                ++$open_bracket;
257
+                                break;
258
+                            }
259
+                            case ')': { // RIGHT PARENTHESIS (29h)
260
+                                --$open_bracket;
261
+                                break;
262
+                            }
263
+                        }
264
+                        ++$strpos;
265
+                    }
266
+                    $objval = substr($this->pdfdata, $offset, ($strpos - $offset - 1));
267
+                    $offset = $strpos;
268
+                }
269
+                break;
270
+            }
271
+            case '[':   // \x5B LEFT SQUARE BRACKET
272
+            case ']': { // \x5D RIGHT SQUARE BRACKET
273
+                // array object
274
+                $objtype = $char;
275
+                ++$offset;
276
+                if ($char == '[') {
277
+                    // get array content
278
+                    $objval = array();
279
+                    do {
280
+                        // get element
281
+                        $element = $this->getRawObject($offset);
282
+                        $offset = $element[2];
283
+                        $objval[] = $element;
284
+                    } while ($element[0] != ']');
285
+                    // remove closing delimiter
286
+                    array_pop($objval);
287
+                }
288
+                break;
289
+            }
290
+            case '<':   // \x3C LESS-THAN SIGN
291
+            case '>': { // \x3E GREATER-THAN SIGN
292
+                if (isset($this->pdfdata{($offset + 1)}) AND ($this->pdfdata{($offset + 1)} == $char)) {
293
+                    // dictionary object
294
+                    $objtype = $char.$char;
295
+                    $offset += 2;
296
+                    if ($char == '<') {
297
+                        // get array content
298
+                        $objval = array();
299
+                        do {
300
+                            // get element
301
+                            $element = $this->getRawObject($offset);
302
+                            $offset = $element[2];
303
+                            $objval[] = $element;
304
+                        } while ($element[0] != '>>');
305
+                        // remove closing delimiter
306
+                        array_pop($objval);
307
+                    }
308
+                } else {
309
+                    // hexadecimal string object
310
+                    $objtype = $char;
311
+                    ++$offset;
312
+                    if (($char == '<') AND (preg_match('/^([0-9A-Fa-f]+)[>]/iU', substr($this->pdfdata, $offset), $matches) == 1)) {
313
+                        $objval = $matches[1];
314
+                        $offset += strlen($matches[0]);
315
+                    }
316
+                }
317
+                break;
318
+            }
319
+            default: {
320
+                if (substr($this->pdfdata, $offset, 6) == 'endobj') {
321
+                    // indirect object
322
+                    $objtype = 'endobj';
323
+                    $offset += 6;
324
+                } elseif (substr($this->pdfdata, $offset, 4) == 'null') {
325
+                    // null object
326
+                    $objtype = 'null';
327
+                    $offset += 4;
328
+                    $objval = 'null';
329
+                } elseif (substr($this->pdfdata, $offset, 4) == 'true') {
330
+                    // boolean true object
331
+                    $objtype = 'boolean';
332
+                    $offset += 4;
333
+                    $objval = 'true';
334
+                } elseif (substr($this->pdfdata, $offset, 5) == 'false') {
335
+                    // boolean false object
336
+                    $objtype = 'boolean';
337
+                    $offset += 5;
338
+                    $objval = 'false';
339
+                } elseif (substr($this->pdfdata, $offset, 6) == 'stream') {
340
+                    // start stream object
341
+                    $objtype = 'stream';
342
+                    $offset += 6;
343
+                    if (preg_match('/^[\r\n]+(.*)[\r\n]*endstream/isU', substr($this->pdfdata, $offset), $matches) == 1) {
344
+                        $objval = $matches[1];
345
+                        $offset += strlen($matches[0]);
346
+                    }
347
+                } elseif (substr($this->pdfdata, $offset, 9) == 'endstream') {
348
+                    // end stream object
349
+                    $objtype = 'endstream';
350
+                    $offset += 9;
351
+                } elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+R/iU', substr($this->pdfdata, $offset, 33), $matches) == 1) {
352
+                    // indirect object reference
353
+                    $objtype = 'ojbref';
354
+                    $offset += strlen($matches[0]);
355
+                    $objval = intval($matches[1]).'_'.intval($matches[2]);
356
+                } elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+obj/iU', substr($this->pdfdata, $offset, 33), $matches) == 1) {
357
+                    // object start
358
+                    $objtype = 'ojb';
359
+                    $objval = intval($matches[1]).'_'.intval($matches[2]);
360
+                    $offset += strlen ($matches[0]);
361
+                } elseif (($numlen = strspn($this->pdfdata, '+-.0123456789', $offset)) > 0) {
362
+                    // numeric object
363
+                    $objtype = 'numeric';
364
+                    $objval = substr($this->pdfdata, $offset, $numlen);
365
+                    $offset += $numlen;
366
+                }
367
+                break;
368
+            }
369
+        }
370
+        return array($objtype, $objval, $offset);
371
+    }
372 372
 
373
-	/**
374
-	 * Get content of indirect object.
375
-	 * @param $obj_ref (string) Object number and generation number separated by underscore character.
376
-	 * @param $offset (int) Object offset.
377
-	 * @param $decoding (boolean) If true decode streams.
378
-	 * @return array containing object data.
379
-	 * @protected
380
-	 * @since 1.0.000 (2011-05-24)
381
-	 */
382
-	protected function getIndirectObject($obj_ref, $offset=0, $decoding=true) {
383
-		$obj = explode('_', $obj_ref);
384
-		if (($obj === false) OR (count($obj) != 2)) {
385
-			$this->Error('Invalid object reference: '.$obj);
386
-			return;
387
-		}
388
-		$objref = $obj[0].' '.$obj[1].' obj';
389
-		if (strpos($this->pdfdata, $objref, $offset) != $offset) {
390
-			// an indirect reference to an undefined object shall be considered a reference to the null object
391
-			return array('null', 'null', $offset);
392
-		}
393
-		// starting position of object content
394
-		$offset += strlen($objref);
395
-		// get array of object content
396
-		$objdata = array();
397
-		$i = 0; // object main index
398
-		do {
399
-			// get element
400
-			$element = $this->getRawObject($offset);
401
-			$offset = $element[2];
402
-			// decode stream using stream's dictionary information
403
-			if ($decoding AND ($element[0] == 'stream') AND (isset($objdata[($i - 1)][0])) AND ($objdata[($i - 1)][0] == '<<')) {
404
-				$element[3] = $this->decodeStream($objdata[($i - 1)][1], $element[1]);
405
-			}
406
-			$objdata[$i] = $element;
407
-			++$i;
408
-		} while ($element[0] != 'endobj');
409
-		// remove closing delimiter
410
-		array_pop($objdata);
411
-		// return raw object content
412
-		return $objdata;
413
-	}
373
+    /**
374
+     * Get content of indirect object.
375
+     * @param $obj_ref (string) Object number and generation number separated by underscore character.
376
+     * @param $offset (int) Object offset.
377
+     * @param $decoding (boolean) If true decode streams.
378
+     * @return array containing object data.
379
+     * @protected
380
+     * @since 1.0.000 (2011-05-24)
381
+     */
382
+    protected function getIndirectObject($obj_ref, $offset=0, $decoding=true) {
383
+        $obj = explode('_', $obj_ref);
384
+        if (($obj === false) OR (count($obj) != 2)) {
385
+            $this->Error('Invalid object reference: '.$obj);
386
+            return;
387
+        }
388
+        $objref = $obj[0].' '.$obj[1].' obj';
389
+        if (strpos($this->pdfdata, $objref, $offset) != $offset) {
390
+            // an indirect reference to an undefined object shall be considered a reference to the null object
391
+            return array('null', 'null', $offset);
392
+        }
393
+        // starting position of object content
394
+        $offset += strlen($objref);
395
+        // get array of object content
396
+        $objdata = array();
397
+        $i = 0; // object main index
398
+        do {
399
+            // get element
400
+            $element = $this->getRawObject($offset);
401
+            $offset = $element[2];
402
+            // decode stream using stream's dictionary information
403
+            if ($decoding AND ($element[0] == 'stream') AND (isset($objdata[($i - 1)][0])) AND ($objdata[($i - 1)][0] == '<<')) {
404
+                $element[3] = $this->decodeStream($objdata[($i - 1)][1], $element[1]);
405
+            }
406
+            $objdata[$i] = $element;
407
+            ++$i;
408
+        } while ($element[0] != 'endobj');
409
+        // remove closing delimiter
410
+        array_pop($objdata);
411
+        // return raw object content
412
+        return $objdata;
413
+    }
414 414
 
415
-	/**
416
-	 * Get the content of object, resolving indect object reference if necessary.
417
-	 * @param $obj (string) Object value.
418
-	 * @return array containing object data.
419
-	 * @protected
420
-	 * @since 1.0.000 (2011-06-26)
421
-	 */
422
-	protected function getObjectVal($obj) {
423
-		if ($obj[0] == 'objref') {
424
-			// reference to indirect object
425
-			if (isset($this->objects[$obj[1]])) {
426
-				// this object has been already parsed
427
-				return $this->objects[$obj[1]];
428
-			} elseif (isset($this->xref[$obj[1]])) {
429
-				// parse new object
430
-				$this->objects[$obj[1]] = $this->getIndirectObject($obj[1], $this->xref[$obj[1]], false);
431
-				return $this->objects[$obj[1]];
432
-			}
433
-		}
434
-		return $obj;
435
-	}
415
+    /**
416
+     * Get the content of object, resolving indect object reference if necessary.
417
+     * @param $obj (string) Object value.
418
+     * @return array containing object data.
419
+     * @protected
420
+     * @since 1.0.000 (2011-06-26)
421
+     */
422
+    protected function getObjectVal($obj) {
423
+        if ($obj[0] == 'objref') {
424
+            // reference to indirect object
425
+            if (isset($this->objects[$obj[1]])) {
426
+                // this object has been already parsed
427
+                return $this->objects[$obj[1]];
428
+            } elseif (isset($this->xref[$obj[1]])) {
429
+                // parse new object
430
+                $this->objects[$obj[1]] = $this->getIndirectObject($obj[1], $this->xref[$obj[1]], false);
431
+                return $this->objects[$obj[1]];
432
+            }
433
+        }
434
+        return $obj;
435
+    }
436 436
 
437
-	/**
438
-	 * Decode the specified stream.
439
-	 * @param $sdic (array) Stream's dictionary array.
440
-	 * @param $stream (string) Stream to decode.
441
-	 * @return array containing decoded stream data and remaining filters.
442
-	 * @protected
443
-	 * @since 1.0.000 (2011-06-22)
444
-	 */
445
-	protected function decodeStream($sdic, $stream) {
446
-		// get stream lenght and filters
447
-		$slength = strlen($stream);
448
-		$filters = array();
449
-		foreach ($sdic as $k => $v) {
450
-			if ($v[0] == '/') {
451
-				if (($v[1] == 'Length') AND (isset($sdic[($k + 1)])) AND ($sdic[($k + 1)][0] == 'numeric')) {
452
-					// get declared stream lenght
453
-					$declength = intval($sdic[($k + 1)][1]);
454
-					if ($declength < $slength) {
455
-						$stream = substr($stream, 0, $declength);
456
-						$slength = $declength;
457
-					}
458
-				} elseif (($v[1] == 'Filter') AND (isset($sdic[($k + 1)]))) {
459
-					// resolve indirect object
460
-					$objval = $this->getObjectVal($sdic[($k + 1)]);
461
-					if ($objval[0] == '/') {
462
-						// single filter
463
-						$filters[] = $objval[1];
464
-					} elseif ($objval[0] == '[') {
465
-						// array of filters
466
-						foreach ($objval[1] as $flt) {
467
-							if ($flt[0] == '/') {
468
-								$filters[] = $flt[1];
469
-							}
470
-						}
471
-					}
472
-				}
473
-			}
474
-		}
475
-		// decode the stream
476
-		$remaining_filters = array();
477
-		foreach ($filters as $filter) {
478
-			if (in_array($filter, $this->FilterDecoders->getAvailableFilters())) {
479
-				$stream = $this->FilterDecoders->decodeFilter($filter, $stream);
480
-			} else {
481
-				// add missing filter to array
482
-				$remaining_filters[] = $filter;
483
-			}
484
-		}
485
-		return array($stream, $remaining_filters);
486
-	}
437
+    /**
438
+     * Decode the specified stream.
439
+     * @param $sdic (array) Stream's dictionary array.
440
+     * @param $stream (string) Stream to decode.
441
+     * @return array containing decoded stream data and remaining filters.
442
+     * @protected
443
+     * @since 1.0.000 (2011-06-22)
444
+     */
445
+    protected function decodeStream($sdic, $stream) {
446
+        // get stream lenght and filters
447
+        $slength = strlen($stream);
448
+        $filters = array();
449
+        foreach ($sdic as $k => $v) {
450
+            if ($v[0] == '/') {
451
+                if (($v[1] == 'Length') AND (isset($sdic[($k + 1)])) AND ($sdic[($k + 1)][0] == 'numeric')) {
452
+                    // get declared stream lenght
453
+                    $declength = intval($sdic[($k + 1)][1]);
454
+                    if ($declength < $slength) {
455
+                        $stream = substr($stream, 0, $declength);
456
+                        $slength = $declength;
457
+                    }
458
+                } elseif (($v[1] == 'Filter') AND (isset($sdic[($k + 1)]))) {
459
+                    // resolve indirect object
460
+                    $objval = $this->getObjectVal($sdic[($k + 1)]);
461
+                    if ($objval[0] == '/') {
462
+                        // single filter
463
+                        $filters[] = $objval[1];
464
+                    } elseif ($objval[0] == '[') {
465
+                        // array of filters
466
+                        foreach ($objval[1] as $flt) {
467
+                            if ($flt[0] == '/') {
468
+                                $filters[] = $flt[1];
469
+                            }
470
+                        }
471
+                    }
472
+                }
473
+            }
474
+        }
475
+        // decode the stream
476
+        $remaining_filters = array();
477
+        foreach ($filters as $filter) {
478
+            if (in_array($filter, $this->FilterDecoders->getAvailableFilters())) {
479
+                $stream = $this->FilterDecoders->decodeFilter($filter, $stream);
480
+            } else {
481
+                // add missing filter to array
482
+                $remaining_filters[] = $filter;
483
+            }
484
+        }
485
+        return array($stream, $remaining_filters);
486
+    }
487 487
 
488
-	/**
489
-	 * This method is automatically called in case of fatal error; it simply outputs the message and halts the execution.
490
-	 * @param $msg (string) The error message
491
-	 * @public
492
-	 * @since 1.0.000 (2011-05-23)
493
-	 */
494
-	public function Error($msg) {
495
-		// exit program and print error
496
-		die('<strong>TCPDF_PARSER ERROR: </strong>'.$msg);
497
-	}
488
+    /**
489
+     * This method is automatically called in case of fatal error; it simply outputs the message and halts the execution.
490
+     * @param $msg (string) The error message
491
+     * @public
492
+     * @since 1.0.000 (2011-05-23)
493
+     */
494
+    public function Error($msg) {
495
+        // exit program and print error
496
+        die('<strong>TCPDF_PARSER ERROR: </strong>'.$msg);
497
+    }
498 498
 
499 499
 } // END OF TCPDF_PARSER CLASS
500 500
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @protected
129 129
 	 * @since 1.0.000 (2011-05-24)
130 130
 	 */
131
-	protected function getXrefData($offset=0, $xref=array()) {
131
+	protected function getXrefData($offset = 0, $xref = array()) {
132 132
 		// find last startxref
133 133
 		if (preg_match_all('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_SET_ORDER, $offset) == 0) {
134 134
 			$this->Error('Unable to find startxref');
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * @protected
206 206
 	 * @since 1.0.000 (2011-06-20)
207 207
 	 */
208
-	protected function getRawObject($offset=0) {
208
+	protected function getRawObject($offset = 0) {
209 209
 		$objtype = ''; // object type to be returned
210 210
 		$objval = ''; // object value to be returned
211 211
 		// skip initial white space chars: \x00 null (NUL), \x09 horizontal tab (HT), \x0A line feed (LF), \x0C form feed (FF), \x0D carriage return (CR), \x20 space (SP)
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 					// object start
358 358
 					$objtype = 'ojb';
359 359
 					$objval = intval($matches[1]).'_'.intval($matches[2]);
360
-					$offset += strlen ($matches[0]);
360
+					$offset += strlen($matches[0]);
361 361
 				} elseif (($numlen = strspn($this->pdfdata, '+-.0123456789', $offset)) > 0) {
362 362
 					// numeric object
363 363
 					$objtype = 'numeric';
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	 * @protected
380 380
 	 * @since 1.0.000 (2011-05-24)
381 381
 	 */
382
-	protected function getIndirectObject($obj_ref, $offset=0, $decoding=true) {
382
+	protected function getIndirectObject($obj_ref, $offset = 0, $decoding = true) {
383 383
 		$obj = explode('_', $obj_ref);
384 384
 		if (($obj === false) OR (count($obj) != 2)) {
385 385
 			$this->Error('Invalid object reference: '.$obj);
Please login to merge, or discard this patch.
phpmyfaq/inc/PMF/Category.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
      * of associative arrays with the keys 'name', 'id', 'lang',
907 907
      * 'parent_id' and 'description'.
908 908
      *
909
-     * @param integer $article_id Record id
909
+     * @param integer $articleId Record id
910 910
      *
911 911
      * @return  array
912 912
      */
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
      *
1096 1096
      * @param  integer $category_id   Category id
1097 1097
      * @param  string  $category_lang Category language
1098
-     * @return boolean
1098
+     * @return integer
1099 1099
      */
1100 1100
     public function checkLanguage($category_id, $category_lang)
1101 1101
     {
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
 
228 228
         while ($row = $this->_config->getDb()->fetchArray($result)) {
229 229
             $this->categoryName[$row['id']] = $row;
230
-            $this->categories[] =& $this->categoryName[$row['id']];
231
-            $this->children[$row['parent_id']][$row['id']] =& $this->categoryName[$row['id']];
230
+            $this->categories[] = & $this->categoryName[$row['id']];
231
+            $this->children[$row['parent_id']][$row['id']] = & $this->categoryName[$row['id']];
232 232
         }
233 233
 
234 234
         return $this->categories;
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
             $symbol = 'minus';
395 395
         } else {
396 396
             $temp = isset($this->children[$thisParent_id]) ? array_keys($this->children[$thisParent_id]) : [];
397
-            if (isset($temp[count($temp)-1])) {
398
-                $symbol = ($id == $temp[count($temp)-1]) ? 'angle' : 'medium';
397
+            if (isset($temp[count($temp) - 1])) {
398
+                $symbol = ($id == $temp[count($temp) - 1]) ? 'angle' : 'medium';
399 399
             }
400 400
         }
401 401
 
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
         $childs = [];
469 469
 
470 470
         if (isset($this->children[$id])) {
471
-            foreach(array_keys($this->children[$id]) as $childId) {
471
+            foreach (array_keys($this->children[$id]) as $childId) {
472 472
                 $childs = array_merge($childs, array($childId));
473 473
                 $childs = array_merge($childs, $this->getChildNodes($childId));
474 474
             }
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
         $open   = 0;
626 626
         $this->expandAll();
627 627
 
628
-        for ($y = 0 ;$y < $this->height(); $y = $this->getNextLineTree($y)) {
628
+        for ($y = 0; $y < $this->height(); $y = $this->getNextLineTree($y)) {
629 629
 
630 630
             list($hasChild, $categoryName, $parent, $description) = $this->getLineDisplay($y);
631 631
             $level     = $this->treeTab[$y]['level'];
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
                 $numFaqs = '';
672 672
             } else {
673 673
                 $totFaqRecords += $number[$parent];
674
-                $numFaqs = '<span class="rssCategoryLink"> (' . $plr->GetMsg('plmsgEntries', $number[$parent]);
674
+                $numFaqs = '<span class="rssCategoryLink"> ('.$plr->GetMsg('plmsgEntries', $number[$parent]);
675 675
                 if ($this->_config->get('main.enableRssFeeds')) {
676 676
                     $numFaqs .= sprintf(
677 677
                         ' <a href="feed/category/rss.php?category_id=%d&category_lang=%s" target="_blank"><i class="fa fa-rss"></i></a>',
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
             $oLink->text      = $categoryName;
695 695
             $oLink->tooltip   = $description;
696 696
 
697
-            $output .= $oLink->toHtmlAnchor() . $numFaqs;
697
+            $output .= $oLink->toHtmlAnchor().$numFaqs;
698 698
             $open    = $level;
699 699
         }
700 700
 
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
             return $l + 1;
739 739
         } else {
740 740
             for ($i = $l + 1; $i < $this->height(); $i++) {
741
-                if ($this->treeTab[$i]["level"]<=$this->treeTab[$l]["level"]) {
741
+                if ($this->treeTab[$i]["level"] <= $this->treeTab[$l]["level"]) {
742 742
                     return $i;
743 743
                 }
744 744
             }
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
         );
779 779
 
780 780
         $oLink            = new PMF_Link($url, $this->_config);
781
-        $oLink->id        = 'category_' . $categoryId;
781
+        $oLink->id        = 'category_'.$categoryId;
782 782
         $oLink->itemTitle = $categoryName;
783 783
         $oLink->text      = $categoryName;
784 784
 
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
                 if ($lang == $selected_lang) {
1322 1322
                     $output .= " selected=\"selected\"";
1323 1323
                 }
1324
-                $output .=  ">".$langname."</option>\n";
1324
+                $output .= ">".$langname."</option>\n";
1325 1325
             }
1326 1326
         }
1327 1327
 
@@ -1348,10 +1348,10 @@  discard block
 block discarded – undo
1348 1348
         $query .= ' ORDER BY id';
1349 1349
         $result = $this->_config->getDb()->query($query);
1350 1350
         while ($row = $this->_config->getDb()->fetchArray($result)) {
1351
-            if (!array_key_exists($row['id'],$this->categoryName)) {
1351
+            if (!array_key_exists($row['id'], $this->categoryName)) {
1352 1352
                $this->categoryName[$row['id']] = $row;
1353
-               $this->categories[] =& $this->categoryName[$row['id']];
1354
-               $this->children[$row['parent_id']][$row['id']] =& $this->categoryName[$row['id']];
1353
+               $this->categories[] = & $this->categoryName[$row['id']];
1354
+               $this->children[$row['parent_id']][$row['id']] = & $this->categoryName[$row['id']];
1355 1355
             }
1356 1356
         }
1357 1357
     }
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -576,10 +576,10 @@  discard block
 block discarded – undo
576 576
     }
577 577
 
578 578
     /**
579
-    * print the static tree with the number of records
580
-    *
581
-    * @return string
582
-    */
579
+     * print the static tree with the number of records
580
+     *
581
+     * @return string
582
+     */
583 583
     public function viewTree()
584 584
     {
585 585
         global $sids, $plr;
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
             PMF_Db::getTablePrefix(),
1233 1233
             $category_id);
1234 1234
         if (!$delete_all) {
1235
-           $query .= " AND lang = '".$category_lang."'";
1235
+            $query .= " AND lang = '".$category_lang."'";
1236 1236
         }
1237 1237
         $this->_config->getDb()->query($query);
1238 1238
 
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
             PMF_Db::getTablePrefix(),
1257 1257
             $category_id);
1258 1258
         if (!$delete_all) {
1259
-           $query .= " AND category_lang = '".$category_lang."'";
1259
+            $query .= " AND category_lang = '".$category_lang."'";
1260 1260
         }
1261 1261
         $this->_config->getDb()->query($query);
1262 1262
 
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
         $translated   = [];
1281 1281
 
1282 1282
         foreach ($existcatlang as $language) {
1283
-           $query = sprintf("
1283
+            $query = sprintf("
1284 1284
                SELECT
1285 1285
                   name, description
1286 1286
                FROM
@@ -1289,13 +1289,13 @@  discard block
 block discarded – undo
1289 1289
                    id = %d
1290 1290
                AND
1291 1291
                    lang = '%s'",
1292
-               PMF_Db::getTablePrefix(),
1293
-               $category_id,
1294
-               $language);
1295
-           $result = $this->_config->getDb()->query($query);
1296
-           if ($row = $this->_config->getDb()->fetchArray($result)) {
1297
-              $translated[$languageCodes[strtoupper($language)]] = $row['name'].('' == $row['description'] ? '' : '  ('.$row['description'].')');
1298
-           }
1292
+                PMF_Db::getTablePrefix(),
1293
+                $category_id,
1294
+                $language);
1295
+            $result = $this->_config->getDb()->query($query);
1296
+            if ($row = $this->_config->getDb()->fetchArray($result)) {
1297
+                $translated[$languageCodes[strtoupper($language)]] = $row['name'].('' == $row['description'] ? '' : '  ('.$row['description'].')');
1298
+            }
1299 1299
         }
1300 1300
         ksort($translated);
1301 1301
 
@@ -1349,9 +1349,9 @@  discard block
 block discarded – undo
1349 1349
         $result = $this->_config->getDb()->query($query);
1350 1350
         while ($row = $this->_config->getDb()->fetchArray($result)) {
1351 1351
             if (!array_key_exists($row['id'],$this->categoryName)) {
1352
-               $this->categoryName[$row['id']] = $row;
1353
-               $this->categories[] =& $this->categoryName[$row['id']];
1354
-               $this->children[$row['parent_id']][$row['id']] =& $this->categoryName[$row['id']];
1352
+                $this->categoryName[$row['id']] = $row;
1353
+                $this->categories[] =& $this->categoryName[$row['id']];
1354
+                $this->children[$row['parent_id']][$row['id']] =& $this->categoryName[$row['id']];
1355 1355
             }
1356 1356
         }
1357 1357
     }
@@ -1548,8 +1548,8 @@  discard block
 block discarded – undo
1548 1548
                 fd.lang = fcr.category_lang
1549 1549
             ORDER BY
1550 1550
                 fcr.category_id, fd.id',
1551
-             PMF_Db::getTablePrefix(),
1552
-             PMF_Db::getTablePrefix());
1551
+                PMF_Db::getTablePrefix(),
1552
+                PMF_Db::getTablePrefix());
1553 1553
         $result = $this->_config->getDb()->query($query);
1554 1554
 
1555 1555
         if ($this->_config->getDb()->numRows($result) > 0) {
Please login to merge, or discard this patch.
phpmyfaq/inc/PMF/DB/Mssql.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      * @param   string $password
69 69
      * @param   string $database
70 70
      *
71
-     * @return  boolean TRUE, if connected, otherwise FALSE
71
+     * @return  null|boolean TRUE, if connected, otherwise FALSE
72 72
      */
73 73
     public function connect($host, $user, $password, $database = '')
74 74
     {
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
      *
283 283
      * @param  string $prefix Table prefix
284 284
      *
285
-     * @return array
285
+     * @return string[]
286 286
      */
287 287
     public function getTableNames($prefix = '')
288 288
     {
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
     /**
118
-    * Escapes a string for use in a query
119
-    *
120
-    * @param   string
121
-    * @return  string
122
-    */
118
+     * Escapes a string for use in a query
119
+     *
120
+     * @param   string
121
+     * @return  string
122
+     */
123 123
     public function escape($string)
124 124
     {
125 125
         return str_replace("'", "''", $string);
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public function clientVersion()
260 260
     {
261
-         return '';
261
+            return '';
262 262
     }
263 263
 
264 264
     /**
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@
 block discarded – undo
160 160
     {
161 161
         $ret = [];
162 162
         if (false === $result) {
163
-            throw new Exception('Error while fetching result: ' . $this->error());
163
+            throw new Exception('Error while fetching result: '.$this->error());
164 164
         }
165 165
         
166 166
         while ($row = $this->fetchObject($result)) {
Please login to merge, or discard this patch.
phpmyfaq/inc/PMF/DB/Mysqli.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      *
69 69
      * @throws PMF_Exception
70 70
      *
71
-     * @return  boolean true, if connected, otherwise false
71
+     * @return  null|boolean true, if connected, otherwise false
72 72
      */
73 73
     public function connect($host, $user, $password, $database = '')
74 74
     {
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      *
285 285
      * @param  string $prefix Table prefix
286 286
      *
287
-     * @return array
287
+     * @return string[]
288 288
      */
289 289
     function getTableNames($prefix = '')
290 290
     {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function connect($host, $user, $password, $database = '')
74 74
     {
75
-        if (substr($host, 0, 1)=='/') {
75
+        if (substr($host, 0, 1) == '/') {
76 76
                 // Connect to MySQL via socket
77 77
                 $this->conn = new mysqli(null, $user, $password, null, null, $host);
78 78
         } else {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                 $this->conn = new mysqli($host, $user, $password);
81 81
         }
82 82
         if ($this->conn->connect_error) {
83
-            PMF_Db::errorPage($this->conn->connect_errno . ': ' . $this->conn->connect_error);
83
+            PMF_Db::errorPage($this->conn->connect_errno.': '.$this->conn->connect_error);
84 84
             die();
85 85
         }
86 86
         
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
         }
91 91
 
92 92
         if ('' !== $database) {
93
-            if (! $this->conn->select_db($database)) {
94
-                throw new PMF_Exception('Cannot connect to database ' . $database);
93
+            if (!$this->conn->select_db($database)) {
94
+                throw new PMF_Exception('Cannot connect to database '.$database);
95 95
             }
96 96
         }
97 97
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     {
177 177
         $ret = [];
178 178
         if (false === $result) {
179
-            throw new Exception('Error while fetching result: ' . $this->error());
179
+            throw new Exception('Error while fetching result: '.$this->error());
180 180
         }
181 181
         
182 182
         while ($row = $this->fetchObject($result)) {
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
     }
128 128
 
129 129
     /**
130
-    * Escapes a string for use in a query
131
-    *
132
-    * @param   string
133
-    * @return  string
134
-    */
130
+     * Escapes a string for use in a query
131
+     *
132
+     * @param   string
133
+     * @return  string
134
+     */
135 135
     public function escape($string)
136 136
     {
137 137
         return $this->conn->real_escape_string($string);
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
         return $this->sqllog;
212 212
     }
213 213
 
214
-     /**
215
-      * This function returns the table status.
216
-      *
217
-      * @return array
218
-      */
214
+        /**
215
+         * This function returns the table status.
216
+         *
217
+         * @return array
218
+         */
219 219
     public function getTableStatus()
220 220
     {
221 221
         $arr = [];
@@ -241,19 +241,19 @@  discard block
 block discarded – undo
241 241
                MAX(%s) AS current_id
242 242
            FROM
243 243
                %s",
244
-           $id,
245
-           $table);
244
+            $id,
245
+            $table);
246 246
            
247 247
         $result  = $this->query($select);
248 248
         $current = $result->fetch_row();
249 249
         return $current[0] + 1;
250 250
     }
251 251
 
252
-     /**
253
-      * Returns the error string.
254
-      *
255
-      * @return string
256
-      */
252
+        /**
253
+         * Returns the error string.
254
+         *
255
+         * @return string
256
+         */
257 257
     public function error()
258 258
     {
259 259
         return $this->conn->error;
Please login to merge, or discard this patch.