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
Branch master (69a36c)
by Marco
02:57
created
contrib/ipImap/function.php 2 patches
Doc Comments   +23 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,24 @@  discard block
 block discarded – undo
28 31
 	return array($ip,$host,$dateR,$dateC['date'],$mid['mid']);
29 32
 }
30 33
 
34
+/**
35
+ * @param string|false $ip
36
+ * @param string $hostname
37
+ * @param string $dateC
38
+ * @param string|null $msgid
39
+ * @param string|false $dateL
40
+ */
31 41
 function updateReport ($ip,$uid,$ipcount,$uidcount,$hostname,$dateC,$msgid,$dateL) {
32 42
 
33 43
 	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 44
 }
35 45
 
46
+/**
47
+ * @param string $dateC
48
+ * @param string|null $msgid
49
+ * @param string|false $dateL
50
+ * @param string $text
51
+ */
36 52
 function updatebadReport ( $uid,$dateC,$msgid,$dateL,$text ) {
37 53
 	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 54
 }
@@ -84,6 +100,9 @@  discard block
 block discarded – undo
84 100
 }
85 101
 
86 102
 
103
+/**
104
+ * @param null|mysqli $myconn
105
+ */
87 106
 function summaryReportAndList ($cf,$myconn,$tables,$category,$ipvet) {
88 107
 	$nips = $ipvet['count'];
89 108
 
@@ -154,6 +173,10 @@  discard block
 block discarded – undo
154 173
 }
155 174
 
156 175
 
176
+/**
177
+ * @param string $message_id
178
+ * @param string $date
179
+ */
157 180
 function splunksearch ($service,$message_id,$date) {
158 181
 
159 182
 	// Run a blocking search
Please login to merge, or discard this patch.
Indentation   +121 added lines, -121 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"])AND($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;
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 	// A blocking search returns the job when the search is done
165 165
 	/* Wait to finish */
166 166
 	$job = $service->getJobs()->create($searchQueryBlocking, array(
167
-	    'exec_mode' => 'blocking',
168
-	    'earliest_time' => date("c",strtotime ($date)-120),
169
-	    'latest_time' => date("c",strtotime ($date)+60)
167
+		'exec_mode' => 'blocking',
168
+		'earliest_time' => date("c",strtotime ($date)-120),
169
+		'latest_time' => date("c",strtotime ($date)+60)
170 170
 	));
171 171
 
172 172
 	/*
@@ -190,38 +190,38 @@  discard block
 block discarded – undo
190 190
 	// Use the built-in XML parser to display the job results
191 191
 	foreach ($resultSearch as $result)
192 192
 	  {
193
-	    if ($result instanceof Splunk_ResultsFieldOrder)
194
-	    {
195
-	      // More than one field attribute returned by search
196
-	      // You must redefine the search
197
-	      if ( count($result->getFieldNames()) > 1 ) return FALSE;
198
-	    }
199
-	    else if ($result instanceof Splunk_ResultsMessage)
200
-	    {
201
-	      // I don't want messages in my search
202
-	      return FALSE;
203
-	    }
204
-	    else if (is_array($result))
205
-	    {
206
-	      // Process a row
207
-	      foreach ($result as $key => $valueOrValues)
208
-	        {
209
-	         if (is_array($valueOrValues))
210
-	          {
211
-	            return FALSE;
212
-	          }
213
-	         else
214
-	          {
215
-	            return $valueOrValues;
216
-	            #print "  {$key} => {$value}\r\n";
217
-	          }
218
-	        }
219
-	    }
220
-	    else
221
-	    {
222
-	      #print "Unknow result type";
223
-	      return FALSE;
224
-	    }
193
+		if ($result instanceof Splunk_ResultsFieldOrder)
194
+		{
195
+		  // More than one field attribute returned by search
196
+		  // You must redefine the search
197
+		  if ( count($result->getFieldNames()) > 1 ) return FALSE;
198
+		}
199
+		else if ($result instanceof Splunk_ResultsMessage)
200
+		{
201
+		  // I don't want messages in my search
202
+		  return FALSE;
203
+		}
204
+		else if (is_array($result))
205
+		{
206
+		  // Process a row
207
+		  foreach ($result as $key => $valueOrValues)
208
+			{
209
+			 if (is_array($valueOrValues))
210
+			  {
211
+				return FALSE;
212
+			  }
213
+			 else
214
+			  {
215
+				return $valueOrValues;
216
+				#print "  {$key} => {$value}\r\n";
217
+			  }
218
+			}
219
+		}
220
+		else
221
+		{
222
+		  #print "Unknow result type";
223
+		  return FALSE;
224
+		}
225 225
 	  }
226 226
 }
227 227
 
@@ -230,26 +230,26 @@  discard block
 block discarded – undo
230 230
 	$file = dirname(__FILE__) . '/' . $cf['reportFile']["$type"];
231 231
 	$fileb= dirname(__FILE__) . '/' . $cf['badreportFile']["$type"];
232 232
 	$m_mail = imap_open('{'.$cf['mailhost'].':143/imap/novalidate-cert/authuser='.$cf['authuser'].'}'.$cf['folder']["$type"], $cf['account'],$cf['authpassword'], OP_READONLY)
233
-        	or syslog (LOG_EMERG, $cf['user'].': Error in IMAP connection to <'.$cf['mailhost'].'>: ' . imap_last_error());
233
+			or syslog (LOG_EMERG, $cf['user'].': Error in IMAP connection to <'.$cf['mailhost'].'>: ' . imap_last_error());
234 234
 	if ( !$m_mail ) exit(254);
235 235
 		
236 236
 
237 237
 	syslog (LOG_INFO,$cf['user'].': Successfully connected to <'.$cf['mailhost'].">; Reading $type messages of last ".$cf['oldestday'].' days...');
238 238
 	//get all messages
239 239
 	$dateTh = date ( "d-M-Y", strToTime ( '-'.$cf['oldestday'].' days' ) );
240
-        $dateN  = date ( "d-M-Y", strToTime ( "now" ) );
241
-        $m_search=imap_search ($m_mail, "SINCE \"$dateTh\" BEFORE \"$dateN\"" );
240
+		$dateN  = date ( "d-M-Y", strToTime ( "now" ) );
241
+		$m_search=imap_search ($m_mail, "SINCE \"$dateTh\" BEFORE \"$dateN\"" );
242 242
 
243 243
 
244 244
 	// Order results starting from newest message
245 245
 	if (!$m_search) {
246 246
 		syslog (LOG_INFO,$cf['user'].": No mail found in $type folder. No reports written for $type.");
247
-	        if ( $ierr = imap_errors() )
248
-	                foreach ( $ierr as $thiserr )
249
-	                        syslog (LOG_ERR, $cf['user'].": IMAP Error: $thiserr");
250
-	        if ( $ierr = imap_alerts() )
251
-	                foreach ( $ierr as $thiserr )
252
-	                        syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr");
247
+			if ( $ierr = imap_errors() )
248
+					foreach ( $ierr as $thiserr )
249
+							syslog (LOG_ERR, $cf['user'].": IMAP Error: $thiserr");
250
+			if ( $ierr = imap_alerts() )
251
+					foreach ( $ierr as $thiserr )
252
+							syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr");
253 253
 		imap_close( $m_mail );
254 254
 		if ( file_exists( $file ) ) unlink ($file);
255 255
 		if ( file_exists( $fileb ) ) unlink ($fileb);
@@ -280,16 +280,16 @@  discard block
 block discarded – undo
280 280
 	$uidbad['count'] = 0;
281 281
 	$uidbad['uid'] = array();
282 282
 
283
-        // loop for each message
283
+		// loop for each message
284 284
 	foreach ($m_search as $onem) {
285 285
 
286
-	        //get imap header info for obj thang
287
-	        //$headers = imap_headerinfo($m_mail, $onem);
288
-	        //$head = imap_fetchheader($m_mail, $headers->Msgno);
286
+			//get imap header info for obj thang
287
+			//$headers = imap_headerinfo($m_mail, $onem);
288
+			//$head = imap_fetchheader($m_mail, $headers->Msgno);
289 289
 		$head = imap_fetchheader($m_mail, $onem );
290
-	        //$obj = imap_rfc822_parse_headers( $head);
290
+			//$obj = imap_rfc822_parse_headers( $head);
291 291
 
292
-	        list ($ip,$host,$dateReceived,$dateClient,$mid) =  getIP( $head,$cf['mx'],$cf['msalearn'] );
292
+			list ($ip,$host,$dateReceived,$dateClient,$mid) =  getIP( $head,$cf['mx'],$cf['msalearn'] );
293 293
 		if (empty($mid)) {
294 294
 			$uid='NA';
295 295
 			syslog (LOG_ERR, $cf['user'].": Error retrieving data for empty Message-ID.");
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
 				}
305 305
 		}
306 306
 
307
-	        /* Update count of each ip */
308
-	        if ($host and ($uid!='NA') and ($uid!='unauthenticated') and ($uid!='unknown')) { /* IP is received by MX servers  and learned by valid uid */
307
+			/* Update count of each ip */
308
+			if ($host and ($uid!='NA') and ($uid!='unauthenticated') and ($uid!='unknown')) { /* IP is received by MX servers  and learned by valid uid */
309 309
 			$ipuid['count']++;					//number of right messages
310 310
 
311
-	                if (in_array($uid,array_keys($ipuid['uid']))) {
311
+					if (in_array($uid,array_keys($ipuid['uid']))) {
312 312
 				$ipuid['uid']["$uid"]['count']++;		//number of learn by this uid
313 313
 				if (!in_array($ip,$ipuid['uid']["$uid"])) 
314 314
 					$ipuid['uid']["$uid"][]=$ip;		//ips learned by this uid
@@ -319,29 +319,29 @@  discard block
 block discarded – undo
319 319
 				$ipuid['uid']['count']++;                	//number of unique uids
320 320
 			}
321 321
 
322
-                        if (in_array($ip,array_keys($ipuid['ip']))) {
323
-                                $ipuid['ip']["$ip"]['count']++;			//number of time this ip appears in different messages
322
+						if (in_array($ip,array_keys($ipuid['ip']))) {
323
+								$ipuid['ip']["$ip"]['count']++;			//number of time this ip appears in different messages
324 324
 				if (!in_array($uid,$ipuid['ip']["$ip"]))
325 325
 					$ipuid['ip']["$ip"][]=$uid;		//uids that learned this ip
326 326
 			}
327
-                        else {
328
-                                $ipuid['ip']["$ip"]['count'] = 1;
327
+						else {
328
+								$ipuid['ip']["$ip"]['count'] = 1;
329 329
 				$ipuid['ip']["$ip"][]=$uid;
330 330
 				$ipuid['ip']['count']++;			//number of unique ips
331
-                        }
331
+						}
332 332
 
333
-	        	/* Update HTML report */
334
-	        	fwrite($fp,updateReport ( $ip,$uid,$ipuid['ip']["$ip"]['count'],$ipuid['uid']["$uid"]['count'],$host,$dateClient,$mid,$dateReceived) );
333
+				/* Update HTML report */
334
+				fwrite($fp,updateReport ( $ip,$uid,$ipuid['ip']["$ip"]['count'],$ipuid['uid']["$uid"]['count'],$host,$dateClient,$mid,$dateReceived) );
335 335
 		}
336
-	        else {	/* Bad learn */
336
+			else {	/* Bad learn */
337 337
 			
338
-                        if (in_array($uid,array_keys($uidbad['uid']))) 
339
-                                $uidbad['uid']["$uid"]['count']++;               //number of bad learn by this uid
340
-                        else {
341
-                                $uidbad['uid']["$uid"]['count'] = 1;
338
+						if (in_array($uid,array_keys($uidbad['uid']))) 
339
+								$uidbad['uid']["$uid"]['count']++;               //number of bad learn by this uid
340
+						else {
341
+								$uidbad['uid']["$uid"]['count'] = 1;
342 342
 				$uidbad['uid']["$uid"][]=$uid;
343
-                                $uidbad['count']++;                       //numeber of unique bad uids
344
-                        }
343
+								$uidbad['count']++;                       //numeber of unique bad uids
344
+						}
345 345
 			/* The reason of bad report */
346 346
 			if (!$host) $reason = 'This mail was not received by recognized MX host';
347 347
 			if (!$dateReceived) $reason = 'This mail was not submitted to recognized MSA for learn';
@@ -363,17 +363,17 @@  discard block
 block discarded – undo
363 363
 	fwrite($fp, '</table>');
364 364
 	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 365
 
366
-        /* Make MYSQL connection */
366
+		/* Make MYSQL connection */
367 367
 	if ( $cf['onlyReport'] )
368 368
 		$mysqli = NULL;
369 369
 	else {
370
-        	$mysqli = new mysqli($myconnArray['dbhost'], $myconnArray['userdb'], $myconnArray['pwd'], $myconnArray['db'], $myconnArray['dbport']);
371
-        	if ($mysqli->connect_error) {
372
-                	syslog (LOG_EMERG, $cf['user'].': Connect Error (' . $mysqli->connect_errno . ') '
373
-                	. $mysqli->connect_error);
374
-                	exit (254);
375
-        	}
376
-        	syslog(LOG_INFO, $cf['user'].': Successfully mysql connected to ' . $mysqli->host_info) ;
370
+			$mysqli = new mysqli($myconnArray['dbhost'], $myconnArray['userdb'], $myconnArray['pwd'], $myconnArray['db'], $myconnArray['dbport']);
371
+			if ($mysqli->connect_error) {
372
+					syslog (LOG_EMERG, $cf['user'].': Connect Error (' . $mysqli->connect_errno . ') '
373
+					. $mysqli->connect_error);
374
+					exit (254);
375
+			}
376
+			syslog(LOG_INFO, $cf['user'].': Successfully mysql connected to ' . $mysqli->host_info) ;
377 377
 	}
378 378
 	/***********************/
379 379
 
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 		foreach ( $ierr as $thiserr )
394 394
 			syslog (LOG_ERR, $cf['user'].": IMAP Error: $thiserr");
395 395
 	if ( $ierr = imap_alerts() )
396
-                foreach ( $ierr as $thiserr )
397
-                        syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr");
396
+				foreach ( $ierr as $thiserr )
397
+						syslog (LOG_ALERT, $cf['user'].": IMAP Alert: $thiserr");
398 398
 	imap_close($m_mail);
399 399
 }
400 400
 ?>
Please login to merge, or discard this patch.
contrib/ipImap/report/calendar/calendar_functions.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -1,4 +1,7 @@
 block discarded – undo
1 1
 <?php
2
+/**
3
+ * @param string $str
4
+ */
2 5
 function filterInput($str, $type = "text"){
3 6
 	switch(strtolower($type)){
4 7
 		case "number":
Please login to merge, or discard this patch.
contrib/ipImap/report/calendar/classes/tc_calendar.php 2 patches
Doc Comments   +20 added lines patch added patch discarded remove patch
@@ -122,6 +122,11 @@  discard block
 block discarded – undo
122 122
     }
123 123
 
124 124
 	//get the total day of each month in year
125
+
126
+    /**
127
+     * @param integer $month
128
+     * @param integer $year
129
+     */
125 130
     function total_days($month,$year){
126 131
     	$days = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
127 132
 		if($month > 0 && $year > 0){
@@ -170,6 +175,12 @@  discard block
 block discarded – undo
170 175
 	}
171 176
 
172 177
 	//set default selected date
178
+
179
+	/**
180
+	 * @param integer $day
181
+	 * @param integer $month
182
+	 * @param integer $year
183
+	 */
173 184
 	function setDate($day, $month, $year){
174 185
 		//get system timezone before set the date
175 186
 		$this->system_timezone = date_default_timezone_get();
@@ -516,6 +527,9 @@  discard block
 block discarded – undo
516 527
 		return $str;
517 528
 	}
518 529
 
530
+	/**
531
+	 * @param string $suffix
532
+	 */
519 533
 	function eHidden($suffix, $value) {
520 534
 		if(trim($value) != ""){
521 535
 			if($suffix) $suffix = "_".$suffix;
@@ -849,6 +863,9 @@  discard block
 block discarded – undo
849 863
 		return true;
850 864
 	}
851 865
 
866
+	/**
867
+	 * @return string
868
+	 */
852 869
 	function check_json_encode($obj){
853 870
 		//try customize to get it work, should replace with better solution in the future
854 871
 		if(is_array($obj)){
@@ -997,6 +1014,9 @@  discard block
 block discarded – undo
997 1014
 		}
998 1015
 	}
999 1016
 
1017
+	/**
1018
+	 * @param string $tz
1019
+	 */
1000 1020
 	function setTimezone($tz){
1001 1021
 		$this->timezone = $tz;
1002 1022
 		@date_default_timezone_set($tz);
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -117,17 +117,17 @@
 block discarded – undo
117 117
 
118 118
 	//check for leapyear
119 119
 	function is_leapyear($year){
120
-    	return ($year % 4 == 0) ?
121
-    		!($year % 100 == 0 && $year % 400 <> 0)	: false;
122
-    }
120
+		return ($year % 4 == 0) ?
121
+			!($year % 100 == 0 && $year % 400 <> 0)	: false;
122
+	}
123 123
 
124 124
 	//get the total day of each month in year
125
-    function total_days($month,$year){
126
-    	$days = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
125
+	function total_days($month,$year){
126
+		$days = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
127 127
 		if($month > 0 && $year > 0){
128
-	    	return ($month == 2 && $this->is_leapYear($year)) ? 29 : $days[$month-1];
128
+			return ($month == 2 && $this->is_leapYear($year)) ? 29 : $days[$month-1];
129 129
 		}else return 31;
130
-    }
130
+	}
131 131
 
132 132
 	//Deprecate since v1.6
133 133
 	function getDayNum($day){
Please login to merge, or discard this patch.
contrib/ipImap/report/calendar/classes/tc_date.php 1 patch
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -54,6 +54,9 @@  discard block
 block discarded – undo
54 54
 		}
55 55
 	}
56 56
 
57
+	/**
58
+	 * @return string
59
+	 */
57 60
 	function getDate($format = "Y-m-d", $cdate = ""){
58 61
 		if(!$this->compatible){
59 62
 			return tc_date_main::getDate($format, $cdate);
@@ -123,6 +126,9 @@  discard block
 block discarded – undo
123 126
 		}
124 127
 	}
125 128
 
129
+	/**
130
+	 * @param string $timespan
131
+	 */
126 132
 	function addDate($format = "Y-m-d", $timespan, $cdate = ""){
127 133
 		if($this->compatible){
128 134
 			$tmp_date = ($cdate != "") ? new DateTime($cdate) : $this->mydate;
@@ -148,6 +154,10 @@  discard block
 block discarded – undo
148 154
 
149 155
 	//check if date1 is before date2
150 156
 	//if date1 omitted use set date
157
+
158
+	/**
159
+	 * @param string|boolean $date2
160
+	 */
151 161
 	function dateBefore($date2, $date1 = "", $equal = true){
152 162
 		if(!$this->compatible){
153 163
 			return tc_date_main::dateBefore($date2, $date1, $equal);
@@ -162,6 +172,10 @@  discard block
 block discarded – undo
162 172
 
163 173
 	//check if date1 is after date2
164 174
 	//if date1 omitted use set date
175
+
176
+	/**
177
+	 * @param string|boolean $date2
178
+	 */
165 179
 	function dateAfter($date2, $date1 = "", $equal = true){
166 180
 		if(!$this->compatible){
167 181
 			return tc_date_main::dateAfter($date2, $date1, $equal);
Please login to merge, or discard this patch.
function.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -204,6 +204,11 @@  discard block
 block discarded – undo
204 204
 }
205 205
 
206 206
 
207
+/**
208
+ * @param integer $id
209
+ * @param string $what
210
+ * @param boolean $lock
211
+ */
207 212
 function ask($myconn,$id,$what,$alltables,$typedesc,$value,$lock,$user,$adm) {
208 213
 
209 214
 	switch ($what) {
@@ -404,6 +409,9 @@  discard block
 block discarded – undo
404 409
 }
405 410
 
406 411
 
412
+/**
413
+ * @param string $reason
414
+ */
407 415
 function searchAndList ($myconn,$loguser,$tables,$typedesc,$value,$unit,&$quantity,$reason) {
408 416
 
409 417
 /* Search and list value */
Please login to merge, or discard this patch.
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
 
5 5
 function username() {
6 6
 	if (isset ($_SERVER['REMOTE_USER'])) $user = $_SERVER['REMOTE_USER'];
7
-        	else if (isset ($_SERVER['USER'])) $user = $_SERVER['USER'];
8
-                	else $user='unknown';
7
+			else if (isset ($_SERVER['USER'])) $user = $_SERVER['USER'];
8
+					else $user='unknown';
9 9
 	return $user;
10 10
 }
11 11
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 	  case 'network':
36 36
 		list($sub['net'],$sub['mask'])=explode('/',$value);
37
-                $query= sprintf("INSERT INTO `$table` (
37
+				$query= sprintf("INSERT INTO `$table` (
38 38
                         `$type` ,
39 39
 			`netmask`,
40 40
                         `date` ,
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
                         INET_ATON( '%s' ) , INET_ATON( '%s' ) ,
48 48
                         CURRENT_TIMESTAMP , TIMESTAMPADD(%s,%d,CURRENT_TIMESTAMP), '1', '%s', '%s'
49 49
                 )" ,$sub['net'],$sub['mask'],$expUnit,$expQ,$user,$myreason);
50
-                break;
50
+				break;
51 51
 
52 52
 	  default:
53
-                $query= sprintf("INSERT INTO `$table` (
53
+				$query= sprintf("INSERT INTO `$table` (
54 54
                         `$type` ,
55 55
                         `date` ,
56 56
                         `exp` ,
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 	}
66 66
 
67 67
 	if ($myconn->query($query) === TRUE) {
68
-	    syslog(LOG_INFO, "$user: $type <$value> successfully listed on <$table> for $expQ $expUnit.");
69
-	    $result=TRUE;
68
+		syslog(LOG_INFO, "$user: $type <$value> successfully listed on <$table> for $expQ $expUnit.");
69
+		$result=TRUE;
70 70
 	}
71 71
 	else syslog(LOG_ERR, "$user: Error: ".$myconn->error);
72 72
 	return $result;
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 
77 77
 	$result=FALSE;
78 78
 
79
-        switch ($type) {
79
+		switch ($type) {
80 80
 	  case 'ip':
81
-                $query= sprintf("UPDATE `$table` SET
81
+				$query= sprintf("UPDATE `$table` SET
82 82
 			`active` = '1',
83 83
 			`user` = '%s',
84 84
 			`exp` = TIMESTAMPADD(%s,%d,CURRENT_TIMESTAMP),
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 			`reason` = '%s'
87 87
 			WHERE `$table`.`$type` = INET_ATON('%s') LIMIT 1" ,$user,$expUnit,$expQ,$myreason,$value);
88 88
 		break;
89
-          case 'network':
89
+		  case 'network':
90 90
 		list($sub['net'],$sub['mask'])=explode('/',$value);
91
-                $query= sprintf("UPDATE `$table` SET
91
+				$query= sprintf("UPDATE `$table` SET
92 92
                         `active` = '1',
93 93
                         `user` = '%s',
94 94
                         `exp` = TIMESTAMPADD(%s,%d,CURRENT_TIMESTAMP),
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
                         WHERE (`$table`.`$type` = INET_ATON('%s') AND `$table`.`netmask` = INET_ATON('%s')) LIMIT 1" ,$user,$expUnit,$expQ,$myreason,$sub['net'],$sub['mask']);
98 98
 		break;
99 99
 	  default:
100
-                $query= sprintf("UPDATE `$table` SET
100
+				$query= sprintf("UPDATE `$table` SET
101 101
                         `active` = '1',
102 102
                         `user` = '%s',
103 103
                         `exp` = TIMESTAMPADD(%s,%d,CURRENT_TIMESTAMP),
@@ -106,19 +106,19 @@  discard block
 block discarded – undo
106 106
 			WHERE `$table`.`$type` = '%s' LIMIT 1" ,$user,$expUnit,$expQ,$myreason,$value);
107 107
 	}
108 108
 
109
-        if ($myconn->query($query) === TRUE) {
110
-            syslog(LOG_INFO, "$user: relist $type <$value> on <$table> for $expQ $expUnit.");
109
+		if ($myconn->query($query) === TRUE) {
110
+			syslog(LOG_INFO, "$user: relist $type <$value> on <$table> for $expQ $expUnit.");
111 111
 		$result=TRUE;
112
-        }
113
-        else syslog (LOG_ERR, "$user: Error: ". $myconn->error);
112
+		}
113
+		else syslog (LOG_ERR, "$user: Error: ". $myconn->error);
114 114
 	return $result;
115 115
 }
116 116
 
117 117
 function remove ($myconn,$user,$value,$type,$table) {
118
-        $result=FALSE;
118
+		$result=FALSE;
119 119
 
120
-        switch ($type) {
121
-          case 'ip':
120
+		switch ($type) {
121
+		  case 'ip':
122 122
 		$query = sprintf("DELETE FROM `$table` WHERE
123 123
                         `$table`.`$type` = INET_ATON('%s') LIMIT 1", $value);
124 124
 		break;
@@ -134,18 +134,18 @@  discard block
 block discarded – undo
134 134
 	}
135 135
 
136 136
 
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);
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);
140 140
 
141
-        return $return;
141
+		return $return;
142 142
 }
143 143
 
144 144
 
145 145
 function changestatus ($myconn,$user,$value,$status,$type,$table) {
146 146
 
147 147
 	switch ($type) {
148
-          case 'ip':
148
+		  case 'ip':
149 149
 		$query= sprintf("UPDATE `$table` SET `active` = '$status', `user` = '%s' WHERE `$table`.`$type` = INET_ATON('%s') LIMIT 1" ,$user, $value);
150 150
 		break;
151 151
 	  case 'network':
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
 		$query= sprintf("UPDATE `$table` SET `active` = '$status', `user` = '%s' WHERE `$table`.`$type` = '%s' LIMIT 1" ,$user, $value);
157 157
 	}
158 158
 
159
-        if ($return=$myconn->query($query) === TRUE) {
160
-            syslog(LOG_INFO, "$user: change status of $type <$value>. The status is now <$status>");
161
-        }
162
-        else syslog(LOG_ERR, "$user: Error: ". $myconn->error);
159
+		if ($return=$myconn->query($query) === TRUE) {
160
+			syslog(LOG_INFO, "$user: change status of $type <$value>. The status is now <$status>");
161
+		}
162
+		else syslog(LOG_ERR, "$user: Error: ". $myconn->error);
163 163
 	return $return;	
164 164
 }
165 165
 
166 166
 
167 167
 function expire ($myconn,$user,$tables,$expireTime) {
168
-        $return=TRUE;
168
+		$return=TRUE;
169 169
 	$desc = array_keys($tables);
170 170
 	foreach ($desc as $tdesc) { 
171 171
 		/* QUERY */
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 		/* END OF QUERY */
175 175
 		$log[0] = 'expired for';
176 176
 		$log[1] = 'disabled for';
177
-        	if ($myconn->multi_query($query)) {
177
+			if ($myconn->multi_query($query)) {
178 178
 			$j = 0;
179 179
 			do {
180
-		    		$numdel = $myconn->affected_rows;
181
-	            		syslog(LOG_INFO, "Expire job - <$user> Permanently DELETED $numdel records ".$log[$j]." $expireTime YEARS from <".$tables["$tdesc"]['name'].'>.');
180
+					$numdel = $myconn->affected_rows;
181
+						syslog(LOG_INFO, "Expire job - <$user> Permanently DELETED $numdel records ".$log[$j]." $expireTime YEARS from <".$tables["$tdesc"]['name'].'>.');
182 182
 				$j++;
183 183
 
184 184
 			} while ($myconn->next_result());
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	}
191 191
 	if ( !($return) ) syslog(LOG_EMERG, 'End of Expire job with error. See above logs. SQL Connection terminated');
192 192
 	else  syslog(LOG_INFO, 'Successfully End of Expire job. SQL Connection successfully terminated.');
193
-        return $return;
193
+		return $return;
194 194
 }
195 195
 
196 196
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		if ( $entry->num_rows ) {
232 232
 			if ( $entry->num_rows == 1 ) {
233 233
 				$riga = $entry->fetch_array(MYSQLI_ASSOC);
234
-                        	if (isListed($riga)) {
234
+							if (isListed($riga)) {
235 235
 					$warn = "<$value> is already present in <$listdep> list!";
236 236
 					$entry->free();
237 237
 					return FALSE;
@@ -248,28 +248,28 @@  discard block
 block discarded – undo
248 248
 function searchentry ($myconn,$value,$tablelist) {
249 249
 /* Make a MYSQL query and return result */
250 250
 
251
-        $type = $tablelist['field'];
252
-        $table = $tablelist['name'];
253
-
254
-        if ($value == 'ALL') $query = 'select * from '.$table;
255
-        else {
256
-                switch ($type) {
257
-                  case 'ip':
258
-                        $query= "select * from $table where $type =  INET_ATON('$value')";
259
-                        break;
260
-                  case 'network':
261
-                        list($sub['net'],$sub['mask'])=explode('/',$value);
262
-                        $query= 'select * from '.$table.' where (((inet_aton(\''.$sub['net'].'\') | (~ inet_aton(\''.$sub['mask'].'\'))) & netmask) = network)';
263
-                        break;
264
-                  default:
265
-                        $query= "select * from $table where $type = '$value'";
266
-                }
267
-        }
251
+		$type = $tablelist['field'];
252
+		$table = $tablelist['name'];
253
+
254
+		if ($value == 'ALL') $query = 'select * from '.$table;
255
+		else {
256
+				switch ($type) {
257
+				  case 'ip':
258
+						$query= "select * from $table where $type =  INET_ATON('$value')";
259
+						break;
260
+				  case 'network':
261
+						list($sub['net'],$sub['mask'])=explode('/',$value);
262
+						$query= 'select * from '.$table.' where (((inet_aton(\''.$sub['net'].'\') | (~ inet_aton(\''.$sub['mask'].'\'))) & netmask) = network)';
263
+						break;
264
+				  default:
265
+						$query= "select * from $table where $type = '$value'";
266
+				}
267
+		}
268 268
 
269 269
 	$result = $myconn->query($query);
270 270
 	if($result === false)
271 271
 		syslog(LOG_EMERG, "ALERT: Query <$query> failed: ".$myconn->error);
272
-        return $result;
272
+		return $result;
273 273
 }
274 274
 
275 275
 function countListed ($myconn,$table) {
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
 
286 286
 
287 287
 function isFull($myconn,$typedesc,$alltables) {
288
-        if (isset($alltables["$typedesc"]['limit'])) {
289
-                if ( countListed($myconn,$alltables["$typedesc"]['name']) >= $alltables["$typedesc"]['limit'] ) 
290
-                        return TRUE;
291
-        }
288
+		if (isset($alltables["$typedesc"]['limit'])) {
289
+				if ( countListed($myconn,$alltables["$typedesc"]['name']) >= $alltables["$typedesc"]['limit'] ) 
290
+						return TRUE;
291
+		}
292 292
 	return FALSE;
293 293
 }
294 294
 
@@ -301,14 +301,14 @@  discard block
 block discarded – undo
301 301
 	if ($result) {
302 302
 		printf("<pre>Your request for $type &lt;$value&gt; returned %d items.\n</pre>", $result->num_rows);
303 303
 
304
-        /* Check for limit in number of listed items */
304
+		/* Check for limit in number of listed items */
305 305
 	$full = isFull($myconn,$typedesc,$tables);
306 306
 	if ($full) print '<p>'.htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.').'</p>';
307 307
 
308 308
 		if ($result->num_rows) {
309 309
 			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";
310 310
 			$i=0;
311
-        		while ($riga = $result->fetch_array(MYSQLI_ASSOC)) {
311
+				while ($riga = $result->fetch_array(MYSQLI_ASSOC)) {
312 312
 				if (isListed($riga)) {
313 313
 					if ($tables["$typedesc"]['bl']) $listed='Listed';
314 314
 					else $listed='WhiteListed';
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 					$element = $riga["$type"];
328 328
 				}
329 329
 
330
-                		printf ("<tr id=id$i><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td>%s</td></tr>\n", $element, $riga['date'], $riga['datemod'], $riga['exp'], $riga['active'], $riga['nlist'], $riga['user'],htmlspecialchars($riga['reason']),ask($myconn,$i,$listed,$tables,$typedesc,$element,$full,$user,$adm));
330
+						printf ("<tr id=id$i><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td>%s</td></tr>\n", $element, $riga['date'], $riga['datemod'], $riga['exp'], $riga['active'], $riga['nlist'], $riga['user'],htmlspecialchars($riga['reason']),ask($myconn,$i,$listed,$tables,$typedesc,$element,$full,$user,$adm));
331 331
 				$i++;
332
-        		}
332
+				}
333 333
 			print '</tbody></table>';
334 334
 		}
335 335
 		else {
@@ -347,15 +347,15 @@  discard block
 block discarded – undo
347 347
 
348 348
 function sendEmailWarn($tplf,$from,$to,$sbj,$emailListed,$intervalToExpire,$detail) {
349 349
 	$now = time();
350
-        setlocale (LC_TIME, 'it_IT');
351
-        $date = date("r",$now);
350
+		setlocale (LC_TIME, 'it_IT');
351
+		$date = date("r",$now);
352 352
 	$messageID = md5(uniqid($now,1)) . '@' . $_SERVER["HOSTNAME"];
353 353
 	$mua = 'PHP/' . phpversion();
354 354
 
355 355
 	/* Parsing headers */
356 356
 	if (!file_exists($tplf['header'])) {
357
-    		syslog(LOG_ERR, 'Sending email... template file <'.$tplf['header'].'> not found!');
358
-    		exit;
357
+			syslog(LOG_ERR, 'Sending email... template file <'.$tplf['header'].'> not found!');
358
+			exit;
359 359
 	}
360 360
 
361 361
 	$head_tmpl = file_get_contents($tplf['header']);
@@ -364,36 +364,36 @@  discard block
 block discarded – undo
364 364
 	$headers = str_replace($arr_tpl_vars, $arr_tpl_data, $head_tmpl);
365 365
 	$headers = preg_replace( '/\r|\n/', "\r\n", $headers );
366 366
 
367
-        /* Parsing body */
367
+		/* Parsing body */
368 368
 
369
-        if (!file_exists($tplf['body'])) {
370
-                syslog(LOG_ERR, 'Sending email... template file <'.$tplf['body'].'> not found!');
371
-                exit;
372
-        }
369
+		if (!file_exists($tplf['body'])) {
370
+				syslog(LOG_ERR, 'Sending email... template file <'.$tplf['body'].'> not found!');
371
+				exit;
372
+		}
373 373
 
374
-        $body_tmpl = file_get_contents($tplf['body']);
375
-        $arr_tpl_vars = array('{emailListed}','{expInterval}','{reason}');
376
-        $arr_tpl_data = array($emailListed,$intervalToExpire,$detail);
377
-        $body = str_replace($arr_tpl_vars, $arr_tpl_data, $body_tmpl);
378
-        $body = preg_replace( "/\r|\n/", "\r\n", $body );
374
+		$body_tmpl = file_get_contents($tplf['body']);
375
+		$arr_tpl_vars = array('{emailListed}','{expInterval}','{reason}');
376
+		$arr_tpl_data = array($emailListed,$intervalToExpire,$detail);
377
+		$body = str_replace($arr_tpl_vars, $arr_tpl_data, $body_tmpl);
378
+		$body = preg_replace( "/\r|\n/", "\r\n", $body );
379 379
 	$body = wordwrap ( $body, 75 , "\r\n" );	
380 380
 
381 381
 	/* Send the mail! */
382 382
 	$params = NULL;
383
-        if ( strlen(ini_get("safe_mode"))< 1) {
384
-                $old_mailfrom = ini_get("sendmail_from");
385
-                ini_set("sendmail_from", $from);
386
-                $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;
395
-        }
396
-        return $flag;
383
+		if ( strlen(ini_get("safe_mode"))< 1) {
384
+				$old_mailfrom = ini_get("sendmail_from");
385
+				ini_set("sendmail_from", $from);
386
+				$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;
395
+		}
396
+		return $flag;
397 397
 }
398 398
 
399 399
 function emailToNotify($notify_file,$dom) {
@@ -407,59 +407,59 @@  discard block
 block discarded – undo
407 407
 function searchAndList ($myconn,$loguser,$tables,$typedesc,$value,$unit,&$quantity,$reason) {
408 408
 
409 409
 /* Search and list value */
410
-        $type = $tables["$typedesc"]['field'];
411
-        $table = $tables["$typedesc"]['name'];
412
-        $result = searchentry ($myconn,$value,$tables["$typedesc"]);
413
-
414
-        /* Manage abnormal conditions */
415
-        /* Value already present in db more than once. This is absurd. Panic! */
416
-        if ($result->num_rows > 1) {
417
-                syslog(LOG_EMERG,"$loguser: PANIC! Select for $type '$value' returned ". $result->num_rows ." items instead of one. Abnormal. Contact a sysadmin or a developer.");
418
-                $result->free();
419
-                return FALSE;
420
-        }
421
-
422
-        /* Value already present in db or not present: to list anyway */
423
-        if ($result->num_rows >= 0) {
424
-                /* First, check for limit in number of listed items */
425
-                if (isFull($myconn,$typedesc,$tables)) {
426
-                        syslog(LOG_EMERG,"$loguser: $typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items. Abnormal exit.');
427
-                        $result->free();
428
-                        return FALSE;
429
-                }
430
-                /* Second, check if the (re)list would be consistent now */
431
-                if (! consistentListing($myconn,$tables,$typedesc,$value,$whynot) ) {
432
-                        syslog(LOG_ERR, $loguser.': '.$whynot);
433
-                        $result->free();
434
-                        return FALSE;
435
-                }
436
-        }
437
-        /* End of abnormal conditions */
438
-
439
-
440
-        /* Finally, here I can list the value! */
410
+		$type = $tables["$typedesc"]['field'];
411
+		$table = $tables["$typedesc"]['name'];
412
+		$result = searchentry ($myconn,$value,$tables["$typedesc"]);
413
+
414
+		/* Manage abnormal conditions */
415
+		/* Value already present in db more than once. This is absurd. Panic! */
416
+		if ($result->num_rows > 1) {
417
+				syslog(LOG_EMERG,"$loguser: PANIC! Select for $type '$value' returned ". $result->num_rows ." items instead of one. Abnormal. Contact a sysadmin or a developer.");
418
+				$result->free();
419
+				return FALSE;
420
+		}
421
+
422
+		/* Value already present in db or not present: to list anyway */
423
+		if ($result->num_rows >= 0) {
424
+				/* First, check for limit in number of listed items */
425
+				if (isFull($myconn,$typedesc,$tables)) {
426
+						syslog(LOG_EMERG,"$loguser: $typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items. Abnormal exit.');
427
+						$result->free();
428
+						return FALSE;
429
+				}
430
+				/* Second, check if the (re)list would be consistent now */
431
+				if (! consistentListing($myconn,$tables,$typedesc,$value,$whynot) ) {
432
+						syslog(LOG_ERR, $loguser.': '.$whynot);
433
+						$result->free();
434
+						return FALSE;
435
+				}
436
+		}
437
+		/* End of abnormal conditions */
438
+
439
+
440
+		/* Finally, here I can list the value! */
441 441
 	$thisentry = $result->fetch_array(MYSQLI_ASSOC);
442
-        switch ($result->num_rows) {
443
-                /* Relist value if already present */
444
-                case 1:
445
-                        /* Entry already listed */
446
-                        if ( isListed($thisentry) ) {
447
-                                syslog(LOG_INFO, $loguser.': '.$value.' already listed. Nothing to do.');
448
-                                $result->free();
449
-                                return FALSE;
450
-                        }
451
-
452
-                        /* Entry delisted */
453
-                        $result->free();
442
+		switch ($result->num_rows) {
443
+				/* Relist value if already present */
444
+				case 1:
445
+						/* Entry already listed */
446
+						if ( isListed($thisentry) ) {
447
+								syslog(LOG_INFO, $loguser.': '.$value.' already listed. Nothing to do.');
448
+								$result->free();
449
+								return FALSE;
450
+						}
451
+
452
+						/* Entry delisted */
453
+						$result->free();
454 454
 			$quantity *= $thisentry['nlist'];
455
-                        return relist ($myconn,$loguser,$value,$type,$table,$unit,$quantity,$reason);
455
+						return relist ($myconn,$loguser,$value,$type,$table,$unit,$quantity,$reason);
456 456
 
457 457
 
458
-                /* First time list value */
459
-                case 0:
460
-                        $result->free();
461
-                        return addtolist ($myconn,$loguser,$value,$type,$table,$unit,$quantity,$reason);
462
-        }
458
+				/* First time list value */
459
+				case 0:
460
+						$result->free();
461
+						return addtolist ($myconn,$loguser,$value,$type,$table,$unit,$quantity,$reason);
462
+		}
463 463
 }
464 464
 
465 465
 
Please login to merge, or discard this patch.
result.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 		exit ('<pre>&lt;'.$_POST['Value'].'&gt; is NOT a valid email address.</pre>');
11 11
 
12 12
 if ( ($tables["$_"]['field']=='domain') AND ($_POST['Value']!='ALL') )
13
-        if (!(filter_var(gethostbyname($_POST['Value']), FILTER_VALIDATE_IP)))
13
+		if (!(filter_var(gethostbyname($_POST['Value']), FILTER_VALIDATE_IP)))
14 14
 		exit ('<pre>&lt;'.$_POST['Value'].'&gt; is NOT a valid domain.</pre>');
15 15
 
16 16
 if ( ($tables["$_"]['field']=='ip')  AND ($_POST['Value']!='ALL') )
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 }
27 27
 
28 28
 if ( ($tables["$_"]['field']=='username') AND ($_POST['Value']!='ALL') ) {
29
-        if ( preg_match( '/[^\x20-\x7f]/', $_POST['Value']) )
30
-                exit('<pre>&lt;'.$_POST['Value'].'&gt; contains NON ASCII chars.</pre>');
29
+		if ( preg_match( '/[^\x20-\x7f]/', $_POST['Value']) )
30
+				exit('<pre>&lt;'.$_POST['Value'].'&gt; contains NON ASCII chars.</pre>');
31 31
 	if ( preg_match( '/[$~=#*+%,{}()\/\\<>;:\"`\[\]&?\s]/', $_POST['Value']) )
32 32
 		exit('<pre>&lt;'.$_POST['Value'].'&gt; contains invalid ASCII chars.</pre>');
33 33
 	switch ( $_POST['Value'] ) {
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 
50 50
 $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport);
51 51
 if ($mysqli->connect_error) {
52
-            syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') '
53
-                    . $mysqli->connect_error);
54
-            exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '
55
-                    . $mysqli->connect_error);
52
+			syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') '
53
+					. $mysqli->connect_error);
54
+			exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '
55
+					. $mysqli->connect_error);
56 56
 }
57 57
 
58 58
 syslog(LOG_INFO, $user.': Successfully mysql connected to ' . $mysqli->host_info) ;
Please login to merge, or discard this patch.
remove.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@
 block discarded – undo
10 10
 $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport);
11 11
 if ($mysqli->connect_error) {
12 12
 	syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') '
13
-                    . $mysqli->connect_error);
14
-        die($user.': Connect Error (' . $mysqli->connect_errno . ') '
15
-                    . $mysqli->connect_error);
13
+					. $mysqli->connect_error);
14
+		die($user.': Connect Error (' . $mysqli->connect_errno . ') '
15
+					. $mysqli->connect_error);
16 16
 }
17 17
 syslog (LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info );
18 18
 
Please login to merge, or discard this patch.
list.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@
 block discarded – undo
12 12
 $user = username();
13 13
 
14 14
 $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport);
15
-        if ($mysqli->connect_error) {
16
-            syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') '
17
-                    . $mysqli->connect_error);
18
-            die($user.': Connect Error (' . $mysqli->connect_errno . ') '
19
-                    . $mysqli->connect_error);
20
-        }
15
+		if ($mysqli->connect_error) {
16
+			syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') '
17
+					. $mysqli->connect_error);
18
+			die($user.': Connect Error (' . $mysqli->connect_errno . ') '
19
+					. $mysqli->connect_error);
20
+		}
21 21
 syslog (LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info );
22 22
 
23 23
 if (addtolist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason']))
Please login to merge, or discard this patch.
relist.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,23 +2,23 @@
 block discarded – undo
2 2
 require_once('config.php');
3 3
 require_once('function.php');
4 4
 $typedesc=$_POST['type'];
5
-        $type = $tables["$typedesc"]['field'];
6
-        $table = $tables["$typedesc"]['name'];
5
+		$type = $tables["$typedesc"]['field'];
6
+		$table = $tables["$typedesc"]['name'];
7 7
 ?>
8 8
 <td colspan="9" style="text-align: center">
9 9
 <?php
10 10
 openlog($tag, LOG_PID, $fac);
11 11
 if (empty($_POST['reason'])) die ("Specify a reason, please!</td>");
12 12
 if (preg_match( '/[^\x20-\x7f]/', $_POST['reason']))
13
-        exit('ERROR: &lt;'.htmlentities($_POST['reason'],ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'&gt; contains NON ASCII chars.</td>');
13
+		exit('ERROR: &lt;'.htmlentities($_POST['reason'],ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'&gt; contains NON ASCII chars.</td>');
14 14
 $user = username();
15 15
 
16 16
 $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport);
17 17
 if ($mysqli->connect_error) {
18 18
 	syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') '
19
-        	. $mysqli->connect_error);
20
-            exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '
21
-                    . $mysqli->connect_error);
19
+			. $mysqli->connect_error);
20
+			exit ($user.': Connect Error (' . $mysqli->connect_errno . ') '
21
+					. $mysqli->connect_error);
22 22
 }
23 23
 syslog(LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info) ;
24 24
 
Please login to merge, or discard this patch.