@@ -141,17 +141,19 @@ discard block |
||
| 141 | 141 | $thisVal = $data[1]; |
| 142 | 142 | unset($data[1]); |
| 143 | 143 | $data = array_values($data); |
| 144 | - if ( !in_array($thisVal,array_keys($tolist)) ) |
|
| 145 | - $tolist["$thisVal"] = $data; |
|
| 146 | - else if ($data[3]>$tolist[$thisVal][3]) |
|
| 147 | - $tolist["$thisVal"] = $data; |
|
| 148 | -} |
|
| 144 | + if ( !in_array($thisVal,array_keys($tolist)) ) { |
|
| 145 | + $tolist["$thisVal"] = $data; |
|
| 146 | + } else if ($data[3]>$tolist[$thisVal][3]) { |
|
| 147 | + $tolist["$thisVal"] = $data; |
|
| 148 | + } |
|
| 149 | + } |
|
| 149 | 150 | |
| 150 | 151 | /* Make MYSQL connection */ |
| 151 | 152 | |
| 152 | 153 | $mysqli = myConnect($host, $userdb, $pwd, $db, $dbport, $tables, $typedesc, $user); |
| 153 | -if ( $mysqli === FALSE ) |
|
| 154 | +if ( $mysqli === FALSE ) { |
|
| 154 | 155 | exit (254); |
| 156 | +} |
|
| 155 | 157 | |
| 156 | 158 | foreach ( array_keys($tolist) as $value) { |
| 157 | 159 | $quantity = $conf['quantity']; |
@@ -168,17 +170,18 @@ discard block |
||
| 168 | 170 | $recip = emailToNotify($domainNotify_file,$domain); |
| 169 | 171 | $subject = sprintf('%s <%s> is now blocked because exceedes limits on outgoing emails', |
| 170 | 172 | $tables["$typedesc"]['field'], $value); |
| 171 | - if (!empty($recip)) |
|
| 172 | - if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
| 173 | + if (!empty($recip)) { |
|
| 174 | + if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
| 173 | 175 | $subject,$value,"$quantity $unit",$reason) ) |
| 174 | 176 | syslog(LOG_INFO, "$user: \"$recip\" was notified about the \"$value\" abuse."); |
| 177 | + } |
|
| 178 | + } else { |
|
| 179 | + syslog(LOG_ERR,"$user: <$domain> contains the '@' char. Notification cannot be sent."); |
|
| 175 | 180 | } |
| 176 | - else syslog(LOG_ERR,"$user: <$domain> contains the '@' char. Notification cannot be sent."); |
|
| 177 | 181 | } |
| 178 | 182 | } |
| 179 | 183 | } |
| 180 | - } |
|
| 181 | - else { |
|
| 184 | + } else { |
|
| 182 | 185 | $reason .= " But it has NOT been listed because it doesn't apply to the trigger condition."; |
| 183 | 186 | syslog (LOG_INFO, "$user: ".$reason); |
| 184 | 187 | } |
@@ -14,12 +14,14 @@ |
||
| 14 | 14 | require_once('function.php'); |
| 15 | 15 | |
| 16 | 16 | checkSSL(); |
| 17 | -if ( $require_auth ) |
|
| 17 | +if ( $require_auth ) { |
|
| 18 | 18 | if ( username() == 'unknown' ) exit ("<p>You MUST configure your server to use authentication.</p>"); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | |
| 21 | -if ( $imapListActive ) |
|
| 22 | +if ( $imapListActive ) { |
|
| 22 | 23 | print ' <p style="text-align: right"><a href="/spamreport" target="_new">SPAM Learn Observer</a></p>'; |
| 24 | +} |
|
| 23 | 25 | |
| 24 | 26 | print <<<END |
| 25 | 27 | <form name="check" action="result.php" onSubmit="xmlhttpPost('result.php', 'check', 'Risultato', '<img src=\'/include/pleasewait.gif\'>'); return false;" enctype="text/plain" method="post" target="_self"> |
@@ -3,22 +3,27 @@ discard block |
||
| 3 | 3 | ini_set('error_log', 'syslog'); |
| 4 | 4 | |
| 5 | 5 | function username() { |
| 6 | - if (isset ($_SERVER['REMOTE_USER'])) $user = $_SERVER['REMOTE_USER']; |
|
| 7 | - else if (isset ($_SERVER['USER'])) $user = $_SERVER['USER']; |
|
| 8 | - else $user='unknown'; |
|
| 6 | + if (isset ($_SERVER['REMOTE_USER'])) { |
|
| 7 | + $user = $_SERVER['REMOTE_USER']; |
|
| 8 | + } else if (isset ($_SERVER['USER'])) { |
|
| 9 | + $user = $_SERVER['USER']; |
|
| 10 | + } else { |
|
| 11 | + $user='unknown'; |
|
| 12 | + } |
|
| 9 | 13 | return $user; |
| 10 | 14 | } |
| 11 | 15 | |
| 12 | 16 | function checkSSL() { |
| 13 | - if ( empty( $_SERVER['HTTPS'] ) ) |
|
| 14 | - printf ('<div id="content">Ehi sysadmin! Your site is not secure. Please enable SSL on your server and configure a redirect, such as' . |
|
| 17 | + if ( empty( $_SERVER['HTTPS'] ) ) { |
|
| 18 | + printf ('<div id="content">Ehi sysadmin! Your site is not secure. Please enable SSL on your server and configure a redirect, such as' . |
|
| 15 | 19 | '<pre>' . |
| 16 | 20 | htmlspecialchars('<VirtualHost *:80>' . "\n" . |
| 17 | 21 | ' ServerName %s' . "\n" . |
| 18 | 22 | ' Redirect permanent / https://%s/' . "\n" . |
| 19 | 23 | '</VirtualHost>') . |
| 20 | 24 | '</pre></div>', gethostname(), gethostname()); |
| 21 | -} |
|
| 25 | + } |
|
| 26 | + } |
|
| 22 | 27 | |
| 23 | 28 | function myConnect($host, $user, $pass, $db, $port, $tablelist, $typedesc, $loguser) { |
| 24 | 29 | $db = ( $tablelist["$typedesc"]['milter'] ) ? $tablelist["$typedesc"]['name'] : $db; |
@@ -99,8 +104,9 @@ discard block |
||
| 99 | 104 | if ($myconn->query($query) === TRUE) { |
| 100 | 105 | syslog(LOG_INFO, "$user: $type <$value> successfully listed on <$table> for $expQ $expUnit."); |
| 101 | 106 | $result=TRUE; |
| 107 | + } else { |
|
| 108 | + syslog(LOG_ERR, "$user: Error: ".$myconn->error); |
|
| 102 | 109 | } |
| 103 | - else syslog(LOG_ERR, "$user: Error: ".$myconn->error); |
|
| 104 | 110 | return $result; |
| 105 | 111 | } |
| 106 | 112 | |
@@ -110,8 +116,7 @@ discard block |
||
| 110 | 116 | if ( $exptime ) { /* Entry already listed */ |
| 111 | 117 | $nlist = '`nlist`'; |
| 112 | 118 | $exptime = sprintf('\'%s\'', $exptime); /* Eh MySQL... an hour lost to notice this */ |
| 113 | - } |
|
| 114 | - else { |
|
| 119 | + } else { |
|
| 115 | 120 | $exptime = 'CURRENT_TIMESTAMP'; |
| 116 | 121 | $nlist = '`nlist` + 1'; |
| 117 | 122 | } |
@@ -149,8 +154,9 @@ discard block |
||
| 149 | 154 | if ($myconn->query($query) === TRUE) { |
| 150 | 155 | syslog(LOG_INFO, "$user: relist $type <$value> on <$table> for $expQ $expUnit from $exptime."); |
| 151 | 156 | $result=TRUE; |
| 157 | + } else { |
|
| 158 | + syslog (LOG_ERR, "$user: Error: ". $myconn->error); |
|
| 152 | 159 | } |
| 153 | - else syslog (LOG_ERR, "$user: Error: ". $myconn->error); |
|
| 154 | 160 | return $result; |
| 155 | 161 | } |
| 156 | 162 | |
@@ -173,9 +179,11 @@ discard block |
||
| 173 | 179 | } |
| 174 | 180 | |
| 175 | 181 | |
| 176 | - if ($return=$myconn->query($query) === TRUE) |
|
| 177 | - syslog(LOG_INFO, "$user: permanently DELETED $type <$value> from <$table>."); |
|
| 178 | - else syslog(LOG_ERR, "$user: Error: ". $myconn->error); |
|
| 182 | + if ($return=$myconn->query($query) === TRUE) { |
|
| 183 | + syslog(LOG_INFO, "$user: permanently DELETED $type <$value> from <$table>."); |
|
| 184 | + } else { |
|
| 185 | + syslog(LOG_ERR, "$user: Error: ". $myconn->error); |
|
| 186 | + } |
|
| 179 | 187 | |
| 180 | 188 | return $return; |
| 181 | 189 | } |
@@ -197,8 +205,9 @@ discard block |
||
| 197 | 205 | |
| 198 | 206 | if ($return=$myconn->query($query) === TRUE) { |
| 199 | 207 | syslog(LOG_INFO, "$user: change status of $type <$value>. The status is now <$status>"); |
| 208 | + } else { |
|
| 209 | + syslog(LOG_ERR, "$user: Error: ". $myconn->error); |
|
| 200 | 210 | } |
| 201 | - else syslog(LOG_ERR, "$user: Error: ". $myconn->error); |
|
| 202 | 211 | return $return; |
| 203 | 212 | } |
| 204 | 213 | |
@@ -222,14 +231,16 @@ discard block |
||
| 222 | 231 | $j++; |
| 223 | 232 | |
| 224 | 233 | } while ($myconn->next_result()); |
| 225 | - } |
|
| 226 | - else { |
|
| 234 | + } else { |
|
| 227 | 235 | syslog(LOG_ERR, "Expire job - Error: ". $myconn->error); |
| 228 | 236 | $return = FALSE; |
| 229 | 237 | } |
| 230 | 238 | } |
| 231 | - if ( !($return) ) syslog(LOG_EMERG, 'End of Expire job with error. See above logs. SQL Connection terminated'); |
|
| 232 | - else syslog(LOG_INFO, 'Successfully End of Expire job. SQL Connection successfully terminated.'); |
|
| 239 | + if ( !($return) ) { |
|
| 240 | + syslog(LOG_EMERG, 'End of Expire job with error. See above logs. SQL Connection terminated'); |
|
| 241 | + } else { |
|
| 242 | + syslog(LOG_INFO, 'Successfully End of Expire job. SQL Connection successfully terminated.'); |
|
| 243 | + } |
|
| 233 | 244 | return $return; |
| 234 | 245 | } |
| 235 | 246 | |
@@ -238,8 +249,11 @@ discard block |
||
| 238 | 249 | |
| 239 | 250 | $exp=new DateTime($row['exp']); |
| 240 | 251 | $now=new DateTime('NOW'); |
| 241 | - if (($exp > $now) and ($row['active'])) return true; |
|
| 242 | - else return false; |
|
| 252 | + if (($exp > $now) and ($row['active'])) { |
|
| 253 | + return true; |
|
| 254 | + } else { |
|
| 255 | + return false; |
|
| 256 | + } |
|
| 243 | 257 | |
| 244 | 258 | } |
| 245 | 259 | |
@@ -259,10 +273,11 @@ discard block |
||
| 259 | 273 | END; |
| 260 | 274 | $activeMilts = explode(',',$value); |
| 261 | 275 | foreach ( $milts as $milter ) { |
| 262 | - if ( in_array($milter, $activeMilts) ) |
|
| 263 | - $selected= 'selected'; |
|
| 264 | - else |
|
| 265 | - $selected= NULL; |
|
| 276 | + if ( in_array($milter, $activeMilts) ) { |
|
| 277 | + $selected= 'selected'; |
|
| 278 | + } else { |
|
| 279 | + $selected= NULL; |
|
| 280 | + } |
|
| 266 | 281 | $button .= sprintf('<option value="%s" %s>%s</option>', $milter, $selected, $milter); |
| 267 | 282 | } |
| 268 | 283 | $button .= '</select></div><input class="button" name="Change" type="submit" value="Change" /></form>'; |
@@ -279,9 +294,12 @@ discard block |
||
| 279 | 294 | $whynot=NULL; |
| 280 | 295 | switch ($what) { |
| 281 | 296 | case 'Ok': |
| 282 | - if ($lock) return NULL; |
|
| 283 | - if (in_array($user,array_keys($adm))) |
|
| 284 | - if ( consistentListing($myconn,$alltables,$typedesc,$value,$whynot) ) return require('relistButton.php'); |
|
| 297 | + if ($lock) { |
|
| 298 | + return NULL; |
|
| 299 | + } |
|
| 300 | + if (in_array($user,array_keys($adm))) { |
|
| 301 | + if ( consistentListing($myconn,$alltables,$typedesc,$value,$whynot) ) return require('relistButton.php'); |
|
| 302 | + } |
|
| 285 | 303 | return htmlspecialchars($whynot); |
| 286 | 304 | case 'Listed': |
| 287 | 305 | case 'WhiteListed': |
@@ -293,7 +311,9 @@ discard block |
||
| 293 | 311 | function consistentListing($myconn,$alltables,$typed,$value,&$warn) { |
| 294 | 312 | /* Check if there are no pending mislisting */ |
| 295 | 313 | $warn = NULL; |
| 296 | - if (! isset($alltables["$typed"]['depend']) ) return TRUE; |
|
| 314 | + if (! isset($alltables["$typed"]['depend']) ) { |
|
| 315 | + return TRUE; |
|
| 316 | + } |
|
| 297 | 317 | foreach ($alltables["$typed"]['depend'] as $listdep) { |
| 298 | 318 | if ($alltables["$typed"]['field'] != $alltables["$listdep"]['field'] ) { |
| 299 | 319 | $warn = "Config ERROR: <$typed> and <$listdep> are of different types! I can't check consistency!"; |
@@ -324,10 +344,10 @@ discard block |
||
| 324 | 344 | |
| 325 | 345 | if ( $tablelist['milter'] ) { |
| 326 | 346 | $table = milterTable($type); |
| 327 | - if ($value == 'ALL') |
|
| 328 | - $query = sprintf('SELECT *, GROUP_CONCAT(milt.name) as miltnames FROM `%s` LEFT JOIN milt ON (%s.idmilt=milt.id) GROUP by idmilt', |
|
| 347 | + if ($value == 'ALL') { |
|
| 348 | + $query = sprintf('SELECT *, GROUP_CONCAT(milt.name) as miltnames FROM `%s` LEFT JOIN milt ON (%s.idmilt=milt.id) GROUP by idmilt', |
|
| 329 | 349 | $table,$table); |
| 330 | - else { |
|
| 350 | + } else { |
|
| 331 | 351 | switch ($type) { |
| 332 | 352 | case 'network': |
| 333 | 353 | list($sub['net'],$sub['mask'])=explode('/',$value); |
@@ -352,12 +372,11 @@ discard block |
||
| 352 | 372 | return FALSE; |
| 353 | 373 | } |
| 354 | 374 | } |
| 355 | - } |
|
| 356 | - |
|
| 357 | - else { |
|
| 375 | + } else { |
|
| 358 | 376 | $table = $tablelist['name']; |
| 359 | - if ($value == 'ALL') $query = 'select * from '.$table; |
|
| 360 | - else { |
|
| 377 | + if ($value == 'ALL') { |
|
| 378 | + $query = 'select * from '.$table; |
|
| 379 | + } else { |
|
| 361 | 380 | switch ($type) { |
| 362 | 381 | case 'ip': |
| 363 | 382 | $query= "select * from $table where $type = INET_ATON('$value')"; |
@@ -379,8 +398,9 @@ discard block |
||
| 379 | 398 | } |
| 380 | 399 | |
| 381 | 400 | $result = $myconn->query($query); |
| 382 | - if($result === false) |
|
| 383 | - syslog(LOG_EMERG, "ALERT: Query <$query> failed: ".$myconn->error); |
|
| 401 | + if($result === false) { |
|
| 402 | + syslog(LOG_EMERG, "ALERT: Query <$query> failed: ".$myconn->error); |
|
| 403 | + } |
|
| 384 | 404 | return $result; |
| 385 | 405 | } |
| 386 | 406 | |
@@ -397,12 +417,14 @@ discard block |
||
| 397 | 417 | |
| 398 | 418 | function isFull($myconn,$typedesc,$alltables) { |
| 399 | 419 | if (isset($alltables["$typedesc"]['limit'])) { |
| 400 | - if ( $alltables["$typedesc"]['milter'] ) |
|
| 401 | - $tab = 'net'; |
|
| 402 | - else |
|
| 403 | - $tab = $alltables["$typedesc"]['name']; |
|
| 404 | - if ( countListed($myconn,$tab) >= $alltables["$typedesc"]['limit'] ) |
|
| 405 | - return TRUE; |
|
| 420 | + if ( $alltables["$typedesc"]['milter'] ) { |
|
| 421 | + $tab = 'net'; |
|
| 422 | + } else { |
|
| 423 | + $tab = $alltables["$typedesc"]['name']; |
|
| 424 | + } |
|
| 425 | + if ( countListed($myconn,$tab) >= $alltables["$typedesc"]['limit'] ) { |
|
| 426 | + return TRUE; |
|
| 427 | + } |
|
| 406 | 428 | } |
| 407 | 429 | return FALSE; |
| 408 | 430 | } |
@@ -415,8 +437,9 @@ discard block |
||
| 415 | 437 | $tabhtm = <<<END |
| 416 | 438 | <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> |
| 417 | 439 | END; |
| 418 | - if ( $tables["$typedesc"]['milter'] ) |
|
| 419 | - $tabhtm .= '<th title="Milter active for this object">Milters</th>'; |
|
| 440 | + if ( $tables["$typedesc"]['milter'] ) { |
|
| 441 | + $tabhtm .= '<th title="Milter active for this object">Milters</th>'; |
|
| 442 | + } |
|
| 420 | 443 | $tabhtm .= '<th>Authored by</th><th width="250">Reason</th><th>Action</th></tr></thead><tfoot><tr></tr></tfoot><tbody>'."\n"; |
| 421 | 444 | |
| 422 | 445 | $result = searchentry ($myconn,$value,$tables["$typedesc"]); |
@@ -425,18 +448,23 @@ discard block |
||
| 425 | 448 | |
| 426 | 449 | /* Check for limit in number of listed items */ |
| 427 | 450 | $full = isFull($myconn,$typedesc,$tables); |
| 428 | - if ($full) print '<p>'.htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.').'</p>'; |
|
| 451 | + if ($full) { |
|
| 452 | + print '<p>'.htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.').'</p>'; |
|
| 453 | + } |
|
| 429 | 454 | |
| 430 | 455 | if ($result->num_rows) { |
| 431 | 456 | print $tabhtm; |
| 432 | 457 | $i=0; |
| 433 | 458 | while ($riga = $result->fetch_array(MYSQLI_ASSOC)) { |
| 434 | 459 | if (isListed($riga)) { |
| 435 | - if ($tables["$typedesc"]['bl']) $listed='Listed'; |
|
| 436 | - else $listed='WhiteListed'; |
|
| 437 | - } |
|
| 438 | - else |
|
| 439 | - $listed='Ok'; |
|
| 460 | + if ($tables["$typedesc"]['bl']) { |
|
| 461 | + $listed='Listed'; |
|
| 462 | + } else { |
|
| 463 | + $listed='WhiteListed'; |
|
| 464 | + } |
|
| 465 | + } else { |
|
| 466 | + $listed='Ok'; |
|
| 467 | + } |
|
| 440 | 468 | |
| 441 | 469 | switch ($type) { |
| 442 | 470 | case 'ip': |
@@ -449,27 +477,30 @@ discard block |
||
| 449 | 477 | $element = $riga["$type"]; |
| 450 | 478 | } |
| 451 | 479 | |
| 452 | - if ( $tables["$typedesc"]['milter'] AND checkMilterConf($tables["$typedesc"]) ) |
|
| 453 | - 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 nowrap id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td>%s</td></tr>\n", |
|
| 480 | + if ( $tables["$typedesc"]['milter'] AND checkMilterConf($tables["$typedesc"]) ) { |
|
| 481 | + 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 nowrap id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td>%s</td></tr>\n", |
|
| 454 | 482 | $element, $riga['date'], $riga['datemod'], $riga['exp'], $riga['active'], $riga['nlist'], askMilter($myconn,$i,$element,$typedesc,$riga['idmilt'],$riga['miltnames'],$user,$adm), $riga['user'],htmlspecialchars($riga['reason']),ask($myconn,$i,$listed,$tables,$typedesc,$element,$full,$user,$adm)); |
| 455 | - else |
|
| 456 | - 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", |
|
| 483 | + } else { |
|
| 484 | + 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", |
|
| 457 | 485 | $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)); |
| 486 | + } |
|
| 458 | 487 | $i++; |
| 459 | 488 | } |
| 460 | 489 | print '</tbody></table>'; |
| 461 | - } |
|
| 462 | - else { |
|
| 490 | + } else { |
|
| 463 | 491 | print "<pre>$type <$value> is not listed!\n</pre>"; |
| 464 | - if ( in_array($user,array_keys($adm)) AND ($value != 'ALL') ) |
|
| 465 | - if ( (!$full) AND (consistentListing($myconn,$tables,$typedesc,$value,$whynot)) ) require_once('listForm.php'); |
|
| 466 | - else print '<p>'.htmlspecialchars($whynot).'</p>'; |
|
| 492 | + if ( in_array($user,array_keys($adm)) AND ($value != 'ALL') ) { |
|
| 493 | + if ( (!$full) AND (consistentListing($myconn,$tables,$typedesc,$value,$whynot)) ) require_once('listForm.php'); |
|
| 494 | + } else { |
|
| 495 | + print '<p>'.htmlspecialchars($whynot).'</p>'; |
|
| 496 | + } |
|
| 467 | 497 | |
| 468 | 498 | } |
| 469 | 499 | $result->free(); |
| 500 | + } else { |
|
| 501 | + print '<pre>Query error or something wrong in DB schema'."\n</pre>"; |
|
| 502 | + } |
|
| 470 | 503 | } |
| 471 | - else print '<pre>Query error or something wrong in DB schema'."\n</pre>"; |
|
| 472 | -} |
|
| 473 | 504 | |
| 474 | 505 | |
| 475 | 506 | |
@@ -512,24 +543,32 @@ discard block |
||
| 512 | 543 | $old_mailfrom = ini_get("sendmail_from"); |
| 513 | 544 | ini_set("sendmail_from", $from); |
| 514 | 545 | $params = sprintf("-oi -f %s", '<>'); |
| 515 | - if (!(mail($to,$sbj, $body,$headers,$params))) $flag=FALSE; |
|
| 516 | - else $flag=TRUE; |
|
| 517 | - if (isset($old_mailfrom)) |
|
| 518 | - ini_set("sendmail_from", $old_mailfrom); |
|
| 519 | - } |
|
| 520 | - else { |
|
| 521 | - if (!(mail($to,$sbj, $body,$headers))) $flag=FALSE; |
|
| 522 | - else $flag=TRUE; |
|
| 546 | + if (!(mail($to,$sbj, $body,$headers,$params))) { |
|
| 547 | + $flag=FALSE; |
|
| 548 | + } else { |
|
| 549 | + $flag=TRUE; |
|
| 550 | + } |
|
| 551 | + if (isset($old_mailfrom)) { |
|
| 552 | + ini_set("sendmail_from", $old_mailfrom); |
|
| 553 | + } |
|
| 554 | + } else { |
|
| 555 | + if (!(mail($to,$sbj, $body,$headers))) { |
|
| 556 | + $flag=FALSE; |
|
| 557 | + } else { |
|
| 558 | + $flag=TRUE; |
|
| 559 | + } |
|
| 523 | 560 | } |
| 524 | 561 | return $flag; |
| 525 | 562 | } |
| 526 | 563 | |
| 527 | 564 | function emailToNotify($notify_file,$dom) { |
| 528 | 565 | $ini_array = parse_ini_file($notify_file); |
| 529 | - if (in_array($dom,array_keys($ini_array))) |
|
| 530 | - return $ini_array["$dom"]; |
|
| 531 | - else return FALSE; |
|
| 532 | -} |
|
| 566 | + if (in_array($dom,array_keys($ini_array))) { |
|
| 567 | + return $ini_array["$dom"]; |
|
| 568 | + } else { |
|
| 569 | + return FALSE; |
|
| 570 | + } |
|
| 571 | + } |
|
| 533 | 572 | |
| 534 | 573 | |
| 535 | 574 | function searchAndList ($myconn,$loguser,$tables,$typedesc,$value,$unit,&$quantity,&$reason) { |
@@ -577,8 +616,7 @@ discard block |
||
| 577 | 616 | $reason); |
| 578 | 617 | $quantity = 1; |
| 579 | 618 | $unit = 'DAY'; |
| 580 | - } |
|
| 581 | - else { |
|
| 619 | + } else { |
|
| 582 | 620 | /* Entry delisted */ |
| 583 | 621 | $quantity *= $thisentry['nlist']; |
| 584 | 622 | $expdate = 0; /* This forces expiration from CURRENT_TIMESTAMP */ |
@@ -609,9 +647,10 @@ discard block |
||
| 609 | 647 | $net = new \dautkom\ipv4\IPv4(); |
| 610 | 648 | $range = $net->address($addressA)->mask($maskA)->getRange(); |
| 611 | 649 | $ips = ipRange($range); |
| 612 | - foreach ( $ips as $ip ) |
|
| 613 | - if ( $net->address($addressB)->mask($maskB)->has($ip) ) |
|
| 650 | + foreach ( $ips as $ip ) { |
|
| 651 | + if ( $net->address($addressB)->mask($maskB)->has($ip) ) |
|
| 614 | 652 | return TRUE; |
| 653 | + } |
|
| 615 | 654 | return FALSE; |
| 616 | 655 | } |
| 617 | 656 | |
@@ -688,8 +727,9 @@ discard block |
||
| 688 | 727 | return FALSE; |
| 689 | 728 | } |
| 690 | 729 | if ($result->num_rows) { |
| 691 | - while ($milt = $result->fetch_array(MYSQLI_ASSOC)) |
|
| 692 | - $milters[] = $milt['name']; |
|
| 730 | + while ($milt = $result->fetch_array(MYSQLI_ASSOC)) { |
|
| 731 | + $milters[] = $milt['name']; |
|
| 732 | + } |
|
| 693 | 733 | } |
| 694 | 734 | $result->free(); |
| 695 | 735 | return $milters; |
@@ -715,12 +755,14 @@ discard block |
||
| 715 | 755 | $query[] = "DELETE FROM `milt` WHERE (`id` = '$miltID' AND `name` = '$value')"; |
| 716 | 756 | } |
| 717 | 757 | } |
| 718 | - if ( count($query) ) /* This "if" is redundant, because if I call this I already checked there is a change */ |
|
| 758 | + if ( count($query) ) { |
|
| 759 | + /* This "if" is redundant, because if I call this I already checked there is a change */ |
|
| 719 | 760 | /* I update datemod because the user couldn't change */ |
| 720 | 761 | $query[] = sprintf('UPDATE `%s` SET |
| 721 | 762 | `user`=\'%s\', |
| 722 | 763 | `datemod`= CURRENT_TIMESTAMP |
| 723 | 764 | WHERE `idmilt`=%d', $table, $loguser, $miltID); |
| 765 | + } |
|
| 724 | 766 | |
| 725 | 767 | |
| 726 | 768 | /* Start a safe transaction: it commits only if all queries happen */ |
@@ -734,19 +776,20 @@ discard block |
||
| 734 | 776 | } |
| 735 | 777 | } |
| 736 | 778 | if ( $ok ) { |
| 737 | - if ( $myconn->commit() ) |
|
| 738 | - syslog(LOG_INFO, "$loguser: Milter setting changed successfully."); |
|
| 739 | - else { |
|
| 779 | + if ( $myconn->commit() ) { |
|
| 780 | + syslog(LOG_INFO, "$loguser: Milter setting changed successfully."); |
|
| 781 | + } else { |
|
| 740 | 782 | syslog(LOG_ERR, "$loguser: Milter setting NOT changed for an unpredictable COMMIT error."); |
| 741 | - if ( $myconn->rollback() ) |
|
| 742 | - syslog(LOG_INFO, "$loguser: rollback succeeded."); |
|
| 743 | - else |
|
| 744 | - syslog(LOG_ERR, "$loguser: rollback failed. Your db could be compromized. Check it!"); |
|
| 783 | + if ( $myconn->rollback() ) { |
|
| 784 | + syslog(LOG_INFO, "$loguser: rollback succeeded."); |
|
| 785 | + } else { |
|
| 786 | + syslog(LOG_ERR, "$loguser: rollback failed. Your db could be compromized. Check it!"); |
|
| 787 | + } |
|
| 745 | 788 | $ok = FALSE; |
| 746 | 789 | } |
| 790 | + } else { |
|
| 791 | + syslog(LOG_ERR, "$loguser: Error: Milter setting NOT changed. See at above errors."); |
|
| 747 | 792 | } |
| 748 | - else |
|
| 749 | - syslog(LOG_ERR, "$loguser: Error: Milter setting NOT changed. See at above errors."); |
|
| 750 | 793 | return $ok; |
| 751 | 794 | |
| 752 | 795 | } |