/** * 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', ''); }
/** * 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'); } }
/** * 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' => '')); }
/** * 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', ''); } } }
/** * 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'))); }
/** * 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'); } } }
/** * 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', ''); } }
/** * 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', ''); } }
/** * 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', ''); } } }
/** * 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', ''); } }
/** * @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 : '')); }
/** * 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'))); }
/** * 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}"; }
/** * 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'); } }
/** * 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', ''); } }
/** * 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', ''); } }
/** * 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']); }
/** * 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)))); }
/** * 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'); } }
/** * 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)))); }
/** * 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']))))); }
/** * 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', ''); } }
/** * 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(); } }
/** * 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))); }
/** * 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); } }
/** * @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++; } } }
/** * Generate page * * @param iMSCP_pTemplate $tpl * @return void */ function client_generatePage($tpl) { $cfg = iMSCP_Registry::get('config'); if ($cfg['MYSQL_PREFIX'] == 'yes') { $tpl->assign('MYSQL_PREFIX_YES', ''); if ($cfg['MYSQL_PREFIX_TYPE'] == 'behind') { $tpl->assign('MYSQL_PREFIX_INFRONT', ''); $tpl->parse('MYSQL_PREFIX_BEHIND', 'mysql_prefix_behind'); $tpl->assign('MYSQL_PREFIX_ALL', ''); } else { $tpl->parse('MYSQL_PREFIX_INFRONT', 'mysql_prefix_infront'); $tpl->assign(array('MYSQL_PREFIX_BEHIND' => '', 'MYSQL_PREFIX_ALL' => '')); } } else { $tpl->assign(array('MYSQL_PREFIX_NO' => '', 'MYSQL_PREFIX_INFRONT' => '', 'MYSQL_PREFIX_BEHIND' => '')); $tpl->parse('MYSQL_PREFIX_ALL', 'mysql_prefix_all'); } if (isset($_POST['uaction']) && $_POST['uaction'] == 'add_db') { $tpl->assign(array('DB_NAME' => clean_input($_POST['db_name'], true), 'USE_DMN_ID' => isset($_POST['use_dmn_id']) && $_POST['use_dmn_id'] === 'on' ? $cfg['HTML_CHECKED'] : '', 'START_ID_POS_SELECTED' => isset($_POST['id_pos']) && $_POST['id_pos'] !== 'end' ? $cfg['HTML_CHECKED'] : '', 'END_ID_POS_SELECTED' => isset($_POST['id_pos']) && $_POST['id_pos'] === 'end' ? $cfg['HTML_CHECKED'] : '')); return; } $tpl->assign(array('DB_NAME' => '', 'USE_DMN_ID' => '', 'START_ID_POS_SELECTED' => $cfg['HTML_SELECTED'], 'END_ID_POS_SELECTED' => '')); }
set_page_message(tr('Could not create domain alias. An unexpected error occurred.'), 'error'); return false; } return true; } /*********************************************************************************************************************** * Main */ require_once 'imscp-lib.php'; iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart); check_login('user'); customerHasFeature('domain_aliases') or showBadRequestErrorPage(); $mainDmnProps = get_domain_default_props($_SESSION['user_id']); $domainAliasesCount = get_domain_running_als_cnt($mainDmnProps['domain_id']); if ($mainDmnProps['domain_alias_limit'] != 0 && $domainAliasesCount >= $mainDmnProps['domain_alias_limit']) { set_page_message(tr('You have reached the maximum number of domain aliasses allowed by your subscription.'), 'warning'); redirectTo('domains_manage.php'); } if (!empty($_POST) && addDomainAlias()) { redirectTo('domains_manage.php'); } $tpl = new iMSCP_pTemplate(); $tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'client/alias_add.tpl', 'page_message' => 'layout', 'shared_mount_point_domain' => 'page')); $tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Domains / Add Domain Alias'), 'TR_DOMAIN_ALIAS' => tr('Domain alias'), 'TR_DOMAIN_ALIAS_NAME' => tr('Domain alias name'), 'TR_DOMAIN_ALIAS_NAME_TOOLTIP' => tr("You must omit 'www'. It will be added automatically."), 'TR_SHARED_MOUNT_POINT' => tr('Shared mount point'), 'TR_SHARED_MOUNT_POINT_TOOLTIP' => tr('Allows to share the mount point of another domain.'), 'TR_URL_FORWARDING' => tr('URL forwarding'), 'TR_URL_FORWARDING_TOOLTIP' => tr('Allows to forward any request made to this domain alias to a specific URL. Be aware that when this option is in use, no Web folder is created for the domain alias.'), 'TR_FORWARD_TO_URL' => tr('Forward to URL'), 'TR_YES' => tr('Yes'), 'TR_NO' => tr('No'), 'TR_HTTP' => 'http://', 'TR_HTTPS' => 'https://', 'TR_FTP' => 'ftp://', 'TR_ADD' => tr('Add'), 'TR_CANCEL' => tr('Cancel'))); generateNavigation($tpl); generatePage($tpl); generatePageMessage($tpl); $tpl->parse('LAYOUT_CONTENT', 'page'); iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptEnd, array('templateEngine' => $tpl)); $tpl->prnt(); unsetMessages();
/** * Render exception template file * * @return void */ protected function render() { $tpl = new iMSCP_pTemplate(); $tpl->define_dynamic(array('layout' => 'shared/layouts/simple.tpl', 'page' => $this->templateFile, 'page_message' => 'layout', 'backlink_block' => 'page')); if (iMSCP_Registry::isRegistered('backButtonDestination')) { $backButtonDestination = iMSCP_Registry::get('backButtonDestination'); } else { $backButtonDestination = 'javascript:history.go(-1)'; } $tpl->assign(array('TR_PAGE_TITLE' => 'i-MSCP - internet Multi Server Control Panel - Fatal Error', 'HEADER_BLOCK' => '', 'BOX_MESSAGE_TITLE' => 'An unexpected error occurred', 'PAGE_MESSAGE' => '', 'BOX_MESSAGE' => $this->message, 'BACK_BUTTON_DESTINATION' => $backButtonDestination, 'TR_BACK' => 'Back')); $tpl->parse('LAYOUT_CONTENT', 'page'); $this->templateEngine = $tpl; }
/** * Generates network cards list. * * @access private * @param iMSCP_pTemplate $tpl Template engine * @return void */ function _client_generateNetcardsList($tpl) { /** @var $networkCardObject iMSCP_NetworkCard */ $networkCardObject = iMSCP_Registry::get('networkCardObject'); if ($networkCardObject->getErrors() != '') { set_page_message($networkCardObject->getErrors(), 'error'); } $networkCards = $networkCardObject->getAvailableInterface(); sort($networkCards); if (!empty($networkCards)) { foreach ($networkCards as $networkCard) { $tpl->assign('NETWORK_CARD', $networkCard); $tpl->parse('NETWORK_CARD_BLOCK', '.network_card_block'); } } else { // Should never occur but who knows. set_page_message(tr('Unable to find any network interface. You cannot add new IP address.'), 'error'); $tpl->assign('IP_ADDRESS_FORM_BLOCK', ''); } }