Completed
Push — v3.0 ( 23635d...e28df5 )
by Samir
23s
created
web_interface/astpp/system/core/Utf8.php 1 patch
Braces   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php  if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * CodeIgniter
4 6
  *
@@ -58,13 +60,11 @@  discard block
 block discarded – undo
58 60
 			{
59 61
 				define('MB_ENABLED', TRUE);
60 62
 				mb_internal_encoding('UTF-8');
61
-			}
62
-			else
63
+			} else
63 64
 			{
64 65
 				define('MB_ENABLED', FALSE);
65 66
 			}
66
-		}
67
-		else
67
+		} else
68 68
 		{
69 69
 			log_message('debug', "UTF-8 Support Disabled");
70 70
 			define('UTF8_ENABLED', FALSE);
@@ -127,12 +127,10 @@  discard block
 block discarded – undo
127 127
 		if (function_exists('iconv'))
128 128
 		{
129 129
 			$str = @iconv($encoding, 'UTF-8', $str);
130
-		}
131
-		elseif (function_exists('mb_convert_encoding'))
130
+		} elseif (function_exists('mb_convert_encoding'))
132 131
 		{
133 132
 			$str = @mb_convert_encoding($str, 'UTF-8', $encoding);
134
-		}
135
-		else
133
+		} else
136 134
 		{
137 135
 			return FALSE;
138 136
 		}
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Xmlrpc.php 1 patch
Braces   +56 added lines, -79 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php  if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * CodeIgniter
4 6
  *
@@ -237,13 +239,11 @@  discard block
 block discarded – undo
237 239
 				if (is_array($value[0]))
238 240
 				{
239 241
 					$temp = new XML_RPC_Values($value['0'], 'array');
240
-				}
241
-				else
242
+				} else
242 243
 				{
243 244
 					$temp = new XML_RPC_Values($value['0'], 'string');
244 245
 				}
245
-			}
246
-			elseif (is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array'))
246
+			} elseif (is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array'))
247 247
 			{
248 248
 				while (list($k) = each($value['0']))
249 249
 				{
@@ -251,13 +251,11 @@  discard block
 block discarded – undo
251 251
 				}
252 252
 
253 253
 				$temp = new XML_RPC_Values($value['0'], $value['1']);
254
-			}
255
-			else
254
+			} else
256 255
 			{
257 256
 				$temp = new XML_RPC_Values($value['0'], $value['1']);
258 257
 			}
259
-		}
260
-		else
258
+		} else
261 259
 		{
262 260
 			$temp = new XML_RPC_Values($value, 'string');
263 261
 		}
@@ -280,8 +278,7 @@  discard block
 block discarded – undo
280 278
 		{
281 279
 			$this->error = $this->result->errstr;
282 280
 			return FALSE;
283
-		}
284
-		elseif ( ! is_object($this->result->val))
281
+		} elseif ( ! is_object($this->result->val))
285 282
 		{
286 283
 			$this->error = $this->result->errstr;
287 284
 			return FALSE;
@@ -443,14 +440,12 @@  discard block
 block discarded – undo
443 440
 			// error
444 441
 			$this->errno = $code;
445 442
 			$this->errstr = htmlentities($fstr);
446
-		}
447
-		else if ( ! is_object($val))
443
+		} else if ( ! is_object($val))
448 444
 		{
449 445
 			// programmer error, not an object
450 446
 			error_log("Invalid type '" . gettype($val) . "' (value: $val) passed to XML_RPC_Response.  Defaulting to empty value.");
451 447
 			$this->val = new XML_RPC_Values();
452
-		}
453
-		else
448
+		} else
454 449
 		{
455 450
 			$this->val = $val;
456 451
 		}
@@ -490,8 +485,7 @@  discard block
 block discarded – undo
490 485
 		</struct>
491 486
 	</value>
492 487
 </fault>';
493
-		}
494
-		else
488
+		} else
495 489
 		{
496 490
 			$result .= "<params>\n<param>\n" .
497 491
 					$this->val->serialize_class() .
@@ -512,24 +506,21 @@  discard block
 block discarded – undo
512 506
 				if (is_array($array[$key]))
513 507
 				{
514 508
 					$array[$key] = $this->decode($array[$key]);
515
-				}
516
-				else
509
+				} else
517 510
 				{
518 511
 					$array[$key] = ($this->xss_clean) ? $CI->security->xss_clean($array[$key]) : $array[$key];
519 512
 				}
520 513
 			}
521 514
 
522 515
 			$result = $array;
523
-		}
524
-		else
516
+		} else
525 517
 		{
526 518
 			$result = $this->xmlrpc_decoder($this->val);
527 519
 
528 520
 			if (is_array($result))
529 521
 			{
530 522
 				$result = $this->decode($result);
531
-			}
532
-			else
523
+			} else
533 524
 			{
534 525
 				$result = ($this->xss_clean) ? $CI->security->xss_clean($result) : $result;
535 526
 			}
@@ -551,8 +542,7 @@  discard block
 block discarded – undo
551 542
 		if ($kind == 'scalar')
552 543
 		{
553 544
 			return $xmlrpc_val->scalarval();
554
-		}
555
-		elseif ($kind == 'array')
545
+		} elseif ($kind == 'array')
556 546
 		{
557 547
 			reset($xmlrpc_val->me);
558 548
 			list($a,$b) = each($xmlrpc_val->me);
@@ -565,8 +555,7 @@  discard block
 block discarded – undo
565 555
 				$arr[] = $this->xmlrpc_decoder($xmlrpc_val->me['array'][$i]);
566 556
 			}
567 557
 			return $arr;
568
-		}
569
-		elseif ($kind == 'struct')
558
+		} elseif ($kind == 'struct')
570 559
 		{
571 560
 			reset($xmlrpc_val->me['struct']);
572 561
 			$arr = array();
@@ -764,8 +753,7 @@  discard block
 block discarded – undo
764 753
 
765 754
 			$r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']);
766 755
 			return $r;
767
-		}
768
-		elseif ( ! is_object($this->xh[$parser]['value']))
756
+		} elseif ( ! is_object($this->xh[$parser]['value']))
769 757
 		{
770 758
 			$r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']);
771 759
 			return $r;
@@ -815,8 +803,7 @@  discard block
 block discarded – undo
815 803
 			}
816 804
 
817 805
 			$r = new XML_RPC_Response($v, $errno, $errstr_v->scalarval());
818
-		}
819
-		else
806
+		} else
820 807
 		{
821 808
 			$r = new XML_RPC_Response($v);
822 809
 		}
@@ -846,7 +833,9 @@  discard block
 block discarded – undo
846 833
 	function open_tag($the_parser, $name, $attrs)
847 834
 	{
848 835
 		// If invalid nesting, then return
849
-		if ($this->xh[$the_parser]['isf'] > 1) return;
836
+		if ($this->xh[$the_parser]['isf'] > 1) {
837
+			return;
838
+		}
850 839
 
851 840
 		// Evaluate and check for correct nesting of XML elements
852 841
 
@@ -858,8 +847,7 @@  discard block
 block discarded – undo
858 847
 				$this->xh[$the_parser]['isf_reason'] = 'Top level XML-RPC element is missing';
859 848
 				return;
860 849
 			}
861
-		}
862
-		else
850
+		} else
863 851
 		{
864 852
 			// not top level element: see if parent is OK
865 853
 			if ( ! in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name], TRUE))
@@ -936,7 +924,9 @@  discard block
 block discarded – undo
936 924
 		// Add current element name to stack, to allow validation of nesting
937 925
 		array_unshift($this->xh[$the_parser]['stack'], $name);
938 926
 
939
-		if ($name != 'VALUE') $this->xh[$the_parser]['lv'] = 0;
927
+		if ($name != 'VALUE') {
928
+			$this->xh[$the_parser]['lv'] = 0;
929
+		}
940 930
 	}
941 931
 	// END
942 932
 
@@ -947,7 +937,9 @@  discard block
 block discarded – undo
947 937
 
948 938
 	function closing_tag($the_parser, $name)
949 939
 	{
950
-		if ($this->xh[$the_parser]['isf'] > 1) return;
940
+		if ($this->xh[$the_parser]['isf'] > 1) {
941
+			return;
942
+		}
951 943
 
952 944
 		// Remove current element from stack and set variable
953 945
 		// NOTE: If the XML validates, then we do not have to worry about
@@ -979,50 +971,42 @@  discard block
 block discarded – undo
979 971
 				if ($name == 'STRING')
980 972
 				{
981 973
 					$this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
982
-				}
983
-				elseif ($name=='DATETIME.ISO8601')
974
+				} elseif ($name=='DATETIME.ISO8601')
984 975
 				{
985 976
 					$this->xh[$the_parser]['vt']	= $this->xmlrpcDateTime;
986 977
 					$this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
987
-				}
988
-				elseif ($name=='BASE64')
978
+				} elseif ($name=='BASE64')
989 979
 				{
990 980
 					$this->xh[$the_parser]['value'] = base64_decode($this->xh[$the_parser]['ac']);
991
-				}
992
-				elseif ($name=='BOOLEAN')
981
+				} elseif ($name=='BOOLEAN')
993 982
 				{
994 983
 					// Translated BOOLEAN values to TRUE AND FALSE
995 984
 					if ($this->xh[$the_parser]['ac'] == '1')
996 985
 					{
997 986
 						$this->xh[$the_parser]['value'] = TRUE;
998
-					}
999
-					else
987
+					} else
1000 988
 					{
1001 989
 						$this->xh[$the_parser]['value'] = FALSE;
1002 990
 					}
1003
-				}
1004
-				elseif ($name=='DOUBLE')
991
+				} elseif ($name=='DOUBLE')
1005 992
 				{
1006 993
 					// we have a DOUBLE
1007 994
 					// we must check that only 0123456789-.<space> are characters here
1008 995
 					if ( ! preg_match('/^[+-]?[eE0-9\t \.]+$/', $this->xh[$the_parser]['ac']))
1009 996
 					{
1010 997
 						$this->xh[$the_parser]['value'] = 'ERROR_NON_NUMERIC_FOUND';
1011
-					}
1012
-					else
998
+					} else
1013 999
 					{
1014 1000
 						$this->xh[$the_parser]['value'] = (double)$this->xh[$the_parser]['ac'];
1015 1001
 					}
1016
-				}
1017
-				else
1002
+				} else
1018 1003
 				{
1019 1004
 					// we have an I4/INT
1020 1005
 					// we must check that only 0123456789-<space> are characters here
1021 1006
 					if ( ! preg_match('/^[+-]?[0-9\t ]+$/', $this->xh[$the_parser]['ac']))
1022 1007
 					{
1023 1008
 						$this->xh[$the_parser]['value'] = 'ERROR_NON_NUMERIC_FOUND';
1024
-					}
1025
-					else
1009
+					} else
1026 1010
 					{
1027 1011
 						$this->xh[$the_parser]['value'] = (int)$this->xh[$the_parser]['ac'];
1028 1012
 					}
@@ -1045,8 +1029,7 @@  discard block
 block discarded – undo
1045 1029
 				{
1046 1030
 					// Array
1047 1031
 					$this->xh[$the_parser]['valuestack'][0]['values'][] = $temp;
1048
-				}
1049
-				else
1032
+				} else
1050 1033
 				{
1051 1034
 					// Struct
1052 1035
 					$this->xh[$the_parser]['value'] = $temp;
@@ -1091,7 +1074,10 @@  discard block
 block discarded – undo
1091 1074
 
1092 1075
 	function character_data($the_parser, $data)
1093 1076
 	{
1094
-		if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already
1077
+		if ($this->xh[$the_parser]['isf'] > 1) {
1078
+			return;
1079
+		}
1080
+		// XML Fault found already
1095 1081
 
1096 1082
 		// If a value has not been found
1097 1083
 		if ($this->xh[$the_parser]['lv'] != 3)
@@ -1124,8 +1110,7 @@  discard block
 block discarded – undo
1124 1110
 				if (is_array($array[$key]))
1125 1111
 				{
1126 1112
 					$array[$key] = $this->output_parameters($array[$key]);
1127
-				}
1128
-				else
1113
+				} else
1129 1114
 				{
1130 1115
 					// 'bits' is for the MetaWeblog API image bits
1131 1116
 					// @todo - this needs to be made more general purpose
@@ -1134,8 +1119,7 @@  discard block
 block discarded – undo
1134 1119
 			}
1135 1120
 
1136 1121
 			$parameters = $array;
1137
-		}
1138
-		else
1122
+		} else
1139 1123
 		{
1140 1124
 			$parameters = array();
1141 1125
 
@@ -1146,8 +1130,7 @@  discard block
 block discarded – undo
1146 1130
 				if (is_array($a_param))
1147 1131
 				{
1148 1132
 					$parameters[] = $this->output_parameters($a_param);
1149
-				}
1150
-				else
1133
+				} else
1151 1134
 				{
1152 1135
 					$parameters[] = ($this->xss_clean) ? $CI->security->xss_clean($a_param) : $a_param;
1153 1136
 				}
@@ -1165,8 +1148,7 @@  discard block
 block discarded – undo
1165 1148
 		if ($kind == 'scalar')
1166 1149
 		{
1167 1150
 			return $param->scalarval();
1168
-		}
1169
-		elseif ($kind == 'array')
1151
+		} elseif ($kind == 'array')
1170 1152
 		{
1171 1153
 			reset($param->me);
1172 1154
 			list($a,$b) = each($param->me);
@@ -1179,8 +1161,7 @@  discard block
 block discarded – undo
1179 1161
 			}
1180 1162
 
1181 1163
 			return $arr;
1182
-		}
1183
-		elseif ($kind == 'struct')
1164
+		} elseif ($kind == 'struct')
1184 1165
 		{
1185 1166
 			reset($param->me['struct']);
1186 1167
 
@@ -1222,12 +1203,10 @@  discard block
 block discarded – undo
1222 1203
 			if ($this->xmlrpcTypes[$type] == 1)
1223 1204
 			{
1224 1205
 				$this->addScalar($val,$type);
1225
-			}
1226
-			elseif ($this->xmlrpcTypes[$type] == 2)
1206
+			} elseif ($this->xmlrpcTypes[$type] == 2)
1227 1207
 			{
1228 1208
 				$this->addArray($val);
1229
-			}
1230
-			elseif ($this->xmlrpcTypes[$type] == 3)
1209
+			} elseif ($this->xmlrpcTypes[$type] == 3)
1231 1210
 			{
1232 1211
 				$this->addStruct($val);
1233 1212
 			}
@@ -1255,8 +1234,7 @@  discard block
 block discarded – undo
1255 1234
 			if (strcasecmp($val,'true')==0 OR $val==1 OR ($val==true && strcasecmp($val,'false')))
1256 1235
 			{
1257 1236
 				$val = 1;
1258
-			}
1259
-			else
1237
+			} else
1260 1238
 			{
1261 1239
 				$val=0;
1262 1240
 			}
@@ -1268,8 +1246,7 @@  discard block
 block discarded – undo
1268 1246
 			$ar = $this->me['array'];
1269 1247
 			$ar[] = new XML_RPC_Values($val, $type);
1270 1248
 			$this->me['array'] = $ar;
1271
-		}
1272
-		else
1249
+		} else
1273 1250
 		{
1274 1251
 			// a scalar, so set the value and remember we're scalar
1275 1252
 			$this->me[$type] = $val;
@@ -1405,13 +1382,13 @@  discard block
 block discarded – undo
1405 1382
 		if ($utc == 1)
1406 1383
 		{
1407 1384
 			$t = strftime("%Y%m%dT%H:%i:%s", $time);
1408
-		}
1409
-		else
1385
+		} else
1410 1386
 		{
1411
-			if (function_exists('gmstrftime'))
1412
-				$t = gmstrftime("%Y%m%dT%H:%i:%s", $time);
1413
-			else
1414
-				$t = strftime("%Y%m%dT%H:%i:%s", $time - date('Z'));
1387
+			if (function_exists('gmstrftime')) {
1388
+							$t = gmstrftime("%Y%m%dT%H:%i:%s", $time);
1389
+			} else {
1390
+							$t = strftime("%Y%m%dT%H:%i:%s", $time - date('Z'));
1391
+			}
1415 1392
 		}
1416 1393
 		return $t;
1417 1394
 	}
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Parser.php 1 patch
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php  if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * CodeIgniter
4 6
  *
@@ -95,8 +97,7 @@  discard block
 block discarded – undo
95 97
 			if (is_array($val))
96 98
 			{
97 99
 				$template = $this->_parse_pair($key, $val, $template);
98
-			}
99
-			else
100
+			} else
100 101
 			{
101 102
 				$template = $this->_parse_single($key, (string)$val, $template);
102 103
 			}
@@ -172,8 +173,7 @@  discard block
 block discarded – undo
172 173
 				if ( ! is_array($val))
173 174
 				{
174 175
 					$temp = $this->_parse_single($key, $val, $temp);
175
-				}
176
-				else
176
+				} else
177 177
 				{
178 178
 					$temp = $this->_parse_pair($key, $val, $temp);
179 179
 				}
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Cache/drivers/Cache_memcached.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * CodeIgniter
4 6
  *
@@ -67,8 +69,7 @@  discard block
 block discarded – undo
67 69
 		if (get_class($this->_memcached) == 'Memcached')
68 70
 		{
69 71
 			return $this->_memcached->set($id, array($data, time(), $ttl), $ttl);
70
-		}
71
-		else if (get_class($this->_memcached) == 'Memcache')
72
+		} else if (get_class($this->_memcached) == 'Memcache')
72 73
 		{
73 74
 			return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl);
74 75
 		}
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/User_agent.php 1 patch
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php  if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * CodeIgniter
4 6
  *
@@ -87,12 +89,10 @@  discard block
 block discarded – undo
87 89
 		if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
88 90
 		{
89 91
 			include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
90
-		}
91
-		elseif (is_file(APPPATH.'config/user_agents.php'))
92
+		} elseif (is_file(APPPATH.'config/user_agents.php'))
92 93
 		{
93 94
 			include(APPPATH.'config/user_agents.php');
94
-		}
95
-		else
95
+		} else
96 96
 		{
97 97
 			return FALSE;
98 98
 		}
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/pdf.php 1 patch
Braces   +59 added lines, -44 removed lines patch added patch discarded remove patch
@@ -11,21 +11,25 @@  discard block
 block discarded – undo
11 11
   
12 12
   
13 13
     $this->page++;
14
-    if(!isset($this->pages[$this->page])) // solves the problem of overwriting a page if it already exists
14
+    if(!isset($this->pages[$this->page])) {
15
+    	// solves the problem of overwriting a page if it already exists
15 16
         $this->pages[$this->page] = '';
17
+    }
16 18
     $this->state  =2;
17 19
     $this->x = $this->lMargin;
18 20
     $this->y = $this->tMargin;
19 21
     $this->FontFamily = '';
20 22
     // Check page size and orientation
21
-    if($orientation=='')
22
-        $orientation = $this->DefOrientation;
23
-    else
24
-        $orientation = strtoupper($orientation[0]);
25
-    if($size=='')
26
-        $size = $this->DefPageSize;
27
-    else
28
-        $size = $this->_getpagesize($size);
23
+    if($orientation=='') {
24
+            $orientation = $this->DefOrientation;
25
+    } else {
26
+            $orientation = strtoupper($orientation[0]);
27
+    }
28
+    if($size=='') {
29
+            $size = $this->DefPageSize;
30
+    } else {
31
+            $size = $this->_getpagesize($size);
32
+    }
29 33
     if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1])
30 34
     {
31 35
         // New size or orientation
@@ -33,8 +37,7 @@  discard block
 block discarded – undo
33 37
         {
34 38
             $this->w = $size[0];
35 39
             $this->h = $size[1];
36
-        }
37
-        else
40
+        } else
38 41
         {
39 42
             $this->w = $size[1];
40 43
             $this->h = $size[0];
@@ -45,9 +48,10 @@  discard block
 block discarded – undo
45 48
         $this->CurOrientation = $orientation;
46 49
         $this->CurPageSize = $size;
47 50
     }
48
-    if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1])
49
-        $this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
50
-}
51
+    if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) {
52
+            $this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
53
+    }
54
+    }
51 55
 
52 56
 function Footer() {
53 57
     // Check if Footer for this page already exists (do the same for Header())
@@ -82,19 +86,22 @@  discard block
 block discarded – undo
82 86
             $this->page = $currpage;
83 87
             $this->SetXY($l,$h);
84 88
 
85
-	    if($col == 5)
86
-	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,"R");
87
-            else
88
-	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt);
89
+	    if($col == 5) {
90
+	    	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,"R");
91
+	    } else {
92
+            	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt);
93
+            }
89 94
             $l += $this->tablewidths[$col];
90 95
 
91
-            if(!isset($tmpheight[$row.'-'.$this->page]))
92
-                $tmpheight[$row.'-'.$this->page] = 0;
96
+            if(!isset($tmpheight[$row.'-'.$this->page])) {
97
+                            $tmpheight[$row.'-'.$this->page] = 0;
98
+            }
93 99
             if($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
94 100
                 $tmpheight[$row.'-'.$this->page] = $this->GetY();
95 101
             }
96
-            if($this->page > $maxpage)
97
-                $maxpage = $this->page;
102
+            if($this->page > $maxpage) {
103
+                            $maxpage = $this->page;
104
+            }
98 105
         }
99 106
 
100 107
         // get the height we were in the last used page
@@ -142,30 +149,35 @@  discard block
 block discarded – undo
142 149
     foreach($datas AS $row => $data) {
143 150
         $this->page = $currpage;
144 151
         // write the horizontal borders
145
-	if($data != "")
146
-        $this->Line(100,$h,200,$h);
152
+	if($data != "") {
153
+	        $this->Line(100,$h,200,$h);
154
+	}
147 155
         // write the content and remember the height of the highest col
148 156
         foreach($data AS $col => $txt) {
149 157
             $this->page = $currpage;
150 158
             $this->SetXY($l,$h);
151 159
             
152
-            if($col == 3)
153
-	      $this->SetFont('Arial', 'B', 8);
154
-	    else
155
-	      $this->SetFont('Arial', '', 8);
156
-	    if($col == 5)
157
-	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,"R");
158
-            else
159
-	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt);
160
+            if($col == 3) {
161
+            	      $this->SetFont('Arial', 'B', 8);
162
+            } else {
163
+	    	      $this->SetFont('Arial', '', 8);
164
+	    }
165
+	    if($col == 5) {
166
+	    	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,"R");
167
+	    } else {
168
+            	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt);
169
+            }
160 170
             $l += $this->tablewidths[$col];
161 171
 
162
-            if(!isset($tmpheight[$row.'-'.$this->page]))
163
-                $tmpheight[$row.'-'.$this->page] = 0;
172
+            if(!isset($tmpheight[$row.'-'.$this->page])) {
173
+                            $tmpheight[$row.'-'.$this->page] = 0;
174
+            }
164 175
             if($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
165 176
                 $tmpheight[$row.'-'.$this->page] = $this->GetY();
166 177
             }
167
-            if($this->page > $maxpage)
168
-                $maxpage = $this->page;
178
+            if($this->page > $maxpage) {
179
+                            $maxpage = $this->page;
180
+            }
169 181
         }
170 182
 
171 183
         // get the height we were in the last used page
@@ -224,19 +236,22 @@  discard block
 block discarded – undo
224 236
             $this->page = $currpage;
225 237
             $this->SetXY($l,$h);
226 238
 
227
-	    if($col == 5)
228
-	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,"R");
229
-            else
230
-	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt);
239
+	    if($col == 5) {
240
+	    	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,"R");
241
+	    } else {
242
+            	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt);
243
+            }
231 244
             $l += $this->tablewidths[$col];
232 245
 
233
-            if(!isset($tmpheight[$row.'-'.$this->page]))
234
-                $tmpheight[$row.'-'.$this->page] = 0;
246
+            if(!isset($tmpheight[$row.'-'.$this->page])) {
247
+                            $tmpheight[$row.'-'.$this->page] = 0;
248
+            }
235 249
             if($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
236 250
                 $tmpheight[$row.'-'.$this->page] = $this->GetY();
237 251
             }
238
-            if($this->page > $maxpage)
239
-                $maxpage = $this->page;
252
+            if($this->page > $maxpage) {
253
+                            $maxpage = $this->page;
254
+            }
240 255
         }
241 256
 
242 257
         // get the height we were in the last used page
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Fpdf.php 1 patch
Braces   +586 added lines, -456 removed lines patch added patch discarded remove patch
@@ -116,26 +116,28 @@  discard block
 block discarded – undo
116 116
 	if(defined('FPDF_FONTPATH'))
117 117
 	{
118 118
 		$this->fontpath = FPDF_FONTPATH;
119
-		if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\')
120
-			$this->fontpath .= '/';
121
-	}
122
-	elseif(is_dir(dirname(__FILE__).'/font'))
123
-		$this->fontpath = dirname(__FILE__).'/font/';
124
-	else
125
-		$this->fontpath = '';	
119
+		if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\') {
120
+					$this->fontpath .= '/';
121
+		}
122
+	} elseif(is_dir(dirname(__FILE__).'/font')) {
123
+			$this->fontpath = dirname(__FILE__).'/font/';
124
+	} else {
125
+			$this->fontpath = '';
126
+	}
126 127
 	// Core fonts
127 128
 	$this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats');
128 129
 	// Scale factor
129
-	if($unit=='pt')
130
-		$this->k = 1;
131
-	elseif($unit=='mm')
132
-		$this->k = 72/25.4;
133
-	elseif($unit=='cm')
134
-		$this->k = 72/2.54;
135
-	elseif($unit=='in')
136
-		$this->k = 72;
137
-	else
138
-		$this->Error('Incorrect unit: '.$unit);
130
+	if($unit=='pt') {
131
+			$this->k = 1;
132
+	} elseif($unit=='mm') {
133
+			$this->k = 72/25.4;
134
+	} elseif($unit=='cm') {
135
+			$this->k = 72/2.54;
136
+	} elseif($unit=='in') {
137
+			$this->k = 72;
138
+	} else {
139
+			$this->Error('Incorrect unit: '.$unit);
140
+	}
139 141
 	// Page sizes
140 142
 	$this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
141 143
 		'letter'=>array(612,792), 'legal'=>array(612,1008));
@@ -149,15 +151,14 @@  discard block
 block discarded – undo
149 151
 		$this->DefOrientation = 'P';
150 152
 		$this->w = $size[0];
151 153
 		$this->h = $size[1];
152
-	}
153
-	elseif($orientation=='l' || $orientation=='landscape')
154
+	} elseif($orientation=='l' || $orientation=='landscape')
154 155
 	{
155 156
 		$this->DefOrientation = 'L';
156 157
 		$this->w = $size[1];
157 158
 		$this->h = $size[0];
158
-	}
159
-	else
160
-		$this->Error('Incorrect orientation: '.$orientation);
159
+	} else {
160
+			$this->Error('Incorrect orientation: '.$orientation);
161
+	}
161 162
 	$this->CurOrientation = $this->DefOrientation;
162 163
 	$this->wPt = $this->w*$this->k;
163 164
 	$this->hPt = $this->h*$this->k;
@@ -183,8 +184,9 @@  discard block
 block discarded – undo
183 184
 	// Set left, top and right margins
184 185
 	$this->lMargin = $left;
185 186
 	$this->tMargin = $top;
186
-	if($right===null)
187
-		$right = $left;
187
+	if($right===null) {
188
+			$right = $left;
189
+	}
188 190
 	$this->rMargin = $right;
189 191
 }
190 192
 
@@ -192,9 +194,10 @@  discard block
 block discarded – undo
192 194
 {
193 195
 	// Set left margin
194 196
 	$this->lMargin = $margin;
195
-	if($this->page>0 && $this->x<$margin)
196
-		$this->x = $margin;
197
-}
197
+	if($this->page>0 && $this->x<$margin) {
198
+			$this->x = $margin;
199
+	}
200
+	}
198 201
 
199 202
 function SetTopMargin($margin)
200 203
 {
@@ -219,62 +222,70 @@  discard block
 block discarded – undo
219 222
 function SetDisplayMode($zoom, $layout='default')
220 223
 {
221 224
 	// Set display mode in viewer
222
-	if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
223
-		$this->ZoomMode = $zoom;
224
-	else
225
-		$this->Error('Incorrect zoom display mode: '.$zoom);
226
-	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
227
-		$this->LayoutMode = $layout;
228
-	else
229
-		$this->Error('Incorrect layout display mode: '.$layout);
230
-}
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
+	}
230
+	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') {
231
+			$this->LayoutMode = $layout;
232
+	} else {
233
+			$this->Error('Incorrect layout display mode: '.$layout);
234
+	}
235
+	}
231 236
 
232 237
 function SetCompression($compress)
233 238
 {
234 239
 	// Set page compression
235
-	if(function_exists('gzcompress'))
236
-		$this->compress = $compress;
237
-	else
238
-		$this->compress = false;
239
-}
240
+	if(function_exists('gzcompress')) {
241
+			$this->compress = $compress;
242
+	} else {
243
+			$this->compress = false;
244
+	}
245
+	}
240 246
 
241 247
 function SetTitle($title, $isUTF8=false)
242 248
 {
243 249
 	// Title of document
244
-	if($isUTF8)
245
-		$title = $this->_UTF8toUTF16($title);
250
+	if($isUTF8) {
251
+			$title = $this->_UTF8toUTF16($title);
252
+	}
246 253
 	$this->title = $title;
247 254
 }
248 255
 
249 256
 function SetSubject($subject, $isUTF8=false)
250 257
 {
251 258
 	// Subject of document
252
-	if($isUTF8)
253
-		$subject = $this->_UTF8toUTF16($subject);
259
+	if($isUTF8) {
260
+			$subject = $this->_UTF8toUTF16($subject);
261
+	}
254 262
 	$this->subject = $subject;
255 263
 }
256 264
 
257 265
 function SetAuthor($author, $isUTF8=false)
258 266
 {
259 267
 	// Author of document
260
-	if($isUTF8)
261
-		$author = $this->_UTF8toUTF16($author);
268
+	if($isUTF8) {
269
+			$author = $this->_UTF8toUTF16($author);
270
+	}
262 271
 	$this->author = $author;
263 272
 }
264 273
 
265 274
 function SetKeywords($keywords, $isUTF8=false)
266 275
 {
267 276
 	// Keywords of document
268
-	if($isUTF8)
269
-		$keywords = $this->_UTF8toUTF16($keywords);
277
+	if($isUTF8) {
278
+			$keywords = $this->_UTF8toUTF16($keywords);
279
+	}
270 280
 	$this->keywords = $keywords;
271 281
 }
272 282
 
273 283
 function SetCreator($creator, $isUTF8=false)
274 284
 {
275 285
 	// Creator of document
276
-	if($isUTF8)
277
-		$creator = $this->_UTF8toUTF16($creator);
286
+	if($isUTF8) {
287
+			$creator = $this->_UTF8toUTF16($creator);
288
+	}
278 289
 	$this->creator = $creator;
279 290
 }
280 291
 
@@ -299,10 +310,12 @@  discard block
 block discarded – undo
299 310
 function Close()
300 311
 {
301 312
 	// Terminate document
302
-	if($this->state==3)
303
-		return;
304
-	if($this->page==0)
305
-		$this->AddPage();
313
+	if($this->state==3) {
314
+			return;
315
+	}
316
+	if($this->page==0) {
317
+			$this->AddPage();
318
+	}
306 319
 	// Page footer
307 320
 	$this->InFooter = true;
308 321
 	$this->Footer();
@@ -316,8 +329,9 @@  discard block
 block discarded – undo
316 329
 function AddPage($orientation='', $size='')
317 330
 {
318 331
 	// Start a new page
319
-	if($this->state==0)
320
-		$this->Open();
332
+	if($this->state==0) {
333
+			$this->Open();
334
+	}
321 335
 	$family = $this->FontFamily;
322 336
 	$style = $this->FontStyle.($this->underline ? 'U' : '');
323 337
 	$fontsize = $this->FontSizePt;
@@ -343,15 +357,18 @@  discard block
 block discarded – undo
343 357
 	$this->LineWidth = $lw;
344 358
 	$this->_out(sprintf('%.2F w',$lw*$this->k));
345 359
 	// Set font
346
-	if($family)
347
-		$this->SetFont($family,$style,$fontsize);
360
+	if($family) {
361
+			$this->SetFont($family,$style,$fontsize);
362
+	}
348 363
 	// Set colors
349 364
 	$this->DrawColor = $dc;
350
-	if($dc!='0 G')
351
-		$this->_out($dc);
365
+	if($dc!='0 G') {
366
+			$this->_out($dc);
367
+	}
352 368
 	$this->FillColor = $fc;
353
-	if($fc!='0 g')
354
-		$this->_out($fc);
369
+	if($fc!='0 g') {
370
+			$this->_out($fc);
371
+	}
355 372
 	$this->TextColor = $tc;
356 373
 	$this->ColorFlag = $cf;
357 374
 	// Page header
@@ -365,8 +382,9 @@  discard block
 block discarded – undo
365 382
 		$this->_out(sprintf('%.2F w',$lw*$this->k));
366 383
 	}
367 384
 	// Restore font
368
-	if($family)
369
-		$this->SetFont($family,$style,$fontsize);
385
+	if($family) {
386
+			$this->SetFont($family,$style,$fontsize);
387
+	}
370 388
 	// Restore colors
371 389
 	if($this->DrawColor!=$dc)
372 390
 	{
@@ -401,33 +419,38 @@  discard block
 block discarded – undo
401 419
 function SetDrawColor($r, $g=null, $b=null)
402 420
 {
403 421
 	// Set color for all stroking operations
404
-	if(($r==0 && $g==0 && $b==0) || $g===null)
405
-		$this->DrawColor = sprintf('%.3F G',$r/255);
406
-	else
407
-		$this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
408
-	if($this->page>0)
409
-		$this->_out($this->DrawColor);
410
-}
422
+	if(($r==0 && $g==0 && $b==0) || $g===null) {
423
+			$this->DrawColor = sprintf('%.3F G',$r/255);
424
+	} else {
425
+			$this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
426
+	}
427
+	if($this->page>0) {
428
+			$this->_out($this->DrawColor);
429
+	}
430
+	}
411 431
 
412 432
 function SetFillColor($r, $g=null, $b=null)
413 433
 {
414 434
 	// Set color for all filling operations
415
-	if(($r==0 && $g==0 && $b==0) || $g===null)
416
-		$this->FillColor = sprintf('%.3F g',$r/255);
417
-	else
418
-		$this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
435
+	if(($r==0 && $g==0 && $b==0) || $g===null) {
436
+			$this->FillColor = sprintf('%.3F g',$r/255);
437
+	} else {
438
+			$this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
439
+	}
419 440
 	$this->ColorFlag = ($this->FillColor!=$this->TextColor);
420
-	if($this->page>0)
421
-		$this->_out($this->FillColor);
422
-}
441
+	if($this->page>0) {
442
+			$this->_out($this->FillColor);
443
+	}
444
+	}
423 445
 
424 446
 function SetTextColor($r, $g=null, $b=null)
425 447
 {
426 448
 	// Set color for text
427
-	if(($r==0 && $g==0 && $b==0) || $g===null)
428
-		$this->TextColor = sprintf('%.3F g',$r/255);
429
-	else
430
-		$this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
449
+	if(($r==0 && $g==0 && $b==0) || $g===null) {
450
+			$this->TextColor = sprintf('%.3F g',$r/255);
451
+	} else {
452
+			$this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
453
+	}
431 454
 	$this->ColorFlag = ($this->FillColor!=$this->TextColor);
432 455
 }
433 456
 
@@ -438,8 +461,9 @@  discard block
 block discarded – undo
438 461
 	$cw = &$this->CurrentFont['cw'];
439 462
 	$w = 0;
440 463
 	$l = strlen($s);
441
-	for($i=0;$i<$l;$i++)
442
-		$w += $cw[$s[$i]];
464
+	for($i=0;$i<$l;$i++) {
465
+			$w += $cw[$s[$i]];
466
+	}
443 467
 	return $w*$this->FontSize/1000;
444 468
 }
445 469
 
@@ -447,9 +471,10 @@  discard block
 block discarded – undo
447 471
 {
448 472
 	// Set line width
449 473
 	$this->LineWidth = $width;
450
-	if($this->page>0)
451
-		$this->_out(sprintf('%.2F w',$width*$this->k));
452
-}
474
+	if($this->page>0) {
475
+			$this->_out(sprintf('%.2F w',$width*$this->k));
476
+	}
477
+	}
453 478
 
454 479
 function Line($x1, $y1, $x2, $y2)
455 480
 {
@@ -460,12 +485,13 @@  discard block
 block discarded – undo
460 485
 function Rect($x, $y, $w, $h, $style='')
461 486
 {
462 487
 	// Draw a rectangle
463
-	if($style=='F')
464
-		$op = 'f';
465
-	elseif($style=='FD' || $style=='DF')
466
-		$op = 'B';
467
-	else
468
-		$op = 'S';
488
+	if($style=='F') {
489
+			$op = 'f';
490
+	} elseif($style=='FD' || $style=='DF') {
491
+			$op = 'B';
492
+	} else {
493
+			$op = 'S';
494
+	}
469 495
 	$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
470 496
 }
471 497
 
@@ -473,14 +499,17 @@  discard block
 block discarded – undo
473 499
 {
474 500
 	// Add a TrueType, OpenType or Type1 font
475 501
 	$family = strtolower($family);
476
-	if($file=='')
477
-		$file = str_replace(' ','',$family).strtolower($style).'.php';
502
+	if($file=='') {
503
+			$file = str_replace(' ','',$family).strtolower($style).'.php';
504
+	}
478 505
 	$style = strtoupper($style);
479
-	if($style=='IB')
480
-		$style = 'BI';
506
+	if($style=='IB') {
507
+			$style = 'BI';
508
+	}
481 509
 	$fontkey = $family.$style;
482
-	if(isset($this->fonts[$fontkey]))
483
-		return;
510
+	if(isset($this->fonts[$fontkey])) {
511
+			return;
512
+	}
484 513
 	$info = $this->_loadfont($file);
485 514
 	$info['i'] = count($this->fonts)+1;
486 515
 	if(!empty($info['diff']))
@@ -497,10 +526,11 @@  discard block
 block discarded – undo
497 526
 	if(!empty($info['file']))
498 527
 	{
499 528
 		// Embedded font
500
-		if($info['type']=='TrueType')
501
-			$this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
502
-		else
503
-			$this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
529
+		if($info['type']=='TrueType') {
530
+					$this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
531
+		} else {
532
+					$this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
533
+		}
504 534
 	}
505 535
 	$this->fonts[$fontkey] = $info;
506 536
 }
@@ -508,42 +538,49 @@  discard block
 block discarded – undo
508 538
 function SetFont($family, $style='', $size=0)
509 539
 {
510 540
 	// Select a font; size given in points
511
-	if($family=='')
512
-		$family = $this->FontFamily;
513
-	else
514
-		$family = strtolower($family);
541
+	if($family=='') {
542
+			$family = $this->FontFamily;
543
+	} else {
544
+			$family = strtolower($family);
545
+	}
515 546
 	$style = strtoupper($style);
516 547
 	if(strpos($style,'U')!==false)
517 548
 	{
518 549
 		$this->underline = true;
519 550
 		$style = str_replace('U','',$style);
520
-	}
521
-	else
522
-		$this->underline = false;
523
-	if($style=='IB')
524
-		$style = 'BI';
525
-	if($size==0)
526
-		$size = $this->FontSizePt;
551
+	} else {
552
+			$this->underline = false;
553
+	}
554
+	if($style=='IB') {
555
+			$style = 'BI';
556
+	}
557
+	if($size==0) {
558
+			$size = $this->FontSizePt;
559
+	}
527 560
 	// Test if font is already selected
528
-	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
529
-		return;
561
+	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) {
562
+			return;
563
+	}
530 564
 	// Test if font is already loaded
531 565
 	$fontkey = $family.$style;
532 566
 	if(!isset($this->fonts[$fontkey]))
533 567
 	{
534 568
 		// Test if one of the core fonts
535
-		if($family=='arial')
536
-			$family = 'helvetica';
569
+		if($family=='arial') {
570
+					$family = 'helvetica';
571
+		}
537 572
 		if(in_array($family,$this->CoreFonts))
538 573
 		{
539
-			if($family=='symbol' || $family=='zapfdingbats')
540
-				$style = '';
574
+			if($family=='symbol' || $family=='zapfdingbats') {
575
+							$style = '';
576
+			}
541 577
 			$fontkey = $family.$style;
542
-			if(!isset($this->fonts[$fontkey]))
543
-				$this->AddFont($family,$style);
544
-		}
545
-		else
546
-			$this->Error('Undefined font: '.$family.' '.$style);
578
+			if(!isset($this->fonts[$fontkey])) {
579
+							$this->AddFont($family,$style);
580
+			}
581
+		} else {
582
+					$this->Error('Undefined font: '.$family.' '.$style);
583
+		}
547 584
 	}
548 585
 	// Select it
549 586
 	$this->FontFamily = $family;
@@ -551,20 +588,23 @@  discard block
 block discarded – undo
551 588
 	$this->FontSizePt = $size;
552 589
 	$this->FontSize = $size/$this->k;
553 590
 	$this->CurrentFont = &$this->fonts[$fontkey];
554
-	if($this->page>0)
555
-		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
556
-}
591
+	if($this->page>0) {
592
+			$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
593
+	}
594
+	}
557 595
 
558 596
 function SetFontSize($size)
559 597
 {
560 598
 	// Set font size in points
561
-	if($this->FontSizePt==$size)
562
-		return;
599
+	if($this->FontSizePt==$size) {
600
+			return;
601
+	}
563 602
 	$this->FontSizePt = $size;
564 603
 	$this->FontSize = $size/$this->k;
565
-	if($this->page>0)
566
-		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
567
-}
604
+	if($this->page>0) {
605
+			$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
606
+	}
607
+	}
568 608
 
569 609
 function AddLink()
570 610
 {
@@ -577,10 +617,12 @@  discard block
 block discarded – undo
577 617
 function SetLink($link, $y=0, $page=-1)
578 618
 {
579 619
 	// Set destination of internal link
580
-	if($y==-1)
581
-		$y = $this->y;
582
-	if($page==-1)
583
-		$page = $this->page;
620
+	if($y==-1) {
621
+			$y = $this->y;
622
+	}
623
+	if($page==-1) {
624
+			$page = $this->page;
625
+	}
584 626
 	$this->links[$link] = array($page, $y);
585 627
 }
586 628
 
@@ -594,10 +636,12 @@  discard block
 block discarded – undo
594 636
 {
595 637
 	// Output a string
596 638
 	$s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
597
-	if($this->underline && $txt!='')
598
-		$s .= ' '.$this->_dounderline($x,$y,$txt);
599
-	if($this->ColorFlag)
600
-		$s = 'q '.$this->TextColor.' '.$s.' Q';
639
+	if($this->underline && $txt!='') {
640
+			$s .= ' '.$this->_dounderline($x,$y,$txt);
641
+	}
642
+	if($this->ColorFlag) {
643
+			$s = 'q '.$this->TextColor.' '.$s.' Q';
644
+	}
601 645
 	$this->_out($s);
602 646
 }
603 647
 
@@ -629,74 +673,89 @@  discard block
 block discarded – undo
629 673
 			$this->_out(sprintf('%.3F Tw',$ws*$k));
630 674
 		}
631 675
 	}
632
-	if($w==0)
633
-		$w = $this->w-$this->rMargin-$this->x;
676
+	if($w==0) {
677
+			$w = $this->w-$this->rMargin-$this->x;
678
+	}
634 679
 	$s = '';
635 680
 	if($fill || $border==1)
636 681
 	{
637
-		if($fill)
638
-			$op = ($border==1) ? 'B' : 'f';
639
-		else
640
-			$op = 'S';
682
+		if($fill) {
683
+					$op = ($border==1) ? 'B' : 'f';
684
+		} else {
685
+					$op = 'S';
686
+		}
641 687
 		$s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
642 688
 	}
643 689
 	if(is_string($border))
644 690
 	{
645 691
 		$x = $this->x;
646 692
 		$y = $this->y;
647
-		if(strpos($border,'L')!==false)
648
-			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
649
-		if(strpos($border,'T')!==false)
650
-			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
651
-		if(strpos($border,'R')!==false)
652
-			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
653
-		if(strpos($border,'B')!==false)
654
-			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
693
+		if(strpos($border,'L')!==false) {
694
+					$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
695
+		}
696
+		if(strpos($border,'T')!==false) {
697
+					$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
698
+		}
699
+		if(strpos($border,'R')!==false) {
700
+					$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
701
+		}
702
+		if(strpos($border,'B')!==false) {
703
+					$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
704
+		}
655 705
 	}
656 706
 	if($txt!=='')
657 707
 	{
658
-		if($align=='R')
659
-			$dx = $w-$this->cMargin-$this->GetStringWidth($txt);
660
-		elseif($align=='C')
661
-			$dx = ($w-$this->GetStringWidth($txt))/2;
662
-		else
663
-			$dx = $this->cMargin;
664
-		if($this->ColorFlag)
665
-			$s .= 'q '.$this->TextColor.' ';
708
+		if($align=='R') {
709
+					$dx = $w-$this->cMargin-$this->GetStringWidth($txt);
710
+		} elseif($align=='C') {
711
+					$dx = ($w-$this->GetStringWidth($txt))/2;
712
+		} else {
713
+					$dx = $this->cMargin;
714
+		}
715
+		if($this->ColorFlag) {
716
+					$s .= 'q '.$this->TextColor.' ';
717
+		}
666 718
 		$txt2 = str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
667 719
 		$s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
668
-		if($this->underline)
669
-			$s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
670
-		if($this->ColorFlag)
671
-			$s .= ' Q';
672
-		if($link)
673
-			$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
720
+		if($this->underline) {
721
+					$s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
722
+		}
723
+		if($this->ColorFlag) {
724
+					$s .= ' Q';
725
+		}
726
+		if($link) {
727
+					$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
728
+		}
674 729
 	}
675
-	if($s)
676
-		$this->_out($s);
730
+	if($s) {
731
+			$this->_out($s);
732
+	}
677 733
 	$this->lasth = $h;
678 734
 	if($ln>0)
679 735
 	{
680 736
 		// Go to next line
681 737
 		$this->y += $h;
682
-		if($ln==1)
683
-			$this->x = $this->lMargin;
738
+		if($ln==1) {
739
+					$this->x = $this->lMargin;
740
+		}
741
+	} else {
742
+			$this->x += $w;
743
+	}
684 744
 	}
685
-	else
686
-		$this->x += $w;
687
-}
688 745
 
689 746
 function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
690 747
 {
691 748
 	// Output text with automatic or explicit line breaks
692 749
 	$cw = &$this->CurrentFont['cw'];
693
-	if($w==0)
694
-		$w = $this->w-$this->rMargin-$this->x;
750
+	if($w==0) {
751
+			$w = $this->w-$this->rMargin-$this->x;
752
+	}
695 753
 	$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
696 754
 	$s = str_replace("\r",'',$txt);
697 755
 	$nb = strlen($s);
698
-	if($nb>0 && $s[$nb-1]=="\n")
699
-		$nb--;
756
+	if($nb>0 && $s[$nb-1]=="\n") {
757
+			$nb--;
758
+	}
700 759
 	$b = 0;
701 760
 	if($border)
702 761
 	{
@@ -705,14 +764,15 @@  discard block
 block discarded – undo
705 764
 			$border = 'LTRB';
706 765
 			$b = 'LRT';
707 766
 			$b2 = 'LR';
708
-		}
709
-		else
767
+		} else
710 768
 		{
711 769
 			$b2 = '';
712
-			if(strpos($border,'L')!==false)
713
-				$b2 .= 'L';
714
-			if(strpos($border,'R')!==false)
715
-				$b2 .= 'R';
770
+			if(strpos($border,'L')!==false) {
771
+							$b2 .= 'L';
772
+			}
773
+			if(strpos($border,'R')!==false) {
774
+							$b2 .= 'R';
775
+			}
716 776
 			$b = (strpos($border,'T')!==false) ? $b2.'T' : $b2;
717 777
 		}
718 778
 	}
@@ -741,8 +801,9 @@  discard block
 block discarded – undo
741 801
 			$l = 0;
742 802
 			$ns = 0;
743 803
 			$nl++;
744
-			if($border && $nl==2)
745
-				$b = $b2;
804
+			if($border && $nl==2) {
805
+							$b = $b2;
806
+			}
746 807
 			continue;
747 808
 		}
748 809
 		if($c==' ')
@@ -757,16 +818,16 @@  discard block
 block discarded – undo
757 818
 			// Automatic line break
758 819
 			if($sep==-1)
759 820
 			{
760
-				if($i==$j)
761
-					$i++;
821
+				if($i==$j) {
822
+									$i++;
823
+				}
762 824
 				if($this->ws>0)
763 825
 				{
764 826
 					$this->ws = 0;
765 827
 					$this->_out('0 Tw');
766 828
 				}
767 829
 				$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
768
-			}
769
-			else
830
+			} else
770 831
 			{
771 832
 				if($align=='J')
772 833
 				{
@@ -781,11 +842,12 @@  discard block
 block discarded – undo
781 842
 			$l = 0;
782 843
 			$ns = 0;
783 844
 			$nl++;
784
-			if($border && $nl==2)
785
-				$b = $b2;
786
-		}
787
-		else
788
-			$i++;
845
+			if($border && $nl==2) {
846
+							$b = $b2;
847
+			}
848
+		} else {
849
+					$i++;
850
+		}
789 851
 	}
790 852
 	// Last chunk
791 853
 	if($this->ws>0)
@@ -793,8 +855,9 @@  discard block
 block discarded – undo
793 855
 		$this->ws = 0;
794 856
 		$this->_out('0 Tw');
795 857
 	}
796
-	if($border && strpos($border,'B')!==false)
797
-		$b .= 'B';
858
+	if($border && strpos($border,'B')!==false) {
859
+			$b .= 'B';
860
+	}
798 861
 	$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
799 862
 	$this->x = $this->lMargin;
800 863
 }
@@ -833,8 +896,9 @@  discard block
 block discarded – undo
833 896
 			$nl++;
834 897
 			continue;
835 898
 		}
836
-		if($c==' ')
837
-			$sep = $i;
899
+		if($c==' ') {
900
+					$sep = $i;
901
+		}
838 902
 		$l += $cw[$c];
839 903
 		if($l>$wmax)
840 904
 		{
@@ -852,11 +916,11 @@  discard block
 block discarded – undo
852 916
 					$nl++;
853 917
 					continue;
854 918
 				}
855
-				if($i==$j)
856
-					$i++;
919
+				if($i==$j) {
920
+									$i++;
921
+				}
857 922
 				$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
858
-			}
859
-			else
923
+			} else
860 924
 			{
861 925
 				$this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
862 926
 				$i = $sep+1;
@@ -871,24 +935,26 @@  discard block
 block discarded – undo
871 935
 				$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
872 936
 			}
873 937
 			$nl++;
874
-		}
875
-		else
876
-			$i++;
938
+		} else {
939
+					$i++;
940
+		}
877 941
 	}
878 942
 	// Last chunk
879
-	if($i!=$j)
880
-		$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
881
-}
943
+	if($i!=$j) {
944
+			$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
945
+	}
946
+	}
882 947
 
883 948
 function Ln($h=null)
884 949
 {
885 950
 	// Line feed; default value is last cell height
886 951
 	$this->x = $this->lMargin;
887
-	if($h===null)
888
-		$this->y += $this->lasth;
889
-	else
890
-		$this->y += $h;
891
-}
952
+	if($h===null) {
953
+			$this->y += $this->lasth;
954
+	} else {
955
+			$this->y += $h;
956
+	}
957
+	}
892 958
 
893 959
 function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
894 960
 {
@@ -899,22 +965,25 @@  discard block
 block discarded – undo
899 965
 		if($type=='')
900 966
 		{
901 967
 			$pos = strrpos($file,'.');
902
-			if(!$pos)
903
-				$this->Error('Image file has no extension and no type was specified: '.$file);
968
+			if(!$pos) {
969
+							$this->Error('Image file has no extension and no type was specified: '.$file);
970
+			}
904 971
 			$type = substr($file,$pos+1);
905 972
 		}
906 973
 		$type = strtolower($type);
907
-		if($type=='jpeg')
908
-			$type = 'jpg';
974
+		if($type=='jpeg') {
975
+					$type = 'jpg';
976
+		}
909 977
 		$mtd = '_parse'.$type;
910
-		if(!method_exists($this,$mtd))
911
-			$this->Error('Unsupported image type: '.$type);
978
+		if(!method_exists($this,$mtd)) {
979
+					$this->Error('Unsupported image type: '.$type);
980
+		}
912 981
 		$info = $this->$mtd($file);
913 982
 		$info['i'] = count($this->images)+1;
914 983
 		$this->images[$file] = $info;
915
-	}
916
-	else
917
-		$info = $this->images[$file];
984
+	} else {
985
+			$info = $this->images[$file];
986
+	}
918 987
 
919 988
 	// Automatic width and height calculation if needed
920 989
 	if($w==0 && $h==0)
@@ -923,14 +992,18 @@  discard block
 block discarded – undo
923 992
 		$w = -96;
924 993
 		$h = -96;
925 994
 	}
926
-	if($w<0)
927
-		$w = -$info['w']*72/$w/$this->k;
928
-	if($h<0)
929
-		$h = -$info['h']*72/$h/$this->k;
930
-	if($w==0)
931
-		$w = $h*$info['w']/$info['h'];
932
-	if($h==0)
933
-		$h = $w*$info['h']/$info['w'];
995
+	if($w<0) {
996
+			$w = -$info['w']*72/$w/$this->k;
997
+	}
998
+	if($h<0) {
999
+			$h = -$info['h']*72/$h/$this->k;
1000
+	}
1001
+	if($w==0) {
1002
+			$w = $h*$info['w']/$info['h'];
1003
+	}
1004
+	if($h==0) {
1005
+			$h = $w*$info['h']/$info['w'];
1006
+	}
934 1007
 
935 1008
 	// Flowing mode
936 1009
 	if($y===null)
@@ -946,12 +1019,14 @@  discard block
 block discarded – undo
946 1019
 		$this->y += $h;
947 1020
 	}
948 1021
 
949
-	if($x===null)
950
-		$x = $this->x;
1022
+	if($x===null) {
1023
+			$x = $this->x;
1024
+	}
951 1025
 	$this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
952
-	if($link)
953
-		$this->Link($x,$y,$w,$h,$link);
954
-}
1026
+	if($link) {
1027
+			$this->Link($x,$y,$w,$h,$link);
1028
+	}
1029
+	}
955 1030
 
956 1031
 function GetX()
957 1032
 {
@@ -962,11 +1037,12 @@  discard block
 block discarded – undo
962 1037
 function SetX($x)
963 1038
 {
964 1039
 	// Set x position
965
-	if($x>=0)
966
-		$this->x = $x;
967
-	else
968
-		$this->x = $this->w+$x;
969
-}
1040
+	if($x>=0) {
1041
+			$this->x = $x;
1042
+	} else {
1043
+			$this->x = $this->w+$x;
1044
+	}
1045
+	}
970 1046
 
971 1047
 function GetY()
972 1048
 {
@@ -978,11 +1054,12 @@  discard block
 block discarded – undo
978 1054
 {
979 1055
 	// Set y position and reset x
980 1056
 	$this->x = $this->lMargin;
981
-	if($y>=0)
982
-		$this->y = $y;
983
-	else
984
-		$this->y = $this->h+$y;
985
-}
1057
+	if($y>=0) {
1058
+			$this->y = $y;
1059
+	} else {
1060
+			$this->y = $this->h+$y;
1061
+	}
1062
+	}
986 1063
 
987 1064
 function SetXY($x, $y)
988 1065
 {
@@ -994,8 +1071,9 @@  discard block
 block discarded – undo
994 1071
 function Output($name='', $dest='')
995 1072
 {
996 1073
 	// Output PDF to some destination
997
-	if($this->state<3)
998
-		$this->Close();
1074
+	if($this->state<3) {
1075
+			$this->Close();
1076
+	}
999 1077
 	$dest = strtoupper($dest);
1000 1078
 	if($dest=='')
1001 1079
 	{
@@ -1003,9 +1081,9 @@  discard block
 block discarded – undo
1003 1081
 		{
1004 1082
 			$name = 'doc.pdf';
1005 1083
 			$dest = 'I';
1006
-		}
1007
-		else
1008
-			$dest = 'F';
1084
+		} else {
1085
+					$dest = 'F';
1086
+		}
1009 1087
 	}
1010 1088
 	switch($dest)
1011 1089
 	{
@@ -1035,8 +1113,9 @@  discard block
 block discarded – undo
1035 1113
 		case 'F':
1036 1114
 			// Save to local file
1037 1115
 			$f = fopen($name,'wb');
1038
-			if(!$f)
1039
-				$this->Error('Unable to create output file: '.$name);
1116
+			if(!$f) {
1117
+							$this->Error('Unable to create output file: '.$name);
1118
+			}
1040 1119
 			fwrite($f,$this->buffer,strlen($this->buffer));
1041 1120
 			fclose($f);
1042 1121
 			break;
@@ -1057,22 +1136,26 @@  discard block
 block discarded – undo
1057 1136
 function _dochecks()
1058 1137
 {
1059 1138
 	// Check availability of %F
1060
-	if(sprintf('%.1F',1.0)!='1.0')
1061
-		$this->Error('This version of PHP is not supported');
1139
+	if(sprintf('%.1F',1.0)!='1.0') {
1140
+			$this->Error('This version of PHP is not supported');
1141
+	}
1062 1142
 	// Check mbstring overloading
1063
-	if(ini_get('mbstring.func_overload') & 2)
1064
-		$this->Error('mbstring overloading must be disabled');
1143
+	if(ini_get('mbstring.func_overload') & 2) {
1144
+			$this->Error('mbstring overloading must be disabled');
1145
+	}
1065 1146
 	// Ensure runtime magic quotes are disabled
1066
-	if(get_magic_quotes_runtime())
1067
-		@set_magic_quotes_runtime(0);
1068
-}
1147
+	if(get_magic_quotes_runtime()) {
1148
+			@set_magic_quotes_runtime(0);
1149
+	}
1150
+	}
1069 1151
 
1070 1152
 function _checkoutput()
1071 1153
 {
1072 1154
 	if(PHP_SAPI!='cli')
1073 1155
 	{
1074
-		if(headers_sent($file,$line))
1075
-			$this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
1156
+		if(headers_sent($file,$line)) {
1157
+					$this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
1158
+		}
1076 1159
 	}
1077 1160
 	if(ob_get_length())
1078 1161
 	{
@@ -1081,9 +1164,9 @@  discard block
 block discarded – undo
1081 1164
 		{
1082 1165
 			// It contains only a UTF-8 BOM and/or whitespace, let's clean it
1083 1166
 			ob_clean();
1084
-		}
1085
-		else
1086
-			$this->Error("Some data has already been output, can't send PDF file");
1167
+		} else {
1168
+					$this->Error("Some data has already been output, can't send PDF file");
1169
+		}
1087 1170
 	}
1088 1171
 }
1089 1172
 
@@ -1092,17 +1175,18 @@  discard block
 block discarded – undo
1092 1175
 	if(is_string($size))
1093 1176
 	{
1094 1177
 		$size = strtolower($size);
1095
-		if(!isset($this->StdPageSizes[$size]))
1096
-			$this->Error('Unknown page size: '.$size);
1178
+		if(!isset($this->StdPageSizes[$size])) {
1179
+					$this->Error('Unknown page size: '.$size);
1180
+		}
1097 1181
 		$a = $this->StdPageSizes[$size];
1098 1182
 		return array($a[0]/$this->k, $a[1]/$this->k);
1099
-	}
1100
-	else
1183
+	} else
1101 1184
 	{
1102
-		if($size[0]>$size[1])
1103
-			return array($size[1], $size[0]);
1104
-		else
1105
-			return $size;
1185
+		if($size[0]>$size[1]) {
1186
+					return array($size[1], $size[0]);
1187
+		} else {
1188
+					return $size;
1189
+		}
1106 1190
 	}
1107 1191
 }
1108 1192
 
@@ -1115,14 +1199,16 @@  discard block
 block discarded – undo
1115 1199
 	$this->y = $this->tMargin;
1116 1200
 	$this->FontFamily = '';
1117 1201
 	// Check page size and orientation
1118
-	if($orientation=='')
1119
-		$orientation = $this->DefOrientation;
1120
-	else
1121
-		$orientation = strtoupper($orientation[0]);
1122
-	if($size=='')
1123
-		$size = $this->DefPageSize;
1124
-	else
1125
-		$size = $this->_getpagesize($size);
1202
+	if($orientation=='') {
1203
+			$orientation = $this->DefOrientation;
1204
+	} else {
1205
+			$orientation = strtoupper($orientation[0]);
1206
+	}
1207
+	if($size=='') {
1208
+			$size = $this->DefPageSize;
1209
+	} else {
1210
+			$size = $this->_getpagesize($size);
1211
+	}
1126 1212
 	if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1])
1127 1213
 	{
1128 1214
 		// New size or orientation
@@ -1130,8 +1216,7 @@  discard block
 block discarded – undo
1130 1216
 		{
1131 1217
 			$this->w = $size[0];
1132 1218
 			$this->h = $size[1];
1133
-		}
1134
-		else
1219
+		} else
1135 1220
 		{
1136 1221
 			$this->w = $size[1];
1137 1222
 			$this->h = $size[0];
@@ -1142,9 +1227,10 @@  discard block
 block discarded – undo
1142 1227
 		$this->CurOrientation = $orientation;
1143 1228
 		$this->CurPageSize = $size;
1144 1229
 	}
1145
-	if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1])
1146
-		$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
1147
-}
1230
+	if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) {
1231
+			$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
1232
+	}
1233
+	}
1148 1234
 
1149 1235
 function _endpage()
1150 1236
 {
@@ -1156,8 +1242,9 @@  discard block
 block discarded – undo
1156 1242
 	// Load a font definition file from the font directory
1157 1243
 	include($this->fontpath.$font);
1158 1244
 	$a = get_defined_vars();
1159
-	if(!isset($a['name']))
1160
-		$this->Error('Could not include font definition file');
1245
+	if(!isset($a['name'])) {
1246
+			$this->Error('Could not include font definition file');
1247
+	}
1161 1248
 	return $a;
1162 1249
 }
1163 1250
 
@@ -1193,15 +1280,13 @@  discard block
 block discarded – undo
1193 1280
 			$c3 = ord($s[$i++]);
1194 1281
 			$res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
1195 1282
 			$res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
1196
-		}
1197
-		elseif($c1>=192)
1283
+		} elseif($c1>=192)
1198 1284
 		{
1199 1285
 			// 2-byte character
1200 1286
 			$c2 = ord($s[$i++]);
1201 1287
 			$res .= chr(($c1 & 0x1C)>>2);
1202 1288
 			$res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
1203
-		}
1204
-		else
1289
+		} else
1205 1290
 		{
1206 1291
 			// Single-byte character
1207 1292
 			$res .= "\0".chr($c1);
@@ -1223,16 +1308,19 @@  discard block
 block discarded – undo
1223 1308
 {
1224 1309
 	// Extract info from a JPEG file
1225 1310
 	$a = getimagesize($file);
1226
-	if(!$a)
1227
-		$this->Error('Missing or incorrect image file: '.$file);
1228
-	if($a[2]!=2)
1229
-		$this->Error('Not a JPEG file: '.$file);
1230
-	if(!isset($a['channels']) || $a['channels']==3)
1231
-		$colspace = 'DeviceRGB';
1232
-	elseif($a['channels']==4)
1233
-		$colspace = 'DeviceCMYK';
1234
-	else
1235
-		$colspace = 'DeviceGray';
1311
+	if(!$a) {
1312
+			$this->Error('Missing or incorrect image file: '.$file);
1313
+	}
1314
+	if($a[2]!=2) {
1315
+			$this->Error('Not a JPEG file: '.$file);
1316
+	}
1317
+	if(!isset($a['channels']) || $a['channels']==3) {
1318
+			$colspace = 'DeviceRGB';
1319
+	} elseif($a['channels']==4) {
1320
+			$colspace = 'DeviceCMYK';
1321
+	} else {
1322
+			$colspace = 'DeviceGray';
1323
+	}
1236 1324
 	$bpc = isset($a['bits']) ? $a['bits'] : 8;
1237 1325
 	$data = file_get_contents($file);
1238 1326
 	return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
@@ -1242,8 +1330,9 @@  discard block
 block discarded – undo
1242 1330
 {
1243 1331
 	// Extract info from a PNG file
1244 1332
 	$f = fopen($file,'rb');
1245
-	if(!$f)
1246
-		$this->Error('Can\'t open image file: '.$file);
1333
+	if(!$f) {
1334
+			$this->Error('Can\'t open image file: '.$file);
1335
+	}
1247 1336
 	$info = $this->_parsepngstream($f,$file);
1248 1337
 	fclose($f);
1249 1338
 	return $info;
@@ -1252,33 +1341,40 @@  discard block
 block discarded – undo
1252 1341
 function _parsepngstream($f, $file)
1253 1342
 {
1254 1343
 	// Check signature
1255
-	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1256
-		$this->Error('Not a PNG file: '.$file);
1344
+	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
1345
+			$this->Error('Not a PNG file: '.$file);
1346
+	}
1257 1347
 
1258 1348
 	// Read header chunk
1259 1349
 	$this->_readstream($f,4);
1260
-	if($this->_readstream($f,4)!='IHDR')
1261
-		$this->Error('Incorrect PNG file: '.$file);
1350
+	if($this->_readstream($f,4)!='IHDR') {
1351
+			$this->Error('Incorrect PNG file: '.$file);
1352
+	}
1262 1353
 	$w = $this->_readint($f);
1263 1354
 	$h = $this->_readint($f);
1264 1355
 	$bpc = ord($this->_readstream($f,1));
1265
-	if($bpc>8)
1266
-		$this->Error('16-bit depth not supported: '.$file);
1356
+	if($bpc>8) {
1357
+			$this->Error('16-bit depth not supported: '.$file);
1358
+	}
1267 1359
 	$ct = ord($this->_readstream($f,1));
1268
-	if($ct==0 || $ct==4)
1269
-		$colspace = 'DeviceGray';
1270
-	elseif($ct==2 || $ct==6)
1271
-		$colspace = 'DeviceRGB';
1272
-	elseif($ct==3)
1273
-		$colspace = 'Indexed';
1274
-	else
1275
-		$this->Error('Unknown color type: '.$file);
1276
-	if(ord($this->_readstream($f,1))!=0)
1277
-		$this->Error('Unknown compression method: '.$file);
1278
-	if(ord($this->_readstream($f,1))!=0)
1279
-		$this->Error('Unknown filter method: '.$file);
1280
-	if(ord($this->_readstream($f,1))!=0)
1281
-		$this->Error('Interlacing not supported: '.$file);
1360
+	if($ct==0 || $ct==4) {
1361
+			$colspace = 'DeviceGray';
1362
+	} elseif($ct==2 || $ct==6) {
1363
+			$colspace = 'DeviceRGB';
1364
+	} elseif($ct==3) {
1365
+			$colspace = 'Indexed';
1366
+	} else {
1367
+			$this->Error('Unknown color type: '.$file);
1368
+	}
1369
+	if(ord($this->_readstream($f,1))!=0) {
1370
+			$this->Error('Unknown compression method: '.$file);
1371
+	}
1372
+	if(ord($this->_readstream($f,1))!=0) {
1373
+			$this->Error('Unknown filter method: '.$file);
1374
+	}
1375
+	if(ord($this->_readstream($f,1))!=0) {
1376
+			$this->Error('Interlacing not supported: '.$file);
1377
+	}
1282 1378
 	$this->_readstream($f,4);
1283 1379
 	$dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w;
1284 1380
 
@@ -1295,44 +1391,45 @@  discard block
 block discarded – undo
1295 1391
 			// Read palette
1296 1392
 			$pal = $this->_readstream($f,$n);
1297 1393
 			$this->_readstream($f,4);
1298
-		}
1299
-		elseif($type=='tRNS')
1394
+		} elseif($type=='tRNS')
1300 1395
 		{
1301 1396
 			// Read transparency info
1302 1397
 			$t = $this->_readstream($f,$n);
1303
-			if($ct==0)
1304
-				$trns = array(ord(substr($t,1,1)));
1305
-			elseif($ct==2)
1306
-				$trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
1307
-			else
1398
+			if($ct==0) {
1399
+							$trns = array(ord(substr($t,1,1)));
1400
+			} elseif($ct==2) {
1401
+							$trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
1402
+			} else
1308 1403
 			{
1309 1404
 				$pos = strpos($t,chr(0));
1310
-				if($pos!==false)
1311
-					$trns = array($pos);
1405
+				if($pos!==false) {
1406
+									$trns = array($pos);
1407
+				}
1312 1408
 			}
1313 1409
 			$this->_readstream($f,4);
1314
-		}
1315
-		elseif($type=='IDAT')
1410
+		} elseif($type=='IDAT')
1316 1411
 		{
1317 1412
 			// Read image data block
1318 1413
 			$data .= $this->_readstream($f,$n);
1319 1414
 			$this->_readstream($f,4);
1320
-		}
1321
-		elseif($type=='IEND')
1322
-			break;
1323
-		else
1324
-			$this->_readstream($f,$n+4);
1415
+		} elseif($type=='IEND') {
1416
+					break;
1417
+		} else {
1418
+					$this->_readstream($f,$n+4);
1419
+		}
1325 1420
 	}
1326 1421
 	while($n);
1327 1422
 
1328
-	if($colspace=='Indexed' && empty($pal))
1329
-		$this->Error('Missing palette in '.$file);
1423
+	if($colspace=='Indexed' && empty($pal)) {
1424
+			$this->Error('Missing palette in '.$file);
1425
+	}
1330 1426
 	$info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns);
1331 1427
 	if($ct>=4)
1332 1428
 	{
1333 1429
 		// Extract alpha channel
1334
-		if(!function_exists('gzuncompress'))
1335
-			$this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
1430
+		if(!function_exists('gzuncompress')) {
1431
+					$this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
1432
+		}
1336 1433
 		$data = gzuncompress($data);
1337 1434
 		$color = '';
1338 1435
 		$alpha = '';
@@ -1349,8 +1446,7 @@  discard block
 block discarded – undo
1349 1446
 				$color .= preg_replace('/(.)./s','$1',$line);
1350 1447
 				$alpha .= preg_replace('/.(.)/s','$1',$line);
1351 1448
 			}
1352
-		}
1353
-		else
1449
+		} else
1354 1450
 		{
1355 1451
 			// RGB image
1356 1452
 			$len = 4*$w;
@@ -1367,8 +1463,9 @@  discard block
 block discarded – undo
1367 1463
 		unset($data);
1368 1464
 		$data = gzcompress($color);
1369 1465
 		$info['smask'] = gzcompress($alpha);
1370
-		if($this->PDFVersion<'1.4')
1371
-			$this->PDFVersion = '1.4';
1466
+		if($this->PDFVersion<'1.4') {
1467
+					$this->PDFVersion = '1.4';
1468
+		}
1372 1469
 	}
1373 1470
 	$info['data'] = $data;
1374 1471
 	return $info;
@@ -1381,13 +1478,15 @@  discard block
 block discarded – undo
1381 1478
 	while($n>0 && !feof($f))
1382 1479
 	{
1383 1480
 		$s = fread($f,$n);
1384
-		if($s===false)
1385
-			$this->Error('Error while reading stream');
1481
+		if($s===false) {
1482
+					$this->Error('Error while reading stream');
1483
+		}
1386 1484
 		$n -= strlen($s);
1387 1485
 		$res .= $s;
1388 1486
 	}
1389
-	if($n>0)
1390
-		$this->Error('Unexpected end of stream');
1487
+	if($n>0) {
1488
+			$this->Error('Unexpected end of stream');
1489
+	}
1391 1490
 	return $res;
1392 1491
 }
1393 1492
 
@@ -1401,13 +1500,16 @@  discard block
 block discarded – undo
1401 1500
 function _parsegif($file)
1402 1501
 {
1403 1502
 	// Extract info from a GIF file (via PNG conversion)
1404
-	if(!function_exists('imagepng'))
1405
-		$this->Error('GD extension is required for GIF support');
1406
-	if(!function_exists('imagecreatefromgif'))
1407
-		$this->Error('GD has no GIF read support');
1503
+	if(!function_exists('imagepng')) {
1504
+			$this->Error('GD extension is required for GIF support');
1505
+	}
1506
+	if(!function_exists('imagecreatefromgif')) {
1507
+			$this->Error('GD has no GIF read support');
1508
+	}
1408 1509
 	$im = imagecreatefromgif($file);
1409
-	if(!$im)
1410
-		$this->Error('Missing or incorrect image file: '.$file);
1510
+	if(!$im) {
1511
+			$this->Error('Missing or incorrect image file: '.$file);
1512
+	}
1411 1513
 	imageinterlace($im,0);
1412 1514
 	$f = @fopen('php://temp','rb+');
1413 1515
 	if($f)
@@ -1421,15 +1523,16 @@  discard block
 block discarded – undo
1421 1523
 		rewind($f);
1422 1524
 		$info = $this->_parsepngstream($f,$file);
1423 1525
 		fclose($f);
1424
-	}
1425
-	else
1526
+	} else
1426 1527
 	{
1427 1528
 		// Use temporary file
1428 1529
 		$tmp = tempnam('.','gif');
1429
-		if(!$tmp)
1430
-			$this->Error('Unable to create a temporary file');
1431
-		if(!imagepng($im,$tmp))
1432
-			$this->Error('Error while saving to temporary file');
1530
+		if(!$tmp) {
1531
+					$this->Error('Unable to create a temporary file');
1532
+		}
1533
+		if(!imagepng($im,$tmp)) {
1534
+					$this->Error('Error while saving to temporary file');
1535
+		}
1433 1536
 		imagedestroy($im);
1434 1537
 		$info = $this->_parsepng($tmp);
1435 1538
 		unlink($tmp);
@@ -1455,11 +1558,12 @@  discard block
 block discarded – undo
1455 1558
 function _out($s)
1456 1559
 {
1457 1560
 	// Add a line to the document
1458
-	if($this->state==2)
1459
-		$this->pages[$this->page] .= $s."\n";
1460
-	else
1461
-		$this->buffer .= $s."\n";
1462
-}
1561
+	if($this->state==2) {
1562
+			$this->pages[$this->page] .= $s."\n";
1563
+	} else {
1564
+			$this->buffer .= $s."\n";
1565
+	}
1566
+	}
1463 1567
 
1464 1568
 function _putpages()
1465 1569
 {
@@ -1467,15 +1571,15 @@  discard block
 block discarded – undo
1467 1571
 	if(!empty($this->AliasNbPages))
1468 1572
 	{
1469 1573
 		// Replace number of pages
1470
-		for($n=1;$n<=$nb;$n++)
1471
-			$this->pages[$n] = str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
1574
+		for($n=1;$n<=$nb;$n++) {
1575
+					$this->pages[$n] = str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
1576
+		}
1472 1577
 	}
1473 1578
 	if($this->DefOrientation=='P')
1474 1579
 	{
1475 1580
 		$wPt = $this->DefPageSize[0]*$this->k;
1476 1581
 		$hPt = $this->DefPageSize[1]*$this->k;
1477
-	}
1478
-	else
1582
+	} else
1479 1583
 	{
1480 1584
 		$wPt = $this->DefPageSize[1]*$this->k;
1481 1585
 		$hPt = $this->DefPageSize[0]*$this->k;
@@ -1487,8 +1591,9 @@  discard block
 block discarded – undo
1487 1591
 		$this->_newobj();
1488 1592
 		$this->_out('<</Type /Page');
1489 1593
 		$this->_out('/Parent 1 0 R');
1490
-		if(isset($this->PageSizes[$n]))
1491
-			$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
1594
+		if(isset($this->PageSizes[$n])) {
1595
+					$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
1596
+		}
1492 1597
 		$this->_out('/Resources 2 0 R');
1493 1598
 		if(isset($this->PageLinks[$n]))
1494 1599
 		{
@@ -1498,9 +1603,9 @@  discard block
 block discarded – undo
1498 1603
 			{
1499 1604
 				$rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
1500 1605
 				$annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1501
-				if(is_string($pl[4]))
1502
-					$annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1503
-				else
1606
+				if(is_string($pl[4])) {
1607
+									$annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1608
+				} else
1504 1609
 				{
1505 1610
 					$l = $this->links[$pl[4]];
1506 1611
 					$h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
@@ -1509,8 +1614,9 @@  discard block
 block discarded – undo
1509 1614
 			}
1510 1615
 			$this->_out($annots.']');
1511 1616
 		}
1512
-		if($this->PDFVersion>'1.3')
1513
-			$this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
1617
+		if($this->PDFVersion>'1.3') {
1618
+					$this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
1619
+		}
1514 1620
 		$this->_out('/Contents '.($this->n+1).' 0 R>>');
1515 1621
 		$this->_out('endobj');
1516 1622
 		// Page content
@@ -1525,8 +1631,9 @@  discard block
 block discarded – undo
1525 1631
 	$this->_out('1 0 obj');
1526 1632
 	$this->_out('<</Type /Pages');
1527 1633
 	$kids = '/Kids [';
1528
-	for($i=0;$i<$nb;$i++)
1529
-		$kids .= (3+2*$i).' 0 R ';
1634
+	for($i=0;$i<$nb;$i++) {
1635
+			$kids .= (3+2*$i).' 0 R ';
1636
+	}
1530 1637
 	$this->_out($kids.']');
1531 1638
 	$this->_out('/Count '.$nb);
1532 1639
 	$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt));
@@ -1550,17 +1657,21 @@  discard block
 block discarded – undo
1550 1657
 		$this->_newobj();
1551 1658
 		$this->FontFiles[$file]['n'] = $this->n;
1552 1659
 		$font = file_get_contents($this->fontpath.$file,true);
1553
-		if(!$font)
1554
-			$this->Error('Font file not found: '.$file);
1660
+		if(!$font) {
1661
+					$this->Error('Font file not found: '.$file);
1662
+		}
1555 1663
 		$compressed = (substr($file,-2)=='.z');
1556
-		if(!$compressed && isset($info['length2']))
1557
-			$font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']);
1664
+		if(!$compressed && isset($info['length2'])) {
1665
+					$font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']);
1666
+		}
1558 1667
 		$this->_out('<</Length '.strlen($font));
1559
-		if($compressed)
1560
-			$this->_out('/Filter /FlateDecode');
1668
+		if($compressed) {
1669
+					$this->_out('/Filter /FlateDecode');
1670
+		}
1561 1671
 		$this->_out('/Length1 '.$info['length1']);
1562
-		if(isset($info['length2']))
1563
-			$this->_out('/Length2 '.$info['length2'].' /Length3 0');
1672
+		if(isset($info['length2'])) {
1673
+					$this->_out('/Length2 '.$info['length2'].' /Length3 0');
1674
+		}
1564 1675
 		$this->_out('>>');
1565 1676
 		$this->_putstream($font);
1566 1677
 		$this->_out('endobj');
@@ -1578,12 +1689,12 @@  discard block
 block discarded – undo
1578 1689
 			$this->_out('<</Type /Font');
1579 1690
 			$this->_out('/BaseFont /'.$name);
1580 1691
 			$this->_out('/Subtype /Type1');
1581
-			if($name!='Symbol' && $name!='ZapfDingbats')
1582
-				$this->_out('/Encoding /WinAnsiEncoding');
1692
+			if($name!='Symbol' && $name!='ZapfDingbats') {
1693
+							$this->_out('/Encoding /WinAnsiEncoding');
1694
+			}
1583 1695
 			$this->_out('>>');
1584 1696
 			$this->_out('endobj');
1585
-		}
1586
-		elseif($type=='Type1' || $type=='TrueType')
1697
+		} elseif($type=='Type1' || $type=='TrueType')
1587 1698
 		{
1588 1699
 			// Additional Type1 or TrueType/OpenType font
1589 1700
 			$this->_newobj();
@@ -1593,36 +1704,40 @@  discard block
 block discarded – undo
1593 1704
 			$this->_out('/FirstChar 32 /LastChar 255');
1594 1705
 			$this->_out('/Widths '.($this->n+1).' 0 R');
1595 1706
 			$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
1596
-			if(isset($font['diffn']))
1597
-				$this->_out('/Encoding '.($nf+$font['diffn']).' 0 R');
1598
-			else
1599
-				$this->_out('/Encoding /WinAnsiEncoding');
1707
+			if(isset($font['diffn'])) {
1708
+							$this->_out('/Encoding '.($nf+$font['diffn']).' 0 R');
1709
+			} else {
1710
+							$this->_out('/Encoding /WinAnsiEncoding');
1711
+			}
1600 1712
 			$this->_out('>>');
1601 1713
 			$this->_out('endobj');
1602 1714
 			// Widths
1603 1715
 			$this->_newobj();
1604 1716
 			$cw = &$font['cw'];
1605 1717
 			$s = '[';
1606
-			for($i=32;$i<=255;$i++)
1607
-				$s .= $cw[chr($i)].' ';
1718
+			for($i=32;$i<=255;$i++) {
1719
+							$s .= $cw[chr($i)].' ';
1720
+			}
1608 1721
 			$this->_out($s.']');
1609 1722
 			$this->_out('endobj');
1610 1723
 			// Descriptor
1611 1724
 			$this->_newobj();
1612 1725
 			$s = '<</Type /FontDescriptor /FontName /'.$name;
1613
-			foreach($font['desc'] as $k=>$v)
1614
-				$s .= ' /'.$k.' '.$v;
1615
-			if(!empty($font['file']))
1616
-				$s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R';
1726
+			foreach($font['desc'] as $k=>$v) {
1727
+							$s .= ' /'.$k.' '.$v;
1728
+			}
1729
+			if(!empty($font['file'])) {
1730
+							$s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R';
1731
+			}
1617 1732
 			$this->_out($s.'>>');
1618 1733
 			$this->_out('endobj');
1619
-		}
1620
-		else
1734
+		} else
1621 1735
 		{
1622 1736
 			// Allow for additional types
1623 1737
 			$mtd = '_put'.strtolower($type);
1624
-			if(!method_exists($this,$mtd))
1625
-				$this->Error('Unsupported font type: '.$type);
1738
+			if(!method_exists($this,$mtd)) {
1739
+							$this->Error('Unsupported font type: '.$type);
1740
+			}
1626 1741
 			$this->$mtd($font);
1627 1742
 		}
1628 1743
 	}
@@ -1646,28 +1761,33 @@  discard block
 block discarded – undo
1646 1761
 	$this->_out('/Subtype /Image');
1647 1762
 	$this->_out('/Width '.$info['w']);
1648 1763
 	$this->_out('/Height '.$info['h']);
1649
-	if($info['cs']=='Indexed')
1650
-		$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
1651
-	else
1764
+	if($info['cs']=='Indexed') {
1765
+			$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
1766
+	} else
1652 1767
 	{
1653 1768
 		$this->_out('/ColorSpace /'.$info['cs']);
1654
-		if($info['cs']=='DeviceCMYK')
1655
-			$this->_out('/Decode [1 0 1 0 1 0 1 0]');
1769
+		if($info['cs']=='DeviceCMYK') {
1770
+					$this->_out('/Decode [1 0 1 0 1 0 1 0]');
1771
+		}
1656 1772
 	}
1657 1773
 	$this->_out('/BitsPerComponent '.$info['bpc']);
1658
-	if(isset($info['f']))
1659
-		$this->_out('/Filter /'.$info['f']);
1660
-	if(isset($info['dp']))
1661
-		$this->_out('/DecodeParms <<'.$info['dp'].'>>');
1774
+	if(isset($info['f'])) {
1775
+			$this->_out('/Filter /'.$info['f']);
1776
+	}
1777
+	if(isset($info['dp'])) {
1778
+			$this->_out('/DecodeParms <<'.$info['dp'].'>>');
1779
+	}
1662 1780
 	if(isset($info['trns']) && is_array($info['trns']))
1663 1781
 	{
1664 1782
 		$trns = '';
1665
-		for($i=0;$i<count($info['trns']);$i++)
1666
-			$trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
1783
+		for($i=0;$i<count($info['trns']);$i++) {
1784
+					$trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
1785
+		}
1667 1786
 		$this->_out('/Mask ['.$trns.']');
1668 1787
 	}
1669
-	if(isset($info['smask']))
1670
-		$this->_out('/SMask '.($this->n+1).' 0 R');
1788
+	if(isset($info['smask'])) {
1789
+			$this->_out('/SMask '.($this->n+1).' 0 R');
1790
+	}
1671 1791
 	$this->_out('/Length '.strlen($info['data']).'>>');
1672 1792
 	$this->_putstream($info['data']);
1673 1793
 	$this->_out('endobj');
@@ -1692,16 +1812,18 @@  discard block
 block discarded – undo
1692 1812
 
1693 1813
 function _putxobjectdict()
1694 1814
 {
1695
-	foreach($this->images as $image)
1696
-		$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
1697
-}
1815
+	foreach($this->images as $image) {
1816
+			$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
1817
+	}
1818
+	}
1698 1819
 
1699 1820
 function _putresourcedict()
1700 1821
 {
1701 1822
 	$this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
1702 1823
 	$this->_out('/Font <<');
1703
-	foreach($this->fonts as $font)
1704
-		$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
1824
+	foreach($this->fonts as $font) {
1825
+			$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
1826
+	}
1705 1827
 	$this->_out('>>');
1706 1828
 	$this->_out('/XObject <<');
1707 1829
 	$this->_putxobjectdict();
@@ -1724,16 +1846,21 @@  discard block
 block discarded – undo
1724 1846
 function _putinfo()
1725 1847
 {
1726 1848
 	$this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
1727
-	if(!empty($this->title))
1728
-		$this->_out('/Title '.$this->_textstring($this->title));
1729
-	if(!empty($this->subject))
1730
-		$this->_out('/Subject '.$this->_textstring($this->subject));
1731
-	if(!empty($this->author))
1732
-		$this->_out('/Author '.$this->_textstring($this->author));
1733
-	if(!empty($this->keywords))
1734
-		$this->_out('/Keywords '.$this->_textstring($this->keywords));
1735
-	if(!empty($this->creator))
1736
-		$this->_out('/Creator '.$this->_textstring($this->creator));
1849
+	if(!empty($this->title)) {
1850
+			$this->_out('/Title '.$this->_textstring($this->title));
1851
+	}
1852
+	if(!empty($this->subject)) {
1853
+			$this->_out('/Subject '.$this->_textstring($this->subject));
1854
+	}
1855
+	if(!empty($this->author)) {
1856
+			$this->_out('/Author '.$this->_textstring($this->author));
1857
+	}
1858
+	if(!empty($this->keywords)) {
1859
+			$this->_out('/Keywords '.$this->_textstring($this->keywords));
1860
+	}
1861
+	if(!empty($this->creator)) {
1862
+			$this->_out('/Creator '.$this->_textstring($this->creator));
1863
+	}
1737 1864
 	$this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
1738 1865
 }
1739 1866
 
@@ -1741,21 +1868,23 @@  discard block
 block discarded – undo
1741 1868
 {
1742 1869
 	$this->_out('/Type /Catalog');
1743 1870
 	$this->_out('/Pages 1 0 R');
1744
-	if($this->ZoomMode=='fullpage')
1745
-		$this->_out('/OpenAction [3 0 R /Fit]');
1746
-	elseif($this->ZoomMode=='fullwidth')
1747
-		$this->_out('/OpenAction [3 0 R /FitH null]');
1748
-	elseif($this->ZoomMode=='real')
1749
-		$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
1750
-	elseif(!is_string($this->ZoomMode))
1751
-		$this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']');
1752
-	if($this->LayoutMode=='single')
1753
-		$this->_out('/PageLayout /SinglePage');
1754
-	elseif($this->LayoutMode=='continuous')
1755
-		$this->_out('/PageLayout /OneColumn');
1756
-	elseif($this->LayoutMode=='two')
1757
-		$this->_out('/PageLayout /TwoColumnLeft');
1758
-}
1871
+	if($this->ZoomMode=='fullpage') {
1872
+			$this->_out('/OpenAction [3 0 R /Fit]');
1873
+	} elseif($this->ZoomMode=='fullwidth') {
1874
+			$this->_out('/OpenAction [3 0 R /FitH null]');
1875
+	} elseif($this->ZoomMode=='real') {
1876
+			$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
1877
+	} elseif(!is_string($this->ZoomMode)) {
1878
+			$this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']');
1879
+	}
1880
+	if($this->LayoutMode=='single') {
1881
+			$this->_out('/PageLayout /SinglePage');
1882
+	} elseif($this->LayoutMode=='continuous') {
1883
+			$this->_out('/PageLayout /OneColumn');
1884
+	} elseif($this->LayoutMode=='two') {
1885
+			$this->_out('/PageLayout /TwoColumnLeft');
1886
+	}
1887
+	}
1759 1888
 
1760 1889
 function _putheader()
1761 1890
 {
@@ -1791,8 +1920,9 @@  discard block
 block discarded – undo
1791 1920
 	$this->_out('xref');
1792 1921
 	$this->_out('0 '.($this->n+1));
1793 1922
 	$this->_out('0000000000 65535 f ');
1794
-	for($i=1;$i<=$this->n;$i++)
1795
-		$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
1923
+	for($i=1;$i<=$this->n;$i++) {
1924
+			$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
1925
+	}
1796 1926
 	// Trailer
1797 1927
 	$this->_out('trailer');
1798 1928
 	$this->_out('<<');
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Form_validation.php 1 patch
Braces   +31 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php  if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * CodeIgniter
4 6
  *
@@ -128,8 +130,7 @@  discard block
 block discarded – undo
128 130
 			}
129 131
 
130 132
 			$is_array = TRUE;
131
-		}
132
-		else
133
+		} else
133 134
 		{
134 135
 			$indexes	= array();
135 136
 			$is_array	= FALSE;
@@ -333,8 +334,7 @@  discard block
 block discarded – undo
333 334
 			if ($uri != '' AND isset($this->_config_rules[$uri]))
334 335
 			{
335 336
 				$this->set_rules($this->_config_rules[$uri]);
336
-			}
337
-			else
337
+			} else
338 338
 			{
339 339
 				$this->set_rules($this->_config_rules);
340 340
 			}
@@ -360,8 +360,7 @@  discard block
 block discarded – undo
360 360
 			if ($row['is_array'] == TRUE)
361 361
 			{
362 362
 				$this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']);
363
-			}
364
-			else
363
+			} else
365 364
 			{
366 365
 				if (isset($_POST[$field]) AND $_POST[$field] != "")
367 366
 				{
@@ -413,13 +412,11 @@  discard block
 block discarded – undo
413 412
 				if (isset($array[$keys[$i]]))
414 413
 				{
415 414
 					$array = $this->_reduce_array($array[$keys[$i]], $keys, ($i+1));
416
-				}
417
-				else
415
+				} else
418 416
 				{
419 417
 					return NULL;
420 418
 				}
421
-			}
422
-			else
419
+			} else
423 420
 			{
424 421
 				return $array;
425 422
 			}
@@ -448,8 +445,7 @@  discard block
 block discarded – undo
448 445
 					{
449 446
 						$_POST[$row['field']] = $this->prep_for_form($row['postdata']);
450 447
 					}
451
-				}
452
-				else
448
+				} else
453 449
 				{
454 450
 					// start with a reference
455 451
 					$post_ref =& $_POST;
@@ -458,8 +454,7 @@  discard block
 block discarded – undo
458 454
 					if (count($row['keys']) == 1)
459 455
 					{
460 456
 						$post_ref =& $post_ref[current($row['keys'])];
461
-					}
462
-					else
457
+					} else
463 458
 					{
464 459
 						foreach ($row['keys'] as $val)
465 460
 						{
@@ -476,8 +471,7 @@  discard block
 block discarded – undo
476 471
 						}
477 472
 
478 473
 						$post_ref = $array;
479
-					}
480
-					else
474
+					} else
481 475
 					{
482 476
 						$post_ref = $this->prep_for_form($row['postdata']);
483 477
 					}
@@ -525,8 +519,7 @@  discard block
 block discarded – undo
525 519
 			{
526 520
 				$callback = TRUE;
527 521
 				$rules = (array('1' => $match[1]));
528
-			}
529
-			else
522
+			} else
530 523
 			{
531 524
 				return;
532 525
 			}
@@ -548,8 +541,7 @@  discard block
 block discarded – undo
548 541
 					{
549 542
 						$line = 'The field was not set';
550 543
 					}
551
-				}
552
-				else
544
+				} else
553 545
 				{
554 546
 					$line = $this->_error_messages[$type];
555 547
 				}
@@ -588,8 +580,7 @@  discard block
 block discarded – undo
588 580
 
589 581
 				$postdata = $this->_field_data[$row['field']]['postdata'][$cycles];
590 582
 				$_in_array = TRUE;
591
-			}
592
-			else
583
+			} else
593 584
 			{
594 585
 				$postdata = $this->_field_data[$row['field']]['postdata'];
595 586
 			}
@@ -628,8 +619,7 @@  discard block
 block discarded – undo
628 619
 				if ($_in_array == TRUE)
629 620
 				{
630 621
 					$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
631
-				}
632
-				else
622
+				} else
633 623
 				{
634 624
 					$this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
635 625
 				}
@@ -639,8 +629,7 @@  discard block
 block discarded – undo
639 629
 				{
640 630
 					continue;
641 631
 				}
642
-			}
643
-			else
632
+			} else
644 633
 			{
645 634
 				if ( ! method_exists($this, $rule))
646 635
 				{
@@ -661,13 +650,11 @@  discard block
 block discarded – undo
661 650
 						if ($_in_array == TRUE)
662 651
 						{
663 652
 							$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
664
-						}
665
-						else
653
+						} else
666 654
 						{
667 655
 							$this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
668 656
 						}
669
-					}
670
-					else
657
+					} else
671 658
 					{
672 659
 						log_message('debug', "Unable to find validation rule: ".$rule);
673 660
 					}
@@ -680,8 +667,7 @@  discard block
 block discarded – undo
680 667
 				if ($_in_array == TRUE)
681 668
 				{
682 669
 					$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
683
-				}
684
-				else
670
+				} else
685 671
 				{
686 672
 					$this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
687 673
 				}
@@ -696,8 +682,7 @@  discard block
 block discarded – undo
696 682
 					{
697 683
 						$line = 'Unable to access an error message corresponding to your field name.';
698 684
 					}
699
-				}
700
-				else
685
+				} else
701 686
 				{
702 687
 					$line = $this->_error_messages[$rule];
703 688
 				}
@@ -815,8 +800,7 @@  discard block
 block discarded – undo
815 800
 			{
816 801
 				return '';
817 802
 			}
818
-		}
819
-		else
803
+		} else
820 804
 		{
821 805
 			if (($field == '' OR $value == '') OR ($field != $value))
822 806
 			{
@@ -859,8 +843,7 @@  discard block
 block discarded – undo
859 843
 			{
860 844
 				return '';
861 845
 			}
862
-		}
863
-		else
846
+		} else
864 847
 		{
865 848
 			if (($field == '' OR $value == '') OR ($field != $value))
866 849
 			{
@@ -903,8 +886,7 @@  discard block
 block discarded – undo
903 886
 			{
904 887
 				return '';
905 888
 			}
906
-		}
907
-		else
889
+		} else
908 890
 		{
909 891
 			if (($field == '' OR $value == '') OR ($field != $value))
910 892
 			{
@@ -929,8 +911,7 @@  discard block
 block discarded – undo
929 911
 		if ( ! is_array($str))
930 912
 		{
931 913
 			return (trim($str) == '') ? FALSE : TRUE;
932
-		}
933
-		else
914
+		} else
934 915
 		{
935 916
 			return ( ! empty($str));
936 917
 		}
@@ -994,8 +975,9 @@  discard block
 block discarded – undo
994 975
 		$data =explode('.', $field);
995 976
                 $table=$data[0];
996 977
                 $field=$data[1];
997
-                if(isset($data[2]))
998
-                $id=$data[2];
978
+                if(isset($data[2])) {
979
+                                $id=$data[2];
980
+                }
999 981
                 $where=array($field => $str);
1000 982
                 if($id != ''){
1001 983
                  $where['id !=']=$id;
@@ -1463,10 +1445,10 @@  discard block
 block discarded – undo
1463 1445
               $password=$this->CI->common->decode($result['password']);
1464 1446
               if($password && $password == $str){
1465 1447
                   return true;
1466
-              }else{
1448
+              } else{
1467 1449
                   return false;
1468 1450
               }
1469
-          }else{
1451
+          } else{
1470 1452
               return false;
1471 1453
           }
1472 1454
         }
@@ -1480,10 +1462,10 @@  discard block
 block discarded – undo
1480 1462
 	      $available_bal = ($customer_info["balance"]) + $customer_info["posttoexternal"] * ($customer_info["credit_limit"]);
1481 1463
 	      if($available_bal >= $post_array['setup']){
1482 1464
 	       return TRUE;
1483
-	      }else{
1465
+	      } else{
1484 1466
 	       return FALSE;
1485 1467
 	      }
1486
-          }else{
1468
+          } else{
1487 1469
            return TRUE;
1488 1470
           }
1489 1471
         }
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Calendar.php 1 patch
Braces   +27 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php  if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * CodeIgniter
4 6
  *
@@ -98,20 +100,25 @@  discard block
 block discarded – undo
98 100
 	function generate($year = '', $month = '', $data = array())
99 101
 	{
100 102
 		// Set and validate the supplied month/year
101
-		if ($year == '')
102
-			$year  = date("Y", $this->local_time);
103
+		if ($year == '') {
104
+					$year  = date("Y", $this->local_time);
105
+		}
103 106
 
104
-		if ($month == '')
105
-			$month = date("m", $this->local_time);
107
+		if ($month == '') {
108
+					$month = date("m", $this->local_time);
109
+		}
106 110
 
107
-		if (strlen($year) == 1)
108
-			$year = '200'.$year;
111
+		if (strlen($year) == 1) {
112
+					$year = '200'.$year;
113
+		}
109 114
 
110
-		if (strlen($year) == 2)
111
-			$year = '20'.$year;
115
+		if (strlen($year) == 2) {
116
+					$year = '20'.$year;
117
+		}
112 118
 
113
-		if (strlen($month) == 1)
114
-			$month = '0'.$month;
119
+		if (strlen($month) == 1) {
120
+					$month = '0'.$month;
121
+		}
115 122
 
116 123
 		$adjusted_date = $this->adjust_date($month, $year);
117 124
 
@@ -219,15 +226,13 @@  discard block
 block discarded – undo
219 226
 						// Cells with content
220 227
 						$temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
221 228
 						$out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp));
222
-					}
223
-					else
229
+					} else
224 230
 					{
225 231
 						// Cells with no content
226 232
 						$temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
227 233
 						$out .= str_replace('{day}', $day, $temp);
228 234
 					}
229
-				}
230
-				else
235
+				} else
231 236
 				{
232 237
 					// Blank cells
233 238
 					$out .= $this->temp['cal_cell_blank'];
@@ -265,8 +270,7 @@  discard block
 block discarded – undo
265 270
 		if ($this->month_type == 'short')
266 271
 		{
267 272
 			$month_names = array('01' => 'cal_jan', '02' => 'cal_feb', '03' => 'cal_mar', '04' => 'cal_apr', '05' => 'cal_may', '06' => 'cal_jun', '07' => 'cal_jul', '08' => 'cal_aug', '09' => 'cal_sep', '10' => 'cal_oct', '11' => 'cal_nov', '12' => 'cal_dec');
268
-		}
269
-		else
273
+		} else
270 274
 		{
271 275
 			$month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_november', '12' => 'cal_december');
272 276
 		}
@@ -295,18 +299,17 @@  discard block
 block discarded – undo
295 299
 	 */
296 300
 	function get_day_names($day_type = '')
297 301
 	{
298
-		if ($day_type != '')
299
-			$this->day_type = $day_type;
302
+		if ($day_type != '') {
303
+					$this->day_type = $day_type;
304
+		}
300 305
 
301 306
 		if ($this->day_type == 'long')
302 307
 		{
303 308
 			$day_names = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
304
-		}
305
-		elseif ($this->day_type == 'short')
309
+		} elseif ($this->day_type == 'short')
306 310
 		{
307 311
 			$day_names = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
308
-		}
309
-		else
312
+		} else
310 313
 		{
311 314
 			$day_names = array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa');
312 315
 		}
@@ -456,8 +459,7 @@  discard block
 block discarded – undo
456 459
 			if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match))
457 460
 			{
458 461
 				$this->temp[$val] = $match['1'];
459
-			}
460
-			else
462
+			} else
461 463
 			{
462 464
 				if (in_array($val, $today, TRUE))
463 465
 				{
Please login to merge, or discard this patch.