GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( e39801...b79b58 )
by Marco
03:51
created
contrib/ipImap/report/calendar/calendar_functions.php 1 patch
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,14 +2,18 @@  discard block
 block discarded – undo
2 2
 function filterInput($str, $type = "text"){
3 3
 	switch(strtolower($type)){
4 4
 		case "number":
5
-			if(is_numeric($str))
6
-				return array(true, $str);
7
-			else return array(false, "Invalid input - '$str', required number");
5
+			if(is_numeric($str)) {
6
+							return array(true, $str);
7
+			} else {
8
+				return array(false, "Invalid input - '$str', required number");
9
+			}
8 10
 			break;
9 11
 		case "boolean":
10
-			if($str == "" || $str == 0 || $str == 1 || is_bool($str))
11
-				return array(true, $str);
12
-			else return array(false, "Invalid input - '$str', required boolean");
12
+			if($str == "" || $str == 0 || $str == 1 || is_bool($str)) {
13
+							return array(true, $str);
14
+			} else {
15
+				return array(false, "Invalid input - '$str', required boolean");
16
+			}
13 17
 			break;
14 18
 		default:
15 19
 			//$str = addslashes($str);
@@ -26,8 +30,10 @@  discard block
 block discarded – undo
26 30
 	$result_txt = isset($results[1]) ? $results[1] : "";
27 31
 	if(isset($results[0]) && $results[0] === true){
28 32
 		return $result_txt;
29
-	}else exit("Error returned '$name' - ".$result_txt);
30
-}
33
+	} else {
34
+		exit("Error returned '$name' - ".$result_txt);
35
+	}
36
+	}
31 37
 
32 38
 function getTranslatedTxt($txt, $allow_tag = false, $maps = array()){
33 39
 	$content = $txt;
Please login to merge, or discard this patch.
contrib/ipImap/report/calendar/calendar_info.php 1 patch
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,9 +2,15 @@  discard block
 block discarded – undo
2 2
 require_once("classes/tc_calendar.php");
3 3
 require_once("classes/tc_date.php");
4 4
 
5
-if(!isset($show_calendar_info)) $show_calendar_info = true;
6
-if(!isset($show_fb_info)) $show_fb_info = true;
7
-if(!isset($show_servertime_info)) $show_servertime_info = true;
5
+if(!isset($show_calendar_info)) {
6
+	$show_calendar_info = true;
7
+}
8
+if(!isset($show_fb_info)) {
9
+	$show_fb_info = true;
10
+}
11
+if(!isset($show_servertime_info)) {
12
+	$show_servertime_info = true;
13
+}
8 14
 
9 15
 $tobj = new tc_calendar("");
10 16
 $version = $tobj->version;
@@ -12,7 +18,9 @@  discard block
 block discarded – undo
12 18
 
13 19
 $tdate = new tc_date();
14 20
 
15
-if(!isset($timezone)) $timezone = date_default_timezone_get();
21
+if(!isset($timezone)) {
22
+	$timezone = date_default_timezone_get();
23
+}
16 24
 
17 25
 $wan_enabled = 0;
18 26
 $new_version = 0;
@@ -22,8 +30,7 @@  discard block
 block discarded – undo
22 30
 			$new_version = @file_get_contents("http://www.triconsole.com/php/tc_calendar_version.php?v=".$version);
23 31
 		}
24 32
 	}
25
-}
26
-elseif(function_exists("file_get_contents")){
33
+} elseif(function_exists("file_get_contents")){
27 34
 	$ctx = stream_context_create(array('http' => array('timeout' => 1)));
28 35
 	$wan_enabled = @file_get_contents("http://www.google.com",null,$ctx,0,1);
29 36
 	if($check_version && $wan_enabled){
Please login to merge, or discard this patch.
contrib/ipImap/report/calendar/calendar_form.php 1 patch
Braces   +136 added lines, -67 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 //timezone var, need to setup before any other tasks
14 14
 $timezone = getParameter("tmz");
15 15
 
16
-if(!$timezone) $timezone = date_default_timezone_get();
16
+if(!$timezone) {
17
+	$timezone = date_default_timezone_get();
18
+}
17 19
 @date_default_timezone_set($timezone);
18 20
 
19 21
 $cdate = new tc_date();
@@ -23,9 +25,15 @@  discard block
 block discarded – undo
23 25
 $slm = getParameter("selected_month");
24 26
 $sly = getParameter("selected_year");
25 27
 
26
-if(!is_numeric($sld)) $sld = "00";
27
-if(!is_numeric($slm)) $slm = "00";
28
-if(!is_numeric($sly)) $sly = "0000";
28
+if(!is_numeric($sld)) {
29
+	$sld = "00";
30
+}
31
+if(!is_numeric($slm)) {
32
+	$slm = "00";
33
+}
34
+if(!is_numeric($sly)) {
35
+	$sly = "0000";
36
+}
29 37
 
30 38
 $year_start = getParameter("year_start", "number", 0);
31 39
 $year_end = getParameter("year_end", "number", 0);
@@ -74,62 +82,79 @@  discard block
 block discarded – undo
74 82
 
75 83
 //check year to be select in case of date_allow is set
76 84
 if(!$show_not_allow){
77
-  if ($ta1_set && $cdate->validDate($time_allow1)) $year_start = $cdate->getDate('Y', $time_allow1);
78
-  if ($ta2_set && $cdate->validDate($time_allow2)) $year_end = $cdate->getDate('Y', $time_allow2);
79
-}
80
-
81
-if(isset($_REQUEST["m"]))
82
-	$m = getParameter("m", "number");
83
-else{
85
+  if ($ta1_set && $cdate->validDate($time_allow1)) {
86
+  	$year_start = $cdate->getDate('Y', $time_allow1);
87
+  }
88
+  if ($ta2_set && $cdate->validDate($time_allow2)) {
89
+  	$year_end = $cdate->getDate('Y', $time_allow2);
90
+  }
91
+  }
92
+
93
+if(isset($_REQUEST["m"])) {
94
+	$m = getParameter("m", "number");
95
+} else{
84 96
 	if($slm != "00"){
85 97
 		$m = $slm;
86
-	}else{
98
+	} else{
87 99
 		if($ta2_set && $year_end > 0){
88 100
 			//compare which one is more
89 101
 			$year_allow2 = $cdate->getDate('Y', $time_allow2);
90 102
 			if($year_allow2 >= $year_end){
91 103
 				//use time_allow2
92 104
 				$m = ($cdate->dateBefore($time_allow2)) ? $cdate->getDate("m") : $cdate->getDate('m', $time_allow2);
93
-			}else{
105
+			} else{
94 106
 				//use year_end
95 107
 				$m = ($year_end > $cdate->getDate("Y")) ? $cdate->getDate("m") : 12;
96 108
 			}
97
-		}elseif($ta2_set){
109
+		} elseif($ta2_set){
98 110
 			$m = ($cdate->dateBefore($time_allow2)) ? $cdate->getDate("m") : $cdate->getDate('m', $time_allow2);
99
-		}elseif($year_end > 0){
111
+		} elseif($year_end > 0){
100 112
 			$m = ($year_end > $cdate->getDate("Y")) ? $cdate->getDate("m") : 12; //date('m')
101
-		}else{
113
+		} else{
102 114
 			$m = $cdate->getDate("m");
103 115
 		}
104 116
 	}
105 117
 }
106 118
 
107
-if($m < 1 && $m > 12) $m = $cdate->getDate("m");
119
+if($m < 1 && $m > 12) {
120
+	$m = $cdate->getDate("m");
121
+}
108 122
 
109 123
 $m = str_pad($m, 2, "0", STR_PAD_LEFT);
110 124
 
111 125
 $cyr = ($sly != "0000") ? true : false;
112
-if($cyr && $sly && $sly < $year_start) $sly = $year_start;
113
-if($cyr && $sly && $sly > $year_end) $sly = $year_end;
114
-
115
-if(isset($_REQUEST["y"]))
116
-	$y = getParameter("y", "number");
117
-else
118
-	$y = ($cyr) ? $sly : $cdate->getDate("Y");
119
-
120
-if($y <= 0) $y = $cdate->getDate("Y");
126
+if($cyr && $sly && $sly < $year_start) {
127
+	$sly = $year_start;
128
+}
129
+if($cyr && $sly && $sly > $year_end) {
130
+	$sly = $year_end;
131
+}
132
+
133
+if(isset($_REQUEST["y"])) {
134
+	$y = getParameter("y", "number");
135
+} else {
136
+	$y = ($cyr) ? $sly : $cdate->getDate("Y");
137
+}
138
+
139
+if($y <= 0) {
140
+	$y = $cdate->getDate("Y");
141
+}
121 142
 
122 143
 // ensure m-y fits date allow range
123 144
 if (!$show_not_allow) {
124 145
 	if ($ta1_set) {
125 146
 		$m1 = $cdate->getDate('m', $time_allow1);
126 147
 		$y1 = $cdate->getDate('Y', $time_allow1);
127
-		if ($y == $y1 && (int)$m < (int)$m1) $m = $m1;
148
+		if ($y == $y1 && (int)$m < (int)$m1) {
149
+			$m = $m1;
150
+		}
128 151
 	}
129 152
 	if ($ta2_set) {
130 153
 		$m2 = $cdate->getDate('m', $time_allow2);
131 154
 		$y2 = $cdate->getDate('Y', $time_allow2);
132
-		if ($y == $y2 && (int)$m > (int)$m2) $m = $m2;
155
+		if ($y == $y2 && (int)$m > (int)$m2) {
156
+			$m = $m2;
157
+		}
133 158
 	}
134 159
 }
135 160
 
@@ -147,7 +172,9 @@  discard block
 block discarded – undo
147 172
 $cobj->setTimezone($timezone); //set for further usage, nothing for now
148 173
 
149 174
 $theme_path = ($theme != "") ? $cobj->getThemePath($theme) : "";
150
-if(!is_file($theme_path)) $theme_path = "";
175
+if(!is_file($theme_path)) {
176
+	$theme_path = "";
177
+}
151 178
 
152 179
 //check and show default calendar month and year on valid range of date_allow
153 180
 if(!isset($_REQUEST["m"])){
@@ -168,15 +195,19 @@  discard block
 block discarded – undo
168 195
 $year_end = $cobj->year_end;
169 196
 
170 197
 //check year display in valid range
171
-if($y >= $year_end) $y = $year_end;
172
-if($y <= $year_start) $y = $year_start;
198
+if($y >= $year_end) {
199
+	$y = $year_end;
200
+}
201
+if($y <= $year_start) {
202
+	$y = $year_start;
203
+}
173 204
 
174 205
 $total_thismonth = $cobj->total_days($m, $y);
175 206
 
176 207
 if($m == 1){
177 208
 	$previous_month = 12;
178 209
 	$previous_year = $y-1;
179
-}else{
210
+} else{
180 211
 	$previous_month = $m-1;
181 212
 	$previous_year = $y;
182 213
 }
@@ -184,7 +215,7 @@  discard block
 block discarded – undo
184 215
 if($m == 12){
185 216
 	$next_month = 1;
186 217
 	$next_year = $y+1;
187
-}else{
218
+} else{
188 219
 	$next_month = $m+1;
189 220
 	$next_year = $y;
190 221
 }
@@ -196,9 +227,9 @@  discard block
 block discarded – undo
196 227
 if($firstdate == $startDate){
197 228
 	//skip last month
198 229
 	$startwrite = $total_lastmonth+1;
199
-}elseif($firstdate < $startDate){
230
+} elseif($firstdate < $startDate){
200 231
 	$startwrite = $total_lastmonth - (6-($startDate-$firstdate));
201
-}else{
232
+} else{
202 233
 	$startwrite = $total_lastmonth - ($firstdate - $startDate - 1);
203 234
 }
204 235
 
@@ -222,8 +253,10 @@  discard block
 block discarded – undo
222 253
 	$wknum = $cdate->getWeekNumber($prev_d);
223 254
 	if(!isset($week_rows[$row_count][$wknum])){
224 255
 		$week_rows[$row_count][$wknum] = 1;
225
-	}else $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1;
226
-}
256
+	} else {
257
+		$week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1;
258
+	}
259
+	}
227 260
 
228 261
 $pvMonthTime = $previous_year."-".$previous_month."-".$total_lastmonth;
229 262
 
@@ -231,13 +264,20 @@  discard block
 block discarded – undo
231 264
 if($ta1_set && !$show_not_allow){
232 265
 	if($cdate->dateBefore($pvMonthTime, $time_allow1)){
233 266
 		$show_previous = true;
234
-	}else $show_previous = false;
235
-}else $show_previous = true; //always show when not set
267
+	} else {
268
+		$show_previous = false;
269
+	}
270
+	} else {
271
+	$show_previous = true;
272
+}
273
+//always show when not set
236 274
 
237 275
 $date_num = $cdate->getDayOfWeek(($previous_year."-".$previous_month."-".$total_lastmonth));
238 276
 if(($startDate == 0 && $date_num == 6) || ($startDate > 0 && $date_num == $startDate-1) && $startwrite<$total_lastmonth){
239
-	if(isset($calendar_rows[0])) $row_count++;
240
-}
277
+	if(isset($calendar_rows[0])) {
278
+		$row_count++;
279
+	}
280
+	}
241 281
 
242 282
 $dp_time = ($date_pair_value) ? $date_pair_value : "";
243 283
 
@@ -270,13 +310,13 @@  discard block
 block discarded – undo
270 310
 	if($ta1_set && $ta2_set){
271 311
 		//both date specified
272 312
 		$dateLink = ($cdate->dateBefore($date_str, $time_allow1) && $cdate->dateAfter($date_str, $time_allow2)) ? true : false;
273
-	}elseif($ta1_set){
313
+	} elseif($ta1_set){
274 314
 		//only date 1 specified
275 315
 		$dateLink = $cdate->dateBefore($date_str, $time_allow1) ? true : false;
276
-	}elseif($ta2_set){
316
+	} elseif($ta2_set){
277 317
 		//only date 2 specified
278 318
 		$dateLink = $cdate->dateAfter($date_str, $time_allow2) ? true : false;
279
-	}else{
319
+	} else{
280 320
 		//no date allow specified, assume show all
281 321
 		$dateLink = true;
282 322
 	}
@@ -343,13 +383,15 @@  discard block
 block discarded – undo
343 383
 	if($date_pair_value){
344 384
 		//check date_pair1 & 2
345 385
 		if($date_pair1 && $date_pair_value != "0000-00-00" && $cdate->dateAfter($date_pair_value, $date_str) && (($slm>0 && $sld>0 && $sly>0) && $cdate->dateBefore("$sly-$slm-$sld", $date_str))){ //set date only after date_pair1
346
-			if(!in_array("select", $htmlClass))
347
-				$htmlClass[] = "select";
386
+			if(!in_array("select", $htmlClass)) {
387
+							$htmlClass[] = "select";
388
+			}
348 389
 		}
349 390
 
350 391
 		if($date_pair2 && $date_pair_value != "0000-00-00" && $cdate->dateBefore($date_pair_value, $date_str) && (($slm>0 && $sld>0 && $sly>0) && $cdate->dateAfter("$sly-$slm-$sld", $date_str))){ //set date only before date_pair2
351
-			if(!in_array("select", $htmlClass))
352
-				$htmlClass[] = "select";
392
+			if(!in_array("select", $htmlClass)) {
393
+							$htmlClass[] = "select";
394
+			}
353 395
 		}
354 396
 	}
355 397
 
@@ -364,7 +406,7 @@  discard block
 block discarded – undo
364 406
 		$class = implode(" ", $htmlClass);
365 407
 
366 408
 		$calendar_rows[$row_count][] = array($day, "javascript:selectDay('".str_pad($day, 2, "0", STR_PAD_LEFT)."');", $class, "$y".str_pad($m, 2, "0", STR_PAD_LEFT).str_pad($day, 2, "0", STR_PAD_LEFT));
367
-	}else{
409
+	} else{
368 410
 		$htmlClass[] = "disabledate";
369 411
 		$class = implode(" ", $htmlClass);
370 412
 
@@ -381,14 +423,18 @@  discard block
 block discarded – undo
381 423
 		$row_count++;
382 424
 
383 425
 		$dayinweek_counter = 0;
384
-	}else $dayinweek_counter++;
426
+	} else {
427
+		$dayinweek_counter++;
428
+	}
385 429
 
386 430
 	$wknum = $cdate->getWeekNumber(($y."-".$m."-".$day));
387 431
 
388 432
 	if(!isset($week_rows[$row_count][$wknum])){
389 433
 		$week_rows[$row_count][$wknum] = 1;
390
-	}else $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1;
391
-}
434
+	} else {
435
+		$week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1;
436
+	}
437
+	}
392 438
 
393 439
 //write next other month
394 440
 $write_end_days = (6-$dayinweek_counter)+1;
@@ -399,7 +445,9 @@  discard block
 block discarded – undo
399 445
 		$wknum = $cdate->getWeekNumber($cdate->addMonth("Y-m-d", 1, ($y."-".$m."-".$day))); //date('W', mktime(0,0,0, $m+1, $day, $y));
400 446
 		if(!isset($week_rows[$row_count][$wknum])){
401 447
 			$week_rows[$row_count][$wknum] = 1;
402
-		}else $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1;
448
+		} else {
449
+			$week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1;
450
+		}
403 451
 	}
404 452
 	 $row_count++;
405 453
 }
@@ -414,7 +462,9 @@  discard block
 block discarded – undo
414 462
 
415 463
 		if(!isset($week_rows[$row_count][$wknum])){
416 464
 			$week_rows[$row_count][$wknum] = 1;
417
-		}else $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1;
465
+		} else {
466
+			$week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1;
467
+		}
418 468
 	}
419 469
 	$write_end_days += 6;
420 470
 }
@@ -424,11 +474,19 @@  discard block
 block discarded – undo
424 474
 	$nxMonthTime = $next_year."-".$next_month."-1";
425 475
 	if($cdate->dateAfter($nxMonthTime, $time_allow2)){
426 476
 		$show_next = true;
427
-	}else $show_next = false;
428
-}else $show_next = true; //always show when not set
477
+	} else {
478
+		$show_next = false;
479
+	}
480
+	} else {
481
+	$show_next = true;
482
+}
483
+//always show when not set
429 484
 ?>
430 485
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
431
-<html xmlns="http://www.w3.org/1999/xhtml"<?php if($rtl) echo(" dir=\"rtl\""); ?>>
486
+<html xmlns="http://www.w3.org/1999/xhtml"<?php if($rtl) {
487
+	echo(" dir=\"rtl\"");
488
+}
489
+?>>
432 490
 <head>
433 491
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
434 492
 <title>TriConsole.com - PHP Calendar Date Picker</title>
@@ -459,7 +517,7 @@  discard block
 block discarded – undo
459 517
 		if($form_name){
460 518
 			//submit value by post form
461 519
 			echo("window.parent.document.".$form_name.".submit();\n");
462
-		}elseif($target_url){
520
+		} elseif($target_url){
463 521
 			//submit value by get method
464 522
 			echo("var date_selected = yvalue + \"-\" + mvalue + \"-\" + dvalue;\n");
465 523
 			echo("window.parent.location.href='".$target_url."?".$objname."='+date_selected;\n");
@@ -474,7 +532,10 @@  discard block
 block discarded – undo
474 532
 <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
475 533
 <span id="calendar-page" class="font">
476 534
 	<div id="calendar-header" align="center">
477
-		<?php if($show_calendar_info) include("calendar_info.php"); ?>
535
+		<?php if($show_calendar_info) {
536
+	include("calendar_info.php");
537
+}
538
+?>
478 539
 		<?php if($dp && !$auto_hide){ ?>
479 540
 		<div style="float: right;" class="closeme"><a href="javascript:closeMe();"><img src="images/close.gif" border="0" alt="Close" title="Close" /></a></div>
480 541
 		<?php } ?>
@@ -561,7 +622,9 @@  discard block
 block discarded – undo
561 622
 
562 623
 			echo("<tr>");
563 624
 
564
-			if ($show_weeks) echo("<td align=\"center\" class=\"header wk-hdr\"><div>".$cobj->week_hdr."</div></td>");
625
+			if ($show_weeks) {
626
+				echo("<td align=\"center\" class=\"header wk-hdr\"><div>".$cobj->week_hdr."</div></td>");
627
+			}
565 628
 
566 629
 			//write calendar day header
567 630
 			foreach($day_headers as $dh){
@@ -591,7 +654,7 @@  discard block
 block discarded – undo
591 654
 
592 655
 					if($this_link){
593 656
 						echo("<td".$id_str." align=\"center\" class=\"".$this_class."\"><div><a href=\"".$this_link."\">".$this_day."</a></div></td>");
594
-					}else{
657
+					} else{
595 658
 						echo("<td".$id_str." align=\"center\" class=\"".$this_class."\"><div>".$this_day."</div></td>");
596 659
 					}
597 660
 				}
@@ -610,7 +673,9 @@  discard block
 block discarded – undo
610 673
 				if($previous_year >= $year_start && $show_previous){
611 674
 				?><a href="javascript:move('<?php echo(str_pad($previous_month, 2, "0", STR_PAD_LEFT));?>', '<?php echo($previous_year);?>');"><img src="images/btn_<?php echo($rtl ? "next" : "previous"); ?>.gif" width="16" height="16" border="0" alt="Previous" title="Previous" /></a>
612 675
 				<?php
613
-				}else echo("&nbsp;");
676
+				} else {
677
+					echo("&nbsp;");
678
+				}
614 679
 				?>
615 680
 			</div>
616 681
 			<div style="float: <?php echo($rtl ? "left" : "right"); ?>;" class="btn">
@@ -618,18 +683,22 @@  discard block
 block discarded – undo
618 683
 				if($next_year <= $year_end && $show_next){
619 684
 				?><a href="javascript:move('<?php echo(str_pad($next_month, 2, "0", STR_PAD_LEFT));?>', '<?php echo($next_year);?>');"><img src="images/btn_<?php echo($rtl ? "previous" : "next"); ?>.gif" width="16" height="16" border="0" alt="Next" title="Next" /></a>
620 685
 				<?php
621
-				}else echo("&nbsp;");
686
+				} else {
687
+					echo("&nbsp;");
688
+				}
622 689
 				?>
623 690
 			</div>
624 691
 			<div class="links">
625 692
 				<?php
626 693
 				$footer_links = array();
627 694
 
628
-				if($cobj->validTodayDate() && ($m != $cdate->getDate('m') || $y != $cdate->getDate('Y')))
629
-					$footer_links[] = "<a href=\"javascript:today();\" class=\"txt\" alt=\"Today\" title=\"Today\">Today</a>";
695
+				if($cobj->validTodayDate() && ($m != $cdate->getDate('m') || $y != $cdate->getDate('Y'))) {
696
+									$footer_links[] = "<a href=\"javascript:today();\" class=\"txt\" alt=\"Today\" title=\"Today\">Today</a>";
697
+				}
630 698
 
631
-				if($sld>0 && $slm>0 && $sly>0)
632
-					$footer_links[] = "<a href=\"javascript:unsetValue();\" class=\"txt\" alt=\"Unset\" title=\"Unset\">Unset</a>";
699
+				if($sld>0 && $slm>0 && $sly>0) {
700
+									$footer_links[] = "<a href=\"javascript:unsetValue();\" class=\"txt\" alt=\"Unset\" title=\"Unset\">Unset</a>";
701
+				}
633 702
 
634 703
 				if(sizeof($footer_links)>0){
635 704
 					echo(implode(" | ", $footer_links));
Please login to merge, or discard this patch.
contrib/ipImap/getip.php 1 patch
Braces   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,9 +51,7 @@
 block discarded – undo
51 51
 		'db'	 => $db,
52 52
 		'dbport' => $dbport
53 53
 	);
54
-}
55
-
56
-else {
54
+} else {
57 55
 	$mysqlconf = NULL;
58 56
 	syslog(LOG_INFO, $conf['user'].': Report only, no listing activated in configuration.') ;
59 57
 }
Please login to merge, or discard this patch.
delist.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,10 +18,11 @@
 block discarded – undo
18 18
 }
19 19
 syslog(LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info) ;
20 20
 
21
-if (changestatus($mysqli,username(),$_POST['value'],'0',$type,$table))
21
+if (changestatus($mysqli,username(),$_POST['value'],'0',$type,$table)) {
22 22
  print 'OK '.$_POST["type"].' &lt;'.$_POST['value'].'&gt; delisted.';
23
-else
23
+} else {
24 24
  print 'ERROR in delist &lt;'.$_POST['value'].'&gt;; check log';
25
+}
25 26
 print '</td>';
26 27
 $mysqli->close();
27 28
 closelog();
Please login to merge, or discard this patch.
relistForm.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,9 +3,12 @@
 block discarded – undo
3 3
         $type = $tables["$typedesc"]['field'];
4 4
         $table = $tables["$typedesc"]['name'];
5 5
 	$adm = unserialize($_POST["adm"]);
6
-	if (in_array($_POST["user"],array_keys(array_filter($adm)))) $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>';
7
-	else $extopt = NULL;
8
-?>
6
+	if (in_array($_POST["user"],array_keys(array_filter($adm)))) {
7
+		$extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>';
8
+	} else {
9
+		$extopt = NULL;
10
+	}
11
+	?>
9 12
 
10 13
 
11 14
 <td  colspan="9">
Please login to merge, or discard this patch.
function.php 1 patch
Braces   +84 added lines, -49 removed lines patch added patch discarded remove patch
@@ -3,9 +3,13 @@  discard block
 block discarded – undo
3 3
 $version='1.9d';
4 4
 
5 5
 function username() {
6
-	if (isset ($_SERVER['REMOTE_USER'])) $user = $_SERVER['REMOTE_USER'];
7
-        	else if (isset ($_SERVER['USER'])) $user = $_SERVER['USER'];
8
-                	else $user='unknown';
6
+	if (isset ($_SERVER['REMOTE_USER'])) {
7
+		$user = $_SERVER['REMOTE_USER'];
8
+	} else if (isset ($_SERVER['USER'])) {
9
+        		$user = $_SERVER['USER'];
10
+        	} else {
11
+                		$user='unknown';
12
+                	}
9 13
 	return $user;
10 14
 }
11 15
 
@@ -68,8 +72,9 @@  discard block
 block discarded – undo
68 72
 	if ($myconn->query($query) === TRUE) {
69 73
 	    syslog(LOG_INFO, "$user: $type <$value> successfully listed on <$table> for $expQ $expUnit.");
70 74
 	    $result=TRUE;
75
+	} else {
76
+		syslog(LOG_ERR, "$user: Error: ".$myconn->error);
71 77
 	}
72
-	else syslog(LOG_ERR, "$user: Error: ".$myconn->error);
73 78
 	return $result;
74 79
 }
75 80
 
@@ -110,8 +115,9 @@  discard block
 block discarded – undo
110 115
         if ($myconn->query($query) === TRUE) {
111 116
             syslog(LOG_INFO, "$user: relist $type <$value> on <$table> for $expQ $expUnit.");
112 117
 		$result=TRUE;
118
+        } else {
119
+        	syslog (LOG_ERR, "$user: Error: ". $myconn->error);
113 120
         }
114
-        else syslog (LOG_ERR, "$user: Error: ". $myconn->error);
115 121
 	return $result;
116 122
 }
117 123
 
@@ -134,9 +140,11 @@  discard block
 block discarded – undo
134 140
 	}
135 141
 
136 142
 
137
-        if ($return=$myconn->query($query) === TRUE) 
138
-            syslog(LOG_INFO, "$user: permanently DELETED $type <$value> from <$table>.");
139
-        else syslog(LOG_ERR, "$user: Error: ". $myconn->error);
143
+        if ($return=$myconn->query($query) === TRUE) {
144
+                    syslog(LOG_INFO, "$user: permanently DELETED $type <$value> from <$table>.");
145
+        } else {
146
+        	syslog(LOG_ERR, "$user: Error: ". $myconn->error);
147
+        }
140 148
 
141 149
         return $return;
142 150
 }
@@ -158,8 +166,9 @@  discard block
 block discarded – undo
158 166
 
159 167
         if ($return=$myconn->query($query) === TRUE) {
160 168
             syslog(LOG_INFO, "$user: change status of $type <$value>. The status is now <$status>");
169
+        } else {
170
+        	syslog(LOG_ERR, "$user: Error: ". $myconn->error);
161 171
         }
162
-        else syslog(LOG_ERR, "$user: Error: ". $myconn->error);
163 172
 	return $return;	
164 173
 }
165 174
 
@@ -183,14 +192,16 @@  discard block
 block discarded – undo
183 192
 				$j++;
184 193
 
185 194
 			} while ($myconn->next_result());
186
-		}
187
-		else {
195
+		} else {
188 196
 			syslog(LOG_ERR, "Expire job - Error: ". $myconn->error);
189 197
 			$return = FALSE;
190 198
 		}
191 199
 	}
192
-	if ( !($return) ) syslog(LOG_EMERG, 'End of Expire job with error. See above logs. SQL Connection terminated');
193
-	else  syslog(LOG_INFO, 'Successfully End of Expire job. SQL Connection successfully terminated.');
200
+	if ( !($return) ) {
201
+		syslog(LOG_EMERG, 'End of Expire job with error. See above logs. SQL Connection terminated');
202
+	} else {
203
+		syslog(LOG_INFO, 'Successfully End of Expire job. SQL Connection successfully terminated.');
204
+	}
194 205
         return $return;
195 206
 }
196 207
 
@@ -199,8 +210,11 @@  discard block
 block discarded – undo
199 210
 
200 211
 	$exp=new DateTime($row['exp']);
201 212
 	$now=new DateTime('NOW');
202
-	if (($exp > $now) and ($row['active'])) return true;
203
-	else return false;
213
+	if (($exp > $now) and ($row['active'])) {
214
+		return true;
215
+	} else {
216
+		return false;
217
+	}
204 218
 
205 219
 }
206 220
 
@@ -210,9 +224,12 @@  discard block
 block discarded – undo
210 224
 	$whynot=NULL;
211 225
 	switch ($what) {
212 226
 		case 'Ok':
213
-			if ($lock) return NULL;
214
-			if (in_array($user,array_keys($adm)))
215
-				if ( consistentListing($myconn,$alltables,$typedesc,$value,$whynot) ) return require('relistButton.php');
227
+			if ($lock) {
228
+				return NULL;
229
+			}
230
+			if (in_array($user,array_keys($adm))) {
231
+							if ( consistentListing($myconn,$alltables,$typedesc,$value,$whynot) ) return require('relistButton.php');
232
+			}
216 233
 			return htmlspecialchars($whynot);
217 234
 		case 'Listed':
218 235
 		case 'WhiteListed':
@@ -253,8 +270,9 @@  discard block
 block discarded – undo
253 270
         $type = $tablelist['field'];
254 271
         $table = $tablelist['name'];
255 272
 
256
-        if ($value == 'ALL') $query = 'select * from '.$table;
257
-        else {
273
+        if ($value == 'ALL') {
274
+        	$query = 'select * from '.$table;
275
+        } else {
258 276
                 switch ($type) {
259 277
                   case 'ip':
260 278
                         $query= "select * from $table where $type =  INET_ATON('$value')";
@@ -269,8 +287,9 @@  discard block
 block discarded – undo
269 287
         }
270 288
 
271 289
 	$result = $myconn->query($query);
272
-	if($result === false)
273
-		syslog(LOG_EMERG, "ALERT: Query <$query> failed: ".$myconn->error);
290
+	if($result === false) {
291
+			syslog(LOG_EMERG, "ALERT: Query <$query> failed: ".$myconn->error);
292
+	}
274 293
         return $result;
275 294
 }
276 295
 
@@ -287,8 +306,9 @@  discard block
 block discarded – undo
287 306
 
288 307
 function isFull($myconn,$typedesc,$alltables) {
289 308
         if (isset($alltables["$typedesc"]['limit'])) {
290
-                if ( countListed($myconn,$alltables["$typedesc"]['name']) >= $alltables["$typedesc"]['limit'] ) 
291
-                        return TRUE;
309
+                if ( countListed($myconn,$alltables["$typedesc"]['name']) >= $alltables["$typedesc"]['limit'] ) {
310
+                                        return TRUE;
311
+                }
292 312
         }
293 313
 	return FALSE;
294 314
 }
@@ -304,18 +324,23 @@  discard block
 block discarded – undo
304 324
 
305 325
         /* Check for limit in number of listed items */
306 326
 	$full = isFull($myconn,$typedesc,$tables);
307
-	if ($full) print '<p>'.htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.').'</p>';
327
+	if ($full) {
328
+		print '<p>'.htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.').'</p>';
329
+	}
308 330
 
309 331
 		if ($result->num_rows) {
310 332
 			print '<table><thead><tr><th>'.$type.'</th><th title="The date this object has been listed for the first time">DateAdd</th><th>DateMod</th><th>Exp</th><th>Status</th><th title="Number of times this object has been listed">#List</th><th>Authored by</th><th width="250">Reason</th><th>Action</th></tr></thead><tfoot><tr></tr></tfoot><tbody>'."\n";
311 333
 			$i=0;
312 334
         		while ($riga = $result->fetch_array(MYSQLI_ASSOC)) {
313 335
 				if (isListed($riga)) {
314
-					if ($tables["$typedesc"]['bl']) $listed='Listed';
315
-					else $listed='WhiteListed';
316
-				}	
317
-				else
318
-					$listed='Ok';
336
+					if ($tables["$typedesc"]['bl']) {
337
+						$listed='Listed';
338
+					} else {
339
+						$listed='WhiteListed';
340
+					}
341
+				} else {
342
+									$listed='Ok';
343
+				}
319 344
 
320 345
 				switch ($type) {
321 346
 				  case 'ip':
@@ -332,18 +357,20 @@  discard block
 block discarded – undo
332 357
 				$i++;
333 358
         		}
334 359
 			print '</tbody></table>';
335
-		}
336
-		else {
360
+		} else {
337 361
 			print "<pre>$type &lt;$value&gt; is not listed!\n</pre>";
338
-			if ( in_array($user,array_keys($adm)) AND ($value != 'ALL') )
339
-				if ( (!$full) AND (consistentListing($myconn,$tables,$typedesc,$value,$whynot)) ) require_once('listForm.php');
340
-									else print '<p>'.htmlspecialchars($whynot).'</p>';
362
+			if ( in_array($user,array_keys($adm)) AND ($value != 'ALL') ) {
363
+							if ( (!$full) AND (consistentListing($myconn,$tables,$typedesc,$value,$whynot)) ) require_once('listForm.php');
364
+			} else {
365
+										print '<p>'.htmlspecialchars($whynot).'</p>';
366
+									}
341 367
 				
342 368
 		}
343 369
 		$result->free();
370
+	} else {
371
+		print '<pre>Query error or something wrong in DB schema'."\n</pre>";
372
+	}
344 373
 	}
345
-	else print '<pre>Query error or something wrong in DB schema'."\n</pre>";
346
-}
347 374
 
348 375
 
349 376
 function sendEmailWarn($tplf,$from,$to,$sbj,$emailListed,$intervalToExpire,$detail) {
@@ -384,24 +411,32 @@  discard block
 block discarded – undo
384 411
                 $old_mailfrom = ini_get("sendmail_from");
385 412
                 ini_set("sendmail_from", $from);
386 413
                 $params = sprintf("-oi -f %s", '<>');
387
-                if (!(mail($to,$sbj, $body,$headers,$params))) $flag=FALSE;
388
-                else $flag=TRUE;
389
-                if (isset($old_mailfrom))
390
-                        ini_set("sendmail_from", $old_mailfrom);
391
-        }
392
-        else {
393
-                if (!(mail($to,$sbj, $body,$headers))) $flag=FALSE;
394
-                else $flag=TRUE;
414
+                if (!(mail($to,$sbj, $body,$headers,$params))) {
415
+                	$flag=FALSE;
416
+                } else {
417
+                	$flag=TRUE;
418
+                }
419
+                if (isset($old_mailfrom)) {
420
+                                        ini_set("sendmail_from", $old_mailfrom);
421
+                }
422
+        } else {
423
+                if (!(mail($to,$sbj, $body,$headers))) {
424
+                	$flag=FALSE;
425
+                } else {
426
+                	$flag=TRUE;
427
+                }
395 428
         }
396 429
         return $flag;
397 430
 }
398 431
 
399 432
 function emailToNotify($notify_file,$dom) {
400 433
 	$ini_array = parse_ini_file($notify_file);
401
-	if (in_array($dom,array_keys($ini_array)))
402
-		return $ini_array["$dom"];
403
-	else return FALSE;
404
-}
434
+	if (in_array($dom,array_keys($ini_array))) {
435
+			return $ini_array["$dom"];
436
+	} else {
437
+		return FALSE;
438
+	}
439
+	}
405 440
 
406 441
 
407 442
 function searchAndList ($myconn,$loguser,$tables,$typedesc,$value,$unit,&$quantity,$reason) {
Please login to merge, or discard this patch.
remove.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,10 +16,11 @@
 block discarded – undo
16 16
 }
17 17
 syslog (LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info );
18 18
 
19
-if (remove ($mysqli,$user,$_POST['value'],$type,$table))
19
+if (remove ($mysqli,$user,$_POST['value'],$type,$table)) {
20 20
  print 'OK '.$typedesc.' &lt;'.$_POST['value'].'&gt; permanently REMOVED!';
21
-else
21
+} else {
22 22
  print 'Delete operation ERROR on '.$typedesc.' &lt;'.$_POST['value'].'&gt;; check log.';
23
+}
23 24
 $mysqli->close();
24 25
 closelog();
25 26
 ?>
Please login to merge, or discard this patch.
contrib/ipImap/function.php 1 patch
Braces   +107 added lines, -61 removed lines patch added patch discarded remove patch
@@ -10,21 +10,25 @@  discard block
 block discarded – undo
10 10
 	if ( preg_match_all('/^Received:\sfrom(?:.|\r\n\s)*?[\[\(]\s*(?P<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[\]\)](?:.|\r\n\s)+\s+by(?:\s|\r\n\s+)(?P<host>\S+).*(?:\s|\r\n\s\s)+.*;\s+(?P<date>.*)/m',$header,$received) ) {
11 11
 		for ($i = count($received[0])-1;$i>=0;$i--) {
12 12
 #			print "Examine ".$received[0][$i]."\n";
13
-			if ( preg_match($msa,$received['host'][$i]) )
14
-				$dateR = $received['date'][$i];
13
+			if ( preg_match($msa,$received['host'][$i]) ) {
14
+							$dateR = $received['date'][$i];
15
+			}
15 16
         		foreach ($mxserver as $mx) {
16
-        			if (!$ip)
17
-					if ($mx == $received['host'][$i]) {
17
+        			if (!$ip) {
18
+        								if ($mx == $received['host'][$i]) {
18 19
 						$host = $received['host'][$i];
20
+        			}
19 21
 						$ip = $received['ip'][$i];
20 22
                     			}
21 23
                 	}
22 24
         	}
23 25
 	}
24
-	if ( preg_match ('/\r\nDate:\s(?P<date>.*)\r\n/',$header,$dateC) != 1)
25
-		$dateC['date'] = 'Not found';
26
-	if ( preg_match ('/\r\nMessage\-I(?:D|d):\s(?P<mid>.*)\r\n/',$header,$mid) != 1)
27
-		$mid['mid'] = NULL;
26
+	if ( preg_match ('/\r\nDate:\s(?P<date>.*)\r\n/',$header,$dateC) != 1) {
27
+			$dateC['date'] = 'Not found';
28
+	}
29
+	if ( preg_match ('/\r\nMessage\-I(?:D|d):\s(?P<mid>.*)\r\n/',$header,$mid) != 1) {
30
+			$mid['mid'] = NULL;
31
+	}
28 32
 	return array($ip,$host,$dateR,$dateC['date'],$mid['mid']);
29 33
 }
30 34
 
@@ -40,7 +44,9 @@  discard block
 block discarded – undo
40 44
 
41 45
 function summaryBadReport ($uidvet) {
42 46
         $nuid = $uidvet['count'];
43
-        if ( empty($uidvet) ) return NULL;
47
+        if ( empty($uidvet) ) {
48
+        	return NULL;
49
+        }
44 50
         $return = '<hr><h3>Statistics by UID</h3><table><tr><th>UID</th><th>Learned times</th></tr>'."\n";
45 51
 
46 52
         /* Remove count index */
@@ -75,8 +81,12 @@  discard block
 block discarded – undo
75 81
     foreach ($colarr as $col => $arr) {
76 82
         foreach ($arr as $k => $v) {
77 83
             $k = substr($k,1);
78
-            if (!isset($ret[$k])) $ret[$k] = $array[$k];
79
-            if (isset ($array[$k][$col])) $ret[$k][$col] = $array[$k][$col];
84
+            if (!isset($ret[$k])) {
85
+            	$ret[$k] = $array[$k];
86
+            }
87
+            if (isset ($array[$k][$col])) {
88
+            	$ret[$k][$col] = $array[$k][$col];
89
+            }
80 90
         }
81 91
     }
82 92
     return $ret;
@@ -87,13 +97,17 @@  discard block
 block discarded – undo
87 97
 function summaryReportAndList ($cf,$myconn,$tables,$category,$ipvet) {
88 98
 	$nips = $ipvet['count'];
89 99
 
90
-	if ( empty($ipvet) ) return NULL;
100
+	if ( empty($ipvet) ) {
101
+		return NULL;
102
+	}
91 103
 	$return = '<h3>Statistics by IP</h3><table><tr><th>IP</th><th>Learned by</th><th>Learned times</th><th title="This field doesn\'t say if this ip is currently listed, but it says if this IP has listed now!">Listed Now</th></tr>'."\n";
92 104
 	
93 105
 	$ips = array_keys($ipvet['ip']);
94 106
 
95 107
 	foreach ( $ips as $ip ) {
96
-		if ( $ip == 'count' ) continue;
108
+		if ( $ip == 'count' ) {
109
+			continue;
110
+		}
97 111
                 $nlearn = $ipvet['ip']["$ip"]['count'];
98 112
                 unset($ipvet['ip']["$ip"]['count']);
99 113
 		$quantity = $cf['quantity']["$category"]; /* In searchAndList this value is passed by reference and modified */
@@ -102,10 +116,12 @@  discard block
 block discarded – undo
102 116
 			if ( ($nlearn >= $cf['thresholdip']["$category"])&&($nuid >= $cf['thresholduid']["$category"]) ) {
103 117
 				$reason = "The IP <$ip> has been listed because was marked $nlearn times as $category by $nuid different accounts during last ".$cf['oldestday'].' days.';
104 118
 				$listed = searchAndList ($myconn,$cf['user'],$tables,$cf['list']["$category"],$ip,$cf['unit']["$category"],$quantity,$reason);
119
+			} else {
120
+				$listed = FALSE;
105 121
 			}
106
-			else $listed = FALSE;
122
+		} else {
123
+			$listed = FALSE;
107 124
 		}
108
-		else $listed = FALSE;
109 125
 		$nowlist = array( TRUE =>  array(
110 126
 					'style' => 'id=\'ipfound\'',
111 127
 					'name'  => 'YES',
@@ -123,7 +139,9 @@  discard block
 block discarded – undo
123 139
 		$return .='<tr><td rowspan="'.$nuid.'">'.$ip.'</td>';
124 140
 		$return .= sprintf ('<td>%s</td><td rowspan="'.$nuid.'">%u</td><td rowspan="'.$nuid.'" '.$nowlist["$listed"]['style'].'>%s</td></tr>',$ipvet['ip']["$ip"][0],$nlearn,$nowlist["$listed"]['name']);
125 141
 		$rowuid=NULL;
126
-                for ($j=1;$j<$nuid;$j++) $rowuid .= '<tr><td>%s</td></tr>';
142
+                for ($j=1;$j<$nuid;$j++) {
143
+                	$rowuid .= '<tr><td>%s</td></tr>';
144
+                }
127 145
 		array_shift($ipvet['ip']["$ip"]);
128 146
                 $return .= vsprintf ($rowuid,$ipvet['ip']["$ip"]);
129 147
 
@@ -136,14 +154,18 @@  discard block
 block discarded – undo
136 154
 	$return .= '<h3>Statistics by UID</h3><table><tr><th>UID</th><th>IP learned</th><th>Learned times</th></tr>'."\n";
137 155
 	$uids = array_keys($ipvet['uid']);
138 156
         foreach ( $uids as $uid ) {
139
-		if ( $uid == 'count' ) continue;	
157
+		if ( $uid == 'count' ) {
158
+			continue;
159
+		}
140 160
 	        $nlearn = $ipvet['uid']["$uid"]['count'];
141 161
 	        unset ( $ipvet['uid']["$uid"]['count'] );
142 162
 		$nip = count($ipvet['uid']["$uid"]);
143 163
 		$return .='<tr><td rowspan="'.$nip.'">'.$uid.'</td>';
144 164
 		$return .= sprintf ('<td>%s</td><td rowspan="'.$nip.'">%u</td></tr>',$ipvet['uid']["$uid"][0],$nlearn);
145 165
                 $rowuid=NULL;
146
-                for ($j=1;$j<$nip;$j++) $rowuid .= '<tr><td>%s</td></tr>';
166
+                for ($j=1;$j<$nip;$j++) {
167
+                	$rowuid .= '<tr><td>%s</td></tr>';
168
+                }
147 169
                 array_shift($ipvet['uid']["$uid"]);
148 170
                 $return .= vsprintf ($rowuid,$ipvet['uid']["$uid"]);
149 171
 
@@ -192,14 +214,14 @@  discard block
 block discarded – undo
192 214
 	    {
193 215
 	      // More than one field attribute returned by search
194 216
 	      // You must redefine the search
195
-	      if ( count($result->getFieldNames()) > 1 ) return FALSE;
196
-	    }
197
-	    else if ($result instanceof Splunk_ResultsMessage)
217
+	      if ( count($result->getFieldNames()) > 1 ) {
218
+	      	return FALSE;
219
+	      }
220
+	    } else if ($result instanceof Splunk_ResultsMessage)
198 221
 	    {
199 222
 	      // I don't want messages in my search
200 223
 	      return FALSE;
201
-	    }
202
-	    else if (is_array($result))
224
+	    } else if (is_array($result))
203 225
 	    {
204 226
 	      // Process a row
205 227
 	      foreach ($result as $key => $valueOrValues)
@@ -207,15 +229,13 @@  discard block
 block discarded – undo
207 229
 	         if (is_array($valueOrValues))
208 230
 	          {
209 231
 	            return FALSE;
210
-	          }
211
-	         else
232
+	          } else
212 233
 	          {
213 234
 	            return $valueOrValues;
214 235
 	            #print "  {$key} => {$value}\r\n";
215 236
 	          }
216 237
 	        }
217
-	    }
218
-	    else
238
+	    } else
219 239
 	    {
220 240
 	      #print "Unknow result type";
221 241
 	      return FALSE;
@@ -229,7 +249,9 @@  discard block
 block discarded – undo
229 249
 	$fileb= dirname(__FILE__) . '/' . $cf['badreportFile']["$type"];
230 250
 	$m_mail = imap_open('{'.$cf['mailhost'].':143/imap/novalidate-cert/authuser='.$cf['authuser'].'}'.$cf['folder']["$type"], $cf['account'],$cf['authpassword'], OP_READONLY)
231 251
         	or syslog (LOG_EMERG, $cf['user'].': Error in IMAP connection to <'.$cf['mailhost'].'>: ' . imap_last_error());
232
-	if ( !$m_mail ) exit(254);
252
+	if ( !$m_mail ) {
253
+		exit(254);
254
+	}
233 255
 		
234 256
 
235 257
 	syslog (LOG_INFO,$cf['user'].': Successfully connected to <'.$cf['mailhost'].">; Reading $type messages of last ".$cf['oldestday'].' days...');
@@ -242,20 +264,28 @@  discard block
 block discarded – undo
242 264
 	// Order results starting from newest message
243 265
 	if ( empty($m_search) ) {
244 266
 		syslog (LOG_INFO,$cf['user'].": No mail found in $type folder. No reports written for $type.");
245
-	        if ( $ierr = imap_errors() )
246
-	                foreach ( $ierr as $thiserr )
267
+	        if ( $ierr = imap_errors() ) {
268
+	        	                foreach ( $ierr as $thiserr )
247 269
 	                        syslog (LOG_ERR, $cf['user'].": IMAP Error: $thiserr");
248
-	        if ( $ierr = imap_alerts() )
249
-	                foreach ( $ierr as $thiserr )
270
+	        }
271
+	        if ( $ierr = imap_alerts() ) {
272
+	        	                foreach ( $ierr as $thiserr )
250 273
 	                        syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr");
274
+	        }
251 275
 		imap_close( $m_mail );
252
-		if ( file_exists( $file ) ) unlink ($file);
253
-		if ( file_exists( $fileb ) ) unlink ($fileb);
276
+		if ( file_exists( $file ) ) {
277
+			unlink ($file);
278
+		}
279
+		if ( file_exists( $fileb ) ) {
280
+			unlink ($fileb);
281
+		}
254 282
 		return FALSE;
255 283
 	}
256 284
 	$nmes = count ($m_search);
257 285
 	syslog (LOG_INFO,$cf['user'].": Found $nmes mail in $type folder.");
258
-	if ($nmes>0) rsort($m_search);
286
+	if ($nmes>0) {
287
+		rsort($m_search);
288
+	}
259 289
 
260 290
 	// Create report file
261 291
 
@@ -264,7 +294,9 @@  discard block
 block discarded – undo
264 294
 	$lastup = "Last Update: " . date ("d F Y H:i", time());
265 295
 	fwrite( $fp, file_get_contents(dirname(__FILE__) . '/' . $cf['reportTemplateHeader']) );
266 296
 	fwrite( $fp,"<h1> Report of IP sending $type</h1><h5>$lastup</h5><h2>Detailed Report</h2>" );
267
-	if ($cf['onlyReport']) fwrite( $fp,'<p>None of the below IP has been listed because listing is not active in configuration.</p>');
297
+	if ($cf['onlyReport']) {
298
+		fwrite( $fp,'<p>None of the below IP has been listed because listing is not active in configuration.</p>');
299
+	}
268 300
 	fwrite( $fp,'<table><tr><th title="taken from Received header" nowrap>Date of Learn</th><th title="taken from Date header" nowrap>Date of Write</th><th nowrap>UID</th><th nowrap>IP</th><th title="How many times this uid learns">#UID</th><th title="Number of times this learned IP appears in different mails">#IP</th><th nowrap>Received by</th><th>Message-Id</th></tr>' );
269 301
 	fwrite( $fpb,file_get_contents(dirname(__FILE__) . '/' . $cf['reportTemplateHeader']) );
270 302
 	fwrite( $fpb,"<h1> Report of bad reported $type mails</h1><h5>$lastup</h5><h2>Detailed Report</h2>" );
@@ -310,10 +342,11 @@  discard block
 block discarded – undo
310 342
 
311 343
 	                if (in_array($uid,array_keys($ipuid['uid']))) {
312 344
 				$ipuid['uid']["$uid"]['count']++;		//number of learn by this uid
313
-				if (!in_array($ip,$ipuid['uid']["$uid"])) 
314
-					$ipuid['uid']["$uid"][]=$ip;		//ips learned by this uid
315
-			}
316
-			else {
345
+				if (!in_array($ip,$ipuid['uid']["$uid"])) {
346
+									$ipuid['uid']["$uid"][]=$ip;
347
+				}
348
+				//ips learned by this uid
349
+			} else {
317 350
 				$ipuid['uid']["$uid"]['count'] = 1;
318 351
 				$ipuid['uid']["$uid"][]=$ip;
319 352
 				$ipuid['uid']['count']++;                	//number of unique uids
@@ -321,10 +354,11 @@  discard block
 block discarded – undo
321 354
 
322 355
                         if (in_array($ip,array_keys($ipuid['ip']))) {
323 356
                                 $ipuid['ip']["$ip"]['count']++;			//number of time this ip appears in different messages
324
-				if (!in_array($uid,$ipuid['ip']["$ip"]))
325
-					$ipuid['ip']["$ip"][]=$uid;		//uids that learned this ip
326
-			}
327
-                        else {
357
+				if (!in_array($uid,$ipuid['ip']["$ip"])) {
358
+									$ipuid['ip']["$ip"][]=$uid;
359
+				}
360
+				//uids that learned this ip
361
+			} else {
328 362
                                 $ipuid['ip']["$ip"]['count'] = 1;
329 363
 				$ipuid['ip']["$ip"][]=$uid;
330 364
 				$ipuid['ip']['count']++;			//number of unique ips
@@ -332,21 +366,30 @@  discard block
 block discarded – undo
332 366
 
333 367
 	        	/* Update HTML report */
334 368
 	        	fwrite($fp,updateReport ( $ip,$uid,$ipuid['ip']["$ip"]['count'],$ipuid['uid']["$uid"]['count'],$host,$dateClient,$mid,$dateReceived) );
335
-		}
336
-	        else {	/* Bad learn */
369
+		} else {	/* Bad learn */
337 370
 			
338
-                        if (in_array($uid,array_keys($uidbad['uid']))) 
339
-                                $uidbad['uid']["$uid"]['count']++;               //number of bad learn by this uid
371
+                        if (in_array($uid,array_keys($uidbad['uid']))) {
372
+                                                        $uidbad['uid']["$uid"]['count']++;
373
+                        }
374
+                        //number of bad learn by this uid
340 375
                         else {
341 376
                                 $uidbad['uid']["$uid"]['count'] = 1;
342 377
 				$uidbad['uid']["$uid"][]=$uid;
343 378
                                 $uidbad['count']++;                       //numeber of unique bad uids
344 379
                         }
345 380
 			/* The reason of bad report */
346
-			if ($host === FALSE) $reason = 'This mail was not received by recognized MX host';
347
-			if ($dateReceived === FALSE) $reason = 'This mail was not submitted to recognized MSA for learn';
348
-			if ($uid=='unknown') $reason = 'The uid of this mail was not found in splunk log';
349
-			if (!isset($reason)) $reason = '?';
381
+			if ($host === FALSE) {
382
+				$reason = 'This mail was not received by recognized MX host';
383
+			}
384
+			if ($dateReceived === FALSE) {
385
+				$reason = 'This mail was not submitted to recognized MSA for learn';
386
+			}
387
+			if ($uid=='unknown') {
388
+				$reason = 'The uid of this mail was not found in splunk log';
389
+			}
390
+			if (!isset($reason)) {
391
+				$reason = '?';
392
+			}
350 393
 				
351 394
 			fwrite( $fpb,updatebadReport ( $uid,$dateClient,$mid,$dateReceived,$reason ) );
352 395
 		}
@@ -364,9 +407,9 @@  discard block
 block discarded – undo
364 407
 	fwrite($fp, '<hr><h2>Summary Report</h2><h5>Listing policy: ip must be learned at least '.$cf['thresholdip']["$type"].' times from at least '.$cf['thresholduid']["$type"].' different valid uids.</h5>' );
365 408
 
366 409
         /* Make MYSQL connection */
367
-	if ( $cf['onlyReport'] )
368
-		$mysqli = NULL;
369
-	else {
410
+	if ( $cf['onlyReport'] ) {
411
+			$mysqli = NULL;
412
+	} else {
370 413
         	$mysqli = new mysqli($myconnArray['dbhost'], $myconnArray['userdb'], $myconnArray['pwd'], $myconnArray['db'], $myconnArray['dbport']);
371 414
         	if ($mysqli->connect_error) {
372 415
                 	syslog (LOG_EMERG, $cf['user'].': Connect Error (' . $mysqli->connect_errno . ') '
@@ -378,8 +421,9 @@  discard block
 block discarded – undo
378 421
 	/***********************/
379 422
 
380 423
 	fwrite($fp, summaryReportAndList ($cf,$mysqli,$tables,$type,$ipuid) );
381
-	if ( !$cf['onlyReport'] )
382
-		$mysqli->close();
424
+	if ( !$cf['onlyReport'] ) {
425
+			$mysqli->close();
426
+	}
383 427
 	fwrite($fp,file_get_contents(dirname(__FILE__) . '/' . $cf['reportTemplateFooter']));
384 428
 	fclose($fp);
385 429
 
@@ -389,12 +433,14 @@  discard block
 block discarded – undo
389 433
 	fclose($fpb);
390 434
 	syslog (LOG_INFO,$cf['user'].': Report files written. Listing job for '.$type.' terminated.');
391 435
 
392
-	if ( $ierr = imap_errors() )
393
-		foreach ( $ierr as $thiserr )
436
+	if ( $ierr = imap_errors() ) {
437
+			foreach ( $ierr as $thiserr )
394 438
 			syslog (LOG_ERR, $cf['user'].": IMAP Error: $thiserr");
395
-	if ( $ierr = imap_alerts() )
396
-                foreach ( $ierr as $thiserr )
439
+	}
440
+	if ( $ierr = imap_alerts() ) {
441
+	                foreach ( $ierr as $thiserr )
397 442
                         syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr");
443
+	}
398 444
 	imap_close($m_mail);
399 445
 }
400 446
 ?>
Please login to merge, or discard this patch.