Exemplo n.º 1
0
function display($page, $title = '', $topnav = true, $metatags = '', $AdminPage = false, $isDisplayMenu = true)
{
    global $link, $debug, $user, $planetrow, $IsUserChecked, $time_now, $config, $lang;
    if (!$user || !isset($user['id']) || !is_numeric($user['id'])) {
        $isDisplayMenu = false;
        $topnav = false;
    }
    // Global header
    $template = gettemplate('simple_header', true);
    $template->assign_vars(array('title' => ($title ? "{$title} - " : '') . "{$lang['sys_server']} {$config->game_name} - {$lang['sys_supernova']}", '-meta-' => $metatags));
    displayP(parsetemplate($template));
    // Left menu
    if ($isDisplayMenu) {
        $AdminPage = $AdminPage ? $user['authlevel'] : 0;
        displayP(parsetemplate(ShowLeftMenu($AdminPage)));
        echo '<div id="page_body">';
    } else {
        echo '<div>';
    }
    echo '<center>';
    if ($topnav) {
        displayP(parsetemplate(ShowTopNavigationBar($user, $planetrow)));
    }
    displayP($page);
    echo '</center></div>';
    // Global footer
    $template = gettemplate('simple_footer', true);
    $template->assign_vars(array('ADMIN_EMAIL' => $config->game_adminEmail, 'SERVER_TIME' => $time_now, 'SN_VERSION' => SN_VERSION));
    displayP(parsetemplate($template));
    sys_log_hit();
    // Affichage du Debug si necessaire
    if ($user['authlevel'] == 3 && $config->debug) {
        $debug->echo_log();
    }
    if (isset($link)) {
        mysql_close();
    }
    die;
}
Exemplo n.º 2
0
    $page_count = ceil($rows['CNT'] / $page_limit);
    for ($i = 0; $i < $page_count; $i++) {
        $template->assign_block_vars('page', array('NUMBER' => $i));
    }
    $page = min($page_count, sys_get_param_int('page'));
} else {
    $page = 0;
}
$chat = array();
$start_row = $page * $page_limit;
$query = doquery("SELECT * FROM {{chat}} WHERE ally_id = '{$alliance}' ORDER BY messageid DESC LIMIT {$start_row}, {$page_limit};");
while ($chat_row = mysql_fetch_object($query)) {
    // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick
    $nick_stripped = htmlentities(strip_tags($chat_row->user), ENT_QUOTES, 'cp1251');
    $nick = str_replace(strip_tags($chat_row->user), $nick_stripped, $chat_row->user);
    if (!$history) {
        $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('[{$nick_stripped}]');\">{$nick}</span>";
    }
    $chat[] = array('TIME' => date(FMT_DATE_TIME, htmlentities($chat_row->timestamp, ENT_QUOTES, 'cp1251')), 'NICK' => $nick, 'TEXT' => CHT_messageParse(htmlentities($chat_row->message, ENT_QUOTES, 'cp1251')));
}
$chat = array_reverse($chat);
foreach ($chat as $chat_item) {
    $template->assign_block_vars('chat', $chat_item);
}
$template->assign_vars(array('PAGE' => $page, 'ALLY' => $alliance, 'HISTORY' => $history));
$config->array_set('users', $user['id'], 'chat_last_refresh', $microtime);
if ($history) {
    display(parsetemplate($template), "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}");
} else {
    displayP(parsetemplate($template));
}
Exemplo n.º 3
0
function sn_chat_msg_view($template = null)
{
    global $config, $skip_fleet_update, $user, $lang;
    define('IN_AJAX', true);
    $skip_fleet_update = true;
    $history = sys_get_param_str('history');
    if (!$history) {
        $config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO);
    }
    $page = 0;
    $last_message = '';
    $alliance = 0;
    $template_result['.']['chat'] = array();
    if (!$history && $config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) {
        $result['disable'] = true;
        $template_result['.']['chat'][] = array('TIME' => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')), 'DISABLE' => true);
    } else {
        $alliance = sys_get_param_str('ally') && $user['ally_id'] ? $user['ally_id'] : 0;
        $page_limit = 20;
        // Chat rows Limit
        $where_add = '';
        $last_message = 0;
        if ($history) {
            $rows = doquery("SELECT count(1) AS CNT FROM {{chat}} WHERE ally_id = '{$alliance}';", true);
            $page_count = ceil($rows['CNT'] / $page_limit);
            for ($i = 0; $i < $page_count; $i++) {
                $template_result['.']['page'][] = array('NUMBER' => $i);
            }
            $page = min($page_count, max(0, sys_get_param_int('sheet')));
        } else {
            $last_message = sys_get_param_id('last_message');
            $where_add = $last_message ? "AND `messageid` > {$last_message}" : '';
        }
        $start_row = $page * $page_limit;
        $query = doquery("SELECT c.*, u.authlevel\n      FROM\n        {{chat}} AS c\n        LEFT JOIN {{users}} AS u ON u.id = c.chat_message_sender_id\n      WHERE c.chat_message_recipient_id IS NULL AND c.ally_id = '{$alliance}' {$where_add} ORDER BY messageid DESC LIMIT {$start_row}, {$page_limit};");
        while ($chat_row = db_fetch($query)) {
            // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick
            $chat_row['user'] = player_nick_render_to_html($chat_row['user']);
            $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8');
            $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']);
            if (!$history) {
                $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>";
            }
            $template_result['.']['chat'][] = array('TIME' => cht_message_parse(date(FMT_DATE_TIME, $chat_row['timestamp'] + SN_CLIENT_TIME_DIFF)), 'NICK' => $nick, 'TEXT' => cht_message_parse($chat_row['message'], false, intval($chat_row['authlevel'])));
            $last_message = max($last_message, $chat_row['messageid']);
        }
    }
    $template_result['.']['chat'] = array_reverse($template_result['.']['chat']);
    $template_result += array('PAGE' => $page, 'ALLY' => $alliance, 'HISTORY' => $history);
    $template = gettemplate('chat_messages', $template);
    $template->assign_recursive($template_result);
    if ($history) {
        display($template, "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true);
    } else {
        $result['last_message'] = $last_message;
        ob_start();
        displayP($template);
        $result['html'] = ob_get_contents();
        ob_end_clean();
        print json_encode($result);
    }
    die;
}
Exemplo n.º 4
0
function sn_display($page, $title = '', $topnav = true, $metatags = '', $AdminPage = false, $isDisplayMenu = true, $die = true)
{
    global $link, $debug, $user, $user_impersonator, $planetrow, $config, $lang, $template_result, $sn_mvc;
    if (!$user || !isset($user['id']) || !is_numeric($user['id'])) {
        $isDisplayMenu = false;
        $topnav = false;
    }
    //  $template->assign_recursive($template_result);
    $isDisplayMenu = is_object($page) && isset($page->_rootref['MENU']) ? $page->_rootref['MENU'] : $isDisplayMenu;
    $topnav = is_object($page) && isset($page->_rootref['NAVBAR']) ? $page->_rootref['NAVBAR'] : $topnav;
    $title = $title ? $title : (is_object($page) && isset($page->_rootref['PAGE_HEADER']) ? $page->_rootref['PAGE_HEADER'] : '');
    if (is_object($page) && !isset($page->_rootref['PAGE_HEADER']) && $title) {
        $page->assign_var('PAGE_HEADER', $title);
    }
    isset($sn_mvc['view']['']) and execute_hooks($sn_mvc['view'][''], $page);
    // Global header
    $user_time_diff = user_time_diff_get();
    $user_time_measured_unix = intval(isset($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) ? strtotime($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) : 0);
    $player_options = player_load_option($user);
    $template = gettemplate('_global_header', true);
    $template->assign_vars(array('USER_AUTHLEVEL' => intval($user['authlevel']), 'TIME_NOW' => SN_TIME_NOW, 'LOGIN_LOGOUT' => defined('LOGIN_LOGOUT') && LOGIN_LOGOUT === true, 'GAME_MODE_CSS_PREFIX' => $config->game_mode == GAME_BLITZ ? 'blitz_' : '', 'TIME_DIFF_MEASURE' => intval(empty($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) && (SN_TIME_NOW - $user_time_measured_unix > PERIOD_HOUR || $user_time_diff[PLAYER_OPTION_TIME_DIFF] == '')), 'title' => ($title ? "{$title} - " : '') . "{$lang['sys_server']} {$config->game_name} - {$lang['sys_supernova']}", '-meta-' => $metatags, 'ADV_SEO_META_DESCRIPTION' => $config->adv_seo_meta_description, 'ADV_SEO_META_KEYWORDS' => $config->adv_seo_meta_keywords, 'ADV_SEO_JAVASCRIPT' => $config->adv_seo_javascript, 'LANG_LANGUAGE' => $lang['LANG_INFO']['LANG_NAME_ISO2'], 'LANG_ENCODING' => 'utf-8', 'LANG_DIRECTION' => $lang['LANG_INFO']['LANG_DIRECTION'], 'SOUND_ENABLED' => $player_options[PLAYER_OPTION_SOUND_ENABLED], 'IMPERSONATING' => $user_impersonator ? sprintf($lang['sys_impersonated_as'], $user['username'], $user_impersonator['username']) : ''));
    $template->assign_recursive($template_result);
    displayP(parsetemplate($template));
    if ($isDisplayMenu && !isset($_COOKIE['menu_disable'])) {
        $AdminPage = $AdminPage ? $user['authlevel'] : 0;
        displayP(parsetemplate(tpl_render_menu($AdminPage)));
    }
    if ($topnav) {
        displayP(parsetemplate(tpl_render_topnav($user, $planetrow)));
    }
    displayP(parsetemplate(gettemplate('_content_header', true)));
    if (!is_array($page)) {
        $page = array($page);
    }
    $result_added = false;
    foreach ($page as $page_item) {
        if (!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) {
            $page_item = gettemplate('_result_message', $page_item);
            $temp = $page_item->files['_result_message'];
            unset($page_item->files['_result_message']);
            $page_item->files = array_reverse($page_item->files);
            $page_item->files['_result_message'] = $temp;
            $page_item->files = array_reverse($page_item->files);
            $result_added = true;
        }
        displayP($page_item);
    }
    //  echo '</center>';
    if ($isDisplayMenu) {
        //    echo '</div>';
    }
    displayP(parsetemplate(gettemplate('_content_footer', true)));
    // Global footer
    $template = gettemplate('_global_footer', true);
    $template->assign_vars(array('ADMIN_EMAIL' => $config->game_adminEmail, 'TIME_NOW' => SN_TIME_NOW, 'SN_VERSION' => SN_VERSION));
    displayP(parsetemplate($template));
    $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false;
    isset($link) ? sn_db_diconnect($link) : false;
    sn_benchmark();
    $die ? die($die === true ? 0 : $die) : false;
}
Exemplo n.º 5
0
/**
 * @param template|string $page
 * @param string          $title
 * @param bool|true       $isDisplayTopNav
 * @param string          $metatags
 * @param bool|false      $AdminPage
 * @param bool|true       $isDisplayMenu
 * @param bool|int|string $exitStatus - Код или сообщение выхода
 */
function sn_display($page, $title = '', $isDisplayTopNav = true, $metatags = '', $isDisplayMenu = true, $exitStatus = true)
{
    global $debug, $user, $planetrow, $config, $lang, $template_result, $sn_mvc, $sn_page_name;
    //  $isDisplayMenu = is_object($page) && isset($page->_rootref['MENU']) ? $page->_rootref['MENU'] : $isDisplayMenu;
    //  $topnav = is_object($page) && isset($page->_rootref['NAVBAR']) ? $page->_rootref['NAVBAR'] : $topnav;
    //  $title = $title ? $title : (is_object($page) && isset($page->_rootref['PAGE_HEADER']) ? $page->_rootref['PAGE_HEADER'] : '');
    //  if(is_object($page) && !isset($page->_rootref['PAGE_HEADER']) && $title) {
    //    $page->assign_var('PAGE_HEADER', $title);
    //  }
    if (is_object($page)) {
        isset($page->_rootref['MENU']) ? $isDisplayMenu = $page->_rootref['MENU'] : false;
        isset($page->_rootref['NAVBAR']) ? $isDisplayTopNav = $page->_rootref['NAVBAR'] : false;
        !$title && !empty($page->_rootref['PAGE_HEADER']) ? $title = $page->_rootref['PAGE_HEADER'] : false;
        !isset($page->_rootref['PAGE_HEADER']) && $title ? $page->assign_var('PAGE_HEADER', $title) : false;
    }
    if (empty($user['id']) || !is_numeric($user['id'])) {
        $isDisplayMenu = false;
        $isDisplayTopNav = false;
    }
    isset($sn_mvc['view']['']) and execute_hooks($sn_mvc['view'][''], $page);
    // Global header
    $user_time_diff = playerTimeDiff::user_time_diff_get();
    $user_time_measured_unix = intval(isset($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) ? strtotime($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) : 0);
    $font_size = !empty($_COOKIE[SN_COOKIE_F]) ? $_COOKIE[SN_COOKIE_F] : classSupernova::$user_options[PLAYER_OPTION_BASE_FONT_SIZE];
    if (strpos($font_size, '%') !== false) {
        // Размер шрифта в процентах
        $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%';
    } elseif (strpos($font_size, 'px') !== false) {
        // Размер шрифта в пикселях
        $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px';
    } else {
        // Не мышонка, не лягушка...
        $font_size = FONT_SIZE_PERCENT_DEFAULT_STRING;
    }
    $template = gettemplate('_global_header', true);
    if (!empty($sn_mvc['javascript'])) {
        foreach ($sn_mvc['javascript'] as $page_name => $script_list) {
            if (empty($page_name) || $page_name == $sn_page_name) {
                foreach ($script_list as $filename => $content) {
                    $template->assign_block_vars('javascript', array('FILE' => $filename, 'CONTENT' => $content));
                }
            }
        }
    }
    $template->assign_vars(array('USER_AUTHLEVEL' => intval($user['authlevel']), 'FONT_SIZE' => $font_size, 'FONT_SIZE_PERCENT_DEFAULT_STRING' => FONT_SIZE_PERCENT_DEFAULT_STRING, 'SN_TIME_NOW' => SN_TIME_NOW, 'LOGIN_LOGOUT' => defined('LOGIN_LOGOUT') && LOGIN_LOGOUT === true, 'GAME_MODE_CSS_PREFIX' => $config->game_mode == GAME_BLITZ ? 'blitz_' : '', 'TIME_DIFF_MEASURE' => intval(empty($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) && (SN_TIME_NOW - $user_time_measured_unix > PERIOD_HOUR || $user_time_diff[PLAYER_OPTION_TIME_DIFF] == '')), 'title' => ($title ? "{$title} - " : '') . "{$lang['sys_server']} {$config->game_name} - {$lang['sys_supernova']}", '-meta-' => $metatags, 'ADV_SEO_META_DESCRIPTION' => $config->adv_seo_meta_description, 'ADV_SEO_META_KEYWORDS' => $config->adv_seo_meta_keywords, 'ADV_SEO_JAVASCRIPT' => $config->adv_seo_javascript, 'LANG_LANGUAGE' => $lang['LANG_INFO']['LANG_NAME_ISO2'], 'LANG_ENCODING' => 'utf-8', 'LANG_DIRECTION' => $lang['LANG_INFO']['LANG_DIRECTION'], 'SOUND_ENABLED' => classSupernova::$user_options[PLAYER_OPTION_SOUND_ENABLED], 'PLAYER_OPTION_ANIMATION_DISABLED' => classSupernova::$user_options[PLAYER_OPTION_ANIMATION_DISABLED], 'PLAYER_OPTION_PROGRESS_BARS_DISABLED' => classSupernova::$user_options[PLAYER_OPTION_PROGRESS_BARS_DISABLED], 'IMPERSONATING' => !empty($template_result[F_IMPERSONATE_STATUS]) ? sprintf($lang['sys_impersonated_as'], $user['username'], $template_result[F_IMPERSONATE_OPERATOR]) : '', 'PLAYER_OPTION_DESIGN_DISABLE_BORDERS' => classSupernova::$user_options[PLAYER_OPTION_DESIGN_DISABLE_BORDERS]));
    $template->assign_recursive($template_result);
    displayP(parsetemplate($template));
    if ($isDisplayMenu && !isset($_COOKIE['menu_disable'])) {
        // $AdminPage = $AdminPage ? $user['authlevel'] : 0;
        displayP(parsetemplate(tpl_render_menu()));
    }
    if ($isDisplayTopNav) {
        displayP(parsetemplate(tpl_render_topnav($user, $planetrow)));
    }
    displayP(parsetemplate(gettemplate('_content_header', true)));
    !is_array($page) ? $page = array($page) : false;
    $result_added = false;
    foreach ($page as $page_item) {
        if (!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) {
            $page_item = gettemplate('_result_message', $page_item);
            $temp = $page_item->files['_result_message'];
            unset($page_item->files['_result_message']);
            $page_item->files = array_reverse($page_item->files);
            $page_item->files['_result_message'] = $temp;
            $page_item->files = array_reverse($page_item->files);
            $result_added = true;
        }
        displayP($page_item);
    }
    displayP(parsetemplate(gettemplate('_content_footer', true)));
    // Global footer
    $template = gettemplate('_global_footer', true);
    $template->assign_vars(array('ADMIN_EMAIL' => $config->game_adminEmail, 'SN_TIME_NOW' => SN_TIME_NOW, 'SN_VERSION' => SN_VERSION));
    displayP(parsetemplate($template));
    $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false;
    sn_db_disconnect();
    $exitStatus and die($exitStatus === true ? 0 : $exitStatus);
}