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 ( eb5762...21d5d1 )
by Marco
04:20
created
contrib/ipImap/function.php 1 patch
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 #			print "Examine ".$received[0][$i]."\n";
13 13
 			if ( preg_match($msa,$received['host'][$i]) )
14 14
 				$dateR = $received['date'][$i];
15
-        		foreach ($mxserver as $mx) {
16
-        			if (!$ip)
15
+				foreach ($mxserver as $mx) {
16
+					if (!$ip)
17 17
 					if ($mx == $received['host'][$i]) {
18 18
 						$host = $received['host'][$i];
19 19
 						$ip = $received['ip'][$i];
20
-                    			}
21
-                	}
22
-        	}
20
+								}
21
+					}
22
+			}
23 23
 	}
24 24
 	if ( preg_match ('/\r\nDate:\s(?P<date>.*)\r\n/',$header,$dateC) != 1)
25 25
 		$dateC['date'] = 'Not found';
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
 
40 40
 
41 41
 function summaryBadReport ($uidvet) {
42
-        $nuid = $uidvet['count'];
43
-        if ( empty($uidvet) ) return NULL;
44
-        $return = '<hr><h3>Statistics by UID</h3><table><tr><th>UID</th><th>Learned times</th></tr>'."\n";
42
+		$nuid = $uidvet['count'];
43
+		if ( empty($uidvet) ) return NULL;
44
+		$return = '<hr><h3>Statistics by UID</h3><table><tr><th>UID</th><th>Learned times</th></tr>'."\n";
45 45
 
46
-        /* Remove count index */
47
-        $uids = array_keys($uidvet['uid']);
46
+		/* Remove count index */
47
+		$uids = array_keys($uidvet['uid']);
48 48
 	$totlearn = 0;
49 49
 
50
-        foreach ( $uids as $uid ) {
50
+		foreach ( $uids as $uid ) {
51 51
 		$totlearn += $uidvet['uid']["$uid"]['count'];; 
52 52
 		$return .= sprintf ('<tr><td>%s</td><td>%u</td></tr>',$uid,$uidvet['uid']["$uid"]['count']);
53 53
 	}
@@ -60,26 +60,26 @@  discard block
 block discarded – undo
60 60
 
61 61
 function array_msort($array, $cols)
62 62
 {
63
-    $colarr = array();
64
-    foreach ($cols as $col => $order) {
65
-        $colarr[$col] = array();
66
-        foreach ($array as $k => $row) { $colarr[$col]['_'.$k] = strtolower($row[$col]); }
67
-    }
68
-    $eval = 'array_multisort(';
69
-    foreach ($cols as $col => $order) {
70
-        $eval .= '$colarr[\''.$col.'\'],'.$order.',';
71
-    }
72
-    $eval = substr($eval,0,-1).');';
73
-    eval($eval);
74
-    $ret = array();
75
-    foreach ($colarr as $col => $arr) {
76
-        foreach ($arr as $k => $v) {
77
-            $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];
80
-        }
81
-    }
82
-    return $ret;
63
+	$colarr = array();
64
+	foreach ($cols as $col => $order) {
65
+		$colarr[$col] = array();
66
+		foreach ($array as $k => $row) { $colarr[$col]['_'.$k] = strtolower($row[$col]); }
67
+	}
68
+	$eval = 'array_multisort(';
69
+	foreach ($cols as $col => $order) {
70
+		$eval .= '$colarr[\''.$col.'\'],'.$order.',';
71
+	}
72
+	$eval = substr($eval,0,-1).');';
73
+	eval($eval);
74
+	$ret = array();
75
+	foreach ($colarr as $col => $arr) {
76
+		foreach ($arr as $k => $v) {
77
+			$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];
80
+		}
81
+	}
82
+	return $ret;
83 83
 
84 84
 }
85 85
 
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 
95 95
 	foreach ( $ips as $ip ) {
96 96
 		if ( $ip == 'count' ) continue;
97
-                $nlearn = $ipvet['ip']["$ip"]['count'];
98
-                unset($ipvet['ip']["$ip"]['count']);
97
+				$nlearn = $ipvet['ip']["$ip"]['count'];
98
+				unset($ipvet['ip']["$ip"]['count']);
99 99
 		$nuid = count($ipvet['ip']["$ip"]);
100 100
 		if ( !$cf['onlyReport'] ) {
101 101
 			if ( ($nlearn >= $cf['thresholdip']["$category"])&&($nuid >= $cf['thresholduid']["$category"]) ) {
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 		$return .='<tr><td rowspan="'.$nuid.'">'.$ip.'</td>';
123 123
 		$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']);
124 124
 		$rowuid=NULL;
125
-                for ($j=1;$j<$nuid;$j++) $rowuid .= '<tr><td>%s</td></tr>';
125
+				for ($j=1;$j<$nuid;$j++) $rowuid .= '<tr><td>%s</td></tr>';
126 126
 		array_shift($ipvet['ip']["$ip"]);
127
-                $return .= vsprintf ($rowuid,$ipvet['ip']["$ip"]);
127
+				$return .= vsprintf ($rowuid,$ipvet['ip']["$ip"]);
128 128
 
129 129
 	}
130 130
 	$return .= sprintf ('<tr><th title="unique ips">%u</th><th title="unique uids">%u</th><th>%u</th></table>',$ipvet['ip']['count'],$ipvet['uid']['count'],$nips);
@@ -134,20 +134,20 @@  discard block
 block discarded – undo
134 134
 	/* Not used for listing purpose, but useful to you! */
135 135
 	$return .= '<h3>Statistics by UID</h3><table><tr><th>UID</th><th>IP learned</th><th>Learned times</th></tr>'."\n";
136 136
 	$uids = array_keys($ipvet['uid']);
137
-        foreach ( $uids as $uid ) {
137
+		foreach ( $uids as $uid ) {
138 138
 		if ( $uid == 'count' ) continue;	
139
-	        $nlearn = $ipvet['uid']["$uid"]['count'];
140
-	        unset ( $ipvet['uid']["$uid"]['count'] );
139
+			$nlearn = $ipvet['uid']["$uid"]['count'];
140
+			unset ( $ipvet['uid']["$uid"]['count'] );
141 141
 		$nip = count($ipvet['uid']["$uid"]);
142 142
 		$return .='<tr><td rowspan="'.$nip.'">'.$uid.'</td>';
143 143
 		$return .= sprintf ('<td>%s</td><td rowspan="'.$nip.'">%u</td></tr>',$ipvet['uid']["$uid"][0],$nlearn);
144
-                $rowuid=NULL;
145
-                for ($j=1;$j<$nip;$j++) $rowuid .= '<tr><td>%s</td></tr>';
146
-                array_shift($ipvet['uid']["$uid"]);
147
-                $return .= vsprintf ($rowuid,$ipvet['uid']["$uid"]);
144
+				$rowuid=NULL;
145
+				for ($j=1;$j<$nip;$j++) $rowuid .= '<tr><td>%s</td></tr>';
146
+				array_shift($ipvet['uid']["$uid"]);
147
+				$return .= vsprintf ($rowuid,$ipvet['uid']["$uid"]);
148 148
 
149
-        }
150
-        $return .= sprintf ('<tr><th title="unique uids">%u</th><th title="unique ips">%u</th><th>%u</th></table>',$ipvet['uid']['count'],$ipvet['ip']['count'],$nips);	
149
+		}
150
+		$return .= sprintf ('<tr><th title="unique uids">%u</th><th title="unique ips">%u</th><th>%u</th></table>',$ipvet['uid']['count'],$ipvet['ip']['count'],$nips);	
151 151
 
152 152
 
153 153
 	return $return;
@@ -175,50 +175,50 @@  discard block
 block discarded – undo
175 175
 	*/
176 176
 
177 177
 	// A one shot search
178
-        $searchParams = array(
179
-                'earliest_time' => date("c",strtotime ($date)-120),
180
-                'latest_time' => date("c",strtotime ($date)+60)
181
-        );
178
+		$searchParams = array(
179
+				'earliest_time' => date("c",strtotime ($date)-120),
180
+				'latest_time' => date("c",strtotime ($date)+60)
181
+		);
182 182
 
183
-        // Run a oneshot search that returns the job's results
184
-        $resultsStream = $service->oneshotSearch($searchQueryBlocking, $searchParams);
185
-        $resultSearch = new Splunk_ResultsReader($resultsStream);
183
+		// Run a oneshot search that returns the job's results
184
+		$resultsStream = $service->oneshotSearch($searchQueryBlocking, $searchParams);
185
+		$resultSearch = new Splunk_ResultsReader($resultsStream);
186 186
 
187 187
 	// Use the built-in XML parser to display the job results
188 188
 	foreach ($resultSearch as $result)
189 189
 	  {
190
-	    if ($result instanceof Splunk_ResultsFieldOrder)
191
-	    {
192
-	      // More than one field attribute returned by search
193
-	      // You must redefine the search
194
-	      if ( count($result->getFieldNames()) > 1 ) return FALSE;
195
-	    }
196
-	    else if ($result instanceof Splunk_ResultsMessage)
197
-	    {
198
-	      // I don't want messages in my search
199
-	      return FALSE;
200
-	    }
201
-	    else if (is_array($result))
202
-	    {
203
-	      // Process a row
204
-	      foreach ($result as $key => $valueOrValues)
205
-	        {
206
-	         if (is_array($valueOrValues))
207
-	          {
208
-	            return FALSE;
209
-	          }
210
-	         else
211
-	          {
212
-	            return $valueOrValues;
213
-	            #print "  {$key} => {$value}\r\n";
214
-	          }
215
-	        }
216
-	    }
217
-	    else
218
-	    {
219
-	      #print "Unknow result type";
220
-	      return FALSE;
221
-	    }
190
+		if ($result instanceof Splunk_ResultsFieldOrder)
191
+		{
192
+		  // More than one field attribute returned by search
193
+		  // You must redefine the search
194
+		  if ( count($result->getFieldNames()) > 1 ) return FALSE;
195
+		}
196
+		else if ($result instanceof Splunk_ResultsMessage)
197
+		{
198
+		  // I don't want messages in my search
199
+		  return FALSE;
200
+		}
201
+		else if (is_array($result))
202
+		{
203
+		  // Process a row
204
+		  foreach ($result as $key => $valueOrValues)
205
+			{
206
+			 if (is_array($valueOrValues))
207
+			  {
208
+				return FALSE;
209
+			  }
210
+			 else
211
+			  {
212
+				return $valueOrValues;
213
+				#print "  {$key} => {$value}\r\n";
214
+			  }
215
+			}
216
+		}
217
+		else
218
+		{
219
+		  #print "Unknow result type";
220
+		  return FALSE;
221
+		}
222 222
 	  }
223 223
 }
224 224
 
@@ -227,26 +227,26 @@  discard block
 block discarded – undo
227 227
 	$file = dirname(__FILE__) . '/' . $cf['reportFile']["$type"];
228 228
 	$fileb= dirname(__FILE__) . '/' . $cf['badreportFile']["$type"];
229 229
 	$m_mail = imap_open('{'.$cf['mailhost'].':143/imap/novalidate-cert/authuser='.$cf['authuser'].'}'.$cf['folder']["$type"], $cf['account'],$cf['authpassword'], OP_READONLY)
230
-        	or syslog (LOG_EMERG, $cf['user'].': Error in IMAP connection to <'.$cf['mailhost'].'>: ' . imap_last_error());
230
+			or syslog (LOG_EMERG, $cf['user'].': Error in IMAP connection to <'.$cf['mailhost'].'>: ' . imap_last_error());
231 231
 	if ( !$m_mail ) exit(254);
232 232
 		
233 233
 
234 234
 	syslog (LOG_INFO,$cf['user'].': Successfully connected to <'.$cf['mailhost'].">; Reading $type messages of last ".$cf['oldestday'].' days...');
235 235
 	//get all messages
236 236
 	$dateTh = date ( "d-M-Y", strToTime ( '-'.$cf['oldestday'].' days' ) );
237
-        $dateN  = date ( "d-M-Y", strToTime ( "now" ) );
238
-        $m_search=imap_search ($m_mail, "SINCE \"$dateTh\" BEFORE \"$dateN\"" );
237
+		$dateN  = date ( "d-M-Y", strToTime ( "now" ) );
238
+		$m_search=imap_search ($m_mail, "SINCE \"$dateTh\" BEFORE \"$dateN\"" );
239 239
 
240 240
 
241 241
 	// Order results starting from newest message
242 242
 	if ( empty($m_search) ) {
243 243
 		syslog (LOG_INFO,$cf['user'].": No mail found in $type folder. No reports written for $type.");
244
-	        if ( $ierr = imap_errors() )
245
-	                foreach ( $ierr as $thiserr )
246
-	                        syslog (LOG_ERR, $cf['user'].": IMAP Error: $thiserr");
247
-	        if ( $ierr = imap_alerts() )
248
-	                foreach ( $ierr as $thiserr )
249
-	                        syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr");
244
+			if ( $ierr = imap_errors() )
245
+					foreach ( $ierr as $thiserr )
246
+							syslog (LOG_ERR, $cf['user'].": IMAP Error: $thiserr");
247
+			if ( $ierr = imap_alerts() )
248
+					foreach ( $ierr as $thiserr )
249
+							syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr");
250 250
 		imap_close( $m_mail );
251 251
 		if ( file_exists( $file ) ) unlink ($file);
252 252
 		if ( file_exists( $fileb ) ) unlink ($fileb);
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
 	$uidbad['count'] = 0;
280 280
 	$uidbad['uid'] = array();
281 281
 
282
-        // loop for each message
282
+		// loop for each message
283 283
 	foreach ($m_search as $onem) {
284 284
 
285
-	        //get imap header info for obj thang
286
-	        //$headers = imap_headerinfo($m_mail, $onem);
287
-	        //$head = imap_fetchheader($m_mail, $headers->Msgno);
285
+			//get imap header info for obj thang
286
+			//$headers = imap_headerinfo($m_mail, $onem);
287
+			//$head = imap_fetchheader($m_mail, $headers->Msgno);
288 288
 		$head = imap_fetchheader($m_mail, $onem );
289
-	        //$obj = imap_rfc822_parse_headers( $head);
289
+			//$obj = imap_rfc822_parse_headers( $head);
290 290
 
291
-	        list ($ip,$host,$dateReceived,$dateClient,$mid) =  getIP( $head,$cf['mx'],$cf['msalearn'] );
291
+			list ($ip,$host,$dateReceived,$dateClient,$mid) =  getIP( $head,$cf['mx'],$cf['msalearn'] );
292 292
 		if (empty($mid)) {
293 293
 			$uid='NA';
294 294
 			syslog (LOG_ERR, $cf['user'].": Error retrieving data for empty Message-ID.");
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 				}
304 304
 		}
305 305
 
306
-	        /* Update count of each ip */
307
-	        if ($host and ($uid!='NA') and ($uid!='unauthenticated') and ($uid!='unknown')) { /* IP is received by MX servers  and learned by valid uid */
306
+			/* Update count of each ip */
307
+			if ($host and ($uid!='NA') and ($uid!='unauthenticated') and ($uid!='unknown')) { /* IP is received by MX servers  and learned by valid uid */
308 308
 			$ipuid['count']++;					//number of right messages
309 309
 
310
-	                if (in_array($uid,array_keys($ipuid['uid']))) {
310
+					if (in_array($uid,array_keys($ipuid['uid']))) {
311 311
 				$ipuid['uid']["$uid"]['count']++;		//number of learn by this uid
312 312
 				if (!in_array($ip,$ipuid['uid']["$uid"])) 
313 313
 					$ipuid['uid']["$uid"][]=$ip;		//ips learned by this uid
@@ -318,29 +318,29 @@  discard block
 block discarded – undo
318 318
 				$ipuid['uid']['count']++;                	//number of unique uids
319 319
 			}
320 320
 
321
-                        if (in_array($ip,array_keys($ipuid['ip']))) {
322
-                                $ipuid['ip']["$ip"]['count']++;			//number of time this ip appears in different messages
321
+						if (in_array($ip,array_keys($ipuid['ip']))) {
322
+								$ipuid['ip']["$ip"]['count']++;			//number of time this ip appears in different messages
323 323
 				if (!in_array($uid,$ipuid['ip']["$ip"]))
324 324
 					$ipuid['ip']["$ip"][]=$uid;		//uids that learned this ip
325 325
 			}
326
-                        else {
327
-                                $ipuid['ip']["$ip"]['count'] = 1;
326
+						else {
327
+								$ipuid['ip']["$ip"]['count'] = 1;
328 328
 				$ipuid['ip']["$ip"][]=$uid;
329 329
 				$ipuid['ip']['count']++;			//number of unique ips
330
-                        }
330
+						}
331 331
 
332
-	        	/* Update HTML report */
333
-	        	fwrite($fp,updateReport ( $ip,$uid,$ipuid['ip']["$ip"]['count'],$ipuid['uid']["$uid"]['count'],$host,$dateClient,$mid,$dateReceived) );
332
+				/* Update HTML report */
333
+				fwrite($fp,updateReport ( $ip,$uid,$ipuid['ip']["$ip"]['count'],$ipuid['uid']["$uid"]['count'],$host,$dateClient,$mid,$dateReceived) );
334 334
 		}
335
-	        else {	/* Bad learn */
335
+			else {	/* Bad learn */
336 336
 			
337
-                        if (in_array($uid,array_keys($uidbad['uid']))) 
338
-                                $uidbad['uid']["$uid"]['count']++;               //number of bad learn by this uid
339
-                        else {
340
-                                $uidbad['uid']["$uid"]['count'] = 1;
337
+						if (in_array($uid,array_keys($uidbad['uid']))) 
338
+								$uidbad['uid']["$uid"]['count']++;               //number of bad learn by this uid
339
+						else {
340
+								$uidbad['uid']["$uid"]['count'] = 1;
341 341
 				$uidbad['uid']["$uid"][]=$uid;
342
-                                $uidbad['count']++;                       //numeber of unique bad uids
343
-                        }
342
+								$uidbad['count']++;                       //numeber of unique bad uids
343
+						}
344 344
 			/* The reason of bad report */
345 345
 			if ($host === FALSE) $reason = 'This mail was not received by recognized MX host';
346 346
 			if ($dateReceived === FALSE) $reason = 'This mail was not submitted to recognized MSA for learn';
@@ -362,17 +362,17 @@  discard block
 block discarded – undo
362 362
 	fwrite($fp, '</table>');
363 363
 	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>' );
364 364
 
365
-        /* Make MYSQL connection */
365
+		/* Make MYSQL connection */
366 366
 	if ( $cf['onlyReport'] )
367 367
 		$mysqli = NULL;
368 368
 	else {
369
-        	$mysqli = new mysqli($myconnArray['dbhost'], $myconnArray['userdb'], $myconnArray['pwd'], $myconnArray['db'], $myconnArray['dbport']);
370
-        	if ($mysqli->connect_error) {
371
-                	syslog (LOG_EMERG, $cf['user'].': Connect Error (' . $mysqli->connect_errno . ') '
372
-                	. $mysqli->connect_error);
373
-                	exit (254);
374
-        	}
375
-        	syslog(LOG_INFO, $cf['user'].': Successfully mysql connected to ' . $mysqli->host_info) ;
369
+			$mysqli = new mysqli($myconnArray['dbhost'], $myconnArray['userdb'], $myconnArray['pwd'], $myconnArray['db'], $myconnArray['dbport']);
370
+			if ($mysqli->connect_error) {
371
+					syslog (LOG_EMERG, $cf['user'].': Connect Error (' . $mysqli->connect_errno . ') '
372
+					. $mysqli->connect_error);
373
+					exit (254);
374
+			}
375
+			syslog(LOG_INFO, $cf['user'].': Successfully mysql connected to ' . $mysqli->host_info) ;
376 376
 	}
377 377
 	/***********************/
378 378
 
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 		foreach ( $ierr as $thiserr )
393 393
 			syslog (LOG_ERR, $cf['user'].": IMAP Error: $thiserr");
394 394
 	if ( $ierr = imap_alerts() )
395
-                foreach ( $ierr as $thiserr )
396
-                        syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr");
395
+				foreach ( $ierr as $thiserr )
396
+						syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr");
397 397
 	imap_close($m_mail);
398 398
 }
399 399
 ?>
Please login to merge, or discard this patch.