function restrict_relay_domains() { @file_put_contents("/etc/postfix/relay_domains_restricted", "\n"); $ldap = new clladp(); $q = new mysql(); $f = array(); $relaysdomains = $ldap->hash_get_relay_domains(); $main = new maincf_multi("master", "master"); $relay_domains_restricted = $main->relay_domains_restricted(); echo "Starting......: " . date("H:i:s") . " Postfix " . count($relay_domains_restricted) . " restricted defined domains\n"; if (count($relaysdomains) > 0) { while (list($domain, $ligne) = each($relaysdomains)) { if (preg_match("#^@(.+)#", $domain, $re)) { $domain = $re[1]; } if (!isset($relay_domains_restricted[$domain])) { continue; } $f[] = "{$domain}\tartica_restrict_relay_domains"; echo "Starting......: " . date("H:i:s") . " Postfix `{$domain}` will be restricted\n"; } } echo "Starting......: " . date("H:i:s") . " Postfix " . count($f) . " restricted relayed domains\n"; @file_put_contents("/etc/postfix/relay_domains_restricted", implode("\n", $f)); shell_exec("{$GLOBALS["postmap"]} hash:/etc/postfix/relay_domains_restricted >/dev/null 2>&1"); }
function RelayDomainsTable($echo=0){ $ldap=new clladp(); $hash=$ldap->hash_get_relay_domains(); //$add_routing_relay_domain_rule=Paragraphe("routing-domain-relay.png","{add_routing_relay_domain_rule}","{add_routing_relay_domain_rule}","PostfixAddRelayTable()"); $html=" <div style='text-align:right;margin:5px;margin-top:0px'>". button("{add_routing_relay_domain_rule}","PostfixAddRelayTable()")."</div> <table style='width:99%;padding:5px;border:2px solid #8E8785;' align='center' class=table_form> <tr style='background-color:#CCCCCC'> <th style='font-size:12px'> </th> <th style='font-size:12px'><strong>{domain}</strong></th> <th style='font-size:12px'><strong> </strong></th> <th align='center' style='font-size:12px'><strong>-</strong></th> <th style='font-size:12px'><strong>-</strong></td> <th align='center' style='font-size:12px'><strong>-</strong></th> <th align='center' style='font-size:12px'><strong-</strong></th> <th style='font-size:12px'> </th> </tr>"; if(is_array($hash)){ while (list ($domain, $ligne) = each ($hash) ){ $delete=imgtootltip("ed_delete.gif",'{delete}',"PostfixDeleteRelayDomain('$domain')"); if($domain=="localhost.localdomain"){$delete=" ";} $html=$html . "<tr> <td width=1%><img src='img/internet.png'></td> <td style='font-size:13px'><code>$domain</a></strong></code></td> <td width=1%><img src='img/fw_bold.gif'></td> <td align='center' style='font-size:12px'>{relay}</td> <td ><code></td> <td align='center' style='font-size:12px'><code></code></td> <td align='center' style='font-size:12px'><code></code></td> <td align='center' style='font-size:12px' width=1%>$delete</td> </tr>"; } } $html=$html . "</table>"; $html=RoundedLightWhite("<div style='width:99%;height:350px;overflow:auto' id='routing-table'>$html</div>"); $tpl=new templates(); if($echo==1){echo $tpl->_ENGINE_parse_body($html);exit;} return $tpl->_ENGINE_parse_body($html); }
function restrict_relay_domains() { $ldap = new clladp(); $f = array(); $dn = "dc=organizations,{$ldap->suffix}"; $attr = array("cn"); $pattern = "(&(objectclass=PostfixRelayRecipientMaps)(cn=@*))"; $sr = @ldap_search($ldap->ldap_connection, $dn, $pattern, $attr); $hash = ldap_get_entries($ldap->ldap_connection, $sr); $relaysdomains = $ldap->hash_get_relay_domains(); if ($GLOBALS["postmap"] == null) { $unix = new unix(); $GLOBALS["postmap"] = $unix->find_program("postmap"); } for ($i = 0; $i < $hash["count"]; $i++) { $domain = $hash[$i]["cn"][0]; if (preg_match("#^@(.+)#", $domain, $re)) { $domain = $re[1]; } unset($relaysdomains[$domain]); } unset($relaysdomains["localhost.localdomain"]); if (is_array($relaysdomains)) { while (list($num, $ligne) = each($relaysdomains)) { $f[] = "{$num}\tartica_restrict_relay_domains"; } } echo "Starting......: Postfix " . count($f) . " restricted relayed domains\n"; @file_put_contents("/etc/postfix/relay_domains_restricted", implode("\n", $f)); shell_exec("{$GLOBALS["postmap"]} hash:/etc/postfix/relay_domains_restricted >/dev/null 2>&1"); }