Completed
Push — development ( 6a24df...5afdf5 )
by Nils
07:52
created
includes/libraries/LDAP/adLDAP/classes/adLDAPFolders.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -118,8 +118,7 @@
 block discarded – undo
118 118
             $ou = $dnType."=".implode(",".$dnType."=", $folderName);
119 119
             $filter .= '(!(distinguishedname='.$ou.','.$this->adldap->getBaseDn().')))';
120 120
             $searchOu = $ou.','.$this->adldap->getBaseDn();
121
-        }
122
-        else {
121
+        } else {
123 122
             $filter .= '(!(distinguishedname='.$this->adldap->getBaseDn().')))';
124 123
         }
125 124
 
Please login to merge, or discard this patch.
includes/libraries/Database/Meekrodb/db.class.php 1 patch
Braces   +162 added lines, -70 removed lines patch added patch discarded remove patch
@@ -161,12 +161,24 @@  discard block
 block discarded – undo
161 161
 
162 162
 
163 163
     public function __construct($host=null, $user=null, $password=null, $dbName=null, $port=null, $encoding=null) {
164
-    if ($host === null) $host = DB::$host;
165
-    if ($user === null) $user = DB::$user;
166
-    if ($password === null) $password = DB::$password;
167
-    if ($dbName === null) $dbName = DB::$dbName;
168
-    if ($port === null) $port = DB::$port;
169
-    if ($encoding === null) $encoding = DB::$encoding;
164
+    if ($host === null) {
165
+        $host = DB::$host;
166
+    }
167
+    if ($user === null) {
168
+        $user = DB::$user;
169
+    }
170
+    if ($password === null) {
171
+        $password = DB::$password;
172
+    }
173
+    if ($dbName === null) {
174
+        $dbName = DB::$dbName;
175
+    }
176
+    if ($port === null) {
177
+        $port = DB::$port;
178
+    }
179
+    if ($encoding === null) {
180
+        $encoding = DB::$encoding;
181
+    }
170 182
 
171 183
     $this->host = $host;
172 184
     $this->user = $user;
@@ -180,7 +192,9 @@  discard block
 block discarded – undo
180 192
     $mysql = $this->internal_mysql;
181 193
 
182 194
     if (!($mysql instanceof MySQLi)) {
183
-        if (! $this->port) $this->port = ini_get('mysqli.default_port');
195
+        if (! $this->port) {
196
+            $this->port = ini_get('mysqli.default_port');
197
+        }
184 198
         $this->current_db = $this->dbName;
185 199
       
186 200
         $mysql = new mysqli($this->host, $this->user, $this->password, $this->dbName, $this->port);
@@ -200,7 +214,9 @@  discard block
 block discarded – undo
200 214
     public function disconnect() {
201 215
     $mysqli = $this->internal_mysql;
202 216
     if ($mysqli instanceof MySQLi) {
203
-        if ($thread_id = $mysqli->thread_id) $mysqli->kill($thread_id);
217
+        if ($thread_id = $mysqli->thread_id) {
218
+            $mysqli->kill($thread_id);
219
+        }
204 220
         $mysqli->close();
205 221
     }
206 222
     $this->internal_mysql = null;
@@ -262,8 +278,9 @@  discard block
 block discarded – undo
262 278
         return $this->nonSQLError("Nested transactions are only available on MySQL 5.5 and greater. You are using MySQL " . $this->serverVersion());
263 279
     }
264 280
 
265
-    if ($this->nested_transactions && $this->nested_transactions_count > 0)
266
-        $this->nested_transactions_count--;
281
+    if ($this->nested_transactions && $this->nested_transactions_count > 0) {
282
+            $this->nested_transactions_count--;
283
+    }
267 284
 
268 285
     if (!$this->nested_transactions || $all || $this->nested_transactions_count == 0) {
269 286
         $this->nested_transactions_count = 0;
@@ -280,8 +297,9 @@  discard block
 block discarded – undo
280 297
         return $this->nonSQLError("Nested transactions are only available on MySQL 5.5 and greater. You are using MySQL " . $this->serverVersion());
281 298
     }
282 299
 
283
-    if ($this->nested_transactions && $this->nested_transactions_count > 0)
284
-        $this->nested_transactions_count--;
300
+    if ($this->nested_transactions && $this->nested_transactions_count > 0) {
301
+            $this->nested_transactions_count--;
302
+    }
285 303
 
286 304
     if (!$this->nested_transactions || $all || $this->nested_transactions_count == 0) {
287 305
         $this->nested_transactions_count = 0;
@@ -296,8 +314,11 @@  discard block
 block discarded – undo
296 314
     protected function formatTableName($table) {
297 315
     $table = trim($table, '`');
298 316
 
299
-    if (strpos($table, '.')) return implode('.', array_map(array($this, 'formatTableName'), explode('.', $table)));
300
-    else return '`' . str_replace('`', '``', $table) . '`';
317
+    if (strpos($table, '.')) {
318
+        return implode('.', array_map(array($this, 'formatTableName'), explode('.', $table)));
319
+    } else {
320
+        return '`' . str_replace('`', '``', $table) . '`';
321
+    }
301 322
     }
302 323
 
303 324
     public function update() {
@@ -471,7 +492,9 @@  discard block
 block discarded – undo
471 492
         // handle numbered parameters
472 493
         if ($arg_number_length = strspn($sql, '0123456789', $new_pos_back)) {
473 494
         $arg_number = substr($sql, $new_pos_back, $arg_number_length);
474
-        if (!array_key_exists($arg_number, $args_all)) $this->nonSQLError("Non existent argument reference (arg $arg_number): $sql");
495
+        if (!array_key_exists($arg_number, $args_all)) {
496
+            $this->nonSQLError("Non existent argument reference (arg $arg_number): $sql");
497
+        }
475 498
 
476 499
         $arg = $args_all[$arg_number];
477 500
 
@@ -481,8 +504,12 @@  discard block
 block discarded – undo
481 504
             $new_pos_back + $named_seperator_length) + $named_seperator_length;
482 505
 
483 506
         $arg_number = substr($sql, $new_pos_back + $named_seperator_length, $arg_number_length - $named_seperator_length);
484
-        if (count($args_all) != 1 || !is_array($args_all[0])) $this->nonSQLError("If you use named parameters, the second argument must be an array of parameters");
485
-        if (!array_key_exists($arg_number, $args_all[0])) $this->nonSQLError("Non existent argument reference (arg $arg_number): $sql");
507
+        if (count($args_all) != 1 || !is_array($args_all[0])) {
508
+            $this->nonSQLError("If you use named parameters, the second argument must be an array of parameters");
509
+        }
510
+        if (!array_key_exists($arg_number, $args_all[0])) {
511
+            $this->nonSQLError("Non existent argument reference (arg $arg_number): $sql");
512
+        }
486 513
 
487 514
         $arg = $args_all[0][$arg_number];
488 515
 
@@ -491,7 +518,9 @@  discard block
 block discarded – undo
491 518
         $arg = array_shift($args);
492 519
         }
493 520
 
494
-        if ($new_pos > 0) $chunkyQuery[] = substr($sql, 0, $new_pos);
521
+        if ($new_pos > 0) {
522
+            $chunkyQuery[] = substr($sql, 0, $new_pos);
523
+        }
495 524
 
496 525
         if (is_object($arg) && ($arg instanceof WhereClause)) {
497 526
         list($clause_sql, $clause_args) = $arg->textAndArgs();
@@ -517,21 +546,31 @@  discard block
 block discarded – undo
517 546
 
518 547
     protected function sanitize($value) {
519 548
     if (is_object($value)) {
520
-        if ($value instanceof MeekroDBEval) return $value->text;
521
-        else if ($value instanceof DateTime) return $this->escape($value->format('Y-m-d H:i:s'));
522
-        else return '';
549
+        if ($value instanceof MeekroDBEval) {
550
+            return $value->text;
551
+        } else if ($value instanceof DateTime) {
552
+            return $this->escape($value->format('Y-m-d H:i:s'));
553
+        } else {
554
+            return '';
555
+        }
523 556
     }
524 557
 
525
-    if (is_null($value)) return $this->usenull ? 'NULL' : "''";
526
-    else if (is_bool($value)) return ($value ? 1 : 0);
527
-    else if (is_int($value)) return $value;
528
-    else if (is_float($value)) return $value;
529
-
530
-    else if (is_array($value)) {
558
+    if (is_null($value)) {
559
+        return $this->usenull ? 'NULL' : "''";
560
+    } else if (is_bool($value)) {
561
+        return ($value ? 1 : 0);
562
+    } else if (is_int($value)) {
563
+        return $value;
564
+    } else if (is_float($value)) {
565
+        return $value;
566
+    } else if (is_array($value)) {
531 567
         // non-assoc array?
532 568
         if (array_values($value) === $value) {
533
-        if (is_array($value[0])) return implode(', ', array_map(array($this, 'sanitize'), $value));
534
-        else return '(' . implode(', ', array_map(array($this, 'sanitize'), $value)) . ')';
569
+        if (is_array($value[0])) {
570
+            return implode(', ', array_map(array($this, 'sanitize'), $value));
571
+        } else {
572
+            return '(' . implode(', ', array_map(array($this, 'sanitize'), $value)) . ')';
573
+        }
535 574
         }
536 575
 
537 576
         $pairs = array();
@@ -540,17 +579,23 @@  discard block
 block discarded – undo
540 579
         }
541 580
 
542 581
         return implode(', ', $pairs);
582
+    } else {
583
+        return $this->escape($value);
543 584
     }
544
-    else return $this->escape($value);
545 585
     }
546 586
 
547 587
     protected function parseTS($ts) {
548
-    if (is_string($ts)) return date('Y-m-d H:i:s', strtotime($ts));
549
-    else if (is_object($ts) && ($ts instanceof DateTime)) return $ts->format('Y-m-d H:i:s');
588
+    if (is_string($ts)) {
589
+        return date('Y-m-d H:i:s', strtotime($ts));
590
+    } else if (is_object($ts) && ($ts instanceof DateTime)) {
591
+        return $ts->format('Y-m-d H:i:s');
592
+    }
550 593
     }
551 594
 
552 595
     protected function intval($var) {
553
-    if (PHP_INT_SIZE == 8) return intval($var);
596
+    if (PHP_INT_SIZE == 8) {
597
+        return intval($var);
598
+    }
554 599
     return floor(doubleval($var));
555 600
     }
556 601
 
@@ -573,30 +618,48 @@  discard block
 block discarded – undo
573 618
 
574 619
       if ($type != '?') {
575 620
         $is_array_type = in_array($type, $array_types, true);
576
-        if ($is_array_type && !is_array($arg)) $this->nonSQLError("Badly formatted SQL query: Expected array, got scalar instead!");
577
-        else if (!$is_array_type && is_array($arg)) $this->nonSQLError("Badly formatted SQL query: Expected scalar, got array instead!");
621
+        if ($is_array_type && !is_array($arg)) {
622
+            $this->nonSQLError("Badly formatted SQL query: Expected array, got scalar instead!");
623
+        } else if (!$is_array_type && is_array($arg)) {
624
+            $this->nonSQLError("Badly formatted SQL query: Expected scalar, got array instead!");
625
+        }
578 626
       }
579 627
 
580
-      if ($type == 's') $result = $this->escape($arg);
581
-      else if ($type == 'i') $result = $this->intval($arg);
582
-      else if ($type == 'd') $result = doubleval($arg);
583
-      else if ($type == 'b') $result = $this->formatTableName($arg);
584
-      else if ($type == 'l') $result = $arg;
585
-      else if ($type == 'ss') $result = $this->escape("%".str_replace(array('%', '_'), array('\%', '\_'), $arg)."%");
586
-      else if ($type == 't') $result = $this->escape($this->parseTS($arg));
587
-
588
-      else if ($type == 'ls') $result = array_map(array($this, 'escape'), $arg);
589
-      else if ($type == 'li') $result = array_map(array($this, 'intval'), $arg);
590
-      else if ($type == 'ld') $result = array_map('doubleval', $arg);
591
-      else if ($type == 'lb') $result = array_map(array($this, 'formatTableName'), $arg);
592
-      else if ($type == 'll') $result = $arg;
593
-      else if ($type == 'lt') $result = array_map(array($this, 'escape'), array_map(array($this, 'parseTS'), $arg));
594
-
595
-      else if ($type == '?') $result = $this->sanitize($arg);
596
-
597
-      else $this->nonSQLError("Badly formatted SQL query: Invalid MeekroDB param $type");
628
+      if ($type == 's') {
629
+          $result = $this->escape($arg);
630
+      } else if ($type == 'i') {
631
+          $result = $this->intval($arg);
632
+      } else if ($type == 'd') {
633
+          $result = doubleval($arg);
634
+      } else if ($type == 'b') {
635
+          $result = $this->formatTableName($arg);
636
+      } else if ($type == 'l') {
637
+          $result = $arg;
638
+      } else if ($type == 'ss') {
639
+          $result = $this->escape("%".str_replace(array('%', '_'), array('\%', '\_'), $arg)."%");
640
+      } else if ($type == 't') {
641
+          $result = $this->escape($this->parseTS($arg));
642
+      } else if ($type == 'ls') {
643
+          $result = array_map(array($this, 'escape'), $arg);
644
+      } else if ($type == 'li') {
645
+          $result = array_map(array($this, 'intval'), $arg);
646
+      } else if ($type == 'ld') {
647
+          $result = array_map('doubleval', $arg);
648
+      } else if ($type == 'lb') {
649
+          $result = array_map(array($this, 'formatTableName'), $arg);
650
+      } else if ($type == 'll') {
651
+          $result = $arg;
652
+      } else if ($type == 'lt') {
653
+          $result = array_map(array($this, 'escape'), array_map(array($this, 'parseTS'), $arg));
654
+      } else if ($type == '?') {
655
+          $result = $this->sanitize($arg);
656
+      } else {
657
+          $this->nonSQLError("Badly formatted SQL query: Invalid MeekroDB param $type");
658
+      }
598 659
 
599
-      if (is_array($result)) $result = '('.implode(',', $result).')';
660
+      if (is_array($result)) {
661
+          $result = '('.implode(',', $result).')';
662
+      }
600 663
 
601 664
       $query .= $result;
602 665
     }
@@ -702,23 +765,33 @@  discard block
 block discarded – undo
702 765
     $this->affected_rows = $db->affected_rows;
703 766
 
704 767
     // mysqli_result->num_rows won't initially show correct results for unbuffered data
705
-    if ($is_buffered && ($result instanceof MySQLi_Result)) $this->num_rows = $result->num_rows;
706
-    else $this->num_rows = null;
768
+    if ($is_buffered && ($result instanceof MySQLi_Result)) {
769
+        $this->num_rows = $result->num_rows;
770
+    } else {
771
+        $this->num_rows = null;
772
+    }
707 773
 
708
-    if ($row_type == 'raw' || !($result instanceof MySQLi_Result)) return $result;
774
+    if ($row_type == 'raw' || !($result instanceof MySQLi_Result)) {
775
+        return $result;
776
+    }
709 777
 
710 778
     $return = array();
711 779
 
712 780
     if ($full_names) {
713 781
         $infos = array();
714 782
         foreach ($result->fetch_fields() as $info) {
715
-        if (strlen($info->table)) $infos[] = $info->table . '.' . $info->name;
716
-        else $infos[] = $info->name;
783
+        if (strlen($info->table)) {
784
+            $infos[] = $info->table . '.' . $info->name;
785
+        } else {
786
+            $infos[] = $info->name;
787
+        }
717 788
         }
718 789
     }
719 790
 
720 791
     while ($row = ($row_type == 'assoc' ? $result->fetch_assoc() : $result->fetch_row())) {
721
-        if ($full_names) $row = array_combine($infos, $row);
792
+        if ($full_names) {
793
+            $row = array_combine($infos, $row);
794
+        }
722 795
         $return[] = $row;
723 796
     }
724 797
 
@@ -726,7 +799,9 @@  discard block
 block discarded – undo
726 799
     $result->free();
727 800
     while ($db->more_results()) {
728 801
         $db->next_result();
729
-        if ($result = $db->use_result()) $result->free();
802
+        if ($result = $db->use_result()) {
803
+            $result->free();
804
+        }
730 805
     }
731 806
 
732 807
     return $return;
@@ -736,7 +811,9 @@  discard block
 block discarded – undo
736 811
     public function queryFirstRow() {
737 812
     $args = func_get_args();
738 813
     $result = call_user_func_array(array($this, 'query'), $args);
739
-    if (!$result) return null;
814
+    if (!$result) {
815
+        return null;
816
+    }
740 817
     return reset($result);
741 818
     }
742 819
 
@@ -744,7 +821,9 @@  discard block
 block discarded – undo
744 821
     public function queryFirstList() {
745 822
     $args = func_get_args();
746 823
     $result = call_user_func_array(array($this, 'queryAllLists'), $args);
747
-    if (!$result) return null;
824
+    if (!$result) {
825
+        return null;
826
+    }
748 827
     return reset($result);
749 828
     }
750 829
 
@@ -881,10 +960,15 @@  discard block
 block discarded – undo
881 960
         $args = array_merge($args, $clause_args);
882 961
     }
883 962
 
884
-    if ($this->type == 'and') $sql = implode(' AND ', $sql);
885
-    else $sql = implode(' OR ', $sql);
963
+    if ($this->type == 'and') {
964
+        $sql = implode(' AND ', $sql);
965
+    } else {
966
+        $sql = implode(' OR ', $sql);
967
+    }
886 968
 
887
-    if ($this->negate) $sql = '(NOT '.$sql.')';
969
+    if ($this->negate) {
970
+        $sql = '(NOT '.$sql.')';
971
+    }
888 972
     return array($sql, $args);
889 973
     }
890 974
 
@@ -900,7 +984,9 @@  discard block
 block discarded – undo
900 984
     DB::startTransaction();
901 985
     }
902 986
     function __destruct() {
903
-    if (! $this->committed) DB::rollback();
987
+    if (! $this->committed) {
988
+        DB::rollback();
989
+    }
904 990
     }
905 991
     function commit() {
906 992
     DB::commit();
@@ -934,10 +1020,14 @@  discard block
 block discarded – undo
934 1020
 
935 1021
     $R = array();
936 1022
     foreach ($array as $obj) {
937
-        if (! array_key_exists($field, $obj)) die("verticalSlice: array doesn't have requested field\n");
1023
+        if (! array_key_exists($field, $obj)) {
1024
+            die("verticalSlice: array doesn't have requested field\n");
1025
+        }
938 1026
 
939 1027
         if ($keyfield) {
940
-        if (! array_key_exists($keyfield, $obj)) die("verticalSlice: array doesn't have requested field\n");
1028
+        if (! array_key_exists($keyfield, $obj)) {
1029
+            die("verticalSlice: array doesn't have requested field\n");
1030
+        }
941 1031
         $R[$obj[$keyfield]] = $obj[$field];
942 1032
         } else {
943 1033
         $R[] = $obj[$field];
@@ -961,7 +1051,9 @@  discard block
 block discarded – undo
961 1051
         $target =& $R;
962 1052
 
963 1053
         foreach ($fields as $field) {
964
-        if (! array_key_exists($field, $obj)) die("reIndex: array doesn't have requested field\n");
1054
+        if (! array_key_exists($field, $obj)) {
1055
+            die("reIndex: array doesn't have requested field\n");
1056
+        }
965 1057
 
966 1058
         $nextkey = $obj[$field];
967 1059
         $target =& $target[$nextkey];
Please login to merge, or discard this patch.
includes/libraries/Authentication/Yubico/Yubico.php 1 patch
Braces   +38 added lines, -15 removed lines patch added patch discarded remove patch
@@ -148,15 +148,21 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	function getNextURLpart()
150 150
 	{
151
-	  if ($this->_url_list) $url_list = $this->_url_list;
152
-	  else $url_list = array('api.yubico.com/wsapi/2.0/verify',
151
+	  if ($this->_url_list) {
152
+	      $url_list = $this->_url_list;
153
+	  } else {
154
+	      $url_list = array('api.yubico.com/wsapi/2.0/verify',
153 155
 			       'api2.yubico.com/wsapi/2.0/verify', 
154 156
 			       'api3.yubico.com/wsapi/2.0/verify', 
155 157
 			       'api4.yubico.com/wsapi/2.0/verify',
156 158
 			       'api5.yubico.com/wsapi/2.0/verify');
159
+	  }
157 160
 	  
158
-	  if ($this->_url_index >= count($url_list)) return false;
159
-	  else return $url_list[$this->_url_index++];
161
+	  if ($this->_url_index >= count($url_list)) {
162
+	      return false;
163
+	  } else {
164
+	      return $url_list[$this->_url_index++];
165
+	  }
160 166
 	}
161 167
 
162 168
 	/**
@@ -291,12 +297,20 @@  discard block
 block discarded – undo
291 297
 			  'otp'=>$ret['otp'],
292 298
 			  'nonce'=>md5(uniqid(rand())));
293 299
 	  /* Take care of protocol version 2 parameters */
294
-	  if ($use_timestamp) $params['timestamp'] = 1;
295
-	  if ($sl) $params['sl'] = $sl;
296
-	  if ($timeout) $params['timeout'] = $timeout;
300
+	  if ($use_timestamp) {
301
+	      $params['timestamp'] = 1;
302
+	  }
303
+	  if ($sl) {
304
+	      $params['sl'] = $sl;
305
+	  }
306
+	  if ($timeout) {
307
+	      $params['timeout'] = $timeout;
308
+	  }
297 309
 	  ksort($params);
298 310
 	  $parameters = '';
299
-	  foreach ($params as $p=>$v) $parameters .= "&".$p."=".$v;
311
+	  foreach ($params as $p=>$v) {
312
+	      $parameters .= "&".$p."=".$v;
313
+	  }
300 314
 	  $parameters = ltrim($parameters, "&");
301 315
 	  
302 316
 	  /* Generate signature. */
@@ -385,8 +399,7 @@  discard block
 block discarded – undo
385 399
             if (!preg_match("/otp=".$params['otp']."/", $str) ||
386 400
               !preg_match("/nonce=".$params['nonce']."/", $str)) {
387 401
             /* Case 1. Ignore response. */
388
-            } 
389
-            elseif ($this->_key <> "") {
402
+            } elseif ($this->_key <> "") {
390 403
             /* Case 2. Verify signature first */
391 404
             $rows = explode("\r\n", trim($str));
392 405
             $response=array();
@@ -402,7 +415,9 @@  discard block
 block discarded – undo
402 415
             $check=Null;
403 416
             foreach ($parameters as $param) {
404 417
                 if (array_key_exists($param, $response)) {
405
-            if ($check) $check = $check . '&';
418
+            if ($check) {
419
+                $check = $check . '&';
420
+            }
406 421
             $check = $check . $param . '=' . $response[$param];
407 422
                 }
408 423
             }
@@ -441,8 +456,12 @@  discard block
 block discarded – undo
441 456
                 curl_close($h);
442 457
             }
443 458
             curl_multi_close($mh);
444
-            if ($replay) return PEAR::raiseError('REPLAYED_OTP');
445
-            if ($valid) return true;
459
+            if ($replay) {
460
+                return PEAR::raiseError('REPLAYED_OTP');
461
+            }
462
+            if ($valid) {
463
+                return true;
464
+            }
446 465
             return PEAR::raiseError($status);
447 466
             }
448 467
 		
@@ -465,8 +484,12 @@  discard block
 block discarded – undo
465 484
         }
466 485
         curl_multi_close ($mh);
467 486
 	  
468
-        if ($replay) return PEAR::raiseError('REPLAYED_OTP');
469
-        if ($valid) return true;
487
+        if ($replay) {
488
+            return PEAR::raiseError('REPLAYED_OTP');
489
+        }
490
+        if ($valid) {
491
+            return true;
492
+        }
470 493
         return PEAR::raiseError('NO_VALID_ANSWER');
471 494
     }
472 495
 }
Please login to merge, or discard this patch.
includes/libraries/Authentication/agses/axs/AXSErrorcodes.inc.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,10 +19,12 @@
 block discarded – undo
19 19
      */
20 20
     function getErrorcode($message) {
21 21
         $errorcode = -10000;
22
-        if (($begin = strpos($message, "ERROR (")) === FALSE)
23
-            $begin = -1;
24
-        if (($end = strpos($message, ")")) === FALSE)
25
-            $end = -1;
22
+        if (($begin = strpos($message, "ERROR (")) === FALSE) {
23
+                    $begin = -1;
24
+        }
25
+        if (($end = strpos($message, ")")) === FALSE) {
26
+                    $end = -1;
27
+        }
26 28
 		
27 29
         if ($begin >= 0 && $end >= 0) {
28 30
             $realBegin = $begin + 7;
Please login to merge, or discard this patch.
includes/libraries/Authentication/TwoFactorAuth/TwoFactorAuth.php 1 patch
Braces   +34 added lines, -21 removed lines patch added patch discarded remove patch
@@ -26,25 +26,30 @@  discard block
 block discarded – undo
26 26
     {
27 27
         $this->issuer = $issuer;
28 28
 
29
-        if (!is_int($digits) || $digits <= 0)
30
-            throw new TwoFactorAuthException('Digits must be int > 0');
29
+        if (!is_int($digits) || $digits <= 0) {
30
+                    throw new TwoFactorAuthException('Digits must be int > 0');
31
+        }
31 32
         $this->digits = $digits;
32 33
 
33
-        if (!is_int($period) || $period <= 0)
34
-            throw new TwoFactorAuthException('Period must be int > 0');
34
+        if (!is_int($period) || $period <= 0) {
35
+                    throw new TwoFactorAuthException('Period must be int > 0');
36
+        }
35 37
         $this->period = $period;
36 38
 
37 39
         $algorithm = strtolower(trim($algorithm));
38
-        if (!in_array($algorithm, self::$_supportedalgos))
39
-            throw new TwoFactorAuthException('Unsupported algorithm: '.$algorithm);
40
+        if (!in_array($algorithm, self::$_supportedalgos)) {
41
+                    throw new TwoFactorAuthException('Unsupported algorithm: '.$algorithm);
42
+        }
40 43
         $this->algorithm = $algorithm;
41 44
 
42 45
         // Set default QR Code provider if none was specified
43
-        if ($qrcodeprovider == null)
44
-            $qrcodeprovider = new Providers\Qr\GoogleQRCodeProvider();
46
+        if ($qrcodeprovider == null) {
47
+                    $qrcodeprovider = new Providers\Qr\GoogleQRCodeProvider();
48
+        }
45 49
 
46
-        if (!($qrcodeprovider instanceof Providers\Qr\IQRCodeProvider))
47
-            throw new TwoFactorAuthException('QRCodeProvider must implement IQRCodeProvider');
50
+        if (!($qrcodeprovider instanceof Providers\Qr\IQRCodeProvider)) {
51
+                    throw new TwoFactorAuthException('QRCodeProvider must implement IQRCodeProvider');
52
+        }
48 53
 
49 54
         $this->qrcodeprovider = $qrcodeprovider;
50 55
 
@@ -80,11 +85,14 @@  discard block
 block discarded – undo
80 85
     {
81 86
         $secret = '';
82 87
         $bytes = ceil($bits / 5); //We use 5 bits of each byte (since we have a 32-character 'alphabet' / BASE32)
83
-        if ($requirecryptosecure && !$this->rngprovider->isCryptographicallySecure())
84
-            throw new TwoFactorAuthException('RNG provider is not cryptographically secure');
88
+        if ($requirecryptosecure && !$this->rngprovider->isCryptographicallySecure()) {
89
+                    throw new TwoFactorAuthException('RNG provider is not cryptographically secure');
90
+        }
85 91
         $rnd = $this->rngprovider->getRandomBytes($bytes);
86
-        for ($i = 0; $i < $bytes; $i++)
87
-            $secret .= self::$_base32[ord($rnd[$i]) & 31]; //Mask out left 3 bits for 0-31 values
92
+        for ($i = 0; $i < $bytes; $i++) {
93
+                    $secret .= self::$_base32[ord($rnd[$i]) & 31];
94
+        }
95
+        //Mask out left 3 bits for 0-31 values
88 96
         return $secret;
89 97
     }
90 98
 
@@ -181,23 +189,28 @@  discard block
 block discarded – undo
181 189
 
182 190
     private function base32Decode($value)
183 191
     {
184
-        if (strlen($value) == 0) return '';
192
+        if (strlen($value) == 0) {
193
+            return '';
194
+        }
185 195
 
186
-        if (preg_match('/[^'.preg_quote(self::$_base32dict).']/', $value) !== 0)
187
-            throw new TwoFactorAuthException('Invalid base32 string');
196
+        if (preg_match('/[^'.preg_quote(self::$_base32dict).']/', $value) !== 0) {
197
+                    throw new TwoFactorAuthException('Invalid base32 string');
198
+        }
188 199
 
189 200
         $buffer = '';
190 201
         foreach (str_split($value) as $char)
191 202
         {
192
-            if ($char !== '=')
193
-                $buffer .= str_pad(decbin(self::$_base32lookup[$char]), 5, 0, STR_PAD_LEFT);
203
+            if ($char !== '=') {
204
+                            $buffer .= str_pad(decbin(self::$_base32lookup[$char]), 5, 0, STR_PAD_LEFT);
205
+            }
194 206
         }
195 207
         $length = strlen($buffer);
196 208
         $blocks = trim(chunk_split(substr($buffer, 0, $length - ($length % 8)), 8, ' '));
197 209
 
198 210
         $output = '';
199
-        foreach (explode(' ', $blocks) as $block)
200
-            $output .= chr(bindec(str_pad($block, 8, 0, STR_PAD_RIGHT)));
211
+        foreach (explode(' ', $blocks) as $block) {
212
+                    $output .= chr(bindec(str_pad($block, 8, 0, STR_PAD_RIGHT)));
213
+        }
201 214
 
202 215
         return $output;
203 216
     }
Please login to merge, or discard this patch.
includes/libraries/Pdf/Tfpdf/tfpdf.class.php 1 patch
Braces   +491 added lines, -408 removed lines patch added patch discarded remove patch
@@ -108,26 +108,28 @@  discard block
 block discarded – undo
108 108
     if (defined('FPDF_FONTPATH'))
109 109
     {
110 110
         $this->fontpath = FPDF_FONTPATH;
111
-        if (substr($this->fontpath, -1) != '/' && substr($this->fontpath, -1) != '\\')
112
-            $this->fontpath .= '/';
111
+        if (substr($this->fontpath, -1) != '/' && substr($this->fontpath, -1) != '\\') {
112
+                    $this->fontpath .= '/';
113
+        }
114
+    } elseif (is_dir(dirname(__FILE__).'/font')) {
115
+            $this->fontpath = dirname(__FILE__).'/font/';
116
+    } else {
117
+            $this->fontpath = '';
113 118
     }
114
-    elseif (is_dir(dirname(__FILE__).'/font'))
115
-        $this->fontpath = dirname(__FILE__).'/font/';
116
-    else
117
-        $this->fontpath = '';
118 119
     // Core fonts
119 120
     $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats');
120 121
     // Scale factor
121
-    if ($unit == 'pt')
122
-        $this->k = 1;
123
-    elseif ($unit == 'mm')
124
-        $this->k = 72 / 25.4;
125
-    elseif ($unit == 'cm')
126
-        $this->k = 72 / 2.54;
127
-    elseif ($unit == 'in')
128
-        $this->k = 72;
129
-    else
130
-        $this->Error('Incorrect unit: '.$unit);
122
+    if ($unit == 'pt') {
123
+            $this->k = 1;
124
+    } elseif ($unit == 'mm') {
125
+            $this->k = 72 / 25.4;
126
+    } elseif ($unit == 'cm') {
127
+            $this->k = 72 / 2.54;
128
+    } elseif ($unit == 'in') {
129
+            $this->k = 72;
130
+    } else {
131
+            $this->Error('Incorrect unit: '.$unit);
132
+    }
131 133
     // Page sizes
132 134
     $this->StdPageSizes = array('a3'=>array(841.89, 1190.55), 'a4'=>array(595.28, 841.89), 'a5'=>array(420.94, 595.28),
133 135
         'letter'=>array(612, 792), 'legal'=>array(612, 1008));
@@ -141,15 +143,14 @@  discard block
 block discarded – undo
141 143
         $this->DefOrientation = 'P';
142 144
         $this->w = $size[0];
143 145
         $this->h = $size[1];
144
-    }
145
-    elseif ($orientation == 'l' || $orientation == 'landscape')
146
+    } elseif ($orientation == 'l' || $orientation == 'landscape')
146 147
     {
147 148
         $this->DefOrientation = 'L';
148 149
         $this->w = $size[1];
149 150
         $this->h = $size[0];
151
+    } else {
152
+            $this->Error('Incorrect orientation: '.$orientation);
150 153
     }
151
-    else
152
-        $this->Error('Incorrect orientation: '.$orientation);
153 154
     $this->CurOrientation = $this->DefOrientation;
154 155
     $this->wPt = $this->w * $this->k;
155 156
     $this->hPt = $this->h * $this->k;
@@ -189,9 +190,10 @@  discard block
 block discarded – undo
189 190
 {
190 191
     // Set left margin
191 192
     $this->lMargin = $margin;
192
-    if ($this->page > 0 && $this->x < $margin)
193
-        $this->x = $margin;
194
-}
193
+    if ($this->page > 0 && $this->x < $margin) {
194
+            $this->x = $margin;
195
+    }
196
+    }
195 197
 
196 198
 function SetTopMargin($margin)
197 199
 {
@@ -222,15 +224,17 @@  discard block
 block discarded – undo
222 224
 function SetDisplayMode($zoom, $layout='default')
223 225
 {
224 226
     // Set display mode in viewer
225
-    if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
226
-        $this->ZoomMode = $zoom;
227
-    else
228
-        $this->Error('Incorrect zoom display mode: '.$zoom);
229
-    if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
230
-        $this->LayoutMode = $layout;
231
-    else
232
-        $this->Error('Incorrect layout display mode: '.$layout);
233
-}
227
+    if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) {
228
+            $this->ZoomMode = $zoom;
229
+    } else {
230
+            $this->Error('Incorrect zoom display mode: '.$zoom);
231
+    }
232
+    if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') {
233
+            $this->LayoutMode = $layout;
234
+    } else {
235
+            $this->Error('Incorrect layout display mode: '.$layout);
236
+    }
237
+    }
234 238
 
235 239
 /**
236 240
  * @param boolean $compress
@@ -238,49 +242,55 @@  discard block
 block discarded – undo
238 242
 function SetCompression($compress)
239 243
 {
240 244
     // Set page compression
241
-    if (function_exists('gzcompress'))
242
-        $this->compress = $compress;
243
-    else
244
-        $this->compress = false;
245
-}
245
+    if (function_exists('gzcompress')) {
246
+            $this->compress = $compress;
247
+    } else {
248
+            $this->compress = false;
249
+    }
250
+    }
246 251
 
247 252
 function SetTitle($title, $isUTF8 = false)
248 253
 {
249 254
     // Title of document
250
-    if ($isUTF8)
251
-        $title = $this->_UTF8toUTF16($title);
255
+    if ($isUTF8) {
256
+            $title = $this->_UTF8toUTF16($title);
257
+    }
252 258
     $this->title = $title;
253 259
 }
254 260
 
255 261
 function SetSubject($subject, $isUTF8 = false)
256 262
 {
257 263
     // Subject of document
258
-    if ($isUTF8)
259
-        $subject = $this->_UTF8toUTF16($subject);
264
+    if ($isUTF8) {
265
+            $subject = $this->_UTF8toUTF16($subject);
266
+    }
260 267
     $this->subject = $subject;
261 268
 }
262 269
 
263 270
 function SetAuthor($author, $isUTF8 = false)
264 271
 {
265 272
     // Author of document
266
-    if ($isUTF8)
267
-        $author = $this->_UTF8toUTF16($author);
273
+    if ($isUTF8) {
274
+            $author = $this->_UTF8toUTF16($author);
275
+    }
268 276
     $this->author = $author;
269 277
 }
270 278
 
271 279
 function SetKeywords($keywords, $isUTF8 = false)
272 280
 {
273 281
     // Keywords of document
274
-    if ($isUTF8)
275
-        $keywords = $this->_UTF8toUTF16($keywords);
282
+    if ($isUTF8) {
283
+            $keywords = $this->_UTF8toUTF16($keywords);
284
+    }
276 285
     $this->keywords = $keywords;
277 286
 }
278 287
 
279 288
 function SetCreator($creator, $isUTF8 = false)
280 289
 {
281 290
     // Creator of document
282
-    if ($isUTF8)
283
-        $creator = $this->_UTF8toUTF16($creator);
291
+    if ($isUTF8) {
292
+            $creator = $this->_UTF8toUTF16($creator);
293
+    }
284 294
     $this->creator = $creator;
285 295
 }
286 296
 
@@ -305,10 +315,12 @@  discard block
 block discarded – undo
305 315
 function Close()
306 316
 {
307 317
     // Terminate document
308
-    if ($this->state == 3)
309
-        return;
310
-    if ($this->page == 0)
311
-        $this->AddPage();
318
+    if ($this->state == 3) {
319
+            return;
320
+    }
321
+    if ($this->page == 0) {
322
+            $this->AddPage();
323
+    }
312 324
     // Page footer
313 325
     $this->InFooter = true;
314 326
     $this->Footer();
@@ -322,8 +334,9 @@  discard block
 block discarded – undo
322 334
 function AddPage($orientation = '', $size = '')
323 335
 {
324 336
     // Start a new page
325
-    if ($this->state == 0)
326
-        $this->Open();
337
+    if ($this->state == 0) {
338
+            $this->Open();
339
+    }
327 340
     $family = $this->FontFamily;
328 341
     $style = $this->FontStyle.($this->underline ? 'U' : '');
329 342
     $fontsize = $this->FontSizePt;
@@ -349,15 +362,18 @@  discard block
 block discarded – undo
349 362
     $this->LineWidth = $lw;
350 363
     $this->_out(sprintf('%.2F w', $lw * $this->k));
351 364
     // Set font
352
-    if ($family)
353
-        $this->SetFont($family, $style, $fontsize);
365
+    if ($family) {
366
+            $this->SetFont($family, $style, $fontsize);
367
+    }
354 368
     // Set colors
355 369
     $this->DrawColor = $dc;
356
-    if ($dc != '0 G')
357
-        $this->_out($dc);
370
+    if ($dc != '0 G') {
371
+            $this->_out($dc);
372
+    }
358 373
     $this->FillColor = $fc;
359
-    if ($fc != '0 g')
360
-        $this->_out($fc);
374
+    if ($fc != '0 g') {
375
+            $this->_out($fc);
376
+    }
361 377
     $this->TextColor = $tc;
362 378
     $this->ColorFlag = $cf;
363 379
     // Page header
@@ -371,8 +387,9 @@  discard block
 block discarded – undo
371 387
         $this->_out(sprintf('%.2F w', $lw * $this->k));
372 388
     }
373 389
     // Restore font
374
-    if ($family)
375
-        $this->SetFont($family, $style, $fontsize);
390
+    if ($family) {
391
+            $this->SetFont($family, $style, $fontsize);
392
+    }
376 393
     // Restore colors
377 394
     if ($this->DrawColor != $dc)
378 395
     {
@@ -498,23 +515,23 @@  discard block
 block discarded – undo
498 515
     // Add a TrueType, OpenType or Type1 font
499 516
     $family = strtolower($family);
500 517
     $style = strtoupper($style);
501
-    if($style=='IB')
502
-        $style='BI';
518
+    if($style=='IB') {
519
+            $style='BI';
520
+    }
503 521
     if($file=='') {
504 522
         if ($uni) {
505 523
         $file = str_replace(' ','',$family).strtolower($style).'.ttf';
506
-        }
507
-        else {
524
+        } else {
508 525
         $file = str_replace(' ','',$family).strtolower($style).'.php';
509 526
         }
510 527
     }
511 528
     $fontkey = $family.$style;
512
-    if(isset($this->fonts[$fontkey]))
513
-        return;
529
+    if(isset($this->fonts[$fontkey])) {
530
+            return;
531
+    }
514 532
 
515 533
     if ($uni) {
516
-        if (defined("_SYSTEM_TTFONTS") && file_exists(_SYSTEM_TTFONTS.$file )) { $ttffilename = _SYSTEM_TTFONTS.$file ; }
517
-        else { $ttffilename = $this->_getfontpath().'unifont/'.$file ; }
534
+        if (defined("_SYSTEM_TTFONTS") && file_exists(_SYSTEM_TTFONTS.$file )) { $ttffilename = _SYSTEM_TTFONTS.$file ; } else { $ttffilename = $this->_getfontpath().'unifont/'.$file ; }
518 535
         $unifilename = $this->_getfontpath().'unifont/'.strtolower(substr($file ,0,(strpos($file ,'.'))));
519 536
         $name = '';
520 537
         $originalsize = 0;
@@ -563,22 +580,21 @@  discard block
 block discarded – undo
563 580
                 @unlink($unifilename.'.cw127.php');
564 581
             }
565 582
             unset($ttf);
566
-        }
567
-        else {
583
+        } else {
568 584
             $cw = @file_get_contents($unifilename.'.cw.dat');
569 585
         }
570 586
         $i = count($this->fonts) + 1;
571
-        if (!empty($this->AliasNbPages))
572
-            $sbarr = range(0, 57);
573
-        else
574
-            $sbarr = range(0, 32);
587
+        if (!empty($this->AliasNbPages)) {
588
+                    $sbarr = range(0, 57);
589
+        } else {
590
+                    $sbarr = range(0, 32);
591
+        }
575 592
         $this->fonts[$fontkey] = array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'ttffile'=>$ttffile, 'fontkey'=>$fontkey, 'subset'=>$sbarr, 'unifilename'=>$unifilename);
576 593
 
577 594
         $this->FontFiles[$fontkey] = array('length1'=>$originalsize, 'type'=>"TTF", 'ttffile'=>$ttffile);
578 595
         $this->FontFiles[$file] = array('type'=>"TTF");
579 596
         unset($cw);
580
-    }
581
-    else {
597
+    } else {
582 598
         $info = $this->_loadfont($file);
583 599
         $info['i'] = count($this->fonts) + 1;
584 600
         if (!empty($info['diff']))
@@ -595,10 +611,11 @@  discard block
 block discarded – undo
595 611
         if (!empty($info['file']))
596 612
         {
597 613
             // Embedded font
598
-            if ($info['type'] == 'TrueType')
599
-                $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
600
-            else
601
-                $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
614
+            if ($info['type'] == 'TrueType') {
615
+                            $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
616
+            } else {
617
+                            $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
618
+            }
602 619
         }
603 620
         $this->fonts[$fontkey] = $info;
604 621
     }
@@ -660,22 +677,24 @@  discard block
 block discarded – undo
660 677
     $this->FontSizePt = $size;
661 678
     $this->FontSize = $size / $this->k;
662 679
     $this->CurrentFont = &$this->fonts[$fontkey];
663
-    if ($this->fonts[$fontkey]['type'] == 'TTF') { $this->unifontSubset = true; }
664
-    else { $this->unifontSubset = false; }
665
-    if ($this->page > 0)
666
-        $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
667
-}
680
+    if ($this->fonts[$fontkey]['type'] == 'TTF') { $this->unifontSubset = true; } else { $this->unifontSubset = false; }
681
+    if ($this->page > 0) {
682
+            $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
683
+    }
684
+    }
668 685
 
669 686
 function SetFontSize($size)
670 687
 {
671 688
     // Set font size in points
672
-    if ($this->FontSizePt == $size)
673
-        return;
689
+    if ($this->FontSizePt == $size) {
690
+            return;
691
+    }
674 692
     $this->FontSizePt = $size;
675 693
     $this->FontSize = $size / $this->k;
676
-    if ($this->page > 0)
677
-        $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
678
-}
694
+    if ($this->page > 0) {
695
+            $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
696
+    }
697
+    }
679 698
 
680 699
 function AddLink()
681 700
 {
@@ -688,10 +707,12 @@  discard block
 block discarded – undo
688 707
 function SetLink($link, $y = 0, $page = -1)
689 708
 {
690 709
     // Set destination of internal link
691
-    if ($y == -1)
692
-        $y = $this->y;
693
-    if ($page == -1)
694
-        $page = $this->page;
710
+    if ($y == -1) {
711
+            $y = $this->y;
712
+    }
713
+    if ($page == -1) {
714
+            $page = $this->page;
715
+    }
695 716
     $this->links[$link] = array($page, $y);
696 717
 }
697 718
 
@@ -711,16 +732,19 @@  discard block
 block discarded – undo
711 732
     if ($this->unifontSubset)
712 733
     {
713 734
         $txt2 = '('.$this->_escape($this->UTF8ToUTF16BE($txt, false)).')';
714
-        foreach ($this->UTF8StringToArray($txt) as $uni)
715
-            $this->CurrentFont['subset'][$uni] = $uni;
735
+        foreach ($this->UTF8StringToArray($txt) as $uni) {
736
+                    $this->CurrentFont['subset'][$uni] = $uni;
737
+        }
738
+    } else {
739
+            $txt2 = '('.$this->_escape($txt).')';
716 740
     }
717
-    else
718
-        $txt2 = '('.$this->_escape($txt).')';
719 741
     $s = sprintf('BT %.2F %.2F Td %s Tj ET', $x * $this->k, ($this->h - $y) * $this->k, $txt2);
720
-    if ($this->underline && $txt != '')
721
-        $s .= ' '.$this->_dounderline($x, $y, $txt);
722
-    if ($this->ColorFlag)
723
-        $s = 'q '.$this->TextColor.' '.$s.' Q';
742
+    if ($this->underline && $txt != '') {
743
+            $s .= ' '.$this->_dounderline($x, $y, $txt);
744
+    }
745
+    if ($this->ColorFlag) {
746
+            $s = 'q '.$this->TextColor.' '.$s.' Q';
747
+    }
724 748
     $this->_out($s);
725 749
 }
726 750
 
@@ -752,45 +776,54 @@  discard block
 block discarded – undo
752 776
             $this->_out(sprintf('%.3F Tw', $ws * $k));
753 777
         }
754 778
     }
755
-    if ($w == 0)
756
-        $w = $this->w - $this->rMargin - $this->x;
779
+    if ($w == 0) {
780
+            $w = $this->w - $this->rMargin - $this->x;
781
+    }
757 782
     $s = '';
758 783
     if ($fill || $border == 1)
759 784
     {
760
-        if ($fill)
761
-            $op = ($border == 1) ? 'B' : 'f';
762
-        else
763
-            $op = 'S';
785
+        if ($fill) {
786
+                    $op = ($border == 1) ? 'B' : 'f';
787
+        } else {
788
+                    $op = 'S';
789
+        }
764 790
         $s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op);
765 791
     }
766 792
     if (is_string($border))
767 793
     {
768 794
         $x = $this->x;
769 795
         $y = $this->y;
770
-        if (strpos($border, 'L') !== false)
771
-            $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k);
772
-        if (strpos($border, 'T') !== false)
773
-            $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k);
774
-        if (strpos($border, 'R') !== false)
775
-            $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
776
-        if (strpos($border, 'B') !== false)
777
-            $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
796
+        if (strpos($border, 'L') !== false) {
797
+                    $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k);
798
+        }
799
+        if (strpos($border, 'T') !== false) {
800
+                    $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k);
801
+        }
802
+        if (strpos($border, 'R') !== false) {
803
+                    $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
804
+        }
805
+        if (strpos($border, 'B') !== false) {
806
+                    $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
807
+        }
778 808
     }
779 809
     if ($txt !== '')
780 810
     {
781
-        if ($align == 'R')
782
-            $dx = $w - $this->cMargin - $this->GetStringWidth($txt);
783
-        elseif ($align == 'C')
784
-            $dx = ($w - $this->GetStringWidth($txt)) / 2;
785
-        else
786
-            $dx = $this->cMargin;
787
-        if ($this->ColorFlag)
788
-            $s .= 'q '.$this->TextColor.' ';
811
+        if ($align == 'R') {
812
+                    $dx = $w - $this->cMargin - $this->GetStringWidth($txt);
813
+        } elseif ($align == 'C') {
814
+                    $dx = ($w - $this->GetStringWidth($txt)) / 2;
815
+        } else {
816
+                    $dx = $this->cMargin;
817
+        }
818
+        if ($this->ColorFlag) {
819
+                    $s .= 'q '.$this->TextColor.' ';
820
+        }
789 821
 
790 822
         // If multibyte, Tw has no effect - do word spacing using an adjustment before each space
791 823
         if ($this->ws && $this->unifontSubset) {
792
-            foreach ($this->UTF8StringToArray($txt) as $uni)
793
-                $this->CurrentFont['subset'][$uni] = $uni;
824
+            foreach ($this->UTF8StringToArray($txt) as $uni) {
825
+                            $this->CurrentFont['subset'][$uni] = $uni;
826
+            }
794 827
             $space = $this->_escape($this->UTF8ToUTF16BE(' ', false));
795 828
             $s .= sprintf('BT 0 Tw %.2F %.2F Td [', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k);
796 829
             $t = explode(' ', $txt);
@@ -806,55 +839,63 @@  discard block
 block discarded – undo
806 839
             }
807 840
             $s .= '] TJ';
808 841
             $s .= ' ET';
809
-        }
810
-        else {
842
+        } else {
811 843
             if ($this->unifontSubset)
812 844
             {
813 845
                 $txt2 = '('.$this->_escape($this->UTF8ToUTF16BE($txt, false)).')';
814
-                foreach ($this->UTF8StringToArray($txt) as $uni)
815
-                    $this->CurrentFont['subset'][$uni] = $uni;
846
+                foreach ($this->UTF8StringToArray($txt) as $uni) {
847
+                                    $this->CurrentFont['subset'][$uni] = $uni;
848
+                }
849
+            } else {
850
+                            $txt2 = '('.str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt))).')';
816 851
             }
817
-            else
818
-                $txt2 = '('.str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt))).')';
819 852
             $s .= sprintf('BT %.2F %.2F Td %s Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k, $txt2);
820 853
         }
821
-        if ($this->underline)
822
-            $s .= ' '.$this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt);
823
-        if ($this->ColorFlag)
824
-            $s .= ' Q';
825
-        if ($link)
826
-            $this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link);
854
+        if ($this->underline) {
855
+                    $s .= ' '.$this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt);
856
+        }
857
+        if ($this->ColorFlag) {
858
+                    $s .= ' Q';
859
+        }
860
+        if ($link) {
861
+                    $this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link);
862
+        }
863
+    }
864
+    if ($s) {
865
+            $this->_out($s);
827 866
     }
828
-    if ($s)
829
-        $this->_out($s);
830 867
     $this->lasth = $h;
831 868
     if ($ln > 0)
832 869
     {
833 870
         // Go to next line
834 871
         $this->y += $h;
835
-        if ($ln == 1)
836
-            $this->x = $this->lMargin;
872
+        if ($ln == 1) {
873
+                    $this->x = $this->lMargin;
874
+        }
875
+    } else {
876
+            $this->x += $w;
877
+    }
837 878
     }
838
-    else
839
-        $this->x += $w;
840
-}
841 879
 
842 880
 function MultiCell($w, $h, $txt, $border = 0, $align = 'J', $fill = false)
843 881
 {
844 882
     // Output text with automatic or explicit line breaks
845 883
     $cw = &$this->CurrentFont['cw'];
846
-    if ($w == 0)
847
-        $w = $this->w - $this->rMargin - $this->x;
884
+    if ($w == 0) {
885
+            $w = $this->w - $this->rMargin - $this->x;
886
+    }
848 887
     $wmax = ($w - 2 * $this->cMargin);
849 888
     $s = str_replace("\r", '', $txt);
850 889
     if ($this->unifontSubset) {
851 890
         $nb = mb_strlen($s, 'utf-8');
852
-        while ($nb > 0 && mb_substr($s, $nb - 1, 1, 'utf-8') == "\n") $nb--;
853
-    }
854
-    else {
855
-        $nb = strlen($s);
856
-        if ($nb > 0 && $s[$nb - 1] == "\n")
891
+        while ($nb > 0 && mb_substr($s, $nb - 1, 1, 'utf-8') == "\n") {
857 892
             $nb--;
893
+        }
894
+    } else {
895
+        $nb = strlen($s);
896
+        if ($nb > 0 && $s[$nb - 1] == "\n") {
897
+                    $nb--;
898
+        }
858 899
     }
859 900
     $b = 0;
860 901
     if ($border)
@@ -864,14 +905,15 @@  discard block
 block discarded – undo
864 905
             $border = 'LTRB';
865 906
             $b = 'LRT';
866 907
             $b2 = 'LR';
867
-        }
868
-        else
908
+        } else
869 909
         {
870 910
             $b2 = '';
871
-            if (strpos($border, 'L') !== false)
872
-                $b2 .= 'L';
873
-            if (strpos($border, 'R') !== false)
874
-                $b2 .= 'R';
911
+            if (strpos($border, 'L') !== false) {
912
+                            $b2 .= 'L';
913
+            }
914
+            if (strpos($border, 'R') !== false) {
915
+                            $b2 .= 'R';
916
+            }
875 917
             $b = (strpos($border, 'T') !== false) ? $b2.'T' : $b2;
876 918
         }
877 919
     }
@@ -886,8 +928,7 @@  discard block
 block discarded – undo
886 928
         // Get next character
887 929
         if ($this->unifontSubset) {
888 930
             $c = mb_substr($s, $i, 1, 'UTF-8');
889
-        }
890
-        else {
931
+        } else {
891 932
             $c = $s[$i];
892 933
         }
893 934
         if ($c == "\n")
@@ -900,8 +941,7 @@  discard block
 block discarded – undo
900 941
             }
901 942
             if ($this->unifontSubset) {
902 943
                 $this->Cell($w, $h, mb_substr($s, $j, $i - $j, 'UTF-8'), $b, 2, $align, $fill);
903
-            }
904
-            else {
944
+            } else {
905 945
                 $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
906 946
             }
907 947
             $i++;
@@ -910,8 +950,9 @@  discard block
 block discarded – undo
910 950
             $l = 0;
911 951
             $ns = 0;
912 952
             $nl++;
913
-            if ($border && $nl == 2)
914
-                $b = $b2;
953
+            if ($border && $nl == 2) {
954
+                            $b = $b2;
955
+            }
915 956
             continue;
916 957
         }
917 958
         if ($c == ' ')
@@ -921,16 +962,16 @@  discard block
 block discarded – undo
921 962
             $ns++;
922 963
         }
923 964
 
924
-        if ($this->unifontSubset) { $l += $this->GetStringWidth($c); }
925
-        else { $l += $cw[$c] * $this->FontSize / 1000; }
965
+        if ($this->unifontSubset) { $l += $this->GetStringWidth($c); } else { $l += $cw[$c] * $this->FontSize / 1000; }
926 966
 
927 967
         if ($l > $wmax)
928 968
         {
929 969
             // Automatic line break
930 970
             if ($sep == -1)
931 971
             {
932
-                if ($i == $j)
933
-                    $i++;
972
+                if ($i == $j) {
973
+                                    $i++;
974
+                }
934 975
                 if ($this->ws > 0)
935 976
                 {
936 977
                     $this->ws = 0;
@@ -938,12 +979,10 @@  discard block
 block discarded – undo
938 979
                 }
939 980
                 if ($this->unifontSubset) {
940 981
                     $this->Cell($w, $h, mb_substr($s, $j, $i - $j, 'UTF-8'), $b, 2, $align, $fill);
941
-                }
942
-                else {
982
+                } else {
943 983
                     $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
944 984
                 }
945
-            }
946
-            else
985
+            } else
947 986
             {
948 987
                 if ($align == 'J')
949 988
                 {
@@ -952,8 +991,7 @@  discard block
 block discarded – undo
952 991
                 }
953 992
                 if ($this->unifontSubset) {
954 993
                     $this->Cell($w, $h, mb_substr($s, $j, $sep - $j, 'UTF-8'), $b, 2, $align, $fill);
955
-                }
956
-                else {
994
+                } else {
957 995
                     $this->Cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill);
958 996
                 }
959 997
                 $i = $sep + 1;
@@ -963,11 +1001,12 @@  discard block
 block discarded – undo
963 1001
             $l = 0;
964 1002
             $ns = 0;
965 1003
             $nl++;
966
-            if ($border && $nl == 2)
967
-                $b = $b2;
1004
+            if ($border && $nl == 2) {
1005
+                            $b = $b2;
1006
+            }
1007
+        } else {
1008
+                    $i++;
968 1009
         }
969
-        else
970
-            $i++;
971 1010
     }
972 1011
     // Last chunk
973 1012
     if ($this->ws > 0)
@@ -975,12 +1014,12 @@  discard block
 block discarded – undo
975 1014
         $this->ws = 0;
976 1015
         $this->_out('0 Tw');
977 1016
     }
978
-    if ($border && strpos($border, 'B') !== false)
979
-        $b .= 'B';
1017
+    if ($border && strpos($border, 'B') !== false) {
1018
+            $b .= 'B';
1019
+    }
980 1020
     if ($this->unifontSubset) {
981 1021
         $this->Cell($w, $h, mb_substr($s, $j, $i - $j, 'UTF-8'), $b, 2, $align, $fill);
982
-    }
983
-    else {
1022
+    } else {
984 1023
         $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
985 1024
     }
986 1025
     $this->x = $this->lMargin;
@@ -1013,8 +1052,7 @@  discard block
 block discarded – undo
1013 1052
         // Get next character
1014 1053
         if ($this->unifontSubset) {
1015 1054
             $c = mb_substr($s, $i, 1, 'UTF-8');
1016
-        }
1017
-        else {
1055
+        } else {
1018 1056
             $c = $s[$i];
1019 1057
         }
1020 1058
         if ($c == "\n")
@@ -1022,8 +1060,7 @@  discard block
 block discarded – undo
1022 1060
             // Explicit line break
1023 1061
             if ($this->unifontSubset) {
1024 1062
                 $this->Cell($w, $h, mb_substr($s, $j, $i - $j, 'UTF-8'), 0, 2, '', 0, $link);
1025
-            }
1026
-            else {
1063
+            } else {
1027 1064
                 $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
1028 1065
             }
1029 1066
             $i++;
@@ -1039,11 +1076,11 @@  discard block
 block discarded – undo
1039 1076
             $nl++;
1040 1077
             continue;
1041 1078
         }
1042
-        if ($c == ' ')
1043
-            $sep = $i;
1079
+        if ($c == ' ') {
1080
+                    $sep = $i;
1081
+        }
1044 1082
 
1045
-        if ($this->unifontSubset) { $l += $this->GetStringWidth($c); }
1046
-        else { $l += $cw[$c] * $this->FontSize / 1000; }
1083
+        if ($this->unifontSubset) { $l += $this->GetStringWidth($c); } else { $l += $cw[$c] * $this->FontSize / 1000; }
1047 1084
 
1048 1085
         if ($l > $wmax)
1049 1086
         {
@@ -1061,21 +1098,19 @@  discard block
 block discarded – undo
1061 1098
                     $nl++;
1062 1099
                     continue;
1063 1100
                 }
1064
-                if ($i == $j)
1065
-                    $i++;
1101
+                if ($i == $j) {
1102
+                                    $i++;
1103
+                }
1066 1104
                 if ($this->unifontSubset) {
1067 1105
                     $this->Cell($w, $h, mb_substr($s, $j, $i - $j, 'UTF-8'), 0, 2, '', 0, $link);
1068
-                }
1069
-                else {
1106
+                } else {
1070 1107
                     $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
1071 1108
                 }
1072
-            }
1073
-            else
1109
+            } else
1074 1110
             {
1075 1111
                 if ($this->unifontSubset) {
1076 1112
                     $this->Cell($w, $h, mb_substr($s, $j, $sep - $j, 'UTF-8'), 0, 2, '', 0, $link);
1077
-                }
1078
-                else {
1113
+                } else {
1079 1114
                     $this->Cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', 0, $link);
1080 1115
                 }
1081 1116
                 $i = $sep + 1;
@@ -1199,11 +1234,12 @@  discard block
 block discarded – undo
1199 1234
 function SetX($x)
1200 1235
 {
1201 1236
     // Set x position
1202
-    if ($x >= 0)
1203
-        $this->x = $x;
1204
-    else
1205
-        $this->x = $this->w + $x;
1206
-}
1237
+    if ($x >= 0) {
1238
+            $this->x = $x;
1239
+    } else {
1240
+            $this->x = $this->w + $x;
1241
+    }
1242
+    }
1207 1243
 
1208 1244
 function GetY()
1209 1245
 {
@@ -1215,11 +1251,12 @@  discard block
 block discarded – undo
1215 1251
 {
1216 1252
     // Set y position and reset x
1217 1253
     $this->x = $this->lMargin;
1218
-    if ($y >= 0)
1219
-        $this->y = $y;
1220
-    else
1221
-        $this->y = $this->h + $y;
1222
-}
1254
+    if ($y >= 0) {
1255
+            $this->y = $y;
1256
+    } else {
1257
+            $this->y = $this->h + $y;
1258
+    }
1259
+    }
1223 1260
 
1224 1261
 function SetXY($x, $y)
1225 1262
 {
@@ -1231,8 +1268,9 @@  discard block
 block discarded – undo
1231 1268
 function Output($name = '', $dest = '')
1232 1269
 {
1233 1270
     // Output PDF to some destination
1234
-    if ($this->state < 3)
1235
-        $this->Close();
1271
+    if ($this->state < 3) {
1272
+            $this->Close();
1273
+    }
1236 1274
     $dest = strtoupper($dest);
1237 1275
     if ($dest == '')
1238 1276
     {
@@ -1271,8 +1309,9 @@  discard block
 block discarded – undo
1271 1309
         case 'F':
1272 1310
             // Save to local file
1273 1311
             $f = fopen($name, 'wb');
1274
-            if (!$f)
1275
-                $this->Error('Unable to create output file: '.$name);
1312
+            if (!$f) {
1313
+                            $this->Error('Unable to create output file: '.$name);
1314
+            }
1276 1315
             fwrite($f, $this->buffer, strlen($this->buffer));
1277 1316
             fclose($f);
1278 1317
             break;
@@ -1293,18 +1332,22 @@  discard block
 block discarded – undo
1293 1332
 function _dochecks()
1294 1333
 {
1295 1334
     // Check availability of %F
1296
-    if (sprintf('%.1F', 1.0) != '1.0')
1297
-        $this->Error('This version of PHP is not supported');
1335
+    if (sprintf('%.1F', 1.0) != '1.0') {
1336
+            $this->Error('This version of PHP is not supported');
1337
+    }
1298 1338
     // Check availability of mbstring
1299
-    if (!function_exists('mb_strlen'))
1300
-        $this->Error('mbstring extension is not available');
1339
+    if (!function_exists('mb_strlen')) {
1340
+            $this->Error('mbstring extension is not available');
1341
+    }
1301 1342
     // Check mbstring overloading
1302
-    if (ini_get('mbstring.func_overload') & 2)
1303
-        $this->Error('mbstring overloading must be disabled');
1343
+    if (ini_get('mbstring.func_overload') & 2) {
1344
+            $this->Error('mbstring overloading must be disabled');
1345
+    }
1304 1346
     // Ensure runtime magic quotes are disabled
1305
-    if (get_magic_quotes_runtime())
1306
-        @set_magic_quotes_runtime(0);
1307
-}
1347
+    if (get_magic_quotes_runtime()) {
1348
+            @set_magic_quotes_runtime(0);
1349
+    }
1350
+    }
1308 1351
 
1309 1352
 function _getfontpath()
1310 1353
 {
@@ -1315,8 +1358,9 @@  discard block
 block discarded – undo
1315 1358
 {
1316 1359
     if (PHP_SAPI != 'cli')
1317 1360
     {
1318
-        if (headers_sent($file, $line))
1319
-            $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
1361
+        if (headers_sent($file, $line)) {
1362
+                    $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
1363
+        }
1320 1364
     }
1321 1365
     if (ob_get_length())
1322 1366
     {
@@ -1336,17 +1380,18 @@  discard block
 block discarded – undo
1336 1380
     if (is_string($size))
1337 1381
     {
1338 1382
         $size = strtolower($size);
1339
-        if (!isset($this->StdPageSizes[$size]))
1340
-            $this->Error('Unknown page size: '.$size);
1383
+        if (!isset($this->StdPageSizes[$size])) {
1384
+                    $this->Error('Unknown page size: '.$size);
1385
+        }
1341 1386
         $a = $this->StdPageSizes[$size];
1342 1387
         return array($a[0] / $this->k, $a[1] / $this->k);
1343
-    }
1344
-    else
1388
+    } else
1345 1389
     {
1346
-        if ($size[0] > $size[1])
1347
-            return array($size[1], $size[0]);
1348
-        else
1349
-            return $size;
1390
+        if ($size[0] > $size[1]) {
1391
+                    return array($size[1], $size[0]);
1392
+        } else {
1393
+                    return $size;
1394
+        }
1350 1395
     }
1351 1396
 }
1352 1397
 
@@ -1363,14 +1408,16 @@  discard block
 block discarded – undo
1363 1408
     $this->y = $this->tMargin;
1364 1409
     $this->FontFamily = '';
1365 1410
     // Check page size and orientation
1366
-    if ($orientation == '')
1367
-        $orientation = $this->DefOrientation;
1368
-    else
1369
-        $orientation = strtoupper($orientation[0]);
1370
-    if ($size == '')
1371
-        $size = $this->DefPageSize;
1372
-    else
1373
-        $size = $this->_getpagesize($size);
1411
+    if ($orientation == '') {
1412
+            $orientation = $this->DefOrientation;
1413
+    } else {
1414
+            $orientation = strtoupper($orientation[0]);
1415
+    }
1416
+    if ($size == '') {
1417
+            $size = $this->DefPageSize;
1418
+    } else {
1419
+            $size = $this->_getpagesize($size);
1420
+    }
1374 1421
     if ($orientation != $this->CurOrientation || $size[0] != $this->CurPageSize[0] || $size[1] != $this->CurPageSize[1])
1375 1422
     {
1376 1423
         // New size or orientation
@@ -1389,9 +1436,10 @@  discard block
 block discarded – undo
1389 1436
         $this->CurOrientation = $orientation;
1390 1437
         $this->CurPageSize = $size;
1391 1438
     }
1392
-    if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1])
1393
-        $this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
1394
-}
1439
+    if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1]) {
1440
+            $this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
1441
+    }
1442
+    }
1395 1443
 
1396 1444
 function _endpage()
1397 1445
 {
@@ -1406,8 +1454,9 @@  discard block
 block discarded – undo
1406 1454
     // Load a font definition file from the font directory
1407 1455
     include($this->fontpath.$font);
1408 1456
     $a = get_defined_vars();
1409
-    if (!isset($a['name']))
1410
-        $this->Error('Could not include font definition file');
1457
+    if (!isset($a['name'])) {
1458
+            $this->Error('Could not include font definition file');
1459
+    }
1411 1460
     return $a;
1412 1461
 }
1413 1462
 
@@ -1443,15 +1492,13 @@  discard block
 block discarded – undo
1443 1492
             $c3 = ord($s[$i++]);
1444 1493
             $res .= chr((($c1 & 0x0F) << 4) + (($c2 & 0x3C) >> 2));
1445 1494
             $res .= chr((($c2 & 0x03) << 6) + ($c3 & 0x3F));
1446
-        }
1447
-        elseif ($c1 >= 192)
1495
+        } elseif ($c1 >= 192)
1448 1496
         {
1449 1497
             // 2-byte character
1450 1498
             $c2 = ord($s[$i++]);
1451 1499
             $res .= chr(($c1 & 0x1C) >> 2);
1452 1500
             $res .= chr((($c1 & 0x03) << 6) + ($c2 & 0x3F));
1453
-        }
1454
-        else
1501
+        } else
1455 1502
         {
1456 1503
             // Single-byte character
1457 1504
             $res .= "\0".chr($c1);
@@ -1473,16 +1520,19 @@  discard block
 block discarded – undo
1473 1520
 {
1474 1521
     // Extract info from a JPEG file
1475 1522
     $a = getimagesize($file);
1476
-    if (!$a)
1477
-        $this->Error('Missing or incorrect image file: '.$file);
1478
-    if ($a[2] != 2)
1479
-        $this->Error('Not a JPEG file: '.$file);
1480
-    if (!isset($a['channels']) || $a['channels'] == 3)
1481
-        $colspace = 'DeviceRGB';
1482
-    elseif ($a['channels'] == 4)
1483
-        $colspace = 'DeviceCMYK';
1484
-    else
1485
-        $colspace = 'DeviceGray';
1523
+    if (!$a) {
1524
+            $this->Error('Missing or incorrect image file: '.$file);
1525
+    }
1526
+    if ($a[2] != 2) {
1527
+            $this->Error('Not a JPEG file: '.$file);
1528
+    }
1529
+    if (!isset($a['channels']) || $a['channels'] == 3) {
1530
+            $colspace = 'DeviceRGB';
1531
+    } elseif ($a['channels'] == 4) {
1532
+            $colspace = 'DeviceCMYK';
1533
+    } else {
1534
+            $colspace = 'DeviceGray';
1535
+    }
1486 1536
     $bpc = isset($a['bits']) ? $a['bits'] : 8;
1487 1537
     $data = file_get_contents($file);
1488 1538
     return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
@@ -1495,8 +1545,9 @@  discard block
 block discarded – undo
1495 1545
 {
1496 1546
     // Extract info from a PNG file
1497 1547
     $f = fopen($file, 'rb');
1498
-    if (!$f)
1499
-        $this->Error('Can\'t open image file: '.$file);
1548
+    if (!$f) {
1549
+            $this->Error('Can\'t open image file: '.$file);
1550
+    }
1500 1551
     $info = $this->_parsepngstream($f, $file);
1501 1552
     fclose($f);
1502 1553
     return $info;
@@ -1505,33 +1556,40 @@  discard block
 block discarded – undo
1505 1556
 function _parsepngstream($f, $file)
1506 1557
 {
1507 1558
     // Check signature
1508
-    if ($this->_readstream($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1509
-        $this->Error('Not a PNG file: '.$file);
1559
+    if ($this->_readstream($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
1560
+            $this->Error('Not a PNG file: '.$file);
1561
+    }
1510 1562
 
1511 1563
     // Read header chunk
1512 1564
     $this->_readstream($f, 4);
1513
-    if ($this->_readstream($f, 4) != 'IHDR')
1514
-        $this->Error('Incorrect PNG file: '.$file);
1565
+    if ($this->_readstream($f, 4) != 'IHDR') {
1566
+            $this->Error('Incorrect PNG file: '.$file);
1567
+    }
1515 1568
     $w = $this->_readint($f);
1516 1569
     $h = $this->_readint($f);
1517 1570
     $bpc = ord($this->_readstream($f, 1));
1518
-    if ($bpc > 8)
1519
-        $this->Error('16-bit depth not supported: '.$file);
1571
+    if ($bpc > 8) {
1572
+            $this->Error('16-bit depth not supported: '.$file);
1573
+    }
1520 1574
     $ct = ord($this->_readstream($f, 1));
1521
-    if ($ct == 0 || $ct == 4)
1522
-        $colspace = 'DeviceGray';
1523
-    elseif ($ct == 2 || $ct == 6)
1524
-        $colspace = 'DeviceRGB';
1525
-    elseif ($ct == 3)
1526
-        $colspace = 'Indexed';
1527
-    else
1528
-        $this->Error('Unknown color type: '.$file);
1529
-    if (ord($this->_readstream($f, 1)) != 0)
1530
-        $this->Error('Unknown compression method: '.$file);
1531
-    if (ord($this->_readstream($f, 1)) != 0)
1532
-        $this->Error('Unknown filter method: '.$file);
1533
-    if (ord($this->_readstream($f, 1)) != 0)
1534
-        $this->Error('Interlacing not supported: '.$file);
1575
+    if ($ct == 0 || $ct == 4) {
1576
+            $colspace = 'DeviceGray';
1577
+    } elseif ($ct == 2 || $ct == 6) {
1578
+            $colspace = 'DeviceRGB';
1579
+    } elseif ($ct == 3) {
1580
+            $colspace = 'Indexed';
1581
+    } else {
1582
+            $this->Error('Unknown color type: '.$file);
1583
+    }
1584
+    if (ord($this->_readstream($f, 1)) != 0) {
1585
+            $this->Error('Unknown compression method: '.$file);
1586
+    }
1587
+    if (ord($this->_readstream($f, 1)) != 0) {
1588
+            $this->Error('Unknown filter method: '.$file);
1589
+    }
1590
+    if (ord($this->_readstream($f, 1)) != 0) {
1591
+            $this->Error('Interlacing not supported: '.$file);
1592
+    }
1535 1593
     $this->_readstream($f, 4);
1536 1594
     $dp = '/Predictor 15 /Colors '.($colspace == 'DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w;
1537 1595
 
@@ -1548,44 +1606,45 @@  discard block
 block discarded – undo
1548 1606
             // Read palette
1549 1607
             $pal = $this->_readstream($f, $n);
1550 1608
             $this->_readstream($f, 4);
1551
-        }
1552
-        elseif ($type == 'tRNS')
1609
+        } elseif ($type == 'tRNS')
1553 1610
         {
1554 1611
             // Read transparency info
1555 1612
             $t = $this->_readstream($f, $n);
1556
-            if ($ct == 0)
1557
-                $trns = array(ord(substr($t, 1, 1)));
1558
-            elseif ($ct == 2)
1559
-                $trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1)));
1560
-            else
1613
+            if ($ct == 0) {
1614
+                            $trns = array(ord(substr($t, 1, 1)));
1615
+            } elseif ($ct == 2) {
1616
+                            $trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1)));
1617
+            } else
1561 1618
             {
1562 1619
                 $pos = strpos($t, chr(0));
1563
-                if ($pos !== false)
1564
-                    $trns = array($pos);
1620
+                if ($pos !== false) {
1621
+                                    $trns = array($pos);
1622
+                }
1565 1623
             }
1566 1624
             $this->_readstream($f, 4);
1567
-        }
1568
-        elseif ($type == 'IDAT')
1625
+        } elseif ($type == 'IDAT')
1569 1626
         {
1570 1627
             // Read image data block
1571 1628
             $data .= $this->_readstream($f, $n);
1572 1629
             $this->_readstream($f, 4);
1630
+        } elseif ($type == 'IEND') {
1631
+                    break;
1632
+        } else {
1633
+                    $this->_readstream($f, $n + 4);
1573 1634
         }
1574
-        elseif ($type == 'IEND')
1575
-            break;
1576
-        else
1577
-            $this->_readstream($f, $n + 4);
1578 1635
     }
1579 1636
     while ($n);
1580 1637
 
1581
-    if ($colspace == 'Indexed' && empty($pal))
1582
-        $this->Error('Missing palette in '.$file);
1638
+    if ($colspace == 'Indexed' && empty($pal)) {
1639
+            $this->Error('Missing palette in '.$file);
1640
+    }
1583 1641
     $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns);
1584 1642
     if ($ct >= 4)
1585 1643
     {
1586 1644
         // Extract alpha channel
1587
-        if (!function_exists('gzuncompress'))
1588
-            $this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
1645
+        if (!function_exists('gzuncompress')) {
1646
+                    $this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
1647
+        }
1589 1648
         $data = gzuncompress($data);
1590 1649
         $color = '';
1591 1650
         $alpha = '';
@@ -1619,8 +1678,9 @@  discard block
 block discarded – undo
1619 1678
         unset($data);
1620 1679
         $data = gzcompress($color);
1621 1680
         $info['smask'] = gzcompress($alpha);
1622
-        if ($this->PDFVersion < '1.4')
1623
-            $this->PDFVersion = '1.4';
1681
+        if ($this->PDFVersion < '1.4') {
1682
+                    $this->PDFVersion = '1.4';
1683
+        }
1624 1684
     }
1625 1685
     $info['data'] = $data;
1626 1686
     return $info;
@@ -1633,13 +1693,15 @@  discard block
 block discarded – undo
1633 1693
     while ($n > 0 && !feof($f))
1634 1694
     {
1635 1695
         $s = fread($f, $n);
1636
-        if ($s === false)
1637
-            $this->Error('Error while reading stream');
1696
+        if ($s === false) {
1697
+                    $this->Error('Error while reading stream');
1698
+        }
1638 1699
         $n -= strlen($s);
1639 1700
         $res .= $s;
1640 1701
     }
1641
-    if ($n > 0)
1642
-        $this->Error('Unexpected end of stream');
1702
+    if ($n > 0) {
1703
+            $this->Error('Unexpected end of stream');
1704
+    }
1643 1705
     return $res;
1644 1706
 }
1645 1707
 
@@ -1653,13 +1715,16 @@  discard block
 block discarded – undo
1653 1715
 function _parsegif($file)
1654 1716
 {
1655 1717
     // Extract info from a GIF file (via PNG conversion)
1656
-    if (!function_exists('imagepng'))
1657
-        $this->Error('GD extension is required for GIF support');
1658
-    if (!function_exists('imagecreatefromgif'))
1659
-        $this->Error('GD has no GIF read support');
1718
+    if (!function_exists('imagepng')) {
1719
+            $this->Error('GD extension is required for GIF support');
1720
+    }
1721
+    if (!function_exists('imagecreatefromgif')) {
1722
+            $this->Error('GD has no GIF read support');
1723
+    }
1660 1724
     $im = imagecreatefromgif($file);
1661
-    if (!$im)
1662
-        $this->Error('Missing or incorrect image file: '.$file);
1725
+    if (!$im) {
1726
+            $this->Error('Missing or incorrect image file: '.$file);
1727
+    }
1663 1728
     imageinterlace($im, 0);
1664 1729
     $f = @fopen('php://temp', 'rb+');
1665 1730
     if ($f)
@@ -1673,15 +1738,16 @@  discard block
 block discarded – undo
1673 1738
         rewind($f);
1674 1739
         $info = $this->_parsepngstream($f, $file);
1675 1740
         fclose($f);
1676
-    }
1677
-    else
1741
+    } else
1678 1742
     {
1679 1743
         // Use temporary file
1680 1744
         $tmp = tempnam('.', 'gif');
1681
-        if (!$tmp)
1682
-            $this->Error('Unable to create a temporary file');
1683
-        if (!imagepng($im, $tmp))
1684
-            $this->Error('Error while saving to temporary file');
1745
+        if (!$tmp) {
1746
+                    $this->Error('Unable to create a temporary file');
1747
+        }
1748
+        if (!imagepng($im, $tmp)) {
1749
+                    $this->Error('Error while saving to temporary file');
1750
+        }
1685 1751
         imagedestroy($im);
1686 1752
         $info = $this->_parsepng($tmp);
1687 1753
         unlink($tmp);
@@ -1707,11 +1773,12 @@  discard block
 block discarded – undo
1707 1773
 function _out($s)
1708 1774
 {
1709 1775
     // Add a line to the document
1710
-    if ($this->state == 2)
1711
-        $this->pages[$this->page] .= $s."\n";
1712
-    else
1713
-        $this->buffer .= $s."\n";
1714
-}
1776
+    if ($this->state == 2) {
1777
+            $this->pages[$this->page] .= $s."\n";
1778
+    } else {
1779
+            $this->buffer .= $s."\n";
1780
+    }
1781
+    }
1715 1782
 
1716 1783
 function _putpages()
1717 1784
 {
@@ -1721,18 +1788,19 @@  discard block
 block discarded – undo
1721 1788
         // Replace number of pages in fonts using subsets
1722 1789
         $alias = $this->UTF8ToUTF16BE($this->AliasNbPages, false);
1723 1790
         $r = $this->UTF8ToUTF16BE("$nb", false);
1724
-        for ($n = 1; $n <= $nb; $n++)
1725
-            $this->pages[$n] = str_replace($alias, $r, $this->pages[$n]);
1791
+        for ($n = 1; $n <= $nb; $n++) {
1792
+                    $this->pages[$n] = str_replace($alias, $r, $this->pages[$n]);
1793
+        }
1726 1794
         // Now repeat for no pages in non-subset fonts
1727
-        for ($n = 1; $n <= $nb; $n++)
1728
-            $this->pages[$n] = str_replace($this->AliasNbPages, $nb, $this->pages[$n]);
1795
+        for ($n = 1; $n <= $nb; $n++) {
1796
+                    $this->pages[$n] = str_replace($this->AliasNbPages, $nb, $this->pages[$n]);
1797
+        }
1729 1798
     }
1730 1799
     if ($this->DefOrientation == 'P')
1731 1800
     {
1732 1801
         $wPt = $this->DefPageSize[0] * $this->k;
1733 1802
         $hPt = $this->DefPageSize[1] * $this->k;
1734
-    }
1735
-    else
1803
+    } else
1736 1804
     {
1737 1805
         $wPt = $this->DefPageSize[1] * $this->k;
1738 1806
         $hPt = $this->DefPageSize[0] * $this->k;
@@ -1744,8 +1812,9 @@  discard block
 block discarded – undo
1744 1812
         $this->_newobj();
1745 1813
         $this->_out('<</Type /Page');
1746 1814
         $this->_out('/Parent 1 0 R');
1747
-        if (isset($this->PageSizes[$n]))
1748
-            $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageSizes[$n][0], $this->PageSizes[$n][1]));
1815
+        if (isset($this->PageSizes[$n])) {
1816
+                    $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageSizes[$n][0], $this->PageSizes[$n][1]));
1817
+        }
1749 1818
         $this->_out('/Resources 2 0 R');
1750 1819
         if (isset($this->PageLinks[$n]))
1751 1820
         {
@@ -1755,9 +1824,9 @@  discard block
 block discarded – undo
1755 1824
             {
1756 1825
                 $rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]);
1757 1826
                 $annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1758
-                if (is_string($pl[4]))
1759
-                    $annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1760
-                else
1827
+                if (is_string($pl[4])) {
1828
+                                    $annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1829
+                } else
1761 1830
                 {
1762 1831
                     $l = $this->links[$pl[4]];
1763 1832
                     $h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
@@ -1766,8 +1835,9 @@  discard block
 block discarded – undo
1766 1835
             }
1767 1836
             $this->_out($annots.']');
1768 1837
         }
1769
-        if ($this->PDFVersion > '1.3')
1770
-            $this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
1838
+        if ($this->PDFVersion > '1.3') {
1839
+                    $this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
1840
+        }
1771 1841
         $this->_out('/Contents '.($this->n + 1).' 0 R>>');
1772 1842
         $this->_out('endobj');
1773 1843
         // Page content
@@ -1889,18 +1959,21 @@  discard block
 block discarded – undo
1889 1959
             $this->_newobj();
1890 1960
             $cw = &$font['cw'];
1891 1961
             $s = '[';
1892
-            for ($i = 32; $i <= 255; $i++)
1893
-                $s .= $cw[chr($i)].' ';
1962
+            for ($i = 32; $i <= 255; $i++) {
1963
+                            $s .= $cw[chr($i)].' ';
1964
+            }
1894 1965
             $this->_out($s.']');
1895 1966
             $this->_out('endobj');
1896 1967
             // Descriptor
1897 1968
             $this->_newobj();
1898 1969
             $s = '<</Type /FontDescriptor /FontName /'.$name;
1899
-            foreach ($font['desc'] as $k=>$v)
1900
-                $s .= ' /'.$k.' '.$v;
1970
+            foreach ($font['desc'] as $k=>$v) {
1971
+                            $s .= ' /'.$k.' '.$v;
1972
+            }
1901 1973
             $file = $font['file'];
1902
-            if ($file)
1903
-                $s .= ' /FontFile'.($type == 'Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
1974
+            if ($file) {
1975
+                            $s .= ' /FontFile'.($type == 'Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
1976
+            }
1904 1977
             $this->_out($s.'>>');
1905 1978
             $this->_out('endobj');
1906 1979
         }
@@ -2019,14 +2092,14 @@  discard block
 block discarded – undo
2019 2092
             $this->_putstream($fontstream);
2020 2093
             $this->_out('endobj');
2021 2094
             unset($ttf);
2022
-        }
2023
-        else
2095
+        } else
2024 2096
         {
2025 2097
             // Allow for additional types
2026 2098
             $this->fonts[$k]['n'] = $this->n + 1;
2027 2099
             $mtd = '_put'.strtolower($type);
2028
-            if (!method_exists($this, $mtd))
2029
-                $this->Error('Unsupported font type: '.$type);
2100
+            if (!method_exists($this, $mtd)) {
2101
+                            $this->Error('Unsupported font type: '.$type);
2102
+            }
2030 2103
             $this->$mtd($font);
2031 2104
         }
2032 2105
     }
@@ -2058,8 +2131,7 @@  discard block
 block discarded – undo
2058 2131
                 $cw127 .= '$rangeid='.$rangeid.";\n";
2059 2132
                 $cw127 .= '$prevcid='.$prevcid.";\n";
2060 2133
                 $cw127 .= '$prevwidth='.$prevwidth.";\n";
2061
-                if ($interval) { $cw127 .= '$interval=true'.";\n"; }
2062
-                else { $cw127 .= '$interval=false'.";\n"; }
2134
+                if ($interval) { $cw127 .= '$interval=true'.";\n"; } else { $cw127 .= '$interval=false'.";\n"; }
2063 2135
                 $cw127 .= '$range='.var_export($range, true).";\n";
2064 2136
                 $cw127 .= "?>";
2065 2137
                 fwrite($fh, $cw127, strlen($cw127));
@@ -2113,21 +2185,17 @@  discard block
 block discarded – undo
2113 2185
             if (isset($range[$k]['interval'])) { unset($range[$k]['interval']); }
2114 2186
             $range[$prevk] = array_merge($range[$prevk], $range[$k]);
2115 2187
             unset($range[$k]);
2116
-        }
2117
-        else { $prevk = $k; }
2188
+        } else { $prevk = $k; }
2118 2189
         $nextk = $k + $cws;
2119 2190
         if (isset($ws['interval'])) {
2120
-            if ($cws > 3) { $prevint = true; }
2121
-            else { $prevint = false; }
2191
+            if ($cws > 3) { $prevint = true; } else { $prevint = false; }
2122 2192
             unset($range[$k]['interval']);
2123 2193
             --$nextk;
2124
-        }
2125
-        else { $prevint = false; }
2194
+        } else { $prevint = false; }
2126 2195
     }
2127 2196
     $w = '';
2128 2197
     foreach ($range as $k => $ws) {
2129
-        if (count(array_count_values($ws)) == 1) { $w .= ' '.$k.' '.($k + count($ws) - 1).' '.$ws[0]; }
2130
-        else { $w .= ' '.$k.' [ '.implode(' ', $ws).' ]'."\n"; }
2198
+        if (count(array_count_values($ws)) == 1) { $w .= ' '.$k.' '.($k + count($ws) - 1).' '.$ws[0]; } else { $w .= ' '.$k.' [ '.implode(' ', $ws).' ]'."\n"; }
2131 2199
     }
2132 2200
     $this->_out('/W ['.$w.' ]');
2133 2201
 }
@@ -2150,28 +2218,33 @@  discard block
 block discarded – undo
2150 2218
     $this->_out('/Subtype /Image');
2151 2219
     $this->_out('/Width '.$info['w']);
2152 2220
     $this->_out('/Height '.$info['h']);
2153
-    if ($info['cs'] == 'Indexed')
2154
-        $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal']) / 3 - 1).' '.($this->n + 1).' 0 R]');
2155
-    else
2221
+    if ($info['cs'] == 'Indexed') {
2222
+            $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal']) / 3 - 1).' '.($this->n + 1).' 0 R]');
2223
+    } else
2156 2224
     {
2157 2225
         $this->_out('/ColorSpace /'.$info['cs']);
2158
-        if ($info['cs'] == 'DeviceCMYK')
2159
-            $this->_out('/Decode [1 0 1 0 1 0 1 0]');
2226
+        if ($info['cs'] == 'DeviceCMYK') {
2227
+                    $this->_out('/Decode [1 0 1 0 1 0 1 0]');
2228
+        }
2160 2229
     }
2161 2230
     $this->_out('/BitsPerComponent '.$info['bpc']);
2162
-    if (isset($info['f']))
2163
-        $this->_out('/Filter /'.$info['f']);
2164
-    if (isset($info['dp']))
2165
-        $this->_out('/DecodeParms <<'.$info['dp'].'>>');
2231
+    if (isset($info['f'])) {
2232
+            $this->_out('/Filter /'.$info['f']);
2233
+    }
2234
+    if (isset($info['dp'])) {
2235
+            $this->_out('/DecodeParms <<'.$info['dp'].'>>');
2236
+    }
2166 2237
     if (isset($info['trns']) && is_array($info['trns']))
2167 2238
     {
2168 2239
         $trns = '';
2169
-        for ($i = 0; $i < count($info['trns']); $i++)
2170
-            $trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
2240
+        for ($i = 0; $i < count($info['trns']); $i++) {
2241
+                    $trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
2242
+        }
2171 2243
         $this->_out('/Mask ['.$trns.']');
2172 2244
     }
2173
-    if (isset($info['smask']))
2174
-        $this->_out('/SMask '.($this->n + 1).' 0 R');
2245
+    if (isset($info['smask'])) {
2246
+            $this->_out('/SMask '.($this->n + 1).' 0 R');
2247
+    }
2175 2248
     $this->_out('/Length '.strlen($info['data']).'>>');
2176 2249
     $this->_putstream($info['data']);
2177 2250
     $this->_out('endobj');
@@ -2196,9 +2269,10 @@  discard block
 block discarded – undo
2196 2269
 
2197 2270
 function _putxobjectdict()
2198 2271
 {
2199
-    foreach ($this->images as $image)
2200
-        $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
2201
-}
2272
+    foreach ($this->images as $image) {
2273
+            $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
2274
+    }
2275
+    }
2202 2276
 
2203 2277
 function _putresourcedict()
2204 2278
 {
@@ -2229,16 +2303,21 @@  discard block
 block discarded – undo
2229 2303
 function _putinfo()
2230 2304
 {
2231 2305
     $this->_out('/Producer '.$this->_textstring('tFPDF '.tFPDF_VERSION));
2232
-    if (!empty($this->title))
2233
-        $this->_out('/Title '.$this->_textstring($this->title));
2234
-    if (!empty($this->subject))
2235
-        $this->_out('/Subject '.$this->_textstring($this->subject));
2236
-    if (!empty($this->author))
2237
-        $this->_out('/Author '.$this->_textstring($this->author));
2238
-    if (!empty($this->keywords))
2239
-        $this->_out('/Keywords '.$this->_textstring($this->keywords));
2240
-    if (!empty($this->creator))
2241
-        $this->_out('/Creator '.$this->_textstring($this->creator));
2306
+    if (!empty($this->title)) {
2307
+            $this->_out('/Title '.$this->_textstring($this->title));
2308
+    }
2309
+    if (!empty($this->subject)) {
2310
+            $this->_out('/Subject '.$this->_textstring($this->subject));
2311
+    }
2312
+    if (!empty($this->author)) {
2313
+            $this->_out('/Author '.$this->_textstring($this->author));
2314
+    }
2315
+    if (!empty($this->keywords)) {
2316
+            $this->_out('/Keywords '.$this->_textstring($this->keywords));
2317
+    }
2318
+    if (!empty($this->creator)) {
2319
+            $this->_out('/Creator '.$this->_textstring($this->creator));
2320
+    }
2242 2321
     $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
2243 2322
 }
2244 2323
 
@@ -2246,21 +2325,23 @@  discard block
 block discarded – undo
2246 2325
 {
2247 2326
     $this->_out('/Type /Catalog');
2248 2327
     $this->_out('/Pages 1 0 R');
2249
-    if ($this->ZoomMode == 'fullpage')
2250
-        $this->_out('/OpenAction [3 0 R /Fit]');
2251
-    elseif ($this->ZoomMode == 'fullwidth')
2252
-        $this->_out('/OpenAction [3 0 R /FitH null]');
2253
-    elseif ($this->ZoomMode == 'real')
2254
-        $this->_out('/OpenAction [3 0 R /XYZ null null 1]');
2255
-    elseif (!is_string($this->ZoomMode))
2256
-        $this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F', $this->ZoomMode / 100).']');
2257
-    if ($this->LayoutMode == 'single')
2258
-        $this->_out('/PageLayout /SinglePage');
2259
-    elseif ($this->LayoutMode == 'continuous')
2260
-        $this->_out('/PageLayout /OneColumn');
2261
-    elseif ($this->LayoutMode == 'two')
2262
-        $this->_out('/PageLayout /TwoColumnLeft');
2263
-}
2328
+    if ($this->ZoomMode == 'fullpage') {
2329
+            $this->_out('/OpenAction [3 0 R /Fit]');
2330
+    } elseif ($this->ZoomMode == 'fullwidth') {
2331
+            $this->_out('/OpenAction [3 0 R /FitH null]');
2332
+    } elseif ($this->ZoomMode == 'real') {
2333
+            $this->_out('/OpenAction [3 0 R /XYZ null null 1]');
2334
+    } elseif (!is_string($this->ZoomMode)) {
2335
+            $this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F', $this->ZoomMode / 100).']');
2336
+    }
2337
+    if ($this->LayoutMode == 'single') {
2338
+            $this->_out('/PageLayout /SinglePage');
2339
+    } elseif ($this->LayoutMode == 'continuous') {
2340
+            $this->_out('/PageLayout /OneColumn');
2341
+    } elseif ($this->LayoutMode == 'two') {
2342
+            $this->_out('/PageLayout /TwoColumnLeft');
2343
+    }
2344
+    }
2264 2345
 
2265 2346
 function _putheader()
2266 2347
 {
@@ -2296,8 +2377,9 @@  discard block
 block discarded – undo
2296 2377
     $this->_out('xref');
2297 2378
     $this->_out('0 '.($this->n + 1));
2298 2379
     $this->_out('0000000000 65535 f ');
2299
-    for ($i = 1; $i <= $this->n; $i++)
2300
-        $this->_out(sprintf('%010d 00000 n ', $this->offsets[$i]));
2380
+    for ($i = 1; $i <= $this->n; $i++) {
2381
+            $this->_out(sprintf('%010d 00000 n ', $this->offsets[$i]));
2382
+    }
2301 2383
     // Trailer
2302 2384
     $this->_out('trailer');
2303 2385
     $this->_out('<<');
@@ -2327,18 +2409,19 @@  discard block
 block discarded – undo
2327 2409
     for ($i = 0; $i < $len; $i++) {
2328 2410
     $uni = -1;
2329 2411
         $h = ord($str[$i]);
2330
-        if ( $h <= 0x7F )
2331
-            $uni = $h;
2332
-        elseif ( $h >= 0xC2 ) {
2333
-            if ( ($h <= 0xDF) && ($i < $len -1) )
2334
-            $uni = ($h & 0x1F) << 6 | (ord($str[++$i]) & 0x3F);
2335
-            elseif ( ($h <= 0xEF) && ($i < $len -2) )
2336
-            $uni = ($h & 0x0F) << 12 | (ord($str[++$i]) & 0x3F) << 6
2412
+        if ( $h <= 0x7F ) {
2413
+                    $uni = $h;
2414
+        } elseif ( $h >= 0xC2 ) {
2415
+            if ( ($h <= 0xDF) && ($i < $len -1) ) {
2416
+                        $uni = ($h & 0x1F) << 6 | (ord($str[++$i]) & 0x3F);
2417
+            } elseif ( ($h <= 0xEF) && ($i < $len -2) ) {
2418
+                        $uni = ($h & 0x0F) << 12 | (ord($str[++$i]) & 0x3F) << 6
2337 2419
                                         | (ord($str[++$i]) & 0x3F);
2338
-            elseif ( ($h <= 0xF4) && ($i < $len -3) )
2339
-            $uni = ($h & 0x0F) << 18 | (ord($str[++$i]) & 0x3F) << 12
2420
+            } elseif ( ($h <= 0xF4) && ($i < $len -3) ) {
2421
+                        $uni = ($h & 0x0F) << 18 | (ord($str[++$i]) & 0x3F) << 12
2340 2422
                                         | (ord($str[++$i]) & 0x3F) << 6
2341 2423
                                         | (ord($str[++$i]) & 0x3F);
2424
+            }
2342 2425
         }
2343 2426
     if ($uni >= 0) {
2344 2427
         $out[] = $uni;
Please login to merge, or discard this patch.
includes/libraries/Pdf/Tfpdf/font/courier.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,6 +3,7 @@
 block discarded – undo
3 3
 $name = 'Courier';
4 4
 $up = -100;
5 5
 $ut = 50;
6
-for($i=0;$i<=255;$i++)
6
+for($i=0;$i<=255;$i++) {
7 7
     $cw[chr($i)] = 600;
8
+}
8 9
 ?>
Please login to merge, or discard this patch.
includes/libraries/Pdf/Tfpdf/font/courieri.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,6 +3,7 @@
 block discarded – undo
3 3
 $name = 'Courier-Oblique';
4 4
 $up = -100;
5 5
 $ut = 50;
6
-for ($i = 0; $i <= 255; $i++)
6
+for ($i = 0; $i <= 255; $i++) {
7 7
 	$cw[chr($i)] = 600;
8
+}
8 9
 ?>
Please login to merge, or discard this patch.
includes/libraries/Pdf/Tfpdf/font/courierbi.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,6 +3,7 @@
 block discarded – undo
3 3
 $name = 'Courier-BoldOblique';
4 4
 $up = -100;
5 5
 $ut = 50;
6
-for ($i = 0; $i <= 255; $i++)
6
+for ($i = 0; $i <= 255; $i++) {
7 7
 	$cw[chr($i)] = 600;
8
+}
8 9
 ?>
Please login to merge, or discard this patch.