示例#1
0
/**
 * @param iMSCP_pTemplate $tpl
 * @param $user_id
 */
function gen_reseller_personal_data($tpl, $user_id)
{
    $cfg = iMSCP_Registry::get('config');
    $query = "\n\t\tSELECT\n\t\t\t`fname`,\n\t\t\t`lname`,\n\t\t\t`gender`,\n\t\t\t`firm`,\n\t\t\t`zip`,\n\t\t\t`city`,\n\t\t\t`state`,\n\t\t\t`country`,\n\t\t\t`street1`,\n\t\t\t`street2`,\n\t\t\t`email`,\n\t\t\t`phone`,\n\t\t\t`fax`\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_id` = ?\n\t";
    $rs = exec_query($query, $user_id);
    $tpl->assign(array('FIRST_NAME' => $rs->fields['fname'] == null ? '' : tohtml($rs->fields['fname']), 'LAST_NAME' => $rs->fields['lname'] == null ? '' : tohtml($rs->fields['lname']), 'FIRM' => $rs->fields['firm'] == null ? '' : tohtml($rs->fields['firm']), 'ZIP' => $rs->fields['zip'] == null ? '' : tohtml($rs->fields['zip']), 'CITY' => $rs->fields['city'] == null ? '' : tohtml($rs->fields['city']), 'STATE' => $rs->fields['state'] == null ? '' : tohtml($rs->fields['state']), 'COUNTRY' => $rs->fields['country'] == null ? '' : tohtml($rs->fields['country']), 'STREET_1' => $rs->fields['street1'] == null ? '' : tohtml($rs->fields['street1']), 'STREET_2' => $rs->fields['street2'] == null ? '' : tohtml($rs->fields['street2']), 'EMAIL' => $rs->fields['email'] == null ? '' : tohtml($rs->fields['email']), 'PHONE' => $rs->fields['phone'] == null ? '' : tohtml($rs->fields['phone']), 'FAX' => $rs->fields['fax'] == null ? '' : tohtml($rs->fields['fax']), 'VL_MALE' => $rs->fields['gender'] == 'M' ? $cfg->HTML_SELECTED : '', 'VL_FEMALE' => $rs->fields['gender'] == 'F' ? $cfg->HTML_SELECTED : '', 'VL_UNKNOWN' => $rs->fields['gender'] == 'U' || empty($rs->fields['gender']) ? $cfg->HTML_SELECTED : ''));
}
示例#2
0
/**
 * Generates directories list.
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @return void
 */
function client_generateDirectoriesList($tpl)
{
    // Initialize variables
    $path = isset($_GET['cur_dir']) ? clean_input($_GET['cur_dir']) : '';
    $domain = $_SESSION['user_logged'];
    // Create the virtual file system and open it so it can be used
    $vfs = new iMSCP_VirtualFileSystem($domain);
    // Get the directory listing
    $list = $vfs->ls($path);
    if (!$list) {
        set_page_message(tr('Unable to retrieve directories list for your domain. Please contact your reseller.'), 'error');
        $tpl->assign('FTP_CHOOSER', '');
        return;
    }
    // Show parent directory link
    $parent = explode('/', $path);
    array_pop($parent);
    $parent = implode('/', $parent);
    $tpl->assign(array('ACTION_LINK' => '', 'ACTION' => '', 'ICON' => 'parent', 'DIR_NAME' => tr('Parent directory'), 'LINK' => "ftp_choose_dir.php?cur_dir={$parent}"));
    $tpl->parse('DIR_ITEM', '.dir_item');
    // Show directories only
    foreach ($list as $entry) {
        $directory = $path . '/' . $entry['file'];
        if ($entry['type'] != iMSCP_VirtualFileSystem::VFS_TYPE_DIR || ($entry['file'] == '.' || $entry['file'] == '..') || !isAllowedDir(get_user_domain_id($_SESSION['user_id']), $directory)) {
            continue;
        }
        // Create the directory link
        $tpl->assign(array('DIR_NAME' => tohtml($entry['file']), 'CHOOSE_IT' => $directory, 'LINK' => 'ftp_choose_dir.php?cur_dir=' . $directory));
        $tpl->parse('ACTION_LINK', 'action_link');
        $tpl->parse('DIR_ITEM', '.dir_item');
    }
}
示例#3
0
/**
 * Generate page
 *
 * @param  iMSCP_pTemplate $tpl
 * @return void
 */
function admin_generatePage($tpl)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    if (!isset($cfg['CHECK_FOR_UPDATES']) || !$cfg['CHECK_FOR_UPDATES']) {
        set_page_message(tr('i-MSCP version update checking is disabled'), 'static_warning');
    } else {
        /** @var iMSCP_Update_Version $updateVersion */
        $updateVersion = iMSCP_Update_Version::getInstance();
        if ($updateVersion->isAvailableUpdate()) {
            if ($updateInfo = $updateVersion->getUpdateInfo()) {
                $date = new DateTime($updateInfo['published_at']);
                $tpl->assign(array('TR_UPDATE_INFO' => tr('Update info'), 'TR_RELEASE_VERSION' => tr('Release version'), 'RELEASE_VERSION' => tohtml($updateInfo['tag_name']), 'TR_RELEASE_DATE' => tr('Release date'), 'RELEASE_DATE' => tohtml($date->format($cfg['DATE_FORMAT'])), 'TR_RELEASE_DESCRIPTION' => tr('Release description'), 'RELEASE_DESCRIPTION' => tohtml($updateInfo['body']), 'TR_DOWNLOAD_LINKS' => tr('Download links'), 'TR_DOWNLOAD_ZIP' => tr('Download ZIP'), 'TR_DOWNLOAD_TAR' => tr('Download TAR'), 'TARBALL_URL' => tohtml($updateInfo['tarball_url']), 'ZIPBALL_URL' => tohtml($updateInfo['zipball_url'])));
                return;
            } else {
                set_page_message($updateVersion->getError(), 'error');
            }
        } elseif ($updateVersion->getError()) {
            set_page_message($updateVersion, 'error');
        } else {
            set_page_message(tr('No update available'), 'static_info');
        }
    }
    $tpl->assign('UPDATE_INFO', '');
}
示例#4
0
/**
 * Generate graph list
 *
 * @param TemplateEngine $tpl
 * @param string $graphName Graphic name
 * @param string $showWhen Period to show
 */
function selectedGraphic($tpl, $graphName, $showWhen)
{
    $cfg = Registry::get('config');
    /** @var PluginManager $pluginManager */
    $pluginManager = Registry::get('pluginManager');
    $graphDirectory = $pluginManager->pluginGetDirectory() . '/Monitorix/themes/default/assets/images/graphs';
    $monitorixGraphics = array();
    if ($dirHandle = @opendir($graphDirectory)) {
        while (($file = @readdir($dirHandle)) !== false) {
            if (!is_dir($file) && preg_match("/^{$graphName}\\d+[a-y]?[z]\\.\\d{$showWhen}\\.png/", $file)) {
                array_push($monitorixGraphics, $file);
            }
        }
        closedir($dirHandle);
        if (count($monitorixGraphics) > 0) {
            sort($monitorixGraphics);
            foreach ($monitorixGraphics as $graphValue) {
                $tpl->assign('MONITORIXGRAPH', pathinfo($graphValue, PATHINFO_FILENAME) . '.png');
                $tpl->parse('MONITORIX_GRAPH_ITEM', '.monitorix_graph_item');
            }
            $tpl->assign('MONITORIXGRAPH_ERROR', '');
        } else {
            $tpl->assign(array('MONITORIXGRAPH_SELECTED' => '', 'MONITORIXGRAPHIC_ERROR' => tr("No graph for your selection is available")));
        }
    } else {
        $tpl->assign(array('MONITORIXGRAPH_SELECTED' => '', 'MONITORIXGRAPHIC_ERROR' => tr("An error occured while opening the directory: %s", $graphDirectory)));
    }
    $htmlSelected = $cfg['HTML_SELECTED'];
    $tpl->assign(array('M_HOUR_SELECTED' => $showWhen == 'hour' ? $htmlSelected : '', 'M_DAY_SELECTED' => $showWhen == 'day' ? $htmlSelected : '', 'M_WEEK_SELECTED' => $showWhen == 'week' ? $htmlSelected : '', 'M_MONTH_SELECTED' => $showWhen == 'month' ? $htmlSelected : '', 'M_YEAR_SELECTED' => $showWhen == 'year' ? $htmlSelected : '', 'MONITORIXGRAPH_NOT_SELECTED' => ''));
}
示例#5
0
/**
 * Generates page.
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 */
function reseller_generatePage($tpl)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    $query = "SELECT domain_created from admin where admin_id = ?";
    $stmt = exec_query($query, (int) $_SESSION['user_id']);
    $tpl->assign(array('TR_ACCOUNT_SUMMARY' => tr('Account summary'), 'TR_USERNAME' => tr('Username'), 'USERNAME' => tohtml($_SESSION['user_logged']), 'TR_ACCOUNT_TYPE' => tr('Account type'), 'ACCOUNT_TYPE' => $_SESSION['user_type'], 'TR_REGISTRATION_DATE' => tr('Registration date'), 'REGISTRATION_DATE' => $stmt->fields['domain_created'] != 0 ? date($cfg->DATE_FORMAT, $stmt->fields['domain_created']) : tr('Unknown')));
}
示例#6
0
/**
 * Generates page
 *
 * @param  iMSCP_pTemplate $tpl Template engine
 * @return void
 */
function generatePage($tpl)
{
    global $hpId, $dmnName, $adminName, $email, $customerId, $firstName, $lastName, $gender, $firm, $zip, $city, $state, $country, $street1, $street2, $phone, $fax, $domainIp;
    $adminName = decode_idna($adminName);
    $tpl->assign(array('VL_USERNAME' => tohtml($adminName, 'htmlAttr'), 'VL_MAIL' => tohtml($email, 'htmlAttr'), 'VL_USR_ID' => tohtml($customerId, 'htmlAttr'), 'VL_USR_NAME' => tohtml($firstName, 'htmlAttr'), 'VL_LAST_USRNAME' => tohtml($lastName, 'htmlAttr'), 'VL_USR_FIRM' => tohtml($firm, 'htmlAttr'), 'VL_USR_POSTCODE' => tohtml($zip, 'htmlAttr'), 'VL_USRCITY' => tohtml($city, 'htmlAttr'), 'VL_USRSTATE' => tohtml($state, 'htmlAttr'), 'VL_MALE' => $gender == 'M' ? ' selected' : '', 'VL_FEMALE' => $gender == 'F' ? ' selected' : '', 'VL_UNKNOWN' => $gender == 'U' ? ' selected' : '', 'VL_COUNTRY' => tohtml($country, 'htmlAttr'), 'VL_STREET1' => tohtml($street1, 'htmlAttr'), 'VL_STREET2' => tohtml($street2, 'htmlAttr'), 'VL_PHONE' => tohtml($phone, 'htmlAttr'), 'VL_FAX' => tohtml($fax, 'htmlAttr')));
    reseller_generate_ip_list($tpl, $_SESSION['user_id'], $domainIp);
    $_SESSION['local_data'] = "{$dmnName};{$hpId}";
}
/**
 * Generates page.
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @param int $dmn_id Domain unique identifier
 * @return void
 */
function client_generatePage($tpl, &$dmn_id)
{
    if (isset($_GET['uname']) && $_GET['uname'] !== '' && is_numeric($_GET['uname'])) {
        $uuser_id = $_GET['uname'];
        $tpl->assign('UNAME', tohtml(client_getHtaccessUsername($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(client_getHtaccessUsername($uuser_id, $dmn_id)));
            $tpl->assign('UID', $uuser_id);
        } else {
            redirectTo('protected_user_manage.php');
            exit;
            // Useless but avoid stupid IDE warning about possibled undefined variable
        }
    }
    // get groups
    $query = "SELECT * FROM `htaccess_groups` WHERE `dmn_id` = ?";
    $stmt = exec_query($query, $dmn_id);
    if ($stmt->rowCount() == 0) {
        set_page_message(tr('You have no groups.'), 'error');
        redirectTo('protected_user_manage.php');
    } else {
        $added_in = 0;
        $not_added_in = 0;
        while (!$stmt->EOF) {
            $group_id = $stmt->fields['id'];
            $group_name = $stmt->fields['ugroup'];
            $members = $stmt->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->assign(array('GRP_IN' => tohtml($group_name), 'GRP_IN_ID' => $group_id));
                    $tpl->parse('ALREADY_IN', '.already_in');
                    $grp_in = $group_id;
                    $added_in++;
                }
            }
            if ($grp_in !== $group_id) {
                $tpl->assign(array('GRP_NAME' => tohtml($group_name), 'GRP_ID' => $group_id));
                $tpl->parse('GRP_AVLB', '.grp_avlb');
                $not_added_in++;
            }
            $stmt->moveNext();
        }
        // generate add/remove buttons
        if ($added_in < 1) {
            $tpl->assign('IN_GROUP', '');
        }
        if ($not_added_in < 1) {
            $tpl->assign('NOT_IN_GROUP', '');
        }
    }
}
/**
 * Genrate statistics entry for the given user
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @param int $adminId User unique identifier
 * @return void
 */
function _generateUserStatistics($tpl, $adminId)
{
    list($adminName, $domainId, $web, $ftp, $smtp, $pop3, $trafficUsageBytes, $diskspaceUsageBytes) = shared_getCustomerStats($adminId);
    list($usub_current, $usub_max, $uals_current, $uals_max, $umail_current, $umail_max, $uftp_current, $uftp_max, $usql_db_current, $usql_db_max, $usql_user_current, $usql_user_max, $trafficMaxMebimytes, $diskspaceMaxMebibytes) = shared_getCustomerProps($adminId);
    $trafficLimitBytes = $trafficMaxMebimytes * 1048576;
    $diskspaceLimitBytes = $diskspaceMaxMebibytes * 1048576;
    $trafficUsagePercent = make_usage_vals($trafficUsageBytes, $trafficLimitBytes);
    $diskspaceUsagePercent = make_usage_vals($diskspaceUsageBytes, $diskspaceLimitBytes);
    $tpl->assign(array('USER_NAME' => tohtml(decode_idna($adminName)), 'USER_ID' => tohtml($adminId), 'TRAFF_PERCENT' => tohtml($trafficUsagePercent), 'TRAFF_MSG' => $trafficLimitBytes ? tohtml(tr('%s of %s', bytesHuman($trafficUsageBytes), bytesHuman($trafficLimitBytes))) : tohtml(tr('%s of unlimited', bytesHuman($trafficUsageBytes))), 'DISK_PERCENT' => tohtml($diskspaceUsagePercent), 'DISK_MSG' => $diskspaceLimitBytes ? tohtml(tr('%s of %s', bytesHuman($diskspaceUsageBytes), bytesHuman($diskspaceLimitBytes))) : tohtml(tr('%s of unlimited', bytesHuman($diskspaceUsageBytes))), 'WEB' => tohtml(bytesHuman($web)), 'FTP' => tohtml(bytesHuman($ftp)), 'SMTP' => tohtml(bytesHuman($smtp)), 'POP3' => tohtml(bytesHuman($pop3)), 'SUB_MSG' => $usub_max ? tohtml(tr('%d of %s', $usub_current, translate_limit_value($usub_max))) : tohtml(translate_limit_value($usub_max)), 'ALS_MSG' => $uals_max ? tohtml(tr('%d of %s', $uals_current, translate_limit_value($uals_max))) : tohtml(translate_limit_value($uals_max)), 'MAIL_MSG' => $umail_max ? tohtml(tr('%d of %s', $umail_current, translate_limit_value($umail_max))) : tohtml(translate_limit_value($umail_max)), 'FTP_MSG' => $uftp_max ? tohtml(tr('%d of %s', $uftp_current, translate_limit_value($uftp_max))) : tohtml(translate_limit_value($uftp_max)), 'SQL_DB_MSG' => $usql_db_max ? tohtml(tr('%d of %s', $usql_db_current, translate_limit_value($usql_db_max))) : tohtml(translate_limit_value($usql_db_max)), 'SQL_USER_MSG' => $usql_user_max ? tohtml(tr('%1$d of %2$d', $usql_user_current, translate_limit_value($usql_user_max))) : tohtml(translate_limit_value($usql_user_max))));
}
示例#9
0
/**
 * Generate page
 *
 * @param iMSCP_pTemplate $tpl
 * @param int $id Sql user id
 * @return array
 */
function client_generatePage($tpl, $id)
{
    $stmt = exec_query('SELECT sqlu_name, sqlu_host, sqlu_pass FROM sql_user WHERE sqlu_id = ?', $id);
    if (!$stmt->rowCount()) {
        showBadRequestErrorPage();
    }
    $row = $stmt->fetchRow(PDO::FETCH_ASSOC);
    $tpl->assign(array('USER_NAME' => tohtml($row['sqlu_name']), 'ID' => tohtml($id)));
    return array($row['sqlu_name'], $row['sqlu_host'], $row['sqlu_pass']);
}
示例#10
0
/**
 * Generates statistics for the given user
 *
 * @access private
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @param int $adminId User unique identifier
 * @return void
 */
function _generateUserStatistics($tpl, $adminId)
{
    list($adminName, , $webTraffic, $ftpTraffic, $smtpTraffic, $popImapTraffic, $trafficUsageBytes, $diskspaceUsageBytes) = shared_getCustomerStats($adminId);
    list($subCount, $subMax, $alsCount, $alsMax, $mailCount, $mailMax, $ftpUserCount, $FtpUserMax, $sqlDbCount, $sqlDbMax, $sqlUserCount, $sqlUserMax, $trafficLimit, $diskspaceLimit) = shared_getCustomerProps($adminId);
    $trafficLimitBytes = $trafficLimit * 1048576;
    $diskspaceLimitBytes = $diskspaceLimit * 1048576;
    $trafficPercent = make_usage_vals($trafficUsageBytes, $trafficLimitBytes);
    $diskPercent = make_usage_vals($diskspaceUsageBytes, $diskspaceLimitBytes);
    $tpl->assign(array('USER_ID' => tohtml($adminId), 'USERNAME' => tohtml(decode_idna($adminName)), 'TRAFF_PERCENT' => tohtml($trafficPercent), 'TRAFF_MSG' => $trafficLimitBytes ? tohtml(tr('%1$s / %2$s', bytesHuman($trafficUsageBytes), bytesHuman($trafficLimitBytes))) : tohtml(tr('%s / unlimited', bytesHuman($trafficUsageBytes))), 'DISK_PERCENT' => tohtml($diskPercent), 'DISK_MSG' => $diskspaceLimitBytes ? tohtml(tr('%1$s / %2$s', bytesHuman($diskspaceUsageBytes), bytesHuman($diskspaceLimitBytes))) : tohtml(tr('%s / unlimited', bytesHuman($diskspaceUsageBytes))), 'WEB' => tohtml(bytesHuman($webTraffic)), 'FTP' => tohtml(bytesHuman($ftpTraffic)), 'SMTP' => tohtml(bytesHuman($smtpTraffic)), 'POP3' => tohtml(bytesHuman($popImapTraffic)), 'SUB_MSG' => $subMax ? $subMax > 0 ? tohtml(tr('%1$d / %2$d', $subCount, $subMax)) : tohtml(tr('disabled')) : tohtml(tr('%d / unlimited', $subCount)), 'ALS_MSG' => $alsMax ? $alsMax > 0 ? tohtml(tr('%1$d / %2$d', $alsCount, $alsMax)) : tohtml(tr('disabled')) : tohtml(tr('%d / unlimited', $alsCount)), 'MAIL_MSG' => $mailMax ? $mailMax > 0 ? tohtml(tr('%1$d / %2$d', $mailCount, $mailMax)) : tohtml(tr('disabled')) : tohtml(tr('%d / unlimited', $mailCount)), 'FTP_MSG' => $FtpUserMax ? $FtpUserMax > 0 ? tohtml(tr('%1$d / %2$d', $ftpUserCount, $FtpUserMax)) : tohtml(tr('disabled')) : tohtml(tr('%d / unlimited', $ftpUserCount)), 'SQL_DB_MSG' => $sqlDbMax ? $sqlDbMax > 0 ? tohtml(tr('%1$d / %2$d', $sqlDbCount, $sqlDbMax)) : tohtml(tr('disabled')) : tohtml(tr('%d / unlimited', $sqlDbCount)), 'SQL_USER_MSG' => $sqlUserMax ? $sqlUserMax > 0 ? tohtml(tr('%1$d / %2$d', $sqlUserCount, $sqlUserMax)) : tohtml(tr('disabled')) : tohtml(tr('%d / unlimited', $sqlUserCount))));
}
示例#11
0
/**
 * Generates statistics for the given reseller
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @param int $resellerId Reseller unique identifier
 * @param string $resellerName Reseller name
 * @return void
 */
function _generateResellerStatistics($tpl, $resellerId, $resellerName)
{
    $resellerProps = imscp_getResellerProperties($resellerId, true);
    list($udmn_current, , , $usub_current, , , $uals_current, , , $umail_current, , , $uftp_current, , , $usql_db_current, , , $usql_user_current, , , $utraff_current, , , $udisk_current, ) = generate_reseller_users_props($resellerId);
    $trafficLimitBytes = $resellerProps['max_traff_amnt'] * 1048576;
    $trafficUsageBytes = $resellerProps['current_traff_amnt'] * 1048576;
    $diskspaceLimitBytes = $resellerProps['max_disk_amnt'] * 1048576;
    $diskspaceUsageBytes = $resellerProps['current_disk_amnt'] * 1048576;
    $trafficUsagePercent = make_usage_vals($trafficUsageBytes, $trafficLimitBytes);
    $diskspaceUsagePercent = make_usage_vals($diskspaceUsageBytes, $diskspaceLimitBytes);
    $tpl->assign(array('RESELLER_NAME' => tohtml($resellerName), 'RESELLER_ID' => tohtml($resellerId), 'TRAFFIC_PERCENT' => tohtml($trafficUsagePercent), 'TRAFFIC_MSG' => $trafficLimitBytes ? tohtml(tr('%1$s / %2$s of %3$s', bytesHuman($utraff_current), bytesHuman($trafficUsageBytes), bytesHuman($trafficLimitBytes))) : tohtml(tr('%1$s / %2$s of unlimited', bytesHuman($utraff_current), bytesHuman($trafficUsageBytes))), 'DISK_PERCENT' => tohtml($diskspaceUsagePercent), 'DISK_MSG' => $diskspaceLimitBytes ? tohtml(tr('%1$s / %2$s of %3$s', bytesHuman($udisk_current), bytesHuman($diskspaceUsageBytes), bytesHuman($diskspaceLimitBytes))) : tohtml(tr('%1$s / %2$s of unlimited', bytesHuman($udisk_current), bytesHuman($diskspaceUsageBytes))), 'DMN_MSG' => $resellerProps['max_dmn_cnt'] ? tohtml(tr('%1$d / %2$d of %3$d', $udmn_current, $resellerProps['current_dmn_cnt'], $resellerProps['max_dmn_cnt'])) : tohtml(tr('%1$d / %2$d of unlimited', $udmn_current, $resellerProps['current_dmn_cnt'])), 'SUB_MSG' => $resellerProps['max_sub_cnt'] > 0 ? tohtml(tr('%1$d / %2$d of %3$d', $usub_current, $resellerProps['current_sub_cnt'], $resellerProps['max_sub_cnt'])) : ($resellerProps['max_sub_cnt'] == '-1' ? tohtml(tr('disabled')) : tohtml(tr('%1$d / %2$d of unlimited', $usub_current, $resellerProps['current_sub_cnt']))), 'ALS_MSG' => $resellerProps['max_als_cnt'] > 0 ? tohtml(tr('%1$d / %2$d of %3$d', $uals_current, $resellerProps['current_als_cnt'], $resellerProps['max_als_cnt'])) : ($resellerProps['max_als_cnt'] == '-1' ? tohtml(tr('disabled')) : tohtml(tr('%1$d / %2$d of unlimited', $uals_current, $resellerProps['current_als_cnt']))), 'MAIL_MSG' => $resellerProps['max_mail_cnt'] > 0 ? tohtml(tr('%1$d / %2$d of %3$d', $umail_current, $resellerProps['current_mail_cnt'], $resellerProps['max_mail_cnt'])) : ($resellerProps['max_mail_cnt'] == '-1' ? tohtml(tr('disabled')) : tohtml(tr('%1$d / %2$d of unlimited', $umail_current, $resellerProps['current_mail_cnt']))), 'FTP_MSG' => $resellerProps['max_ftp_cnt'] > 0 ? tohtml(tr('%1$d / %2$d of %3$d', $uftp_current, $resellerProps['current_ftp_cnt'], $resellerProps['max_ftp_cnt'])) : ($resellerProps['max_ftp_cnt'] == '-1' ? tohtml(tr('disabled')) : tohtml(tr('%1$d / %2$d of unlimited', $uftp_current, $resellerProps['current_ftp_cnt']))), 'SQL_DB_MSG' => $resellerProps['max_sql_db_cnt'] > 0 ? tohtml(tr('%1$d / %2$d of %3$d', $usql_db_current, $resellerProps['current_sql_db_cnt'], $resellerProps['max_sql_db_cnt'])) : ($resellerProps['max_sql_db_cnt'] == '-1' ? tohtml(tr('disabled')) : tohtml(tr('%1$d / %2$d of unlimited', $usql_db_current, $resellerProps['current_sql_db_cnt']))), 'SQL_USER_MSG' => $resellerProps['max_sql_user_cnt'] > 0 ? tohtml(tr('%1$d / %2$d of %3$d', $usql_user_current, $resellerProps['current_sql_user_cnt'], $resellerProps['max_sql_user_cnt'])) : ($resellerProps['max_sql_user_cnt'] == '-1' ? tohtml(tr('disabled')) : tohtml(tr('%1$d / %2$d of unlimited', $usql_user_current, $resellerProps['current_sql_user_cnt'])))));
}
示例#12
0
/**
 * Generate PHP editor block
 *
 * @param iMSCP_pTemplate $tpl
 * @return void
 */
function generatePhpBlock($tpl)
{
    $phpini = iMSCP_PHPini::getInstance();
    if (!$phpini->resellerHasPermission('phpiniSystem')) {
        $tpl->assign('PHP_EDITOR_BLOCK', '');
    }
    $tpl->assign(array('PHP_EDITOR_YES' => $phpini->clientHasPermission('phpiniSystem') ? ' checked' : '', 'PHP_EDITOR_NO' => $phpini->clientHasPermission('phpiniSystem') ? '' : ' checked', 'TR_PHP_EDITOR' => tr('PHP Editor'), 'TR_PHP_EDITOR_SETTINGS' => tr('PHP Settings'), 'TR_SETTINGS' => tr('PHP Settings'), 'TR_DIRECTIVES_VALUES' => tr('PHP Configuration options'), 'TR_FIELDS_OK' => tr('All fields are valid.'), 'TR_MIB' => tr('MiB'), 'TR_SEC' => tr('Sec.')));
    iMSCP_Events_Aggregator::getInstance()->registerListener('onGetJsTranslations', function ($e) {
        /** @var iMSCP_Events_Event $e */
        $translations = $e->getParam('translations');
        $translations['core']['close'] = tr('Close');
        $translations['core']['fields_ok'] = tr('All fields are valid.');
        $translations['core']['out_of_range_value_error'] = tr('Value for the PHP %%s directive must be in range %%d to %%d.');
        $translations['core']['lower_value_expected_error'] = tr('%%s must be lower than %%s.');
    });
    $permissionsBlock = false;
    if (!$phpini->resellerHasPermission('phpiniAllowUrlFopen')) {
        $tpl->assign('PHP_EDITOR_ALLOW_URL_FOPEN_BLOCK', '');
    } else {
        $tpl->assign(array('TR_CAN_EDIT_ALLOW_URL_FOPEN' => tr('Can edit the PHP %s configuration option', '<b>allow_url_fopen</b>'), 'ALLOW_URL_FOPEN_YES' => $phpini->clientHasPermission('phpiniAllowUrlFopen') ? ' checked' : '', 'ALLOW_URL_FOPEN_NO' => $phpini->clientHasPermission('phpiniAllowUrlFopen') ? '' : ' checked'));
        $permissionsBlock = true;
    }
    if (!$phpini->resellerHasPermission('phpiniDisplayErrors')) {
        $tpl->assign('PHP_EDITOR_DISPLAY_ERRORS_BLOCK', '');
    } else {
        $tpl->assign(array('TR_CAN_EDIT_DISPLAY_ERRORS' => tr('Can edit the PHP %s configuration option', '<b>display_errors</b>'), 'DISPLAY_ERRORS_YES' => $phpini->clientHasPermission('phpiniDisplayErrors') ? ' checked' : '', 'DISPLAY_ERRORS_NO' => $phpini->clientHasPermission('phpiniDisplayErrors') ? '' : ' checked'));
        $permissionsBlock = true;
    }
    $cfg = iMSCP_Registry::get('config');
    if ($cfg['HTTPD_SERVER'] == 'apache_itk') {
        $tpl->assign(array('PHP_EDITOR_DISABLE_FUNCTIONS_BLOCK' => '', 'PHP_EDITOR_MAIL_FUNCTION_BLOCK' => ''));
    } else {
        if ($phpini->resellerHasPermission('phpiniDisableFunctions')) {
            $tpl->assign(array('TR_CAN_EDIT_DISABLE_FUNCTIONS' => tr('Can edit the PHP %s configuration option', '<b>disable_functions</b>'), 'DISABLE_FUNCTIONS_YES' => $phpini->getClientPermission('phpiniDisableFunctions') == 'yes' ? ' checked' : '', 'DISABLE_FUNCTIONS_NO' => $phpini->getClientPermission('phpiniDisableFunctions') == 'no' ? ' checked' : '', 'TR_ONLY_EXEC' => tr('Only exec'), 'DISABLE_FUNCTIONS_EXEC' => $phpini->getClientPermission('phpiniDisableFunctions') == 'exec' ? ' checked' : ''));
        } else {
            $tpl->assign('PHP_EDITOR_DISABLE_FUNCTIONS_BLOCK', '');
        }
        if ($phpini->resellerHasPermission('phpiniMailFunction')) {
            $tpl->assign(array('TR_CAN_USE_MAIL_FUNCTION' => tr('Can use the PHP %s function', '<b>mail</b>'), 'MAIL_FUNCTION_YES' => $phpini->clientHasPermission('phpiniMailFunction') ? ' checked' : '', 'MAIL_FUNCTION_NO' => $phpini->clientHasPermission('phpiniMailFunction') ? '' : ' checked'));
        } else {
            $tpl->assign('PHP_EDITOR_MAIL_FUNCTION_BLOCK', '');
        }
        $permissionsBlock = true;
    }
    if (!$permissionsBlock) {
        $tpl->assign('PHP_EDITOR_PERMISSIONS_BLOCK', '');
    } else {
        $tpl->assign(array('TR_PERMISSIONS' => tr('PHP Permissions'), 'TR_ONLY_EXEC' => tr('Only exec')));
    }
    $tpl->assign(array('TR_POST_MAX_SIZE' => tr('PHP %s configuration option', '<b>post_max_size</b>'), 'POST_MAX_SIZE' => tohtml($phpini->getDomainIni('phpiniPostMaxSize'), 'htmlAttr'), 'TR_UPLOAD_MAX_FILEZISE' => tr('PHP %s configuration option', '<b>upload_max_filesize</b>'), 'UPLOAD_MAX_FILESIZE' => tohtml($phpini->getDomainIni('phpiniUploadMaxFileSize'), 'htmlAttr'), 'TR_MAX_EXECUTION_TIME' => tr('PHP %s configuration option', '<b>max_execution_time</b>'), 'MAX_EXECUTION_TIME' => tohtml($phpini->getDomainIni('phpiniMaxExecutionTime'), 'htmlAttr'), 'TR_MAX_INPUT_TIME' => tr('PHP %s configuration option', '<b>max_input_time</b>'), 'MAX_INPUT_TIME' => tohtml($phpini->getDomainIni('phpiniMaxInputTime'), 'htmlAttr'), 'TR_MEMORY_LIMIT' => tr('PHP %s configuration option', '<b>memory_limit</b>'), 'MEMORY_LIMIT' => tohtml($phpini->getDomainIni('phpiniMemoryLimit'), 'htmlAttr'), 'POST_MAX_SIZE_LIMIT' => tohtml($phpini->getResellerPermission('phpiniPostMaxSize'), 'htmlAttr'), 'UPLOAD_MAX_FILESIZE_LIMIT' => tohtml($phpini->getResellerPermission('phpiniUploadMaxFileSize'), 'htmlAttr'), 'MAX_EXECUTION_TIME_LIMIT' => tohtml($phpini->getResellerPermission('phpiniMaxExecutionTime'), 'htmlAttr'), 'MAX_INPUT_TIME_LIMIT' => tohtml($phpini->getResellerPermission('phpiniMaxInputTime'), 'htmlAttr'), 'MEMORY_LIMIT_LIMIT' => tohtml($phpini->getResellerPermission('phpiniMemoryLimit'), 'htmlAttr')));
}
示例#13
0
/**
 * Generates databases list
 *
 * @param iMSCP_pTemplate $tpl Template engine
 * @param int $dmnId Domain unique identifier
 * @return void
 */
function client_databasesList($tpl, $dmnId)
{
    $stmt = exec_query('SELECT sqld_id, sqld_name FROM sql_database WHERE domain_id = ? ORDER BY sqld_name ', $dmnId);
    if (!$stmt->rowCount()) {
        set_page_message(tr('You do not have databases.'), 'static_info');
        $tpl->assign('SQL_DATABASES_USERS_LIST', '');
    } else {
        while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
            $tpl->assign(array('DB_ID' => $row['sqld_id'], 'DB_NAME' => tohtml($row['sqld_name']), 'DB_NAME_JS' => tojs($row['sqld_name'])));
            _client_generateDatabaseSqlUserList($tpl, $row['sqld_id']);
            $tpl->parse('SQL_DATABASES_LIST', '.sql_databases_list');
        }
    }
}
示例#14
0
/**
 * Hide disabled feature.
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 */
function client_hideDisabledFeatures($tpl)
{
    if (!customerHasFeature('backup')) {
        $tpl->assign('BACKUP_FEATURE', '');
    }
    $webmails = getWebmailList();
    if (!customerHasFeature('mail') || empty($webmails)) {
        $tpl->assign('MAIL_FEATURE', '');
    } else {
        if (in_array('Roundcube', $webmails)) {
            $tpl->assign('WEBMAIL_RPATH', '/webmail');
        } else {
            $tpl->assign('WEBMAIL_RPATH', '/' . strtolower($webmails[0]));
        }
    }
    if (!customerHasFeature('ftp')) {
        $tpl->assign('FTP_FEATURE', '');
    }
    if (!customerHasFeature('aps')) {
        $tpl->assign('APS_FEATURE', '');
    }
    if (!customerHasFeature('webstats')) {
        $tpl->assign('WEBSTATS_FEATURE', '');
    }
}
示例#15
0
/**
 * Generate page
 *
 * @param iMSCP_pTemplate $tpl Template engine
 * @return void
 */
function admin_generateLanguagesList($tpl)
{
    $cfg = iMSCP_Registry::get('config');
    $defaultLanguage = $cfg['USER_INITIAL_LANG'];
    $availableLanguages = i18n_getAvailableLanguages();
    if (!empty($availableLanguages)) {
        foreach ($availableLanguages as $languageDefinition) {
            $tpl->assign(array('LANGUAGE_NAME' => tohtml($languageDefinition['language']), 'NUMBER_TRANSLATED_STRINGS' => tohtml(tr('%d strings translated', $languageDefinition['translatedStrings'])), 'LANGUAGE_REVISION' => tohtml($languageDefinition['revision']), 'LOCALE_CHECKED' => $languageDefinition['locale'] == $defaultLanguage ? 'checked' : '', 'LOCALE' => tohtml($languageDefinition['locale'], 'htmlAttr')));
            $tpl->parse('LANGUAGE_BLOCK', '.language_block');
        }
    } else {
        $tpl->assign('LANGUAGES_BLOCK', '');
    }
}
示例#16
0
/**
 * Generates the page messages to display on client browser
 *
 * Note: The default level for message is sets to 'info'.
 * See the {@link set_page_message()} function for more information.
 *
 * @param  iMSCP_pTemplate $tpl iMSCP_pTemplate instance
 * @return void
 */
function generatePageMessage($tpl)
{
    $namespace = new Zend_Session_Namespace('pageMessages');
    if (Zend_Session::namespaceIsset('pageMessages')) {
        foreach (array('success', 'error', 'warning', 'info', 'static_success', 'static_error', 'static_warning', 'static_info') as $level) {
            if (isset($namespace->{$level})) {
                $tpl->assign(array('MESSAGE_CLS' => $level, 'MESSAGE' => $namespace->{$level}));
                $tpl->parse('PAGE_MESSAGE', '.page_message');
            }
        }
        Zend_Session::namespaceUnset('pageMessages');
    } else {
        $tpl->assign('PAGE_MESSAGE', '');
    }
}
示例#17
0
/**
 * Generate catchall item
 *
 * @param iMSCP_pTemplate $tpl
 * @param string $action Action
 * @param int $dmnId Domain unique identifier
 * @param string $dmnName Domain name
 * @param int $mailId Mail unique identifier
 * @param string $mailAcc Mail account
 * @param string $mailStatus Mail account status
 * @param string $catchallType Catchall type
 * @return void
 */
function client_generateCatchallItem($tpl, $action, $dmnId, $dmnName, $mailId, $mailAcc, $mailStatus, $catchallType)
{
    $showDmnName = decode_idna($dmnName);
    if ($action == 'create') {
        $tpl->assign(array('CATCHALL_DOMAIN' => tohtml($showDmnName), 'CATCHALL_ACC' => tr('None'), 'TR_CATCHALL_STATUS' => tr('N/A'), 'TR_CATCHALL_ACTION' => tr('Create catch all'), 'CATCHALL_ACTION' => $action, 'CATCHALL_ACTION_SCRIPT' => "mail_catchall_add.php?id={$dmnId};{$catchallType}", 'DEL_ICON' => ''));
    } else {
        list($catchallAction, $catchallActionScript) = client_generateAction($mailId, $mailStatus);
        $showDmnName = decode_idna($dmnName);
        $showMailAcc = decode_idna($mailAcc);
        $tpl->assign(array('CATCHALL_DOMAIN' => tohtml($showDmnName), 'CATCHALL_ACC' => tohtml($showMailAcc), 'TR_CATCHALL_STATUS' => translate_dmn_status($mailStatus), 'TR_CATCHALL_ACTION' => $catchallAction, 'CATCHALL_ACTION' => $catchallAction, 'CATCHALL_ACTION_SCRIPT' => $catchallActionScript));
        if ($catchallActionScript == '#') {
            $tpl->assign('DEL_ICON', '');
        }
    }
}
示例#18
0
/**
 * Generate page data
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @param string $ftpUserId Ftp userid
 * @param string $mainDomainName Main domain name
 * @return void
 */
function generatePageData($tpl, $ftpUserId, $mainDomainName)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    $query = "SELECT `homedir` FROM `ftp_users` WHERE `userid` = ?";
    $stmt = exec_query($query, $ftpUserId);
    $ftpHomeDir = $stmt->fields['homedir'];
    $customerHomeDir = $cfg->USER_WEB_DIR . '/' . $mainDomainName;
    if ($ftpHomeDir == $customerHomeDir) {
        $customFtpHomeDir = '/';
    } else {
        $customFtpHomeDir = substr($ftpHomeDir, strlen($customerHomeDir));
    }
    $tpl->assign(array('USERNAME' => tohtml($ftpUserId), 'HOME_DIR' => isset($_POST['home_dir']) ? tohtml($_POST['home_dir']) : tohtml($customFtpHomeDir), 'ID' => tohtml($ftpUserId)));
}
示例#19
0
/**
 * Generate form.
 *
 * @param iMSCP_pTemplate $tpl Template engine
 */
function admin_generateForm($tpl)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    $selected = $cfg->HTML_SELECTED;
    $customMenu = array('menu_id' => '', 'menu_name' => '', 'menu_link' => '', 'menu_target' => '_self', 'menu_level' => 'a', 'menu_order' => '');
    if (empty($_POST) && isset($_GET['edit_id'])) {
        $query = "SELECT * FROM `custom_menus` WHERE `menu_id` = ?";
        $stmt = exec_query($query, (int) $_GET['edit_id']);
        if (!$stmt->rowCount()) {
            set_page_message(tr("The menu you are trying to edit doesn't exist."), 'error');
            redirectTo('custom_menus.php');
        }
        $customMenu = $stmt->fetchRow();
    } elseif (!empty($_POST)) {
        $customMenu = $_POST;
    }
    if (isset($_REQUEST['edit_id'])) {
        $tpl->assign(array('TR_DYNAMIC_TITLE' => tr('Edit custom menu'), 'TR_UPDATE' => tr('Update'), 'EDIT_ID' => tohtml($_REQUEST['edit_id']), 'ADD_MENU' => ''));
    } else {
        $tpl->assign(array('TR_DYNAMIC_TITLE' => tr('Add custom menu'), 'TR_ADD' => tr('Add'), 'EDIT_MENU' => ''));
    }
    foreach (array('_blank', '_parent', '_self', '_top') as $target) {
        $tpl->assign(array('TR_TARGET' => tr('%s page', str_replace('_', '', $target)), 'TARGET_VALUE' => $target, 'SELECTED_TARGET' => $customMenu['menu_target'] == $target ? $selected : ''));
        $tpl->parse('MENU_TARGET_BLOCK', '.menu_target_block');
    }
    foreach (array('A' => tr('Administrator level'), 'R' => tr('Reseller level'), 'C' => tr('Customer level'), 'AR' => tr('Administrator and Reseller levels'), 'AC' => tr('Administrator and customer levels'), 'RC' => tr('Reseller and customer levels'), 'ARC' => tr('All levels')) as $level => $trLevel) {
        $tpl->assign(array('TR_LEVEL' => $trLevel, 'LEVEL_VALUE' => $level, 'SELECTED_LEVEL' => $customMenu['menu_level'] == $level ? $selected : ''));
        $tpl->parse('MENU_LEVEL_BLOCK', '.menu_level_block');
    }
    $tpl->assign(array('MENU_NAME' => tohtml($customMenu['menu_name']), 'MENU_LINK' => tohtml($customMenu['menu_link']), 'MENU_ORDER' => $customMenu['menu_order']));
}
示例#20
0
/**
 * Generates server traffic bar
 *
 * @param  iMSCP_pTemplate $tpl iMSCP_pTemplate instance
 * @return void
 */
function admin_generateServerTrafficInfo($tpl)
{
    $cfg = iMSCP_Registry::get('config');
    $trafficLimitBytes = intval($cfg['SERVER_TRAFFIC_LIMIT']) * 1048576;
    $trafficWarningBytes = intval($cfg['SERVER_TRAFFIC_WARN']) * 1048576;
    if (!$trafficWarningBytes) {
        $trafficWarningBytes = $trafficLimitBytes;
    }
    // Get server traffic usage value in bytes for the current month
    $stmt = exec_query('
            SELECT IFNULL((SUM(bytes_in) + SUM(bytes_out)), 0) AS serverTrafficUsage FROM server_traffic
            WHERE  traff_time BETWEEN ? AND ?
        ', array(getFirstDayOfMonth(), getLastDayOfMonth()));
    if ($stmt->rowCount()) {
        $row = $stmt->fetchRow();
        $trafficUsageBytes = $row['serverTrafficUsage'];
    } else {
        $trafficUsageBytes = 0;
    }
    // Get traffic usage in percent
    $trafficUsagePercent = make_usage_vals($trafficUsageBytes, $trafficLimitBytes);
    if ($trafficLimitBytes) {
        $trafficMessage = tr('%1$s%% [%2$s of %3$s]', $trafficUsagePercent, bytesHuman($trafficUsageBytes), bytesHuman($trafficLimitBytes));
    } else {
        $trafficMessage = tr('%1$s%% [%2$s of unlimited]', $trafficUsagePercent, bytesHuman($trafficUsageBytes));
    }
    // Warning message about traffic
    if ($trafficUsageBytes && ($trafficWarningBytes && $trafficUsageBytes > $trafficWarningBytes || $trafficLimitBytes && $trafficUsageBytes > $trafficLimitBytes)) {
        set_page_message(tr('You are exceeding the monthly server traffic limit.'), 'static_warning');
    }
    $tpl->assign(array('TRAFFIC_WARNING' => $trafficMessage, 'TRAFFIC_PERCENT' => $trafficUsagePercent));
}
/**
 * Generates page.
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @param int $trafficLimit Monthly traffic limit
 * @param int $trafficWarning Traffic warning
 * @return void
 */
function admin_generatePage($tpl, $trafficLimit, $trafficWarning)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    if (empty($_POST)) {
        $trafficLimit = $cfg->SERVER_TRAFFIC_LIMIT;
        $trafficWarning = $cfg->SERVER_TRAFFIC_WARN;
    }
    $tpl->assign(array('MAX_TRAFFIC' => tohtml($trafficLimit), 'TRAFFIC_WARNING' => tohtml($trafficWarning)));
}
示例#22
0
/**
 * Generate page
 *
 * @param iMSCP_pTemplate $tpl
 * @return void
 */
function generatePage($tpl)
{
    $stmt = exec_query('SELECT id, name, status FROM hosting_plans WHERE reseller_id = ? ORDER BY id', $_SESSION['user_id']);
    if (!$stmt->rowCount()) {
        $tpl->assign('HOSTING_PLANS', '');
        set_page_message(tr('No hosting plan available.'), 'static_info');
        return;
    }
    $tpl->assign(array('TR_ID' => tr('Id'), 'TR_NAME' => tr('Name'), 'TR_STATUS' => tr('Status'), 'TR_EDIT' => tr('Edit'), 'TR_ACTION' => tr('Actions'), 'TR_DELETE' => tr('Delete')));
    iMSCP_Events_Aggregator::getInstance()->registerListener('onGetJsTranslations', function ($e) {
        /** @var iMSCP_Events_Event $e */
        $translations = $e->getParam('translations');
        $translations['core']['hp_delete_confirmation'] = tr('Are you sure you want to delete this hosting plan?');
    });
    while ($row = $stmt->fetchRow()) {
        $tpl->assign(array('ID' => $row['id'], 'NAME' => tohtml($row['name']), 'STATUS' => $row['status'] ? tr('Available') : tr('Unavailable')));
        $tpl->parse('HOSTING_PLAN', '.hosting_plan');
    }
}
示例#23
0
/**
 * Generates page
 *
 * @param iMSCP_pTemplate $tpl Template instance engine
 * @param int $domainId Domain unique identifier
 * @return void
 */
function reseller_generatePage($tpl, $domainId)
{
    $stmt = exec_query('
            SELECT
                domain_admin_id
            FROM
                domain
            INNER JOIN
                admin ON(admin_id = domain_admin_id)
            WHERE
                domain_id = ?
            AND
                created_by = ?
        ', array($domainId, $_SESSION['user_id']));
    if (!$stmt->rowCount()) {
        showBadRequestErrorPage();
    }
    $domainAdminId = $stmt->fields['domain_admin_id'];
    $domainProperties = get_domain_default_props($domainAdminId, $_SESSION['user_id']);
    // Domain IP address info
    $stmt = exec_query("SELECT ip_number FROM server_ips WHERE ip_id = ?", $domainProperties['domain_ip_id']);
    if (!$stmt->rowCount()) {
        $domainIpAddr = tr('Not found.');
    } else {
        $domainIpAddr = $stmt->fields['ip_number'];
    }
    $domainStatus = $domainProperties['domain_status'];
    // Domain status
    if ($domainStatus == 'ok' || $domainStatus == 'disabled' || $domainStatus == 'todelete' || $domainStatus == 'toadd' || $domainStatus == 'torestore' || $domainStatus == 'tochange' || $domainStatus == 'toenable' || $domainStatus == 'todisable') {
        $domainStatus = '<span style="color:green">' . tohtml(translate_dmn_status($domainStatus)) . '</span>';
    } else {
        $domainStatus = '<b><font size="3" color="red">' . $domainStatus . "</font></b>";
    }
    // Get total domain traffic usage in bytes
    $query = "\n        SELECT\n            IFNULL(SUM(dtraff_web), 0) AS dtraff_web, IFNULL(SUM(dtraff_ftp), 0) AS dtraff_ftp,\n            IFNULL(SUM(dtraff_mail), 0) AS dtraff_mail, IFNULL(SUM(dtraff_pop), 0) AS dtraff_pop\n        FROM\n            domain_traffic\n        WHERE\n            domain_id = ?\n        AND\n            dtraff_time BETWEEN ? AND ?\n    ";
    $stmt = exec_query($query, array($domainProperties['domain_id'], getFirstDayOfMonth(), getLastDayOfMonth()));
    if ($stmt->rowCount()) {
        $trafficUsageBytes = $stmt->fields['dtraff_web'] + $stmt->fields['dtraff_ftp'] + $stmt->fields['dtraff_mail'] + $stmt->fields['dtraff_pop'];
    } else {
        $trafficUsageBytes = 0;
    }
    // Get limits in bytes
    $trafficLimitBytes = $domainProperties['domain_traffic_limit'] * 1048576;
    $diskspaceLimitBytes = $domainProperties['domain_disk_limit'] * 1048576;
    // Get usages in percent
    $trafficUsagePercent = make_usage_vals($trafficUsageBytes, $trafficLimitBytes);
    $diskspaceUsagePercent = make_usage_vals($domainProperties['domain_disk_usage'], $diskspaceLimitBytes);
    // Get Email quota info
    list($quota, $quotaLimit) = reseller_gen_mail_quota_limit_mgs($domainAdminId);
    # Features
    $trEnabled = '<span style="color:green">' . tr('Enabled') . '</span>';
    $trDisabled = '<span style="color:red">' . tr('Disabled') . '</span>';
    $tpl->assign(array('DOMAIN_ID' => $domainId, 'VL_DOMAIN_NAME' => tohtml(decode_idna($domainProperties['domain_name'])), 'VL_DOMAIN_IP' => tohtml($domainIpAddr), 'VL_STATUS' => $domainStatus, 'VL_PHP_SUPP' => $domainProperties['domain_php'] == 'yes' ? $trEnabled : $trDisabled, 'VL_PHP_EDITOR_SUPP' => $domainProperties['phpini_perm_system'] == 'yes' ? $trEnabled : $trDisabled, 'VL_CGI_SUPP' => $domainProperties['domain_cgi'] == 'yes' ? $trEnabled : $trDisabled, 'VL_DNS_SUPP' => $domainProperties['domain_dns'] == 'yes' ? $trEnabled : $trDisabled, 'VL_EXT_MAIL_SUPP' => $domainProperties['domain_external_mail'] == 'yes' ? $trEnabled : $trDisabled, 'VL_SOFTWARE_SUPP' => $domainProperties['domain_software_allowed'] == 'yes' ? $trEnabled : $trDisabled, 'VL_BACKUP_SUP' => translate_limit_value($domainProperties['allowbackup']), 'VL_TRAFFIC_PERCENT' => $trafficUsagePercent, 'VL_TRAFFIC_USED' => bytesHuman($trafficUsageBytes), 'VL_TRAFFIC_LIMIT' => bytesHuman($trafficLimitBytes), 'VL_DISK_PERCENT' => $diskspaceUsagePercent, 'VL_DISK_USED' => bytesHuman($domainProperties['domain_disk_usage']), 'VL_DISK_LIMIT' => bytesHuman($diskspaceLimitBytes), 'VL_MAIL_ACCOUNTS_USED' => get_domain_running_mail_acc_cnt($domainId), 'VL_MAIL_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_mailacc_limit']), 'VL_MAIL_QUOTA_USED' => $quota, 'VL_MAIL_QUOTA_LIMIT' => $domainProperties['domain_mailacc_limit'] != '-1' ? $quotaLimit : tr('Disabled'), 'VL_FTP_ACCOUNTS_USED' => get_customer_running_ftp_acc_cnt($domainAdminId), 'VL_FTP_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_ftpacc_limit']), 'VL_SQL_DB_ACCOUNTS_USED' => get_domain_running_sqld_acc_cnt($domainId), 'VL_SQL_DB_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_sqld_limit']), 'VL_SQL_USER_ACCOUNTS_USED' => get_domain_running_sqlu_acc_cnt($domainId), 'VL_SQL_USER_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_sqlu_limit']), 'VL_SUBDOM_ACCOUNTS_USED' => get_domain_running_sub_cnt($domainId), 'VL_SUBDOM_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_subd_limit']), 'VL_DOMALIAS_ACCOUNTS_USED' => get_domain_running_als_cnt($domainId), 'VL_DOMALIAS_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_alias_limit'])));
}
示例#24
0
/**
 * Generate List of Domains assigned to IPs
 *
 * @param  iMSCP_pTemplate $tpl Template engine
 * @return void
 */
function listIPDomains($tpl)
{
    $resellerId = $_SESSION['user_id'];
    $stmt = exec_query('SELECT reseller_ips FROM reseller_props WHERE reseller_id = ?', $resellerId);
    $data = $stmt->fetchRow();
    $resellerIps = explode(';', substr($data['reseller_ips'], 0, -1));
    $stmt = execute_query('SELECT ip_id, ip_number FROM server_ips WHERE ip_id IN (' . implode(',', $resellerIps) . ')');
    while ($ip = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
        $stmt2 = exec_query('
				SELECT
					domain_name
				FROM
					domain
				INNER JOIN
					admin ON(admin_id = domain_admin_id)
				WHERE
					domain_ip_id = :ip_id
				AND
					created_by = :reseller_id
				UNION
				SELECT
					alias_name AS domain_name
				FROM
					domain_aliasses
				INNER JOIN
					domain USING(domain_id)
				INNER JOIN
					admin ON(admin_id = domain_admin_id)
				WHERE
					alias_ip_id = :ip_id
				AND
					created_by = :reseller_id
			', array('ip_id' => $ip['ip_id'], 'reseller_id' => $resellerId));
        $domainsCount = $stmt2->rowCount();
        $tpl->assign(array('IP' => tohtml($ip['ip_number']), 'RECORD_COUNT' => tr('Total Domains') . ': ' . $domainsCount));
        if ($domainsCount) {
            while ($data = $stmt2->fetchRow(PDO::FETCH_ASSOC)) {
                $tpl->assign('DOMAIN_NAME', tohtml(idn_to_utf8($data['domain_name'])));
                $tpl->parse('DOMAIN_ROW', '.domain_row');
            }
        } else {
            $tpl->assign('DOMAIN_NAME', tr('No used yet'));
            $tpl->parse('DOMAIN_ROW', 'domain_row');
        }
        $tpl->parse('IP_ROW', '.ip_row');
        $tpl->assign('DOMAIN_ROW', '');
    }
}
示例#25
0
/**
 * Generate page
 *
 * @param iMSCP_pTemplate $tpl
 * @param int $year Year
 * @param int $month Month
 * @param int $day Day
 * @return void
 */
function generatePage($tpl, $year, $month, $day)
{
    $firstHourOfDay = mktime(0, 0, 0, $month, $day, $year);
    $lastHourOfDay = mktime(23, 59, 59, $month, $day, $year);
    $stmt = exec_query('
			SELECT
				traff_time AS period, bytes_in AS all_in, bytes_out AS all_out, bytes_mail_in AS mail_in,
				bytes_mail_out AS mail_out, bytes_pop_in AS pop_in, bytes_pop_out AS pop_out, bytes_web_in AS web_in,
				bytes_web_out AS web_out
			FROM
				server_traffic
			WHERE
				traff_time BETWEEN ? AND ?
		', array($firstHourOfDay, $lastHourOfDay));
    if ($stmt->rowCount()) {
        $all = array_fill(0, 8, 0);
        while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
            $otherIn = $row['all_in'] - ($row['mail_in'] + $row['pop_in'] + $row['web_in']);
            $otherOut = $row['all_out'] - ($row['mail_out'] + $row['pop_out'] + $row['web_out']);
            $tpl->assign(array('HOUR' => tohtml(date('H:i', $row['period'])), 'WEB_IN' => tohtml(bytesHuman($row['web_in'])), 'WEB_OUT' => tohtml(bytesHuman($row['web_out'])), 'SMTP_IN' => tohtml(bytesHuman($row['mail_in'])), 'SMTP_OUT' => tohtml(bytesHuman($row['mail_out'])), 'POP_IN' => tohtml(bytesHuman($row['pop_in'])), 'POP_OUT' => tohtml(bytesHuman($row['pop_out'])), 'OTHER_IN' => tohtml(bytesHuman($otherIn)), 'OTHER_OUT' => tohtml(bytesHuman($otherOut)), 'ALL_IN' => tohtml(bytesHuman($row['all_in'])), 'ALL_OUT' => tohtml(bytesHuman($row['all_out'])), 'ALL' => tohtml(bytesHuman($row['all_in'] + $row['all_out']))));
            $all[0] += $row['web_in'];
            $all[1] += $row['web_out'];
            $all[2] += $row['mail_in'];
            $all[3] += $row['mail_out'];
            $all[4] += $row['pop_in'];
            $all[5] += $row['pop_out'];
            $all[6] += $row['all_in'];
            $all[7] += $row['all_out'];
            $tpl->parse('HOUR_LIST', '.hour_list');
        }
        $allOtherIn = $all[6] - ($all[0] + $all[2] + $all[4]);
        $allOtherOut = $all[7] - ($all[1] + $all[3] + $all[5]);
        $tpl->assign(array('WEB_IN_ALL' => tohtml(bytesHuman($all[0])), 'WEB_OUT_ALL' => tohtml(bytesHuman($all[1])), 'SMTP_IN_ALL' => tohtml(bytesHuman($all[2])), 'SMTP_OUT_ALL' => tohtml(bytesHuman($all[3])), 'POP_IN_ALL' => tohtml(bytesHuman($all[4])), 'POP_OUT_ALL' => tohtml(bytesHuman($all[5])), 'OTHER_IN_ALL' => tohtml(bytesHuman($allOtherIn)), 'OTHER_OUT_ALL' => tohtml(bytesHuman($allOtherOut)), 'ALL_IN_ALL' => tohtml(bytesHuman($all[6])), 'ALL_OUT_ALL' => tohtml(bytesHuman($all[7])), 'ALL_ALL' => tohtml(bytesHuman($all[6] + $all[7]))));
    } else {
        set_page_message(tr('No statistics found for the given period. Try another period.'), 'static_info');
        $tpl->assign('DAY_SERVER_STATISTICS_BLOCK', '');
    }
}
示例#26
0
/**
 * Generates users sessoion list.
 *
 * @param iMSCP_pTemplate $tpl Template engine
 * @return void
 */
function client_generatePage($tpl)
{
    $currentUserSessionId = session_id();
    $query = "SELECT `session_id`, `user_name`, `lastaccess` FROM `login`";
    $stmt = exec_query($query);
    while (!$stmt->EOF) {
        $username = tohtml($stmt->fields['user_name']);
        $sessionId = $stmt->fields['session_id'];
        if ($username === null) {
            $tpl->assign(array('ADMIN_USERNAME' => tr('Unknown'), 'LOGIN_TIME' => date('G:i:s', $stmt->fields['lastaccess'])));
        } else {
            $tpl->assign(array('ADMIN_USERNAME' => $username . ($username == $_SESSION['user_logged'] && $currentUserSessionId !== $sessionId ? ' (' . tr('from other browser') . ')' : ''), 'LOGIN_TIME' => date('G:i:s', $stmt->fields['lastaccess'])));
        }
        if ($currentUserSessionId === $sessionId) {
            // Deletion of our own session is not allowed
            $tpl->assign(array('DISCONNECT_LINK' => 'sessions_manage.php?own=1', 'KILL_LINK' => 'sessions_manage.php?own=1'));
        } else {
            $tpl->assign(array('DISCONNECT_LINK' => "sessions_manage.php?logout_only&kill={$stmt->fields['session_id']}&username={$username}", 'KILL_LINK' => "sessions_manage.php?kill={$stmt->fields['session_id']}&username={$username}"));
        }
        $tpl->parse('USER_SESSION', '.user_session');
        $stmt->moveNext();
    }
}
示例#27
0
/**
 * @param iMSCP_pTemplate $tpl
 * @param $dmn_id
 * @return void
 */
function gen_htaccess_entries($tpl, &$dmn_id)
{
    $query = "SELECT * FROM `htaccess` WHERE `dmn_id` = ?";
    $rs = exec_query($query, $dmn_id);
    if ($rs->recordCount() == 0) {
        $tpl->assign('PROTECTED_AREAS', '');
        set_page_message(tr('You do not have protected areas.'), 'static_info');
    } else {
        $counter = 0;
        while (!$rs->EOF) {
            $tpl->assign('CLASS', $counter % 2 == 0 ? 'content' : 'content2');
            $id = $rs->fields['id'];
            $user_id = $rs->fields['user_id'];
            $group_id = $rs->fields['group_id'];
            $status = $rs->fields['status'];
            $path = $rs->fields['path'];
            $auth_name = $rs->fields['auth_name'];
            $tpl->assign(array('AREA_NAME' => tohtml($auth_name), 'JS_AREA_NAME' => addslashes($auth_name), 'AREA_PATH' => tohtml($path), 'PID' => $id, 'STATUS' => translate_dmn_status($status)));
            $tpl->parse('DIR_ITEM', '.dir_item');
            $rs->moveNext();
            $counter++;
        }
    }
}
示例#28
0
/**
 * Generate List of Domains assigned to IPs
 *
 * @param iMSCP_pTemplate $tpl
 * @return void
 */
function listIPDomains($tpl)
{
    $stmt = execute_query('SELECT ip_id, ip_number FROM server_ips');
    while ($ip = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
        $stmt2 = exec_query('
				SELECT
					t1.domain_name, t3.admin_name
				FROM
					domain AS t1
				INNER JOIN
					admin AS t2 ON(t2.admin_id = t1.domain_admin_id)
				INNER JOIN
					admin as t3 ON(t3.admin_id = t2.created_by)
				WHERE
					t1.domain_ip_id = :ip_id
				UNION
				SELECT
					t1.alias_name AS domain_name, t4.admin_name
				FROM
					domain_aliasses AS t1
				INNER JOIN
					domain AS t2 USING(domain_id)
				INNER JOIN
					admin AS t3 ON(admin_id = domain_admin_id)
				INNER JOIN
					admin AS t4 ON(t4.admin_id = t3.created_by)
				WHERE
					alias_ip_id = :ip_id
			', array('ip_id' => $ip['ip_id']));
        $domainsCount = $stmt2->rowCount();
        $tpl->assign(array('IP' => tohtml($ip['ip_number']), 'RECORD_COUNT' => tr('Total Domains') . ': ' . $domainsCount));
        if ($domainsCount) {
            while ($data = $stmt2->fetchRow(PDO::FETCH_ASSOC)) {
                $tpl->assign(array('DOMAIN_NAME' => tohtml(idn_to_utf8($data['domain_name'])), 'RESELLER_NAME' => tohtml($data['admin_name'])));
                $tpl->parse('DOMAIN_ROW', '.domain_row');
            }
        } else {
            $tpl->assign('DOMAIN_NAME', tr('No used yet'));
            $tpl->parse('DOMAIN_ROW', 'domain_row');
        }
        $tpl->parse('IP_ROW', '.ip_row');
        $tpl->assign('DOMAIN_ROW', '');
    }
}
示例#29
0
/**
 * Generate an external mail server item
 *
 * @access private
 * @param iMSCP_pTemplate $tpl Template instance
 * @param string $externalMail Status of external mail for the domain
 * @param int $domainId Domain id
 * @param string $domainName Domain name
 * @param string $status Item status
 * @param string $type Domain type (normal for domain or alias for domain alias)
 * @return void
 */
function _client_generateItem($tpl, $externalMail, $domainId, $domainName, $status, $type)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    $idnDomainName = decode_idna($domainName);
    $statusOk = 'ok';
    $queryParam = urlencode("{$domainId};{$type}");
    $htmlDisabled = $cfg['HTML_DISABLED'];
    if ($externalMail == 'off') {
        $tpl->assign(array('DOMAIN' => $idnDomainName, 'STATUS' => $status == $statusOk ? tr('Deactivated') : translate_dmn_status($status), 'DISABLED' => $htmlDisabled, 'ITEM_TYPE' => $type, 'ITEM_ID' => $domainId, 'ACTIVATE_URL' => $status == $statusOk ? "mail_external_add.php?item={$queryParam}" : '#', 'TR_ACTIVATE' => $status == $statusOk ? tr('Activate') : tr('N/A'), 'EDIT_LINK' => '', 'DEACTIVATE_LINK' => ''));
        $tpl->parse('ACTIVATE_LINK', 'activate_link');
    } elseif (in_array($externalMail, array('domain', 'wildcard', 'filter'))) {
        $tpl->assign(array('DOMAIN' => $idnDomainName, 'STATUS' => $status == $statusOk ? tr('Activated') : translate_dmn_status($status), 'DISABLED' => $status == $statusOk ? '' : $htmlDisabled, 'ITEM_TYPE' => $type, 'ITEM_ID' => $domainId, 'ACTIVATE_LINK' => '', 'TR_EDIT' => $status == $statusOk ? tr('Edit') : tr('N/A'), 'EDIT_URL' => $status == $statusOk ? "mail_external_edit.php?item={$queryParam}" : '#', 'TR_DEACTIVATE' => $status == $statusOk ? tr('Deactivate') : tr('N/A'), 'DEACTIVATE_URL' => $status == $statusOk ? "mail_external_delete.php?item={$queryParam}" : '#'));
        $tpl->parse('EDIT_LINK', 'edit_link');
        $tpl->parse('DEACTIVATE_LINK', 'deactivate_link');
    }
}
示例#30
0
/**
 * Generates page data
 *
 * @param iMSCP_pTemplate $tpl
 * @return void
 */
function ftp_generatePageData($tpl)
{
    $query = "SELECT `userid` FROM `ftp_users` WHERE `admin_id` = ? ORDER BY LENGTH(`userid`) DESC";
    $stmt = exec_query($query, $_SESSION['user_id']);
    if (!$stmt->rowCount()) {
        set_page_message(tr('You do not have FTP accounts.'), 'static_info');
        $tpl->assign('FTP_ACCOUNTS', '');
    } else {
        /** @var $cfg iMSCP_Config_Handler_File */
        $cfg = iMSCP_Registry::get('config');
        if (!(isset($cfg->FILEMANAGER_PACKAGE) && $cfg->FILEMANAGER_PACKAGE == 'Pydio')) {
            $tpl->assign('FTP_EASY_LOGIN', '');
        }
        $nbFtpAccounts = 0;
        while (!$stmt->EOF) {
            $userid = $stmt->fields['userid'];
            $tpl->assign(array('FTP_ACCOUNT' => tohtml($userid), 'UID' => urlencode($userid)));
            $tpl->parse('FTP_ITEM', '.ftp_item');
            $stmt->moveNext();
            $nbFtpAccounts++;
        }
        $tpl->assign('TOTAL_FTP_ACCOUNTS', $nbFtpAccounts);
    }
}