Exemplo n.º 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' => ''));
}
Exemplo n.º 2
0
resellerHasFeature('domain_aliases') or showBadRequestErrorPage();
if (is_xhr()) {
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-type: application/json');
    header('Status: 200 OK');
    echo json_encode(reseller_getDatatable());
    exit;
}
/** @var $tpl iMSCP_pTemplate */
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'reseller/alias.tpl', 'page_message' => 'layout', 'als_add_button' => 'page'));
$tpl->assign(array('TR_PAGE_TITLE' => tr('Reseller / Customers / Domain Aliases'), 'TR_ALIAS_NAME' => tr('Domain alias name'), 'TR_MOUNT_POINT' => tr('Mount point'), 'TR_FORWARD_URL' => tr('Forward URL'), 'TR_STATUS' => tr('Status'), 'TR_CUSTOMER' => tr('Customer'), 'TR_ACTIONS' => tr('Actions'), 'TR_ADD_DOMAIN_ALIAS' => tr('Add domain alias'), 'TR_MESSAGE_DELETE_ALIAS' => tr('Are you sure you want to delete the %s domain alias?', '%s'), 'TR_MESSAGE_DELETE_ALIAS_ORDER' => tr('Are you sure you want to delete the %s domain alias order?', '%s'), 'TR_PROCESSING_DATA' => tr('Processing...')));
iMSCP_Events_Aggregator::getInstance()->registerListener('onGetJsTranslations', function ($e) {
    /** @var $e \iMSCP_Events_Event */
    $e->getParam('translations')->core['dataTable'] = getDataTablesPluginTranslations(false);
});
$resellerId = $_SESSION['user_id'];
$resellerProps = imscp_getResellerProperties($resellerId);
if ($resellerProps['max_als_cnt'] != 0) {
    list(, , , , , , $customersAlsCount) = generate_reseller_user_props($resellerId);
    if ($customersAlsCount >= $resellerProps['max_als_cnt'] || $resellerProps['current_als_cnt'] >= $resellerProps['max_als_cnt']) {
        $tpl->assign('ALS_ADD_BUTTON', '');
    }
}
generateNavigation($tpl);
generatePageMessage($tpl);
$tpl->parse('LAYOUT_CONTENT', 'page');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onResellerScriptEnd, array('templateEngine' => $tpl));
$tpl->prnt();
unsetMessages();
Exemplo n.º 3
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' => ''));
}
Exemplo n.º 4
0
/**
 * Generate domain alias list
 *
 * @todo Use prepared statements (min. with placeholders like ":search_for")
 * @param EasySCP_TemplateEngine $tpl
 * @param int $reseller_id
 * @param string $als_err
 */
function generate_als_list($tpl, $reseller_id, &$als_err)
{
    $sql = EasySCP_Registry::get('Db');
    $cfg = EasySCP_Registry::get('Config');
    list(, , , , , , $uals_current) = generate_reseller_user_props($reseller_id);
    list(, , , , , $rals_max) = get_reseller_default_props($sql, $reseller_id);
    if ($uals_current >= $rals_max && $rals_max != "0") {
        $tpl->assign('ALS_ADD_BUTTON', '');
    }
    $start_index = 0;
    $rows_per_page = $cfg->DOMAIN_ROWS_PER_PAGE;
    $current_psi = 0;
    $_SESSION['search_for'] = '';
    $search_common = '';
    $search_for = '';
    if (isset($_GET['psi'])) {
        $start_index = $_GET['psi'];
        $current_psi = $_GET['psi'];
    }
    if (isset($_POST['uaction']) && !empty($_POST['uaction'])) {
        $_SESSION['search_for'] = trim(clean_input($_POST['search_for']));
        $_SESSION['search_common'] = $_POST['search_common'];
        $search_for = $_SESSION['search_for'];
        $search_common = $_SESSION['search_common'];
    } else {
        if (isset($_SESSION['search_for']) && !isset($_GET['psi'])) {
            unset($_SESSION['search_for']);
            unset($_SESSION['search_common']);
        }
    }
    $tpl->assign(array('PSI' => $current_psi, 'SEARCH_FOR' => tohtml($search_for), 'TR_SEARCH' => tr('Search'), 'M_ALIAS_NAME' => tr('Alias name'), 'M_ACCOUNT_NAME' => tr('Account name')));
    if (isset($_SESSION['search_for']) && $_SESSION['search_for'] != '') {
        if (isset($search_common) && $search_common == 'alias_name') {
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tt1.*,\n\t\t\t\t\tt2.`domain_id`,\n\t\t\t\t\tt2.`domain_name`,\n\t\t\t\t\tt2.`domain_created_id`\n\t\t\t\tFROM\n\t\t\t\t\t`domain_aliasses` AS t1,\n\t\t\t\t\t`domain` AS t2\n\t\t\t\tWHERE\n\t\t\t\t\t`alias_name` RLIKE '{$search_for}'\n\t\t\t\tAND\n\t\t\t\t\tt2.`domain_created_id` = ?\n\t\t\t\tAND\n\t\t\t\t\tt1.`domain_id` = t2.`domain_id`\n\t\t\t\tORDER BY\n\t\t\t\t\tt1.`alias_name` ASC\n\t\t\t\tLIMIT\n\t\t\t\t\t{$start_index}, {$rows_per_page}\n\t\t\t";
            // count query
            $count_query = "\n\t\t\t\tSELECT\n\t\t\t\t\tCOUNT(`alias_id`) AS cnt\n\t\t\t\tFROM\n\t\t\t\t\t`domain_aliasses` AS t1,\n\t\t\t\t\t`domain` AS t2\n\t\t\t\tWHERE\n\t\t\t\t\tt2.`domain_created_id` = ?\n\t\t\t\tAND\n\t\t\t\t\t`alias_name` RLIKE '{$search_for}'\n\t\t\t\tAND\n\t\t\t\t\tt1.`domain_id` = t2.`domain_id`\n\t\t\t";
        } else {
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tt1.*,\n\t\t\t\t\tt2.`domain_id`,\n\t\t\t\t\tt2.`domain_name`,\n\t\t\t\t\tt2.`domain_created_id`\n\t\t\t\tFROM\n\t\t\t\t\t`domain_aliasses` AS t1,\n\t\t\t\t\t`domain` AS t2\n\t\t\t\tWHERE\n\t\t\t\t\tt2.`domain_name` RLIKE '{$search_for}'\n\t\t\t\tAND\n\t\t\t\t\tt1.`domain_id` = t2.`domain_id`\n\t\t\t\tAND\n\t\t\t\t\tt2.`domain_created_id` = ?\n\t\t\t\tORDER BY\n\t\t\t\t\tt1.`alias_name` ASC\n\t\t\t\tLIMIT\n\t\t\t\t\t{$start_index}, {$rows_per_page}\n\t\t\t";
            // count query
            $count_query = "\n\t\t\t\tSELECT\n\t\t\t\t\tCOUNT(`alias_id`) AS cnt\n\t\t\t\tFROM\n\t\t\t\t\t`domain_aliasses` AS t1,\n\t\t\t\t\t`domain` AS t2\n\t\t\t\tWHERE\n\t\t\t\t\tt2.`domain_created_id` = ?\n\t\t\t\tAND\n\t\t\t\t\tt2.`domain_name` RLIKE '{$search_for}'\n\t\t\t\tAND\n\t\t\t\t\tt1.`domain_id` = t2.`domain_id`\n\t\t\t";
        }
    } else {
        $query = "\n\t\t\tSELECT\n\t\t\t\tt1.*,\n\t\t\t\tt2.`domain_id`,\n\t\t\t\tt2.`domain_name`,\n\t\t\t\tt2.`domain_created_id`\n\t\t\tFROM\n\t\t\t\t`domain_aliasses` AS t1,\n\t\t\t\t`domain` AS t2\n\t\t\tWHERE\n\t\t\t\tt1.`domain_id` = t2.`domain_id`\n\t\t\tAND\n\t\t\t\tt2.`domain_created_id` = ?\n\t\t\tORDER BY\n\t\t\t\tt1.`alias_name` ASC\n\t\t\tLIMIT\n\t\t\t\t{$start_index}, {$rows_per_page}\n\t\t";
        // count query
        $count_query = "\n\t\t\tSELECT\n\t\t\t\tCOUNT(`alias_id`) AS cnt\n\t\t\tFROM\n\t\t\t\t`domain_aliasses` AS t1,\n\t\t\t\t`domain` AS t2\n\t\t\tWHERE\n\t\t\t\tt1.`domain_id` = t2.domain_id\n\t\t\tAND\n\t\t\t\tt2.`domain_created_id` = ?\n\t\t";
    }
    // let's count
    $rs = exec_query($sql, $count_query, $reseller_id);
    $records_count = $rs->fields['cnt'];
    // Get all alias records
    $rs = exec_query($sql, $query, $reseller_id);
    if ($records_count == 0) {
        if (isset($_SESSION['search_for']) && $_SESSION['search_for'] != '') {
            $tpl->assign(array('TABLE_LIST' => '', 'USERS_LIST' => '', 'SCROLL_PREV' => '', 'SCROLL_NEXT' => '', 'M_DOMAIN_NAME_SELECTED' => '', 'M_ACCOUN_NAME_SELECTED' => ''));
        } else {
            $tpl->assign(array('TABLE_LIST' => '', 'TABLE_HEADER' => '', 'USERS_LIST' => '', 'SCROLL_PREV' => '', 'SCROLL_NEXT' => ''));
        }
        if (isset($_SESSION['search_for'])) {
            $als_err = tr('Not found user records matching the search criteria!');
        } else {
            if (isset($_SESSION['almax'])) {
                if ($_SESSION['almax'] === '_yes_') {
                    $als_err = tr('Domain alias limit reached!');
                } else {
                    $als_err = tr('You have no alias records.');
                }
                unset($_SESSION['almax']);
            } else {
                $als_err = tr('You have no alias records.');
            }
        }
        return;
    } else {
        $prev_si = $start_index - $rows_per_page;
        if ($start_index == 0) {
            $tpl->assign('SCROLL_PREV', '');
        } else {
            $tpl->assign(array('SCROLL_PREV_GRAY' => '', 'PREV_PSI' => $prev_si));
        }
        $next_si = $start_index + $rows_per_page;
        if ($next_si + 1 > $records_count) {
            $tpl->assign('SCROLL_NEXT', '');
        } else {
            $tpl->assign(array('SCROLL_NEXT_GRAY' => '', 'NEXT_PSI' => $next_si));
        }
    }
    if (isset($_SESSION['search_common']) && $_SESSION['search_common'] === 'account_name') {
        $domain_name_selected = '';
        $account_name_selected = $cfg->HTML_SELECTED;
    } else {
        $domain_name_selected = $cfg->HTML_SELECTED;
        $account_name_selected = '';
    }
    $tpl->assign(array('M_DOMAIN_NAME_SELECTED' => $domain_name_selected, 'M_ACCOUN_NAME_SELECTED' => $account_name_selected));
    while (!$rs->EOF) {
        $als_id = $rs->fields['alias_id'];
        $als_name = $rs->fields['alias_name'];
        $als_mount_point = $rs->fields['alias_mount'] != '' ? $rs->fields['alias_mount'] : '/';
        $als_status = $rs->fields['status'];
        $als_ip_id = $rs->fields['alias_ip_id'];
        $als_fwd = $rs->fields['url_forward'];
        $show_als_fwd = $als_fwd == 'no' ? "-" : $als_fwd;
        $domain_name = decode_idna($rs->fields['domain_name']);
        $query = "SELECT `ip_number`, `ip_domain` FROM `server_ips` WHERE `ip_id` = ?";
        $alsip_r = exec_query($sql, $query, $als_ip_id);
        $alsip_d = $alsip_r->fetchRow();
        $als_ip = $alsip_d['ip_number'];
        $als_ip_name = $alsip_d['ip_domain'];
        if ($als_status === $cfg->ITEM_OK_STATUS) {
            $delete_link = "alias_delete.php?del_id=" . $als_id;
            $edit_link = "alias_edit.php?edit_id=" . $als_id;
            $action_text = tr("Delete");
            $edit_text = tr("Edit");
        } else {
            if ($als_status === $cfg->ITEM_ORDERED_STATUS) {
                $delete_link = "alias_order.php?action=delete&amp;del_id=" . $als_id;
                $edit_link = "alias_order.php?action=activate&amp;act_id=" . $als_id;
                $action_text = tr("Delete order");
                $edit_text = tr("Activate");
            } else {
                $delete_link = "#";
                $edit_link = "#";
                $action_text = tr('N/A');
                $edit_text = tr('N/A');
            }
        }
        $als_status = translate_dmn_status($als_status);
        $als_name = decode_idna($als_name);
        $show_als_fwd = decode_idna($show_als_fwd);
        $tpl->append(array('NAME' => tohtml($als_name), 'ALIAS_IP' => tohtml("{$als_ip} ({$als_ip_name})"), 'REAL_DOMAIN' => tohtml($domain_name), 'REAL_DOMAIN_MOUNT' => tohtml($als_mount_point), 'FORWARD' => tohtml($show_als_fwd), 'STATUS' => $als_status, 'ID' => $als_id, 'DELETE' => $action_text, 'DELETE_LINK' => $delete_link, 'EDIT_LINK' => $edit_link, 'EDIT' => $edit_text));
        $rs->moveNext();
    }
}
Exemplo n.º 5
0
/**
 * Generates page data
 *
 * @param iMSCP_pTemplate $tpl Template engine
 * @param int $resellerId Reseller unique identifier
 * @param string $resellerName Reseller name
 * @return void
 */
function reseller_generatePageData($tpl, $resellerId, $resellerName)
{
    $resellerProperties = imscp_getResellerProperties($resellerId);
    list($udmnCurrent, , , $usubCurrent, , , $ualsCurrent, , , $umailCurrent, , , $uftpCurrent, , , $usqlDbCurrent, , , $usqlUserCurrent, , , $utraffCurrent, , , $udiskCurrent) = generate_reseller_user_props($resellerId);
    // Convert into Mib values
    $rtraffMax = $resellerProperties['max_traff_amnt'] * 1024 * 1024;
    $rdiskMax = $resellerProperties['max_disk_amnt'] * 1024 * 1024;
    reseller_generateTrafficUsageBar($tpl, $utraffCurrent, $rtraffMax);
    reseller_generateDiskUsageBar($tpl, $udiskCurrent, $rdiskMax);
    if ($rtraffMax > 0 && $utraffCurrent > $rtraffMax) {
        $tpl->assign('TR_TRAFFIC_WARNING', tr('You are exceeding your monthly traffic limit.'));
    } else {
        $tpl->assign('TRAFFIC_WARNING_MESSAGE', '');
    }
    if ($rdiskMax > 0 && $udiskCurrent > $rdiskMax) {
        $tpl->assign('TR_DISK_WARNING', tr('You are exceeding your disk space limit.'));
    } else {
        $tpl->assign('DISK_WARNING_MESSAGE', '');
    }
    $tpl->assign(array('TR_ACCOUNT_OVERVIEW' => tr('Account overview'), 'TR_ACCOUNT_LIMITS' => tr('Account limits'), 'TR_FEATURES' => tr('Features'), 'ACCOUNT_NAME' => tr('Account name'), 'GENERAL_INFO' => tr('General information'), 'DOMAINS' => tr('Domain accounts'), 'SUBDOMAINS' => tr('Subdomains'), 'ALIASES' => tr('Aliases'), 'MAIL_ACCOUNTS' => tr('Email accounts'), 'TR_FTP_ACCOUNTS' => tr('FTP accounts'), 'SQL_DATABASES' => tr('SQL databases'), 'SQL_USERS' => tr('SQL users'), 'TRAFFIC' => tr("Traffic"), 'DISK' => tr('Disk'), 'RESELLER_NAME' => tohtml($resellerName), 'DMN_MSG' => $resellerProperties['max_dmn_cnt'] ? tr('%1$d / %2$d of %3$d', $udmnCurrent, $resellerProperties['current_dmn_cnt'], $resellerProperties['max_dmn_cnt']) : tr('%1$d / %2$d of unlimited', $udmnCurrent, $resellerProperties['current_dmn_cnt']), 'SUB_MSG' => $resellerProperties['max_sub_cnt'] > 0 ? tr('%1$d / %2$d of %3$d</b>', $usubCurrent, $resellerProperties['current_sub_cnt'], $resellerProperties['max_sub_cnt']) : ($resellerProperties['max_sub_cnt'] == '-1' ? tr('disabled') : tr('%1$d / %2$d of unlimited', $usubCurrent, $resellerProperties['current_sub_cnt'])), 'ALS_MSG' => $resellerProperties['max_als_cnt'] > 0 ? tr('%1$d / %2$d of %3$d', $ualsCurrent, $resellerProperties['current_als_cnt'], $resellerProperties['max_als_cnt']) : ($resellerProperties['max_als_cnt'] == '-1' ? tr('disabled') : tr('%1$d / %2$d of unlimited', $ualsCurrent, $resellerProperties['current_als_cnt'])), 'MAIL_MSG' => $resellerProperties['max_mail_cnt'] > 0 ? tr('%1$d / %2$d of %3$d', $umailCurrent, $resellerProperties['current_mail_cnt'], $resellerProperties['max_mail_cnt']) : ($resellerProperties['max_mail_cnt'] == '-1' ? tr('disabled') : tr('%1$d / %2$d of unlimited', $umailCurrent, $resellerProperties['current_mail_cnt'])), 'FTP_MSG' => $resellerProperties['max_ftp_cnt'] > 0 ? tr('%1$d / %2$d of %3$d', $uftpCurrent, $resellerProperties['current_ftp_cnt'], $resellerProperties['max_ftp_cnt']) : ($resellerProperties['max_ftp_cnt'] == '-1' ? tr('disabled') : tr('%1$d / %2$d of unlimited', $uftpCurrent, $resellerProperties['current_ftp_cnt'])), 'SQL_DB_MSG' => $resellerProperties['max_sql_db_cnt'] > 0 ? tr('%1$d / %2$d of %3$d', $usqlDbCurrent, $resellerProperties['current_sql_db_cnt'], $resellerProperties['max_sql_db_cnt']) : ($resellerProperties['max_sql_db_cnt'] == '-1' ? tr('disabled') : tr('%1$d / %2$d of unlimited', $usqlDbCurrent, $resellerProperties['current_sql_db_cnt'])), 'SQL_USER_MSG' => $resellerProperties['max_sql_db_cnt'] > 0 ? tr('%1$d / %2$d of %3$d', $usqlUserCurrent, $resellerProperties['current_sql_user_cnt'], $resellerProperties['max_sql_user_cnt']) : ($resellerProperties['max_sql_user_cnt'] == '-1' ? tr('disabled') : tr('%1$d / %2$d of unlimited', $usqlUserCurrent, $resellerProperties['current_sql_user_cnt'])), 'TR_SUPPORT' => tr('Support system'), 'SUPPORT_STATUS' => $resellerProperties['support_system'] == 'yes' ? '<span style="color:green;">' . tr('Enabled') . '</span>' : '<span style="color:red;">' . tr('Disabled') . '</span>', 'TR_PHP_EDITOR' => tr('PHP Editor'), 'PHP_EDITOR_STATUS' => $resellerProperties['php_ini_system'] == 'yes' ? '<span style="color:green;">' . tr('Enabled') . '</span>' : '<span style="color:red;">' . tr('Disabled') . '</span>', 'TR_APS' => tr('Software installer'), 'APS_STATUS' => $resellerProperties['software_allowed'] == 'yes' ? '<span style="color:green;">' . tr('Enabled') . '</span>' : '<span style="color:red;">' . tr('Disabled') . '</span>'));
}
Exemplo n.º 6
0
/**
 * Show data fields
 *
 * @global string $alias_name
 * @global string $forward
 * @global string $forward_prefix
 * @global string $mount_point
 * @param EasySCP_TemplateEngine $tpl
 * @param int $reseller_id
 */
function gen_al_page($tpl, $reseller_id)
{
    global $alias_name, $forward, $forward_prefix, $mount_point;
    $sql = EasySCP_Registry::get('Db');
    $cfg = EasySCP_Registry::get('Config');
    list(, , , , , , $uals_current) = generate_reseller_user_props($reseller_id);
    list(, , , , , $rals_max) = get_reseller_default_props($sql, $reseller_id);
    if ($uals_current >= $rals_max && $rals_max != "0") {
        $_SESSION['almax'] = '_yes_';
        user_goto('alias.php');
    }
    if (isset($_POST['status']) && $_POST['status'] == 1) {
        $forward_prefix = clean_input($_POST['forward_prefix']);
        if ($_POST['status'] == 1) {
            $check_en = $cfg->HTML_CHECKED;
            $check_dis = '';
            $forward = encode_idna(strtolower(clean_input($_POST['forward'])));
            $tpl->assign(array('READONLY_FORWARD' => '', 'DISABLE_FORWARD' => ''));
        } else {
            $check_en = '';
            $check_dis = $cfg->HTML_CHECKED;
            $forward = '';
            $tpl->assign(array('READONLY_FORWARD' => $cfg->HTML_READONLY, 'DISABLE_FORWARD' => $cfg->HTML_DISABLED));
        }
        $tpl->assign(array('HTTP_YES' => $forward_prefix === 'http://' ? $cfg->HTML_SELECTED : '', 'HTTPS_YES' => $forward_prefix === 'https://' ? $cfg->HTML_SELECTED : '', 'FTP_YES' => $forward_prefix === 'ftp://' ? $cfg->HTML_SELECTED : ''));
    } else {
        $check_en = '';
        $check_dis = $cfg->HTML_CHECKED;
        $forward = '';
        $tpl->assign(array('READONLY_FORWARD' => $cfg->HTML_READONLY, 'DISABLE_FORWARD' => $cfg->HTML_DISABLED, 'HTTP_YES' => '', 'HTTPS_YES' => '', 'FTP_YES' => ''));
    }
    $tpl->assign(array('DOMAIN' => tohtml(decode_idna($alias_name)), 'MP' => tohtml($mount_point), 'FORWARD' => tohtml(encode_idna($forward)), 'CHECK_EN' => $check_en, 'CHECK_DIS' => $check_dis));
    generate_ip_list($tpl, $reseller_id);
    gen_users_list($tpl, $reseller_id);
}