Ejemplo n.º 1
0
// TODO !!! Просто $allow_anonymous используется в платежных модулях !!!
$allow_anonymous = $allow_anonymous || isset($sn_page_data['allow_anonymous']) && $sn_page_data['allow_anonymous'];
// pdump($allow_anonymous, '$allow_anonymous');
// pdump($sys_user_logged_in, '$sys_user_logged_in');
if ($sys_user_logged_in && INITIAL_PAGE == 'login') {
    sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
} elseif ($account_logged_in && !$sys_user_logged_in) {
    // empty(core_auth::$user['id'])
    //  pdump($sn_page_name);
    //  pdump(INITIAL_PAGE);
    //  die('{Тут должна быть ваша реклама. Точнее - ввод имени игрока}');
} elseif (!$allow_anonymous && !$sys_user_logged_in) {
    // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
    sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
}
$user_time_diff = playerTimeDiff::user_time_diff_get();
global $time_diff;
define('SN_CLIENT_TIME_DIFF', $time_diff = $user_time_diff[PLAYER_OPTION_TIME_DIFF] + $user_time_diff[PLAYER_OPTION_TIME_DIFF_UTC_OFFSET]);
define('SN_CLIENT_TIME_LOCAL', SN_TIME_NOW + SN_CLIENT_TIME_DIFF);
define('SN_CLIENT_TIME_DIFF_GMT', $user_time_diff[PLAYER_OPTION_TIME_DIFF]);
// Разница в GMT-времени между клиентом и сервером. Реальная разница в ходе часов
!empty($user) && sys_get_param_id('only_hide_news') ? die(nws_mark_read($user)) : false;
!empty($user) && sys_get_param_id('survey_vote') ? die(survey_vote($user)) : false;
!empty($sn_mvc['i18n']['']) ? lng_load_i18n($sn_mvc['i18n']['']) : false;
$sn_page_name && !empty($sn_mvc['i18n'][$sn_page_name]) ? lng_load_i18n($sn_mvc['i18n'][$sn_page_name]) : false;
execute_hooks($sn_mvc['model'][''], $template);
global $skip_fleet_update;
$skip_fleet_update = $skip_fleet_update || $supernova->options['fleet_update_skip'] || defined('IN_ADMIN');
if (!$skip_fleet_update && SN_TIME_NOW - strtotime($config->fleet_update_last) > $config->fleet_update_interval) {
    require_once SN_ROOT_PHYSICAL . "includes/includes/flt_flying_fleet_handler2" . DOT_PHP_EX;
    flt_flying_fleet_handler($skip_fleet_update);
Ejemplo n.º 2
0
function sn_options_view($template = null)
{
    global $lang, $template_result, $user, $planetrow, $user_option_list, $user_option_types, $sn_message_class_list, $config;
    sys_user_vacation($user);
    $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE);
    $template = gettemplate('options', $template);
    //  $template_result['.']['skin_list'][] = array(
    //    'NAME'  => $lang['select_skin_path'],
    //    'VALUE' => '',
    //  );
    $dir = dir(SN_ROOT_PHYSICAL . 'skins');
    while (($entry = $dir->read()) !== false) {
        if (is_dir("skins/{$entry}") && $entry[0] != '.') {
            $template_result['.']['skin_list'][] = array('VALUE' => $entry, 'NAME' => $entry, 'SELECTED' => $user['dpath'] == "skins/{$entry}/");
        }
    }
    $dir->close();
    foreach ($lang['opt_planet_sort_options'] as $key => &$value) {
        $template_result['.']['planet_sort_options'][] = array('VALUE' => $key, 'NAME' => $value, 'SELECTED' => classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT] == $key);
    }
    /*
      foreach($lang['opt_planet_sort_ascending'] as $key => &$value) {
        $template_result['.']['planet_sort_ascending'][] = array(
          'VALUE' => $key,
          'NAME'  => $value,
          'SELECTED' => classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == $key,
        );
      }
    */
    foreach ($lang['sys_gender_list'] as $key => $value) {
        $template_result['.']['gender_list'][] = array('VALUE' => $key, 'NAME' => $value, 'SELECTED' => $user['gender'] == $key);
    }
    $lang_list = lng_get_list();
    foreach ($lang_list as $lang_id => $lang_data) {
        $template_result['.']['languages'][] = array('VALUE' => $lang_id, 'NAME' => $lang_data['LANG_NAME_NATIVE'], 'SELECTED' => $lang_id == $user['lang']);
    }
    if (isset($lang['menu_customize_show_hide_button_state'])) {
        foreach ($lang['menu_customize_show_hide_button_state'] as $key => $value) {
            $template->assign_block_vars('menu_customize_show_hide_button_state', array('ID' => $key, 'NAME' => $value));
        }
    }
    $str_date_format = "%3\$02d %2\$0s %1\$04d {$lang['top_of_year']} %4\$02d:%5\$02d:%6\$02d";
    $time_now_parsed = getdate($user['deltime']);
    $user_time_diff = playerTimeDiff::user_time_diff_get();
    // $player_options = player_load_option($user);
    $template->assign_vars(array('USER_ID' => $user['id'], 'ACCOUNT_NAME' => sys_safe_output(classSupernova::$auth->account->account_name), 'USER_AUTHLEVEL' => $user['authlevel'], 'menu_customize_show_hide_button' => classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON], 'PLAYER_OPTION_MENU_SHOW_ON_BUTTON' => classSupernova::$user_options[PLAYER_OPTION_MENU_SHOW_ON_BUTTON], 'PLAYER_OPTION_MENU_HIDE_ON_BUTTON' => classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_ON_BUTTON], 'PLAYER_OPTION_MENU_HIDE_ON_LEAVE' => classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_ON_LEAVE], 'PLAYER_OPTION_MENU_UNPIN_ABSOLUTE' => classSupernova::$user_options[PLAYER_OPTION_MENU_UNPIN_ABSOLUTE], 'PLAYER_OPTION_MENU_ITEMS_AS_BUTTONS' => classSupernova::$user_options[PLAYER_OPTION_MENU_ITEMS_AS_BUTTONS], 'PLAYER_OPTION_MENU_WHITE_TEXT' => classSupernova::$user_options[PLAYER_OPTION_MENU_WHITE_TEXT], 'PLAYER_OPTION_MENU_OLD' => classSupernova::$user_options[PLAYER_OPTION_MENU_OLD], 'PLAYER_OPTION_UNIVERSE_OLD' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_OLD], 'PLAYER_OPTION_UNIVERSE_DISABLE_COLONIZE' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_DISABLE_COLONIZE], 'PLAYER_OPTION_DESIGN_DISABLE_BORDERS' => classSupernova::$user_options[PLAYER_OPTION_DESIGN_DISABLE_BORDERS], 'PLAYER_OPTION_TECH_TREE_TABLE' => classSupernova::$user_options[PLAYER_OPTION_TECH_TREE_TABLE], '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], 'ADM_PROTECT_PLANETS' => $user['authlevel'] >= 3, 'opt_usern_data' => htmlspecialchars($user['username']), 'opt_mail1_data' => $user['email'], 'opt_mail2_data' => sys_safe_output(classSupernova::$auth->account->account_email), 'OPT_DPATH_DATA' => $user['dpath'], 'PLAYER_OPTION_PLANET_SORT_INVERSE' => classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE], 'PLAYER_OPTION_FLEET_SPY_DEFAULT' => classSupernova::$user_options[PLAYER_OPTION_FLEET_SPY_DEFAULT], 'PLAYER_OPTION_TOOLTIP_DELAY' => classSupernova::$user_options[PLAYER_OPTION_TOOLTIP_DELAY], 'PLAYER_OPTION_BUILD_AUTOCONVERT_HIDE' => classSupernova::$user_options[PLAYER_OPTION_BUILD_AUTOCONVERT_HIDE], 'PLAYER_OPTION_NAVBAR_RESEARCH_WIDE' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_RESEARCH_WIDE], 'PLAYER_OPTION_NAVBAR_DISABLE_EXPEDITIONS' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_EXPEDITIONS], 'PLAYER_OPTION_NAVBAR_DISABLE_FLYING_FLEETS' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_FLYING_FLEETS], 'PLAYER_OPTION_NAVBAR_DISABLE_RESEARCH' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_RESEARCH], 'PLAYER_OPTION_NAVBAR_DISABLE_PLANET' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_PLANET], 'PLAYER_OPTION_NAVBAR_DISABLE_HANGAR' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_HANGAR], 'PLAYER_OPTION_NAVBAR_DISABLE_QUESTS' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_QUESTS], 'PLAYER_OPTION_NAVBAR_DISABLE_META_MATTER' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_META_MATTER], 'opt_sskin_data' => $user['design'] == 1 ? " checked='checked'" : '', 'opt_noipc_data' => $user['noipcheck'] == 1 ? " checked='checked'" : '', 'deltime' => $user['deltime'], 'deltime_text' => sprintf($str_date_format, $time_now_parsed['year'], $lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'], $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds']), 'opt_avatar' => $user['avatar'], 'config_game_email_pm' => $config->game_email_pm, 'user_settings_esp' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_SPYING], 'user_settings_mis' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_MISSILE], 'user_settings_wri' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_PM], 'user_settings_statistics' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_STATS], 'user_settings_info' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_PROFILE], 'user_settings_bud' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_BUDDY], 'user_time_diff_forced' => $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED], 'adm_pl_prot' => $user['admin_protection'], 'user_birthday' => $user['user_birthday'], 'GENDER' => $user['gender'], 'GENDER_TEXT' => $lang['sys_gender_list'][$user['gender']], 'FMT_DATE' => $FMT_DATE, 'JS_FMT_DATE' => js_safe_string($FMT_DATE), 'USER_VACATION_DISABLE' => $config->user_vacation_disable, 'VACATION_NEXT' => $user['vacation_next'], 'VACATION_NEXT_TEXT' => date(FMT_DATE_TIME, $user['vacation_next']), 'VACATION_TIMEOUT' => $user['vacation_next'] - SN_TIME_NOW > 0 ? $user['vacation_next'] - SN_TIME_NOW : 0, 'SN_TIME_NOW' => SN_TIME_NOW, 'SERVER_SEND_EMAIL' => $config->game_email_pm, 'SERVER_NAME_CHANGE' => $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE, 'SERVER_NAME_CHANGE_PAY' => $config->game_user_changename == SERVER_PLAYER_NAME_CHANGE_PAY, 'SERVER_NAME_CHANGE_ENABLED' => $config->game_user_changename == SERVER_PLAYER_NAME_CHANGE_FREE || $config->game_user_changename == SERVER_PLAYER_NAME_CHANGE_PAY && mrc_get_level($user, $planetrow, RES_DARK_MATTER) >= $config->game_user_changename_cost, 'DARK_MATTER' => pretty_number($config->game_user_changename_cost, true, mrc_get_level($user, $planetrow, RES_DARK_MATTER)), 'PAGE_HEADER' => $lang['opt_header']));
    foreach ($user_option_list as $option_group_id => $option_group) {
        if ($option_group_id == OPT_MESSAGE) {
            foreach ($sn_message_class_list as $message_class_id => $message_class_data) {
                if ($message_class_data['switchable'] || $message_class_data['email'] && $config->game_email_pm) {
                    $option_name = $message_class_data['name'];
                    $template->assign_block_vars("options_{$option_group_id}", array('NAME' => $message_class_data['name'], 'TEXT' => $lang['msg_class'][$message_class_id], 'PM' => $message_class_data['switchable'] ? $user["opt_{$option_name}"] : -1, 'EMAIL' => $message_class_data['email'] && $config->game_email_pm ? $user["opt_email_{$option_name}"] : -1));
                }
            }
        } else {
            foreach ($option_group as $option_name => $option_value) {
                if (array_key_exists($option_name, $user_option_types)) {
                    $option_type = $user_option_types[$option_name];
                } else {
                    $option_type = 'switch';
                }
                $template->assign_block_vars("options_{$option_group_id}", array('NAME' => $option_name, 'TYPE' => $option_type, 'TEXT' => $lang['opt_custom'][$option_name], 'HINT' => $lang['opt_custom']["{$option_name}_hint"], 'VALUE' => $user[$option_name]));
            }
        }
    }
    return parsetemplate($template);
}
Ejemplo n.º 3
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);
}