Exemplo n.º 1
0
function emailAccountsCreateCallback($id)
{
    global $pro_mysql_pop_table;
    global $pro_mysql_list_table;
    global $conf_dtc_system_uid;
    global $conf_dtc_system_gid;
    global $adm_login;
    global $edit_domain;
    global $cyrus_used;
    global $pro_mysql_mailaliasgroup_table;
    global $CYRUS;
    $q = "SELECT * FROM {$pro_mysql_pop_table} WHERE autoinc='{$id}';";
    $r = mysql_query($q) or die("Cannot query {$q} line: " . __LINE__ . " file " . __FILE__ . " sql said:" . mysql_error());
    $n = mysql_num_rows($r);
    if ($n != 1) {
        die("Cannot find created email line " . __LINE__ . " file " . __FILE__);
    }
    $a = mysql_fetch_array($r);
    $test_query = "SELECT * FROM {$pro_mysql_list_table} WHERE name='" . $a["id"] . "' AND domain='{$edit_domain}'";
    $test_result = mysql_query($test_query) or die("Cannot execute query \"{$test_query}\" line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error());
    $testnum_rows = mysql_num_rows($test_result);
    if ($testnum_rows >= 1) {
        $q = "DELETE FROM {$pro_mysql_pop_table} WHERE autoinc='{$id}';";
        $r = mysql_query($q) or die("Cannot query {$q} line: " . __LINE__ . " file " . __FILE__ . " sql said:" . mysql_error());
        return "<font color=\"red\">" . _("Error: a mailing list already exists with this name!") . "</font>";
    }
    $test_query = "SELECT * FROM {$pro_mysql_mailaliasgroup_table} WHERE id='" . $a["id"] . "' AND domain_parent='{$edit_domain}'";
    $test_result = mysql_query($test_query) or die("Cannot execute query \"{$test_query}\" line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error());
    $testnum_rows = mysql_num_rows($test_result);
    if ($testnum_rows >= 1) {
        $q = "DELETE FROM {$pro_mysql_pop_table} WHERE autoinc='{$id}';";
        $r = mysql_query($q) or die("Cannot query {$q} line: " . __LINE__ . " file " . __FILE__ . " sql said:" . mysql_error());
        return "<font color=\"red\">" . _("Error: Email group alias already exists with this name!") . "</font><br />";
    }
    $crypted_pass = crypt($a["passwd"], dtc_makesalt());
    if (!$cyrus_used) {
        writeDotQmailFile($a["id"], $a["mbox_host"]);
    }
    $admin_path = getAdminPath($adm_login);
    $box_path = "{$admin_path}/{$edit_domain}/Mailboxs/" . $a["id"];
    $q = "UPDATE {$pro_mysql_pop_table} SET crypt='{$crypted_pass}',home='{$box_path}',uid='{$conf_dtc_system_uid}',gid='{$conf_dtc_system_gid}',fullemail='" . $a["id"] . '@' . $a["mbox_host"] . "',quota_couriermaildrop=CONCAT(1024000*quota_size,'S,',quota_files,'C') WHERE autoinc='{$id}';";
    $r2 = mysql_query($q) or die("Cannot query {$q} line: " . __LINE__ . " file " . __FILE__ . " sql said:" . mysql_error());
    triggerMXListUpdate();
    if ($cyrus_used) {
        # login to cyradm
        $cyr_conn = new cyradm();
        $error = $cyr_conn->imap_login();
        if ($error != 0) {
            die("imap_login Error {$error}");
        }
        $result = $cyr_conn->createmb("user/" . $a["id"] . "@" . $edit_domain);
        $result = $cyr_conn->createmb("user/" . $a["id"] . "/" . $a["spam_mailbox"] . "@" . $edit_domain);
        $result = $cyr_conn->setacl("user/" . $a["id"] . "@" . $edit_domain, $CYRUS['ADMIN'], "lrswipcda");
        $result = $cyr_conn->setmbquota("user/" . $a["id"] . "@" . $edit_domain, $a["quota_size"]);
    }
    updateUsingCron("gen_qmail='yes', qmail_newu='yes'");
    return "";
}
Exemplo n.º 2
0
#!/usr/bin/env php

<?php 
$base_path = dirname(__FILE__);
if ($_SERVER["argc"] < 1) {
    print "Syntax Error: " . $_SERVER["argv"][0] . " <root domain>\n";
    exit;
}
$root_domain = $_SERVER["argv"][1];
require $base_path . '/../../shared/cyradm.php';
require $base_path . '/../../shared/cyrus.php';
# login to cyradm
$cyr_conn = new cyradm();
$error = $cyr_conn->imap_login();
if ($error != 0) {
    die("imap_login Error {$error}");
}
$result = $cyr_conn->createmb("user/root" . "@" . $root_domain);