function milter_greylist() { $save = false; if (!is_array($GLOBALS["WHITELISTED"])) { return null; } $mi = new milter_greylist(); $whitelisted = $mi->GetWhiteListed(); if ($GLOBALS["VERBOSE"]) { echo "whitelisted=" . count($whitelisted) . "\n"; } while (list($num, $ligne) = each($GLOBALS["WHITELISTED"])) { if ($GLOBALS["VERBOSE"]) { echo "whitelisted[{$num}]=" . $whitelisted[$num] . "\n"; } if (!$whitelisted[$num]) { if ($GLOBALS["VERBOSE"]) { echo "insert new milter-greylist rule for {$ligne}\n"; } $mi->acl[] = "acl whitelist addr {$num} # PostfixAutoBlockWhiteList"; $save = true; } else { if ($GLOBALS["VERBOSE"]) { echo "Already inserted {$ligne}\n"; } } } if ($save) { $mi->SaveToLdap(); } }
function MultiplesInstances($hostname = null, $ou = null) { echo "{$GLOBALS["deflog_start"]} milter-greylist: MultiplesInstances() `{$hostname}` and ou `{$ou}`\n"; if ($ou == null && $hostname == null) { MultiplesInstancesFound(); return; } if ($hostname == null) { echo __FUNCTION__ . " unable to get hostname name\n"; return; } $mg = new milter_greylist(false, $hostname, $ou); $datas = $mg->BuildConfig(); @mkdir("/etc/milter-greylist/{$hostname}", 0666, true); @mkdir("/var/spool/{$hostname}/run/milter-greylist", 0666, true); $tbl = explode("\n", $datas); while (list($num, $ligne) = each($tbl)) { $ligne = trim($ligne); if ($ligne == null) { continue; } $newf[] = $ligne; } $newf[] = ""; echo "{$GLOBALS["deflog_start"]} milter-greylist {$hostname}: writing /etc/milter-greylist/{$hostname}/greylist.conf\n"; $datas = @implode("\n", $newf); @file_put_contents("/etc/milter-greylist/{$hostname}/greylist.conf", $datas); echo "{$GLOBALS["deflog_start"]} milter-greylist {$hostname}: or={$ou} START_ONLY={$GLOBALS["START_ONLY"]},STOP_ONLY={$GLOBALS["STOP_ONLY"]}\n"; if ($GLOBALS["STOP_ONLY"] == 1) { MultiplesInstances_stop($hostname, $ou); } if ($GLOBALS["START_ONLY"] == 1) { MultiplesInstances_start($hostname, $ou); } }
function BackToDNSBLDefault() { $mil = new milter_greylist(false, $_GET["hostname"], base64_decode($_GET["ou"])); unset($mil->dnsrbl_array); $mil->SaveToLdap(); echo main_dnsrbl_list(); }
function GetNewForm() { $pure = new milter_greylist(); $id = $_GET["class"]; $line = $pure->ParseAcl($pure->acl[$id]); switch ($_GET["ChangeFormType"]) { case "dnsrbl": if (!preg_match('#delay\\s+([0-9]+)([a-z])#', $line[3], $re)) { $re[1] = 15; $re[2] = "m"; } $form = "<table style='width:100%'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td strong width=1% nowrap align='right'>{dnsrbl_service}:</strong></td>\n\t\t\t\t\t<td>" . Field_array_Hash($pure->dnsrbl_class, 'dnsrbl_class', null) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td strong width=1% nowrap align='right'>{delay}:</strong></td>\n\t\t\t\t\t<td>" . Field_text("delay", "{$re[1]}{$re[2]}", 'width:100px') . "</td>\n\t\t\t\t</tr>\t\t\t\t\n\t\t\t</table>"; break; default: $form = "<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td align='right' width=1% nowrap>{pattern}:</strong></td>\n\t\t\t\t<td><textarea name='pattern' rows=3 style='width:100%'>{$line[3]}</textarea>\n\t\t\t</tr>\n\t\t</table>"; break; } $tpl = new templates(); echo $tpl->_ENGINE_parse_body($form); }
function compile_miltergreylist() { $users = new usersMenus(); $tpl = new templates(); $users->LoadModulesEnabled(); $page = CurrentPageName(); $policy = new policydweight(); $policy->SaveConf(); $script = "\n\t<div id='compile_miltergreylist'></div>\n\t<script>\n\t\tChangeStatus(45);\n\t\tLoadAjaxSilent('compile_miltergreylist','{$page}?compile_postfix_save=yes');\n\t</script>\n\t"; if ($users->MILTERGREYLIST_INSTALLED != 1) { echo $tpl->_ENGINE_parse_body("<strong>{APP_MILTERGREYLIST}:</strong> {error_module_not_installed})") . $script; die; } if ($users->MilterGreyListEnabled != 1) { echo $tpl->_ENGINE_parse_body("<strong>{APP_MILTERGREYLIST}:</strong> {error_module_not_enabled})") . $script; die; } $milter = new milter_greylist(); $milter->SaveToLdap(); echo $tpl->_ENGINE_parse_body("<br><strong>{APP_MILTERGREYLIST}:</strong>{apply config} {success}") . $script; }
function BackToDNSBLDefault() { $mil = new milter_greylist(); unset($mil->dnsrbl_array); $mil->SaveToLdap(); echo main_dnsrbl_list(); }
function compile_miltergreylist() { $users = new usersMenus(); $tpl = new templates(); $users->LoadModulesEnabled(); $policy = new policydweight(); $policy->SaveConf(); if ($users->MILTERGREYLIST_INSTALLED != 1) { echo $tpl->_ENGINE_parse_body("<strong>{APP_MILTERGREYLIST}:</strong> {error_module_not_installed})"); die; } if ($users->MilterGreyListEnabled != 1) { echo $tpl->_ENGINE_parse_body("<strong>{APP_MILTERGREYLIST}:</strong> {error_module_not_enabled})"); die; } $milter = new milter_greylist(); $milter->SaveToLdap(); echo $tpl->_ENGINE_parse_body("<br><strong>{APP_MILTERGREYLIST}:</strong>{apply config} {success}"); }
function AddPeerMX() { $mgrey = new milter_greylist(false, $_POST["hostname"], $_POST["ou"]); $mgrey->main_array["peer"][$_POST["AddPeerMX"]] = $_POST["AddPeerMX"]; $mgrey->SaveToLdap(); }
function RebuildModules() { $tpl = new templates(); $artica = new artica_general(); $artica->ArticaFilterEnabled = 0; $user = new usersMenus(); if ($user->kas_installed) { $artica->KasxFilterEnabled = 1; echo $tpl->_ENGINE_parse_body('kaspersky anti-spam {added}<br>'); } if ($user->MAILFROMD_INSTALLED) { $artica->MailFromdEnabled = 1; $mailfromd = new mailfromd(); $mailfromd->SaveToLdap(); $mailfromd->SaveToServer(); echo $tpl->_ENGINE_parse_body('mailfromd {added}<br>'); } $artica->AmavisFilterEnabled = 0; if ($user->KAV_MILTER_INSTALLED) { $milter = new kavmilterd(); $milter->milter_enabled = 'yes'; $milter->SaveToLdap(); $milter->SaveRuleToLdap(); echo $tpl->_ENGINE_parse_body('kaspersky anti-virus {added}<br>'); } $artica->Save(); $grey = new sqlgrey(); $grey->SqlGreyEnabled = 0; $grey->SaveToLdap(); if ($user->MILTERGREYLIST_INSTALLED) { echo $tpl->_ENGINE_parse_body('milter-greylist {added}<br>'); $grey = new milter_greylist(); $grey->MilterGreyListEnabled = "TRUE"; $grey->SaveToLdap(); } }
function MultiplesInstances($hostname=null,$ou=null){ if(($ou==null) && ($hostname==null)){MultiplesInstancesFound();return;} if($ou==null){echo __FUNCTION__." unable to get ou name\n";return;} if($hostname==null){echo __FUNCTION__." unable to get hostname name\n";return;} $mg=new milter_greylist(false,$hostname,$ou); $datas=$mg->BuildConfig(); @mkdir("/etc/milter-greylist/$hostname",0666,true); @mkdir("/var/spool/$hostname/run/milter-greylist",0666,true); $tbl=explode("\n",$datas); while (list ($num, $ligne) = each ($tbl) ){ $ligne=trim($ligne); if($ligne==null){continue;} $newf[]=$ligne; } $newf[]=""; echo "Starting......: writing $conf_path\n"; $datas=@implode("\n",$newf); @file_put_contents("/etc/milter-greylist/$hostname/greylist.conf",$datas); echo "Starting......: milter-greylist $hostname or=$ou START_ONLY={$GLOBALS["START_ONLY"]},STOP_ONLY={$GLOBALS["STOP_ONLY"]}\n"; if($GLOBALS["STOP_ONLY"]==1){MultiplesInstances_stop($hostname,$ou);} if($GLOBALS["START_ONLY"]==1){MultiplesInstances_start($hostname,$ou);} }