示例#1
0
/**
 * Generate auto-resonder action links
 *
 * @param iMSCP_pTemplate $tpl pTemplate instance
 * @param int $mailId Mail uique identifier
 * @param string $mailStatus Mail status
 * @param bool $mailAutoRespond
 * @return void
 */
function _client_generateUserMailAutoRespond($tpl, $mailId, $mailStatus, $mailAutoRespond)
{
    if ($mailStatus == 'ok') {
        if (!$mailAutoRespond) {
            $tpl->assign(array('AUTO_RESPOND' => tr('Enable'), 'AUTO_RESPOND_SCRIPT' => "mail_autoresponder_enable.php?mail_account_id={$mailId}", 'AUTO_RESPOND_EDIT_LINK' => ''));
        } else {
            $tpl->assign(array('AUTO_RESPOND' => tr('Disable'), 'AUTO_RESPOND_SCRIPT' => "mail_autoresponder_disable.php?mail_account_id={$mailId}", 'AUTO_RESPOND_EDIT' => tr('Edit'), 'AUTO_RESPOND_EDIT_SCRIPT' => "mail_autoresponder_edit.php?mail_account_id={$mailId}"));
            $tpl->parse('AUTO_RESPOND_EDIT_LINK', 'auto_respond_edit_link');
        }
        $tpl->parse('AUTO_RESPOND_ITEM', 'auto_respond_item');
    } else {
        $tpl->assign('AUTO_RESPOND_ITEM', '');
    }
}
示例#2
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', '');
    }
}
示例#3
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');
    }
}
示例#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
/**
 * 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');
    }
}
示例#6
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', '');
    }
}
示例#7
0
/**
 * 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' => ''));
}
示例#8
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', '');
    }
}
示例#9
0
/**
 * Generates database sql users list
 *
 * @access private
 * @param iMSCP_pTemplate $tpl Template engine
 * @param int $dbId Database unique identifier
 * @return void
 */
function _client_generateDatabaseSqlUserList($tpl, $dbId)
{
    $stmt = exec_query('SELECT sqlu_id, sqlu_name, sqlu_host FROM sql_user WHERE sqld_id = ? ORDER BY sqlu_name', $dbId);
    if (!$stmt->rowCount()) {
        $tpl->assign('SQL_USERS_LIST', '');
    } else {
        $tpl->assign('SQL_USERS_LIST', '');
        $tpl->assign(array('TR_DB_USER' => 'User', 'TR_DB_USER_HOST' => 'Host', 'TR_DB_USER_HOST_TOOLTIP' => tr('Host from which SQL user is allowed to connect to SQL server')));
        while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
            $sqlUserName = $row['sqlu_name'];
            $tpl->assign(array('DB_USER' => tohtml($sqlUserName), 'DB_USER_HOST' => tohtml(decode_idna($row['sqlu_host'])), 'DB_USER_JS' => tojs($sqlUserName), 'USER_ID' => $row['sqlu_id']));
            $tpl->parse('SQL_USERS_LIST', '.sql_users_list');
        }
    }
}
示例#10
0
/**
 * Generate domain type list
 *
 * @throws iMSCP_Exception
 * @param int $mainDmnId Customer main domain id
 * @param iMSCP_pTemplate $tpl
 * @return void
 */
function ftp_generateDomainTypeList($mainDmnId, $tpl)
{
    $query = "\n\t\tSELECT\n\t\t\tcount(`t2`.`subdomain_id`) AS `sub_count`, count(`t3`.`alias_id`) AS `als_count`,\n\t\t\tcount(`t4`.`subdomain_alias_id`) AS `alssub_count`\n\t\tFROM\n\t\t\t`domain` AS `t1`\n\t\tLEFT JOIN\n\t\t\t`subdomain` AS `t2` ON(`t2`.`domain_id` = `t1`.`domain_id`)\n\t\tLEFT JOIN\n\t\t\t`domain_aliasses` AS `t3` ON(`t3`.`domain_id` = `t1`.`domain_id`)\n\t\tLEFT JOIN\n\t\t\t`subdomain_alias` AS `t4` ON(`t4`.`alias_id` = `t3`.`alias_id`)\n\t\tWHERE\n\t\t\t`t1`.`domain_id` = ?\n\t";
    $stmt = exec_query($query, $mainDmnId);
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    $selected = $cfg->HTML_SELECTED;
    $dmns = array(array('count' => '1', 'type' => 'dmn', 'tr' => tr('Domain')), array('count' => $stmt->fields['sub_count'], 'type' => 'sub', 'tr' => tr('Subdomain')), array('count' => $stmt->fields['als_count'], 'type' => 'als', 'tr' => tr('Domain alias')), array('count' => $stmt->fields['alssub_count'], 'type' => 'alssub', 'tr' => tr('Subdomain alias')));
    foreach ($dmns as $dmn) {
        if ($dmn['count']) {
            $tpl->assign(array('DOMAIN_TYPE' => tohtml($dmn['type']), 'DOMAIN_TYPE_SELECTED' => isset($_POST['domain_type']) && $_POST['domain_type'] == $dmn['type'] ? $selected : $dmn['type'] == 'dmn' ? $selected : '', 'TR_DOMAIN_TYPE' => $dmn['tr']));
            $tpl->parse('DOMAIN_TYPES', '.domain_types');
        }
    }
}
示例#11
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', '');
    }
}
示例#12
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');
    }
}
示例#13
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', '');
    }
}
示例#14
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++;
        }
    }
}
示例#15
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);
    }
}
示例#16
0
/**
 * 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', '');
    }
}
示例#17
0
/**
 * Gets and prepares the template part for services ports
 *
 * This function is used for generation of both pages (show page and error page)
 *
 * @param iMSCP_pTemplate $tpl iMSCP_pTemplate instance
 * @return void;
 */
function admin_showServices($tpl)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    if (isset($_SESSION['error_on_updt'])) {
        $values = new iMSCP_Config_Handler($_SESSION['error_on_updt']);
        unset($_SESSION['error_on_updt']);
        $services = array_keys($values->toArray());
    } else {
        $values = iMSCP_Registry::get('dbConfig');
        // Gets list of services port names
        $services = array_filter(array_keys($values->toArray()), function ($name) {
            return strlen($name) > 5 && substr($name, 0, 5) == 'PORT_';
        });
        if (isset($_SESSION['errorOnAdd'])) {
            $errorOnAdd = new iMSCP_Config_Handler($_SESSION['errorOnAdd']);
            unset($_SESSION['errorOnAdd']);
        }
    }
    if (empty($services)) {
        $tpl->assign('SERVICE_PORTS', '');
        set_page_message(tr('You have not service ports defined.'), 'static_info');
    } else {
        sort($services);
        foreach ($services as $index => $service) {
            list($port, $protocol, $name, $status, $ip) = explode(';', $values->{$service});
            $htmlSelected = $cfg->HTML_SELECTED;
            $selectedUdp = $protocol == 'udp' ? $htmlSelected : '';
            $selectedTcp = $protocol == 'udp' ? '' : $htmlSelected;
            $selectedOn = $status == '1' ? $htmlSelected : '';
            $selectedOff = $status == '1' ? '' : $htmlSelected;
            $tpl->assign(array('SERVICE' => '<input name="name[]" type="text" id="name' . $index . '" value="' . tohtml($name) . '" class="textinput" maxlength="25" />', 'NAME' => tohtml($name), 'DISABLED' => '', 'TR_DELETE' => tr('Delete'), 'URL_DELETE' => "?delete={$service}", 'NUM' => $index));
            $tpl->parse('PORT_DELETE_LINK', 'port_delete_link');
            $tpl->assign(array('VAR_NAME' => tohtml($service), 'IP' => $ip == 'localhost' ? '127.0.0.1' : (!$ip ? '0.0.0.0' : tohtml($ip)), 'PORT' => tohtml($port), 'SELECTED_UDP' => $selectedUdp, 'SELECTED_TCP' => $selectedTcp, 'SELECTED_ON' => $selectedOn, 'SELECTED_OFF' => $selectedOff));
            $tpl->parse('SERVICE_PORTS', '.service_ports');
        }
        // Add fields
        $tpl->assign(isset($errorOnAdd) ? array('VAL_FOR_NAME_NEW' => $errorOnAdd['name_new'], 'VAL_FOR_IP_NEW' => $errorOnAdd['ip_new'], 'VAL_FOR_PORT_NEW' => $errorOnAdd['port_new']) : array('VAL_FOR_NAME_NEW' => '', 'VAL_FOR_IP_NEW' => '', 'VAL_FOR_PORT_NEW' => ''));
        // Error fields ids
        $tpl->assign('ERROR_FIELDS_IDS', isset($_SESSION['errorFieldsIds']) ? $_SESSION['errorFieldsIds'] : '[]');
        unset($_SESSION['errorFieldsIds']);
    }
}
示例#18
0
/**
 * 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', '');
        }
    }
}
示例#19
0
                $search[] = '/Not infected/i';
                $replace[] = '<span style="color:green">$0</span>';
                $search[] = '/no packet sniffer/i';
                $replace[] = '<span style="color:green">$0</span>';
                $search[] = '/(: )(PACKET SNIFFER)/i';
                $replace[] = '$1<span style="color:orange">$2</span>';
                $search[] = '/not promisc/i';
                $replace[] = '<span style="color:green">$0</span>';
                $search[] = '/no suspect file(s|)/i';
                $replace[] = '<span style="color:green">$0</span>';
                $search[] = '/([0-9]+) process(|es) hidden/i';
                $replace[] = '<span style="color:#cfcf00">$0</span>';
            }
            $content = preg_replace($search, $replace, $content);
        } else {
            $content = '<strong style="color:red">' . tr("%s doesn't exist or is empty.", $logFile) . '</strong>';
        }
        $tpl->assign(array('LOG' => $content, 'FILENAME' => $logFile));
        $tpl->parse('ANTIROOTKITS_LOG', '.antirootkits_log');
    }
    $tpl->assign('NB_LOG', sizeof($antiRootkitLogFiles));
} else {
    $tpl->assign('ANTIROOTKITS_LOG', '');
    set_page_message(tr('No anti-rootkits logs'), 'static_info');
}
generateNavigation($tpl);
generatePageMessage($tpl);
$tpl->parse('LAYOUT_CONTENT', 'page');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAdminScriptEnd, array('templateEngine' => $tpl));
$tpl->prnt();
unsetMessages();
示例#20
0
/**
 * Generates plugin list
 *
 * @param TemplateEngine $tpl Template engine instance
 * @param PluginManager $pluginManager
 * @return void
 */
function generatePage($tpl, $pluginManager)
{
    $pluginList = $pluginManager->pluginGetList('Action', false);
    if (empty($pluginList)) {
        $tpl->assign('PLUGINS_BLOCK', '');
        set_page_message(tr('Plugin list is empty.'), 'static_info');
    } else {
        natsort($pluginList);
        $cacheFile = PERSISTENT_PATH . '/protected_plugins.php';
        foreach ($pluginList as $pluginName) {
            $pluginInfo = $pluginManager->pluginGetInfo($pluginName);
            $pluginStatus = $pluginManager->pluginGetStatus($pluginName);
            if (is_array($pluginInfo['author'])) {
                if (count($pluginInfo['author']) == 2) {
                    $pluginInfo['author'] = implode(' ' . tr('and') . ' ', $pluginInfo['author']);
                } else {
                    $lastEntry = array_pop($pluginInfo['author']);
                    $pluginInfo['author'] = implode(', ', $pluginInfo['author']);
                    $pluginInfo['author'] .= ' ' . tr('and') . ' ' . $lastEntry;
                }
            }
            $tpl->assign(array('PLUGIN_NAME' => tohtml($pluginName), 'PLUGIN_DESCRIPTION' => tr($pluginInfo['desc']), 'PLUGIN_STATUS' => $pluginManager->pluginHasError($pluginName) ? tr('Unexpected error') : translateStatus($pluginStatus), 'PLUGIN_VERSION' => isset($pluginInfo['__nversion__']) ? tohtml($pluginInfo['__nversion__']) : tr('Unknown'), 'PLUGIN_AUTHOR' => tohtml($pluginInfo['author']), 'PLUGIN_MAILTO' => tohtml($pluginInfo['email']), 'PLUGIN_SITE' => tohtml($pluginInfo['url'])));
            if ($pluginManager->pluginHasError($pluginName)) {
                $tpl->assign('PLUGIN_STATUS_DETAILS', tr('An unexpected error occurred: %s', '<br><br>' . $pluginManager->pluginGetError($pluginName)));
                $tpl->parse('PLUGIN_STATUS_DETAILS_BLOCK', 'plugin_status_details_block');
                $tpl->assign(array('PLUGIN_DEACTIVATE_LINK' => '', 'PLUGIN_ACTIVATE_LINK' => '', 'PLUGIN_PROTECTED_LINK' => ''));
            } else {
                $tpl->assign('PLUGIN_STATUS_DETAILS_BLOCK', '');
                if ($pluginManager->pluginIsProtected($pluginName)) {
                    // Protected plugin
                    $tpl->assign(array('PLUGIN_ACTIVATE_LINK' => '', 'PLUGIN_DEACTIVATE_LINK' => '', 'TR_UNPROTECT_TOOLTIP' => tr('To unprotect this plugin, you must edit the %s file', $cacheFile)));
                    $tpl->parse('PLUGIN_PROTECTED_LINK', 'plugin_protected_link');
                } elseif ($pluginManager->pluginIsUninstalled($pluginName)) {
                    // Uninstalled plugin
                    $tpl->assign(array('PLUGIN_DEACTIVATE_LINK' => '', 'ACTIVATE_ACTION' => 'install', 'TR_ACTIVATE_TOOLTIP' => tr('Install this plugin'), 'UNINSTALL_ACTION' => 'delete', 'TR_UNINSTALL_TOOLTIP' => tr('Delete this plugin'), 'PLUGIN_PROTECTED_LINK' => ''));
                    $tpl->parse('PLUGIN_ACTIVATE_LINK', 'plugin_activate_link');
                } elseif ($pluginManager->pluginIsDisabled($pluginName)) {
                    // Disabled plugin
                    $tpl->assign(array('PLUGIN_DEACTIVATE_LINK' => '', 'ACTIVATE_ACTION' => 'enable', 'TR_ACTIVATE_TOOLTIP' => tr('Activate this plugin'), 'UNINSTALL_ACTION' => $pluginManager->pluginIsUninstallable($pluginName) ? 'uninstall' : 'delete', 'TR_UNINSTALL_TOOLTIP' => $pluginManager->pluginIsUninstallable($pluginName) ? tr('Uninstall this plugin') : tr('Delete this plugin'), 'PLUGIN_PROTECTED_LINK' => ''));
                    $tpl->parse('PLUGIN_ACTIVATE_LINK', 'plugin_activate_link');
                } elseif ($pluginManager->pluginIsEnabled($pluginName)) {
                    // Enabled plugin
                    $tpl->assign(array('PLUGIN_ACTIVATE_LINK' => '', 'PLUGIN_PROTECTED_LINK' => ''));
                    $tpl->parse('PLUGIN_DEACTIVATE_LINK', 'plugin_deactivate_link');
                } else {
                    // Plugin with unknown status
                    $tpl->assign(array('PLUGIN_DEACTIVATE_LINK' => '', 'PLUGIN_ACTIVATE_LINK' => '', 'PLUGIN_PROTECTED_LINK' => ''));
                }
            }
            $tpl->parse('PLUGIN_BLOCK', '.plugin_block');
        }
    }
}
示例#21
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();
    }
}
示例#22
0
/**
 * Generates IP list form
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @param array &$data Reseller data
 * @return void
 */
function _admin_generateIpListForm($tpl, &$data)
{
    $tpl->assign(array('TR_IP_ADDRESS' => tr('IP address'), 'TR_IP_LABEL' => tr('Label'), 'TR_ASSIGN' => tr('Assign')));
    iMSCP_Events_Aggregator::getInstance()->registerListener('onGetJsTranslations', function ($e) {
        /** @var $e \iMSCP_Events_Event */
        $e->getParam('translations')->core['dataTable'] = getDataTablesPluginTranslations(false);
    });
    foreach ($data['server_ips'] as $ipData) {
        $tpl->assign(array('IP_ID' => tohtml($ipData['ip_id']), 'IP_NUMBER' => tohtml($ipData['ip_number']), 'IP_ASSIGNED' => in_array($ipData['ip_id'], $data['reseller_ips']) ? ' checked' : ''));
        $tpl->parse('IP_BLOCK', '.ip_block');
    }
}
示例#23
0
/**
 * Generate temporary openssl coonfiguration file
 *
 * @throws iMSCP_Exception_Database
 * @param array $data User data
 * @return bool|string Path to generate openssl temporary file, FALSE on failure
 */
function _client_generateOpenSSLConfFile($data)
{
    global $domainType, $domainId;
    $config = iMSCP_Registry::get('config');
    $altNames = <<<'EOF'
DNS.1 = {DOMAIN_NAME}
DNS.2 = www.{DOMAIN_NAME}
EOF;
    if ($domainType == 'dmn') {
        $altNames .= "\nDNS.3 = {ADMIN_SYS_NAME}.{BASE_SERVER_VHOST}\n";
    } elseif ($domainType == 'als') {
        $altNames .= "\nDNS.3 = {ADMIN_SYS_NAME}als{$domainId}.{BASE_SERVER_VHOST}\n";
    } elseif ($domainType == 'sub') {
        $altNames .= "\nDNS.3 = {ADMIN_SYS_NAME}sub{$domainId}.{BASE_SERVER_VHOST}\n";
    } else {
        $altNames .= "\nDNS.3 = {ADMIN_SYS_NAME}alssub{$domainId}.{BASE_SERVER_VHOST}\n";
    }
    $sslTpl = new iMSCP_pTemplate();
    $sslTpl->setRootDir(LIBRARY_PATH . '/Resources/ssl');
    $sslTpl->define('tpl', 'openssl.cnf.tpl');
    $sslTpl->assign(array('DOMAIN_NAME' => $data['domain_name'], 'ALT_NAMES' => $altNames, 'ADMIN_SYS_NAME' => $data['admin_sys_name'], 'BASE_SERVER_VHOST' => $config['BASE_SERVER_VHOST']));
    $sslTpl->parse('TPL', 'tpl');
    if (!($opensslConfFile = @tempnam(sys_get_temp_dir(), $_SESSION['user_id'] . '-openssl.cnf'))) {
        write_log('Could not create temporary openssl configuration file.', E_USER_ERROR);
        return false;
    }
    register_shutdown_function(function ($file) {
        @unlink($file);
    }, $opensslConfFile);
    if (!@file_put_contents($opensslConfFile, $sslTpl->getLastParseResult())) {
        write_log(sprintf('Could not write in %s openssl temporary configuration file.', $opensslConfFile), E_USER_ERROR);
        return false;
    }
    return $opensslConfFile;
}
示例#24
0
/**
 * Generate page data
 *
 * @param iMSCP_pTemplate $tpl
 * @return void
 */
function admin_generatePageData($tpl)
{
    $senderName = isset($_POST['sender_name']) ? $_POST['sender_name'] : '';
    $senderEmail = isset($_POST['sender_email']) ? $_POST['sender_email'] : '';
    $rcptTo = isset($_POST['rcpt_to']) ? $_POST['rcpt_to'] : '';
    $subject = isset($_POST['subject']) ? $_POST['subject'] : '';
    $body = isset($_POST['body']) ? $_POST['body'] : '';
    if ($senderName == '' && $senderEmail == '') {
        $query = 'SELECT `admin_name`, `fname`, `lname`, `email` FROM `admin` WHERE `admin_id` = ?';
        $stmt = exec_query($query, $_SESSION['user_id']);
        $data = $stmt->fetchRow();
        if (!empty($data['fname']) && !empty($data['lname'])) {
            $senderName = $data['fname'] . ' ' . $data['lname'];
        } elseif (!empty($data['fname'])) {
            $senderName = $stmt->fields['fname'];
        } elseif (!empty($data['lname'])) {
            $senderName = $stmt->fields['lname'];
        } else {
            $senderName = $data['admin_name'];
        }
        if ($data['email'] != '') {
            $senderEmail = $data['email'];
        } else {
            $config = iMSCP_Registry::get('config');
            if (isset($config['DEFAULT_ADMIN_ADDRESS']) && $config['DEFAULT_ADMIN_ADDRESS'] != '') {
                $senderEmail = $config['DEFAULT_ADMIN_ADDRESS'];
            } else {
                $senderEmail = 'webmaster@' . $config['BASE_SERVER_VHOST'];
            }
        }
    }
    $tpl->assign(array('SENDER_NAME' => tohtml($senderName), 'SENDER_EMAIL' => tohtml($senderEmail), 'SUBJECT' => tohtml($subject), 'BODY' => tohtml($body)));
    $rcptToOptions = array(array('all_users', tr('All users')));
    if (systemHasManyAdmins() && systemHasResellers()) {
        $rcptToOptions[] = array('administrators_resellers', tr('Administrators and resellers'));
    }
    if (systemHasManyAdmins() && systemHasCustomers()) {
        $rcptToOptions[] = array('administrators_customers', tr('Administrators and customers'));
    }
    if (systemHasResellers() && systemHasCustomers()) {
        $rcptToOptions[] = array('resellers_customers', tr('Resellers and customers'));
    }
    if (systemHasManyAdmins()) {
        $rcptToOptions[] = array('administrators', tr('Administrators'));
    }
    if (systemHasResellers()) {
        $rcptToOptions[] = array('resellers', tr('Resellers'));
    }
    if (systemHasCustomers()) {
        $rcptToOptions[] = array('customers', tr('Customers'));
    }
    foreach ($rcptToOptions as $option) {
        $tpl->assign(array('RCPT_TO' => $option[0], 'TR_RCPT_TO' => $option[1], 'SELECTED' => $rcptTo == $option[0] ? ' selected="selected"' : ''));
        $tpl->parse('RCPT_TO_OPTION', '.rcpt_to_option');
    }
}
示例#25
0
/**
 * Generate page
 *
 * @param iMSCP_pTemplate $tpl Template engine
 * @param iMSCP_PHPini $phpini PHP editor instance
 * @param iMSCP_Config_Handler_File $config Configuration handler
 * @param string $configLevel PHP configuration level
 * @return void
 */
function generatePage($tpl, $phpini, $config, $configLevel)
{
    $mainDmnId = get_user_domain_id($_SESSION['user_id']);
    if (isset($_GET['domain_id']) && isset($_GET['domain_type'])) {
        $dmnId = intval($_GET['domain_id']);
        $dmnType = clean_input($_GET['domain_type']);
    } else {
        $dmnId = $mainDmnId;
        $dmnType = 'dmn';
    }
    if ($configLevel == 'per_user' && $dmnType != 'dmn' || $configLevel == 'per_domain' && !in_array($dmnType, array('dmn', 'als'))) {
        showBadRequestErrorPage();
    }
    $dmnsData = getDomainData($configLevel);
    $knowDomain = false;
    foreach ($dmnsData as $dmnData) {
        if ($dmnData['domain_id'] == $dmnId && $dmnData['domain_type'] == $dmnType) {
            $knowDomain = true;
        }
    }
    if (!$knowDomain) {
        showBadRequestErrorPage();
    }
    $phpini->loadDomainIni($_SESSION['user_id'], $dmnId, $dmnType);
    if ($configLevel != 'per_user') {
        foreach ($dmnsData as $dmnData) {
            $tpl->assign(array('DOMAIN_ID' => tohtml($dmnData['domain_id'], 'htmlAttr'), 'DOMAIN_TYPE' => tohtml($dmnData['domain_type'], 'htmlAttr'), 'DOMAIN_NAME_UNICODE' => tohtml(decode_idna($dmnData['domain_name'])), 'SELECTED' => $dmnData['domain_id'] == $dmnId && $dmnData['domain_type'] == $dmnType ? ' selected' : ''));
            $tpl->parse('DOMAIN_NAME_BLOCK', '.domain_name_block');
        }
        $tpl->assign('DOMAIN_TYPE', $dmnType);
    } else {
        $tpl->assign('DOMAIN_LIST_BLOCK', '');
    }
    if (!$phpini->clientHasPermission('phpiniAllowUrlFopen')) {
        $tpl->assign('ALLOW_URL_FOPEN_BLOCK', '');
    } else {
        $tpl->assign(array('TR_ALLOW_URL_FOPEN' => tr('Allow URL fopen'), 'ALLOW_URL_FOPEN_ON' => $phpini->getDomainIni('phpiniAllowUrlFopen') == 'on' ? ' checked' : '', 'ALLOW_URL_FOPEN_OFF' => $phpini->getDomainIni('phpiniAllowUrlFopen') == 'off' ? ' checked' : ''));
    }
    if (!$phpini->clientHasPermission('phpiniDisplayErrors')) {
        $tpl->assign('DISPLAY_ERRORS_BLOCK', '');
    } else {
        $tpl->assign(array('TR_DISPLAY_ERRORS' => tr('Display errors'), 'DISPLAY_ERRORS_ON' => $phpini->getDomainIni('phpiniDisplayErrors') == 'on' ? ' checked' : '', 'DISPLAY_ERRORS_OFF' => $phpini->getDomainIni('phpiniDisplayErrors') == 'off' ? ' checked' : ''));
    }
    if (!$phpini->clientHasPermission('phpiniDisplayErrors') || $config['HTTPD_SERVER'] == 'apache_itk') {
        $tpl->assign('ERROR_REPORTING_BLOCK', '');
    } else {
        $errorReporting = $phpini->getDomainIni('phpiniErrorReporting');
        $tpl->assign(array('TR_ERROR_REPORTING' => tohtml(tr('Error reporting')), 'TR_ERROR_REPORTING_DEFAULT' => tohtml(tr('All errors, except E_NOTICES, E_STRICT AND E_DEPRECATED (Default)'), 'htmlAttr'), 'TR_ERROR_REPORTING_DEVELOPEMENT' => tohtml(tr('All errors (Development)'), 'htmlAttr'), 'TR_ERROR_REPORTING_PRODUCTION' => tohtml(tr('All errors, except E_DEPRECATED and E_STRICT (Production)'), 'htmlAttr'), 'ERROR_REPORTING_0' => $errorReporting == 'E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED' ? ' selected' : '', 'ERROR_REPORTING_1' => $errorReporting == 'E_ALL & ~E_DEPRECATED & ~E_STRICT' ? ' selected' : '', 'ERROR_REPORTING_2' => $errorReporting == '-1' ? ' selected' : ''));
    }
    if ($config['HTTPD_SERVER'] == 'apache_itk' || !$phpini->clientHasPermission('phpiniDisableFunctions')) {
        $tpl->assign(array('DISABLE_FUNCTIONS_BLOCK' => '', 'DISABLE_EXEC_BLOCK' => ''));
    } elseif ($phpini->getClientPermission('phpiniDisableFunctions') == 'exec') {
        $disableFunctions = explode(',', $phpini->getDomainIni('phpiniDisableFunctions'));
        $execYes = in_array('exec', $disableFunctions) ? false : true;
        $tpl->assign(array('TR_DISABLE_FUNCTIONS_EXEC' => tohtml(tr('PHP exec() function')), 'TR_EXEC_HELP' => tohtml(tr("When set to 'yes', your PHP scripts can call the PHP exec() function."), 'htmlAttr'), 'EXEC_YES' => $execYes ? ' checked' : '', 'EXEC_NO' => $execYes ? '' : ' checked', 'DISABLE_FUNCTIONS_BLOCK' => ''));
    } else {
        $disableableFunctions = array('EXEC', 'PASSTHRU', 'PHPINFO', 'POPEN', 'PROC_OPEN', 'SHOW_SOURCE', 'SYSTEM', 'SHELL', 'SHELL_EXEC', 'SYMLINK');
        if ($phpini->clientHasPermission('phpiniMailFunction')) {
            $disableableFunctions[] = 'MAIL';
        } else {
            $tpl->assign('MAIL_FUNCTION_BLOCK', '');
        }
        $disabledFunctions = explode(',', $phpini->getDomainIni('phpiniDisableFunctions'));
        foreach ($disableableFunctions as $function) {
            $tpl->assign($function, in_array(strtolower($function), $disabledFunctions, true) ? ' checked' : '');
        }
        $tpl->assign(array('TR_DISABLE_FUNCTIONS' => tohtml(tr('Disabled functions')), 'DISABLE_EXEC_BLOCK' => ''));
    }
    $tpl->assign(array('TR_PHP_SETTINGS' => tohtml(tr('PHP Settings')), 'TR_YES' => tohtml(tr('Yes')), 'TR_NO' => tohtml(tr('No'))));
}
示例#26
0
/**
 * Get plugin items errors
 *
 * @param iMSCP_pTemplate $tpl
 * @return void
 */
function debugger_getPluginItemErrors($tpl)
{
    /** @var iMSCP_Plugin_Manager $pluginManager */
    $pluginManager = iMSCP_Registry::get('pluginManager');
    /** @var iMSCP_Plugin[] $plugins */
    $plugins = $pluginManager->pluginGetLoaded();
    $itemFound = false;
    foreach ($plugins as $plugin) {
        $items = $plugin->getItemWithErrorStatus();
        if (!empty($items)) {
            $itemFound = true;
            foreach ($items as $item) {
                $tpl->assign(array('PLUGIN_ITEM_MESSAGE' => '', 'PLUGIN_NAME' => tohtml($plugin->getName()) . ' (' . tohtml($item['item_name']) . ')', 'PLUGIN_ITEM_ERROR' => tohtml($item['status']), 'CHANGE_ID' => $item['item_id'], 'CHANGE_TYPE' => tohtml($plugin->getName()), 'TABLE' => tohtml($item['table']), 'FIELD' => tohtml($item['field'])));
                $tpl->parse('PLUGIN_ITEM_ITEM', '.plugin_item_item');
            }
        }
    }
    if (!$itemFound) {
        $tpl->assign(array('PLUGIN_ITEM_ITEM' => '', 'TR_PLUGIN_ITEM_MESSAGE' => tr('No errors')));
        $tpl->parse('PLUGIN_ITEM_MESSAGE', 'plugin_item_message');
    }
}
示例#27
0
/**
 * Returns reseller Ip list
 *
 * @param iMSCP_pTemplate $tpl Template engine
 * @param int $resellerId Reseller unique identifier
 * @param int $domainIp Identifier of the selected domain IP
 * @return void
 */
function reseller_generate_ip_list($tpl, $resellerId, $domainIp)
{
    $stmt = exec_query('SELECT reseller_ips FROM reseller_props WHERE reseller_id = ?', $resellerId);
    $row = $stmt->fetchRow();
    $resellerIps = explode(';', rtrim($row['reseller_ips'], ';'));
    $stmt = execute_query('SELECT * FROM server_ips');
    while ($row = $stmt->fetchRow()) {
        if (in_array($row['ip_id'], $resellerIps)) {
            $tpl->assign(array('IP_NUM' => $row['ip_number'], 'IP_VALUE' => $row['ip_id'], 'IP_SELECTED' => $domainIp === $row['ip_id'] ? ' selected' : ''));
            $tpl->parse('IP_ENTRY', '.ip_entry');
        }
    }
}
示例#28
0
/**
 * Generates IP list form
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @param array &$data Reseller data
 * @return void
 */
function _admin_generateIpListForm($tpl, &$data)
{
    $assignedTranslation = tr('Already in use');
    $unusedTranslation = tr('Not used');
    $tpl->assign(array('TR_IP_ADDRESS' => tr('IP address'), 'TR_IP_LABEL' => tr('Label'), 'TR_ASSIGN' => tr('Assign'), 'TR_STATUS' => tr('Usage status')));
    iMSCP_Events_Aggregator::getInstance()->registerListener('onGetJsTranslations', function ($e) {
        /** @var $e \iMSCP_Events_Event */
        $e->getParam('translations')->core['dataTable'] = getDataTablesPluginTranslations(false);
    });
    foreach ($data['server_ips'] as $ipData) {
        $resellerHasIp = in_array($ipData['ip_id'], $data['reseller_ips']);
        $isUsedIp = in_array($ipData['ip_id'], $data['used_ips']);
        $tpl->assign(array('IP_ID' => tohtml($ipData['ip_id']), 'IP_NUMBER' => tohtml($ipData['ip_number']), 'IP_ASSIGNED' => $resellerHasIp ? ' checked' : '', 'IP_STATUS' => $isUsedIp ? $assignedTranslation : $unusedTranslation, 'IP_READONLY' => $isUsedIp ? ' title="' . tohtml(tr('You cannot unassign an IP address already in use.'), 'htmlAttr') . '" readonly' : ''));
        $tpl->parse('IP_BLOCK', '.ip_block');
    }
}
示例#29
0
 /**
  * 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;
 }
示例#30
0
/**
 * Show first page of add user with data
 *
 * @param  iMSCP_pTemplate $tpl Template engine
 * @return void
 */
function reseller_generatePage($tpl)
{
    $tpl->assign(array('DOMAIN_NAME_VALUE' => isset($_POST['dmn_name']) ? tohtml($_POST['dmn_name']) : '', 'DATEPICKER_VALUE' => isset($_POST['datepicker']) ? tohtml($_POST['datepicker']) : '', 'DATEPICKER_DISABLED' => isset($_POST['datepicker']) ? '' : ' disabled', 'NEVER_EXPIRE_CHECKED' => isset($_POST['datepicker']) ? '' : '  checked', 'CHTPL1_VAL' => isset($_POST['chtpl']) && $_POST['chtpl'] == '_yes_' ? ' checked' : '', 'CHTPL2_VAL' => isset($_POST['chtpl']) && $_POST['chtpl'] == '_yes_' ? '' : ' checked'));
    $stmt = exec_query('SELECT id, name FROM hosting_plans WHERE reseller_id = ? AND status = ? ORDER BY name', array($_SESSION['user_id'], '1'));
    if (!$stmt->rowCount()) {
        $tpl->assign('HOSTING_PLAN_ENTRIES_BLOCK', '');
        return;
    }
    while ($row = $stmt->fetchRow()) {
        $hpId = isset($_POST['dmn_tpl']) ? $_POST['dmn_tpl'] : '';
        $tpl->assign(array('HP_NAME' => tohtml($row['name']), 'HP_ID' => tohtml($row['id']), 'HP_SELECTED' => $row['id'] == $hpId ? ' selected' : ''));
        $tpl->parse('HOSTING_PLAN_ENTRY_BLOCK', '.hosting_plan_entry_block');
    }
}