예제 #1
0
function add_domain_alias(&$sql, &$err_al)
{
    global $cr_user_id, $alias_name, $domain_ip, $forward, $mount_point, $tpl;
    $cr_user_id = $_SESSION['dmn_id'];
    $alias_name = strtolower($_POST['ndomain_name']);
    $domain_ip = $_SESSION['dmn_ip'];
    $mount_point = strtolower($_POST['ndomain_mpoint']);
    $forward = $_POST['forward'];
    $alias_name = get_punny($alias_name);
    // Fisrt check is the data correct
    if (chk_dname($alias_name) > 0) {
        $err_al = tr("Incorrect domain name syntax");
    } else {
        if (vhcs_domain_exists($alias_name, $_SESSION['user_id'])) {
            $err_al = tr('Domain with that name already exists on the system!');
        } else {
            if (chk_mountp($mount_point) > 0) {
                $err_al = tr("Incorrect mount point syntax");
            } else {
                if ($forward != 'no') {
                    if (chk_url($forward) > 0) {
                        $err_al = tr("Incorrect forward syntax");
                    }
                } else {
                    $res = exec_query($sql, "select domain_id from domain_aliasses where alias_name=?", array($alias_name));
                    $res2 = exec_query($sql, "select domain_id from domain where domain_name =?", array($alias_name));
                    if ($res->RowCount() > 0 or $res2->RowCount() > 0) {
                        // we already have domain with this name
                        $err_al = tr("Domain with this name already exist");
                    }
                    // all seems ok - add it
                    $mres = exec_query($sql, "select count(alias_id) as cnt from domain_aliasses where domain_id=? and alias_mount=?", array($cr_user_id, $mount_point));
                    $mdata = $mres->FetchRow();
                    $subdomres = exec_query($sql, "select count(subdomain_id) as cnt from subdomain where domain_id=? and subdomain_mount=?", array($cr_user_id, $mount_point));
                    $subdomdata = $subdomres->FetchRow();
                    if ($mdata['cnt'] > 0 || $subdomdata['cnt'] > 0) {
                        // whe have alias with same mount point !!! ERROR
                        $err_al = tr("There are alias with same mount point");
                    }
                }
            }
        }
    }
    if ('_off_' !== $err_al) {
        set_page_message($err_al);
        return;
    }
    // Begin add new alias domain
    check_for_lock_file();
    global $cfg;
    $status = $cfg['ITEM_ADD_STATUS'];
    exec_query($sql, "insert into domain_aliasses(domain_id, alias_name, alias_mount, alias_status, alias_ip_id, url_forward) values (?, ?, ?, ?, ?, ?)", array($cr_user_id, $alias_name, $mount_point, $status, $domain_ip, $forward));
    send_request();
    $admin_login = $_SESSION['user_logged'];
    write_log("{$admin_login}: add domain alias -> {$alias_name}");
    set_page_message(tr('Domain alias added!'));
}
예제 #2
0
function add_domain_alias(&$sql, &$err_al)
{
    global $cr_user_id, $alias_name, $domain_ip, $forward, $mount_point;
    $cr_user_id = $domain_id = get_user_domain_id($sql, $_SESSION['user_id']);
    $alias_name = strtolower($_POST['ndomain_name']);
    $mount_point = strtolower($_POST['ndomain_mpoint']);
    $forward = $_POST['forward'];
    $query = <<<SQL_QUERY
        select
            domain_ip_id
        from
            domain
        where
            domain_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($cr_user_id));
    $domain_ip = $rs->fields['domain_ip_id'];
    $alias_name = get_punny($alias_name);
    //$mount_point = "/".$mount_point;
    // Fisrt check is the data correct
    if (chk_dname($alias_name) > 0) {
        $err_al = tr("Incorrect domain name syntax");
    } else {
        if (vhcs_domain_exists($alias_name, 0)) {
            $err_al = tr('Domain with that name already exists on the system!');
        } else {
            if (chk_mountp($mount_point) > 0) {
                $err_al = tr("Incorrect mount point syntax");
            } else {
                if ($forward != 'no') {
                    if (chk_url($forward) > 0) {
                        $err_al = tr("Incorrect forward syntax");
                    }
                } else {
                    $query = "select domain_id from domain_aliasses where alias_name=?";
                    $res = exec_query($sql, $query, array($alias_name));
                    $query = "select domain_id from domain where domain_name=?";
                    $res2 = exec_query($sql, $query, array($alias_name));
                    if ($res->RowCount() > 0 or $res2->RowCount() > 0) {
                        // we already have domain with this name
                        $err_al = tr("Domain with this name already exist");
                    }
                    // all seems ok - add it
                    $query = "select count(alias_id) as cnt from domain_aliasses where domain_id=? and alias_mount=?";
                    $mres = exec_query($sql, $query, array($cr_user_id, $mount_point));
                    $mdata = $mres->FetchRow();
                    $query = "select count(subdomain_id) as cnt from subdomain where domain_id=? and subdomain_mount=?";
                    $subdomres = exec_query($sql, $query, array($cr_user_id, $mount_point));
                    $subdomdata = $subdomres->FetchRow();
                    if ($mdata['cnt'] > 0 || $subdomdata['cnt'] > 0) {
                        // whe have alias with same mount point !!! ERROR
                        $err_al = tr("There are alias with same mount point");
                    }
                }
            }
        }
    }
    if ('_off_' !== $err_al) {
        return;
    }
    // Begin add new alias domain
    $alias_name = htmlspecialchars($alias_name, ENT_QUOTES, "UTF-8");
    check_for_lock_file();
    global $cfg;
    $status = $cfg['ITEM_ADD_STATUS'];
    $query = "insert into domain_aliasses(domain_id, alias_name, alias_mount, alias_status, alias_ip_id, url_forward) values (?, ?, ?, ?, ?, ?)";
    exec_query($sql, $query, array($cr_user_id, $alias_name, $mount_point, $status, $domain_ip, $forward));
    send_request();
    $admin_login = $_SESSION['user_logged'];
    write_log("{$admin_login}: add domain alias -> {$alias_name}");
    set_page_message(tr('Alias scheduled for addition!'));
    header("Location: manage_domains.php");
    die;
}
예제 #3
0
function check_user_data(&$tpl, $alias_id)
{
    global $sql;
    $forward_url = $_POST['forward'];
    $ed_error = '_off_';
    $admin_login = '';
    if ($forward_url != 'no') {
        if (chk_url($forward_url) > 0) {
            $ed_error = tr("Incorrect forward syntax");
        }
    }
    if ('_off_' === $ed_error) {
        exec_query($sql, "update domain_aliasses set url_forward=?,alias_status='" . STATUS_TOCHANGE . "' where alias_id=?", array($forward_url, $alias_id));
        check_for_lock_file();
        send_request();
        $admin_login = $_SESSION['user_logged'];
        write_log("{$admin_login}: change domain alias forward");
        unset($_SESSION['edit_ID']);
        return true;
    } else {
        $tpl->assign('MESSAGE', $ed_error);
        $tpl->parse('PAGE_MESSAGE', 'page_message');
        return false;
    }
}