Esempio n. 1
0
function save()
{
    $email = $_GET["luser_relay"];
    $ldap = new clladp();
    $users = new usersMenus();
    $mustcheck = false;
    if ($users->cyrus_imapd_installed) {
        $mustcheck = true;
    }
    if ($users->ZARAFA_INSTALLED) {
        $mustcheck = true;
    }
    if (preg_match("#^@(.+)#", $email, $re)) {
        $mustcheck = false;
        $email = null;
    }
    if ($mustcheck) {
        $ldap = new clladp();
        $uid = $ldap->uid_from_email($email);
        if ($uid == null) {
            $tpl = new templates();
            echo $tpl->javascript_parse_text("\n{$email}\n{mailbox_does_not_exists}");
            return;
        }
    }
    $sock = new sockets();
    $sock->SET_INFO("luser_relay", $email);
    $sock->getFrameWork("cmd.php?postfix-luser-relay=yes");
}
Esempio n. 2
0
function WhiteListSender()
{
    $sql = "SELECT mail_from,mail_to from messages WHERE zMD5=\"{$_GET["id"]}\"";
    $result = QUERY_SQL($sql);
    $ligne = @sqlite3_fetch_array(QUERY_SQL($sql));
    $mail_from = $ligne["mail_from"];
    if ($mail_from == null) {
        SinglePage(ParseLogs("ERROR\n"));
        exit;
    }
    $ldap = new clladp();
    $upd["KasperkyASDatasAllow"] = $mail_from;
    $uid = $ldap->uid_from_email($ligne["mail_to"]);
    if ($uid == null) {
        SinglePage(ParseLogs("ERROR\n"));
        exit;
    }
    $hash = $ldap->UserDatas($uid);
    $dn = $hash["dn"];
    if (!$ldap->Ldap_add_mod($dn, $upd)) {
        $error = $ldap->ldap_last_error . "\n";
    }
    $sock = new sockets();
    $error = $error . $sock->getfile('releaseallmailfrommd5:' . $_GET["id"]);
    SinglePage(ParseLogs($error));
}
Esempio n. 3
0
function save()
{
    $email = $_GET["postmaster"];
    $ldap = new clladp();
    $users = new usersMenus();
    $mustcheck = false;
    if ($users->cyrus_imapd_installed) {
        $mustcheck = true;
    }
    if ($users->ZARAFA_INSTALLED) {
        $mustcheck = true;
    }
    if ($mustcheck) {
        $ldap = new clladp();
        $uid = $ldap->uid_from_email($email);
        if ($uid == null) {
            $tpl = new templates();
            echo $tpl->javascript_parse_text("\n{$email}\n{mailbox_does_not_exists}");
            return;
        }
    }
    $sock = new sockets();
    $sock->SET_INFO("PostfixPostmaster", $email);
    $sock->getFrameWork("cmd.php?postfix-hash-aliases=yes");
    $sock->getFrameWork("cmd.php?postmaster-cron=yes");
}
Esempio n. 4
0
function archive_process_copyto($file, $realmailfrom, $realmailto)
{
    $dests = array();
    $ldap = new clladp();
    if (!isset($GLOBALS["uidfrom"][$realmailfrom])) {
        $GLOBALS["uidfrom"][$realmailfrom] = $ldap->uid_from_email($realmailfrom);
    }
    if (!archive_process_copytorule($GLOBALS["uidfrom"][$realmailfrom], "out", $file, $realmailfrom)) {
        return false;
    }
    $f = explode("\r\n", @file_get_contents($file));
    while (list($index, $line) = each($f)) {
        if (preg_match("#X-REAL-RCPTTO.*?:(.+)#", $line, $re)) {
            $email = trim($re[1]);
            $email = str_replace(">", "", $email);
            $email = str_replace("<", "", $email);
            $email = trim(strtolower($email));
            events("Recipient Detected: from=<{$realmailfrom}> to=<{$email}>", __LINE__);
            $dests[] = $email;
            if (preg_match("#subject.*?:#i", $line)) {
                break;
            }
            if (preg_match("#X-Archive-end#", $line)) {
                break;
            }
        }
    }
    while (list($index, $rcpt) = each($dests)) {
        $rcpt = trim($rcpt);
        if ($rcpt == null) {
            continue;
        }
        if (!isset($GLOBALS["uidfrom"][$rcpt])) {
            $GLOBALS["uidfrom"][$rcpt] = $ldap->uid_from_email($rcpt);
        }
        events("Checks to=<{$rcpt}> ({$GLOBALS["uidfrom"][$rcpt]})", __LINE__);
        if (!archive_process_copytorule($rcpt, "in", $file, $realmailfrom)) {
            return false;
        }
        events("Checks to=<{$GLOBALS["uidfrom"][$rcpt]}> ({$rcpt})", __LINE__);
        if (!archive_process_copytorule($GLOBALS["uidfrom"][$rcpt], "in", $file, $realmailfrom)) {
            return false;
        }
    }
    return true;
}
Esempio n. 5
0
function import_single_file($filepath, $ID, $ou, $localdomain)
{
    writelogs("{$ID}:: importing {$filepath} for {$ou}", __FUNCTION__, __FILE__, __LINE__);
    if ($ou == null) {
        writelogs("{$ID}:: OU IS NULL !!! ", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $GLOBALS["OU"] = $ou;
    $f = explode("\n", @file_get_contents($filepath));
    $ldap = new clladp();
    $count = 0;
    while (list($num, $line) = each($f)) {
        if ($line == null) {
            continue;
        }
        $tbl = explode(";", $line);
        $account = $tbl[0];
        $password = $tbl[1];
        $imap_server = $tbl[2];
        $new_uid = null;
        $uid = null;
        $usessl = 0;
        $zmd5 = md5("{$account}{$imap_server}");
        if (preg_match("#(.+?)@(.+?)\$#", trim($account), $re)) {
            $new_uid = $re[1];
        } else {
            $new_uid = $account;
        }
        writelogs("{$ID}:: local user={$new_uid}@{$localdomain}", __FUNCTION__, __FILE__, __LINE__);
        $uid = $ldap->uid_from_email("{$new_uid}@{$localdomain}");
        if ($uid == null) {
            if (preg_match("#(.+?)@(.+?)\$#", trim($new_uid), $re)) {
                $new_uid = $re[1];
            }
            writelogs("{$ID}:: Add uid=\"{$new_uid}\" ou={$GLOBALS["OU"]} mail={$new_uid}@{$localdomain}", __FUNCTION__, __FILE__, __LINE__);
            $user_uid = new user();
            $user_uid->uid = $new_uid;
            $user_uid->ou = $GLOBALS["OU"];
            $user_uid->password = $password;
            $user_uid->mail = "{$new_uid}@{$localdomain}";
            $user_uid->domainname = $localdomain;
            if (!$user_uid->add_user()) {
                writelogs("{$ID}:: failed to add {$user_uid->uid} in LDAP database", __FUNCTION__, __FILE__, __LINE__);
                continue;
            } else {
                $new_uid = $user_uid->uid;
            }
        } else {
            $new_uid = $uid;
        }
        $count++;
        writelogs("{$ID}:: local uid:{$uid}", __FUNCTION__, __FILE__, __LINE__);
        if (preg_match("#ssl:(.+?)\$#", $imap_server, $re)) {
            $usessl = 1;
            $imap_server = $re[1];
        }
        $sql = "INSERT INTO mbx_migr_users (`zmd5`,`mbx_migr_id`,`ou`, `imap_server`,`usessl`,`username`,`password`,`uid`)\n\t\tVALUES('{$zmd5}','{$ID}','{$GLOBALS["OU"]}','{$imap_server}','{$usessl}','{$account}','{$password}','{$new_uid}')";
        writelogs("{$ID}:: \"{$sql}\"", __FUNCTION__, __FILE__, __LINE__);
        $q = new mysql();
        $q->QUERY_SQL($sql, "artica_backup");
        if (!$q->ok) {
            writelogs("{$ID}:: {$q->mysql_error} \"{$sql}\"", __FUNCTION__, __FILE__, __LINE__);
        }
    }
    $sql = "UPDATE mbx_migr SET imported=1,members_count={$count} WHERE ID={$ID}";
    $q = new mysql();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        writelogs("{$ID}:: {$q->mysql_error} \"{$sql}\"", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $users = new usersMenus();
    if (!$users->offlineimap_installed) {
        shell_exec("/usr/share/artica-postfix/bin/artica-make APP_OFFLINEIMAP");
    }
    sys_THREAD_COMMAND_SET(LOCATE_PHP5_BIN2() . " " . __FILE__ . " --accounts");
}
Esempio n. 6
0
function BuildQuery()
{
    $users = new usersMenus();
    $ldap = new clladp();
    $tpl = new templates();
    $recipient = $_GET["recipient"];
    if ($_GET["query"] == '*') {
        $_GET["query"] = null;
    }
    writelogs("recipient={$_GET["recipient"]}", __FUNCTION__, __FILE__);
    if ($recipient == null) {
        $recipient = '*';
    }
    if (!$users->AsArticaAdministrator) {
        writelogs("AsArticaAdministrator=FALSE", __FUNCTION__, __FILE__);
        if (strpos(" {$recipient}", '*') == 0) {
            $uid = $ldap->uid_from_email($_GET["recipient"]);
            if ($uid == null) {
                return array(false, $tpl->_ENGINE_parse_body('{error_no_user_exists}'));
            } else {
                $filter1 = "mailto='{$recipient}'";
            }
        } else {
            if (!preg_match('#(.+?)@(.+)#', $recipient, $re)) {
                return array(false, $tpl->_ENGINE_parse_body('{error_bad_recipient_pattern}'));
            }
            $domains = $ldap->hash_get_domains_ou($_GET["ou"]);
            if ($domains[trim($re[2])] == null) {
                return array(false, $tpl->_ENGINE_parse_body('{error_match_recipient_domain}'));
            }
            $re[1] = str_replace('*', '%', $re[1]);
            $filter1 = "mailto LIKE '{$re[1]}@{$re[2]}'";
        }
    }
    if ($users->AsPostfixAdministrator) {
        writelogs("AsArticaAdministrator=TRUE", __FUNCTION__, __FILE__);
        writelogs("recipient={$_GET["recipient"]}", __FUNCTION__, __FILE__);
        if (strpos(" {$recipient}", '*') > 0) {
            $_GET["recipient"] = str_replace('*', '%', $_GET["recipient"]);
            $filter1 = "mailto LIKE '{$_GET["recipient"]}'";
            writelogs("filter={$filter1}", __FUNCTION__, __FILE__);
        } else {
            $filter1 = "mailto='{$_GET["recipient"]}'";
        }
    }
    if ($_GET["limit"] == null) {
        $limit = 0;
    }
    if ($_GET["query"] != null) {
        $field2 = ",MessageBody,MATCH (MessageBody) AGAINST ('{$_GET["query"]}') AS pertinence";
        $ORDER2 = ",pertinence DESC ";
    }
    if ($filter1 == "mailto LIKE ''") {
        $domains = $ldap->hash_get_domains_ou($_GET["ou"]);
        while (list($num, $ligne) = each($domains)) {
            $dd[] = "(mailto LIKE '%{$num}')";
        }
        $filter1 = "(" . implode("OR ", $dd) . ")";
    }
    $limit = $_GET["next"] * 100;
    $sql = "SELECT \n\t\t MessageID,\n\t\t MessageBody,\n\t\t zDate,\n\t\t mailfrom,\n\t\t subject,\n\t\t mailto\n\t\t {$field2}\n\t\t\tFROM `quarantine` WHERE 1\n\t\t\tAND {$filter1}\n\t\t\tORDER BY zDate DESC {$ORDER2} LIMIT {$limit},100";
    writelogs($sql, __FUNCTION__, __FILE__);
    return array(true, $sql);
}
Esempio n. 7
0
function GROUP_MAILING_LIST()
{
    $ou = $_GET["LoadMailingList"];
    $group = new groups(null);
    $hash = $group->load_MailingList($ou);
    $html = "\n\t<input type='hidden' id='RemoveMailingList_text' value='{RemoveMailingList_text}'>\n\t<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:99%'>\n\t<thead class='thead'>\n\t\t<tr>\n\t\t<th width=99% colspan=3>{mailing_list}</th>\n\t\t</tr>\n\t</thead>\n\t<tbody class='tbody'>";
    while (list($num, $ligne) = each($hash)) {
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $ldap = new clladp();
        $uid = $ldap->uid_from_email($num);
        $js = MEMBER_JS($uid, 1);
        $delete = "RemoveMailingList('{$ou}','{$num}');";
        $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t<td width=1%>" . imgtootltip('24-mailinglist.png', '{select}', $js) . "</td>\n\t\t<td><strong style='font-size:14px'><a href='#' OnClick=\"{$js}\">{$num} ({$ligne} {members})</a></strong></td>\n\t\t<td width=1%>" . imgtootltip('delete-32.png', '{delete}', $delete) . "</td>\n\t\t</tr>\n\t\t\n\t";
    }
    $html = $html . "</table>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
Esempio n. 8
0
function AddAliases()
{
    $ldap = new clladp();
    $tpl = new templates();
    $_GET["aliase"] = trim($_GET["aliase"]);
    $_GET["aliase"] = str_replace(" ", "", $_GET["aliase"]);
    writelogs("Adding a new alias \"{$_GET["aliase"]}\" for uid={$_GET["AddAliases"]}", __FUNCTION__, __FILE__, __LINE__);
    $uid = $ldap->uid_from_email($_GET["aliase"]);
    writelogs("\"{$_GET["aliase"]}\"=\"{$uid}\"", __FUNCTION__, __FILE__, __LINE__);
    if (trim($uid) != null) {
        writelogs("Error, this email already exists", __FUNCTION__, __FILE__, __LINE__);
        echo $tpl->javascript_parse_text("{error_alias_exists}\n{owner}:{$uid}", 1);
        exit;
    }
    writelogs("OK, this email did not exists", __FUNCTION__, __FILE__, __LINE__);
    $user = new user($_GET["AddAliases"]);
    if (substr($_GET["aliase"], 0, 1) == '*') {
        $_GET["aliase"] = str_replace('*', '', $_GET["aliase"]);
    } else {
        if (!$user->isEmailValid($_GET["aliase"])) {
            writelogs("Error, this email is invalid", __FUNCTION__, __FILE__, __LINE__);
            echo $tpl->_ENGINE_parse_body('{error_email_invalid}');
            exit;
        }
    }
    writelogs("OK, this {$_GET["aliase"]} email is valid add it for uid={$user->uid}", __FUNCTION__, __FILE__, __LINE__);
    if (!$user->add_alias($_GET["aliase"])) {
        writelogs("Error, LDAP DATABASE {$user->ldap_error}", __FUNCTION__, __FILE__, __LINE__);
        echo $user->ldap_error;
        exit;
    }
}
Esempio n. 9
0
<?php

header("Content-Type:text/xml");
include_once 'ressources/class.templates.inc';
include_once 'ressources/class.ldap.inc';
include_once 'ressources/class.users.menus.inc';
include_once 'ressources/class.main_cf.inc';
$emailaddress = $_GET["emailaddress"];
$tr = explode("@", $emailaddress);
$domain = $tr[1];
$users = new user();
$ldap = new clladp();
$uid = $ldap->uid_from_email($emailaddress);
$f[] = "<?xml version=\"1.0\"?>";
$f[] = "<clientConfig version=\"1.1\">";
$f[] = "    <emailProvider id=\"example.com\">";
$f[] = "      <domain>{$domain}</domain>";
$f[] = "";
$f[] = "      <displayName>{$uid} Mail</displayName>";
$f[] = "      <displayShortName>{$uid}</displayShortName>";
$f[] = "";
$f[] = "      <incomingServer type=\"imap\">";
$f[] = "         <hostname>pop.example.com</hostname>";
$f[] = "         <port>143</port>";
$f[] = "         <socketType>SSL</socketType>";
$f[] = "           <!-- \"plain\": no encryption";
$f[] = "                \"SSL\": SSL 3 or TLS 1 on SSL-specific port";
$f[] = "                \"STARTTLS\": on normal plain port and mandatory upgrade to TLS via STARTTLS";
$f[] = "                -->";
$f[] = "         <username>{$uid}</username>";
$f[] = "            <!-- \"password-cleartext\",";
Esempio n. 10
0
function wbl_robots_quar_add()
{
    if (!isset($_GET["ou"])) {
        die('No organization');
    }
    $ou = $_GET["ou"];
    $users = new usersMenus();
    if ($users->AllowEditOuSecurity == false) {
        $tpl = new templates();
        $error = "\n{ERROR_NO_PRIVS}\n";
        echo $tpl->_ENGINE_parse_body($error);
        die;
    }
    if (preg_match("#^(.+?)@(.+?)@(.+)#", $_GET["AddQuarantineRobot"], $re)) {
        $_GET["AddQuarantineRobot"] = "{$re[1]}@{$re[3]}";
    }
    $ldap = new clladp();
    if ($ldap->uid_from_email($_GET["AddQuarantineRobot"]) != null) {
        $tpl = new templates();
        echo $tpl->_ENGINE_parse_body("{error_alias_exists}");
        die;
    }
    if (!Buildn($ou)) {
        return false;
    }
    $dn = "cn={$_GET["AddQuarantineRobot"]},cn=whitelists,cn={$ou},cn=PostfixRobots,cn=artica,{$ldap->suffix}";
    if (!$ldap->ExistsDN($dn)) {
        $upd['objectClass'][1] = 'top';
        $upd['objectClass'][0] = 'transportTable';
        $upd['cn'][0] = "{$_GET["AddQuarantineRobot"]}";
        $upd["transport"] = "artica-reportquar:{$_GET["AddQuarantineRobot"]}";
        if (!$ldap->ldap_add($dn, $upd)) {
            echo $ldap->ldap_last_error;
            return;
        }
        unset($upd);
    }
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?postfix-hash-tables=yes");
}
Esempio n. 11
0
function catchall_save()
{
    $ou = $_GET["ou"];
    $domain = $_GET["domain"];
    $ldap = new clladp();
    if (trim($_GET["catch-all-addr"]) == null) {
        $dn = "cn=@{$domain},cn={$ou},cn=catch-all,cn=artica,{$ldap->suffix}";
        if ($ldap->ExistsDN($dn)) {
            $ldap->ldap_delete($dn);
            return null;
        }
    }
    $email = $_GET["catch-all-addr"] . "@{$domain}";
    $tpl = new templates();
    $uid = $ldap->uid_from_email($email);
    if ($uid == null) {
        echo $tpl->_ENGINE_parse_body('{error_no_user_exists}');
        return null;
    }
    $ct = new user($uid);
    if ($ct->ou != $ou) {
        echo $tpl->_ENGINE_parse_body('{error_no_user_exists}');
        return null;
    }
    $dn = "cn=catch-all,cn=artica,{$ldap->suffix}";
    if (!$ldap->ExistsDN($dn)) {
        if (!$ldap->ExistsDN($dn)) {
            $upd['cn'][0] = "catch-all";
            $upd['objectClass'][0] = 'PostFixStructuralClass';
            $upd['objectClass'][1] = 'top';
            if (!$ldap->ldap_add($dn, $upd)) {
                echo $ldap->ldap_last_error;
                return null;
            }
            unset($upd);
        }
    }
    $dn = "cn={$ou},cn=catch-all,cn=artica,{$ldap->suffix}";
    if (!$ldap->ExistsDN($dn)) {
        if (!$ldap->ExistsDN($dn)) {
            $upd['cn'][0] = "{$ou}";
            $upd['objectClass'][0] = 'PostFixStructuralClass';
            $upd['objectClass'][1] = 'top';
            if (!$ldap->ldap_add($dn, $upd)) {
                echo $ldap->ldap_last_error;
                return null;
            }
            unset($upd);
        }
    }
    $dn = "cn=@{$domain},cn={$ou},cn=catch-all,cn=artica,{$ldap->suffix}";
    if (!$ldap->ExistsDN($dn)) {
        if (!$ldap->ExistsDN($dn)) {
            $upd['cn'][0] = "@{$domain}";
            $upd['objectClass'][0] = 'AdditionalPostfixMaps';
            $upd['objectClass'][1] = 'top';
            $upd['CatchAllPostfixAddr'][0] = "{$email}";
            if (!$ldap->ldap_add($dn, $upd)) {
                echo $ldap->ldap_last_error;
                return null;
            }
            unset($upd);
        }
    }
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?postfix-hash-aliases=yes");
}
Esempio n. 12
0
function list_save()
{
    $listname = $_GET["listname"];
    $admin_email = $_GET["admin_email"];
    $tpl = new templates();
    if ($_SESSION["uid"] == -100) {
        echo "ok\n";
        $ou_q = base64_decode($_GET["ou"]);
    } else {
        $ct = new user($_SESSION["uid"]);
        $ou_q = $ct->ou;
    }
    $ldap = new clladp();
    $uid = $ldap->uid_from_email($admin_email);
    if ($uid == null) {
        echo $tpl->_ENGINE_parse_body("{$admin_email}:{mailman_admin_not_exists}");
        exit;
    }
    $ct = new user($uid);
    $listuid = $ldap->uid_from_email("{$listname}@{$domain}");
    if ($listuid != null) {
        echo $tpl->_ENGINE_parse_body("{account_already_exists}:{$listname}@{$domain}");
        exit;
    }
    if ($_GET["webservername"] == null) {
        echo $tpl->_ENGINE_parse_body("{www_server_name}:NULL !");
        exit;
    }
    $apache = new vhosts();
    $array = $apache->SearchHosts($_GET["webservername"] . '.' . $_GET["webservername_domain"]);
    if ($array["apacheservername"] != null) {
        echo $tpl->_ENGINE_parse_body($_GET["webservername"] . '.' . $_GET["webservername_domain"] . " {error_domain_exists}");
        exit;
    }
    $admin_password = $_GET["admin_password"];
    $domain = $_GET["domain"];
    $mailman = new mailman_control($ou_q);
    $mailman->list_name = $listname;
    $mailman->list_domain = $domain;
    $mailman->admin_email = $admin_email;
    $mailman->admin_password = $_GET["admin_password"];
    $mailman->webservername = $_GET["webservername"] . '.' . $_GET["webservername_domain"];
    if ($mailman->EditList()) {
    }
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?syncro-mailman=yes");
}
Esempio n. 13
0
function CreateThisUser($email)
{
    if (!preg_match("#(.+?)@(.+)#", $email, $re)) {
        return null;
    }
    $domain = $re[2];
    $uid = $re[1];
    $ldap = new clladp();
    $ou = $ldap->ou_by_smtp_domain($domain);
    if ($ou == null) {
        write_syslog("CreateThisUser():: Unable to detect organization by domain \"{$domain}\"", __FILE__);
        return null;
    }
    $ct = new user($uid);
    $ct->ou = $ou;
    $ct->mail = $email;
    $ct->uid = $uid;
    if (!$ct->add_user()) {
        write_syslog("CreateThisUser():: Unable to Create user {$uid} \"{$email}\"", __FILE__);
        return null;
    }
    $uid2 = $ldap->uid_from_email($email);
    write_syslog("CreateThisUser():: new user \"{$uid2}\"", __FILE__);
    return $uid2;
}
Esempio n. 14
0
function popup_addlist()
{
    $tpl = new templates();
    $listname = strtolower($_GET["listname_add"]);
    $domain = $_GET["domain"];
    $adminmail = $_GET["adminmail"];
    $urlhost = $_GET["urlhost"];
    $emailhost = $_GET["emailhost"];
    $ldap = new clladp();
    $uid = $ldap->uid_from_email($adminmail);
    if ($uid == null) {
        echo $tpl->_ENGINE_parse_body("{mailman_admin_not_exists}", 'mailman.lists.php');
    }
    $users = new user($uid);
    $password = $users->password;
    $sock = new sockets();
    $sock->getfile("MailManAddList:{$listname};{$urlhost};{$domain};{$adminmail};{$password}");
}
Esempio n. 15
0
function list_add()
{
    $tpl = new templates();
    $listname = strtolower($_POST["listname_add"]);
    $domain = $_POST["domain"];
    $adminmail = $_POST["adminmail"];
    $urlhost = $_POST["urlhost"];
    $emailhost = $_POST["emailhost"];
    $ldap = new clladp();
    $uid = $ldap->uid_from_email($adminmail);
    if ($uid == null) {
        echo $tpl->javascript_parse_text("{mailman_admin_not_exists}", 'mailman.lists.php');
        return;
    }
    $urlhost = "{$urlhost}.{$domain}";
    if ($emailhost == null) {
        if ($_POST["mangle"] == 0) {
            echo $tpl->javascript_parse_text("{please_fill_subdomain_correctly}");
            return;
        }
    }
    $emailhost = "{$emailhost}.{$domain}";
    if ($_POST["mangle"] == 1) {
        $emailhost = $domain;
    } else {
        if ($emailhost == null) {
            echo $tpl->javascript_parse_text("{unable_to_add_this_domain_conflict}: {$domain}");
            return;
        }
    }
    $mailman = new mailmancontrol($listname);
    $mailman->emailhost = $emailhost;
    $mailman->urlhost = $urlhost;
    $mailman->adminmail = $adminmail;
    $mailman->mangle = $_POST["mangle"];
    $mailman->EditMysqlList();
}
Esempio n. 16
0
function GROUP_MAILING_LIST()
{
    $ou = $_GET["LoadMailingList"];
    $group = new groups(null);
    $hash = $group->load_MailingList($ou);
    $html = "\n\t<input type='hidden' id='RemoveMailingList_text' value='{RemoveMailingList_text}'>\n\t<table style='width:90%' align=\"center\" style='margin-left:50px'>";
    while (list($num, $ligne) = each($hash)) {
        $ldap = new clladp();
        $uid = $ldap->uid_from_email($num);
        $js = MEMBER_JS($uid, 1);
        $delete = "RemoveMailingList('{$ou}','{$num}');";
        $html = $html . "\n\t\t<tr " . CellRollOver() . ">\n\t\t<td width=1%>" . imgtootltip('24-mailinglist.png', '{select}', $js) . "</td>\n\t\t<td><strong>" . texttooltip("{$num} ({$ligne} {members})", "{select}", $js) . "</strong></td>\n\t\t<td width=1%>" . imgtootltip('ed_delete.gif', '{delete}', $delete) . "</td>\n\t\t</tr>\n\t\t\n\t";
    }
    $html = $html . "</table>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body("<h1 style='width:103%'>{mailing_list}</h1>" . RoundedLightWhite($html));
}
Esempio n. 17
0
function CheckOutOfOffice($recipient, $from, $subject)
{
    $ldap = new clladp();
    $uid = $ldap->uid_from_email($recipient);
    if ($uid == null) {
        //events("unknown user $recipient from=<$from>",__FUNCTION__,__LINE__);
        $GLOBALS["uid"][$recipient] = "NO";
        return;
    } else {
        $GLOBALS["uid"][$recipient] = $uid;
    }
    $vacation = $ldap->UserVacation($uid);
    if ($vacation["vacationactive"][0] != "TRUE") {
        if ($GLOBALS["VERBOSE"]) {
            events("from=<{$from}>  <{$recipient}> (uid \"{$uid}\") ", __FUNCTION__, __LINE__);
            events("Vacation is disabled ({$vacation["vacationactive"][0]})", __FUNCTION__, __LINE__);
        }
        return;
    }
    $datefrom = $vacation["vacationstart"][0];
    $dateTo = $vacation["vacationend"][0];
    $DisplayName = $vacation["displayname"][0];
    $vacationinfo = stripslashes($vacation["vacationinfo"][0]);
    $now = time();
    if ($now < $datefrom) {
        events("Vacation not started {$datefrom}", __FUNCTION__, __LINE__);
        return;
    }
    if ($now >= $dateTo) {
        events("Vacation is finished {$dateTo}", __FUNCTION__, __LINE__);
        return;
    }
    $q = new mysql();
    $md5 = md5("{$datefrom}{$dateTo}{$from}{$uid}");
    $date = date('Y-m-d h:i:s');
    $sql = "SELECT zMD5 from OutOfOffice WHERE zMD5='{$md5}' LIMIT 0,1";
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_events"));
    if ($GLOBALS["VERBOSE"]) {
        events("zMD5={$ligne["zMD5"]} \"{$sql}\"", __FUNCTION__, __LINE__);
    }
    if ($ligne["zMD5"] != null) {
        events("Vacation is already sended", __FUNCTION__, __LINE__);
        return;
    }
    $mail = new simplemail();
    $mail->addrecipient($from, $from);
    $mail->addfrom($recipient, $DisplayName);
    $mail->addsubject("Re: {$subject}");
    $disctxt = br2nl($vacationinfo);
    $disctxt = p2nl($disctxt);
    $disctxt = strip_tags($disctxt);
    $disctxt = html_entity_decode($disctxt);
    $mail->text = $disctxt;
    $mail->html = $vacationinfo;
    if ($mail->sendmail()) {
        echo events("Auto-reply sent..", __FUNCTION__, __LINE__);
    } else {
        events("Auto-reply Error:{$mail->error_log}");
        return;
    }
    $sql = "INSERT INTO OutOfOffice (zMD5,uid,zDate,mailfrom) VALUES ('{$md5}','{$uid}',NOW(),'{$from}')";
    $q->QUERY_SQL($sql, "artica_events");
}
Esempio n. 18
0
function autoaccount_submit()
{
    if (!CheckAutousers()) {
        exit;
    }
    $login = $_GET["login"];
    $email = "{$login}@{$_GET["domain"]}";
    $tpl = new templates();
    $ldap = new clladp();
    $uid = $ldap->uid_from_email($email);
    if ($uid != null) {
        echo $tpl->_ENGINE_parse_body('{account_already_exists}');
        exit;
    }
    $ou = $ldap->ou_by_smtp_domain($_GET["domain"]);
    $user = new user();
    $user->DisplayName = $_GET["first_name"] . " " . $_GET["last_name"];
    $user->sn = $_GET["first_name"];
    $user->cn = $_GET["last_name"];
    $user->mail = $email;
    $user->domainname = $_GET["domain"];
    $user->password = $_GET["password"];
    $user->ou = $ou;
    $user->uid = $login;
    if ($user->add_user()) {
        echo $tpl->_ENGINE_parse_body("{success}:{$email}\n");
    } else {
        echo $user->ldap_error;
    }
}
Esempio n. 19
0
function SaveWhiteList()
{
    $tpl = new templates();
    $to = $_GET["recipient"];
    $wbl = $_GET["wbl"];
    $RcptDomain = $_GET["RcptDomain"];
    $from = $_GET["whitelist"];
    if ($to == null) {
        $to = "*@{$RcptDomain}";
    }
    if ($from == null) {
        echo $tpl->_ENGINE_parse_body('{from}: {error_miss_datas}');
        return false;
    }
    if (substr($to, 0, 1) == '@') {
        $domain = substr($to, 1, strlen($to));
    } else {
        if (strpos($to, '@') > 0) {
            $tbl = explode('@', $to);
            $domain = $tbl[1];
        } else {
            $domain = $to;
            $to = "@{$to}";
        }
    }
    $tbl[0] = str_replace("*", "", $tbl[0]);
    $ldap = new clladp();
    $domains = $ldap->hash_get_all_domains();
    if ($domains[$domain] == null) {
        echo $tpl->javascript_parse_text('{recipient}: {error_unknown_domain} ' . $domain);
        return false;
    }
    if ($tbl[0] == null) {
        $ldap->WhiteListsAddDomain($domain, $from, $wbl);
        return true;
    } else {
        $uid = $ldap->uid_from_email($to);
        if ($uid == null) {
            echo $tpl->javascript_parse_text('{recipient}: {error_no_user_exists} ' . $to);
            return false;
        }
        $ldap->WhiteListsAddUser($uid, $from, $wbl);
    }
}
function maillings_table()
{
    if (isset($GLOBALS["maillings_table_exectuted"])) {
        return;
    }
    $GLOBALS["maillings_table_exectuted"] = true;
    $sock = new sockets();
    $MailingListUseLdap = $sock->GET_INFO("MailingListUseLdap");
    if (!is_numeric($MailingListUseLdap)) {
        $MailingListUseLdap = 0;
    }
    if ($MailingListUseLdap == 1) {
        return;
    }
    $ldap = new clladp();
    $filter = "(&(objectClass=MailingAliasesTable)(cn=*))";
    $attrs = array("cn", "MailingListAddress", "MailingListAddressGroup");
    $dn = "dc=organizations,{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $cn = trim($hash[$i]["cn"][0]);
        $MailingListAddressGroup = 0;
        if (isset($hash[$i]["mailinglistaddressgroup"])) {
            $MailingListAddressGroup = $hash[$i]["mailinglistaddressgroup"][0];
        }
        for ($t = 0; $t < $hash[$i]["mailinglistaddress"]["count"]; $t++) {
            $mailinglistaddress_email = repair_addr($hash[$i]["mailinglistaddress"][$t]);
            if ($mailinglistaddress_email == null) {
                continue;
            }
            if ($GLOBALS["DEBUG"]) {
                echo "[" . __LINE__ . "]: maillings_table(): -> \"{$mailinglistaddress_email}\"\n";
            }
            $mailinglistaddress[$mailinglistaddress_email] = $mailinglistaddress_email;
        }
        if ($MailingListAddressGroup == 1) {
            $uid = $ldap->uid_from_email($cn);
            $user = new user($uid);
            $array = $user->MailingGroupsLoadAliases();
            while (list($num, $ligne) = each($array)) {
                $ligne = repair_addr($ligne);
                if (trim($ligne) == null) {
                    continue;
                }
                if ($GLOBALS["DEBUG"]) {
                    echo "[" . __LINE__ . "]: {$uid} -> [{$ligne}]\n";
                }
                $mailinglistaddress[$ligne] = $ligne;
            }
        }
        $final = array();
        if (is_array($mailinglistaddress)) {
            while (list($num, $ligne) = each($mailinglistaddress)) {
                $num = repair_addr($num);
                if ($num == null) {
                    continue;
                }
                $final[] = $num;
            }
            if ($GLOBALS["DEBUG"]) {
                echo "[" . __LINE__ . "]: maillings_table(): {$cn} = " . implode(",", $final) . "\n";
            }
            if (count($final) > 0) {
                $cn = trim($cn);
                $cn = str_replace("\n", "", $cn);
                $cn = str_replace("\r", "", $cn);
                if ($cn == null) {
                    continue;
                }
                $GLOBALS["virtual_alias_maps_emailing"][$cn] = "{$cn}\t" . implode(",", $final);
            }
        }
        unset($final);
        unset($mailinglistaddress);
        $MailingListAddressGroup = 0;
    }
    $filter = "(&(objectClass=ArticaMailManRobots)(cn=*))";
    $attrs = array("cn", "MailManAliasPath");
    $dn = "dc=organizations,{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    $sock = new sockets();
    if ($sock->GET_INFO("MailManEnabled") == 1) {
        $GLOBALS["MAILMAN"] = true;
    } else {
        $GLOBALS["MAILMAN"] = false;
        return;
    }
    if ($hash["count"] > 0) {
        $GLOBALS["MAILMAN"] = true;
    } else {
        $GLOBALS["MAILMAN"] = false;
    }
}
function transport_maps_search()
{
    $ldap = new clladp();
    $filter = "(&(objectClass=transportTable)(cn=*))";
    $attrs = array("cn", "transport");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $domain = $hash[$i]["cn"][0];
        $transport = $hash[$i]["transport"][0];
        //$transport=str_replace("relay:","smtp:",$transport);
        if (substr($domain, 0, 1) == "@") {
            $domain = substr($domain, 1, strlen($domain));
        }
        if (!$GLOBALS["transport_mem"]["{$domain}"]) {
            $GLOBALS["transport_maps"]["{$domain}"] = "{$transport}";
        }
        if (strpos("  {$domain}", "@") == 0) {
            $domain = "@{$domain}";
        }
        if (!$GLOBALS["transport_mem"]["{$domain}"]) {
            $GLOBALS["transport_maps_AT"]["{$domain}"] = "{$transport}";
        }
        $GLOBALS["transport_mem"]["{$domain}"] = true;
    }
    $dn = "cn=artica_smtp_sync,cn=artica,{$ldap->suffix}";
    $filter = "(&(objectClass=InternalRecipients)(cn=*))";
    $attrs = array("cn", "ArticaSMTPSenderTable");
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $email = $hash[$i]["cn"][0];
        $transport = $hash[$i][strtolower("ArticaSMTPSenderTable")][0];
        $uid = $ldap->uid_from_email($email);
        if ($uid != null) {
            continue;
        }
        if (!$GLOBALS["transport_mem"]["{$email}"]) {
            $GLOBALS["transport_maps"]["{$email}"] = "{$transport}";
        }
        $GLOBALS["transport_mem"]["{$email}"] = true;
    }
}
Esempio n. 22
0
function PopulateUser($from){
	$ldap=new clladp();
	$uid=$ldap->uid_from_email($from);
	if($uid==null){
		events("<$from> uid:$uid",__FUNCTION__,__LINE__);
		$GLOBALS["INTERNAL_FROM"][$from]["uid"]=null;
		$GLOBALS["INTERNAL_FROM"][$from]["MaxMailsDay"]=0;
		$GLOBALS["INTERNAL_FROM"][$from]["MaxMailDaySize"]=0;
		$GLOBALS["INTERNAL_FROM"][$from]["OnlyNotify"]=0;
		return;
	}
	events("<$from> uid:$uid",__FUNCTION__,__LINE__);
	$sql="SELECT * FROM postfix_sender_quotas WHERE uid='$uid'";
	if($GLOBALS["DebugArticaFilter"]==1){events("$sql",__FUNCTION__,__LINE__);}
	$q=new mysql();
	$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,'artica_backup'));
	if(!$q->ok){events("$q->mysql_error",__FUNCTION__,__LINE__);}
	$MaxMailsDay=$ligne["MaxMailsDay"];
	$MaxMailDaySize=$ligne["MaxMailDaySize"];
	$OnlyNotify=$ligne["OnlyNotify"];
	if($MaxMailsDay==null){$MaxMailsDay=0;}
	if($MaxMailDaySize==null){$MaxMailDaySize=0;}
	if($OnlyNotify==null){$OnlyNotify=1;}
	if($MaxMailDaySize>0){$MaxMailDaySize=$MaxMailDaySize*1024;$MaxMailDaySize=$MaxMailDaySize*1000;}
	$GLOBALS["INTERNAL_FROM"][$from]["uid"]=$uid;
	$GLOBALS["INTERNAL_FROM"][$uid]["MaxMailsDay"]=$MaxMailsDay;
	$GLOBALS["INTERNAL_FROM"][$uid]["MaxMailDaySize"]=$MaxMailDaySize;
	$GLOBALS["INTERNAL_FROM"][$uid]["OnlyNotify"]=$OnlyNotify;		
	}
Esempio n. 23
0
function ChangeFetchMailUser()
{
    if ($_GET["ChangeFetchMailUser"] == "*") {
        return null;
    }
    $ldap = new clladp();
    $uid = $ldap->uid_from_email($_GET["ChangeFetchMailUser"]);
    if (trim($uid) == null) {
        $tpl = new templates();
        echo $tpl->_ENGINE_parse_body("\n{$_GET["ChangeFetchMailUser"]}\n*****************\n{error_no_user_exists}");
    }
}
Esempio n. 24
0
function transport_maps_search()
{
    $ldap = new clladp();
    $unix = new unix();
    $sock = new sockets();
    $PostfixLocalDomainToRemote = $sock->GET_INFO("PostfixLocalDomainToRemote");
    if (!is_numeric($PostfixLocalDomainToRemote)) {
        $PostfixLocalDomainToRemote = 0;
    }
    $PostfixLocalDomainToRemoteAddr = $sock->GET_INFO("PostfixLocalDomainToRemoteAddr");
    if (!isset($GLOBALS["REMOTE_SMTP_LDAPDB_ROUTING"])) {
        $GLOBALS["REMOTE_SMTP_LDAPDB_ROUTING"] = array();
    }
    //----------------------------------------------------------------------------------------------------------
    $filter = "(&(objectClass=transportTable)(cn=*))";
    $attrs = array("cn", "transport");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $domain = $hash[$i]["cn"][0];
        $transport = $hash[$i]["transport"][0];
        if (substr($domain, 0, 1) == "@") {
            $domain = substr($domain, 1, strlen($domain));
        }
        if (!$GLOBALS["transport_mem"]["{$domain}"]) {
            $GLOBALS["transport_maps"]["{$domain}"] = "{$transport}";
        }
        if (strpos("  {$domain}", "@") == 0) {
            $domain = "@{$domain}";
        }
        if (!$GLOBALS["transport_mem"]["{$domain}"]) {
            $GLOBALS["transport_maps_AT"]["{$domain}"] = "{$transport}";
        }
        $GLOBALS["transport_mem"]["{$domain}"] = true;
    }
    //----------------------------------------------------------------------------------------------------------
    if ($PostfixLocalDomainToRemote == 1) {
        $filter = "(&(objectClass=organizationalUnit)(associatedDomain=*))";
        $attrs = array("associatedDomain");
        $dn = "{$ldap->suffix}";
        $hash = $ldap->Ldap_search($dn, $filter, $attrs);
        $transport = "smtp:{$PostfixLocalDomainToRemoteAddr}";
        for ($i = 0; $i < $hash["count"]; $i++) {
            for ($t = 0; $t < $hash[$i]["associateddomain"]["count"]; $t++) {
                $domain = $hash[$i][strtolower("associatedDomain")][$t];
                if (substr($domain, 0, 1) == "@") {
                    $domain = substr($domain, 1, strlen($domain));
                }
                if (!$GLOBALS["transport_mem"]["{$domain}"]) {
                    $GLOBALS["transport_maps"]["{$domain}"] = "{$transport}";
                }
                if (strpos("  {$domain}", "@") == 0) {
                    $domain = "@{$domain}";
                }
                if (!$GLOBALS["transport_mem"]["{$domain}"]) {
                    $GLOBALS["transport_maps_AT"]["{$domain}"] = "{$transport}";
                }
                $GLOBALS["transport_mem"]["{$domain}"] = true;
            }
        }
    }
    //----------------------------------------------------------------------------------------------------------
    $t = 0;
    if (count($GLOBALS["REMOTE_SMTP_LDAPDB_ROUTING"]) > 0) {
        while (list($domain, $targeted_ip) = each($GLOBALS["REMOTE_SMTP_LDAPDB_ROUTING"])) {
            $transport = "relay[{$targeted_ip}]:25";
            if (!$GLOBALS["transport_mem"]["@{$domain}"]) {
                $t++;
                $GLOBALS["transport_maps"]["{$domain}"] = "{$transport}";
                $GLOBALS["transport_maps_AT"]["{$domain}"] = "{$transport}";
            }
            $GLOBALS["transport_mem"]["@{$domain}"] = true;
        }
    }
    echo "Starting......: " . date("H:i:s") . " Postfix {$t} routed domains from external sources\n";
    $dn = "cn=artica_smtp_sync,cn=artica,{$ldap->suffix}";
    $filter = "(&(objectClass=InternalRecipients)(cn=*))";
    $attrs = array("cn", "ArticaSMTPSenderTable");
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $email = $hash[$i]["cn"][0];
        $transport = $hash[$i][strtolower("ArticaSMTPSenderTable")][0];
        $uid = $ldap->uid_from_email($email);
        if ($uid != null) {
            continue;
        }
        if (!$GLOBALS["transport_mem"]["{$email}"]) {
            $GLOBALS["transport_maps"]["{$email}"] = "{$transport}";
        }
        $GLOBALS["transport_mem"]["{$email}"] = true;
    }
    $sql = "SELECT *  FROM postfix_transport_recipients WHERE hostname='master' AND enabled=1";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        $unix->send_email_events("Fatal: {$q->mysql_error}", "function:" . __FUNCTION__ . "\nFile:" . __FILE__ . "\nLIne:" . __LINE__, "postfix");
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $email = $ligne["recipient"];
        $transport = $ligne["transport"];
        if (isset($GLOBALS["transport_mem"]["{$email}"])) {
            continue;
        }
        $GLOBALS["transport_maps"]["{$email}"] = "{$transport}";
        $GLOBALS["transport_mem"]["{$email}"] = true;
    }
}
Esempio n. 25
0
function main_fetchmail_build(){
	include_once('ressources/class.user.inc');
	include_once('ressources/class.main_cf.inc');
	include_once('ressources/class.fetchmail.inc');
	
	
$failed=false;	
	
$isp_address_mail=$_GET["isp_address_mail"];
$isp_pop3_server=$_GET["isp_pop3_server"];
$isp_smtp_server=$_GET["isp_smtp_server"];
	
$isp_account=$_GET["isp_account"];
$isp_password=$_GET["isp_password"];
$local_email=$_GET["local_email"];
$local_password=$_GET["local_password"];
	
$isp_smtp_account=$_GET["isp_smtp_account"];
$isp_smtp_password=$_GET["isp_smtp_password"];
	
$relay_server=$_GET["relay_server"];


if($local_email==null){
	echo main_fetchmail_build_results(true,'local mail (False)');
	exit;
}

$ldap=new clladp();
writelogs("i try to found if user exists",__FUNCTION__,__FILE__);
$uid=$ldap->uid_from_email($local_email);
if($uid<>null){
	$user=new user($local_email);
	$ou=$user->ou;
}else{
	writelogs("no user found, create it",__FUNCTION__,__FILE__);
	$tb=explode("@",$local_email);
	$local_domain=$tb[1];  
	$user=new user($tb[0]);
	$ou=$ldap->ou_by_smtp_domain($local_domain);
	if($ou==null){
		$ou=$local_domain;
		writelogs("Adding new organization $ou",__FUNCTION__,__FILE__);
		$ldap->AddOrganization($ou);
	}	
	
}


	
	writelogs("Creating user",__FUNCTION__,__FILE__);
	$user=new user($local_email);
	$user->mail=$local_email;
	$user->password=$local_password;
	$user->ou=$ou;
	$user->SenderCanonical=$isp_address_mail;
	if(!$user->add_user()){
		echo main_fetchmail_build_results(true,$user->ldap_error);
		exit;
	}
	
	
	if($isp_smtp_account<>null){
		writelogs("Creating SMTP authentification for $isp_smtp_server width $isp_smtp_account",__FUNCTION__,__FILE__);
		$sasl=new smtp_sasl_password_maps();
		$sasl->add($isp_address_mail,$isp_smtp_account,$isp_password);
		$main=new main_cf();
		writelogs("Enable sasl engine in postfix",__FUNCTION__,__FILE__);
		$main->smtp_sasl_password_maps_enable_2();		
		
	}
	writelogs("Creating sender_dependent_relayhost_maps -> $isp_smtp_server",__FUNCTION__,__FILE__);
	$sender=new sender_dependent_relayhost_maps();
	if(!$sender->Add($isp_address_mail,$isp_smtp_server)){
		echo main_fetchmail_build_results(true,"sender_dependent_relayhost_maps:$sender->ldap_error");
		exit;
	}
	

	$fetchmail=new Fetchmail_settings();
	$array["poll"]=$isp_pop3_server;
	$array["proto"]="auto";
	$array["keep"]="yes";
	$array["user"]=$isp_account;
	$array["pass"]=$isp_password;
	$array["is"]=$local_email;
	$array["fetchall"]="yes";
	$line=$fetchmail->compile($array);
	if(!$user->fetchmail_add_rule($line)){
		echo main_fetchmail_build_results(true,"fetchmail rule:$user->ldap_error");
		exit;
	}
	
	$relay=new Routing($ou);
	if($relay_server<>null){
		if(!$relay->create_relay_server($local_domain,$relay_server,$ou)){
				echo main_fetchmail_build_results(true,"relay:$relay->ldap_error");
			}
		}else{
			if(!$relay->create_localdomain($ou,$local_domain)){
				echo main_fetchmail_build_results(true,"local domain:$relay->ldap_error");
			}
		}

	
	$fetchmail=new fetchmail();
	$fetchmail->Save();
	$main=new main_cf();
	$main->save_conf();
	$main->save_conf_to_server();
	
	
	
	$info="<table style='width:100%'>
	<tr>
		<td width=1%><img src='img/fw_bold.gif'></td>
		<td nowrap align='right'><strong>{organization}</strong>:</td>
		<td nowrap><strong>$ou</strong></td>
	</tr>
	<tr>
		<td width=1%><img src='img/fw_bold.gif'></td>
		<td nowrap align='right'><strong>{local_mail}</strong>:</td>
		<td nowrap><strong>$local_email</strong></td>
	</tr>
	<tr>
		<td width=1%><img src='img/fw_bold.gif'></td>
		<td nowrap align='right'><strong>{isp_address_mail}</strong>:</td>
		<td nowrap><strong>$isp_address_mail</strong></td>
	</tr>			
	</table>	
	";
	
	echo main_fetchmail_build_results(false,$info);
	
	
}
Esempio n. 26
0
function transport_maps_search()
{
    $ldap = new clladp();
    $filter = "(&(objectClass=transportTable)(cn=*))";
    $attrs = array("cn", "transport");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $domain = $hash[$i]["cn"][0];
        $transport = $hash[$i]["transport"][0];
        //$transport=str_replace("relay:","smtp:",$transport);
        if (substr($domain, 0, 1) == "@") {
            $domain = substr($domain, 1, strlen($domain));
        }
        if (!$GLOBALS["transport_mem"]["{$domain}"]) {
            $GLOBALS["transport_maps"]["{$domain}"] = "{$transport}";
        }
        if (strpos("  {$domain}", "@") == 0) {
            $domain = "@{$domain}";
        }
        if (!$GLOBALS["transport_mem"]["{$domain}"]) {
            $GLOBALS["transport_maps_AT"]["{$domain}"] = "{$transport}";
        }
        $GLOBALS["transport_mem"]["{$domain}"] = true;
    }
    $t = 0;
    if (is_array($GLOBALS["REMOTE_SMTP_LDAPDB_ROUTING"])) {
        while (list($domain, $targeted_ip) = each($GLOBALS["REMOTE_SMTP_LDAPDB_ROUTING"])) {
            $transport = "relay[{$targeted_ip}]:25";
            if (!$GLOBALS["transport_mem"]["@{$domain}"]) {
                $t++;
                $GLOBALS["transport_maps"]["{$domain}"] = "{$transport}";
                $GLOBALS["transport_maps_AT"]["{$domain}"] = "{$transport}";
            }
            $GLOBALS["transport_mem"]["@{$domain}"] = true;
        }
    }
    echo "Starting......: Postfix {$t} routed domains from external sources\n";
    $dn = "cn=artica_smtp_sync,cn=artica,{$ldap->suffix}";
    $filter = "(&(objectClass=InternalRecipients)(cn=*))";
    $attrs = array("cn", "ArticaSMTPSenderTable");
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $email = $hash[$i]["cn"][0];
        $transport = $hash[$i][strtolower("ArticaSMTPSenderTable")][0];
        $uid = $ldap->uid_from_email($email);
        if ($uid != null) {
            continue;
        }
        if (!$GLOBALS["transport_mem"]["{$email}"]) {
            $GLOBALS["transport_maps"]["{$email}"] = "{$transport}";
        }
        $GLOBALS["transport_mem"]["{$email}"] = true;
    }
}