예제 #1
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;
}
예제 #2
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);
}