Пример #1
0
function check_user_data(&$tpl)
{
    global $dmn_name;
    // Domain name
    global $dmn_chp;
    // choosed hosting plan;
    global $dmn_pt;
    global $cfg;
    // personal template
    $even_txt = "_off_";
    if (isset($_POST['dmn_name'])) {
        $dmn_name = strtolower($_POST['dmn_name']);
    }
    $dmn_name = get_punny($dmn_name);
    if (isset($_POST['dmn_tpl'])) {
        $dmn_chp = $_POST['dmn_tpl'];
    }
    if (isset($_POST['chtpl'])) {
        $dmn_pt = $_POST['chtpl'];
    }
    if (!vhcs_domain_check($dmn_name)) {
        $even_txt = tr('Wrong domain name syntax!');
    } else {
        if (vhcs_domain_exists($dmn_name, $_SESSION['user_id'])) {
            $even_txt = tr('Domain with that name already exists on the system!');
        }
    }
    // we have plans only for admins
    if (isset($cfg['HOSTING_PLANS_LEVEL']) && $cfg['HOSTING_PLANS_LEVEL'] === 'admin') {
        $dmn_pt = '_no_';
    }
    if ($even_txt != '_off_') {
        // There are wrong input data
        set_page_message($even_txt);
        return false;
    } else {
        if ($dmn_pt == '_yes_' || !isset($_POST['dmn_tpl'])) {
            // send through the session the data
            $_SESSION['dmn_name'] = $dmn_name;
            $_SESSION['dmn_tpl'] = $dmn_chp;
            $_SESSION['chtpl'] = $dmn_pt;
            $_SESSION['step_one'] = "_yes_";
            Header("Location: rau2.php");
            die;
        } else {
            // send through the session the data
            $_SESSION['dmn_name'] = $dmn_name;
            $_SESSION['dmn_tpl'] = $dmn_chp;
            $_SESSION['chtpl'] = $dmn_pt;
            $_SESSION['step_one'] = "_yes_";
            Header("Location: rau3.php");
            die;
        }
    }
}
Пример #2
0
function addon_domain(&$tpl, $dmn_name)
{
    $dmn_name = strtolower($dmn_name);
    $dmn_name = get_punny($dmn_name);
    if (!vhcs_domain_check($dmn_name)) {
        set_page_message(tr('Wrong domain name syntax!'));
        return;
    } else {
        if (vhcs_domain_exists($dmn_name, 0)) {
            set_page_message(tr('Domain with that name already exists on the system!'));
            return;
        }
    }
    $_SESSION['domainname'] = $dmn_name;
    header("Location: address.php");
    die;
}
Пример #3
0
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);
                    }
                }
            }
        }
    }
}
Пример #4
0
function update_order_details(&$tpl, &$sql, $user_id, $order_id)
{
    $domain = strtolower($_POST['domain']);
    $domain = get_punny($domain);
    $customer_id = strip_html($_POST['customer_id']);
    $fname = strip_html($_POST['fname']);
    $lname = strip_html($_POST['lname']);
    $firm = strip_html($_POST['firm']);
    $zip = strip_html($_POST['zip']);
    $city = strip_html($_POST['city']);
    $country = strip_html($_POST['country']);
    $street1 = strip_html($_POST['street1']);
    $street2 = strip_html($_POST['street2']);
    $email = strip_html($_POST['email']);
    $phone = strip_html($_POST['phone']);
    $fax = strip_html($_POST['fax']);
    $query = <<<SQL_QUERY
            update
                orders
            set
                domain_name=?,
\t\t\t\tcustomer_id=?,
                fname=?,
                lname=?,
                firm=?,
                zip=?,
                city=?,
                country=?,
                email=?,
                phone=?,
                fax=?,
                street1=?,
                street2=?
            where
                id=?
\t\t\tand
\t\t\t\tuser_id=?
SQL_QUERY;
    exec_query($sql, $query, array($domain, $customer_id, $fname, $lname, $firm, $zip, $city, $country, $email, $phone, $fax, $street1, $street2, $order_id, $user_id));
}
Пример #5
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;
}
Пример #6
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!'));
}
Пример #7
0
function gen_editalias_page(&$tpl, $edit_id)
{
    global $sql;
    $reseller_id = $_SESSION['user_id'];
    $query = <<<SQL_QUERY
\tselect
      t1.domain_id, t1.alias_id, t2.domain_id, t2.domain_created_id
\tfrom
      domain_aliasses as t1,
      domain as t2
\twhere
\t\t\tt1.alias_id = ?
\t\tand
\t\t\tt1.domain_id = t2.domain_id
\t\tand
\t\t\tt2.domain_created_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($edit_id, $reseller_id));
    if ($rs->RecordCount() == 0) {
        set_page_message(tr('User does not exist or you do not have permission to access this interface!'));
        header('Location: domain_alias.php');
        die;
    }
    //Get data from sql
    $res = exec_query($sql, "select * from domain_aliasses where alias_id=?", array($edit_id));
    if ($res->RecordCount() <= 0) {
        $_SESSION['aledit'] = '_no_';
        header('Location: domain_alias.php');
        die;
    }
    $data = $res->FetchRow();
    // Get ip -data
    $ipres = exec_query($sql, "select * from server_ips where ip_id=?", array($data['alias_ip_id']));
    $ipdat = $ipres->FetchRow();
    $ip_data = $ipdat['ip_number'] . ' (' . $ipdat['ip_alias'] . ')';
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'modify') {
        $url_forward = get_punny($_POST['forward']);
    } else {
        $url_forward = $data['url_forward'];
    }
    // Fill in the fileds
    $tpl->assign(array('ALIAS_NAME' => $data['alias_name'], 'DOMAIN_IP' => $ip_data, 'FORWARD' => $url_forward, 'ID' => $edit_id));
}
Пример #8
0
function check_user_data(&$tpl, $alias_id)
{
    global $sql;
    $forward_url = get_punny($_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));
        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;
    }
}
Пример #9
0
//  |              Copyright (c) 2001-2005 be moleSoftware		            		|
//  |			http://vhcs.net | http://www.molesoftware.com		           		|
//  |                                                                               |
//  | This program is free software; you can redistribute it and/or                 |
//  | modify it under the terms of the MPL General Public License                   |
//  | as published by the Free Software Foundation; either version 1.1              |
//  | of the License, or (at your option) any later version.                        |
//  |                                                                               |
//  | You should have received a copy of the MPL Mozilla Public License             |
//  | along with this program; if not, write to the Open Source Initiative (OSI)    |
//  | http://opensource.org | osi@opensource.org								    |
//  |                                                                               |
//   -------------------------------------------------------------------------------
include 'include/vhcs-lib.php';
if (isset($_POST['uname']) && isset($_POST['upass'])) {
    $uname = get_punny($_POST['uname']);
    if (register_user($uname, $_POST['upass'])) {
        if ($_SESSION['user_type'] == 'admin') {
            header("Location: admin/index.php");
        } else {
            if ($_SESSION['user_type'] == 'reseller') {
                header("Location: reseller/index.php");
            } else {
                if ($_SESSION['user_type'] == 'user') {
                    header("Location: client/index.php");
                }
            }
        }
    } else {
        header('Location: index.php');
    }
Пример #10
0
function schedule_mail_account(&$sql, $dmn_id, $dmn_name)
{
    global $cfg;
    $domain_id = $dmn_id;
    // standard whithoz encoding
    //$mail_acc = $_POST['username'];
    // lets encode the mail
    $mail_acc_tmp = strtolower($_POST['username']);
    $mail_acc = get_punny($mail_acc_tmp);
    //encoded
    $status = $cfg['ITEM_ADD_STATUS'];
    $mail_auto_respond = '_no_';
    if ($_POST['mail_type'] === 'normal') {
        if ($_POST['dmn_type'] === 'dmn') {
            $mail_pass = $_POST['pass'];
            $mail_forward = '_no_';
            $mail_type = 'normal_mail';
            $sub_id = '0';
        } else {
            if ($_POST['dmn_type'] === 'sub') {
                $mail_pass = $_POST['pass'];
                $mail_forward = '_no_';
                $mail_type = 'subdom_mail';
                $sub_id = $_POST['sub_id'];
            } else {
                if ($_POST['dmn_type'] === 'als') {
                    $mail_pass = $_POST['pass'];
                    $mail_forward = '_no_';
                    $mail_type = 'alias_mail';
                    $sub_id = $_POST['als_id'];
                }
            }
        }
        $check_acc_query = <<<SQL_QUERY
            select
                count(mail_id) as cnt
            from
                mail_users
            where
                mail_acc = ?
              and
                domain_id = ?
              and
                mail_type = ?
              and
                sub_id = ?
SQL_QUERY;
        $rs = exec_query($sql, $check_acc_query, array($mail_acc, $domain_id, $mail_type, $sub_id));
    } else {
        if ($_POST['mail_type'] === 'forward') {
            if ($_POST['dmn_type'] === 'dmn') {
                $mail_pass = '******';
                $mail_forward = $_POST['forward_list'];
                $faray = preg_split("/[\n]+/", $mail_forward);
                foreach ($faray as $value) {
                    $value = trim($value);
                    if (chk_email($value) > 0 && $value !== '') {
                        /* ERR .. strange :) not email in this line - warrning */
                        set_page_message(tr("Mail forward list error!"));
                        return;
                    } else {
                        if ($value === '') {
                            set_page_message(tr("Mail forward list error!"));
                            return;
                        }
                    }
                }
                $mail_type = 'normal_forward';
                $sub_id = '0';
            } else {
                if ($_POST['dmn_type'] === 'sub') {
                    $mail_pass = '******';
                    $mail_forward = $_POST['forward_list'];
                    $faray = preg_split("/[\n]+/", $mail_forward);
                    foreach ($faray as $value) {
                        $value = trim($value);
                        if (chk_email($value) > 0 && $value !== '') {
                            /* ERR .. strange :) not email in this line - warrning */
                            set_page_message(tr("Mail forward list error!"));
                            return;
                        }
                    }
                    $mail_type = 'subdom_forward';
                    $sub_id = $_POST['sub_id'];
                } else {
                    if ($_POST['dmn_type'] === 'als') {
                        $mail_pass = '******';
                        $mail_forward = $_POST['forward_list'];
                        $faray = preg_split("/[\n]+/", $mail_forward);
                        foreach ($faray as $value) {
                            $value = trim($value);
                            if (chk_email($value) > 0 && $value !== '') {
                                /* ERR .. strange :) not email in this line - warrning */
                                set_page_message(tr("Mail forward list error!"));
                                return;
                            }
                        }
                        $mail_type = 'alias_forward';
                        $sub_id = $_POST['als_id'];
                    }
                }
            }
            $check_acc_query = <<<SQL_QUERY
                  select
                      count(mail_id) as cnt
                  from
                      mail_users
                  where
                      mail_acc = ?
                    and
                      domain_id = ?
                    and
                      sub_id = ?
SQL_QUERY;
            $rs = exec_query($sql, $check_acc_query, array($mail_acc, $domain_id, $sub_id));
        }
    }
    if ($rs->fields['cnt'] > 0) {
        set_page_message(tr('Mail account already exists!'));
        return;
    }
    if (chk_username($mail_acc)) {
        set_page_message(tr("Incorrect username range or syntax!"));
        return;
    }
    check_for_lock_file();
    $query = <<<SQL_QUERY
        insert into mail_users
            (mail_acc,
             mail_pass,
             mail_forward,
             domain_id,
             mail_type,
             sub_id,
             status,
             mail_auto_respond)
        values
            (?, ?, ?, ?, ?, ?, ?, ?)
SQL_QUERY;
    $rs = exec_query($sql, $query, array($mail_acc, $mail_pass, $mail_forward, $domain_id, $mail_type, $sub_id, $status, $mail_auto_respond));
    write_log($_SESSION['user_logged'] . " : add new mail account  -> " . $mail_acc . "@" . $dmn_name);
    set_page_message(tr('Mail account scheduled for addition!'));
    send_request();
    header("Location: email_accounts.php");
    exit(0);
}