Ejemplo n.º 1
0
function padd_group($tpl, $sql, $dmn_id)
{
    $cfg = EasySCP_Registry::get('Config');
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'add_group') {
        // we have to add the group
        if (isset($_POST['groupname'])) {
            if (!validates_username($_POST['groupname'])) {
                set_page_message(tr('Invalid group name!'), 'warning');
                return;
            }
            $groupname = $_POST['groupname'];
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`id`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_groups`\n\t\t\t\tWHERE\n\t\t\t\t\t`ugroup` = ?\n\t\t\t\tAND\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t";
            $rs = exec_query($sql, $query, array($groupname, $dmn_id));
            if ($rs->recordCount() == 0) {
                $change_status = $cfg->ITEM_ADD_STATUS;
                $query = "\n\t\t\t\t\tINSERT INTO `htaccess_groups`\n\t\t\t\t\t\t(`dmn_id`, `ugroup`, `status`)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(?, ?, ?)\n\t\t\t\t";
                exec_query($sql, $query, array($dmn_id, $groupname, $change_status));
                send_request();
                $admin_login = $_SESSION['user_logged'];
                write_log("{$admin_login}: add group (protected areas): {$groupname}");
                user_goto('protected_user_manage.php');
            } else {
                set_page_message(tr('Group already exists!'), 'error');
                return;
            }
        } else {
            set_page_message(tr('Invalid group name!'), 'error');
            return;
        }
    } else {
        return;
    }
}
Ejemplo n.º 2
0
/**
 * @param EasySCP_TemplateEngine $tpl
 */
function gen_user_table($tpl)
{
    $cfg = EasySCP_Registry::get('Config');
    $sql = EasySCP_Registry::get('Db');
    $query = "\n\t\tSELECT\n\t\t\t`admin_id`, `admin_name`\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_type` = 'reseller'\n\t\tORDER BY\n\t\t\t`admin_name`\n\t";
    $rs = exec_query($sql, $query);
    if ($rs->recordCount() == 0) {
        set_page_message(tr('Reseller or user list is empty!'), 'info');
        user_goto('manage_users.php');
    }
    $reseller_id = $rs->fields['admin_id'];
    $all_resellers = array();
    while (!$rs->EOF) {
        if (isset($_POST['uaction']) && $_POST['uaction'] === 'change_src' && (isset($_POST['src_reseller']) && $_POST['src_reseller'] == $rs->fields['admin_id'])) {
            $selected = $cfg->HTML_SELECTED;
            $reseller_id = $_POST['src_reseller'];
        } else {
            if (isset($_POST['uaction']) && $_POST['uaction'] === 'move_user' && (isset($_POST['dst_reseller']) && $_POST['dst_reseller'] == $rs->fields['admin_id'])) {
                $selected = $cfg->HTML_SELECTED;
                $reseller_id = $_POST['dst_reseller'];
            } else {
                $selected = '';
            }
        }
        $all_resellers[] = $rs->fields['admin_id'];
        $tpl->append(array('SRC_RSL_OPTION' => tohtml($rs->fields['admin_name']), 'SRC_RSL_VALUE' => $rs->fields['admin_id'], 'SRC_RSL_SELECTED' => $selected));
        $tpl->append(array('DST_RSL_OPTION' => tohtml($rs->fields['admin_name']), 'DST_RSL_VALUE' => $rs->fields['admin_id'], 'DST_RSL_SELECTED' => ''));
        $rs->moveNext();
    }
    if (isset($_POST['src_reseller']) && $_POST['src_reseller'] == 0) {
        $selected = $cfg->HTML_SELECTED;
        $reseller_id = 0;
    } else {
        $selected = '';
    }
    $tpl->append(array('SRC_RSL_OPTION' => tr("N/A"), 'SRC_RSL_VALUE' => 0, 'SRC_RSL_SELECTED' => $selected));
    if ($reseller_id === 0) {
        $query = "\n\t\t\tSELECT\n\t\t\t\t`admin_id`, `admin_name`\n\t\t\tFROM\n\t\t\t\t`admin`\n\t\t\tWHERE\n\t\t\t\t`admin_type` = 'user'\n\t\t\tAND\n\t\t\t\t`created_by` NOT IN (?)\n\t\t\tORDER BY\n\t\t\t\t`admin_name`\n\t\t";
        $not_in = implode(',', $all_resellers);
        $rs = exec_query($sql, $query, $not_in);
    } else {
        $query = "\n\t\t\tSELECT\n\t\t\t\t`admin_id`, `admin_name`\n\t\t\tFROM\n\t\t\t\t`admin`\n\t\t\tWHERE\n\t\t\t\t`admin_type` = 'user'\n\t\t\tAND\n\t\t\t\t`created_by` = ?\n\t\t\tORDER BY\n\t\t\t\t`admin_name`\n\t\t";
        $rs = exec_query($sql, $query, $reseller_id);
    }
    if ($rs->recordCount() == 0) {
        set_page_message(tr('User list is empty!'), 'info');
        $tpl->assign('RESELLER_LIST', '');
    } else {
        $i = 0;
        while (!$rs->EOF) {
            $admin_id = $rs->fields['admin_id'];
            $admin_id_var_name = 'admin_id_' . $admin_id;
            $show_admin_name = decode_idna($rs->fields['admin_name']);
            $tpl->append(array('NUMBER' => $i + 1, 'USER_NAME' => tohtml($show_admin_name), 'CKB_NAME' => $admin_id_var_name));
            $rs->moveNext();
            $i++;
        }
    }
}
Ejemplo n.º 3
0
/**
 * @param EasySCP_TemplateEngine $tpl
 * @param EasySCP_Database $sql
 * @param int $dmn_id
 */
function gen_user_assign($tpl, $sql, &$dmn_id)
{
    if (isset($_GET['uname']) && $_GET['uname'] !== '' && is_numeric($_GET['uname'])) {
        $uuser_id = $_GET['uname'];
        $tpl->assign('UNAME', tohtml(get_htuser_name($sql, $uuser_id, $dmn_id)));
        $tpl->assign('UID', $uuser_id);
    } else {
        if (isset($_POST['nadmin_name']) && !empty($_POST['nadmin_name']) && is_numeric($_POST['nadmin_name'])) {
            $uuser_id = $_POST['nadmin_name'];
            $tpl->assign('UNAME', tohtml(get_htuser_name($sql, $uuser_id, $dmn_id)));
            $tpl->assign('UID', $uuser_id);
        } else {
            user_goto('protected_user_manage.php');
        }
    }
    // get groups
    $query = "\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t`htaccess_groups`\n\t\tWHERE\n\t\t\t`dmn_id` = ?\n\t";
    $rs = exec_query($sql, $query, $dmn_id);
    if ($rs->recordCount() == 0) {
        set_page_message(tr('You have no groups!'), 'info');
        user_goto('protected_user_manage.php');
    } else {
        $added_in = 0;
        $not_added_in = 0;
        while (!$rs->EOF) {
            $group_id = $rs->fields['id'];
            $group_name = $rs->fields['ugroup'];
            $members = $rs->fields['members'];
            $members = explode(",", $members);
            $grp_in = 0;
            // let's generete all groups wher the user is assigned
            for ($i = 0, $cnt_members = count($members); $i < $cnt_members; $i++) {
                if ($uuser_id == $members[$i]) {
                    $tpl->append(array('GRP_IN' => tohtml($group_name), 'GRP_IN_ID' => $group_id));
                    $grp_in = $group_id;
                    $added_in++;
                }
            }
            if ($grp_in !== $group_id) {
                $tpl->append(array('GRP_NAME' => tohtml($group_name), 'GRP_ID' => $group_id));
                $not_added_in++;
            }
            $rs->moveNext();
        }
        // generate add/remove buttons
        if ($added_in != 0) {
            $tpl->assign('IN_GROUP', true);
        }
        if ($not_added_in != 0) {
            $tpl->assign('NOT_IN_GROUP', true);
        }
    }
}
Ejemplo n.º 4
0
/**
 * Load data from sql
 */
function load_user_data($user_id, $domain_id)
{
    global $sub, $als, $mail, $ftp, $sql_db, $sql_user, $traff, $disk;
    $sql = EasySCP_Registry::get('Db');
    $query = "\n\t\tSELECT\n\t\t\t`domain_id`\n\t\tFROM\n\t\t\t`domain`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\tAND\n\t\t\t`domain_created_id` = ?\n\t";
    $rs = exec_query($sql, $query, array($domain_id, $user_id));
    if ($rs->recordCount() == 0) {
        set_page_message(tr('User does not exist or you do not have permission to access this interface!'), 'error');
        user_goto('users.php?psi=last');
    }
    list(, $sub, , $als, , $mail, , $ftp, , $sql_db, , $sql_user, $traff, $disk) = generate_user_props($domain_id);
    load_additional_data($user_id, $domain_id);
}
function change_sql_user_pass(&$sql, $db_user_id, $db_user_name)
{
    global $cfg;
    if (!isset($_POST['uaction'])) {
        return;
    }
    if ($_POST['pass'] === '' && $_POST['pass_rep'] === '') {
        set_page_message(tr('Please type user password!'));
        return;
    }
    if ($_POST['pass'] !== $_POST['pass_rep']) {
        set_page_message(tr('Entered passwords does not match!'));
        return;
    }
    if (strlen($_POST['pass']) > $cfg['MAX_SQL_PASS_LENGTH']) {
        set_page_message(tr('Too long user password!'));
        return;
    }
    $user_pass = $_POST['pass'];
    //
    // update user pass in the vhcs sql_user table;
    //
    $query = <<<SQL_QUERY
        update
            sql_user
        set
            sqlu_pass = ?
        where
            sqlu_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($user_pass, $db_user_id));
    //
    // update user pass in the mysql system tables;
    //
    $query = <<<SQL_QUERY

        SET PASSWORD FOR '{$db_user_name}'@'%' = PASSWORD('{$user_pass}')
 
SQL_QUERY;
    $rs = execute_query($sql, $query);
    $query = <<<SQL_QUERY

\tSET PASSWORD FOR '{$db_user_name}'@localhost = PASSWORD('{$user_pass}')

SQL_QUERY;
    $rs = execute_query($sql, $query);
    write_log($_SESSION['user_logged'] . " : update SQL user password" . $db_user_name);
    set_page_message(tr('SQL user password was successfully changed!'));
    user_goto('manage_sql.php');
}
Ejemplo n.º 6
0
/**
 * @param EasySCP_TemplateEngine $tpl
 */
function add_user($tpl)
{
    $cfg = EasySCP_Registry::get('Config');
    $sql = EasySCP_Registry::get('Db');
    if (isset($_POST['uaction']) && $_POST['uaction'] === 'add_user') {
        if (check_user_data()) {
            $upass = crypt_user_pass($_POST['pass']);
            $user_id = $_SESSION['user_id'];
            $username = clean_input($_POST['username']);
            $fname = clean_input($_POST['fname']);
            $lname = clean_input($_POST['lname']);
            $gender = clean_input($_POST['gender']);
            $firm = clean_input($_POST['firm']);
            $zip = clean_input($_POST['zip']);
            $city = clean_input($_POST['city']);
            $state = clean_input($_POST['state']);
            $country = clean_input($_POST['country']);
            $email = clean_input($_POST['email']);
            $phone = clean_input($_POST['phone']);
            $fax = clean_input($_POST['fax']);
            $street1 = clean_input($_POST['street1']);
            $street2 = clean_input($_POST['street2']);
            if (get_gender_by_code($gender, true) === null) {
                $gender = '';
            }
            $query = "\n\t\t\t\tINSERT INTO `admin`\n\t\t\t\t\t(\n\t\t\t\t\t\t`admin_name`,\n\t\t\t\t\t\t`admin_pass`,\n\t\t\t\t\t\t`admin_type`,\n\t\t\t\t\t\t`domain_created`,\n\t\t\t\t\t\t`created_by`,\n\t\t\t\t\t\t`fname`,\n\t\t\t\t\t\t`lname`,\n\t\t\t\t\t\t`firm`,\n\t\t\t\t\t\t`zip`,\n\t\t\t\t\t\t`city`,\n\t\t\t\t\t\t`state`,\n\t\t\t\t\t\t`country`,\n\t\t\t\t\t\t`email`,\n\t\t\t\t\t\t`phone`,\n\t\t\t\t\t\t`fax`,\n\t\t\t\t\t\t`street1`,\n\t\t\t\t\t\t`street2`,\n\t\t\t\t\t\t`gender`\n\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t'admin',\n\t\t\t\t\t\tunix_timestamp(),\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?,\n\t\t\t\t\t\t?\n\t\t\t\t\t)\n\t\t\t";
            exec_query($sql, $query, array($username, $upass, $user_id, $fname, $lname, $firm, $zip, $city, $state, $country, $email, $phone, $fax, $street1, $street2, $gender));
            $new_admin_id = $sql->insertId();
            $user_logged = $_SESSION['user_logged'];
            write_log("{$user_logged}: add admin: {$username}");
            $user_def_lang = $_SESSION['user_def_lang'];
            $user_theme_color = $_SESSION['user_theme'];
            $query = "\n\t\t\t\tINSERT INTO `user_gui_props` (\n\t\t\t\t\t`user_id`,\n\t\t\t\t\t`lang`,\n\t\t\t\t\t`layout`\n\t\t\t\t) VALUES (?,?,?)\n\t\t\t";
            exec_query($sql, $query, array($new_admin_id, $user_def_lang, $user_theme_color));
            send_add_user_auto_msg($user_id, clean_input($_POST['username']), clean_input($_POST['pass']), clean_input($_POST['email']), clean_input($_POST['fname']), clean_input($_POST['lname']), tr('Administrator'), $gender);
            $_SESSION['user_added'] = 1;
            user_goto('manage_users.php');
        } else {
            // check user data
            $tpl->assign(array('EMAIL' => clean_input($_POST['email'], true), 'USERNAME' => clean_input($_POST['username'], true), 'FIRST_NAME' => clean_input($_POST['fname'], true), 'LAST_NAME' => clean_input($_POST['lname'], true), 'FIRM' => clean_input($_POST['firm'], true), 'ZIP' => clean_input($_POST['zip'], true), 'CITY' => clean_input($_POST['city'], true), 'STATE' => clean_input($_POST['state'], true), 'COUNTRY' => clean_input($_POST['country'], true), 'STREET_1' => clean_input($_POST['street1'], true), 'STREET_2' => clean_input($_POST['street2'], true), 'PHONE' => clean_input($_POST['phone'], true), 'FAX' => clean_input($_POST['fax'], true), 'VL_MALE' => $_POST['gender'] == 'M' ? $cfg->HTML_SELECTED : '', 'VL_FEMALE' => $_POST['gender'] == 'F' ? $cfg->HTML_SELECTED : '', 'VL_UNKNOWN' => $_POST['gender'] == 'U' || empty($_POST['gender']) ? $cfg->HTML_SELECTED : ''));
        }
    } else {
        $tpl->assign(array('EMAIL' => '', 'USERNAME' => '', 'FIRST_NAME' => '', 'LAST_NAME' => '', 'FIRM' => '', 'ZIP' => '', 'CITY' => '', 'STATE' => '', 'COUNTRY' => '', 'STREET_1' => '', 'STREET_2' => '', 'PHONE' => '', 'FAX' => '', 'VL_MALE' => '', 'VL_FEMALE' => '', 'VL_UNKNOWN' => $cfg->HTML_SELECTED));
    }
    // end else
}
Ejemplo n.º 7
0
function get_domain_trafic($from, $to, $domain_id)
{
    $sql = EasySCP_Registry::get('Db');
    $reseller_id = $_SESSION['user_id'];
    $query = "\n\t\tSELECT\n\t\t\t`domain_id`\n\t\tFROM\n\t\t\t`domain`\n\t\tWHERE\n\t\t\t`domain_id` = ? AND `domain_created_id` = ?\n\t";
    $rs = exec_query($sql, $query, array($domain_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!'), 'error');
        user_goto('user_statistics.php');
    }
    $query = "\n\t\tSELECT\n\t\t\tIFNULL(SUM(`dtraff_web_in`), 0) AS web_dr_in,\n\t\t\tIFNULL(SUM(`dtraff_web_out`), 0) AS web_dr_out,\n\t\t\tIFNULL(SUM(`dtraff_ftp_in`), 0) AS ftp_dr_in,\n\t\t\tIFNULL(SUM(`dtraff_ftp_out`), 0) AS ftp_dr_out,\n\t\t\tIFNULL(SUM(`dtraff_mail`), 0) AS mail_dr,\n\t\t\tIFNULL(SUM(`dtraff_pop`), 0) AS pop_dr\n\t\tFROM\n\t\t\t`domain_traffic`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\tAND\n\t\t\t`dtraff_time` >= ?\n\t\tAND\n\t\t\t`dtraff_time` <= ?\n\t";
    $rs = exec_query($sql, $query, array($domain_id, $from, $to));
    if ($rs->recordCount() == 0) {
        return array(0, 0, 0, 0, 0, 0);
    } else {
        return array($rs->fields['web_dr_in'], $rs->fields['web_dr_out'], $rs->fields['ftp_dr_in'], $rs->fields['ftp_dr_out'], $rs->fields['pop_dr'], $rs->fields['mail_dr']);
    }
}
Ejemplo n.º 8
0
function padd_user($tpl, $sql, $dmn_id)
{
    $cfg = EasySCP_Registry::get('Config');
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'add_user') {
        // we have to add the user
        if (isset($_POST['username']) && isset($_POST['pass']) && isset($_POST['pass_rep'])) {
            if (!validates_username($_POST['username'])) {
                set_page_message(tr('Wrong username!'), 'warning');
                return;
            }
            if (!chk_password($_POST['pass'])) {
                if ($cfg->PASSWD_STRONG) {
                    set_page_message(sprintf(tr('The password must be at least %s chars long and contain letters and numbers to be valid.'), $cfg->PASSWD_CHARS), 'warning');
                } else {
                    set_page_message(sprintf(tr('Password data is shorter than %s signs or includes not permitted signs!'), $cfg->PASSWD_CHARS), 'warning');
                }
                return;
            }
            if ($_POST['pass'] !== $_POST['pass_rep']) {
                set_page_message(tr('Passwords do not match!'), 'warning');
                return;
            }
            $status = $cfg->ITEM_ADD_STATUS;
            $uname = clean_input($_POST['username']);
            $upass = crypt_user_pass_with_salt($_POST['pass']);
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`id`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_users`\n\t\t\t\tWHERE\n\t\t\t\t\t`uname` = ?\n\t\t\t\tAND\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t";
            $rs = exec_query($sql, $query, array($uname, $dmn_id));
            if ($rs->recordCount() == 0) {
                $query = "\n\t\t\t\t\tINSERT INTO `htaccess_users`\n\t\t\t\t\t\t(`dmn_id`, `uname`, `upass`, `status`)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(?, ?, ?, ?)\n\t\t\t\t";
                exec_query($sql, $query, array($dmn_id, $uname, $upass, $status));
                send_request('110 DOMAIN htaccess ' . $dmn_id);
                $admin_login = $_SESSION['user_logged'];
                write_log("{$admin_login}: add user (protected areas): {$uname}");
                user_goto('protected_user_manage.php');
            } else {
                set_page_message(tr('User already exist !'), 'error');
                return;
            }
        }
    } else {
        return;
    }
}
Ejemplo n.º 9
0
/**
 * Add new host plan to DB
 */
function save_data_to_db()
{
    global $tpl;
    global $hp_name, $hp_php, $hp_phpe, $hp_cgi, $hp_ssl;
    global $hp_sub, $hp_als, $hp_mail;
    global $hp_ftp, $hp_sql_db, $hp_sql_user;
    global $hp_traff, $hp_disk, $hp_countbackup;
    global $hpid;
    global $hp_backup, $hp_dns;
    //	global $tos;
    $sql = EasySCP_Registry::get('Db');
    $err_msg = '';
    $description = clean_input($_POST['hp_description']);
    $price = clean_input($_POST['hp_price']);
    $setup_fee = clean_input($_POST['hp_setupfee']);
    $value = clean_input($_POST['hp_value']);
    $payment = clean_input($_POST['hp_payment']);
    $status = clean_input($_POST['status']);
    $tos = clean_input($_POST['hp_tos']);
    //$hp_props = "$hp_php;$hp_cgi;$hp_sub;$hp_als;$hp_mail;$hp_ftp;$hp_sql_db;" .
    //	"$hp_sql_user;$hp_traff;$hp_disk;$hp_backup;$hp_dns;$hp_ssl";
    $newProps = array('allow_php' => $hp_php, 'allow_phpe' => $hp_phpe, 'allow_cgi' => $hp_cgi, 'subdomain_cnt' => $hp_sub, 'alias_cnt' => $hp_als, 'mail_cnt' => $hp_mail, 'ftp_cnt' => $hp_ftp, 'db_cnt' => $hp_sql_db, 'sqluser_cnt' => $hp_sql_user, 'traffic' => $hp_traff, 'disk' => $hp_disk, 'disk_countbackup' => $hp_countbackup, 'allow_backup' => $hp_backup, 'allow_dns' => $hp_dns, 'allow_ssl' => $hp_ssl);
    $hp_props = serialize($newProps);
    $admin_id = $_SESSION['user_id'];
    if (reseller_limits_check($sql, $err_msg, $admin_id, $hpid, $hp_props)) {
        if (!empty($err_msg)) {
            set_page_message($err_msg, 'error');
            restore_form($tpl, $sql);
            return false;
        } else {
            $query = "\n\t\t\t\tUPDATE\n\t\t\t\t\t`hosting_plans`\n\t\t\t\tSET\n\t\t\t\t\t`name` = ?,\n\t\t\t\t\t`description` = ?,\n\t\t\t\t\t`props` = ?,\n\t\t\t\t\t`price` = ?,\n\t\t\t\t\t`setup_fee` = ?,\n\t\t\t\t\t`value` = ?,\n\t\t\t\t\t`payment` = ?,\n\t\t\t\t\t`status` = ?,\n\t\t\t\t\t`tos` = ?\n\t\t\t\tWHERE\n\t\t\t\t\t`id` = ?\n\t\t\t\t;\n\t\t\t";
            exec_query($sql, $query, array($hp_name, $description, $hp_props, $price, $setup_fee, $value, $payment, $status, $tos, $hpid));
            $_SESSION['hp_updated'] = '_yes_';
            user_goto('hosting_plan.php');
        }
    } else {
        set_page_message(tr("Hosting plan values exceed reseller maximum values!"), 'warning');
        restore_form($tpl, $sql);
        return false;
    }
}
Ejemplo n.º 10
0
function not_allowed()
{
    $_SESSION['dnsedit'] = '_no_';
    user_goto('dns_overview.php');
}
Ejemplo n.º 11
0
 *
 * @link 		http://www.easyscp.net
 * @author 		EasySCP Team
 */
require '../../include/easyscp-lib.php';
check_login(__FILE__);
$cfg = EasySCP_Registry::get('Config');
$tpl = EasySCP_TemplateEngine::getInstance();
$template = 'admin/server_statistic_day.tpl';
global $month, $year, $day;
if (isset($_GET['month']) && isset($_GET['year']) && isset($_GET['day']) && is_numeric($_GET['month']) && is_numeric($_GET['year']) && is_numeric($_GET['day'])) {
    $year = $_GET['year'];
    $month = $_GET['month'];
    $day = $_GET['day'];
} else {
    user_goto('server_statistic.php');
}
// static page messages
$tpl->assign(array('TR_PAGE_TITLE' => tr('EasySCP - Admin/Server day stats'), 'TR_SERVER_STATISTICS' => tr('Server statistics'), 'TR_SERVER_DAY_STATISTICS' => tr('Server day statistics'), 'TR_MONTH' => tr('Month:'), 'TR_YEAR' => tr('Year:'), 'TR_DAY' => tr('Day:'), 'TR_HOUR' => tr('Hour'), 'TR_WEB_IN' => tr('Web in'), 'TR_WEB_OUT' => tr('Web out'), 'TR_SMTP_IN' => tr('SMTP in'), 'TR_SMTP_OUT' => tr('SMTP out'), 'TR_POP_IN' => tr('POP3/IMAP in'), 'TR_POP_OUT' => tr('POP3/IMAP out'), 'TR_OTHER_IN' => tr('Other in'), 'TR_OTHER_OUT' => tr('Other out'), 'TR_ALL_IN' => tr('All in'), 'TR_ALL_OUT' => tr('All out'), 'TR_ALL' => tr('All'), 'TR_BACK' => tr('Back'), 'MONTH' => $month, 'YEAR' => $year, 'DAY' => $day));
gen_admin_mainmenu($tpl, 'admin/main_menu_statistics.tpl');
gen_admin_menu($tpl, 'admin/menu_statistics.tpl');
gen_page_message($tpl);
generate_page($tpl);
if ($cfg->DUMP_GUI_DEBUG) {
    dump_gui_debug($tpl);
}
$tpl->display($template);
unset_messages();
/**
 * @param EasySCP_TemplateEngine $tpl
 */
Ejemplo n.º 12
0
/**
 * @param EasySCP_TemplateEngine $tpl
 * @param int $user_id
 * @param int $domain_id
 */
function gen_detaildom_page($tpl, $user_id, $domain_id)
{
    $sql = EasySCP_Registry::get('Db');
    $cfg = EasySCP_Registry::get('Config');
    // Get domain data
    $query = "\n\t\tSELECT\n\t\t\t*,\n\t\t\tIFNULL(`domain_disk_usage`, 0) AS domain_disk_usage\n\t\tFROM\n\t\t\t`domain`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t";
    $res = exec_query($sql, $query, $domain_id);
    $data = $res->fetchRow();
    if ($res->recordCount() <= 0) {
        user_goto('users.php?psi=last');
    }
    // Get admin data
    $created_by = $_SESSION['user_id'];
    $query = "SELECT `admin_name` FROM `admin` WHERE `admin_id` = ? AND `created_by` = ?";
    $res1 = exec_query($sql, $query, array($data['domain_admin_id'], $created_by));
    // NXW: Unused variable so...
    // $data1 = $res1->fetchRow();
    $res1->fetchRow();
    if ($res1->recordCount() <= 0) {
        user_goto('users.php?psi=last');
    }
    // Get IP info
    $query = "SELECT * FROM `server_ips` WHERE `ip_id` = ?";
    $ipres = exec_query($sql, $query, $data['domain_ip_id']);
    $ipres->fetchRow();
    // Get staus name
    $dstatus = translate_dmn_status($data['status']);
    // Traffic diagram
    $fdofmnth = mktime(0, 0, 0, date("m"), 1, date("Y"));
    $ldofmnth = mktime(1, 0, 0, date("m") + 1, 0, date("Y"));
    $query = "SELECT\n\t\t\tIFNULL(SUM(`dtraff_web_in`), 0) AS dtraff_web_in,\n\t\t\tIFNULL(SUM(`dtraff_web_out`), 0) AS dtraff_web_out,\n\t\t\tIFNULL(SUM(`dtraff_ftp_in`), 0) AS dtraff_ftp_in,\n\t\t\tIFNULL(SUM(`dtraff_ftp_out`), 0) AS dtraff_ftp_out,\n\t\t\tIFNULL(SUM(`dtraff_mail`), 0) AS dtraff_mail,\n\t\t\tIFNULL(SUM(`dtraff_pop`),0) AS dtraff_pop\n\t\tFROM\n\t\t\t`domain_traffic`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\tAND\n\t\t\t`dtraff_time` > ?\n\t\tAND\n\t\t\t`dtraff_time` < ?\n\t";
    $res7 = exec_query($sql, $query, array($data['domain_id'], $fdofmnth, $ldofmnth));
    $dtraff = $res7->fetchRow();
    $sumtraff = $dtraff['dtraff_web_in'] + $dtraff['dtraff_web_out'] + $dtraff['dtraff_ftp_in'] + $dtraff['dtraff_ftp_out'] + $dtraff['dtraff_mail'] + $dtraff['dtraff_pop'];
    // NXW: Unused variables so ...
    /*
    $dtraffmb = sprintf("%.1f", ($sumtraff / 1024) / 1024);
    $month = date("m");
    $year = date("Y");
    */
    $query = "SELECT * FROM `server_ips` WHERE `ip_id` = ?";
    $res8 = exec_query($sql, $query, $data['domain_ip_id']);
    $ipdat = $res8->fetchRow();
    $domain_traffic_limit = $data['domain_traffic_limit'];
    $domain_all_traffic = $sumtraff;
    $traffic_percent = $domain_all_traffic != 0 ? sprintf("%.2f", 100 * $domain_all_traffic / ($domain_traffic_limit * 1024 * 1024)) : 0;
    // Get disk status
    $domdu = $data['domain_disk_usage'];
    $domdl = $data['domain_disk_limit'];
    $domduh = sizeit($domdu);
    $disk_percent = sprintf("%.2f", 100 * $domdu / ($domdl * 1024 * 1024));
    // Get current mail count
    $query = "SELECT COUNT(`mail_id`) AS mcnt " . "FROM `mail_users` " . "WHERE `domain_id` = ? " . "AND `mail_type` NOT RLIKE '_catchall'";
    $res6 = exec_query($sql, $query, $data['domain_id']);
    $dat3 = $res6->fetchRow();
    $mail_limit = translate_limit_value($data['domain_mailacc_limit']);
    // FTP stat
    $query = "SELECT `gid` FROM `ftp_group` WHERE `groupname` = ?";
    $res4 = exec_query($sql, $query, $data['domain_name']);
    $ftp_gnum = $res4->rowCount();
    if ($ftp_gnum == 0) {
        $used_ftp_acc = 0;
    } else {
        $dat1 = $res4->fetchRow();
        $query = "SELECT COUNT(*) AS ftp_cnt FROM `ftp_users` WHERE `gid` = ?";
        $res5 = exec_query($sql, $query, $dat1['gid']);
        $dat2 = $res5->fetchRow();
        $used_ftp_acc = $dat2['ftp_cnt'];
    }
    $ftp_limit = translate_limit_value($data['domain_ftpacc_limit']);
    // Get sql database count
    $query = "SELECT COUNT(*) AS dnum FROM `sql_database` WHERE `domain_id` = ?";
    $res = exec_query($sql, $query, $data['domain_id']);
    $dat5 = $res->fetchRow();
    $sql_db = translate_limit_value($data['domain_sqld_limit']);
    // Get sql users count
    $query = "SELECT COUNT(u.`sqlu_id`) AS ucnt FROM sql_user u, sql_database d WHERE u.`sqld_id` = d.`sqld_id` AND d.`domain_id` = ?";
    $res = exec_query($sql, $query, $data['domain_id']);
    $dat6 = $res->fetchRow();
    $sql_users = translate_limit_value($data['domain_sqlu_limit']);
    // Get subdomain
    $query = "SELECT COUNT(`subdomain_id`) AS sub_num FROM `subdomain` WHERE `domain_id` = ?";
    $res1 = exec_query($sql, $query, $domain_id);
    $sub_num_data = $res1->fetchRow();
    $query = "SELECT COUNT(`subdomain_alias_id`) AS sub_num FROM `subdomain_alias` WHERE `alias_id` IN (SELECT `alias_id` FROM `domain_aliasses` WHERE `domain_id` = ?)";
    $res1 = exec_query($sql, $query, $domain_id);
    $alssub_num_data = $res1->fetchRow();
    $sub_dom = translate_limit_value($data['domain_subd_limit']);
    // Get domain aliases
    $query = "SELECT COUNT(*) AS alias_num FROM `domain_aliasses` WHERE `domain_id` = ?";
    $res1 = exec_query($sql, $query, $domain_id);
    $alias_num_data = $res1->fetchRow();
    // Check if Backup support is available for this user
    switch ($data['allowbackup']) {
        case "full":
            $tpl->assign(array('VL_BACKUP_SUPPORT' => tr('Full')));
            break;
        case "sql":
            $tpl->assign(array('VL_BACKUP_SUPPORT' => tr('SQL')));
            break;
        case "dmn":
            $tpl->assign(array('VL_BACKUP_SUPPORT' => tr('Domain')));
            break;
        default:
            $tpl->assign(array('VL_BACKUP_SUPPORT' => tr('No')));
    }
    $dom_alias = translate_limit_value($data['domain_alias_limit']);
    // Fill in the fields
    $tpl->assign(array('DOMAIN_ID' => $data['domain_id'], 'VL_DOMAIN_NAME' => tohtml(decode_idna($data['domain_name'])), 'VL_DOMAIN_IP' => tohtml($ipdat['ip_number'] . ' (' . $ipdat['ip_alias'] . ')'), 'VL_STATUS' => $dstatus, 'VL_PHP_SUPP' => $data['domain_php'] == 'yes' ? tr('Enabled') : tr('Disabled'), 'VL_CGI_SUPP' => $data['domain_cgi'] == 'yes' ? tr('Enabled') : tr('Disabled'), 'VL_DNS_SUPP' => $data['domain_dns'] == 'yes' ? tr('Enabled') : tr('Disabled'), 'VL_MYSQL_SUPP' => $data['domain_sqld_limit'] >= 0 ? tr('Enabled') : tr('Disabled'), 'VL_TRAFFIC_PERCENT' => $traffic_percent, 'VL_TRAFFIC_USED' => sizeit($domain_all_traffic), 'VL_TRAFFIC_LIMIT' => sizeit($domain_traffic_limit, 'MB'), 'VL_DISK_PERCENT' => $disk_percent, 'VL_DISK_USED' => $domduh, 'VL_DISK_LIMIT' => sizeit($data['domain_disk_limit'], 'MB'), 'VL_MAIL_ACCOUNTS_USED' => $dat3['mcnt'], 'VL_MAIL_ACCOUNTS_LIIT' => $mail_limit, 'VL_FTP_ACCOUNTS_USED' => $used_ftp_acc, 'VL_FTP_ACCOUNTS_LIIT' => $ftp_limit, 'VL_SQL_DB_ACCOUNTS_USED' => $dat5['dnum'], 'VL_SQL_DB_ACCOUNTS_LIIT' => $sql_db, 'VL_SQL_USER_ACCOUNTS_USED' => $dat6['ucnt'], 'VL_SQL_USER_ACCOUNTS_LIIT' => $sql_users, 'VL_SUBDOM_ACCOUNTS_USED' => $sub_num_data['sub_num'] + $alssub_num_data['sub_num'], 'VL_SUBDOM_ACCOUNTS_LIIT' => $sub_dom, 'VL_DOMALIAS_ACCOUNTS_USED' => $alias_num_data['alias_num'], 'VL_DOMALIAS_ACCOUNTS_LIIT' => $dom_alias));
}
Ejemplo n.º 13
0
check_login(__FILE__);
$reseller_id = $_SESSION['user_created_by'];
if (!hasTicketSystem($reseller_id)) {
    user_goto('index.php');
}
$back_url = 'ticket_system.php';
$user_id = $_SESSION['user_id'];
if (isset($_GET['ticket_id']) && $_GET['ticket_id'] != '') {
    $ticket_id = $_GET['ticket_id'];
    $user_id = $_SESSION['user_id'];
    $query = "\n\t\tSELECT\n\t\t\t`ticket_status`\n\t\tFROM\n\t\t\t`tickets`\n\t\tWHERE\n\t\t\t`ticket_id` = ?\n\t\tAND\n\t\t\t(`ticket_from` = ? OR `ticket_to` = ?)\n\t;";
    $rs = exec_query($sql, $query, array($ticket_id, $user_id, $user_id));
    if ($rs->recordCount() == 0) {
        user_goto('ticket_system.php');
    }
    $back_url = getTicketStatus($ticket_id) == 0 ? 'ticket_closed.php' : 'ticket_system.php';
    deleteTicket($ticket_id);
    write_log(sprintf("%s: deletes support ticket %d", $_SESSION['user_logged'], $ticket_id));
    set_page_message(tr('Support ticket deleted successfully!'), 'info');
} elseif (isset($_GET['delete']) && $_GET['delete'] == 'open') {
    deleteTickets('open', $user_id);
    write_log(sprintf("%s: deletes all open support tickets.", $_SESSION['user_logged']));
    set_page_message(tr('All open support tickets deleted successfully!'), 'info');
} elseif (isset($_GET['delete']) && $_GET['delete'] == 'closed') {
    deleteTickets('closed', $user_id);
    write_log(sprintf("%s: deletes all closed support ticket.", $_SESSION['user_logged']));
    set_page_message(tr('All closed support tickets deleted successfully!'), 'info');
    $back_url = 'ticket_closed.php';
}
user_goto($back_url);
Ejemplo n.º 14
0
$template = 'reseller/user_statistics.tpl';
$rid = $_SESSION['user_id'];
$name = $_SESSION['user_logged'];
$month = date('m');
$year = date('Y');
if (isset($_POST['month']) && isset($_POST['year'])) {
    $year = intval($_POST['year']);
    $month = intval($_POST['month']);
} else {
    if (isset($_GET['month']) && isset($_GET['year'])) {
        $month = intval($_GET['month']);
        $year = intval($_GET['year']);
    }
}
if (!is_numeric($rid) || !is_numeric($month) || !is_numeric($year)) {
    user_goto('./reseller_statistics.php');
}
// static page messages
gen_logged_from($tpl);
$tpl->assign(array('TR_PAGE_TITLE' => tr('EasySCP - Admin/Reseller User Statistics'), 'TR_RESELLER_USER_STATISTICS' => tr('Reseller users table'), 'TR_MONTH' => tr('Month'), 'TR_YEAR' => tr('Year'), 'TR_SHOW' => tr('Show'), 'TR_NO_DOMAINS' => tr('This reseller has no domains yet.'), 'TR_DOMAIN_NAME' => tr('Domain'), 'TR_TRAFF' => tr('Traffic<br />usage'), 'TR_DISK' => tr('Disk<br />usage'), 'TR_WEB' => tr('Web<br />traffic'), 'TR_FTP_TRAFF' => tr('FTP<br />traffic'), 'TR_SMTP' => tr('SMTP<br />traffic'), 'TR_POP3' => tr('POP3/IMAP<br />traffic'), 'TR_SUBDOMAIN' => tr('Subdomain'), 'TR_ALIAS' => tr('Alias'), 'TR_MAIL' => tr('Mail'), 'TR_FTP' => tr('FTP'), 'TR_SQL_DB' => tr('SQL<br />database'), 'TR_SQL_USER' => tr('SQL<br />user'), 'VALUE_NAME' => $name, 'VALUE_RID' => $rid));
gen_reseller_mainmenu($tpl, 'reseller/main_menu_statistics.tpl');
gen_reseller_menu($tpl, 'reseller/menu_statistics.tpl');
gen_select_lists($tpl, $month, $year);
generate_page($tpl, $rid, $name);
gen_page_message($tpl);
if ($cfg->DUMP_GUI_DEBUG) {
    dump_gui_debug($tpl);
}
$tpl->display($template);
unset_messages();
/**
Ejemplo n.º 15
0
        $query = <<<SQL_QUERY
      delete from
          ftp_group
      where
          gid = ?
SQL_QUERY;
        $rs = exec_query($sql, $query, array($ftp_gid));
    } else {
        $query = <<<SQL_QUERY
      update
          ftp_group
      set
          members = ?
      where
          gid = ?
SQL_QUERY;
        $rs = exec_query($sql, $query, array($members, $ftp_gid));
    }
    $query = <<<SQL_QUERY
      delete from
          ftp_users
      where
          userid = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($ftp_id));
    write_log($_SESSION['user_logged'] . " : delete FTP account -> " . $_GET['id']);
    set_page_message(tr('FTP account deleted successfully!'));
    user_goto('ftp_accounts.php');
} else {
    user_goto('ftp_accounts.php');
}
Ejemplo n.º 16
0
if (isset($_POST['Submit']) && isset($_POST['uaction']) && $_POST['uaction'] === 'apply') {
    $sslkey = clean_input(filter_input(INPUT_POST, 'ssl_key'));
    $sslcert = clean_input(filter_input(INPUT_POST, 'ssl_cert'));
    $sslcacert = clean_input(filter_input(INPUT_POST, 'ssl_cacert'));
    $sslstatus = clean_input(filter_input(INPUT_POST, 'ssl_status'));
    $rs = EasySSL::storeSSLData($_POST['ssl_domain'], $sslstatus, $sslkey, $sslcert, $sslcacert);
    if ($rs === false) {
        set_page_message(tr("SSL Certificate and key don't match!"), 'error');
    } else {
        if ($rs->rowCount() == 0) {
            set_page_message(tr("SSL configuration unchanged"), 'info');
        } else {
            $_SESSION['ssl_configuration_updated'] = "_yes_";
            set_page_message(tr('SSL configuration updated!'), 'success');
        }
        user_goto('domain_manage_ssl.php');
    }
}
if (isset($_POST['ssl_domain'])) {
    genDomainSelect($tpl, $dmn_props['domain_id'], $_POST['ssl_domain']);
    $dmn_props = EasySSL::getSSLData($_POST['ssl_domain']);
    $tpl->assign(array('SSL_KEY' => $dmn_props['ssl_key'], 'SSL_CERTIFICATE' => $dmn_props['ssl_cert'], 'SSL_CACERT' => $dmn_props['ssl_cacert'], 'SSL_STATUS' => $dmn_props['ssl_status']));
} else {
    $tpl->assign(array('SSL_KEY' => $dmn_props['ssl_key'], 'SSL_CERTIFICATE' => $dmn_props['ssl_cert'], 'SSL_CACERT' => $dmn_props['ssl_cacert'], 'SSL_STATUS' => $dmn_props['ssl_status']));
    genDomainSelect($tpl, $dmn_props['domain_id'], '');
}
switch ($dmn_props['ssl_status']) {
    case 0:
        $tpl->assign('SSL_SELECTED_DISABLED', $html_selected);
        $tpl->assign('SSL_SELECTED_SSLONLY', '');
        $tpl->assign('SSL_SELECTED_BOTH', '');
Ejemplo n.º 17
0
 * @link 		http://www.easyscp.net
 * @author 		EasySCP Team
 */
require '../../include/easyscp-lib.php';
check_login(__FILE__);
$cfg = EasySCP_Registry::get('Config');
if (!isset($_GET['domain_id'])) {
    user_goto('manage_users.php');
}
if (!is_numeric($_GET['domain_id'])) {
    user_goto('manage_users.php');
}
// so we have domain id and let's disable or enable it
$domain_id = $_GET['domain_id'];
// check status to know if have to disable or enable it
$query = "\n\tSELECT\n\t\tdomain_name, status\n\tFROM\n\t\tdomain\n\tWHERE\n\t\tdomain_id = ?\n";
$rs = exec_query($sql, $query, $domain_id);
$location = 'admin';
if ($rs->fields['status'] == $cfg->ITEM_OK_STATUS) {
    //disable_domain($sql, $domain_id, $rs->fields['domain_name']);
    $action = 'disable';
    change_domain_status($sql, $domain_id, $rs->fields['domain_name'], $action, $location);
} else {
    if ($rs->fields['status'] == $cfg->ITEM_DISABLED_STATUS) {
        //enable_domain($sql, $domain_id, $rs->fields['domain_name']);
        $action = 'enable';
        change_domain_status($sql, $domain_id, $rs->fields['domain_name'], $action, $location);
    } else {
        user_goto('manage_users.php');
    }
}
Ejemplo n.º 18
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * @link 		http://www.easyscp.net
 * @author 		EasySCP Team
 */
require '../../include/easyscp-lib.php';
check_login(__FILE__);
$cfg = EasySCP_Registry::get('Config');
if (isset($_GET['id']) && $_GET['id'] !== '') {
    $mail_id = $_GET['id'];
    $item_delete_status = $cfg->ITEM_DELETE_STATUS;
    $dmn_id = get_user_domain_id($_SESSION['user_id']);
    $query = "\n\t\tSELECT\n\t\t\t`mail_id`\n\t\tFROM\n\t\t\t`mail_users`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\tAND\n\t\t\t`mail_id` = ?\n\t";
    $rs = exec_query($sql, $query, array($dmn_id, $mail_id));
    if ($rs->recordCount() == 0) {
        user_goto('mail_catchall.php');
    }
    $query = "\n\t\tUPDATE\n\t\t\t`mail_users`\n\t\tSET\n\t\t\t`status` = ?\n\t\tWHERE\n\t\t\t`mail_id` = ?\n\t";
    $rs = exec_query($sql, $query, array($item_delete_status, $mail_id));
    send_request('130 MAIL ' . $dmn_id);
    write_log($_SESSION['user_logged'] . ': deletes email catch all!');
    set_page_message(tr('Catch all account scheduled for deletion!'), 'success');
    user_goto('mail_catchall.php');
} else {
    user_goto('mail_catchall.php');
}
Ejemplo n.º 19
0
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * @link 		http://www.easyscp.net
 * @author 		EasySCP Team
 */
require '../../include/easyscp-lib.php';
check_login(__FILE__);
if (isset($_GET['del_id']) && !empty($_GET['del_id'])) {
    $del_id = $_GET['del_id'];
} else {
    $_SESSION['orderaldel'] = '_no_';
    user_goto('domains_manage.php');
}
$domainId = get_user_domain_id($_SESSION['user_id']);
$query = "\n\tDELETE FROM\n\t\t`domain_aliasses`\n\tWHERE\n\t\t`alias_id` = ?\n\tAND\n\t\t`domain_id` = ?\n\tAND\n\t\t`status` = ?\n\t";
$rs = exec_query($sql, $query, array($domainAliasId, $domainId, $cfg->ITEM_ORDERED_STATUS));
user_goto('domains_manage.php');
Ejemplo n.º 20
0
            $dat_tmp = $res_tmp->fetchRow();
            $mail_name = $data['mail_acc'] . '@' . $dat_tmp['subdomain_name'] . '.' . $dmn_name;
        } else {
            if (preg_match("/" . MT_ALSSUB_MAIL . "/", $data['mail_type']) || preg_match("/" . MT_ALSSUB_FORWARD . "/", $data['mail_type'])) {
                // mail to subdomain
                $res_tmp = exec_query($sql, "SELECT `subdomain_alias_name`, `alias_name` FROM `subdomain_alias` AS t1, `domain_aliasses` AS t2 WHERE t1.`alias_id` = t2.`alias_id` AND `subdomain_alias_id` = ?", $data['sub_id']);
                $dat_tmp = $res_tmp->fetchRow();
                $mail_name = $data['mail_acc'] . '@' . $dat_tmp['subdomain_alias_name'] . '.' . $dat_tmp['alias_name'];
            }
        }
    }
}
$query = "SELECT `mail_id` FROM `mail_users` WHERE `mail_acc` = ? OR `mail_acc` LIKE ? OR `mail_acc` LIKE ? OR `mail_acc` LIKE ?";
$res_tmp = exec_query($sql, $query, array($mail_name, "{$mail_name},%", "%,{$mail_name},%", "%,{$mail_name}"));
$num = $res_tmp->rowCount();
if ($num > 0) {
    set_page_message(tr('First delete the CatchAll account for this email!'), 'warning');
    $_SESSION['catchall_assigned'] = 1;
    user_goto('mail_accounts.php');
}
$sql_param = array(':status' => $cfg->ITEM_DELETE_STATUS, ':mail_id' => $delete_id);
$sql_query = "\n\tUPDATE\n\t\t`mail_users`\n\tSET\n\t\t`status` = :status\n\tWHERE\n\t\t`mail_id` = :mail_id\n";
DB::prepare($sql_query);
DB::execute($sql_param);
update_reseller_c_props(get_reseller_id($data['domain_id']));
send_request('130 MAIL ' . $data['domain_id']);
$admin_login = decode_idna($_SESSION['user_logged']);
write_log("{$admin_login}: deletes mail account: " . $mail_name);
$_SESSION['maildel'] = 1;
user_goto('mail_accounts.php');
Ejemplo n.º 21
0
/**
 * Validate domain deletion, display all items to delete
 * @param integer $domain_id
 */
function validate_domain_deletion($domain_id)
{
    global $tpl, $sql;
    $reseller = $_SESSION['user_id'];
    // check for domain owns
    $query = "SELECT `domain_id`, `domain_name` FROM `domain` WHERE `domain_id` = ? AND `domain_created_id` = ?";
    $res = exec_query($sql, $query, array($domain_id, $reseller));
    $data = $res->fetchRow();
    if ($data['domain_id'] == 0) {
        set_page_message(tr('Wrong domain ID!'), 'error');
        user_goto('users.php?psi=last');
    }
    $tpl->assign(array('TR_DELETE_DOMAIN' => tr('Delete domain'), 'TR_DOMAIN_SUMMARY' => tr('Domain summary:'), 'TR_DOMAIN_EMAILS' => tr('Domain e-mails:'), 'TR_DOMAIN_FTPS' => tr('Domain FTP accounts:'), 'TR_DOMAIN_ALIASES' => tr('Domain aliases:'), 'TR_DOMAIN_SUBS' => tr('Domain subdomains:'), 'TR_DOMAIN_DBS' => tr('Domain databases:'), 'TR_REALLY_WANT_TO_DELETE_DOMAIN' => tr('Do you really want to delete the entire domain? This operation cannot be undone!'), 'TR_BUTTON_DELETE' => tr('Delete domain'), 'TR_YES_DELETE_DOMAIN' => tr('Yes, delete the domain.'), 'DOMAIN_NAME' => decode_idna($data['domain_name']), 'DOMAIN_ID' => $data['domain_id']));
    // check for mail acc in MAIN domain
    $query = "SELECT * FROM `mail_users` WHERE `domain_id` = ?";
    $res = exec_query($sql, $query, $domain_id);
    if (!$res->EOF) {
        while (!$res->EOF) {
            // Create mail type's text
            $mail_types = explode(',', $res->fields['mail_type']);
            $mdisplay_a = array();
            foreach ($mail_types as $mtype) {
                $mdisplay_a[] = user_trans_mail_type($mtype);
            }
            $mdisplay_txt = implode(', ', $mdisplay_a);
            $tpl->append(array('MAIL_ADDR' => decode_idna($res->fields['mail_addr']), 'MAIL_TYPE' => $mdisplay_txt));
            $res->moveNext();
        }
    }
    // check for ftp acc in MAIN domain
    $query = "SELECT `ftp_users`.* FROM `ftp_users`, `domain` WHERE `domain`.`domain_id` = ? AND `ftp_users`.`uid` = `domain`.`domain_uid`";
    $res = exec_query($sql, $query, $domain_id);
    if (!$res->EOF) {
        while (!$res->EOF) {
            $tpl->append(array('FTP_USER' => decode_idna($res->fields['userid']), 'FTP_HOME' => tohtml($res->fields['homedir'])));
            $res->moveNext();
        }
    }
    // check for alias domains
    $alias_a = array();
    $query = "SELECT * FROM `domain_aliasses` WHERE `domain_id` = ?";
    $res = exec_query($sql, $query, $domain_id);
    if (!$res->EOF) {
        while (!$res->EOF) {
            $alias_a[] = $res->fields['alias_id'];
            $tpl->append(array('ALS_NAME' => decode_idna($res->fields['alias_name']), 'ALS_MNT' => tohtml($res->fields['alias_mount'])));
            $res->moveNext();
        }
    }
    // check for subdomains
    $any_sub_found = false;
    $query = "SELECT * FROM `subdomain` WHERE `domain_id` = ?";
    $res = exec_query($sql, $query, $domain_id);
    while (!$res->EOF) {
        $any_sub_found = true;
        $tpl->append(array('SUB_NAME' => tohtml($res->fields['subdomain_name']), 'SUB_MNT' => tohtml($res->fields['subdomain_mount'])));
        $res->moveNext();
    }
    // Check subdomain_alias
    if (count($alias_a) > 0) {
        $query = "SELECT * FROM `subdomain_alias` WHERE `alias_id` IN (";
        $query .= implode(',', $alias_a);
        $query .= ")";
        $res = exec_query($sql, $query);
        while (!$res->EOF) {
            $tpl->append(array('SUB_NAME' => tohtml($res->fields['subdomain_alias_name']), 'SUB_MNT' => tohtml($res->fields['subdomain_alias_mount'])));
            $res->moveNext();
        }
    }
    // Check for databases and -users
    $query = "SELECT * FROM `sql_database` WHERE `domain_id` = ?";
    $res = exec_query($sql, $query, $domain_id);
    if (!$res->EOF) {
        while (!$res->EOF) {
            $query = "SELECT * FROM `sql_user` WHERE `sqld_id` = ?";
            $ures = exec_query($sql, $query, $res->fields['sqld_id']);
            $users_a = array();
            while (!$ures->EOF) {
                $users_a[] = $ures->fields['sqlu_name'];
                $ures->moveNext();
            }
            $users_txt = implode(', ', $users_a);
            $tpl->append(array('DB_NAME' => tohtml($res->fields['sqld_name']), 'DB_USERS' => tohtml($users_txt)));
            $res->moveNext();
        }
    }
}
Ejemplo n.º 22
0
\t\t and
\t\t \tdmn_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($id, $dmn_id));
    $status = $rs->fields['status'];
    $ok_status = $cfg['ITEM_OK_STATUS'];
    if ($status !== $ok_status) {
        set_page_message(tr('Protected area status should be OK if you wannt to delete it!'));
        header("Location: protected_areas.php");
        die;
    }
    $query = <<<SQL_QUERY
      update
          htaccess
      set
          status = '{$delete_status}'
      where
         \tid = ?
\t\t and
\t\t \tdmn_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($id, $dmn_id));
    check_for_lock_file();
    send_request();
    write_log($_SESSION['user_logged'] . " : delete protected area with ID -> " . $_GET['id']);
    set_page_message(tr('Protected area deleted successfully!'));
    user_goto('protected_areas.php');
} else {
    set_page_message(tr('Permission deny!'));
    user_goto('protected_areas.php');
}
Ejemplo n.º 23
0
function create_catchall_mail_account($sql, $id)
{
    $cfg = EasySCP_Registry::get('Config');
    list($realId, $type) = explode(';', $id);
    // Check if user is owner of the domain
    if (!preg_match('(normal|alias|subdom|alssub)', $type) || who_owns_this($realId, $type) != $_SESSION['user_id']) {
        set_page_message(tr('User does not exist or you do not have permission to access this interface!'), 'error');
        user_goto('mail_catchall.php');
    }
    $match = array();
    if (isset($_POST['uaction']) && $_POST['uaction'] === 'create_catchall' && $_POST['mail_type'] === 'normal') {
        if (preg_match("/(\\d+);(normal|alias|subdom|alssub)/", $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 === 'normal') {
                    $mail_type = 'normal_catchall';
                } elseif ($item_type === 'alias') {
                    $mail_type = 'alias_catchall';
                } elseif ($item_type === 'subdom') {
                    $mail_type = 'subdom_catchall';
                } elseif ($item_type === 'alssub') {
                    $mail_type = 'alssub_catchall';
                }
                $query = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t`domain_id`, `sub_id`\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`mail_users`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`mail_id` = ?\n\t\t\t\t";
                $rs = exec_query($sql, $query, $mail_id);
                $domain_id = $rs->fields['domain_id'];
                $sub_id = $rs->fields['sub_id'];
                $status = $cfg->ITEM_ADD_STATUS;
                // find the mail_addr (catchall -> "@(sub/alias)domain.tld", should be domain part of mail_acc
                $match = explode('@', $mail_acc);
                $mail_addr = '@' . $match[1];
                $query = "\n\t\t\t\t\tINSERT INTO `mail_users`\n\t\t\t\t\t\t(`mail_acc`,\n\t\t\t\t\t\t`mail_pass`,\n\t\t\t\t\t\t`mail_forward`,\n\t\t\t\t\t\t`domain_id`,\n\t\t\t\t\t\t`mail_type`,\n\t\t\t\t\t\t`sub_id`,\n\t\t\t\t\t\t`status`,\n\t\t\t\t\t\t`quota`,\n\t\t\t\t\t\t`mail_addr`)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(?, ?, ?, ?, ?, ?, ?, ?, ?)\n\t\t\t\t";
                exec_query($sql, $query, array($mail_acc, '_no_', '_no_', $domain_id, $mail_type, $sub_id, $status, NULL, $mail_addr));
                send_request('130 MAIL ' . $domain_id);
                write_log($_SESSION['user_logged'] . ": adds new email catch all");
                set_page_message(tr('Catch all account scheduled for creation!'), 'success');
                user_goto('mail_catchall.php');
            } else {
                user_goto('mail_catchall.php');
            }
        }
    } else {
        if (isset($_POST['uaction']) && $_POST['uaction'] === 'create_catchall' && $_POST['mail_type'] === 'forward' && isset($_POST['forward_list'])) {
            if (preg_match("/(\\d+);(normal|alias|subdom|alssub)/", $id, $match) == 1) {
                $item_id = $match[1];
                $item_type = $match[2];
                if ($item_type === 'normal') {
                    $mail_type = 'normal_catchall';
                    $sub_id = '0';
                    $domain_id = $item_id;
                    $query = "SELECT `domain_name` FROM `domain` WHERE `domain_id` = ?";
                    $rs = exec_query($sql, $query, $domain_id);
                    $mail_addr = '@' . $rs->fields['domain_name'];
                } elseif ($item_type === 'alias') {
                    $mail_type = 'alias_catchall';
                    $sub_id = $item_id;
                    $query = "SELECT `domain_aliasses`.`domain_id`, `alias_name` FROM `domain_aliasses` WHERE `alias_id` = ?";
                    $rs = exec_query($sql, $query, $item_id);
                    $domain_id = $rs->fields['domain_id'];
                    $mail_addr = '@' . $rs->fields['alias_name'];
                } elseif ($item_type === 'subdom') {
                    $mail_type = 'subdom_catchall';
                    $sub_id = $item_id;
                    $query = "SELECT `subdomain`.`domain_id`, `subdomain_name`, `domain_name` FROM `subdomain`, `domain`\n\t\t\t\t\tWHERE `subdomain_id` = ? AND `domain`.`domain_id` = `subdomain`.`domain_id`";
                    $rs = exec_query($sql, $query, $item_id);
                    $domain_id = $rs->fields['domain_id'];
                    $mail_addr = '@' . $rs->fields['subdomain_name'] . '.' . $rs->fields['domain_name'];
                } elseif ($item_type === 'alssub') {
                    $mail_type = 'alssub_catchall';
                    $sub_id = $item_id;
                    $query = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tt1.`subdomain_alias_name`,\n\t\t\t\t\t\tt2.`alias_name`,\n\t\t\t\t\t\tt2.`domain_id`\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`subdomain_alias` AS t1,\n\t\t\t\t\t\t`domain_aliasses` AS t2\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tt1.`subdomain_alias_id` = ?\n\t\t\t\t\tAND\n\t\t\t\t\t\tt1.`alias_id` = t2.`alias_id`\n\t\t\t\t\t";
                    $rs = exec_query($sql, $query, $item_id);
                    $domain_id = $rs->fields['domain_id'];
                    $mail_addr = '@' . $rs->fields['subdomain_alias_name'] . '.' . $rs->fields['alias_name'];
                }
                $mail_forward = clean_input($_POST['forward_list']);
                $mail_acc = array();
                $faray = preg_split("/[\n,]+/", $mail_forward);
                foreach ($faray as $value) {
                    $value = trim($value);
                    if (!chk_email($value) && $value !== '' || $value === '') {
                        // @todo ERROR .. strange :) not email in this line - warning
                        set_page_message(tr("Mail forward list error!"), 'error');
                        return;
                    }
                    $mail_acc[] = $value;
                }
                $status = $cfg->ITEM_ADD_STATUS;
                $query = "\n\t\t\t\tINSERT INTO `mail_users`\n\t\t\t\t\t(`mail_acc`,\n\t\t\t\t\t`mail_pass`,\n\t\t\t\t\t`mail_forward`,\n\t\t\t\t\t`domain_id`,\n\t\t\t\t\t`mail_type`,\n\t\t\t\t\t`sub_id`,\n\t\t\t\t\t`status`,\n\t\t\t\t\t`quota`,\n\t\t\t\t\t`mail_addr`)\n\t\t\t\tVALUES\n\t\t\t\t\t(?, ?, ?, ?, ?, ?, ?, ?, ?)\n\t\t\t";
                exec_query($sql, $query, array(implode(',', $mail_acc), '_no_', '_no_', $domain_id, $mail_type, $sub_id, $status, NULL, $mail_addr));
                send_request('130 MAIL ' . $domain_id);
                write_log($_SESSION['user_logged'] . ": adds new email catch all ");
                set_page_message(tr('Catch all account scheduled for creation!'), 'success');
                user_goto('mail_catchall.php');
            } else {
                user_goto('mail_catchall.php');
            }
        }
    }
}
Ejemplo n.º 24
0
          (ticket_from = ?
        or
          ticket_to = ?)
        and
          ticket_status != '0'
SQL_QUERY;
    $rs = exec_query($sql, $query, array($user_id, $user_id));
    while (!$rs->EOF) {
        $rs->MoveNext();
    }
    set_page_message(tr('All open support tickets deleted successfully!'));
    user_goto('support_system.php');
} elseif (isset($_GET['delete']) && $_GET['delete'] == 'closed') {
    $user_id = $_SESSION['user_id'];
    $query = <<<SQL_QUERY
      delete from
          tickets
      where
          (ticket_from = ? or ticket_to = ?)
        and
          ticket_status = '0'
SQL_QUERY;
    $rs = exec_query($sql, $query, array($user_id, $user_id));
    while (!$rs->EOF) {
        $rs->MoveNext();
    }
    set_page_message(tr('All closed support tickets deleted successfully!'));
    user_goto('ss_closed.php');
} else {
    user_goto('support_system.php');
}
Ejemplo n.º 25
0
 * static page messages.
 *
 */
gen_admin_mainmenu($tpl, 'admin/main_menu_system_tools.tpl');
gen_admin_menu($tpl, 'admin/menu_system_tools.tpl');
gen_logged_from($tpl);
check_permissions($tpl);
if (isset($_POST['uaction']) && $_POST['uaction'] === 'add_cronjob') {
    EasyCron::addCronJob();
    user_goto('cronjob_overview.php');
}
$tpl->assign(array('TR_ACTIVE' => tr('Active'), 'TR_COMMAND' => tr('Command to run:'), 'TR_CRON_SCHEDULE' => tr('Cronjob schedule'), 'TR_DAY' => tr('Day(s):'), 'TR_DESCRIPTION' => tr('Description'), 'TR_EXPERT_MODE' => tr('Expert mode'), 'TR_CRON_SIMPLE' => tr('Simple schedule'), 'TR_CRON_DATETIME' => tr('Select date/time below'), 'TR_SIMPLE_SCHEDULE' => tr('Simple schedule'), 'TR_HOUR' => tr('Hour(s):'), 'TR_MIN' => tr('Minute(s):'), 'TR_MONTHS' => tr('Month(s):'), 'TR_NAME' => tr('Name'), 'TR_NO' => tr('No'), 'TR_PAGE_TITLE' => tr('EasySCP - Admin/Manage cronjobs'), 'TR_RESET' => tr('Reset'), 'TR_USER' => tr('User'), 'TR_WEEKDAYS' => tr('Weekday(s):'), 'TR_YES' => tr('Yes')));
if (isset($_GET['edit_cron_id']) && is_numeric($_GET['edit_cron_id'])) {
    $rs = EasyCron::getCronJobByID($_GET['edit_cron_id']);
    if ($rs->rowCount() <= 0) {
        user_goto('cronjob_overview.php');
    } else {
        $row = $rs->fetch();
        $scheduleSplit = explode(' ', $row['schedule']);
        if (count($scheduleSplit) == 5) {
            $tpl->assign(array('MINUTE_EXPERT' => $scheduleSplit[0], 'DOM_EXPERT' => $scheduleSplit[2], 'HOUR_EXPERT' => $scheduleSplit[1], 'MONTH_EXPERT' => $scheduleSplit[3], 'DOW_EXPERT' => $scheduleSplit[4]));
            $minutes = explode(',', $scheduleSplit[0]);
            $days = explode(',', $scheduleSplit[2]);
            $hours = explode(',', $scheduleSplit[1]);
            $months = explode(',', $scheduleSplit[3]);
            $weekdays = explode(',', $scheduleSplit[4]);
        } else {
            $tpl->assign(array('MINUTE_EXPERT' => '*', 'DOM_EXPERT' => '*', 'HOUR_EXPERT' => '*', 'MONTH_EXPERT' => '*', 'DOW_EXPERT' => '*'));
            $minutes = array('*');
            $days = array('*');
            $hours = array('*');
Ejemplo n.º 26
0
<?php

//   -------------------------------------------------------------------------------
//  |             VHCS(tm) - Virtual Hosting Control System                         |
//  |              Copyright (c) 2001-2005 by 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';
check_login();
if (isset($_GET['id'])) {
    $db_user_id = $_GET['id'];
} else {
    user_goto('manage_sql.php');
}
$dmn_id = get_user_domain_id($sql, $_SESSION['user_id']);
check_usr_sql_perms($sql, $db_user_id);
sql_delete_user($sql, $dmn_id, $db_user_id);
write_log($_SESSION['user_logged'] . " : delete SQL user" . $db_user_id);
set_page_message(tr('SQL user was removed successfully!'));
user_goto('manage_sql.php');
Ejemplo n.º 27
0
        if ($_POST['uaction'] == "close") {
            // close ticket
            closeTicket($ticket_id);
        } elseif ($_POST['uaction'] == "open") {
            // open ticket
            openTicket($ticket_id);
        } elseif (empty($_POST['user_message'])) {
            // no message check->error
            set_page_message(tr('Please type your message!'), 'warning');
        } else {
            $userLevel = getUserLevel($_GET['ticket_id']);
            updateTicket($ticket_id, $user_id, $_POST['urgency'], $_POST['subject'], $_POST['user_message'], $userLevel, 2);
            user_goto('ticket_system.php');
        }
    }
    showTicketContent($tpl, $ticket_id, $user_id, $screenwidth);
} else {
    set_page_message(tr('Ticket not found!'), 'error');
    user_goto('ticket_system.php');
}
// static page messages
gen_logged_from($tpl);
$tpl->assign(array('TR_PAGE_TITLE' => tr('EasySCP - Reseller: Support System: View Ticket'), 'TR_VIEW_SUPPORT_TICKET' => tr('View support ticket'), 'TR_TICKET_URGENCY' => tr('Priority'), 'TR_TICKET_SUBJECT' => tr('Subject'), 'TR_TICKET_DATE' => tr('Date'), 'TR_DELETE' => tr('Delete'), 'TR_NEW_TICKET_REPLY' => tr('Send message reply'), 'TR_REPLY' => tr('Send reply'), 'TR_TICKET_FROM' => tr('From'), 'TR_OPEN_TICKETS' => tr('Open tickets'), 'TR_CLOSED_TICKETS' => tr('Closed tickets')));
gen_reseller_mainmenu($tpl, 'reseller/main_menu_ticket_system.tpl');
gen_reseller_menu($tpl, 'reseller/menu_ticket_system.tpl');
gen_page_message($tpl);
if ($cfg->DUMP_GUI_DEBUG) {
    dump_gui_debug($tpl);
}
$tpl->display($template);
unset_messages();
Ejemplo n.º 28
0
/**
* Delete domain with all sub items (usage in admin and reseller)
* @param integer $domain_id
* @param string $goto users.php or manage_users.php
* @param boolean $breseller double check by reseller=current user
*/
function delete_domain($domain_id, $goto, $breseller = false)
{
    $cfg = EasySCP_Registry::get('Config');
    $sql = EasySCP_Registry::get('Db');
    // Get uid and gid of domain user
    $query = "\n\t\tSELECT\n\t\t\t`domain_uid`,\n\t\t\t`domain_gid`,\n\t\t\t`domain_admin_id`,\n\t\t\t`domain_name`,\n\t\t\t`domain_created_id`\n\t\tFROM\n\t\t\t`domain`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t";
    if ($breseller) {
        $reseller_id = $_SESSION['user_id'];
        $query .= " AND `domain_created_id` = ?";
        $res = exec_query($sql, $query, array($domain_id, $reseller_id));
    } else {
        $res = exec_query($sql, $query, $domain_id);
    }
    $data = $res->fetchRow();
    if (empty($data['domain_uid']) || empty($data['domain_admin_id'])) {
        set_page_message(tr('Wrong domain ID!'), 'error');
        user_goto($goto);
    }
    $domain_admin_id = $data['domain_admin_id'];
    $domain_name = $data['domain_name'];
    $domain_uid = $data['domain_uid'];
    $domain_gid = $data['domain_gid'];
    if (!$breseller) {
        $reseller_id = $data['domain_created_id'];
    }
    // Mail users:
    $query = "\n\t\tUPDATE\n\t\t\t`mail_users`\n\t\tSET\n\t\t\t`status` = ?\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\t;\n\t";
    exec_query($sql, $query, array($cfg->ITEM_DELETE_STATUS, $domain_id));
    send_request('130 MAIL ' . $domain_id);
    // Delete all protected areas related data (areas, groups and users)
    $query = "\n\t\tDELETE\n\t\t\t`areas`,\n\t\t\t`users`,\n\t\t\t`groups`\n\t\tFROM\n\t\t\t`domain` AS `customer`\n\t\tLEFT JOIN\n\t\t\t`htaccess` AS `areas` ON `areas`.`dmn_id` = `customer`.`domain_id`\n\t\tLEFT JOIN\n\t\t\t`htaccess_users` AS `users` ON `users`.`dmn_id` = `customer`.`domain_id`\n\t\tLEFT JOIN\n\t\t\t`htaccess_groups` AS `groups` ON `groups`.`dmn_id` = `customer`.`domain_id`\n\t\tWHERE\n\t\t\t`customer`.`domain_id` = ?\n\t\t;\n\t";
    exec_query($sql, $query, $domain_id);
    // Delete subdomain aliases:
    $alias_a = array();
    $query = "\n\t\tSELECT\n\t\t\t`alias_id`\n\t\tFROM\n\t\t\t`domain_aliasses`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\t;\n\t";
    $res = exec_query($sql, $query, $domain_id);
    while (!$res->EOF) {
        $alias_a[] = $res->fields['alias_id'];
        $res->moveNext();
    }
    if (count($alias_a) > 0) {
        $query = "\n\t\t\tUPDATE\n\t\t\t\t`subdomain_alias`\n\t\t\tSET\n\t\t\t\t`status` = ?\n\t\t\tWHERE\n\t\t\t\t`alias_id` IN (\n\t\t";
        $query .= implode(',', $alias_a);
        $query .= ")";
        exec_query($sql, $query, $cfg->ITEM_DELETE_STATUS);
    }
    // Delete SQL databases and users
    $query = "\n\t\tSELECT\n\t\t\t`sqld_id`\n\t\tFROM\n\t\t\t`sql_database`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\t;\n\t";
    $res = exec_query($sql, $query, $domain_id);
    while (!$res->EOF) {
        delete_sql_database($sql, $domain_id, $res->fields['sqld_id']);
        $res->moveNext();
    }
    // Domain aliases:
    $query = "\n\t\tUPDATE\n\t\t\tdomain_aliasses\n\t\tSET\n\t\t\tstatus =  ?\n\t\tWHERE\n\t\t\tdomain_id = ?\n\t\t;\n\t";
    exec_query($sql, $query, array($cfg->ITEM_DELETE_STATUS, $domain_id));
    // Remove domain traffic
    $query = "\n\t\tDELETE FROM\n\t\t\t`domain_traffic`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\t;\n\t";
    exec_query($sql, $query, $domain_id);
    // Set domain deletion status
    $query = "\n\t\tUPDATE\n\t\t\t`domain`\n\t\tSET\n\t\t\t`status` = 'delete'\n\t\tWHERE\n\t\t`domain_id` = ?\n\t\t;\n\t";
    exec_query($sql, $query, $domain_id);
    // Set domain subdomains deletion status
    $query = "\n\t\tUPDATE\n\t\t\t`subdomain`\n\t\tSET\n\t\t\t`status` = ?\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\t;\n\t";
    exec_query($sql, $query, array($cfg->ITEM_DELETE_STATUS, $domain_id));
    // --- Activate daemon ---
    send_request('110 DOMAIN domain ' . $domain_id);
    // Delete FTP users:
    $query = "\n\t\tDELETE FROM\n\t\t\t`ftp_users`\n\t\tWHERE\n\t\t\t`uid` = ?\n\t\t;\n\t";
    exec_query($sql, $query, $domain_uid);
    // Delete FTP groups:
    $query = "\n\t\tDELETE FROM\n\t\t\t`ftp_group`\n\t\tWHERE\n\t\t\t`gid` = ?\n\t\t;\n\t";
    exec_query($sql, $query, $domain_gid);
    // Delete EasySCP login:
    $query = "\n\t\tDELETE FROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_id` = ?\n\t\t;\n\t";
    exec_query($sql, $query, $domain_admin_id);
    // Delete the quota section:
    $query = "\n\t\tDELETE FROM\n\t\t\t`quotalimits`\n\t\tWHERE\n\t\t\t`name` = ?\n\t\t;\n\t";
    exec_query($sql, $query, $domain_name);
    // Delete the quota section:
    $query = "\n\t\tDELETE FROM\n\t\t\t`quotatallies`\n\t\tWHERE\n\t\t\t`name` = ?\n\t\t;\n\t";
    exec_query($sql, $query, $domain_name);
    // Remove support tickets:
    $query = "\n\t\tDELETE FROM\n\t\t\t`tickets`\n\t\tWHERE\n\t\t\tticket_from = ?\n\t\tOR\n\t\t\tticket_to = ?\n\t\t;\n\t";
    exec_query($sql, $query, array($domain_admin_id, $domain_admin_id));
    // Delete user gui properties
    $query = "\n\t\tDELETE FROM\n\t\t\t`user_gui_props`\n\t\tWHERE\n\t\t\t`user_id` = ?\n\t\t;\n\t";
    exec_query($sql, $query, $domain_admin_id);
    write_log($_SESSION['user_logged'] . ': deletes domain ' . $domain_name);
    update_reseller_c_props($reseller_id);
    $_SESSION['ddel'] = '_yes_';
    user_goto($goto);
}
Ejemplo n.º 29
0
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * @link 		http://www.easyscp.net
 * @author 		EasySCP Team
 */
require '../../include/easyscp-lib.php';
check_login(__FILE__);
$cfg = EasySCP_Registry::get('Config');
$tpl = EasySCP_TemplateEngine::getInstance();
$template = 'common/ticket_closed.tpl';
// dynamic page data
if (!hasTicketSystem()) {
    user_goto('index.php');
}
if (isset($_GET['psi'])) {
    $start = $_GET['psi'];
} else {
    $start = 0;
}
generateTicketList($tpl, $_SESSION['user_id'], $start, $cfg->DOMAIN_ROWS_PER_PAGE, 'admin', 'closed');
// static page messages
$tpl->assign(array('TR_PAGE_TITLE' => tr('EasySCP - Client/Questions & Comments'), 'TR_SUPPORT_SYSTEM' => tr('Support system'), 'TR_SUPPORT_TICKETS' => tr('Support tickets'), 'TR_STATUS' => tr('Status'), 'TR_NEW' => ' ', 'TR_ACTION' => tr('Action'), 'TR_URGENCY' => tr('Priority'), 'TR_SUBJECT' => tr('Subject'), 'TR_LAST_DATA' => tr('Last reply'), 'TR_DELETE_ALL' => tr('Delete all'), 'TR_OPEN_TICKETS' => tr('Open tickets'), 'TR_CLOSED_TICKETS' => tr('Closed tickets'), 'TR_DELETE' => tr('Delete'), 'TR_TICKET_FROM' => tr('From'), 'TR_MESSAGE_DELETE' => tr('Are you sure you want to delete %s?', true, '%s'), 'TR_EDIT' => tr('Edit')));
gen_admin_mainmenu($tpl, 'admin/main_menu_ticket_system.tpl');
gen_admin_menu($tpl, 'admin/menu_ticket_system.tpl');
gen_page_message($tpl);
if ($cfg->DUMP_GUI_DEBUG) {
    dump_gui_debug($tpl);
}
Ejemplo n.º 30
-1
function delete_sql_database(&$sql, $dmn_id, $db_id)
{
    $query = <<<SQL_QUERY
        select
            sqld_name as db_name
        from
            sql_database
        where
            domain_id = ?
          and
            sqld_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($dmn_id, $db_id));
    if ($rs->RecordCount() == 0) {
        user_goto('manage_sql.php');
    }
    $db_name = quoteIdentifier($rs->fields['db_name']);
    //
    // have we any users assigned to this database;
    //
    $query = <<<SQL_QUERY
        select
            t2.sqlu_id as db_user_id,
            t2.sqlu_name as db_user_name
        from
            sql_database as t1,
            sql_user as t2
        where
            t1.sqld_id = t2.sqld_id
          and
            t1.domain_id = ?
          and
            t1.sqld_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($dmn_id, $db_id));
    if ($rs->RecordCount() != 0) {
        while (!$rs->EOF) {
            $db_user_id = $rs->fields['db_user_id'];
            $db_user_name = $rs->fields['db_user_name'];
            sql_delete_user($sql, $dmn_id, $db_user_id);
            $rs->MoveNext();
        }
    }
    //
    // drop desired database;
    //
    $query = <<<SQL_QUERY
        drop database {$db_name}
SQL_QUERY;
    $rs = exec_query($sql, $query);
    write_log($_SESSION['user_logged'] . " : delete SQL database -> " . $db_name);
    //
    // delete desired database from the vhcs sql_database table;
    //
    $query = <<<SQL_QUERY
        delete from
            sql_database
        where
            domain_id = ?
          and
            sqld_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($dmn_id, $db_id));
}