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 ( 2e0f71...277509 )
by Marco
02:00
created
contrib/ipImap/function.php 2 patches
Doc Comments   +34 added lines patch added patch discarded remove patch
@@ -1,4 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
+/**
3
+ * @param string $header
4
+ */
2 5
 function getIP($header,$mxserver,$msa) {
3 6
 /* Get submission server's IP from header's mail */
4 7
 /* Each line must end with /r/n			 */
@@ -28,11 +31,23 @@  discard block
 block discarded – undo
28 31
 	return array($ip,$host,$dateR,$dateC['date'],$mid['mid']);
29 32
 }
30 33
 
34
+/**
35
+ * @param string $hostname
36
+ * @param string $dateC
37
+ * @param string|null $msgid
38
+ * @param string|false $dateL
39
+ */
31 40
 function updateReport ($ip,$uid,$ipcount,$uidcount,$hostname,$dateC,$msgid,$dateL) {
32 41
 
33 42
 	return sprintf ('<tr><td nowrap>%s</td><td nowrap>%s</td><td>%s</td><td>%s</td><td>%u</td><td>%u</td><td>%s</td><td>%s</td></tr>'."\n",$dateL,$dateC,$uid,$ip,$uidcount,$ipcount,$hostname,htmlentities($msgid) );
34 43
 }
35 44
 
45
+/**
46
+ * @param string $dateC
47
+ * @param string|null $msgid
48
+ * @param false|string $dateL
49
+ * @param string $text
50
+ */
36 51
 function updatebadReport ( $uid,$dateC,$msgid,$dateL,$text ) {
37 52
 	return sprintf ('<tr><td nowrap>%s</td><td nowrap>%s</td><td>%s</td><td>%s</td><td nowrap>%s</td></tr>'."\n",$dateL,$dateC,$uid,htmlentities($msgid),$text );
38 53
 }
@@ -84,6 +99,10 @@  discard block
 block discarded – undo
84 99
 }
85 100
 
86 101
 
102
+/**
103
+ * @param null|mysqli $myconn
104
+ * @param string $key
105
+ */
87 106
 function summaryReportAndList ($cf,$myconn,$tables,$category,$vet,$key) {
88 107
 	$nk = $vet['count'];
89 108
 
@@ -160,6 +179,10 @@  discard block
 block discarded – undo
160 179
 }
161 180
 
162 181
 
182
+/**
183
+ * @param string $message_id
184
+ * @param string $date
185
+ */
163 186
 function splunksearch ($service,$message_id,$date) {
164 187
 
165 188
 	// Run a blocking search
@@ -272,6 +295,9 @@  discard block
 block discarded – undo
272 295
 }
273 296
 /***********************************/
274 297
 
298
+/**
299
+ * @param string $text
300
+ */
275 301
 function getDomains ($text) {
276 302
 	/* Pattern from http://blog.mattheworiordan.com/post/13174566389/url-regular-expression-for-links-with-or-without */
277 303
 	$pattern = '/((?:(?:[A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)(?:(?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/';
@@ -325,6 +351,9 @@  discard block
 block discarded – undo
325 351
 	return array();
326 352
 }
327 353
 
354
+/**
355
+ * @return string
356
+ */
328 357
 function humanKey($key) {
329 358
 	switch($key) {
330 359
 		case 'ip':
@@ -335,6 +364,11 @@  discard block
 block discarded – undo
335 364
 	return $key;
336 365
 }
337 366
 
367
+/**
368
+ * @param resource $f
369
+ * @param string $key
370
+ * @param string $rtime
371
+ */
338 372
 function writeFileHeader($f,$conf,$key,$type,$rtime) {
339 373
         fwrite( $f, file_get_contents(dirname(__FILE__) . '/' . $conf['report']['reportTemplateHeader']) );
340 374
         fwrite( $f,sprintf('<h1> Report of %s %s</h1><h5>%s</h5><h2>Detailed Report</h2>',$type, strtoupper(humanKey($key)),$rtime) );
Please login to merge, or discard this patch.
Spacing   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-function getIP($header,$mxserver,$msa) {
2
+function getIP($header, $mxserver, $msa) {
3 3
 /* Get submission server's IP from header's mail */
4 4
 /* Each line must end with /r/n			 */
5 5
 /* IP is the first one written by your mxserver	 */
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
 	$ip = FALSE;
8 8
 	$host = FALSE;
9 9
 	$dateR = FALSE;
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
-		for ($i = count($received[0])-1;$i>=0;$i--) {
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
+		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]) )
13
+			if (preg_match($msa, $received['host'][$i]))
14 14
 				$dateR = $received['date'][$i];
15 15
         		foreach ($mxserver as $mx) {
16 16
         			if (!$ip)
@@ -21,38 +21,38 @@  discard block
 block discarded – undo
21 21
                 	}
22 22
         	}
23 23
 	}
24
-	if ( preg_match ('/\r\nDate:\s(?P<date>.*)\r\n/',$header,$dateC) != 1)
24
+	if (preg_match('/\r\nDate:\s(?P<date>.*)\r\n/', $header, $dateC) != 1)
25 25
 		$dateC['date'] = 'Not found';
26
-	if ( preg_match ('/\r\nMessage\-I(?:D|d):\s(?P<mid>.*)\r\n/',$header,$mid) != 1)
26
+	if (preg_match('/\r\nMessage\-I(?:D|d):\s(?P<mid>.*)\r\n/', $header, $mid) != 1)
27 27
 		$mid['mid'] = NULL;
28
-	return array($ip,$host,$dateR,$dateC['date'],$mid['mid']);
28
+	return array($ip, $host, $dateR, $dateC['date'], $mid['mid']);
29 29
 }
30 30
 
31
-function updateReport ($ip,$uid,$ipcount,$uidcount,$hostname,$dateC,$msgid,$dateL) {
31
+function updateReport($ip, $uid, $ipcount, $uidcount, $hostname, $dateC, $msgid, $dateL) {
32 32
 
33
-	return sprintf ('<tr><td nowrap>%s</td><td nowrap>%s</td><td>%s</td><td>%s</td><td>%u</td><td>%u</td><td>%s</td><td>%s</td></tr>'."\n",$dateL,$dateC,$uid,$ip,$uidcount,$ipcount,$hostname,htmlentities($msgid) );
33
+	return sprintf('<tr><td nowrap>%s</td><td nowrap>%s</td><td>%s</td><td>%s</td><td>%u</td><td>%u</td><td>%s</td><td>%s</td></tr>'."\n", $dateL, $dateC, $uid, $ip, $uidcount, $ipcount, $hostname, htmlentities($msgid));
34 34
 }
35 35
 
36
-function updatebadReport ( $uid,$dateC,$msgid,$dateL,$text ) {
37
-	return sprintf ('<tr><td nowrap>%s</td><td nowrap>%s</td><td>%s</td><td>%s</td><td nowrap>%s</td></tr>'."\n",$dateL,$dateC,$uid,htmlentities($msgid),$text );
36
+function updatebadReport($uid, $dateC, $msgid, $dateL, $text) {
37
+	return sprintf('<tr><td nowrap>%s</td><td nowrap>%s</td><td>%s</td><td>%s</td><td nowrap>%s</td></tr>'."\n", $dateL, $dateC, $uid, htmlentities($msgid), $text);
38 38
 }
39 39
 
40 40
 
41
-function summaryBadReport ($uidvet) {
41
+function summaryBadReport($uidvet) {
42 42
         $nuid = $uidvet['count'];
43
-        if ( empty($uidvet) ) return NULL;
43
+        if (empty($uidvet)) return NULL;
44 44
         $return = '<hr><h3>Statistics by UID</h3><table><tr><th>UID</th><th>Learned times</th></tr>'."\n";
45 45
 
46 46
         /* Remove count index */
47 47
         $uids = array_keys($uidvet['uid']);
48 48
 	$totlearn = 0;
49 49
 
50
-        foreach ( $uids as $uid ) {
51
-		$totlearn += $uidvet['uid']["$uid"]['count'];; 
52
-		$return .= sprintf ('<tr><td>%s</td><td>%u</td></tr>',$uid,$uidvet['uid']["$uid"]['count']);
50
+        foreach ($uids as $uid) {
51
+		$totlearn += $uidvet['uid']["$uid"]['count']; ; 
52
+		$return .= sprintf('<tr><td>%s</td><td>%u</td></tr>', $uid, $uidvet['uid']["$uid"]['count']);
53 53
 	}
54
-	$return .= sprintf ('<tr><th>%s</th><th>%u</th></tr></table>','TOT',$totlearn);
55
-	$return .= sprintf ('<p>%s : %u</p>','Unique UID',$nuid);
54
+	$return .= sprintf('<tr><th>%s</th><th>%u</th></tr></table>', 'TOT', $totlearn);
55
+	$return .= sprintf('<p>%s : %u</p>', 'Unique UID', $nuid);
56 56
 
57 57
 	return $return;
58 58
 }
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
     foreach ($cols as $col => $order) {
70 70
         $eval .= '$colarr[\''.$col.'\'],'.$order.',';
71 71
     }
72
-    $eval = substr($eval,0,-1).');';
72
+    $eval = substr($eval, 0, -1).');';
73 73
     eval($eval);
74 74
     $ret = array();
75 75
     foreach ($colarr as $col => $arr) {
76 76
         foreach ($arr as $k => $v) {
77
-            $k = substr($k,1);
77
+            $k = substr($k, 1);
78 78
             if (!isset($ret[$k])) $ret[$k] = $array[$k];
79 79
             if (isset ($array[$k][$col])) $ret[$k][$col] = $array[$k][$col];
80 80
         }
@@ -84,33 +84,33 @@  discard block
 block discarded – undo
84 84
 }
85 85
 
86 86
 
87
-function summaryReportAndList ($cf,$myconn,$tables,$category,$vet,$key) {
87
+function summaryReportAndList($cf, $myconn, $tables, $category, $vet, $key) {
88 88
 	$nk = $vet['count'];
89 89
 
90
-	if ( empty($vet) ) return NULL;
90
+	if (empty($vet)) return NULL;
91 91
 	
92
-	$return = sprintf('<h3>Statistics by %s</h3><table><tr><th>%s</th><th>Learned by</th><th>Learned times</th><th title="This field doesn\'t say if this %s is currently listed, but it says if this %s has listed now!">Listed Now</th></tr>'."\n", strtoupper($key),strtoupper($key),$key,$key);
92
+	$return = sprintf('<h3>Statistics by %s</h3><table><tr><th>%s</th><th>Learned by</th><th>Learned times</th><th title="This field doesn\'t say if this %s is currently listed, but it says if this %s has listed now!">Listed Now</th></tr>'."\n", strtoupper($key), strtoupper($key), $key, $key);
93 93
 	
94 94
 	$values = array_keys($vet["$key"]);
95 95
 
96
-	foreach ( $values as $value ) {
97
-		if ( $value == 'count' ) continue;
96
+	foreach ($values as $value) {
97
+		if ($value == 'count') continue;
98 98
                 $nlearn = $vet["$key"]["$value"]['count'];
99 99
                 unset($vet["$key"]["$value"]['count']);
100 100
 		$quantity = $cf["listing$key"]['quantity']["$category"]; /* In searchAndList this value is
101 101
 										passed by reference and modified */
102 102
 		$nuid = count($vet["$key"]["$value"]);
103
-		if ( !$cf["listing$key"]['onlyReport']["$category"] ) {
104
-			if ( ($nlearn >= $cf["listing$key"]['threshold']["$category"])&&($nuid >= $cf["listing$key"]['thresholduid']["$category"]) ) {
103
+		if (!$cf["listing$key"]['onlyReport']["$category"]) {
104
+			if (($nlearn>=$cf["listing$key"]['threshold']["$category"]) && ($nuid>=$cf["listing$key"]['thresholduid']["$category"])) {
105 105
 				$reason = sprintf(
106 106
 				'The %s <%s> has been listed because was marked %u times as %s by %u different accounts during last %u days.',
107
-				strtoupper($key),$value,$nlearn,$category,$nuid,$cf['imap']['oldestday']);
108
-				$listed = searchAndList ($myconn,$cf['syslog']['user'],$tables,$cf["listing$key"]['list']["$category"],$value,$cf["listing$key"]['unit']["$category"],$quantity,$reason);
107
+				strtoupper($key), $value, $nlearn, $category, $nuid, $cf['imap']['oldestday']);
108
+				$listed = searchAndList($myconn, $cf['syslog']['user'], $tables, $cf["listing$key"]['list']["$category"], $value, $cf["listing$key"]['unit']["$category"], $quantity, $reason);
109 109
 			}
110 110
 			else $listed = FALSE;
111 111
 		}
112 112
 		else $listed = FALSE;
113
-		$nowlist = array( TRUE =>  array(
113
+		$nowlist = array(TRUE =>  array(
114 114
 					'style' => 'id=\'ipfound\'',
115 115
 					'name'  => 'YES',
116 116
 				  ),
@@ -124,46 +124,46 @@  discard block
 block discarded – undo
124 124
 				  )
125 125
 		);
126 126
 		
127
-		$return .='<tr><td rowspan="'.$nuid.'">'.$value.'</td>';
128
-		$return .= sprintf ('<td>%s</td><td rowspan="'.$nuid.'">%u</td><td rowspan="'.$nuid.'" '.$nowlist["$listed"]['style'].'>%s</td></tr>',$vet["$key"]["$value"][0],$nlearn,$nowlist["$listed"]['name']);
129
-		$rowuid=NULL;
130
-                for ($j=1;$j<$nuid;$j++) $rowuid .= '<tr><td>%s</td></tr>';
127
+		$return .= '<tr><td rowspan="'.$nuid.'">'.$value.'</td>';
128
+		$return .= sprintf('<td>%s</td><td rowspan="'.$nuid.'">%u</td><td rowspan="'.$nuid.'" '.$nowlist["$listed"]['style'].'>%s</td></tr>', $vet["$key"]["$value"][0], $nlearn, $nowlist["$listed"]['name']);
129
+		$rowuid = NULL;
130
+                for ($j = 1; $j<$nuid; $j++) $rowuid .= '<tr><td>%s</td></tr>';
131 131
 		array_shift($vet["$key"]["$value"]);
132
-                $return .= vsprintf ($rowuid,$vet["$key"]["$value"]);
132
+                $return .= vsprintf($rowuid, $vet["$key"]["$value"]);
133 133
 
134 134
 	}
135
-	$return .= sprintf ('<tr><th title="unique %s">%u</th><th title="unique uids">%u</th><th>%u</th></table>',$key,$vet["$key"]['count'],$vet['uid']['count'],$nk);
135
+	$return .= sprintf('<tr><th title="unique %s">%u</th><th title="unique uids">%u</th><th>%u</th></table>', $key, $vet["$key"]['count'], $vet['uid']['count'], $nk);
136 136
 
137 137
 
138 138
 	/* Statistics by UID */
139 139
 	/* Not used for listing purpose, but useful to you! */
140
-	$return .= sprintf('<h3>Statistics by UID</h3><table><tr><th>UID</th><th>%s learned</th><th>Learned times</th></tr>'."\n",$key);
140
+	$return .= sprintf('<h3>Statistics by UID</h3><table><tr><th>UID</th><th>%s learned</th><th>Learned times</th></tr>'."\n", $key);
141 141
 	$uids = array_keys($vet['uid']);
142
-        foreach ( $uids as $uid ) {
143
-		if ( $uid == 'count' ) continue;	
142
+        foreach ($uids as $uid) {
143
+		if ($uid == 'count') continue;	
144 144
 	        $nlearn = $vet['uid']["$uid"]['count'];
145
-	        unset ( $vet['uid']["$uid"]['count'] );
145
+	        unset ($vet['uid']["$uid"]['count']);
146 146
 		$nip = count($vet['uid']["$uid"]);
147
-		$return .='<tr><td rowspan="'.$nip.'">'.$uid.'</td>';
148
-		$return .= sprintf ('<td>%s</td><td rowspan="'.$nip.'">%u</td></tr>',$vet['uid']["$uid"][0],$nlearn);
149
-                $rowuid=NULL;
150
-                for ($j=1;$j<$nip;$j++) $rowuid .= '<tr><td>%s</td></tr>';
147
+		$return .= '<tr><td rowspan="'.$nip.'">'.$uid.'</td>';
148
+		$return .= sprintf('<td>%s</td><td rowspan="'.$nip.'">%u</td></tr>', $vet['uid']["$uid"][0], $nlearn);
149
+                $rowuid = NULL;
150
+                for ($j = 1; $j<$nip; $j++) $rowuid .= '<tr><td>%s</td></tr>';
151 151
                 array_shift($vet['uid']["$uid"]);
152
-                $return .= vsprintf ($rowuid,$vet['uid']["$uid"]);
152
+                $return .= vsprintf($rowuid, $vet['uid']["$uid"]);
153 153
 
154 154
         }
155
-        $return .= sprintf ('<tr><th title="unique uids">%u</th><th title="unique %s">%u</th><th>%u</th></table>',
156
-			$vet['uid']['count'],$key,$vet["$key"]['count'],$nk);
155
+        $return .= sprintf('<tr><th title="unique uids">%u</th><th title="unique %s">%u</th><th>%u</th></table>',
156
+			$vet['uid']['count'], $key, $vet["$key"]['count'], $nk);
157 157
 
158 158
 
159 159
 	return $return;
160 160
 }
161 161
 
162 162
 
163
-function splunksearch ($service,$message_id,$date) {
163
+function splunksearch($service, $message_id, $date) {
164 164
 
165 165
 	// Run a blocking search
166
-	$searchQueryBlocking = 'search (message_id="'. addslashes( $message_id ) .
166
+	$searchQueryBlocking = 'search (message_id="'.addslashes($message_id).
167 167
 				'" OR sasl_username) | transaction message_id queue_id maxspan=3m maxpause=2m | search sasl_username message_id=* | table sasl_username';
168 168
 
169 169
 	/* Doesn't work on Splunk 6.6 for HTTP exceptions
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
 
183 183
 	// A one shot search
184 184
         $searchParams = array(
185
-                'earliest_time' => date("c",strtotime ($date)-120),
186
-                'latest_time' => date("c",strtotime ($date)+60)
185
+                'earliest_time' => date("c", strtotime($date)-120),
186
+                'latest_time' => date("c", strtotime($date)+60)
187 187
         );
188 188
 
189 189
         // Run a oneshot search that returns the job's results
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	    {
198 198
 	      // More than one field attribute returned by search
199 199
 	      // You must redefine the search
200
-	      if ( count($result->getFieldNames()) > 1 ) return FALSE;
200
+	      if (count($result->getFieldNames())>1) return FALSE;
201 201
 	    }
202 202
 	    else if ($result instanceof Splunk_ResultsMessage)
203 203
 	    {
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
 
236 236
 function flattenParts($messageParts, $flattenedParts = array(), $prefix = '', $index = 1, $fullPrefix = true) {
237 237
 
238
-        foreach($messageParts as $part) {
238
+        foreach ($messageParts as $part) {
239 239
                 $flattenedParts[$prefix.$index] = $part;
240
-                if(isset($part->parts)) {
241
-                        if($part->type == 2) {
240
+                if (isset($part->parts)) {
241
+                        if ($part->type == 2) {
242 242
                                 $flattenedParts = flattenParts($part->parts, $flattenedParts, $prefix.$index.'.', 0, false);
243 243
                         }
244
-                        elseif($fullPrefix) {
244
+                        elseif ($fullPrefix) {
245 245
                                 $flattenedParts = flattenParts($part->parts, $flattenedParts, $prefix.$index.'.');
246 246
                         }
247 247
                         else {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 function getPart($connection, $messageNumber, $partNumber, $encoding) {
260 260
 
261 261
         $data = imap_fetchbody($connection, $messageNumber, $partNumber);
262
-        switch($encoding) {
262
+        switch ($encoding) {
263 263
                 case 0: return $data; // 7BIT
264 264
                 case 1: return $data; // 8BIT
265 265
                 case 2: return $data; // BINARY
@@ -272,26 +272,26 @@  discard block
 block discarded – undo
272 272
 }
273 273
 /***********************************/
274 274
 
275
-function getDomains ($text) {
275
+function getDomains($text) {
276 276
 	/* Pattern from http://blog.mattheworiordan.com/post/13174566389/url-regular-expression-for-links-with-or-without */
277 277
 	$pattern = '/((?:(?:[A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)(?:(?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/';
278 278
 	$ret = array();
279 279
 	$num_found = preg_match_all($pattern, $text, $out);
280
-	if ( ($num_found !== FALSE) && ($num_found>0) ) {
280
+	if (($num_found !== FALSE) && ($num_found>0)) {
281 281
 		foreach ($out[0] as $url)
282 282
 			$ret[] = parse_url($url, PHP_URL_HOST);
283 283
 	}
284 284
 	return array_values(array_unique($ret));
285 285
 }
286 286
 
287
-function parseURL ($connection,$messageNumber) {
287
+function parseURL($connection, $messageNumber) {
288 288
 	$message = '';
289 289
 	$structure = imap_fetchstructure($connection, $messageNumber);
290 290
 	if (isset($structure->parts)) {
291 291
 		$flattenedParts = flattenParts($structure->parts);
292
-		foreach($flattenedParts as $partNumber => $part) {
292
+		foreach ($flattenedParts as $partNumber => $part) {
293 293
 
294
-			switch($part->type) {
294
+			switch ($part->type) {
295 295
 		
296 296
 				case 0:
297 297
 					// the HTML or plain text part of the email
@@ -320,13 +320,13 @@  discard block
 block discarded – undo
320 320
 	else
321 321
 		$message = getPart($connection, $messageNumber, 1, $structure->encoding);
322 322
 
323
-	if ( !empty($message) )
323
+	if (!empty($message))
324 324
 		return getDomains($message);
325 325
 	return array();
326 326
 }
327 327
 
328 328
 function humanKey($key) {
329
-	switch($key) {
329
+	switch ($key) {
330 330
 		case 'ip':
331 331
 			return 'ips';
332 332
 		case 'dom':
@@ -335,67 +335,67 @@  discard block
 block discarded – undo
335 335
 	return $key;
336 336
 }
337 337
 
338
-function writeFileHeader($f,$conf,$key,$type,$rtime) {
339
-        fwrite( $f, file_get_contents(dirname(__FILE__) . '/' . $conf['report']['reportTemplateHeader']) );
340
-        fwrite( $f,sprintf('<h1> Report of %s %s</h1><h5>%s</h5><h2>Detailed Report</h2>',$type, strtoupper(humanKey($key)),$rtime) );
338
+function writeFileHeader($f, $conf, $key, $type, $rtime) {
339
+        fwrite($f, file_get_contents(dirname(__FILE__).'/'.$conf['report']['reportTemplateHeader']));
340
+        fwrite($f, sprintf('<h1> Report of %s %s</h1><h5>%s</h5><h2>Detailed Report</h2>', $type, strtoupper(humanKey($key)), $rtime));
341 341
         if ($conf["listing$key"]['onlyReport']["$type"]) {
342
-                fwrite( $f,sprintf('<p>None of the below %s have been listed because listing is not active in configuration.</p>',
343
-		strtoupper(humanKey($key))) );
342
+                fwrite($f, sprintf('<p>None of the below %s have been listed because listing is not active in configuration.</p>',
343
+		strtoupper(humanKey($key))));
344 344
 		syslog(LOG_INFO, sprintf('%s: Report only for %s %s: no listing activated in configuration.',
345
-			$conf['syslog']['user'],$type,humanKey($key))
345
+			$conf['syslog']['user'], $type, humanKey($key))
346 346
 		);
347 347
 	}
348
-        fwrite( $f,sprintf('<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>%s</th><th title="How many times this uid learns">#UID</th><th title="Number of times this learned %s appears in different mails">#%s</th><th nowrap>Received by</th><th>Message-Id</th></tr>',
349
-	strtoupper($key),strtoupper($key),strtoupper($key)) );
348
+        fwrite($f, sprintf('<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>%s</th><th title="How many times this uid learns">#UID</th><th title="Number of times this learned %s appears in different mails">#%s</th><th nowrap>Received by</th><th>Message-Id</th></tr>',
349
+	strtoupper($key), strtoupper($key), strtoupper($key)));
350 350
 }
351 351
 
352 352
 
353
-function imapReport ($cf,$myconnArray,$splunkconn,$tables,$type) {
354
-	$file = dirname(__FILE__) . '/' . $cf['report']['reportFile']["$type"];
355
-	$filed = dirname(__FILE__) . '/' . $cf['report']['reportDomFile']["$type"];
356
-	$fileb= dirname(__FILE__) . '/' . $cf['report']['badreportFile']["$type"];
357
-	$m_mail = imap_open('{'.$cf['imap']['mailhost'].':143/imap/novalidate-cert/authuser='.$cf['imap']['authuser'].'}'.$cf['imap']['folder']["$type"], $cf['imap']['account'],$cf['imap']['authpassword'], OP_READONLY)
358
-        	or syslog (LOG_EMERG, $cf['syslog']['user'].': Error in IMAP connection to <'.$cf['imap']['mailhost'].'>: ' . imap_last_error());
359
-	if ( !$m_mail ) exit(254);
353
+function imapReport($cf, $myconnArray, $splunkconn, $tables, $type) {
354
+	$file = dirname(__FILE__).'/'.$cf['report']['reportFile']["$type"];
355
+	$filed = dirname(__FILE__).'/'.$cf['report']['reportDomFile']["$type"];
356
+	$fileb = dirname(__FILE__).'/'.$cf['report']['badreportFile']["$type"];
357
+	$m_mail = imap_open('{'.$cf['imap']['mailhost'].':143/imap/novalidate-cert/authuser='.$cf['imap']['authuser'].'}'.$cf['imap']['folder']["$type"], $cf['imap']['account'], $cf['imap']['authpassword'], OP_READONLY)
358
+        	or syslog(LOG_EMERG, $cf['syslog']['user'].': Error in IMAP connection to <'.$cf['imap']['mailhost'].'>: '.imap_last_error());
359
+	if (!$m_mail) exit(254);
360 360
 		
361 361
 
362
-	syslog (LOG_INFO,$cf['syslog']['user'].': Successfully connected to <'.$cf['imap']['mailhost'].">; Reading $type messages of last ".$cf['imap']['oldestday'].' days...');
362
+	syslog(LOG_INFO, $cf['syslog']['user'].': Successfully connected to <'.$cf['imap']['mailhost'].">; Reading $type messages of last ".$cf['imap']['oldestday'].' days...');
363 363
 	//get all messages
364
-	$dateTh = date ( "d-M-Y", strToTime ( '-'.$cf['imap']['oldestday'].' days' ) );
365
-        $dateN  = date ( "d-M-Y", strToTime ( "now" ) );
366
-        $m_search=imap_search ($m_mail, "SINCE \"$dateTh\" BEFORE \"$dateN\"" );
364
+	$dateTh = date("d-M-Y", strToTime('-'.$cf['imap']['oldestday'].' days'));
365
+        $dateN = date("d-M-Y", strToTime("now"));
366
+        $m_search = imap_search($m_mail, "SINCE \"$dateTh\" BEFORE \"$dateN\"");
367 367
 
368 368
 	// Order results starting from newest message
369
-	if ( empty($m_search) ) {
370
-		syslog (LOG_INFO,$cf['syslog']['user'].": No mail found in $type folder. No reports written for $type.");
371
-	        if ( $ierr = imap_errors() )
372
-	                foreach ( $ierr as $thiserr )
373
-	                        syslog (LOG_ERR, $cf['syslog']['user'].": IMAP Error: $thiserr");
374
-	        if ( $ierr = imap_alerts() )
375
-	                foreach ( $ierr as $thiserr )
376
-	                        syslog (LOG_ALERT, $cf['syslog']['user'].": IMAP Alert: $thiserr");
377
-		imap_close( $m_mail );
378
-		if ( file_exists( $file ) ) unlink ($file);
379
-		if ( file_exists( $filed ) ) unlink ($filed);
380
-		if ( file_exists( $fileb ) ) unlink ($fileb);
369
+	if (empty($m_search)) {
370
+		syslog(LOG_INFO, $cf['syslog']['user'].": No mail found in $type folder. No reports written for $type.");
371
+	        if ($ierr = imap_errors())
372
+	                foreach ($ierr as $thiserr)
373
+	                        syslog(LOG_ERR, $cf['syslog']['user'].": IMAP Error: $thiserr");
374
+	        if ($ierr = imap_alerts())
375
+	                foreach ($ierr as $thiserr)
376
+	                        syslog(LOG_ALERT, $cf['syslog']['user'].": IMAP Alert: $thiserr");
377
+		imap_close($m_mail);
378
+		if (file_exists($file)) unlink($file);
379
+		if (file_exists($filed)) unlink($filed);
380
+		if (file_exists($fileb)) unlink($fileb);
381 381
 		return FALSE;
382 382
 	}
383
-	$nmes = count ($m_search);
384
-	syslog (LOG_INFO,$cf['syslog']['user'].": Found $nmes mail in $type folder.");
383
+	$nmes = count($m_search);
384
+	syslog(LOG_INFO, $cf['syslog']['user'].": Found $nmes mail in $type folder.");
385 385
 	if ($nmes>0) rsort($m_search);
386 386
 
387 387
 	// Create report file
388 388
 
389 389
 	$fp = fopen($file, 'w');
390
-	$fpd= fopen($filed, 'w');
391
-	$fpb= fopen($fileb, 'w');
392
-	$lastup = "Last Update: " . date ("d F Y H:i", time());
393
-	writeFileHeader($fp,$cf,'ip',$type,$lastup);
394
-	writeFileHeader($fpd,$cf,'dom',$type,$lastup);
390
+	$fpd = fopen($filed, 'w');
391
+	$fpb = fopen($fileb, 'w');
392
+	$lastup = "Last Update: ".date("d F Y H:i", time());
393
+	writeFileHeader($fp, $cf, 'ip', $type, $lastup);
394
+	writeFileHeader($fpd, $cf, 'dom', $type, $lastup);
395 395
 
396
-	fwrite( $fpb,file_get_contents(dirname(__FILE__) . '/' . $cf['report']['reportTemplateHeader']) );
397
-	fwrite( $fpb,"<h1> Report of bad reported $type mails</h1><h5>$lastup</h5><h2>Detailed Report</h2>" );
398
-	fwrite( $fpb,'<table><tr><th title="taken from Received header" nowrap>Date Learn</th><th title="taken from Date header" nowrap>Date Received</th><th nowrap>UID</th><th>Message-Id</th><th title="Why is this a bad report?">Reason</th></tr>' );
396
+	fwrite($fpb, file_get_contents(dirname(__FILE__).'/'.$cf['report']['reportTemplateHeader']));
397
+	fwrite($fpb, "<h1> Report of bad reported $type mails</h1><h5>$lastup</h5><h2>Detailed Report</h2>");
398
+	fwrite($fpb, '<table><tr><th title="taken from Received header" nowrap>Date Learn</th><th title="taken from Date header" nowrap>Date Received</th><th nowrap>UID</th><th>Message-Id</th><th title="Why is this a bad report?">Reason</th></tr>');
399 399
 
400 400
 	$ipuid = array();
401 401
 	$ipuid['count'] = 0;
@@ -419,105 +419,105 @@  discard block
 block discarded – undo
419 419
 	        //get imap header info for obj thang
420 420
 	        //$headers = imap_headerinfo($m_mail, $onem);
421 421
 	        //$head = imap_fetchheader($m_mail, $headers->Msgno);
422
-		$head = imap_fetchheader($m_mail, $onem );
422
+		$head = imap_fetchheader($m_mail, $onem);
423 423
 	        //$obj = imap_rfc822_parse_headers( $head);
424 424
 
425
-	        list ($ip,$host,$dateReceived,$dateClient,$mid) =  getIP( $head,$cf['mx_hostname']['mx'],$cf['msa']['msalearn'] );
425
+	        list ($ip, $host, $dateReceived, $dateClient, $mid) = getIP($head, $cf['mx_hostname']['mx'], $cf['msa']['msalearn']);
426 426
 		if (empty($mid)) {
427
-			$uid='NA';
428
-			syslog (LOG_ERR, $cf['syslog']['user'].": Error retrieving data for empty Message-ID.");
429
-		} else {
427
+			$uid = 'NA';
428
+			syslog(LOG_ERR, $cf['syslog']['user'].": Error retrieving data for empty Message-ID.");
429
+		}else {
430 430
 			if ($dateReceived === FALSE) {
431
-				$uid='unauthenticated';
432
-				syslog (LOG_ERR, $cf['syslog']['user'].": Error retrieving date for $mid. Maybe this mail was not submitted to Learner MSA");
433
-			} else  
434
-				if ( !($uid = splunksearch ($splunkconn, trim($mid,'<>'), $dateReceived)) ) {
435
-					syslog (LOG_ERR, $cf['syslog']['user'].": Error retrieving uid from Splunk log for $mid.");
436
-					$uid='unknown';
431
+				$uid = 'unauthenticated';
432
+				syslog(LOG_ERR, $cf['syslog']['user'].": Error retrieving date for $mid. Maybe this mail was not submitted to Learner MSA");
433
+			}else  
434
+				if (!($uid = splunksearch($splunkconn, trim($mid, '<>'), $dateReceived))) {
435
+					syslog(LOG_ERR, $cf['syslog']['user'].": Error retrieving uid from Splunk log for $mid.");
436
+					$uid = 'unknown';
437 437
 				}
438 438
 		}
439 439
 
440 440
 		/* Extract domains url in body */
441
-		$domains = parseURL ($m_mail,$onem);
441
+		$domains = parseURL($m_mail, $onem);
442 442
 
443 443
 	        /* Update count of each ip */
444
-	        if ($host and ($uid!='NA') and ($uid!='unauthenticated') and ($uid!='unknown')) { /* IP is received by MX servers  and learned by valid uid */
445
-			$ipuid['count']++;					//number of right messages
444
+	        if ($host and ($uid != 'NA') and ($uid != 'unauthenticated') and ($uid != 'unknown')) { /* IP is received by MX servers  and learned by valid uid */
445
+			$ipuid['count']++; //number of right messages
446 446
 
447
-	                if (in_array($uid,array_keys($ipuid['uid']))) {
448
-				$ipuid['uid']["$uid"]['count']++;		//number of learn by this uid
449
-				if (!in_array($ip,$ipuid['uid']["$uid"])) 
450
-					$ipuid['uid']["$uid"][]=$ip;		//ips learned by this uid
447
+	                if (in_array($uid, array_keys($ipuid['uid']))) {
448
+				$ipuid['uid']["$uid"]['count']++; //number of learn by this uid
449
+				if (!in_array($ip, $ipuid['uid']["$uid"])) 
450
+					$ipuid['uid']["$uid"][] = $ip; //ips learned by this uid
451 451
 			}
452 452
 			else {
453 453
 				$ipuid['uid']["$uid"]['count'] = 1;
454
-				$ipuid['uid']["$uid"][]=$ip;
455
-				$ipuid['uid']['count']++;                	//number of unique uids
454
+				$ipuid['uid']["$uid"][] = $ip;
455
+				$ipuid['uid']['count']++; //number of unique uids
456 456
 			}
457 457
 
458
-                        if (in_array($ip,array_keys($ipuid['ip']))) {
459
-                                $ipuid['ip']["$ip"]['count']++;			//number of time this ip appears in different messages
460
-				if (!in_array($uid,$ipuid['ip']["$ip"]))
461
-					$ipuid['ip']["$ip"][]=$uid;		//uids that learned this ip
458
+                        if (in_array($ip, array_keys($ipuid['ip']))) {
459
+                                $ipuid['ip']["$ip"]['count']++; //number of time this ip appears in different messages
460
+				if (!in_array($uid, $ipuid['ip']["$ip"]))
461
+					$ipuid['ip']["$ip"][] = $uid; //uids that learned this ip
462 462
 			}
463 463
                         else {
464 464
                                 $ipuid['ip']["$ip"]['count'] = 1;
465
-				$ipuid['ip']["$ip"][]=$uid;
466
-				$ipuid['ip']['count']++;			//number of unique ips
465
+				$ipuid['ip']["$ip"][] = $uid;
466
+				$ipuid['ip']['count']++; //number of unique ips
467 467
                         }
468 468
 
469 469
 			foreach ($domains as $dom) {
470 470
 				$domuid['count']++;
471
-				if (in_array($uid,array_keys($domuid['uid']))) {
472
-					$domuid['uid']["$uid"]['count']++;               //number of learn by this uid
473
-					if (!in_array($dom,$domuid['uid']["$uid"]))
474
-						$domuid['uid']["$uid"][]=$dom;		//domains learned by this uid
471
+				if (in_array($uid, array_keys($domuid['uid']))) {
472
+					$domuid['uid']["$uid"]['count']++; //number of learn by this uid
473
+					if (!in_array($dom, $domuid['uid']["$uid"]))
474
+						$domuid['uid']["$uid"][] = $dom; //domains learned by this uid
475 475
 				}
476 476
 				else {
477 477
 					$domuid['uid']["$uid"]['count'] = 1;
478
-					$domuid['uid']["$uid"][]=$dom;
479
-					$domuid['uid']['count']++;			//number of unique uids
478
+					$domuid['uid']["$uid"][] = $dom;
479
+					$domuid['uid']['count']++; //number of unique uids
480 480
 				}
481 481
 
482
-				if (in_array($dom,array_keys($domuid['dom']))) {
483
-					$domuid['dom']["$dom"]['count']++;	//number of learn with this domain
484
-					if (!in_array($uid,$domuid['dom']["$dom"]))
485
-						$domuid['dom']["$dom"][]=$uid;	//uids that learned this domain
482
+				if (in_array($dom, array_keys($domuid['dom']))) {
483
+					$domuid['dom']["$dom"]['count']++; //number of learn with this domain
484
+					if (!in_array($uid, $domuid['dom']["$dom"]))
485
+						$domuid['dom']["$dom"][] = $uid; //uids that learned this domain
486 486
 				}
487 487
 				else {
488 488
 					$domuid['dom']["$dom"]['count'] = 1;
489
-					$domuid['dom']["$dom"][]=$uid;
490
-					$domuid['dom']['count']++;		//number of unique domains
489
+					$domuid['dom']["$dom"][] = $uid;
490
+					$domuid['dom']['count']++; //number of unique domains
491 491
 				}
492 492
 
493 493
 				fwrite($fpd,
494
-					updateReport (
495
-						$dom,$uid,$domuid['dom']["$dom"]['count'],
496
-						$domuid['uid']["$uid"]['count'],$host,
497
-						$dateClient,$mid,$dateReceived
494
+					updateReport(
495
+						$dom, $uid, $domuid['dom']["$dom"]['count'],
496
+						$domuid['uid']["$uid"]['count'], $host,
497
+						$dateClient, $mid, $dateReceived
498 498
 					)
499 499
 				);
500 500
 			}
501 501
 
502 502
 	        	/* Update HTML report */
503
-	        	fwrite($fp,updateReport ( $ip,$uid,$ipuid['ip']["$ip"]['count'],$ipuid['uid']["$uid"]['count'],$host,$dateClient,$mid,$dateReceived) );
503
+	        	fwrite($fp, updateReport($ip, $uid, $ipuid['ip']["$ip"]['count'], $ipuid['uid']["$uid"]['count'], $host, $dateClient, $mid, $dateReceived));
504 504
 		}
505 505
 	        else {	/* Bad learn */
506 506
 			
507
-                        if (in_array($uid,array_keys($uidbad['uid']))) 
508
-                                $uidbad['uid']["$uid"]['count']++;               //number of bad learn by this uid
507
+                        if (in_array($uid, array_keys($uidbad['uid']))) 
508
+                                $uidbad['uid']["$uid"]['count']++; //number of bad learn by this uid
509 509
                         else {
510 510
                                 $uidbad['uid']["$uid"]['count'] = 1;
511
-				$uidbad['uid']["$uid"][]=$uid;
512
-                                $uidbad['count']++;                       //numeber of unique bad uids
511
+				$uidbad['uid']["$uid"][] = $uid;
512
+                                $uidbad['count']++; //numeber of unique bad uids
513 513
                         }
514 514
 			/* The reason of bad report */
515 515
 			if ($host === FALSE) $reason = 'This mail was not received by recognized MX host';
516 516
 			if ($dateReceived === FALSE) $reason = 'This mail was not submitted to recognized MSA for learn';
517
-			if ($uid=='unknown') $reason = 'The uid of this mail was not found in splunk log';
517
+			if ($uid == 'unknown') $reason = 'The uid of this mail was not found in splunk log';
518 518
 			if (!isset($reason)) $reason = '?';
519 519
 				
520
-			fwrite( $fpb,updatebadReport ( $uid,$dateClient,$mid,$dateReceived,$reason ) );
520
+			fwrite($fpb, updatebadReport($uid, $dateClient, $mid, $dateReceived, $reason));
521 521
 		}
522 522
 	}
523 523
 
@@ -525,54 +525,54 @@  discard block
 block discarded – undo
525 525
 	//close report file and mailbox
526 526
 
527 527
 	/* Summary Report */
528
-	$ipuid['ip'] = array_msort( $ipuid['ip'], array('count'=>SORT_DESC) );
529
-	$ipuid['uid'] = array_msort( $ipuid['uid'], array('count'=>SORT_DESC) );
530
-	$domuid['dom'] = array_msort( $domuid['dom'], array('count'=>SORT_DESC) );
531
-	$domuid['uid'] = array_msort( $domuid['uid'], array('count'=>SORT_DESC) );
532
-	$uidbad['uid'] = array_msort( $uidbad['uid'], array('count'=>SORT_DESC) );
528
+	$ipuid['ip'] = array_msort($ipuid['ip'], array('count'=>SORT_DESC));
529
+	$ipuid['uid'] = array_msort($ipuid['uid'], array('count'=>SORT_DESC));
530
+	$domuid['dom'] = array_msort($domuid['dom'], array('count'=>SORT_DESC));
531
+	$domuid['uid'] = array_msort($domuid['uid'], array('count'=>SORT_DESC));
532
+	$uidbad['uid'] = array_msort($uidbad['uid'], array('count'=>SORT_DESC));
533 533
 	
534 534
 	fwrite($fp, '</table>');
535 535
 	fwrite($fpd, '</table>');
536
-	fwrite($fp, '<hr><h2>Summary Report</h2><h5>Listing policy: ip must be learned at least '.$cf['listingip']['threshold']["$type"].' times from at least '.$cf['listingip']['thresholduid']["$type"].' different valid uids.</h5>' );
537
-	fwrite($fpd, '<hr><h2>Summary Report</h2><h5>Listing policy: domains must be learned at least '.$cf['listingdom']['threshold']["$type"].' times from at least '.$cf['listingdom']['thresholduid']["$type"].' different valid uids.</h5>' );
536
+	fwrite($fp, '<hr><h2>Summary Report</h2><h5>Listing policy: ip must be learned at least '.$cf['listingip']['threshold']["$type"].' times from at least '.$cf['listingip']['thresholduid']["$type"].' different valid uids.</h5>');
537
+	fwrite($fpd, '<hr><h2>Summary Report</h2><h5>Listing policy: domains must be learned at least '.$cf['listingdom']['threshold']["$type"].' times from at least '.$cf['listingdom']['thresholduid']["$type"].' different valid uids.</h5>');
538 538
 
539 539
         /* Make MYSQL connection */
540
-	if ( $cf['listingip']['onlyReport']["$type"] && $cf['listingdom']['onlyReport']["$type"] )
540
+	if ($cf['listingip']['onlyReport']["$type"] && $cf['listingdom']['onlyReport']["$type"])
541 541
 		$mysqli = NULL;
542 542
 	else {
543 543
         	$mysqli = new mysqli($myconnArray['dbhost'], $myconnArray['userdb'], $myconnArray['pwd'], $myconnArray['db'], $myconnArray['dbport']);
544 544
         	if ($mysqli->connect_error) {
545
-                	syslog (LOG_EMERG, $cf['syslog']['user'].': Connect Error (' . $mysqli->connect_errno . ') '
545
+                	syslog(LOG_EMERG, $cf['syslog']['user'].': Connect Error ('.$mysqli->connect_errno.') '
546 546
                 	. $mysqli->connect_error);
547 547
                 	exit (254);
548 548
         	}
549
-        	syslog(LOG_INFO, $cf['syslog']['user'].': Successfully mysql connected to ' . $mysqli->host_info) ;
549
+        	syslog(LOG_INFO, $cf['syslog']['user'].': Successfully mysql connected to '.$mysqli->host_info);
550 550
 	}
551 551
 	/***********************/
552 552
 
553
-	fwrite($fp, summaryReportAndList ($cf,$mysqli,$tables,$type,$ipuid, 'ip') );
554
-	fwrite($fp,file_get_contents(dirname(__FILE__) . '/' . $cf['report']['reportTemplateFooter']));
553
+	fwrite($fp, summaryReportAndList($cf, $mysqli, $tables, $type, $ipuid, 'ip'));
554
+	fwrite($fp, file_get_contents(dirname(__FILE__).'/'.$cf['report']['reportTemplateFooter']));
555 555
 	fclose($fp);
556 556
 
557
-	fwrite($fpd, summaryReportAndList ($cf,$mysqli,$tables,$type,$domuid, 'dom') );
558
-	fwrite($fpd,file_get_contents(dirname(__FILE__) . '/' . $cf['report']['reportTemplateFooter']));
557
+	fwrite($fpd, summaryReportAndList($cf, $mysqli, $tables, $type, $domuid, 'dom'));
558
+	fwrite($fpd, file_get_contents(dirname(__FILE__).'/'.$cf['report']['reportTemplateFooter']));
559 559
 	fclose($fpd);
560 560
 	
561
-	if ( !($cf['listingip']['onlyReport']["$type"] && $cf['listingdom']['onlyReport']["$type"]) )
561
+	if (!($cf['listingip']['onlyReport']["$type"] && $cf['listingdom']['onlyReport']["$type"]))
562 562
 		$mysqli->close();
563 563
 
564 564
 	fwrite($fpb, '</table>');
565
-	fwrite( $fpb,summaryBadReport( $uidbad ) );
566
-	fwrite($fpb,file_get_contents(dirname(__FILE__) . '/' . $cf['report']['reportTemplateFooter']));
565
+	fwrite($fpb, summaryBadReport($uidbad));
566
+	fwrite($fpb, file_get_contents(dirname(__FILE__).'/'.$cf['report']['reportTemplateFooter']));
567 567
 	fclose($fpb);
568
-	syslog (LOG_INFO,$cf['syslog']['user'].': Report files written. Listing job for '.$type.' terminated.');
569
-
570
-	if ( $ierr = imap_errors() )
571
-		foreach ( $ierr as $thiserr )
572
-			syslog (LOG_ERR, $cf['syslog']['user'].": IMAP Error: $thiserr");
573
-	if ( $ierr = imap_alerts() )
574
-                foreach ( $ierr as $thiserr )
575
-                        syslog (LOG_ALERT, $cf['syslog']['user'].": IMAP Alert: $thiserr");
568
+	syslog(LOG_INFO, $cf['syslog']['user'].': Report files written. Listing job for '.$type.' terminated.');
569
+
570
+	if ($ierr = imap_errors())
571
+		foreach ($ierr as $thiserr)
572
+			syslog(LOG_ERR, $cf['syslog']['user'].": IMAP Error: $thiserr");
573
+	if ($ierr = imap_alerts())
574
+                foreach ($ierr as $thiserr)
575
+                        syslog(LOG_ALERT, $cf['syslog']['user'].": IMAP Alert: $thiserr");
576 576
 	imap_close($m_mail);
577 577
 }
578 578
 ?>
Please login to merge, or discard this patch.