Beispiel #1
0
/**
 * @param EasySCP_TemplateEngine $tpl
 * @param int $reseller_id
 * @param string $reseller_name
 */
function generate_page_data($tpl, $reseller_id, $reseller_name)
{
    global $crnt_month, $crnt_year;
    $sql = EasySCP_Registry::get('Db');
    $crnt_month = date("m");
    $crnt_year = date("Y");
    // global
    $tmpArr = get_reseller_default_props($sql, $reseller_id);
    if ($tmpArr != NULL) {
        // there are data in db
        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) = $tmpArr;
    } else {
        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) = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }
    list($udmn_current, , , $usub_current, , , $uals_current, , , $umail_current, , , $uftp_current, , , $usql_db_current, , , $usql_user_current, , , $utraff_current, , , $udisk_current) = generate_reseller_user_props($reseller_id);
    // Convert into MB values
    $rtraff_max = $rtraff_max * 1024 * 1024;
    $rtraff_current = $rtraff_current * 1024 * 1024;
    $rdisk_max = $rdisk_max * 1024 * 1024;
    $rdisk_current = $rdisk_current * 1024 * 1024;
    if ($rtraff_max != 0) {
        $traff_percent = sprintf("%.2f", 100 * $utraff_current / $rtraff_max);
    } else {
        $traff_percent = 0;
    }
    gen_traff_usage($tpl, $utraff_current, $rtraff_max, 400);
    gen_disk_usage($tpl, $udisk_current, $rdisk_max, 400);
    if ($rtraff_max > 0) {
        if ($utraff_current > $rtraff_max) {
            $tpl->assign('TR_TRAFFIC_WARNING', tr('You are exceeding your traffic limit!'));
        }
    }
    // warning HDD Usage
    if ($rdisk_max > 0) {
        if ($udisk_current > $rdisk_max) {
            $tpl->assign('TR_DISK_WARNING', tr('You are exceeding your disk limit!'));
        }
    }
    $tpl->assign(array("ACCOUNT_NAME" => tr("Account name"), "GENERAL_INFO" => tr("General information"), "DOMAINS" => tr("User accounts"), "SUBDOMAINS" => tr("Subdomains"), "ALIASES" => tr("Aliases"), "MAIL_ACCOUNTS" => tr("Mail account"), "TR_FTP_ACCOUNTS" => tr("FTP account"), "SQL_DATABASES" => tr("SQL databases"), "SQL_USERS" => tr("SQL users"), "TRAFFIC" => tr("Traffic"), "DISK" => tr("Disk"), "TR_EXTRAS" => tr("Extras")));
    $tpl->assign(array('RESELLER_NAME' => tohtml($reseller_name), 'TRAFF_PERCENT' => $traff_percent, 'TRAFF_MSG' => $rtraff_max ? tr('%1$s used / %2$s assigned of <strong>%3$s</strong>', sizeit($utraff_current), sizeit($rtraff_current), sizeit($rtraff_max)) : tr('%1$s used / %2$s assigned of <strong>unlimited</strong>', sizeit($utraff_current), sizeit($rtraff_current)), 'DISK_MSG' => $rdisk_max ? tr('%1$s used / %2$s assigned of <strong>%3$s</strong>', sizeit($udisk_current), sizeit($rdisk_current), sizeit($rdisk_max)) : tr('%1$s used / %2$s assigned of <strong>unlimited</strong>', sizeit($udisk_current), sizeit($rdisk_current)), 'DMN_MSG' => $rdmn_max ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $udmn_current, $rdmn_current, $rdmn_max) : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $udmn_current, $rdmn_current), 'SUB_MSG' => $rsub_max > 0 ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $usub_current, $rsub_current, $rsub_max) : ($rsub_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $usub_current, $rsub_current)), 'ALS_MSG' => $rals_max > 0 ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $uals_current, $rals_current, $rals_max) : ($rals_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $uals_current, $rals_current)), 'MAIL_MSG' => $rmail_max > 0 ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $umail_current, $rmail_current, $rmail_max) : ($rmail_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $umail_current, $rmail_current)), 'FTP_MSG' => $rftp_max > 0 ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $uftp_current, $rftp_current, $rftp_max) : ($rftp_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $uftp_current, $rftp_current)), 'SQL_DB_MSG' => $rsql_db_max > 0 ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $usql_db_current, $rsql_db_current, $rsql_db_max) : ($rsql_db_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $usql_db_current, $rsql_db_current)), 'SQL_USER_MSG' => $rsql_user_max > 0 ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $usql_user_current, $rsql_user_current, $rsql_user_max) : ($rsql_user_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $usql_user_current, $rsql_user_current)), 'EXTRAS' => ''));
}
Beispiel #2
0
function generate_page_data(&$tpl, $reseller_id, $reseller_name)
{
    global $sql, $crnt_month, $crnt_year;
    $crnt_month = date("m");
    $crnt_year = date("Y");
    //global
    $tmpArr = get_reseller_default_props($sql, $reseller_id);
    //$tmpArr = generate_reseller_props($reseller_id);
    if (NULL !== $tmpArr) {
        // there are data in db
        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) = $tmpArr;
    } else {
        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) = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }
    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_user_props($reseller_id);
    // Convert into MB values
    $rtraff_max = $rtraff_max * 1024 * 1024;
    $rtraff_current = $rtraff_current * 1024 * 1024;
    $rdisk_max = $rdisk_max * 1024 * 1024;
    $rdisk_current = $rdisk_current * 1024 * 1024;
    $utraff_max = $utraff_max * 1024 * 1024;
    $udisk_max = $udisk_max * 1024 * 1024;
    list($traff_percent, $traff_red, $traff_green) = make_usage_vals($utraff_current, $rtraff_max);
    list($disk_percent, $disk_red, $disk_green) = make_usage_vals($udisk_current, $rdisk_max);
    gen_traff_usage($tpl, $utraff_current, $rtraff_max, 400);
    gen_disk_usage($tpl, $udisk_current, $rdisk_max, 400);
    if ($rtraff_max > 0) {
        if ($utraff_current > $rtraff_max) {
            $tpl->assign('TR_TRAFFIC_WARNING', tr('You are exceeding your traffic limit!'));
        } else {
            $tpl->assign('TRAFF_WARN', '');
        }
    } else {
        if ($utraff_current > 1024 * 1024 * 1024 * 1024) {
            $tpl->assign('TR_TRAFFIC_WARNING', tr('You are exceeding your UNLIMITED traffic limit!'));
        } else {
            $tpl->assign('TRAFF_WARN', '');
        }
    }
    //warning HDD Usage
    if ($rdisk_max > 0) {
        if ($udisk_current > $rdisk_max) {
            $tpl->assign('TR_DISK_WARNING', tr('You are exceeding your disk limit!'));
        } else {
            $tpl->assign('DISK_WARN', '');
        }
    } else {
        if ($udisk_current > 1024 * 1024 * 1024 * 1024) {
            $tpl->assign('TR_DISK_WARNING', tr('You are exceeding your UNLIMITED disk limit!'));
        } else {
            $tpl->assign('DISK_WARN', '');
        }
    }
    $tpl->assign(array('ACCOUNT_NAME' => tr("Account name"), 'GENERAL_INFO' => tr("General information"), "DOMAINS" => tr("User accounts"), "SUBDOMAINS" => tr("Subdomains"), "ALIASES" => tr("Aliases"), "MAIL_ACCOUNTS" => tr("Mail account"), "TR_FTP_ACCOUNTS" => tr("FTP account"), "SQL_DATABASES" => tr("SQL databases"), "SQL_USERS" => tr("SQL users"), "TRAFFIC" => tr("Traffic"), "DISK" => tr("Disk"), "TR_EXTRAS" => tr("Extras")));
    $tpl->assign(array('RESELLER_NAME' => $reseller_name, 'TRAFF_RED' => $traff_red * 3, 'TRAFF_GREEN' => $traff_green * 3, 'TRAFF_PERCENT' => $traff_percent, 'TRAFF_USED' => make_hr($utraff_current), 'TRAFF_CURRENT' => make_hr($rtraff_current), 'TRAFF_MAX' => $rtraff_max ? make_hr($rtraff_max) : tr('unlimited'), 'DISK_USED' => make_hr($udisk_current), 'DISK_CURRENT' => make_hr($rdisk_current), 'DISK_MAX' => $rdisk_max ? make_hr($rdisk_max) : tr('unlimited'), 'DMN_USED' => $udmn_current, 'DMN_CURRENT' => $rdmn_current, 'DMN_MAX' => $rdmn_max ? $rdmn_max : tr('unlimited'), 'SUB_USED' => $usub_current, 'SUB_CURRENT' => $rsub_current, 'SUB_MAX' => $rsub_max ? $rsub_max : tr('unlimited'), 'ALS_USED' => $uals_current, 'ALS_CURRENT' => $rals_current, 'ALS_MAX' => $rals_max ? $rals_max : tr('unlimited'), 'MAIL_USED' => $umail_current, 'MAIL_CURRENT' => $rmail_current, 'MAIL_MAX' => $rmail_max ? $rmail_max : tr('unlimited'), 'FTP_USED' => $uftp_current, 'FTP_CURRENT' => $rftp_current, 'FTP_MAX' => $rftp_max ? $rftp_max : tr('unlimited'), 'SQL_DB_USED' => $usql_db_current, 'SQL_DB_CURRENT' => $rsql_db_current, 'SQL_DB_MAX' => $rsql_db_max ? $rsql_db_max : tr('unlimited'), 'SQL_USER_USED' => $usql_user_current, 'SQL_USER_CURRENT' => $rsql_user_current, 'SQL_USER_MAX' => $rsql_user_max ? $rsql_user_max : tr('unlimited'), 'EXTRAS' => ''));
}
Beispiel #3
0
// ska4ashtijat user
if (!isset($_SESSION['logged_from']) && !isset($_SESSION['logged_from_id'])) {
    list($user_def_lang, $user_def_layout) = get_user_gui_props($sql, $_SESSION['user_id']);
} else {
    $user_def_layout = $_SESSION['user_theme_color'];
    $user_def_lang = $_SESSION['user_def_lang'];
}
gen_def_language($tpl, $sql, $user_def_lang);
gen_def_layout($tpl, $sql, $user_def_layout);
$dtraff_pr = 0;
$dmn_traff_usege = 0;
$dmn_traff_limit = $dmn_traff_limit * 1024 * 1024;
list($dtraff_pr, $dmn_traff_usege) = make_traff_usege($_SESSION['user_id']);
$dmn_disk_limit = $dmn_disk_limit * 1024 * 1024;
gen_traff_usage($tpl, $dmn_traff_usege * 1024 * 1024, $dmn_traff_limit, 400);
gen_disk_usage($tpl, $dmn_disk_usage, $dmn_disk_limit, 400);
gen_user_messages_label($tpl, $sql, $_SESSION['user_id']);
check_user_permissions($tpl, $dmn_sqld_limit, $dmn_sqlu_limit, $dmn_php, $dmn_cgi, $dmn_subd_limit, $dmn_als_limit, $dmn_mailacc_limit);
$account_name = decode_idna($_SESSION['user_logged']);
$tpl->assign(array('ACCOUNT_NAME' => $account_name, 'MAIN_DOMAIN' => $dmn_name, 'MYSQL_SUPPORT' => $dmn_sqld_limit != -1 && $dmn_sqlu_limit != -1 ? tr('yes') : tr('no'), 'SUBDOMAINS' => gen_num_limit_msg($sub_cnt, $dmn_subd_limit), 'DOMAIN_ALIASES' => gen_num_limit_msg($als_cnt, $dmn_als_limit), 'MAIL_ACCOUNTS' => gen_num_limit_msg($mail_acc_cnt, $dmn_mailacc_limit), 'FTP_ACCOUNTS' => gen_num_limit_msg($ftp_acc_cnt, $dmn_ftpacc_limit), 'SQL_DATABASES' => gen_num_limit_msg($sqld_acc_cnt, $dmn_sqld_limit), 'SQL_USERS' => gen_num_limit_msg($sqlu_acc_cnt, $dmn_sqlu_limit)));
$tpl->assign(array('TR_CLIENT_MAIN_INDEX_PAGE_TITLE' => tr('VHCS - Client/Main Index'), 'THEME_COLOR_PATH' => "../themes/{$theme_color}", 'THEME_CHARSET' => tr('encoding'), 'TID' => $_SESSION['layout_id'], 'VHCS_LICENSE' => $cfg['VHCS_LICENSE'], 'ISP_LOGO' => get_logo($_SESSION['user_id'])));
/*
 *
 * static page messages.
 *
 */
gen_client_menu($tpl);
gen_logged_from($tpl);
check_permissions($tpl);
$tpl->assign(array('TR_GENERAL_INFORMATION' => tr('General information'), 'TR_ACCOUNT_NAME' => tr('Account name'), 'TR_MAIN_DOMAIN' => tr('Main domain'), 'TR_PHP_SUPPORT' => tr('PHP support'), 'TR_CGI_SUPPORT' => tr('CGI support'), 'TR_MYSQL_SUPPORT' => tr('SQL support'), 'TR_SUBDOMAINS' => tr('Subdomains'), 'TR_DOMAIN_ALIASES' => tr('Domain aliasses'), 'TR_MAIL_ACCOUNTS' => tr('Mail accounts'), 'TR_FTP_ACCOUNTS' => tr('FTP accounts'), 'TR_SQL_DATABASES' => tr('SQL databases'), 'TR_SQL_USERS' => tr('SQL users'), 'TR_MESSAGES' => tr('Support system'), 'TR_LANGUAGE' => tr('Language'), 'TR_CHOOSE_DEFAULT_LANGUAGE' => tr('Choose default language'), 'TR_SAVE' => tr('Save'), 'TR_LAYOUT' => tr('Layout'), 'TR_CHOOSE_DEFAULT_LAYOUT' => tr('Choose default layout'), 'TR_TRAFFIC_USAGE' => tr('Traffic usage'), 'TR_DISK_USAGE' => tr('Disk usage')));
$tpl->parse('PAGE', 'page');
Beispiel #4
0
if (isset($_POST['uaction']) && $_POST['uaction'] === 'save_layout') {
    $user_id = $_SESSION['user_id'];
    $user_layout = $_POST['def_layout'];
    $query = "\n\t\tUPDATE\n\t\t\t`user_gui_props`\n\t\tSET\n\t\t\t`layout` = ?\n\t\tWHERE\n\t\t\t`user_id` = ?\n\t";
    $rs = exec_query($sql, $query, array($user_layout, $user_id));
    $theme_color = $user_layout;
}
$dmn_props = get_domain_default_props($_SESSION['user_id']);
list($sub_cnt, $als_cnt, $mail_acc_cnt, $ftp_acc_cnt, $sqld_acc_cnt, $sqlu_acc_cnt) = get_domain_running_props_cnt($dmn_props['domain_id']);
$dtraff_pr = 0;
$dmn_traff_usage = 0;
$dmn_traff_limit = $dmn_props['domain_traffic_limit'] * 1024 * 1024;
list($dtraff_pr, $dmn_traff_usage) = make_traff_usage($_SESSION['user_id']);
$dmn_disk_limit = $dmn_props['domain_disk_limit'] * 1024 * 1024;
gen_traff_usage($tpl, $dmn_traff_usage * 1024 * 1024, $dmn_traff_limit, 400);
gen_disk_usage($tpl, $dmn_props['domain_disk_usage'], $dmn_disk_limit, 400);
gen_user_messages_label($tpl, $_SESSION['user_id']);
check_user_permissions($tpl, $dmn_props['domain_sqld_limit'], $dmn_props['domain_sqlu_limit'], $dmn_props['domain_php'], $dmn_props['domain_cgi'], $dmn_props['domain_ssl'], $dmn_props['allowbackup'], $dmn_props['domain_dns'], $dmn_props['domain_subd_limit'], $dmn_props['domain_alias_limit'], $dmn_props['domain_mailacc_limit']);
$account_name = decode_idna($_SESSION['user_logged']);
if ($dmn_props['domain_expires'] == 0) {
    $dmn_expires_date = tr('Not Set');
} else {
    $date_formt = $cfg->DATE_FORMAT;
    $dmn_expires_date = "( <strong style=\"text-decoration:underline;\">" . date($date_formt, $dmn_props['domain_expires']) . "</strong> )";
}
list($years, $month, $days, $hours, $minutes, $seconds) = gen_remain_time($dmn_props['domain_expires']);
if (time() < $dmn_props['domain_expires']) {
    if ($years > 0 && $month > 0 && $days <= 14) {
        $tpl->assign(array('DMN_EXPIRES' => $years . " Years, " . $month . " Month, " . $days . " Days"));
    } else {
        $tpl->assign(array('DMN_EXPIRES' => '<span style="color:red">' . $years . " Years, " . $month . " Month, " . $days . " Days</span>"));