Exemplo n.º 1
0
/**
 * Generate page
 *
 * @param  iMSCP_pTemplate $tpl
 * @return void
 */
function admin_generatePage($tpl)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    if (!isset($cfg['CHECK_FOR_UPDATES']) || !$cfg['CHECK_FOR_UPDATES']) {
        set_page_message(tr('i-MSCP version update checking is disabled'), 'static_warning');
    } else {
        /** @var iMSCP_Update_Version $updateVersion */
        $updateVersion = iMSCP_Update_Version::getInstance();
        if ($updateVersion->isAvailableUpdate()) {
            if ($updateInfo = $updateVersion->getUpdateInfo()) {
                $date = new DateTime($updateInfo['published_at']);
                $tpl->assign(array('TR_UPDATE_INFO' => tr('Update info'), 'TR_RELEASE_VERSION' => tr('Release version'), 'RELEASE_VERSION' => tohtml($updateInfo['tag_name']), 'TR_RELEASE_DATE' => tr('Release date'), 'RELEASE_DATE' => tohtml($date->format($cfg['DATE_FORMAT'])), 'TR_RELEASE_DESCRIPTION' => tr('Release description'), 'RELEASE_DESCRIPTION' => tohtml($updateInfo['body']), 'TR_DOWNLOAD_LINKS' => tr('Download links'), 'TR_DOWNLOAD_ZIP' => tr('Download ZIP'), 'TR_DOWNLOAD_TAR' => tr('Download TAR'), 'TARBALL_URL' => tohtml($updateInfo['tarball_url']), 'ZIPBALL_URL' => tohtml($updateInfo['zipball_url'])));
                return;
            } else {
                set_page_message($updateVersion->getError(), 'error');
            }
        } elseif ($updateVersion->getError()) {
            set_page_message($updateVersion, 'error');
        } else {
            set_page_message(tr('No update available'), 'static_info');
        }
    }
    $tpl->assign('UPDATE_INFO', '');
}
Exemplo n.º 2
0
/**
 * Generate page
 *
 * @param $tpl iMSCP_pTemplate
 * @return void
 */
function client_generatePage($tpl)
{
    if (isset($_GET['id'])) {
        $domainAliasId = clean_input($_GET['id']);
        if (!($domainAliasData = _client_getAliasData($domainAliasId))) {
            showBadRequestErrorPage();
        }
        if (empty($_POST)) {
            if ($domainAliasData['forward_url'] != 'no') {
                $urlForwarding = true;
                $uri = iMSCP_Uri_Redirect::fromString($domainAliasData['forward_url']);
                $forwardUrlScheme = $uri->getScheme();
                $forwardUrl = substr($uri->getUri(), strlen($forwardUrlScheme) + 3);
            } else {
                $urlForwarding = false;
                $forwardUrlScheme = 'http://';
                $forwardUrl = '';
            }
        } else {
            $urlForwarding = isset($_POST['url_forwarding']) && $_POST['url_forwarding'] == 'yes' ? true : false;
            $forwardUrlScheme = isset($_POST['forward_url_scheme']) ? $_POST['forward_url_scheme'] : 'http://';
            $forwardUrl = isset($_POST['forward_url']) ? $_POST['forward_url'] : '';
        }
        /** @var iMSCP_Config_Handler_File $cfg */
        $cfg = iMSCP_Registry::get('config');
        $checked = $cfg->HTML_CHECKED;
        $selected = $cfg->HTML_SELECTED;
        $tpl->assign(array('DOMAIN_ALIAS_ID' => $domainAliasId, 'DOMAIN_ALIAS_NAME' => tohtml($domainAliasData['alias_name_utf8']), 'FORWARD_URL_YES' => $urlForwarding ? $checked : '', 'FORWARD_URL_NO' => $urlForwarding ? '' : $checked, 'HTTP_YES' => $forwardUrlScheme == 'http://' ? $selected : '', 'HTTPS_YES' => $forwardUrlScheme == 'https://' ? $selected : '', 'FTP_YES' => $forwardUrlScheme == 'ftp://' ? $selected : '', 'FORWARD_URL' => tohtml(decode_idna($forwardUrl))));
    } else {
        showBadRequestErrorPage();
    }
}
Exemplo n.º 3
0
/**
 * @todo check if it's useful to have the table admin two times in the same query
 * @param EasySCP_TemplateEngine $tpl
 */
function gen_reseller_table($tpl)
{
    $cfg = EasySCP_Registry::get('Config');
    $sql = EasySCP_Registry::get('Db');
    $query = "\n\t\tSELECT\n\t\t\tt1.`admin_id`, t1.`admin_name`, t2.`admin_name` AS created_by\n\t\tFROM\n\t\t\t`admin` AS t1,\n\t\t\t`admin` AS t2\n\t\tWHERE\n\t\t\tt1.`admin_type` = 'reseller'\n\t\tAND\n\t\t\tt1.`created_by` = t2.`admin_id`\n\t\tORDER BY\n\t\t\t`created_by`,\n\t\t\t`admin_id`\n\t";
    $rs = exec_query($sql, $query);
    $i = 0;
    if ($rs->recordCount() == 0) {
        set_page_message(tr('Reseller list is empty!'), 'info');
    } else {
        while (!$rs->EOF) {
            $admin_id = $rs->fields['admin_id'];
            $admin_id_var_name = "admin_id_" . $admin_id;
            $tpl->append(array('NUMBER' => $i + 1, 'RESELLER_NAME' => tohtml($rs->fields['admin_name']), 'OWNER' => tohtml($rs->fields['created_by']), 'CKB_NAME' => $admin_id_var_name));
            $rs->moveNext();
            $i++;
        }
        $tpl->assign('PAGE_MESSAGE', '');
    }
    $query = "\n\t\tSELECT\n\t\t\t`admin_id`, `admin_name`\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_type` = 'admin'\n\t\tORDER BY\n\t\t\t`admin_name`\n\t";
    $rs = exec_query($sql, $query);
    while (!$rs->EOF) {
        if (isset($_POST['uaction']) && $_POST['uaction'] === 'reseller_owner' && (isset($_POST['dest_admin']) && $_POST['dest_admin'] == $rs->fields['admin_id'])) {
            $selected = $cfg->HTML_SELECTED;
        } else {
            $selected = '';
        }
        $tpl->append(array('OPTION' => tohtml($rs->fields['admin_name']), 'VALUE' => $rs->fields['admin_id'], 'SELECTED' => $selected));
        $rs->moveNext();
    }
    $tpl->assign('PAGE_MESSAGE', '');
}
Exemplo n.º 4
0
/**
 * @param iMSCP_pTemplate $tpl
 * @param $user_id
 */
function gen_reseller_personal_data($tpl, $user_id)
{
    $cfg = iMSCP_Registry::get('config');
    $query = "\n\t\tSELECT\n\t\t\t`fname`,\n\t\t\t`lname`,\n\t\t\t`gender`,\n\t\t\t`firm`,\n\t\t\t`zip`,\n\t\t\t`city`,\n\t\t\t`state`,\n\t\t\t`country`,\n\t\t\t`street1`,\n\t\t\t`street2`,\n\t\t\t`email`,\n\t\t\t`phone`,\n\t\t\t`fax`\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_id` = ?\n\t";
    $rs = exec_query($query, $user_id);
    $tpl->assign(array('FIRST_NAME' => $rs->fields['fname'] == null ? '' : tohtml($rs->fields['fname']), 'LAST_NAME' => $rs->fields['lname'] == null ? '' : tohtml($rs->fields['lname']), 'FIRM' => $rs->fields['firm'] == null ? '' : tohtml($rs->fields['firm']), 'ZIP' => $rs->fields['zip'] == null ? '' : tohtml($rs->fields['zip']), 'CITY' => $rs->fields['city'] == null ? '' : tohtml($rs->fields['city']), 'STATE' => $rs->fields['state'] == null ? '' : tohtml($rs->fields['state']), 'COUNTRY' => $rs->fields['country'] == null ? '' : tohtml($rs->fields['country']), 'STREET_1' => $rs->fields['street1'] == null ? '' : tohtml($rs->fields['street1']), 'STREET_2' => $rs->fields['street2'] == null ? '' : tohtml($rs->fields['street2']), 'EMAIL' => $rs->fields['email'] == null ? '' : tohtml($rs->fields['email']), 'PHONE' => $rs->fields['phone'] == null ? '' : tohtml($rs->fields['phone']), 'FAX' => $rs->fields['fax'] == null ? '' : tohtml($rs->fields['fax']), 'VL_MALE' => $rs->fields['gender'] == 'M' ? $cfg->HTML_SELECTED : '', 'VL_FEMALE' => $rs->fields['gender'] == 'F' ? $cfg->HTML_SELECTED : '', 'VL_UNKNOWN' => $rs->fields['gender'] == 'U' || empty($rs->fields['gender']) ? $cfg->HTML_SELECTED : ''));
}
Exemplo n.º 5
0
/**
 * Generate page
 *
 * @param $tpl iMSCP_pTemplate
 * @return void
 */
function generatePage($tpl)
{
    $tpl->assign(array('DOMAIN_ALIAS_NAME' => isset($_POST['domain_alias_name']) ? tohtml($_POST['domain_alias_name']) : '', 'SHARED_MOUNT_POINT_YES' => isset($_POST['shared_mount_point']) && $_POST['shared_mount_point'] == 'yes' ? ' checked' : '', 'SHARED_MOUNT_POINT_NO' => isset($_POST['shared_mount_point']) && $_POST['shared_mount_point'] == 'yes' ? '' : ' checked', 'FORWARD_URL_YES' => isset($_POST['url_forwarding']) && $_POST['url_forwarding'] == 'yes' ? ' checked' : '', 'FORWARD_URL_NO' => isset($_POST['url_forwarding']) && $_POST['url_forwarding'] == 'yes' ? '' : ' checked', 'HTTP_YES' => isset($_POST['forward_url_scheme']) && $_POST['forward_url_scheme'] == 'http://' ? ' selected' : '', 'HTTPS_YES' => isset($_POST['forward_url_scheme']) && $_POST['forward_url_scheme'] == 'https://' ? ' selected' : '', 'FTP_YES' => isset($_POST['forward_url_scheme']) && $_POST['forward_url_scheme'] == 'ftp://' ? ' selected' : '', 'FORWARD_URL' => isset($_POST['forward_url']) ? tohtml(decode_idna($_POST['forward_url'])) : ''));
    foreach (getDomainsList() as $domain) {
        $tpl->assign(array('DOMAIN_NAME' => tohtml($domain['name']), 'DOMAIN_NAME_UNICODE' => tohtml(decode_idna($domain['name'])), 'SHARED_MOUNT_POINT_DOMAIN_SELECTED' => isset($_POST['shared_mount_point_domain']) && $_POST['shared_mount_point_domain'] == $domain['name'] ? ' selected' : ''));
        $tpl->parse('SHARED_MOUNT_POINT_DOMAIN', '.shared_mount_point_domain');
    }
}
Exemplo n.º 6
0
/**
 * Generates page.
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 */
function reseller_generatePage($tpl)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    $query = "SELECT domain_created from admin where admin_id = ?";
    $stmt = exec_query($query, (int) $_SESSION['user_id']);
    $tpl->assign(array('TR_ACCOUNT_SUMMARY' => tr('Account summary'), 'TR_USERNAME' => tr('Username'), 'USERNAME' => tohtml($_SESSION['user_logged']), 'TR_ACCOUNT_TYPE' => tr('Account type'), 'ACCOUNT_TYPE' => $_SESSION['user_type'], 'TR_REGISTRATION_DATE' => tr('Registration date'), 'REGISTRATION_DATE' => $stmt->fields['domain_created'] != 0 ? date($cfg->DATE_FORMAT, $stmt->fields['domain_created']) : tr('Unknown')));
}
Exemplo n.º 7
0
/**
 * Generates page
 *
 * @param  iMSCP_pTemplate $tpl Template engine
 * @return void
 */
function generatePage($tpl)
{
    global $hpId, $dmnName, $adminName, $email, $customerId, $firstName, $lastName, $gender, $firm, $zip, $city, $state, $country, $street1, $street2, $phone, $fax, $domainIp;
    $adminName = decode_idna($adminName);
    $tpl->assign(array('VL_USERNAME' => tohtml($adminName, 'htmlAttr'), 'VL_MAIL' => tohtml($email, 'htmlAttr'), 'VL_USR_ID' => tohtml($customerId, 'htmlAttr'), 'VL_USR_NAME' => tohtml($firstName, 'htmlAttr'), 'VL_LAST_USRNAME' => tohtml($lastName, 'htmlAttr'), 'VL_USR_FIRM' => tohtml($firm, 'htmlAttr'), 'VL_USR_POSTCODE' => tohtml($zip, 'htmlAttr'), 'VL_USRCITY' => tohtml($city, 'htmlAttr'), 'VL_USRSTATE' => tohtml($state, 'htmlAttr'), 'VL_MALE' => $gender == 'M' ? ' selected' : '', 'VL_FEMALE' => $gender == 'F' ? ' selected' : '', 'VL_UNKNOWN' => $gender == 'U' ? ' selected' : '', 'VL_COUNTRY' => tohtml($country, 'htmlAttr'), 'VL_STREET1' => tohtml($street1, 'htmlAttr'), 'VL_STREET2' => tohtml($street2, 'htmlAttr'), 'VL_PHONE' => tohtml($phone, 'htmlAttr'), 'VL_FAX' => tohtml($fax, 'htmlAttr')));
    reseller_generate_ip_list($tpl, $_SESSION['user_id'], $domainIp);
    $_SESSION['local_data'] = "{$dmnName};{$hpId}";
}
Exemplo n.º 8
0
/**
 * Creates a list of all current installed languages
 *
 * @param string $lang_selected Defines the selected language
 */
function gen_def_language($lang_selected)
{
    $cfg = EasySCP_Registry::get('Config');
    $tpl = EasySCP_TemplateEngine::getInstance();
    $languages = getLanguages();
    foreach ($languages as $lang => $language_name) {
        $tpl->append(array('LANG_VALUE' => $lang, 'LANG_SELECTED' => $lang === $lang_selected ? $cfg->HTML_SELECTED : '', 'LANG_NAME' => tohtml($language_name)));
    }
}
/**
 * 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))));
}
Exemplo n.º 10
0
/**
 * Generate page
 *
 * @param iMSCP_pTemplate $tpl
 * @param int $id Sql user id
 * @return array
 */
function client_generatePage($tpl, $id)
{
    $stmt = exec_query('SELECT sqlu_name, sqlu_host, sqlu_pass FROM sql_user WHERE sqlu_id = ?', $id);
    if (!$stmt->rowCount()) {
        showBadRequestErrorPage();
    }
    $row = $stmt->fetchRow(PDO::FETCH_ASSOC);
    $tpl->assign(array('USER_NAME' => tohtml($row['sqlu_name']), 'ID' => tohtml($id)));
    return array($row['sqlu_name'], $row['sqlu_host'], $row['sqlu_pass']);
}
Exemplo n.º 11
0
/**
 * Generates statistics for the given user
 *
 * @access private
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @param int $adminId User unique identifier
 * @return void
 */
function _generateUserStatistics($tpl, $adminId)
{
    list($adminName, , $webTraffic, $ftpTraffic, $smtpTraffic, $popImapTraffic, $trafficUsageBytes, $diskspaceUsageBytes) = shared_getCustomerStats($adminId);
    list($subCount, $subMax, $alsCount, $alsMax, $mailCount, $mailMax, $ftpUserCount, $FtpUserMax, $sqlDbCount, $sqlDbMax, $sqlUserCount, $sqlUserMax, $trafficLimit, $diskspaceLimit) = shared_getCustomerProps($adminId);
    $trafficLimitBytes = $trafficLimit * 1048576;
    $diskspaceLimitBytes = $diskspaceLimit * 1048576;
    $trafficPercent = make_usage_vals($trafficUsageBytes, $trafficLimitBytes);
    $diskPercent = make_usage_vals($diskspaceUsageBytes, $diskspaceLimitBytes);
    $tpl->assign(array('USER_ID' => tohtml($adminId), 'USERNAME' => tohtml(decode_idna($adminName)), 'TRAFF_PERCENT' => tohtml($trafficPercent), 'TRAFF_MSG' => $trafficLimitBytes ? tohtml(tr('%1$s / %2$s', bytesHuman($trafficUsageBytes), bytesHuman($trafficLimitBytes))) : tohtml(tr('%s / unlimited', bytesHuman($trafficUsageBytes))), 'DISK_PERCENT' => tohtml($diskPercent), 'DISK_MSG' => $diskspaceLimitBytes ? tohtml(tr('%1$s / %2$s', bytesHuman($diskspaceUsageBytes), bytesHuman($diskspaceLimitBytes))) : tohtml(tr('%s / unlimited', bytesHuman($diskspaceUsageBytes))), 'WEB' => tohtml(bytesHuman($webTraffic)), 'FTP' => tohtml(bytesHuman($ftpTraffic)), 'SMTP' => tohtml(bytesHuman($smtpTraffic)), 'POP3' => tohtml(bytesHuman($popImapTraffic)), 'SUB_MSG' => $subMax ? $subMax > 0 ? tohtml(tr('%1$d / %2$d', $subCount, $subMax)) : tohtml(tr('disabled')) : tohtml(tr('%d / unlimited', $subCount)), 'ALS_MSG' => $alsMax ? $alsMax > 0 ? tohtml(tr('%1$d / %2$d', $alsCount, $alsMax)) : tohtml(tr('disabled')) : tohtml(tr('%d / unlimited', $alsCount)), 'MAIL_MSG' => $mailMax ? $mailMax > 0 ? tohtml(tr('%1$d / %2$d', $mailCount, $mailMax)) : tohtml(tr('disabled')) : tohtml(tr('%d / unlimited', $mailCount)), 'FTP_MSG' => $FtpUserMax ? $FtpUserMax > 0 ? tohtml(tr('%1$d / %2$d', $ftpUserCount, $FtpUserMax)) : tohtml(tr('disabled')) : tohtml(tr('%d / unlimited', $ftpUserCount)), 'SQL_DB_MSG' => $sqlDbMax ? $sqlDbMax > 0 ? tohtml(tr('%1$d / %2$d', $sqlDbCount, $sqlDbMax)) : tohtml(tr('disabled')) : tohtml(tr('%d / unlimited', $sqlDbCount)), 'SQL_USER_MSG' => $sqlUserMax ? $sqlUserMax > 0 ? tohtml(tr('%1$d / %2$d', $sqlUserCount, $sqlUserMax)) : tohtml(tr('disabled')) : tohtml(tr('%d / unlimited', $sqlUserCount))));
}
Exemplo n.º 12
0
function do_mysql_query($sql)
{
    $res = mysql_query($sql);
    if ($res == FALSE) {
        echo '</select></p></div><div style="padding: 1em; color:red; font-size:120%; background-color:#CEECF5;">' . '<p><b>Fatal Error in SQL Query:</b> ' . tohtml($sql) . '</p>' . '<p><b>Error Code &amp; Message:</b> [' . mysql_errno() . '] ' . tohtml(mysql_error()) . "</p></div><hr /><pre>Backtrace:\n\n";
        debug_print_backtrace();
        echo '</pre><hr />';
        die('</body></html>');
    } else {
        return $res;
    }
}
Exemplo n.º 13
0
/**
 * Generates statistics for the given reseller
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @param int $resellerId Reseller unique identifier
 * @param string $resellerName Reseller name
 * @return void
 */
function _generateResellerStatistics($tpl, $resellerId, $resellerName)
{
    $resellerProps = imscp_getResellerProperties($resellerId, true);
    list($udmn_current, , , $usub_current, , , $uals_current, , , $umail_current, , , $uftp_current, , , $usql_db_current, , , $usql_user_current, , , $utraff_current, , , $udisk_current, ) = generate_reseller_users_props($resellerId);
    $trafficLimitBytes = $resellerProps['max_traff_amnt'] * 1048576;
    $trafficUsageBytes = $resellerProps['current_traff_amnt'] * 1048576;
    $diskspaceLimitBytes = $resellerProps['max_disk_amnt'] * 1048576;
    $diskspaceUsageBytes = $resellerProps['current_disk_amnt'] * 1048576;
    $trafficUsagePercent = make_usage_vals($trafficUsageBytes, $trafficLimitBytes);
    $diskspaceUsagePercent = make_usage_vals($diskspaceUsageBytes, $diskspaceLimitBytes);
    $tpl->assign(array('RESELLER_NAME' => tohtml($resellerName), 'RESELLER_ID' => tohtml($resellerId), 'TRAFFIC_PERCENT' => tohtml($trafficUsagePercent), 'TRAFFIC_MSG' => $trafficLimitBytes ? tohtml(tr('%1$s / %2$s of %3$s', bytesHuman($utraff_current), bytesHuman($trafficUsageBytes), bytesHuman($trafficLimitBytes))) : tohtml(tr('%1$s / %2$s of unlimited', bytesHuman($utraff_current), bytesHuman($trafficUsageBytes))), 'DISK_PERCENT' => tohtml($diskspaceUsagePercent), 'DISK_MSG' => $diskspaceLimitBytes ? tohtml(tr('%1$s / %2$s of %3$s', bytesHuman($udisk_current), bytesHuman($diskspaceUsageBytes), bytesHuman($diskspaceLimitBytes))) : tohtml(tr('%1$s / %2$s of unlimited', bytesHuman($udisk_current), bytesHuman($diskspaceUsageBytes))), 'DMN_MSG' => $resellerProps['max_dmn_cnt'] ? tohtml(tr('%1$d / %2$d of %3$d', $udmn_current, $resellerProps['current_dmn_cnt'], $resellerProps['max_dmn_cnt'])) : tohtml(tr('%1$d / %2$d of unlimited', $udmn_current, $resellerProps['current_dmn_cnt'])), 'SUB_MSG' => $resellerProps['max_sub_cnt'] > 0 ? tohtml(tr('%1$d / %2$d of %3$d', $usub_current, $resellerProps['current_sub_cnt'], $resellerProps['max_sub_cnt'])) : ($resellerProps['max_sub_cnt'] == '-1' ? tohtml(tr('disabled')) : tohtml(tr('%1$d / %2$d of unlimited', $usub_current, $resellerProps['current_sub_cnt']))), 'ALS_MSG' => $resellerProps['max_als_cnt'] > 0 ? tohtml(tr('%1$d / %2$d of %3$d', $uals_current, $resellerProps['current_als_cnt'], $resellerProps['max_als_cnt'])) : ($resellerProps['max_als_cnt'] == '-1' ? tohtml(tr('disabled')) : tohtml(tr('%1$d / %2$d of unlimited', $uals_current, $resellerProps['current_als_cnt']))), 'MAIL_MSG' => $resellerProps['max_mail_cnt'] > 0 ? tohtml(tr('%1$d / %2$d of %3$d', $umail_current, $resellerProps['current_mail_cnt'], $resellerProps['max_mail_cnt'])) : ($resellerProps['max_mail_cnt'] == '-1' ? tohtml(tr('disabled')) : tohtml(tr('%1$d / %2$d of unlimited', $umail_current, $resellerProps['current_mail_cnt']))), 'FTP_MSG' => $resellerProps['max_ftp_cnt'] > 0 ? tohtml(tr('%1$d / %2$d of %3$d', $uftp_current, $resellerProps['current_ftp_cnt'], $resellerProps['max_ftp_cnt'])) : ($resellerProps['max_ftp_cnt'] == '-1' ? tohtml(tr('disabled')) : tohtml(tr('%1$d / %2$d of unlimited', $uftp_current, $resellerProps['current_ftp_cnt']))), 'SQL_DB_MSG' => $resellerProps['max_sql_db_cnt'] > 0 ? tohtml(tr('%1$d / %2$d of %3$d', $usql_db_current, $resellerProps['current_sql_db_cnt'], $resellerProps['max_sql_db_cnt'])) : ($resellerProps['max_sql_db_cnt'] == '-1' ? tohtml(tr('disabled')) : tohtml(tr('%1$d / %2$d of unlimited', $usql_db_current, $resellerProps['current_sql_db_cnt']))), 'SQL_USER_MSG' => $resellerProps['max_sql_user_cnt'] > 0 ? tohtml(tr('%1$d / %2$d of %3$d', $usql_user_current, $resellerProps['current_sql_user_cnt'], $resellerProps['max_sql_user_cnt'])) : ($resellerProps['max_sql_user_cnt'] == '-1' ? tohtml(tr('disabled')) : tohtml(tr('%1$d / %2$d of unlimited', $usql_user_current, $resellerProps['current_sql_user_cnt'])))));
}
Exemplo n.º 14
0
function output_text($saveterm, $saverom, $savetrans, $savetags, $show_rom, $show_trans, $show_tags, $annplcmnt)
{
    if ($show_tags) {
        if ($savetrans == '' && $savetags != '') {
            $savetrans = '* ' . $savetags;
        } else {
            $savetrans = trim($savetrans . ' ' . $savetags);
        }
    }
    if ($show_rom && $saverom == '') {
        $show_rom = 0;
    }
    if ($show_trans && $savetrans == '') {
        $show_trans = 0;
    }
    if ($annplcmnt == 1) {
        if ($show_rom || $show_trans) {
            echo ' ';
            if ($show_trans) {
                echo '<span class="anntrans">' . tohtml($savetrans) . '</span> ';
            }
            if ($show_rom && !$show_trans) {
                echo '<span class="annrom">' . tohtml($saverom) . '</span> ';
            }
            if ($show_rom && $show_trans) {
                echo '<span class="annrom" dir="ltr">[' . tohtml($saverom) . ']</span> ';
            }
            echo ' <span class="annterm">';
        }
        echo tohtml($saveterm);
        if ($show_rom || $show_trans) {
            echo '</span> ';
        }
    } else {
        if ($show_rom || $show_trans) {
            echo ' <span class="annterm">';
        }
        echo tohtml($saveterm);
        if ($show_rom || $show_trans) {
            echo '</span> ';
            if ($show_rom && !$show_trans) {
                echo '<span class="annrom">' . tohtml($saverom) . '</span>';
            }
            if ($show_rom && $show_trans) {
                echo '<span class="annrom" dir="ltr">[' . tohtml($saverom) . ']</span> ';
            }
            if ($show_trans) {
                echo '<span class="anntrans">' . tohtml($savetrans) . '</span>';
            }
            echo ' ';
        }
    }
}
Exemplo n.º 15
0
/**
 * @param EasySCP_TemplateEngine $tpl
 * @param EasySCP_Database $sql
 * @param int $dmn_id
 */
function gen_htaccess_entries($tpl, $sql, &$dmn_id)
{
    $query = "\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t`htaccess`\n\t\tWHERE\n\t\t\t`dmn_id` = ?\n\t";
    $rs = exec_query($sql, $query, $dmn_id);
    if ($rs->recordCount() == 0) {
        set_page_message(tr('You do not have protected areas'), 'info');
    } else {
        while (!$rs->EOF) {
            $auth_name = $rs->fields['auth_name'];
            $tpl->append(array('AREA_NAME' => tohtml($auth_name), 'JS_AREA_NAME' => addslashes($auth_name), 'AREA_PATH' => tohtml($rs->fields['path']), 'PID' => $rs->fields['id'], 'STATUS' => translate_dmn_status($rs->fields['status'])));
            $rs->moveNext();
        }
    }
}
Exemplo n.º 16
0
/**
 * @param EasySCP_TemplateEngine $tpl
 * @param EasySCP_Database $sql
 * @param int $user_id
 * @param string $eid
 */
function gen_error_page_data($tpl, $sql, $eid)
{
    $domain = $_SESSION['user_logged'];
    // Check if we already have an error page
    $vfs = new EasySCP_VirtualFileSystem($domain, $sql);
    $error = $vfs->get('/errors/' . $eid . '.html');
    if (false !== $error) {
        // We already have an error page, return it
        $tpl->assign(array('ERROR' => tohtml($error)));
        return;
    }
    // No error page
    $tpl->assign(array('ERROR' => ''));
}
Exemplo n.º 17
0
/**
 * Generates admin general informations
 *
 * @param  iMSCP_pTemplate $tpl iMSCP_pTemplate instance
 * @return void
 */
function admin_getAdminGeneralInfo($tpl)
{
    $cfg = iMSCP_Registry::get('config');
    $totalMails = records_count('mail_users', 'mail_type NOT RLIKE \'_catchall\'', '');
    if ($cfg['COUNT_DEFAULT_EMAIL_ADDRESSES']) {
        $showTotalMails = $totalMails;
    } else {
        $totalDefaultMails = records_count('mail_users', 'mail_acc', 'abuse');
        $totalDefaultMails += records_count('mail_users', 'mail_acc', 'webmaster');
        $totalDefaultMails += records_count('mail_users', 'mail_acc', 'postmaster');
        $showTotalMails = $totalMails - $totalDefaultMails . '/' . $totalMails;
    }
    $tpl->assign(array('ACCOUNT_NAME' => tohtml($_SESSION['user_logged']), 'ADMIN_USERS' => records_count('admin', 'admin_type', 'admin'), 'RESELLER_USERS' => records_count('admin', 'admin_type', 'reseller'), 'NORMAL_USERS' => records_count('admin', 'admin_type', 'user'), 'DOMAINS' => records_count('domain', '', ''), 'SUBDOMAINS' => records_count('subdomain', '', '') + records_count('subdomain_alias', 'subdomain_alias_id', '', ''), 'DOMAINS_ALIASES' => records_count('domain_aliasses', '', ''), 'MAIL_ACCOUNTS' => $showTotalMails, 'FTP_ACCOUNTS' => records_count('ftp_users', '', ''), 'SQL_DATABASES' => records_count('sql_database', '', ''), 'SQL_USERS' => get_sql_user_count()));
}
Exemplo n.º 18
0
/**
 * Generates databases list
 *
 * @param iMSCP_pTemplate $tpl Template engine
 * @param int $dmnId Domain unique identifier
 * @return void
 */
function client_databasesList($tpl, $dmnId)
{
    $stmt = exec_query('SELECT sqld_id, sqld_name FROM sql_database WHERE domain_id = ? ORDER BY sqld_name ', $dmnId);
    if (!$stmt->rowCount()) {
        set_page_message(tr('You do not have databases.'), 'static_info');
        $tpl->assign('SQL_DATABASES_USERS_LIST', '');
    } else {
        while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
            $tpl->assign(array('DB_ID' => $row['sqld_id'], 'DB_NAME' => tohtml($row['sqld_name']), 'DB_NAME_JS' => tojs($row['sqld_name'])));
            _client_generateDatabaseSqlUserList($tpl, $row['sqld_id']);
            $tpl->parse('SQL_DATABASES_LIST', '.sql_databases_list');
        }
    }
}
Exemplo n.º 19
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', '');
    }
}
Exemplo n.º 20
0
/**
 * clean_input
 *
 * @param String $input input data (eg. post-var) to be cleaned
 * @param boolean $htmlencode should return value be html encoded (& -> &amp;)
 * @return String space trimmed, {|} trimmed, stripslashed, eventually htmlencoded input string
 */
function clean_input($input, $htmlencode = false)
{
    // Trim leading and trealing white spaces
    $input = trim($input, " ");
    $input = trim($input, '{..}');
    if (get_magic_quotes_gpc()) {
        $input = stripslashes($input);
    }
    if ($htmlencode) {
        return tohtml($input, 'htmlAttr');
    } else {
        return $input;
    }
}
Exemplo n.º 21
0
/**
 * Generate catchall item
 *
 * @param iMSCP_pTemplate $tpl
 * @param string $action Action
 * @param int $dmnId Domain unique identifier
 * @param string $dmnName Domain name
 * @param int $mailId Mail unique identifier
 * @param string $mailAcc Mail account
 * @param string $mailStatus Mail account status
 * @param string $catchallType Catchall type
 * @return void
 */
function client_generateCatchallItem($tpl, $action, $dmnId, $dmnName, $mailId, $mailAcc, $mailStatus, $catchallType)
{
    $showDmnName = decode_idna($dmnName);
    if ($action == 'create') {
        $tpl->assign(array('CATCHALL_DOMAIN' => tohtml($showDmnName), 'CATCHALL_ACC' => tr('None'), 'TR_CATCHALL_STATUS' => tr('N/A'), 'TR_CATCHALL_ACTION' => tr('Create catch all'), 'CATCHALL_ACTION' => $action, 'CATCHALL_ACTION_SCRIPT' => "mail_catchall_add.php?id={$dmnId};{$catchallType}", 'DEL_ICON' => ''));
    } else {
        list($catchallAction, $catchallActionScript) = client_generateAction($mailId, $mailStatus);
        $showDmnName = decode_idna($dmnName);
        $showMailAcc = decode_idna($mailAcc);
        $tpl->assign(array('CATCHALL_DOMAIN' => tohtml($showDmnName), 'CATCHALL_ACC' => tohtml($showMailAcc), 'TR_CATCHALL_STATUS' => translate_dmn_status($mailStatus), 'TR_CATCHALL_ACTION' => $catchallAction, 'CATCHALL_ACTION' => $catchallAction, 'CATCHALL_ACTION_SCRIPT' => $catchallActionScript));
        if ($catchallActionScript == '#') {
            $tpl->assign('DEL_ICON', '');
        }
    }
}
Exemplo n.º 22
0
/**
 * Generate page data
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @param string $ftpUserId Ftp userid
 * @param string $mainDomainName Main domain name
 * @return void
 */
function generatePageData($tpl, $ftpUserId, $mainDomainName)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    $query = "SELECT `homedir` FROM `ftp_users` WHERE `userid` = ?";
    $stmt = exec_query($query, $ftpUserId);
    $ftpHomeDir = $stmt->fields['homedir'];
    $customerHomeDir = $cfg->USER_WEB_DIR . '/' . $mainDomainName;
    if ($ftpHomeDir == $customerHomeDir) {
        $customFtpHomeDir = '/';
    } else {
        $customFtpHomeDir = substr($ftpHomeDir, strlen($customerHomeDir));
    }
    $tpl->assign(array('USERNAME' => tohtml($ftpUserId), 'HOME_DIR' => isset($_POST['home_dir']) ? tohtml($_POST['home_dir']) : tohtml($customFtpHomeDir), 'ID' => tohtml($ftpUserId)));
}
Exemplo n.º 23
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', '');
    }
}
Exemplo n.º 24
0
/**
 * Generate page
 *
 * @param $tpl TemplateEngine
 * @return void
 */
function opendkim_generatePage($tpl)
{
    $stmt = exec_query('
			SELECT
				opendkim_id, domain_name, opendkim_status, domain_dns, domain_text
			FROM
				opendkim
			LEFT JOIN domain_dns ON(
					domain_dns.domain_id = opendkim.domain_id
				AND
					domain_dns.alias_id = IFNULL(opendkim.alias_id, 0)
				AND
					owned_by = ?
			)
			WHERE
				admin_id = ?
		', array('OpenDKIM_Plugin', $_SESSION['user_id']));
    if ($stmt->rowCount()) {
        while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
            if ($row['opendkim_status'] == 'ok') {
                $statusIcon = 'ok';
            } elseif ($row['opendkim_status'] == 'disabled') {
                $statusIcon = 'disabled';
            } elseif (in_array($row['opendkim_status'], array('toadd', 'tochange', 'todelete', 'torestore', 'tochange', 'toenable', 'todisable', 'todelete'))) {
                $statusIcon = 'reload';
            } else {
                $statusIcon = 'error';
            }
            if ($row['domain_text']) {
                if (strpos($row['domain_dns'], ' ') !== false) {
                    $dnsName = explode(' ', $row['domain_dns']);
                    $dnsName = $dnsName[0];
                } else {
                    $dnsName = $row['domain_dns'];
                }
            } else {
                $dnsName = '';
            }
            $tpl->assign(array('DOMAIN_NAME' => decode_idna($row['domain_name']), 'DOMAIN_KEY' => $row['domain_text'] ? tohtml($row['domain_text']) : tr('Generation in progress.'), 'OPENDKIM_ID' => $row['opendkim_id'], 'DNS_NAME' => $dnsName ? tohtml($dnsName) : tr('n/a'), 'KEY_STATUS' => translate_dmn_status($row['opendkim_status']), 'STATUS_ICON' => $statusIcon));
            $tpl->parse('DOMAINKEY_ITEM', '.domainkey_item');
        }
    } else {
        $tpl->assign('CUSTOMER_LIST', '');
        set_page_message(tr('No domain with OpenDKIM support has been found.'), 'static_info');
    }
}
Exemplo n.º 25
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', '');
    }
}
Exemplo n.º 26
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');
    }
}
Exemplo n.º 27
0
/**
 * Generates IPs list.
 *
 * @access private
 * @param iMSCP_pTemplate $tpl Template engine
 * @return void
 */
function _client_generateIpsList($tpl)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    $query = "SELECT * FROM `server_ips`";
    $stmt = execute_query($query);
    if ($stmt->rowCount()) {
        while (!$stmt->EOF) {
            list($actionName, $actionUrl) = _client_generateIpAction($stmt->fields['ip_id'], $stmt->fields['ip_status']);
            $tpl->assign(array('IP' => $stmt->fields['ip_number'], 'NETWORK_CARD' => $stmt->fields['ip_card'] === NULL ? '' : tohtml($stmt->fields['ip_card'])));
            $tpl->assign(array('ACTION_NAME' => $cfg->BASE_SERVER_IP == $stmt->fields['ip_number'] ? tr('Protected') : $actionName, 'ACTION_URL' => $cfg->BASE_SERVER_IP == $stmt->fields['ip_number'] ? '#' : $actionUrl));
            $tpl->parse('IP_ADDRESS_BLOCK', '.ip_address_block');
            $stmt->moveNext();
        }
    } else {
        // Should never occur but who knows.
        $tpl->assign('IP_ADDRESSES_BLOCK', '');
        set_page_message(tr('No IP address found.'), 'info');
    }
}
Exemplo n.º 28
0
/**
 * @param EasySCP_TemplateEngine $tpl
 * @param EasySCP_Database $sql
 * @param int $dmn_id
 * @param string $dmn_name
 */
function gen_page_ftp_list($tpl, $sql, $dmn_id, $dmn_name)
{
    $query = "\n\t\tSELECT\n\t\t\t`gid`,\n\t\t\t`members`\n\t\tFROM\n\t\t\t`ftp_group`\n\t\tWHERE\n\t\t\t`groupname` = ?\n\t;";
    $rs = exec_query($sql, $query, $dmn_name);
    if ($rs->recordCount() == 0) {
        $tpl->assign(array('FTP_MSG' => tr('FTP list is empty!'), 'FTP_MSG_TYPE' => 'info', 'FTP_ITEM' => '', 'FTPS_TOTAL' => '', 'TABLE_LIST' => ''));
    } else {
        $ftp_accs = explode(',', $rs->fields['members']);
        sort($ftp_accs);
        reset($ftp_accs);
        for ($i = 0, $cnt_ftp_accs = count($ftp_accs); $i < $cnt_ftp_accs; $i++) {
            $tpl->assign('ITEM_CLASS', $i % 2 == 0 ? 'content' : 'content2');
            $ftp_accs_encode[$i] = decode_idna($ftp_accs[$i]);
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`net2ftppasswd`\n\t\t\t\tFROM\n\t\t\t\t\t`ftp_users`\n\t\t\t\tWHERE\n\t\t\t\t\t`userid` = ?\n\t\t\t;";
            $rs = exec_query($sql, $query, $ftp_accs[$i]);
            $tpl->append(array('FTP_ACCOUNT' => tohtml($ftp_accs_encode[$i]), 'UID' => urlencode($ftp_accs[$i]), 'FTP_LOGIN_AVAILABLE' => !is_null($rs->fields['net2ftppasswd'])));
        }
        $tpl->assign('TOTAL_FTP_ACCOUNTS', count($ftp_accs));
    }
}
Exemplo n.º 29
0
function make_trans($i, $wid, $trans, $word, $lang)
{
    global $tbpref;
    $trans = trim($trans);
    $widset = is_numeric($wid);
    if ($widset) {
        $alltrans = get_first_value("select WoTranslation as value from " . $tbpref . "words where WoID = " . $wid);
        $transarr = preg_split('/[' . get_sepas() . ']/u', $alltrans);
        $r = "";
        $set = false;
        foreach ($transarr as $t) {
            $tt = trim($t);
            if ($tt == '*' || $tt == '') {
                continue;
            }
            if (!$set && $tt == $trans) {
                $set = true;
                $r .= '<span class="nowrap"><input class="impr-ann-radio" checked="checked" type="radio" name="rg' . $i . '" value="' . tohtml($tt) . '" />&nbsp;' . tohtml($tt) . '</span> <br /> ';
            } else {
                $r .= '<span class="nowrap"><input class="impr-ann-radio" type="radio" name="rg' . $i . '" value="' . tohtml($tt) . '" />&nbsp;' . tohtml($tt) . '</span>  <br />  ';
            }
        }
        if (!$set) {
            $r .= '<span class="nowrap"><input class="impr-ann-radio" checked="checked" type="radio" name="rg' . $i . '" value="" />&nbsp;<input class="impr-ann-text" type="text" name="tx' . $i . '" id="tx' . $i . '" value="' . tohtml($trans) . '" maxlength="50" size="40" />';
        } else {
            $r .= '<span class="nowrap"><input class="impr-ann-radio" type="radio" name="rg' . $i . '" value="" />&nbsp;<input class="impr-ann-text" type="text" name="tx' . $i . '" id="tx' . $i . '" value="" maxlength="50" size="40" />';
        }
    } else {
        $r = '<span class="nowrap"><input checked="checked" type="radio" name="rg' . $i . '" value="" />&nbsp;<input class="impr-ann-text" type="text" name="tx' . $i . '" id="tx' . $i . '" value="' . tohtml($trans) . '" maxlength="50" size="40" />';
    }
    $r .= ' &nbsp;<img class="click" src="icn/eraser.png" title="Erase Text Field" alt="Erase Text Field" onclick="$(\'#tx' . $i . '\').val(\'\').trigger(\'change\');" />';
    $r .= ' &nbsp;<img class="click" src="icn/star.png" title="* (Set to Term)" alt="* (Set to Term)" onclick="$(\'#tx' . $i . '\').val(\'*\').trigger(\'change\');" />';
    if ($widset) {
        $r .= ' &nbsp;<img class="click" src="icn/plus-button.png" title="Save another translation to existent term" alt="Save another translation to existent term" onclick="addTermTranslation(' . $wid . ', \'#tx' . $i . '\',\'\',' . $lang . ');" />';
    } else {
        $r .= ' &nbsp;<img class="click" src="icn/plus-button.png" title="Save translation to new term" alt="Save translation to new term" onclick="addTermTranslation(0, \'#tx' . $i . '\',' . prepare_textdata_js($word) . ',' . $lang . ');" />';
    }
    $r .= '</span>';
    return $r;
}
Exemplo n.º 30
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', '');
    }
}