Ejemplo n.º 1
0
function gen_page_dynamic_data(&$tpl, &$sql, $mail_id)
{
    global $cfg;
    if (isset($_POST['uaction']) && $_POST['uaction'] === 'enable_arsp') {
        if ($_POST['arsp_message'] === '') {
            $tpl->assign('ARSP_MESSAGE', '');
            set_page_message(tr('Please type your mail autorespond message!'));
            return;
        }
        $arsp_message = $_POST['arsp_message'];
        $item_change_status = $cfg['ITEM_CHANGE_STATUS'];
        check_for_lock_file();
        $query = <<<SQL_QUERY
            update
                mail_users
            set
                status = ?,
                mail_auto_respond = ?
            where
                mail_id = ?
SQL_QUERY;
        $rs = exec_query($sql, $query, array($item_change_status, $arsp_message, $mail_id));
        send_request();
        write_log($_SESSION['user_logged'] . " : add mail autorsponder");
        set_page_message(tr('Mail account scheduler for modification!'));
        header("Location: email_accounts.php");
        exit(0);
    } else {
        $tpl->assign('ARSP_MESSAGE', '');
    }
}
Ejemplo n.º 2
0
function pedit_user(&$tpl, &$sql, &$dmn_id, &$user_id)
{
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'modify_user') {
        // we have user to add
        if (isset($_POST['pass']) && isset($_POST['pass_rep'])) {
            if ($_POST['pass'] !== $_POST['pass_rep']) {
                set_page_message(tr('Passwords don\'t match!'));
                return;
            }
            $nadmin_password = crypt($_POST['pass']);
            $query = <<<SQL_QUERY
                    update
                        htaccess_users
                    set
                        upass = ?
                    where
                        dmn_id = ?
\t\t\t\t\tand
\t\t\t\t\t\tid = ?

SQL_QUERY;
            $rs = exec_query($sql, $query, array($nadmin_password, $dmn_id, $user_id));
            // lets update htaccess to rebuild the htaccess files#
            global $cfg;
            $change_status = $cfg['ITEM_CHANGE_STATUS'];
            $query = <<<SQL_QUERY
                    update
                        htaccess
                    set
                        status = ?
                    where
                         user_id = ?
\t\t\t\t\tand
\t\t\t\t\t\t dmn_id = ?
SQL_QUERY;
            $rs = exec_query($sql, $query, array($change_status, $user_id, $dmn_id));
            check_for_lock_file();
            send_request();
            $admin_login = $_SESSION['user_logged'];
            write_log("{$admin_login}: modify user ID (protected areas) -> {$user_id}");
            header("Location: puser_manage.php");
            die;
        }
    } else {
        return;
    }
}
Ejemplo n.º 3
0
function send_backup_restore_request(&$sql, $user_id)
{
    if (isset($_POST['uaction']) && $_POST['uaction'] === 'bk_restore') {
        check_for_lock_file();
        $query = <<<SQL_QUERY
        update
            domain
        set
            domain_status = 'restore'
        where
            domain_admin_id = ?
SQL_QUERY;
        $rs = exec_query($sql, $query, array($user_id));
        send_request();
        write_log($_SESSION['user_logged'] . " : restor backup files");
        set_page_message(tr('Backup archive scheduled for restoring!'));
    }
}
Ejemplo n.º 4
0
function change_domain_status(&$sql, &$domain_id, &$domain_name, &$action, &$location)
{
    global $cfg;
    check_for_lock_file();
    if ($action == 'disable') {
        $new_status = $cfg['ITEM_TODISABLED_STATUS'];
    } else {
        if ($action == 'enable') {
            $new_status = $cfg['ITEM_TOENABLE_STATUS'];
        } else {
            return;
        }
    }
    $query = <<<SQL_QUERY
      select
          mail_id,
          mail_pass
      from
          mail_users
      where
          domain_id = ?
        and
          mail_pass != '_no_'
SQL_QUERY;
    $rs = exec_query($sql, $query, array($domain_id));
    while (!$rs->EOF) {
        if ($action == 'disable') {
            $mail_id = $rs->fields['mail_id'];
            $timestamp = time();
            $pass_prefix = substr(md5($timestamp), 0, 4);
            $mail_pass = $pass_prefix . $rs->fields['mail_pass'];
        } else {
            if ($action == 'enable') {
                $mail_id = $rs->fields['mail_id'];
                $mail_pass = substr($rs->fields['mail_pass'], 4, 50);
            } else {
                return;
            }
        }
        $mail_status = $cfg['ITEM_CHANGE_STATUS'];
        // and lets update the pass
        $query = <<<SQL_QUERY
            update
                 mail_users
            set
                mail_pass = ?,
                status = ?
            where
                mail_id = ?
SQL_QUERY;
        $rs2 = exec_query($sql, $query, array($mail_pass, $mail_status, $mail_id));
        $rs->MoveNext();
    }
    // end of while => all mails account are with changed passwords :-)
    $query = <<<SQL_QUERY
          update
              domain
          set
              domain_status = ?
          where
              domain_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($new_status, $domain_id));
    send_request();
    // lets get back to user overview after the system changes are finished
    $user_logged = $_SESSION['user_logged'];
    if ($action == 'disable') {
        write_log("{$user_logged} : suspended domin -> {$domain_name}");
        $_SESSION['user_disabled'] = 1;
    } else {
        if ($action == 'enable') {
            write_log("{$user_logged} : enabled domin -> {$domain_name}");
            $_SESSION['user_enabled'] = 1;
        } else {
            return;
        }
    }
    if ($location == 'admin') {
        header("Location: manage_users.php");
    } else {
        if ($location == 'reseller') {
            header("Location: users.php");
        }
    }
    die;
}
Ejemplo n.º 5
0
function subdomain_schedule(&$sql, $user_id, $domain_id, $sub_name, $sub_mnt_pt)
{
    global $cfg;
    $status_add = $cfg['ITEM_ADD_STATUS'];
    check_for_lock_file();
    $query = <<<SQL_QUERY
        insert into
            subdomain
                (domain_id, subdomain_name, subdomain_mount, subdomain_status)
            values
                (?, ?, ?, ?)
SQL_QUERY;
    $rs = exec_query($sql, $query, array($domain_id, $sub_name, $sub_mnt_pt, $status_add));
    write_log($_SESSION['user_logged'] . " : add new subdomain  -> " . $sub_name);
    send_request();
}
Ejemplo n.º 6
0
function update_user_props($user_id, $props)
{
    global $sql, $cfg;
    list($sub_current, $sub_max, $als_current, $als_max, $mail_current, $mail_max, $ftp_current, $ftp_max, $sql_db_current, $sql_db_max, $sql_user_current, $sql_user_max, $traff_max, $disk_max, $domain_php, $domain_cgi) = explode(";", $props);
    //$domain_ip_id, $domain_php, $domain_cgi) = explode (";", $props);
    //have to check if PHP and/or CGI and/or IP change
    $domain_last_modified = time();
    $query = <<<SQL_QUERY
        select
            domain_name
        from
            domain
        where
            domain_id  = ?
          and
            domain_php = ?
          and
            domain_cgi = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($user_id, $domain_php, $domain_cgi));
    if ($rs->RecordCount() == 0) {
        // mama mia, we have to rebuild the system entry for this domain
        // and also all domain alias and subdomains
        $update_status = $cfg['ITEM_CHANGE_STATUS'];
        // check if we have to wait some system update
        check_for_lock_file();
        // ... and go update
        // update the domain
        $query = <<<SQL_QUERY
        update
            domain
        set
            domain_last_modified = ?,
            domain_mailacc_limit = ?,
            domain_ftpacc_limit = ?,
            domain_traffic_limit = ?,
            domain_sqld_limit = ?,
            domain_sqlu_limit = ?,
            domain_status = ?,
            domain_alias_limit = ?,
            domain_subd_limit = ?,
            domain_disk_limit = ?,
            domain_php = ?,
            domain_cgi = ?
        where
            domain_id  = ?
SQL_QUERY;
        $rs = exec_query($sql, $query, array($domain_last_modified, $mail_max, $ftp_max, $traff_max, $sql_db_max, $sql_user_max, $update_status, $als_max, $sub_max, $disk_max, $domain_php, $domain_cgi, $user_id));
        // lets update all alias domains for this domain
        $query = <<<SQL_QUERY
        update
            domain_aliasses
        set
            alias_status = ?
        where
            domain_id  = ?
SQL_QUERY;
        $rs = exec_query($sql, $query, array($update_status, $user_id));
        while (!$rs->EOF) {
            $rs->MoveNext();
        }
        // lets update all subdomains for this domain
        $query = <<<SQL_QUERY
        update
            subdomain
        set
            subdomain_status = ?
        where
            domain_id  = ?
SQL_QUERY;
        $rs = exec_query($sql, $query, array($update_status, $user_id));
        while (!$rs->EOF) {
            $rs->MoveNext();
        }
        // and now we start the daemon
        send_request();
    } else {
        // we do not have IP and/or PHP and/or CGI changes
        // we have to update only the domain props and not
        // to rebuild system entries
        $query = <<<SQL_QUERY
        update
            domain
        set
            domain_subd_limit = ?,
            domain_alias_limit = ?,
            domain_mailacc_limit = ?,
            domain_ftpacc_limit = ?,
            domain_sqld_limit = ?,
            domain_sqlu_limit = ?,
            domain_traffic_limit = ?,
            domain_disk_limit = ?
        where
            domain_id = ?

SQL_QUERY;
        $rs = exec_query($sql, $query, array($sub_max, $als_max, $mail_max, $ftp_max, $sql_db_max, $sql_user_max, $traff_max, $disk_max, $user_id));
    }
}
Ejemplo n.º 7
0
function update_email_forward(&$tpl, &$sql)
{
    if (!isset($_POST['uaction'])) {
        return;
    }
    if ($_POST['uaction'] != 'update_forward') {
        return;
    }
    $mail_account = $_POST['mail_account'];
    $mail_id = $_GET['id'];
    $forward_list = $_POST['forward_list'];
    $faray = preg_split("/[\n]+/", $forward_list);
    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;
            }
        }
    }
    global $cfg;
    $status = $cfg['ITEM_CHANGE_STATUS'];
    check_for_lock_file();
    $query = <<<SQL_QUERY
          update
              mail_users
          set
              mail_forward = ?,
              status = ?
          where
              mail_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($forward_list, $status, $mail_id));
    send_request();
    write_log($_SESSION['user_logged'] . ": change mail forward -> {$mail_account}");
    header("Location: email_accounts.php");
    die;
}
Ejemplo n.º 8
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;
}
Ejemplo n.º 9
0
function add_user_data($reseller_id)
{
    global $sql, $cfg;
    global $dmn_name, $hpid, $dmn_user_name;
    global $user_email, $customer_id, $first_name;
    global $last_name, $firm, $zip;
    global $city, $country, $street_one;
    global $street_two, $mail, $phone;
    global $fax, $inpass, $domain_ip;
    global $admin_login;
    // Let's get Desired Hosting Plan Data;
    //
    $err_msg = '_off_';
    reseller_limits_check($sql, $err_msg, $reseller_id, $hpid);
    if ($err_msg != '_off_') {
        set_page_message($err_msg);
        return;
    }
    if (isset($_SESSION["ch_hpprops"])) {
        $props = $_SESSION["ch_hpprops"];
        unset($_SESSION["ch_hpprops"]);
    } else {
        $query = "select props from hosting_plans where reseller_id = ? and id = ?";
        $res = exec_query($sql, $query, array($reseller_id, $hpid));
        $data = $res->FetchRow();
        $props = $data['props'];
    }
    list($php, $cgi, $sub, $als, $mail, $ftp, $sql_db, $sql_user, $traff, $disk) = explode(";", $props);
    $php = preg_replace("/\\_/", "", $php);
    $cgi = preg_replace("/\\_/", "", $cgi);
    $pure_user_pass = $inpass;
    $inpass = crypt_user_pass($inpass);
    //   $first_name = escape_user_data($first_name);
    //   $last_name = escape_user_data($last_name);
    //   $firm = escape_user_data($firm);
    //   $zip = escape_user_data($zip);
    //   $city = escape_user_data($city);
    //   $country = escape_user_data($country);
    //   $phone = escape_user_data($phone);
    //   $fax = escape_user_data($fax);
    //   $street_one = escape_user_data($street_one);
    //   $street_two = escape_user_data($street_two);
    //   $customer_id = escape_user_data($customer_id);
    if (!vhcs_domain_check($dmn_user_name)) {
        //set_page_message = tr("Wrong domain name syntax!");
        return;
    }
    check_for_lock_file();
    $query = <<<VHCS_SQL_QUERY
            insert into admin
                      (
                        admin_name, admin_pass, admin_type, domain_created,
                        created_by, fname, lname,
                        firm, zip, city,
                        country, email, phone,
                        fax, street1, street2, customer_id
                      )
                values
                      (
                        ?, ?, 'user', unix_timestamp(),
                        ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
                      )
VHCS_SQL_QUERY;
    $res = exec_query($sql, $query, array($dmn_user_name, $inpass, $reseller_id, $first_name, $last_name, $firm, $zip, $city, $country, $user_email, $phone, $fax, $street_one, $street_two, $customer_id));
    print $sql->ErrorMsg();
    $record_id = $sql->Insert_ID();
    $query = <<<VHCS_SQL_QUERY
            insert into domain (
                        domain_name, domain_admin_id,
                        domain_created_id, domain_created,
                        domain_mailacc_limit, domain_ftpacc_limit,
                        domain_traffic_limit, domain_sqld_limit,
                        domain_sqlu_limit, domain_status,
                        domain_subd_limit, domain_alias_limit,
                        domain_ip_id, domain_disk_limit,
                        domain_disk_usage, domain_php, domain_cgi
                       )
                values (
                        ?, ?,
                        ?, unix_timestamp(),
                        ?, ?,
                        ?, ?,
                        ?, 'toadd',
                        ?, ?,
                        ?, ?, '0',
                        ?, ?
                       )
VHCS_SQL_QUERY;
    $res = exec_query($sql, $query, array($dmn_name, $record_id, $reseller_id, $mail, $ftp, $traff, $sql_db, $sql_user, $sub, $als, $domain_ip, $disk, $php, $cgi));
    $dmn_id = $sql->Insert_ID();
    // vhcs 2.5 feature
    //add_domain_extras($dmn_id, $record_id, $sql);
    // lets send mail to user
    send_add_user_auto_msg($reseller_id, $dmn_user_name, $pure_user_pass, $user_email, $first_name, $last_name, tr('Domain account'));
    // send query to the vhcs2 daemon
    // add user into user_gui_props => domain looser needs language and skin too :-)
    $user_def_lang = $_SESSION['user_def_lang'];
    $user_theme_color = $_SESSION['user_theme_color'];
    $query = <<<SQL_QUERY
                insert into
                  user_gui_props
                      (user_id, lang, layout)
                  values
                      (?, ?, ?)
SQL_QUERY;
    $res = exec_query($sql, $query, array($record_id, $user_def_lang, $user_theme_color));
    send_request();
    $admin_login = $_SESSION['user_logged'];
    write_log("{$admin_login}: add user -> {$dmn_user_name} (for domain {$dmn_name})");
    write_log("{$admin_login}: add domain -> {$dmn_name}");
    au_update_reseller_props($reseller_id, $props);
    if (isset($_POST['add_alias']) && $_POST['add_alias'] === 'on') {
        //we have to add some aliases for this looser
        $_SESSION['dmn_id'] = $dmn_id;
        $_SESSION['dmn_ip'] = $domain_ip;
        header("Location: rau4.php?accout={$dmn_id}");
        die;
    } else {
        //we have not to add alias
        $_SESSION['rau3_added'] = "_yes_";
        header("Location: users.php");
        die;
    }
}
Ejemplo n.º 10
0
function protect_area(&$tpl, &$sql, &$dmn_id)
{
    global $cfg;
    if (isset($_POST['uaction']) && $_POST['uaction'] === 'protect_it') {
        if (!isset($_POST['users']) && !isset($_POST['groups'])) {
            set_page_message(tr('Please choose user or group'));
            return;
        } else {
            if (!isset($_POST['paname']) || $_POST['paname'] == '') {
                set_page_message(tr('Please enter area name'));
                return;
            } else {
                if (!isset($_POST['other_dir']) || $_POST['other_dir'] == '') {
                    set_page_message(tr('Please enter area path'));
                    return;
                } else {
                    if (!is_dir($cfg['FTP_HOMEDIR'] . "/" . $_SESSION['user_logged'] . $_POST['other_dir'])) {
                        set_page_message($_POST['other_dir'] . tr(' do not exist'));
                        return;
                    }
                }
            }
        }
        $ptype = $_POST['ptype'];
        if (isset($_POST['users'])) {
            $users = $_POST['users'];
        }
        if (isset($_POST['groups'])) {
            $groups = $_POST['groups'];
        }
        $path = $_POST['other_dir'];
        $area_name = $_POST['paname'];
        $user_id = '';
        $group_id = '';
        if ($ptype == 'user') {
            for ($i = 0; $i < count($users); $i++) {
                if (count($users) == 1 || count($users) == $i + 1) {
                    $user_id .= $users[$i];
                    if ($user_id == '-1' || $user_id == '') {
                        set_page_message(tr('You can not protect area without selected usre(s)'));
                        return;
                    }
                } else {
                    $user_id .= $users[$i] . ',';
                }
            }
            $group_id = 0;
        } else {
            for ($i = 0; $i < count($groups); $i++) {
                if (count($groups) == 1 || count($groups) == $i + 1) {
                    $group_id .= $groups[$i];
                    if ($group_id == '-1' || $group_id == '') {
                        set_page_message(tr('You can not protect area without selected group(s)'));
                        return;
                    }
                } else {
                    $group_id .= $groups[$i] . ',';
                }
            }
            $user_id = 0;
        }
        // lets check if we have to update or to make new enrie
        $alt_path = $path . "/";
        $query = <<<SQL_QUERY
        select
            id
        from
            htaccess
        where
             dmn_id = ?
\t\tand
\t\t\t(path = ?
\t\t\t\tor
\t\t\tpath = ?)
SQL_QUERY;
        $rs = exec_query($sql, $query, array($dmn_id, $path, $alt_path));
        $basic = 'Basic';
        $toadd_status = $cfg['ITEM_ADD_STATUS'];
        $tochange_statsu = $cfg['ITEM_CHANGE_STATUS'];
        if ($rs->RecordCount() !== 0) {
            $update_id = $rs->fields['id'];
            $query = <<<SQL_QUERY
        update htaccess
\t\tset
\t\t\tuser_id = ?,
\t\t\tgroup_id = ?,
\t\t\tauth_name = ?,
\t\t\tpath = ?,
\t\t\tstatus = ?
        where 
\t\t\tid = '{$update_id}'
SQL_QUERY;
            check_for_lock_file();
            send_request();
            $rs = exec_query($sql, $query, array($user_id, $group_id, $area_name, $path, $tochange_statsu));
            set_page_message(tr('Protected area updated successfully!'));
        } else {
            $query = <<<SQL_QUERY
        insert into htaccess
            (dmn_id, user_id, group_id, auth_type, auth_name, path, status)
        values
            (?, ?, ?, ?, ?, ?, ?)
SQL_QUERY;
            check_for_lock_file();
            send_request();
            $rs = exec_query($sql, $query, array($dmn_id, $user_id, $group_id, $basic, $area_name, $path, $toadd_status));
            set_page_message(tr('Protected area created successfully!'));
        }
        header("Location: protected_areas.php");
        die;
    } else {
        return;
    }
}
Ejemplo n.º 11
0
function write_error_page(&$sql, &$user_id, &$eid)
{
    $error = $_POST['error'];
    $eid = $_POST['eid'];
    $eid = "error_" . $eid;
    // let's check if exist error table for this looser
    $query = <<<SQL_QUERY
        select
            user_id
        from
            error_pages
        where
            user_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($user_id));
    if ($rs->RecordCount() == 0) {
        /// oooo noooo we dont have error table ... i can't believe it ...
        $query = <<<SQL_QUERY
          insert into error_pages
              (user_id, error_401, error_403, error_404, error_500)
          values
               (?, '', '', '', '')
SQL_QUERY;
        $rs = exec_query($sql, $query, array($user_id));
    }
    check_for_lock_file();
    $query = <<<SQL_QUERY
        update
            error_pages
        set
          {$eid} = ?
        where
          user_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($error, $user_id));
    // now save the file
    // error num (dir) = $eid
    // error text = $error
    list($temp_dmn_id, $temp_dmn_name, $temp_dmn_gid, $temp_dmn_uid, $temp_dmn_created_id, $temp_dmn_created, $temp_dmn_last_modified, $temp_dmn_mailacc_limit, $temp_dmn_ftpacc_limit, $temp_dmn_traff_limit, $temp_dmn_sqld_limit, $temp_dmn_sqlu_limit, $temp_dmn_status, $temp_dmn_als_limit, $temp_dmn_subd_limit, $temp_dmn_ip_id, $temp_dmn_disk_limit, $temp_dmn_disk_usage, $temp_dmn_php, $temp_dmn_cgi) = get_domain_default_props($sql, $_SESSION['user_id']);
    switch ($eid) {
        case 'error_401':
            $e_dir = '401';
            break;
        case 'error_403':
            $e_dir = '403';
            break;
        case 'error_404':
            $e_dir = '404';
            break;
        case 'error_500':
            $e_dir = '500';
            break;
    }
    global $cfg;
    @($file = fopen($cfg['FTP_HOMEDIR'] . '/' . $temp_dmn_name . '/errors/' . $e_dir . '/index.php', 'w'));
    if (!$file) {
        /* cannot open file for writing */
        $error_saving = 1;
        session_register("error_saving");
    } else {
        $content = stripslashes($error);
        fputs($file, $content);
        $saved = 1;
        session_register("saved");
    }
}
Ejemplo n.º 12
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!'));
}
Ejemplo n.º 13
0
function check_for_disable($alias_id)
{
    global $sql;
    //Get data from sql
    $res = exec_query($sql, "select * from domain_aliasses where alias_id=?", array($alias_id));
    if ($res->RecordCount() <= 0) {
        $_SESSION['aledit'] = '_no_';
        header('Location: domain_alias.php');
        die;
    }
    $data = $res->FetchRow();
    if ($data['url_forward'] != 'no') {
        check_for_lock_file();
        // remove the forwarding
        exec_query($sql, "UPDATE domain_aliasses SET url_forward='no',alias_status='change' WHERE alias_id=?", array($alias_id));
        #print "UPDATEE domain_aliasses SET url_forward='no',alias_status='change' WHERE alias_id='$alias_id'";
        $_SESSION['aledit'] = "_yes_";
        // send request to the daemon
        send_request();
        header('Location: domain_alias.php');
        die;
    }
    return;
}
Ejemplo n.º 14
0
function create_catchall_mail_account(&$sql, $id)
{
    // Check if user is owner of the domain
    /*$query = <<<SQL_QUERY
    		SELECT
    			COUNT(mail_id) as cnt
    		FROM
    			mail_users
    		WHERE
    			domain_id = ?
    		AND
    			mail_id = ?
    SQL_QUERY;
    	global $domain_id;
    	$eid = explode(';', $id);
    	$mail_id = $eid[0];
    	$rs = exec_query($sql, $query, array($domain_id, $mail_id));
    	
    	if ($rs -> fields['cnt'] == 0) {
    		set_page_message(tr('0!'.$domain_id.$mail_id));
    		header("Location: catchall.php");
    		die();
    #		header("Location: catchall.php");
    	}
    */
    global $cfg;
    if (isset($_POST['uaction']) && $_POST['uaction'] === 'create_catchall' && $_POST['mail_type'] === 'normal') {
        if (preg_match("/(\\d+);(dmn|als)/", $id, $match) == 1) {
            $item_id = $match[1];
            $item_type = $match[2];
            $post_mail_id = $_POST['mail_id'];
            if (preg_match("/(\\d+);([^;]+);/", $post_mail_id, $match) == 1) {
                $mail_id = $match[1];
                $mail_acc = $match[2];
                if ($item_type === 'dmn') {
                    $mail_type = 'normal_catchall';
                } else {
                    $mail_type = 'alias_catchall';
                }
                $query = <<<SQL_QUERY
                    select
                        domain_id, sub_id
                    from
                        mail_users
                    where
                        mail_id = ?
SQL_QUERY;
                $rs = exec_query($sql, $query, array($mail_id));
                $domain_id = $rs->fields['domain_id'];
                $sub_id = $rs->fields['sub_id'];
                $status = $cfg['ITEM_ADD_STATUS'];
                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, '_no_', '_no_', $domain_id, $mail_type, $sub_id, $status, '_no_'));
                send_request();
                write_log($_SESSION['user_logged'] . " : add new email catch all ");
                set_page_message(tr('Catch all account sheculed for creation!'));
                user_goto('catchall.php');
            } else {
                user_goto('catchall.php');
            }
        }
    } else {
        if (isset($_POST['uaction']) && $_POST['uaction'] === 'create_catchall' && $_POST['mail_type'] === 'forward' && isset($_POST['forward_list'])) {
            if (preg_match("/(\\d+);(dmn|als)/", $id, $match) == 1) {
                $item_id = $match[1];
                $item_type = $match[2];
                if ($item_type === 'dmn') {
                    $mail_type = 'normal_catchall';
                } else {
                    $mail_type = 'alias_catchall';
                }
                $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_acc = $_POST['forward_list'];
                $domain_id = $item_id;
                $sub_id = '0';
                $status = $cfg['ITEM_ADD_STATUS'];
                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, '_no_', '_no_', $domain_id, $mail_type, $sub_id, $status, '_no_'));
                send_request();
                write_log($_SESSION['user_logged'] . " : add new email catch all ");
                set_page_message(tr('Catch all account sheculed for creation!'));
                user_goto('catchall.php');
            } else {
                user_goto('catchall.php');
            }
        }
    }
}
Ejemplo n.º 15
0
function delete_user_from_group(&$tpl, &$sql, &$dmn_id)
{
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'remove' && isset($_POST['groups_in']) && $_POST['groups_in'] !== '' && isset($_POST['nadmin_name']) && is_numeric($_POST['groups_in']) && is_numeric($_POST['nadmin_name'])) {
        $group_id = $_POST['groups_in'];
        $user_id = $_POST['nadmin_name'];
        $query = <<<SQL_QUERY
        select 
\t\t\tid,
\t\t\tugroup,
\t\t\tmembers 
\t\tfrom
        \thtaccess_groups
        where
\t\t\tdmn_id = ?
\t\t\tand
\t\t\tid = ?
SQL_QUERY;
        $rs = exec_query($sql, $query, array($dmn_id, $group_id));
        $members = $rs->fields['members'];
        $members = preg_replace("/{$user_id}/", "", "{$members}");
        $members = preg_replace("/,,/", ",", "{$members}");
        $members = preg_replace("/^,/", "", "{$members}");
        $members = preg_replace("/,\$/", "", "{$members}");
        $update_query = <<<SQL_QUERY
\t\t\t\tupdate
\t\t\t\t\thtaccess_groups
\t\t\t\tset
\t\t\t\t\tmembers = ?
\t\t\t\twhere
\t\t\t\t\tid = ?
\t\t\t\tand
\t\t\t\t\tdmn_id = ?
SQL_QUERY;
        $rs_update = exec_query($sql, $update_query, array($members, $group_id, $dmn_id));
        global $cfg;
        $change_status = $cfg['ITEM_CHANGE_STATUS'];
        $query = <<<SQL_QUERY
\t\t\t\tupdate
\t\t\t\t\thtaccess
\t\t\t\tset
\t\t\t\t\tstatus = ?
\t\t\t\twhere
\t\t\t\t\tgroup_id rlike ?
\t\t\t\t\tand
\t\t\t\t\tdmn_id = ?
SQL_QUERY;
        check_for_lock_file();
        $rs_update_htaccess = exec_query($sql, $query, array($change_status, $group_id, $dmn_id));
        send_request();
        set_page_message(tr('User was deleted from group ') . "- " . $rs->fields['ugroup']);
    } else {
        return;
    }
}
Ejemplo n.º 16
0
            
            SQL_QUERY;
            
            	$rs = execute_query($sql, $query);
            
            while (!$rs -> EOF) {
            	$delete_user_account_id = $rs -> fields['admin_id'];
            	print $delete_user_account_id."<br>";
            	rm_rf_user_account ($delete_user_account_id);
            }
            die ();
            */
        } else {
            if ($local_admin_type == 'user') {
                rm_rf_user_account($delete_id);
                check_for_lock_file();
                send_request();
            }
        }
    }
    $query = <<<SQL_QUERY
        delete
            from admin
        where
            admin_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($delete_id));
    $query = <<<SQL_QUERY
            delete
                from user_gui_props
            where
Ejemplo n.º 17
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);
}