function AddNewRelayDomain() { $ou = $_GET["ou"]; $tpl = new templates(); $relayIP = $_GET["AddNewRelayDomainIP"]; if ($relayIP == "127.0.0.1") { echo $tpl->javascript_parse_text("{NO_RELAY_TO_THIS_SERVER_EXPLAIN}"); return; } $tc = new networking(); $IPSAR = $tc->ALL_IPS_GET_ARRAY(); if (!preg_match("#[0-9]\\.[0-9]+\\.[0-9]+\\.[0-9]+#", $relayIP)) { $ip = gethostbyname($relayIP); while (list($ip1, $ip2) = each($IPSAR)) { if ($relayIP == $ip1) { echo $tpl->javascript_parse_text("{NO_RELAY_TO_THIS_SERVER_EXPLAIN}"); return; } } } else { while (list($ip1, $ip2) = each($IPSAR)) { if ($relayIP == $ip1) { echo $tpl->javascript_parse_text("{NO_RELAY_TO_THIS_SERVER_EXPLAIN}"); return; } } } $relayPort = $_GET["AddNewRelayDomainPort"]; $mx = $_GET["MX"]; $domain_name = trim(strtolower($_GET["AddNewRelayDomainName"])); $ldap = new clladp(); if (!$ldap->UseLdap) { $sqlite = new lib_sqlite(); $sqlite->AddRelayDomain($ou, $domain_name, $relayIP, $relayPort, $mx); if ($sqlite->ok) { ChockServices(); } return; } $tpl = new templates(); $trusted_smtp_domain = $_GET["trusted_smtp_domain"]; $dn = "cn=relay_domains,ou={$ou},dc=organizations,{$ldap->suffix}"; $upd = array(); if (!$ldap->ExistsDN($dn)) { $upd['cn'][0] = "relay_domains"; $upd['objectClass'][0] = 'PostFixStructuralClass'; $upd['objectClass'][1] = 'top'; $ldap->ldap_add($dn, $upd); unset($upd); } $hashdoms = $ldap->hash_get_all_domains(); if ($hashdoms[$domain_name] != null) { echo $tpl->_ENGINE_parse_body('{error_domain_exists}'); exit; } $dn = "cn={$domain_name},cn=relay_domains,ou={$ou},dc=organizations,{$ldap->suffix}"; $upd['cn'][0] = "{$domain_name}"; $upd['objectClass'][0] = 'PostFixRelayDomains'; $upd['objectClass'][1] = 'top'; $ldap->ldap_add($dn, $upd); $dn = "cn=relay_recipient_maps,ou={$ou},dc=organizations,{$ldap->suffix}"; if (!$ldap->ExistsDN($dn)) { $upd['cn'][0] = "relay_recipient_maps"; $upd['objectClass'][0] = 'PostFixStructuralClass'; $upd['objectClass'][1] = 'top'; $ldap->ldap_add($dn, $upd); unset($upd); } if ($trusted_smtp_domain == 0) { $dn = "cn=@{$domain_name},cn=relay_recipient_maps,ou={$ou},dc=organizations,{$ldap->suffix}"; $upd['cn'][0] = "@{$domain_name}"; $upd['objectClass'][0] = 'PostfixRelayRecipientMaps'; $upd['objectClass'][1] = 'top'; $ldap->ldap_add($dn, $upd); } $dn = "cn=transport_map,ou={$ou},dc=organizations,{$ldap->suffix}"; if (!$ldap->ExistsDN($dn)) { $upd['cn'][0] = "transport_map"; $upd['objectClass'][0] = 'PostFixStructuralClass'; $upd['objectClass'][1] = 'top'; $ldap->ldap_add($dn, $upd); unset($upd); } if ($relayIP != null) { if ($mx == "no") { $relayIP = "[{$relayIP}]"; } $dn = "cn={$domain_name},cn=transport_map,ou={$ou},dc=organizations,{$ldap->suffix}"; $upd['cn'][0] = "{$domain_name}"; $upd['objectClass'][0] = 'transportTable'; $upd['objectClass'][1] = 'top'; $upd["transport"][] = "relay:{$relayIP}:{$relayPort}"; $ldap->ldap_add($dn, $upd); } ChockServices(); }
function remotedomain_remove() { $ldap = new clladp(); $domain_name = $_POST["remotedomain-remove"]; $ou = $_POST["ou"]; if ($ou == null) { $ou = $ldap->ou_by_smtp_domain($domain_name); } $ldap = new clladp(); $ldap->DeleteRemoteDomain($domain_name, $ou); ChockServices(); }
function DeleteRelayDomainName() { $ou = $_GET["ou"]; $domain_name = $_GET["DeleteRelayDomainName"]; $ldap = new clladp(); $ldap->DeleteRemoteDomain($domain_name, $ou); ChockServices(); }