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; }
function check_subdomain_data(&$tpl, &$sql, $user_id) { $domain_id = get_user_domain_id($sql, $user_id); if (isset($_POST['uaction']) && $_POST['uaction'] === 'add_subd') { if ($_POST['subdomain_name'] === '') { set_page_message(tr('Please specify subdomain name!')); return; } $sub_name = strtolower($_POST['subdomain_name']); $sub_name = get_punny($sub_name); if (isset($_POST['subdomain_mnt_pt']) && $_POST['subdomain_mnt_pt'] !== '') { $sub_mnt_pt = strtolower($_POST['subdomain_mnt_pt']); $sub_mnt_pt = decode_idna($sub_mnt_pt); } if (subdmn_exists($sql, $user_id, $domain_id, $sub_name) > 0) { set_page_message(tr('Subdomain already exists!')); } else { if (chk_subdname($sub_name . "." . $_SESSION['user_logged']) > 0) { set_page_message(tr('Wrong subdomain syntax!')); } else { if (subdmn_mnt_pt_exists($sql, $user_id, $domain_id, $sub_name, $sub_mnt_pt)) { set_page_message(tr('Subdomain mount point already exists!')); } else { if (chk_mountp($sub_mnt_pt) > 0) { set_page_message(tr('Incorrect mount point syntax')); } else { subdomain_schedule($sql, $user_id, $domain_id, $sub_name, $sub_mnt_pt); set_page_message(tr('Subdomain scheduled for addition!')); header('Location:manage_domains.php'); exit(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!')); }