Exemplo n.º 1
0
function show_coppa()
{
    global $config, $user, $template, $lang;
    // Load the appropriate Rules file
    $lang_file = 'lang_rules';
    $l_title = $lang['BoardRules'];
    // Include the rules settings
    setup_extra_lang(array($lang_file));
    //
    // Pull the array data from the lang pack
    //
    $j = 0;
    $counter = 0;
    $counter_2 = 0;
    $rules_block = array();
    $rules_block_titles = array();
    for ($i = 0; $i < sizeof($rules); $i++) {
        if ($rules[$i][0] != '--') {
            $rules_block[$j][$counter]['id'] = $counter_2;
            $rules_block[$j][$counter]['question'] = $rules[$i][0];
            $rules_block[$j][$counter]['answer'] = $rules[$i][1];
            $counter++;
            $counter_2++;
        } else {
            $j = $counter != 0 ? $j + 1 : 0;
            $rules_block_titles[$j] = $rules[$i][1];
            $counter = 0;
        }
    }
    $template->set_filenames(array('body' => 'agreement.tpl'));
    if (!function_exists('language_select')) {
        @(include_once IP_ROOT_PATH . 'includes/functions_selects.' . PHP_EXT);
    }
    $available_networks = array();
    $social_connect_append = '';
    $social_network = request_get_var('social_network', '');
    if ($config['enable_social_connect']) {
        include_once IP_ROOT_PATH . 'includes/class_social_connect.' . PHP_EXT;
        $available_networks = SocialConnect::get_available_networks();
        $login_admin = request_get_var('admin', 0);
        $redirect_url = CMS_LOGIN_REDIRECT_PAGE;
        $template->assign_var('SOCIAL_CONNECT', true);
        foreach ($available_networks as $social_network_item) {
            $template->assign_block_vars('social_connect_button', array('L_SOCIAL_CONNECT' => sprintf($lang['SOCIAL_CONNECT_LOGIN'], $social_network_item->get_name()), 'U_SOCIAL_CONNECT' => append_sid(CMS_PAGE_LOGIN . '?social_network=' . $social_network_item->get_name_clean() . '&redirect=' . urlencode($redirect_url) . '&admin=' . $login_admin), 'IMG_SOCIAL_CONNECT' => '<img src="' . IP_ROOT_PATH . 'images/social_connect/' . $social_network_item->get_name_clean() . '_button_connect.png" alt="" title="" />'));
        }
        if (!empty($social_network)) {
            if (!empty($available_networks[$social_network])) {
                $social_connect_append = '&amp;social_network=' . $social_network;
            }
        }
    }
    $template->assign_vars(array('L_PAGE_TITLE' => $lang['Registration'], 'REGISTRATION' => $lang['Registration'], 'AGREEMENT' => $lang['Reg_agreement'], 'L_AGREEMENT' => $lang['Agreement'], 'L_PRIVACY_DISCLAIMER' => $lang['PrivacyDisclaimer'], 'AGREE_OVER_13' => $lang['Agree_over_13'], 'AGREE_UNDER_13' => $lang['Agree_under_13'], 'DO_NOT_AGREE' => $lang['Agree_not'], 'AGREE_CHECKBOX' => $lang['Agree_checkbox'], 'S_LANG_CHANGE_ACTION' => append_sid(CMS_PAGE_PROFILE . '?mode=register' . $social_connect_append), 'LANGUAGE_SELECT' => language_select('l', $config['default_lang']), 'L_RULES_TITLE' => $l_title, 'L_BACK_TO_TOP' => $lang['Back_to_top'], 'S_AGREE_ACTION' => append_sid(CMS_PAGE_PROFILE . '?mode=register&amp;agreed=true' . $social_connect_append), 'U_AGREE_OVER13' => append_sid(CMS_PAGE_PROFILE . '?mode=register&amp;agreed=true' . $social_connect_append), 'U_AGREE_UNDER13' => append_sid(CMS_PAGE_PROFILE . '?mode=register&amp;agreed=true&amp;coppa=true' . $social_connect_append)));
    for ($i = 0; $i < sizeof($rules_block); $i++) {
        if (sizeof($rules_block[$i])) {
            $template->assign_block_vars('rules_block', array('BLOCK_TITLE' => $rules_block_titles[$i]));
            $template->assign_block_vars('rules_block_link', array('BLOCK_TITLE' => $rules_block_titles[$i]));
            for ($j = 0; $j < sizeof($rules_block[$i]); $j++) {
                $row_class = !($j % 2) ? $theme['td_class1'] : $theme['td_class2'];
                $template->assign_block_vars('rules_block.rules_row', array('ROW_CLASS' => $row_class, 'RULES_QUESTION' => $rules_block[$i][$j]['question'], 'RULES_ANSWER' => $rules_block[$i][$j]['answer'], 'U_RULES_ID' => $rules_block[$i][$j]['id']));
                $template->assign_block_vars('rules_block_link.rules_row_link', array('ROW_CLASS' => $row_class, 'RULES_LINK' => $rules_block[$i][$j]['question'], 'U_RULES_LINK' => '#' . $rules_block[$i][$j]['id']));
            }
        }
    }
    $template->pparse('body');
}
Exemplo n.º 2
0
		$username = isset($_POST['username']) ? phpbb_clean_username($_POST['username']) : '';
		$password = isset($_POST['password']) ? $_POST['password'] : '';

		$login_result = login_db($username, $password, false, true);

		if ($login_result['status'] === LOGIN_ERROR_ATTEMPTS)
		{
			message_die(GENERAL_MESSAGE, sprintf($lang['LOGIN_ATTEMPTS_EXCEEDED'], $config['max_login_attempts'], $config['login_reset_time']));
		}

		if ($login_result['status'] === LOGIN_SUCCESS)
		{
			// Is user linking a social network account?
			if ($config['enable_social_connect'])
			{
				$available_networks = SocialConnect::get_available_networks();

				$social_network_link = request_var('social_network_link', '');
				if (!empty($social_network_link) && !empty($available_networks[$social_network_link]))
				{
					$social_network = $available_networks[$social_network_link];
					$field_name = "user_" . $social_network->get_name_clean() . "_id";
					$user_data_social = $social_network->get_user_data();

					$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $field_name . " = '" . $user_data_social[$field_name] . "' WHERE user_id = " . $login_result['user_row']['user_id'];
					$db->sql_query($sql);
				}
			}

			if(($login_result['user_row']['user_level'] != ADMIN) && !empty($config['board_disable']))
			{
Exemplo n.º 3
0
/**
* Page Header
*/
function page_header($title = '', $parse_template = false)
{
    global $db, $cache, $config, $user, $template, $images, $theme, $lang, $tree;
    global $table_prefix, $SID, $_SID;
    global $ip_cms, $cms_config_vars, $cms_config_global_blocks, $cms_config_layouts, $cms_page;
    global $starttime, $base_memory_usage, $do_gzip_compress, $start;
    global $gen_simple_header, $meta_content, $nav_separator, $nav_links, $nav_pgm, $nav_add_page_title, $skip_nav_cat;
    global $breadcrumbs;
    global $forum_id, $topic_id;
    if (defined('HEADER_INC')) {
        return;
    }
    define('HEADER_INC', true);
    // gzip_compression
    $config['gzip_compress_runtime'] = isset($config['gzip_compress_runtime']) ? $config['gzip_compress_runtime'] : $config['gzip_compress'];
    $config['url_rw_runtime'] = $config['url_rw'] || $config['url_rw_guests'] && $user->data['user_id'] == ANONYMOUS ? true : false;
    if ($config['gzip_compress_runtime']) {
        if (@extension_loaded('zlib') && !headers_sent()) {
            ob_start('ob_gzhandler');
        }
    } else {
        // We need to enable this otherwise URL Rewrite will not work without output buffering
        if ($config['url_rw_runtime'] && !headers_sent()) {
            ob_start();
        }
    }
    // CMS
    if (!defined('CMS_INIT')) {
        define('CMS_INIT', true);
        $cms_config_vars = $cache->obtain_cms_config();
        $cms_config_global_blocks = $cache->obtain_cms_global_blocks_config(false);
    }
    //$server_url = create_server_url();
    $page_url = pathinfo($_SERVER['SCRIPT_NAME']);
    $page_query = $_SERVER['QUERY_STRING'];
    $meta_content['page_title'] = !empty($title) ? $title : $meta_content['page_title'];
    $meta_content['page_title'] = empty($meta_content['page_title']) ? $config['sitename'] : strip_tags($meta_content['page_title']);
    $meta_content['page_title_clean'] = empty($meta_content['page_title_clean']) ? strip_tags($meta_content['page_title']) : $meta_content['page_title_clean'];
    // DYNAMIC META TAGS - BEGIN
    // Reset some defaults... to be sure some values are taken from DB properly
    $lang['Default_META_Keywords'] = !empty($config['site_meta_keywords_switch']) && !empty($config['site_meta_keywords']) ? $config['site_meta_keywords'] : (!empty($lang['Default_META_Keywords']) ? $lang['Default_META_Keywords'] : strtolower(htmlspecialchars(strip_tags($config['sitename']))));
    $lang['Default_META_Description'] = !empty($config['site_meta_description_switch']) && !empty($config['site_meta_description']) ? $config['site_meta_description'] : (!empty($lang['Default_META_Description']) ? $lang['Default_META_Description'] : htmlspecialchars(strip_tags($config['site_desc'])));
    $lang['Default_META_Author'] = !empty($config['site_meta_author_switch']) && !empty($config['site_meta_author']) ? $config['site_meta_author'] : (!empty($lang['Default_META_Author']) ? $lang['Default_META_Author'] : htmlspecialchars(strip_tags($config['sitename'])));
    $lang['Default_META_Copyright'] = !empty($config['site_meta_copyright_switch']) && !empty($config['site_meta_copyright']) ? $config['site_meta_copyright'] : (!empty($lang['Default_META_Copyright']) ? $lang['Default_META_Copyright'] : htmlspecialchars(strip_tags($config['sitename'])));
    $meta_content_pages_array = array(CMS_PAGE_VIEWFORUM, CMS_PAGE_VIEWFORUMLIST, CMS_PAGE_VIEWTOPIC);
    if (!in_array($page_url['basename'], $meta_content_pages_array)) {
        $meta_content['cat_id'] = request_var(POST_CAT_URL, 0);
        $meta_content['forum_id'] = request_var(POST_FORUM_URL, 0);
        $meta_content['topic_id'] = request_var(POST_TOPIC_URL, 0);
        $meta_content['post_id'] = request_var(POST_POST_URL, 0);
        $no_meta_pages_array = array(CMS_PAGE_LOGIN, CMS_PAGE_PRIVMSG, CMS_PAGE_POSTING, 'kb.' . PHP_EXT);
        if (!in_array($page_url['basename'], $no_meta_pages_array) && (!empty($meta_content['post_id']) || !empty($meta_content['topic_id']) || !empty($meta_content['forum_id']) || !empty($meta_content['cat_id']))) {
            @(include_once IP_ROOT_PATH . 'includes/functions_meta.' . PHP_EXT);
            create_meta_content();
        } else {
            $meta_content['page_title'] = defined('IN_LOGIN') ? $lang['Login'] : $meta_content['page_title'];
            $meta_content['description'] = defined('IN_LOGIN') ? $lang['Default_META_Description'] : $meta_content['description'];
            $meta_content['keywords'] = defined('IN_LOGIN') ? $lang['Default_META_Keywords'] : $meta_content['keywords'];
        }
    }
    $meta_content['description'] = !empty($meta_content['description']) ? $meta_content['description'] . (META_TAGS_ATTACH ? ' - ' . $lang['Default_META_Description'] : '') : $lang['Default_META_Description'];
    $meta_content['keywords'] = !empty($meta_content['keywords']) ? $meta_content['keywords'] . (META_TAGS_ATTACH ? ' - ' . $lang['Default_META_Keywords'] : '') : $lang['Default_META_Keywords'];
    $meta_content['description'] = strip_tags($meta_content['description']);
    $meta_content['keywords'] = strip_tags($meta_content['keywords']);
    $meta_content['keywords'] = substr($meta_content['keywords'], -2) == ', ' ? substr($meta_content['keywords'], 0, -2) : $meta_content['keywords'];
    $phpbb_meta = '';
    $phpbb_meta .= '<meta name="author" content="' . $lang['Default_META_Author'] . '" />' . "\n";
    $phpbb_meta .= '<meta name="description" content="' . str_replace('"', '', $meta_content['description']) . '" />' . "\n";
    $phpbb_meta .= '<meta name="keywords" content="' . str_replace('"', '', $meta_content['keywords']) . '" />' . "\n";
    // These META are not valid and needed anymore by SEO and HTML 5
    /*
    $phpbb_meta .= '<meta name="title" content="' . $meta_content['page_title'] . '" />' . "\n";
    $phpbb_meta .= '<meta name="copyright" content="' . $lang['Default_META_Copyright'] . '" />' . "\n";
    $phpbb_meta .= '<meta name="category" content="general" />' . "\n";
    $phpbb_meta .= '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9" />' . "\n";
    */
    if (defined('IN_ADMIN') || defined('IN_CMS') || defined('IN_SEARCH') || defined('IN_POSTING')) {
        $phpbb_meta_content = 'noindex,nofollow';
    } else {
        if (defined('ROBOTS_NOINDEX')) {
            $phpbb_meta_content = 'noindex';
        } else {
            $phpbb_meta_content = 'index,follow';
        }
    }
    $phpbb_meta .= '<meta name="robots" content="' . $phpbb_meta_content . '" />' . "\n";
    $phpbb_meta .= !empty($lang['Extra_Meta']) ? $lang['Extra_Meta'] . "\n\n" : "\n";
    $canonical_pages_array = array(CMS_PAGE_FORUM, CMS_PAGE_VIEWFORUM, CMS_PAGE_VIEWTOPIC);
    if (in_array($page_url['basename'], $canonical_pages_array)) {
        $canonical_append = '';
        if ($page_url['basename'] == CMS_PAGE_FORUM) {
            $canonical_append .= !empty($meta_content['cat_id']) ? (empty($canonical_append) ? '' : '&amp;') . POST_CAT_URL . '=' . $meta_content['cat_id'] : '';
        }
        $canonical_append .= !empty($meta_content['forum_id']) ? (empty($canonical_append) ? '' : '&amp;') . POST_FORUM_URL . '=' . $meta_content['forum_id'] : '';
        $canonical_append .= !empty($meta_content['topic_id']) ? (empty($canonical_append) ? '' : '&amp;') . POST_TOPIC_URL . '=' . $meta_content['topic_id'] : '';
        $canonical_append .= !empty($meta_content['post_id']) ? (empty($canonical_append) ? '' : '&amp;') . POST_POST_URL . '=' . $meta_content['post_id'] : '';
        $canonical_append .= !empty($start) ? (empty($canonical_append) ? '' : '&amp;') . 'start=' . $start : '';
        $canonical_url = $page_url['basename'] . (empty($canonical_append) ? '' : '?') . $canonical_append;
        $phpbb_meta .= !empty($canonical_url) ? '<link rel="canonical" href="' . $canonical_url . '" />' . "\n" : '';
    }
    // DYNAMIC META TAGS - END
    // Mighty Gorgon - Smart Header - Begin
    $encoding_charset = !empty($lang['ENCODING']) ? $lang['ENCODING'] : 'UTF-8';
    $lang_dir = !empty($lang['DIRECTION']) ? $lang['DIRECTION'] : 'ltr';
    $header_lang = !empty($lang['HEADER_LANG']) ? $lang['HEADER_LANG'] : 'en-gb';
    $xml_header_lang = !empty($lang['HEADER_LANG_XML']) ? $lang['HEADER_LANG_XML'] : 'en-gb';
    $doctype_html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
    //$doctype_html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
    $doctype_html .= '<html xmlns="http://www.w3.org/1999/xhtml" dir="' . $lang_dir . '" lang="' . $header_lang . '" xml:lang="' . $xml_header_lang . '">' . "\n";
    if ($page_url['basename'] == CMS_PAGE_VIEWONLINE) {
        $phpbb_meta .= '<meta http-equiv="refresh" content="180;url=viewonline.' . PHP_EXT . '" />' . "\n";
    }
    // Mighty Gorgon - Smart Header - End
    // Mighty Gorgon - AJAX Features - Begin
    $ajax_user_check = '';
    $ajax_user_check_alt = '';
    if (!empty($config['ajax_features'])) {
        $ajax_user_check = 'onkeyup="AJAXUsernameSearch(this.value, 0);"';
        $ajax_user_check_alt = 'onkeyup="AJAXUsernameSearch(this.value, 1);"';
    }
    // Mighty Gorgon - AJAX Features - End
    // Generate HTML required for Mozilla Navigation bar
    $nav_base_url = create_server_url();
    // Mozilla navigation bar - Default items that should be valid on all pages.
    // Defined here to correctly assign the Language Variables and be able to change the variables within code.
    $nav_links['top'] = array('url' => append_sid(CMS_PAGE_HOME), 'title' => $config['sitename']);
    $nav_links['forum'] = array('url' => append_sid(CMS_PAGE_FORUM), 'title' => sprintf($lang['Forum_Index'], $config['sitename']));
    $nav_links['search'] = array('url' => append_sid(CMS_PAGE_SEARCH), 'title' => $lang['Search']);
    $nav_links['help'] = array('url' => append_sid(CMS_PAGE_FAQ), 'title' => $lang['FAQ']);
    $nav_links['author'] = array('url' => append_sid(CMS_PAGE_MEMBERLIST), 'title' => $lang['Memberlist']);
    $nav_links_html = '';
    while (list($nav_item, $nav_array) = @each($nav_links)) {
        if (!empty($nav_array['url'])) {
            $nav_links_html .= '<link rel="' . $nav_item . '" type="text/html" title="' . strip_tags($nav_array['title']) . '" href="' . $nav_base_url . $nav_array['url'] . '" />' . "\n";
        } else {
            // We have a nested array, used for items like <link rel='chapter'> that can occur more than once.
            while (list(, $nested_array) = each($nav_array)) {
                $nav_links_html .= '<link rel="' . $nav_item . '" type="text/html" title="' . strip_tags($nested_array['title']) . '" href="' . $nav_base_url . $nested_array['url'] . '" />' . "\n";
            }
        }
    }
    // RSS Autodiscovery - BEGIN
    $rss_url = $nav_base_url . 'rss.' . PHP_EXT;
    $rss_forum_id = request_var(POST_FORUM_URL, 0);
    $rss_url_append = '';
    $rss_a_url_append = '';
    if ($rss_forum_id != 0) {
        $rss_url_append = '?' . POST_FORUM_URL . '=' . $rss_forum_id;
        $rss_a_url_append = '&amp;' . POST_FORUM_URL . '=' . $rss_forum_id;
    }
    $nav_links_html .= '<link rel="alternate" type="application/rss+xml" title="RSS" href="' . $rss_url . $rss_url_append . '" />' . "\n";
    $nav_links_html .= '<link rel="alternate" type="application/atom+xml" title="Atom" href="' . $rss_url . '?atom' . $rss_a_url_append . '" />' . "\n";
    // RSS Autodiscovery - END
    // Time Management - BEGIN
    // Format Timezone. We are unable to use array_pop here, because of PHP3 compatibility
    $s_timezone = str_replace('.0', '', sprintf('%.1f', number_format($config['board_timezone'], 1)));
    $l_timezone = $lang['tz'][$s_timezone];
    if (!$user->data['session_logged_in']) {
        $user->data['user_time_mode'] = $config['default_time_mode'];
    }
    switch ($user->data['user_time_mode']) {
        case MANUAL_DST:
            $time_message = sprintf($lang['All_times'], $l_timezone) . $lang['dst_enabled_mode'];
            break;
        case SERVER_SWITCH:
            $time_message = sprintf($lang['All_times'], $l_timezone);
            if (@date('I')) {
                $time_message = $time_message . $lang['dst_enabled_mode'];
            }
            break;
        default:
            $time_message = sprintf($lang['All_times'], $l_timezone);
            break;
    }
    $time_message = str_replace('GMT', 'UTC', $time_message);
    // Time Management - END
    // Mighty Gorgon - Advanced Switches - BEGIN
    $new_pm_switch = false;
    $new_private_chat_switch = false;
    // LOGGED IN CHECK - BEGIN
    if (!$user->data['session_logged_in']) {
        // Allow autologin?
        if (!isset($config['allow_autologin']) || $config['allow_autologin']) {
            $template->assign_block_vars('switch_allow_autologin', array());
        }
        $smart_redirect = strrchr($_SERVER['SCRIPT_NAME'], '/');
        $smart_redirect = substr($smart_redirect, 1, strlen($smart_redirect));
        if ($smart_redirect == CMS_PAGE_PROFILE || $smart_redirect == CMS_PAGE_LOGIN) {
            $smart_redirect = '';
        }
        if (isset($_GET) && !empty($smart_redirect)) {
            $smart_get_keys = array_keys($_GET);
            for ($i = 0; $i < sizeof($_GET); $i++) {
                //Better sanitize each key...
                $smart_get_keys[$i] = htmlspecialchars($smart_get_keys[$i]);
                if ($smart_get_keys[$i] != 'sid') {
                    $smart_redirect .= '&amp;' . $smart_get_keys[$i] . '=' . urlencode(ip_utf8_decode($_GET[$smart_get_keys[$i]]));
                }
            }
        }
        $u_login_logout = CMS_PAGE_LOGIN;
        $u_login_logout .= !empty($smart_redirect) ? '?redirect=' . $smart_redirect : '';
        $l_login_logout = $lang['Login'];
        $l_login_logout2 = $lang['Login'];
        $s_last_visit = '';
        $icon_pm = $images['pm_no_new_msg'];
        $l_privmsgs_text = $lang['Login_check_pm'];
        $l_privmsgs_text_unread = '';
        $s_privmsg_new = 0;
        $icon_private_chat = $images['private_chat'];
        $u_private_chat = '#';
    } else {
        if (!empty($user->data['user_popup_pm'])) {
            $template->assign_block_vars('switch_enable_pm_popup', array());
        }
        $u_login_logout = CMS_PAGE_LOGIN . '?logout=true&amp;sid=' . $user->data['session_id'];
        $l_login_logout = $lang['Logout'] . ' (' . $user->data['username'] . ')';
        $l_login_logout2 = $lang['Logout'];
        $s_last_visit = create_date($config['default_dateformat'], $user->data['user_lastvisit'], $config['board_timezone']);
        // DOWNLOADS ADV - BEGIN
        //@include(IP_ROOT_PATH . PLUGINS_PATH . $config['plugins']['downloads']['dir'] . 'includes/dl_page_header_inc.' . PHP_EXT);
        // DOWNLOADS ADV - END
        // Obtain number of new private messages
        if (empty($gen_simple_header)) {
            // Birthday - BEGIN
            // see if user has or have had birthday, also see if greeting are enabled
            if ($user->data['user_birthday'] != 999999 && $config['birthday_greeting'] && create_date('Ymd', time(), $config['board_timezone']) >= $user->data['user_next_birthday_greeting'] . realdate('md', $user->data['user_birthday'])) {
                if (!function_exists('birthday_pm_send')) {
                    include_once IP_ROOT_PATH . 'includes/functions_users.' . PHP_EXT;
                }
                birthday_pm_send();
            }
            // Birthday - END
            if ($user->data['user_profile_view'] && $user->data['user_profile_view_popup']) {
                $template->assign_vars(array('PROFILE_VIEW' => true, 'U_PROFILE_VIEW' => append_sid('profile_view_popup.' . PHP_EXT)));
            }
            if ($user->data['user_new_privmsg'] && !$config['privmsg_disable']) {
                $new_pm_switch = true;
                $l_message_new = $user->data['user_new_privmsg'] == 1 ? $lang['New_pm'] : $lang['New_pms'];
                $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']);
                if ($user->data['user_last_privmsg'] > $user->data['user_lastvisit']) {
                    $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\t\tSET user_last_privmsg = '" . $user->data['user_lastvisit'] . "'\n\t\t\t\t\t\tWHERE user_id = " . $user->data['user_id'];
                    $db->sql_query($sql);
                    $s_privmsg_new = 1;
                    $icon_pm = $images['pm_new_msg'];
                } else {
                    $s_privmsg_new = 0;
                    $icon_pm = $images['pm_new_msg'];
                }
            } else {
                $l_privmsgs_text = $lang['No_new_pm'];
                $s_privmsg_new = 0;
                $icon_pm = $images['pm_no_new_msg'];
            }
            $icon_private_chat = $images['private_chat'];
            if (!empty($user->data['user_private_chat_alert'])) {
                $new_private_chat_switch = true;
                $icon_private_chat = $images['private_chat_alert'];
                $ajax_chat_page = !empty($config['ajax_chat_link_type']) ? CMS_PAGE_AJAX_CHAT : CMS_PAGE_AJAX_SHOUTBOX;
                $ajax_chat_room = 'chat_room=' . $user->data['user_private_chat_alert'];
                $ajax_chat_link = append_sid($ajax_chat_page . '?' . $ajax_chat_room);
                $ajax_chat_ref = !empty($config['ajax_chat_link_type']) ? $ajax_chat_link . '" target="_chat' : '#" onclick="window.open(\'' . $ajax_chat_link . '\', \'_chat\', \'width=720,height=600,resizable=yes\'); $(\'#shoutbox_pvt_alert\').css(\'display\', \'none\'); return false;';
                $u_private_chat = $ajax_chat_ref;
            }
            if ($user->data['user_unread_privmsg']) {
                $l_message_unread = $user->data['user_unread_privmsg'] == 1 ? $lang['Unread_pm'] : $lang['Unread_pms'];
                $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']);
            } else {
                $l_privmsgs_text_unread = $lang['No_unread_pm'];
            }
        } else {
            $icon_pm = $images['pm_no_new_msg'];
            $l_privmsgs_text = $lang['Login_check_pm'];
            $l_privmsgs_text_unread = '';
            $s_privmsg_new = 0;
        }
        // We don't want this SQL being too expensive... so we will allow the number of new messages only for some pages... (you can add here other pages if you wish!)
        // We will also allow the number of new messages only for users which log on frequently
        $new_messages_counter_pages_array = array(CMS_PAGE_FORUM, CMS_PAGE_VIEWFORUM);
        $display_counter = $config['enable_new_messages_number'] && !$user->data['is_bot'] && in_array($page_url['basename'], $new_messages_counter_pages_array) && $user->data['user_lastvisit'] > time() - LAST_LOGIN_DAYS_NEW_POSTS_RESET * 60 * 60 * 24 ? true : false;
        if ($display_counter) {
            $auth_forum = '';
            if ($user->data['user_level'] != ADMIN) {
                if (!function_exists('auth_forum_read')) {
                    include_once IP_ROOT_PATH . 'includes/functions_upi2db.' . PHP_EXT;
                }
                $user->data['auth_forum_id'] = isset($user->data['auth_forum_id']) ? $user->data['auth_forum_id'] : auth_forum_read($user->data);
                $auth_forum = !empty($user->data['auth_forum_id']) ? ' AND p.forum_id IN (' . $user->data['auth_forum_id'] . ') ' : '';
            }
            $sql = "SELECT p.forum_id, t.topic_poster\n\t\t\t\tFROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t\n\t\t\t\tWHERE t.topic_id = p.topic_id\n\t\t\t\tAND p.post_time >= " . $user->data['user_lastvisit'] . $auth_forum . "\n\t\t\t\tAND p.poster_id != " . $user->data['user_id'];
            $db->sql_return_on_error(true);
            $result = $db->sql_query($sql);
            $db->sql_return_on_error(false);
            if ($result) {
                $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $user->data);
                $new_posts = 0;
                while ($row = $db->sql_fetchrow($result)) {
                    if (intval($is_auth_ary[$row['forum_id']]['auth_read']) != AUTH_SELF || $user->data['user_level'] == ADMIN || $user->data['user_level'] == MOD && $config['allow_mods_view_self'] == true || $row['topic_poster'] == $user->data['user_id']) {
                        $new_posts++;
                    }
                }
                $lang['Search_new'] = $lang['Search_new'] . ' (' . $new_posts . ')';
                $lang['New'] = $lang['New'] . ' (' . $new_posts . ')';
                $lang['NEW_POSTS_SHORT'] = $lang['New_Label'] . ' (' . $new_posts . ')';
                $lang['NEW_POSTS_LONG'] = $lang['New_Messages_Label'] . ' (' . $new_posts . ')';
                $lang['Search_new2'] = $lang['Search_new2'] . ' (' . $new_posts . ')';
                $lang['Search_new_p'] = $lang['Search_new_p'] . ' (' . $new_posts . ')';
                $db->sql_freeresult($result);
            }
        } else {
            $lang['NEW_POSTS_SHORT'] = $lang['New_Label'];
            $lang['NEW_POSTS_LONG'] = $lang['New_Messages_Label'];
        }
    }
    // LOGGED IN CHECK - END
    if (!defined('IN_CMS')) {
        // UPI2DB - BEGIN
        $upi2db_first_use = '';
        $u_display_new = array();
        if ($user->data['upi2db_access']) {
            $u_display_new = index_display_new($user->data['upi2db_unread']);
            $template->assign_block_vars('switch_upi2db_on', array());
            $template->assign_var('IS_UPI2DB', true);
            $upi2db_first_use = $user->data['user_upi2db_datasync'] == '0' ? '<script type="text/javascript">' . "\n" . '// <![CDATA[' . "\n" . 'alert ("' . $lang['upi2db_first_use_txt'] . '");' . "\n" . '// ]]>' . "\n" . '</script>' : '';
        } else {
            if ($user->data['session_logged_in']) {
                $template->assign_block_vars('switch_upi2db_off', array());
            }
        }
        // UPI2DB - END
        // Digests - BEGIN
        if (!empty($config['cron_digests_interval']) && $config['cron_digests_interval'] > 0) {
            if (!defined('DIGEST_SITE_URL')) {
                $digest_server_url = create_server_url();
                define('DIGEST_SITE_URL', $digest_server_url);
            }
            setup_extra_lang(array('lang_digests'));
            if ($user->data['session_logged_in']) {
                $template->assign_block_vars('switch_show_digests', array());
            }
        }
        // Digests - END
        // Visit Counter - BEGIN
        if ($config['visit_counter_switch']) {
            $sql = "UPDATE " . CONFIG_TABLE . "\n\t\t\t\t\tSET config_value = (config_value + 1)\n\t\t\t\t\tWHERE config_name = 'visit_counter'";
            $result = $db->sql_query($sql);
        }
        // Visit Counter - END
        // Mighty Gorgon - Random Quote - Begin
        $randomquote_phrase = '';
        if ($config['show_random_quote']) {
            @(include_once IP_ROOT_PATH . 'language/lang_' . $config['default_lang'] . '/lang_randomquote.' . PHP_EXT);
            $randomquote_phrase = $randomquote[rand(0, sizeof($randomquote) - 1)];
        }
        // Mighty Gorgon - Random Quote - End
        // Mighty Gorgon - Advanced Switches - END
        // Show Online Block - BEGIN
        // Get basic (usernames + totals) online situation
        $online_userlist = '';
        $l_online_users = '';
        $ac_online_users = array('reg' => 0, 'guests' => 0, 'tot' => 0, 'list' => '', 'text' => '');
        if (defined('SHOW_ONLINE') && !$user->data['is_bot']) {
            include IP_ROOT_PATH . 'includes/users_online_block.' . PHP_EXT;
        }
        // Show Online Block - END
        // CrackerTracker v5.x
        /*
         * CrackerTracker IP Range Scanner
         */
        $marknow = request_var('marknow', '');
        if ($marknow == 'ipfeature' && $user->data['session_logged_in']) {
            // Mark IP Feature Read
            $user->data['ct_last_ip'] = $user->data['ct_last_used_ip'];
            $sql = 'UPDATE ' . USERS_TABLE . ' SET ct_last_ip = ct_last_used_ip WHERE user_id=' . $user->data['user_id'];
            $result = $db->sql_query($sql);
            if (!empty($_SERVER['HTTP_REFERER'])) {
                preg_match('#/([^/]*?)$#', $_SERVER['HTTP_REFERER'], $backlink);
                redirect($backlink[1]);
            }
        }
        if ($config['ctracker_login_ip_check'] == 1 && $user->data['ct_enable_ip_warn'] == 1 && $user->data['session_logged_in']) {
            include_once IP_ROOT_PATH . 'includes/ctracker/classes/class_ct_userfunctions.' . PHP_EXT;
            $ctracker_user = new ct_userfunctions();
            $check_ip_range = $ctracker_user->check_ip_range();
            if ($check_ip_range != 'allclear') {
                $template->assign_block_vars('ctracker_message', array('ROW_COLOR' => 'ffdfdf', 'ICON_GLOB' => $images['ctracker_note'], 'L_MESSAGE_TEXT' => $check_ip_range, 'L_MARK_MESSAGE' => $lang['ctracker_gmb_markip'], 'U_MARK_MESSAGE' => append_sid('index.' . PHP_EXT . '?marknow=ipfeature')));
            }
        }
        /*
         * CrackerTracker Global Message Function
         */
        if ($marknow == 'globmsg' && $user->data['session_logged_in']) {
            // Mark Global Message as read
            $user->data['ct_global_msg_read'] = 0;
            $sql = 'UPDATE ' . USERS_TABLE . ' SET ct_global_msg_read = 0 WHERE user_id=' . $user->data['user_id'];
            $result = $db->sql_query($sql);
            if (!empty($_SERVER['HTTP_REFERER'])) {
                preg_match('#/([^/]*?)$#', $_SERVER['HTTP_REFERER'], $backlink);
                redirect($backlink[1]);
            }
        }
        if ($user->data['ct_global_msg_read'] == 1 && $user->data['session_logged_in'] && $config['ctracker_global_message'] != '') {
            // Output Global Message
            $global_message_output = '';
            if ($config['ctracker_global_message_type'] == 1) {
                $global_message_output = $config['ctracker_global_message'];
            } else {
                $global_message_output = sprintf($lang['ctracker_gmb_link'], $config['ctracker_global_message'], $config['ctracker_global_message']);
            }
            $template->assign_block_vars('ctracker_message', array('ROW_COLOR' => 'e1ffdf', 'ICON_GLOB' => $images['ctracker_note'], 'L_MESSAGE_TEXT' => $global_message_output, 'L_MARK_MESSAGE' => $lang['ctracker_gmb_mark'], 'U_MARK_MESSAGE' => append_sid('index.' . PHP_EXT . '?marknow=globmsg')));
        }
        if (($config['login_history'] == 1 || $config['login_ip_check'] == 1) && $user->data['session_logged_in']) {
            $template->assign_block_vars('login_sec_link', array());
        }
        /*
         * CrackerTracker Password Expiry Check
         */
        if ($user->data['session_logged_in'] && $config['ctracker_pw_control'] == 1) {
            $pwd_expiry_time = $user->data['user_passchg'] + (!empty($config['ctracker_pw_validity']) ? (int) $config['ctracker_pw_validity'] : 365) * 24 * 60 * 60;
            if (time() > $pwd_expiry_time) {
                $template->assign_block_vars('ctracker_message', array('ROW_COLOR' => 'ffdfdf', 'ICON_GLOB' => $images['ctracker_note'], 'L_MESSAGE_TEXT' => sprintf($lang['ctracker_info_pw_expired'], $config['ctracker_pw_validity'], $user->data['user_id']), 'L_MARK_MESSAGE' => '', 'U_MARK_MESSAGE' => ''));
            }
        }
        /*
         * CrackerTracker Debug Mode Check
         */
        if (defined('CT_DEBUG_MODE') && CT_DEBUG_MODE === true && $user->data['user_level'] == ADMIN) {
            $template->assign_block_vars('ctracker_message', array('ROW_COLOR' => 'ffdfdf', 'ICON_GLOB' => $images['ctracker_note'], 'L_MESSAGE_TEXT' => $lang['ctracker_dbg_mode'], 'L_MARK_MESSAGE' => '', 'U_MARK_MESSAGE' => ''));
        }
        // CrackerTracker v5.x
        if ($config['switch_header_table']) {
            $template->assign_block_vars('switch_header_table', array('HEADER_TEXT' => $config['header_table_text'], 'L_STAFF_MESSAGE' => $lang['staff_message']));
        }
        if ($config['show_calendar_box_index']) {
            $path_parts = pathinfo($_SERVER['SCRIPT_NAME']);
            if ($path_parts['basename'] != CMS_PAGE_LOGIN) {
                if (!defined('IN_CALENDAR')) {
                    if (intval($config['calendar_header_cells']) > 0) {
                        $template->assign_block_vars('switch_calendar_box', array());
                        include_once IP_ROOT_PATH . 'includes/functions_calendar.' . PHP_EXT;
                        display_calendar('CALENDAR_BOX', intval($config['calendar_header_cells']));
                    }
                }
            }
        }
        $top_html_block_text = get_ad('glt');
        $header_banner_text = get_ad('glh');
        $nav_menu_ads_top = get_ad('nmt');
        $nav_menu_ads_bottom = get_ad('nmb');
        $social_connect_buttons = '';
        if (!empty($config['enable_social_connect'])) {
            include_once IP_ROOT_PATH . 'includes/class_social_connect.' . PHP_EXT;
            $available_networks = SocialConnect::get_available_networks();
            foreach ($available_networks as $social_network) {
                $social_connect_url = append_sid(CMS_PAGE_LOGIN . '?social_network=' . $social_network->get_name_clean());
                $social_connect_img = '<img src="' . IP_ROOT_PATH . 'images/social_connect/' . $social_network->get_name_clean() . '_button_connect.png" alt="" title="' . $social_network->get_name() . '" />';
                $social_connect_buttons .= '<a href="' . $social_connect_url . '">' . $social_connect_img . '</a>';
            }
        }
        // The following assigns all _common_ variables that may be used at any point in a template.
        $template->assign_vars(array('TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, 'BOT_LIST' => !empty($online_botlist) ? $online_botlist : '', 'AC_LIST_TEXT' => $ac_online_users['text'], 'AC_LIST' => $ac_online_users['list'], 'RECORD_USERS' => sprintf($lang['Record_online_users'], $config['record_online_users'], create_date($config['default_dateformat'], $config['record_online_date'], $config['board_timezone'])), 'TOP_HTML_BLOCK' => $top_html_block_text, 'S_HEADER_BANNER' => empty($header_banner_text) ? false : true, 'HEADER_BANNER_CODE' => $header_banner_text, 'NAV_MENU_ADS_TOP' => $nav_menu_ads_top, 'NAV_MENU_ADS_BOTTOM' => $nav_menu_ads_bottom, 'L_SEARCH_NEW' => $lang['Search_new'], 'L_SEARCH_NEW2' => $lang['Search_new2'], 'L_NEW' => $lang['New'], 'L_NEW2' => empty($lang['NEW_POSTS_SHORT']) ? $lang['New_Label'] : $lang['NEW_POSTS_SHORT'], 'L_NEW3' => empty($lang['NEW_POSTS_LONG']) ? $lang['New_Messages_Label'] : $lang['NEW_POSTS_LONG'], 'L_POSTS' => $lang['Posts'], 'L_DISPLAY_ALL' => !empty($u_display_new) ? $u_display_new['all'] : '', 'L_DISPLAY_U' => !empty($u_display_new) ? $u_display_new['u'] : '', 'L_DISPLAY_M' => !empty($u_display_new) ? $u_display_new['m'] : '', 'L_DISPLAY_P' => !empty($u_display_new) ? $u_display_new['p'] : '', 'L_DISPLAY_UNREAD' => !empty($u_display_new) ? $u_display_new['unread'] : '', 'L_DISPLAY_MARKED' => !empty($u_display_new) ? $u_display_new['marked'] : '', 'L_DISPLAY_PERMANENT' => !empty($u_display_new) ? $u_display_new['permanent'] : '', 'L_DISPLAY_U_S' => !empty($u_display_new) ? $u_display_new['u_string_full'] : '', 'L_DISPLAY_M_S' => !empty($u_display_new) ? $u_display_new['m_string_full'] : '', 'L_DISPLAY_P_S' => !empty($u_display_new) ? $u_display_new['p_string_full'] : '', 'L_DISPLAY_UNREAD_S' => !empty($u_display_new) ? $u_display_new['unread_string'] : '', 'L_DISPLAY_MARKED_S' => !empty($u_display_new) ? $u_display_new['marked_string'] : '', 'L_DISPLAY_PERMANENT_S' => !empty($u_display_new) ? $u_display_new['permanent_string'] : '', 'U_DISPLAY_U' => !empty($u_display_new) ? $u_display_new['u_url'] : '', 'U_DISPLAY_M' => !empty($u_display_new) ? $u_display_new['m_url'] : '', 'U_DISPLAY_P' => !empty($u_display_new) ? $u_display_new['p_url'] : '', 'L_SEARCH_UNANSWERED' => $lang['Search_unanswered'], 'L_SEARCH_SELF' => $lang['Search_your_posts'], 'L_RECENT' => $lang['Recent_topics'], 'L_WATCHED_TOPICS' => $lang['Watched_Topics'], 'L_BOOKMARKS' => $lang['Bookmarks'], 'L_DIGESTS' => $lang['DIGESTS'], 'L_DRAFTS' => $lang['Drafts'], 'RANDOM_QUOTE' => $randomquote_phrase, 'L_LOGIN_SEC' => $lang['ctracker_gmb_loginlink'], 'U_LOGIN_SEC' => append_sid('ct_login_history.' . PHP_EXT), 'L_VIEWER' => $lang['Username'], 'L_NUMBER' => $lang['Views'], 'L_STAMP' => $lang['Last_updated'], 'L_YOUR_ACTIVITY' => $lang['Cpl_Personal_Profile'], 'L_PROFILE_EXPLAIN' => $lang['profile_explain'], 'L_PROFILE_MAIN' => $lang['profile_main'], 'L_CPL_NAV' => $lang['Profile'], 'L_CPL_REG_INFO' => $lang['Registration_info'], 'L_CPL_DELETE_ACCOUNT' => $lang['Delete_My_Account'], 'L_CPL_PROFILE_INFO' => $lang['Profile_info'], 'L_CPL_PROFILE_VIEWED' => $lang['Profile_viewed'], 'L_CPL_AVATAR_PANEL' => $lang['Avatar_panel'], 'L_CPL_SIG_EDIT' => $lang['sig_edit_link'], 'L_CPL_PREFERENCES' => $lang['Preferences'], 'L_CPL_SETTINGS_OPTIONS' => $lang['Cpl_Settings_Options'], 'L_CPL_BOARD_SETTINGS' => $lang['Cpl_Board_Settings'], 'L_CPL_MORE_INFO' => $lang['Cpl_More_info'], 'L_CPL_NEWMSG' => $lang['Cpl_NewMSG'], 'L_CPL_PERSONAL_PROFILE' => $lang['Cpl_Personal_Profile'], 'L_CPL_OWN_POSTS' => $lang['Search_your_posts'], 'L_CPL_OWN_PICTURES' => $lang['Personal_Gallery'], 'L_CPL_BOOKMARKS' => $lang['Bookmarks'], 'L_CPL_SUBSCFORUMS' => $lang['UCP_SubscForums'], 'L_CPL_PRIVATE_MESSAGES' => $lang['Private_Messages'], 'L_CPL_INBOX' => $lang['Inbox'], 'L_CPL_OUTBOX' => $lang['Outbox'], 'L_CPL_SAVEBOX' => $lang['Savebox'], 'L_CPL_SENTBOX' => $lang['Sentbox'], 'L_CPL_DRAFTS' => $lang['Drafts'], 'L_CPL_ZEBRA' => $lang['UCP_ZEBRA'], 'L_CPL_ZEBRA_EXPLAIN' => $lang['FRIENDS_EXPLAIN'], 'U_CPL_PROFILE_VIEWED' => append_sid('profile_view_user.' . PHP_EXT . '?' . POST_USERS_URL . '=' . $user->data['user_id']), 'U_CPL_NEWMSG' => append_sid(CMS_PAGE_PRIVMSG . '?mode=post'), 'U_CPL_REGISTRATION_INFO' => append_sid(CMS_PAGE_PROFILE . '?mode=editprofile&amp;cpl_mode=reg_info'), 'U_CPL_DELETE_ACCOUNT' => append_sid('contact_us.' . PHP_EXT . '?account_delete=' . $user->data['user_id']), 'U_CPL_PROFILE_INFO' => append_sid(CMS_PAGE_PROFILE . '?mode=editprofile&amp;cpl_mode=profile_info'), 'U_CPL_PREFERENCES' => append_sid(CMS_PAGE_PROFILE . '?mode=editprofile&amp;cpl_mode=preferences'), 'U_CPL_BOARD_SETTINGS' => append_sid(CMS_PAGE_PROFILE . '?mode=editprofile&amp;cpl_mode=board_settings'), 'U_CPL_AVATAR_PANEL' => append_sid(CMS_PAGE_PROFILE . '?mode=editprofile&amp;cpl_mode=avatar'), 'U_CPL_SIGNATURE' => append_sid(CMS_PAGE_PROFILE . '?mode=signature'), 'U_CPL_OWN_POSTS' => append_sid(CMS_PAGE_SEARCH . '?search_author=' . urlencode($user->data['username']) . '&amp;showresults=posts'), 'U_CPL_OWN_PICTURES' => append_sid('album.' . PHP_EXT . '?user_id=' . $user->data['user_id']), 'U_CPL_CALENDAR_SETTINGS' => append_sid('profile_options.' . PHP_EXT . '?sub=preferences&amp;module=calendar_settings&amp;' . POST_USERS_URL . '=' . $user->data['user_id']), 'U_CPL_SUBFORUM_SETTINGS' => append_sid('profile_options.' . PHP_EXT . '?sub=preferences&amp;module=forums_settings&amp;' . POST_USERS_URL . '=' . $user->data['user_id']), 'U_CPL_SUBSCFORUMS' => append_sid('subsc_forums.' . PHP_EXT), 'U_CPL_BOOKMARKS' => append_sid(CMS_PAGE_SEARCH . '?search_id=bookmarks'), 'U_CPL_INBOX' => append_sid(CMS_PAGE_PRIVMSG . '?folder=inbox'), 'U_CPL_OUTBOX' => append_sid(CMS_PAGE_PRIVMSG . '?folder=outbox'), 'U_CPL_SAVEBOX' => append_sid(CMS_PAGE_PRIVMSG . '?folder=savebox'), 'U_CPL_SENTBOX' => append_sid(CMS_PAGE_PRIVMSG . '?folder=sentbox'), 'U_CPL_DRAFTS' => append_sid('drafts.' . PHP_EXT), 'U_CPL_ZEBRA' => append_sid(CMS_PAGE_PROFILE . '?mode=zebra&amp;zmode=friends'), 'SOCIAL_CONNECT_BUTTONS' => $social_connect_buttons, 'P_ACTIVITY_MOD_PATH' => PLUGINS_PATH . $config['plugins']['activity']['dir'], 'U_ACTIVITY' => append_sid('activity.' . PHP_EXT), 'L_ACTIVITY' => $lang['Activity']));
    }
    // The following assigns all _common_ variables that may be used at any point in a template.
    $current_time = create_date($config['default_dateformat'], time(), $config['board_timezone']);
    $template->assign_vars(array('DOCTYPE_HTML' => $doctype_html, 'HEADER_LANG' => $header_lang, 'NAV_LINKS' => $nav_links_html, 'S_HIGHSLIDE' => !empty($config['thumbnail_highslide']) ? true : false, 'S_HEADER_DROPDOWN' => $config['switch_header_dropdown'] ? true : false, 'S_HEADER_DD_LOGGED_IN' => $config['switch_header_dropdown'] && $user->data['upi2db_access'] ? true : false, 'S_AJAX_FEATURES' => !empty($config['ajax_features']) ? true : false, 'S_AJAX_USER_CHECK' => $ajax_user_check, 'S_AJAX_USER_CHECK_ALT' => $ajax_user_check_alt, 'U_LOGIN_LOGOUT' => append_sid(IP_ROOT_PATH . $u_login_logout), 'USER_USERNAME' => $user->data['session_logged_in'] ? htmlspecialchars($user->data['username']) : $lang['Guest'], 'UPI2DB_FIRST_USE' => $upi2db_first_use, 'L_PAGE_TITLE' => $meta_content['page_title_clean'], 'PAGE_TITLE' => $config['page_title_simple'] ? $meta_content['page_title_clean'] : $meta_content['page_title'], 'META_TAG' => $phpbb_meta, 'LAST_VISIT_DATE' => sprintf($lang['You_last_visit'], $s_last_visit), 'CURRENT_TIME' => sprintf($lang['Current_time'], $current_time), 'CURRENT_TIME_ONLY' => $current_time, 'S_TIMEZONE' => $time_message, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, 'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new, 'PRIVMSG_IMG' => $icon_pm, 'NEW_PM_SWITCH' => $new_pm_switch, 'PRIVATE_CHAT_IMG' => $icon_private_chat, 'U_PRIVATE_CHAT' => $u_private_chat, 'NEW_PRIVATE_CHAT_SWITCH' => $new_private_chat_switch, 'L_USERNAME' => $lang['Username'], 'L_PASSWORD' => $lang['Password'], 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_LOGIN_LOGOUT2' => $l_login_logout2, 'L_LOGIN' => $lang['Login'], 'L_HOME' => $lang['Home'], 'L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_REGISTER' => $lang['Register'], 'L_BOARDRULES' => $lang['BoardRules'], 'L_PROFILE' => $lang['Profile'], 'L_CPL_NAV' => $lang['Profile'], 'L_SEARCH' => $lang['Search'], 'L_PRIVATEMSGS' => $lang['Private_Messages'], 'L_WHO_IS_ONLINE' => $lang['Who_is_Online'], 'L_MEMBERLIST' => $lang['Memberlist'], 'L_FAQ' => $lang['FAQ'], 'L_ADV_SEARCH' => $lang['Adv_Search'], 'L_SEARCH_EXPLAIN' => $lang['Search_Explain'], 'L_KB' => $lang['KB_title'], 'L_NEWS' => $lang['News_Cmx'], 'L_USERGROUPS' => $lang['Usergroups'], 'L_BOARD_DISABLE' => $lang['Board_disabled'], 'L_AJAX_SHOUTBOX' => $lang['Ajax_Chat'], 'L_BACK_TOP' => $lang['Back_to_top'], 'L_BACK_BOTTOM' => $lang['Back_to_bottom'], 'L_CALENDAR' => $lang['Calendar'], 'L_DOWNLOADS' => $lang['Downloads'], 'L_DOWNLOADS_ADV' => $lang['Downloads_ADV'], 'L_HACKS_LIST' => $lang['Hacks_List'], 'L_AVATAR_GEN' => $lang['AvatarGenerator'], 'L_LINKS' => $lang['Links'], 'L_WORDGRAPH' => $lang['Wordgraph'], 'L_ACRONYMS' => $lang['Acronyms'], 'L_SITEMAP' => $lang['Sitemap'], 'L_RANKS' => $lang['Rank_Header'], 'L_STAFF' => $lang['Staff'], 'L_CONTACT_US' => $lang['Contact_us'], 'L_UPLOAD_IMAGE' => $lang['Upload_Image_Local'], 'L_UPLOADED_IMAGES' => $lang['Uploaded_Images_Local'], 'L_ALBUM' => $lang['Album'], 'L_PIC_NAME' => $lang['Pic_Name'], 'L_DESCRIPTION' => $lang['Description'], 'L_GO' => $lang['Go'], 'L_SEARCH_CONTENTS' => $lang['Search_Contents'], 'L_SEARCH_MATCHES' => $lang['Search_Matches'], 'U_PREFERENCES' => append_sid('profile_options.' . PHP_EXT), 'L_PREFERENCES' => $lang['Preferences']));
    // get the nav sentence
    $nav_key = '';
    $nav_key = !empty($meta_content['cat_id']) ? POST_CAT_URL . $meta_content['cat_id'] : $nav_key;
    $nav_key = !empty($meta_content['forum_id']) ? POST_FORUM_URL . $meta_content['forum_id'] : $nav_key;
    $nav_key = !empty($meta_content['topic_id']) ? POST_TOPIC_URL . $meta_content['topic_id'] : $nav_key;
    $nav_key = !empty($meta_content['post_id']) ? POST_POST_URL . $meta_content['post_id'] : $nav_key;
    if (empty($nav_key)) {
        $selected_id = request_var('selected_id', 0);
        $nav_key = $selected_id < 0 ? 0 : $selected_id;
        $nav_key = empty($nav_key) ? 'Root' : $nav_key;
    }
    $nav_separator = empty($nav_separator) ? empty($lang['Nav_Separator']) ? '&nbsp;&raquo;&nbsp;' : $lang['Nav_Separator'] : $nav_separator;
    $nav_cat_desc = '';
    if (!isset($skip_nav_cat)) {
        $nav_pgm = empty($nav_pgm) ? '' : $nav_pgm;
        $nav_cat_desc = make_cat_nav_tree($nav_key, $nav_pgm, $meta_content);
    }
    if (!empty($nav_cat_desc)) {
        $nav_server_url = create_server_url();
        $nav_cat_desc = $nav_separator . $nav_cat_desc;
        $breadcrumbs['address'] = $nav_separator . '<a href="' . $nav_server_url . append_sid(CMS_PAGE_FORUM) . '">' . $lang['Forum'] . '</a>' . $nav_cat_desc;
        if (isset($nav_add_page_title) && $nav_add_page_title == true) {
            $breadcrumbs['address'] = $breadcrumbs['address'] . $nav_separator . '<a href="#" class="nav-current">' . $meta_content['page_title'] . '</a>';
        }
    }
    // send to template
    $template->assign_vars(array('S_PAGE_NAV' => isset($cms_page['page_nav']) ? $cms_page['page_nav'] : true, 'NAV_SEPARATOR' => $nav_separator, 'NAV_CAT_DESC' => $nav_cat_desc, 'BREADCRUMBS_ADDRESS' => empty($breadcrumbs['address']) ? $meta_content['page_title_clean'] != $config['sitename'] ? $lang['Nav_Separator'] . '<a href="#" class="nav-current">' . $meta_content['page_title_clean'] . '</a>' : '' : $breadcrumbs['address'], 'S_BREADCRUMBS_BOTTOM_LEFT_LINKS' => empty($breadcrumbs['bottom_left_links']) ? false : true, 'BREADCRUMBS_BOTTOM_LEFT_LINKS' => empty($breadcrumbs['bottom_left_links']) ? '&nbsp;' : $breadcrumbs['bottom_left_links'], 'S_BREADCRUMBS_BOTTOM_RIGHT_LINKS' => empty($breadcrumbs['bottom_right_links']) ? false : true, 'BREADCRUMBS_BOTTOM_RIGHT_LINKS' => empty($breadcrumbs['bottom_right_links']) ? '&nbsp;' : $breadcrumbs['bottom_right_links']));
    if ($config['board_disable'] && $user->data['user_level'] == ADMIN) {
        $template->assign_block_vars('switch_admin_disable_board', array());
    }
    if (!defined('IN_CMS')) {
        $cms_page['global_blocks'] = empty($cms_page['global_blocks']) ? false : true;
        //$cms_page['global_blocks'] = ((!isset($cms_page['page_id']) || !$cms_page['global_blocks']) ? false : true);
        $cms_page_blocks = empty($cms_page['page_id']) || empty($cms_config_layouts[$cms_page['page_id']]) ? false : true;
        if (empty($gen_simple_header) && !defined('HAS_DIED') && !defined('IN_LOGIN') && ($cms_page['global_blocks'] || $cms_page_blocks) && (!$config['board_disable'] || $user->data['user_level'] == ADMIN)) {
            $template->assign_var('SWITCH_CMS_GLOBAL_BLOCKS', true);
            $ip_cms->cms_parse_blocks($cms_page['page_id'], !empty($cms_page['page_id']), $cms_page['global_blocks'], 'header');
            if ($ip_cms->cms_parse_blocks($cms_page['page_id'], !empty($cms_page['page_id']), $cms_page['global_blocks'], 'headerleft')) {
                $template->assign_vars(array('HEADER_WIDTH' => $cms_config_vars['header_width'], 'HL_BLOCK' => true));
            }
            if ($ip_cms->cms_parse_blocks($cms_page['page_id'], !empty($cms_page['page_id']), $cms_page['global_blocks'], 'headercenter')) {
                $template->assign_var('HC_BLOCK', true);
            }
        }
        if (empty($gen_simple_header)) {
            if ($ip_cms->cms_parse_blocks(0, true, true, 'gheader')) {
                $template->assign_var('GH_BLOCK', true);
            }
            if ($ip_cms->cms_parse_blocks(0, true, true, 'ghtop')) {
                $template->assign_var('GT_BLOCK', true);
            }
            if ($ip_cms->cms_parse_blocks(0, true, true, 'ghbottom')) {
                $template->assign_var('GB_BLOCK', true);
            }
            if ($ip_cms->cms_parse_blocks(0, true, true, 'ghleft')) {
                $template->assign_var('GL_BLOCK', true);
            }
            if ($ip_cms->cms_parse_blocks(0, true, true, 'ghright')) {
                $template->assign_var('GR_BLOCK', true);
            }
        }
        if (defined('PARSE_CPL_NAV')) {
            $template->set_filenames(array('cpl_menu_output' => 'profile_cpl_menu.tpl'));
            $template->assign_var_from_handle('CPL_MENU_OUTPUT', 'cpl_menu_output');
        }
    }
    if ($user->data['user_level'] != ADMIN && $config['board_disable'] && !defined('HAS_DIED') && !defined('IN_ADMIN') && !defined('IN_LOGIN')) {
        if (!defined('STATUS_503')) {
            define('STATUS_503', true);
        }
        if ($config['board_disable_mess_st']) {
            message_die(GENERAL_MESSAGE, $config['board_disable_message']);
        } else {
            message_die(GENERAL_MESSAGE, $lang['Board_disabled']);
        }
    }
    if (!defined('AJAX_HEADERS')) {
        // application/xhtml+xml not used because of IE
        $encoding_charset = !empty($lang['ENCODING']) ? $lang['ENCODING'] : 'UTF-8';
        header('Content-type: text/html; charset=' . $encoding_charset);
        header('Cache-Control: private, no-cache="set-cookie"');
        header('Expires: 0');
        header('Pragma: no-cache');
    }
    if ($parse_template) {
        $header_tpl = empty($gen_simple_header) ? 'overall_header.tpl' : 'simple_header.tpl';
        $template->set_filenames(array('overall_header' => $header_tpl));
        $template->pparse('overall_header');
    }
    define('HEADER_INC_COMPLETED', true);
    return;
}