/** * @dataProvider obtain_users_online_string_data */ public function test_obtain_users_online_string($forum_id, $display_guests, $expected) { $this->db->sql_query('DELETE FROM phpbb_sessions'); global $config, $user, $auth; $config['load_online_guests'] = $display_guests; $user->lang = $this->load_language(); $auth = $this->getMock('auth'); $acl_get_map = array(array('u_viewonline', true)); $auth->expects($this->any())->method('acl_get')->with($this->stringContains('_'), $this->anything())->will($this->returnValueMap($acl_get_map)); $time = time(); $this->create_guest_sessions($time); $this->create_user_sessions($time); $online_users = obtain_users_online($forum_id); $this->assertEquals($expected, obtain_users_online_string($online_users, $forum_id)); }
/** * {@inheritdoc} */ public function display(array $settings, $edit_mode = false) { $data = $this->context->get_data_ref(); if (!empty($data['.'][0]['TOTAL_USERS_ONLINE'])) { $l_online_users = $data['.'][0]['TOTAL_USERS_ONLINE']; $online_userlist = $data['.'][0]['LOGGED_IN_USER_LIST']; $l_online_record = $data['.'][0]['RECORD_USERS']; } else { $item_id = 0; $item = 'forum'; $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; $l_online_record = $this->user->lang('RECORD_ONLINE_USERS', (int) $this->config['record_online_users'], $this->user->format_date($this->config['record_online_date'], false, true)); } $this->ptemplate->assign_vars(array('TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, 'RECORD_USERS' => $l_online_record, 'U_VIEWONLINE' => $this->_get_viewonline_url())); unset($data); return array('title' => 'WHO_IS_ONLINE', 'content' => $this->ptemplate->render_view('blitze/sitemaker', 'blocks/whois.html', 'whois_block')); }
/** * Generate page header */ function page_header($page_title = '', $display_online_list = true) { global $db, $config, $template, $SID, $_SID, $user, $auth, $phpEx, $phpbb_root_path; if (defined('HEADER_INC')) { return; } define('HEADER_INC', true); // gzip_compression if ($config['gzip_compress']) { if (@extension_loaded('zlib') && !headers_sent()) { ob_start('ob_gzhandler'); } } // Generate logged in/logged out status if ($user->data['user_id'] != ANONYMOUS) { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=logout', true, $user->session_id); $l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']); } else { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login'); $l_login_logout = $user->lang['LOGIN']; } // Last visit date/time $s_last_visit = $user->data['user_id'] != ANONYMOUS ? $user->format_date($user->data['session_last_visit']) : ''; // Get users online list ... if required $l_online_users = $online_userlist = $l_online_record = ''; if ($config['load_online'] && $config['load_online_time'] && $display_online_list) { $f = request_var('f', 0); $f = max($f, 0); $online_users = obtain_users_online($f); $user_online_strings = obtain_users_online_string($online_users, $f); $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; $total_online_users = $online_users['total_online']; if ($total_online_users > $config['record_online_users']) { set_config('record_online_users', $total_online_users, true); set_config('record_online_date', time(), true); } $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'])); $l_online_time = $config['load_online_time'] == 1 ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES'; $l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']); } else { $l_online_time = ''; } $l_privmsgs_text = $l_privmsgs_text_unread = ''; $s_privmsg_new = false; // Obtain number of new private messages if user is logged in if (!empty($user->data['is_registered'])) { if ($user->data['user_new_privmsg']) { $l_message_new = $user->data['user_new_privmsg'] == 1 ? $user->lang['NEW_PM'] : $user->lang['NEW_PMS']; $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']); if (!$user->data['user_last_privmsg'] || $user->data['user_last_privmsg'] > $user->data['session_last_visit']) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_last_privmsg = ' . $user->data['session_last_visit'] . ' WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); $s_privmsg_new = true; } else { $s_privmsg_new = false; } } else { $l_privmsgs_text = $user->lang['NO_NEW_PM']; $s_privmsg_new = false; } $l_privmsgs_text_unread = ''; if ($user->data['user_unread_privmsg'] && $user->data['user_unread_privmsg'] != $user->data['user_new_privmsg']) { $l_message_unread = $user->data['user_unread_privmsg'] == 1 ? $user->lang['UNREAD_PM'] : $user->lang['UNREAD_PMS']; $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']); } } // Which timezone? $tz = $user->data['user_id'] != ANONYMOUS ? strval(doubleval($user->data['user_timezone'])) : strval(doubleval($config['board_timezone'])); // Send a proper content-language to the output $user_lang = $user->lang['USER_LANG']; if (strpos($user_lang, '-x-') !== false) { $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-')); } // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array('SITENAME' => $config['sitename'], 'SITE_DESCRIPTION' => $config['site_desc'], 'PAGE_TITLE' => $page_title, 'SCRIPT_NAME' => str_replace('.' . $phpEx, '', $user->page['page_name']), 'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit), 'LAST_VISIT_YOU' => $s_last_visit, 'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time(), false, true)), 'TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, 'RECORD_USERS' => $l_online_record, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 'SID' => $SID, '_SID' => $_SID, 'SESSION_ID' => $user->session_id, 'ROOT_PATH' => $phpbb_root_path, 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_INDEX' => $user->lang['FORUM_INDEX'], 'L_ONLINE_EXPLAIN' => $l_online_time, 'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&folder=inbox'), 'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&folder=inbox'), 'U_POPUP_PM' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&mode=popup'), 'UA_POPUP_PM' => addslashes(append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&mode=popup')), 'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}"), 'U_VIEWONLINE' => $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel') ? append_sid("{$phpbb_root_path}viewonline.{$phpEx}") : '', 'U_LOGIN_LOGOUT' => $u_login_logout, 'U_INDEX' => append_sid("{$phpbb_root_path}index.{$phpEx}"), 'U_SEARCH' => append_sid("{$phpbb_root_path}search.{$phpEx}"), 'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register'), 'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}"), 'U_MODCP' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", false, true, $user->session_id), 'U_FAQ' => append_sid("{$phpbb_root_path}faq.{$phpEx}"), 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unanswered'), 'U_SEARCH_ACTIVE_TOPICS' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=delete_cookies'), 'U_TEAM' => $user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile') ? '' : append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=leaders'), 'U_RESTORE_PERMISSIONS' => $user->data['user_perm_from'] && $auth->acl_get('a_switchperm') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm') : '', 'S_USER_LOGGED_IN' => $user->data['user_id'] != ANONYMOUS ? true : false, 'S_AUTOLOGIN_ENABLED' => $config['allow_autologin'] ? true : false, 'S_BOARD_DISABLED' => $config['board_disable'] ? true : false, 'S_REGISTERED_USER' => !empty($user->data['is_registered']) ? true : false, 'S_IS_BOT' => !empty($user->data['is_bot']) ? true : false, 'S_USER_PM_POPUP' => $user->optionget('popuppm'), 'S_USER_LANG' => $user_lang, 'S_USER_BROWSER' => isset($user->data['session_browser']) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'], 'S_USERNAME' => $user->data['username'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left', 'S_CONTENT_ENCODING' => 'UTF-8', 'S_TIMEZONE' => $user->data['user_dst'] || $user->data['user_id'] == ANONYMOUS && $config['board_dst'] ? sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], ''), 'S_DISPLAY_ONLINE_LIST' => $l_online_time ? 1 : 0, 'S_DISPLAY_SEARCH' => !$config['load_search'] ? 0 : (isset($auth) ? $auth->acl_get('u_search') && $auth->acl_getf_global('f_search') : 1), 'S_DISPLAY_PM' => $config['allow_privmsg'] && !empty($user->data['is_registered']) && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm')) ? true : false, 'S_DISPLAY_MEMBERLIST' => isset($auth) ? $auth->acl_get('u_viewprofile') : 0, 'S_NEW_PM' => $s_privmsg_new ? 1 : 0, 'S_REGISTER_ENABLED' => $config['require_activation'] != USER_ACTIVATION_DISABLE ? true : false, 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', 'T_SUPER_TEMPLATE_PATH' => isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path'] ? "{$phpbb_root_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', 'T_IMAGESET_PATH' => "{$phpbb_root_path}styles/" . $user->theme['imageset_path'] . '/imageset', 'T_IMAGESET_LANG_PATH' => "{$phpbb_root_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->data['user_lang'], 'T_IMAGES_PATH' => "{$phpbb_root_path}images/", 'T_SMILIES_PATH' => "{$phpbb_root_path}{$config['smilies_path']}/", 'T_AVATAR_PATH' => "{$phpbb_root_path}{$config['avatar_path']}/", 'T_AVATAR_GALLERY_PATH' => "{$phpbb_root_path}{$config['avatar_gallery_path']}/", 'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/", 'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/", 'T_STYLESHEET_LINK' => !$user->theme['theme_storedb'] ? "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : "{$phpbb_root_path}style.{$phpEx}?sid={$user->session_id}&id=" . $user->theme['style_id'] . '&lang=' . $user->data['user_lang'], 'T_STYLESHEET_NAME' => $user->theme['theme_name'], 'SITE_LOGO_IMG' => $user->img('site_logo'), 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . (!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1' ? '' : '; domain=' . $config['cookie_domain']) . (!$config['cookie_secure'] ? '' : '; secure')))); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); header('Cache-Control: private, no-cache="set-cookie"'); header('Expires: 0'); header('Pragma: no-cache'); return; }
/** * Generate page header */ function page_header($page_title = '', $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = true) { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; global $phpbb_dispatcher, $request, $phpbb_container, $phpbb_admin_path; if (defined('HEADER_INC')) { return; } define('HEADER_INC', true); // A listener can set this variable to `true` when it overrides this function $page_header_override = false; /** * Execute code and/or overwrite page_header() * * @event core.page_header * @var string page_title Page title * @var bool display_online_list Do we display online users list * @var string item Restrict online users to a certain * session item, e.g. forum for * session_forum_id * @var int item_id Restrict online users to item id * @var bool page_header_override Shall we return instead of running * the rest of page_header() * @since 3.1.0-a1 */ $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'page_header_override'); extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars))); if ($page_header_override) { return; } // gzip_compression if ($config['gzip_compress']) { // to avoid partially compressed output resulting in blank pages in // the browser or error messages, compression is disabled in a few cases: // // 1) if headers have already been sent, this indicates plaintext output // has been started so further content must not be compressed // 2) the length of the current output buffer is non-zero. This means // there is already some uncompressed content in this output buffer // so further output must not be compressed // 3) if more than one level of output buffering is used because we // cannot test all output buffer level content lengths. One level // could be caused by php.ini output_buffering. Anything // beyond that is manual, so the code wrapping phpBB in output buffering // can easily compress the output itself. // if (@extension_loaded('zlib') && !headers_sent() && ob_get_level() <= 1 && ob_get_length() == 0) { ob_start('ob_gzhandler'); } } $user->update_session_infos(); // Generate logged in/logged out status if ($user->data['user_id'] != ANONYMOUS) { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=logout', true, $user->session_id); $l_login_logout = $user->lang['LOGOUT']; } else { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login'); $l_login_logout = $user->lang['LOGIN']; } // Last visit date/time $s_last_visit = $user->data['user_id'] != ANONYMOUS ? $user->format_date($user->data['session_last_visit']) : ''; // Get users online list ... if required $l_online_users = $online_userlist = $l_online_record = $l_online_time = ''; if ($config['load_online'] && $config['load_online_time'] && $display_online_list) { /** * Load online data: * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id. */ $item_id = max($item_id, 0); $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; $total_online_users = $online_users['total_online']; if ($total_online_users > $config['record_online_users']) { set_config('record_online_users', $total_online_users, true); set_config('record_online_date', time(), true); } $l_online_record = $user->lang('RECORD_ONLINE_USERS', (int) $config['record_online_users'], $user->format_date($config['record_online_date'], false, true)); $l_online_time = $user->lang('VIEW_ONLINE_TIMES', (int) $config['load_online_time']); } $s_privmsg_new = false; // Check for new private messages if user is logged in if (!empty($user->data['is_registered'])) { if ($user->data['user_new_privmsg']) { if (!$user->data['user_last_privmsg'] || $user->data['user_last_privmsg'] > $user->data['session_last_visit']) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_last_privmsg = ' . $user->data['session_last_visit'] . ' WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); $s_privmsg_new = true; } else { $s_privmsg_new = false; } } else { $s_privmsg_new = false; } } $forum_id = request_var('f', 0); $topic_id = request_var('t', 0); $s_feed_news = false; // Get option for news if ($config['feed_enable']) { $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); $result = $db->sql_query_limit($sql, 1, 0, 600); $s_feed_news = (int) $db->sql_fetchfield('forum_id'); $db->sql_freeresult($result); } // Determine board url - we may need it later $board_url = generate_board_url() . '/'; // This path is sent with the base template paths in the assign_vars() // call below. We need to correct it in case we are accessing from a // controller because the web paths will be incorrect otherwise. $phpbb_path_helper = $phpbb_container->get('path_helper'); $corrected_path = $phpbb_path_helper->get_web_root_path(); $web_path = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH ? $board_url : $corrected_path; // Send a proper content-language to the output $user_lang = $user->lang['USER_LANG']; if (strpos($user_lang, '-x-') !== false) { $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-')); } $s_search_hidden_fields = array(); if ($_SID) { $s_search_hidden_fields['sid'] = $_SID; } if (!empty($_EXTRA_URL)) { foreach ($_EXTRA_URL as $url_param) { $url_param = explode('=', $url_param, 2); $s_search_hidden_fields[$url_param[0]] = $url_param[1]; } } $dt = $user->create_datetime(); $timezone_offset = $user->lang(array('timezones', 'UTC_OFFSET'), phpbb_format_timezone_offset($dt->getOffset())); $timezone_name = $user->timezone->getName(); if (isset($user->lang['timezones'][$timezone_name])) { $timezone_name = $user->lang['timezones'][$timezone_name]; } // Output the notifications $notifications = false; if ($config['load_notifications'] && $user->data['user_id'] != ANONYMOUS && $user->data['user_type'] != USER_IGNORE) { $phpbb_notifications = $phpbb_container->get('notification_manager'); $notifications = $phpbb_notifications->load_notifications(array('all_unread' => true, 'limit' => 5)); foreach ($notifications['notifications'] as $notification) { $template->assign_block_vars('notifications', $notification->prepare_for_display()); } } $notification_mark_hash = generate_link_hash('mark_all_notifications_read'); // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array('SITENAME' => $config['sitename'], 'SITE_DESCRIPTION' => $config['site_desc'], 'PAGE_TITLE' => $page_title, 'SCRIPT_NAME' => str_replace('.' . $phpEx, '', $user->page['page_name']), 'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit), 'LAST_VISIT_YOU' => $s_last_visit, 'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time(), false, true)), 'TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, 'RECORD_USERS' => $l_online_record, 'PRIVATE_MESSAGE_COUNT' => !empty($user->data['user_unread_privmsg']) ? $user->data['user_unread_privmsg'] : 0, 'CURRENT_USER_AVATAR' => phpbb_get_user_avatar($user->data), 'CURRENT_USERNAME_SIMPLE' => get_username_string('no_profile', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), 'CURRENT_USERNAME_FULL' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), 'UNREAD_NOTIFICATIONS_COUNT' => $notifications !== false ? $notifications['unread_count'] : '', 'NOTIFICATIONS_COUNT' => $notifications !== false ? $notifications['unread_count'] : '', 'U_VIEW_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=ucp_notifications'), 'U_MARK_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=ucp_notifications&mode=notification_list&mark=all&token=' . $notification_mark_hash), 'U_NOTIFICATION_SETTINGS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=ucp_notifications&mode=notification_options'), 'S_NOTIFICATIONS_DISPLAY' => $config['load_notifications'], 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 'S_USER_NEW' => $user->data['user_new'], 'SID' => $SID, '_SID' => $_SID, 'SESSION_ID' => $user->session_id, 'ROOT_PATH' => $web_path, 'BOARD_URL' => $board_url, 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_INDEX' => $config['board_index_text'] !== '' ? $config['board_index_text'] : $user->lang['FORUM_INDEX'], 'L_SITE_HOME' => $config['site_home_text'] !== '' ? $config['site_home_text'] : $user->lang['HOME'], 'L_ONLINE_EXPLAIN' => $l_online_time, 'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&folder=inbox'), 'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&folder=inbox'), 'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}"), 'U_VIEWONLINE' => $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel') ? append_sid("{$phpbb_root_path}viewonline.{$phpEx}") : '', 'U_LOGIN_LOGOUT' => $u_login_logout, 'U_INDEX' => append_sid("{$phpbb_root_path}index.{$phpEx}"), 'U_SEARCH' => append_sid("{$phpbb_root_path}search.{$phpEx}"), 'U_SITE_HOME' => $config['site_home_url'], 'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register'), 'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}"), 'U_USER_PROFILE' => get_username_string('profile', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), 'U_MODCP' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", false, true, $user->session_id), 'U_FAQ' => append_sid("{$phpbb_root_path}faq.{$phpEx}"), 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unanswered'), 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=delete_cookies'), 'U_CONTACT_US' => $config['contact_admin_form_enable'] && $config['email_enable'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=contactadmin') : '', 'U_TEAM' => $user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile') ? '' : append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=team'), 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=privacy'), 'U_RESTORE_PERMISSIONS' => $user->data['user_perm_from'] && $auth->acl_get('a_switchperm') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm') : '', 'U_FEED' => generate_board_url() . "/feed.{$phpEx}", 'S_USER_LOGGED_IN' => $user->data['user_id'] != ANONYMOUS ? true : false, 'S_AUTOLOGIN_ENABLED' => $config['allow_autologin'] ? true : false, 'S_BOARD_DISABLED' => $config['board_disable'] ? true : false, 'S_REGISTERED_USER' => !empty($user->data['is_registered']) ? true : false, 'S_IS_BOT' => !empty($user->data['is_bot']) ? true : false, 'S_USER_LANG' => $user_lang, 'S_USER_BROWSER' => isset($user->data['session_browser']) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'], 'S_USERNAME' => $user->data['username'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left', 'S_CONTENT_ENCODING' => 'UTF-8', 'S_TIMEZONE' => sprintf($user->lang['ALL_TIMES'], $timezone_offset, $timezone_name), 'S_DISPLAY_ONLINE_LIST' => $l_online_time ? 1 : 0, 'S_DISPLAY_SEARCH' => !$config['load_search'] ? 0 : (isset($auth) ? $auth->acl_get('u_search') && $auth->acl_getf_global('f_search') : 1), 'S_DISPLAY_PM' => $config['allow_privmsg'] && !empty($user->data['is_registered']) && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm')) ? true : false, 'S_DISPLAY_MEMBERLIST' => isset($auth) ? $auth->acl_get('u_viewprofile') : 0, 'S_NEW_PM' => $s_privmsg_new ? 1 : 0, 'S_REGISTER_ENABLED' => $config['require_activation'] != USER_ACTIVATION_DISABLE ? true : false, 'S_FORUM_ID' => $forum_id, 'S_TOPIC_ID' => $topic_id, 'S_LOGIN_ACTION' => !defined('ADMIN_START') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login') : append_sid("{$phpbb_admin_path}index.{$phpEx}", false, true, $user->session_id), 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => $phpbb_path_helper->remove_web_root_path(build_url()))), 'S_ENABLE_FEEDS' => $config['feed_enable'] ? true : false, 'S_ENABLE_FEEDS_OVERALL' => $config['feed_overall'] ? true : false, 'S_ENABLE_FEEDS_FORUMS' => $config['feed_overall_forums'] ? true : false, 'S_ENABLE_FEEDS_TOPICS' => $config['feed_topics_new'] ? true : false, 'S_ENABLE_FEEDS_TOPICS_ACTIVE' => $config['feed_topics_active'] ? true : false, 'S_ENABLE_FEEDS_NEWS' => $s_feed_news ? true : false, 'S_LOAD_UNREADS' => $config['load_unreads_search'] && ($config['load_anon_lastread'] || $user->data['is_registered']) ? true : false, 'S_SEARCH_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), 'T_ASSETS_VERSION' => $config['assets_version'], 'T_ASSETS_PATH' => "{$web_path}assets", 'T_THEME_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme', 'T_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template', 'T_SUPER_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template', 'T_IMAGES_PATH' => "{$web_path}images/", 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", 'T_AVATAR_GALLERY_PATH' => "{$web_path}{$config['avatar_gallery_path']}/", 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", 'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/stylesheet.css?assets_version=' . $config['assets_version'], 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'], 'T_JQUERY_LINK' => !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.min.js?assets_version=" . $config['assets_version'], 'S_ALLOW_CDN' => !empty($config['allow_cdn']), 'T_THEME_NAME' => rawurlencode($user->style['style_path']), 'T_THEME_LANG_NAME' => $user->data['user_lang'], 'T_TEMPLATE_NAME' => $user->style['style_path'], 'T_SUPER_TEMPLATE_NAME' => rawurlencode(isset($user->style['style_parent_tree']) && $user->style['style_parent_tree'] ? $user->style['style_parent_tree'] : $user->style['style_path']), 'T_IMAGES' => 'images', 'T_SMILIES' => $config['smilies_path'], 'T_AVATAR' => $config['avatar_path'], 'T_AVATAR_GALLERY' => $config['avatar_gallery_path'], 'T_ICONS' => $config['icons_path'], 'T_RANKS' => $config['ranks_path'], 'T_UPLOAD' => $config['upload_path'], 'SITE_LOGO_IMG' => $user->img('site_logo'))); $http_headers = array(); if ($send_headers) { // An array of http headers that phpbb will set. The following event may override these. $http_headers += array('Content-type' => 'text/html; charset=UTF-8', 'Cache-Control' => 'private, no-cache="set-cookie"', 'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT'); if (!empty($user->data['is_bot'])) { // Let reverse proxies know we detected a bot. $http_headers['X-PHPBB-IS-BOT'] = 'yes'; } } /** * Execute code and/or overwrite _common_ template variables after they have been assigned. * * @event core.page_header_after * @var string page_title Page title * @var bool display_online_list Do we display online users list * @var string item Restrict online users to a certain * session item, e.g. forum for * session_forum_id * @var int item_id Restrict online users to item id * @var array http_headers HTTP headers that should be set by phpbb * * @since 3.1.0-b3 */ $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'http_headers'); extract($phpbb_dispatcher->trigger_event('core.page_header_after', compact($vars))); foreach ($http_headers as $hname => $hval) { header((string) $hname . ': ' . (string) $hval); } return; }
/** * Generate page header */ function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; if (defined('HEADER_INC')) { return; } define('HEADER_INC', true); // gzip_compression if ($config['gzip_compress']) { // to avoid partially compressed output resulting in blank pages in // the browser or error messages, compression is disabled in a few cases: // // 1) if headers have already been sent, this indicates plaintext output // has been started so further content must not be compressed // 2) the length of the current output buffer is non-zero. This means // there is already some uncompressed content in this output buffer // so further output must not be compressed // 3) if more than one level of output buffering is used because we // cannot test all output buffer level content lengths. One level // could be caused by php.ini output_buffering. Anything // beyond that is manual, so the code wrapping phpBB in output buffering // can easily compress the output itself. // if (@extension_loaded('zlib') && !headers_sent() && ob_get_level() <= 1 && ob_get_length() == 0) { ob_start('ob_gzhandler'); } } // Generate logged in/logged out status if ($user->data['user_id'] != ANONYMOUS) { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=logout', true, $user->session_id); $l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']); } else { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login'); $l_login_logout = $user->lang['LOGIN']; } // Last visit date/time $s_last_visit = $user->data['user_id'] != ANONYMOUS ? $user->format_date($user->data['session_last_visit']) : ''; // Get users online list ... if required $l_online_users = $online_userlist = $l_online_record = $l_online_time = ''; if ($config['load_online'] && $config['load_online_time'] && $display_online_list) { /** * Load online data: * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id. */ $item_id = max($item_id, 0); $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; $total_online_users = $online_users['total_online']; if ($total_online_users > $config['record_online_users']) { set_config('record_online_users', $total_online_users, true); set_config('record_online_date', time(), true); } $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'], false, true)); $l_online_time = $config['load_online_time'] == 1 ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES'; $l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']); } $l_privmsgs_text = $l_privmsgs_text_unread = ''; $s_privmsg_new = false; // Obtain number of new private messages if user is logged in if (!empty($user->data['is_registered'])) { if ($user->data['user_new_privmsg']) { $l_message_new = $user->data['user_new_privmsg'] == 1 ? $user->lang['NEW_PM'] : $user->lang['NEW_PMS']; $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']); if (!$user->data['user_last_privmsg'] || $user->data['user_last_privmsg'] > $user->data['session_last_visit']) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_last_privmsg = ' . $user->data['session_last_visit'] . ' WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); $s_privmsg_new = true; } else { $s_privmsg_new = false; } } else { $l_privmsgs_text = $user->lang['NO_NEW_PM']; $s_privmsg_new = false; } $l_privmsgs_text_unread = ''; if ($user->data['user_unread_privmsg'] && $user->data['user_unread_privmsg'] != $user->data['user_new_privmsg']) { $l_message_unread = $user->data['user_unread_privmsg'] == 1 ? $user->lang['UNREAD_PM'] : $user->lang['UNREAD_PMS']; $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']); } } $forum_id = request_var('f', 0); $topic_id = request_var('t', 0); $s_feed_news = false; // Get option for news if ($config['feed_enable']) { $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); $result = $db->sql_query_limit($sql, 1, 0, 600); $s_feed_news = (int) $db->sql_fetchfield('forum_id'); $db->sql_freeresult($result); } // Determine board url - we may need it later $board_url = generate_board_url() . '/'; $web_path = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH ? $board_url : $phpbb_root_path; // Which timezone? $tz = $user->data['user_id'] != ANONYMOUS ? strval(doubleval($user->data['user_timezone'])) : strval(doubleval($config['board_timezone'])); // Send a proper content-language to the output $user_lang = $user->lang['USER_LANG']; if (strpos($user_lang, '-x-') !== false) { $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-')); } $s_search_hidden_fields = array(); if ($_SID) { $s_search_hidden_fields['sid'] = $_SID; } if (!empty($_EXTRA_URL)) { foreach ($_EXTRA_URL as $url_param) { $url_param = explode('=', $url_param, 2); $s_hidden_fields[$url_param[0]] = $url_param[1]; } } // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array('SITENAME' => $config['sitename'], 'SITE_DESCRIPTION' => $config['site_desc'], 'PAGE_TITLE' => $page_title, 'SCRIPT_NAME' => str_replace('.' . $phpEx, '', $user->page['page_name']), 'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit), 'LAST_VISIT_YOU' => $s_last_visit, 'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time(), false, true)), 'TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, 'RECORD_USERS' => $l_online_record, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 'S_USER_NEW' => $user->data['user_new'], 'SID' => $SID, '_SID' => $_SID, 'SESSION_ID' => $user->session_id, 'ROOT_PATH' => $phpbb_root_path, 'BOARD_URL' => $board_url, 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_INDEX' => $user->lang['FORUM_INDEX'], 'L_ONLINE_EXPLAIN' => $l_online_time, 'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&folder=inbox'), 'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&folder=inbox'), 'U_POPUP_PM' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&mode=popup'), 'UA_POPUP_PM' => addslashes(append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&mode=popup')), 'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}"), 'U_VIEWONLINE' => $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel') ? append_sid("{$phpbb_root_path}viewonline.{$phpEx}") : '', 'U_LOGIN_LOGOUT' => $u_login_logout, 'U_INDEX' => append_sid("{$phpbb_root_path}index.{$phpEx}"), 'U_SEARCH' => append_sid("{$phpbb_root_path}search.{$phpEx}"), 'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register'), 'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}"), 'U_MODCP' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", false, true, $user->session_id), 'U_FAQ' => append_sid("{$phpbb_root_path}faq.{$phpEx}"), 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unanswered'), 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=delete_cookies'), 'U_TEAM' => $user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile') ? '' : append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=leaders'), 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=privacy'), 'U_RESTORE_PERMISSIONS' => $user->data['user_perm_from'] && $auth->acl_get('a_switchperm') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm') : '', 'U_FEED' => generate_board_url() . "/feed.{$phpEx}", 'S_USER_LOGGED_IN' => $user->data['user_id'] != ANONYMOUS ? true : false, 'S_AUTOLOGIN_ENABLED' => $config['allow_autologin'] ? true : false, 'S_BOARD_DISABLED' => $config['board_disable'] ? true : false, 'S_REGISTERED_USER' => !empty($user->data['is_registered']) ? true : false, 'S_IS_BOT' => !empty($user->data['is_bot']) ? true : false, 'S_USER_PM_POPUP' => $user->optionget('popuppm'), 'S_USER_LANG' => $user_lang, 'S_USER_BROWSER' => isset($user->data['session_browser']) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'], 'S_USERNAME' => $user->data['username'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left', 'S_CONTENT_ENCODING' => 'UTF-8', 'S_TIMEZONE' => $user->data['user_dst'] || $user->data['user_id'] == ANONYMOUS && $config['board_dst'] ? sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], ''), 'S_DISPLAY_ONLINE_LIST' => $l_online_time ? 1 : 0, 'S_DISPLAY_SEARCH' => !$config['load_search'] ? 0 : (isset($auth) ? $auth->acl_get('u_search') && $auth->acl_getf_global('f_search') : 1), 'S_DISPLAY_PM' => $config['allow_privmsg'] && !empty($user->data['is_registered']) && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm')) ? true : false, 'S_DISPLAY_MEMBERLIST' => isset($auth) ? $auth->acl_get('u_viewprofile') : 0, 'S_NEW_PM' => $s_privmsg_new ? 1 : 0, 'S_REGISTER_ENABLED' => $config['require_activation'] != USER_ACTIVATION_DISABLE ? true : false, 'S_FORUM_ID' => $forum_id, 'S_TOPIC_ID' => $topic_id, 'S_LOGIN_ACTION' => !defined('ADMIN_START') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login') : append_sid("index.{$phpEx}", false, true, $user->session_id), 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => build_url())), 'S_ENABLE_FEEDS' => $config['feed_enable'] ? true : false, 'S_ENABLE_FEEDS_OVERALL' => $config['feed_overall'] ? true : false, 'S_ENABLE_FEEDS_FORUMS' => $config['feed_overall_forums'] ? true : false, 'S_ENABLE_FEEDS_TOPICS' => $config['feed_topics_new'] ? true : false, 'S_ENABLE_FEEDS_TOPICS_ACTIVE' => $config['feed_topics_active'] ? true : false, 'S_ENABLE_FEEDS_NEWS' => $s_feed_news ? true : false, 'S_LOAD_UNREADS' => $config['load_unreads_search'] && ($config['load_anon_lastread'] || $user->data['is_registered']) ? true : false, 'S_SEARCH_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), 'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$web_path}styles/" . $user->theme['template_path'] . '/template', 'T_SUPER_TEMPLATE_PATH' => isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path'] ? "{$web_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$web_path}styles/" . $user->theme['template_path'] . '/template', 'T_IMAGESET_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset', 'T_IMAGESET_LANG_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->lang_name, 'T_IMAGES_PATH' => "{$web_path}images/", 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", 'T_AVATAR_GALLERY_PATH' => "{$web_path}{$config['avatar_gallery_path']}/", 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", 'T_STYLESHEET_LINK' => !$user->theme['theme_storedb'] ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.{$phpEx}", 'id=' . $user->theme['style_id'] . '&lang=' . $user->lang_name), 'T_STYLESHEET_NAME' => $user->theme['theme_name'], 'T_THEME_NAME' => $user->theme['theme_path'], 'T_TEMPLATE_NAME' => $user->theme['template_path'], 'T_SUPER_TEMPLATE_NAME' => isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path'] ? $user->theme['template_inherit_path'] : $user->theme['template_path'], 'T_IMAGESET_NAME' => $user->theme['imageset_path'], 'T_IMAGESET_LANG_NAME' => $user->data['user_lang'], 'T_IMAGES' => 'images', 'T_SMILIES' => $config['smilies_path'], 'T_AVATAR' => $config['avatar_path'], 'T_AVATAR_GALLERY' => $config['avatar_gallery_path'], 'T_ICONS' => $config['icons_path'], 'T_RANKS' => $config['ranks_path'], 'T_UPLOAD' => $config['upload_path'], 'SITE_LOGO_IMG' => $user->img('site_logo'), 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . (!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1' ? '' : '; domain=' . $config['cookie_domain']) . (!$config['cookie_secure'] ? '' : '; secure')))); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); header('Cache-Control: private, no-cache="set-cookie"'); header('Expires: 0'); header('Pragma: no-cache'); if (!empty($user->data['is_bot'])) { // Let reverse proxies know we detected a bot. header('X-PHPBB-IS-BOT: yes'); } return; }
} else { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login'); $l_login_logout = $user->lang['LOGIN']; } // Last visit date/time $s_last_visit = $user->data['user_id'] != ANONYMOUS ? $user->format_date($user->data['session_last_visit']) : ''; // Get users online list ... if required $l_online_users = $online_userlist = $l_online_record = $l_online_time = ''; if ($config['load_online'] && $config['load_online_time'] && $display_online_list) { // // Load online data: // For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id. // $item_id = max($item_id, 0); $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; $total_online_users = $online_users['total_online']; if ($total_online_users > $config['record_online_users']) { set_config('record_online_users', $total_online_users, true); set_config('record_online_date', time(), true); } $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'], false, true)); $l_online_time = $config['load_online_time'] == 1 ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES'; $l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']); } $l_privmsgs_text = $l_privmsgs_text_unread = ''; $s_privmsg_new = false; // Obtain number of new private messages if user is logged in if (!empty($user->data['is_registered'])) {
/** * Generate page header */ function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $user, $auth, $phpEx, $phpbb_root_path; if (defined('HEADER_INC')) { return; } define('HEADER_INC', true); // gzip_compression if ($config['gzip_compress']) { if (@extension_loaded('zlib') && !headers_sent()) { ob_start('ob_gzhandler'); } } // Generate logged in/logged out status if ($user->data['user_id'] != ANONYMOUS) { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=logout', true, $user->session_id); $l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']); } else { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login'); $l_login_logout = $user->lang['LOGIN']; } // Last visit date/time $s_last_visit = $user->data['user_id'] != ANONYMOUS ? $user->format_date($user->data['session_last_visit']) : ''; // Get users online list ... if required $l_online_users = $online_userlist = $l_online_record = ''; if ($config['load_online'] && $config['load_online_time'] && $display_online_list) { /** * Load online data: * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id. */ $item_id = max($item_id, 0); $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; $total_online_users = $online_users['total_online']; if ($total_online_users > $config['record_online_users']) { set_config('record_online_users', $total_online_users, true); set_config('record_online_date', time(), true); } $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'])); $l_online_time = $config['load_online_time'] == 1 ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES'; $l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']); } else { $l_online_time = ''; } $l_privmsgs_text = $l_privmsgs_text_unread = ''; $s_privmsg_new = false; // Obtain number of new private messages if user is logged in if (!empty($user->data['is_registered'])) { if ($user->data['user_new_privmsg']) { $l_message_new = $user->data['user_new_privmsg'] == 1 ? $user->lang['NEW_PM'] : $user->lang['NEW_PMS']; $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']); if (!$user->data['user_last_privmsg'] || $user->data['user_last_privmsg'] > $user->data['session_last_visit']) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_last_privmsg = ' . $user->data['session_last_visit'] . ' WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); $s_privmsg_new = true; } else { $s_privmsg_new = false; } } else { $l_privmsgs_text = $user->lang['NO_NEW_PM']; $s_privmsg_new = false; } $l_privmsgs_text_unread = ''; if ($user->data['user_unread_privmsg'] && $user->data['user_unread_privmsg'] != $user->data['user_new_privmsg']) { $l_message_unread = $user->data['user_unread_privmsg'] == 1 ? $user->lang['UNREAD_PM'] : $user->lang['UNREAD_PMS']; $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']); } } $forum_id = request_var('f', 0); $topic_id = request_var('t', 0); $s_feed_news = false; // Get option for news if ($config['feed_enable']) { $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); $result = $db->sql_query_limit($sql, 1, 0, 600); $s_feed_news = (int) $db->sql_fetchfield('forum_id'); $db->sql_freeresult($result); } // Determine board url - we may need it later $board_url = generate_board_url() . '/'; $web_path = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH ? $board_url : $phpbb_root_path; // Which timezone? $tz = $user->data['user_id'] != ANONYMOUS ? strval(doubleval($user->data['user_timezone'])) : strval(doubleval($config['board_timezone'])); // Send a proper content-language to the output $user_lang = $user->lang['USER_LANG']; if (strpos($user_lang, '-x-') !== false) { $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-')); } // Start output Ad $adID = ''; $forum_id = isset($f) ? $f : 0; $sql = "SELECT a.code, a.ad_id, a.position, a.type, a.image, a.url, a.height, a.width\n\t\tFROM " . AD_TABLE . " a, " . USER_GROUP_TABLE . " g\n\t\tWHERE (a.max_views >= a.views OR a.max_views = '0')\n\t\tAND (FIND_IN_SET(" . $forum_id . ", a.show_forums) > 0 OR a.show_all_forums = '1')\n\t\tAND g.user_id = " . $user->data['user_id'] . "\n\t\tAND FIND_IN_SET(g.group_id, a.groups)\n\t\tAND FIND_IN_SET(" . $user->data['user_rank'] . ", a.ranks)\n\t\tAND a.start_time < " . time() . "\n\t\tAND a.end_time > " . time() . "\n\t\tAND (a.clicks <= a.max_clicks OR a.max_clicks = '0')\n\t\tORDER BY rand()"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if ($row['type'] == 2) { $adcode[$row['position']] = '<a href="' . $phpbb_root_path . 'adclick.' . $phpEx . '?id=' . $row['ad_id'] . '"><img src="' . $row['image'] . '" height="' . $row['height'] . '" width="' . $row['width'] . '" alt="" /></a>'; } else { $adcode[$row['position']] = html_entity_decode($row['code']); } $adID[$row['position']]['ID'] = $row['ad_id']; } $db->sql_freeresult($result); // update views for every Ad for ($i = 1; $i <= 6; $i++) { if (isset($adID[$i]['ad_id'])) { $db->sql_query('UPDATE ' . AD_TABLE . ' SET views = views +1 WHERE ad_id = ' . $adID[$i]['ad_id']); } } // End output Ad // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array('AD_CODE1' => isset($adcode[1]) ? $adcode[1] : '', 'AD_CODE2' => isset($adcode[2]) ? $adcode[2] : '', 'AD_CODE3' => isset($adcode[3]) ? $adcode[3] : '', 'AD_CODE4' => isset($adcode[4]) ? $adcode[4] : '', 'AD_CODE5' => isset($adcode[5]) ? $adcode[5] : '', 'AD_CODE6' => isset($adcode[6]) ? $adcode[6] : '', 'SITENAME' => $config['sitename'], 'SITE_DESCRIPTION' => $config['site_desc'], 'PAGE_TITLE' => $page_title, 'SCRIPT_NAME' => str_replace('.' . $phpEx, '', $user->page['page_name']), 'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit), 'LAST_VISIT_YOU' => $s_last_visit, 'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time(), false, true)), 'TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, 'RECORD_USERS' => $l_online_record, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 'S_USER_NEW' => $user->data['user_new'], 'SID' => $SID, '_SID' => $_SID, 'SESSION_ID' => $user->session_id, 'ROOT_PATH' => $phpbb_root_path, 'BOARD_URL' => $board_url, 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_INDEX' => $user->lang['FORUM_INDEX'], 'L_ONLINE_EXPLAIN' => $l_online_time, 'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&folder=inbox'), 'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&folder=inbox'), 'U_POPUP_PM' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&mode=popup'), 'UA_POPUP_PM' => addslashes(append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&mode=popup')), 'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}"), 'U_VIEWONLINE' => $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel') ? append_sid("{$phpbb_root_path}viewonline.{$phpEx}") : '', 'U_LOGIN_LOGOUT' => $u_login_logout, 'U_INDEX' => append_sid("{$phpbb_root_path}index.{$phpEx}"), 'U_SEARCH' => append_sid("{$phpbb_root_path}search.{$phpEx}"), 'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register'), 'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}"), 'U_MODCP' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", false, true, $user->session_id), 'U_FAQ' => append_sid("{$phpbb_root_path}faq.{$phpEx}"), 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unanswered'), 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=delete_cookies'), 'U_TEAM' => $user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile') ? '' : append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=leaders'), 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=privacy'), 'U_RESTORE_PERMISSIONS' => $user->data['user_perm_from'] && $auth->acl_get('a_switchperm') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm') : '', 'U_FEED' => generate_board_url() . "/feed.{$phpEx}", 'S_USER_LOGGED_IN' => $user->data['user_id'] != ANONYMOUS ? true : false, 'S_AUTOLOGIN_ENABLED' => $config['allow_autologin'] ? true : false, 'S_BOARD_DISABLED' => $config['board_disable'] ? true : false, 'S_REGISTERED_USER' => !empty($user->data['is_registered']) ? true : false, 'S_IS_BOT' => !empty($user->data['is_bot']) ? true : false, 'S_USER_PM_POPUP' => $user->optionget('popuppm'), 'S_USER_LANG' => $user_lang, 'S_USER_BROWSER' => isset($user->data['session_browser']) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'], 'S_USERNAME' => $user->data['username'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left', 'S_CONTENT_ENCODING' => 'UTF-8', 'S_TIMEZONE' => $user->data['user_dst'] || $user->data['user_id'] == ANONYMOUS && $config['board_dst'] ? sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], ''), 'S_DISPLAY_ONLINE_LIST' => $l_online_time ? 1 : 0, 'S_DISPLAY_SEARCH' => !$config['load_search'] ? 0 : (isset($auth) ? $auth->acl_get('u_search') && $auth->acl_getf_global('f_search') : 1), 'S_DISPLAY_PM' => $config['allow_privmsg'] && !empty($user->data['is_registered']) && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm')) ? true : false, 'S_DISPLAY_MEMBERLIST' => isset($auth) ? $auth->acl_get('u_viewprofile') : 0, 'S_NEW_PM' => $s_privmsg_new ? 1 : 0, 'S_REGISTER_ENABLED' => $config['require_activation'] != USER_ACTIVATION_DISABLE ? true : false, 'S_FORUM_ID' => $forum_id, 'S_TOPIC_ID' => $topic_id, 'S_LOGIN_ACTION' => !defined('ADMIN_START') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login') . '&redirect=' . urlencode(str_replace('&', '&', build_url())) : append_sid("index.{$phpEx}", false, true, $user->session_id) . '&redirect=' . urlencode(str_replace('&', '&', build_url())), 'S_ENABLE_FEEDS' => $config['feed_enable'] ? true : false, 'S_ENABLE_FEEDS_FORUMS' => $config['feed_overall_forums'] ? true : false, 'S_ENABLE_FEEDS_TOPICS' => $config['feed_overall_topics'] ? true : false, 'S_ENABLE_FEEDS_NEWS' => $s_feed_news ? true : false, 'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$web_path}styles/" . $user->theme['template_path'] . '/template', 'T_SUPER_TEMPLATE_PATH' => isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path'] ? "{$web_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$web_path}styles/" . $user->theme['template_path'] . '/template', 'T_IMAGESET_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset', 'T_IMAGESET_LANG_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->data['user_lang'], 'T_IMAGES_PATH' => "{$web_path}images/", 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", 'T_AVATAR_GALLERY_PATH' => "{$web_path}{$config['avatar_gallery_path']}/", 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", 'T_STYLESHEET_LINK' => !$user->theme['theme_storedb'] ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.{$phpEx}", 'id=' . $user->theme['style_id'] . '&lang=' . $user->data['user_lang']), 'T_STYLESHEET_NAME' => $user->theme['theme_name'], 'T_THEME_NAME' => $user->theme['theme_path'], 'T_TEMPLATE_NAME' => $user->theme['template_path'], 'T_SUPER_TEMPLATE_NAME' => isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path'] ? $user->theme['template_inherit_path'] : $user->theme['template_path'], 'T_IMAGESET_NAME' => $user->theme['imageset_path'], 'T_IMAGESET_LANG_NAME' => $user->data['user_lang'], 'T_IMAGES' => 'images', 'T_SMILIES' => $config['smilies_path'], 'T_AVATAR' => $config['avatar_path'], 'T_AVATAR_GALLERY' => $config['avatar_gallery_path'], 'T_ICONS' => $config['icons_path'], 'T_RANKS' => $config['ranks_path'], 'T_UPLOAD' => $config['upload_path'], 'SITE_LOGO_IMG' => $user->img('site_logo'), 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . (!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1' ? '' : '; domain=' . $config['cookie_domain']) . (!$config['cookie_secure'] ? '' : '; secure')))); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); header('Cache-Control: private, no-cache="set-cookie"'); header('Expires: 0'); header('Pragma: no-cache'); return; }
/** * Generate page header */ function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $user, $auth, $phpEx, $phpbb_root_path; if (defined('HEADER_INC')) { return; } // www.phpBB-SEO.com SEO TOOLKIT BEGIN global $phpbb_seo; $template->assign_vars(array('PHPBB_FULL_URL' => $phpbb_seo->seo_path['phpbb_url'], 'SEO_BASE_HREF' => $phpbb_seo->seo_opt['seo_base_href'], 'SEO_START_DELIM' => $phpbb_seo->seo_delim['start'], 'SEO_SATIC_PAGE' => $phpbb_seo->seo_static['pagination'], 'SEO_EXT_PAGE' => $phpbb_seo->seo_ext['pagination'], 'SEO_CANONICAL_URL' => $phpbb_seo->seo_path['canonical'], 'SEO_EXTERNAL' => !empty($config['seo_ext_links']) ? 'true' : 'false', 'SEO_EXTERNAL_SUB' => !empty($config['seo_ext_subdomain']) ? 'true' : 'false', 'SEO_EXT_CLASSES' => !empty($config['seo_ext_classes']) ? "'" . preg_replace('`[^a-z0-9_|-]+`', '', str_replace(',', '|', trim($config['seo_ext_classes'], ', '))) . "'" : 'false', 'SEO_HASHFIX' => $phpbb_seo->seo_opt['url_rewrite'] && $phpbb_seo->seo_opt['virtual_folder'] ? 'true' : 'false')); if (isset($user->lang['Page']) && !empty($config['seo_append_sitename'])) { $page_title = $page_title && strpos($page_title, $config['sitename']) === false ? $page_title . ' - ' . $config['sitename'] : $page_title; } // www.phpBB-SEO.com SEO TOOLKIT END // www.phpBB-SEO.com SEO TOOLKIT BEGIN - META global $seo_meta; $seo_meta->build_meta($page_title); // www.phpBB-SEO.com SEO TOOLKIT END - META // www.phpBB-SEO.com SEO TOOLKIT BEGIN - GYM LINKS if (!empty($config['gym_installed'])) { if (!function_exists('obtain_gym_links')) { require_once $phpbb_root_path . 'gym_sitemaps/includes/gym_common.' . $phpEx; } $gym_setup = obtain_gym_links(); } // www.phpBB-SEO.com SEO TOOLKIT END - GYM LINKS define('HEADER_INC', true); // gzip_compression if ($config['gzip_compress']) { if (@extension_loaded('zlib') && !headers_sent()) { ob_start('ob_gzhandler'); } } // Generate logged in/logged out status if ($user->data['user_id'] != ANONYMOUS) { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=logout', true, $user->session_id); $l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']); } else { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login'); $l_login_logout = $user->lang['LOGIN']; } // Last visit date/time $s_last_visit = $user->data['user_id'] != ANONYMOUS ? $user->format_date($user->data['session_last_visit']) : ''; // Get users online list ... if required $l_online_users = $online_userlist = $l_online_record = ''; if ($config['load_online'] && $config['load_online_time'] && $display_online_list) { /** * Load online data: * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id. */ $item_id = max($item_id, 0); $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; $total_online_users = $online_users['total_online']; if ($total_online_users > $config['record_online_users']) { set_config('record_online_users', $total_online_users, true); set_config('record_online_date', time(), true); } $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'])); $l_online_time = $config['load_online_time'] == 1 ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES'; $l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']); } else { $l_online_time = ''; } $l_privmsgs_text = $l_privmsgs_text_unread = ''; $s_privmsg_new = false; // Obtain number of new private messages if user is logged in if (!empty($user->data['is_registered'])) { if ($user->data['user_new_privmsg']) { $l_message_new = $user->data['user_new_privmsg'] == 1 ? $user->lang['NEW_PM'] : $user->lang['NEW_PMS']; $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']); if (!$user->data['user_last_privmsg'] || $user->data['user_last_privmsg'] > $user->data['session_last_visit']) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_last_privmsg = ' . $user->data['session_last_visit'] . ' WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); $s_privmsg_new = true; } else { $s_privmsg_new = false; } } else { $l_privmsgs_text = $user->lang['NO_NEW_PM']; $s_privmsg_new = false; } $l_privmsgs_text_unread = ''; if ($user->data['user_unread_privmsg'] && $user->data['user_unread_privmsg'] != $user->data['user_new_privmsg']) { $l_message_unread = $user->data['user_unread_privmsg'] == 1 ? $user->lang['UNREAD_PM'] : $user->lang['UNREAD_PMS']; $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']); } } $forum_id = request_var('f', 0); $topic_id = request_var('t', 0); $s_feed_news = false; // Get option for news if ($config['feed_enable']) { $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); $result = $db->sql_query_limit($sql, 1, 0, 600); $s_feed_news = (int) $db->sql_fetchfield('forum_id'); $db->sql_freeresult($result); } // Determine board url - we may need it later $board_url = generate_board_url() . '/'; $web_path = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH ? $board_url : $phpbb_root_path; // Which timezone? $tz = $user->data['user_id'] != ANONYMOUS ? strval(doubleval($user->data['user_timezone'])) : strval(doubleval($config['board_timezone'])); if (isset($config['announcement_enable']) && isset($config['announcement_show_birthdays_always'])) { if (!$config['announcement_show_index'] && ($config['announcement_enable'] || $config['announcement_show_birthdays_always'])) { if (!function_exists('get_announcement_data')) { include $phpbb_root_path . 'includes/functions_announcements.' . $phpEx; } get_announcement_data(); } } // Send a proper content-language to the output $user_lang = $user->lang['USER_LANG']; if (strpos($user_lang, '-x-') !== false) { $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-')); } // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array('U_SEARCH_UNSOLVED_TOPICS' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unsolved_topics'), 'U_SEARCH_YOUR_UNSOLVED_TOPICS' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=your_unsolved_topics'), 'SITENAME' => $config['sitename'], 'SITE_DESCRIPTION' => $config['site_desc'], 'PAGE_TITLE' => $page_title, 'SCRIPT_NAME' => str_replace('.' . $phpEx, '', $user->page['page_name']), 'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit), 'LAST_VISIT_YOU' => $s_last_visit, 'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time(), false, true)), 'TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, 'RECORD_USERS' => $l_online_record, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 'S_USER_NEW' => $user->data['user_new'], 'SID' => $SID, '_SID' => $_SID, 'SESSION_ID' => $user->session_id, 'ROOT_PATH' => $phpbb_root_path, 'BOARD_URL' => $board_url, 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_INDEX' => $user->lang['FORUM_INDEX'], 'L_ONLINE_EXPLAIN' => $l_online_time, 'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&folder=inbox'), 'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&folder=inbox'), 'U_POPUP_PM' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&mode=popup'), 'UA_POPUP_PM' => addslashes(append_sid($phpbb_seo->seo_path['phpbb_url'] . "ucp.{$phpEx}", 'i=pm&mode=popup')), 'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}"), 'U_VIEWONLINE' => $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel') ? append_sid("{$phpbb_root_path}viewonline.{$phpEx}") : '', 'U_LOGIN_LOGOUT' => $u_login_logout, 'U_INDEX' => append_sid("{$phpbb_root_path}index.{$phpEx}"), 'U_SEARCH' => append_sid("{$phpbb_root_path}search.{$phpEx}"), 'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register'), 'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}"), 'U_MODCP' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", false, true, $user->session_id), 'U_FAQ' => append_sid("{$phpbb_root_path}faq.{$phpEx}"), 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unanswered'), 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=delete_cookies'), 'U_TEAM' => $user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile') ? '' : append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=leaders'), 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=privacy'), 'U_RESTORE_PERMISSIONS' => $user->data['user_perm_from'] && $auth->acl_get('a_switchperm') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm') : '', 'U_FEED' => generate_board_url() . "/feed.{$phpEx}", 'S_USER_LOGGED_IN' => $user->data['user_id'] != ANONYMOUS ? true : false, 'S_AUTOLOGIN_ENABLED' => $config['allow_autologin'] ? true : false, 'S_BOARD_DISABLED' => $config['board_disable'] ? true : false, 'S_REGISTERED_USER' => !empty($user->data['is_registered']) ? true : false, 'S_IS_BOT' => !empty($user->data['is_bot']) ? true : false, 'S_USER_PM_POPUP' => $user->optionget('popuppm'), 'S_USER_LANG' => $user_lang, 'S_USER_BROWSER' => isset($user->data['session_browser']) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'], 'S_USERNAME' => $user->data['username'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left', 'S_CONTENT_ENCODING' => 'UTF-8', 'S_TIMEZONE' => $user->data['user_dst'] || $user->data['user_id'] == ANONYMOUS && $config['board_dst'] ? sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], ''), 'S_DISPLAY_ONLINE_LIST' => $l_online_time ? 1 : 0, 'S_DISPLAY_SEARCH' => !$config['load_search'] ? 0 : (isset($auth) ? $auth->acl_get('u_search') && $auth->acl_getf_global('f_search') : 1), 'S_DISPLAY_PM' => $config['allow_privmsg'] && !empty($user->data['is_registered']) && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm')) ? true : false, 'S_DISPLAY_MEMBERLIST' => isset($auth) ? $auth->acl_get('u_viewprofile') : 0, 'S_NEW_PM' => $s_privmsg_new ? 1 : 0, 'S_REGISTER_ENABLED' => $config['require_activation'] != USER_ACTIVATION_DISABLE ? true : false, 'S_FORUM_ID' => $forum_id, 'S_TOPIC_ID' => $topic_id, 'S_LOGIN_ACTION' => !defined('ADMIN_START') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login') . '&redirect=' . urlencode(str_replace('&', '&', build_url())) : append_sid("index.{$phpEx}", false, true, $user->session_id) . '&redirect=' . urlencode(str_replace('&', '&', build_url())), 'S_ENABLE_FEEDS' => $config['feed_enable'] ? true : false, 'S_ENABLE_FEEDS_FORUMS' => $config['feed_overall_forums'] ? true : false, 'S_ENABLE_FEEDS_TOPICS' => $config['feed_overall_topics'] ? true : false, 'S_ENABLE_FEEDS_NEWS' => $s_feed_news ? true : false, 'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$web_path}styles/" . $user->theme['template_path'] . '/template', 'T_SUPER_TEMPLATE_PATH' => isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path'] ? "{$web_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$web_path}styles/" . $user->theme['template_path'] . '/template', 'T_IMAGESET_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset', 'T_IMAGESET_LANG_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->data['user_lang'], 'T_IMAGES_PATH' => "{$web_path}images/", 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", 'T_AVATAR_GALLERY_PATH' => "{$web_path}{$config['avatar_gallery_path']}/", 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", 'T_STYLESHEET_LINK' => !$user->theme['theme_storedb'] ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.{$phpEx}", 'id=' . $user->theme['style_id'] . '&lang=' . $user->data['user_lang']), 'T_STYLESHEET_NAME' => $user->theme['theme_name'], 'T_THEME_NAME' => $user->theme['theme_path'], 'T_TEMPLATE_NAME' => $user->theme['template_path'], 'T_SUPER_TEMPLATE_NAME' => isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path'] ? $user->theme['template_inherit_path'] : $user->theme['template_path'], 'T_IMAGESET_NAME' => $user->theme['imageset_path'], 'T_IMAGESET_LANG_NAME' => $user->data['user_lang'], 'T_IMAGES' => 'images', 'T_SMILIES' => $config['smilies_path'], 'T_AVATAR' => $config['avatar_path'], 'T_AVATAR_GALLERY' => $config['avatar_gallery_path'], 'T_ICONS' => $config['icons_path'], 'T_RANKS' => $config['ranks_path'], 'T_UPLOAD' => $config['upload_path'], 'SITE_LOGO_IMG' => $user->img('site_logo'), 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . (!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1' ? '' : '; domain=' . $config['cookie_domain']) . (!$config['cookie_secure'] ? '' : '; secure')))); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); header('Cache-Control: private, no-cache="set-cookie"'); header('Expires: 0'); header('Pragma: no-cache'); return; }
/** * Generate page header */ function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $user, $auth, $phpEx, $phpbb_root_path; if (defined('HEADER_INC')) { return; } define('HEADER_INC', true); // gzip_compression if ($config['gzip_compress']) { if (@extension_loaded('zlib') && !headers_sent()) { ob_start('ob_gzhandler'); } } // Generate logged in/logged out status if ($user->data['user_id'] != ANONYMOUS) { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=logout', true, $user->session_id); $l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']); } else { $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login'); $l_login_logout = $user->lang['LOGIN']; } // Last visit date/time $s_last_visit = $user->data['user_id'] != ANONYMOUS ? $user->format_date($user->data['session_last_visit']) : ''; // Get users online list ... if required $l_online_users = $online_userlist = $l_online_record = $l_online_time = ''; if ($config['load_online'] && $config['load_online_time'] && $display_online_list) { /** * Load online data: * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id. */ $item_id = max($item_id, 0); $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; $total_online_users = $online_users['total_online']; if ($total_online_users > $config['record_online_users']) { set_config('record_online_users', $total_online_users, true); set_config('record_online_date', time(), true); } $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'], false, true)); $l_online_time = $config['load_online_time'] == 1 ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES'; $l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']); } $l_privmsgs_text = $l_privmsgs_text_unread = ''; $s_privmsg_new = false; // Obtain number of new private messages if user is logged in if (!empty($user->data['is_registered'])) { if ($user->data['user_new_privmsg']) { $l_message_new = $user->data['user_new_privmsg'] == 1 ? $user->lang['NEW_PM'] : $user->lang['NEW_PMS']; $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']); if (!$user->data['user_last_privmsg'] || $user->data['user_last_privmsg'] > $user->data['session_last_visit']) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_last_privmsg = ' . $user->data['session_last_visit'] . ' WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); $s_privmsg_new = true; } else { $s_privmsg_new = false; } } else { $l_privmsgs_text = $user->lang['NO_NEW_PM']; $s_privmsg_new = false; } $l_privmsgs_text_unread = ''; if ($user->data['user_unread_privmsg'] && $user->data['user_unread_privmsg'] != $user->data['user_new_privmsg']) { $l_message_unread = $user->data['user_unread_privmsg'] == 1 ? $user->lang['UNREAD_PM'] : $user->lang['UNREAD_PMS']; $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']); } } $forum_id = request_var('f', 0); $topic_id = request_var('t', 0); $s_feed_news = false; // Get option for news if ($config['feed_enable']) { $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); $result = $db->sql_query_limit($sql, 1, 0, 600); $s_feed_news = (int) $db->sql_fetchfield('forum_id'); $db->sql_freeresult($result); } // Determine board url - we may need it later $board_url = generate_board_url() . '/'; $web_path = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH ? $board_url : $phpbb_root_path; // Which timezone? $tz = $user->data['user_id'] != ANONYMOUS ? strval(doubleval($user->data['user_timezone'])) : strval(doubleval($config['board_timezone'])); // Send a proper content-language to the output $user_lang = $user->lang['USER_LANG']; if (strpos($user_lang, '-x-') !== false) { $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-')); } // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array('SITENAME' => $config['sitename'], 'SITE_DESCRIPTION' => $config['site_desc'], 'PAGE_TITLE' => $page_title, 'SCRIPT_NAME' => str_replace('.' . $phpEx, '', $user->page['page_name']), 'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit), 'LAST_VISIT_YOU' => $s_last_visit, 'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time(), false, true)), 'TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, 'RECORD_USERS' => $l_online_record, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 'S_USER_NEW' => $user->data['user_new'], 'SID' => $SID, '_SID' => $_SID, 'SESSION_ID' => $user->session_id, 'ROOT_PATH' => $phpbb_root_path, 'BOARD_URL' => $board_url, 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_INDEX' => $user->lang['FORUM_INDEX'], 'L_ONLINE_EXPLAIN' => $l_online_time, 'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&folder=inbox'), 'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&folder=inbox'), 'U_POPUP_PM' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&mode=popup'), 'UA_POPUP_PM' => addslashes(append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&mode=popup')), 'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}"), 'U_VIEWONLINE' => $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel') ? append_sid("{$phpbb_root_path}viewonline.{$phpEx}") : '', 'U_LOGIN_LOGOUT' => $u_login_logout, 'U_INDEX' => append_sid("{$phpbb_root_path}index.{$phpEx}"), 'U_SEARCH' => append_sid("{$phpbb_root_path}search.{$phpEx}"), 'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register'), 'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}"), 'U_MODCP' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", false, true, $user->session_id), 'U_FAQ' => append_sid("{$phpbb_root_path}faq.{$phpEx}"), 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unanswered'), 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=delete_cookies'), 'U_TEAM' => $user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile') ? '' : append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=leaders'), 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=privacy'), 'U_RESTORE_PERMISSIONS' => $user->data['user_perm_from'] && $auth->acl_get('a_switchperm') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm') : '', 'U_FEED' => generate_board_url() . "/feed.{$phpEx}", 'S_USER_LOGGED_IN' => $user->data['user_id'] != ANONYMOUS ? true : false, 'S_AUTOLOGIN_ENABLED' => $config['allow_autologin'] ? true : false, 'S_BOARD_DISABLED' => $config['board_disable'] ? true : false, 'S_REGISTERED_USER' => !empty($user->data['is_registered']) ? true : false, 'S_IS_BOT' => !empty($user->data['is_bot']) ? true : false, 'S_USER_PM_POPUP' => $user->optionget('popuppm'), 'S_USER_LANG' => $user_lang, 'S_USER_BROWSER' => isset($user->data['session_browser']) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'], 'S_USERNAME' => $user->data['username'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left', 'S_CONTENT_ENCODING' => 'UTF-8', 'S_TIMEZONE' => $user->data['user_dst'] || $user->data['user_id'] == ANONYMOUS && $config['board_dst'] ? sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], ''), 'S_DISPLAY_ONLINE_LIST' => $l_online_time ? 1 : 0, 'S_DISPLAY_SEARCH' => !$config['load_search'] ? 0 : (isset($auth) ? $auth->acl_get('u_search') && $auth->acl_getf_global('f_search') : 1), 'S_DISPLAY_PM' => $config['allow_privmsg'] && !empty($user->data['is_registered']) && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm')) ? true : false, 'S_DISPLAY_MEMBERLIST' => isset($auth) ? $auth->acl_get('u_viewprofile') : 0, 'S_NEW_PM' => $s_privmsg_new ? 1 : 0, 'S_REGISTER_ENABLED' => $config['require_activation'] != USER_ACTIVATION_DISABLE ? true : false, 'S_FORUM_ID' => $forum_id, 'S_TOPIC_ID' => $topic_id, 'S_LOGIN_ACTION' => !defined('ADMIN_START') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login') : append_sid("index.{$phpEx}", false, true, $user->session_id), 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => str_replace('&', '&', build_url()))), 'S_ENABLE_FEEDS' => $config['feed_enable'] ? true : false, 'S_ENABLE_FEEDS_OVERALL' => $config['feed_overall'] ? true : false, 'S_ENABLE_FEEDS_FORUMS' => $config['feed_overall_forums'] ? true : false, 'S_ENABLE_FEEDS_TOPICS' => $config['feed_topics_new'] ? true : false, 'S_ENABLE_FEEDS_TOPICS_ACTIVE' => $config['feed_topics_active'] ? true : false, 'S_ENABLE_FEEDS_NEWS' => $s_feed_news ? true : false, 'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$web_path}styles/" . $user->theme['template_path'] . '/template', 'T_SUPER_TEMPLATE_PATH' => isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path'] ? "{$web_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$web_path}styles/" . $user->theme['template_path'] . '/template', 'T_IMAGESET_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset', 'T_IMAGESET_LANG_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->data['user_lang'], 'T_IMAGES_PATH' => "{$web_path}images/", 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", 'T_AVATAR_GALLERY_PATH' => "{$web_path}{$config['avatar_gallery_path']}/", 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", 'T_STYLESHEET_LINK' => !$user->theme['theme_storedb'] ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.{$phpEx}", 'id=' . $user->theme['style_id'] . '&lang=' . $user->data['user_lang'], true, $user->session_id), 'T_STYLESHEET_NAME' => $user->theme['theme_name'], 'T_THEME_NAME' => $user->theme['theme_path'], 'T_TEMPLATE_NAME' => $user->theme['template_path'], 'T_SUPER_TEMPLATE_NAME' => isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path'] ? $user->theme['template_inherit_path'] : $user->theme['template_path'], 'T_IMAGESET_NAME' => $user->theme['imageset_path'], 'T_IMAGESET_LANG_NAME' => $user->data['user_lang'], 'T_IMAGES' => 'images', 'T_SMILIES' => $config['smilies_path'], 'T_AVATAR' => $config['avatar_path'], 'T_AVATAR_GALLERY' => $config['avatar_gallery_path'], 'T_ICONS' => $config['icons_path'], 'T_RANKS' => $config['ranks_path'], 'T_UPLOAD' => $config['upload_path'], 'SITE_LOGO_IMG' => $user->img('site_logo'), 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . (!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1' ? '' : '; domain=' . $config['cookie_domain']) . (!$config['cookie_secure'] ? '' : '; secure')))); // START needed for PBWoW if ($user->data['user_id'] != ANONYMOUS) { $user->get_profile_fields($user->data['user_id']); $user_fieldx = $user->profile_fields; get_user_rank_4others($user->data['user_rank'], $user->data['user_posts'], $rankx_title, $rankx_img, $rankx_img_src); $template->assign_vars(array('S_STYLE_OPTIONS' => $config['override_user_style'] ? '' : style_select($data['style']), 'PBUSER_AVATAR_SRC' => get_user_avatar_src($user->data['user_avatar'], $user->data['user_avatar_type']), 'PBPROFILE_LEVEL' => isset($user_fieldx['pf_pblevel']) ? $user_fieldx['pf_pblevel'] : '', 'PBPROFILE_RACE' => isset($user_fieldx['pf_pbrace']) ? $user_fieldx['pf_pbrace'] - 1 : '', 'PBPROFILE_GENDER' => isset($user_fieldx['pf_pbgender']) ? $user_fieldx['pf_pbgender'] - 1 : '', 'PBPROFILE_CLASS' => isset($user_fieldx['pf_pbclass']) ? $user_fieldx['pf_pbclass'] - 1 : '', 'PBRANK_TITLE' => isset($rankx_title) ? $rankx_title : '', 'PBRANK_IMG' => isset($rankx_img) ? $rankx_img : '', 'PBRANK_IMG_SRC' => isset($rankx_img_src) ? $rankx_img_src : '')); } $pbwow_config = obtain_pbwow_config(); $template->assign_vars(array('CURRENT_TIME_CLEAN' => sprintf($user->format_date(time(), false, true)), 'PBFORUM_IMAGE_SRC' => get_forum_image_src_4header(request_var('f', 0)), 'PB_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login') . '&redirect=' . urlencode(str_replace('&', '&', build_url())), 'PBWOW_TOPNAV_CODE' => html_entity_decode($pbwow_config['pbwow_topnav_code']), 'S_PBWOW_IE6MESSAGE' => $pbwow_config['pbwow_ie6message_enable'] == 1 ? true : false, 'PBWOW_IE6MESSAGE_CODE' => html_entity_decode($pbwow_config['pbwow_ie6message_code']), 'S_PBWOW_ADS_INDEX' => $pbwow_config['pbwow_ads_index_enable'] == 1 ? true : false, 'PBWOW_ADS_INDEX_CODE' => html_entity_decode($pbwow_config['pbwow_ads_index_code']), 'S_PBWOW_ADS_TOP' => $pbwow_config['pbwow_ads_top_enable'] == 1 ? true : false, 'PBWOW_ADS_TOP_CODE' => html_entity_decode($pbwow_config['pbwow_ads_top_code']), 'S_PBWOW_ADS_SIDE' => $pbwow_config['pbwow_ads_side_enable'] == 1 ? true : false, 'PBWOW_ADS_SIDE_CODE' => html_entity_decode($pbwow_config['pbwow_ads_side_code']), 'S_PBWOW_BLIZZ_RANKS' => $pbwow_config['pbwow_blizz_enable'] == 1 ? true : false, 'S_PBWOW_PROPASS_RANKS' => $pbwow_config['pbwow_propass_enable'] == 1 ? true : false)); //-- mod: Prime Quick Style -------------------------------------------------// include $phpbb_root_path . 'includes/prime_quick_style.' . $phpEx; $prime_quick_style->select_style(); //-- end: Prime Quick Style -------------------------------------------------// // END needed for PBWoW // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); header('Cache-Control: private, no-cache="set-cookie"'); header('Expires: 0'); header('Pragma: no-cache'); return; }
/** * Returns the logged in user list without displaying it * @author John Wells * @since v0.8.0 * @example wpu_useronlinelist('before=<li>&after=</li>&showBreakdown=1&showRecord=1&showLegend=1'); */ function get_wpu_useronlinelist($args = '') { global $phpbbForum, $template, $auth, $db, $config, $user, $phpEx, $phpbb_root_path; $defaults = array('before' => '<li>', 'after' => '</li>', 'showCurrent' => 1, 'showRecord' => 1, 'showLegend' => 1); extract(_wpu_process_args($args, $defaults)); $fStateChanged = $phpbbForum->foreground(); if (!empty($template) && !empty($legend) && ($theList = $template->_rootref['LOGGED_IN_USER_LIST'])) { // On the phpBB index page -- everything's already in template $legend = $template->_rootref['LEGEND']; $l_online_users = $template->_rootref['TOTAL_USERS_ONLINE']; $l_online_time = $template->_rootref['L_ONLINE_EXPLAIN']; $l_online_record = $template->_rootref['RECORD_USERS']; } else { // On other pages, get the list $online_users = obtain_users_online(); $list = obtain_users_online_string($online_users); // Grab group details for legend display if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) { $sql = 'SELECT group_id, group_name, group_colour, group_type FROM ' . GROUPS_TABLE . ' WHERE group_legend = 1 ORDER BY group_name ASC'; } else { $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type FROM ' . GROUPS_TABLE . ' g LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON ( g.group_id = ug.group_id AND ug.user_id = ' . (int) $phpbbForum->get_userdata('user_id') . ' AND ug.user_pending = 0 ) WHERE g.group_legend = 1 AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . (int) $phpbbForum->get_userdata('user_id') . ') ORDER BY g.group_name ASC'; } $result = $db->sql_query($sql); $legend = array(); while ($row = $db->sql_fetchrow($result)) { $colour_text = $row['group_colour'] ? ' style="color:#' . $row['group_colour'] . '"' : ''; $group_name = $row['group_type'] == GROUP_SPECIAL ? $phpbbForum->lang['G_' . $row['group_name']] : $row['group_name']; if ($row['group_name'] == 'BOTS' || $phpbbForum->get_userdata('user_id') != ANONYMOUS && !$auth->acl_get('u_viewprofile')) { $legend[] = '<span' . $colour_text . '>' . $group_name . '</span>'; } else { $legend[] = '<a' . $colour_text . ' href="' . $phpbbForum->append_sid("{$phpbbForum->get_board_url()}memberlist.{$phpEx}", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>'; } } $db->sql_freeresult($result); $legend = implode(', ', $legend); $l_online_time = $config['load_online_time'] == 1 ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES'; $l_online_time = sprintf($phpbbForum->lang[$l_online_time], $config['load_online_time']); $l_online_record = sprintf($phpbbForum->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'])); $l_online_users = $list['l_online_users']; $theList = str_replace($phpbb_root_path, $phpbbForum->get_board_url(), $list['online_userlist']); } $phpbbForum->restore_state($fStateChanged); $ret = "{$before}{$theList}{$after}"; if ($showBreakdown) { $ret .= "{$before}{$l_online_users} ({$l_online_time}){$after}"; } if ($showRecord) { $ret .= "{$before}{$l_online_record}{$after}"; } if ($showLegend) { $ret .= "{$before}<em>{$phpbbForum->lang['LEGEND']}: {$legend}</em>{$after}"; } return $ret; }