GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — develop (#1814)
by
unknown
11:57
created
modules/member/member.admin.view.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php	
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 /**
4
- * @class  memberAdminView
5
- * @author NAVER ([email protected])
6
- * member module's admin view class
7
- */
4
+	 * @class  memberAdminView
5
+	 * @author NAVER ([email protected])
6
+	 * member module's admin view class
7
+	 */
8 8
 class memberAdminView extends member
9 9
 {
10 10
 	/**
Please login to merge, or discard this patch.
modules/module/module.model.php 1 patch
Braces   +457 added lines, -203 removed lines patch added patch discarded remove patch
@@ -19,26 +19,34 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	function isIDExists($id, $site_srl = 0)
21 21
 	{
22
-		if(!preg_match('/^[a-z]{1}([a-z0-9_]+)$/i',$id)) return true;
22
+		if(!preg_match('/^[a-z]{1}([a-z0-9_]+)$/i',$id)) {
23
+			return true;
24
+		}
23 25
 		// directory and rss/atom/api reserved checking, etc.
24 26
 		$dirs = FileHandler::readDir(_XE_PATH_);
25 27
 		$dirs[] = 'rss';
26 28
 		$dirs[] = 'atom';
27 29
 		$dirs[] = 'api';
28
-		if(in_array($id, $dirs)) return true;
30
+		if(in_array($id, $dirs)) {
31
+			return true;
32
+		}
29 33
 		// mid test
30 34
 		$args = new stdClass();
31 35
 		$args->mid = $id;
32 36
 		$args->site_srl = $site_srl;
33 37
 		$output = executeQuery('module.isExistsModuleName', $args);
34
-		if($output->data->count) return true;
38
+		if($output->data->count) {
39
+			return true;
40
+		}
35 41
 		// vid test (check mid != vid if site_srl=0, which means it is not a virtual site)
36 42
 		if(!$site_srl)
37 43
 		{
38 44
 			$site_args = new stdClass();
39 45
 			$site_args->domain = $id;
40 46
 			$output = executeQuery('module.isExistsSiteDomain', $site_args);
41
-			if($output->data->count) return true;
47
+			if($output->data->count) {
48
+				return true;
49
+			}
42 50
 		}
43 51
 
44 52
 		return false;
@@ -82,10 +90,14 @@  discard block
 block discarded – undo
82 90
 	function getDefaultMid()
83 91
 	{
84 92
 		$default_url = Context::getDefaultUrl();
85
-		if($default_url && substr_compare($default_url, '/', -1) === 0) $default_url = substr($default_url, 0, -1);
93
+		if($default_url && substr_compare($default_url, '/', -1) === 0) {
94
+			$default_url = substr($default_url, 0, -1);
95
+		}
86 96
 
87 97
 		$request_url = Context::getRequestUri();
88
-		if($request_url && substr_compare($request_url, '/', -1) === 0) $request_url = substr($request_url, 0, -1);
98
+		if($request_url && substr_compare($request_url, '/', -1) === 0) {
99
+			$request_url = substr($request_url, 0, -1);
100
+		}
89 101
 
90 102
 		$default_url_parse = parse_url($default_url);
91 103
 		$request_url_parse = parse_url($request_url);
@@ -100,14 +112,18 @@  discard block
 block discarded – undo
100 112
 			$url_info = parse_url($request_url);
101 113
 			$hostname = $url_info['host'];
102 114
 			$path = $url_info['path'];
103
-			if(strlen($path) >= 1 && substr_compare($path, '/', -1) === 0) $path = substr($path, 0, -1);
115
+			if(strlen($path) >= 1 && substr_compare($path, '/', -1) === 0) {
116
+				$path = substr($path, 0, -1);
117
+			}
104 118
 
105 119
 			$domain = sprintf('%s%s%s', $hostname, $url_info['port']&&$url_info['port']!=80?':'.$url_info['port']:'',$path);
106 120
 		}
107 121
 
108 122
 		if($domain === '')
109 123
 		{
110
-			if(!$vid) $vid = $mid;
124
+			if(!$vid) {
125
+				$vid = $mid;
126
+			}
111 127
 			if($vid)
112 128
 			{
113 129
 				$domain = $vid;
@@ -133,13 +149,17 @@  discard block
 block discarded – undo
133 149
 				$output = executeQuery('module.getSiteInfoByDomain', $args);
134 150
 				$site_info = $output->data;
135 151
 
136
-				if($oCacheHandler->isSupport()) $oCacheHandler->put($domain_cache_key, $site_info);
152
+				if($oCacheHandler->isSupport()) {
153
+					$oCacheHandler->put($domain_cache_key, $site_info);
154
+				}
137 155
 			}
138 156
 
139 157
 			if($site_info && $vid)
140 158
 			{
141 159
 				Context::set('vid', $site_info->domain, true);
142
-				if(strtolower($mid)==strtolower($site_info->domain)) Context::set('mid', $site_info->mid,true);
160
+				if(strtolower($mid)==strtolower($site_info->domain)) {
161
+					Context::set('mid', $site_info->mid,true);
162
+				}
143 163
 			}
144 164
 			if(!$site_info || !$site_info->domain) { $domain = ''; unset($site_info); }
145 165
 		}
@@ -165,8 +185,12 @@  discard block
 block discarded – undo
165 185
 				{
166 186
 					// Create a table if sites table doesn't exist
167 187
 					$oDB = &DB::getInstance();
168
-					if(!$oDB->isTableExists('sites')) $oDB->createTableByXmlFile(_XE_PATH_.'modules/module/schemas/sites.xml');
169
-					if(!$oDB->isTableExists('sites')) return;
188
+					if(!$oDB->isTableExists('sites')) {
189
+						$oDB->createTableByXmlFile(_XE_PATH_.'modules/module/schemas/sites.xml');
190
+					}
191
+					if(!$oDB->isTableExists('sites')) {
192
+						return;
193
+					}
170 194
 
171 195
 					// Get mid, language
172 196
 					$mid_output = $oDB->executeQuery('module.getDefaultMidInfo', $args);
@@ -184,21 +208,28 @@  discard block
 block discarded – undo
184 208
 					if($output->data && !$output->data->index_module_srl)
185 209
 					{
186 210
 						$output = executeQuery('module.updateSite', $site_args);
187
-					}
188
-					else
211
+					} else
189 212
 					{
190 213
 						$output = executeQuery('module.insertSite', $site_args);
191
-						if(!$output->toBool()) return $output;
214
+						if(!$output->toBool()) {
215
+							return $output;
216
+						}
192 217
 					}
193 218
 					$output = executeQuery('module.getSiteInfo', $args);
194 219
 				}
195 220
 				$site_info = $output->data;
196
-				if($oCacheHandler->isSupport()) $oCacheHandler->put($default_site_cache_key, $site_info);
221
+				if($oCacheHandler->isSupport()) {
222
+					$oCacheHandler->put($default_site_cache_key, $site_info);
223
+				}
197 224
 			}
198 225
 		}
199 226
 
200
-		if(!$site_info->module_srl) return $site_info;
201
-		if(is_array($site_info) && $site_info->data[0]) $site_info = $site_info[0];
227
+		if(!$site_info->module_srl) {
228
+			return $site_info;
229
+		}
230
+		if(is_array($site_info) && $site_info->data[0]) {
231
+			$site_info = $site_info[0];
232
+		}
202 233
 		return $this->addModuleExtraVars($site_info);
203 234
 	}
204 235
 
@@ -248,7 +279,9 @@  discard block
 block discarded – undo
248 279
 		}
249 280
 
250 281
 		$this->applyDefaultSkin($module_info);
251
-		if(!$module_info->module_srl && $module_info->data[0]) $module_info = $module_info->data[0];
282
+		if(!$module_info->module_srl && $module_info->data[0]) {
283
+			$module_info = $module_info->data[0];
284
+		}
252 285
 		return $this->addModuleExtraVars($module_info);
253 286
 	}
254 287
 
@@ -340,8 +373,7 @@  discard block
 block discarded – undo
340 373
 				$object_key = 'mid_info:' . $output->data->module_srl;
341 374
 				$module_info_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
342 375
 				$oCacheHandler->put($module_info_cache_key, $moduleInfo);
343
-			}
344
-			else
376
+			} else
345 377
 			{
346 378
 				$mid_info->designSettings = $moduleInfo->designSettings;
347 379
 				$moduleInfo = $mid_info;
@@ -382,11 +414,15 @@  discard block
 block discarded – undo
382 414
 			$args = new stdClass();
383 415
 			$args->module_srl = $module_srl;
384 416
 			$output = executeQuery('module.getMidInfo', $args);
385
-			if(!$output->toBool()) return;
417
+			if(!$output->toBool()) {
418
+				return;
419
+			}
386 420
 
387 421
 			$mid_info = $output->data;
388 422
 			$this->applyDefaultSkin($mid_info);
389
-			if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $mid_info);
423
+			if($oCacheHandler->isSupport()) {
424
+				$oCacheHandler->put($cache_key, $mid_info);
425
+			}
390 426
 		}
391 427
 
392 428
 		if($mid_info && count($columnList))
@@ -399,11 +435,14 @@  discard block
 block discarded – undo
399 435
 					$module_info->$key = $item;
400 436
 				}
401 437
 			}
438
+		} else {
439
+			$module_info = $mid_info;
402 440
 		}
403
-		else $module_info = $mid_info;
404 441
 
405 442
 		$oModuleController = getController('module');
406
-		if(isset($module_info->browser_title)) $oModuleController->replaceDefinedLangCode($module_info->browser_title);
443
+		if(isset($module_info->browser_title)) {
444
+			$oModuleController->replaceDefinedLangCode($module_info->browser_title);
445
+		}
407 446
 
408 447
 		$this->applyDefaultSkin($module_info);
409 448
 		return $this->addModuleExtraVars($module_info);
@@ -451,11 +490,15 @@  discard block
 block discarded – undo
451 490
 	 */
452 491
 	function getModulesInfo($module_srls, $columnList = array())
453 492
 	{
454
-		if(is_array($module_srls)) $module_srls = implode(',',$module_srls);
493
+		if(is_array($module_srls)) {
494
+			$module_srls = implode(',',$module_srls);
495
+		}
455 496
 		$args = new stdClass();
456 497
 		$args->module_srls = $module_srls;
457 498
 		$output = executeQueryArray('module.getModulesInfo', $args, $columnList);
458
-		if(!$output->toBool()) return;
499
+		if(!$output->toBool()) {
500
+			return;
501
+		}
459 502
 		return $this->addModuleExtraVars($output->data);
460 503
 	}
461 504
 
@@ -465,31 +508,44 @@  discard block
 block discarded – undo
465 508
 	function addModuleExtraVars($module_info)
466 509
 	{
467 510
 		// Process although one or more module informaion is requested
468
-		if(!is_array($module_info)) $target_module_info = array($module_info);
469
-		else $target_module_info = $module_info;
511
+		if(!is_array($module_info)) {
512
+			$target_module_info = array($module_info);
513
+		} else {
514
+			$target_module_info = $module_info;
515
+		}
470 516
 		// Get module_srl
471 517
 		$module_srls = array();
472 518
 		foreach($target_module_info as $key => $val)
473 519
 		{
474 520
 			$module_srl = $val->module_srl;
475
-			if(!$module_srl) continue;
521
+			if(!$module_srl) {
522
+				continue;
523
+			}
476 524
 			$module_srls[] = $val->module_srl;
477 525
 		}
478 526
 		// Extract extra information of the module and skin
479 527
 		$extra_vars = $this->getModuleExtraVars($module_srls);
480
-		if(!count($module_srls) || !count($extra_vars)) return $module_info;
528
+		if(!count($module_srls) || !count($extra_vars)) {
529
+			return $module_info;
530
+		}
481 531
 
482 532
 		foreach($target_module_info as $key => $val)
483 533
 		{
484
-			if(!$extra_vars[$val->module_srl] || !count($extra_vars[$val->module_srl])) continue;
534
+			if(!$extra_vars[$val->module_srl] || !count($extra_vars[$val->module_srl])) {
535
+				continue;
536
+			}
485 537
 			foreach($extra_vars[$val->module_srl] as $k => $v)
486 538
 			{
487
-				if($target_module_info[$key]->{$k}) continue;
539
+				if($target_module_info[$key]->{$k}) {
540
+					continue;
541
+				}
488 542
 				$target_module_info[$key]->{$k} = $v;
489 543
 			}
490 544
 		}
491 545
 
492
-		if(is_array($module_info)) return $target_module_info;
546
+		if(is_array($module_info)) {
547
+			return $target_module_info;
548
+		}
493 549
 		return $target_module_info[0];
494 550
 	}
495 551
 
@@ -518,7 +574,9 @@  discard block
 block discarded – undo
518 574
 			}
519 575
 
520 576
 			$output = executeQuery('module.getMidList', $args, $columnList);
521
-			if(!$output->toBool()) return $output;
577
+			if(!$output->toBool()) {
578
+				return $output;
579
+			}
522 580
 			$list = $output->data;
523 581
 
524 582
 			if($oCacheHandler->isSupport() && count($args) === 1 && isset($args->site_srl))
@@ -526,9 +584,13 @@  discard block
 block discarded – undo
526 584
 				$oCacheHandler->put($cache_key, $list);
527 585
 			}
528 586
 		}
529
-		if(!$list) return;
587
+		if(!$list) {
588
+			return;
589
+		}
530 590
 
531
-		if(!is_array($list)) $list = array($list);
591
+		if(!is_array($list)) {
592
+			$list = array($list);
593
+		}
532 594
 
533 595
 		foreach($list as $val)
534 596
 		{
@@ -544,10 +606,14 @@  discard block
 block discarded – undo
544 606
 	function getModuleSrlList($args = null, $columnList = array())
545 607
 	{
546 608
 		$output = executeQueryArray('module.getMidList', $args, $columnList);
547
-		if(!$output->toBool()) return $output;
609
+		if(!$output->toBool()) {
610
+			return $output;
611
+		}
548 612
 
549 613
 		$list = $output->data;
550
-		if(!$list) return;
614
+		if(!$list) {
615
+			return;
616
+		}
551 617
 
552 618
 		return $list;
553 619
 	}
@@ -557,20 +623,32 @@  discard block
 block discarded – undo
557 623
 	 */
558 624
 	function getModuleSrlByMid($mid)
559 625
 	{
560
-		if($mid && !is_array($mid)) $mid = explode(',',$mid);
561
-		if(is_array($mid)) $mid = "'".implode("','",$mid)."'";
626
+		if($mid && !is_array($mid)) {
627
+			$mid = explode(',',$mid);
628
+		}
629
+		if(is_array($mid)) {
630
+			$mid = "'".implode("','",$mid)."'";
631
+		}
562 632
 
563 633
 		$site_module_info = Context::get('site_module_info');
564 634
 
565 635
 		$args = new stdClass;
566 636
 		$args->mid = $mid;
567
-		if($site_module_info) $args->site_srl = $site_module_info->site_srl;
637
+		if($site_module_info) {
638
+			$args->site_srl = $site_module_info->site_srl;
639
+		}
568 640
 		$output = executeQuery('module.getModuleSrlByMid', $args);
569
-		if(!$output->toBool()) return $output;
641
+		if(!$output->toBool()) {
642
+			return $output;
643
+		}
570 644
 
571 645
 		$list = $output->data;
572
-		if(!$list) return;
573
-		if(!is_array($list)) $list = array($list);
646
+		if(!$list) {
647
+			return;
648
+		}
649
+		if(!is_array($list)) {
650
+			$list = array($list);
651
+		}
574 652
 
575 653
 		foreach($list as $key => $val)
576 654
 		{
@@ -599,8 +677,12 @@  discard block
 block discarded – undo
599 677
 		{
600 678
 			$args = new stdClass();
601 679
 			$output = executeQueryArray('module.getActionForward',$args);
602
-			if(!$output->toBool()) return new stdClass;
603
-			if(!$output->data) $output->data = array();
680
+			if(!$output->toBool()) {
681
+				return new stdClass;
682
+			}
683
+			if(!$output->data) {
684
+				$output->data = array();
685
+			}
604 686
 
605 687
 			$action_forward = array();
606 688
 			foreach($output->data as $item)
@@ -617,8 +699,7 @@  discard block
 block discarded – undo
617 699
 		if($action_forward[$act])
618 700
 		{
619 701
 			return $action_forward[$act];
620
-		}
621
-		else
702
+		} else
622 703
 		{
623 704
 			return new stdClass();
624 705
 		}
@@ -726,8 +807,7 @@  discard block
 block discarded – undo
726 807
 			if(file_exists($cache_file))
727 808
 			{
728 809
 				$GLOBALS['__MODULE_EXTEND__'] = include($cache_file);
729
-			}
730
-			else
810
+			} else
731 811
 			{
732 812
 				$GLOBALS['__MODULE_EXTEND__'] = array();
733 813
 			}
@@ -743,16 +823,22 @@  discard block
 block discarded – undo
743 823
 	{
744 824
 		// Get a path of the requested module. Return if not exists.
745 825
 		$module_path = ModuleHandler::getModulePath($module);
746
-		if(!$module_path) return;
826
+		if(!$module_path) {
827
+			return;
828
+		}
747 829
 		// Read the xml file for module skin information
748 830
 		$xml_file = sprintf("%s/conf/info.xml", $module_path);
749
-		if(!file_exists($xml_file)) return;
831
+		if(!file_exists($xml_file)) {
832
+			return;
833
+		}
750 834
 
751 835
 		$oXmlParser = new XmlParser();
752 836
 		$tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file);
753 837
 		$xml_obj = $tmp_xml_obj->module;
754 838
 
755
-		if(!$xml_obj) return;
839
+		if(!$xml_obj) {
840
+			return;
841
+		}
756 842
 
757 843
 		// Module Information
758 844
 		$module_info = new stdClass();
@@ -764,14 +850,19 @@  discard block
 block discarded – undo
764 850
 			$module_info->version = $xml_obj->version->body;
765 851
 			$module_info->homepage = $xml_obj->link->body;
766 852
 			$module_info->category = $xml_obj->category->body;
767
-			if(!$module_info->category) $module_info->category = 'service';
853
+			if(!$module_info->category) {
854
+				$module_info->category = 'service';
855
+			}
768 856
 			sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d);
769 857
 			$module_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
770 858
 			$module_info->license = $xml_obj->license->body;
771 859
 			$module_info->license_link = $xml_obj->license->attrs->link;
772 860
 
773
-			if(!is_array($xml_obj->author)) $author_list[] = $xml_obj->author;
774
-			else $author_list = $xml_obj->author;
861
+			if(!is_array($xml_obj->author)) {
862
+				$author_list[] = $xml_obj->author;
863
+			} else {
864
+				$author_list = $xml_obj->author;
865
+			}
775 866
 
776 867
 			foreach($author_list as $author)
777 868
 			{
@@ -781,15 +872,16 @@  discard block
 block discarded – undo
781 872
 				$author_obj->homepage = $author->attrs->link;
782 873
 				$module_info->author[] = $author_obj;
783 874
 			}
784
-		}
785
-		else
875
+		} else
786 876
 		{
787 877
 			// module format 0.1
788 878
 			$module_info->title = $xml_obj->title->body;
789 879
 			$module_info->description = $xml_obj->author->description->body;
790 880
 			$module_info->version = $xml_obj->attrs->version;
791 881
 			$module_info->category = $xml_obj->attrs->category;
792
-			if(!$module_info->category) $module_info->category = 'service';
882
+			if(!$module_info->category) {
883
+				$module_info->category = 'service';
884
+			}
793 885
 			sscanf($xml_obj->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d);
794 886
 			$module_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
795 887
 			$author_obj = new stdClass();
@@ -818,11 +910,15 @@  discard block
 block discarded – undo
818 910
 	{
819 911
 		// Get a path of the requested module. Return if not exists.
820 912
 		$class_path = ModuleHandler::getModulePath($module);
821
-		if(!$class_path) return;
913
+		if(!$class_path) {
914
+			return;
915
+		}
822 916
 
823 917
 		// Check if module.xml exists in the path. Return if not exist
824 918
 		$xml_file = sprintf("%sconf/module.xml", $class_path);
825
-		if(!file_exists($xml_file)) return;
919
+		if(!file_exists($xml_file)) {
920
+			return;
921
+		}
826 922
 
827 923
 		// Check if cached file exists
828 924
 		$cache_file = sprintf(_XE_PATH_ . "files/cache/module_info/%s.%s.%s.php", $module, Context::getLangType(), __XE_VERSION__);
@@ -841,7 +937,10 @@  discard block
 block discarded – undo
841 937
 
842 938
 			$xml_obj = XmlParser::loadXmlFile($xml_file); // /< Read xml file and convert it to xml object
843 939
 
844
-			if(!count($xml_obj->module)) return; // /< Error occurs if module tag doesn't included in the xml
940
+			if(!count($xml_obj->module)) {
941
+				return;
942
+			}
943
+			// /< Error occurs if module tag doesn't included in the xml
845 944
 
846 945
 			$grants = $xml_obj->module->grants->grant; // /< Permission information
847 946
 			$permissions = $xml_obj->module->permissions->permission; // /<  Acting permission
@@ -853,8 +952,11 @@  discard block
 block discarded – undo
853 952
 			// Arrange permission information
854 953
 			if($grants)
855 954
 			{
856
-				if(is_array($grants)) $grant_list = $grants;
857
-				else $grant_list[] = $grants;
955
+				if(is_array($grants)) {
956
+					$grant_list = $grants;
957
+				} else {
958
+					$grant_list[] = $grants;
959
+				}
858 960
 
859 961
 				$info->grant = new stdClass();
860 962
 				$buff[] = '$info->grant = new stdClass;';
@@ -876,8 +978,11 @@  discard block
 block discarded – undo
876 978
 			// Permissions to grant
877 979
 			if($permissions)
878 980
 			{
879
-				if(is_array($permissions)) $permission_list = $permissions;
880
-				else $permission_list[] = $permissions;
981
+				if(is_array($permissions)) {
982
+					$permission_list = $permissions;
983
+				} else {
984
+					$permission_list[] = $permissions;
985
+				}
881 986
 
882 987
 				$buff[] = '$info->permission = new stdClass;';
883 988
 
@@ -895,8 +1000,11 @@  discard block
 block discarded – undo
895 1000
 			// for admin menus
896 1001
 			if($menus)
897 1002
 			{
898
-				if(is_array($menus)) $menu_list = $menus;
899
-				else $menu_list[] = $menus;
1003
+				if(is_array($menus)) {
1004
+					$menu_list = $menus;
1005
+				} else {
1006
+					$menu_list[] = $menus;
1007
+				}
900 1008
 
901 1009
 				$buff[] = '$info->menu = new stdClass;';
902 1010
 				$info->menu = new stdClass();
@@ -920,8 +1028,11 @@  discard block
 block discarded – undo
920 1028
 			// actions
921 1029
 			if($actions)
922 1030
 			{
923
-				if(is_array($actions)) $action_list = $actions;
924
-				else $action_list[] = $actions;
1031
+				if(is_array($actions)) {
1032
+					$action_list = $actions;
1033
+				} else {
1034
+					$action_list[] = $actions;
1035
+				}
925 1036
 
926 1037
 				$buff[] = '$info->action = new stdClass;';
927 1038
 				$info->action = new stdClass();
@@ -1007,7 +1118,9 @@  discard block
 block discarded – undo
1007 1118
 			return $info;
1008 1119
 		}
1009 1120
 
1010
-		if(file_exists($cache_file)) return include($cache_file);
1121
+		if(file_exists($cache_file)) {
1122
+			return include($cache_file);
1123
+		}
1011 1124
 	}
1012 1125
 
1013 1126
 	/**
@@ -1045,7 +1158,9 @@  discard block
 block discarded – undo
1045 1158
 
1046 1159
 		$skin_path = sprintf("%s/%s/", $path, $dir);
1047 1160
 		$list = FileHandler::readDir($skin_path);
1048
-		if(!count($list)) return;
1161
+		if(!count($list)) {
1162
+			return;
1163
+		}
1049 1164
 
1050 1165
 		natcasesort($list);
1051 1166
 
@@ -1099,8 +1214,7 @@  discard block
 block discarded – undo
1099 1214
 			if($dir == 'skins')
1100 1215
 			{
1101 1216
 				$type = 'P';
1102
-			}
1103
-			else
1217
+			} else
1104 1218
 			{
1105 1219
 				$type = 'M';
1106 1220
 			}
@@ -1128,14 +1242,20 @@  discard block
 block discarded – undo
1128 1242
 	function loadSkinInfo($path, $skin, $dir = 'skins')
1129 1243
 	{
1130 1244
 		// Read xml file having skin information
1131
-		if(substr($path,-1)!='/') $path .= '/';
1245
+		if(substr($path,-1)!='/') {
1246
+			$path .= '/';
1247
+		}
1132 1248
 		$skin_xml_file = sprintf("%s%s/%s/skin.xml", $path, $dir, $skin);
1133
-		if(!file_exists($skin_xml_file)) return;
1249
+		if(!file_exists($skin_xml_file)) {
1250
+			return;
1251
+		}
1134 1252
 		// Create XmlParser object
1135 1253
 		$oXmlParser = new XmlParser();
1136 1254
 		$_xml_obj = $oXmlParser->loadXmlFile($skin_xml_file);
1137 1255
 		// Return if no skin information is
1138
-		if(!$_xml_obj->skin) return;
1256
+		if(!$_xml_obj->skin) {
1257
+			return;
1258
+		}
1139 1259
 		$xml_obj = $_xml_obj->skin;
1140 1260
 		// Skin Name
1141 1261
 		$skin_info = new stdClass();
@@ -1152,8 +1272,11 @@  discard block
 block discarded – undo
1152 1272
 			$skin_info->license_link = $xml_obj->license->attrs->link;
1153 1273
 			$skin_info->description = $xml_obj->description->body;
1154 1274
 
1155
-			if(!is_array($xml_obj->author)) $author_list[] = $xml_obj->author;
1156
-			else $author_list = $xml_obj->author;
1275
+			if(!is_array($xml_obj->author)) {
1276
+				$author_list[] = $xml_obj->author;
1277
+			} else {
1278
+				$author_list = $xml_obj->author;
1279
+			}
1157 1280
 
1158 1281
 			foreach($author_list as $author)
1159 1282
 			{
@@ -1167,8 +1290,12 @@  discard block
 block discarded – undo
1167 1290
 			if($xml_obj->extra_vars)
1168 1291
 			{
1169 1292
 				$extra_var_groups = $xml_obj->extra_vars->group;
1170
-				if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars;
1171
-				if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups);
1293
+				if(!$extra_var_groups) {
1294
+					$extra_var_groups = $xml_obj->extra_vars;
1295
+				}
1296
+				if(!is_array($extra_var_groups)) {
1297
+					$extra_var_groups = array($extra_var_groups);
1298
+				}
1172 1299
 
1173 1300
 				foreach($extra_var_groups as $group)
1174 1301
 				{
@@ -1177,7 +1304,9 @@  discard block
 block discarded – undo
1177 1304
 					{
1178 1305
 						continue;
1179 1306
 					}
1180
-					if(!is_array($group->var)) $extra_vars = array($group->var);
1307
+					if(!is_array($group->var)) {
1308
+						$extra_vars = array($group->var);
1309
+					}
1181 1310
 
1182 1311
 					foreach($extra_vars as $key => $val)
1183 1312
 					{
@@ -1204,8 +1333,7 @@  discard block
 block discarded – undo
1204 1333
 								$obj->options[$i]->title = $val->options[$i]->title->body;
1205 1334
 								$obj->options[$i]->value = $val->options[$i]->attrs->value;
1206 1335
 							}
1207
-						}
1208
-						else
1336
+						} else
1209 1337
 						{
1210 1338
 							$obj->options[0] = new stdClass();
1211 1339
 							$obj->options[0]->title = $val->options->title->body;
@@ -1216,8 +1344,7 @@  discard block
 block discarded – undo
1216 1344
 					}
1217 1345
 				}
1218 1346
 			}
1219
-		}
1220
-		else
1347
+		} else
1221 1348
 		{
1222 1349
 			// skin format v0.1
1223 1350
 			sscanf($xml_obj->maker->attrs->date, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d);
@@ -1235,8 +1362,12 @@  discard block
 block discarded – undo
1235 1362
 			$skin_info->author[0]->homepage = $xml_obj->maker->attrs->link;
1236 1363
 			// Variables used in the skin
1237 1364
 			$extra_var_groups = $xml_obj->extra_vars->group;
1238
-			if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars;
1239
-			if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups);
1365
+			if(!$extra_var_groups) {
1366
+				$extra_var_groups = $xml_obj->extra_vars;
1367
+			}
1368
+			if(!is_array($extra_var_groups)) {
1369
+				$extra_var_groups = array($extra_var_groups);
1370
+			}
1240 1371
 
1241 1372
 			foreach($extra_var_groups as $group)
1242 1373
 			{
@@ -1244,7 +1375,9 @@  discard block
 block discarded – undo
1244 1375
 
1245 1376
 				if($extra_vars)
1246 1377
 				{
1247
-					if(!is_array($extra_vars)) $extra_vars = array($extra_vars);
1378
+					if(!is_array($extra_vars)) {
1379
+						$extra_vars = array($extra_vars);
1380
+					}
1248 1381
 
1249 1382
 					foreach($extra_vars as $var)
1250 1383
 					{
@@ -1266,8 +1399,7 @@  discard block
 block discarded – undo
1266 1399
 								$options[$i]->title = $var->default[$i]->body;
1267 1400
 								$options[$i]->value = $var->default[$i]->body;
1268 1401
 							}
1269
-						}
1270
-						else
1402
+						} else
1271 1403
 						{
1272 1404
 							$options[0]->title = $var->default->body;
1273 1405
 							$options[0]->value = $var->default->body;
@@ -1297,7 +1429,9 @@  discard block
 block discarded – undo
1297 1429
 		$colorset = $xml_obj->colorset->color;
1298 1430
 		if($colorset)
1299 1431
 		{
1300
-			if(!is_array($colorset)) $colorset = array($colorset);
1432
+			if(!is_array($colorset)) {
1433
+				$colorset = array($colorset);
1434
+			}
1301 1435
 
1302 1436
 			foreach($colorset as $color)
1303 1437
 			{
@@ -1307,9 +1441,12 @@  discard block
 block discarded – undo
1307 1441
 				if($screenshot)
1308 1442
 				{
1309 1443
 					$screenshot = sprintf("%s%s/%s/%s", $path, $dir, $skin, $screenshot);
1310
-					if(!file_exists($screenshot)) $screenshot = "";
1444
+					if(!file_exists($screenshot)) {
1445
+						$screenshot = "";
1446
+					}
1447
+				} else {
1448
+					$screenshot = "";
1311 1449
 				}
1312
-				else $screenshot = "";
1313 1450
 
1314 1451
 				$obj = new stdClass();
1315 1452
 				$obj->name = $name;
@@ -1322,7 +1459,9 @@  discard block
 block discarded – undo
1322 1459
 		if($xml_obj->menus->menu)
1323 1460
 		{
1324 1461
 			$menus = $xml_obj->menus->menu;
1325
-			if(!is_array($menus)) $menus = array($menus);
1462
+			if(!is_array($menus)) {
1463
+				$menus = array($menus);
1464
+			}
1326 1465
 
1327 1466
 			$menu_count = count($menus);
1328 1467
 			$skin_info->menu_count = $menu_count;
@@ -1331,7 +1470,9 @@  discard block
 block discarded – undo
1331 1470
 				unset($obj);
1332 1471
 
1333 1472
 				$obj->name = $menus[$i]->attrs->name;
1334
-				if($menus[$i]->attrs->default == "true") $obj->default = true;
1473
+				if($menus[$i]->attrs->default == "true") {
1474
+					$obj->default = true;
1475
+				}
1335 1476
 				$obj->title = $menus[$i]->title->body;
1336 1477
 				$obj->maxdepth = $menus[$i]->maxdepth->body;
1337 1478
 
@@ -1351,7 +1492,9 @@  discard block
 block discarded – undo
1351 1492
 	{
1352 1493
 		$args = new stdClass;
1353 1494
 		$args->site_srl = $site_srl;
1354
-		if(!is_null($module)) $args->module = $module;
1495
+		if(!is_null($module)) {
1496
+			$args->module = $module;
1497
+		}
1355 1498
 		$output = executeQuery('module.getModuleCount', $args);
1356 1499
 		return $output->data->count;
1357 1500
 	}
@@ -1380,8 +1523,11 @@  discard block
 block discarded – undo
1380 1523
 				$args->module = $module;
1381 1524
 				$args->site_srl = $site_srl;
1382 1525
 				$output = executeQuery('module.getModuleConfig', $args);
1383
-				if($output->data->config) $config = unserialize($output->data->config);
1384
-				else $config = new stdClass();
1526
+				if($output->data->config) {
1527
+					$config = unserialize($output->data->config);
1528
+				} else {
1529
+					$config = new stdClass();
1530
+				}
1385 1531
 
1386 1532
 				//insert in cache
1387 1533
 				if($oCacheHandler->isSupport())
@@ -1420,8 +1566,11 @@  discard block
 block discarded – undo
1420 1566
 				$args->module = $module;
1421 1567
 				$args->module_srl = $module_srl;
1422 1568
 				$output = executeQuery('module.getModulePartConfig', $args);
1423
-				if($output->data->config) $config = unserialize($output->data->config);
1424
-				else $config = null;
1569
+				if($output->data->config) {
1570
+					$config = unserialize($output->data->config);
1571
+				} else {
1572
+					$config = null;
1573
+				}
1425 1574
 
1426 1575
 				//insert in cache
1427 1576
 				if($oCacheHandler->isSupport())
@@ -1443,9 +1592,13 @@  discard block
 block discarded – undo
1443 1592
 	{
1444 1593
 		$args = new stdClass();
1445 1594
 		$args->module = $module;
1446
-		if($site_srl) $args->site_srl = $site_srl;
1595
+		if($site_srl) {
1596
+			$args->site_srl = $site_srl;
1597
+		}
1447 1598
 		$output = executeQueryArray('module.getModulePartConfigs', $args);
1448
-		if(!$output->toBool() || !$output->data) return array();
1599
+		if(!$output->toBool() || !$output->data) {
1600
+			return array();
1601
+		}
1449 1602
 
1450 1603
 		foreach($output->data as $key => $val)
1451 1604
 		{
@@ -1463,10 +1616,16 @@  discard block
 block discarded – undo
1463 1616
 		$args->moduleCategorySrl = $moduleCategorySrl;
1464 1617
 		// Get data from the DB
1465 1618
 		$output = executeQuery('module.getModuleCategories', $args);
1466
-		if(!$output->toBool()) return $output;
1619
+		if(!$output->toBool()) {
1620
+			return $output;
1621
+		}
1467 1622
 		$list = $output->data;
1468
-		if(!$list) return;
1469
-		if(!is_array($list)) $list = array($list);
1623
+		if(!$list) {
1624
+			return;
1625
+		}
1626
+		if(!is_array($list)) {
1627
+			$list = array($list);
1628
+		}
1470 1629
 
1471 1630
 		foreach($list as $val)
1472 1631
 		{
@@ -1484,7 +1643,9 @@  discard block
 block discarded – undo
1484 1643
 		$args = new stdClass;
1485 1644
 		$args->module_category_srl = $module_category_srl;
1486 1645
 		$output = executeQuery('module.getModuleCategory', $args);
1487
-		if(!$output->toBool()) return $output;
1646
+		if(!$output->toBool()) {
1647
+			return $output;
1648
+		}
1488 1649
 		return $output->data;
1489 1650
 	}
1490 1651
 
@@ -1496,7 +1657,9 @@  discard block
 block discarded – undo
1496 1657
 		// Get a list of downloaded and installed modules
1497 1658
 		$searched_list = FileHandler::readDir('./modules');
1498 1659
 		$searched_count = count($searched_list);
1499
-		if(!$searched_count) return;
1660
+		if(!$searched_count) {
1661
+			return;
1662
+		}
1500 1663
 		sort($searched_list);
1501 1664
 
1502 1665
 		for($i=0;$i<$searched_count;$i++)
@@ -1509,7 +1672,9 @@  discard block
 block discarded – undo
1509 1672
 			$info = $this->getModuleInfoXml($module_name);
1510 1673
 			unset($obj);
1511 1674
 
1512
-			if(!isset($info)) continue;
1675
+			if(!isset($info)) {
1676
+				continue;
1677
+			}
1513 1678
 			$info->module = $module_name;
1514 1679
 			$info->created_table_count = $created_table_count;
1515 1680
 			$info->table_count = $table_count;
@@ -1535,11 +1700,16 @@  discard block
 block discarded – undo
1535 1700
 			for($j=0;$j<count($tmp_files);$j++)
1536 1701
 			{
1537 1702
 				list($table_name) = explode(".",$tmp_files[$j]);
1538
-				if($oDB->isTableExists($table_name)) $created_table_count ++;
1703
+				if($oDB->isTableExists($table_name)) {
1704
+					$created_table_count ++;
1705
+				}
1539 1706
 			}
1540 1707
 			// Check if DB is installed
1541
-			if($table_count > $created_table_count) return true;
1542
-			else return false;
1708
+			if($table_count > $created_table_count) {
1709
+				return true;
1710
+			} else {
1711
+				return false;
1712
+			}
1543 1713
 		}
1544 1714
 		return false;
1545 1715
 	}
@@ -1567,7 +1737,9 @@  discard block
 block discarded – undo
1567 1737
 		sort($searched_list);
1568 1738
 
1569 1739
 		$searched_count = count($searched_list);
1570
-		if(!$searched_count) return;
1740
+		if(!$searched_count) {
1741
+			return;
1742
+		}
1571 1743
 
1572 1744
 		for($i=0;$i<$searched_count;$i++)
1573 1745
 		{
@@ -1575,7 +1747,9 @@  discard block
 block discarded – undo
1575 1747
 			$module_name = $searched_list[$i];
1576 1748
 
1577 1749
 			$path = ModuleHandler::getModulePath($module_name);
1578
-			if(!is_dir(FileHandler::getRealPath($path))) continue;
1750
+			if(!is_dir(FileHandler::getRealPath($path))) {
1751
+				continue;
1752
+			}
1579 1753
 
1580 1754
 			// Get the number of xml files to create a table in schemas
1581 1755
 			$tmp_files = FileHandler::readDir($path.'schemas', '/(\.xml)$/');
@@ -1585,13 +1759,17 @@  discard block
 block discarded – undo
1585 1759
 			for($j=0;$j<$table_count;$j++)
1586 1760
 			{
1587 1761
 				list($table_name) = explode('.',$tmp_files[$j]);
1588
-				if($oDB->isTableExists($table_name)) $created_table_count ++;
1762
+				if($oDB->isTableExists($table_name)) {
1763
+					$created_table_count ++;
1764
+				}
1589 1765
 			}
1590 1766
 			// Get information of the module
1591 1767
 			$info = NULL;
1592 1768
 			$info = $this->getModuleInfoXml($module_name);
1593 1769
 
1594
-			if(!$info) continue;
1770
+			if(!$info) {
1771
+				continue;
1772
+			}
1595 1773
 
1596 1774
 			$info->module = $module_name;
1597 1775
 			$info->category = $info->category;
@@ -1600,16 +1778,18 @@  discard block
 block discarded – undo
1600 1778
 			$info->path = $path;
1601 1779
 			$info->admin_index_act = $info->admin_index_act;
1602 1780
 			// Check if DB is installed
1603
-			if($table_count > $created_table_count) $info->need_install = true;
1604
-			else $info->need_install = false;
1781
+			if($table_count > $created_table_count) {
1782
+				$info->need_install = true;
1783
+			} else {
1784
+				$info->need_install = false;
1785
+			}
1605 1786
 			// Check if it is upgraded to module.class.php on each module
1606 1787
 			$oDummy = null;
1607 1788
 			$oDummy = getModule($module_name, 'class');
1608 1789
 			if($oDummy && method_exists($oDummy, "checkUpdate"))
1609 1790
 			{
1610 1791
 				$info->need_update = $oDummy->checkUpdate();
1611
-			}
1612
-			else
1792
+			} else
1613 1793
 			{
1614 1794
 				continue;
1615 1795
 			}
@@ -1626,7 +1806,9 @@  discard block
 block discarded – undo
1626 1806
 	 */
1627 1807
 	function syncModuleToSite(&$data)
1628 1808
 	{
1629
-		if(!$data) return;
1809
+		if(!$data) {
1810
+			return;
1811
+		}
1630 1812
 
1631 1813
 		if(is_array($data))
1632 1814
 		{
@@ -1634,9 +1816,10 @@  discard block
 block discarded – undo
1634 1816
 			{
1635 1817
 				$module_srls[] = $val->module_srl;
1636 1818
 			}
1637
-			if(!count($module_srls)) return;
1638
-		}
1639
-		else
1819
+			if(!count($module_srls)) {
1820
+				return;
1821
+			}
1822
+		} else
1640 1823
 		{
1641 1824
 			$module_srls[] = $data->module_srl;
1642 1825
 		}
@@ -1644,7 +1827,9 @@  discard block
 block discarded – undo
1644 1827
 		$args = new stdClass();
1645 1828
 		$args->module_srls = implode(',',$module_srls);
1646 1829
 		$output = executeQueryArray('module.getModuleSites', $args);
1647
-		if(!$output->data) return array();
1830
+		if(!$output->data) {
1831
+			return array();
1832
+		}
1648 1833
 		foreach($output->data as $key => $val)
1649 1834
 		{
1650 1835
 			$modules[$val->module_srl] = $val;
@@ -1656,8 +1841,7 @@  discard block
 block discarded – undo
1656 1841
 			{
1657 1842
 				$data[$key]->domain = $modules[$val->module_srl]->domain;
1658 1843
 			}
1659
-		}
1660
-		else
1844
+		} else
1661 1845
 		{
1662 1846
 			$data->domain = $modules[$data->module_srl]->domain;
1663 1847
 		}
@@ -1668,24 +1852,31 @@  discard block
 block discarded – undo
1668 1852
 	 */
1669 1853
 	function isSiteAdmin($member_info, $site_srl = null)
1670 1854
 	{
1671
-		if(!$member_info->member_srl) return false;
1672
-		if($member_info->is_admin == 'Y') return true;
1855
+		if(!$member_info->member_srl) {
1856
+			return false;
1857
+		}
1858
+		if($member_info->is_admin == 'Y') {
1859
+			return true;
1860
+		}
1673 1861
 
1674 1862
 		$args = new stdClass();
1675 1863
 		if(!isset($site_srl))
1676 1864
 		{
1677 1865
 			$site_module_info = Context::get('site_module_info');
1678
-			if(!$site_module_info) return;
1866
+			if(!$site_module_info) {
1867
+				return;
1868
+			}
1679 1869
 			$args->site_srl = $site_module_info->site_srl;
1680
-		}
1681
-		else
1870
+		} else
1682 1871
 		{
1683 1872
 			$args->site_srl = $site_srl;
1684 1873
 		}
1685 1874
 
1686 1875
 		$args->member_srl = $member_info->member_srl;
1687 1876
 		$output = executeQuery('module.isSiteAdmin', $args);
1688
-		if($output->data->member_srl == $args->member_srl) return true;
1877
+		if($output->data->member_srl == $args->member_srl) {
1878
+			return true;
1879
+		}
1689 1880
 		return false;
1690 1881
 	}
1691 1882
 
@@ -1708,7 +1899,9 @@  discard block
 block discarded – undo
1708 1899
 		$obj = new stdClass();
1709 1900
 		$obj->module_srl = $module_srl;
1710 1901
 		$output = executeQueryArray('module.getAdminID', $obj);
1711
-		if(!$output->toBool() || !$output->data) return;
1902
+		if(!$output->toBool() || !$output->data) {
1903
+			return;
1904
+		}
1712 1905
 
1713 1906
 		return $output->data;
1714 1907
 	}
@@ -1721,7 +1914,9 @@  discard block
 block discarded – undo
1721 1914
 	{
1722 1915
 		$extra_vars = array();
1723 1916
 		$get_module_srls = array();
1724
-		if(!is_array($list_module_srl)) $list_module_srl = array($list_module_srl);
1917
+		if(!is_array($list_module_srl)) {
1918
+			$list_module_srl = array($list_module_srl);
1919
+		}
1725 1920
 
1726 1921
 		$vars = false;
1727 1922
 		// cache controll
@@ -1737,14 +1932,12 @@  discard block
 block discarded – undo
1737 1932
 				if($vars)
1738 1933
 				{
1739 1934
 					$extra_vars[$module_srl] = $vars;
1740
-				}
1741
-				else
1935
+				} else
1742 1936
 				{
1743 1937
 					$get_module_srls[] = $module_srl;
1744 1938
 				}
1745 1939
 			}
1746
-		}
1747
-		else
1940
+		} else
1748 1941
 		{
1749 1942
 			$get_module_srls = $list_module_srl;
1750 1943
 		}
@@ -1769,7 +1962,9 @@  discard block
 block discarded – undo
1769 1962
 			}
1770 1963
 			foreach($output->data as $key => $val)
1771 1964
 			{
1772
-				if(in_array($val->name, array('mid','module')) || $val->value == 'Array') continue;
1965
+				if(in_array($val->name, array('mid','module')) || $val->value == 'Array') {
1966
+					continue;
1967
+				}
1773 1968
 
1774 1969
 				if(!isset($extra_vars[$val->module_srl]))
1775 1970
 				{
@@ -1808,7 +2003,9 @@  discard block
 block discarded – undo
1808 2003
 			$args = new stdClass();
1809 2004
 			$args->module_srl = $module_srl;
1810 2005
 			$output = executeQueryArray('module.getModuleSkinVars',$args);
1811
-			if(!$output->toBool()) return;
2006
+			if(!$output->toBool()) {
2007
+				return;
2008
+			}
1812 2009
 
1813 2010
 			$skin_vars = array();
1814 2011
 			foreach($output->data as $vars)
@@ -1816,7 +2013,9 @@  discard block
 block discarded – undo
1816 2013
 				$skin_vars[$vars->name] = $vars;
1817 2014
 			}
1818 2015
 
1819
-			if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $skin_vars);
2016
+			if($oCacheHandler->isSupport()) {
2017
+				$oCacheHandler->put($cache_key, $skin_vars);
2018
+			}
1820 2019
 		}
1821 2020
 
1822 2021
 		return $skin_vars;
@@ -1828,7 +2027,9 @@  discard block
 block discarded – undo
1828 2027
 	function getModuleDefaultSkin($module_name, $skin_type = 'P', $site_srl = 0, $updateCache = true)
1829 2028
 	{
1830 2029
 		$target = ($skin_type == 'M') ? 'mskin' : 'skin';
1831
-		if(!$site_srl) $site_srl = 0;
2030
+		if(!$site_srl) {
2031
+			$site_srl = 0;
2032
+		}
1832 2033
 
1833 2034
 		$designInfoFile = sprintf(_XE_PATH_.'files/site_design/design_%s.php', $site_srl);
1834 2035
 		if(is_readable($designInfoFile))
@@ -1845,19 +2046,16 @@  discard block
 block discarded – undo
1845 2046
 			if(is_dir($moduleSkinPath.'default'))
1846 2047
 			{
1847 2048
 				$skinName = 'default';
1848
-			}
1849
-			else if(is_dir($moduleSkinPath.'xe_default'))
2049
+			} else if(is_dir($moduleSkinPath.'xe_default'))
1850 2050
 			{
1851 2051
 				$skinName = 'xe_default';
1852
-			}
1853
-			else
2052
+			} else
1854 2053
 			{
1855 2054
 				$skins = FileHandler::readDir($moduleSkinPath);
1856 2055
 				if(count($skins) > 0)
1857 2056
 				{
1858 2057
 					$skinName = $skins[0];
1859
-				}
1860
-				else
2058
+				} else
1861 2059
 				{
1862 2060
 					$skinName = NULL;
1863 2061
 				}
@@ -1865,7 +2063,9 @@  discard block
 block discarded – undo
1865 2063
 
1866 2064
 			if($updateCache && $skinName)
1867 2065
 			{
1868
-				if(!isset($designInfo->module->{$module_name})) $designInfo->module->{$module_name} = new stdClass();
2066
+				if(!isset($designInfo->module->{$module_name})) {
2067
+					$designInfo->module->{$module_name} = new stdClass();
2068
+				}
1869 2069
 				$designInfo->module->{$module_name}->{$target} = $skinName;
1870 2070
 
1871 2071
 				$oAdminController = getAdminController('admin');
@@ -1881,23 +2081,28 @@  discard block
 block discarded – undo
1881 2081
 	 */
1882 2082
 	function syncSkinInfoToModuleInfo(&$module_info)
1883 2083
 	{
1884
-		if(!$module_info->module_srl) return;
2084
+		if(!$module_info->module_srl) {
2085
+			return;
2086
+		}
1885 2087
 
1886 2088
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
1887 2089
 		if(Mobile::isFromMobilePhone())
1888 2090
 		{
1889 2091
 			$skin_vars = $this->getModuleMobileSkinVars($module_info->module_srl);
1890
-		}
1891
-		else
2092
+		} else
1892 2093
 		{
1893 2094
 			$skin_vars = $this->getModuleSkinVars($module_info->module_srl);
1894 2095
 		}
1895 2096
 
1896
-		if(!$skin_vars) return;
2097
+		if(!$skin_vars) {
2098
+			return;
2099
+		}
1897 2100
 
1898 2101
 		foreach($skin_vars as $name => $val)
1899 2102
 		{
1900
-			if(isset($module_info->{$name})) continue;
2103
+			if(isset($module_info->{$name})) {
2104
+				continue;
2105
+			}
1901 2106
 			$module_info->{$name} = $val->value;
1902 2107
 		}
1903 2108
 	}
@@ -1923,7 +2128,9 @@  discard block
 block discarded – undo
1923 2128
 			$args = new stdClass();
1924 2129
 			$args->module_srl = $module_srl;
1925 2130
 			$output = executeQueryArray('module.getModuleMobileSkinVars',$args);
1926
-			if(!$output->toBool() || !$output->data) return;
2131
+			if(!$output->toBool() || !$output->data) {
2132
+				return;
2133
+			}
1927 2134
 
1928 2135
 			$skin_vars = array();
1929 2136
 			foreach($output->data as $vars)
@@ -1931,7 +2138,9 @@  discard block
 block discarded – undo
1931 2138
 				$skin_vars[$vars->name] = $vars;
1932 2139
 			}
1933 2140
 
1934
-			if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $skin_vars);
2141
+			if($oCacheHandler->isSupport()) {
2142
+				$oCacheHandler->put($cache_key, $skin_vars);
2143
+			}
1935 2144
 		}
1936 2145
 
1937 2146
 		return $skin_vars;
@@ -1943,7 +2152,9 @@  discard block
 block discarded – undo
1943 2152
 	 */
1944 2153
 	function syncMobileSkinInfoToModuleInfo(&$module_info)
1945 2154
 	{
1946
-		if(!$module_info->module_srl) return;
2155
+		if(!$module_info->module_srl) {
2156
+			return;
2157
+		}
1947 2158
 		$skin_vars = false;
1948 2159
 		// cache controll
1949 2160
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
@@ -1958,17 +2169,25 @@  discard block
 block discarded – undo
1958 2169
 			$args = new stdClass;
1959 2170
 			$args->module_srl = $module_info->module_srl;
1960 2171
 			$output = executeQueryArray('module.getModuleMobileSkinVars',$args);
1961
-			if(!$output->toBool()) return;
2172
+			if(!$output->toBool()) {
2173
+				return;
2174
+			}
1962 2175
 			$skin_vars = $output->data;
1963 2176
 
1964 2177
 			//insert in cache
1965
-			if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $skin_vars);
2178
+			if($oCacheHandler->isSupport()) {
2179
+				$oCacheHandler->put($cache_key, $skin_vars);
2180
+			}
2181
+		}
2182
+		if(!$skin_vars) {
2183
+			return;
1966 2184
 		}
1967
-		if(!$skin_vars) return;
1968 2185
 
1969 2186
 		foreach($output->data as $val)
1970 2187
 		{
1971
-			if(isset($module_info->{$val->name})) continue;
2188
+			if(isset($module_info->{$val->name})) {
2189
+				continue;
2190
+			}
1972 2191
 			$module_info->{$val->name} = $val->value;
1973 2192
 		}
1974 2193
 	}
@@ -1990,10 +2209,12 @@  discard block
 block discarded – undo
1990 2209
 		$grant_info = $xml_info->grant;
1991 2210
 		if($member_info->member_srl)
1992 2211
 		{
1993
-			if(is_array($member_info->group_list)) $group_list = array_keys($member_info->group_list);
1994
-			else $group_list = array();
1995
-		}
1996
-		else
2212
+			if(is_array($member_info->group_list)) {
2213
+				$group_list = array_keys($member_info->group_list);
2214
+			} else {
2215
+				$group_list = array();
2216
+			}
2217
+		} else
1997 2218
 		{
1998 2219
 			$group_list = array();
1999 2220
 		}
@@ -2007,8 +2228,7 @@  discard block
 block discarded – undo
2007 2228
 			}
2008 2229
 
2009 2230
 			$grant->is_admin = $grant->manager = ($member_info->is_admin == 'Y') ? true : false;
2010
-		}
2011
-		else
2231
+		} else
2012 2232
 		{
2013 2233
 			// If module_srl exists
2014 2234
 			// Get a type of granted permission
@@ -2021,7 +2241,9 @@  discard block
 block discarded – undo
2021 2241
 				$args->module_srl = $module_srl;
2022 2242
 				$args->member_srl = $member_info->member_srl;
2023 2243
 				$output = executeQuery('module.getModuleAdmin',$args);
2024
-				if($output->data && $output->data->member_srl == $member_info->member_srl) $grant->manager = true;
2244
+				if($output->data && $output->data->member_srl == $member_info->member_srl) {
2245
+					$grant->manager = true;
2246
+				}
2025 2247
 			}
2026 2248
 			// If not an administrator, get information from the DB and grant manager privilege.
2027 2249
 			if(!$grant->manager)
@@ -2031,8 +2253,7 @@  discard block
 block discarded – undo
2031 2253
 				if($module_info->module == 'planet')
2032 2254
 				{
2033 2255
 					$output = executeQueryArray('module.getPlanetGrants', $args);
2034
-				}
2035
-				else
2256
+				} else
2036 2257
 				{
2037 2258
 					$args = new stdClass;
2038 2259
 					$args->module_srl = $module_srl;
@@ -2047,37 +2268,44 @@  discard block
 block discarded – undo
2047 2268
 					foreach($output->data as $val)
2048 2269
 					{
2049 2270
 						$grant_exists[$val->name] = true;
2050
-						if($granted[$val->name]) continue;
2271
+						if($granted[$val->name]) {
2272
+							continue;
2273
+						}
2051 2274
 						// Log-in member only
2052 2275
 						if($val->group_srl == -1)
2053 2276
 						{
2054 2277
 							$granted[$val->name] = true;
2055
-							if($member_info->member_srl) $grant->{$val->name} = true;
2278
+							if($member_info->member_srl) {
2279
+								$grant->{$val->name} = true;
2280
+							}
2056 2281
 							// Site-joined member only
2057
-						}
2058
-						elseif($val->group_srl == -2)
2282
+						} elseif($val->group_srl == -2)
2059 2283
 						{
2060 2284
 							$granted[$val->name] = true;
2061 2285
 							// Do not grant any permission for non-logged member
2062
-							if(!$member_info->member_srl) $grant->{$val->name} = false;
2286
+							if(!$member_info->member_srl) {
2287
+								$grant->{$val->name} = false;
2288
+							}
2063 2289
 							// Log-in member
2064 2290
 							else
2065 2291
 							{
2066 2292
 								$site_module_info = Context::get('site_module_info');
2067 2293
 								// Permission granted if no information of the currently connected site exists
2068
-								if(!$site_module_info->site_srl) $grant->{$val->name} = true;
2294
+								if(!$site_module_info->site_srl) {
2295
+									$grant->{$val->name} = true;
2296
+								}
2069 2297
 								// Permission is not granted if information of the currently connected site exists
2070
-								elseif(count($group_list)) $grant->{$val->name} = true;
2298
+								elseif(count($group_list)) {
2299
+									$grant->{$val->name} = true;
2300
+								}
2071 2301
 							}
2072 2302
 							// All of non-logged members
2073
-						}
2074
-						elseif($val->group_srl == 0)
2303
+						} elseif($val->group_srl == 0)
2075 2304
 						{
2076 2305
 							$granted[$val->name] = true;
2077 2306
 							$grant->{$val->name} = true;
2078 2307
 							// If a target is a group
2079
-						}
2080
-						else
2308
+						} else
2081 2309
 						{
2082 2310
 							if($group_list && count($group_list) && in_array($val->group_srl, $group_list))
2083 2311
 							{
@@ -2088,30 +2316,43 @@  discard block
 block discarded – undo
2088 2316
 					}
2089 2317
 				}
2090 2318
 				// Separate processing for the virtual group access
2091
-				if(!$grant_exists['access']) $grant->access = true;
2319
+				if(!$grant_exists['access']) {
2320
+					$grant->access = true;
2321
+				}
2092 2322
 				if(count($grant_info))
2093 2323
 				{
2094 2324
 					foreach($grant_info as  $grant_name => $grant_item)
2095 2325
 					{
2096
-						if($grant_exists[$grant_name]) continue;
2326
+						if($grant_exists[$grant_name]) {
2327
+							continue;
2328
+						}
2097 2329
 						switch($grant_item->default)
2098 2330
 						{
2099 2331
 							case 'guest' :
2100 2332
 								$grant->{$grant_name} = true;
2101 2333
 								break;
2102 2334
 							case 'member' :
2103
-								if($member_info->member_srl) $grant->{$grant_name} = true;
2104
-								else $grant->{$grant_name} = false;
2335
+								if($member_info->member_srl) {
2336
+									$grant->{$grant_name} = true;
2337
+								} else {
2338
+									$grant->{$grant_name} = false;
2339
+								}
2105 2340
 								break;
2106 2341
 							case 'site' :
2107 2342
 								$site_module_info = Context::get('site_module_info');
2108
-								if($member_info->member_srl && (($site_module_info->site_srl && count($group_list)) || !$site_module_info->site_srl)) $grant->{$grant_name} = true;
2109
-								else $grant->{$grant_name} = false;
2343
+								if($member_info->member_srl && (($site_module_info->site_srl && count($group_list)) || !$site_module_info->site_srl)) {
2344
+									$grant->{$grant_name} = true;
2345
+								} else {
2346
+									$grant->{$grant_name} = false;
2347
+								}
2110 2348
 								break;
2111 2349
 							case 'manager' :
2112 2350
 							case 'root' :
2113
-								if($member_info->is_admin == 'Y') $grant->{$grant_name} = true;
2114
-								else $grant->{$grant_name} = false;
2351
+								if($member_info->is_admin == 'Y') {
2352
+									$grant->{$grant_name} = true;
2353
+								} else {
2354
+									$grant->{$grant_name} = false;
2355
+								}
2115 2356
 								break;
2116 2357
 						}
2117 2358
 					}
@@ -2187,16 +2428,22 @@  discard block
 block discarded – undo
2187 2428
 	function getFileBoxListHtml()
2188 2429
 	{
2189 2430
 		$logged_info = Context::get('logged_info');
2190
-		if($logged_info->is_admin !='Y' && !$logged_info->is_site_admin) return new Object(-1, 'msg_not_permitted');
2431
+		if($logged_info->is_admin !='Y' && !$logged_info->is_site_admin) {
2432
+			return new Object(-1, 'msg_not_permitted');
2433
+		}
2191 2434
 		$link = parse_url($_SERVER["HTTP_REFERER"]);
2192 2435
 		$link_params = explode('&',$link['query']);
2193 2436
 		foreach ($link_params as $param)
2194 2437
 		{
2195 2438
 			$param = explode("=",$param);
2196
-			if($param[0] == 'selected_widget') $selected_widget = $param[1];
2439
+			if($param[0] == 'selected_widget') {
2440
+				$selected_widget = $param[1];
2441
+			}
2197 2442
 		}
2198 2443
 		$oWidgetModel = getModel('widget');
2199
-		if($selected_widget) $widget_info = $oWidgetModel->getWidgetInfo($selected_widget);
2444
+		if($selected_widget) {
2445
+			$widget_info = $oWidgetModel->getWidgetInfo($selected_widget);
2446
+		}
2200 2447
 		Context::set('allow_multiple', $widget_info->extra_var->images->allow_multiple);
2201 2448
 
2202 2449
 		$oModuleModel = getModel('module');
@@ -2204,7 +2451,9 @@  discard block
 block discarded – undo
2204 2451
 		Context::set('filebox_list', $output->data);
2205 2452
 
2206 2453
 		$page = Context::get('page');
2207
-		if (!$page) $page = 1;
2454
+		if (!$page) {
2455
+			$page = 1;
2456
+		}
2208 2457
 		Context::set('page', $page);
2209 2458
 		Context::set('page_navigation', $output->page_navigation);
2210 2459
 
@@ -2234,25 +2483,28 @@  discard block
 block discarded – undo
2234 2483
 			$rulsetFile = str_replace('@', '', $ruleset);
2235 2484
 			$xml_file = sprintf('./files/ruleset/%s.xml', $rulsetFile);
2236 2485
 			return FileHandler::getRealPath($xml_file);
2237
-		}
2238
-		else if (strpos($ruleset, '#') !== false)
2486
+		} else if (strpos($ruleset, '#') !== false)
2239 2487
 		{
2240 2488
 			$rulsetFile = str_replace('#', '', $ruleset).'.'.$mid;
2241 2489
 			$xml_file = sprintf('./files/ruleset/%s.xml', $rulsetFile);
2242
-			if(is_readable($xml_file))
2243
-				return FileHandler::getRealPath($xml_file);
2244
-			else{
2490
+			if(is_readable($xml_file)) {
2491
+							return FileHandler::getRealPath($xml_file);
2492
+			} else{
2245 2493
 				$ruleset = str_replace('#', '', $ruleset);
2246 2494
 			}
2247 2495
 
2248 2496
 		}
2249 2497
 		// Get a path of the requested module. Return if not exists.
2250 2498
 		$class_path = ModuleHandler::getModulePath($module);
2251
-		if(!$class_path) return;
2499
+		if(!$class_path) {
2500
+			return;
2501
+		}
2252 2502
 
2253 2503
 		// Check if module.xml exists in the path. Return if not exist
2254 2504
 		$xml_file = sprintf("%sruleset/%s.xml", $class_path, $ruleset);
2255
-		if(!file_exists($xml_file)) return;
2505
+		if(!file_exists($xml_file)) {
2506
+			return;
2507
+		}
2256 2508
 
2257 2509
 		return $xml_file;
2258 2510
 	}
@@ -2302,7 +2554,9 @@  discard block
 block discarded – undo
2302 2554
 	function getLangByLangcode()
2303 2555
 	{
2304 2556
 		$langCode = Context::get('langCode');
2305
-		if (!$langCode) return;
2557
+		if (!$langCode) {
2558
+			return;
2559
+		}
2306 2560
 
2307 2561
 		$oModuleController = getController('module');
2308 2562
 		$oModuleController->replaceDefinedLangCode($langCode);
Please login to merge, or discard this patch.
classes/context/Context.class.php 2 patches
Braces   +79 added lines, -91 removed lines patch added patch discarded remove patch
@@ -227,7 +227,9 @@  discard block
 block discarded – undo
227 227
 		$this->loadDBInfo();
228 228
 		if($this->db_info->use_sitelock == 'Y')
229 229
 		{
230
-			if(is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist;
230
+			if(is_array($this->db_info->sitelock_whitelist)) {
231
+				$whitelist = $this->db_info->sitelock_whitelist;
232
+			}
231 233
 
232 234
 			if(!IpFilter::filter($whitelist))
233 235
 			{
@@ -242,8 +244,7 @@  discard block
 block discarded – undo
242 244
 				if(FileHandler::exists(_XE_PATH_ . 'common/tpl/sitelock.user.html'))
243 245
 				{
244 246
 					include _XE_PATH_ . 'common/tpl/sitelock.user.html';
245
-				}
246
-				else
247
+				} else
247 248
 				{
248 249
 					include _XE_PATH_ . 'common/tpl/sitelock.html';
249 250
 				}
@@ -300,8 +301,7 @@  discard block
 block discarded – undo
300 301
 			{
301 302
 				setcookie('lang_type', $this->lang_type, $_SERVER['REQUEST_TIME'] + 3600 * 24 * 1000, '/');
302 303
 			}
303
-		}
304
-		elseif($_COOKIE['lang_type'])
304
+		} elseif($_COOKIE['lang_type'])
305 305
 		{
306 306
 			$this->lang_type = $_COOKIE['lang_type'];
307 307
 		}
@@ -338,7 +338,9 @@  discard block
 block discarded – undo
338 338
 			);
339 339
 		}
340 340
 
341
-		if($sess = $_POST[session_name()]) session_id($sess);
341
+		if($sess = $_POST[session_name()]) {
342
+			session_id($sess);
343
+		}
342 344
 		session_start();
343 345
 
344 346
 		// set authentication information in Context and session
@@ -391,22 +393,21 @@  discard block
 block discarded – undo
391 393
 						{
392 394
 							$url[] = $key . '[' . $k . ']=' . urlencode($v);
393 395
 						}
394
-					}
395
-					elseif($val)
396
+					} elseif($val)
396 397
 					{
397 398
 						$url[] = $key . '=' . urlencode($val);
398 399
 					}
399 400
 				}
400 401
 
401 402
 				$current_url = self::getRequestUri();
402
-				if($url) $current_url .= '?' . join('&', $url);
403
-			}
404
-			else
403
+				if($url) {
404
+					$current_url .= '?' . join('&', $url);
405
+				}
406
+			} else
405 407
 			{
406 408
 				$current_url = $this->getUrl();
407 409
 			}
408
-		}
409
-		else
410
+		} else
410 411
 		{
411 412
 			$current_url = self::getRequestUri();
412 413
 		}
@@ -491,18 +492,22 @@  discard block
 block discarded – undo
491 492
 			$db_info->use_prepared_statements = 'Y';
492 493
 		}
493 494
 
494
-		if(!$db_info->time_zone)
495
-			$db_info->time_zone = date('O');
495
+		if(!$db_info->time_zone) {
496
+					$db_info->time_zone = date('O');
497
+		}
496 498
 		$GLOBALS['_time_zone'] = $db_info->time_zone;
497 499
 
498
-		if($db_info->qmail_compatibility != 'Y')
499
-			$db_info->qmail_compatibility = 'N';
500
+		if($db_info->qmail_compatibility != 'Y') {
501
+					$db_info->qmail_compatibility = 'N';
502
+		}
500 503
 		$GLOBALS['_qmail_compatibility'] = $db_info->qmail_compatibility;
501 504
 
502
-		if(!$db_info->use_db_session)
503
-			$db_info->use_db_session = 'N';
504
-		if(!$db_info->use_ssl)
505
-			$db_info->use_ssl = 'none';
505
+		if(!$db_info->use_db_session) {
506
+					$db_info->use_db_session = 'N';
507
+		}
508
+		if(!$db_info->use_ssl) {
509
+					$db_info->use_ssl = 'none';
510
+		}
506 511
 		$this->set('_use_ssl', $db_info->use_ssl);
507 512
 
508 513
 		$self->set('_http_port', ($db_info->http_port) ? $db_info->http_port : NULL);
@@ -619,8 +624,7 @@  discard block
 block discarded – undo
619 624
 				$buff = FileHandler::readFile($orig_lang_file);
620 625
 				FileHandler::writeFile($selected_lang_file, $buff);
621 626
 				$lang_selected = self::loadLangSupported();
622
-			}
623
-			else
627
+			} else
624 628
 			{
625 629
 				$langs = file($selected_lang_file);
626 630
 				foreach($langs as $val)
@@ -689,8 +693,7 @@  discard block
 block discarded – undo
689 693
 				return FALSE;
690 694
 			}
691 695
 			// for sites requesting SSO validation
692
-		}
693
-		else
696
+		} else
694 697
 		{
695 698
 			// result handling : set session_name()
696 699
 			if($session_name = self::get('SSOID'))
@@ -701,8 +704,7 @@  discard block
 block discarded – undo
701 704
 				header('location:' . $url);
702 705
 				return FALSE;
703 706
 				// send SSO request
704
-			}
705
-			else if(!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri()))
707
+			} else if(!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri()))
706 708
 			{
707 709
 				setcookie('sso', md5(self::getRequestUri()), 0, '/');
708 710
 				$url = sprintf("%s?default_url=%s", $default_url, base64_encode(self::getRequestUrl()));
@@ -760,8 +762,7 @@  discard block
 block discarded – undo
760 762
 		if($self->site_title)
761 763
 		{
762 764
 			$self->site_title .= ' - ' . $site_title;
763
-		}
764
-		else
765
+		} else
765 766
 		{
766 767
 			$self->site_title = $site_title;
767 768
 		}
@@ -861,8 +862,7 @@  discard block
 block discarded – undo
861 862
 		{
862 863
 			$self->loaded_lang_files[] = $filename;
863 864
 			include($filename);
864
-		}
865
-		else
865
+		} else
866 866
 		{
867 867
 			$self->_evalxmlLang($path);
868 868
 		}
@@ -878,7 +878,9 @@  discard block
 block discarded – undo
878 878
 	{
879 879
 		global $lang;
880 880
 
881
-		if(!$path) return;
881
+		if(!$path) {
882
+			return;
883
+		}
882 884
 
883 885
 		$_path = 'eval://' . $path;
884 886
 
@@ -910,7 +912,9 @@  discard block
 block discarded – undo
910 912
 	 */
911 913
 	function _loadXmlLang($path)
912 914
 	{
913
-		if(!$path) return;
915
+		if(!$path) {
916
+			return;
917
+		}
914 918
 
915 919
 		$oXmlLangParser = new XmlLangParser($path . ((substr_compare($path, '/', -1) !== 0) ? '/' : '') . 'lang.xml', $this->lang_type);
916 920
 		return $oXmlLangParser->compile();
@@ -924,7 +928,9 @@  discard block
 block discarded – undo
924 928
 	 */
925 929
 	function _loadPhpLang($path)
926 930
 	{
927
-		if(!$path) return;
931
+		if(!$path) {
932
+			return;
933
+		}
928 934
 
929 935
 		if(substr_compare($path, '/', -1) !== 0)
930 936
 		{
@@ -1060,12 +1066,14 @@  discard block
 block discarded – undo
1060 1066
 		static $flag = TRUE;
1061 1067
 		if($charset)
1062 1068
 		{
1063
-			if(is_array($val))
1064
-				array_walk($val,'Context::checkConvertFlag',$charset);
1065
-			else if($val && iconv($charset,$charset,$val)!=$val) $flag = FALSE;
1066
-			else $flag = FALSE;
1067
-		}
1068
-		else
1069
+			if(is_array($val)) {
1070
+							array_walk($val,'Context::checkConvertFlag',$charset);
1071
+			} else if($val && iconv($charset,$charset,$val)!=$val) {
1072
+				$flag = FALSE;
1073
+			} else {
1074
+				$flag = FALSE;
1075
+			}
1076
+		} else
1069 1077
 		{
1070 1078
 			$return = $flag;
1071 1079
 			$flag = TRUE;
@@ -1087,8 +1095,9 @@  discard block
 block discarded – undo
1087 1095
 		if (is_array($val))
1088 1096
 		{
1089 1097
 			array_walk($val,'Context::doConvertEncoding',$charset);
1098
+		} else {
1099
+			$val = iconv($charset,'UTF-8',$val);
1090 1100
 		}
1091
-		else $val = iconv($charset,'UTF-8',$val);
1092 1101
 	}
1093 1102
 
1094 1103
 	/**
@@ -1099,7 +1108,9 @@  discard block
 block discarded – undo
1099 1108
 	 */
1100 1109
 	function convertEncodingStr($str)
1101 1110
 	{
1102
-        if(!$str) return null;
1111
+        if(!$str) {
1112
+        	return null;
1113
+        }
1103 1114
 		$obj = new stdClass();
1104 1115
 		$obj->str = $str;
1105 1116
 		$obj = self::convertEncoding($obj);
@@ -1212,16 +1223,13 @@  discard block
 block discarded – undo
1212 1223
 			if($requestMethod == 'GET' && isset($_GET[$key]))
1213 1224
 			{
1214 1225
 				$set_to_vars = TRUE;
1215
-			}
1216
-			elseif($requestMethod == 'POST' && isset($_POST[$key]))
1226
+			} elseif($requestMethod == 'POST' && isset($_POST[$key]))
1217 1227
 			{
1218 1228
 				$set_to_vars = TRUE;
1219
-			}
1220
-			elseif($requestMethod == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key])))
1229
+			} elseif($requestMethod == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key])))
1221 1230
 			{
1222 1231
 				$set_to_vars = TRUE;
1223
-			}
1224
-			else
1232
+			} else
1225 1233
 			{
1226 1234
 				$set_to_vars = FALSE;
1227 1235
 			}
@@ -1247,8 +1255,7 @@  discard block
 block discarded – undo
1247 1255
 					return;
1248 1256
 				}
1249 1257
 			}
1250
-		}
1251
-		else if(is_array($val))
1258
+		} else if(is_array($val))
1252 1259
 		{
1253 1260
 			foreach($val as $val2)
1254 1261
 			{
@@ -1388,16 +1395,13 @@  discard block
 block discarded – undo
1388 1395
 			if($key === 'page' || $key === 'cpage' || substr_compare($key, 'srl', -3) === 0)
1389 1396
 			{
1390 1397
 				$result[$k] = !preg_match('/^[0-9,]+$/', $v) ? (int) $v : $v;
1391
-			}
1392
-			elseif($key === 'mid' || $key === 'search_keyword')
1398
+			} elseif($key === 'mid' || $key === 'search_keyword')
1393 1399
 			{
1394 1400
 				$result[$k] = htmlspecialchars($v, ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE);
1395
-			}
1396
-			elseif($key === 'vid')
1401
+			} elseif($key === 'vid')
1397 1402
 			{
1398 1403
 				$result[$k] = urlencode($v);
1399
-			}
1400
-			else
1404
+			} else
1401 1405
 			{
1402 1406
 				$result[$k] = $v;
1403 1407
 
@@ -1451,8 +1455,7 @@  discard block
 block discarded – undo
1451 1455
 				$val['name'] = htmlspecialchars($val['name'], ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE);
1452 1456
 				$this->set($key, $val, TRUE);
1453 1457
 				$this->is_uploaded = TRUE;
1454
-			}
1455
-			else
1458
+			} else
1456 1459
 			{
1457 1460
 				for($i = 0, $c = count($tmp_name); $i < $c; $i++)
1458 1461
 				{
@@ -1558,8 +1561,7 @@  discard block
 block discarded – undo
1558 1561
 			if($site_module_info->domain && isSiteID($site_module_info->domain))
1559 1562
 			{
1560 1563
 				$vid = $site_module_info->domain;
1561
-			}
1562
-			else
1564
+			} else
1563 1565
 			{
1564 1566
 				$domain = $site_module_info->domain;
1565 1567
 			}
@@ -1576,8 +1578,7 @@  discard block
 block discarded – undo
1576 1578
 			if($domain_info['host'] . $domain_info['path'] == $current_info['host'] . $current_info['path'])
1577 1579
 			{
1578 1580
 				unset($domain);
1579
-			}
1580
-			else
1581
+			} else
1581 1582
 			{
1582 1583
 				$domain = preg_replace('/^(http|https):\/\//i', '', trim($domain));
1583 1584
 				if(substr_compare($domain, '/', -1) !== 0)
@@ -1597,8 +1598,7 @@  discard block
 block discarded – undo
1597 1598
 			{
1598 1599
 				array_shift($args_list);
1599 1600
 			}
1600
-		}
1601
-		else
1601
+		} else
1602 1602
 		{
1603 1603
 			// Otherwise, make GET variables into array
1604 1604
 			$get_vars = get_object_vars($self->get_vars);
@@ -1625,8 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 		if($vid)
1626 1626
 		{
1627 1627
 			$get_vars['vid'] = $vid;
1628
-		}
1629
-		else
1628
+		} else
1630 1629
 		{
1631 1630
 			unset($get_vars['vid']);
1632 1631
 		}
@@ -1698,8 +1697,7 @@  discard block
 block discarded – undo
1698 1697
 						{
1699 1698
 							$queries[] = $key . '[' . $k . ']=' . urlencode($v);
1700 1699
 						}
1701
-					}
1702
-					elseif(!is_array($val))
1700
+					} elseif(!is_array($val))
1703 1701
 					{
1704 1702
 						$queries[] = $key . '=' . urlencode($val);
1705 1703
 					}
@@ -1717,25 +1715,23 @@  discard block
 block discarded – undo
1717 1715
 		{
1718 1716
 			$query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query;
1719 1717
 			// optional SSL use
1720
-		}
1721
-		elseif($_use_ssl == 'optional')
1718
+		} elseif($_use_ssl == 'optional')
1722 1719
 		{
1723 1720
 			$ssl_mode = (($self->get('module') === 'admin') || ($get_vars['module'] === 'admin') || (isset($get_vars['act']) && $self->isExistsSSLAction($get_vars['act']))) ? ENFORCE_SSL : RELEASE_SSL;
1724 1721
 			$query = $self->getRequestUri($ssl_mode, $domain) . $query;
1725 1722
 			// no SSL
1726
-		}
1727
-		else
1723
+		} else
1728 1724
 		{
1729 1725
 			// currently on SSL but target is not based on SSL
1730 1726
 			if($_SERVER['HTTPS'] == 'on')
1731 1727
 			{
1732 1728
 				$query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query;
1733
-			}
1734
-			else if($domain) // if $domain is set
1729
+			} else if($domain) {
1730
+				// if $domain is set
1735 1731
 			{
1736 1732
 				$query = $self->getRequestUri(FOLLOW_REQUEST_SSL, $domain) . $query;
1737 1733
 			}
1738
-			else
1734
+			} else
1739 1735
 			{
1740 1736
 				$query = getScriptPath() . $query;
1741 1737
 			}
@@ -1792,8 +1788,7 @@  discard block
 block discarded – undo
1792 1788
 		if($domain)
1793 1789
 		{
1794 1790
 			$domain_key = md5($domain);
1795
-		}
1796
-		else
1791
+		} else
1797 1792
 		{
1798 1793
 			$domain_key = 'default';
1799 1794
 		}
@@ -1822,8 +1817,7 @@  discard block
 block discarded – undo
1822 1817
 			{
1823 1818
 				$target_url.= '/';
1824 1819
 			}
1825
-		}
1826
-		else
1820
+		} else
1827 1821
 		{
1828 1822
 			$target_url = $_SERVER['HTTP_HOST'] . getScriptPath();
1829 1823
 		}
@@ -1841,20 +1835,17 @@  discard block
 block discarded – undo
1841 1835
 			if($port && $port != 443)
1842 1836
 			{
1843 1837
 				$url_info['port'] = $port;
1844
-			}
1845
-			elseif($url_info['port'] == 443)
1838
+			} elseif($url_info['port'] == 443)
1846 1839
 			{
1847 1840
 				unset($url_info['port']);
1848 1841
 			}
1849
-		}
1850
-		else
1842
+		} else
1851 1843
 		{
1852 1844
 			$port = self::get('_http_port');
1853 1845
 			if($port && $port != 80)
1854 1846
 			{
1855 1847
 				$url_info['port'] = $port;
1856
-			}
1857
-			elseif($url_info['port'] == 80)
1848
+			} elseif($url_info['port'] == 80)
1858 1849
 			{
1859 1850
 				unset($url_info['port']);
1860 1851
 			}
@@ -2090,8 +2081,7 @@  discard block
 block discarded – undo
2090 2081
 		if(strpos($file, './') === 0)
2091 2082
 		{
2092 2083
 			$file = dirname($_SERVER['SCRIPT_NAME']) . '/' . substr($file, 2);
2093
-		}
2094
-		elseif(strpos($file, '../') === 0)
2084
+		} elseif(strpos($file, '../') === 0)
2095 2085
 		{
2096 2086
 			$file = self::normalizeFilePath(dirname($_SERVER['SCRIPT_NAME']) . "/{$file}");
2097 2087
 		}
@@ -2353,8 +2343,7 @@  discard block
 block discarded – undo
2353 2343
 			if(substr_compare($filename, '.js', -3) === 0)
2354 2344
 			{
2355 2345
 				$result->jsList[] = $plugin_path . $filename;
2356
-			}
2357
-			elseif(substr_compare($filename, '.css', -4) === 0)
2346
+			} elseif(substr_compare($filename, '.css', -4) === 0)
2358 2347
 			{
2359 2348
 				$result->cssList[] = $plugin_path . $filename;
2360 2349
 			}
@@ -2611,8 +2600,7 @@  discard block
 block discarded – undo
2611 2600
 			if(count($_base) > 0)
2612 2601
 			{
2613 2602
 				array_shift($_base);
2614
-			}
2615
-			else
2603
+			} else
2616 2604
 			{
2617 2605
 				array_unshift($_base, '..');
2618 2606
 			}
Please login to merge, or discard this patch.
Spacing   +237 added lines, -237 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	function &getInstance()
163 163
 	{
164 164
 		static $theInstance = null;
165
-		if(!$theInstance)
165
+		if (!$theInstance)
166 166
 		{
167 167
 			$theInstance = new Context();
168 168
 		}
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
 
183 183
 		// include ssl action cache file
184 184
 		$this->sslActionCacheFile = FileHandler::getRealPath($this->sslActionCacheFile);
185
-		if(is_readable($this->sslActionCacheFile))
185
+		if (is_readable($this->sslActionCacheFile))
186 186
 		{
187 187
 			require($this->sslActionCacheFile);
188
-			if(isset($sslActions))
188
+			if (isset($sslActions))
189 189
 			{
190 190
 				$this->ssl_actions = $sslActions;
191 191
 			}
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
 	function init()
202 202
 	{
203 203
 		// fix missing HTTP_RAW_POST_DATA in PHP 5.6 and above
204
-		if(!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE)
204
+		if (!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE)
205 205
 		{
206 206
 			$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input");
207 207
 			
208 208
 			// If content is not XML JSON, unset
209
-			if(!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === FALSE && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === FALSE)
209
+			if (!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === FALSE && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === FALSE)
210 210
 			{
211 211
 				unset($GLOBALS['HTTP_RAW_POST_DATA']);
212 212
 			}
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 		$this->_setUploadedArgument();
229 229
 
230 230
 		$this->loadDBInfo();
231
-		if($this->db_info->use_sitelock == 'Y')
231
+		if ($this->db_info->use_sitelock == 'Y')
232 232
 		{
233
-			if(is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist;
233
+			if (is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist;
234 234
 
235
-			if(!IpFilter::filter($whitelist))
235
+			if (!IpFilter::filter($whitelist))
236 236
 			{
237 237
 				$title = ($this->db_info->sitelock_title) ? $this->db_info->sitelock_title : 'Maintenance in progress...';
238 238
 				$message = $this->db_info->sitelock_message;
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 				define('_XE_SITELOCK_MESSAGE_', $message);
243 243
 
244 244
 				header("HTTP/1.1 403 Forbidden");
245
-				if(FileHandler::exists(_XE_PATH_ . 'common/tpl/sitelock.user.html'))
245
+				if (FileHandler::exists(_XE_PATH_ . 'common/tpl/sitelock.user.html'))
246 246
 				{
247 247
 					include _XE_PATH_ . 'common/tpl/sitelock.user.html';
248 248
 				}
@@ -255,39 +255,39 @@  discard block
 block discarded – undo
255 255
 		}
256 256
 
257 257
 		// If XE is installed, get virtual site information
258
-		if(self::isInstalled())
258
+		if (self::isInstalled())
259 259
 		{
260 260
 			$oModuleModel = getModel('module');
261 261
 			$site_module_info = $oModuleModel->getDefaultMid();
262 262
 
263
-			if(!isset($site_module_info))
263
+			if (!isset($site_module_info))
264 264
 			{
265 265
 				$site_module_info = new stdClass();
266 266
 			}
267 267
 
268 268
 			// if site_srl of site_module_info is 0 (default site), compare the domain to default_url of db_config
269
-			if($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url)
269
+			if ($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url)
270 270
 			{
271 271
 				$site_module_info->domain = $this->db_info->default_url;
272 272
 			}
273 273
 
274 274
 			$this->set('site_module_info', $site_module_info);
275
-			if($site_module_info->site_srl && isSiteID($site_module_info->domain))
275
+			if ($site_module_info->site_srl && isSiteID($site_module_info->domain))
276 276
 			{
277 277
 				$this->set('vid', $site_module_info->domain, TRUE);
278 278
 			}
279 279
 
280
-			if(!isset($this->db_info))
280
+			if (!isset($this->db_info))
281 281
 			{
282 282
 				$this->db_info = new stdClass();
283 283
 			}
284 284
 
285 285
 			$this->db_info->lang_type = $site_module_info->default_language;
286
-			if(!$this->db_info->lang_type)
286
+			if (!$this->db_info->lang_type)
287 287
 			{
288 288
 				$this->db_info->lang_type = 'en';
289 289
 			}
290
-			if(!$this->db_info->use_db_session)
290
+			if (!$this->db_info->use_db_session)
291 291
 			{
292 292
 				$this->db_info->use_db_session = 'N';
293 293
 			}
@@ -297,30 +297,30 @@  discard block
 block discarded – undo
297 297
 		$lang_supported = $this->loadLangSelected();
298 298
 
299 299
 		// Retrieve language type set in user's cookie
300
-		if($this->lang_type = $this->get('l'))
300
+		if ($this->lang_type = $this->get('l'))
301 301
 		{
302
-			if($_COOKIE['lang_type'] != $this->lang_type)
302
+			if ($_COOKIE['lang_type'] != $this->lang_type)
303 303
 			{
304 304
 				setcookie('lang_type', $this->lang_type, $_SERVER['REQUEST_TIME'] + 3600 * 24 * 1000, '/');
305 305
 			}
306 306
 		}
307
-		elseif($_COOKIE['lang_type'])
307
+		elseif ($_COOKIE['lang_type'])
308 308
 		{
309 309
 			$this->lang_type = $_COOKIE['lang_type'];
310 310
 		}
311 311
 
312 312
 		// If it's not exists, follow default language type set in db_info
313
-		if(!$this->lang_type)
313
+		if (!$this->lang_type)
314 314
 		{
315 315
 			$this->lang_type = $this->db_info->lang_type;
316 316
 		}
317 317
 
318 318
 		// if still lang_type has not been set or has not-supported type , set as English.
319
-		if(!$this->lang_type)
319
+		if (!$this->lang_type)
320 320
 		{
321 321
 			$this->lang_type = 'en';
322 322
 		}
323
-		if(is_array($lang_supported) && !isset($lang_supported[$this->lang_type]))
323
+		if (is_array($lang_supported) && !isset($lang_supported[$this->lang_type]))
324 324
 		{
325 325
 			$this->lang_type = 'en';
326 326
 		}
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 		$this->loadLang(_XE_PATH_ . 'modules/module/lang');
333 333
 
334 334
 		// set session handler
335
-		if(self::isInstalled() && $this->db_info->use_db_session == 'Y')
335
+		if (self::isInstalled() && $this->db_info->use_db_session == 'Y')
336 336
 		{
337 337
 			$oSessionModel = getModel('session');
338 338
 			$oSessionController = getController('session');
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
 			);
342 342
 		}
343 343
 
344
-		if($sess = $_POST[session_name()]) session_id($sess);
344
+		if ($sess = $_POST[session_name()]) session_id($sess);
345 345
 		session_start();
346 346
 
347 347
 		// set authentication information in Context and session
348
-		if(self::isInstalled())
348
+		if (self::isInstalled())
349 349
 		{
350 350
 			$oModuleModel = getModel('module');
351 351
 			$oModuleModel->loadModuleExtends();
@@ -353,15 +353,15 @@  discard block
 block discarded – undo
353 353
 			$oMemberModel = getModel('member');
354 354
 			$oMemberController = getController('member');
355 355
 
356
-			if($oMemberController && $oMemberModel)
356
+			if ($oMemberController && $oMemberModel)
357 357
 			{
358 358
 				// if signed in, validate it.
359
-				if($oMemberModel->isLogged())
359
+				if ($oMemberModel->isLogged())
360 360
 				{
361 361
 					$oMemberController->setSessionInfo();
362 362
 				}
363 363
 				// check auto sign-in
364
-				elseif($_COOKIE['xeak'])
364
+				elseif ($_COOKIE['xeak'])
365 365
 				{
366 366
 					$oMemberController->doAutologin();
367 367
 				}
@@ -381,28 +381,28 @@  discard block
 block discarded – undo
381 381
 		// set locations for javascript use
382 382
 		$url = array();
383 383
 		$current_url = self::getRequestUri();
384
-		if($_SERVER['REQUEST_METHOD'] == 'GET')
384
+		if ($_SERVER['REQUEST_METHOD'] == 'GET')
385 385
 		{
386
-			if($this->get_vars)
386
+			if ($this->get_vars)
387 387
 			{
388 388
 				$url = array();
389
-				foreach($this->get_vars as $key => $val)
389
+				foreach ($this->get_vars as $key => $val)
390 390
 				{
391
-					if(is_array($val) && count($val) > 0)
391
+					if (is_array($val) && count($val) > 0)
392 392
 					{
393
-						foreach($val as $k => $v)
393
+						foreach ($val as $k => $v)
394 394
 						{
395 395
 							$url[] = $key . '[' . $k . ']=' . urlencode($v);
396 396
 						}
397 397
 					}
398
-					elseif($val)
398
+					elseif ($val)
399 399
 					{
400 400
 						$url[] = $key . '=' . urlencode($val);
401 401
 					}
402 402
 				}
403 403
 
404 404
 				$current_url = self::getRequestUri();
405
-				if($url) $current_url .= '?' . join('&', $url);
405
+				if ($url) $current_url .= '?' . join('&', $url);
406 406
 			}
407 407
 			else
408 408
 			{
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
 		$this->set('current_url', $current_url);
418 418
 		$this->set('request_uri', self::getRequestUri());
419 419
 
420
-		if(strpos($current_url, 'xn--') !== FALSE)
420
+		if (strpos($current_url, 'xn--') !== FALSE)
421 421
 		{
422 422
 			$this->set('current_url', self::decodeIdna($current_url));
423 423
 		}
424 424
 
425
-		if(strpos(self::getRequestUri(), 'xn--') !== FALSE)
425
+		if (strpos(self::getRequestUri(), 'xn--') !== FALSE)
426 426
 		{
427 427
 			$this->set('request_uri', self::decodeIdna(self::getRequestUri()));
428 428
 		}
@@ -447,19 +447,19 @@  discard block
 block discarded – undo
447 447
 	{
448 448
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
449 449
 
450
-		if(!$self->isInstalled())
450
+		if (!$self->isInstalled())
451 451
 		{
452 452
 			return;
453 453
 		}
454 454
 
455 455
 		$config_file = $self->getConfigFile();
456
-		if(is_readable($config_file))
456
+		if (is_readable($config_file))
457 457
 		{
458 458
 			include($config_file);
459 459
 		}
460 460
 
461 461
 		// If master_db information does not exist, the config file needs to be updated
462
-		if(!isset($db_info->master_db))
462
+		if (!isset($db_info->master_db))
463 463
 		{
464 464
 			$db_info->master_db = array();
465 465
 			$db_info->master_db["db_type"] = $db_info->db_type;
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 			$db_info->master_db["db_table_prefix"] = $db_info->db_table_prefix;
478 478
 			unset($db_info->db_table_prefix);
479 479
 
480
-			if(isset($db_info->master_db["db_table_prefix"]) && substr_compare($db_info->master_db["db_table_prefix"], '_', -1) !== 0)
480
+			if (isset($db_info->master_db["db_table_prefix"]) && substr_compare($db_info->master_db["db_table_prefix"], '_', -1) !== 0)
481 481
 			{
482 482
 				$db_info->master_db["db_table_prefix"] .= '_';
483 483
 			}
@@ -489,33 +489,33 @@  discard block
 block discarded – undo
489 489
 			$oInstallController->makeConfigFile();
490 490
 		}
491 491
 
492
-		if(!$db_info->use_prepared_statements)
492
+		if (!$db_info->use_prepared_statements)
493 493
 		{
494 494
 			$db_info->use_prepared_statements = 'Y';
495 495
 		}
496 496
 
497
-		if(!$db_info->time_zone)
497
+		if (!$db_info->time_zone)
498 498
 			$db_info->time_zone = date('O');
499 499
 		$GLOBALS['_time_zone'] = $db_info->time_zone;
500 500
 
501
-		if($db_info->qmail_compatibility != 'Y')
501
+		if ($db_info->qmail_compatibility != 'Y')
502 502
 			$db_info->qmail_compatibility = 'N';
503 503
 		$GLOBALS['_qmail_compatibility'] = $db_info->qmail_compatibility;
504 504
 
505
-		if(!$db_info->use_db_session)
505
+		if (!$db_info->use_db_session)
506 506
 			$db_info->use_db_session = 'N';
507
-		if(!$db_info->use_ssl)
507
+		if (!$db_info->use_ssl)
508 508
 			$db_info->use_ssl = 'none';
509 509
 		$this->set('_use_ssl', $db_info->use_ssl);
510 510
 
511 511
 		$self->set('_http_port', ($db_info->http_port) ? $db_info->http_port : NULL);
512 512
 		$self->set('_https_port', ($db_info->https_port) ? $db_info->https_port : NULL);
513 513
 
514
-		if(!$db_info->sitelock_whitelist) {
514
+		if (!$db_info->sitelock_whitelist) {
515 515
 			$db_info->sitelock_whitelist = '127.0.0.1';
516 516
 		}
517 517
 
518
-		if(is_string($db_info->sitelock_whitelist)) {
518
+		if (is_string($db_info->sitelock_whitelist)) {
519 519
 			$db_info->sitelock_whitelist = explode(',', $db_info->sitelock_whitelist);
520 520
 		}
521 521
 
@@ -586,10 +586,10 @@  discard block
 block discarded – undo
586 586
 	function loadLangSupported()
587 587
 	{
588 588
 		static $lang_supported = null;
589
-		if(!$lang_supported)
589
+		if (!$lang_supported)
590 590
 		{
591 591
 			$langs = file(_XE_PATH_ . 'common/lang/lang.info');
592
-			foreach($langs as $val)
592
+			foreach ($langs as $val)
593 593
 			{
594 594
 				list($lang_prefix, $lang_text) = explode(',', $val);
595 595
 				$lang_text = trim($lang_text);
@@ -607,17 +607,17 @@  discard block
 block discarded – undo
607 607
 	function loadLangSelected()
608 608
 	{
609 609
 		static $lang_selected = null;
610
-		if(!$lang_selected)
610
+		if (!$lang_selected)
611 611
 		{
612 612
 			$orig_lang_file = _XE_PATH_ . 'common/lang/lang.info';
613 613
 			$selected_lang_file = _XE_PATH_ . 'files/config/lang_selected.info';
614
-			if(!FileHandler::hasContent($selected_lang_file))
614
+			if (!FileHandler::hasContent($selected_lang_file))
615 615
 			{
616 616
 				$old_selected_lang_file = _XE_PATH_ . 'files/cache/lang_selected.info';
617 617
 				FileHandler::moveFile($old_selected_lang_file, $selected_lang_file);
618 618
 			}
619 619
 
620
-			if(!FileHandler::hasContent($selected_lang_file))
620
+			if (!FileHandler::hasContent($selected_lang_file))
621 621
 			{
622 622
 				$buff = FileHandler::readFile($orig_lang_file);
623 623
 				FileHandler::writeFile($selected_lang_file, $buff);
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 			else
627 627
 			{
628 628
 				$langs = file($selected_lang_file);
629
-				foreach($langs as $val)
629
+				foreach ($langs as $val)
630 630
 				{
631 631
 					list($lang_prefix, $lang_text) = explode(',', $val);
632 632
 					$lang_text = trim($lang_text);
@@ -645,32 +645,32 @@  discard block
 block discarded – undo
645 645
 	function checkSSO()
646 646
 	{
647 647
 		// pass if it's not GET request or XE is not yet installed
648
-		if($this->db_info->use_sso != 'Y' || isCrawler())
648
+		if ($this->db_info->use_sso != 'Y' || isCrawler())
649 649
 		{
650 650
 			return TRUE;
651 651
 		}
652 652
 		$checkActList = array('rss' => 1, 'atom' => 1);
653
-		if(self::getRequestMethod() != 'GET' || !self::isInstalled() || isset($checkActList[self::get('act')]))
653
+		if (self::getRequestMethod() != 'GET' || !self::isInstalled() || isset($checkActList[self::get('act')]))
654 654
 		{
655 655
 			return TRUE;
656 656
 		}
657 657
 
658 658
 		// pass if default URL is not set
659 659
 		$default_url = trim($this->db_info->default_url);
660
-		if(!$default_url)
660
+		if (!$default_url)
661 661
 		{
662 662
 			return TRUE;
663 663
 		}
664 664
 
665
-		if(substr_compare($default_url, '/', -1) !== 0)
665
+		if (substr_compare($default_url, '/', -1) !== 0)
666 666
 		{
667 667
 			$default_url .= '/';
668 668
 		}
669 669
 
670 670
 		// for sites recieving SSO valdiation
671
-		if($default_url == self::getRequestUri())
671
+		if ($default_url == self::getRequestUri())
672 672
 		{
673
-			if(self::get('default_url'))
673
+			if (self::get('default_url'))
674 674
 			{
675 675
 				$url = base64_decode(self::get('default_url'));
676 676
 				$url_info = parse_url($url);
@@ -678,14 +678,14 @@  discard block
 block discarded – undo
678 678
 				$oModuleModel = getModel('module');
679 679
 				$target_domain = (stripos($url, $default_url) !== 0) ? $url_info['host'] : $default_url;
680 680
 				$site_info = $oModuleModel->getSiteInfoByDomain($target_domain);
681
-				if(!$site_info->site_srl) {
681
+				if (!$site_info->site_srl) {
682 682
 					$oModuleObject = new ModuleObject();
683 683
 					$oModuleObject->stop('msg_invalid_request');
684 684
 
685 685
 					return false;
686 686
 				}
687 687
 
688
-				$url_info['query'].= ($url_info['query'] ? '&' : '') . 'SSOID=' . session_id();
688
+				$url_info['query'] .= ($url_info['query'] ? '&' : '') . 'SSOID=' . session_id();
689 689
 				$redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':' . $url_info['port'] : '', $url_info['path'], $url_info['query']);
690 690
 				header('location:' . $redirect_url);
691 691
 
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 		else
697 697
 		{
698 698
 			// result handling : set session_name()
699
-			if($session_name = self::get('SSOID'))
699
+			if ($session_name = self::get('SSOID'))
700 700
 			{
701 701
 				setcookie(session_name(), $session_name);
702 702
 
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 				return FALSE;
706 706
 				// send SSO request
707 707
 			}
708
-			else if(!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri()))
708
+			else if (!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri()))
709 709
 			{
710 710
 				setcookie('sso', md5(self::getRequestUri()), 0, '/');
711 711
 				$url = sprintf("%s?default_url=%s", $default_url, base64_encode(self::getRequestUrl()));
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 	{
737 737
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
738 738
 
739
-		if(!$self->isFTPRegisted())
739
+		if (!$self->isFTPRegisted())
740 740
 		{
741 741
 			return null;
742 742
 		}
@@ -754,13 +754,13 @@  discard block
 block discarded – undo
754 754
 	 */
755 755
 	function addBrowserTitle($site_title)
756 756
 	{
757
-		if(!$site_title)
757
+		if (!$site_title)
758 758
 		{
759 759
 			return;
760 760
 		}
761 761
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
762 762
 
763
-		if($self->site_title)
763
+		if ($self->site_title)
764 764
 		{
765 765
 			$self->site_title .= ' - ' . $site_title;
766 766
 		}
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 	 */
779 779
 	function setBrowserTitle($site_title)
780 780
 	{
781
-		if(!$site_title)
781
+		if (!$site_title)
782 782
 		{
783 783
 			return;
784 784
 		}
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 		$oModuleModel = getModel('module');
811 811
 		$moduleConfig = $oModuleModel->getModuleConfig('module');
812 812
 
813
-		if(isset($moduleConfig->siteTitle))
813
+		if (isset($moduleConfig->siteTitle))
814 814
 		{
815 815
 			return $moduleConfig->siteTitle;
816 816
 		}
@@ -837,30 +837,30 @@  discard block
 block discarded – undo
837 837
 		global $lang;
838 838
 
839 839
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
840
-		if(!$self->lang_type)
840
+		if (!$self->lang_type)
841 841
 		{
842 842
 			return;
843 843
 		}
844
-		if(!is_object($lang))
844
+		if (!is_object($lang))
845 845
 		{
846 846
 			$lang = new stdClass;
847 847
 		}
848 848
 
849
-		if(!($filename = $self->_loadXmlLang($path)))
849
+		if (!($filename = $self->_loadXmlLang($path)))
850 850
 		{
851 851
 			$filename = $self->_loadPhpLang($path);
852 852
 		}
853 853
 
854
-		if(!is_array($self->loaded_lang_files))
854
+		if (!is_array($self->loaded_lang_files))
855 855
 		{
856 856
 			$self->loaded_lang_files = array();
857 857
 		}
858
-		if(in_array($filename, $self->loaded_lang_files))
858
+		if (in_array($filename, $self->loaded_lang_files))
859 859
 		{
860 860
 			return;
861 861
 		}
862 862
 
863
-		if($filename && is_readable($filename))
863
+		if ($filename && is_readable($filename))
864 864
 		{
865 865
 			$self->loaded_lang_files[] = $filename;
866 866
 			include($filename);
@@ -881,16 +881,16 @@  discard block
 block discarded – undo
881 881
 	{
882 882
 		global $lang;
883 883
 
884
-		if(!$path) return;
884
+		if (!$path) return;
885 885
 
886 886
 		$_path = 'eval://' . $path;
887 887
 
888
-		if(in_array($_path, $this->loaded_lang_files))
888
+		if (in_array($_path, $this->loaded_lang_files))
889 889
 		{
890 890
 			return;
891 891
 		}
892 892
 
893
-		if(substr_compare($path, '/', -1) !== 0)
893
+		if (substr_compare($path, '/', -1) !== 0)
894 894
 		{
895 895
 			$path .= '/';
896 896
 		}
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 		$oXmlLangParser = new XmlLangParser($path . 'lang.xml', $this->lang_type);
899 899
 		$content = $oXmlLangParser->getCompileContent();
900 900
 
901
-		if($content)
901
+		if ($content)
902 902
 		{
903 903
 			$this->loaded_lang_files[] = $_path;
904 904
 			eval($content);
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 	 */
914 914
 	function _loadXmlLang($path)
915 915
 	{
916
-		if(!$path) return;
916
+		if (!$path) return;
917 917
 
918 918
 		$oXmlLangParser = new XmlLangParser($path . ((substr_compare($path, '/', -1) !== 0) ? '/' : '') . 'lang.xml', $this->lang_type);
919 919
 		return $oXmlLangParser->compile();
@@ -927,9 +927,9 @@  discard block
 block discarded – undo
927 927
 	 */
928 928
 	function _loadPhpLang($path)
929 929
 	{
930
-		if(!$path) return;
930
+		if (!$path) return;
931 931
 
932
-		if(substr_compare($path, '/', -1) !== 0)
932
+		if (substr_compare($path, '/', -1) !== 0)
933 933
 		{
934 934
 			$path .= '/';
935 935
 		}
@@ -937,12 +937,12 @@  discard block
 block discarded – undo
937 937
 		$file = sprintf($path_tpl, $this->lang_type);
938 938
 
939 939
 		$langs = array('ko', 'en'); // this will be configurable.
940
-		while(!is_readable($file) && $langs[0])
940
+		while (!is_readable($file) && $langs[0])
941 941
 		{
942 942
 			$file = sprintf($path_tpl, array_shift($langs));
943 943
 		}
944 944
 
945
-		if(!is_readable($file))
945
+		if (!is_readable($file))
946 946
 		{
947 947
 			return FALSE;
948 948
 		}
@@ -984,11 +984,11 @@  discard block
 block discarded – undo
984 984
 	 */
985 985
 	function getLang($code)
986 986
 	{
987
-		if(!$code)
987
+		if (!$code)
988 988
 		{
989 989
 			return;
990 990
 		}
991
-		if($GLOBALS['lang']->{$code})
991
+		if ($GLOBALS['lang']->{$code})
992 992
 		{
993 993
 			return $GLOBALS['lang']->{$code};
994 994
 		}
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 	 */
1005 1005
 	function setLang($code, $val)
1006 1006
 	{
1007
-		if(!isset($GLOBALS['lang']))
1007
+		if (!isset($GLOBALS['lang']))
1008 1008
 		{
1009 1009
 			$GLOBALS['lang'] = new stdClass();
1010 1010
 		}
@@ -1032,17 +1032,17 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
 		$obj = clone $source_obj;
1034 1034
 
1035
-		foreach($charset_list as $charset)
1035
+		foreach ($charset_list as $charset)
1036 1036
 		{
1037
-			array_walk($obj,'Context::checkConvertFlag',$charset);
1037
+			array_walk($obj, 'Context::checkConvertFlag', $charset);
1038 1038
 			$flag = self::checkConvertFlag($flag = TRUE);
1039
-			if($flag)
1039
+			if ($flag)
1040 1040
 			{
1041
-				if($charset == 'UTF-8')
1041
+				if ($charset == 'UTF-8')
1042 1042
 				{
1043 1043
 					return $obj;
1044 1044
 				}
1045
-				array_walk($obj,'Context::doConvertEncoding',$charset);
1045
+				array_walk($obj, 'Context::doConvertEncoding', $charset);
1046 1046
 				return $obj;
1047 1047
 			}
1048 1048
 		}
@@ -1061,11 +1061,11 @@  discard block
 block discarded – undo
1061 1061
 	function checkConvertFlag(&$val, $key = null, $charset = null)
1062 1062
 	{
1063 1063
 		static $flag = TRUE;
1064
-		if($charset)
1064
+		if ($charset)
1065 1065
 		{
1066
-			if(is_array($val))
1067
-				array_walk($val,'Context::checkConvertFlag',$charset);
1068
-			else if($val && iconv($charset,$charset,$val)!=$val) $flag = FALSE;
1066
+			if (is_array($val))
1067
+				array_walk($val, 'Context::checkConvertFlag', $charset);
1068
+			else if ($val && iconv($charset, $charset, $val) != $val) $flag = FALSE;
1069 1069
 			else $flag = FALSE;
1070 1070
 		}
1071 1071
 		else
@@ -1089,9 +1089,9 @@  discard block
 block discarded – undo
1089 1089
 	{
1090 1090
 		if (is_array($val))
1091 1091
 		{
1092
-			array_walk($val,'Context::doConvertEncoding',$charset);
1092
+			array_walk($val, 'Context::doConvertEncoding', $charset);
1093 1093
 		}
1094
-		else $val = iconv($charset,'UTF-8',$val);
1094
+		else $val = iconv($charset, 'UTF-8', $val);
1095 1095
 	}
1096 1096
 
1097 1097
 	/**
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 	 */
1103 1103
 	function convertEncodingStr($str)
1104 1104
 	{
1105
-        if(!$str) return null;
1105
+        if (!$str) return null;
1106 1106
 		$obj = new stdClass();
1107 1107
 		$obj->str = $str;
1108 1108
 		$obj = self::convertEncoding($obj);
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 
1112 1112
 	function decodeIdna($domain)
1113 1113
 	{
1114
-		if(strpos($domain, 'xn--') !== FALSE)
1114
+		if (strpos($domain, 'xn--') !== FALSE)
1115 1115
 		{
1116 1116
 			require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php');
1117 1117
 			$IDN = new idna_convert(array('idn_version' => 2008));
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 	{
1145 1145
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
1146 1146
 
1147
-		if($self->response_method)
1147
+		if ($self->response_method)
1148 1148
 		{
1149 1149
 			return $self->response_method;
1150 1150
 		}
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
 		$this->_recursiveCheckVar($_SERVER['HTTP_HOST']);
1185 1185
 
1186 1186
 		$pattern = "/[\,\"\'\{\}\[\]\(\);$]/";
1187
-		if(preg_match($pattern, $_SERVER['HTTP_HOST']))
1187
+		if (preg_match($pattern, $_SERVER['HTTP_HOST']))
1188 1188
 		{
1189 1189
 			$this->isSuccessInit = FALSE;
1190 1190
 		}
@@ -1197,30 +1197,30 @@  discard block
 block discarded – undo
1197 1197
 	 */
1198 1198
 	function _setRequestArgument()
1199 1199
 	{
1200
-		if(!count($_REQUEST))
1200
+		if (!count($_REQUEST))
1201 1201
 		{
1202 1202
 			return;
1203 1203
 		}
1204 1204
 
1205 1205
 		$requestMethod = $this->getRequestMethod();
1206
-		foreach($_REQUEST as $key => $val)
1206
+		foreach ($_REQUEST as $key => $val)
1207 1207
 		{
1208
-			if($val === '' || self::get($key))
1208
+			if ($val === '' || self::get($key))
1209 1209
 			{
1210 1210
 				continue;
1211 1211
 			}
1212 1212
 			$key = htmlentities($key);
1213 1213
 			$val = $this->_filterRequestVar($key, $val);
1214 1214
 
1215
-			if($requestMethod == 'GET' && isset($_GET[$key]))
1215
+			if ($requestMethod == 'GET' && isset($_GET[$key]))
1216 1216
 			{
1217 1217
 				$set_to_vars = TRUE;
1218 1218
 			}
1219
-			elseif($requestMethod == 'POST' && isset($_POST[$key]))
1219
+			elseif ($requestMethod == 'POST' && isset($_POST[$key]))
1220 1220
 			{
1221 1221
 				$set_to_vars = TRUE;
1222 1222
 			}
1223
-			elseif($requestMethod == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key])))
1223
+			elseif ($requestMethod == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key])))
1224 1224
 			{
1225 1225
 				$set_to_vars = TRUE;
1226 1226
 			}
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 				$set_to_vars = FALSE;
1230 1230
 			}
1231 1231
 
1232
-			if($set_to_vars)
1232
+			if ($set_to_vars)
1233 1233
 			{
1234 1234
 				$this->_recursiveCheckVar($val);
1235 1235
 			}
@@ -1240,20 +1240,20 @@  discard block
 block discarded – undo
1240 1240
 
1241 1241
 	function _recursiveCheckVar($val)
1242 1242
 	{
1243
-		if(is_string($val))
1243
+		if (is_string($val))
1244 1244
 		{
1245
-			foreach($this->patterns as $pattern)
1245
+			foreach ($this->patterns as $pattern)
1246 1246
 			{
1247
-				if(preg_match($pattern, $val))
1247
+				if (preg_match($pattern, $val))
1248 1248
 				{
1249 1249
 					$this->isSuccessInit = FALSE;
1250 1250
 					return;
1251 1251
 				}
1252 1252
 			}
1253 1253
 		}
1254
-		else if(is_array($val))
1254
+		else if (is_array($val))
1255 1255
 		{
1256
-			foreach($val as $val2)
1256
+			foreach ($val as $val2)
1257 1257
 			{
1258 1258
 				$this->_recursiveCheckVar($val2);
1259 1259
 			}
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 	 */
1268 1268
 	function _setJSONRequestArgument()
1269 1269
 	{
1270
-		if($this->getRequestMethod() != 'JSON')
1270
+		if ($this->getRequestMethod() != 'JSON')
1271 1271
 		{
1272 1272
 			return;
1273 1273
 		}
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
 		$params = array();
1276 1276
 		parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $params);
1277 1277
 
1278
-		foreach($params as $key => $val)
1278
+		foreach ($params as $key => $val)
1279 1279
 		{
1280 1280
 			$this->set($key, $this->_filterRequestVar($key, $val, 1), TRUE);
1281 1281
 		}
@@ -1288,13 +1288,13 @@  discard block
 block discarded – undo
1288 1288
 	 */
1289 1289
 	function _setXmlRpcArgument()
1290 1290
 	{
1291
-		if($this->getRequestMethod() != 'XMLRPC')
1291
+		if ($this->getRequestMethod() != 'XMLRPC')
1292 1292
 		{
1293 1293
 			return;
1294 1294
 		}
1295 1295
 
1296 1296
 		$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
1297
-		if(Security::detectingXEE($xml))
1297
+		if (Security::detectingXEE($xml))
1298 1298
 		{
1299 1299
 			header("HTTP/1.0 400 Bad Request");
1300 1300
 			exit;
@@ -1306,12 +1306,12 @@  discard block
 block discarded – undo
1306 1306
 		$params = $xml_obj->methodcall->params;
1307 1307
 		unset($params->node_name, $params->attrs, $params->body);
1308 1308
 
1309
-		if(!count(get_object_vars($params)))
1309
+		if (!count(get_object_vars($params)))
1310 1310
 		{
1311 1311
 			return;
1312 1312
 		}
1313 1313
 
1314
-		foreach($params as $key => $val)
1314
+		foreach ($params as $key => $val)
1315 1315
 		{
1316 1316
 			$this->set($key, $this->_filterXmlVars($key, $val), TRUE);
1317 1317
 		}
@@ -1326,10 +1326,10 @@  discard block
 block discarded – undo
1326 1326
 	 */
1327 1327
 	function _filterXmlVars($key, $val)
1328 1328
 	{
1329
-		if(is_array($val))
1329
+		if (is_array($val))
1330 1330
 		{
1331 1331
 			$stack = array();
1332
-			foreach($val as $k => $v)
1332
+			foreach ($val as $k => $v)
1333 1333
 			{
1334 1334
 				$stack[$k] = $this->_filterXmlVars($k, $v);
1335 1335
 			}
@@ -1339,20 +1339,20 @@  discard block
 block discarded – undo
1339 1339
 
1340 1340
 		$body = $val->body;
1341 1341
 		unset($val->node_name, $val->attrs, $val->body);
1342
-		if(!count(get_object_vars($val)))
1342
+		if (!count(get_object_vars($val)))
1343 1343
 		{
1344 1344
 			return $this->_filterRequestVar($key, $body, 0);
1345 1345
 		}
1346 1346
 
1347 1347
 		$stack = new stdClass();
1348
-		foreach($val as $k => $v)
1348
+		foreach ($val as $k => $v)
1349 1349
 		{
1350 1350
 			$output = $this->_filterXmlVars($k, $v);
1351
-			if(is_object($v) && $v->attrs->type == 'array')
1351
+			if (is_object($v) && $v->attrs->type == 'array')
1352 1352
 			{
1353 1353
 				$output = array($output);
1354 1354
 			}
1355
-			if($k == 'value' && (is_array($v) || $v->attrs->type == 'array'))
1355
+			if ($k == 'value' && (is_array($v) || $v->attrs->type == 'array'))
1356 1356
 			{
1357 1357
 				return $output;
1358 1358
 			}
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 			$stack->{$k} = $output;
1361 1361
 		}
1362 1362
 
1363
-		if(!count(get_object_vars($stack)))
1363
+		if (!count(get_object_vars($stack)))
1364 1364
 		{
1365 1365
 			return NULL;
1366 1366
 		}
@@ -1379,24 +1379,24 @@  discard block
 block discarded – undo
1379 1379
 	 */
1380 1380
 	function _filterRequestVar($key, $val, $do_stripslashes = 1)
1381 1381
 	{
1382
-		if(!($isArray = is_array($val)))
1382
+		if (!($isArray = is_array($val)))
1383 1383
 		{
1384 1384
 			$val = array($val);
1385 1385
 		}
1386 1386
 
1387 1387
 		$result = array();
1388
-		foreach($val as $k => $v)
1388
+		foreach ($val as $k => $v)
1389 1389
 		{
1390 1390
 			$k = htmlentities($k);
1391
-			if($key === 'page' || $key === 'cpage' || substr_compare($key, 'srl', -3) === 0)
1391
+			if ($key === 'page' || $key === 'cpage' || substr_compare($key, 'srl', -3) === 0)
1392 1392
 			{
1393 1393
 				$result[$k] = !preg_match('/^[0-9,]+$/', $v) ? (int) $v : $v;
1394 1394
 			}
1395
-			elseif($key === 'mid' || $key === 'search_keyword')
1395
+			elseif ($key === 'mid' || $key === 'search_keyword')
1396 1396
 			{
1397 1397
 				$result[$k] = htmlspecialchars($v, ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE);
1398 1398
 			}
1399
-			elseif($key === 'vid')
1399
+			elseif ($key === 'vid')
1400 1400
 			{
1401 1401
 				$result[$k] = urlencode($v);
1402 1402
 			}
@@ -1404,12 +1404,12 @@  discard block
 block discarded – undo
1404 1404
 			{
1405 1405
 				$result[$k] = $v;
1406 1406
 
1407
-				if($do_stripslashes && version_compare(PHP_VERSION, '5.4.0', '<') && get_magic_quotes_gpc())
1407
+				if ($do_stripslashes && version_compare(PHP_VERSION, '5.4.0', '<') && get_magic_quotes_gpc())
1408 1408
 				{
1409 1409
 					$result[$k] = stripslashes($result[$k]);
1410 1410
 				}
1411 1411
 
1412
-				if(!is_array($result[$k]))
1412
+				if (!is_array($result[$k]))
1413 1413
 				{
1414 1414
 					$result[$k] = trim($result[$k]);
1415 1415
 				}
@@ -1437,17 +1437,17 @@  discard block
 block discarded – undo
1437 1437
 	 */
1438 1438
 	function _setUploadedArgument()
1439 1439
 	{
1440
-		if($_SERVER['REQUEST_METHOD'] != 'POST' || !$_FILES || (stripos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') === FALSE && stripos($_SERVER['HTTP_CONTENT_TYPE'], 'multipart/form-data') === FALSE))
1440
+		if ($_SERVER['REQUEST_METHOD'] != 'POST' || !$_FILES || (stripos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') === FALSE && stripos($_SERVER['HTTP_CONTENT_TYPE'], 'multipart/form-data') === FALSE))
1441 1441
 		{
1442 1442
 			return;
1443 1443
 		}
1444 1444
 
1445
-		foreach($_FILES as $key => $val)
1445
+		foreach ($_FILES as $key => $val)
1446 1446
 		{
1447 1447
 			$tmp_name = $val['tmp_name'];
1448
-			if(!is_array($tmp_name))
1448
+			if (!is_array($tmp_name))
1449 1449
 			{
1450
-				if(!$tmp_name || !is_uploaded_file($tmp_name))
1450
+				if (!$tmp_name || !is_uploaded_file($tmp_name))
1451 1451
 				{
1452 1452
 					continue;
1453 1453
 				}
@@ -1457,9 +1457,9 @@  discard block
 block discarded – undo
1457 1457
 			}
1458 1458
 			else
1459 1459
 			{
1460
-				for($i = 0, $c = count($tmp_name); $i < $c; $i++)
1460
+				for ($i = 0, $c = count($tmp_name); $i < $c; $i++)
1461 1461
 				{
1462
-					if($val['size'][$i] > 0)
1462
+					if ($val['size'][$i] > 0)
1463 1463
 					{
1464 1464
 						$file['name'] = $val['name'][$i];
1465 1465
 						$file['type'] = $val['type'][$i];
@@ -1491,12 +1491,12 @@  discard block
 block discarded – undo
1491 1491
 	function getRequestUrl()
1492 1492
 	{
1493 1493
 		static $url = null;
1494
-		if(is_null($url))
1494
+		if (is_null($url))
1495 1495
 		{
1496 1496
 			$url = self::getRequestUri();
1497
-			if(count($_GET) > 0)
1497
+			if (count($_GET) > 0)
1498 1498
 			{
1499
-				foreach($_GET as $key => $val)
1499
+				foreach ($_GET as $key => $val)
1500 1500
 				{
1501 1501
 					$vars[] = $key . '=' . ($val ? urlencode(self::convertEncodingStr($val)) : '');
1502 1502
 				}
@@ -1515,7 +1515,7 @@  discard block
 block discarded – undo
1515 1515
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
1516 1516
 		$js_callback_func = isset($_GET['xe_js_callback']) ? $_GET['xe_js_callback'] : $_POST['xe_js_callback'];
1517 1517
 
1518
-		if(!preg_match('/^[a-z0-9\.]+$/i', $js_callback_func))
1518
+		if (!preg_match('/^[a-z0-9\.]+$/i', $js_callback_func))
1519 1519
 		{
1520 1520
 			unset($js_callback_func);
1521 1521
 			unset($_GET['xe_js_callback']);
@@ -1543,22 +1543,22 @@  discard block
 block discarded – undo
1543 1543
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
1544 1544
 
1545 1545
 		// retrieve virtual site information
1546
-		if(is_null($site_module_info))
1546
+		if (is_null($site_module_info))
1547 1547
 		{
1548 1548
 			$site_module_info = self::get('site_module_info');
1549 1549
 		}
1550 1550
 
1551 1551
 		// If $domain is set, handle it (if $domain is vid type, remove $domain and handle with $vid)
1552
-		if($domain && isSiteID($domain))
1552
+		if ($domain && isSiteID($domain))
1553 1553
 		{
1554 1554
 			$vid = $domain;
1555 1555
 			$domain = '';
1556 1556
 		}
1557 1557
 
1558 1558
 		// If $domain, $vid are not set, use current site information
1559
-		if(!$domain && !$vid)
1559
+		if (!$domain && !$vid)
1560 1560
 		{
1561
-			if($site_module_info->domain && isSiteID($site_module_info->domain))
1561
+			if ($site_module_info->domain && isSiteID($site_module_info->domain))
1562 1562
 			{
1563 1563
 				$vid = $site_module_info->domain;
1564 1564
 			}
@@ -1569,21 +1569,21 @@  discard block
 block discarded – undo
1569 1569
 		}
1570 1570
 
1571 1571
 		// if $domain is set, compare current URL. If they are same, remove the domain, otherwise link to the domain.
1572
-		if($domain)
1572
+		if ($domain)
1573 1573
 		{
1574 1574
 			$domain_info = parse_url($domain);
1575
-			if(is_null($current_info))
1575
+			if (is_null($current_info))
1576 1576
 			{
1577 1577
 				$current_info = parse_url(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . getScriptPath());
1578 1578
 			}
1579
-			if($domain_info['host'] . $domain_info['path'] == $current_info['host'] . $current_info['path'])
1579
+			if ($domain_info['host'] . $domain_info['path'] == $current_info['host'] . $current_info['path'])
1580 1580
 			{
1581 1581
 				unset($domain);
1582 1582
 			}
1583 1583
 			else
1584 1584
 			{
1585 1585
 				$domain = preg_replace('/^(http|https):\/\//i', '', trim($domain));
1586
-				if(substr_compare($domain, '/', -1) !== 0)
1586
+				if (substr_compare($domain, '/', -1) !== 0)
1587 1587
 				{
1588 1588
 					$domain .= '/';
1589 1589
 				}
@@ -1593,10 +1593,10 @@  discard block
 block discarded – undo
1593 1593
 		$get_vars = array();
1594 1594
 
1595 1595
 		// If there is no GET variables or first argument is '' to reset variables
1596
-		if(!$self->get_vars || $args_list[0] == '')
1596
+		if (!$self->get_vars || $args_list[0] == '')
1597 1597
 		{
1598 1598
 			// rearrange args_list
1599
-			if(is_array($args_list) && $args_list[0] == '')
1599
+			if (is_array($args_list) && $args_list[0] == '')
1600 1600
 			{
1601 1601
 				array_shift($args_list);
1602 1602
 			}
@@ -1608,13 +1608,13 @@  discard block
 block discarded – undo
1608 1608
 		}
1609 1609
 
1610 1610
 		// arrange args_list
1611
-		for($i = 0, $c = count($args_list); $i < $c; $i += 2)
1611
+		for ($i = 0, $c = count($args_list); $i < $c; $i += 2)
1612 1612
 		{
1613 1613
 			$key = $args_list[$i];
1614 1614
 			$val = trim($args_list[$i + 1]);
1615 1615
 
1616 1616
 			// If value is not set, remove the key
1617
-			if(!isset($val) || !strlen($val))
1617
+			if (!isset($val) || !strlen($val))
1618 1618
 			{
1619 1619
 				unset($get_vars[$key]);
1620 1620
 				continue;
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 
1626 1626
 		// remove vid, rnd
1627 1627
 		unset($get_vars['rnd']);
1628
-		if($vid)
1628
+		if ($vid)
1629 1629
 		{
1630 1630
 			$get_vars['vid'] = $vid;
1631 1631
 		}
@@ -1642,17 +1642,17 @@  discard block
 block discarded – undo
1642 1642
 			'dispDocumentAdminManageDocument' => 'dispDocumentManageDocument',
1643 1643
 			'dispModuleAdminSelectList' => 'dispModuleSelectList'
1644 1644
 		);
1645
-		if($act_alias[$act])
1645
+		if ($act_alias[$act])
1646 1646
 		{
1647 1647
 			$get_vars['act'] = $act_alias[$act];
1648 1648
 		}
1649 1649
 
1650 1650
 		// organize URL
1651 1651
 		$query = '';
1652
-		if(count($get_vars) > 0)
1652
+		if (count($get_vars) > 0)
1653 1653
 		{
1654 1654
 			// if using rewrite mod
1655
-			if($self->allow_rewrite)
1655
+			if ($self->allow_rewrite)
1656 1656
 			{
1657 1657
 				$var_keys = array_keys($get_vars);
1658 1658
 				sort($var_keys);
@@ -1690,24 +1690,24 @@  discard block
 block discarded – undo
1690 1690
 				$query = $target_map[$target];
1691 1691
 			}
1692 1692
 
1693
-			if(!$query)
1693
+			if (!$query)
1694 1694
 			{
1695 1695
 				$queries = array();
1696
-				foreach($get_vars as $key => $val)
1696
+				foreach ($get_vars as $key => $val)
1697 1697
 				{
1698
-					if(is_array($val) && count($val) > 0)
1698
+					if (is_array($val) && count($val) > 0)
1699 1699
 					{
1700
-						foreach($val as $k => $v)
1700
+						foreach ($val as $k => $v)
1701 1701
 						{
1702 1702
 							$queries[] = $key . '[' . $k . ']=' . urlencode($v);
1703 1703
 						}
1704 1704
 					}
1705
-					elseif(!is_array($val))
1705
+					elseif (!is_array($val))
1706 1706
 					{
1707 1707
 						$queries[] = $key . '=' . urlencode($val);
1708 1708
 					}
1709 1709
 				}
1710
-				if(count($queries) > 0)
1710
+				if (count($queries) > 0)
1711 1711
 				{
1712 1712
 					$query = 'index.php?' . join('&', $queries);
1713 1713
 				}
@@ -1716,12 +1716,12 @@  discard block
 block discarded – undo
1716 1716
 
1717 1717
 		// If using SSL always
1718 1718
 		$_use_ssl = $self->get('_use_ssl');
1719
-		if($_use_ssl == 'always')
1719
+		if ($_use_ssl == 'always')
1720 1720
 		{
1721 1721
 			$query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query;
1722 1722
 			// optional SSL use
1723 1723
 		}
1724
-		elseif($_use_ssl == 'optional')
1724
+		elseif ($_use_ssl == 'optional')
1725 1725
 		{
1726 1726
 			$ssl_mode = (($self->get('module') === 'admin') || ($get_vars['module'] === 'admin') || (isset($get_vars['act']) && $self->isExistsSSLAction($get_vars['act']))) ? ENFORCE_SSL : RELEASE_SSL;
1727 1727
 			$query = $self->getRequestUri($ssl_mode, $domain) . $query;
@@ -1730,11 +1730,11 @@  discard block
 block discarded – undo
1730 1730
 		else
1731 1731
 		{
1732 1732
 			// currently on SSL but target is not based on SSL
1733
-			if($_SERVER['HTTPS'] == 'on')
1733
+			if ($_SERVER['HTTPS'] == 'on')
1734 1734
 			{
1735 1735
 				$query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query;
1736 1736
 			}
1737
-			else if($domain) // if $domain is set
1737
+			else if ($domain) // if $domain is set
1738 1738
 			{
1739 1739
 				$query = $self->getRequestUri(FOLLOW_REQUEST_SSL, $domain) . $query;
1740 1740
 			}
@@ -1744,12 +1744,12 @@  discard block
 block discarded – undo
1744 1744
 			}
1745 1745
 		}
1746 1746
 
1747
-		if(!$encode)
1747
+		if (!$encode)
1748 1748
 		{
1749 1749
 			return $query;
1750 1750
 		}
1751 1751
 
1752
-		if(!$autoEncode)
1752
+		if (!$autoEncode)
1753 1753
 		{
1754 1754
 			return htmlspecialchars($query, ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE);
1755 1755
 		}
@@ -1758,9 +1758,9 @@  discard block
 block discarded – undo
1758 1758
 		$encode_queries = array();
1759 1759
 		$parsedUrl = parse_url($query);
1760 1760
 		parse_str($parsedUrl['query'], $output);
1761
-		foreach($output as $key => $value)
1761
+		foreach ($output as $key => $value)
1762 1762
 		{
1763
-			if(preg_match('/&([a-z]{2,}|#\d+);/', urldecode($value)))
1763
+			if (preg_match('/&([a-z]{2,}|#\d+);/', urldecode($value)))
1764 1764
 			{
1765 1765
 				$value = urlencode(htmlspecialchars_decode(urldecode($value)));
1766 1766
 			}
@@ -1782,17 +1782,17 @@  discard block
 block discarded – undo
1782 1782
 		static $url = array();
1783 1783
 
1784 1784
 		// Check HTTP Request
1785
-		if(!isset($_SERVER['SERVER_PROTOCOL']))
1785
+		if (!isset($_SERVER['SERVER_PROTOCOL']))
1786 1786
 		{
1787 1787
 			return;
1788 1788
 		}
1789 1789
 
1790
-		if(self::get('_use_ssl') == 'always')
1790
+		if (self::get('_use_ssl') == 'always')
1791 1791
 		{
1792 1792
 			$ssl_mode = ENFORCE_SSL;
1793 1793
 		}
1794 1794
 
1795
-		if($domain)
1795
+		if ($domain)
1796 1796
 		{
1797 1797
 			$domain_key = md5($domain);
1798 1798
 		}
@@ -1801,14 +1801,14 @@  discard block
 block discarded – undo
1801 1801
 			$domain_key = 'default';
1802 1802
 		}
1803 1803
 
1804
-		if(isset($url[$ssl_mode][$domain_key]))
1804
+		if (isset($url[$ssl_mode][$domain_key]))
1805 1805
 		{
1806 1806
 			return $url[$ssl_mode][$domain_key];
1807 1807
 		}
1808 1808
 
1809 1809
 		$current_use_ssl = ($_SERVER['HTTPS'] == 'on');
1810 1810
 
1811
-		switch($ssl_mode)
1811
+		switch ($ssl_mode)
1812 1812
 		{
1813 1813
 			case FOLLOW_REQUEST_SSL: $use_ssl = $current_use_ssl;
1814 1814
 				break;
@@ -1818,12 +1818,12 @@  discard block
 block discarded – undo
1818 1818
 				break;
1819 1819
 		}
1820 1820
 
1821
-		if($domain)
1821
+		if ($domain)
1822 1822
 		{
1823 1823
 			$target_url = trim($domain);
1824
-			if(substr_compare($target_url, '/', -1) !== 0)
1824
+			if (substr_compare($target_url, '/', -1) !== 0)
1825 1825
 			{
1826
-				$target_url.= '/';
1826
+				$target_url .= '/';
1827 1827
 			}
1828 1828
 		}
1829 1829
 		else
@@ -1833,19 +1833,19 @@  discard block
 block discarded – undo
1833 1833
 
1834 1834
 		$url_info = parse_url('http://' . $target_url);
1835 1835
 
1836
-		if($current_use_ssl != $use_ssl)
1836
+		if ($current_use_ssl != $use_ssl)
1837 1837
 		{
1838 1838
 			unset($url_info['port']);
1839 1839
 		}
1840 1840
 
1841
-		if($use_ssl)
1841
+		if ($use_ssl)
1842 1842
 		{
1843 1843
 			$port = self::get('_https_port');
1844
-			if($port && $port != 443)
1844
+			if ($port && $port != 443)
1845 1845
 			{
1846 1846
 				$url_info['port'] = $port;
1847 1847
 			}
1848
-			elseif($url_info['port'] == 443)
1848
+			elseif ($url_info['port'] == 443)
1849 1849
 			{
1850 1850
 				unset($url_info['port']);
1851 1851
 			}
@@ -1853,11 +1853,11 @@  discard block
 block discarded – undo
1853 1853
 		else
1854 1854
 		{
1855 1855
 			$port = self::get('_http_port');
1856
-			if($port && $port != 80)
1856
+			if ($port && $port != 80)
1857 1857
 			{
1858 1858
 				$url_info['port'] = $port;
1859 1859
 			}
1860
-			elseif($url_info['port'] == 80)
1860
+			elseif ($url_info['port'] == 80)
1861 1861
 			{
1862 1862
 				unset($url_info['port']);
1863 1863
 			}
@@ -1880,16 +1880,16 @@  discard block
 block discarded – undo
1880 1880
 	{
1881 1881
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
1882 1882
 		$self->context->{$key} = $val;
1883
-		if($set_to_get_vars === FALSE)
1883
+		if ($set_to_get_vars === FALSE)
1884 1884
 		{
1885 1885
 			return;
1886 1886
 		}
1887
-		if($val === NULL || $val === '')
1887
+		if ($val === NULL || $val === '')
1888 1888
 		{
1889 1889
 			unset($self->get_vars->{$key});
1890 1890
 			return;
1891 1891
 		}
1892
-		if($set_to_get_vars || $self->get_vars->{$key})
1892
+		if ($set_to_get_vars || $self->get_vars->{$key})
1893 1893
 		{
1894 1894
 			$self->get_vars->{$key} = $val;
1895 1895
 		}
@@ -1905,7 +1905,7 @@  discard block
 block discarded – undo
1905 1905
 	{
1906 1906
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
1907 1907
 
1908
-		if(!isset($self->context->{$key}))
1908
+		if (!isset($self->context->{$key}))
1909 1909
 		{
1910 1910
 			return null;
1911 1911
 		}
@@ -1920,7 +1920,7 @@  discard block
 block discarded – undo
1920 1920
 	function gets()
1921 1921
 	{
1922 1922
 		$num_args = func_num_args();
1923
-		if($num_args < 1)
1923
+		if ($num_args < 1)
1924 1924
 		{
1925 1925
 			return;
1926 1926
 		}
@@ -1928,7 +1928,7 @@  discard block
 block discarded – undo
1928 1928
 
1929 1929
 		$args_list = func_get_args();
1930 1930
 		$output = new stdClass();
1931
-		foreach($args_list as $v)
1931
+		foreach ($args_list as $v)
1932 1932
 		{
1933 1933
 			$output->{$v} = $self->get($v);
1934 1934
 		}
@@ -1954,7 +1954,7 @@  discard block
 block discarded – undo
1954 1954
 	function getRequestVars()
1955 1955
 	{
1956 1956
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
1957
-		if($self->get_vars)
1957
+		if ($self->get_vars)
1958 1958
 		{
1959 1959
 			return clone($self->get_vars);
1960 1960
 		}
@@ -1971,13 +1971,13 @@  discard block
 block discarded – undo
1971 1971
 	{
1972 1972
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
1973 1973
 
1974
-		if(!is_readable($self->sslActionCacheFile))
1974
+		if (!is_readable($self->sslActionCacheFile))
1975 1975
 		{
1976 1976
 			$buff = '<?php if(!defined("__XE__"))exit;';
1977 1977
 			FileHandler::writeFile($self->sslActionCacheFile, $buff);
1978 1978
 		}
1979 1979
 
1980
-		if(!isset($self->ssl_actions[$action]))
1980
+		if (!isset($self->ssl_actions[$action]))
1981 1981
 		{
1982 1982
 			$self->ssl_actions[$action] = 1;
1983 1983
 			$sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action);
@@ -1995,16 +1995,16 @@  discard block
 block discarded – undo
1995 1995
 	{
1996 1996
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
1997 1997
 
1998
-		if(!is_readable($self->sslActionCacheFile))
1998
+		if (!is_readable($self->sslActionCacheFile))
1999 1999
 		{
2000 2000
 			unset($self->ssl_actions);
2001 2001
 			$buff = '<?php if(!defined("__XE__"))exit;';
2002 2002
 			FileHandler::writeFile($self->sslActionCacheFile, $buff);
2003 2003
 		}
2004 2004
 
2005
-		foreach($action_array as $action)
2005
+		foreach ($action_array as $action)
2006 2006
 		{
2007
-			if(!isset($self->ssl_actions[$action]))
2007
+			if (!isset($self->ssl_actions[$action]))
2008 2008
 			{
2009 2009
 				$self->ssl_actions[$action] = 1;
2010 2010
 				$sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action);
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
 	{
2024 2024
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
2025 2025
 
2026
-		if($self->isExistsSSLAction($action))
2026
+		if ($self->isExistsSSLAction($action))
2027 2027
 		{
2028 2028
 			$sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action);
2029 2029
 			$buff = FileHandler::readFile($self->sslActionCacheFile);
@@ -2040,7 +2040,7 @@  discard block
 block discarded – undo
2040 2040
 	function getSSLActions()
2041 2041
 	{
2042 2042
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
2043
-		if($self->getSslStatus() == 'optional')
2043
+		if ($self->getSslStatus() == 'optional')
2044 2044
 		{
2045 2045
 			return $self->ssl_actions;
2046 2046
 		}
@@ -2067,12 +2067,12 @@  discard block
 block discarded – undo
2067 2067
 	 */
2068 2068
 	function normalizeFilePath($file)
2069 2069
 	{
2070
-		if($file{0} != '/' && $file{0} != '.' && strpos($file, '://') === FALSE)
2070
+		if ($file{0} != '/' && $file{0} != '.' && strpos($file, '://') === FALSE)
2071 2071
 		{
2072 2072
 			$file = './' . $file;
2073 2073
 		}
2074 2074
 		$file = preg_replace('@/\./|(?<!:)\/\/@', '/', $file);
2075
-		while(strpos($file, '/../') !== FALSE)
2075
+		while (strpos($file, '/../') !== FALSE)
2076 2076
 		{
2077 2077
 			$file = preg_replace('/\/([^\/]+)\/\.\.\//s', '/', $file, 1);
2078 2078
 		}
@@ -2090,11 +2090,11 @@  discard block
 block discarded – undo
2090 2090
 	function getAbsFileUrl($file)
2091 2091
 	{
2092 2092
 		$file = self::normalizeFilePath($file);
2093
-		if(strpos($file, './') === 0)
2093
+		if (strpos($file, './') === 0)
2094 2094
 		{
2095 2095
 			$file = dirname($_SERVER['SCRIPT_NAME']) . '/' . substr($file, 2);
2096 2096
 		}
2097
-		elseif(strpos($file, '../') === 0)
2097
+		elseif (strpos($file, '../') === 0)
2098 2098
 		{
2099 2099
 			$file = self::normalizeFilePath(dirname($_SERVER['SCRIPT_NAME']) . "/{$file}");
2100 2100
 		}
@@ -2166,12 +2166,12 @@  discard block
 block discarded – undo
2166 2166
 	 */
2167 2167
 	function addJsFile($file, $optimized = FALSE, $targetie = '', $index = 0, $type = 'head', $isRuleset = FALSE, $autoPath = null)
2168 2168
 	{
2169
-		if($isRuleset)
2169
+		if ($isRuleset)
2170 2170
 		{
2171
-			if(strpos($file, '#') !== FALSE)
2171
+			if (strpos($file, '#') !== FALSE)
2172 2172
 			{
2173 2173
 				$file = str_replace('#', '', $file);
2174
-				if(!is_readable($file))
2174
+				if (!is_readable($file))
2175 2175
 				{
2176 2176
 					$file = $autoPath;
2177 2177
 				}
@@ -2236,9 +2236,9 @@  discard block
 block discarded – undo
2236 2236
 		ksort($files);
2237 2237
 		$files = array_values($files);
2238 2238
 		$filenames = array();
2239
-		for($i = 0, $c = count($files); $i < $c; ++$i)
2239
+		for ($i = 0, $c = count($files); $i < $c; ++$i)
2240 2240
 		{
2241
-			if(in_array($files[$i]['file'], $filenames))
2241
+			if (in_array($files[$i]['file'], $filenames))
2242 2242
 			{
2243 2243
 				unset($files[$i]);
2244 2244
 			}
@@ -2323,14 +2323,14 @@  discard block
 block discarded – undo
2323 2323
 	 */
2324 2324
 	function getJavascriptPluginInfo($pluginName)
2325 2325
 	{
2326
-		if($plugin_name == 'ui.datepicker')
2326
+		if ($plugin_name == 'ui.datepicker')
2327 2327
 		{
2328 2328
 			$plugin_name = 'ui';
2329 2329
 		}
2330 2330
 
2331 2331
 		$plugin_path = './common/js/plugins/' . $pluginName . '/';
2332 2332
 		$info_file = $plugin_path . 'plugin.load';
2333
-		if(!is_readable($info_file))
2333
+		if (!is_readable($info_file))
2334 2334
 		{
2335 2335
 			return;
2336 2336
 		}
@@ -2340,30 +2340,30 @@  discard block
 block discarded – undo
2340 2340
 		$result->jsList = array();
2341 2341
 		$result->cssList = array();
2342 2342
 
2343
-		foreach($list as $filename)
2343
+		foreach ($list as $filename)
2344 2344
 		{
2345 2345
 			$filename = trim($filename);
2346
-			if(!$filename)
2346
+			if (!$filename)
2347 2347
 			{
2348 2348
 				continue;
2349 2349
 			}
2350 2350
 
2351
-			if(strncasecmp('./', $filename, 2) === 0)
2351
+			if (strncasecmp('./', $filename, 2) === 0)
2352 2352
 			{
2353 2353
 				$filename = substr($filename, 2);
2354 2354
 			}
2355 2355
 
2356
-			if(substr_compare($filename, '.js', -3) === 0)
2356
+			if (substr_compare($filename, '.js', -3) === 0)
2357 2357
 			{
2358 2358
 				$result->jsList[] = $plugin_path . $filename;
2359 2359
 			}
2360
-			elseif(substr_compare($filename, '.css', -4) === 0)
2360
+			elseif (substr_compare($filename, '.css', -4) === 0)
2361 2361
 			{
2362 2362
 				$result->cssList[] = $plugin_path . $filename;
2363 2363
 			}
2364 2364
 		}
2365 2365
 
2366
-		if(is_dir($plugin_path . 'lang'))
2366
+		if (is_dir($plugin_path . 'lang'))
2367 2367
 		{
2368 2368
 			$result->langPath = $plugin_path . 'lang';
2369 2369
 		}
@@ -2381,12 +2381,12 @@  discard block
 block discarded – undo
2381 2381
 		static $loaded_plugins = array();
2382 2382
 
2383 2383
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
2384
-		if($plugin_name == 'ui.datepicker')
2384
+		if ($plugin_name == 'ui.datepicker')
2385 2385
 		{
2386 2386
 			$plugin_name = 'ui';
2387 2387
 		}
2388 2388
 
2389
-		if($loaded_plugins[$plugin_name])
2389
+		if ($loaded_plugins[$plugin_name])
2390 2390
 		{
2391 2391
 			return;
2392 2392
 		}
@@ -2394,35 +2394,35 @@  discard block
 block discarded – undo
2394 2394
 
2395 2395
 		$plugin_path = './common/js/plugins/' . $plugin_name . '/';
2396 2396
 		$info_file = $plugin_path . 'plugin.load';
2397
-		if(!is_readable($info_file))
2397
+		if (!is_readable($info_file))
2398 2398
 		{
2399 2399
 			return;
2400 2400
 		}
2401 2401
 
2402 2402
 		$list = file($info_file);
2403
-		foreach($list as $filename)
2403
+		foreach ($list as $filename)
2404 2404
 		{
2405 2405
 			$filename = trim($filename);
2406
-			if(!$filename)
2406
+			if (!$filename)
2407 2407
 			{
2408 2408
 				continue;
2409 2409
 			}
2410 2410
 
2411
-			if(strncasecmp('./', $filename, 2) === 0)
2411
+			if (strncasecmp('./', $filename, 2) === 0)
2412 2412
 			{
2413 2413
 				$filename = substr($filename, 2);
2414 2414
 			}
2415
-			if(substr_compare($filename, '.js', -3) === 0)
2415
+			if (substr_compare($filename, '.js', -3) === 0)
2416 2416
 			{
2417 2417
 				$self->loadFile(array($plugin_path . $filename, 'body', '', 0), TRUE);
2418 2418
 			}
2419
-			if(substr_compare($filename, '.css', -4) === 0)
2419
+			if (substr_compare($filename, '.css', -4) === 0)
2420 2420
 			{
2421 2421
 				$self->loadFile(array($plugin_path . $filename, 'all', '', 0), TRUE);
2422 2422
 			}
2423 2423
 		}
2424 2424
 
2425
-		if(is_dir($plugin_path . 'lang'))
2425
+		if (is_dir($plugin_path . 'lang'))
2426 2426
 		{
2427 2427
 			$self->loadLang($plugin_path . 'lang');
2428 2428
 		}
@@ -2594,14 +2594,14 @@  discard block
 block discarded – undo
2594 2594
 		$_path = explode('/', $path);
2595 2595
 		$_base = explode('/', $base_url);
2596 2596
 
2597
-		if(!$_base[count($_base) - 1])
2597
+		if (!$_base[count($_base) - 1])
2598 2598
 		{
2599 2599
 			array_pop($_base);
2600 2600
 		}
2601 2601
 
2602
-		foreach($_xe as $idx => $dir)
2602
+		foreach ($_xe as $idx => $dir)
2603 2603
 		{
2604
-			if($_path[0] != $dir)
2604
+			if ($_path[0] != $dir)
2605 2605
 			{
2606 2606
 				break;
2607 2607
 			}
@@ -2609,9 +2609,9 @@  discard block
 block discarded – undo
2609 2609
 		}
2610 2610
 
2611 2611
 		$idx = count($_xe) - $idx - 1;
2612
-		while($idx--)
2612
+		while ($idx--)
2613 2613
 		{
2614
-			if(count($_base) > 0)
2614
+			if (count($_base) > 0)
2615 2615
 			{
2616 2616
 				array_shift($_base);
2617 2617
 			}
@@ -2621,13 +2621,13 @@  discard block
 block discarded – undo
2621 2621
 			}
2622 2622
 		}
2623 2623
 
2624
-		if(count($_base) > 0)
2624
+		if (count($_base) > 0)
2625 2625
 		{
2626 2626
 			array_unshift($_path, join('/', $_base));
2627 2627
 		}
2628 2628
 
2629 2629
 		$path = '/' . join('/', $_path);
2630
-		if(substr_compare($path, '/', -1) !== 0)
2630
+		if (substr_compare($path, '/', -1) !== 0)
2631 2631
 		{
2632 2632
 			$path .= '/';
2633 2633
 		}
@@ -2642,13 +2642,13 @@  discard block
 block discarded – undo
2642 2642
 	{
2643 2643
 		is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
2644 2644
 
2645
-		if(!is_array($self->meta_tags))
2645
+		if (!is_array($self->meta_tags))
2646 2646
 		{
2647 2647
 			$self->meta_tags = array();
2648 2648
 		}
2649 2649
 
2650 2650
 		$ret = array();
2651
-		foreach($self->meta_tags as $key => $val)
2651
+		foreach ($self->meta_tags as $key => $val)
2652 2652
 		{
2653 2653
 			list($name, $is_http_equiv) = explode("\t", $key);
2654 2654
 			$ret[] = array('name' => $name, 'is_http_equiv' => $is_http_equiv, 'content' => $val);
Please login to merge, or discard this patch.
libs/phpmailer/phpmailer.php 2 patches
Indentation   +1309 added lines, -1309 removed lines patch added patch discarded remove patch
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
   public $SingleToArray = array();
252 252
 
253 253
  /**
254
-   * Provides the ability to change the line ending
255
-   * @var string
256
-   */
254
+  * Provides the ability to change the line ending
255
+  * @var string
256
+  */
257 257
   public $LE              = "\n";
258 258
 
259 259
   /**
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
    * @param boolean $exceptions Should we throw external exceptions?
341 341
    */
342 342
   public function __construct($exceptions = false) {
343
-    $this->exceptions = ($exceptions == true);
343
+	$this->exceptions = ($exceptions == true);
344 344
   }
345 345
 
346 346
   /**
@@ -349,11 +349,11 @@  discard block
 block discarded – undo
349 349
    * @return void
350 350
    */
351 351
   public function IsHTML($ishtml = true) {
352
-    if ($ishtml) {
353
-      $this->ContentType = 'text/html';
354
-    } else {
355
-      $this->ContentType = 'text/plain';
356
-    }
352
+	if ($ishtml) {
353
+	  $this->ContentType = 'text/html';
354
+	} else {
355
+	  $this->ContentType = 'text/plain';
356
+	}
357 357
   }
358 358
 
359 359
   /**
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
    * @return void
362 362
    */
363 363
   public function IsSMTP() {
364
-    $this->Mailer = 'smtp';
364
+	$this->Mailer = 'smtp';
365 365
   }
366 366
 
367 367
   /**
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
    * @return void
370 370
    */
371 371
   public function IsMail() {
372
-    $this->Mailer = 'mail';
372
+	$this->Mailer = 'mail';
373 373
   }
374 374
 
375 375
   /**
@@ -377,10 +377,10 @@  discard block
 block discarded – undo
377 377
    * @return void
378 378
    */
379 379
   public function IsSendmail() {
380
-    if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
381
-      $this->Sendmail = '/var/qmail/bin/sendmail';
382
-    }
383
-    $this->Mailer = 'sendmail';
380
+	if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
381
+	  $this->Sendmail = '/var/qmail/bin/sendmail';
382
+	}
383
+	$this->Mailer = 'sendmail';
384 384
   }
385 385
 
386 386
   /**
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
    * @return void
389 389
    */
390 390
   public function IsQmail() {
391
-    if (stristr(ini_get('sendmail_path'), 'qmail')) {
392
-    $this->Sendmail = '/var/qmail/bin/sendmail';
393
-    }
394
-    $this->Mailer   = 'sendmail';
391
+	if (stristr(ini_get('sendmail_path'), 'qmail')) {
392
+	$this->Sendmail = '/var/qmail/bin/sendmail';
393
+	}
394
+	$this->Mailer   = 'sendmail';
395 395
   }
396 396
 
397 397
   /////////////////////////////////////////////////
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
    * @return boolean true on success, false if address already used
406 406
    */
407 407
   public function AddAddress($address, $name = '') {
408
-    return $this->AddAnAddress('to', $address, $name);
408
+	return $this->AddAnAddress('to', $address, $name);
409 409
   }
410 410
 
411 411
   /**
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
    * @return boolean true on success, false if address already used
417 417
    */
418 418
   public function AddCC($address, $name = '') {
419
-    return $this->AddAnAddress('cc', $address, $name);
419
+	return $this->AddAnAddress('cc', $address, $name);
420 420
   }
421 421
 
422 422
   /**
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
    * @return boolean true on success, false if address already used
428 428
    */
429 429
   public function AddBCC($address, $name = '') {
430
-    return $this->AddAnAddress('bcc', $address, $name);
430
+	return $this->AddAnAddress('bcc', $address, $name);
431 431
   }
432 432
 
433 433
   /**
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
    * @return boolean
438 438
    */
439 439
   public function AddReplyTo($address, $name = '') {
440
-    return $this->AddAnAddress('ReplyTo', $address, $name);
440
+	return $this->AddAnAddress('ReplyTo', $address, $name);
441 441
   }
442 442
 
443 443
   /**
@@ -450,31 +450,31 @@  discard block
 block discarded – undo
450 450
    * @access private
451 451
    */
452 452
   private function AddAnAddress($kind, $address, $name = '') {
453
-    if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) {
454
-      echo 'Invalid recipient array: ' . kind;
455
-      return false;
456
-    }
457
-    $address = trim($address);
458
-    $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
459
-    if (!self::ValidateAddress($address)) {
460
-      $this->SetError($this->Lang('invalid_address').': '. $address);
461
-      if ($this->exceptions) {
462
-        throw new phpmailerException($this->Lang('invalid_address').': '.$address);
463
-      }
464
-      echo $this->Lang('invalid_address').': '.$address;
465
-      return false;
466
-    }
467
-    if ($kind != 'ReplyTo') {
468
-      if (!isset($this->all_recipients[strtolower($address)])) {
469
-        array_push($this->$kind, array($address, $name));
470
-        $this->all_recipients[strtolower($address)] = true;
471
-        return true;
472
-      }
473
-    } else {
474
-      if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
475
-        $this->ReplyTo[strtolower($address)] = array($address, $name);
476
-      return true;
477
-    }
453
+	if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) {
454
+	  echo 'Invalid recipient array: ' . kind;
455
+	  return false;
456
+	}
457
+	$address = trim($address);
458
+	$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
459
+	if (!self::ValidateAddress($address)) {
460
+	  $this->SetError($this->Lang('invalid_address').': '. $address);
461
+	  if ($this->exceptions) {
462
+		throw new phpmailerException($this->Lang('invalid_address').': '.$address);
463
+	  }
464
+	  echo $this->Lang('invalid_address').': '.$address;
465
+	  return false;
466
+	}
467
+	if ($kind != 'ReplyTo') {
468
+	  if (!isset($this->all_recipients[strtolower($address)])) {
469
+		array_push($this->$kind, array($address, $name));
470
+		$this->all_recipients[strtolower($address)] = true;
471
+		return true;
472
+	  }
473
+	} else {
474
+	  if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
475
+		$this->ReplyTo[strtolower($address)] = array($address, $name);
476
+	  return true;
477
+	}
478 478
   }
479 479
   return false;
480 480
 }
@@ -486,27 +486,27 @@  discard block
 block discarded – undo
486 486
  * @return boolean
487 487
  */
488 488
   public function SetFrom($address, $name = '',$auto=1) {
489
-    $address = trim($address);
490
-    $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
491
-    if (!self::ValidateAddress($address)) {
492
-      $this->SetError($this->Lang('invalid_address').': '. $address);
493
-      if ($this->exceptions) {
494
-        throw new phpmailerException($this->Lang('invalid_address').': '.$address);
495
-      }
496
-      echo $this->Lang('invalid_address').': '.$address;
497
-      return false;
498
-    }
499
-    $this->From = $address;
500
-    $this->FromName = $name;
501
-    if ($auto) {
502
-      if (empty($this->ReplyTo)) {
503
-        $this->AddAnAddress('ReplyTo', $address, $name);
504
-      }
505
-      if (empty($this->Sender)) {
506
-        $this->Sender = $address;
507
-      }
508
-    }
509
-    return true;
489
+	$address = trim($address);
490
+	$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
491
+	if (!self::ValidateAddress($address)) {
492
+	  $this->SetError($this->Lang('invalid_address').': '. $address);
493
+	  if ($this->exceptions) {
494
+		throw new phpmailerException($this->Lang('invalid_address').': '.$address);
495
+	  }
496
+	  echo $this->Lang('invalid_address').': '.$address;
497
+	  return false;
498
+	}
499
+	$this->From = $address;
500
+	$this->FromName = $name;
501
+	if ($auto) {
502
+	  if (empty($this->ReplyTo)) {
503
+		$this->AddAnAddress('ReplyTo', $address, $name);
504
+	  }
505
+	  if (empty($this->Sender)) {
506
+		$this->Sender = $address;
507
+	  }
508
+	}
509
+	return true;
510 510
   }
511 511
 
512 512
   /**
@@ -521,15 +521,15 @@  discard block
 block discarded – undo
521 521
    * @access public
522 522
    */
523 523
   public static function ValidateAddress($address) {
524
-    if (function_exists('filter_var')) { //Introduced in PHP 5.2
525
-      if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
526
-        return false;
527
-      } else {
528
-        return true;
529
-      }
530
-    } else {
531
-      return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
532
-    }
524
+	if (function_exists('filter_var')) { //Introduced in PHP 5.2
525
+	  if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
526
+		return false;
527
+	  } else {
528
+		return true;
529
+	  }
530
+	} else {
531
+	  return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
532
+	}
533 533
   }
534 534
 
535 535
   /////////////////////////////////////////////////
@@ -543,49 +543,49 @@  discard block
 block discarded – undo
543 543
    * @return bool
544 544
    */
545 545
   public function Send() {
546
-    try {
547
-    if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
548
-        throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL);
549
-    }
550
-
551
-      // Set whether the message is multipart/alternative
552
-    if(!empty($this->AltBody)) {
553
-      $this->ContentType = 'multipart/alternative';
554
-    }
555
-
556
-    $this->error_count = 0; // reset errors
557
-    $this->SetMessageType();
558
-      $header = $this->CreateHeader();
559
-    $body = $this->CreateBody();
560
-
561
-      if (empty($this->Body)) {
562
-        throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL);
563
-      }
564
-
565
-      // digitally sign with DKIM if enabled
566
-      if ($this->DKIM_domain && $this->DKIM_private) {
567
-        $header_dkim = $this->DKIM_Add($header,$this->Subject,$body);
568
-        $header = str_replace("\r\n","\n",$header_dkim) . $header;
569
-    }
570
-
571
-      // Choose the mailer and send through it
572
-    switch($this->Mailer) {
573
-      case 'sendmail':
574
-          return $this->SendmailSend($header, $body);
575
-      case 'smtp':
576
-          return $this->SmtpSend($header, $body);
577
-      default:
578
-          return $this->MailSend($header, $body);
579
-    }
580
-
581
-    } catch (phpmailerException $e) {
582
-      $this->SetError($e->getMessage());
583
-      if ($this->exceptions) {
584
-        throw $e;
585
-      }
586
-      echo $e->getMessage()."\n";
587
-      return false;
588
-    }
546
+	try {
547
+	if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
548
+		throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL);
549
+	}
550
+
551
+	  // Set whether the message is multipart/alternative
552
+	if(!empty($this->AltBody)) {
553
+	  $this->ContentType = 'multipart/alternative';
554
+	}
555
+
556
+	$this->error_count = 0; // reset errors
557
+	$this->SetMessageType();
558
+	  $header = $this->CreateHeader();
559
+	$body = $this->CreateBody();
560
+
561
+	  if (empty($this->Body)) {
562
+		throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL);
563
+	  }
564
+
565
+	  // digitally sign with DKIM if enabled
566
+	  if ($this->DKIM_domain && $this->DKIM_private) {
567
+		$header_dkim = $this->DKIM_Add($header,$this->Subject,$body);
568
+		$header = str_replace("\r\n","\n",$header_dkim) . $header;
569
+	}
570
+
571
+	  // Choose the mailer and send through it
572
+	switch($this->Mailer) {
573
+	  case 'sendmail':
574
+		  return $this->SendmailSend($header, $body);
575
+	  case 'smtp':
576
+		  return $this->SmtpSend($header, $body);
577
+	  default:
578
+		  return $this->MailSend($header, $body);
579
+	}
580
+
581
+	} catch (phpmailerException $e) {
582
+	  $this->SetError($e->getMessage());
583
+	  if ($this->exceptions) {
584
+		throw $e;
585
+	  }
586
+	  echo $e->getMessage()."\n";
587
+	  return false;
588
+	}
589 589
   }
590 590
 
591 591
   /**
@@ -596,42 +596,42 @@  discard block
 block discarded – undo
596 596
    * @return bool
597 597
    */
598 598
   protected function SendmailSend($header, $body) {
599
-    if ($this->Sender != '') {
600
-      $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
601
-    } else {
602
-      $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
603
-    }
604
-    if ($this->SingleTo === true) {
605
-      foreach ($this->SingleToArray as $key => $val) {
606
-    if(!@$mail = popen($sendmail, 'w')) {
607
-          throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
608
-    }
609
-        fputs($mail, "To: " . $val . "\n");
610
-    fputs($mail, $header);
611
-    fputs($mail, $body);
612
-    $result = pclose($mail);
613
-        // implement call back function if it exists
614
-        $isSent = ($result == 0) ? 1 : 0;
615
-        $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
616
-        if($result != 0) {
617
-          throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
618
-        }
619
-      }
620
-    } else {
621
-      if(!@$mail = popen($sendmail, 'w')) {
622
-        throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
623
-    }
624
-      fputs($mail, $header);
625
-      fputs($mail, $body);
626
-      $result = pclose($mail);
627
-      // implement call back function if it exists
628
-      $isSent = ($result == 0) ? 1 : 0;
629
-      $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
630
-    if($result != 0) {
631
-        throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
632
-      }
633
-    }
634
-    return true;
599
+	if ($this->Sender != '') {
600
+	  $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
601
+	} else {
602
+	  $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
603
+	}
604
+	if ($this->SingleTo === true) {
605
+	  foreach ($this->SingleToArray as $key => $val) {
606
+	if(!@$mail = popen($sendmail, 'w')) {
607
+		  throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
608
+	}
609
+		fputs($mail, "To: " . $val . "\n");
610
+	fputs($mail, $header);
611
+	fputs($mail, $body);
612
+	$result = pclose($mail);
613
+		// implement call back function if it exists
614
+		$isSent = ($result == 0) ? 1 : 0;
615
+		$this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
616
+		if($result != 0) {
617
+		  throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
618
+		}
619
+	  }
620
+	} else {
621
+	  if(!@$mail = popen($sendmail, 'w')) {
622
+		throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
623
+	}
624
+	  fputs($mail, $header);
625
+	  fputs($mail, $body);
626
+	  $result = pclose($mail);
627
+	  // implement call back function if it exists
628
+	  $isSent = ($result == 0) ? 1 : 0;
629
+	  $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
630
+	if($result != 0) {
631
+		throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
632
+	  }
633
+	}
634
+	return true;
635 635
   }
636 636
 
637 637
   /**
@@ -642,51 +642,51 @@  discard block
 block discarded – undo
642 642
    * @return bool
643 643
    */
644 644
   protected function MailSend($header, $body) {
645
-    $toArr = array();
646
-    foreach($this->to as $t) {
647
-      $toArr[] = $this->AddrFormat($t);
648
-    }
649
-    $to = implode(', ', $toArr);
650
-
651
-    $params = sprintf("-oi -f %s", $this->Sender);
652
-    if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) {
653
-      $old_from = ini_get('sendmail_from');
654
-      ini_set('sendmail_from', $this->Sender);
655
-      if ($this->SingleTo === true && count($toArr) > 1) {
656
-        foreach ($toArr as $key => $val) {
657
-          $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
658
-          // implement call back function if it exists
659
-          $isSent = ($rt == 1) ? 1 : 0;
660
-          $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
661
-        }
662
-      } else {
663
-        $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
664
-        // implement call back function if it exists
665
-        $isSent = ($rt == 1) ? 1 : 0;
666
-        $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
667
-      }
668
-    } else {
669
-      if ($this->SingleTo === true && count($toArr) > 1) {
670
-        foreach ($toArr as $key => $val) {
671
-          $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
672
-          // implement call back function if it exists
673
-          $isSent = ($rt == 1) ? 1 : 0;
674
-          $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
675
-        }
676
-      } else {
677
-        $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
678
-        // implement call back function if it exists
679
-        $isSent = ($rt == 1) ? 1 : 0;
680
-        $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
681
-      }
682
-    }
683
-    if (isset($old_from)) {
684
-      ini_set('sendmail_from', $old_from);
685
-    }
686
-    if(!$rt) {
687
-      throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
688
-    }
689
-    return true;
645
+	$toArr = array();
646
+	foreach($this->to as $t) {
647
+	  $toArr[] = $this->AddrFormat($t);
648
+	}
649
+	$to = implode(', ', $toArr);
650
+
651
+	$params = sprintf("-oi -f %s", $this->Sender);
652
+	if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) {
653
+	  $old_from = ini_get('sendmail_from');
654
+	  ini_set('sendmail_from', $this->Sender);
655
+	  if ($this->SingleTo === true && count($toArr) > 1) {
656
+		foreach ($toArr as $key => $val) {
657
+		  $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
658
+		  // implement call back function if it exists
659
+		  $isSent = ($rt == 1) ? 1 : 0;
660
+		  $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
661
+		}
662
+	  } else {
663
+		$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
664
+		// implement call back function if it exists
665
+		$isSent = ($rt == 1) ? 1 : 0;
666
+		$this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
667
+	  }
668
+	} else {
669
+	  if ($this->SingleTo === true && count($toArr) > 1) {
670
+		foreach ($toArr as $key => $val) {
671
+		  $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
672
+		  // implement call back function if it exists
673
+		  $isSent = ($rt == 1) ? 1 : 0;
674
+		  $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
675
+		}
676
+	  } else {
677
+		$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
678
+		// implement call back function if it exists
679
+		$isSent = ($rt == 1) ? 1 : 0;
680
+		$this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
681
+	  }
682
+	}
683
+	if (isset($old_from)) {
684
+	  ini_set('sendmail_from', $old_from);
685
+	}
686
+	if(!$rt) {
687
+	  throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
688
+	}
689
+	return true;
690 690
   }
691 691
 
692 692
   /**
@@ -699,67 +699,67 @@  discard block
 block discarded – undo
699 699
    * @return bool
700 700
    */
701 701
   protected function SmtpSend($header, $body) {
702
-    require_once $this->PluginDir . 'smtp.php';
703
-    $bad_rcpt = array();
704
-
705
-    if(!$this->SmtpConnect()) {
706
-      throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
707
-    }
708
-    $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
709
-    if(!$this->smtp->Mail($smtp_from)) {
710
-      throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
711
-    }
712
-
713
-    // Attempt to send attach all recipients
714
-    foreach($this->to as $to) {
715
-      if (!$this->smtp->Recipient($to[0])) {
716
-        $bad_rcpt[] = $to[0];
717
-        // implement call back function if it exists
718
-        $isSent = 0;
719
-        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
720
-      } else {
721
-        // implement call back function if it exists
722
-        $isSent = 1;
723
-        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
724
-      }
725
-    }
726
-    foreach($this->cc as $cc) {
727
-      if (!$this->smtp->Recipient($cc[0])) {
728
-        $bad_rcpt[] = $cc[0];
729
-        // implement call back function if it exists
730
-        $isSent = 0;
731
-        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
732
-      } else {
733
-        // implement call back function if it exists
734
-        $isSent = 1;
735
-        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
736
-      }
737
-    }
738
-    foreach($this->bcc as $bcc) {
739
-      if (!$this->smtp->Recipient($bcc[0])) {
740
-        $bad_rcpt[] = $bcc[0];
741
-        // implement call back function if it exists
742
-        $isSent = 0;
743
-        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
744
-      } else {
745
-        // implement call back function if it exists
746
-        $isSent = 1;
747
-        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
748
-      }
749
-    }
750
-
751
-
752
-    if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
753
-      $badaddresses = implode(', ', $bad_rcpt);
754
-      throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
755
-    }
756
-    if(!$this->smtp->Data($header . $body)) {
757
-      throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
758
-    }
759
-    if($this->SMTPKeepAlive == true) {
760
-      $this->smtp->Reset();
761
-    }
762
-    return true;
702
+	require_once $this->PluginDir . 'smtp.php';
703
+	$bad_rcpt = array();
704
+
705
+	if(!$this->SmtpConnect()) {
706
+	  throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
707
+	}
708
+	$smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
709
+	if(!$this->smtp->Mail($smtp_from)) {
710
+	  throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
711
+	}
712
+
713
+	// Attempt to send attach all recipients
714
+	foreach($this->to as $to) {
715
+	  if (!$this->smtp->Recipient($to[0])) {
716
+		$bad_rcpt[] = $to[0];
717
+		// implement call back function if it exists
718
+		$isSent = 0;
719
+		$this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
720
+	  } else {
721
+		// implement call back function if it exists
722
+		$isSent = 1;
723
+		$this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
724
+	  }
725
+	}
726
+	foreach($this->cc as $cc) {
727
+	  if (!$this->smtp->Recipient($cc[0])) {
728
+		$bad_rcpt[] = $cc[0];
729
+		// implement call back function if it exists
730
+		$isSent = 0;
731
+		$this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
732
+	  } else {
733
+		// implement call back function if it exists
734
+		$isSent = 1;
735
+		$this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
736
+	  }
737
+	}
738
+	foreach($this->bcc as $bcc) {
739
+	  if (!$this->smtp->Recipient($bcc[0])) {
740
+		$bad_rcpt[] = $bcc[0];
741
+		// implement call back function if it exists
742
+		$isSent = 0;
743
+		$this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
744
+	  } else {
745
+		// implement call back function if it exists
746
+		$isSent = 1;
747
+		$this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
748
+	  }
749
+	}
750
+
751
+
752
+	if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
753
+	  $badaddresses = implode(', ', $bad_rcpt);
754
+	  throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
755
+	}
756
+	if(!$this->smtp->Data($header . $body)) {
757
+	  throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
758
+	}
759
+	if($this->SMTPKeepAlive == true) {
760
+	  $this->smtp->Reset();
761
+	}
762
+	return true;
763 763
   }
764 764
 
765 765
   /**
@@ -770,61 +770,61 @@  discard block
 block discarded – undo
770 770
    * @return bool
771 771
    */
772 772
   public function SmtpConnect() {
773
-    if(is_null($this->smtp)) {
774
-      $this->smtp = new SMTP();
775
-    }
776
-
777
-    $this->smtp->do_debug = $this->SMTPDebug;
778
-    $hosts = explode(';', $this->Host);
779
-    $index = 0;
780
-    $connection = $this->smtp->Connected();
781
-
782
-    // Retry while there is no connection
783
-    try {
784
-      while($index < count($hosts) && !$connection) {
785
-      $hostinfo = array();
786
-        if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) {
787
-        $host = $hostinfo[1];
788
-        $port = $hostinfo[2];
789
-      } else {
790
-        $host = $hosts[$index];
791
-        $port = $this->Port;
792
-      }
793
-
794
-      $tls = ($this->SMTPSecure == 'tls');
795
-      $ssl = ($this->SMTPSecure == 'ssl');
796
-
797
-      if($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) {
798
-
799
-        $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname());
800
-        $this->smtp->Hello($hello);
801
-
802
-        if($tls) {
803
-          if(!$this->smtp->StartTLS()) {
804
-              throw new phpmailerException($this->Lang('tls'));
805
-          }
806
-
807
-            //We must resend HELO after tls negotiation
808
-          $this->smtp->Hello($hello);
809
-        }
810
-
811
-        $connection = true;
812
-        if($this->SMTPAuth) {
813
-          if(!$this->smtp->Authenticate($this->Username, $this->Password)) {
814
-              throw new phpmailerException($this->Lang('authenticate'));
815
-          }
816
-        }
817
-      }
818
-      $index++;
819
-    if(!$connection) {
820
-          throw new phpmailerException($this->Lang('connect_host'));
821
-    }
822
-      }
823
-    } catch (phpmailerException $e) {
824
-      $this->smtp->Reset();
825
-      throw $e;
826
-    }
827
-    return true;
773
+	if(is_null($this->smtp)) {
774
+	  $this->smtp = new SMTP();
775
+	}
776
+
777
+	$this->smtp->do_debug = $this->SMTPDebug;
778
+	$hosts = explode(';', $this->Host);
779
+	$index = 0;
780
+	$connection = $this->smtp->Connected();
781
+
782
+	// Retry while there is no connection
783
+	try {
784
+	  while($index < count($hosts) && !$connection) {
785
+	  $hostinfo = array();
786
+		if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) {
787
+		$host = $hostinfo[1];
788
+		$port = $hostinfo[2];
789
+	  } else {
790
+		$host = $hosts[$index];
791
+		$port = $this->Port;
792
+	  }
793
+
794
+	  $tls = ($this->SMTPSecure == 'tls');
795
+	  $ssl = ($this->SMTPSecure == 'ssl');
796
+
797
+	  if($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) {
798
+
799
+		$hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname());
800
+		$this->smtp->Hello($hello);
801
+
802
+		if($tls) {
803
+		  if(!$this->smtp->StartTLS()) {
804
+			  throw new phpmailerException($this->Lang('tls'));
805
+		  }
806
+
807
+			//We must resend HELO after tls negotiation
808
+		  $this->smtp->Hello($hello);
809
+		}
810
+
811
+		$connection = true;
812
+		if($this->SMTPAuth) {
813
+		  if(!$this->smtp->Authenticate($this->Username, $this->Password)) {
814
+			  throw new phpmailerException($this->Lang('authenticate'));
815
+		  }
816
+		}
817
+	  }
818
+	  $index++;
819
+	if(!$connection) {
820
+		  throw new phpmailerException($this->Lang('connect_host'));
821
+	}
822
+	  }
823
+	} catch (phpmailerException $e) {
824
+	  $this->smtp->Reset();
825
+	  throw $e;
826
+	}
827
+	return true;
828 828
   }
829 829
 
830 830
   /**
@@ -832,57 +832,57 @@  discard block
 block discarded – undo
832 832
    * @return void
833 833
    */
834 834
   public function SmtpClose() {
835
-    if(!is_null($this->smtp)) {
836
-      if($this->smtp->Connected()) {
837
-        $this->smtp->Quit();
838
-        $this->smtp->Close();
839
-      }
840
-    }
835
+	if(!is_null($this->smtp)) {
836
+	  if($this->smtp->Connected()) {
837
+		$this->smtp->Quit();
838
+		$this->smtp->Close();
839
+	  }
840
+	}
841 841
   }
842 842
 
843 843
   /**
844
-  * Sets the language for all class error messages.
845
-  * Returns false if it cannot load the language file.  The default language is English.
846
-  * @param string $langcode ISO 639-1 2-character language code (e.g. Portuguese: "br")
844
+   * Sets the language for all class error messages.
845
+   * Returns false if it cannot load the language file.  The default language is English.
846
+   * @param string $langcode ISO 639-1 2-character language code (e.g. Portuguese: "br")
847 847
    * @param string $lang_path Path to the language file directory
848 848
    * @access public
849 849
    */
850 850
   function SetLanguage($langcode = 'en', $lang_path = 'language/') {
851
-    //Define full set of translatable strings
852
-    $PHPMAILER_LANG = array(
853
-      'provide_address' => 'You must provide at least one recipient email address.',
854
-      'mailer_not_supported' => ' mailer is not supported.',
855
-      'execute' => 'Could not execute: ',
856
-      'instantiate' => 'Could not instantiate mail function.',
857
-      'authenticate' => 'SMTP Error: Could not authenticate.',
858
-      'from_failed' => 'The following From address failed: ',
859
-      'recipients_failed' => 'SMTP Error: The following recipients failed: ',
860
-      'data_not_accepted' => 'SMTP Error: Data not accepted.',
861
-      'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
862
-      'file_access' => 'Could not access file: ',
863
-      'file_open' => 'File Error: Could not open file: ',
864
-      'encoding' => 'Unknown encoding: ',
865
-      'signing' => 'Signing Error: ',
866
-      'smtp_error' => 'SMTP server error: ',
867
-      'empty_message' => 'Message body empty',
868
-      'invalid_address' => 'Invalid address',
869
-      'variable_set' => 'Cannot set or reset variable: '
870
-    );
871
-    //Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"!
872
-    $l = true;
873
-    if ($langcode != 'en') { //There is no English translation file
874
-      $l = @include $lang_path.'phpmailer.lang-'.$langcode.'.php';
875
-    }
876
-    $this->language = $PHPMAILER_LANG;
877
-    return ($l == true); //Returns false if language not found
878
-  }
879
-
880
-  /**
881
-  * Return the current array of language strings
882
-  * @return array
883
-  */
851
+	//Define full set of translatable strings
852
+	$PHPMAILER_LANG = array(
853
+	  'provide_address' => 'You must provide at least one recipient email address.',
854
+	  'mailer_not_supported' => ' mailer is not supported.',
855
+	  'execute' => 'Could not execute: ',
856
+	  'instantiate' => 'Could not instantiate mail function.',
857
+	  'authenticate' => 'SMTP Error: Could not authenticate.',
858
+	  'from_failed' => 'The following From address failed: ',
859
+	  'recipients_failed' => 'SMTP Error: The following recipients failed: ',
860
+	  'data_not_accepted' => 'SMTP Error: Data not accepted.',
861
+	  'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
862
+	  'file_access' => 'Could not access file: ',
863
+	  'file_open' => 'File Error: Could not open file: ',
864
+	  'encoding' => 'Unknown encoding: ',
865
+	  'signing' => 'Signing Error: ',
866
+	  'smtp_error' => 'SMTP server error: ',
867
+	  'empty_message' => 'Message body empty',
868
+	  'invalid_address' => 'Invalid address',
869
+	  'variable_set' => 'Cannot set or reset variable: '
870
+	);
871
+	//Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"!
872
+	$l = true;
873
+	if ($langcode != 'en') { //There is no English translation file
874
+	  $l = @include $lang_path.'phpmailer.lang-'.$langcode.'.php';
875
+	}
876
+	$this->language = $PHPMAILER_LANG;
877
+	return ($l == true); //Returns false if language not found
878
+  }
879
+
880
+  /**
881
+   * Return the current array of language strings
882
+   * @return array
883
+   */
884 884
   public function GetTranslations() {
885
-    return $this->language;
885
+	return $this->language;
886 886
   }
887 887
 
888 888
   /////////////////////////////////////////////////
@@ -895,15 +895,15 @@  discard block
 block discarded – undo
895 895
    * @return string
896 896
    */
897 897
   public function AddrAppend($type, $addr) {
898
-    $addr_str = $type . ': ';
899
-    $addresses = array();
900
-    foreach ($addr as $a) {
901
-      $addresses[] = $this->AddrFormat($a);
902
-    }
903
-    $addr_str .= implode(', ', $addresses);
904
-    $addr_str .= $this->LE;
898
+	$addr_str = $type . ': ';
899
+	$addresses = array();
900
+	foreach ($addr as $a) {
901
+	  $addresses[] = $this->AddrFormat($a);
902
+	}
903
+	$addr_str .= implode(', ', $addresses);
904
+	$addr_str .= $this->LE;
905 905
 
906
-    return $addr_str;
906
+	return $addr_str;
907 907
   }
908 908
 
909 909
   /**
@@ -912,11 +912,11 @@  discard block
 block discarded – undo
912 912
    * @return string
913 913
    */
914 914
   public function AddrFormat($addr) {
915
-    if(empty($addr[1])) {
916
-      return $this->SecureHeader($addr[0]);
917
-    } else {
918
-      return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
919
-    }
915
+	if(empty($addr[1])) {
916
+	  return $this->SecureHeader($addr[0]);
917
+	} else {
918
+	  return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
919
+	}
920 920
   }
921 921
 
922 922
   /**
@@ -930,76 +930,76 @@  discard block
 block discarded – undo
930 930
    * @return string
931 931
    */
932 932
   public function WrapText($message, $length, $qp_mode = false) {
933
-    $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
934
-    // If utf-8 encoding is used, we will need to make sure we don't
935
-    // split multibyte characters when we wrap
936
-    $is_utf8 = (strtolower($this->CharSet) == "utf-8");
937
-
938
-    $message = $this->FixEOL($message);
939
-    if (substr($message, -1) == $this->LE) {
940
-      $message = substr($message, 0, -1);
941
-    }
942
-
943
-    $line = explode($this->LE, $message);
944
-    $message = '';
945
-    for ($i=0 ;$i < count($line); $i++) {
946
-      $line_part = explode(' ', $line[$i]);
947
-      $buf = '';
948
-      for ($e = 0; $e<count($line_part); $e++) {
949
-        $word = $line_part[$e];
950
-        if ($qp_mode and (strlen($word) > $length)) {
951
-          $space_left = $length - strlen($buf) - 1;
952
-          if ($e != 0) {
953
-            if ($space_left > 20) {
954
-              $len = $space_left;
955
-              if ($is_utf8) {
956
-                $len = $this->UTF8CharBoundary($word, $len);
957
-              } elseif (substr($word, $len - 1, 1) == "=") {
958
-                $len--;
959
-              } elseif (substr($word, $len - 2, 1) == "=") {
960
-                $len -= 2;
961
-              }
962
-              $part = substr($word, 0, $len);
963
-              $word = substr($word, $len);
964
-              $buf .= ' ' . $part;
965
-              $message .= $buf . sprintf("=%s", $this->LE);
966
-            } else {
967
-              $message .= $buf . $soft_break;
968
-            }
969
-            $buf = '';
970
-          }
971
-          while (strlen($word) > 0) {
972
-            $len = $length;
973
-            if ($is_utf8) {
974
-              $len = $this->UTF8CharBoundary($word, $len);
975
-            } elseif (substr($word, $len - 1, 1) == "=") {
976
-              $len--;
977
-            } elseif (substr($word, $len - 2, 1) == "=") {
978
-              $len -= 2;
979
-            }
980
-            $part = substr($word, 0, $len);
981
-            $word = substr($word, $len);
982
-
983
-            if (strlen($word) > 0) {
984
-              $message .= $part . sprintf("=%s", $this->LE);
985
-            } else {
986
-              $buf = $part;
987
-            }
988
-          }
989
-        } else {
990
-          $buf_o = $buf;
991
-          $buf .= ($e == 0) ? $word : (' ' . $word);
992
-
993
-          if (strlen($buf) > $length and $buf_o != '') {
994
-            $message .= $buf_o . $soft_break;
995
-            $buf = $word;
996
-          }
997
-        }
998
-      }
999
-      $message .= $buf . $this->LE;
1000
-    }
1001
-
1002
-    return $message;
933
+	$soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
934
+	// If utf-8 encoding is used, we will need to make sure we don't
935
+	// split multibyte characters when we wrap
936
+	$is_utf8 = (strtolower($this->CharSet) == "utf-8");
937
+
938
+	$message = $this->FixEOL($message);
939
+	if (substr($message, -1) == $this->LE) {
940
+	  $message = substr($message, 0, -1);
941
+	}
942
+
943
+	$line = explode($this->LE, $message);
944
+	$message = '';
945
+	for ($i=0 ;$i < count($line); $i++) {
946
+	  $line_part = explode(' ', $line[$i]);
947
+	  $buf = '';
948
+	  for ($e = 0; $e<count($line_part); $e++) {
949
+		$word = $line_part[$e];
950
+		if ($qp_mode and (strlen($word) > $length)) {
951
+		  $space_left = $length - strlen($buf) - 1;
952
+		  if ($e != 0) {
953
+			if ($space_left > 20) {
954
+			  $len = $space_left;
955
+			  if ($is_utf8) {
956
+				$len = $this->UTF8CharBoundary($word, $len);
957
+			  } elseif (substr($word, $len - 1, 1) == "=") {
958
+				$len--;
959
+			  } elseif (substr($word, $len - 2, 1) == "=") {
960
+				$len -= 2;
961
+			  }
962
+			  $part = substr($word, 0, $len);
963
+			  $word = substr($word, $len);
964
+			  $buf .= ' ' . $part;
965
+			  $message .= $buf . sprintf("=%s", $this->LE);
966
+			} else {
967
+			  $message .= $buf . $soft_break;
968
+			}
969
+			$buf = '';
970
+		  }
971
+		  while (strlen($word) > 0) {
972
+			$len = $length;
973
+			if ($is_utf8) {
974
+			  $len = $this->UTF8CharBoundary($word, $len);
975
+			} elseif (substr($word, $len - 1, 1) == "=") {
976
+			  $len--;
977
+			} elseif (substr($word, $len - 2, 1) == "=") {
978
+			  $len -= 2;
979
+			}
980
+			$part = substr($word, 0, $len);
981
+			$word = substr($word, $len);
982
+
983
+			if (strlen($word) > 0) {
984
+			  $message .= $part . sprintf("=%s", $this->LE);
985
+			} else {
986
+			  $buf = $part;
987
+			}
988
+		  }
989
+		} else {
990
+		  $buf_o = $buf;
991
+		  $buf .= ($e == 0) ? $word : (' ' . $word);
992
+
993
+		  if (strlen($buf) > $length and $buf_o != '') {
994
+			$message .= $buf_o . $soft_break;
995
+			$buf = $word;
996
+		  }
997
+		}
998
+	  }
999
+	  $message .= $buf . $this->LE;
1000
+	}
1001
+
1002
+	return $message;
1003 1003
   }
1004 1004
 
1005 1005
   /**
@@ -1012,35 +1012,35 @@  discard block
 block discarded – undo
1012 1012
    * @return int
1013 1013
    */
1014 1014
   public function UTF8CharBoundary($encodedText, $maxLength) {
1015
-    $foundSplitPos = false;
1016
-    $lookBack = 3;
1017
-    while (!$foundSplitPos) {
1018
-      $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
1019
-      $encodedCharPos = strpos($lastChunk, "=");
1020
-      if ($encodedCharPos !== false) {
1021
-        // Found start of encoded character byte within $lookBack block.
1022
-        // Check the encoded byte value (the 2 chars after the '=')
1023
-        $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
1024
-        $dec = hexdec($hex);
1025
-        if ($dec < 128) { // Single byte character.
1026
-          // If the encoded char was found at pos 0, it will fit
1027
-          // otherwise reduce maxLength to start of the encoded char
1028
-          $maxLength = ($encodedCharPos == 0) ? $maxLength :
1029
-          $maxLength - ($lookBack - $encodedCharPos);
1030
-          $foundSplitPos = true;
1031
-        } elseif ($dec >= 192) { // First byte of a multi byte character
1032
-          // Reduce maxLength to split at start of character
1033
-          $maxLength = $maxLength - ($lookBack - $encodedCharPos);
1034
-          $foundSplitPos = true;
1035
-        } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
1036
-          $lookBack += 3;
1037
-        }
1038
-      } else {
1039
-        // No encoded character found
1040
-        $foundSplitPos = true;
1041
-      }
1042
-    }
1043
-    return $maxLength;
1015
+	$foundSplitPos = false;
1016
+	$lookBack = 3;
1017
+	while (!$foundSplitPos) {
1018
+	  $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
1019
+	  $encodedCharPos = strpos($lastChunk, "=");
1020
+	  if ($encodedCharPos !== false) {
1021
+		// Found start of encoded character byte within $lookBack block.
1022
+		// Check the encoded byte value (the 2 chars after the '=')
1023
+		$hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
1024
+		$dec = hexdec($hex);
1025
+		if ($dec < 128) { // Single byte character.
1026
+		  // If the encoded char was found at pos 0, it will fit
1027
+		  // otherwise reduce maxLength to start of the encoded char
1028
+		  $maxLength = ($encodedCharPos == 0) ? $maxLength :
1029
+		  $maxLength - ($lookBack - $encodedCharPos);
1030
+		  $foundSplitPos = true;
1031
+		} elseif ($dec >= 192) { // First byte of a multi byte character
1032
+		  // Reduce maxLength to split at start of character
1033
+		  $maxLength = $maxLength - ($lookBack - $encodedCharPos);
1034
+		  $foundSplitPos = true;
1035
+		} elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
1036
+		  $lookBack += 3;
1037
+		}
1038
+	  } else {
1039
+		// No encoded character found
1040
+		$foundSplitPos = true;
1041
+	  }
1042
+	}
1043
+	return $maxLength;
1044 1044
   }
1045 1045
 
1046 1046
 
@@ -1050,19 +1050,19 @@  discard block
 block discarded – undo
1050 1050
    * @return void
1051 1051
    */
1052 1052
   public function SetWordWrap() {
1053
-    if($this->WordWrap < 1) {
1054
-      return;
1055
-    }
1053
+	if($this->WordWrap < 1) {
1054
+	  return;
1055
+	}
1056 1056
 
1057
-    switch($this->message_type) {
1058
-      case 'alt':
1059
-      case 'alt_attachments':
1060
-        $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
1061
-        break;
1062
-      default:
1063
-        $this->Body = $this->WrapText($this->Body, $this->WordWrap);
1064
-        break;
1065
-    }
1057
+	switch($this->message_type) {
1058
+	  case 'alt':
1059
+	  case 'alt_attachments':
1060
+		$this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
1061
+		break;
1062
+	  default:
1063
+		$this->Body = $this->WrapText($this->Body, $this->WordWrap);
1064
+		break;
1065
+	}
1066 1066
   }
1067 1067
 
1068 1068
   /**
@@ -1071,81 +1071,81 @@  discard block
 block discarded – undo
1071 1071
    * @return string The assembled header
1072 1072
    */
1073 1073
   public function CreateHeader() {
1074
-    $result = '';
1075
-
1076
-    // Set the boundaries
1077
-    $uniq_id = md5(uniqid(time()));
1078
-    $this->boundary[1] = 'b1_' . $uniq_id;
1079
-    $this->boundary[2] = 'b2_' . $uniq_id;
1080
-
1081
-    $result .= $this->HeaderLine('Date', self::RFCDate());
1082
-    if($this->Sender == '') {
1083
-      $result .= $this->HeaderLine('Return-Path', trim($this->From));
1084
-    } else {
1085
-      $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
1086
-    }
1087
-
1088
-    // To be created automatically by mail()
1089
-    if($this->Mailer != 'mail') {
1090
-      if ($this->SingleTo === true) {
1091
-        foreach($this->to as $t) {
1092
-          $this->SingleToArray[] = $this->AddrFormat($t);
1093
-        }
1094
-      } else {
1095
-      if(count($this->to) > 0) {
1096
-        $result .= $this->AddrAppend('To', $this->to);
1097
-      } elseif (count($this->cc) == 0) {
1098
-        $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
1099
-      }
1100
-    }
1101
-    }
1102
-
1103
-    $from = array();
1104
-    $from[0][0] = trim($this->From);
1105
-    $from[0][1] = $this->FromName;
1106
-    $result .= $this->AddrAppend('From', $from);
1107
-
1108
-    // sendmail and mail() extract Cc from the header before sending
1109
-    if(count($this->cc) > 0) {
1110
-      $result .= $this->AddrAppend('Cc', $this->cc);
1111
-    }
1112
-
1113
-    // sendmail and mail() extract Bcc from the header before sending
1114
-    if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
1115
-      $result .= $this->AddrAppend('Bcc', $this->bcc);
1116
-    }
1117
-
1118
-    if(count($this->ReplyTo) > 0) {
1119
-      $result .= $this->AddrAppend('Reply-to', $this->ReplyTo);
1120
-    }
1121
-
1122
-    // mail() sets the subject itself
1123
-    if($this->Mailer != 'mail') {
1124
-      $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
1125
-    }
1126
-
1127
-    if($this->MessageID != '') {
1128
-      $result .= $this->HeaderLine('Message-ID',$this->MessageID);
1129
-    } else {
1130
-      $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
1131
-    }
1132
-    $result .= $this->HeaderLine('X-Priority', $this->Priority);
1133
-    $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)');
1134
-
1135
-    if($this->ConfirmReadingTo != '') {
1136
-      $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
1137
-    }
1138
-
1139
-    // Add custom headers
1140
-    for($index = 0; $index < count($this->CustomHeader); $index++) {
1141
-      $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
1142
-    }
1143
-    if (!$this->sign_key_file) {
1144
-      $result .= $this->HeaderLine('MIME-Version', '1.0');
1145
-      $result .= $this->GetMailMIME();
1146
-    }
1147
-
1148
-    return $result;
1074
+	$result = '';
1075
+
1076
+	// Set the boundaries
1077
+	$uniq_id = md5(uniqid(time()));
1078
+	$this->boundary[1] = 'b1_' . $uniq_id;
1079
+	$this->boundary[2] = 'b2_' . $uniq_id;
1080
+
1081
+	$result .= $this->HeaderLine('Date', self::RFCDate());
1082
+	if($this->Sender == '') {
1083
+	  $result .= $this->HeaderLine('Return-Path', trim($this->From));
1084
+	} else {
1085
+	  $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
1086
+	}
1087
+
1088
+	// To be created automatically by mail()
1089
+	if($this->Mailer != 'mail') {
1090
+	  if ($this->SingleTo === true) {
1091
+		foreach($this->to as $t) {
1092
+		  $this->SingleToArray[] = $this->AddrFormat($t);
1093
+		}
1094
+	  } else {
1095
+	  if(count($this->to) > 0) {
1096
+		$result .= $this->AddrAppend('To', $this->to);
1097
+	  } elseif (count($this->cc) == 0) {
1098
+		$result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
1099
+	  }
1100
+	}
1101
+	}
1102
+
1103
+	$from = array();
1104
+	$from[0][0] = trim($this->From);
1105
+	$from[0][1] = $this->FromName;
1106
+	$result .= $this->AddrAppend('From', $from);
1107
+
1108
+	// sendmail and mail() extract Cc from the header before sending
1109
+	if(count($this->cc) > 0) {
1110
+	  $result .= $this->AddrAppend('Cc', $this->cc);
1111
+	}
1112
+
1113
+	// sendmail and mail() extract Bcc from the header before sending
1114
+	if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
1115
+	  $result .= $this->AddrAppend('Bcc', $this->bcc);
1116
+	}
1117
+
1118
+	if(count($this->ReplyTo) > 0) {
1119
+	  $result .= $this->AddrAppend('Reply-to', $this->ReplyTo);
1120
+	}
1121
+
1122
+	// mail() sets the subject itself
1123
+	if($this->Mailer != 'mail') {
1124
+	  $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
1125
+	}
1126
+
1127
+	if($this->MessageID != '') {
1128
+	  $result .= $this->HeaderLine('Message-ID',$this->MessageID);
1129
+	} else {
1130
+	  $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
1131
+	}
1132
+	$result .= $this->HeaderLine('X-Priority', $this->Priority);
1133
+	$result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)');
1134
+
1135
+	if($this->ConfirmReadingTo != '') {
1136
+	  $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
1137
+	}
1138
+
1139
+	// Add custom headers
1140
+	for($index = 0; $index < count($this->CustomHeader); $index++) {
1141
+	  $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
1142
+	}
1143
+	if (!$this->sign_key_file) {
1144
+	  $result .= $this->HeaderLine('MIME-Version', '1.0');
1145
+	  $result .= $this->GetMailMIME();
1146
+	}
1147
+
1148
+	return $result;
1149 1149
   }
1150 1150
 
1151 1151
   /**
@@ -1154,32 +1154,32 @@  discard block
 block discarded – undo
1154 1154
    * @return string
1155 1155
    */
1156 1156
   public function GetMailMIME() {
1157
-    $result = '';
1158
-    switch($this->message_type) {
1159
-      case 'plain':
1160
-        $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
1161
-        $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
1162
-        break;
1163
-      case 'attachments':
1164
-      case 'alt_attachments':
1165
-        if($this->InlineImageExists()){
1166
-          $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
1167
-        } else {
1168
-          $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
1169
-          $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1170
-        }
1171
-        break;
1172
-      case 'alt':
1173
-        $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
1174
-        $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1175
-        break;
1176
-    }
1177
-
1178
-    if($this->Mailer != 'mail') {
1179
-      $result .= $this->LE.$this->LE;
1180
-    }
1181
-
1182
-    return $result;
1157
+	$result = '';
1158
+	switch($this->message_type) {
1159
+	  case 'plain':
1160
+		$result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
1161
+		$result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
1162
+		break;
1163
+	  case 'attachments':
1164
+	  case 'alt_attachments':
1165
+		if($this->InlineImageExists()){
1166
+		  $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
1167
+		} else {
1168
+		  $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
1169
+		  $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1170
+		}
1171
+		break;
1172
+	  case 'alt':
1173
+		$result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
1174
+		$result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1175
+		break;
1176
+	}
1177
+
1178
+	if($this->Mailer != 'mail') {
1179
+	  $result .= $this->LE.$this->LE;
1180
+	}
1181
+
1182
+	return $result;
1183 1183
   }
1184 1184
 
1185 1185
   /**
@@ -1188,72 +1188,72 @@  discard block
 block discarded – undo
1188 1188
    * @return string The assembled message body
1189 1189
    */
1190 1190
   public function CreateBody() {
1191
-    $body = '';
1192
-
1193
-    if ($this->sign_key_file) {
1194
-      $body .= $this->GetMailMIME();
1195
-    }
1196
-
1197
-    $this->SetWordWrap();
1198
-
1199
-    switch($this->message_type) {
1200
-      case 'alt':
1201
-        $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
1202
-        $body .= $this->EncodeString($this->AltBody, $this->Encoding);
1203
-        $body .= $this->LE.$this->LE;
1204
-        $body .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
1205
-        $body .= $this->EncodeString($this->Body, $this->Encoding);
1206
-        $body .= $this->LE.$this->LE;
1207
-        $body .= $this->EndBoundary($this->boundary[1]);
1208
-        break;
1209
-      case 'plain':
1210
-        $body .= $this->EncodeString($this->Body, $this->Encoding);
1211
-        break;
1212
-      case 'attachments':
1213
-        $body .= $this->GetBoundary($this->boundary[1], '', '', '');
1214
-        $body .= $this->EncodeString($this->Body, $this->Encoding);
1215
-        $body .= $this->LE;
1216
-        $body .= $this->AttachAll();
1217
-        break;
1218
-      case 'alt_attachments':
1219
-        $body .= sprintf("--%s%s", $this->boundary[1], $this->LE);
1220
-        $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
1221
-        $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
1222
-        $body .= $this->EncodeString($this->AltBody, $this->Encoding);
1223
-        $body .= $this->LE.$this->LE;
1224
-        $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
1225
-        $body .= $this->EncodeString($this->Body, $this->Encoding);
1226
-        $body .= $this->LE.$this->LE;
1227
-        $body .= $this->EndBoundary($this->boundary[2]);
1228
-        $body .= $this->AttachAll();
1229
-        break;
1230
-    }
1231
-
1232
-    if($this->IsError()) {
1233
-      $body = '';
1234
-    } else if ($this->sign_key_file) {
1235
-      try {
1236
-        $file = tempnam('', 'mail');
1237
-        file_put_contents($file, $body, LOCK_EX); //TODO check this worked
1238
-      $signed = tempnam("", "signed");
1239
-        if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) {
1240
-          @unlink($file);
1241
-          @unlink($signed);
1242
-          $body = file_get_contents($signed);
1243
-      } else {
1244
-          @unlink($file);
1245
-          @unlink($signed);
1246
-          throw new phpmailerException($this->Lang("signing").openssl_error_string());
1247
-        }
1248
-      } catch (phpmailerException $e) {
1249
-        $body = '';
1250
-        if ($this->exceptions) {
1251
-          throw $e;
1252
-        }
1253
-      }
1254
-    }
1255
-
1256
-    return $body;
1191
+	$body = '';
1192
+
1193
+	if ($this->sign_key_file) {
1194
+	  $body .= $this->GetMailMIME();
1195
+	}
1196
+
1197
+	$this->SetWordWrap();
1198
+
1199
+	switch($this->message_type) {
1200
+	  case 'alt':
1201
+		$body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
1202
+		$body .= $this->EncodeString($this->AltBody, $this->Encoding);
1203
+		$body .= $this->LE.$this->LE;
1204
+		$body .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
1205
+		$body .= $this->EncodeString($this->Body, $this->Encoding);
1206
+		$body .= $this->LE.$this->LE;
1207
+		$body .= $this->EndBoundary($this->boundary[1]);
1208
+		break;
1209
+	  case 'plain':
1210
+		$body .= $this->EncodeString($this->Body, $this->Encoding);
1211
+		break;
1212
+	  case 'attachments':
1213
+		$body .= $this->GetBoundary($this->boundary[1], '', '', '');
1214
+		$body .= $this->EncodeString($this->Body, $this->Encoding);
1215
+		$body .= $this->LE;
1216
+		$body .= $this->AttachAll();
1217
+		break;
1218
+	  case 'alt_attachments':
1219
+		$body .= sprintf("--%s%s", $this->boundary[1], $this->LE);
1220
+		$body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
1221
+		$body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
1222
+		$body .= $this->EncodeString($this->AltBody, $this->Encoding);
1223
+		$body .= $this->LE.$this->LE;
1224
+		$body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
1225
+		$body .= $this->EncodeString($this->Body, $this->Encoding);
1226
+		$body .= $this->LE.$this->LE;
1227
+		$body .= $this->EndBoundary($this->boundary[2]);
1228
+		$body .= $this->AttachAll();
1229
+		break;
1230
+	}
1231
+
1232
+	if($this->IsError()) {
1233
+	  $body = '';
1234
+	} else if ($this->sign_key_file) {
1235
+	  try {
1236
+		$file = tempnam('', 'mail');
1237
+		file_put_contents($file, $body, LOCK_EX); //TODO check this worked
1238
+	  $signed = tempnam("", "signed");
1239
+		if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) {
1240
+		  @unlink($file);
1241
+		  @unlink($signed);
1242
+		  $body = file_get_contents($signed);
1243
+	  } else {
1244
+		  @unlink($file);
1245
+		  @unlink($signed);
1246
+		  throw new phpmailerException($this->Lang("signing").openssl_error_string());
1247
+		}
1248
+	  } catch (phpmailerException $e) {
1249
+		$body = '';
1250
+		if ($this->exceptions) {
1251
+		  throw $e;
1252
+		}
1253
+	  }
1254
+	}
1255
+
1256
+	return $body;
1257 1257
   }
1258 1258
 
1259 1259
   /**
@@ -1261,23 +1261,23 @@  discard block
 block discarded – undo
1261 1261
    * @access private
1262 1262
    */
1263 1263
   private function GetBoundary($boundary, $charSet, $contentType, $encoding) {
1264
-    $result = '';
1265
-    if($charSet == '') {
1266
-      $charSet = $this->CharSet;
1267
-    }
1268
-    if($contentType == '') {
1269
-      $contentType = $this->ContentType;
1270
-    }
1271
-    if($encoding == '') {
1272
-      $encoding = $this->Encoding;
1273
-    }
1274
-    $result .= $this->TextLine('--' . $boundary);
1275
-    $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
1276
-    $result .= $this->LE;
1277
-    $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
1278
-    $result .= $this->LE;
1279
-
1280
-    return $result;
1264
+	$result = '';
1265
+	if($charSet == '') {
1266
+	  $charSet = $this->CharSet;
1267
+	}
1268
+	if($contentType == '') {
1269
+	  $contentType = $this->ContentType;
1270
+	}
1271
+	if($encoding == '') {
1272
+	  $encoding = $this->Encoding;
1273
+	}
1274
+	$result .= $this->TextLine('--' . $boundary);
1275
+	$result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
1276
+	$result .= $this->LE;
1277
+	$result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
1278
+	$result .= $this->LE;
1279
+
1280
+	return $result;
1281 1281
   }
1282 1282
 
1283 1283
   /**
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
    * @access private
1286 1286
    */
1287 1287
   private function EndBoundary($boundary) {
1288
-    return $this->LE . '--' . $boundary . '--' . $this->LE;
1288
+	return $this->LE . '--' . $boundary . '--' . $this->LE;
1289 1289
   }
1290 1290
 
1291 1291
   /**
@@ -1294,19 +1294,19 @@  discard block
 block discarded – undo
1294 1294
    * @return void
1295 1295
    */
1296 1296
   private function SetMessageType() {
1297
-    if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
1298
-      $this->message_type = 'plain';
1299
-    } else {
1300
-      if(count($this->attachment) > 0) {
1301
-        $this->message_type = 'attachments';
1302
-      }
1303
-      if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
1304
-        $this->message_type = 'alt';
1305
-      }
1306
-      if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
1307
-        $this->message_type = 'alt_attachments';
1308
-      }
1309
-    }
1297
+	if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
1298
+	  $this->message_type = 'plain';
1299
+	} else {
1300
+	  if(count($this->attachment) > 0) {
1301
+		$this->message_type = 'attachments';
1302
+	  }
1303
+	  if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
1304
+		$this->message_type = 'alt';
1305
+	  }
1306
+	  if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
1307
+		$this->message_type = 'alt_attachments';
1308
+	  }
1309
+	}
1310 1310
   }
1311 1311
 
1312 1312
   /**
@@ -1315,7 +1315,7 @@  discard block
 block discarded – undo
1315 1315
    * @return string
1316 1316
    */
1317 1317
   public function HeaderLine($name, $value) {
1318
-    return $name . ': ' . $value . $this->LE;
1318
+	return $name . ': ' . $value . $this->LE;
1319 1319
   }
1320 1320
 
1321 1321
   /**
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
    * @return string
1325 1325
    */
1326 1326
   public function TextLine($value) {
1327
-    return $value . $this->LE;
1327
+	return $value . $this->LE;
1328 1328
   }
1329 1329
 
1330 1330
   /////////////////////////////////////////////////
@@ -1342,45 +1342,45 @@  discard block
 block discarded – undo
1342 1342
    * @return bool
1343 1343
    */
1344 1344
   public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1345
-    try {
1346
-    if(!@is_file($path)) {
1347
-        throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
1348
-    }
1349
-    $filename = basename($path);
1350
-    if($name == '') {
1351
-      $name = $filename;
1352
-    }
1353
-
1354
-      $this->attachment[] = array(
1355
-        0 => $path,
1356
-        1 => $filename,
1357
-        2 => $name,
1358
-        3 => $encoding,
1359
-        4 => $type,
1360
-        5 => false,  // isStringAttachment
1361
-        6 => 'attachment',
1362
-        7 => 0
1363
-      );
1364
-
1365
-    } catch (phpmailerException $e) {
1366
-      $this->SetError($e->getMessage());
1367
-      if ($this->exceptions) {
1368
-        throw $e;
1369
-      }
1370
-      echo $e->getMessage()."\n";
1371
-      if ( $e->getCode() == self::STOP_CRITICAL ) {
1372
-        return false;
1373
-      }
1374
-    }
1375
-    return true;
1376
-  }
1377
-
1378
-  /**
1379
-  * Return the current array of attachments
1380
-  * @return array
1381
-  */
1345
+	try {
1346
+	if(!@is_file($path)) {
1347
+		throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
1348
+	}
1349
+	$filename = basename($path);
1350
+	if($name == '') {
1351
+	  $name = $filename;
1352
+	}
1353
+
1354
+	  $this->attachment[] = array(
1355
+		0 => $path,
1356
+		1 => $filename,
1357
+		2 => $name,
1358
+		3 => $encoding,
1359
+		4 => $type,
1360
+		5 => false,  // isStringAttachment
1361
+		6 => 'attachment',
1362
+		7 => 0
1363
+	  );
1364
+
1365
+	} catch (phpmailerException $e) {
1366
+	  $this->SetError($e->getMessage());
1367
+	  if ($this->exceptions) {
1368
+		throw $e;
1369
+	  }
1370
+	  echo $e->getMessage()."\n";
1371
+	  if ( $e->getCode() == self::STOP_CRITICAL ) {
1372
+		return false;
1373
+	  }
1374
+	}
1375
+	return true;
1376
+  }
1377
+
1378
+  /**
1379
+   * Return the current array of attachments
1380
+   * @return array
1381
+   */
1382 1382
   public function GetAttachments() {
1383
-    return $this->attachment;
1383
+	return $this->attachment;
1384 1384
   }
1385 1385
 
1386 1386
   /**
@@ -1390,61 +1390,61 @@  discard block
 block discarded – undo
1390 1390
    * @return string
1391 1391
    */
1392 1392
   private function AttachAll() {
1393
-    // Return text of body
1394
-    $mime = array();
1395
-    $cidUniq = array();
1396
-    $incl = array();
1397
-
1398
-    // Add all attachments
1399
-    foreach ($this->attachment as $attachment) {
1400
-      // Check for string attachment
1401
-      $bString = $attachment[5];
1402
-      if ($bString) {
1403
-        $string = $attachment[0];
1404
-      } else {
1405
-        $path = $attachment[0];
1406
-      }
1407
-
1408
-      if (in_array($attachment[0], $incl)) { continue; }
1409
-      $filename    = $attachment[1];
1410
-      $name        = $attachment[2];
1411
-      $encoding    = $attachment[3];
1412
-      $type        = $attachment[4];
1413
-      $disposition = $attachment[6];
1414
-      $cid         = $attachment[7];
1415
-      $incl[]      = $attachment[0];
1416
-      if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; }
1417
-      $cidUniq[$cid] = true;
1418
-
1419
-      $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
1420
-      $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE);
1421
-      $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
1422
-
1423
-      if($disposition == 'inline') {
1424
-        $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
1425
-      }
1426
-
1427
-      $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE);
1428
-
1429
-      // Encode as string attachment
1430
-      if($bString) {
1431
-        $mime[] = $this->EncodeString($string, $encoding);
1432
-        if($this->IsError()) {
1433
-          return '';
1434
-        }
1435
-        $mime[] = $this->LE.$this->LE;
1436
-      } else {
1437
-        $mime[] = $this->EncodeFile($path, $encoding);
1438
-        if($this->IsError()) {
1439
-          return '';
1440
-        }
1441
-        $mime[] = $this->LE.$this->LE;
1442
-      }
1443
-    }
1444
-
1445
-    $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
1446
-
1447
-    return join('', $mime);
1393
+	// Return text of body
1394
+	$mime = array();
1395
+	$cidUniq = array();
1396
+	$incl = array();
1397
+
1398
+	// Add all attachments
1399
+	foreach ($this->attachment as $attachment) {
1400
+	  // Check for string attachment
1401
+	  $bString = $attachment[5];
1402
+	  if ($bString) {
1403
+		$string = $attachment[0];
1404
+	  } else {
1405
+		$path = $attachment[0];
1406
+	  }
1407
+
1408
+	  if (in_array($attachment[0], $incl)) { continue; }
1409
+	  $filename    = $attachment[1];
1410
+	  $name        = $attachment[2];
1411
+	  $encoding    = $attachment[3];
1412
+	  $type        = $attachment[4];
1413
+	  $disposition = $attachment[6];
1414
+	  $cid         = $attachment[7];
1415
+	  $incl[]      = $attachment[0];
1416
+	  if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; }
1417
+	  $cidUniq[$cid] = true;
1418
+
1419
+	  $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
1420
+	  $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE);
1421
+	  $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
1422
+
1423
+	  if($disposition == 'inline') {
1424
+		$mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
1425
+	  }
1426
+
1427
+	  $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE);
1428
+
1429
+	  // Encode as string attachment
1430
+	  if($bString) {
1431
+		$mime[] = $this->EncodeString($string, $encoding);
1432
+		if($this->IsError()) {
1433
+		  return '';
1434
+		}
1435
+		$mime[] = $this->LE.$this->LE;
1436
+	  } else {
1437
+		$mime[] = $this->EncodeFile($path, $encoding);
1438
+		if($this->IsError()) {
1439
+		  return '';
1440
+		}
1441
+		$mime[] = $this->LE.$this->LE;
1442
+	  }
1443
+	}
1444
+
1445
+	$mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
1446
+
1447
+	return join('', $mime);
1448 1448
   }
1449 1449
 
1450 1450
   /**
@@ -1457,27 +1457,27 @@  discard block
 block discarded – undo
1457 1457
    * @return string
1458 1458
    */
1459 1459
   private function EncodeFile($path, $encoding = 'base64') {
1460
-    try {
1461
-      if (!is_readable($path)) {
1462
-        throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
1463
-    }
1464
-    if (function_exists('get_magic_quotes')) {
1465
-        function get_magic_quotes() {
1466
-            return false;
1467
-        }
1460
+	try {
1461
+	  if (!is_readable($path)) {
1462
+		throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
1463
+	}
1464
+	if (function_exists('get_magic_quotes')) {
1465
+		function get_magic_quotes() {
1466
+			return false;
1467
+		}
1468 1468
 }
1469
-    if (PHP_VERSION < 5) {
1470
-      $magic_quotes = get_magic_quotes_runtime();
1471
-      set_magic_quotes_runtime(0);
1472
-    }
1473
-    $file_buffer  = file_get_contents($path);
1474
-    $file_buffer  = $this->EncodeString($file_buffer, $encoding);
1475
-    if (PHP_VERSION < 5) { set_magic_quotes_runtime($magic_quotes); }
1476
-    return $file_buffer;
1477
-    } catch (Exception $e) {
1478
-      $this->SetError($e->getMessage());
1479
-      return '';
1480
-    }
1469
+	if (PHP_VERSION < 5) {
1470
+	  $magic_quotes = get_magic_quotes_runtime();
1471
+	  set_magic_quotes_runtime(0);
1472
+	}
1473
+	$file_buffer  = file_get_contents($path);
1474
+	$file_buffer  = $this->EncodeString($file_buffer, $encoding);
1475
+	if (PHP_VERSION < 5) { set_magic_quotes_runtime($magic_quotes); }
1476
+	return $file_buffer;
1477
+	} catch (Exception $e) {
1478
+	  $this->SetError($e->getMessage());
1479
+	  return '';
1480
+	}
1481 1481
   }
1482 1482
 
1483 1483
   /**
@@ -1489,29 +1489,29 @@  discard block
 block discarded – undo
1489 1489
    * @return string
1490 1490
    */
1491 1491
   public function EncodeString ($str, $encoding = 'base64') {
1492
-    $encoded = '';
1493
-    switch(strtolower($encoding)) {
1494
-      case 'base64':
1495
-        $encoded = chunk_split(base64_encode($str), 76, $this->LE);
1496
-        break;
1497
-      case '7bit':
1498
-      case '8bit':
1499
-        $encoded = $this->FixEOL($str);
1500
-        //Make sure it ends with a line break
1501
-        if (substr($encoded, -(strlen($this->LE))) != $this->LE)
1502
-          $encoded .= $this->LE;
1503
-        break;
1504
-      case 'binary':
1505
-        $encoded = $str;
1506
-        break;
1507
-      case 'quoted-printable':
1508
-        $encoded = $this->EncodeQP($str);
1509
-        break;
1510
-      default:
1511
-        $this->SetError($this->Lang('encoding') . $encoding);
1512
-        break;
1513
-    }
1514
-    return $encoded;
1492
+	$encoded = '';
1493
+	switch(strtolower($encoding)) {
1494
+	  case 'base64':
1495
+		$encoded = chunk_split(base64_encode($str), 76, $this->LE);
1496
+		break;
1497
+	  case '7bit':
1498
+	  case '8bit':
1499
+		$encoded = $this->FixEOL($str);
1500
+		//Make sure it ends with a line break
1501
+		if (substr($encoded, -(strlen($this->LE))) != $this->LE)
1502
+		  $encoded .= $this->LE;
1503
+		break;
1504
+	  case 'binary':
1505
+		$encoded = $str;
1506
+		break;
1507
+	  case 'quoted-printable':
1508
+		$encoded = $this->EncodeQP($str);
1509
+		break;
1510
+	  default:
1511
+		$this->SetError($this->Lang('encoding') . $encoding);
1512
+		break;
1513
+	}
1514
+	return $encoded;
1515 1515
   }
1516 1516
 
1517 1517
   /**
@@ -1520,58 +1520,58 @@  discard block
 block discarded – undo
1520 1520
    * @return string
1521 1521
    */
1522 1522
   public function EncodeHeader ($str, $position = 'text') {
1523
-    $x = 0;
1524
-
1525
-    switch (strtolower($position)) {
1526
-      case 'phrase':
1527
-        if (!preg_match('/[\200-\377]/', $str)) {
1528
-          // Can't use addslashes as we don't know what value has magic_quotes_sybase
1529
-          $encoded = addcslashes($str, "\0..\37\177\\\"");
1530
-          if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
1531
-            return ($encoded);
1532
-          } else {
1533
-            return ("\"$encoded\"");
1534
-          }
1535
-        }
1536
-        $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
1537
-        break;
1538
-      case 'comment':
1539
-        $x = preg_match_all('/[()"]/', $str, $matches);
1540
-        // Fall-through
1541
-      case 'text':
1542
-      default:
1543
-        $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
1544
-        break;
1545
-    }
1546
-
1547
-    if ($x == 0) {
1548
-      return ($str);
1549
-    }
1550
-
1551
-    $maxlen = 75 - 7 - strlen($this->CharSet);
1552
-    // Try to select the encoding which should produce the shortest output
1553
-    if (strlen($str)/3 < $x) {
1554
-      $encoding = 'B';
1555
-      if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
1556
-     // Use a custom function which correctly encodes and wraps long
1557
-     // multibyte strings without breaking lines within a character
1558
-        $encoded = $this->Base64EncodeWrapMB($str);
1559
-      } else {
1560
-        $encoded = base64_encode($str);
1561
-        $maxlen -= $maxlen % 4;
1562
-        $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
1563
-      }
1564
-    } else {
1565
-      $encoding = 'Q';
1566
-      $encoded = $this->EncodeQ($str, $position);
1567
-      $encoded = $this->WrapText($encoded, $maxlen, true);
1568
-      $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
1569
-    }
1570
-
1571
-    $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
1572
-    $encoded = trim(str_replace("\n", $this->LE, $encoded));
1573
-
1574
-    return $encoded;
1523
+	$x = 0;
1524
+
1525
+	switch (strtolower($position)) {
1526
+	  case 'phrase':
1527
+		if (!preg_match('/[\200-\377]/', $str)) {
1528
+		  // Can't use addslashes as we don't know what value has magic_quotes_sybase
1529
+		  $encoded = addcslashes($str, "\0..\37\177\\\"");
1530
+		  if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
1531
+			return ($encoded);
1532
+		  } else {
1533
+			return ("\"$encoded\"");
1534
+		  }
1535
+		}
1536
+		$x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
1537
+		break;
1538
+	  case 'comment':
1539
+		$x = preg_match_all('/[()"]/', $str, $matches);
1540
+		// Fall-through
1541
+	  case 'text':
1542
+	  default:
1543
+		$x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
1544
+		break;
1545
+	}
1546
+
1547
+	if ($x == 0) {
1548
+	  return ($str);
1549
+	}
1550
+
1551
+	$maxlen = 75 - 7 - strlen($this->CharSet);
1552
+	// Try to select the encoding which should produce the shortest output
1553
+	if (strlen($str)/3 < $x) {
1554
+	  $encoding = 'B';
1555
+	  if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
1556
+	 // Use a custom function which correctly encodes and wraps long
1557
+	 // multibyte strings without breaking lines within a character
1558
+		$encoded = $this->Base64EncodeWrapMB($str);
1559
+	  } else {
1560
+		$encoded = base64_encode($str);
1561
+		$maxlen -= $maxlen % 4;
1562
+		$encoded = trim(chunk_split($encoded, $maxlen, "\n"));
1563
+	  }
1564
+	} else {
1565
+	  $encoding = 'Q';
1566
+	  $encoded = $this->EncodeQ($str, $position);
1567
+	  $encoded = $this->WrapText($encoded, $maxlen, true);
1568
+	  $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
1569
+	}
1570
+
1571
+	$encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
1572
+	$encoded = trim(str_replace("\n", $this->LE, $encoded));
1573
+
1574
+	return $encoded;
1575 1575
   }
1576 1576
 
1577 1577
   /**
@@ -1581,11 +1581,11 @@  discard block
 block discarded – undo
1581 1581
    * @return bool
1582 1582
    */
1583 1583
   public function HasMultiBytes($str) {
1584
-    if (function_exists('mb_strlen')) {
1585
-      return (strlen($str) > mb_strlen($str, $this->CharSet));
1586
-    } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
1587
-      return false;
1588
-    }
1584
+	if (function_exists('mb_strlen')) {
1585
+	  return (strlen($str) > mb_strlen($str, $this->CharSet));
1586
+	} else { // Assume no multibytes (we can't handle without mbstring functions anyway)
1587
+	  return false;
1588
+	}
1589 1589
   }
1590 1590
 
1591 1591
   /**
@@ -1597,117 +1597,117 @@  discard block
 block discarded – undo
1597 1597
    * @return string
1598 1598
    */
1599 1599
   public function Base64EncodeWrapMB($str) {
1600
-    $start = "=?".$this->CharSet."?B?";
1601
-    $end = "?=";
1602
-    $encoded = "";
1603
-
1604
-    $mb_length = mb_strlen($str, $this->CharSet);
1605
-    // Each line must have length <= 75, including $start and $end
1606
-    $length = 75 - strlen($start) - strlen($end);
1607
-    // Average multi-byte ratio
1608
-    $ratio = $mb_length / strlen($str);
1609
-    // Base64 has a 4:3 ratio
1610
-    $offset = $avgLength = floor($length * $ratio * .75);
1611
-
1612
-    for ($i = 0; $i < $mb_length; $i += $offset) {
1613
-      $lookBack = 0;
1614
-
1615
-      do {
1616
-        $offset = $avgLength - $lookBack;
1617
-        $chunk = mb_substr($str, $i, $offset, $this->CharSet);
1618
-        $chunk = base64_encode($chunk);
1619
-        $lookBack++;
1620
-      }
1621
-      while (strlen($chunk) > $length);
1622
-
1623
-      $encoded .= $chunk . $this->LE;
1624
-    }
1625
-
1626
-    // Chomp the last linefeed
1627
-    $encoded = substr($encoded, 0, -strlen($this->LE));
1628
-    return $encoded;
1629
-  }
1630
-
1631
-  /**
1632
-  * Encode string to quoted-printable.
1633
-  * Only uses standard PHP, slow, but will always work
1634
-  * @access public
1635
-  * @param string $string the text to encode
1636
-  * @param integer $line_max Number of chars allowed on a line before wrapping
1637
-  * @return string
1638
-  */
1600
+	$start = "=?".$this->CharSet."?B?";
1601
+	$end = "?=";
1602
+	$encoded = "";
1603
+
1604
+	$mb_length = mb_strlen($str, $this->CharSet);
1605
+	// Each line must have length <= 75, including $start and $end
1606
+	$length = 75 - strlen($start) - strlen($end);
1607
+	// Average multi-byte ratio
1608
+	$ratio = $mb_length / strlen($str);
1609
+	// Base64 has a 4:3 ratio
1610
+	$offset = $avgLength = floor($length * $ratio * .75);
1611
+
1612
+	for ($i = 0; $i < $mb_length; $i += $offset) {
1613
+	  $lookBack = 0;
1614
+
1615
+	  do {
1616
+		$offset = $avgLength - $lookBack;
1617
+		$chunk = mb_substr($str, $i, $offset, $this->CharSet);
1618
+		$chunk = base64_encode($chunk);
1619
+		$lookBack++;
1620
+	  }
1621
+	  while (strlen($chunk) > $length);
1622
+
1623
+	  $encoded .= $chunk . $this->LE;
1624
+	}
1625
+
1626
+	// Chomp the last linefeed
1627
+	$encoded = substr($encoded, 0, -strlen($this->LE));
1628
+	return $encoded;
1629
+  }
1630
+
1631
+  /**
1632
+   * Encode string to quoted-printable.
1633
+   * Only uses standard PHP, slow, but will always work
1634
+   * @access public
1635
+   * @param string $string the text to encode
1636
+   * @param integer $line_max Number of chars allowed on a line before wrapping
1637
+   * @return string
1638
+   */
1639 1639
   public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) {
1640
-    $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
1641
-    $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
1642
-    $eol = "\r\n";
1643
-    $escape = '=';
1644
-    $output = '';
1645
-    while( list(, $line) = each($lines) ) {
1646
-      $linlen = strlen($line);
1647
-      $newline = '';
1648
-      for($i = 0; $i < $linlen; $i++) {
1649
-        $c = substr( $line, $i, 1 );
1650
-        $dec = ord( $c );
1651
-        if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
1652
-          $c = '=2E';
1653
-        }
1654
-        if ( $dec == 32 ) {
1655
-          if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
1656
-            $c = '=20';
1657
-          } else if ( $space_conv ) {
1658
-            $c = '=20';
1659
-          }
1660
-        } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
1661
-          $h2 = floor($dec/16);
1662
-          $h1 = floor($dec%16);
1663
-          $c = $escape.$hex[$h2].$hex[$h1];
1664
-        }
1665
-        if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
1666
-          $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay
1667
-          $newline = '';
1668
-          // check if newline first character will be point or not
1669
-          if ( $dec == 46 ) {
1670
-            $c = '=2E';
1671
-          }
1672
-        }
1673
-        $newline .= $c;
1674
-      } // end of for
1675
-      $output .= $newline.$eol;
1676
-    } // end of while
1677
-    return $output;
1678
-  }
1679
-
1680
-  /**
1681
-  * Encode string to RFC2045 (6.7) quoted-printable format
1682
-  * Uses a PHP5 stream filter to do the encoding about 64x faster than the old version
1683
-  * Also results in same content as you started with after decoding
1684
-  * @see EncodeQPphp()
1685
-  * @access public
1686
-  * @param string $string the text to encode
1687
-  * @param integer $line_max Number of chars allowed on a line before wrapping
1688
-  * @param boolean $space_conv Dummy param for compatibility with existing EncodeQP function
1689
-  * @return string
1690
-  * @author Marcus Bointon
1691
-  */
1640
+	$hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
1641
+	$lines = preg_split('/(?:\r\n|\r|\n)/', $input);
1642
+	$eol = "\r\n";
1643
+	$escape = '=';
1644
+	$output = '';
1645
+	while( list(, $line) = each($lines) ) {
1646
+	  $linlen = strlen($line);
1647
+	  $newline = '';
1648
+	  for($i = 0; $i < $linlen; $i++) {
1649
+		$c = substr( $line, $i, 1 );
1650
+		$dec = ord( $c );
1651
+		if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
1652
+		  $c = '=2E';
1653
+		}
1654
+		if ( $dec == 32 ) {
1655
+		  if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
1656
+			$c = '=20';
1657
+		  } else if ( $space_conv ) {
1658
+			$c = '=20';
1659
+		  }
1660
+		} elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
1661
+		  $h2 = floor($dec/16);
1662
+		  $h1 = floor($dec%16);
1663
+		  $c = $escape.$hex[$h2].$hex[$h1];
1664
+		}
1665
+		if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
1666
+		  $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay
1667
+		  $newline = '';
1668
+		  // check if newline first character will be point or not
1669
+		  if ( $dec == 46 ) {
1670
+			$c = '=2E';
1671
+		  }
1672
+		}
1673
+		$newline .= $c;
1674
+	  } // end of for
1675
+	  $output .= $newline.$eol;
1676
+	} // end of while
1677
+	return $output;
1678
+  }
1679
+
1680
+  /**
1681
+   * Encode string to RFC2045 (6.7) quoted-printable format
1682
+   * Uses a PHP5 stream filter to do the encoding about 64x faster than the old version
1683
+   * Also results in same content as you started with after decoding
1684
+   * @see EncodeQPphp()
1685
+   * @access public
1686
+   * @param string $string the text to encode
1687
+   * @param integer $line_max Number of chars allowed on a line before wrapping
1688
+   * @param boolean $space_conv Dummy param for compatibility with existing EncodeQP function
1689
+   * @return string
1690
+   * @author Marcus Bointon
1691
+   */
1692 1692
   public function EncodeQP($string, $line_max = 76, $space_conv = false) {
1693
-    if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3)
1694
-      return quoted_printable_encode($string);
1695
-    }
1696
-    $filters = stream_get_filters();
1697
-    if (!in_array('convert.*', $filters)) { //Got convert stream filter?
1698
-      return $this->EncodeQPphp($string, $line_max, $space_conv); //Fall back to old implementation
1699
-    }
1700
-    $fp = fopen('php://temp/', 'r+');
1701
-    $string = preg_replace('/\r\n?/', $this->LE, $string); //Normalise line breaks
1702
-    $params = array('line-length' => $line_max, 'line-break-chars' => $this->LE);
1703
-    $s = stream_filter_append($fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params);
1704
-    fputs($fp, $string);
1705
-    rewind($fp);
1706
-    $out = stream_get_contents($fp);
1707
-    stream_filter_remove($s);
1708
-    $out = preg_replace('/^\./m', '=2E', $out); //Encode . if it is first char on a line, workaround for bug in Exchange
1709
-    fclose($fp);
1710
-    return $out;
1693
+	if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3)
1694
+	  return quoted_printable_encode($string);
1695
+	}
1696
+	$filters = stream_get_filters();
1697
+	if (!in_array('convert.*', $filters)) { //Got convert stream filter?
1698
+	  return $this->EncodeQPphp($string, $line_max, $space_conv); //Fall back to old implementation
1699
+	}
1700
+	$fp = fopen('php://temp/', 'r+');
1701
+	$string = preg_replace('/\r\n?/', $this->LE, $string); //Normalise line breaks
1702
+	$params = array('line-length' => $line_max, 'line-break-chars' => $this->LE);
1703
+	$s = stream_filter_append($fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params);
1704
+	fputs($fp, $string);
1705
+	rewind($fp);
1706
+	$out = stream_get_contents($fp);
1707
+	stream_filter_remove($s);
1708
+	$out = preg_replace('/^\./m', '=2E', $out); //Encode . if it is first char on a line, workaround for bug in Exchange
1709
+	fclose($fp);
1710
+	return $out;
1711 1711
   }
1712 1712
 
1713 1713
   /**
@@ -1719,28 +1719,28 @@  discard block
 block discarded – undo
1719 1719
    * @return string
1720 1720
    */
1721 1721
   public function EncodeQ ($str, $position = 'text') {
1722
-    // There should not be any EOL in the string
1723
-    $encoded = preg_replace('/[\r\n]*/', '', $str);
1722
+	// There should not be any EOL in the string
1723
+	$encoded = preg_replace('/[\r\n]*/', '', $str);
1724 1724
 
1725
-    switch (strtolower($position)) {
1726
-      case 'phrase':
1725
+	switch (strtolower($position)) {
1726
+	  case 'phrase':
1727 1727
 		$encoded = preg_replace_callback('/([^A-Za-z0-9!*+\/ -])/', function($n) { return '='.sprintf('%02X', ord('\\1')); }, $encoded);
1728
-        break;
1729
-      case 'comment':
1728
+		break;
1729
+	  case 'comment':
1730 1730
 		$encoded = preg_replace_callback('/([\(\)\"])/', function($n) { return '='.sprintf('%02X', ord('\\1')); }, $encoded);
1731
-      case 'text':
1732
-      default:
1733
-        // Replace every high ascii, control =, ? and _ characters
1734
-        //TODO using /e (equivalent to eval()) is probably not a good idea
1735
-        $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
1736
-              "'='.sprintf('%02X', ord('\\1'))", $encoded);
1737
-        break;
1738
-    }
1731
+	  case 'text':
1732
+	  default:
1733
+		// Replace every high ascii, control =, ? and _ characters
1734
+		//TODO using /e (equivalent to eval()) is probably not a good idea
1735
+		$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
1736
+			  "'='.sprintf('%02X', ord('\\1'))", $encoded);
1737
+		break;
1738
+	}
1739 1739
 
1740
-    // Replace every spaces to _ (more readable than =20)
1741
-    $encoded = str_replace(' ', '_', $encoded);
1740
+	// Replace every spaces to _ (more readable than =20)
1741
+	$encoded = str_replace(' ', '_', $encoded);
1742 1742
 
1743
-    return $encoded;
1743
+	return $encoded;
1744 1744
   }
1745 1745
 
1746 1746
   /**
@@ -1754,17 +1754,17 @@  discard block
 block discarded – undo
1754 1754
    * @return void
1755 1755
    */
1756 1756
   public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {
1757
-    // Append to $attachment array
1758
-    $this->attachment[] = array(
1759
-      0 => $string,
1760
-      1 => $filename,
1761
-      2 => basename($filename),
1762
-      3 => $encoding,
1763
-      4 => $type,
1764
-      5 => true,  // isStringAttachment
1765
-      6 => 'attachment',
1766
-      7 => 0
1767
-    );
1757
+	// Append to $attachment array
1758
+	$this->attachment[] = array(
1759
+	  0 => $string,
1760
+	  1 => $filename,
1761
+	  2 => basename($filename),
1762
+	  3 => $encoding,
1763
+	  4 => $type,
1764
+	  5 => true,  // isStringAttachment
1765
+	  6 => 'attachment',
1766
+	  7 => 0
1767
+	);
1768 1768
   }
1769 1769
 
1770 1770
   /**
@@ -1782,29 +1782,29 @@  discard block
 block discarded – undo
1782 1782
    */
1783 1783
   public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1784 1784
 
1785
-    if(!@is_file($path)) {
1786
-      $this->SetError($this->Lang('file_access') . $path);
1787
-      return false;
1788
-    }
1785
+	if(!@is_file($path)) {
1786
+	  $this->SetError($this->Lang('file_access') . $path);
1787
+	  return false;
1788
+	}
1789 1789
 
1790
-    $filename = basename($path);
1791
-    if($name == '') {
1792
-      $name = $filename;
1793
-    }
1790
+	$filename = basename($path);
1791
+	if($name == '') {
1792
+	  $name = $filename;
1793
+	}
1794 1794
 
1795
-    // Append to $attachment array
1796
-    $this->attachment[] = array(
1797
-      0 => $path,
1798
-      1 => $filename,
1799
-      2 => $name,
1800
-      3 => $encoding,
1801
-      4 => $type,
1802
-      5 => false,  // isStringAttachment
1803
-      6 => 'inline',
1804
-      7 => $cid
1805
-    );
1795
+	// Append to $attachment array
1796
+	$this->attachment[] = array(
1797
+	  0 => $path,
1798
+	  1 => $filename,
1799
+	  2 => $name,
1800
+	  3 => $encoding,
1801
+	  4 => $type,
1802
+	  5 => false,  // isStringAttachment
1803
+	  6 => 'inline',
1804
+	  7 => $cid
1805
+	);
1806 1806
 
1807
-    return true;
1807
+	return true;
1808 1808
   }
1809 1809
 
1810 1810
   /**
@@ -1813,12 +1813,12 @@  discard block
 block discarded – undo
1813 1813
    * @return bool
1814 1814
    */
1815 1815
   public function InlineImageExists() {
1816
-    foreach($this->attachment as $attachment) {
1817
-      if ($attachment[6] == 'inline') {
1818
-        return true;
1819
-      }
1820
-    }
1821
-    return false;
1816
+	foreach($this->attachment as $attachment) {
1817
+	  if ($attachment[6] == 'inline') {
1818
+		return true;
1819
+	  }
1820
+	}
1821
+	return false;
1822 1822
   }
1823 1823
 
1824 1824
   /////////////////////////////////////////////////
@@ -1830,10 +1830,10 @@  discard block
 block discarded – undo
1830 1830
    * @return void
1831 1831
    */
1832 1832
   public function ClearAddresses() {
1833
-    foreach($this->to as $to) {
1834
-      unset($this->all_recipients[strtolower($to[0])]);
1835
-    }
1836
-    $this->to = array();
1833
+	foreach($this->to as $to) {
1834
+	  unset($this->all_recipients[strtolower($to[0])]);
1835
+	}
1836
+	$this->to = array();
1837 1837
   }
1838 1838
 
1839 1839
   /**
@@ -1841,10 +1841,10 @@  discard block
 block discarded – undo
1841 1841
    * @return void
1842 1842
    */
1843 1843
   public function ClearCCs() {
1844
-    foreach($this->cc as $cc) {
1845
-      unset($this->all_recipients[strtolower($cc[0])]);
1846
-    }
1847
-    $this->cc = array();
1844
+	foreach($this->cc as $cc) {
1845
+	  unset($this->all_recipients[strtolower($cc[0])]);
1846
+	}
1847
+	$this->cc = array();
1848 1848
   }
1849 1849
 
1850 1850
   /**
@@ -1852,10 +1852,10 @@  discard block
 block discarded – undo
1852 1852
    * @return void
1853 1853
    */
1854 1854
   public function ClearBCCs() {
1855
-    foreach($this->bcc as $bcc) {
1856
-      unset($this->all_recipients[strtolower($bcc[0])]);
1857
-    }
1858
-    $this->bcc = array();
1855
+	foreach($this->bcc as $bcc) {
1856
+	  unset($this->all_recipients[strtolower($bcc[0])]);
1857
+	}
1858
+	$this->bcc = array();
1859 1859
   }
1860 1860
 
1861 1861
   /**
@@ -1863,7 +1863,7 @@  discard block
 block discarded – undo
1863 1863
    * @return void
1864 1864
    */
1865 1865
   public function ClearReplyTos() {
1866
-    $this->ReplyTo = array();
1866
+	$this->ReplyTo = array();
1867 1867
   }
1868 1868
 
1869 1869
   /**
@@ -1872,10 +1872,10 @@  discard block
 block discarded – undo
1872 1872
    * @return void
1873 1873
    */
1874 1874
   public function ClearAllRecipients() {
1875
-    $this->to = array();
1876
-    $this->cc = array();
1877
-    $this->bcc = array();
1878
-    $this->all_recipients = array();
1875
+	$this->to = array();
1876
+	$this->cc = array();
1877
+	$this->bcc = array();
1878
+	$this->all_recipients = array();
1879 1879
   }
1880 1880
 
1881 1881
   /**
@@ -1884,7 +1884,7 @@  discard block
 block discarded – undo
1884 1884
    * @return void
1885 1885
    */
1886 1886
   public function ClearAttachments() {
1887
-    $this->attachment = array();
1887
+	$this->attachment = array();
1888 1888
   }
1889 1889
 
1890 1890
   /**
@@ -1892,7 +1892,7 @@  discard block
 block discarded – undo
1892 1892
    * @return void
1893 1893
    */
1894 1894
   public function ClearCustomHeaders() {
1895
-    $this->CustomHeader = array();
1895
+	$this->CustomHeader = array();
1896 1896
   }
1897 1897
 
1898 1898
   /////////////////////////////////////////////////
@@ -1905,14 +1905,14 @@  discard block
 block discarded – undo
1905 1905
    * @return void
1906 1906
    */
1907 1907
   protected function SetError($msg) {
1908
-    $this->error_count++;
1909
-    if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
1910
-      $lasterror = $this->smtp->getError();
1911
-      if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
1912
-        $msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
1913
-      }
1914
-    }
1915
-    $this->ErrorInfo = $msg;
1908
+	$this->error_count++;
1909
+	if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
1910
+	  $lasterror = $this->smtp->getError();
1911
+	  if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
1912
+		$msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
1913
+	  }
1914
+	}
1915
+	$this->ErrorInfo = $msg;
1916 1916
   }
1917 1917
 
1918 1918
   /**
@@ -1922,13 +1922,13 @@  discard block
 block discarded – undo
1922 1922
    * @static
1923 1923
    */
1924 1924
   public static function RFCDate() {
1925
-    $tz = date('Z');
1926
-    $tzs = ($tz < 0) ? '-' : '+';
1927
-    $tz = abs($tz);
1928
-    $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
1929
-    $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
1925
+	$tz = date('Z');
1926
+	$tzs = ($tz < 0) ? '-' : '+';
1927
+	$tz = abs($tz);
1928
+	$tz = (int)($tz/3600)*100 + ($tz%3600)/60;
1929
+	$result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
1930 1930
 
1931
-    return $result;
1931
+	return $result;
1932 1932
   }
1933 1933
 
1934 1934
   /**
@@ -1937,15 +1937,15 @@  discard block
 block discarded – undo
1937 1937
    * @return string
1938 1938
    */
1939 1939
   private function ServerHostname() {
1940
-    if (!empty($this->Hostname)) {
1941
-      $result = $this->Hostname;
1942
-    } elseif (isset($_SERVER['SERVER_NAME'])) {
1943
-      $result = $_SERVER['SERVER_NAME'];
1944
-    } else {
1945
-      $result = 'localhost.localdomain';
1946
-    }
1940
+	if (!empty($this->Hostname)) {
1941
+	  $result = $this->Hostname;
1942
+	} elseif (isset($_SERVER['SERVER_NAME'])) {
1943
+	  $result = $_SERVER['SERVER_NAME'];
1944
+	} else {
1945
+	  $result = 'localhost.localdomain';
1946
+	}
1947 1947
 
1948
-    return $result;
1948
+	return $result;
1949 1949
   }
1950 1950
 
1951 1951
   /**
@@ -1954,15 +1954,15 @@  discard block
 block discarded – undo
1954 1954
    * @return string
1955 1955
    */
1956 1956
   private function Lang($key) {
1957
-    if(count($this->language) < 1) {
1958
-      $this->SetLanguage('en'); // set the default language
1959
-    }
1957
+	if(count($this->language) < 1) {
1958
+	  $this->SetLanguage('en'); // set the default language
1959
+	}
1960 1960
 
1961
-    if(isset($this->language[$key])) {
1962
-      return $this->language[$key];
1963
-    } else {
1964
-      return 'Language string failed to load: ' . $key;
1965
-    }
1961
+	if(isset($this->language[$key])) {
1962
+	  return $this->language[$key];
1963
+	} else {
1964
+	  return 'Language string failed to load: ' . $key;
1965
+	}
1966 1966
   }
1967 1967
 
1968 1968
   /**
@@ -1971,7 +1971,7 @@  discard block
 block discarded – undo
1971 1971
    * @return bool
1972 1972
    */
1973 1973
   public function IsError() {
1974
-    return ($this->error_count > 0);
1974
+	return ($this->error_count > 0);
1975 1975
   }
1976 1976
 
1977 1977
   /**
@@ -1980,10 +1980,10 @@  discard block
 block discarded – undo
1980 1980
    * @return string
1981 1981
    */
1982 1982
   private function FixEOL($str) {
1983
-    $str = str_replace("\r\n", "\n", $str);
1984
-    $str = str_replace("\r", "\n", $str);
1985
-    $str = str_replace("\n", $this->LE, $str);
1986
-    return $str;
1983
+	$str = str_replace("\r\n", "\n", $str);
1984
+	$str = str_replace("\r", "\n", $str);
1985
+	$str = str_replace("\n", $this->LE, $str);
1986
+	return $str;
1987 1987
   }
1988 1988
 
1989 1989
   /**
@@ -1992,7 +1992,7 @@  discard block
 block discarded – undo
1992 1992
    * @return void
1993 1993
    */
1994 1994
   public function AddCustomHeader($custom_header) {
1995
-    $this->CustomHeader[] = explode(':', $custom_header, 2);
1995
+	$this->CustomHeader[] = explode(':', $custom_header, 2);
1996 1996
   }
1997 1997
 
1998 1998
   /**
@@ -2001,34 +2001,34 @@  discard block
 block discarded – undo
2001 2001
    * @return $message
2002 2002
    */
2003 2003
   public function MsgHTML($message,$basedir='') {
2004
-    preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
2005
-    if(isset($images[2])) {
2006
-      foreach($images[2] as $i => $url) {
2007
-        // do not change urls for absolute images (thanks to corvuscorax)
2008
-        if (!preg_match('#^[A-z]+://#',$url)) {
2009
-          $filename = basename($url);
2010
-          $directory = dirname($url);
2011
-          ($directory == '.')?$directory='':'';
2012
-          $cid = 'cid:' . md5($filename);
2013
-          $ext = pathinfo($filename, PATHINFO_EXTENSION);
2014
-          $mimeType  = self::_mime_types($ext);
2015
-          if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
2016
-          if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
2017
-          if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
2018
-            $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
2019
-          }
2020
-        }
2021
-      }
2022
-    }
2023
-    $this->IsHTML(true);
2024
-    $this->Body = $message;
2025
-    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
2026
-    if ( !empty($textMsg) && empty($this->AltBody) ) {
2027
-      $this->AltBody = html_entity_decode($textMsg);
2028
-    }
2029
-    if ( empty($this->AltBody) ) {
2030
-      $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
2031
-    }
2004
+	preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
2005
+	if(isset($images[2])) {
2006
+	  foreach($images[2] as $i => $url) {
2007
+		// do not change urls for absolute images (thanks to corvuscorax)
2008
+		if (!preg_match('#^[A-z]+://#',$url)) {
2009
+		  $filename = basename($url);
2010
+		  $directory = dirname($url);
2011
+		  ($directory == '.')?$directory='':'';
2012
+		  $cid = 'cid:' . md5($filename);
2013
+		  $ext = pathinfo($filename, PATHINFO_EXTENSION);
2014
+		  $mimeType  = self::_mime_types($ext);
2015
+		  if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
2016
+		  if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
2017
+		  if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
2018
+			$message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
2019
+		  }
2020
+		}
2021
+	  }
2022
+	}
2023
+	$this->IsHTML(true);
2024
+	$this->Body = $message;
2025
+	$textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
2026
+	if ( !empty($textMsg) && empty($this->AltBody) ) {
2027
+	  $this->AltBody = html_entity_decode($textMsg);
2028
+	}
2029
+	if ( empty($this->AltBody) ) {
2030
+	  $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
2031
+	}
2032 2032
   }
2033 2033
 
2034 2034
   /**
@@ -2039,96 +2039,96 @@  discard block
 block discarded – undo
2039 2039
    * @static
2040 2040
    */
2041 2041
   public static function _mime_types($ext = '') {
2042
-    $mimes = array(
2043
-      'hqx'   =>  'application/mac-binhex40',
2044
-      'cpt'   =>  'application/mac-compactpro',
2045
-      'doc'   =>  'application/msword',
2046
-      'bin'   =>  'application/macbinary',
2047
-      'dms'   =>  'application/octet-stream',
2048
-      'lha'   =>  'application/octet-stream',
2049
-      'lzh'   =>  'application/octet-stream',
2050
-      'exe'   =>  'application/octet-stream',
2051
-      'class' =>  'application/octet-stream',
2052
-      'psd'   =>  'application/octet-stream',
2053
-      'so'    =>  'application/octet-stream',
2054
-      'sea'   =>  'application/octet-stream',
2055
-      'dll'   =>  'application/octet-stream',
2056
-      'oda'   =>  'application/oda',
2057
-      'pdf'   =>  'application/pdf',
2058
-      'ai'    =>  'application/postscript',
2059
-      'eps'   =>  'application/postscript',
2060
-      'ps'    =>  'application/postscript',
2061
-      'smi'   =>  'application/smil',
2062
-      'smil'  =>  'application/smil',
2063
-      'mif'   =>  'application/vnd.mif',
2064
-      'xls'   =>  'application/vnd.ms-excel',
2065
-      'ppt'   =>  'application/vnd.ms-powerpoint',
2066
-      'wbxml' =>  'application/vnd.wap.wbxml',
2067
-      'wmlc'  =>  'application/vnd.wap.wmlc',
2068
-      'dcr'   =>  'application/x-director',
2069
-      'dir'   =>  'application/x-director',
2070
-      'dxr'   =>  'application/x-director',
2071
-      'dvi'   =>  'application/x-dvi',
2072
-      'gtar'  =>  'application/x-gtar',
2073
-      'php'   =>  'application/x-httpd-php',
2074
-      'php4'  =>  'application/x-httpd-php',
2075
-      'php3'  =>  'application/x-httpd-php',
2076
-      'phtml' =>  'application/x-httpd-php',
2077
-      'phps'  =>  'application/x-httpd-php-source',
2078
-      'js'    =>  'application/x-javascript',
2079
-      'swf'   =>  'application/x-shockwave-flash',
2080
-      'sit'   =>  'application/x-stuffit',
2081
-      'tar'   =>  'application/x-tar',
2082
-      'tgz'   =>  'application/x-tar',
2083
-      'xhtml' =>  'application/xhtml+xml',
2084
-      'xht'   =>  'application/xhtml+xml',
2085
-      'zip'   =>  'application/zip',
2086
-      'mid'   =>  'audio/midi',
2087
-      'midi'  =>  'audio/midi',
2088
-      'mpga'  =>  'audio/mpeg',
2089
-      'mp2'   =>  'audio/mpeg',
2090
-      'mp3'   =>  'audio/mpeg',
2091
-      'aif'   =>  'audio/x-aiff',
2092
-      'aiff'  =>  'audio/x-aiff',
2093
-      'aifc'  =>  'audio/x-aiff',
2094
-      'ram'   =>  'audio/x-pn-realaudio',
2095
-      'rm'    =>  'audio/x-pn-realaudio',
2096
-      'rpm'   =>  'audio/x-pn-realaudio-plugin',
2097
-      'ra'    =>  'audio/x-realaudio',
2098
-      'rv'    =>  'video/vnd.rn-realvideo',
2099
-      'wav'   =>  'audio/x-wav',
2100
-      'bmp'   =>  'image/bmp',
2101
-      'gif'   =>  'image/gif',
2102
-      'jpeg'  =>  'image/jpeg',
2103
-      'jpg'   =>  'image/jpeg',
2104
-      'jpe'   =>  'image/jpeg',
2105
-      'png'   =>  'image/png',
2106
-      'tiff'  =>  'image/tiff',
2107
-      'tif'   =>  'image/tiff',
2108
-      'css'   =>  'text/css',
2109
-      'html'  =>  'text/html',
2110
-      'htm'   =>  'text/html',
2111
-      'shtml' =>  'text/html',
2112
-      'txt'   =>  'text/plain',
2113
-      'text'  =>  'text/plain',
2114
-      'log'   =>  'text/plain',
2115
-      'rtx'   =>  'text/richtext',
2116
-      'rtf'   =>  'text/rtf',
2117
-      'xml'   =>  'text/xml',
2118
-      'xsl'   =>  'text/xml',
2119
-      'mpeg'  =>  'video/mpeg',
2120
-      'mpg'   =>  'video/mpeg',
2121
-      'mpe'   =>  'video/mpeg',
2122
-      'qt'    =>  'video/quicktime',
2123
-      'mov'   =>  'video/quicktime',
2124
-      'avi'   =>  'video/x-msvideo',
2125
-      'movie' =>  'video/x-sgi-movie',
2126
-      'doc'   =>  'application/msword',
2127
-      'word'  =>  'application/msword',
2128
-      'xl'    =>  'application/excel',
2129
-      'eml'   =>  'message/rfc822'
2130
-    );
2131
-    return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
2042
+	$mimes = array(
2043
+	  'hqx'   =>  'application/mac-binhex40',
2044
+	  'cpt'   =>  'application/mac-compactpro',
2045
+	  'doc'   =>  'application/msword',
2046
+	  'bin'   =>  'application/macbinary',
2047
+	  'dms'   =>  'application/octet-stream',
2048
+	  'lha'   =>  'application/octet-stream',
2049
+	  'lzh'   =>  'application/octet-stream',
2050
+	  'exe'   =>  'application/octet-stream',
2051
+	  'class' =>  'application/octet-stream',
2052
+	  'psd'   =>  'application/octet-stream',
2053
+	  'so'    =>  'application/octet-stream',
2054
+	  'sea'   =>  'application/octet-stream',
2055
+	  'dll'   =>  'application/octet-stream',
2056
+	  'oda'   =>  'application/oda',
2057
+	  'pdf'   =>  'application/pdf',
2058
+	  'ai'    =>  'application/postscript',
2059
+	  'eps'   =>  'application/postscript',
2060
+	  'ps'    =>  'application/postscript',
2061
+	  'smi'   =>  'application/smil',
2062
+	  'smil'  =>  'application/smil',
2063
+	  'mif'   =>  'application/vnd.mif',
2064
+	  'xls'   =>  'application/vnd.ms-excel',
2065
+	  'ppt'   =>  'application/vnd.ms-powerpoint',
2066
+	  'wbxml' =>  'application/vnd.wap.wbxml',
2067
+	  'wmlc'  =>  'application/vnd.wap.wmlc',
2068
+	  'dcr'   =>  'application/x-director',
2069
+	  'dir'   =>  'application/x-director',
2070
+	  'dxr'   =>  'application/x-director',
2071
+	  'dvi'   =>  'application/x-dvi',
2072
+	  'gtar'  =>  'application/x-gtar',
2073
+	  'php'   =>  'application/x-httpd-php',
2074
+	  'php4'  =>  'application/x-httpd-php',
2075
+	  'php3'  =>  'application/x-httpd-php',
2076
+	  'phtml' =>  'application/x-httpd-php',
2077
+	  'phps'  =>  'application/x-httpd-php-source',
2078
+	  'js'    =>  'application/x-javascript',
2079
+	  'swf'   =>  'application/x-shockwave-flash',
2080
+	  'sit'   =>  'application/x-stuffit',
2081
+	  'tar'   =>  'application/x-tar',
2082
+	  'tgz'   =>  'application/x-tar',
2083
+	  'xhtml' =>  'application/xhtml+xml',
2084
+	  'xht'   =>  'application/xhtml+xml',
2085
+	  'zip'   =>  'application/zip',
2086
+	  'mid'   =>  'audio/midi',
2087
+	  'midi'  =>  'audio/midi',
2088
+	  'mpga'  =>  'audio/mpeg',
2089
+	  'mp2'   =>  'audio/mpeg',
2090
+	  'mp3'   =>  'audio/mpeg',
2091
+	  'aif'   =>  'audio/x-aiff',
2092
+	  'aiff'  =>  'audio/x-aiff',
2093
+	  'aifc'  =>  'audio/x-aiff',
2094
+	  'ram'   =>  'audio/x-pn-realaudio',
2095
+	  'rm'    =>  'audio/x-pn-realaudio',
2096
+	  'rpm'   =>  'audio/x-pn-realaudio-plugin',
2097
+	  'ra'    =>  'audio/x-realaudio',
2098
+	  'rv'    =>  'video/vnd.rn-realvideo',
2099
+	  'wav'   =>  'audio/x-wav',
2100
+	  'bmp'   =>  'image/bmp',
2101
+	  'gif'   =>  'image/gif',
2102
+	  'jpeg'  =>  'image/jpeg',
2103
+	  'jpg'   =>  'image/jpeg',
2104
+	  'jpe'   =>  'image/jpeg',
2105
+	  'png'   =>  'image/png',
2106
+	  'tiff'  =>  'image/tiff',
2107
+	  'tif'   =>  'image/tiff',
2108
+	  'css'   =>  'text/css',
2109
+	  'html'  =>  'text/html',
2110
+	  'htm'   =>  'text/html',
2111
+	  'shtml' =>  'text/html',
2112
+	  'txt'   =>  'text/plain',
2113
+	  'text'  =>  'text/plain',
2114
+	  'log'   =>  'text/plain',
2115
+	  'rtx'   =>  'text/richtext',
2116
+	  'rtf'   =>  'text/rtf',
2117
+	  'xml'   =>  'text/xml',
2118
+	  'xsl'   =>  'text/xml',
2119
+	  'mpeg'  =>  'video/mpeg',
2120
+	  'mpg'   =>  'video/mpeg',
2121
+	  'mpe'   =>  'video/mpeg',
2122
+	  'qt'    =>  'video/quicktime',
2123
+	  'mov'   =>  'video/quicktime',
2124
+	  'avi'   =>  'video/x-msvideo',
2125
+	  'movie' =>  'video/x-sgi-movie',
2126
+	  'doc'   =>  'application/msword',
2127
+	  'word'  =>  'application/msword',
2128
+	  'xl'    =>  'application/excel',
2129
+	  'eml'   =>  'message/rfc822'
2130
+	);
2131
+	return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
2132 2132
   }
2133 2133
 
2134 2134
   /**
@@ -2141,22 +2141,22 @@  discard block
 block discarded – undo
2141 2141
    * @param string $name Parameter Name
2142 2142
    * @param mixed $value Parameter Value
2143 2143
    * NOTE: will not work with arrays, there are no arrays to set/reset
2144
-  * @todo Should this not be using __set() magic function?
2144
+   * @todo Should this not be using __set() magic function?
2145 2145
    */
2146 2146
   public function set ( $name, $value = '' ) {
2147
-    try {
2148
-    if ( isset($this->$name) ) {
2149
-      $this->$name = $value;
2150
-    } else {
2151
-        throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL);
2147
+	try {
2148
+	if ( isset($this->$name) ) {
2149
+	  $this->$name = $value;
2150
+	} else {
2151
+		throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL);
2152 2152
   }
2153
-    } catch (Exception $e) {
2154
-      $this->SetError($e->getMessage());
2155
-      if ($e->getCode() == self::STOP_CRITICAL) {
2156
-      return false;
2157
-    }
2153
+	} catch (Exception $e) {
2154
+	  $this->SetError($e->getMessage());
2155
+	  if ($e->getCode() == self::STOP_CRITICAL) {
2156
+	  return false;
2157
+	}
2158 2158
   }
2159
-    return true;
2159
+	return true;
2160 2160
   }
2161 2161
 
2162 2162
   /**
@@ -2166,9 +2166,9 @@  discard block
 block discarded – undo
2166 2166
    * @return string
2167 2167
    */
2168 2168
   public function SecureHeader($str) {
2169
-    $str = str_replace("\r", '', $str);
2170
-    $str = str_replace("\n", '', $str);
2171
-    return trim($str);
2169
+	$str = str_replace("\r", '', $str);
2170
+	$str = str_replace("\n", '', $str);
2171
+	return trim($str);
2172 2172
   }
2173 2173
 
2174 2174
   /**
@@ -2179,9 +2179,9 @@  discard block
 block discarded – undo
2179 2179
    * @param string $key_pass Password for private key
2180 2180
    */
2181 2181
   public function Sign($cert_filename, $key_filename, $key_pass) {
2182
-    $this->sign_cert_file = $cert_filename;
2183
-    $this->sign_key_file = $key_filename;
2184
-    $this->sign_key_pass = $key_pass;
2182
+	$this->sign_cert_file = $cert_filename;
2183
+	$this->sign_key_file = $key_filename;
2184
+	$this->sign_key_pass = $key_pass;
2185 2185
   }
2186 2186
 
2187 2187
   /**
@@ -2192,17 +2192,17 @@  discard block
 block discarded – undo
2192 2192
    * @param string $key_pass Password for private key
2193 2193
    */
2194 2194
   public function DKIM_QP($txt) {
2195
-    $tmp="";
2196
-    $line="";
2197
-    for ($i=0;$i<strlen($txt);$i++) {
2198
-      $ord=ord($txt[$i]);
2199
-      if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) {
2200
-        $line.=$txt[$i];
2201
-      } else {
2202
-        $line.="=".sprintf("%02X",$ord);
2203
-      }
2204
-    }
2205
-    return $line;
2195
+	$tmp="";
2196
+	$line="";
2197
+	for ($i=0;$i<strlen($txt);$i++) {
2198
+	  $ord=ord($txt[$i]);
2199
+	  if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) {
2200
+		$line.=$txt[$i];
2201
+	  } else {
2202
+		$line.="=".sprintf("%02X",$ord);
2203
+	  }
2204
+	}
2205
+	return $line;
2206 2206
 }
2207 2207
 
2208 2208
   /**
@@ -2212,15 +2212,15 @@  discard block
 block discarded – undo
2212 2212
    * @param string $s Header
2213 2213
    */
2214 2214
   public function DKIM_Sign($s) {
2215
-    $privKeyStr = file_get_contents($this->DKIM_private);
2216
-    if ($this->DKIM_passphrase!='') {
2217
-      $privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
2218
-    } else {
2219
-      $privKey = $privKeyStr;
2220
-    }
2221
-    if (openssl_sign($s, $signature, $privKey)) {
2222
-      return base64_encode($signature);
2223
-    }
2215
+	$privKeyStr = file_get_contents($this->DKIM_private);
2216
+	if ($this->DKIM_passphrase!='') {
2217
+	  $privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
2218
+	} else {
2219
+	  $privKey = $privKeyStr;
2220
+	}
2221
+	if (openssl_sign($s, $signature, $privKey)) {
2222
+	  return base64_encode($signature);
2223
+	}
2224 2224
   }
2225 2225
 
2226 2226
   /**
@@ -2230,16 +2230,16 @@  discard block
 block discarded – undo
2230 2230
    * @param string $s Header
2231 2231
    */
2232 2232
   public function DKIM_HeaderC($s) {
2233
-    $s=preg_replace("/\r\n\s+/"," ",$s);
2234
-    $lines=explode("\r\n",$s);
2235
-    foreach ($lines as $key=>$line) {
2236
-      list($heading,$value)=explode(":",$line,2);
2237
-      $heading=strtolower($heading);
2238
-      $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces
2239
-      $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value
2240
-    }
2241
-    $s=implode("\r\n",$lines);
2242
-    return $s;
2233
+	$s=preg_replace("/\r\n\s+/"," ",$s);
2234
+	$lines=explode("\r\n",$s);
2235
+	foreach ($lines as $key=>$line) {
2236
+	  list($heading,$value)=explode(":",$line,2);
2237
+	  $heading=strtolower($heading);
2238
+	  $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces
2239
+	  $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value
2240
+	}
2241
+	$s=implode("\r\n",$lines);
2242
+	return $s;
2243 2243
   }
2244 2244
 
2245 2245
   /**
@@ -2249,15 +2249,15 @@  discard block
 block discarded – undo
2249 2249
    * @param string $body Message Body
2250 2250
    */
2251 2251
   public function DKIM_BodyC($body) {
2252
-    if ($body == '') return "\r\n";
2253
-    // stabilize line endings
2254
-    $body=str_replace("\r\n","\n",$body);
2255
-    $body=str_replace("\n","\r\n",$body);
2256
-    // END stabilize line endings
2257
-    while (substr($body,strlen($body)-4,4) == "\r\n\r\n") {
2258
-      $body=substr($body,0,strlen($body)-2);
2259
-    }
2260
-    return $body;
2252
+	if ($body == '') return "\r\n";
2253
+	// stabilize line endings
2254
+	$body=str_replace("\r\n","\n",$body);
2255
+	$body=str_replace("\n","\r\n",$body);
2256
+	// END stabilize line endings
2257
+	while (substr($body,strlen($body)-4,4) == "\r\n\r\n") {
2258
+	  $body=substr($body,0,strlen($body)-2);
2259
+	}
2260
+	return $body;
2261 2261
   }
2262 2262
 
2263 2263
   /**
@@ -2269,52 +2269,52 @@  discard block
 block discarded – undo
2269 2269
    * @param string $body Body
2270 2270
    */
2271 2271
   public function DKIM_Add($headers_line,$subject,$body) {
2272
-    $DKIMsignatureType    = 'rsa-sha1'; // Signature & hash algorithms
2273
-    $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
2274
-    $DKIMquery            = 'dns/txt'; // Query method
2275
-    $DKIMtime             = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
2276
-    $subject_header       = "Subject: $subject";
2277
-    $headers              = explode("\r\n",$headers_line);
2278
-    foreach($headers as $header) {
2279
-      if (strpos($header,'From:') === 0) {
2280
-        $from_header=$header;
2281
-      } elseif (strpos($header,'To:') === 0) {
2282
-        $to_header=$header;
2283
-      }
2284
-    }
2285
-    $from     = str_replace('|','=7C',$this->DKIM_QP($from_header));
2286
-    $to       = str_replace('|','=7C',$this->DKIM_QP($to_header));
2287
-    $subject  = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable
2288
-    $body     = $this->DKIM_BodyC($body);
2289
-    $DKIMlen  = strlen($body) ; // Length of body
2290
-    $DKIMb64  = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body
2291
-    $ident    = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";";
2292
-    $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n".
2293
-                "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n".
2294
-                "\th=From:To:Subject;\r\n".
2295
-                "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n".
2296
-                "\tz=$from\r\n".
2297
-                "\t|$to\r\n".
2298
-                "\t|$subject;\r\n".
2299
-                "\tbh=" . $DKIMb64 . ";\r\n".
2300
-                "\tb=";
2301
-    $toSign   = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs);
2302
-    $signed   = $this->DKIM_Sign($toSign);
2303
-    return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n";
2272
+	$DKIMsignatureType    = 'rsa-sha1'; // Signature & hash algorithms
2273
+	$DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
2274
+	$DKIMquery            = 'dns/txt'; // Query method
2275
+	$DKIMtime             = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
2276
+	$subject_header       = "Subject: $subject";
2277
+	$headers              = explode("\r\n",$headers_line);
2278
+	foreach($headers as $header) {
2279
+	  if (strpos($header,'From:') === 0) {
2280
+		$from_header=$header;
2281
+	  } elseif (strpos($header,'To:') === 0) {
2282
+		$to_header=$header;
2283
+	  }
2284
+	}
2285
+	$from     = str_replace('|','=7C',$this->DKIM_QP($from_header));
2286
+	$to       = str_replace('|','=7C',$this->DKIM_QP($to_header));
2287
+	$subject  = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable
2288
+	$body     = $this->DKIM_BodyC($body);
2289
+	$DKIMlen  = strlen($body) ; // Length of body
2290
+	$DKIMb64  = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body
2291
+	$ident    = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";";
2292
+	$dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n".
2293
+				"\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n".
2294
+				"\th=From:To:Subject;\r\n".
2295
+				"\td=" . $this->DKIM_domain . ";" . $ident . "\r\n".
2296
+				"\tz=$from\r\n".
2297
+				"\t|$to\r\n".
2298
+				"\t|$subject;\r\n".
2299
+				"\tbh=" . $DKIMb64 . ";\r\n".
2300
+				"\tb=";
2301
+	$toSign   = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs);
2302
+	$signed   = $this->DKIM_Sign($toSign);
2303
+	return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n";
2304 2304
   }
2305 2305
 
2306 2306
   protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) {
2307
-    if (!empty($this->action_function) && function_exists($this->action_function)) {
2308
-      $params = array($isSent,$to,$cc,$bcc,$subject,$body);
2309
-      call_user_func_array($this->action_function,$params);
2310
-    }
2307
+	if (!empty($this->action_function) && function_exists($this->action_function)) {
2308
+	  $params = array($isSent,$to,$cc,$bcc,$subject,$body);
2309
+	  call_user_func_array($this->action_function,$params);
2310
+	}
2311 2311
   }
2312 2312
 }
2313 2313
 
2314 2314
 class phpmailerException extends Exception {
2315 2315
   public function errorMessage() {
2316
-    $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
2317
-    return $errorMsg;
2316
+	$errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
2317
+	return $errorMsg;
2318 2318
   }
2319 2319
 }
2320 2320
 ?>
2321 2321
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +241 added lines, -242 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
39 39
  */
40 40
 
41
-if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
41
+if (version_compare(PHP_VERSION, '5.0.0', '<')) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
42 42
 
43 43
 class PHPMailer {
44 44
 
@@ -50,64 +50,64 @@  discard block
 block discarded – undo
50 50
    * Email priority (1 = High, 3 = Normal, 5 = low).
51 51
    * @var int
52 52
    */
53
-  public $Priority          = 3;
53
+  public $Priority = 3;
54 54
 
55 55
   /**
56 56
    * Sets the CharSet of the message.
57 57
    * @var string
58 58
    */
59
-  public $CharSet           = 'utf-8';
59
+  public $CharSet = 'utf-8';
60 60
 
61 61
   /**
62 62
    * Sets the Content-type of the message.
63 63
    * @var string
64 64
    */
65
-  public $ContentType       = 'text/plain';
65
+  public $ContentType = 'text/plain';
66 66
 
67 67
   /**
68 68
    * Sets the Encoding of the message. Options for this are
69 69
    *  "8bit", "7bit", "binary", "base64", and "quoted-printable".
70 70
    * @var string
71 71
    */
72
-  public $Encoding          = '8bit';
72
+  public $Encoding = '8bit';
73 73
 
74 74
   /**
75 75
    * Holds the most recent mailer error message.
76 76
    * @var string
77 77
    */
78
-  public $ErrorInfo         = '';
78
+  public $ErrorInfo = '';
79 79
 
80 80
   /**
81 81
    * Sets the From email address for the message.
82 82
    * @var string
83 83
    */
84
-  public $From              = 'root@localhost';
84
+  public $From = 'root@localhost';
85 85
 
86 86
   /**
87 87
    * Sets the From name of the message.
88 88
    * @var string
89 89
    */
90
-  public $FromName          = 'Root User';
90
+  public $FromName = 'Root User';
91 91
 
92 92
   /**
93 93
    * Sets the Sender email (Return-Path) of the message.  If not empty,
94 94
    * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
95 95
    * @var string
96 96
    */
97
-  public $Sender            = '';
97
+  public $Sender = '';
98 98
 
99 99
   /**
100 100
    * Sets the Subject of the message.
101 101
    * @var string
102 102
    */
103
-  public $Subject           = '';
103
+  public $Subject = '';
104 104
 
105 105
   /**
106 106
    * Sets the Body of the message.  This can be either an HTML or text body.
107 107
    * If HTML then run IsHTML(true).
108 108
    * @var string
109 109
    */
110
-  public $Body              = '';
110
+  public $Body = '';
111 111
 
112 112
   /**
113 113
    * Sets the text-only body of the message.  This automatically sets the
@@ -116,39 +116,39 @@  discard block
 block discarded – undo
116 116
    * that can read HTML will view the normal Body.
117 117
    * @var string
118 118
    */
119
-  public $AltBody           = '';
119
+  public $AltBody = '';
120 120
 
121 121
   /**
122 122
    * Sets word wrapping on the body of the message to a given number of
123 123
    * characters.
124 124
    * @var int
125 125
    */
126
-  public $WordWrap          = 0;
126
+  public $WordWrap = 0;
127 127
 
128 128
   /**
129 129
    * Method to send mail: ("mail", "sendmail", or "smtp").
130 130
    * @var string
131 131
    */
132
-  public $Mailer            = 'mail';
132
+  public $Mailer = 'mail';
133 133
 
134 134
   /**
135 135
    * Sets the path of the sendmail program.
136 136
    * @var string
137 137
    */
138
-  public $Sendmail          = '/usr/sbin/sendmail';
138
+  public $Sendmail = '/usr/sbin/sendmail';
139 139
 
140 140
   /**
141 141
    * Path to PHPMailer plugins.  Useful if the SMTP class
142 142
    * is in a different directory than the PHP include path.
143 143
    * @var string
144 144
    */
145
-  public $PluginDir         = '';
145
+  public $PluginDir = '';
146 146
 
147 147
   /**
148 148
    * Sets the email address that a reading confirmation will be sent.
149 149
    * @var string
150 150
    */
151
-  public $ConfirmReadingTo  = '';
151
+  public $ConfirmReadingTo = '';
152 152
 
153 153
   /**
154 154
    * Sets the hostname to use in Message-Id and Received headers
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
    * by SERVER_NAME is used or 'localhost.localdomain'.
157 157
    * @var string
158 158
    */
159
-  public $Hostname          = '';
159
+  public $Hostname = '';
160 160
 
161 161
   /**
162 162
    * Sets the message ID to be used in the Message-Id header.
163 163
    * If empty, a unique id will be generated.
164 164
    * @var string
165 165
    */
166
-  public $MessageID      = '';
166
+  public $MessageID = '';
167 167
 
168 168
   /////////////////////////////////////////////////
169 169
   // PROPERTIES FOR SMTP
@@ -177,57 +177,57 @@  discard block
 block discarded – undo
177 177
    * Hosts will be tried in order.
178 178
    * @var string
179 179
    */
180
-  public $Host        = 'localhost';
180
+  public $Host = 'localhost';
181 181
 
182 182
   /**
183 183
    * Sets the default SMTP server port.
184 184
    * @var int
185 185
    */
186
-  public $Port        = 25;
186
+  public $Port = 25;
187 187
 
188 188
   /**
189 189
    * Sets the SMTP HELO of the message (Default is $Hostname).
190 190
    * @var string
191 191
    */
192
-  public $Helo        = '';
192
+  public $Helo = '';
193 193
 
194 194
   /**
195 195
    * Sets connection prefix.
196 196
    * Options are "", "ssl" or "tls"
197 197
    * @var string
198 198
    */
199
-  public $SMTPSecure    = '';
199
+  public $SMTPSecure = '';
200 200
 
201 201
   /**
202 202
    * Sets SMTP authentication. Utilizes the Username and Password variables.
203 203
    * @var bool
204 204
    */
205
-  public $SMTPAuth     = false;
205
+  public $SMTPAuth = false;
206 206
 
207 207
   /**
208 208
    * Sets SMTP username.
209 209
    * @var string
210 210
    */
211
-  public $Username     = '';
211
+  public $Username = '';
212 212
 
213 213
   /**
214 214
    * Sets SMTP password.
215 215
    * @var string
216 216
    */
217
-  public $Password     = '';
217
+  public $Password = '';
218 218
 
219 219
   /**
220 220
    * Sets the SMTP server timeout in seconds.
221 221
    * This function will not work with the win32 version.
222 222
    * @var int
223 223
    */
224
-  public $Timeout      = 10;
224
+  public $Timeout = 10;
225 225
 
226 226
   /**
227 227
    * Sets SMTP class debugging on or off.
228 228
    * @var bool
229 229
    */
230
-  public $SMTPDebug    = false;
230
+  public $SMTPDebug = false;
231 231
 
232 232
   /**
233 233
    * Prevents the SMTP connection from being closed after each mail
@@ -254,34 +254,34 @@  discard block
 block discarded – undo
254 254
    * Provides the ability to change the line ending
255 255
    * @var string
256 256
    */
257
-  public $LE              = "\n";
257
+  public $LE = "\n";
258 258
 
259 259
   /**
260 260
    * Used with DKIM DNS Resource Record
261 261
    * @var string
262 262
    */
263
-  public $DKIM_selector   = 'phpmailer';
263
+  public $DKIM_selector = 'phpmailer';
264 264
 
265 265
   /**
266 266
    * Used with DKIM DNS Resource Record
267 267
    * optional, in format of email address '[email protected]'
268 268
    * @var string
269 269
    */
270
-  public $DKIM_identity   = '';
270
+  public $DKIM_identity = '';
271 271
 
272 272
   /**
273 273
    * Used with DKIM DNS Resource Record
274 274
    * optional, in format of email address '[email protected]'
275 275
    * @var string
276 276
    */
277
-  public $DKIM_domain     = '';
277
+  public $DKIM_domain = '';
278 278
 
279 279
   /**
280 280
    * Used with DKIM DNS Resource Record
281 281
    * optional, in format of email address '[email protected]'
282 282
    * @var string
283 283
    */
284
-  public $DKIM_private    = '';
284
+  public $DKIM_private = '';
285 285
 
286 286
   /**
287 287
    * Callback Action function name
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
    * Sets the PHPMailer Version number
301 301
    * @var string
302 302
    */
303
-  public $Version         = '5.1';
303
+  public $Version = '5.1';
304 304
 
305 305
   /////////////////////////////////////////////////
306 306
   // PROPERTIES, PRIVATE AND PROTECTED
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
   private $CustomHeader    = array();
317 317
   private $message_type    = '';
318 318
   private $boundary        = array();
319
-  protected $language       = array();
319
+  protected $language = array();
320 320
   private $error_count     = 0;
321 321
   private $sign_cert_file  = "";
322 322
   private $sign_key_file   = "";
323 323
   private $sign_key_pass   = "";
324
-  private   $exceptions     = false;
324
+  private   $exceptions = false;
325 325
 
326 326
   /////////////////////////////////////////////////
327 327
   // CONSTANTS
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
     $address = trim($address);
458 458
     $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
459 459
     if (!self::ValidateAddress($address)) {
460
-      $this->SetError($this->Lang('invalid_address').': '. $address);
460
+      $this->SetError($this->Lang('invalid_address') . ': ' . $address);
461 461
       if ($this->exceptions) {
462
-        throw new phpmailerException($this->Lang('invalid_address').': '.$address);
462
+        throw new phpmailerException($this->Lang('invalid_address') . ': ' . $address);
463 463
       }
464
-      echo $this->Lang('invalid_address').': '.$address;
464
+      echo $this->Lang('invalid_address') . ': ' . $address;
465 465
       return false;
466 466
     }
467 467
     if ($kind != 'ReplyTo') {
@@ -485,15 +485,15 @@  discard block
 block discarded – undo
485 485
  * @param string $name
486 486
  * @return boolean
487 487
  */
488
-  public function SetFrom($address, $name = '',$auto=1) {
488
+  public function SetFrom($address, $name = '', $auto = 1) {
489 489
     $address = trim($address);
490 490
     $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
491 491
     if (!self::ValidateAddress($address)) {
492
-      $this->SetError($this->Lang('invalid_address').': '. $address);
492
+      $this->SetError($this->Lang('invalid_address') . ': ' . $address);
493 493
       if ($this->exceptions) {
494
-        throw new phpmailerException($this->Lang('invalid_address').': '.$address);
494
+        throw new phpmailerException($this->Lang('invalid_address') . ': ' . $address);
495 495
       }
496
-      echo $this->Lang('invalid_address').': '.$address;
496
+      echo $this->Lang('invalid_address') . ': ' . $address;
497 497
       return false;
498 498
     }
499 499
     $this->From = $address;
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
    */
523 523
   public static function ValidateAddress($address) {
524 524
     if (function_exists('filter_var')) { //Introduced in PHP 5.2
525
-      if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
525
+      if (filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
526 526
         return false;
527 527
       } else {
528 528
         return true;
@@ -544,12 +544,12 @@  discard block
 block discarded – undo
544 544
    */
545 545
   public function Send() {
546 546
     try {
547
-    if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
547
+    if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
548 548
         throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL);
549 549
     }
550 550
 
551 551
       // Set whether the message is multipart/alternative
552
-    if(!empty($this->AltBody)) {
552
+    if (!empty($this->AltBody)) {
553 553
       $this->ContentType = 'multipart/alternative';
554 554
     }
555 555
 
@@ -564,12 +564,12 @@  discard block
 block discarded – undo
564 564
 
565 565
       // digitally sign with DKIM if enabled
566 566
       if ($this->DKIM_domain && $this->DKIM_private) {
567
-        $header_dkim = $this->DKIM_Add($header,$this->Subject,$body);
568
-        $header = str_replace("\r\n","\n",$header_dkim) . $header;
567
+        $header_dkim = $this->DKIM_Add($header, $this->Subject, $body);
568
+        $header = str_replace("\r\n", "\n", $header_dkim) . $header;
569 569
     }
570 570
 
571 571
       // Choose the mailer and send through it
572
-    switch($this->Mailer) {
572
+    switch ($this->Mailer) {
573 573
       case 'sendmail':
574 574
           return $this->SendmailSend($header, $body);
575 575
       case 'smtp':
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
       if ($this->exceptions) {
584 584
         throw $e;
585 585
       }
586
-      echo $e->getMessage()."\n";
586
+      echo $e->getMessage() . "\n";
587 587
       return false;
588 588
     }
589 589
   }
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
     }
604 604
     if ($this->SingleTo === true) {
605 605
       foreach ($this->SingleToArray as $key => $val) {
606
-    if(!@$mail = popen($sendmail, 'w')) {
606
+    if (!@$mail = popen($sendmail, 'w')) {
607 607
           throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
608 608
     }
609 609
         fputs($mail, "To: " . $val . "\n");
@@ -612,13 +612,13 @@  discard block
 block discarded – undo
612 612
     $result = pclose($mail);
613 613
         // implement call back function if it exists
614 614
         $isSent = ($result == 0) ? 1 : 0;
615
-        $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
616
-        if($result != 0) {
615
+        $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
616
+        if ($result != 0) {
617 617
           throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
618 618
         }
619 619
       }
620 620
     } else {
621
-      if(!@$mail = popen($sendmail, 'w')) {
621
+      if (!@$mail = popen($sendmail, 'w')) {
622 622
         throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
623 623
     }
624 624
       fputs($mail, $header);
@@ -626,8 +626,8 @@  discard block
 block discarded – undo
626 626
       $result = pclose($mail);
627 627
       // implement call back function if it exists
628 628
       $isSent = ($result == 0) ? 1 : 0;
629
-      $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
630
-    if($result != 0) {
629
+      $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body);
630
+    if ($result != 0) {
631 631
         throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
632 632
       }
633 633
     }
@@ -643,13 +643,13 @@  discard block
 block discarded – undo
643 643
    */
644 644
   protected function MailSend($header, $body) {
645 645
     $toArr = array();
646
-    foreach($this->to as $t) {
646
+    foreach ($this->to as $t) {
647 647
       $toArr[] = $this->AddrFormat($t);
648 648
     }
649 649
     $to = implode(', ', $toArr);
650 650
 
651 651
     $params = sprintf("-oi -f %s", $this->Sender);
652
-    if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) {
652
+    if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) {
653 653
       $old_from = ini_get('sendmail_from');
654 654
       ini_set('sendmail_from', $this->Sender);
655 655
       if ($this->SingleTo === true && count($toArr) > 1) {
@@ -657,13 +657,13 @@  discard block
 block discarded – undo
657 657
           $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
658 658
           // implement call back function if it exists
659 659
           $isSent = ($rt == 1) ? 1 : 0;
660
-          $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
660
+          $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
661 661
         }
662 662
       } else {
663 663
         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
664 664
         // implement call back function if it exists
665 665
         $isSent = ($rt == 1) ? 1 : 0;
666
-        $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
666
+        $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
667 667
       }
668 668
     } else {
669 669
       if ($this->SingleTo === true && count($toArr) > 1) {
@@ -671,19 +671,19 @@  discard block
 block discarded – undo
671 671
           $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
672 672
           // implement call back function if it exists
673 673
           $isSent = ($rt == 1) ? 1 : 0;
674
-          $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
674
+          $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
675 675
         }
676 676
       } else {
677 677
         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
678 678
         // implement call back function if it exists
679 679
         $isSent = ($rt == 1) ? 1 : 0;
680
-        $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
680
+        $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
681 681
       }
682 682
     }
683 683
     if (isset($old_from)) {
684 684
       ini_set('sendmail_from', $old_from);
685 685
     }
686
-    if(!$rt) {
686
+    if (!$rt) {
687 687
       throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
688 688
     }
689 689
     return true;
@@ -702,61 +702,61 @@  discard block
 block discarded – undo
702 702
     require_once $this->PluginDir . 'smtp.php';
703 703
     $bad_rcpt = array();
704 704
 
705
-    if(!$this->SmtpConnect()) {
705
+    if (!$this->SmtpConnect()) {
706 706
       throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
707 707
     }
708 708
     $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
709
-    if(!$this->smtp->Mail($smtp_from)) {
709
+    if (!$this->smtp->Mail($smtp_from)) {
710 710
       throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
711 711
     }
712 712
 
713 713
     // Attempt to send attach all recipients
714
-    foreach($this->to as $to) {
714
+    foreach ($this->to as $to) {
715 715
       if (!$this->smtp->Recipient($to[0])) {
716 716
         $bad_rcpt[] = $to[0];
717 717
         // implement call back function if it exists
718 718
         $isSent = 0;
719
-        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
719
+        $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body);
720 720
       } else {
721 721
         // implement call back function if it exists
722 722
         $isSent = 1;
723
-        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
723
+        $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body);
724 724
       }
725 725
     }
726
-    foreach($this->cc as $cc) {
726
+    foreach ($this->cc as $cc) {
727 727
       if (!$this->smtp->Recipient($cc[0])) {
728 728
         $bad_rcpt[] = $cc[0];
729 729
         // implement call back function if it exists
730 730
         $isSent = 0;
731
-        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
731
+        $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body);
732 732
       } else {
733 733
         // implement call back function if it exists
734 734
         $isSent = 1;
735
-        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
735
+        $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body);
736 736
       }
737 737
     }
738
-    foreach($this->bcc as $bcc) {
738
+    foreach ($this->bcc as $bcc) {
739 739
       if (!$this->smtp->Recipient($bcc[0])) {
740 740
         $bad_rcpt[] = $bcc[0];
741 741
         // implement call back function if it exists
742 742
         $isSent = 0;
743
-        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
743
+        $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body);
744 744
       } else {
745 745
         // implement call back function if it exists
746 746
         $isSent = 1;
747
-        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
747
+        $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body);
748 748
       }
749 749
     }
750 750
 
751 751
 
752
-    if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
752
+    if (count($bad_rcpt) > 0) { //Create error message for any bad addresses
753 753
       $badaddresses = implode(', ', $bad_rcpt);
754 754
       throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
755 755
     }
756
-    if(!$this->smtp->Data($header . $body)) {
756
+    if (!$this->smtp->Data($header . $body)) {
757 757
       throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
758 758
     }
759
-    if($this->SMTPKeepAlive == true) {
759
+    if ($this->SMTPKeepAlive == true) {
760 760
       $this->smtp->Reset();
761 761
     }
762 762
     return true;
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
    * @return bool
771 771
    */
772 772
   public function SmtpConnect() {
773
-    if(is_null($this->smtp)) {
773
+    if (is_null($this->smtp)) {
774 774
       $this->smtp = new SMTP();
775 775
     }
776 776
 
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 
782 782
     // Retry while there is no connection
783 783
     try {
784
-      while($index < count($hosts) && !$connection) {
784
+      while ($index < count($hosts) && !$connection) {
785 785
       $hostinfo = array();
786 786
         if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) {
787 787
         $host = $hostinfo[1];
@@ -794,13 +794,13 @@  discard block
 block discarded – undo
794 794
       $tls = ($this->SMTPSecure == 'tls');
795 795
       $ssl = ($this->SMTPSecure == 'ssl');
796 796
 
797
-      if($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) {
797
+      if ($this->smtp->Connect(($ssl ? 'ssl://' : '') . $host, $port, $this->Timeout)) {
798 798
 
799 799
         $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname());
800 800
         $this->smtp->Hello($hello);
801 801
 
802
-        if($tls) {
803
-          if(!$this->smtp->StartTLS()) {
802
+        if ($tls) {
803
+          if (!$this->smtp->StartTLS()) {
804 804
               throw new phpmailerException($this->Lang('tls'));
805 805
           }
806 806
 
@@ -809,14 +809,14 @@  discard block
 block discarded – undo
809 809
         }
810 810
 
811 811
         $connection = true;
812
-        if($this->SMTPAuth) {
813
-          if(!$this->smtp->Authenticate($this->Username, $this->Password)) {
812
+        if ($this->SMTPAuth) {
813
+          if (!$this->smtp->Authenticate($this->Username, $this->Password)) {
814 814
               throw new phpmailerException($this->Lang('authenticate'));
815 815
           }
816 816
         }
817 817
       }
818 818
       $index++;
819
-    if(!$connection) {
819
+    if (!$connection) {
820 820
           throw new phpmailerException($this->Lang('connect_host'));
821 821
     }
822 822
       }
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
    * @return void
833 833
    */
834 834
   public function SmtpClose() {
835
-    if(!is_null($this->smtp)) {
836
-      if($this->smtp->Connected()) {
835
+    if (!is_null($this->smtp)) {
836
+      if ($this->smtp->Connected()) {
837 837
         $this->smtp->Quit();
838 838
         $this->smtp->Close();
839 839
       }
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
     //Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"!
872 872
     $l = true;
873 873
     if ($langcode != 'en') { //There is no English translation file
874
-      $l = @include $lang_path.'phpmailer.lang-'.$langcode.'.php';
874
+      $l = @include $lang_path . 'phpmailer.lang-' . $langcode . '.php';
875 875
     }
876 876
     $this->language = $PHPMAILER_LANG;
877 877
     return ($l == true); //Returns false if language not found
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
    * @return string
913 913
    */
914 914
   public function AddrFormat($addr) {
915
-    if(empty($addr[1])) {
915
+    if (empty($addr[1])) {
916 916
       return $this->SecureHeader($addr[0]);
917 917
     } else {
918 918
       return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
@@ -942,10 +942,10 @@  discard block
 block discarded – undo
942 942
 
943 943
     $line = explode($this->LE, $message);
944 944
     $message = '';
945
-    for ($i=0 ;$i < count($line); $i++) {
945
+    for ($i = 0; $i < count($line); $i++) {
946 946
       $line_part = explode(' ', $line[$i]);
947 947
       $buf = '';
948
-      for ($e = 0; $e<count($line_part); $e++) {
948
+      for ($e = 0; $e < count($line_part); $e++) {
949 949
         $word = $line_part[$e];
950 950
         if ($qp_mode and (strlen($word) > $length)) {
951 951
           $space_left = $length - strlen($buf) - 1;
@@ -1025,8 +1025,7 @@  discard block
 block discarded – undo
1025 1025
         if ($dec < 128) { // Single byte character.
1026 1026
           // If the encoded char was found at pos 0, it will fit
1027 1027
           // otherwise reduce maxLength to start of the encoded char
1028
-          $maxLength = ($encodedCharPos == 0) ? $maxLength :
1029
-          $maxLength - ($lookBack - $encodedCharPos);
1028
+          $maxLength = ($encodedCharPos == 0) ? $maxLength : $maxLength - ($lookBack - $encodedCharPos);
1030 1029
           $foundSplitPos = true;
1031 1030
         } elseif ($dec >= 192) { // First byte of a multi byte character
1032 1031
           // Reduce maxLength to split at start of character
@@ -1050,11 +1049,11 @@  discard block
 block discarded – undo
1050 1049
    * @return void
1051 1050
    */
1052 1051
   public function SetWordWrap() {
1053
-    if($this->WordWrap < 1) {
1052
+    if ($this->WordWrap < 1) {
1054 1053
       return;
1055 1054
     }
1056 1055
 
1057
-    switch($this->message_type) {
1056
+    switch ($this->message_type) {
1058 1057
       case 'alt':
1059 1058
       case 'alt_attachments':
1060 1059
         $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
@@ -1079,20 +1078,20 @@  discard block
 block discarded – undo
1079 1078
     $this->boundary[2] = 'b2_' . $uniq_id;
1080 1079
 
1081 1080
     $result .= $this->HeaderLine('Date', self::RFCDate());
1082
-    if($this->Sender == '') {
1081
+    if ($this->Sender == '') {
1083 1082
       $result .= $this->HeaderLine('Return-Path', trim($this->From));
1084 1083
     } else {
1085 1084
       $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
1086 1085
     }
1087 1086
 
1088 1087
     // To be created automatically by mail()
1089
-    if($this->Mailer != 'mail') {
1088
+    if ($this->Mailer != 'mail') {
1090 1089
       if ($this->SingleTo === true) {
1091
-        foreach($this->to as $t) {
1090
+        foreach ($this->to as $t) {
1092 1091
           $this->SingleToArray[] = $this->AddrFormat($t);
1093 1092
         }
1094 1093
       } else {
1095
-      if(count($this->to) > 0) {
1094
+      if (count($this->to) > 0) {
1096 1095
         $result .= $this->AddrAppend('To', $this->to);
1097 1096
       } elseif (count($this->cc) == 0) {
1098 1097
         $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
@@ -1106,38 +1105,38 @@  discard block
 block discarded – undo
1106 1105
     $result .= $this->AddrAppend('From', $from);
1107 1106
 
1108 1107
     // sendmail and mail() extract Cc from the header before sending
1109
-    if(count($this->cc) > 0) {
1108
+    if (count($this->cc) > 0) {
1110 1109
       $result .= $this->AddrAppend('Cc', $this->cc);
1111 1110
     }
1112 1111
 
1113 1112
     // sendmail and mail() extract Bcc from the header before sending
1114
-    if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
1113
+    if ((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
1115 1114
       $result .= $this->AddrAppend('Bcc', $this->bcc);
1116 1115
     }
1117 1116
 
1118
-    if(count($this->ReplyTo) > 0) {
1117
+    if (count($this->ReplyTo) > 0) {
1119 1118
       $result .= $this->AddrAppend('Reply-to', $this->ReplyTo);
1120 1119
     }
1121 1120
 
1122 1121
     // mail() sets the subject itself
1123
-    if($this->Mailer != 'mail') {
1122
+    if ($this->Mailer != 'mail') {
1124 1123
       $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
1125 1124
     }
1126 1125
 
1127
-    if($this->MessageID != '') {
1128
-      $result .= $this->HeaderLine('Message-ID',$this->MessageID);
1126
+    if ($this->MessageID != '') {
1127
+      $result .= $this->HeaderLine('Message-ID', $this->MessageID);
1129 1128
     } else {
1130 1129
       $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
1131 1130
     }
1132 1131
     $result .= $this->HeaderLine('X-Priority', $this->Priority);
1133
-    $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)');
1132
+    $result .= $this->HeaderLine('X-Mailer', 'PHPMailer ' . $this->Version . ' (phpmailer.sourceforge.net)');
1134 1133
 
1135
-    if($this->ConfirmReadingTo != '') {
1134
+    if ($this->ConfirmReadingTo != '') {
1136 1135
       $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
1137 1136
     }
1138 1137
 
1139 1138
     // Add custom headers
1140
-    for($index = 0; $index < count($this->CustomHeader); $index++) {
1139
+    for ($index = 0; $index < count($this->CustomHeader); $index++) {
1141 1140
       $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
1142 1141
     }
1143 1142
     if (!$this->sign_key_file) {
@@ -1155,14 +1154,14 @@  discard block
 block discarded – undo
1155 1154
    */
1156 1155
   public function GetMailMIME() {
1157 1156
     $result = '';
1158
-    switch($this->message_type) {
1157
+    switch ($this->message_type) {
1159 1158
       case 'plain':
1160 1159
         $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
1161 1160
         $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
1162 1161
         break;
1163 1162
       case 'attachments':
1164 1163
       case 'alt_attachments':
1165
-        if($this->InlineImageExists()){
1164
+        if ($this->InlineImageExists()) {
1166 1165
           $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
1167 1166
         } else {
1168 1167
           $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
@@ -1175,8 +1174,8 @@  discard block
 block discarded – undo
1175 1174
         break;
1176 1175
     }
1177 1176
 
1178
-    if($this->Mailer != 'mail') {
1179
-      $result .= $this->LE.$this->LE;
1177
+    if ($this->Mailer != 'mail') {
1178
+      $result .= $this->LE . $this->LE;
1180 1179
     }
1181 1180
 
1182 1181
     return $result;
@@ -1196,14 +1195,14 @@  discard block
 block discarded – undo
1196 1195
 
1197 1196
     $this->SetWordWrap();
1198 1197
 
1199
-    switch($this->message_type) {
1198
+    switch ($this->message_type) {
1200 1199
       case 'alt':
1201 1200
         $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
1202 1201
         $body .= $this->EncodeString($this->AltBody, $this->Encoding);
1203
-        $body .= $this->LE.$this->LE;
1202
+        $body .= $this->LE . $this->LE;
1204 1203
         $body .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
1205 1204
         $body .= $this->EncodeString($this->Body, $this->Encoding);
1206
-        $body .= $this->LE.$this->LE;
1205
+        $body .= $this->LE . $this->LE;
1207 1206
         $body .= $this->EndBoundary($this->boundary[1]);
1208 1207
         break;
1209 1208
       case 'plain':
@@ -1217,33 +1216,33 @@  discard block
 block discarded – undo
1217 1216
         break;
1218 1217
       case 'alt_attachments':
1219 1218
         $body .= sprintf("--%s%s", $this->boundary[1], $this->LE);
1220
-        $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
1219
+        $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE . $this->LE);
1221 1220
         $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
1222 1221
         $body .= $this->EncodeString($this->AltBody, $this->Encoding);
1223
-        $body .= $this->LE.$this->LE;
1222
+        $body .= $this->LE . $this->LE;
1224 1223
         $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
1225 1224
         $body .= $this->EncodeString($this->Body, $this->Encoding);
1226
-        $body .= $this->LE.$this->LE;
1225
+        $body .= $this->LE . $this->LE;
1227 1226
         $body .= $this->EndBoundary($this->boundary[2]);
1228 1227
         $body .= $this->AttachAll();
1229 1228
         break;
1230 1229
     }
1231 1230
 
1232
-    if($this->IsError()) {
1231
+    if ($this->IsError()) {
1233 1232
       $body = '';
1234 1233
     } else if ($this->sign_key_file) {
1235 1234
       try {
1236 1235
         $file = tempnam('', 'mail');
1237 1236
         file_put_contents($file, $body, LOCK_EX); //TODO check this worked
1238 1237
       $signed = tempnam("", "signed");
1239
-        if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) {
1238
+        if (@openssl_pkcs7_sign($file, $signed, "file://" . $this->sign_cert_file, array("file://" . $this->sign_key_file, $this->sign_key_pass), NULL)) {
1240 1239
           @unlink($file);
1241 1240
           @unlink($signed);
1242 1241
           $body = file_get_contents($signed);
1243 1242
       } else {
1244 1243
           @unlink($file);
1245 1244
           @unlink($signed);
1246
-          throw new phpmailerException($this->Lang("signing").openssl_error_string());
1245
+          throw new phpmailerException($this->Lang("signing") . openssl_error_string());
1247 1246
         }
1248 1247
       } catch (phpmailerException $e) {
1249 1248
         $body = '';
@@ -1262,13 +1261,13 @@  discard block
 block discarded – undo
1262 1261
    */
1263 1262
   private function GetBoundary($boundary, $charSet, $contentType, $encoding) {
1264 1263
     $result = '';
1265
-    if($charSet == '') {
1264
+    if ($charSet == '') {
1266 1265
       $charSet = $this->CharSet;
1267 1266
     }
1268
-    if($contentType == '') {
1267
+    if ($contentType == '') {
1269 1268
       $contentType = $this->ContentType;
1270 1269
     }
1271
-    if($encoding == '') {
1270
+    if ($encoding == '') {
1272 1271
       $encoding = $this->Encoding;
1273 1272
     }
1274 1273
     $result .= $this->TextLine('--' . $boundary);
@@ -1294,16 +1293,16 @@  discard block
 block discarded – undo
1294 1293
    * @return void
1295 1294
    */
1296 1295
   private function SetMessageType() {
1297
-    if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
1296
+    if (count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
1298 1297
       $this->message_type = 'plain';
1299 1298
     } else {
1300
-      if(count($this->attachment) > 0) {
1299
+      if (count($this->attachment) > 0) {
1301 1300
         $this->message_type = 'attachments';
1302 1301
       }
1303
-      if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
1302
+      if (strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
1304 1303
         $this->message_type = 'alt';
1305 1304
       }
1306
-      if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
1305
+      if (strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
1307 1306
         $this->message_type = 'alt_attachments';
1308 1307
       }
1309 1308
     }
@@ -1343,11 +1342,11 @@  discard block
 block discarded – undo
1343 1342
    */
1344 1343
   public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1345 1344
     try {
1346
-    if(!@is_file($path)) {
1345
+    if (!@is_file($path)) {
1347 1346
         throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
1348 1347
     }
1349 1348
     $filename = basename($path);
1350
-    if($name == '') {
1349
+    if ($name == '') {
1351 1350
       $name = $filename;
1352 1351
     }
1353 1352
 
@@ -1357,7 +1356,7 @@  discard block
 block discarded – undo
1357 1356
         2 => $name,
1358 1357
         3 => $encoding,
1359 1358
         4 => $type,
1360
-        5 => false,  // isStringAttachment
1359
+        5 => false, // isStringAttachment
1361 1360
         6 => 'attachment',
1362 1361
         7 => 0
1363 1362
       );
@@ -1367,8 +1366,8 @@  discard block
 block discarded – undo
1367 1366
       if ($this->exceptions) {
1368 1367
         throw $e;
1369 1368
       }
1370
-      echo $e->getMessage()."\n";
1371
-      if ( $e->getCode() == self::STOP_CRITICAL ) {
1369
+      echo $e->getMessage() . "\n";
1370
+      if ($e->getCode() == self::STOP_CRITICAL) {
1372 1371
         return false;
1373 1372
       }
1374 1373
     }
@@ -1413,32 +1412,32 @@  discard block
 block discarded – undo
1413 1412
       $disposition = $attachment[6];
1414 1413
       $cid         = $attachment[7];
1415 1414
       $incl[]      = $attachment[0];
1416
-      if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; }
1415
+      if ($disposition == 'inline' && isset($cidUniq[$cid])) { continue; }
1417 1416
       $cidUniq[$cid] = true;
1418 1417
 
1419 1418
       $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
1420 1419
       $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE);
1421 1420
       $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
1422 1421
 
1423
-      if($disposition == 'inline') {
1422
+      if ($disposition == 'inline') {
1424 1423
         $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
1425 1424
       }
1426 1425
 
1427
-      $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE);
1426
+      $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE . $this->LE);
1428 1427
 
1429 1428
       // Encode as string attachment
1430
-      if($bString) {
1429
+      if ($bString) {
1431 1430
         $mime[] = $this->EncodeString($string, $encoding);
1432
-        if($this->IsError()) {
1431
+        if ($this->IsError()) {
1433 1432
           return '';
1434 1433
         }
1435
-        $mime[] = $this->LE.$this->LE;
1434
+        $mime[] = $this->LE . $this->LE;
1436 1435
       } else {
1437 1436
         $mime[] = $this->EncodeFile($path, $encoding);
1438
-        if($this->IsError()) {
1437
+        if ($this->IsError()) {
1439 1438
           return '';
1440 1439
         }
1441
-        $mime[] = $this->LE.$this->LE;
1440
+        $mime[] = $this->LE . $this->LE;
1442 1441
       }
1443 1442
     }
1444 1443
 
@@ -1488,9 +1487,9 @@  discard block
 block discarded – undo
1488 1487
    * @access public
1489 1488
    * @return string
1490 1489
    */
1491
-  public function EncodeString ($str, $encoding = 'base64') {
1490
+  public function EncodeString($str, $encoding = 'base64') {
1492 1491
     $encoded = '';
1493
-    switch(strtolower($encoding)) {
1492
+    switch (strtolower($encoding)) {
1494 1493
       case 'base64':
1495 1494
         $encoded = chunk_split(base64_encode($str), 76, $this->LE);
1496 1495
         break;
@@ -1519,7 +1518,7 @@  discard block
 block discarded – undo
1519 1518
    * @access public
1520 1519
    * @return string
1521 1520
    */
1522
-  public function EncodeHeader ($str, $position = 'text') {
1521
+  public function EncodeHeader($str, $position = 'text') {
1523 1522
     $x = 0;
1524 1523
 
1525 1524
     switch (strtolower($position)) {
@@ -1550,7 +1549,7 @@  discard block
 block discarded – undo
1550 1549
 
1551 1550
     $maxlen = 75 - 7 - strlen($this->CharSet);
1552 1551
     // Try to select the encoding which should produce the shortest output
1553
-    if (strlen($str)/3 < $x) {
1552
+    if (strlen($str) / 3 < $x) {
1554 1553
       $encoding = 'B';
1555 1554
       if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
1556 1555
      // Use a custom function which correctly encodes and wraps long
@@ -1565,10 +1564,10 @@  discard block
 block discarded – undo
1565 1564
       $encoding = 'Q';
1566 1565
       $encoded = $this->EncodeQ($str, $position);
1567 1566
       $encoded = $this->WrapText($encoded, $maxlen, true);
1568
-      $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
1567
+      $encoded = str_replace('=' . $this->LE, "\n", trim($encoded));
1569 1568
     }
1570 1569
 
1571
-    $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
1570
+    $encoded = preg_replace('/^(.*)$/m', " =?" . $this->CharSet . "?$encoding?\\1?=", $encoded);
1572 1571
     $encoded = trim(str_replace("\n", $this->LE, $encoded));
1573 1572
 
1574 1573
     return $encoded;
@@ -1597,7 +1596,7 @@  discard block
 block discarded – undo
1597 1596
    * @return string
1598 1597
    */
1599 1598
   public function Base64EncodeWrapMB($str) {
1600
-    $start = "=?".$this->CharSet."?B?";
1599
+    $start = "=?" . $this->CharSet . "?B?";
1601 1600
     $end = "?=";
1602 1601
     $encoded = "";
1603 1602
 
@@ -1636,43 +1635,43 @@  discard block
 block discarded – undo
1636 1635
   * @param integer $line_max Number of chars allowed on a line before wrapping
1637 1636
   * @return string
1638 1637
   */
1639
-  public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) {
1640
-    $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
1638
+  public function EncodeQPphp($input = '', $line_max = 76, $space_conv = false) {
1639
+    $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
1641 1640
     $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
1642 1641
     $eol = "\r\n";
1643 1642
     $escape = '=';
1644 1643
     $output = '';
1645
-    while( list(, $line) = each($lines) ) {
1644
+    while (list(, $line) = each($lines)) {
1646 1645
       $linlen = strlen($line);
1647 1646
       $newline = '';
1648
-      for($i = 0; $i < $linlen; $i++) {
1649
-        $c = substr( $line, $i, 1 );
1650
-        $dec = ord( $c );
1651
-        if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
1647
+      for ($i = 0; $i < $linlen; $i++) {
1648
+        $c = substr($line, $i, 1);
1649
+        $dec = ord($c);
1650
+        if (($i == 0) && ($dec == 46)) { // convert first point in the line into =2E
1652 1651
           $c = '=2E';
1653 1652
         }
1654
-        if ( $dec == 32 ) {
1655
-          if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
1653
+        if ($dec == 32) {
1654
+          if ($i == ($linlen - 1)) { // convert space at eol only
1656 1655
             $c = '=20';
1657
-          } else if ( $space_conv ) {
1656
+          } else if ($space_conv) {
1658 1657
             $c = '=20';
1659 1658
           }
1660
-        } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
1661
-          $h2 = floor($dec/16);
1662
-          $h1 = floor($dec%16);
1663
-          $c = $escape.$hex[$h2].$hex[$h1];
1659
+        } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required
1660
+          $h2 = floor($dec / 16);
1661
+          $h1 = floor($dec % 16);
1662
+          $c = $escape . $hex[$h2] . $hex[$h1];
1664 1663
         }
1665
-        if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
1666
-          $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay
1664
+        if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted
1665
+          $output .= $newline . $escape . $eol; //  soft line break; " =\r\n" is okay
1667 1666
           $newline = '';
1668 1667
           // check if newline first character will be point or not
1669
-          if ( $dec == 46 ) {
1668
+          if ($dec == 46) {
1670 1669
             $c = '=2E';
1671 1670
           }
1672 1671
         }
1673 1672
         $newline .= $c;
1674 1673
       } // end of for
1675
-      $output .= $newline.$eol;
1674
+      $output .= $newline . $eol;
1676 1675
     } // end of while
1677 1676
     return $output;
1678 1677
   }
@@ -1718,16 +1717,16 @@  discard block
 block discarded – undo
1718 1717
    * @access public
1719 1718
    * @return string
1720 1719
    */
1721
-  public function EncodeQ ($str, $position = 'text') {
1720
+  public function EncodeQ($str, $position = 'text') {
1722 1721
     // There should not be any EOL in the string
1723 1722
     $encoded = preg_replace('/[\r\n]*/', '', $str);
1724 1723
 
1725 1724
     switch (strtolower($position)) {
1726 1725
       case 'phrase':
1727
-		$encoded = preg_replace_callback('/([^A-Za-z0-9!*+\/ -])/', function($n) { return '='.sprintf('%02X', ord('\\1')); }, $encoded);
1726
+		$encoded = preg_replace_callback('/([^A-Za-z0-9!*+\/ -])/', function($n) { return '=' . sprintf('%02X', ord('\\1')); }, $encoded);
1728 1727
         break;
1729 1728
       case 'comment':
1730
-		$encoded = preg_replace_callback('/([\(\)\"])/', function($n) { return '='.sprintf('%02X', ord('\\1')); }, $encoded);
1729
+		$encoded = preg_replace_callback('/([\(\)\"])/', function($n) { return '=' . sprintf('%02X', ord('\\1')); }, $encoded);
1731 1730
       case 'text':
1732 1731
       default:
1733 1732
         // Replace every high ascii, control =, ? and _ characters
@@ -1761,7 +1760,7 @@  discard block
 block discarded – undo
1761 1760
       2 => basename($filename),
1762 1761
       3 => $encoding,
1763 1762
       4 => $type,
1764
-      5 => true,  // isStringAttachment
1763
+      5 => true, // isStringAttachment
1765 1764
       6 => 'attachment',
1766 1765
       7 => 0
1767 1766
     );
@@ -1782,13 +1781,13 @@  discard block
 block discarded – undo
1782 1781
    */
1783 1782
   public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1784 1783
 
1785
-    if(!@is_file($path)) {
1784
+    if (!@is_file($path)) {
1786 1785
       $this->SetError($this->Lang('file_access') . $path);
1787 1786
       return false;
1788 1787
     }
1789 1788
 
1790 1789
     $filename = basename($path);
1791
-    if($name == '') {
1790
+    if ($name == '') {
1792 1791
       $name = $filename;
1793 1792
     }
1794 1793
 
@@ -1799,7 +1798,7 @@  discard block
 block discarded – undo
1799 1798
       2 => $name,
1800 1799
       3 => $encoding,
1801 1800
       4 => $type,
1802
-      5 => false,  // isStringAttachment
1801
+      5 => false, // isStringAttachment
1803 1802
       6 => 'inline',
1804 1803
       7 => $cid
1805 1804
     );
@@ -1813,7 +1812,7 @@  discard block
 block discarded – undo
1813 1812
    * @return bool
1814 1813
    */
1815 1814
   public function InlineImageExists() {
1816
-    foreach($this->attachment as $attachment) {
1815
+    foreach ($this->attachment as $attachment) {
1817 1816
       if ($attachment[6] == 'inline') {
1818 1817
         return true;
1819 1818
       }
@@ -1830,7 +1829,7 @@  discard block
 block discarded – undo
1830 1829
    * @return void
1831 1830
    */
1832 1831
   public function ClearAddresses() {
1833
-    foreach($this->to as $to) {
1832
+    foreach ($this->to as $to) {
1834 1833
       unset($this->all_recipients[strtolower($to[0])]);
1835 1834
     }
1836 1835
     $this->to = array();
@@ -1841,7 +1840,7 @@  discard block
 block discarded – undo
1841 1840
    * @return void
1842 1841
    */
1843 1842
   public function ClearCCs() {
1844
-    foreach($this->cc as $cc) {
1843
+    foreach ($this->cc as $cc) {
1845 1844
       unset($this->all_recipients[strtolower($cc[0])]);
1846 1845
     }
1847 1846
     $this->cc = array();
@@ -1852,7 +1851,7 @@  discard block
 block discarded – undo
1852 1851
    * @return void
1853 1852
    */
1854 1853
   public function ClearBCCs() {
1855
-    foreach($this->bcc as $bcc) {
1854
+    foreach ($this->bcc as $bcc) {
1856 1855
       unset($this->all_recipients[strtolower($bcc[0])]);
1857 1856
     }
1858 1857
     $this->bcc = array();
@@ -1925,7 +1924,7 @@  discard block
 block discarded – undo
1925 1924
     $tz = date('Z');
1926 1925
     $tzs = ($tz < 0) ? '-' : '+';
1927 1926
     $tz = abs($tz);
1928
-    $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
1927
+    $tz = (int) ($tz / 3600) * 100 + ($tz % 3600) / 60;
1929 1928
     $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
1930 1929
 
1931 1930
     return $result;
@@ -1954,11 +1953,11 @@  discard block
 block discarded – undo
1954 1953
    * @return string
1955 1954
    */
1956 1955
   private function Lang($key) {
1957
-    if(count($this->language) < 1) {
1956
+    if (count($this->language) < 1) {
1958 1957
       $this->SetLanguage('en'); // set the default language
1959 1958
     }
1960 1959
 
1961
-    if(isset($this->language[$key])) {
1960
+    if (isset($this->language[$key])) {
1962 1961
       return $this->language[$key];
1963 1962
     } else {
1964 1963
       return 'Language string failed to load: ' . $key;
@@ -2000,33 +1999,33 @@  discard block
 block discarded – undo
2000 1999
    * @access public
2001 2000
    * @return $message
2002 2001
    */
2003
-  public function MsgHTML($message,$basedir='') {
2002
+  public function MsgHTML($message, $basedir = '') {
2004 2003
     preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
2005
-    if(isset($images[2])) {
2006
-      foreach($images[2] as $i => $url) {
2004
+    if (isset($images[2])) {
2005
+      foreach ($images[2] as $i => $url) {
2007 2006
         // do not change urls for absolute images (thanks to corvuscorax)
2008
-        if (!preg_match('#^[A-z]+://#',$url)) {
2007
+        if (!preg_match('#^[A-z]+://#', $url)) {
2009 2008
           $filename = basename($url);
2010 2009
           $directory = dirname($url);
2011
-          ($directory == '.')?$directory='':'';
2010
+          ($directory == '.') ? $directory = '' : '';
2012 2011
           $cid = 'cid:' . md5($filename);
2013 2012
           $ext = pathinfo($filename, PATHINFO_EXTENSION);
2014
-          $mimeType  = self::_mime_types($ext);
2015
-          if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
2016
-          if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
2017
-          if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
2018
-            $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
2013
+          $mimeType = self::_mime_types($ext);
2014
+          if (strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; }
2015
+          if (strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; }
2016
+          if ($this->AddEmbeddedImage($basedir . $directory . $filename, md5($filename), $filename, 'base64', $mimeType)) {
2017
+            $message = preg_replace("/" . $images[1][$i] . "=\"" . preg_quote($url, '/') . "\"/Ui", $images[1][$i] . "=\"" . $cid . "\"", $message);
2019 2018
           }
2020 2019
         }
2021 2020
       }
2022 2021
     }
2023 2022
     $this->IsHTML(true);
2024 2023
     $this->Body = $message;
2025
-    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
2026
-    if ( !empty($textMsg) && empty($this->AltBody) ) {
2024
+    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message)));
2025
+    if (!empty($textMsg) && empty($this->AltBody)) {
2027 2026
       $this->AltBody = html_entity_decode($textMsg);
2028 2027
     }
2029
-    if ( empty($this->AltBody) ) {
2028
+    if (empty($this->AltBody)) {
2030 2029
       $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
2031 2030
     }
2032 2031
   }
@@ -2128,7 +2127,7 @@  discard block
 block discarded – undo
2128 2127
       'xl'    =>  'application/excel',
2129 2128
       'eml'   =>  'message/rfc822'
2130 2129
     );
2131
-    return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
2130
+    return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
2132 2131
   }
2133 2132
 
2134 2133
   /**
@@ -2143,9 +2142,9 @@  discard block
 block discarded – undo
2143 2142
    * NOTE: will not work with arrays, there are no arrays to set/reset
2144 2143
   * @todo Should this not be using __set() magic function?
2145 2144
    */
2146
-  public function set ( $name, $value = '' ) {
2145
+  public function set($name, $value = '') {
2147 2146
     try {
2148
-    if ( isset($this->$name) ) {
2147
+    if (isset($this->$name)) {
2149 2148
       $this->$name = $value;
2150 2149
     } else {
2151 2150
         throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL);
@@ -2192,14 +2191,14 @@  discard block
 block discarded – undo
2192 2191
    * @param string $key_pass Password for private key
2193 2192
    */
2194 2193
   public function DKIM_QP($txt) {
2195
-    $tmp="";
2196
-    $line="";
2197
-    for ($i=0;$i<strlen($txt);$i++) {
2198
-      $ord=ord($txt[$i]);
2199
-      if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) {
2200
-        $line.=$txt[$i];
2194
+    $tmp = "";
2195
+    $line = "";
2196
+    for ($i = 0; $i < strlen($txt); $i++) {
2197
+      $ord = ord($txt[$i]);
2198
+      if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
2199
+        $line .= $txt[$i];
2201 2200
       } else {
2202
-        $line.="=".sprintf("%02X",$ord);
2201
+        $line .= "=" . sprintf("%02X", $ord);
2203 2202
       }
2204 2203
     }
2205 2204
     return $line;
@@ -2213,8 +2212,8 @@  discard block
 block discarded – undo
2213 2212
    */
2214 2213
   public function DKIM_Sign($s) {
2215 2214
     $privKeyStr = file_get_contents($this->DKIM_private);
2216
-    if ($this->DKIM_passphrase!='') {
2217
-      $privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
2215
+    if ($this->DKIM_passphrase != '') {
2216
+      $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
2218 2217
     } else {
2219 2218
       $privKey = $privKeyStr;
2220 2219
     }
@@ -2230,15 +2229,15 @@  discard block
 block discarded – undo
2230 2229
    * @param string $s Header
2231 2230
    */
2232 2231
   public function DKIM_HeaderC($s) {
2233
-    $s=preg_replace("/\r\n\s+/"," ",$s);
2234
-    $lines=explode("\r\n",$s);
2232
+    $s = preg_replace("/\r\n\s+/", " ", $s);
2233
+    $lines = explode("\r\n", $s);
2235 2234
     foreach ($lines as $key=>$line) {
2236
-      list($heading,$value)=explode(":",$line,2);
2237
-      $heading=strtolower($heading);
2238
-      $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces
2239
-      $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value
2235
+      list($heading, $value) = explode(":", $line, 2);
2236
+      $heading = strtolower($heading);
2237
+      $value = preg_replace("/\s+/", " ", $value); // Compress useless spaces
2238
+      $lines[$key] = $heading . ":" . trim($value); // Don't forget to remove WSP around the value
2240 2239
     }
2241
-    $s=implode("\r\n",$lines);
2240
+    $s = implode("\r\n", $lines);
2242 2241
     return $s;
2243 2242
   }
2244 2243
 
@@ -2251,11 +2250,11 @@  discard block
 block discarded – undo
2251 2250
   public function DKIM_BodyC($body) {
2252 2251
     if ($body == '') return "\r\n";
2253 2252
     // stabilize line endings
2254
-    $body=str_replace("\r\n","\n",$body);
2255
-    $body=str_replace("\n","\r\n",$body);
2253
+    $body = str_replace("\r\n", "\n", $body);
2254
+    $body = str_replace("\n", "\r\n", $body);
2256 2255
     // END stabilize line endings
2257
-    while (substr($body,strlen($body)-4,4) == "\r\n\r\n") {
2258
-      $body=substr($body,0,strlen($body)-2);
2256
+    while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") {
2257
+      $body = substr($body, 0, strlen($body) - 2);
2259 2258
     }
2260 2259
     return $body;
2261 2260
   }
@@ -2268,45 +2267,45 @@  discard block
 block discarded – undo
2268 2267
    * @param string $subject Subject
2269 2268
    * @param string $body Body
2270 2269
    */
2271
-  public function DKIM_Add($headers_line,$subject,$body) {
2270
+  public function DKIM_Add($headers_line, $subject, $body) {
2272 2271
     $DKIMsignatureType    = 'rsa-sha1'; // Signature & hash algorithms
2273 2272
     $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
2274 2273
     $DKIMquery            = 'dns/txt'; // Query method
2275
-    $DKIMtime             = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
2274
+    $DKIMtime             = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
2276 2275
     $subject_header       = "Subject: $subject";
2277
-    $headers              = explode("\r\n",$headers_line);
2278
-    foreach($headers as $header) {
2279
-      if (strpos($header,'From:') === 0) {
2280
-        $from_header=$header;
2281
-      } elseif (strpos($header,'To:') === 0) {
2282
-        $to_header=$header;
2276
+    $headers              = explode("\r\n", $headers_line);
2277
+    foreach ($headers as $header) {
2278
+      if (strpos($header, 'From:') === 0) {
2279
+        $from_header = $header;
2280
+      } elseif (strpos($header, 'To:') === 0) {
2281
+        $to_header = $header;
2283 2282
       }
2284 2283
     }
2285
-    $from     = str_replace('|','=7C',$this->DKIM_QP($from_header));
2286
-    $to       = str_replace('|','=7C',$this->DKIM_QP($to_header));
2287
-    $subject  = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable
2284
+    $from     = str_replace('|', '=7C', $this->DKIM_QP($from_header));
2285
+    $to       = str_replace('|', '=7C', $this->DKIM_QP($to_header));
2286
+    $subject  = str_replace('|', '=7C', $this->DKIM_QP($subject_header)); // Copied header fields (dkim-quoted-printable
2288 2287
     $body     = $this->DKIM_BodyC($body);
2289
-    $DKIMlen  = strlen($body) ; // Length of body
2290
-    $DKIMb64  = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body
2291
-    $ident    = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";";
2292
-    $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n".
2293
-                "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n".
2294
-                "\th=From:To:Subject;\r\n".
2295
-                "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n".
2296
-                "\tz=$from\r\n".
2297
-                "\t|$to\r\n".
2298
-                "\t|$subject;\r\n".
2299
-                "\tbh=" . $DKIMb64 . ";\r\n".
2288
+    $DKIMlen  = strlen($body); // Length of body
2289
+    $DKIMb64  = base64_encode(pack("H*", sha1($body))); // Base64 of packed binary SHA-1 hash of body
2290
+    $ident    = ($this->DKIM_identity == '') ? '' : " i=" . $this->DKIM_identity . ";";
2291
+    $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n" .
2292
+                "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n" .
2293
+                "\th=From:To:Subject;\r\n" .
2294
+                "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n" .
2295
+                "\tz=$from\r\n" .
2296
+                "\t|$to\r\n" .
2297
+                "\t|$subject;\r\n" .
2298
+                "\tbh=" . $DKIMb64 . ";\r\n" .
2300 2299
                 "\tb=";
2301 2300
     $toSign   = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs);
2302 2301
     $signed   = $this->DKIM_Sign($toSign);
2303
-    return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n";
2302
+    return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n" . $dkimhdrs . $signed . "\r\n";
2304 2303
   }
2305 2304
 
2306
-  protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) {
2305
+  protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body) {
2307 2306
     if (!empty($this->action_function) && function_exists($this->action_function)) {
2308
-      $params = array($isSent,$to,$cc,$bcc,$subject,$body);
2309
-      call_user_func_array($this->action_function,$params);
2307
+      $params = array($isSent, $to, $cc, $bcc, $subject, $body);
2308
+      call_user_func_array($this->action_function, $params);
2310 2309
     }
2311 2310
   }
2312 2311
 }
Please login to merge, or discard this patch.