Completed
Pull Request — v3.0 (#136)
by
unknown
25:07
created
web_interface/astpp/system/helpers/url_helper.php 3 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -39,6 +39,9 @@  discard block
 block discarded – undo
39 39
  */
40 40
 if ( ! function_exists('site_url'))
41 41
 {
42
+	/**
43
+	 * @return integer|null
44
+	 */
42 45
 	function site_url($uri = '')
43 46
 	{
44 47
 		$CI =& get_instance();
@@ -61,6 +64,9 @@  discard block
 block discarded – undo
61 64
  */
62 65
 if ( ! function_exists('base_url'))
63 66
 {
67
+	/**
68
+	 * @return string
69
+	 */
64 70
 	function base_url($uri = '')
65 71
 	{
66 72
 		$CI =& get_instance();
@@ -262,6 +268,9 @@  discard block
 block discarded – undo
262 268
  */
263 269
 if ( ! function_exists('safe_mailto'))
264 270
 {
271
+	/**
272
+	 * @param string $email
273
+	 */
265 274
 	function safe_mailto($email, $title = '', $attributes = '')
266 275
 	{
267 276
 		$title = (string) $title;
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 {
42 42
 	function site_url($uri = '')
43 43
 	{
44
-		$CI =& get_instance();
44
+		$CI = & get_instance();
45 45
 		return $CI->config->site_url($uri);
46 46
 	}
47 47
 }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 {
64 64
 	function base_url($uri = '')
65 65
 	{
66
-		$CI =& get_instance();
66
+		$CI = & get_instance();
67 67
 		return $CI->config->base_url($uri);
68 68
 	}
69 69
 }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 {
84 84
 	function current_url()
85 85
 	{
86
-		$CI =& get_instance();
86
+		$CI = & get_instance();
87 87
 		return $CI->config->site_url($CI->uri->uri_string());
88 88
 	}
89 89
 }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 {
102 102
 	function uri_string()
103 103
 	{
104
-		$CI =& get_instance();
104
+		$CI = & get_instance();
105 105
 		return $CI->uri->uri_string();
106 106
 	}
107 107
 }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 {
121 121
 	function index_page()
122 122
 	{
123
-		$CI =& get_instance();
123
+		$CI = & get_instance();
124 124
 		return $CI->config->item('index_page');
125 125
 	}
126 126
 }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 {
143 143
 	function anchor($uri = '', $title = '', $attributes = '')
144 144
 	{
145
-		$title = (string) $title;
145
+		$title = (string)$title;
146 146
 
147 147
 		if ( ! is_array($uri))
148 148
 		{
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 {
186 186
 	function anchor_popup($uri = '', $title = '', $attributes = FALSE)
187 187
 	{
188
-		$title = (string) $title;
188
+		$title = (string)$title;
189 189
 
190 190
 		$site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
191 191
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 			$attributes = array();
205 205
 		}
206 206
 
207
-		foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val)
207
+		foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0',) as $key => $val)
208 208
 		{
209 209
 			$atts[$key] = ( ! isset($attributes[$key])) ? $val : $attributes[$key];
210 210
 			unset($attributes[$key]);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 {
235 235
 	function mailto($email, $title = '', $attributes = '')
236 236
 	{
237
-		$title = (string) $title;
237
+		$title = (string)$title;
238 238
 
239 239
 		if ($title == "")
240 240
 		{
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 {
265 265
 	function safe_mailto($email, $title = '', $attributes = '')
266 266
 	{
267
-		$title = (string) $title;
267
+		$title = (string)$title;
268 268
 
269 269
 		if ($title == "")
270 270
 		{
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 			{
290 290
 				foreach ($attributes as $key => $val)
291 291
 				{
292
-					$x[] =  ' '.$key.'="';
292
+					$x[] = ' '.$key.'="';
293 293
 					for ($i = 0; $i < strlen($val); $i++)
294 294
 					{
295 295
 						$x[] = "|".ord(substr($val, $i, 1));
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	var l=new Array();
346 346
 	<?php
347 347
 	$i = 0;
348
-	foreach ($x as $val){ ?>l[<?php echo $i++; ?>]='<?php echo $val; ?>';<?php } ?>
348
+	foreach ($x as $val) { ?>l[<?php echo $i++; ?>]='<?php echo $val; ?>';<?php } ?>
349 349
 
350 350
 	for (var i = l.length-1; i >= 0; i=i-1){
351 351
 	if (l[i].substring(0, 1) == '|') document.write("&#"+unescape(l[i].substring(1))+";");
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 			$uri = site_url($uri);
540 540
 		}
541 541
 
542
-		switch($method)
542
+		switch ($method)
543 543
 		{
544 544
 			case 'refresh'	: header("Refresh:0;url=".$uri);
545 545
 				break;
@@ -576,11 +576,11 @@  discard block
 block discarded – undo
576 576
 		{
577 577
 			if ($javascript == TRUE)
578 578
 			{
579
-				$att .= $key . '=' . $val . ',';
579
+				$att .= $key.'='.$val.',';
580 580
 			}
581 581
 			else
582 582
 			{
583
-				$att .= ' ' . $key . '="' . $val . '"';
583
+				$att .= ' '.$key.'="'.$val.'"';
584 584
 			}
585 585
 		}
586 586
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -11 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
  *
@@ -147,8 +149,7 @@  discard block
 block discarded – undo
147 149
 		if ( ! is_array($uri))
148 150
 		{
149 151
 			$site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
150
-		}
151
-		else
152
+		} else
152 153
 		{
153 154
 			$site_url = site_url($uri);
154 155
 		}
@@ -296,8 +297,7 @@  discard block
 block discarded – undo
296 297
 					}
297 298
 					$x[] = '"';
298 299
 				}
299
-			}
300
-			else
300
+			} else
301 301
 			{
302 302
 				for ($i = 0; $i < strlen($attributes); $i++)
303 303
 				{
@@ -316,8 +316,7 @@  discard block
 block discarded – undo
316 316
 			if ($ordinal < 128)
317 317
 			{
318 318
 				$x[] = "|".$ordinal;
319
-			}
320
-			else
319
+			} else
321 320
 			{
322 321
 				if (count($temp) == 0)
323 322
 				{
@@ -482,8 +481,7 @@  discard block
 block discarded – undo
482 481
 		{
483 482
 			$search		= '_';
484 483
 			$replace	= '-';
485
-		}
486
-		else
484
+		} else
487 485
 		{
488 486
 			$search		= '-';
489 487
 			$replace	= '_';
@@ -577,8 +575,7 @@  discard block
 block discarded – undo
577 575
 			if ($javascript == TRUE)
578 576
 			{
579 577
 				$att .= $key . '=' . $val . ',';
580
-			}
581
-			else
578
+			} else
582 579
 			{
583 580
 				$att .= ' ' . $key . '="' . $val . '"';
584 581
 			}
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Cart.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @access	public
82 82
 	 * @param	array
83
-	 * @return	bool
83
+	 * @return	string|boolean
84 84
 	 */
85 85
 	function insert($items = array())
86 86
 	{
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @access	private
137 137
 	 * @param	array
138
-	 * @return	bool
138
+	 * @return	false|string
139 139
 	 */
140 140
 	function _insert($items = array())
141 141
 	{
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 	 * that has options associated with it.
470 470
 	 *
471 471
 	 * @access	public
472
-	 * @return	array
472
+	 * @return	boolean
473 473
 	 */
474 474
 	function has_options($rowid = '')
475 475
 	{
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 	 * Returns the supplied number with commas and a decimal point.
510 510
 	 *
511 511
 	 * @access	public
512
-	 * @return	integer
512
+	 * @return	string
513 513
 	 */
514 514
 	function format_number($n = '')
515 515
 	{
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
 class CI_Cart {
28 28
 
29 29
 	// These are the regular expression rules that we use to validate the product ID and product name
30
-	var $product_id_rules	= '\.a-z0-9_-'; // alpha-numeric, dashes, underscores, or periods
31
-	var $product_name_rules	= '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods
30
+	var $product_id_rules = '\.a-z0-9_-'; // alpha-numeric, dashes, underscores, or periods
31
+	var $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods
32 32
 
33 33
 	// Private variables.  Do not change!
34 34
 	var $CI;
35
-	var $_cart_contents	= array();
35
+	var $_cart_contents = array();
36 36
 
37 37
 
38 38
 	/**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	public function __construct($params = array())
44 44
 	{
45 45
 		// Set the super object to a local variable for use later
46
-		$this->CI =& get_instance();
46
+		$this->CI = & get_instance();
47 47
 
48 48
 		// Are any config settings being passed manually?  If so, set them
49 49
 		$config = array();
Please login to merge, or discard this patch.
Braces   +8 added lines, -11 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
  *
@@ -62,8 +64,7 @@  discard block
 block discarded – undo
62 64
 		if ($this->CI->session->userdata('cart_contents') !== FALSE)
63 65
 		{
64 66
 			$this->_cart_contents = $this->CI->session->userdata('cart_contents');
65
-		}
66
-		else
67
+		} else
67 68
 		{
68 69
 			// No cart exists so we'll set some base values
69 70
 			$this->_cart_contents['cart_total'] = 0;
@@ -103,8 +104,7 @@  discard block
 block discarded – undo
103 104
 			{
104 105
 				$save_cart = TRUE;
105 106
 			}
106
-		}
107
-		else
107
+		} else
108 108
 		{
109 109
 			foreach ($items as $val)
110 110
 			{
@@ -218,8 +218,7 @@  discard block
 block discarded – undo
218 218
 		if (isset($items['options']) AND count($items['options']) > 0)
219 219
 		{
220 220
 			$rowid = md5($items['id'].implode('', $items['options']));
221
-		}
222
-		else
221
+		} else
223 222
 		{
224 223
 			// No options were submitted so we simply MD5 the product ID.
225 224
 			// Technically, we don't need to MD5 the ID in this case, but it makes
@@ -281,8 +280,7 @@  discard block
 block discarded – undo
281 280
 			{
282 281
 				$save_cart = TRUE;
283 282
 			}
284
-		}
285
-		else
283
+		} else
286 284
 		{
287 285
 			foreach ($items as $val)
288 286
 			{
@@ -349,8 +347,7 @@  discard block
 block discarded – undo
349 347
 		if ($items['qty'] == 0)
350 348
 		{
351 349
 			unset($this->_cart_contents[$items['rowid']]);
352
-		}
353
-		else
350
+		} else
354 351
 		{
355 352
 			$this->_cart_contents[$items['rowid']]['qty'] = $items['qty'];
356 353
 		}
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Email.php 3 patches
Doc Comments   +28 added lines, -22 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @access	public
107 107
 	 * @param	array
108
-	 * @return	void
108
+	 * @return	CI_Email
109 109
 	 */
110 110
 	public function initialize($config = array())
111 111
 	{
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 * Initialize the Email Data
140 140
 	 *
141 141
 	 * @access	public
142
-	 * @return	void
142
+	 * @return	CI_Email
143 143
 	 */
144 144
 	public function clear($clear_attachments = FALSE)
145 145
 	{
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 * @access	public
176 176
 	 * @param	string
177 177
 	 * @param	string
178
-	 * @return	void
178
+	 * @return	CI_Email
179 179
 	 */
180 180
 	public function from($from, $name = '')
181 181
 	{
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @access	public
219 219
 	 * @param	string
220 220
 	 * @param	string
221
-	 * @return	void
221
+	 * @return	CI_Email
222 222
 	 */
223 223
 	public function reply_to($replyto, $name = '')
224 224
 	{
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 *
256 256
 	 * @access	public
257 257
 	 * @param	string
258
-	 * @return	void
258
+	 * @return	CI_Email
259 259
 	 */
260 260
 	public function to($to)
261 261
 	{
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @access	public
295 295
 	 * @param	string
296
-	 * @return	void
296
+	 * @return	CI_Email
297 297
 	 */
298 298
 	public function cc($cc)
299 299
 	{
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	 * @access	public
324 324
 	 * @param	string
325 325
 	 * @param	string
326
-	 * @return	void
326
+	 * @return	CI_Email
327 327
 	 */
328 328
 	public function bcc($bcc, $limit = '')
329 329
 	{
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 *
361 361
 	 * @access	public
362 362
 	 * @param	string
363
-	 * @return	void
363
+	 * @return	CI_Email
364 364
 	 */
365 365
 	public function subject($subject)
366 366
 	{
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	 *
377 377
 	 * @access	public
378 378
 	 * @param	string
379
-	 * @return	void
379
+	 * @return	CI_Email
380 380
 	 */
381 381
 	public function message($body)
382 382
 	{
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	 *
404 404
 	 * @access	public
405 405
 	 * @param	string
406
-	 * @return	void
406
+	 * @return	CI_Email
407 407
 	 */
408 408
 	public function attach($filename, $disposition = 'attachment')
409 409
 	{
@@ -421,6 +421,7 @@  discard block
 block discarded – undo
421 421
 	 * @access	protected
422 422
 	 * @param	string
423 423
 	 * @param	string
424
+	 * @param string $header
424 425
 	 * @return	void
425 426
 	 */
426 427
 	protected function _set_header($header, $value)
@@ -461,7 +462,7 @@  discard block
 block discarded – undo
461 462
 	 *
462 463
 	 * @access	public
463 464
 	 * @param	string
464
-	 * @return	void
465
+	 * @return	CI_Email
465 466
 	 */
466 467
 	public function set_alt_message($str = '')
467 468
 	{
@@ -476,7 +477,7 @@  discard block
 block discarded – undo
476 477
 	 *
477 478
 	 * @access	public
478 479
 	 * @param	string
479
-	 * @return	void
480
+	 * @return	CI_Email
480 481
 	 */
481 482
 	public function set_mailtype($type = 'text')
482 483
 	{
@@ -491,7 +492,7 @@  discard block
 block discarded – undo
491 492
 	 *
492 493
 	 * @access	public
493 494
 	 * @param	string
494
-	 * @return	void
495
+	 * @return	CI_Email
495 496
 	 */
496 497
 	public function set_wordwrap($wordwrap = TRUE)
497 498
 	{
@@ -506,7 +507,7 @@  discard block
 block discarded – undo
506 507
 	 *
507 508
 	 * @access	public
508 509
 	 * @param	string
509
-	 * @return	void
510
+	 * @return	CI_Email
510 511
 	 */
511 512
 	public function set_protocol($protocol = 'mail')
512 513
 	{
@@ -521,7 +522,7 @@  discard block
 block discarded – undo
521 522
 	 *
522 523
 	 * @access	public
523 524
 	 * @param	integer
524
-	 * @return	void
525
+	 * @return	null|CI_Email
525 526
 	 */
526 527
 	public function set_priority($n = 3)
527 528
 	{
@@ -548,7 +549,7 @@  discard block
 block discarded – undo
548 549
 	 *
549 550
 	 * @access	public
550 551
 	 * @param	string
551
-	 * @return	void
552
+	 * @return	null|CI_Email
552 553
 	 */
553 554
 	public function set_newline($newline = "\n")
554 555
 	{
@@ -570,7 +571,7 @@  discard block
 block discarded – undo
570 571
 	 *
571 572
 	 * @access	public
572 573
 	 * @param	string
573
-	 * @return	void
574
+	 * @return	null|CI_Email
574 575
 	 */
575 576
 	public function set_crlf($crlf = "\n")
576 577
 	{
@@ -861,6 +862,7 @@  discard block
 block discarded – undo
861 862
 	 * @access	public
862 863
 	 * @param	string
863 864
 	 * @param	integer
865
+	 * @param string $str
864 866
 	 * @return	string
865 867
 	 */
866 868
 	public function word_wrap($str, $charlim = '')
@@ -1008,7 +1010,7 @@  discard block
 block discarded – undo
1008 1010
 	 * Build Final Body and attachments
1009 1011
 	 *
1010 1012
 	 * @access	protected
1011
-	 * @return	void
1013
+	 * @return	null|false
1012 1014
 	 */
1013 1015
 	protected function _build_message()
1014 1016
 	{
@@ -1193,6 +1195,7 @@  discard block
 block discarded – undo
1193 1195
 	 * @access	protected
1194 1196
 	 * @param	string
1195 1197
 	 * @param	integer
1198
+	 * @param string $str
1196 1199
 	 * @return	string
1197 1200
 	 */
1198 1201
 	protected function _prep_quoted_printable($str, $charlim = '')
@@ -1353,7 +1356,7 @@  discard block
 block discarded – undo
1353 1356
 	 * Send Email
1354 1357
 	 *
1355 1358
 	 * @access	public
1356
-	 * @return	bool
1359
+	 * @return	boolean|null
1357 1360
 	 */
1358 1361
 	public function send()
1359 1362
 	{
@@ -1396,7 +1399,7 @@  discard block
 block discarded – undo
1396 1399
 	 * Batch Bcc Send.  Sends groups of BCCs in batches
1397 1400
 	 *
1398 1401
 	 * @access	public
1399
-	 * @return	bool
1402
+	 * @return	boolean|null
1400 1403
 	 */
1401 1404
 	public function batch_bcc_send()
1402 1405
 	{
@@ -1675,7 +1678,7 @@  discard block
 block discarded – undo
1675 1678
 	 *
1676 1679
 	 * @access	protected
1677 1680
 	 * @param	string
1678
-	 * @return	string
1681
+	 * @return	boolean
1679 1682
 	 */
1680 1683
 	protected function _smtp_connect()
1681 1684
 	{
@@ -1714,7 +1717,8 @@  discard block
 block discarded – undo
1714 1717
 	 * @access	protected
1715 1718
 	 * @param	string
1716 1719
 	 * @param	string
1717
-	 * @return	string
1720
+	 * @param string $cmd
1721
+	 * @return	boolean
1718 1722
 	 */
1719 1723
 	protected function _send_command($cmd, $data = '')
1720 1724
 	{
@@ -1840,6 +1844,7 @@  discard block
 block discarded – undo
1840 1844
 	 *
1841 1845
 	 * @access	protected
1842 1846
 	 * @return	bool
1847
+	 * @param string $data
1843 1848
 	 */
1844 1849
 	protected function _send_data($data)
1845 1850
 	{
@@ -1965,6 +1970,7 @@  discard block
 block discarded – undo
1965 1970
 	 *
1966 1971
 	 * @access	protected
1967 1972
 	 * @param	string
1973
+	 * @param string $msg
1968 1974
 	 * @return	string
1969 1975
 	 */
1970 1976
 	protected function _set_error_message($msg, $val = '')
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -29,51 +29,51 @@  discard block
 block discarded – undo
29 29
 class CI_Email {
30 30
 
31 31
 	var	$useragent		= "CodeIgniter";
32
-	var	$mailpath		= "/usr/sbin/sendmail";	// Sendmail path
33
-	var	$protocol		= "mail";	// mail/sendmail/smtp
34
-	var	$smtp_host		= "";		// SMTP Server.  Example: mail.earthlink.net
35
-	var	$smtp_user		= "";		// SMTP Username
36
-	var	$smtp_pass		= "";		// SMTP Password
37
-	var	$smtp_port		= "25";		// SMTP Port
38
-	var	$smtp_timeout	= 5;		// SMTP Timeout in seconds
39
-	var	$smtp_crypto	= "";		// SMTP Encryption. Can be null, tls or ssl.
40
-	var	$wordwrap		= TRUE;		// TRUE/FALSE  Turns word-wrap on/off
41
-	var	$wrapchars		= "76";		// Number of characters to wrap at.
42
-	var	$mailtype		= "text";	// text/html  Defines email formatting
43
-	var	$charset		= "utf-8";	// Default char set: iso-8859-1 or us-ascii
44
-	var	$multipart		= "mixed";	// "mixed" (in the body) or "related" (separate)
45
-	var $alt_message	= '';		// Alternative message for HTML emails
46
-	var	$validate		= FALSE;	// TRUE/FALSE.  Enables email validation
47
-	var	$priority		= "3";		// Default priority (1 - 5)
48
-	var	$newline		= "\n";		// Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
49
-	var $crlf			= "\n";		// The RFC 2045 compliant CRLF for quoted-printable is "\r\n".  Apparently some servers,
32
+	var	$mailpath		= "/usr/sbin/sendmail"; // Sendmail path
33
+	var	$protocol		= "mail"; // mail/sendmail/smtp
34
+	var	$smtp_host		= ""; // SMTP Server.  Example: mail.earthlink.net
35
+	var	$smtp_user		= ""; // SMTP Username
36
+	var	$smtp_pass		= ""; // SMTP Password
37
+	var	$smtp_port		= "25"; // SMTP Port
38
+	var	$smtp_timeout = 5; // SMTP Timeout in seconds
39
+	var	$smtp_crypto = ""; // SMTP Encryption. Can be null, tls or ssl.
40
+	var	$wordwrap		= TRUE; // TRUE/FALSE  Turns word-wrap on/off
41
+	var	$wrapchars		= "76"; // Number of characters to wrap at.
42
+	var	$mailtype		= "text"; // text/html  Defines email formatting
43
+	var	$charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii
44
+	var	$multipart		= "mixed"; // "mixed" (in the body) or "related" (separate)
45
+	var $alt_message = ''; // Alternative message for HTML emails
46
+	var	$validate		= FALSE; // TRUE/FALSE.  Enables email validation
47
+	var	$priority		= "3"; // Default priority (1 - 5)
48
+	var	$newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
49
+	var $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n".  Apparently some servers,
50 50
 									// even on the receiving end think they need to muck with CRLFs, so using "\n", while
51 51
 									// distasteful, is the only thing that seems to work for all environments.
52
-	var $send_multipart	= TRUE;		// TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override.  Set to FALSE for Yahoo.
53
-	var	$bcc_batch_mode	= FALSE;	// TRUE/FALSE  Turns on/off Bcc batch feature
54
-	var	$bcc_batch_size	= 200;		// If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
52
+	var $send_multipart	= TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override.  Set to FALSE for Yahoo.
53
+	var	$bcc_batch_mode	= FALSE; // TRUE/FALSE  Turns on/off Bcc batch feature
54
+	var	$bcc_batch_size	= 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
55 55
 	var $_safe_mode		= FALSE;
56
-	var	$_subject		= "";
57
-	var	$_body			= "";
56
+	var	$_subject = "";
57
+	var	$_body = "";
58 58
 	var	$_finalbody		= "";
59 59
 	var	$_alt_boundary	= "";
60 60
 	var	$_atc_boundary	= "";
61 61
 	var	$_header_str	= "";
62 62
 	var	$_smtp_connect	= "";
63
-	var	$_encoding		= "8bit";
64
-	var $_IP			= FALSE;
63
+	var	$_encoding = "8bit";
64
+	var $_IP = FALSE;
65 65
 	var	$_smtp_auth		= FALSE;
66
-	var $_replyto_flag	= FALSE;
66
+	var $_replyto_flag = FALSE;
67 67
 	var	$_debug_msg		= array();
68 68
 	var	$_recipients	= array();
69
-	var	$_cc_array		= array();
69
+	var	$_cc_array = array();
70 70
 	var	$_bcc_array		= array();
71
-	var	$_headers		= array();
71
+	var	$_headers = array();
72 72
 	var	$_attach_name	= array();
73 73
 	var	$_attach_type	= array();
74 74
 	var	$_attach_disp	= array();
75 75
 	var	$_protocols		= array('mail', 'sendmail', 'smtp');
76
-	var	$_base_charsets	= array('us-ascii', 'iso-2022-');	// 7-bit charsets (excluding language suffix)
76
+	var	$_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix)
77 77
 	var	$_bit_depths	= array('7bit', '8bit');
78 78
 	var	$_priorities	= array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)');
79 79
 
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function clear($clear_attachments = FALSE)
145 145
 	{
146
-		$this->_subject		= "";
147
-		$this->_body		= "";
148
-		$this->_finalbody	= "";
146
+		$this->_subject = "";
147
+		$this->_body = "";
148
+		$this->_finalbody = "";
149 149
 		$this->_header_str	= "";
150 150
 		$this->_replyto_flag = FALSE;
151 151
 		$this->_recipients	= array();
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	public function from($from, $name = '')
181 181
 	{
182
-		if (preg_match( '/\<(.*)\>/', $from, $match))
182
+		if (preg_match('/\<(.*)\>/', $from, $match))
183 183
 		{
184 184
 			$from = $match['1'];
185 185
 		}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	public function reply_to($replyto, $name = '')
224 224
 	{
225
-		if (preg_match( '/\<(.*)\>/', $replyto, $match))
225
+		if (preg_match('/\<(.*)\>/', $replyto, $match))
226 226
 		{
227 227
 			$replyto = $match['1'];
228 228
 		}
@@ -554,11 +554,11 @@  discard block
 block discarded – undo
554 554
 	{
555 555
 		if ($newline != "\n" AND $newline != "\r\n" AND $newline != "\r")
556 556
 		{
557
-			$this->newline	= "\n";
557
+			$this->newline = "\n";
558 558
 			return;
559 559
 		}
560 560
 
561
-		$this->newline	= $newline;
561
+		$this->newline = $newline;
562 562
 
563 563
 		return $this;
564 564
 	}
@@ -576,11 +576,11 @@  discard block
 block discarded – undo
576 576
 	{
577 577
 		if ($crlf != "\n" AND $crlf != "\r\n" AND $crlf != "\r")
578 578
 		{
579
-			$this->crlf	= "\n";
579
+			$this->crlf = "\n";
580 580
 			return;
581 581
 		}
582 582
 
583
-		$this->crlf	= $crlf;
583
+		$this->crlf = $crlf;
584 584
 
585 585
 		return $this;
586 586
 	}
@@ -673,15 +673,15 @@  discard block
 block discarded – undo
673 673
 	 */
674 674
 	protected function _get_content_type()
675 675
 	{
676
-		if	($this->mailtype == 'html' &&  count($this->_attach_name) == 0)
676
+		if ($this->mailtype == 'html' && count($this->_attach_name) == 0)
677 677
 		{
678 678
 			return 'html';
679 679
 		}
680
-		elseif	($this->mailtype == 'html' &&  count($this->_attach_name)  > 0)
680
+		elseif ($this->mailtype == 'html' && count($this->_attach_name) > 0)
681 681
 		{
682 682
 			return 'html-attach';
683 683
 		}
684
-		elseif	($this->mailtype == 'text' &&  count($this->_attach_name)  > 0)
684
+		elseif ($this->mailtype == 'text' && count($this->_attach_name) > 0)
685 685
 		{
686 686
 			return 'plain-attach';
687 687
 		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		$timezone = date("Z");
705 705
 		$operator = (strncmp($timezone, '-', 1) == 0) ? '-' : '+';
706 706
 		$timezone = abs($timezone);
707
-		$timezone = floor($timezone/3600) * 100 + ($timezone % 3600 ) / 60;
707
+		$timezone = floor($timezone / 3600) * 100 + ($timezone % 3600) / 60;
708 708
 
709 709
 		return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone);
710 710
 	}
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 
793 793
 		foreach ($email as $addy)
794 794
 		{
795
-			if (preg_match( '/\<(.*)\>/', $addy, $match))
795
+			if (preg_match('/\<(.*)\>/', $addy, $match))
796 796
 			{
797 797
 				$clean_email[] = $match['1'];
798 798
 			}
@@ -835,14 +835,14 @@  discard block
 block discarded – undo
835 835
 		}
836 836
 
837 837
 		$body = trim(strip_tags($body));
838
-		$body = preg_replace( '#<!--(.*)--\>#', "", $body);
838
+		$body = preg_replace('#<!--(.*)--\>#', "", $body);
839 839
 		$body = str_replace("\t", "", $body);
840 840
 
841 841
 		for ($i = 20; $i >= 3; $i--)
842 842
 		{
843 843
 			$n = "";
844 844
 
845
-			for ($x = 1; $x <= $i; $x ++)
845
+			for ($x = 1; $x <= $i; $x++)
846 846
 			{
847 847
 				$n .= "\n";
848 848
 			}
@@ -919,8 +919,8 @@  discard block
 block discarded – undo
919 919
 				}
920 920
 
921 921
 				// Trim the word down
922
-				$temp .= substr($line, 0, $charlim-1);
923
-				$line = substr($line, $charlim-1);
922
+				$temp .= substr($line, 0, $charlim - 1);
923
+				$line = substr($line, $charlim - 1);
924 924
 			}
925 925
 
926 926
 			// If $temp contains data it means we had to split up an over-length
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 	 */
1013 1013
 	protected function _build_message()
1014 1014
 	{
1015
-		if ($this->wordwrap === TRUE  AND  $this->mailtype != 'html')
1015
+		if ($this->wordwrap === TRUE AND $this->mailtype != 'html')
1016 1016
 		{
1017 1017
 			$this->_body = $this->word_wrap($this->_body);
1018 1018
 		}
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 		{
1028 1028
 			case 'plain' :
1029 1029
 
1030
-				$hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
1031
-				$hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
1030
+				$hdr .= "Content-Type: text/plain; charset=".$this->charset.$this->newline;
1031
+				$hdr .= "Content-Transfer-Encoding: ".$this->_get_encoding();
1032 1032
 
1033 1033
 				if ($this->_get_protocol() == 'mail')
1034 1034
 				{
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 				}
1038 1038
 				else
1039 1039
 				{
1040
-					$this->_finalbody = $hdr . $this->newline . $this->newline . $this->_body;
1040
+					$this->_finalbody = $hdr.$this->newline.$this->newline.$this->_body;
1041 1041
 				}
1042 1042
 
1043 1043
 				return;
@@ -1047,25 +1047,25 @@  discard block
 block discarded – undo
1047 1047
 
1048 1048
 				if ($this->send_multipart === FALSE)
1049 1049
 				{
1050
-					$hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
1050
+					$hdr .= "Content-Type: text/html; charset=".$this->charset.$this->newline;
1051 1051
 					$hdr .= "Content-Transfer-Encoding: quoted-printable";
1052 1052
 				}
1053 1053
 				else
1054 1054
 				{
1055
-					$hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline . $this->newline;
1055
+					$hdr .= "Content-Type: multipart/alternative; boundary=\"".$this->_alt_boundary."\"".$this->newline.$this->newline;
1056 1056
 
1057
-					$body .= $this->_get_mime_message() . $this->newline . $this->newline;
1058
-					$body .= "--" . $this->_alt_boundary . $this->newline;
1057
+					$body .= $this->_get_mime_message().$this->newline.$this->newline;
1058
+					$body .= "--".$this->_alt_boundary.$this->newline;
1059 1059
 
1060
-					$body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
1061
-					$body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
1062
-					$body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
1060
+					$body .= "Content-Type: text/plain; charset=".$this->charset.$this->newline;
1061
+					$body .= "Content-Transfer-Encoding: ".$this->_get_encoding().$this->newline.$this->newline;
1062
+					$body .= $this->_get_alt_message().$this->newline.$this->newline."--".$this->_alt_boundary.$this->newline;
1063 1063
 
1064
-					$body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
1065
-					$body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
1064
+					$body .= "Content-Type: text/html; charset=".$this->charset.$this->newline;
1065
+					$body .= "Content-Transfer-Encoding: quoted-printable".$this->newline.$this->newline;
1066 1066
 				}
1067 1067
 
1068
-				$this->_finalbody = $body . $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
1068
+				$this->_finalbody = $body.$this->_prep_quoted_printable($this->_body).$this->newline.$this->newline;
1069 1069
 
1070 1070
 
1071 1071
 				if ($this->_get_protocol() == 'mail')
@@ -1074,13 +1074,13 @@  discard block
 block discarded – undo
1074 1074
 				}
1075 1075
 				else
1076 1076
 				{
1077
-					$this->_finalbody = $hdr . $this->_finalbody;
1077
+					$this->_finalbody = $hdr.$this->_finalbody;
1078 1078
 				}
1079 1079
 
1080 1080
 
1081 1081
 				if ($this->send_multipart !== FALSE)
1082 1082
 				{
1083
-					$this->_finalbody .= "--" . $this->_alt_boundary . "--";
1083
+					$this->_finalbody .= "--".$this->_alt_boundary."--";
1084 1084
 				}
1085 1085
 
1086 1086
 				return;
@@ -1088,46 +1088,46 @@  discard block
 block discarded – undo
1088 1088
 			break;
1089 1089
 			case 'plain-attach' :
1090 1090
 
1091
-				$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;
1091
+				$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"".$this->_atc_boundary."\"".$this->newline.$this->newline;
1092 1092
 
1093 1093
 				if ($this->_get_protocol() == 'mail')
1094 1094
 				{
1095 1095
 					$this->_header_str .= $hdr;
1096 1096
 				}
1097 1097
 
1098
-				$body .= $this->_get_mime_message() . $this->newline . $this->newline;
1099
-				$body .= "--" . $this->_atc_boundary . $this->newline;
1098
+				$body .= $this->_get_mime_message().$this->newline.$this->newline;
1099
+				$body .= "--".$this->_atc_boundary.$this->newline;
1100 1100
 
1101
-				$body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
1102
-				$body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
1101
+				$body .= "Content-Type: text/plain; charset=".$this->charset.$this->newline;
1102
+				$body .= "Content-Transfer-Encoding: ".$this->_get_encoding().$this->newline.$this->newline;
1103 1103
 
1104
-				$body .= $this->_body . $this->newline . $this->newline;
1104
+				$body .= $this->_body.$this->newline.$this->newline;
1105 1105
 
1106 1106
 			break;
1107 1107
 			case 'html-attach' :
1108 1108
 
1109
-				$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;
1109
+				$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"".$this->_atc_boundary."\"".$this->newline.$this->newline;
1110 1110
 
1111 1111
 				if ($this->_get_protocol() == 'mail')
1112 1112
 				{
1113 1113
 					$this->_header_str .= $hdr;
1114 1114
 				}
1115 1115
 
1116
-				$body .= $this->_get_mime_message() . $this->newline . $this->newline;
1117
-				$body .= "--" . $this->_atc_boundary . $this->newline;
1116
+				$body .= $this->_get_mime_message().$this->newline.$this->newline;
1117
+				$body .= "--".$this->_atc_boundary.$this->newline;
1118 1118
 
1119
-				$body .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline;
1120
-				$body .= "--" . $this->_alt_boundary . $this->newline;
1119
+				$body .= "Content-Type: multipart/alternative; boundary=\"".$this->_alt_boundary."\"".$this->newline.$this->newline;
1120
+				$body .= "--".$this->_alt_boundary.$this->newline;
1121 1121
 
1122
-				$body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
1123
-				$body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
1124
-				$body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
1122
+				$body .= "Content-Type: text/plain; charset=".$this->charset.$this->newline;
1123
+				$body .= "Content-Transfer-Encoding: ".$this->_get_encoding().$this->newline.$this->newline;
1124
+				$body .= $this->_get_alt_message().$this->newline.$this->newline."--".$this->_alt_boundary.$this->newline;
1125 1125
 
1126
-				$body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
1127
-				$body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
1126
+				$body .= "Content-Type: text/html; charset=".$this->charset.$this->newline;
1127
+				$body .= "Content-Transfer-Encoding: quoted-printable".$this->newline.$this->newline;
1128 1128
 
1129
-				$body .= $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
1130
-				$body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
1129
+				$body .= $this->_prep_quoted_printable($this->_body).$this->newline.$this->newline;
1130
+				$body .= "--".$this->_alt_boundary."--".$this->newline.$this->newline;
1131 1131
 
1132 1132
 			break;
1133 1133
 		}
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 
1137 1137
 		$z = 0;
1138 1138
 
1139
-		for ($i=0; $i < count($this->_attach_name); $i++)
1139
+		for ($i = 0; $i < count($this->_attach_name); $i++)
1140 1140
 		{
1141 1141
 			$filename = $this->_attach_name[$i];
1142 1142
 			$basename = basename($filename);
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			$h .= "Content-Transfer-Encoding: base64".$this->newline;
1156 1156
 
1157 1157
 			$attachment[$z++] = $h;
1158
-			$file = filesize($filename) +1;
1158
+			$file = filesize($filename) + 1;
1159 1159
 
1160 1160
 			if ( ! $fp = fopen($filename, FOPEN_READ))
1161 1161
 			{
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 		}
1177 1177
 		else
1178 1178
 		{
1179
-			$this->_finalbody = $hdr . $body;
1179
+			$this->_finalbody = $hdr.$body;
1180 1180
 		}
1181 1181
 
1182 1182
 		return;
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 				// encode = signs
1251 1251
 				if ($ascii == '61')
1252 1252
 				{
1253
-					$char = $escape.strtoupper(sprintf('%02s', dechex($ascii)));  // =3D
1253
+					$char = $escape.strtoupper(sprintf('%02s', dechex($ascii))); // =3D
1254 1254
 				}
1255 1255
 
1256 1256
 				// If we're at the character limit, add the line to the output,
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
 			$this->reply_to($this->_headers['From']);
1363 1363
 		}
1364 1364
 
1365
-		if (( ! isset($this->_recipients) AND ! isset($this->_headers['To']))  AND
1365
+		if (( ! isset($this->_recipients) AND ! isset($this->_headers['To'])) AND
1366 1366
 			( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND
1367 1367
 			( ! isset($this->_headers['Cc'])))
1368 1368
 		{
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
 
1373 1373
 		$this->_build_headers();
1374 1374
 
1375
-		if ($this->bcc_batch_mode  AND  count($this->_bcc_array) > 0)
1375
+		if ($this->bcc_batch_mode AND count($this->_bcc_array) > 0)
1376 1376
 		{
1377 1377
 			if (count($this->_bcc_array) > $this->bcc_batch_size)
1378 1378
 				return $this->batch_bcc_send();
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 	 */
1401 1401
 	public function batch_bcc_send()
1402 1402
 	{
1403
-		$float = $this->bcc_batch_size -1;
1403
+		$float = $this->bcc_batch_size - 1;
1404 1404
 
1405 1405
 		$set = "";
1406 1406
 
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
 				$set = "";
1421 1421
 			}
1422 1422
 
1423
-			if ($i == count($this->_bcc_array)-1)
1423
+			if ($i == count($this->_bcc_array) - 1)
1424 1424
 			{
1425 1425
 				$chunk[] = substr($set, 1);
1426 1426
 			}
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
 	 */
1572 1572
 	protected function _send_with_sendmail()
1573 1573
 	{
1574
-		$fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w');
1574
+		$fp = @popen($this->mailpath." -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w');
1575 1575
 
1576 1576
 		if ($fp === FALSE OR $fp === NULL)
1577 1577
 		{
@@ -1650,7 +1650,7 @@  discard block
 block discarded – undo
1650 1650
 		$this->_send_command('data');
1651 1651
 
1652 1652
 		// perform dot transformation on any lines that begin with a dot
1653
-		$this->_send_data($this->_header_str . preg_replace('/^\./m', '..$1', $this->_finalbody));
1653
+		$this->_send_data($this->_header_str.preg_replace('/^\./m', '..$1', $this->_finalbody));
1654 1654
 
1655 1655
 		$this->_send_data('.');
1656 1656
 
@@ -1794,7 +1794,7 @@  discard block
 block discarded – undo
1794 1794
 			return TRUE;
1795 1795
 		}
1796 1796
 
1797
-		if ($this->smtp_user == ""  AND  $this->smtp_pass == "")
1797
+		if ($this->smtp_user == "" AND $this->smtp_pass == "")
1798 1798
 		{
1799 1799
 			$this->_set_error_message('lang:email_no_smtp_unpw');
1800 1800
 			return FALSE;
@@ -1843,7 +1843,7 @@  discard block
 block discarded – undo
1843 1843
 	 */
1844 1844
 	protected function _send_data($data)
1845 1845
 	{
1846
-		if ( ! fwrite($this->_smtp_connect, $data . $this->newline))
1846
+		if ( ! fwrite($this->_smtp_connect, $data.$this->newline))
1847 1847
 		{
1848 1848
 			$this->_set_error_message('lang:email_smtp_data_failure', $data);
1849 1849
 			return FALSE;
@@ -1922,7 +1922,7 @@  discard block
 block discarded – undo
1922 1922
 			$this->_IP = end($x);
1923 1923
 		}
1924 1924
 
1925
-		if ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $this->_IP))
1925
+		if ( ! preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $this->_IP))
1926 1926
 		{
1927 1927
 			$this->_IP = '0.0.0.0';
1928 1928
 		}
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
 	 */
1970 1970
 	protected function _set_error_message($msg, $val = '')
1971 1971
 	{
1972
-		$CI =& get_instance();
1972
+		$CI = & get_instance();
1973 1973
 		$CI->lang->load('email');
1974 1974
 
1975 1975
 		if (substr($msg, 0, 5) != 'lang:' || FALSE === ($line = $CI->lang->line(substr($msg, 5))))
@@ -1993,7 +1993,7 @@  discard block
 block discarded – undo
1993 1993
 	 */
1994 1994
 	protected function _mime_types($ext = "")
1995 1995
 	{
1996
-		$mimes = array(	'hqx'	=>	'application/mac-binhex40',
1996
+		$mimes = array('hqx'	=>	'application/mac-binhex40',
1997 1997
 						'cpt'	=>	'application/mac-compactpro',
1998 1998
 						'doc'	=>	'application/msword',
1999 1999
 						'bin'	=>	'application/macbinary',
Please login to merge, or discard this patch.
Braces   +46 added lines, -59 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
  *
@@ -88,8 +90,7 @@  discard block
 block discarded – undo
88 90
 		if (count($config) > 0)
89 91
 		{
90 92
 			$this->initialize($config);
91
-		}
92
-		else
93
+		} else
93 94
 		{
94 95
 			$this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;
95 96
 			$this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE;
@@ -118,8 +119,7 @@  discard block
 block discarded – undo
118 119
 				if (method_exists($this, $method))
119 120
 				{
120 121
 					$this->$method($val);
121
-				}
122
-				else
122
+				} else
123 123
 				{
124 124
 					$this->$key = $val;
125 125
 				}
@@ -197,8 +197,7 @@  discard block
 block discarded – undo
197 197
 			{
198 198
 				// add slashes for non-printing characters, slashes, and double quotes, and surround it in double quotes
199 199
 				$name = '"'.addcslashes($name, "\0..\37\177'\"\\").'"';
200
-			}
201
-			else
200
+			} else
202 201
 			{
203 202
 				$name = $this->_prep_q_encoding($name, TRUE);
204 203
 			}
@@ -344,8 +343,7 @@  discard block
 block discarded – undo
344 343
 		if (($this->_get_protocol() == "smtp") OR ($this->bcc_batch_mode && count($bcc) > $this->bcc_batch_size))
345 344
 		{
346 345
 			$this->_bcc_array = $bcc;
347
-		}
348
-		else
346
+		} else
349 347
 		{
350 348
 			$this->_set_header('Bcc', implode(", ", $bcc));
351 349
 		}
@@ -444,8 +442,7 @@  discard block
 block discarded – undo
444 442
 			if (strpos($email, ',') !== FALSE)
445 443
 			{
446 444
 				$email = preg_split('/[\s,]/', $email, -1, PREG_SPLIT_NO_EMPTY);
447
-			}
448
-			else
445
+			} else
449 446
 			{
450 447
 				$email = trim($email);
451 448
 				settype($email, "array");
@@ -676,16 +673,13 @@  discard block
 block discarded – undo
676 673
 		if	($this->mailtype == 'html' &&  count($this->_attach_name) == 0)
677 674
 		{
678 675
 			return 'html';
679
-		}
680
-		elseif	($this->mailtype == 'html' &&  count($this->_attach_name)  > 0)
676
+		} elseif	($this->mailtype == 'html' &&  count($this->_attach_name)  > 0)
681 677
 		{
682 678
 			return 'html-attach';
683
-		}
684
-		elseif	($this->mailtype == 'text' &&  count($this->_attach_name)  > 0)
679
+		} elseif	($this->mailtype == 'text' &&  count($this->_attach_name)  > 0)
685 680
 		{
686 681
 			return 'plain-attach';
687
-		}
688
-		else
682
+		} else
689 683
 		{
690 684
 			return 'plain';
691 685
 		}
@@ -781,8 +775,7 @@  discard block
 block discarded – undo
781 775
 			if (preg_match('/\<(.*)\>/', $email, $match))
782 776
 			{
783 777
 				return $match['1'];
784
-			}
785
-			else
778
+			} else
786 779
 			{
787 780
 				return $email;
788 781
 			}
@@ -795,8 +788,7 @@  discard block
 block discarded – undo
795 788
 			if (preg_match( '/\<(.*)\>/', $addy, $match))
796 789
 			{
797 790
 				$clean_email[] = $match['1'];
798
-			}
799
-			else
791
+			} else
800 792
 			{
801 793
 				$clean_email[] = $addy;
802 794
 			}
@@ -828,8 +820,7 @@  discard block
 block discarded – undo
828 820
 		if (preg_match('/\<body.*?\>(.*)\<\/body\>/si', $this->_body, $match))
829 821
 		{
830 822
 			$body = $match['1'];
831
-		}
832
-		else
823
+		} else
833 824
 		{
834 825
 			$body = $this->_body;
835 826
 		}
@@ -928,8 +919,7 @@  discard block
 block discarded – undo
928 919
 			if ($temp != '')
929 920
 			{
930 921
 				$output .= $temp.$this->newline.$line;
931
-			}
932
-			else
922
+			} else
933 923
 			{
934 924
 				$output .= $line;
935 925
 			}
@@ -1034,8 +1024,7 @@  discard block
 block discarded – undo
1034 1024
 				{
1035 1025
 					$this->_header_str .= $hdr;
1036 1026
 					$this->_finalbody = $this->_body;
1037
-				}
1038
-				else
1027
+				} else
1039 1028
 				{
1040 1029
 					$this->_finalbody = $hdr . $this->newline . $this->newline . $this->_body;
1041 1030
 				}
@@ -1049,8 +1038,7 @@  discard block
 block discarded – undo
1049 1038
 				{
1050 1039
 					$hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
1051 1040
 					$hdr .= "Content-Transfer-Encoding: quoted-printable";
1052
-				}
1053
-				else
1041
+				} else
1054 1042
 				{
1055 1043
 					$hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline . $this->newline;
1056 1044
 
@@ -1071,8 +1059,7 @@  discard block
 block discarded – undo
1071 1059
 				if ($this->_get_protocol() == 'mail')
1072 1060
 				{
1073 1061
 					$this->_header_str .= $hdr;
1074
-				}
1075
-				else
1062
+				} else
1076 1063
 				{
1077 1064
 					$this->_finalbody = $hdr . $this->_finalbody;
1078 1065
 				}
@@ -1173,8 +1160,7 @@  discard block
 block discarded – undo
1173 1160
 		if ($this->_get_protocol() == 'mail')
1174 1161
 		{
1175 1162
 			$this->_finalbody = $body;
1176
-		}
1177
-		else
1163
+		} else
1178 1164
 		{
1179 1165
 			$this->_finalbody = $hdr . $body;
1180 1166
 		}
@@ -1374,8 +1360,9 @@  discard block
 block discarded – undo
1374 1360
 
1375 1361
 		if ($this->bcc_batch_mode  AND  count($this->_bcc_array) > 0)
1376 1362
 		{
1377
-			if (count($this->_bcc_array) > $this->bcc_batch_size)
1378
-				return $this->batch_bcc_send();
1363
+			if (count($this->_bcc_array) > $this->bcc_batch_size) {
1364
+							return $this->batch_bcc_send();
1365
+			}
1379 1366
 		}
1380 1367
 
1381 1368
 		$this->_build_message();
@@ -1383,8 +1370,7 @@  discard block
 block discarded – undo
1383 1370
 		if ( ! $this->_spool_email())
1384 1371
 		{
1385 1372
 			return FALSE;
1386
-		}
1387
-		else
1373
+		} else
1388 1374
 		{
1389 1375
 			return TRUE;
1390 1376
 		}
@@ -1437,8 +1423,7 @@  discard block
 block discarded – undo
1437 1423
 			if ($this->protocol != 'smtp')
1438 1424
 			{
1439 1425
 				$this->_set_header('Bcc', implode(", ", $bcc));
1440
-			}
1441
-			else
1426
+			} else
1442 1427
 			{
1443 1428
 				$this->_bcc_array = $bcc;
1444 1429
 			}
@@ -1539,13 +1524,11 @@  discard block
 block discarded – undo
1539 1524
 			if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str))
1540 1525
 			{
1541 1526
 				return FALSE;
1542
-			}
1543
-			else
1527
+			} else
1544 1528
 			{
1545 1529
 				return TRUE;
1546 1530
 			}
1547
-		}
1548
-		else
1531
+		} else
1549 1532
 		{
1550 1533
 			// most documentation of sendmail using the "-f" flag lacks a space after it, however
1551 1534
 			// we've encountered servers that seem to require it to be in place.
@@ -1553,8 +1536,7 @@  discard block
 block discarded – undo
1553 1536
 			if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From'])))
1554 1537
 			{
1555 1538
 				return FALSE;
1556
-			}
1557
-			else
1539
+			} else
1558 1540
 			{
1559 1541
 				return TRUE;
1560 1542
 			}
@@ -1680,8 +1662,9 @@  discard block
 block discarded – undo
1680 1662
 	protected function _smtp_connect()
1681 1663
 	{
1682 1664
 		$ssl = NULL;
1683
-		if ($this->smtp_crypto == 'ssl')
1684
-			$ssl = 'ssl://';
1665
+		if ($this->smtp_crypto == 'ssl') {
1666
+					$ssl = 'ssl://';
1667
+		}
1685 1668
 		$this->_smtp_connect = fsockopen($ssl.$this->smtp_host,
1686 1669
 										$this->smtp_port,
1687 1670
 										$errno,
@@ -1722,10 +1705,11 @@  discard block
 block discarded – undo
1722 1705
 		{
1723 1706
 			case 'hello' :
1724 1707
 
1725
-					if ($this->_smtp_auth OR $this->_get_encoding() == '8bit')
1726
-						$this->_send_data('EHLO '.$this->_get_hostname());
1727
-					else
1728
-						$this->_send_data('HELO '.$this->_get_hostname());
1708
+					if ($this->_smtp_auth OR $this->_get_encoding() == '8bit') {
1709
+											$this->_send_data('EHLO '.$this->_get_hostname());
1710
+					} else {
1711
+											$this->_send_data('HELO '.$this->_get_hostname());
1712
+					}
1729 1713
 
1730 1714
 						$resp = 250;
1731 1715
 			break;
@@ -1847,8 +1831,7 @@  discard block
 block discarded – undo
1847 1831
 		{
1848 1832
 			$this->_set_error_message('lang:email_smtp_data_failure', $data);
1849 1833
 			return FALSE;
1850
-		}
1851
-		else
1834
+		} else
1852 1835
 		{
1853 1836
 			return TRUE;
1854 1837
 		}
@@ -1911,10 +1894,15 @@  discard block
 block discarded – undo
1911 1894
 		$rip = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE;
1912 1895
 		$fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE;
1913 1896
 
1914
-		if ($cip && $rip)	$this->_IP = $cip;
1915
-		elseif ($rip)		$this->_IP = $rip;
1916
-		elseif ($cip)		$this->_IP = $cip;
1917
-		elseif ($fip)		$this->_IP = $fip;
1897
+		if ($cip && $rip) {
1898
+			$this->_IP = $cip;
1899
+		} elseif ($rip) {
1900
+			$this->_IP = $rip;
1901
+		} elseif ($cip) {
1902
+			$this->_IP = $cip;
1903
+		} elseif ($fip) {
1904
+			$this->_IP = $fip;
1905
+		}
1918 1906
 
1919 1907
 		if (strpos($this->_IP, ',') !== FALSE)
1920 1908
 		{
@@ -1975,8 +1963,7 @@  discard block
 block discarded – undo
1975 1963
 		if (substr($msg, 0, 5) != 'lang:' || FALSE === ($line = $CI->lang->line(substr($msg, 5))))
1976 1964
 		{
1977 1965
 			$this->_debug_msg[] = str_replace('%s', $val, $msg)."<br />";
1978
-		}
1979
-		else
1966
+		} else
1980 1967
 		{
1981 1968
 			$this->_debug_msg[] = str_replace('%s', $val, $line)."<br />";
1982 1969
 		}
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Encrypt.php 3 patches
Doc Comments   +8 added lines, -1 removed lines patch added patch discarded remove patch
@@ -233,6 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @access	private
234 234
 	 * @param	string
235 235
 	 * @param	string
236
+	 * @param string $key
236 237
 	 * @return	string
237 238
 	 */
238 239
 	function _xor_encode($string, $key)
@@ -265,6 +266,8 @@  discard block
 block discarded – undo
265 266
 	 * @access	private
266 267
 	 * @param	string
267 268
 	 * @param	string
269
+	 * @param string $string
270
+	 * @param string $key
268 271
 	 * @return	string
269 272
 	 */
270 273
 	function _xor_decode($string, $key)
@@ -312,6 +315,7 @@  discard block
 block discarded – undo
312 315
 	 * @access	public
313 316
 	 * @param	string
314 317
 	 * @param	string
318
+	 * @param string $key
315 319
 	 * @return	string
316 320
 	 */
317 321
 	function mcrypt_encode($data, $key)
@@ -329,6 +333,8 @@  discard block
 block discarded – undo
329 333
 	 * @access	public
330 334
 	 * @param	string
331 335
 	 * @param	string
336
+	 * @param string $data
337
+	 * @param string $key
332 338
 	 * @return	string
333 339
 	 */
334 340
 	function mcrypt_decode($data, $key)
@@ -358,6 +364,7 @@  discard block
 block discarded – undo
358 364
 	 * @access	private
359 365
 	 * @param	string
360 366
 	 * @param	string
367
+	 * @param string $data
361 368
 	 * @return	string
362 369
 	 */
363 370
 	function _add_cipher_noise($data, $key)
@@ -389,7 +396,7 @@  discard block
 block discarded – undo
389 396
 	 *
390 397
 	 * @access	public
391 398
 	 * @param	type
392
-	 * @return	type
399
+	 * @return	string
393 400
 	 */
394 401
 	function _remove_cipher_noise($data, $key)
395 402
 	{
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 	var $CI;
32 32
 	var $encryption_key	= '';
33
-	var $_hash_type	= 'sha1';
33
+	var $_hash_type = 'sha1';
34 34
 	var $_mcrypt_exists = FALSE;
35 35
 	var $_mcrypt_cipher;
36 36
 	var $_mcrypt_mode;
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function __construct()
45 45
 	{
46
-		$this->CI =& get_instance();
46
+		$this->CI = & get_instance();
47 47
 		$this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE;
48 48
 		log_message('debug', "Encrypt Class Initialized");
49 49
 	}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 				return $this->encryption_key;
70 70
 			}
71 71
 
72
-			$CI =& get_instance();
72
+			$CI = & get_instance();
73 73
 			$key = $CI->config->item('encryption_key');
74 74
 
75 75
 			if ($key == FALSE)
Please login to merge, or discard this 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
  *
@@ -120,8 +122,7 @@  discard block
 block discarded – undo
120 122
 		if ($this->_mcrypt_exists === TRUE)
121 123
 		{
122 124
 			$enc = $this->mcrypt_encode($string, $key);
123
-		}
124
-		else
125
+		} else
125 126
 		{
126 127
 			$enc = $this->_xor_encode($string, $key);
127 128
 		}
@@ -158,8 +159,7 @@  discard block
 block discarded – undo
158 159
 			{
159 160
 				return FALSE;
160 161
 			}
161
-		}
162
-		else
162
+		} else
163 163
 		{
164 164
 			$dec = $this->_xor_decode($dec, $key);
165 165
 		}
@@ -527,13 +527,11 @@  discard block
 block discarded – undo
527 527
 				require_once(BASEPATH.'libraries/Sha1.php');
528 528
 				$SH = new CI_SHA;
529 529
 				return $SH->generate($str);
530
-			}
531
-			else
530
+			} else
532 531
 			{
533 532
 				return bin2hex(mhash(MHASH_SHA1, $str));
534 533
 			}
535
-		}
536
-		else
534
+		} else
537 535
 		{
538 536
 			return sha1($str);
539 537
 		}
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Form_validation.php 4 patches
Doc Comments   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @access	public
70 70
 	 * @param	mixed
71 71
 	 * @param	string
72
-	 * @return	void
72
+	 * @return	CI_Form_validation
73 73
 	 */
74 74
 	public function set_rules($field, $label = '', $rules = '')
75 75
 	{
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * @access	public
161 161
 	 * @param	string
162 162
 	 * @param	string
163
-	 * @return	string
163
+	 * @return	CI_Form_validation
164 164
 	 */
165 165
 	public function set_message($lang, $val = '')
166 166
 	{
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 * @access	public
185 185
 	 * @param	string
186 186
 	 * @param	string
187
-	 * @return	void
187
+	 * @return	CI_Form_validation
188 188
 	 */
189 189
 	public function set_error_delimiters($prefix = '<p>', $suffix = '</p>')
190 190
 	{
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @access	public
205 205
 	 * @param	string	the field name
206
-	 * @return	void
206
+	 * @return	string
207 207
 	 */
208 208
 	public function error($field = '', $prefix = '', $suffix = '')
209 209
 	{
@@ -1089,6 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 	 *
1090 1090
 	 * @access	public
1091 1091
 	 * @param	string
1092
+	 * @param string $str
1092 1093
 	 * @return	bool
1093 1094
 	 */
1094 1095
 	public function valid_email($str)
Please login to merge, or discard this patch.
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
 		return $prefix.$this->_field_data[$field]['error'].$suffix;
226 226
 	}
227
-        public function error_string_custom($prefix = '', $suffix = '')
227
+		public function error_string_custom($prefix = '', $suffix = '')
228 228
 	{
229 229
 		// No errrors, validation passes!
230 230
 		if (count($this->_error_array) === 0)
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 			if ($val != '')
250 250
 			{
251 251
 				//$str .= $prefix.$key.$val.$suffix."\n";
252
-                                $str[$key.'_error'] = $val;
252
+								$str[$key.'_error'] = $val;
253 253
 			}
254 254
 		}
255 255
 
@@ -650,11 +650,11 @@  discard block
 block discarded – undo
650 650
 					{
651 651
 					  $str=null;
652 652
 					  if(is_array($postdata)){
653
-					    foreach($postdata as $key=>$value){
654
-					      $str.=$value.",";
655
-					    }
656
-					    $str=rtrim($str,',');
657
-					    $postdata=$str;  
653
+						foreach($postdata as $key=>$value){
654
+						  $str.=$value.",";
655
+						}
656
+						$str=rtrim($str,',');
657
+						$postdata=$str;  
658 658
 					  }
659 659
 						$result = $rule($postdata);
660 660
 
@@ -990,22 +990,22 @@  discard block
 block discarded – undo
990 990
 	 */
991 991
 	public function is_unique($str, $field)
992 992
 	{
993
-                $id='';
993
+				$id='';
994 994
 		$data =explode('.', $field);
995
-                $table=$data[0];
996
-                $field=$data[1];
997
-                if(isset($data[2]))
998
-                $id=$data[2];
999
-                $where=array($field => $str);
1000
-                if($id != ''){
1001
-                 $where['id !=']=$id;
1002
-                }
1003
-                if($table == 'accounts'){
995
+				$table=$data[0];
996
+				$field=$data[1];
997
+				if(isset($data[2]))
998
+				$id=$data[2];
999
+				$where=array($field => $str);
1000
+				if($id != ''){
1001
+				 $where['id !=']=$id;
1002
+				}
1003
+				if($table == 'accounts'){
1004 1004
 		  $where['deleted']=0;
1005
-                }
1006
-                $query = $this->CI->db->limit(1)->get_where($table,$where );
1005
+				}
1006
+				$query = $this->CI->db->limit(1)->get_where($table,$where );
1007 1007
 		return $query->num_rows() > 0 ? FALSE : TRUE;
1008
-         }
1008
+		 }
1009 1009
 
1010 1010
 	// --------------------------------------------------------------------
1011 1011
 
@@ -1424,69 +1424,69 @@  discard block
 block discarded – undo
1424 1424
 	{
1425 1425
 		return str_replace(array('<?php', '<?PHP', '<?', '?>'),  array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
1426 1426
 	}
1427
-	         public function destination($str)
1428
-        {
1429
-                return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE;
1430
-        }
1431
-        public function alpha_dot($str)
1427
+			 public function destination($str)
1428
+		{
1429
+				return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE;
1430
+		}
1431
+		public function alpha_dot($str)
1432 1432
 	{
1433 1433
 		return ( ! preg_match("/^([.a-z0-9])+$/i", $str)) ? FALSE : TRUE;
1434 1434
 	}
1435 1435
 	public function numeric_dot($str)
1436 1436
 	{
1437
-		    return ( ! preg_match("/^([.a-z0-9])+$/i", $str)) ? FALSE : TRUE;
1437
+			return ( ! preg_match("/^([.a-z0-9])+$/i", $str)) ? FALSE : TRUE;
1438 1438
 	}
1439 1439
 	public function valid_decimal($str){
1440
-            return (bool) preg_match('#^\d+(?:\.\d{1,5})?$#', $str);
1441
-        }
1442
-        public function alpha_numeric_space($str)
1440
+			return (bool) preg_match('#^\d+(?:\.\d{1,5})?$#', $str);
1441
+		}
1442
+		public function alpha_numeric_space($str)
1443 1443
 	{
1444 1444
 		return ( ! preg_match("/^[A-Za-z0-9\s]+$/", $str)) ? FALSE : TRUE;
1445 1445
 	}
1446
-        public function alpha_space($str){
1446
+		public function alpha_space($str){
1447 1447
 		return ( ! preg_match("/^[A-Za-z\s]+$/", $str)) ? FALSE : TRUE;
1448 1448
 //                return ( ! preg_match("/^([-a-z0-9_-\s])+$/i", $str)) ? FALSE : TRUE;
1449 1449
 	}
1450
-        public function currency_decimal($str){
1451
-            return (bool) preg_match('#^\d{0,5}+(?:\.\d{1,5})?$#', $str);
1450
+		public function currency_decimal($str){
1451
+			return (bool) preg_match('#^\d{0,5}+(?:\.\d{1,5})?$#', $str);
1452 1452
 //            test(num)
1453
-        }
1454
-        /* ASTPP  3.0 
1453
+		}
1454
+		/* ASTPP  3.0 
1455 1455
          * For Old Password checking
1456 1456
          */
1457
-        public function password_check($str,$table){
1458
-          $this->CI->db->select('password');
1459
-          $this->CI->db->where('id',$_POST['id']);
1460
-          $result=$this->CI->db->get($table);
1461
-          if($result->num_rows() > 0 ){
1462
-              $result=(array)$result->first_row();
1463
-              $password=$this->CI->common->decode($result['password']);
1464
-              if($password && $password == $str){
1465
-                  return true;
1466
-              }else{
1467
-                  return false;
1468
-              }
1469
-          }else{
1470
-              return false;
1471
-          }
1472
-        }
1473
-        public function did_account_checking($str){
1474
-          $post_array=$this->CI->input->post();
1475
-          if($str > 0){
1476
-	      $this->CI->db->where("id",$str);
1477
-	      $this->CI->db->select('posttoexternal,balance,credit_limit');
1478
-	      $acc_result=$this->CI->db->get('accounts');
1479
-	      $customer_info=(array)$acc_result->first_row();
1480
-	      $available_bal = ($customer_info["balance"]) + $customer_info["posttoexternal"] * ($customer_info["credit_limit"]);
1481
-	      if($available_bal >= $post_array['setup']){
1482
-	       return TRUE;
1483
-	      }else{
1484
-	       return FALSE;
1485
-	      }
1486
-          }else{
1487
-           return TRUE;
1488
-          }
1489
-        }
1457
+		public function password_check($str,$table){
1458
+		  $this->CI->db->select('password');
1459
+		  $this->CI->db->where('id',$_POST['id']);
1460
+		  $result=$this->CI->db->get($table);
1461
+		  if($result->num_rows() > 0 ){
1462
+			  $result=(array)$result->first_row();
1463
+			  $password=$this->CI->common->decode($result['password']);
1464
+			  if($password && $password == $str){
1465
+				  return true;
1466
+			  }else{
1467
+				  return false;
1468
+			  }
1469
+		  }else{
1470
+			  return false;
1471
+		  }
1472
+		}
1473
+		public function did_account_checking($str){
1474
+		  $post_array=$this->CI->input->post();
1475
+		  if($str > 0){
1476
+		  $this->CI->db->where("id",$str);
1477
+		  $this->CI->db->select('posttoexternal,balance,credit_limit');
1478
+		  $acc_result=$this->CI->db->get('accounts');
1479
+		  $customer_info=(array)$acc_result->first_row();
1480
+		  $available_bal = ($customer_info["balance"]) + $customer_info["posttoexternal"] * ($customer_info["credit_limit"]);
1481
+		  if($available_bal >= $post_array['setup']){
1482
+		   return TRUE;
1483
+		  }else{
1484
+		   return FALSE;
1485
+		  }
1486
+		  }else{
1487
+		   return TRUE;
1488
+		  }
1489
+		}
1490 1490
 
1491 1491
 }
1492 1492
 // END Form Validation Class
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
 class CI_Form_validation {
28 28
 
29 29
 	protected $CI;
30
-	protected $_field_data			= array();
30
+	protected $_field_data = array();
31 31
 	protected $_config_rules		= array();
32 32
 	protected $_error_array			= array();
33
-	protected $_error_messages		= array();
33
+	protected $_error_messages = array();
34 34
 	protected $_error_prefix		= '<p>';
35 35
 	protected $_error_suffix		= '</p>';
36 36
 	protected $error_string			= '';
37
-	protected $_safe_form_data		= FALSE;
37
+	protected $_safe_form_data = FALSE;
38 38
 
39 39
 	/**
40 40
 	 * Constructor
41 41
 	 */
42 42
 	public function __construct($rules = array())
43 43
 	{
44
-		$this->CI =& get_instance();
44
+		$this->CI = & get_instance();
45 45
 
46 46
 		// Validation rules can be stored in a config file.
47 47
 		$this->_config_rules = $rules;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		}
102 102
 
103 103
 		// No fields? Nothing to do...
104
-		if ( ! is_string($field) OR  ! is_string($rules) OR $field == '')
104
+		if ( ! is_string($field) OR ! is_string($rules) OR $field == '')
105 105
 		{
106 106
 			return $this;
107 107
 		}
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 		}
132 132
 		else
133 133
 		{
134
-			$indexes	= array();
135
-			$is_array	= FALSE;
134
+			$indexes = array();
135
+			$is_array = FALSE;
136 136
 		}
137 137
 
138 138
 		// Build our master array
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 			{
413 413
 				if (isset($array[$keys[$i]]))
414 414
 				{
415
-					$array = $this->_reduce_array($array[$keys[$i]], $keys, ($i+1));
415
+					$array = $this->_reduce_array($array[$keys[$i]], $keys, ($i + 1));
416 416
 				}
417 417
 				else
418 418
 				{
@@ -452,18 +452,18 @@  discard block
 block discarded – undo
452 452
 				else
453 453
 				{
454 454
 					// start with a reference
455
-					$post_ref =& $_POST;
455
+					$post_ref = & $_POST;
456 456
 
457 457
 					// before we assign values, make a reference to the right POST key
458 458
 					if (count($row['keys']) == 1)
459 459
 					{
460
-						$post_ref =& $post_ref[current($row['keys'])];
460
+						$post_ref = & $post_ref[current($row['keys'])];
461 461
 					}
462 462
 					else
463 463
 					{
464 464
 						foreach ($row['keys'] as $val)
465 465
 						{
466
-							$post_ref =& $post_ref[$val];
466
+							$post_ref = & $post_ref[$val];
467 467
 						}
468 468
 					}
469 469
 
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	 */
501 501
 	protected function _execute($row, $rules, $postdata = NULL, $cycles = 0)
502 502
 	{
503
-	$custom_label=explode("<",$row['label']);
504
-	$row['label']=(isset($custom_label[1]) && !empty($custom_label[1])) ? $custom_label[0] : $row['label'];
503
+	$custom_label = explode("<", $row['label']);
504
+	$row['label'] = (isset($custom_label[1]) && ! empty($custom_label[1])) ? $custom_label[0] : $row['label'];
505 505
 		// If the $_POST data is an array we will run a recursive call
506 506
 		if (is_array($postdata))
507 507
 		{
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 
519 519
 		// If the field is blank, but NOT required, no further tests are necessary
520 520
 		$callback = FALSE;
521
-		if ( (! in_array('required', $rules) AND ! in_array('dropdown', $rules)) AND is_null($postdata))
521
+		if (( ! in_array('required', $rules) AND ! in_array('dropdown', $rules)) AND is_null($postdata))
522 522
 		{
523 523
 			// Before we bail out, does the rule contain a callback?
524 524
 			if (preg_match("/(callback_\w+(\[.*?\])?)/", implode(' ', $rules), $match))
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 			
542 542
 				// Set the message type
543 543
                             
544
-				$type = (in_array('required', $rules)) ? 'required' : ((in_array('dropdown',$rules)) ? 'dropdown':'isset' );
544
+				$type = (in_array('required', $rules)) ? 'required' : ((in_array('dropdown', $rules)) ? 'dropdown' : 'isset');
545 545
 				if ( ! isset($this->_error_messages[$type]))
546 546
 				{
547 547
 					if (FALSE === ($line = $this->CI->lang->line($type)))
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 			if (preg_match("/(.*?)\[(.*)\]/", $rule, $match))
611 611
 			{
612 612
 				$rule	= $match[1];
613
-				$param	= $match[2];
613
+				$param = $match[2];
614 614
 			}
615 615
 
616 616
 			// Call the function that corresponds to the rule
@@ -648,13 +648,13 @@  discard block
 block discarded – undo
648 648
 					// Users can use any native PHP function call that has one param.
649 649
 					if (function_exists($rule))
650 650
 					{
651
-					  $str=null;
652
-					  if(is_array($postdata)){
653
-					    foreach($postdata as $key=>$value){
654
-					      $str.=$value.",";
651
+					  $str = null;
652
+					  if (is_array($postdata)) {
653
+					    foreach ($postdata as $key=>$value) {
654
+					      $str .= $value.",";
655 655
 					    }
656
-					    $str=rtrim($str,',');
657
-					    $postdata=$str;  
656
+					    $str = rtrim($str, ',');
657
+					    $postdata = $str;  
658 658
 					  }
659 659
 						$result = $rule($postdata);
660 660
 
@@ -990,20 +990,20 @@  discard block
 block discarded – undo
990 990
 	 */
991 991
 	public function is_unique($str, $field)
992 992
 	{
993
-                $id='';
994
-		$data =explode('.', $field);
995
-                $table=$data[0];
996
-                $field=$data[1];
997
-                if(isset($data[2]))
998
-                $id=$data[2];
999
-                $where=array($field => $str);
1000
-                if($id != ''){
1001
-                 $where['id !=']=$id;
993
+                $id = '';
994
+		$data = explode('.', $field);
995
+                $table = $data[0];
996
+                $field = $data[1];
997
+                if (isset($data[2]))
998
+                $id = $data[2];
999
+                $where = array($field => $str);
1000
+                if ($id != '') {
1001
+                 $where['id !='] = $id;
1002 1002
                 }
1003
-                if($table == 'accounts'){
1004
-		  $where['deleted']=0;
1003
+                if ($table == 'accounts') {
1004
+		  $where['deleted'] = 0;
1005 1005
                 }
1006
-                $query = $this->CI->db->limit(1)->get_where($table,$where );
1006
+                $query = $this->CI->db->limit(1)->get_where($table, $where);
1007 1007
 		return $query->num_rows() > 0 ? FALSE : TRUE;
1008 1008
          }
1009 1009
 
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 	 */
1191 1191
 	public function numeric($str)
1192 1192
 	{
1193
-		return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str);
1193
+		return (bool)preg_match('/^[\-+]?[0-9]*\.?[0-9]+$/', $str);
1194 1194
 
1195 1195
 	}
1196 1196
 
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
 	 */
1220 1220
 	public function integer($str)
1221 1221
 	{
1222
-		return (bool) preg_match('/^[\-+]?[0-9]+$/', $str);
1222
+		return (bool)preg_match('/^[\-+]?[0-9]+$/', $str);
1223 1223
 	}
1224 1224
 
1225 1225
 	// --------------------------------------------------------------------
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 	 */
1234 1234
 	public function decimal($str)
1235 1235
 	{
1236
-		return (bool) preg_match('/^[\-+]?[0-9]+\.[0-9]+$/', $str);
1236
+		return (bool)preg_match('/^[\-+]?[0-9]+\.[0-9]+$/', $str);
1237 1237
 	}
1238 1238
 
1239 1239
 	// --------------------------------------------------------------------
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
 	 */
1284 1284
 	public function is_natural($str)
1285 1285
 	{
1286
-		return (bool) preg_match( '/^[0-9]+$/', $str);
1286
+		return (bool)preg_match('/^[0-9]+$/', $str);
1287 1287
 	}
1288 1288
 
1289 1289
 	// --------------------------------------------------------------------
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 	 */
1298 1298
 	public function is_natural_no_zero($str)
1299 1299
 	{
1300
-		if ( ! preg_match( '/^[0-9]+$/', $str))
1300
+		if ( ! preg_match('/^[0-9]+$/', $str))
1301 1301
 		{
1302 1302
 			return FALSE;
1303 1303
 		}
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
 	 */
1325 1325
 	public function valid_base64($str)
1326 1326
 	{
1327
-		return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str);
1327
+		return (bool)! preg_match('/[^a-zA-Z0-9\/\+=]/', $str);
1328 1328
 	}
1329 1329
 
1330 1330
 	// --------------------------------------------------------------------
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
 	 */
1423 1423
 	public function encode_php_tags($str)
1424 1424
 	{
1425
-		return str_replace(array('<?php', '<?PHP', '<?', '?>'),  array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
1425
+		return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
1426 1426
 	}
1427 1427
 	         public function destination($str)
1428 1428
         {
@@ -1436,54 +1436,54 @@  discard block
 block discarded – undo
1436 1436
 	{
1437 1437
 		    return ( ! preg_match("/^([.a-z0-9])+$/i", $str)) ? FALSE : TRUE;
1438 1438
 	}
1439
-	public function valid_decimal($str){
1440
-            return (bool) preg_match('#^\d+(?:\.\d{1,5})?$#', $str);
1439
+	public function valid_decimal($str) {
1440
+            return (bool)preg_match('#^\d+(?:\.\d{1,5})?$#', $str);
1441 1441
         }
1442 1442
         public function alpha_numeric_space($str)
1443 1443
 	{
1444 1444
 		return ( ! preg_match("/^[A-Za-z0-9\s]+$/", $str)) ? FALSE : TRUE;
1445 1445
 	}
1446
-        public function alpha_space($str){
1446
+        public function alpha_space($str) {
1447 1447
 		return ( ! preg_match("/^[A-Za-z\s]+$/", $str)) ? FALSE : TRUE;
1448 1448
 //                return ( ! preg_match("/^([-a-z0-9_-\s])+$/i", $str)) ? FALSE : TRUE;
1449 1449
 	}
1450
-        public function currency_decimal($str){
1451
-            return (bool) preg_match('#^\d{0,5}+(?:\.\d{1,5})?$#', $str);
1450
+        public function currency_decimal($str) {
1451
+            return (bool)preg_match('#^\d{0,5}+(?:\.\d{1,5})?$#', $str);
1452 1452
 //            test(num)
1453 1453
         }
1454 1454
         /* ASTPP  3.0 
1455 1455
          * For Old Password checking
1456 1456
          */
1457
-        public function password_check($str,$table){
1457
+        public function password_check($str, $table) {
1458 1458
           $this->CI->db->select('password');
1459
-          $this->CI->db->where('id',$_POST['id']);
1460
-          $result=$this->CI->db->get($table);
1461
-          if($result->num_rows() > 0 ){
1462
-              $result=(array)$result->first_row();
1463
-              $password=$this->CI->common->decode($result['password']);
1464
-              if($password && $password == $str){
1459
+          $this->CI->db->where('id', $_POST['id']);
1460
+          $result = $this->CI->db->get($table);
1461
+          if ($result->num_rows() > 0) {
1462
+              $result = (array)$result->first_row();
1463
+              $password = $this->CI->common->decode($result['password']);
1464
+              if ($password && $password == $str) {
1465 1465
                   return true;
1466
-              }else{
1466
+              } else {
1467 1467
                   return false;
1468 1468
               }
1469
-          }else{
1469
+          } else {
1470 1470
               return false;
1471 1471
           }
1472 1472
         }
1473
-        public function did_account_checking($str){
1474
-          $post_array=$this->CI->input->post();
1475
-          if($str > 0){
1476
-	      $this->CI->db->where("id",$str);
1473
+        public function did_account_checking($str) {
1474
+          $post_array = $this->CI->input->post();
1475
+          if ($str > 0) {
1476
+	      $this->CI->db->where("id", $str);
1477 1477
 	      $this->CI->db->select('posttoexternal,balance,credit_limit');
1478
-	      $acc_result=$this->CI->db->get('accounts');
1479
-	      $customer_info=(array)$acc_result->first_row();
1478
+	      $acc_result = $this->CI->db->get('accounts');
1479
+	      $customer_info = (array)$acc_result->first_row();
1480 1480
 	      $available_bal = ($customer_info["balance"]) + $customer_info["posttoexternal"] * ($customer_info["credit_limit"]);
1481
-	      if($available_bal >= $post_array['setup']){
1481
+	      if ($available_bal >= $post_array['setup']) {
1482 1482
 	       return TRUE;
1483
-	      }else{
1483
+	      } else {
1484 1484
 	       return FALSE;
1485 1485
 	      }
1486
-          }else{
1486
+          } else {
1487 1487
            return TRUE;
1488 1488
           }
1489 1489
         }
Please login to merge, or discard this 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/Fpdf.php 4 patches
Doc Comments   +49 added lines patch added patch discarded remove patch
@@ -178,6 +178,10 @@  discard block
 block discarded – undo
178 178
 	$this->PDFVersion = '1.3';
179 179
 }
180 180
 
181
+/**
182
+ * @param double $left
183
+ * @param double $top
184
+ */
181 185
 function SetMargins($left, $top, $right=null)
182 186
 {
183 187
 	// Set left, top and right margins
@@ -208,6 +212,9 @@  discard block
 block discarded – undo
208 212
 	$this->rMargin = $margin;
209 213
 }
210 214
 
215
+/**
216
+ * @param boolean $auto
217
+ */
211 218
 function SetAutoPageBreak($auto, $margin=0)
212 219
 {
213 220
 	// Set auto page break mode and triggering margin
@@ -216,6 +223,9 @@  discard block
 block discarded – undo
216 223
 	$this->PageBreakTrigger = $this->h-$margin;
217 224
 }
218 225
 
226
+/**
227
+ * @param string $zoom
228
+ */
219 229
 function SetDisplayMode($zoom, $layout='default')
220 230
 {
221 231
 	// Set display mode in viewer
@@ -229,6 +239,9 @@  discard block
 block discarded – undo
229 239
 		$this->Error('Incorrect layout display mode: '.$layout);
230 240
 }
231 241
 
242
+/**
243
+ * @param boolean $compress
244
+ */
232 245
 function SetCompression($compress)
233 246
 {
234 247
 	// Set page compression
@@ -409,6 +422,11 @@  discard block
 block discarded – undo
409 422
 		$this->_out($this->DrawColor);
410 423
 }
411 424
 
425
+/**
426
+ * @param integer $r
427
+ * @param integer $g
428
+ * @param integer $b
429
+ */
412 430
 function SetFillColor($r, $g=null, $b=null)
413 431
 {
414 432
 	// Set color for all filling operations
@@ -451,6 +469,10 @@  discard block
 block discarded – undo
451 469
 		$this->_out(sprintf('%.2F w',$width*$this->k));
452 470
 }
453 471
 
472
+/**
473
+ * @param integer $x1
474
+ * @param integer $x2
475
+ */
454 476
 function Line($x1, $y1, $x2, $y2)
455 477
 {
456 478
 	// Draw a line
@@ -469,6 +491,9 @@  discard block
 block discarded – undo
469 491
 	$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 492
 }
471 493
 
494
+/**
495
+ * @param string $family
496
+ */
472 497
 function AddFont($family, $style='', $file='')
473 498
 {
474 499
 	// Add a TrueType, OpenType or Type1 font
@@ -505,6 +530,9 @@  discard block
 block discarded – undo
505 530
 	$this->fonts[$fontkey] = $info;
506 531
 }
507 532
 
533
+/**
534
+ * @param string $family
535
+ */
508 536
 function SetFont($family, $style='', $size=0)
509 537
 {
510 538
 	// Select a font; size given in points
@@ -584,6 +612,10 @@  discard block
 block discarded – undo
584 612
 	$this->links[$link] = array($page, $y);
585 613
 }
586 614
 
615
+/**
616
+ * @param double $y
617
+ * @param string $link
618
+ */
587 619
 function Link($x, $y, $w, $h, $link)
588 620
 {
589 621
 	// Put a link on the page
@@ -686,6 +718,10 @@  discard block
 block discarded – undo
686 718
 		$this->x += $w;
687 719
 }
688 720
 
721
+/**
722
+ * @param integer $w
723
+ * @param integer $h
724
+ */
689 725
 function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
690 726
 {
691 727
 	// Output text with automatic or explicit line breaks
@@ -984,6 +1020,9 @@  discard block
 block discarded – undo
984 1020
 		$this->y = $this->h+$y;
985 1021
 }
986 1022
 
1023
+/**
1024
+ * @param integer $x
1025
+ */
987 1026
 function SetXY($x, $y)
988 1027
 {
989 1028
 	// Set x and y positions
@@ -1106,6 +1145,10 @@  discard block
 block discarded – undo
1106 1145
 	}
1107 1146
 }
1108 1147
 
1148
+/**
1149
+ * @param string $orientation
1150
+ * @param string $size
1151
+ */
1109 1152
 function _beginpage($orientation, $size)
1110 1153
 {
1111 1154
 	$this->page++;
@@ -1151,6 +1194,9 @@  discard block
 block discarded – undo
1151 1194
 	$this->state = 1;
1152 1195
 }
1153 1196
 
1197
+/**
1198
+ * @param string $font
1199
+ */
1154 1200
 function _loadfont($font)
1155 1201
 {
1156 1202
 	// Load a font definition file from the font directory
@@ -1238,6 +1284,9 @@  discard block
 block discarded – undo
1238 1284
 	return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
1239 1285
 }
1240 1286
 
1287
+/**
1288
+ * @param string $file
1289
+ */
1241 1290
 function _parsepng($file)
1242 1291
 {
1243 1292
 	// Extract info from a PNG file
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -77,11 +77,11 @@
 block discarded – undo
77 77
 *******************************************************************************/
78 78
 function FPDF($props = array())
79 79
 {
80
-     if(count($props) == 3)
81
-     {
82
-         list($orientation,$unit,$format) = $props;
83
-         $this->initialize($orientation,$unit,$format);
84
-     }	
80
+	 if(count($props) == 3)
81
+	 {
82
+		 list($orientation,$unit,$format) = $props;
83
+		 $this->initialize($orientation,$unit,$format);
84
+	 }	
85 85
 }
86 86
 
87 87
 function initialize($orientation='P',$unit='mm',$size='A4')
Please login to merge, or discard this patch.
Spacing   +502 added lines, -502 removed lines patch added patch discarded remove patch
@@ -7,68 +7,68 @@  discard block
 block discarded – undo
7 7
 * Author:  Olivier PLATHEY                                                     *
8 8
 *******************************************************************************/
9 9
 
10
-if(!class_exists('FPDF'))
10
+if ( ! class_exists('FPDF'))
11 11
 {
12
-define('FPDF_VERSION','1.7');
12
+define('FPDF_VERSION', '1.7');
13 13
 
14 14
 class FPDF
15 15
 {
16
-var $page;               // current page number
17
-var $n;                  // current object number
18
-var $offsets;            // array of object offsets
19
-var $buffer;             // buffer holding in-memory PDF
20
-var $pages;              // array containing pages
21
-var $state;              // current document state
22
-var $compress;           // compression flag
23
-var $k;                  // scale factor (number of points in user unit)
24
-var $DefOrientation;     // default orientation
25
-var $CurOrientation;     // current orientation
26
-var $StdPageSizes;       // standard page sizes
27
-var $DefPageSize;        // default page size
28
-var $CurPageSize;        // current page size
29
-var $PageSizes;          // used for pages with non default sizes or orientations
30
-var $wPt, $hPt;          // dimensions of current page in points
31
-var $w, $h;              // dimensions of current page in user unit
32
-var $lMargin;            // left margin
33
-var $tMargin;            // top margin
34
-var $rMargin;            // right margin
35
-var $bMargin;            // page break margin
36
-var $cMargin;            // cell margin
37
-var $x, $y;              // current position in user unit
38
-var $lasth;              // height of last printed cell
39
-var $LineWidth;          // line width in user unit
40
-var $fontpath;           // path containing fonts
41
-var $CoreFonts;          // array of core font names
42
-var $fonts;              // array of used fonts
43
-var $FontFiles;          // array of font files
44
-var $diffs;              // array of encoding differences
45
-var $FontFamily;         // current font family
46
-var $FontStyle;          // current font style
47
-var $underline;          // underlining flag
48
-var $CurrentFont;        // current font info
49
-var $FontSizePt;         // current font size in points
50
-var $FontSize;           // current font size in user unit
51
-var $DrawColor;          // commands for drawing color
52
-var $FillColor;          // commands for filling color
53
-var $TextColor;          // commands for text color
54
-var $ColorFlag;          // indicates whether fill and text colors are different
55
-var $ws;                 // word spacing
56
-var $images;             // array of used images
57
-var $PageLinks;          // array of links in pages
58
-var $links;              // array of internal links
59
-var $AutoPageBreak;      // automatic page breaking
60
-var $PageBreakTrigger;   // threshold used to trigger page breaks
61
-var $InHeader;           // flag set when processing header
62
-var $InFooter;           // flag set when processing footer
63
-var $ZoomMode;           // zoom display mode
64
-var $LayoutMode;         // layout display mode
65
-var $title;              // title
66
-var $subject;            // subject
67
-var $author;             // author
68
-var $keywords;           // keywords
69
-var $creator;            // creator
70
-var $AliasNbPages;       // alias for total number of pages
71
-var $PDFVersion;         // PDF version number
16
+var $page; // current page number
17
+var $n; // current object number
18
+var $offsets; // array of object offsets
19
+var $buffer; // buffer holding in-memory PDF
20
+var $pages; // array containing pages
21
+var $state; // current document state
22
+var $compress; // compression flag
23
+var $k; // scale factor (number of points in user unit)
24
+var $DefOrientation; // default orientation
25
+var $CurOrientation; // current orientation
26
+var $StdPageSizes; // standard page sizes
27
+var $DefPageSize; // default page size
28
+var $CurPageSize; // current page size
29
+var $PageSizes; // used for pages with non default sizes or orientations
30
+var $wPt, $hPt; // dimensions of current page in points
31
+var $w, $h; // dimensions of current page in user unit
32
+var $lMargin; // left margin
33
+var $tMargin; // top margin
34
+var $rMargin; // right margin
35
+var $bMargin; // page break margin
36
+var $cMargin; // cell margin
37
+var $x, $y; // current position in user unit
38
+var $lasth; // height of last printed cell
39
+var $LineWidth; // line width in user unit
40
+var $fontpath; // path containing fonts
41
+var $CoreFonts; // array of core font names
42
+var $fonts; // array of used fonts
43
+var $FontFiles; // array of font files
44
+var $diffs; // array of encoding differences
45
+var $FontFamily; // current font family
46
+var $FontStyle; // current font style
47
+var $underline; // underlining flag
48
+var $CurrentFont; // current font info
49
+var $FontSizePt; // current font size in points
50
+var $FontSize; // current font size in user unit
51
+var $DrawColor; // commands for drawing color
52
+var $FillColor; // commands for filling color
53
+var $TextColor; // commands for text color
54
+var $ColorFlag; // indicates whether fill and text colors are different
55
+var $ws; // word spacing
56
+var $images; // array of used images
57
+var $PageLinks; // array of links in pages
58
+var $links; // array of internal links
59
+var $AutoPageBreak; // automatic page breaking
60
+var $PageBreakTrigger; // threshold used to trigger page breaks
61
+var $InHeader; // flag set when processing header
62
+var $InFooter; // flag set when processing footer
63
+var $ZoomMode; // zoom display mode
64
+var $LayoutMode; // layout display mode
65
+var $title; // title
66
+var $subject; // subject
67
+var $author; // author
68
+var $keywords; // keywords
69
+var $creator; // creator
70
+var $AliasNbPages; // alias for total number of pages
71
+var $PDFVersion; // PDF version number
72 72
 
73 73
 /*******************************************************************************
74 74
 *                                                                              *
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 *******************************************************************************/
78 78
 function FPDF($props = array())
79 79
 {
80
-     if(count($props) == 3)
80
+     if (count($props) == 3)
81 81
      {
82
-         list($orientation,$unit,$format) = $props;
83
-         $this->initialize($orientation,$unit,$format);
82
+         list($orientation, $unit, $format) = $props;
83
+         $this->initialize($orientation, $unit, $format);
84 84
      }	
85 85
 }
86 86
 
87
-function initialize($orientation='P',$unit='mm',$size='A4')
87
+function initialize($orientation = 'P', $unit = 'mm', $size = 'A4')
88 88
 {
89 89
 	// Some checks
90 90
 	$this->_dochecks();
@@ -113,44 +113,44 @@  discard block
 block discarded – undo
113 113
 	$this->ColorFlag = false;
114 114
 	$this->ws = 0;
115 115
 	// Font path
116
-	if(defined('FPDF_FONTPATH'))
116
+	if (defined('FPDF_FONTPATH'))
117 117
 	{
118 118
 		$this->fontpath = FPDF_FONTPATH;
119
-		if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\')
119
+		if (substr($this->fontpath, -1) != '/' && substr($this->fontpath, -1) != '\\')
120 120
 			$this->fontpath .= '/';
121 121
 	}
122
-	elseif(is_dir(dirname(__FILE__).'/font'))
122
+	elseif (is_dir(dirname(__FILE__).'/font'))
123 123
 		$this->fontpath = dirname(__FILE__).'/font/';
124 124
 	else
125 125
 		$this->fontpath = '';	
126 126
 	// Core fonts
127 127
 	$this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats');
128 128
 	// Scale factor
129
-	if($unit=='pt')
129
+	if ($unit == 'pt')
130 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')
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 136
 		$this->k = 72;
137 137
 	else
138 138
 		$this->Error('Incorrect unit: '.$unit);
139 139
 	// Page sizes
140
-	$this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
141
-		'letter'=>array(612,792), 'legal'=>array(612,1008));
140
+	$this->StdPageSizes = array('a3'=>array(841.89, 1190.55), 'a4'=>array(595.28, 841.89), 'a5'=>array(420.94, 595.28),
141
+		'letter'=>array(612, 792), 'legal'=>array(612, 1008));
142 142
 	$size = $this->_getpagesize($size);
143 143
 	$this->DefPageSize = $size;
144 144
 	$this->CurPageSize = $size;
145 145
 	// Page orientation
146 146
 	$orientation = strtolower($orientation);
147
-	if($orientation=='p' || $orientation=='portrait')
147
+	if ($orientation == 'p' || $orientation == 'portrait')
148 148
 	{
149 149
 		$this->DefOrientation = 'P';
150 150
 		$this->w = $size[0];
151 151
 		$this->h = $size[1];
152 152
 	}
153
-	elseif($orientation=='l' || $orientation=='landscape')
153
+	elseif ($orientation == 'l' || $orientation == 'landscape')
154 154
 	{
155 155
 		$this->DefOrientation = 'L';
156 156
 		$this->w = $size[1];
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	else
160 160
 		$this->Error('Incorrect orientation: '.$orientation);
161 161
 	$this->CurOrientation = $this->DefOrientation;
162
-	$this->wPt = $this->w*$this->k;
163
-	$this->hPt = $this->h*$this->k;
162
+	$this->wPt = $this->w * $this->k;
163
+	$this->hPt = $this->h * $this->k;
164 164
 	// Page margins (1 cm)
165
-	$margin = 28.35/$this->k;
166
-	$this->SetMargins($margin,$margin);
165
+	$margin = 28.35 / $this->k;
166
+	$this->SetMargins($margin, $margin);
167 167
 	// Interior cell margin (1 mm)
168
-	$this->cMargin = $margin/10;
168
+	$this->cMargin = $margin / 10;
169 169
 	// Line width (0.2 mm)
170
-	$this->LineWidth = .567/$this->k;
170
+	$this->LineWidth = .567 / $this->k;
171 171
 	// Automatic page break
172
-	$this->SetAutoPageBreak(true,2*$margin);
172
+	$this->SetAutoPageBreak(true, 2 * $margin);
173 173
 	// Default display mode
174 174
 	$this->SetDisplayMode('default');
175 175
 	// Enable compression
@@ -178,12 +178,12 @@  discard block
 block discarded – undo
178 178
 	$this->PDFVersion = '1.3';
179 179
 }
180 180
 
181
-function SetMargins($left, $top, $right=null)
181
+function SetMargins($left, $top, $right = null)
182 182
 {
183 183
 	// Set left, top and right margins
184 184
 	$this->lMargin = $left;
185 185
 	$this->tMargin = $top;
186
-	if($right===null)
186
+	if ($right === null)
187 187
 		$right = $left;
188 188
 	$this->rMargin = $right;
189 189
 }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 {
193 193
 	// Set left margin
194 194
 	$this->lMargin = $margin;
195
-	if($this->page>0 && $this->x<$margin)
195
+	if ($this->page > 0 && $this->x < $margin)
196 196
 		$this->x = $margin;
197 197
 }
198 198
 
@@ -208,22 +208,22 @@  discard block
 block discarded – undo
208 208
 	$this->rMargin = $margin;
209 209
 }
210 210
 
211
-function SetAutoPageBreak($auto, $margin=0)
211
+function SetAutoPageBreak($auto, $margin = 0)
212 212
 {
213 213
 	// Set auto page break mode and triggering margin
214 214
 	$this->AutoPageBreak = $auto;
215 215
 	$this->bMargin = $margin;
216
-	$this->PageBreakTrigger = $this->h-$margin;
216
+	$this->PageBreakTrigger = $this->h - $margin;
217 217
 }
218 218
 
219
-function SetDisplayMode($zoom, $layout='default')
219
+function SetDisplayMode($zoom, $layout = 'default')
220 220
 {
221 221
 	// Set display mode in viewer
222
-	if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
222
+	if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || ! is_string($zoom))
223 223
 		$this->ZoomMode = $zoom;
224 224
 	else
225 225
 		$this->Error('Incorrect zoom display mode: '.$zoom);
226
-	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
226
+	if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default')
227 227
 		$this->LayoutMode = $layout;
228 228
 	else
229 229
 		$this->Error('Incorrect layout display mode: '.$layout);
@@ -232,53 +232,53 @@  discard block
 block discarded – undo
232 232
 function SetCompression($compress)
233 233
 {
234 234
 	// Set page compression
235
-	if(function_exists('gzcompress'))
235
+	if (function_exists('gzcompress'))
236 236
 		$this->compress = $compress;
237 237
 	else
238 238
 		$this->compress = false;
239 239
 }
240 240
 
241
-function SetTitle($title, $isUTF8=false)
241
+function SetTitle($title, $isUTF8 = false)
242 242
 {
243 243
 	// Title of document
244
-	if($isUTF8)
244
+	if ($isUTF8)
245 245
 		$title = $this->_UTF8toUTF16($title);
246 246
 	$this->title = $title;
247 247
 }
248 248
 
249
-function SetSubject($subject, $isUTF8=false)
249
+function SetSubject($subject, $isUTF8 = false)
250 250
 {
251 251
 	// Subject of document
252
-	if($isUTF8)
252
+	if ($isUTF8)
253 253
 		$subject = $this->_UTF8toUTF16($subject);
254 254
 	$this->subject = $subject;
255 255
 }
256 256
 
257
-function SetAuthor($author, $isUTF8=false)
257
+function SetAuthor($author, $isUTF8 = false)
258 258
 {
259 259
 	// Author of document
260
-	if($isUTF8)
260
+	if ($isUTF8)
261 261
 		$author = $this->_UTF8toUTF16($author);
262 262
 	$this->author = $author;
263 263
 }
264 264
 
265
-function SetKeywords($keywords, $isUTF8=false)
265
+function SetKeywords($keywords, $isUTF8 = false)
266 266
 {
267 267
 	// Keywords of document
268
-	if($isUTF8)
268
+	if ($isUTF8)
269 269
 		$keywords = $this->_UTF8toUTF16($keywords);
270 270
 	$this->keywords = $keywords;
271 271
 }
272 272
 
273
-function SetCreator($creator, $isUTF8=false)
273
+function SetCreator($creator, $isUTF8 = false)
274 274
 {
275 275
 	// Creator of document
276
-	if($isUTF8)
276
+	if ($isUTF8)
277 277
 		$creator = $this->_UTF8toUTF16($creator);
278 278
 	$this->creator = $creator;
279 279
 }
280 280
 
281
-function AliasNbPages($alias='{nb}')
281
+function AliasNbPages($alias = '{nb}')
282 282
 {
283 283
 	// Define an alias for total number of pages
284 284
 	$this->AliasNbPages = $alias;
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 function Close()
300 300
 {
301 301
 	// Terminate document
302
-	if($this->state==3)
302
+	if ($this->state == 3)
303 303
 		return;
304
-	if($this->page==0)
304
+	if ($this->page == 0)
305 305
 		$this->AddPage();
306 306
 	// Page footer
307 307
 	$this->InFooter = true;
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
 	$this->_enddoc();
314 314
 }
315 315
 
316
-function AddPage($orientation='', $size='')
316
+function AddPage($orientation = '', $size = '')
317 317
 {
318 318
 	// Start a new page
319
-	if($this->state==0)
319
+	if ($this->state == 0)
320 320
 		$this->Open();
321 321
 	$family = $this->FontFamily;
322 322
 	$style = $this->FontStyle.($this->underline ? 'U' : '');
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	$fc = $this->FillColor;
327 327
 	$tc = $this->TextColor;
328 328
 	$cf = $this->ColorFlag;
329
-	if($this->page>0)
329
+	if ($this->page > 0)
330 330
 	{
331 331
 		// Page footer
332 332
 		$this->InFooter = true;
@@ -336,21 +336,21 @@  discard block
 block discarded – undo
336 336
 		$this->_endpage();
337 337
 	}
338 338
 	// Start new page
339
-	$this->_beginpage($orientation,$size);
339
+	$this->_beginpage($orientation, $size);
340 340
 	// Set line cap style to square
341 341
 	$this->_out('2 J');
342 342
 	// Set line width
343 343
 	$this->LineWidth = $lw;
344
-	$this->_out(sprintf('%.2F w',$lw*$this->k));
344
+	$this->_out(sprintf('%.2F w', $lw * $this->k));
345 345
 	// Set font
346
-	if($family)
347
-		$this->SetFont($family,$style,$fontsize);
346
+	if ($family)
347
+		$this->SetFont($family, $style, $fontsize);
348 348
 	// Set colors
349 349
 	$this->DrawColor = $dc;
350
-	if($dc!='0 G')
350
+	if ($dc != '0 G')
351 351
 		$this->_out($dc);
352 352
 	$this->FillColor = $fc;
353
-	if($fc!='0 g')
353
+	if ($fc != '0 g')
354 354
 		$this->_out($fc);
355 355
 	$this->TextColor = $tc;
356 356
 	$this->ColorFlag = $cf;
@@ -359,21 +359,21 @@  discard block
 block discarded – undo
359 359
 	$this->Header();
360 360
 	$this->InHeader = false;
361 361
 	// Restore line width
362
-	if($this->LineWidth!=$lw)
362
+	if ($this->LineWidth != $lw)
363 363
 	{
364 364
 		$this->LineWidth = $lw;
365
-		$this->_out(sprintf('%.2F w',$lw*$this->k));
365
+		$this->_out(sprintf('%.2F w', $lw * $this->k));
366 366
 	}
367 367
 	// Restore font
368
-	if($family)
369
-		$this->SetFont($family,$style,$fontsize);
368
+	if ($family)
369
+		$this->SetFont($family, $style, $fontsize);
370 370
 	// Restore colors
371
-	if($this->DrawColor!=$dc)
371
+	if ($this->DrawColor != $dc)
372 372
 	{
373 373
 		$this->DrawColor = $dc;
374 374
 		$this->_out($dc);
375 375
 	}
376
-	if($this->FillColor!=$fc)
376
+	if ($this->FillColor != $fc)
377 377
 	{
378 378
 		$this->FillColor = $fc;
379 379
 		$this->_out($fc);
@@ -398,37 +398,37 @@  discard block
 block discarded – undo
398 398
 	return $this->page;
399 399
 }
400 400
 
401
-function SetDrawColor($r, $g=null, $b=null)
401
+function SetDrawColor($r, $g = null, $b = null)
402 402
 {
403 403
 	// Set color for all stroking operations
404
-	if(($r==0 && $g==0 && $b==0) || $g===null)
405
-		$this->DrawColor = sprintf('%.3F G',$r/255);
404
+	if (($r == 0 && $g == 0 && $b == 0) || $g === null)
405
+		$this->DrawColor = sprintf('%.3F G', $r / 255);
406 406
 	else
407
-		$this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
408
-	if($this->page>0)
407
+		$this->DrawColor = sprintf('%.3F %.3F %.3F RG', $r / 255, $g / 255, $b / 255);
408
+	if ($this->page > 0)
409 409
 		$this->_out($this->DrawColor);
410 410
 }
411 411
 
412
-function SetFillColor($r, $g=null, $b=null)
412
+function SetFillColor($r, $g = null, $b = null)
413 413
 {
414 414
 	// Set color for all filling operations
415
-	if(($r==0 && $g==0 && $b==0) || $g===null)
416
-		$this->FillColor = sprintf('%.3F g',$r/255);
415
+	if (($r == 0 && $g == 0 && $b == 0) || $g === null)
416
+		$this->FillColor = sprintf('%.3F g', $r / 255);
417 417
 	else
418
-		$this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
419
-	$this->ColorFlag = ($this->FillColor!=$this->TextColor);
420
-	if($this->page>0)
418
+		$this->FillColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
419
+	$this->ColorFlag = ($this->FillColor != $this->TextColor);
420
+	if ($this->page > 0)
421 421
 		$this->_out($this->FillColor);
422 422
 }
423 423
 
424
-function SetTextColor($r, $g=null, $b=null)
424
+function SetTextColor($r, $g = null, $b = null)
425 425
 {
426 426
 	// Set color for text
427
-	if(($r==0 && $g==0 && $b==0) || $g===null)
428
-		$this->TextColor = sprintf('%.3F g',$r/255);
427
+	if (($r == 0 && $g == 0 && $b == 0) || $g === null)
428
+		$this->TextColor = sprintf('%.3F g', $r / 255);
429 429
 	else
430
-		$this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
431
-	$this->ColorFlag = ($this->FillColor!=$this->TextColor);
430
+		$this->TextColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
431
+	$this->ColorFlag = ($this->FillColor != $this->TextColor);
432 432
 }
433 433
 
434 434
 function GetStringWidth($s)
@@ -438,66 +438,66 @@  discard block
 block discarded – undo
438 438
 	$cw = &$this->CurrentFont['cw'];
439 439
 	$w = 0;
440 440
 	$l = strlen($s);
441
-	for($i=0;$i<$l;$i++)
441
+	for ($i = 0; $i < $l; $i++)
442 442
 		$w += $cw[$s[$i]];
443
-	return $w*$this->FontSize/1000;
443
+	return $w * $this->FontSize / 1000;
444 444
 }
445 445
 
446 446
 function SetLineWidth($width)
447 447
 {
448 448
 	// Set line width
449 449
 	$this->LineWidth = $width;
450
-	if($this->page>0)
451
-		$this->_out(sprintf('%.2F w',$width*$this->k));
450
+	if ($this->page > 0)
451
+		$this->_out(sprintf('%.2F w', $width * $this->k));
452 452
 }
453 453
 
454 454
 function Line($x1, $y1, $x2, $y2)
455 455
 {
456 456
 	// Draw a line
457
-	$this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
457
+	$this->_out(sprintf('%.2F %.2F m %.2F %.2F l S', $x1 * $this->k, ($this->h - $y1) * $this->k, $x2 * $this->k, ($this->h - $y2) * $this->k));
458 458
 }
459 459
 
460
-function Rect($x, $y, $w, $h, $style='')
460
+function Rect($x, $y, $w, $h, $style = '')
461 461
 {
462 462
 	// Draw a rectangle
463
-	if($style=='F')
463
+	if ($style == 'F')
464 464
 		$op = 'f';
465
-	elseif($style=='FD' || $style=='DF')
465
+	elseif ($style == 'FD' || $style == 'DF')
466 466
 		$op = 'B';
467 467
 	else
468 468
 		$op = 'S';
469
-	$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
469
+	$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 470
 }
471 471
 
472
-function AddFont($family, $style='', $file='')
472
+function AddFont($family, $style = '', $file = '')
473 473
 {
474 474
 	// Add a TrueType, OpenType or Type1 font
475 475
 	$family = strtolower($family);
476
-	if($file=='')
477
-		$file = str_replace(' ','',$family).strtolower($style).'.php';
476
+	if ($file == '')
477
+		$file = str_replace(' ', '', $family).strtolower($style).'.php';
478 478
 	$style = strtoupper($style);
479
-	if($style=='IB')
479
+	if ($style == 'IB')
480 480
 		$style = 'BI';
481 481
 	$fontkey = $family.$style;
482
-	if(isset($this->fonts[$fontkey]))
482
+	if (isset($this->fonts[$fontkey]))
483 483
 		return;
484 484
 	$info = $this->_loadfont($file);
485
-	$info['i'] = count($this->fonts)+1;
486
-	if(!empty($info['diff']))
485
+	$info['i'] = count($this->fonts) + 1;
486
+	if ( ! empty($info['diff']))
487 487
 	{
488 488
 		// Search existing encodings
489
-		$n = array_search($info['diff'],$this->diffs);
490
-		if(!$n)
489
+		$n = array_search($info['diff'], $this->diffs);
490
+		if ( ! $n)
491 491
 		{
492
-			$n = count($this->diffs)+1;
492
+			$n = count($this->diffs) + 1;
493 493
 			$this->diffs[$n] = $info['diff'];
494 494
 		}
495 495
 		$info['diffn'] = $n;
496 496
 	}
497
-	if(!empty($info['file']))
497
+	if ( ! empty($info['file']))
498 498
 	{
499 499
 		// Embedded font
500
-		if($info['type']=='TrueType')
500
+		if ($info['type'] == 'TrueType')
501 501
 			$this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
502 502
 		else
503 503
 			$this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
@@ -505,42 +505,42 @@  discard block
 block discarded – undo
505 505
 	$this->fonts[$fontkey] = $info;
506 506
 }
507 507
 
508
-function SetFont($family, $style='', $size=0)
508
+function SetFont($family, $style = '', $size = 0)
509 509
 {
510 510
 	// Select a font; size given in points
511
-	if($family=='')
511
+	if ($family == '')
512 512
 		$family = $this->FontFamily;
513 513
 	else
514 514
 		$family = strtolower($family);
515 515
 	$style = strtoupper($style);
516
-	if(strpos($style,'U')!==false)
516
+	if (strpos($style, 'U') !== false)
517 517
 	{
518 518
 		$this->underline = true;
519
-		$style = str_replace('U','',$style);
519
+		$style = str_replace('U', '', $style);
520 520
 	}
521 521
 	else
522 522
 		$this->underline = false;
523
-	if($style=='IB')
523
+	if ($style == 'IB')
524 524
 		$style = 'BI';
525
-	if($size==0)
525
+	if ($size == 0)
526 526
 		$size = $this->FontSizePt;
527 527
 	// Test if font is already selected
528
-	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
528
+	if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size)
529 529
 		return;
530 530
 	// Test if font is already loaded
531 531
 	$fontkey = $family.$style;
532
-	if(!isset($this->fonts[$fontkey]))
532
+	if ( ! isset($this->fonts[$fontkey]))
533 533
 	{
534 534
 		// Test if one of the core fonts
535
-		if($family=='arial')
535
+		if ($family == 'arial')
536 536
 			$family = 'helvetica';
537
-		if(in_array($family,$this->CoreFonts))
537
+		if (in_array($family, $this->CoreFonts))
538 538
 		{
539
-			if($family=='symbol' || $family=='zapfdingbats')
539
+			if ($family == 'symbol' || $family == 'zapfdingbats')
540 540
 				$style = '';
541 541
 			$fontkey = $family.$style;
542
-			if(!isset($this->fonts[$fontkey]))
543
-				$this->AddFont($family,$style);
542
+			if ( ! isset($this->fonts[$fontkey]))
543
+				$this->AddFont($family, $style);
544 544
 		}
545 545
 		else
546 546
 			$this->Error('Undefined font: '.$family.' '.$style);
@@ -549,37 +549,37 @@  discard block
 block discarded – undo
549 549
 	$this->FontFamily = $family;
550 550
 	$this->FontStyle = $style;
551 551
 	$this->FontSizePt = $size;
552
-	$this->FontSize = $size/$this->k;
552
+	$this->FontSize = $size / $this->k;
553 553
 	$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));
554
+	if ($this->page > 0)
555
+		$this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
556 556
 }
557 557
 
558 558
 function SetFontSize($size)
559 559
 {
560 560
 	// Set font size in points
561
-	if($this->FontSizePt==$size)
561
+	if ($this->FontSizePt == $size)
562 562
 		return;
563 563
 	$this->FontSizePt = $size;
564
-	$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));
564
+	$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 567
 }
568 568
 
569 569
 function AddLink()
570 570
 {
571 571
 	// Create a new internal link
572
-	$n = count($this->links)+1;
572
+	$n = count($this->links) + 1;
573 573
 	$this->links[$n] = array(0, 0);
574 574
 	return $n;
575 575
 }
576 576
 
577
-function SetLink($link, $y=0, $page=-1)
577
+function SetLink($link, $y = 0, $page = -1)
578 578
 {
579 579
 	// Set destination of internal link
580
-	if($y==-1)
580
+	if ($y == -1)
581 581
 		$y = $this->y;
582
-	if($page==-1)
582
+	if ($page == -1)
583 583
 		$page = $this->page;
584 584
 	$this->links[$link] = array($page, $y);
585 585
 }
@@ -587,16 +587,16 @@  discard block
 block discarded – undo
587 587
 function Link($x, $y, $w, $h, $link)
588 588
 {
589 589
 	// Put a link on the page
590
-	$this->PageLinks[$this->page][] = array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link);
590
+	$this->PageLinks[$this->page][] = array($x * $this->k, $this->hPt - $y * $this->k, $w * $this->k, $h * $this->k, $link);
591 591
 }
592 592
 
593 593
 function Text($x, $y, $txt)
594 594
 {
595 595
 	// Output a string
596
-	$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)
596
+	$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 600
 		$s = 'q '.$this->TextColor.' '.$s.' Q';
601 601
 	$this->_out($s);
602 602
 }
@@ -607,100 +607,100 @@  discard block
 block discarded – undo
607 607
 	return $this->AutoPageBreak;
608 608
 }
609 609
 
610
-function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
610
+function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '')
611 611
 {
612 612
 	// Output a cell
613 613
 	$k = $this->k;
614
-	if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
614
+	if ($this->y + $h > $this->PageBreakTrigger && ! $this->InHeader && ! $this->InFooter && $this->AcceptPageBreak())
615 615
 	{
616 616
 		// Automatic page break
617 617
 		$x = $this->x;
618 618
 		$ws = $this->ws;
619
-		if($ws>0)
619
+		if ($ws > 0)
620 620
 		{
621 621
 			$this->ws = 0;
622 622
 			$this->_out('0 Tw');
623 623
 		}
624
-		$this->AddPage($this->CurOrientation,$this->CurPageSize);
624
+		$this->AddPage($this->CurOrientation, $this->CurPageSize);
625 625
 		$this->x = $x;
626
-		if($ws>0)
626
+		if ($ws > 0)
627 627
 		{
628 628
 			$this->ws = $ws;
629
-			$this->_out(sprintf('%.3F Tw',$ws*$k));
629
+			$this->_out(sprintf('%.3F Tw', $ws * $k));
630 630
 		}
631 631
 	}
632
-	if($w==0)
633
-		$w = $this->w-$this->rMargin-$this->x;
632
+	if ($w == 0)
633
+		$w = $this->w - $this->rMargin - $this->x;
634 634
 	$s = '';
635
-	if($fill || $border==1)
635
+	if ($fill || $border == 1)
636 636
 	{
637
-		if($fill)
638
-			$op = ($border==1) ? 'B' : 'f';
637
+		if ($fill)
638
+			$op = ($border == 1) ? 'B' : 'f';
639 639
 		else
640 640
 			$op = 'S';
641
-		$s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
641
+		$s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op);
642 642
 	}
643
-	if(is_string($border))
643
+	if (is_string($border))
644 644
 	{
645 645
 		$x = $this->x;
646 646
 		$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);
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);
655 655
 	}
656
-	if($txt!=='')
656
+	if ($txt !== '')
657 657
 	{
658
-		if($align=='R')
659
-			$dx = $w-$this->cMargin-$this->GetStringWidth($txt);
660
-		elseif($align=='C')
661
-			$dx = ($w-$this->GetStringWidth($txt))/2;
658
+		if ($align == 'R')
659
+			$dx = $w - $this->cMargin - $this->GetStringWidth($txt);
660
+		elseif ($align == 'C')
661
+			$dx = ($w - $this->GetStringWidth($txt)) / 2;
662 662
 		else
663 663
 			$dx = $this->cMargin;
664
-		if($this->ColorFlag)
664
+		if ($this->ColorFlag)
665 665
 			$s .= 'q '.$this->TextColor.' ';
666
-		$txt2 = str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
667
-		$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)
666
+		$txt2 = str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt)));
667
+		$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 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);
672
+		if ($link)
673
+			$this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link);
674 674
 	}
675
-	if($s)
675
+	if ($s)
676 676
 		$this->_out($s);
677 677
 	$this->lasth = $h;
678
-	if($ln>0)
678
+	if ($ln > 0)
679 679
 	{
680 680
 		// Go to next line
681 681
 		$this->y += $h;
682
-		if($ln==1)
682
+		if ($ln == 1)
683 683
 			$this->x = $this->lMargin;
684 684
 	}
685 685
 	else
686 686
 		$this->x += $w;
687 687
 }
688 688
 
689
-function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
689
+function MultiCell($w, $h, $txt, $border = 0, $align = 'J', $fill = false)
690 690
 {
691 691
 	// Output text with automatic or explicit line breaks
692 692
 	$cw = &$this->CurrentFont['cw'];
693
-	if($w==0)
694
-		$w = $this->w-$this->rMargin-$this->x;
695
-	$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
696
-	$s = str_replace("\r",'',$txt);
693
+	if ($w == 0)
694
+		$w = $this->w - $this->rMargin - $this->x;
695
+	$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
696
+	$s = str_replace("\r", '', $txt);
697 697
 	$nb = strlen($s);
698
-	if($nb>0 && $s[$nb-1]=="\n")
698
+	if ($nb > 0 && $s[$nb - 1] == "\n")
699 699
 		$nb--;
700 700
 	$b = 0;
701
-	if($border)
701
+	if ($border)
702 702
 	{
703
-		if($border==1)
703
+		if ($border == 1)
704 704
 		{
705 705
 			$border = 'LTRB';
706 706
 			$b = 'LRT';
@@ -709,11 +709,11 @@  discard block
 block discarded – undo
709 709
 		else
710 710
 		{
711 711
 			$b2 = '';
712
-			if(strpos($border,'L')!==false)
712
+			if (strpos($border, 'L') !== false)
713 713
 				$b2 .= 'L';
714
-			if(strpos($border,'R')!==false)
714
+			if (strpos($border, 'R') !== false)
715 715
 				$b2 .= 'R';
716
-			$b = (strpos($border,'T')!==false) ? $b2.'T' : $b2;
716
+			$b = (strpos($border, 'T') !== false) ? $b2.'T' : $b2;
717 717
 		}
718 718
 	}
719 719
 	$sep = -1;
@@ -722,153 +722,153 @@  discard block
 block discarded – undo
722 722
 	$l = 0;
723 723
 	$ns = 0;
724 724
 	$nl = 1;
725
-	while($i<$nb)
725
+	while ($i < $nb)
726 726
 	{
727 727
 		// Get next character
728 728
 		$c = $s[$i];
729
-		if($c=="\n")
729
+		if ($c == "\n")
730 730
 		{
731 731
 			// Explicit line break
732
-			if($this->ws>0)
732
+			if ($this->ws > 0)
733 733
 			{
734 734
 				$this->ws = 0;
735 735
 				$this->_out('0 Tw');
736 736
 			}
737
-			$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
737
+			$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
738 738
 			$i++;
739 739
 			$sep = -1;
740 740
 			$j = $i;
741 741
 			$l = 0;
742 742
 			$ns = 0;
743 743
 			$nl++;
744
-			if($border && $nl==2)
744
+			if ($border && $nl == 2)
745 745
 				$b = $b2;
746 746
 			continue;
747 747
 		}
748
-		if($c==' ')
748
+		if ($c == ' ')
749 749
 		{
750 750
 			$sep = $i;
751 751
 			$ls = $l;
752 752
 			$ns++;
753 753
 		}
754 754
 		$l += $cw[$c];
755
-		if($l>$wmax)
755
+		if ($l > $wmax)
756 756
 		{
757 757
 			// Automatic line break
758
-			if($sep==-1)
758
+			if ($sep == -1)
759 759
 			{
760
-				if($i==$j)
760
+				if ($i == $j)
761 761
 					$i++;
762
-				if($this->ws>0)
762
+				if ($this->ws > 0)
763 763
 				{
764 764
 					$this->ws = 0;
765 765
 					$this->_out('0 Tw');
766 766
 				}
767
-				$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
767
+				$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
768 768
 			}
769 769
 			else
770 770
 			{
771
-				if($align=='J')
771
+				if ($align == 'J')
772 772
 				{
773
-					$this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
774
-					$this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
773
+					$this->ws = ($ns > 1) ? ($wmax - $ls) / 1000 * $this->FontSize / ($ns - 1) : 0;
774
+					$this->_out(sprintf('%.3F Tw', $this->ws * $this->k));
775 775
 				}
776
-				$this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
777
-				$i = $sep+1;
776
+				$this->Cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill);
777
+				$i = $sep + 1;
778 778
 			}
779 779
 			$sep = -1;
780 780
 			$j = $i;
781 781
 			$l = 0;
782 782
 			$ns = 0;
783 783
 			$nl++;
784
-			if($border && $nl==2)
784
+			if ($border && $nl == 2)
785 785
 				$b = $b2;
786 786
 		}
787 787
 		else
788 788
 			$i++;
789 789
 	}
790 790
 	// Last chunk
791
-	if($this->ws>0)
791
+	if ($this->ws > 0)
792 792
 	{
793 793
 		$this->ws = 0;
794 794
 		$this->_out('0 Tw');
795 795
 	}
796
-	if($border && strpos($border,'B')!==false)
796
+	if ($border && strpos($border, 'B') !== false)
797 797
 		$b .= 'B';
798
-	$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
798
+	$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
799 799
 	$this->x = $this->lMargin;
800 800
 }
801 801
 
802
-function Write($h, $txt, $link='')
802
+function Write($h, $txt, $link = '')
803 803
 {
804 804
 	// Output text in flowing mode
805 805
 	$cw = &$this->CurrentFont['cw'];
806
-	$w = $this->w-$this->rMargin-$this->x;
807
-	$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
808
-	$s = str_replace("\r",'',$txt);
806
+	$w = $this->w - $this->rMargin - $this->x;
807
+	$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
808
+	$s = str_replace("\r", '', $txt);
809 809
 	$nb = strlen($s);
810 810
 	$sep = -1;
811 811
 	$i = 0;
812 812
 	$j = 0;
813 813
 	$l = 0;
814 814
 	$nl = 1;
815
-	while($i<$nb)
815
+	while ($i < $nb)
816 816
 	{
817 817
 		// Get next character
818 818
 		$c = $s[$i];
819
-		if($c=="\n")
819
+		if ($c == "\n")
820 820
 		{
821 821
 			// Explicit line break
822
-			$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
822
+			$this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
823 823
 			$i++;
824 824
 			$sep = -1;
825 825
 			$j = $i;
826 826
 			$l = 0;
827
-			if($nl==1)
827
+			if ($nl == 1)
828 828
 			{
829 829
 				$this->x = $this->lMargin;
830
-				$w = $this->w-$this->rMargin-$this->x;
831
-				$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
830
+				$w = $this->w - $this->rMargin - $this->x;
831
+				$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
832 832
 			}
833 833
 			$nl++;
834 834
 			continue;
835 835
 		}
836
-		if($c==' ')
836
+		if ($c == ' ')
837 837
 			$sep = $i;
838 838
 		$l += $cw[$c];
839
-		if($l>$wmax)
839
+		if ($l > $wmax)
840 840
 		{
841 841
 			// Automatic line break
842
-			if($sep==-1)
842
+			if ($sep == -1)
843 843
 			{
844
-				if($this->x>$this->lMargin)
844
+				if ($this->x > $this->lMargin)
845 845
 				{
846 846
 					// Move to next line
847 847
 					$this->x = $this->lMargin;
848 848
 					$this->y += $h;
849
-					$w = $this->w-$this->rMargin-$this->x;
850
-					$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
849
+					$w = $this->w - $this->rMargin - $this->x;
850
+					$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
851 851
 					$i++;
852 852
 					$nl++;
853 853
 					continue;
854 854
 				}
855
-				if($i==$j)
855
+				if ($i == $j)
856 856
 					$i++;
857
-				$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
857
+				$this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
858 858
 			}
859 859
 			else
860 860
 			{
861
-				$this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
862
-				$i = $sep+1;
861
+				$this->Cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', 0, $link);
862
+				$i = $sep + 1;
863 863
 			}
864 864
 			$sep = -1;
865 865
 			$j = $i;
866 866
 			$l = 0;
867
-			if($nl==1)
867
+			if ($nl == 1)
868 868
 			{
869 869
 				$this->x = $this->lMargin;
870
-				$w = $this->w-$this->rMargin-$this->x;
871
-				$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
870
+				$w = $this->w - $this->rMargin - $this->x;
871
+				$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
872 872
 			}
873 873
 			$nl++;
874 874
 		}
@@ -876,81 +876,81 @@  discard block
 block discarded – undo
876 876
 			$i++;
877 877
 	}
878 878
 	// Last chunk
879
-	if($i!=$j)
880
-		$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
879
+	if ($i != $j)
880
+		$this->Cell($l / 1000 * $this->FontSize, $h, substr($s, $j), 0, 0, '', 0, $link);
881 881
 }
882 882
 
883
-function Ln($h=null)
883
+function Ln($h = null)
884 884
 {
885 885
 	// Line feed; default value is last cell height
886 886
 	$this->x = $this->lMargin;
887
-	if($h===null)
887
+	if ($h === null)
888 888
 		$this->y += $this->lasth;
889 889
 	else
890 890
 		$this->y += $h;
891 891
 }
892 892
 
893
-function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
893
+function Image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '')
894 894
 {
895 895
 	// Put an image on the page
896
-	if(!isset($this->images[$file]))
896
+	if ( ! isset($this->images[$file]))
897 897
 	{
898 898
 		// First use of this image, get info
899
-		if($type=='')
899
+		if ($type == '')
900 900
 		{
901
-			$pos = strrpos($file,'.');
902
-			if(!$pos)
901
+			$pos = strrpos($file, '.');
902
+			if ( ! $pos)
903 903
 				$this->Error('Image file has no extension and no type was specified: '.$file);
904
-			$type = substr($file,$pos+1);
904
+			$type = substr($file, $pos + 1);
905 905
 		}
906 906
 		$type = strtolower($type);
907
-		if($type=='jpeg')
907
+		if ($type == 'jpeg')
908 908
 			$type = 'jpg';
909 909
 		$mtd = '_parse'.$type;
910
-		if(!method_exists($this,$mtd))
910
+		if ( ! method_exists($this, $mtd))
911 911
 			$this->Error('Unsupported image type: '.$type);
912 912
 		$info = $this->$mtd($file);
913
-		$info['i'] = count($this->images)+1;
913
+		$info['i'] = count($this->images) + 1;
914 914
 		$this->images[$file] = $info;
915 915
 	}
916 916
 	else
917 917
 		$info = $this->images[$file];
918 918
 
919 919
 	// Automatic width and height calculation if needed
920
-	if($w==0 && $h==0)
920
+	if ($w == 0 && $h == 0)
921 921
 	{
922 922
 		// Put image at 96 dpi
923 923
 		$w = -96;
924 924
 		$h = -96;
925 925
 	}
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'];
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'];
934 934
 
935 935
 	// Flowing mode
936
-	if($y===null)
936
+	if ($y === null)
937 937
 	{
938
-		if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
938
+		if ($this->y + $h > $this->PageBreakTrigger && ! $this->InHeader && ! $this->InFooter && $this->AcceptPageBreak())
939 939
 		{
940 940
 			// Automatic page break
941 941
 			$x2 = $this->x;
942
-			$this->AddPage($this->CurOrientation,$this->CurPageSize);
942
+			$this->AddPage($this->CurOrientation, $this->CurPageSize);
943 943
 			$this->x = $x2;
944 944
 		}
945 945
 		$y = $this->y;
946 946
 		$this->y += $h;
947 947
 	}
948 948
 
949
-	if($x===null)
949
+	if ($x === null)
950 950
 		$x = $this->x;
951
-	$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);
951
+	$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 954
 }
955 955
 
956 956
 function GetX()
@@ -962,10 +962,10 @@  discard block
 block discarded – undo
962 962
 function SetX($x)
963 963
 {
964 964
 	// Set x position
965
-	if($x>=0)
965
+	if ($x >= 0)
966 966
 		$this->x = $x;
967 967
 	else
968
-		$this->x = $this->w+$x;
968
+		$this->x = $this->w + $x;
969 969
 }
970 970
 
971 971
 function GetY()
@@ -978,10 +978,10 @@  discard block
 block discarded – undo
978 978
 {
979 979
 	// Set y position and reset x
980 980
 	$this->x = $this->lMargin;
981
-	if($y>=0)
981
+	if ($y >= 0)
982 982
 		$this->y = $y;
983 983
 	else
984
-		$this->y = $this->h+$y;
984
+		$this->y = $this->h + $y;
985 985
 }
986 986
 
987 987
 function SetXY($x, $y)
@@ -991,15 +991,15 @@  discard block
 block discarded – undo
991 991
 	$this->SetX($x);
992 992
 }
993 993
 
994
-function Output($name='', $dest='')
994
+function Output($name = '', $dest = '')
995 995
 {
996 996
 	// Output PDF to some destination
997
-	if($this->state<3)
997
+	if ($this->state < 3)
998 998
 		$this->Close();
999 999
 	$dest = strtoupper($dest);
1000
-	if($dest=='')
1000
+	if ($dest == '')
1001 1001
 	{
1002
-		if($name=='')
1002
+		if ($name == '')
1003 1003
 		{
1004 1004
 			$name = 'doc.pdf';
1005 1005
 			$dest = 'I';
@@ -1007,12 +1007,12 @@  discard block
 block discarded – undo
1007 1007
 		else
1008 1008
 			$dest = 'F';
1009 1009
 	}
1010
-	switch($dest)
1010
+	switch ($dest)
1011 1011
 	{
1012 1012
 		case 'I':
1013 1013
 			// Send to standard output
1014 1014
 			$this->_checkoutput();
1015
-			if(PHP_SAPI!='cli')
1015
+			if (PHP_SAPI != 'cli')
1016 1016
 			{
1017 1017
 				// We send to a browser
1018 1018
 				header('Content-Type: application/pdf');
@@ -1034,10 +1034,10 @@  discard block
 block discarded – undo
1034 1034
 			break;
1035 1035
 		case 'F':
1036 1036
 			// Save to local file
1037
-			$f = fopen($name,'wb');
1038
-			if(!$f)
1037
+			$f = fopen($name, 'wb');
1038
+			if ( ! $f)
1039 1039
 				$this->Error('Unable to create output file: '.$name);
1040
-			fwrite($f,$this->buffer,strlen($this->buffer));
1040
+			fwrite($f, $this->buffer, strlen($this->buffer));
1041 1041
 			fclose($f);
1042 1042
 			break;
1043 1043
 		case 'S':
@@ -1057,27 +1057,27 @@  discard block
 block discarded – undo
1057 1057
 function _dochecks()
1058 1058
 {
1059 1059
 	// Check availability of %F
1060
-	if(sprintf('%.1F',1.0)!='1.0')
1060
+	if (sprintf('%.1F', 1.0) != '1.0')
1061 1061
 		$this->Error('This version of PHP is not supported');
1062 1062
 	// Check mbstring overloading
1063
-	if(ini_get('mbstring.func_overload') & 2)
1063
+	if (ini_get('mbstring.func_overload') & 2)
1064 1064
 		$this->Error('mbstring overloading must be disabled');
1065 1065
 	// Ensure runtime magic quotes are disabled
1066
-	if(get_magic_quotes_runtime())
1066
+	if (get_magic_quotes_runtime())
1067 1067
 		@set_magic_quotes_runtime(0);
1068 1068
 }
1069 1069
 
1070 1070
 function _checkoutput()
1071 1071
 {
1072
-	if(PHP_SAPI!='cli')
1072
+	if (PHP_SAPI != 'cli')
1073 1073
 	{
1074
-		if(headers_sent($file,$line))
1074
+		if (headers_sent($file, $line))
1075 1075
 			$this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
1076 1076
 	}
1077
-	if(ob_get_length())
1077
+	if (ob_get_length())
1078 1078
 	{
1079 1079
 		// The output buffer is not empty
1080
-		if(preg_match('/^(\xEF\xBB\xBF)?\s*$/',ob_get_contents()))
1080
+		if (preg_match('/^(\xEF\xBB\xBF)?\s*$/', ob_get_contents()))
1081 1081
 		{
1082 1082
 			// It contains only a UTF-8 BOM and/or whitespace, let's clean it
1083 1083
 			ob_clean();
@@ -1089,17 +1089,17 @@  discard block
 block discarded – undo
1089 1089
 
1090 1090
 function _getpagesize($size)
1091 1091
 {
1092
-	if(is_string($size))
1092
+	if (is_string($size))
1093 1093
 	{
1094 1094
 		$size = strtolower($size);
1095
-		if(!isset($this->StdPageSizes[$size]))
1095
+		if ( ! isset($this->StdPageSizes[$size]))
1096 1096
 			$this->Error('Unknown page size: '.$size);
1097 1097
 		$a = $this->StdPageSizes[$size];
1098
-		return array($a[0]/$this->k, $a[1]/$this->k);
1098
+		return array($a[0] / $this->k, $a[1] / $this->k);
1099 1099
 	}
1100 1100
 	else
1101 1101
 	{
1102
-		if($size[0]>$size[1])
1102
+		if ($size[0] > $size[1])
1103 1103
 			return array($size[1], $size[0]);
1104 1104
 		else
1105 1105
 			return $size;
@@ -1115,18 +1115,18 @@  discard block
 block discarded – undo
1115 1115
 	$this->y = $this->tMargin;
1116 1116
 	$this->FontFamily = '';
1117 1117
 	// Check page size and orientation
1118
-	if($orientation=='')
1118
+	if ($orientation == '')
1119 1119
 		$orientation = $this->DefOrientation;
1120 1120
 	else
1121 1121
 		$orientation = strtoupper($orientation[0]);
1122
-	if($size=='')
1122
+	if ($size == '')
1123 1123
 		$size = $this->DefPageSize;
1124 1124
 	else
1125 1125
 		$size = $this->_getpagesize($size);
1126
-	if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1])
1126
+	if ($orientation != $this->CurOrientation || $size[0] != $this->CurPageSize[0] || $size[1] != $this->CurPageSize[1])
1127 1127
 	{
1128 1128
 		// New size or orientation
1129
-		if($orientation=='P')
1129
+		if ($orientation == 'P')
1130 1130
 		{
1131 1131
 			$this->w = $size[0];
1132 1132
 			$this->h = $size[1];
@@ -1136,13 +1136,13 @@  discard block
 block discarded – undo
1136 1136
 			$this->w = $size[1];
1137 1137
 			$this->h = $size[0];
1138 1138
 		}
1139
-		$this->wPt = $this->w*$this->k;
1140
-		$this->hPt = $this->h*$this->k;
1141
-		$this->PageBreakTrigger = $this->h-$this->bMargin;
1139
+		$this->wPt = $this->w * $this->k;
1140
+		$this->hPt = $this->h * $this->k;
1141
+		$this->PageBreakTrigger = $this->h - $this->bMargin;
1142 1142
 		$this->CurOrientation = $orientation;
1143 1143
 		$this->CurPageSize = $size;
1144 1144
 	}
1145
-	if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1])
1145
+	if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1])
1146 1146
 		$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
1147 1147
 }
1148 1148
 
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 	// Load a font definition file from the font directory
1157 1157
 	include($this->fontpath.$font);
1158 1158
 	$a = get_defined_vars();
1159
-	if(!isset($a['name']))
1159
+	if ( ! isset($a['name']))
1160 1160
 		$this->Error('Could not include font definition file');
1161 1161
 	return $a;
1162 1162
 }
@@ -1164,10 +1164,10 @@  discard block
 block discarded – undo
1164 1164
 function _escape($s)
1165 1165
 {
1166 1166
 	// Escape special characters in strings
1167
-	$s = str_replace('\\','\\\\',$s);
1168
-	$s = str_replace('(','\\(',$s);
1169
-	$s = str_replace(')','\\)',$s);
1170
-	$s = str_replace("\r",'\\r',$s);
1167
+	$s = str_replace('\\', '\\\\', $s);
1168
+	$s = str_replace('(', '\\(', $s);
1169
+	$s = str_replace(')', '\\)', $s);
1170
+	$s = str_replace("\r", '\\r', $s);
1171 1171
 	return $s;
1172 1172
 }
1173 1173
 
@@ -1183,23 +1183,23 @@  discard block
 block discarded – undo
1183 1183
 	$res = "\xFE\xFF";
1184 1184
 	$nb = strlen($s);
1185 1185
 	$i = 0;
1186
-	while($i<$nb)
1186
+	while ($i < $nb)
1187 1187
 	{
1188 1188
 		$c1 = ord($s[$i++]);
1189
-		if($c1>=224)
1189
+		if ($c1 >= 224)
1190 1190
 		{
1191 1191
 			// 3-byte character
1192 1192
 			$c2 = ord($s[$i++]);
1193 1193
 			$c3 = ord($s[$i++]);
1194
-			$res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
1195
-			$res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
1194
+			$res .= chr((($c1 & 0x0F) << 4) + (($c2 & 0x3C) >> 2));
1195
+			$res .= chr((($c2 & 0x03) << 6) + ($c3 & 0x3F));
1196 1196
 		}
1197
-		elseif($c1>=192)
1197
+		elseif ($c1 >= 192)
1198 1198
 		{
1199 1199
 			// 2-byte character
1200 1200
 			$c2 = ord($s[$i++]);
1201
-			$res .= chr(($c1 & 0x1C)>>2);
1202
-			$res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
1201
+			$res .= chr(($c1 & 0x1C) >> 2);
1202
+			$res .= chr((($c1 & 0x03) << 6) + ($c2 & 0x3F));
1203 1203
 		}
1204 1204
 		else
1205 1205
 		{
@@ -1215,21 +1215,21 @@  discard block
 block discarded – undo
1215 1215
 	// Underline text
1216 1216
 	$up = $this->CurrentFont['up'];
1217 1217
 	$ut = $this->CurrentFont['ut'];
1218
-	$w = $this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');
1219
-	return sprintf('%.2F %.2F %.2F %.2F re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt);
1218
+	$w = $this->GetStringWidth($txt) + $this->ws * substr_count($txt, ' ');
1219
+	return sprintf('%.2F %.2F %.2F %.2F re f', $x * $this->k, ($this->h - ($y - $up / 1000 * $this->FontSize)) * $this->k, $w * $this->k, -$ut / 1000 * $this->FontSizePt);
1220 1220
 }
1221 1221
 
1222 1222
 function _parsejpg($file)
1223 1223
 {
1224 1224
 	// Extract info from a JPEG file
1225 1225
 	$a = getimagesize($file);
1226
-	if(!$a)
1226
+	if ( ! $a)
1227 1227
 		$this->Error('Missing or incorrect image file: '.$file);
1228
-	if($a[2]!=2)
1228
+	if ($a[2] != 2)
1229 1229
 		$this->Error('Not a JPEG file: '.$file);
1230
-	if(!isset($a['channels']) || $a['channels']==3)
1230
+	if ( ! isset($a['channels']) || $a['channels'] == 3)
1231 1231
 		$colspace = 'DeviceRGB';
1232
-	elseif($a['channels']==4)
1232
+	elseif ($a['channels'] == 4)
1233 1233
 		$colspace = 'DeviceCMYK';
1234 1234
 	else
1235 1235
 		$colspace = 'DeviceGray';
@@ -1241,10 +1241,10 @@  discard block
 block discarded – undo
1241 1241
 function _parsepng($file)
1242 1242
 {
1243 1243
 	// Extract info from a PNG file
1244
-	$f = fopen($file,'rb');
1245
-	if(!$f)
1244
+	$f = fopen($file, 'rb');
1245
+	if ( ! $f)
1246 1246
 		$this->Error('Can\'t open image file: '.$file);
1247
-	$info = $this->_parsepngstream($f,$file);
1247
+	$info = $this->_parsepngstream($f, $file);
1248 1248
 	fclose($f);
1249 1249
 	return $info;
1250 1250
 }
@@ -1252,35 +1252,35 @@  discard block
 block discarded – undo
1252 1252
 function _parsepngstream($f, $file)
1253 1253
 {
1254 1254
 	// Check signature
1255
-	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1255
+	if ($this->_readstream($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1256 1256
 		$this->Error('Not a PNG file: '.$file);
1257 1257
 
1258 1258
 	// Read header chunk
1259
-	$this->_readstream($f,4);
1260
-	if($this->_readstream($f,4)!='IHDR')
1259
+	$this->_readstream($f, 4);
1260
+	if ($this->_readstream($f, 4) != 'IHDR')
1261 1261
 		$this->Error('Incorrect PNG file: '.$file);
1262 1262
 	$w = $this->_readint($f);
1263 1263
 	$h = $this->_readint($f);
1264
-	$bpc = ord($this->_readstream($f,1));
1265
-	if($bpc>8)
1264
+	$bpc = ord($this->_readstream($f, 1));
1265
+	if ($bpc > 8)
1266 1266
 		$this->Error('16-bit depth not supported: '.$file);
1267
-	$ct = ord($this->_readstream($f,1));
1268
-	if($ct==0 || $ct==4)
1267
+	$ct = ord($this->_readstream($f, 1));
1268
+	if ($ct == 0 || $ct == 4)
1269 1269
 		$colspace = 'DeviceGray';
1270
-	elseif($ct==2 || $ct==6)
1270
+	elseif ($ct == 2 || $ct == 6)
1271 1271
 		$colspace = 'DeviceRGB';
1272
-	elseif($ct==3)
1272
+	elseif ($ct == 3)
1273 1273
 		$colspace = 'Indexed';
1274 1274
 	else
1275 1275
 		$this->Error('Unknown color type: '.$file);
1276
-	if(ord($this->_readstream($f,1))!=0)
1276
+	if (ord($this->_readstream($f, 1)) != 0)
1277 1277
 		$this->Error('Unknown compression method: '.$file);
1278
-	if(ord($this->_readstream($f,1))!=0)
1278
+	if (ord($this->_readstream($f, 1)) != 0)
1279 1279
 		$this->Error('Unknown filter method: '.$file);
1280
-	if(ord($this->_readstream($f,1))!=0)
1280
+	if (ord($this->_readstream($f, 1)) != 0)
1281 1281
 		$this->Error('Interlacing not supported: '.$file);
1282
-	$this->_readstream($f,4);
1283
-	$dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w;
1282
+	$this->_readstream($f, 4);
1283
+	$dp = '/Predictor 15 /Colors '.($colspace == 'DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w;
1284 1284
 
1285 1285
 	// Scan chunks looking for palette, transparency and image data
1286 1286
 	$pal = '';
@@ -1289,85 +1289,85 @@  discard block
 block discarded – undo
1289 1289
 	do
1290 1290
 	{
1291 1291
 		$n = $this->_readint($f);
1292
-		$type = $this->_readstream($f,4);
1293
-		if($type=='PLTE')
1292
+		$type = $this->_readstream($f, 4);
1293
+		if ($type == 'PLTE')
1294 1294
 		{
1295 1295
 			// Read palette
1296
-			$pal = $this->_readstream($f,$n);
1297
-			$this->_readstream($f,4);
1296
+			$pal = $this->_readstream($f, $n);
1297
+			$this->_readstream($f, 4);
1298 1298
 		}
1299
-		elseif($type=='tRNS')
1299
+		elseif ($type == 'tRNS')
1300 1300
 		{
1301 1301
 			// Read transparency info
1302
-			$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)));
1302
+			$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 1307
 			else
1308 1308
 			{
1309
-				$pos = strpos($t,chr(0));
1310
-				if($pos!==false)
1309
+				$pos = strpos($t, chr(0));
1310
+				if ($pos !== false)
1311 1311
 					$trns = array($pos);
1312 1312
 			}
1313
-			$this->_readstream($f,4);
1313
+			$this->_readstream($f, 4);
1314 1314
 		}
1315
-		elseif($type=='IDAT')
1315
+		elseif ($type == 'IDAT')
1316 1316
 		{
1317 1317
 			// Read image data block
1318
-			$data .= $this->_readstream($f,$n);
1319
-			$this->_readstream($f,4);
1318
+			$data .= $this->_readstream($f, $n);
1319
+			$this->_readstream($f, 4);
1320 1320
 		}
1321
-		elseif($type=='IEND')
1321
+		elseif ($type == 'IEND')
1322 1322
 			break;
1323 1323
 		else
1324
-			$this->_readstream($f,$n+4);
1324
+			$this->_readstream($f, $n + 4);
1325 1325
 	}
1326
-	while($n);
1326
+	while ($n);
1327 1327
 
1328
-	if($colspace=='Indexed' && empty($pal))
1328
+	if ($colspace == 'Indexed' && empty($pal))
1329 1329
 		$this->Error('Missing palette in '.$file);
1330 1330
 	$info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns);
1331
-	if($ct>=4)
1331
+	if ($ct >= 4)
1332 1332
 	{
1333 1333
 		// Extract alpha channel
1334
-		if(!function_exists('gzuncompress'))
1334
+		if ( ! function_exists('gzuncompress'))
1335 1335
 			$this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
1336 1336
 		$data = gzuncompress($data);
1337 1337
 		$color = '';
1338 1338
 		$alpha = '';
1339
-		if($ct==4)
1339
+		if ($ct == 4)
1340 1340
 		{
1341 1341
 			// Gray image
1342
-			$len = 2*$w;
1343
-			for($i=0;$i<$h;$i++)
1342
+			$len = 2 * $w;
1343
+			for ($i = 0; $i < $h; $i++)
1344 1344
 			{
1345
-				$pos = (1+$len)*$i;
1345
+				$pos = (1 + $len) * $i;
1346 1346
 				$color .= $data[$pos];
1347 1347
 				$alpha .= $data[$pos];
1348
-				$line = substr($data,$pos+1,$len);
1349
-				$color .= preg_replace('/(.)./s','$1',$line);
1350
-				$alpha .= preg_replace('/.(.)/s','$1',$line);
1348
+				$line = substr($data, $pos + 1, $len);
1349
+				$color .= preg_replace('/(.)./s', '$1', $line);
1350
+				$alpha .= preg_replace('/.(.)/s', '$1', $line);
1351 1351
 			}
1352 1352
 		}
1353 1353
 		else
1354 1354
 		{
1355 1355
 			// RGB image
1356
-			$len = 4*$w;
1357
-			for($i=0;$i<$h;$i++)
1356
+			$len = 4 * $w;
1357
+			for ($i = 0; $i < $h; $i++)
1358 1358
 			{
1359
-				$pos = (1+$len)*$i;
1359
+				$pos = (1 + $len) * $i;
1360 1360
 				$color .= $data[$pos];
1361 1361
 				$alpha .= $data[$pos];
1362
-				$line = substr($data,$pos+1,$len);
1363
-				$color .= preg_replace('/(.{3})./s','$1',$line);
1364
-				$alpha .= preg_replace('/.{3}(.)/s','$1',$line);
1362
+				$line = substr($data, $pos + 1, $len);
1363
+				$color .= preg_replace('/(.{3})./s', '$1', $line);
1364
+				$alpha .= preg_replace('/.{3}(.)/s', '$1', $line);
1365 1365
 			}
1366 1366
 		}
1367 1367
 		unset($data);
1368 1368
 		$data = gzcompress($color);
1369 1369
 		$info['smask'] = gzcompress($alpha);
1370
-		if($this->PDFVersion<'1.4')
1370
+		if ($this->PDFVersion < '1.4')
1371 1371
 			$this->PDFVersion = '1.4';
1372 1372
 	}
1373 1373
 	$info['data'] = $data;
@@ -1378,15 +1378,15 @@  discard block
 block discarded – undo
1378 1378
 {
1379 1379
 	// Read n bytes from stream
1380 1380
 	$res = '';
1381
-	while($n>0 && !feof($f))
1381
+	while ($n > 0 && ! feof($f))
1382 1382
 	{
1383
-		$s = fread($f,$n);
1384
-		if($s===false)
1383
+		$s = fread($f, $n);
1384
+		if ($s === false)
1385 1385
 			$this->Error('Error while reading stream');
1386 1386
 		$n -= strlen($s);
1387 1387
 		$res .= $s;
1388 1388
 	}
1389
-	if($n>0)
1389
+	if ($n > 0)
1390 1390
 		$this->Error('Unexpected end of stream');
1391 1391
 	return $res;
1392 1392
 }
@@ -1394,41 +1394,41 @@  discard block
 block discarded – undo
1394 1394
 function _readint($f)
1395 1395
 {
1396 1396
 	// Read a 4-byte integer from stream
1397
-	$a = unpack('Ni',$this->_readstream($f,4));
1397
+	$a = unpack('Ni', $this->_readstream($f, 4));
1398 1398
 	return $a['i'];
1399 1399
 }
1400 1400
 
1401 1401
 function _parsegif($file)
1402 1402
 {
1403 1403
 	// Extract info from a GIF file (via PNG conversion)
1404
-	if(!function_exists('imagepng'))
1404
+	if ( ! function_exists('imagepng'))
1405 1405
 		$this->Error('GD extension is required for GIF support');
1406
-	if(!function_exists('imagecreatefromgif'))
1406
+	if ( ! function_exists('imagecreatefromgif'))
1407 1407
 		$this->Error('GD has no GIF read support');
1408 1408
 	$im = imagecreatefromgif($file);
1409
-	if(!$im)
1409
+	if ( ! $im)
1410 1410
 		$this->Error('Missing or incorrect image file: '.$file);
1411
-	imageinterlace($im,0);
1412
-	$f = @fopen('php://temp','rb+');
1413
-	if($f)
1411
+	imageinterlace($im, 0);
1412
+	$f = @fopen('php://temp', 'rb+');
1413
+	if ($f)
1414 1414
 	{
1415 1415
 		// Perform conversion in memory
1416 1416
 		ob_start();
1417 1417
 		imagepng($im);
1418 1418
 		$data = ob_get_clean();
1419 1419
 		imagedestroy($im);
1420
-		fwrite($f,$data);
1420
+		fwrite($f, $data);
1421 1421
 		rewind($f);
1422
-		$info = $this->_parsepngstream($f,$file);
1422
+		$info = $this->_parsepngstream($f, $file);
1423 1423
 		fclose($f);
1424 1424
 	}
1425 1425
 	else
1426 1426
 	{
1427 1427
 		// Use temporary file
1428
-		$tmp = tempnam('.','gif');
1429
-		if(!$tmp)
1428
+		$tmp = tempnam('.', 'gif');
1429
+		if ( ! $tmp)
1430 1430
 			$this->Error('Unable to create a temporary file');
1431
-		if(!imagepng($im,$tmp))
1431
+		if ( ! imagepng($im, $tmp))
1432 1432
 			$this->Error('Error while saving to temporary file');
1433 1433
 		imagedestroy($im);
1434 1434
 		$info = $this->_parsepng($tmp);
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 function _out($s)
1456 1456
 {
1457 1457
 	// Add a line to the document
1458
-	if($this->state==2)
1458
+	if ($this->state == 2)
1459 1459
 		$this->pages[$this->page] .= $s."\n";
1460 1460
 	else
1461 1461
 		$this->buffer .= $s."\n";
@@ -1464,54 +1464,54 @@  discard block
 block discarded – undo
1464 1464
 function _putpages()
1465 1465
 {
1466 1466
 	$nb = $this->page;
1467
-	if(!empty($this->AliasNbPages))
1467
+	if ( ! empty($this->AliasNbPages))
1468 1468
 	{
1469 1469
 		// Replace number of pages
1470
-		for($n=1;$n<=$nb;$n++)
1471
-			$this->pages[$n] = str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
1470
+		for ($n = 1; $n <= $nb; $n++)
1471
+			$this->pages[$n] = str_replace($this->AliasNbPages, $nb, $this->pages[$n]);
1472 1472
 	}
1473
-	if($this->DefOrientation=='P')
1473
+	if ($this->DefOrientation == 'P')
1474 1474
 	{
1475
-		$wPt = $this->DefPageSize[0]*$this->k;
1476
-		$hPt = $this->DefPageSize[1]*$this->k;
1475
+		$wPt = $this->DefPageSize[0] * $this->k;
1476
+		$hPt = $this->DefPageSize[1] * $this->k;
1477 1477
 	}
1478 1478
 	else
1479 1479
 	{
1480
-		$wPt = $this->DefPageSize[1]*$this->k;
1481
-		$hPt = $this->DefPageSize[0]*$this->k;
1480
+		$wPt = $this->DefPageSize[1] * $this->k;
1481
+		$hPt = $this->DefPageSize[0] * $this->k;
1482 1482
 	}
1483 1483
 	$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1484
-	for($n=1;$n<=$nb;$n++)
1484
+	for ($n = 1; $n <= $nb; $n++)
1485 1485
 	{
1486 1486
 		// Page
1487 1487
 		$this->_newobj();
1488 1488
 		$this->_out('<</Type /Page');
1489 1489
 		$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]));
1490
+		if (isset($this->PageSizes[$n]))
1491
+			$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageSizes[$n][0], $this->PageSizes[$n][1]));
1492 1492
 		$this->_out('/Resources 2 0 R');
1493
-		if(isset($this->PageLinks[$n]))
1493
+		if (isset($this->PageLinks[$n]))
1494 1494
 		{
1495 1495
 			// Links
1496 1496
 			$annots = '/Annots [';
1497
-			foreach($this->PageLinks[$n] as $pl)
1497
+			foreach ($this->PageLinks[$n] as $pl)
1498 1498
 			{
1499
-				$rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
1499
+				$rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]);
1500 1500
 				$annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1501
-				if(is_string($pl[4]))
1501
+				if (is_string($pl[4]))
1502 1502
 					$annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1503 1503
 				else
1504 1504
 				{
1505 1505
 					$l = $this->links[$pl[4]];
1506 1506
 					$h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
1507
-					$annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k);
1507
+					$annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>', 1 + 2 * $l[0], $h - $l[1] * $this->k);
1508 1508
 				}
1509 1509
 			}
1510 1510
 			$this->_out($annots.']');
1511 1511
 		}
1512
-		if($this->PDFVersion>'1.3')
1512
+		if ($this->PDFVersion > '1.3')
1513 1513
 			$this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
1514
-		$this->_out('/Contents '.($this->n+1).' 0 R>>');
1514
+		$this->_out('/Contents '.($this->n + 1).' 0 R>>');
1515 1515
 		$this->_out('endobj');
1516 1516
 		// Page content
1517 1517
 		$p = ($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
@@ -1525,11 +1525,11 @@  discard block
 block discarded – undo
1525 1525
 	$this->_out('1 0 obj');
1526 1526
 	$this->_out('<</Type /Pages');
1527 1527
 	$kids = '/Kids [';
1528
-	for($i=0;$i<$nb;$i++)
1529
-		$kids .= (3+2*$i).' 0 R ';
1528
+	for ($i = 0; $i < $nb; $i++)
1529
+		$kids .= (3 + 2 * $i).' 0 R ';
1530 1530
 	$this->_out($kids.']');
1531 1531
 	$this->_out('/Count '.$nb);
1532
-	$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt));
1532
+	$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $wPt, $hPt));
1533 1533
 	$this->_out('>>');
1534 1534
 	$this->_out('endobj');
1535 1535
 }
@@ -1537,53 +1537,53 @@  discard block
 block discarded – undo
1537 1537
 function _putfonts()
1538 1538
 {
1539 1539
 	$nf = $this->n;
1540
-	foreach($this->diffs as $diff)
1540
+	foreach ($this->diffs as $diff)
1541 1541
 	{
1542 1542
 		// Encodings
1543 1543
 		$this->_newobj();
1544 1544
 		$this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
1545 1545
 		$this->_out('endobj');
1546 1546
 	}
1547
-	foreach($this->FontFiles as $file=>$info)
1547
+	foreach ($this->FontFiles as $file=>$info)
1548 1548
 	{
1549 1549
 		// Font file embedding
1550 1550
 		$this->_newobj();
1551 1551
 		$this->FontFiles[$file]['n'] = $this->n;
1552
-		$font = file_get_contents($this->fontpath.$file,true);
1553
-		if(!$font)
1552
+		$font = file_get_contents($this->fontpath.$file, true);
1553
+		if ( ! $font)
1554 1554
 			$this->Error('Font file not found: '.$file);
1555
-		$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']);
1555
+		$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']);
1558 1558
 		$this->_out('<</Length '.strlen($font));
1559
-		if($compressed)
1559
+		if ($compressed)
1560 1560
 			$this->_out('/Filter /FlateDecode');
1561 1561
 		$this->_out('/Length1 '.$info['length1']);
1562
-		if(isset($info['length2']))
1562
+		if (isset($info['length2']))
1563 1563
 			$this->_out('/Length2 '.$info['length2'].' /Length3 0');
1564 1564
 		$this->_out('>>');
1565 1565
 		$this->_putstream($font);
1566 1566
 		$this->_out('endobj');
1567 1567
 	}
1568
-	foreach($this->fonts as $k=>$font)
1568
+	foreach ($this->fonts as $k=>$font)
1569 1569
 	{
1570 1570
 		// Font objects
1571
-		$this->fonts[$k]['n'] = $this->n+1;
1571
+		$this->fonts[$k]['n'] = $this->n + 1;
1572 1572
 		$type = $font['type'];
1573 1573
 		$name = $font['name'];
1574
-		if($type=='Core')
1574
+		if ($type == 'Core')
1575 1575
 		{
1576 1576
 			// Core font
1577 1577
 			$this->_newobj();
1578 1578
 			$this->_out('<</Type /Font');
1579 1579
 			$this->_out('/BaseFont /'.$name);
1580 1580
 			$this->_out('/Subtype /Type1');
1581
-			if($name!='Symbol' && $name!='ZapfDingbats')
1581
+			if ($name != 'Symbol' && $name != 'ZapfDingbats')
1582 1582
 				$this->_out('/Encoding /WinAnsiEncoding');
1583 1583
 			$this->_out('>>');
1584 1584
 			$this->_out('endobj');
1585 1585
 		}
1586
-		elseif($type=='Type1' || $type=='TrueType')
1586
+		elseif ($type == 'Type1' || $type == 'TrueType')
1587 1587
 		{
1588 1588
 			// Additional Type1 or TrueType/OpenType font
1589 1589
 			$this->_newobj();
@@ -1591,10 +1591,10 @@  discard block
 block discarded – undo
1591 1591
 			$this->_out('/BaseFont /'.$name);
1592 1592
 			$this->_out('/Subtype /'.$type);
1593 1593
 			$this->_out('/FirstChar 32 /LastChar 255');
1594
-			$this->_out('/Widths '.($this->n+1).' 0 R');
1595
-			$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
1596
-			if(isset($font['diffn']))
1597
-				$this->_out('/Encoding '.($nf+$font['diffn']).' 0 R');
1594
+			$this->_out('/Widths '.($this->n + 1).' 0 R');
1595
+			$this->_out('/FontDescriptor '.($this->n + 2).' 0 R');
1596
+			if (isset($font['diffn']))
1597
+				$this->_out('/Encoding '.($nf + $font['diffn']).' 0 R');
1598 1598
 			else
1599 1599
 				$this->_out('/Encoding /WinAnsiEncoding');
1600 1600
 			$this->_out('>>');
@@ -1603,17 +1603,17 @@  discard block
 block discarded – undo
1603 1603
 			$this->_newobj();
1604 1604
 			$cw = &$font['cw'];
1605 1605
 			$s = '[';
1606
-			for($i=32;$i<=255;$i++)
1606
+			for ($i = 32; $i <= 255; $i++)
1607 1607
 				$s .= $cw[chr($i)].' ';
1608 1608
 			$this->_out($s.']');
1609 1609
 			$this->_out('endobj');
1610 1610
 			// Descriptor
1611 1611
 			$this->_newobj();
1612 1612
 			$s = '<</Type /FontDescriptor /FontName /'.$name;
1613
-			foreach($font['desc'] as $k=>$v)
1613
+			foreach ($font['desc'] as $k=>$v)
1614 1614
 				$s .= ' /'.$k.' '.$v;
1615
-			if(!empty($font['file']))
1616
-				$s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R';
1615
+			if ( ! empty($font['file']))
1616
+				$s .= ' /FontFile'.($type == 'Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R';
1617 1617
 			$this->_out($s.'>>');
1618 1618
 			$this->_out('endobj');
1619 1619
 		}
@@ -1621,7 +1621,7 @@  discard block
 block discarded – undo
1621 1621
 		{
1622 1622
 			// Allow for additional types
1623 1623
 			$mtd = '_put'.strtolower($type);
1624
-			if(!method_exists($this,$mtd))
1624
+			if ( ! method_exists($this, $mtd))
1625 1625
 				$this->Error('Unsupported font type: '.$type);
1626 1626
 			$this->$mtd($font);
1627 1627
 		}
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 
1631 1631
 function _putimages()
1632 1632
 {
1633
-	foreach(array_keys($this->images) as $file)
1633
+	foreach (array_keys($this->images) as $file)
1634 1634
 	{
1635 1635
 		$this->_putimage($this->images[$file]);
1636 1636
 		unset($this->images[$file]['data']);
@@ -1646,40 +1646,40 @@  discard block
 block discarded – undo
1646 1646
 	$this->_out('/Subtype /Image');
1647 1647
 	$this->_out('/Width '.$info['w']);
1648 1648
 	$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]');
1649
+	if ($info['cs'] == 'Indexed')
1650
+		$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal']) / 3 - 1).' '.($this->n + 1).' 0 R]');
1651 1651
 	else
1652 1652
 	{
1653 1653
 		$this->_out('/ColorSpace /'.$info['cs']);
1654
-		if($info['cs']=='DeviceCMYK')
1654
+		if ($info['cs'] == 'DeviceCMYK')
1655 1655
 			$this->_out('/Decode [1 0 1 0 1 0 1 0]');
1656 1656
 	}
1657 1657
 	$this->_out('/BitsPerComponent '.$info['bpc']);
1658
-	if(isset($info['f']))
1658
+	if (isset($info['f']))
1659 1659
 		$this->_out('/Filter /'.$info['f']);
1660
-	if(isset($info['dp']))
1660
+	if (isset($info['dp']))
1661 1661
 		$this->_out('/DecodeParms <<'.$info['dp'].'>>');
1662
-	if(isset($info['trns']) && is_array($info['trns']))
1662
+	if (isset($info['trns']) && is_array($info['trns']))
1663 1663
 	{
1664 1664
 		$trns = '';
1665
-		for($i=0;$i<count($info['trns']);$i++)
1665
+		for ($i = 0; $i < count($info['trns']); $i++)
1666 1666
 			$trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
1667 1667
 		$this->_out('/Mask ['.$trns.']');
1668 1668
 	}
1669
-	if(isset($info['smask']))
1670
-		$this->_out('/SMask '.($this->n+1).' 0 R');
1669
+	if (isset($info['smask']))
1670
+		$this->_out('/SMask '.($this->n + 1).' 0 R');
1671 1671
 	$this->_out('/Length '.strlen($info['data']).'>>');
1672 1672
 	$this->_putstream($info['data']);
1673 1673
 	$this->_out('endobj');
1674 1674
 	// Soft mask
1675
-	if(isset($info['smask']))
1675
+	if (isset($info['smask']))
1676 1676
 	{
1677 1677
 		$dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$info['w'];
1678 1678
 		$smask = array('w'=>$info['w'], 'h'=>$info['h'], 'cs'=>'DeviceGray', 'bpc'=>8, 'f'=>$info['f'], 'dp'=>$dp, 'data'=>$info['smask']);
1679 1679
 		$this->_putimage($smask);
1680 1680
 	}
1681 1681
 	// Palette
1682
-	if($info['cs']=='Indexed')
1682
+	if ($info['cs'] == 'Indexed')
1683 1683
 	{
1684 1684
 		$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1685 1685
 		$pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal'];
@@ -1692,7 +1692,7 @@  discard block
 block discarded – undo
1692 1692
 
1693 1693
 function _putxobjectdict()
1694 1694
 {
1695
-	foreach($this->images as $image)
1695
+	foreach ($this->images as $image)
1696 1696
 		$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
1697 1697
 }
1698 1698
 
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
 {
1701 1701
 	$this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
1702 1702
 	$this->_out('/Font <<');
1703
-	foreach($this->fonts as $font)
1703
+	foreach ($this->fonts as $font)
1704 1704
 		$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
1705 1705
 	$this->_out('>>');
1706 1706
 	$this->_out('/XObject <<');
@@ -1724,15 +1724,15 @@  discard block
 block discarded – undo
1724 1724
 function _putinfo()
1725 1725
 {
1726 1726
 	$this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
1727
-	if(!empty($this->title))
1727
+	if ( ! empty($this->title))
1728 1728
 		$this->_out('/Title '.$this->_textstring($this->title));
1729
-	if(!empty($this->subject))
1729
+	if ( ! empty($this->subject))
1730 1730
 		$this->_out('/Subject '.$this->_textstring($this->subject));
1731
-	if(!empty($this->author))
1731
+	if ( ! empty($this->author))
1732 1732
 		$this->_out('/Author '.$this->_textstring($this->author));
1733
-	if(!empty($this->keywords))
1733
+	if ( ! empty($this->keywords))
1734 1734
 		$this->_out('/Keywords '.$this->_textstring($this->keywords));
1735
-	if(!empty($this->creator))
1735
+	if ( ! empty($this->creator))
1736 1736
 		$this->_out('/Creator '.$this->_textstring($this->creator));
1737 1737
 	$this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
1738 1738
 }
@@ -1741,19 +1741,19 @@  discard block
 block discarded – undo
1741 1741
 {
1742 1742
 	$this->_out('/Type /Catalog');
1743 1743
 	$this->_out('/Pages 1 0 R');
1744
-	if($this->ZoomMode=='fullpage')
1744
+	if ($this->ZoomMode == 'fullpage')
1745 1745
 		$this->_out('/OpenAction [3 0 R /Fit]');
1746
-	elseif($this->ZoomMode=='fullwidth')
1746
+	elseif ($this->ZoomMode == 'fullwidth')
1747 1747
 		$this->_out('/OpenAction [3 0 R /FitH null]');
1748
-	elseif($this->ZoomMode=='real')
1748
+	elseif ($this->ZoomMode == 'real')
1749 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')
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 1753
 		$this->_out('/PageLayout /SinglePage');
1754
-	elseif($this->LayoutMode=='continuous')
1754
+	elseif ($this->LayoutMode == 'continuous')
1755 1755
 		$this->_out('/PageLayout /OneColumn');
1756
-	elseif($this->LayoutMode=='two')
1756
+	elseif ($this->LayoutMode == 'two')
1757 1757
 		$this->_out('/PageLayout /TwoColumnLeft');
1758 1758
 }
1759 1759
 
@@ -1764,9 +1764,9 @@  discard block
 block discarded – undo
1764 1764
 
1765 1765
 function _puttrailer()
1766 1766
 {
1767
-	$this->_out('/Size '.($this->n+1));
1767
+	$this->_out('/Size '.($this->n + 1));
1768 1768
 	$this->_out('/Root '.$this->n.' 0 R');
1769
-	$this->_out('/Info '.($this->n-1).' 0 R');
1769
+	$this->_out('/Info '.($this->n - 1).' 0 R');
1770 1770
 }
1771 1771
 
1772 1772
 function _enddoc()
@@ -1789,10 +1789,10 @@  discard block
 block discarded – undo
1789 1789
 	// Cross-ref
1790 1790
 	$o = strlen($this->buffer);
1791 1791
 	$this->_out('xref');
1792
-	$this->_out('0 '.($this->n+1));
1792
+	$this->_out('0 '.($this->n + 1));
1793 1793
 	$this->_out('0000000000 65535 f ');
1794
-	for($i=1;$i<=$this->n;$i++)
1795
-		$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
1794
+	for ($i = 1; $i <= $this->n; $i++)
1795
+		$this->_out(sprintf('%010d 00000 n ', $this->offsets[$i]));
1796 1796
 	// Trailer
1797 1797
 	$this->_out('trailer');
1798 1798
 	$this->_out('<<');
@@ -1807,7 +1807,7 @@  discard block
 block discarded – undo
1807 1807
 }
1808 1808
 
1809 1809
 // Handle special IE contype request
1810
-if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype')
1810
+if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] == 'contype')
1811 1811
 {
1812 1812
 	header('Content-Type: application/pdf');
1813 1813
 	exit;
Please login to merge, or discard this 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/Ftp.php 3 patches
Doc Comments   +7 added lines, -2 removed lines patch added patch discarded remove patch
@@ -233,6 +233,8 @@  discard block
 block discarded – undo
233 233
 	 * @param	string
234 234
 	 * @param	string
235 235
 	 * @param	string
236
+	 * @param string $locpath
237
+	 * @param string $rempath
236 238
 	 * @return	bool
237 239
 	 */
238 240
 	function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL)
@@ -456,6 +458,7 @@  discard block
 block discarded – undo
456 458
 	 * @access	public
457 459
 	 * @param	string	the file path
458 460
 	 * @param	string	the permissions
461
+	 * @param integer $perm
459 462
 	 * @return	bool
460 463
 	 */
461 464
 	function chmod($path, $perm)
@@ -592,6 +595,7 @@  discard block
 block discarded – undo
592 595
 	 *
593 596
 	 * @access	private
594 597
 	 * @param	string
598
+	 * @param string $ext
595 599
 	 * @return	string
596 600
 	 */
597 601
 	function _settype($ext)
@@ -624,7 +628,7 @@  discard block
 block discarded – undo
624 628
 	 * @access	public
625 629
 	 * @param	string	path to source
626 630
 	 * @param	string	path to destination
627
-	 * @return	bool
631
+	 * @return	false|null
628 632
 	 */
629 633
 	function close()
630 634
 	{
@@ -643,7 +647,8 @@  discard block
 block discarded – undo
643 647
 	 *
644 648
 	 * @access	private
645 649
 	 * @param	string
646
-	 * @return	bool
650
+	 * @param string $line
651
+	 * @return	boolean|null
647 652
 	 */
648 653
 	function _error($line)
649 654
 	{
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	var $hostname	= '';
30 30
 	var $username	= '';
31 31
 	var $password	= '';
32
-	var $port		= 21;
32
+	var $port = 21;
33 33
 	var $passive	= TRUE;
34
-	var $debug		= FALSE;
34
+	var $debug = FALSE;
35 35
 	var $conn_id	= FALSE;
36 36
 
37 37
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 		}
418 418
 
419 419
 		// Add a trailing slash to the file path if needed
420
-		$filepath = preg_replace("/(.+?)\/*$/", "\\1/",  $filepath);
420
+		$filepath = preg_replace("/(.+?)\/*$/", "\\1/", $filepath);
421 421
 
422 422
 		$list = $this->list_files($filepath);
423 423
 
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 	 */
648 648
 	function _error($line)
649 649
 	{
650
-		$CI =& get_instance();
650
+		$CI = & get_instance();
651 651
 		$CI->lang->load('ftp');
652 652
 		show_error($CI->lang->line($line));
653 653
 	}
Please login to merge, or discard this 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
  *
@@ -547,8 +549,7 @@  discard block
 block discarded – undo
547 549
 				if (@is_dir($locpath.$file) && substr($file, 0, 1) != '.')
548 550
 				{
549 551
 					$this->mirror($locpath.$file."/", $rempath.$file."/");
550
-				}
551
-				elseif (substr($file, 0, 1) != ".")
552
+				} elseif (substr($file, 0, 1) != ".")
552 553
 				{
553 554
 					// Get the file extension so we can se the upload type
554 555
 					$ext = $this->_getext($file);
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Javascript.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -168,6 +168,8 @@  discard block
 block discarded – undo
168 168
 	 * @param	string	- element
169 169
 	 * @param	string	- Javascript code for mouse over
170 170
 	 * @param	string	- Javascript code for mouse out
171
+	 * @param string $over
172
+	 * @param string $out
171 173
 	 * @return	string
172 174
 	 */
173 175
 	function hover($element = 'this', $over, $out)
@@ -675,6 +677,7 @@  discard block
 block discarded – undo
675 677
 	 * @access	public
676 678
 	 * @param	string	The element to attach the event to
677 679
 	 * @param	boolean	If a CDATA section should be added
680
+	 * @param string $script
678 681
 	 * @return	string
679 682
 	 */
680 683
 	function inline($script, $cdata = TRUE)
@@ -817,7 +820,7 @@  discard block
 block discarded – undo
817 820
 	 *
818 821
 	 * @access	public
819 822
 	 * @param	type
820
-	 * @return	type
823
+	 * @return	boolean
821 824
 	 */
822 825
 	function _is_associative_array($arr)
823 826
 	{
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 
43 43
 		extract($defaults);
44 44
 
45
-		$this->CI =& get_instance();
45
+		$this->CI = & get_instance();
46 46
 
47 47
 		// load the requested js library
48 48
 		$this->CI->load->library('javascript/'.$js_library_driver, array('autoload' => $autoload));
49 49
 		// make js to refer to current library
50
-		$this->js =& $this->CI->$js_library_driver;
50
+		$this->js = & $this->CI->$js_library_driver;
51 51
 
52 52
 		log_message('debug', "Javascript Class Initialized and loaded.  Driver used: $js_library_driver");
53 53
 	}
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	 * @param	string	- element
571 571
 	 * @return	string
572 572
 	 */
573
-	function toggleClass($element = 'this', $class='')
573
+	function toggleClass($element = 'this', $class = '')
574 574
 	{
575 575
 		return $this->js->_toggleClass($element, $class);
576 576
 	}
Please login to merge, or discard this patch.
Braces   +14 added lines, -23 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
  *
@@ -639,8 +641,7 @@  discard block
 block discarded – undo
639 641
 		if ($external_file !== '')
640 642
 		{
641 643
 			$this->_javascript_location = $external_file;
642
-		}
643
-		else
644
+		} else
644 645
 		{
645 646
 			if ($this->CI->config->item('javascript_location') != '')
646 647
 			{
@@ -651,12 +652,10 @@  discard block
 block discarded – undo
651 652
 		if ($relative === TRUE OR strncmp($external_file, 'http://', 7) == 0 OR strncmp($external_file, 'https://', 8) == 0)
652 653
 		{
653 654
 			$str = $this->_open_script($external_file);
654
-		}
655
-		elseif (strpos($this->_javascript_location, 'http://') !== FALSE)
655
+		} elseif (strpos($this->_javascript_location, 'http://') !== FALSE)
656 656
 		{
657 657
 			$str = $this->_open_script($this->_javascript_location.$external_file);
658
-		}
659
-		else
658
+		} else
660 659
 		{
661 660
 			$str = $this->_open_script($this->CI->config->slash_item('base_url').$this->_javascript_location.$external_file);
662 661
 		}
@@ -763,17 +762,14 @@  discard block
 block discarded – undo
763 762
 			if (is_object($result))
764 763
 			{
765 764
 				$json_result = $result->result_array();
766
-			}
767
-			elseif (is_array($result))
765
+			} elseif (is_array($result))
768 766
 			{
769 767
 				$json_result = $result;
770
-			}
771
-			else
768
+			} else
772 769
 			{
773 770
 				return $this->_prep_args($result);
774 771
 			}
775
-		}
776
-		else
772
+		} else
777 773
 		{
778 774
 			return 'null';
779 775
 		}
@@ -784,8 +780,7 @@  discard block
 block discarded – undo
784 780
 		if ( ! is_array($json_result) AND empty($json_result))
785 781
 		{
786 782
 			show_error("Generate JSON Failed - Illegal key, value pair.");
787
-		}
788
-		elseif ($match_array_type)
783
+		} elseif ($match_array_type)
789 784
 		{
790 785
 			$_is_assoc = $this->_is_associative_array($json_result);
791 786
 		}
@@ -795,8 +790,7 @@  discard block
 block discarded – undo
795 790
 			if ($_is_assoc)
796 791
 			{
797 792
 				$json[] = $this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type);
798
-			}
799
-			else
793
+			} else
800 794
 			{
801 795
 				$json[] = $this->generate_json($v, $match_array_type);
802 796
 			}
@@ -848,16 +842,13 @@  discard block
 block discarded – undo
848 842
 		if (is_null($result))
849 843
 		{
850 844
 			return 'null';
851
-		}
852
-		elseif (is_bool($result))
845
+		} elseif (is_bool($result))
853 846
 		{
854 847
 			return ($result === TRUE) ? 'true' : 'false';
855
-		}
856
-		elseif (is_string($result) OR $is_key)
848
+		} elseif (is_string($result) OR $is_key)
857 849
 		{
858 850
 			return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"';			
859
-		}
860
-		elseif (is_scalar($result))
851
+		} elseif (is_scalar($result))
861 852
 		{
862 853
 			return $result;
863 854
 		}
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/javascript/Jquery.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 	 * Creates a jQuery sortable
862 862
 	 *
863 863
 	 * @access	public
864
-	 * @return	void
864
+	 * @return	string
865 865
 	 */
866 866
 	function sortable($element, $options = array())
867 867
 	{
@@ -911,6 +911,8 @@  discard block
 block discarded – undo
911 911
 	 * @param	string	The element to attach the event to
912 912
 	 * @param	string	The code to execute
913 913
 	 * @param	string	The event to pass
914
+	 * @param string $element
915
+	 * @param string $event
914 916
 	 * @return	string
915 917
 	 */	
916 918
 	function _add_event($element, $js, $event)
@@ -1049,6 +1051,7 @@  discard block
 block discarded – undo
1049 1051
 	 *
1050 1052
 	 * @access	private
1051 1053
 	 * @param	string
1054
+	 * @param string $speed
1052 1055
 	 * @return	string
1053 1056
 	 */	
1054 1057
 	function _validate_speed($speed)
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 	public function __construct($params)
38 38
 	{
39
-		$this->CI =& get_instance();	
39
+		$this->CI = & get_instance();	
40 40
 		extract($params);
41 41
 
42 42
 		if ($autoload === TRUE)
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	function _hover($element = 'this', $over, $out)
179 179
 	{
180
-		$event = "\n\t$(" . $this->_prep_element($element) . ").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n";
180
+		$event = "\n\t$(".$this->_prep_element($element).").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n";
181 181
 
182 182
 		$this->jquery_code_for_compile[] = $event;
183 183
 
@@ -392,10 +392,10 @@  discard block
 block discarded – undo
392 392
 	 * @param	string	- element
393 393
 	 * @return	string
394 394
 	 */
395
-	function _addClass($element = 'this', $class='')
395
+	function _addClass($element = 'this', $class = '')
396 396
 	{
397 397
 		$element = $this->_prep_element($element);
398
-		$str  = "$({$element}).addClass(\"$class\");";
398
+		$str = "$({$element}).addClass(\"$class\");";
399 399
 		return $str;
400 400
 	}
401 401
 
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 			$extra = ', '.$extra;
437 437
 		}
438 438
 		
439
-		$str  = "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");";
439
+		$str = "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");";
440 440
 		
441 441
 		return $str;
442 442
 	}
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 			$callback = ", function(){\n{$callback}\n}";
465 465
 		}
466 466
 		
467
-		$str  = "$({$element}).fadeIn({$speed}{$callback});";
467
+		$str = "$({$element}).fadeIn({$speed}{$callback});";
468 468
 		
469 469
 		return $str;
470 470
 	}
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 			$callback = ", function(){\n{$callback}\n}";
493 493
 		}
494 494
 		
495
-		$str  = "$({$element}).fadeOut({$speed}{$callback});";
495
+		$str = "$({$element}).fadeOut({$speed}{$callback});";
496 496
 		
497 497
 		return $str;
498 498
 	}
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 			$callback = ", function(){\n{$callback}\n}";
521 521
 		}
522 522
 		
523
-		$str  = "$({$element}).hide({$speed}{$callback});";
523
+		$str = "$({$element}).hide({$speed}{$callback});";
524 524
 
525 525
 		return $str;
526 526
 	}
@@ -536,10 +536,10 @@  discard block
 block discarded – undo
536 536
 	 * @param	string	- element
537 537
 	 * @return	string
538 538
 	 */
539
-	function _removeClass($element = 'this', $class='')
539
+	function _removeClass($element = 'this', $class = '')
540 540
 	{
541 541
 		$element = $this->_prep_element($element);
542
-		$str  = "$({$element}).removeClass(\"$class\");";
542
+		$str = "$({$element}).removeClass(\"$class\");";
543 543
 		return $str;
544 544
 	}
545 545
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 			$callback = ", function(){\n{$callback}\n}";
567 567
 		}
568 568
 		
569
-		$str  = "$({$element}).slideUp({$speed}{$callback});";
569
+		$str = "$({$element}).slideUp({$speed}{$callback});";
570 570
 		
571 571
 		return $str;
572 572
 	}
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 			$callback = ", function(){\n{$callback}\n}";
595 595
 		}
596 596
 		
597
-		$str  = "$({$element}).slideDown({$speed}{$callback});";
597
+		$str = "$({$element}).slideDown({$speed}{$callback});";
598 598
 		
599 599
 		return $str;
600 600
 	}
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 			$callback = ", function(){\n{$callback}\n}";
623 623
 		}
624 624
 		
625
-		$str  = "$({$element}).slideToggle({$speed}{$callback});";
625
+		$str = "$({$element}).slideToggle({$speed}{$callback});";
626 626
 		
627 627
 		return $str;
628 628
 	}
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 	function _toggle($element = 'this')
642 642
 	{
643 643
 		$element = $this->_prep_element($element);
644
-		$str  = "$({$element}).toggle();";
644
+		$str = "$({$element}).toggle();";
645 645
 		return $str;
646 646
 	}
647 647
 	
@@ -656,10 +656,10 @@  discard block
 block discarded – undo
656 656
 	 * @param	string	- element
657 657
 	 * @return	string
658 658
 	 */
659
-	function _toggleClass($element = 'this', $class='')
659
+	function _toggleClass($element = 'this', $class = '')
660 660
 	{
661 661
 		$element = $this->_prep_element($element);
662
-		$str  = "$({$element}).toggleClass(\"$class\");";
662
+		$str = "$({$element}).toggleClass(\"$class\");";
663 663
 		return $str;
664 664
 	}
665 665
 	
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 			$callback = ", function(){\n{$callback}\n}";
687 687
 		}
688 688
 		
689
-		$str  = "$({$element}).show({$speed}{$callback});";
689
+		$str = "$({$element}).show({$speed}{$callback});";
690 690
 		
691 691
 		return $str;
692 692
 	}
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 		}
720 720
 		else
721 721
 		{
722
-			$loading_notifier = '<img src=\'' . $this->CI->config->slash_item('base_url') . $this->CI->config->item('javascript_ajax_img') . '\' alt=\'Loading\' />';
722
+			$loading_notifier = '<img src=\''.$this->CI->config->slash_item('base_url').$this->CI->config->item('javascript_ajax_img').'\' alt=\'Loading\' />';
723 723
 		}
724 724
 		
725 725
 		$updater = "$($container).empty();\n"; // anything that was in... get it out
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 	{
755 755
 		$class = ($class != '') ? '.'.$class : '';
756 756
 		
757
-		$zebra  = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");";
757
+		$zebra = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");";
758 758
 
759 759
 		$this->jquery_code_for_compile[] = $zebra;
760 760
 
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 			$corner_style = '"'.$corner_style.'"';
792 792
 		}
793 793
 
794
-		return "$(" . $this->_prep_element($element) . ").corner(".$corner_style.");";
794
+		return "$(".$this->_prep_element($element).").corner(".$corner_style.");";
795 795
 	}
796 796
 	
797 797
 	// --------------------------------------------------------------------
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 			$sort_options = '';
881 881
 		}
882 882
 
883
-		return "$(" . $this->_prep_element($element) . ").sortable({".$sort_options."\n\t});";
883
+		return "$(".$this->_prep_element($element).").sortable({".$sort_options."\n\t});";
884 884
 	}
885 885
 
886 886
 	// --------------------------------------------------------------------
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 	 */
896 896
 	function tablesorter($table = '', $options = '')
897 897
 	{
898
-		$this->jquery_code_for_compile[] = "\t$(" . $this->_prep_element($table) . ").tablesorter($options);\n";
898
+		$this->jquery_code_for_compile[] = "\t$(".$this->_prep_element($table).").tablesorter($options);\n";
899 899
 	}
900 900
 	
901 901
 	// --------------------------------------------------------------------
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 
922 922
 		}
923 923
 
924
-		$event = "\n\t$(" . $this->_prep_element($element) . ").{$event}(function(){\n\t\t{$js}\n\t});\n";
924
+		$event = "\n\t$(".$this->_prep_element($element).").{$event}(function(){\n\t\t{$js}\n\t});\n";
925 925
 		$this->jquery_code_for_compile[] = $event;
926 926
 		return $event;
927 927
 	}
@@ -943,14 +943,14 @@  discard block
 block discarded – undo
943 943
 		$external_scripts = implode('', $this->jquery_code_for_load);
944 944
 		$this->CI->load->vars(array('library_src' => $external_scripts));
945 945
 
946
-		if (count($this->jquery_code_for_compile) == 0 )
946
+		if (count($this->jquery_code_for_compile) == 0)
947 947
 		{
948 948
 			// no inline references, let's just return
949 949
 			return;
950 950
 		}
951 951
 
952 952
 		// Inline references
953
-		$script = '$(document).ready(function() {' . "\n";
953
+		$script = '$(document).ready(function() {'."\n";
954 954
 		$script .= implode('', $this->jquery_code_for_compile);
955 955
 		$script .= '});';
956 956
 		
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 	{
990 990
 		if ( ! is_array($js))
991 991
 		{
992
-			$js = array ($js);
992
+			$js = array($js);
993 993
 
994 994
 		}
995 995
 		
Please login to merge, or discard this patch.
Braces   +6 added lines, -7 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
 /**
4 6
  * CodeIgniter
@@ -716,8 +718,7 @@  discard block
 block discarded – undo
716 718
 		if ($this->CI->config->item('javascript_ajax_img') == '')
717 719
 		{
718 720
 			$loading_notifier = "Loading...";
719
-		}
720
-		else
721
+		} else
721 722
 		{
722 723
 			$loading_notifier = '<img src=\'' . $this->CI->config->slash_item('base_url') . $this->CI->config->item('javascript_ajax_img') . '\' alt=\'Loading\' />';
723 724
 		}
@@ -874,8 +875,7 @@  discard block
 block discarded – undo
874 875
 				$sort_options[] = "\n\t\t".$k.': '.$v."";
875 876
 			}
876 877
 			$sort_options = implode(",", $sort_options);
877
-		}
878
-		else
878
+		} else
879 879
 		{
880 880
 			$sort_options = '';
881 881
 		}
@@ -1056,8 +1056,7 @@  discard block
 block discarded – undo
1056 1056
 		if (in_array($speed, array('slow', 'normal', 'fast')))
1057 1057
 		{
1058 1058
 			$speed = '"'.$speed.'"';
1059
-		}
1060
-		elseif (preg_match("/[^0-9]/", $speed))
1059
+		} elseif (preg_match("/[^0-9]/", $speed))
1061 1060
 		{
1062 1061
 			$speed = '';
1063 1062
 		}
Please login to merge, or discard this patch.