Exemplo n.º 1
0
function check_reseller_data($reseller_id, $rip_lst, $reseller_ips)
{
    $reseller_max_domain_cnt = $_POST['nreseller_max_domain_cnt'];
    $reseller_max_subdomain_cnt = $_POST['nreseller_max_subdomain_cnt'];
    $reseller_max_alias_cnt = $_POST['nreseller_max_alias_cnt'];
    $reseller_max_mail_cnt = $_POST['nreseller_max_mail_cnt'];
    $reseller_max_ftp_cnt = $_POST['nreseller_max_ftp_cnt'];
    $reseller_max_sql_db_cnt = $_POST['nreseller_max_sql_db_cnt'];
    $reseller_max_sql_user_cnt = $_POST['nreseller_max_sql_user_cnt'];
    $reseller_max_traffic = $_POST['nreseller_max_traffic'];
    $reseller_max_disk = $_POST['nreseller_max_disk'];
    list($udmn_current, $udmn_max, $udmn_uf, $usub_current, $usub_max, $usub_uf, $uals_current, $uals_max, $uals_uf, $umail_current, $umail_max, $umail_uf, $uftp_current, $uftp_max, $uftp_uf, $usql_db_current, $usql_db_max, $usql_db_uf, $usql_user_current, $usql_user_max, $usql_user_uf, $utraff_current, $utraff_max, $utraff_uf, $udisk_current, $udisk_max, $udisk_uf) = generate_reseller_users_props($reseller_id);
    list($rdmn_current, $rdmn_max, $rsub_current, $rsub_max, $rals_current, $rals_max, $rmail_current, $rmail_max, $rftp_current, $rftp_max, $rsql_db_current, $rsql_db_max, $rsql_user_current, $rsql_user_max, $rtraff_current, $rtraff_max, $rdisk_current, $rdisk_max) = generate_reseller_props($reseller_id);
    $err = '_off_';
    calculate_new_reseller_vals($reseller_max_domain_cnt, $rdmn_current, $rdmn_max, $udmn_current, $rdmn_current, $udmn_uf, $err, tr('Domain'));
    if ($err == '_off_') {
        calculate_new_reseller_vals($reseller_max_subdomain_cnt, $rsub_current, $rsub_max, $usub_current, $rsub_current, $usub_uf, $err, tr('Subdomain'));
    }
    if ($err == '_off_') {
        calculate_new_reseller_vals($reseller_max_alias_cnt, $rals_current, $rals_max, $uals_current, $uals_max, $uals_uf, $err, tr('Alias'));
    }
    if ($err == '_off_') {
        calculate_new_reseller_vals($reseller_max_mail_cnt, $rmail_current, $rmail_max, $umail_current, $umail_max, $umail_uf, $err, tr('Mail'));
    }
    if ($err == '_off_') {
        calculate_new_reseller_vals($reseller_max_ftp_cnt, $rftp_current, $rftp_max, $uftp_current, $uftp_max, $uftp_uf, $err, tr('FTP'));
    }
    if ($err == '_off_') {
        calculate_new_reseller_vals($reseller_max_sql_db_cnt, $rsql_db_current, $rsql_db_max, $usql_db_current, $usql_db_max, $usql_db_uf, $err, tr('SQL Database'));
    }
    if ($err == '_off_') {
        calculate_new_reseller_vals($reseller_max_sql_user_cnt, $rsql_user_current, $rsql_user_max, $usql_user_current, $usql_user_max, $usql_user_uf, $err, tr('SQL User'));
    }
    if ($err == '_off_') {
        calculate_new_reseller_vals($reseller_max_traffic, $rtraff_current, $rtraff_max, $utraff_current / 1024 / 1024, $utraff_max, $utraff_uf, $err, tr('Traffic'));
    }
    if ($err == '_off_') {
        calculate_new_reseller_vals($reseller_max_disk, $rdisk_current, $rdisk_max, $udisk_current / 1024 / 1024, $udisk_max, $udisk_uf, $err, tr('Disk'));
        //							($data,               $r,           &$rmax,         $u,                         $umax,       $uf,    &$err, $obj)
    }
    if ($err == '_off_') {
        check_user_ip_data($reseller_id, $rip_lst, $reseller_ips, $err);
    }
    if ($err != '_off_') {
        set_page_message($err);
        return false;
    }
    return true;
}
Exemplo n.º 2
0
/**
 * Check reseller data
 *
 * @param array &$errFields  rerefence to the error indicators of input fields
 * @return boolean TRUE if all data are valid, FALSE otherwise
 */
function check_data(&$errFields)
{
    $cfg = EasySCP_Registry::get('Config');
    // Get needed data
    $rdata =& get_data();
    /**
     * Check for new password
     */
    if (!empty($_POST['pass0']) || !empty($_POST['pass1'])) {
        if (!chk_password($_POST['pass0'])) {
            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');
            }
            $errFields[] = 'PWD_ERR';
        }
        if ($_POST['pass0'] != $_POST['pass1']) {
            set_page_message(tr('Entered passwords do not match!'), 'warning');
            $errFields[] = 'PWD_ERR';
            $errFields[] = 'PWDR_ERR';
        }
    }
    /**
     * Check for mail address
     */
    if (!chk_email($rdata['email'])) {
        set_page_message(tr('Incorrect email syntax!'), 'warning');
        $errFields[] = 'EMAIL_ERR';
    }
    list($udmn_current, , $udmn_uf, $usub_current, , $usub_uf, $uals_current, , $uals_uf, $umail_current, , $umail_uf, $uftp_current, , $uftp_uf, $usql_db_current, , $usql_db_uf, $usql_user_current, , $usql_user_uf, $utraff_current, , $utraff_uf, $udisk_current, , $udisk_uf) = generate_reseller_users_props($rdata['edit_id']);
    list($rdmn_current, , $rsub_current, , $rals_current, , $rmail_current, , $rftp_current, , $rsql_db_current, , $rsql_user_current, , $rtraff_current, , $rdisk_current, ) = generate_reseller_props($rdata['edit_id']);
    /**
     * Check for new domains limit
     */
    if (easyscp_limit_check($rdata['max_dmn_cnt'], null)) {
        $rs = _check_new_limit($rdata['max_dmn_cnt'], $rdmn_current, $udmn_current, $udmn_uf, tr('Domains'));
    } else {
        set_page_message(tr('Incorrect domains limit!'), 'warning');
        $rs = false;
    }
    if (!$rs) {
        $errFields[] = 'DMN_ERR';
    }
    /**
     * Check for new subdomains limit
     */
    if (easyscp_limit_check($rdata['max_sub_cnt'])) {
        $rs = _check_new_limit($rdata['max_sub_cnt'], $rsub_current, $usub_current, $usub_uf, tr('Subdomains'));
    } else {
        set_page_message(tr('Incorrect subdomains limit!'), 'warning');
        $rs = false;
    }
    if (!$rs) {
        $errFields[] = 'SUB_ERR';
    }
    /**
     * Check for new domain alias limit
     */
    if (easyscp_limit_check($rdata['max_als_cnt'])) {
        $rs = _check_new_limit($rdata['max_als_cnt'], $rals_current, $uals_current, $uals_uf, tr('Aliases'));
    } else {
        set_page_message(tr('Incorrect aliases limit!'), 'warning');
        $rs = false;
    }
    if (!$rs) {
        $errFields[] = 'ALS_ERR';
    }
    /**
     * Check for new mail accounts limit
     */
    if (easyscp_limit_check($rdata['max_mail_cnt'])) {
        $rs = _check_new_limit($rdata['max_mail_cnt'], $rmail_current, $umail_current, $umail_uf, tr('Mail'));
    } else {
        set_page_message(tr('Incorrect mail accounts limit!'), 'warning');
        $rs = false;
    }
    if (!$rs) {
        $errFields[] = 'MAIL_ERR';
    }
    /**
     * Check for new Ftp accounts limit
     */
    if (easyscp_limit_check($rdata['max_ftp_cnt'])) {
        $rs = _check_new_limit($rdata['max_ftp_cnt'], $rftp_current, $uftp_current, $uftp_uf, tr('FTP'));
    } else {
        set_page_message(tr('Incorrect FTP accounts limit!'), 'warning');
        $rs = false;
    }
    if (!$rs) {
        $errFields[] = 'FTP_ERR';
    }
    /**
     * Check for new Sql databases limit
     */
    if (!($rs = easyscp_limit_check($rdata['max_sql_db_cnt']))) {
        set_page_message(tr('Incorrect SQL databases limit!'), 'warning');
    } else {
        if ($rdata['max_sql_db_cnt'] == -1 && $rdata['max_sql_user_cnt'] != -1) {
            set_page_message(tr('SQL databases limit is <em>disabled</em> but SQL users limit not!'), 'warning');
            $rs = false;
        } else {
            $rs = _check_new_limit($rdata['max_sql_db_cnt'], $rsql_db_current, $usql_db_current, $usql_db_uf, tr('SQL Databases'));
        }
    }
    if (!$rs) {
        $errFields[] = 'SQLD_ERR';
    }
    /**
     * Check for new Sql users limit
     */
    if (!($rs = easyscp_limit_check($rdata['max_sql_user_cnt']))) {
        set_page_message(tr('Incorrect SQL users limit!'), 'warning');
    } else {
        if ($rdata['max_sql_db_cnt'] != -1 && $rdata['max_sql_user_cnt'] == -1) {
            set_page_message(tr('SQL users limit is <em>disabled</em> but SQL databases limit not!'), 'warning');
            $rs = false;
        } else {
            $rs = _check_new_limit($rdata['max_sql_user_cnt'], $rsql_user_current, $usql_user_current, $usql_user_uf, tr('SQL Users'));
        }
    }
    if (!$rs) {
        $errFields[] = 'SQLU_ERR';
    }
    /**
     * Check for new traffic limit
     */
    if (easyscp_limit_check($rdata['max_traff_amnt'], null)) {
        $rs = _check_new_limit($rdata['max_traff_amnt'], $rtraff_current, $utraff_current / 1024 / 1024, $utraff_uf, tr('Web Traffic'));
    } else {
        set_page_message(tr('Incorrect traffic limit!'), 'warning');
        $rs = false;
    }
    if (!$rs) {
        $errFields[] = 'TRF_ERR';
    }
    /**
     * Check for new diskspace limit
     */
    if (easyscp_limit_check($rdata['max_disk_amnt'], null)) {
        $rs = _check_new_limit($rdata['max_disk_amnt'], $rdisk_current, $udisk_current / 1024 / 1024, $udisk_uf, tr('Disk storage'));
    } else {
        set_page_message(tr('Incorrect disk quota limit!'), 'warning');
        $rs = false;
    }
    if (!$rs) {
        $errFields[] = 'DISK_ERR';
    }
    /**
     * Check for IP adresses
     */
    if ($rdata['reseller_ips'] == '') {
        set_page_message(tr('You must assign at least one IP number for a reseller!'), 'warning');
    }
    check_user_ip_data($rdata['edit_id'], $rdata['rip_lst'], $rdata['reseller_ips']);
}