function WhiteListed() { $ldap = new clladp(); $unix = new unix(); $SPAMASSASSIN_LOCAL_CF = $unix->SPAMASSASSIN_LOCAL_CF(); $spammassDirectory = dirname($SPAMASSASSIN_LOCAL_CF); $assp = array(); $spamassassin = array(); $miltergrey = array(); $blacks = $ldap->BlackListFromDomain(); if (is_array($blacks)) { while (list($to, $array) = each($blacks)) { $spamassassin[] = "#rcpt :{$to}"; while (list($index, $from) = each($array)) { if ($from == "*@*") { continue; } if (preg_match("#(.+?)@(.+)#", $from, $re)) { $first_part = $re[1]; $domain = $re[2]; } else { $first_part = "*"; $domain = $from; } $domain = str_replace("@", "", $domain); $spamassassin[] = "blacklist_from\t{$first_part}@{$domain}"; } } } echo "Starting......: " . date("H:i:s") . " writing whitelist/blacklists for ASSP\n"; @mkdir("/usr/share/assp/files"); @mkdir("/usr/local/etc"); @file_put_contents("/usr/share/assp/files/whiteorg.txt", implode("\n", $assp)); echo "Starting......: " . date("H:i:s") . " writing whitelist/blacklists for Amavis\n"; $final = implode("\n", $sender_scores_sitewide); $final = $final . "\n"; @file_put_contents("/usr/local/etc/sender_scores_sitewide", $final); @chmod("/usr/local/etc/sender_scores_sitewide", 0644); @chown("/usr/local/etc/sender_scores_sitewide", "postfix"); if (is_file('/usr/local/sbin/amavisd')) { if (is_file('/usr/local/etc/amavisd.conf')) { if (is_file('/var/spool/postfix/var/run/amavisd-new/amavisd-new.pid')) { sys_THREAD_COMMAND_SET('/usr/local/sbin/amavisd -c /usr/local/etc/amavisd.conf -P /var/spool/postfix/var/run/amavisd-new/amavisd-new.pid reload'); } } } echo "Starting......: " . date("H:i:s") . " writing whitelist/blacklists for spamassassin\n"; @file_put_contents("{$spammassDirectory}/wbl.cf", implode("\n", $spamassassin)); }
function blacklistdom($domain = null) { $ldap = new clladp(); if ($domain != null) { $domain = "*"; } $hash = $ldap->BlackListFromDomain($domain); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if ($_POST["query"] != null) { $search = $_POST["query"]; $search = str_replace(".", "\\.", $search); $search = str_replace("*", ".*?", $search); } $c = 0; if (is_array($hash)) { while (list($from, $line) = each($hash)) { $recipient_domain = $from; if (preg_match("#(.+?)@(.+)#", $recipient_domain, $re)) { $recipient_domain = $re[2]; } $ou = $ldap->ou_by_smtp_domain($recipient_domain); while (list($num, $wl) = each($line)) { if ($search != null) { if (!preg_match("#{$search}#", $wl)) { continue; } } $c++; $id = md5("{$from}{$wl}"); $delete = imgsimple("delete-24.png", "{delete}", "DeleteBlackList('{$from}','{$wl}','{$id}');"); $data['rows'][] = array('id' => $id, 'cell' => array("<span style='font-size:14px;color:{$color}'>{$ou}</span>", "<span style='font-size:14px;color:{$color}'>{$wl}</span>", "<span style='font-size:14px;color:{$color}'>{$from}</span>", $delete)); } } } $data['total'] = $c; echo json_encode($data); }
function build_deny_xml($ou, $count) { if ($count < 10) { $numero = "0{$count}"; } else { $numero = $count; } $conf[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; $conf[] = "#include <base/group-deny.xml.macro>"; $conf[] = "BEGIN_GROUP_DENY_EMAIL_LIST(0x000000{$numero})"; $ldap = new clladp(); if ($ldap->ldapFailed) { return null; } $domains = $ldap->hash_get_domains_ou($ou); if (is_array($domains)) { while (list($num, $val) = each($domains)) { $emails = $ldap->BlackListFromDomain($val); while (list($to, $froms) = each($emails)) { while (list($index, $senders) = each($froms)) { $conf[] = "EMAIL_ENTRY(\"{$senders}\")"; } } } } $conf[] = "END_GROUP_DENY_EMAIL_LIST"; $conf[] = ""; @file_put_contents("/usr/local/ap-mailfilter3/conf/def/group/000000{$numero}-deny.xml", @implode("\n", $conf)); }
function WhiteListed() { $ldap = new clladp(); $whites = $ldap->WhitelistsFromDomain(); $unix = new unix(); $unix->miltergreylist_cleanconf(); $SPAMASSASSIN_LOCAL_CF = $unix->SPAMASSASSIN_LOCAL_CF(); $spammassDirectory = dirname($SPAMASSASSIN_LOCAL_CF); $assp = array(); $spamassassin = array(); $miltergrey = array(); if (is_array($whites)) { while (list($to, $array) = each($whites)) { $spamassassin[] = "#rcpt :{$to}"; while (list($index, $from) = each($array)) { if ($from == "*@*") { continue; } if (preg_match("#(.+?)@(.+)#", $from, $re)) { $first_part = $re[1]; $domain = $re[2]; } else { $first_part = "*"; $domain = $from; } $s = "{$first_part}@{$domain}"; $s = str_replace("*@", '', $s); $s = str_replace("@*", '', $s); $asspwbl_string = "{$first_part}@{$domain}"; $asspwbl_string = str_replace('.', '\\.', $asspwbl_string); $asspwbl_string = str_replace('*', '.*?', $asspwbl_string); $assp[] = $asspwbl_string; $sender_scores_sitewide[] = "{$s}\t-7.0"; $spamassassin[] = "whitelist_from\t{$first_part}@{$domain}"; $unix->miltergreylist_addacl($unix->miltergreylist_buildacl("{$first_part}@{$domain}")); } } } $blacks = $ldap->BlackListFromDomain(); if (is_array($blacks)) { while (list($to, $array) = each($blacks)) { $spamassassin[] = "#rcpt :{$to}"; while (list($index, $from) = each($array)) { if ($from == "*@*") { continue; } if (preg_match("#(.+?)@(.+)#", $from, $re)) { $first_part = $re[1]; $domain = $re[2]; } else { $first_part = "*"; $domain = $from; } $spamassassin[] = "blacklist_from\t{$first_part}@{$domain}"; } } } echo "Starting......: writing whitelist/blacklists for ASSP\n"; @mkdir("/usr/share/assp/files"); @mkdir("/usr/local/etc"); @file_put_contents("/usr/share/assp/files/whiteorg.txt", implode("\n", $assp)); echo "Starting......: writing whitelist/blacklists for Amavis\n"; @file_put_contents("/usr/local/etc/sender_scores_sitewide", implode("\n", $sender_scores_sitewide)); @chmod("/usr/local/etc/sender_scores_sitewide", 0750); if (is_file('/usr/local/sbin/amavisd')) { if (is_file('/usr/local/etc/amavisd.conf')) { if (is_file('/var/spool/postfix/var/run/amavisd-new/amavisd-new.pid')) { sys_THREAD_COMMAND_SET('/usr/local/sbin/amavisd -c /usr/local/etc/amavisd.conf -P /var/spool/postfix/var/run/amavisd-new/amavisd-new.pid reload'); } } } echo "Starting......: writing whitelist/blacklists for spamassassin\n"; @file_put_contents("{$spammassDirectory}/wbl.cf", implode("\n", $spamassassin)); }
function blacklistdom($domain=null){ if($domain==null){$domain="*";} $ldap=new clladp(); $hash=$ldap->BlackListFromDomain($domain); $html=" <table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'> <thead class='thead'> <tr> <th colspan=2>{search}:$domain</th> <th>{from}</th> <th>{recipients}</th> <th> </th> </tr> </thead> <tbody class='tbody'>"; if(is_array($hash)){ while (list ($from, $line) = each ($hash)){ $recipient_domain=$from; if(preg_match("#(.+?)@(.+)#",$from,$re)){$recipient_domain=$re[2];} $ou=$ldap->ou_by_smtp_domain($recipient_domain); while (list ($num, $wl) = each ($line)){ if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";} $html=$html . "<tr class=$classtr> <td width=1%><img src='img/fw_bold.gif'></td> <td><strong style='font-size:13px'>$ou</strong></td> <td><strong style='font-size:13px'>$wl</strong> <td><strong style='font-size:13px'>$from</strong></td> <td width=1%>" . imgtootltip('delete-32.png','{delete}',"DeleteBlackList('$from','$wl');")."</td> </tr>";} }} $html=$html . "</table>"; $form=$html; return $form; }
function report_build_black_from_domain($domain) { if ($domain == null) { return null; } $ldap = new clladp(); $hash = $ldap->BlackListFromDomain($domain); if (!is_array($hash)) { return null; } $html = $html . "\n\t\t<hr>\n\t\t<H2 style='font-size:13px'>Deny email addresses (Global)</h2>\n\t\t<table style='width:100%'>"; while (list($email, $array) = each($hash)) { while (list($num, $match) = each($array)) { $html = $html . "\n\t\t\t\t<tr>\n\t\t\t\t<td><strong style='font-size:12px'>From {$match}</td>\n\t\t\t\t<td><strong style='font-size:12px'>To {$email}</td>\n\t\t\t\t<td><div style='width:5px;background-color:#d32d2d'> </div></td>\n\t\t\t\t<td><strong style='font-size:12px'>Deny</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr><td colspan=4><hr></tr>"; } } $html = $html . "</table>"; return $html; }
function blacklistdom($domain = null) { if ($domain == null) { $domain = "*"; } $ldap = new clladp(); $hash = $ldap->BlackListFromDomain($domain); $html = "<H5>{$domain}</H5>\n\t<table style='width:99%' class=table_form>\n\t<tr style='background-color:#CCCCCC'>\n\t\t<td> </td>\n\t\t<td> </td>\n\t\t<td><strong>{recipients}</strong></td>\n\t\t<td><strong>{from}</strong></td>\n\t\t<td> </td>\n\t</tr>"; if (is_array($hash)) { while (list($from, $line) = each($hash)) { $recipient_domain = $from; if (preg_match("#(.+?)@(.+)#", $from, $re)) { $recipient_domain = $re[2]; } $ou = $ldap->ou_by_smtp_domain($recipient_domain); while (list($num, $wl) = each($line)) { $html = $html . "<tr " . CellRollOver() . ">\n\t\t\t\t<td width=1%><img src='img/fw_bold.gif'></td>\n\t\t\t\t<td><strong>{$ou}</strong></td>\n\t\t\t\t<td><strong>{$from}</strong></td>\n\t\t\t\t<td><strong>{$wl}</strong>\n\t\t\t\t<td width=1%>" . imgtootltip('x.gif', '{delete}', "DeleteBlackList('{$from}','{$wl}');") . "</td>\n\t\t\t</tr>"; } } } $html = $html . "</table>"; $form = $html; return $form; }