function admin_get_nav_cat_desc($cur = '')
{
    global $nav_separator, $lang;
    $nav_separator = empty($nav_separator) ? empty($lang['Nav_Separator']) ? ' » ' : $lang['Nav_Separator'] : $nav_separator;
    $nav_cat_desc = make_cat_nav_tree($cur, 'admin_forums_extend');
    if (!empty($nav_cat_desc)) {
        $nav_cat_desc = $nav_separator . $nav_cat_desc;
    }
    return $nav_cat_desc;
}
Example #2
0
// 	FROM " . CATEGORIES_TABLE . " c
// 	ORDER BY c.cat_order";
// if( !($result = $db->sql_query($sql)) )
// {
// 	message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
// }
//
// $category_rows = array();
// while ($row = $db->sql_fetchrow($result))
// {
//	$category_rows[] = $row;
// }
// $db->sql_freeresult($result);
//
// get the nav sentence
$nav_cat_desc = make_cat_nav_tree($viewcat, false);
//
// categories array
$category_rows = get_cat($viewcat);
// End PNphpBB2 Categories Hierarchie Mod
if ($total_categories = count($category_rows)) {
    //
    // Define appropriate SQL
    //
    switch (SQL_LAYER) {
        case 'postgresql':
            $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id \n\t\t\t\tFROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u\n\t\t\t\tWHERE p.post_id = f.forum_last_post_id \n\t\t\t\t\tAND u.user_id = p.poster_id  \n\t\t\t\t\tUNION (\n\t\t\t\t\t\tSELECT f.*, NULL, NULL, NULL, NULL\n\t\t\t\t\t\tFROM " . FORUMS_TABLE . " f\n\t\t\t\t\t\tWHERE NOT EXISTS (\n\t\t\t\t\t\t\tSELECT p.post_time\n\t\t\t\t\t\t\tFROM " . POSTS_TABLE . " p\n\t\t\t\t\t\t\tWHERE p.post_id = f.forum_last_post_id  \n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\tORDER BY cat_id, forum_order";
            break;
        case 'oracle':
            $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id \n\t\t\t\tFROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u\n\t\t\t\tWHERE p.post_id = f.forum_last_post_id(+)\n\t\t\t\t\tAND u.user_id = p.poster_id(+)\n\t\t\t\tORDER BY f.cat_id, f.forum_order";
            break;
Example #3
0
        //		$s_watching_topic_img = ( isset($images['topic_un_watch']) ) ? "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_un_watch'] . '" alt="' . $lang['Stop_watching_topic'] . '" title="' . $lang['Stop_watching_topic'] . '" border="0"></a>' : '';
        $s_watching_topic = "<a href=\"" . append_sid("viewtopic.{$phpEx}?" . POST_TOPIC_URL . "={$topic_id}&amp;unwatch=topic&amp;start={$start}") . "\">" . $lang['Stop_watching_topic'] . "</a>";
        $s_watching_topic_img = isset($images['topic_un_watch']) ? "<a href=\"" . append_sid("viewtopic.{$phpEx}?" . POST_TOPIC_URL . "={$topic_id}&amp;unwatch=topic&amp;start={$start}") . "\"><img src=\"" . $images['topic_un_watch'] . "\" alt=\"" . $lang['Stop_watching_topic'] . "\" title=\"" . $lang['Stop_watching_topic'] . "\" border=\"0\" /></a>" : "";
        // End PNphpBB2 Module
    } else {
        // Begin PNphpBB2 Module
        //		$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '">' . $lang['Start_watching_topic'] . '</a>';
        //		$s_watching_topic_img = ( isset($images['Topic_watch']) ) ? "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['Topic_watch'] . '" alt="' . $lang['Start_watching_topic'] . '" title="' . $lang['Start_watching_topic'] . '" border="0"></a>' : '';
        $s_watching_topic = "<a href=\"" . append_sid("viewtopic.{$phpEx}?" . POST_TOPIC_URL . "={$topic_id}&amp;watch=topic&amp;start={$start}") . "\">" . $lang['Start_watching_topic'] . "</a>";
        $s_watching_topic_img = isset($images['topic_watch']) ? "<a href=\"" . append_sid("viewtopic.{$phpEx}?" . POST_TOPIC_URL . "={$topic_id}&amp;watch=topic&amp;start={$start}") . "\"><img src=\"" . $images['topic_watch'] . "\" alt=\"" . $lang['Start_watching_topic'] . "\" title=\"" . $lang['Start_watching_topic'] . "\" border=\"0\" /></a>" : "";
        // End PNphpBB2 Module
    }
}
// Begin PNphpBB2 Categories Hierarchie Mod
// get the nav sentence
$nav_cat_desc = make_cat_nav_tree($cat_id, true);
if ($nav_cat_desc != "") {
    $nav_cat_desc = $nav_separator . $nav_cat_desc;
}
// End PNphpBB2 Categories Hierarchie Mod
// Begin PNphpBB2 Module (Support Status Mod)
$support_topic_title = '';
if ($forum_topic_data['support_forum'] && $forum_topic_data['topic_type'] == 0) {
    $support_topic_title = '(' . $lang['support_status'][$forum_topic_data['support_status']] . ')';
    if ($is_auth['auth_mod']) {
        $template->assign_block_vars('support_status_update', array());
        $support_status = '<select name="support_status">';
        $support_status .= '<option value="-1">' . $lang['support_status'][-1] . '</option>';
        $support_status .= '<option value="-1">&nbsp;</option>';
        for ($i = 0; $i < count($lang['support_status']); $i++) {
            // $selected = ($forum_topic_data['support_status'] == $i) ? ' selected="selected"' : '';
function topic_list($box, $tpl = '', $topic_rowset, $list_title = '', $split_type = false, $display_nav_tree = true, $footer = '', $inbox = true, $select_field = '', $select_type = 0, $select_formname = '', $select_values = array())
{
    global $db, $template, $board_config, $userdata, $phpEx, $lang, $images, $HTTP_COOKIE_VARS;
    global $tree, $bbcode_parse;
    static $box_id;
    // save template state
    $sav_tpl = $template->_tpldata;
    // init
    if (empty($tpl)) {
        $tpl = 'topics_list_box';
    }
    if (empty($list_title)) {
        $list_title = $lang['Topics'];
    }
    if (!empty($select_values) && !is_array($select_values)) {
        $s_values = $select_values;
        $select_values = array();
        $select_values[] = $s_values;
    }
    // selections
    $select_multi = false;
    $select_unique = false;
    if (!empty($select_field) && $select_type > 0 && !empty($select_formname)) {
        switch ($select_type) {
            case 1:
                $select_multi = true;
                break;
            case 2:
                $select_unique = true;
                break;
        }
    }
    if ($split_type) {
        // set in separate table
        $split_box = $inbox && (isset($board_config['split_topic_split']) ? intval($board_config['split_topic_split']) : false);
        // get split params
        $switch_split_global_announce = isset($board_config['split_global_announce']) ? intval($board_config['split_global_announce']) : false;
        $switch_split_announce = isset($board_config['split_announce']) ? intval($board_config['split_announce']) : false;
        $switch_split_sticky = isset($board_config['split_sticky']) ? intval($board_config['split_sticky']) : false;
        if (!$switch_split_global_announce && !$switch_split_announce && !$switch_split_sticky) {
            $split_box = $split_type = false;
        }
    } else {
        $split_box = $switch_split_global_announce = $switch_split_announce = $switch_split_sticky = false;
    }
    // Define censored word matches
    $orig_word = array();
    $replacement_word = array();
    obtain_word_list($orig_word, $replacement_word);
    //-- mod : keep unread -----------------------------------------------------------------------------
    //-- delete
    //  // read the user cookie
    //  $tracking_topics    = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
    //  $tracking_forums    = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();
    //  $tracking_all       = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) ) ? intval($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) : NULL;
    //-- add
    // get last visit for guest
    if (!$userdata['session_logged_in']) {
        $userdata['user_lastvisit'] = $board_config['guest_lastvisit'];
    }
    //-- fin mod : keep unread -------------------------------------------------------------------------
    // get a default title
    if (empty($list_title)) {
        $list_title = $lang['forum'];
    }
    // choose template
    $template->set_filenames(array($tpl => $tpl . '.tpl'));
    // check if user replied to the topics
    $user_topics = array();
    $topic_rowset_count = count($topic_rowset);
    if ($userdata['user_id'] != ANONYMOUS) {
        // get all the topic ids to display
        $topic_ids = array();
        for ($i = 0; $i < $topic_rowset_count; $i++) {
            $topic_item_type = substr($topic_rowset[$i]['topic_id'], 0, 1);
            $topic_id = intval(substr($topic_rowset[$i]['topic_id'], 1));
            if ($topic_item_type == POST_TOPIC_URL) {
                $topic_ids[] = $topic_id;
            }
        }
        // check if the user replied to
        if (!empty($topic_ids)) {
            // check the posts
            $s_topic_ids = implode(', ', $topic_ids);
            $sql = 'SELECT DISTINCT topic_id FROM ' . POSTS_TABLE . "\n                    WHERE topic_id IN ({$s_topic_ids})\n                        AND poster_id = " . $userdata['user_id'];
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Could not obtain post information', '', __LINE__, __FILE__, $sql);
            }
            while ($row = $db->sql_fetchrow($result)) {
                $user_topics[POST_TOPIC_URL . $row['topic_id']] = true;
            }
        }
    }
    // initiate
    $template->assign_block_vars($tpl, array('FORMNAME' => $select_formname, 'FIELDNAME' => $select_field));
    // spanning of the first column (list name)
    $span_left = 1;
    if ($topic_rowset_count > 0) {
        // add folder image
        $span_left++;
    }
    $span_left++;
    if ($select_unique) {
        // selection in front is asked
        $span_left++;
    }
    // spanning of the whole line (bottom row and/or empty list)
    $span_all = $span_left + 4;
    if ($select_multi && $topic_rowset_count > 0) {
        $span_all++;
    }
    // display topics
    $color = false;
    $prec_topic_type = '';
    $header_sent = false;
    if (!isset($box_id)) {
        $box_id = -1;
    }
    for ($i = 0; $i < $topic_rowset_count; $i++) {
        $topic_item_type = substr($topic_rowset[$i]['topic_id'], 0, 1);
        $topic_id = intval(substr($topic_rowset[$i]['topic_id'], 1));
        $topic_title = count($orig_word) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
        $replies = $topic_rowset[$i]['topic_replies'];
        $topic_type = $topic_rowset[$i]['topic_type'];
        $user_replied = !empty($user_topics) && isset($user_topics[$topic_rowset[$i]['topic_id']]);
        $force_type_display = false;
        $forum_id = $topic_rowset[$i]['forum_id'];
        if (defined('POST_BIRTHDAY') && $topic_type == POST_BIRTHDAY) {
            $topic_type = $lang['Birthday'] . ': ';
        } else {
            if ($topic_type == POST_GLOBAL_ANNOUNCE) {
                $topic_type = $lang['Topic_Global_Announcement'] . ' ';
            } else {
                if ($topic_type == POST_ANNOUNCE) {
                    $topic_type = $lang['Topic_Announcement'] . ' ';
                } else {
                    if ($topic_type == POST_STICKY) {
                        $topic_type = $lang['Topic_Sticky'] . ' ';
                    } else {
                        $topic_type = '';
                    }
                }
            }
        }
        if ($topic_rowset[$i]['topic_vote']) {
            $topic_type .= $lang['Topic_Poll'] . ' ';
            $force_type_display = true;
        }
        if (defined('POST_BIRTHDAY') && $topic_rowset[$i]['topic_type'] == POST_BIRTHDAY) {
            $folder_image = $images['folder_birthday'];
            $folder_alt = $lang['Happy_birthday'];
            $newest_post_img = '';
        } else {
            if ($topic_rowset[$i]['topic_status'] == TOPIC_MOVED) {
                $topic_type = $lang['Topic_Moved'] . ' ';
                $topic_id = $topic_rowset[$i]['topic_moved_id'];
                $folder_image = $images['folder'];
                $folder_alt = $lang['Topics_Moved'];
                $newest_post_img = '';
                $force_type_display = true;
            } else {
                if (defined('POST_BIRTHDAY') && $topic_rowset[$i]['topic_type'] == POST_BIRTHDAY) {
                    $folder = $images['folder_birthday'];
                    $folder_new = $images['folder_birthday'];
                } else {
                    if ($topic_rowset[$i]['topic_type'] == POST_GLOBAL_ANNOUNCE) {
                        $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_global_announce_own'] : $images['folder_global_announce'];
                        $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_global_announce_new_own'] : $images['folder_global_announce_new'];
                    } else {
                        if ($topic_rowset[$i]['topic_type'] == POST_ANNOUNCE) {
                            $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_announce_own'] : $images['folder_announce'];
                            $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_announce_new_own'] : $images['folder_announce_new'];
                        } else {
                            if ($topic_rowset[$i]['topic_type'] == POST_STICKY) {
                                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_sticky_own'] : $images['folder_sticky'];
                                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_sticky_new_own'] : $images['folder_sticky_new'];
                            } else {
                                if ($topic_rowset[$i]['topic_status'] == TOPIC_LOCKED) {
                                    $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_locked_own'] : $images['folder_locked'];
                                    $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_locked_new_own'] : $images['folder_locked_new'];
                                } else {
                                    if ($replies >= $board_config['hot_threshold']) {
                                        $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_hot_own'] : $images['folder_hot'];
                                        $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_hot_new_own'] : $images['folder_hot_new'];
                                    } else {
                                        $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_own'] : $images['folder'];
                                        $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_new_own'] : $images['folder_new'];
                                    }
                                }
                            }
                        }
                    }
                }
                $newest_post_img = '';
                //-- mod : keep unread -----------------------------------------------------------------------------
                //-- delete
                //          if ( $userdata['session_logged_in'] && ($topic_item_type == POST_TOPIC_URL) )
                //          {
                //              if( $topic_rowset[$i]['post_time'] > $userdata['user_lastvisit'] )
                //              {
                //                  if( !empty($tracking_topics) || !empty($tracking_forums) || !empty($tracking_all) )
                //                  {
                //                      $unread_topics = true;
                //                      if( !empty($tracking_topics[$topic_id]) )
                //                      {
                //                          if( $tracking_topics[$topic_id] >= $topic_rowset[$i]['post_time'] )
                //                          {
                //                              $unread_topics = false;
                //                          }
                //                      }
                //                      if( !empty($tracking_forums[$forum_id]) )
                //                      {
                //                          if( $tracking_forums[$forum_id] >= $topic_rowset[$i]['post_time'] )
                //                          {
                //                              $unread_topics = false;
                //                          }
                //                      }
                //                      if( !empty($tracking_all) )
                //                      {
                //                          if( $tracking_all >= $topic_rowset[$i]['post_time'] )
                //                          {
                //                              $unread_topics = false;
                //                          }
                //                      }
                //-- add
                if ($topic_item_type == POST_TOPIC_URL) {
                    // have we got a last visit time for this topic
                    $topic_last_read = intval($board_config['tracking_unreads'][$topic_id]);
                    if (!empty($board_config['tracking_all']) && $board_config['tracking_all'] > $topic_last_read) {
                        $topic_last_read = $board_config['tracking_all'];
                    }
                    if (isset($board_config['tracking_forums'][$forum_id]) && $board_config['tracking_forums'][$forum_id] > $topic_last_read) {
                        $topic_last_read = $board_config['tracking_forums'][$forum_id];
                    }
                    if (isset($board_config['tracking_topics'][$topic_id]) && $board_config['tracking_topics'][$topic_id] > $topic_last_read) {
                        $topic_last_read = $board_config['tracking_topics'][$topic_id];
                    }
                    if (empty($topic_last_read)) {
                        $topic_last_read = $userdata['user_lastvisit'];
                    }
                    // unread status ?
                    $unread_topics = $topic_rowset[$i]['post_time'] > $topic_last_read;
                    //-- fin mod : keep unread -------------------------------------------------------------------------
                    if ($unread_topics) {
                        $folder_image = $folder_new;
                        $folder_alt = $lang['New_posts'];
                        $newest_post_img = '<a href="' . append_sid("viewtopic.{$phpEx}?" . POST_TOPIC_URL . "={$topic_id}&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
                    } else {
                        $folder_image = $folder;
                        $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                        $newest_post_img = '';
                    }
                    //-- mod : keep unread -----------------------------------------------------------------------------
                    //-- delete
                    //                  }
                    //                  else
                    //                  {
                    //                      $folder_image = $folder_new;
                    //                      $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['New_posts'];
                    //                      $newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
                    //                  }
                    //              }
                    //              else
                    //              {
                    //                  $folder_image = $folder;
                    //                  $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
                    //                  $newest_post_img = '';
                    //              }
                    //          }
                    //          else
                    //          {
                    //              $folder_image = $folder;
                    //              $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
                    //              $newest_post_img = '';
                    //-- fin mod : keep unread -------------------------------------------------------------------------
                }
            }
        }
        // generate list of page for the topic
        $goto_page = '';
        if ($replies + 1 > $board_config['posts_per_page']) {
            $total_pages = ceil(($replies + 1) / $board_config['posts_per_page']);
            $goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';
            $times = 1;
            for ($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page']) {
                $goto_page .= '<a href="' . append_sid("viewtopic.{$phpEx}?" . POST_TOPIC_URL . "=" . $topic_id . "&amp;start={$j}") . '">' . $times . '</a>';
                if ($times == 1 && $total_pages > 4) {
                    $goto_page .= ' ... ';
                    $times = $total_pages - 3;
                    $j += ($total_pages - 4) * $board_config['posts_per_page'];
                } else {
                    if ($times < $total_pages) {
                        $goto_page .= ', ';
                    }
                }
                $times++;
            }
            $goto_page .= ' ] ';
        }
        $topic_author = '';
        $first_post_time = '';
        $last_post_time = '';
        $last_post_url = '';
        $views = '';
        switch ($topic_item_type) {
            case POST_USERS_URL:
                $view_topic_url = append_sid("profile.{$phpEx}?" . POST_USERS_URL . "={$topic_id}");
                break;
            default:
                $view_topic_url = append_sid("viewtopic.{$phpEx}?" . POST_TOPIC_URL . "={$topic_id}");
                $topic_author = $topic_rowset[$i]['user_id'] != ANONYMOUS ? '<a href="' . append_sid("profile.{$phpEx}?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $topic_rowset[$i]['user_id']) . '">' : '';
                $topic_author .= $topic_rowset[$i]['user_id'] != ANONYMOUS ? $topic_rowset[$i]['username'] : ($topic_rowset[$i]['post_username'] != '' ? $topic_rowset[$i]['post_username'] : $lang['Guest']);
                $topic_author .= $topic_rowset[$i]['user_id'] != ANONYMOUS ? '</a>' : '';
                $first_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['topic_time'], $board_config['board_timezone']);
                $last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);
                $last_post_author = $topic_rowset[$i]['id2'] == ANONYMOUS ? $topic_rowset[$i]['post_username2'] != '' ? $topic_rowset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' : '<a href="' . append_sid("profile.{$phpEx}?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $topic_rowset[$i]['id2']) . '">' . $topic_rowset[$i]['user2'] . '</a>';
                $last_post_url = '<a href="' . append_sid("viewtopic.{$phpEx}?" . POST_POST_URL . '=' . $topic_rowset[$i]['topic_last_post_id']) . '#' . $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" border="0" /></a>';
                $views = $topic_rowset[$i]['topic_views'];
                break;
        }
        // categories hierarchy v 2 compliancy
        $nav_tree = '';
        if ($display_nav_tree && !empty($topic_rowset[$i]['forum_id'])) {
            if ($tree['auth'][POST_FORUM_URL . $topic_rowset[$i]['forum_id']]['tree.auth_view']) {
                $nav_tree = make_cat_nav_tree(POST_FORUM_URL . $topic_rowset[$i]['forum_id'], '', 'gensmall');
            }
        }
        if (!empty($nav_tree)) {
            $nav_tree = '[ ' . $nav_tree . ' ]';
        }
        // get the type for rupture
        $topic_real_type = $topic_rowset[$i]['topic_type'];
        // if no split between global and standard announcement, group them with standard announcement
        if (!$switch_split_global_announce && $topic_real_type == POST_GLOBAL_ANNOUNCE) {
            $topic_real_type = POST_ANNOUNCE;
        }
        // if no split between announce and sticky, group them with sticky
        if (!$switch_split_announce && $topic_real_type == POST_ANNOUNCE) {
            $topic_real_type = POST_STICKY;
        }
        // if no split between sticky and normal, group them with normal
        if (!$switch_split_sticky && $topic_real_type == POST_STICKY) {
            $topic_real_type = POST_NORMAL;
        }
        // check if rupture
        $rupt = false;
        // split
        if ($i == 0 || $split_type) {
            if ($i == 0) {
                $rupt = true;
            }
            // check the rupt
            if ($prec_topic_type != $topic_real_type) {
                $rupt = true;
            }
        }
        $prec_topic_type = $topic_real_type;
        // header
        if ($rupt) {
            // close the prec box
            if ($split_box && $i != 0) {
                // footer
                $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all));
                // table closure
                $template->assign_block_vars($tpl . '.row.footer_table', array());
                // spacing
                $template->assign_block_vars($tpl . '.row', array());
                $template->assign_block_vars($tpl . '.row.spacer', array());
                // unset header
                $header_sent = false;
            }
            // get box title
            $main_title = $list_title;
            $sub_title = $list_title;
            switch ($topic_real_type) {
                case POST_BIRTHDAY:
                    $sub_title = $lang['Birthday'];
                    break;
                case POST_GLOBAL_ANNOUNCE:
                    $sub_title = $lang['Post_Global_Announcement'];
                    break;
                case POST_ANNOUNCE:
                    $sub_title = $lang['Post_Announcement'];
                    break;
                case POST_STICKY:
                    $sub_title = $lang['Post_Sticky'];
                    break;
                case POST_CALENDAR:
                    $sub_title = $lang['Calendar_event'];
                    break;
                case POST_NORMAL:
                    $sub_title = $lang['Topics'];
                    break;
            }
            $template->assign_block_vars($tpl . '.row', array('L_TITLE' => !$split_box ? $main_title : $sub_title, 'L_REPLIES' => $lang['Replies'], 'L_AUTHOR' => $lang['Author'], 'L_VIEWS' => $lang['Views'], 'L_LASTPOST' => $lang['Last_Post'], 'COLSPAN' => $span_all));
            // open a new box
            if ($split_box || $i == 0) {
                $box_id++;
                $template->assign_block_vars($tpl . '.row.header_table', array('COLSPAN' => $span_left, 'BOX_ID' => $box_id));
                // selection fields
                if ($select_multi) {
                    $template->assign_block_vars($tpl . '.row.header_table.multi_selection', array());
                }
                // set header
                $header_sent = true;
            }
            // not in box, send a row title
            if ($split_type && !$split_box) {
                $template->assign_block_vars($tpl . '.row', array('L_TITLE' => $sub_title, 'COLSPAN' => $span_all));
                $template->assign_block_vars($tpl . '.row.header_row', array());
            }
        }
        // erase the type before the title if split
        if ($split_type && $topic_real_type == $topic_rowset[$i]['topic_type'] && !$force_type_display) {
            $topic_type = '';
        }
        // get the announces dates
        $topic_announces_dates = '';
        if (in_array($topic_rowset[$i]['topic_type'], array(POST_ANNOUNCE, POST_GLOBAL_ANNOUNCE))) {
            $topic_announces_dates = get_announces_title($topic_rowset[$i]['topic_time'], $topic_rowset[$i]['topic_announce_duration']);
        }
        // get the calendar dates
        /*** Remove Calander Stuff
                $topic_calendar_dates = '';
                if (function_exists('get_calendar_title'))
                {
                    $topic_calendar_dates = get_calendar_title($topic_rowset[$i]['topic_calendar_time'], $topic_rowset[$i]['topic_calendar_duration']);
                }
        ***/
        // get the topic icons
        $icon = '';
        $type = $topic_rowset[$i]['topic_type'];
        if ($type == POST_NORMAL) {
            /*** Remove Calander Code
                        if ( defined('POST_CALENDAR') && !empty($topic_rowset[$i]['topic_calendar_time']) )
                        {
                            $type = POST_CALENDAR;
                        }
            ***/
            if (defined('POST_PICTURE') && !empty($topic_rowset[$i]['topic_pic_url'])) {
                $type = POST_PICTURE;
            }
            $icon = get_icon_title($topic_rowset[$i]['topic_icon'], 1, $type);
        }
        //-- mod : topic description -----------------------------------------------------------------------
        //-- add
        $topic_desc = $topic_rowset[$i]['topic_desc'];
        //-- end mod : topic description -------------------------------------------------------------------
        // send topic to template
        $selected = !empty($select_values) && in_array($topic_rowset[$i]['topic_id'], $select_values);
        $color = !$color;
        $template->assign_block_vars($tpl . '.row', array('ROW_CLASS' => $color || !defined('TOPIC_ALTERNATE_ROW_CLASS') ? 'row1' : 'row2', 'ROW_FOLDER_CLASS' => $user_replied && defined('USER_REPLIED_CLASS') ? USER_REPLIED_CLASS : ($color || !defined('TOPIC_ALTERNATE_ROW_CLASS') ? 'row1' : 'row2'), 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'TOPIC_FOLDER_IMG' => $folder_image, 'TOPIC_AUTHOR' => $topic_author, 'GOTO_PAGE' => !empty($goto_page) ? '<br />' . $goto_page : '', 'TOPIC_NAV_TREE' => !empty($nav_tree) ? (empty($goto_page) ? '<br />' : '') . $nav_tree : '', 'REPLIES' => $replies, 'NEWEST_POST_IMG' => $newest_post_img, 'TOPIC_ATTACHMENT_IMG' => topic_attachment_image($topic_rowset[$i]['topic_attachment']), 'ICON' => $icon, 'TOPIC_TITLE' => $topic_title, 'TOPIC_DESCRIPTION' => $bbcode_parse->smilies_pass($topic_desc), 'L_TOPIC_DESCRIPTION' => $lang['Topic_description'], 'TOPIC_ANNOUNCES_DATES' => $topic_announces_dates, 'TOPIC_CALENDAR_DATES' => $topic_calendar_dates, 'TOPIC_TYPE' => $topic_type, 'VIEWS' => $views, 'FIRST_POST_TIME' => $first_post_time, 'LAST_POST_TIME' => $last_post_time, 'LAST_POST_AUTHOR' => $last_post_author, 'LAST_POST_IMG' => $last_post_url, 'L_TOPIC_FOLDER_ALT' => $folder_alt, 'U_VIEW_TOPIC' => $view_topic_url, 'BOX_ID' => $box_id, 'FID' => $topic_rowset[$i]['topic_id'], 'L_SELECT' => $selected && ($select_multi || $select_unique) ? 'checked="checked"' : ''));
        $template->assign_block_vars($tpl . '.row.topic', array());
        // selection fields
        if ($select_multi) {
            $template->assign_block_vars($tpl . '.row.topic.multi_selection', array());
        }
        if ($select_unique) {
            $template->assign_block_vars($tpl . '.row.topic.single_selection', array());
        }
        // icons
        $template->assign_block_vars($tpl . '.row.topic.icon', array());
        //-- mod : topic description -----------------------------------------------------------------------
        //-- add
        // topic description
        if (!empty($topic_desc)) {
            $template->assign_block_vars($tpl . '.row.topic.switch_topic_desc', array());
        }
        //-- end mod : topic description -------------------------------------------------------------------
        // nav tree asked
        if ($display_nav_tree && !empty($nav_tree)) {
            $template->assign_block_vars($tpl . '.row.topic.nav_tree', array());
        }
    }
    // end for topic_rowset read
    // send a header if missing
    if (!$header_sent) {
        $template->assign_block_vars($tpl . '.row', array('L_TITLE' => $list_title, 'L_REPLIES' => $lang['Replies'], 'L_AUTHOR' => $lang['Author'], 'L_VIEWS' => $lang['Views'], 'L_LASTPOST' => $lang['Last_Post'], 'COLSPAN' => $span_all));
        // open a new box
        $template->assign_block_vars($tpl . '.row.header_table', array('COLSPAN' => $span_left));
    }
    // no data
    if ($topic_rowset_count == 0) {
        // send no topics notice
        $template->assign_block_vars($tpl . '.row', array('L_NO_TOPICS' => $lang['No_search_match'], 'COLSPAN' => $span_all));
        $template->assign_block_vars($tpl . '.row.no_topics', array());
    }
    // bottom line
    if (!empty($footer)) {
        $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all, 'FOOTER' => $footer));
        $template->assign_block_vars($tpl . '.row.bottom', array());
    }
    // table closure
    $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all));
    $template->assign_block_vars($tpl . '.row.footer_table', array());
    // spacing
    if (empty($footer)) {
        // spacing
        $template->assign_block_vars($tpl . '.row', array());
        $template->assign_block_vars($tpl . '.row.spacer', array());
    }
    // transfert to a var
    $template->assign_var_from_handle('_box', $tpl);
    $res = $template->vars['_box'];
    // restore template saved state
    $template->_tpldata = $sav_tpl;
    unset($sav_tpl);
    // Man that would be big :), can be do this elegently.
    // assign value to the main template
    $template->assign_vars(array($box => $res));
}
function get_event_topics(&$events, &$number, $start_date, $end_date, $limit = false, $start = 0, $max_limit = -1, $fid = '')
{
    global $tree, $template, $lang, $images, $user, $db, $cache, $config, $bbcode;
    if (!class_exists('bbcode')) {
        include IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT;
    }
    if (empty($bbcode)) {
        $bbcode = new bbcode();
    }
    // get some parameter
    $topic_title_length = isset($config['calendar_title_length']) ? intval($config['calendar_title_length']) : 30;
    $topic_text_length = isset($config['calendar_text_length']) ? intval($config['calendar_text_length']) : 200;
    if ($max_limit < 0) {
        $max_limit = $config['topics_per_page'];
    }
    // get the forums authorized (compliency with categories hierarchy v2 mod)
    $cat_hierarchy = function_exists(get_auth_keys);
    $s_forums_ids = '';
    if (!$cat_hierarchy) {
        // standard read
        $is_auth = array();
        $is_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $user->data);
        // forum or cat asked
        $is_ask = array();
        if ($fid == 'Root' || $fid == POST_CAT_URL . 0) {
            $fid = '';
        }
        if (!empty($fid)) {
            $type = substr($fid, 0, 1);
            $id = intval(substr($fid, 1));
            if ($type == POST_CAT_URL) {
                $sql = "SELECT forum_id FROM " . FORUMS_TABLE . " WHERE parent_id = '" . $id . "'";
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $is_ask[$row['forum_id']] = true;
                }
                $db->sql_freeresult($result);
            } elseif ($type == POST_FORUM_URL) {
                $is_ask[$id] = true;
            } else {
                return;
            }
        }
        // get the list of authorized forums
        while (list($forum_id, $forum_auth) = each($is_auth)) {
            if ($forum_auth['auth_read'] && (empty($fid) || isset($is_ask[$forum_id]))) {
                $s_forum_ids .= (empty($s_forum_ids) ? '' : ', ') . $forum_id;
            }
        }
    } else {
        if (empty($fid) || $fid == POST_CAT_URL . 0) {
            $fid = 'Root';
        }
        // get auth key
        $keys = array();
        $keys = get_auth_keys($fid, true, -1, -1, 'auth_read');
        for ($i = 0; $i < sizeof($keys['id']); $i++) {
            if ($tree['type'][$keys['idx'][$i]] == POST_FORUM_URL && $tree['auth'][$keys['id'][$i]]['auth_read']) {
                $s_forum_ids .= (empty($s_forum_ids) ? '' : ', ') . $tree['id'][$keys['idx'][$i]];
            }
        }
    }
    // no forums authed, return
    if (empty($s_forum_ids)) {
        return;
    }
    // select topics
    $sql_forums_field = '';
    $sql_forums_file = '';
    $sql_forums_match = '';
    if (!$cat_hierarchy) {
        $sql_forums_field = ', f.forum_name';
        $sql_forums_file = ', ' . FORUMS_TABLE . ' AS f';
        $sql_forums_match = ' AND f.forum_id = t.forum_id';
    }
    $sql = "SELECT\n\t\t\t\t\tt.*,\n\t\t\t\t\tp.poster_id, p.post_username, p.post_text, p.enable_bbcode, p.enable_html, p.enable_smilies,\n\t\t\t\t\tu.username, u.user_active, u.user_color,\n\t\t\t\t\tlp.poster_id AS lp_poster_id,\n\t\t\t\t\tlu.username AS lp_username,\n\t\t\t\t\tlp.post_username AS lp_post_username,\n\t\t\t\t\tlp.post_time AS lp_post_time\n\t\t\t\t\t{$sql_forums_field}\n\t\t\tFROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u, " . POSTS_TABLE . " AS lp, " . USERS_TABLE . " lu {$sql_forums_file}\n\t\t\tWHERE\n\t\t\t\tt.forum_id IN ({$s_forum_ids})\n\t\t\t\tAND p.post_id = t.topic_first_post_id\n\t\t\t\tAND u.user_id = p.poster_id\n\t\t\t\tAND lp.post_id = t.topic_last_post_id\n\t\t\t\tAND lu.user_id = lp.poster_id\n\t\t\t\tAND t.topic_calendar_time < {$end_date}\n\t\t\t\tAND (t.topic_calendar_time + t.topic_calendar_duration) >= {$start_date}\n\t\t\t\tAND t.topic_status <> " . TOPIC_MOVED . "\n\t\t\t\t{$sql_forums_match}\n\t\t\tORDER BY\n\t\t\t\tt.topic_calendar_time, t.topic_calendar_duration DESC, t.topic_last_post_id DESC";
    $result = $db->sql_query($sql);
    // get the number of occurences
    $number = $db->sql_numrows($result);
    // if limit per page asked, limit the number of results
    if ($limit) {
        $db->sql_freeresult($result);
        $sql .= " LIMIT {$start}, {$max_limit}";
        $result = $db->sql_query($sql);
    }
    $bbcode->allow_html = $user->data['user_allowhtml'] && $config['allow_html'] ? 1 : 0;
    $bbcode->allow_bbcode = $user->data['user_allowbbcode'] && $config['allow_bbcode'] ? 1 : 0;
    $bbcode->allow_smilies = $user->data['user_allowsmile'] && $config['allow_smilies'] ? 1 : 0;
    // read the items
    while ($row = $db->sql_fetchrow($result)) {
        // prepare the message
        $topic_author_id = $row['poster_id'];
        $topic_author = $row['poster_id'] == ANONYMOUS ? $row['post_username'] : $row['username'];
        $topic_time = $row['topic_time'];
        $topic_last_author_id = $row['lp_poster_id'];
        $topic_last_author = $row['lp_poster_id'] == ANONYMOUS ? $row['lp_post_username'] : $row['lp_username'];
        $topic_last_time = $row['lp_post_time'];
        $topic_views = $row['topic_views'];
        $topic_replies = $row['topic_replies'];
        $topic_icon = $row['topic_icon'];
        $topic_title = $row['topic_title'];
        $message = htmlspecialchars($row['post_text']);
        $topic_calendar_time = $row['topic_calendar_time'];
        $topic_calendar_duration = $row['topic_calendar_duration'];
        $topic_link = append_sid(IP_ROOT_PATH . CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $row['topic_id']);
        $topic_title = censor_text($topic_title);
        $message = censor_text($message);
        $short_title = strlen($topic_title) > $topic_title_length + 3 ? substr($topic_title, 0, $topic_title_length) . '...' : $topic_title;
        // Convert and clean special chars!
        $topic_title = htmlspecialchars_clean($topic_title);
        $short_title = htmlspecialchars_clean($short_title);
        // SMILEYS IN TITLE - BEGIN
        if ($config['smilies_topic_title'] && !$lofi) {
            $topic_title = $bbcode->parse_only_smilies($topic_title);
            $short_title = $bbcode->parse_only_smilies($short_title);
        }
        // SMILEYS IN TITLE - END
        $dsp_topic_icon = '';
        if (function_exists('get_icon_title')) {
            $dsp_topic_icon = get_icon_title($topic_icon, 0, POST_CALENDAR);
        }
        // parse the message
        $message = substr($message, 0, $topic_text_length);
        // remove HTML if not allowed
        if (!$config['allow_html'] && $row['enable_html']) {
            $message = preg_replace('#(<)([\\/]?.*?)(>)#is', "&lt;\\2&gt;", $message);
        }
        $message = $bbcode->parse($message);
        // get the date format
        $fmt = $lang['DATE_FORMAT_CALENDAR'];
        if (!empty($topic_calendar_duration)) {
            $fmt = $config['default_dateformat'];
        }
        // replace \n with <br />
        //$message = preg_replace("/[\n\r]{1,2}/", '<br />', $message);
        // build the overview
        $sav_tpl = $template->_tpldata;
        $det_handler = '_overview_topic_' . $row['topic_id'];
        $template->set_filenames(array($det_handler => 'calendar_overview_topic.tpl'));
        $nav_desc = '';
        if ($cat_hierarchy) {
            $nav_desc = make_cat_nav_tree(POST_FORUM_URL . $row['forum_id'], '', '', 'gensmall');
        } else {
            $nav_desc = '<a href="' . append_sid(IP_ROOT_PATH . CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $row['forum_id']) . '" class="gensmall">' . $row['forum_name'] . '</a>';
        }
        $template->assign_vars(array('L_CALENDAR_EVENT' => $lang['Calendar_event'], 'L_AUTHOR' => $lang['Author'], 'L_TOPIC_DATE' => $lang['Date'], 'L_FORUM' => $lang['Forum'], 'L_VIEWS' => $lang['Views'], 'L_REPLIES' => $lang['Replies'], 'TOPIC_TITLE' => $dsp_topic_icon . '&nbsp;' . $topic_title, 'CALENDAR_EVENT' => get_calendar_title_date($topic_calendar_time, $topic_calendar_duration), 'AUTHOR' => $topic_author, 'TOPIC_DATE' => create_date($user->data['user_dateformat'], $topic_time, $config['board_timezone']), 'NAV_DESC' => $nav_desc, 'CALENDAR_MESSAGE' => $message, 'VIEWS' => $topic_views, 'REPLIES' => $topic_replies));
        $template->assign_var_from_handle('_calendar_overview', $det_handler);
        $message = $template->_tpldata['.'][0]['_calendar_overview'];
        $template->_tpldata = $sav_tpl;
        // remove \n remaining from the template
        $message = preg_replace("/[\n\r]{1,2}/", '', $message);
        // store only the new values
        $new_row = array();
        $new_row['event_id'] = POST_TOPIC_URL . $row['topic_id'];
        $new_row['event_author_id'] = $topic_author_id;
        $new_row['event_author'] = $topic_author;
        $new_row['event_author_active'] = $row['user_active'];
        $new_row['event_author_color'] = $row['user_color'];
        $new_row['event_time'] = $topic_time;
        $new_row['event_last_author_id'] = $topic_last_author_id;
        $new_row['event_last_author'] = $topic_last_author;
        $new_row['event_last_time'] = $topic_last_time;
        $new_row['event_replies'] = $topic_replies;
        $new_row['event_views'] = $topic_views;
        $new_row['event_type'] = $row['topic_type'];
        $new_row['event_status'] = $row['topic_status'];
        $new_row['event_moved_id'] = $row['topic_moved_id'];
        $new_row['event_last_id'] = $row['topic_last_post_id'];
        $new_row['event_forum_id'] = $row['forum_id'];
        $new_row['event_forum_name'] = $row['forum_name'];
        $new_row['event_icon'] = $topic_icon;
        $new_row['event_title'] = $topic_title;
        $new_row['event_short_title'] = $short_title;
        $new_row['event_message'] = $message;
        $new_row['event_calendar_time'] = $topic_calendar_time;
        $new_row['event_calendar_duration'] = $topic_calendar_duration;
        $new_row['event_link'] = $topic_link;
        $new_row['event_birthday'] = false;
        $new_row['event_txt_class'] = 'genmed';
        $new_row['event_type_icon'] = '<img src="' . $images['icon_tiny_topic'] . '" style="vertical-align: bottom;" alt="" hspace="2" />';
        $events[] = $new_row;
    }
    $db->sql_freeresult($result);
}
function admin_get_nav_cat_desc($cur = '')
{
    global $nav_separator;
    $nav_cat_desc = make_cat_nav_tree($cur, 'admin_forums');
    if (!empty($nav_cat_desc)) {
        $nav_cat_desc = $nav_separator . $nav_cat_desc;
    }
    return $nav_cat_desc;
}
if (isset($HTTP_POST_VARS[POST_FORUM_URL]) || isset($HTTP_GET_VARS[POST_FORUM_URL])) {
    $nav_key = POST_FORUM_URL . (isset($HTTP_POST_VARS[POST_FORUM_URL]) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]));
}
if (isset($HTTP_POST_VARS[POST_TOPIC_URL]) || isset($HTTP_GET_VARS[POST_TOPIC_URL])) {
    $nav_key = POST_TOPIC_URL . (isset($HTTP_POST_VARS[POST_TOPIC_URL]) ? intval($HTTP_POST_VARS[POST_TOPIC_URL]) : intval($HTTP_GET_VARS[POST_TOPIC_URL]));
}
if (isset($HTTP_POST_VARS[POST_POST_URL]) || isset($HTTP_GET_VARS[POST_POST_URL])) {
    $nav_key = POST_POST_URL . (isset($HTTP_POST_VARS[POST_POST_URL]) ? intval($HTTP_POST_VARS[POST_POST_URL]) : intval($HTTP_GET_VARS[POST_POST_URL]));
}
if (empty($nav_key) && (isset($HTTP_POST_VARS['selected_id']) || isset($HTTP_GET_VARS['selected_id']))) {
    $nav_key = isset($HTTP_GET_VARS['selected_id']) ? $HTTP_GET_VARS['selected_id'] : $HTTP_POST_VARS['selected_id'];
}
if (empty($nav_key)) {
    $nav_key = 'Root';
}
$nav_cat_desc = make_cat_nav_tree($nav_key, $nav_pgm, 'nav', $topic_topic_title, $topic_forum_id);
if (!empty($nav_cat_desc)) {
    $nav_cat_desc = $nav_separator . $nav_cat_desc;
}
// send	to template
$template->assign_vars(array('SPACER' => $images['spacer'], 'NAV_SEPARATOR' => $nav_separator, 'NAV_CAT_DESC' => $nav_cat_desc));
//-- fin mod : categories hierarchy	----------------------------------------------------------------
//-- mod : profile cp ------------------------------------------------------------------------------
//-- add
if ($userdata['session_logged_in']) {
    if (empty($gen_simple_header)) {
        $today_year = date('Y', cal_date(time(), $board_config['board_timezone']));
        $today_month = date('m', cal_date(time(), $board_config['board_timezone']));
        $today_day = date('d', cal_date(time(), $board_config['board_timezone']));
        $today = mktime(0, 0, 1, $today_month, $today_day, $today_year);
        $birthday_year = $today_year;
function topic_list($box, $tpl = '', $topic_rowset, $list_title = '', $split_type = false, $display_nav_tree = true, $footer = '', $inbox = true, $select_field = '', $select_type = 0, $select_formname = '', $select_values = array())
{
    global $template, $db, $cache, $config, $user, $lang, $images, $theme;
    global $tree, $bbcode, $user;
    static $box_id;
    // save template state
    $sav_tpl = $template->_tpldata;
    // init
    if (empty($tpl)) {
        $tpl = 'topics_list_box';
    }
    if (empty($list_title)) {
        $list_title = $lang['Topics'];
    }
    if (!empty($select_values) && !is_array($select_values)) {
        $s_values = $select_values;
        $select_values = array();
        $select_values[] = $s_values;
    }
    // selections
    $select_multi = false;
    $select_unique = false;
    if (!empty($select_field) && $select_type > 0 && !empty($select_formname)) {
        switch ($select_type) {
            case 1:
                $select_multi = true;
                break;
            case 2:
                $select_unique = true;
                break;
        }
    }
    // get split params
    $switch_split_global_announce = isset($config['split_global_announce']) && isset($lang['Post_Global_Announcement']) ? intval($config['split_global_announce']) : false;
    $switch_split_announce = isset($config['split_announce']) ? intval($config['split_announce']) : false;
    $switch_split_sticky = isset($config['split_sticky']) ? intval($config['split_sticky']) : false;
    $switch_split_news = isset($config['split_news']) ? intval($config['split_news']) : false;
    // set in separate table
    $split_box = $inbox && (isset($config['split_topic_split']) ? intval($config['split_topic_split']) : false);
    // take care of the context
    if (!$split_type) {
        $split_box = false;
        $switch_split_global_announce = false;
        $switch_split_announce = false;
        $switch_split_sticky = false;
        $switch_split_news = false;
    }
    if (!$switch_split_global_announce && !$switch_split_announce && !$switch_split_sticky && !$switch_split_news) {
        $split_type = false;
        $split_box = false;
    }
    // read the user cookie
    $tracking_forums = isset($_COOKIE[$config['cookie_name'] . '_f']) ? unserialize($_COOKIE[$config['cookie_name'] . '_f']) : array();
    $tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_t']) ? unserialize($_COOKIE[$config['cookie_name'] . '_t']) : array();
    $tracking_all = isset($_COOKIE[$config['cookie_name'] . '_f_all']) ? intval($_COOKIE[$config['cookie_name'] . '_f_all']) : NULL;
    // categories hierarchy v 2 compliancy
    $cat_hierarchy = function_exists('get_auth_keys');
    if (!$cat_hierarchy) {
        // standard read
        $is_auth = array();
        $is_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $user->data);
    }
    // topic icon present
    $icon_installed = function_exists('get_icon_title');
    // get a default title
    if (empty($list_title)) {
        $list_title = $lang['forum'];
    }
    // choose template
    $template->set_filenames(array($tpl => $tpl . '.tpl'));
    // check if user replied to the topic
    $user_topics = array();
    if ($user->data['user_id'] != ANONYMOUS) {
        // get all the topic ids to display
        $topic_ids = array();
        for ($i = 0; $i < sizeof($topic_rowset); $i++) {
            $topic_item_type = substr($topic_rowset[$i]['topic_id'], 0, 1);
            $topic_id = intval(substr($topic_rowset[$i]['topic_id'], 1));
            if ($topic_item_type == POST_TOPIC_URL) {
                $topic_ids[] = $topic_id;
            }
        }
        // check if the user replied to
        if (!empty($topic_ids)) {
            // check the posts
            $s_topic_ids = implode(', ', $topic_ids);
            $sql = "SELECT DISTINCT topic_id FROM " . POSTS_TABLE . "\n\t\t\t\t\tWHERE topic_id IN ({$s_topic_ids})\n\t\t\t\t\t\tAND poster_id = " . $user->data['user_id'];
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $user_topics[POST_TOPIC_URL . $row['topic_id']] = true;
            }
        }
    }
    // initiate
    $template->assign_block_vars($tpl, array('FORMNAME' => $select_formname, 'FIELDNAME' => $select_field));
    // spanning of the first column (list name)
    $span_left = 1;
    if (sizeof($topic_rowset) > 0) {
        // add folder image
        $span_left++;
    }
    if ($icon_installed) {
        // add topic icon
        $span_left++;
    }
    if ($select_unique) {
        // selection in front is asked
        $span_left++;
    }
    // spanning of the whole line (bottom row and/or empty list)
    $span_all = $span_left + 4;
    if ($select_multi && sizeof($topic_rowset) > 0) {
        $span_all++;
    }
    // display topics
    $color = false;
    $prec_topic_type = '';
    $header_sent = false;
    if (!isset($box_id)) {
        $box_id = -1;
    }
    for ($i = 0; $i < sizeof($topic_rowset); $i++) {
        $topic_item_type = substr($topic_rowset[$i]['topic_id'], 0, 1);
        $topic_id = intval(substr($topic_rowset[$i]['topic_id'], 1));
        $topic_title = censor_text($topic_rowset[$i]['topic_title']);
        $replies = $topic_rowset[$i]['topic_replies'];
        $topic_type = $topic_rowset[$i]['topic_type'];
        $user_replied = !empty($user_topics) && isset($user_topics[$topic_rowset[$i]['topic_id']]);
        $force_type_display = false;
        $forum_id = $topic_rowset[$i]['forum_id'];
        if (defined('POST_BIRTHDAY') && $topic_type == POST_BIRTHDAY) {
            $topic_type = $lang['Birthday'] . ': ';
        } elseif ($topic_type == POST_NEWS) {
            $topic_type = $lang['News'] . ': ';
        } elseif ($topic_type == POST_GLOBAL_ANNOUNCE) {
            $topic_type = $lang['Topic_Global_Announcement'] . ' ';
        } elseif ($topic_type == POST_ANNOUNCE) {
            $topic_type = $lang['Topic_Announcement'] . ' ';
        } elseif ($topic_type == POST_STICKY) {
            $topic_type = $lang['Topic_Sticky'] . ' ';
        } else {
            $topic_type = '';
        }
        if (!empty($topic_rowset[$i]['poll_start']) && $topic_rowset[$i]['topic_status'] != TOPIC_MOVED) {
            $topic_type .= $lang['Topic_Poll'] . ' ';
            $force_type_display = true;
        }
        if (defined('POST_BIRTHDAY') && $topic_rowset[$i]['topic_type'] == POST_BIRTHDAY) {
            $folder_image = $images['folder_birthday'];
            $folder_alt = $lang['HAPPY_BIRTHDAY'];
            $newest_post_img = '';
        } elseif ($topic_rowset[$i]['topic_status'] == TOPIC_MOVED) {
            $topic_type = $lang['Topic_Moved'] . ' ';
            $topic_id = $topic_rowset[$i]['topic_moved_id'];
            $folder_image = $images['topic_nor_read'];
            $folder_alt = $lang['Topics_Moved'];
            $newest_post_img = '';
            $force_type_display = true;
        } else {
            /*
            define('USER_REPLIED_ICON', true);
            $user_replied = true;
            */
            if (defined('POST_BIRTHDAY') && $topic_rowset[$i]['topic_type'] == POST_BIRTHDAY) {
                $folder = $images['folder_birthday'];
                $folder_new = $images['folder_birthday'];
            } elseif ($topic_rowset[$i]['topic_type'] == POST_NEWS) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_read_own'] : $images['topic_nor_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_unread_own'] : $images['topic_nor_unread'];
            } elseif ($topic_rowset[$i]['topic_type'] == POST_GLOBAL_ANNOUNCE) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_glo_read_own'] : $images['topic_glo_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_glo_unread_own'] : $images['topic_glo_unread'];
            } elseif ($topic_rowset[$i]['topic_type'] == POST_ANNOUNCE) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_ann_read_own'] : $images['topic_ann_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_ann_unread_own'] : $images['topic_ann_unread'];
            } elseif ($topic_rowset[$i]['topic_type'] == POST_STICKY) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_imp_read_own'] : $images['topic_imp_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_imp_unread_own'] : $images['topic_imp_unread'];
            } elseif ($topic_rowset[$i]['topic_status'] == TOPIC_LOCKED) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_locked_read_own'] : $images['topic_nor_locked_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_locked_unread_own'] : $images['topic_nor_locked_unread'];
            } else {
                if ($replies >= $config['hot_threshold']) {
                    $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_hot_read_own'] : $images['topic_hot_read'];
                    $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_hot_unread_own'] : $images['topic_hot_unread'];
                } else {
                    $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_read_own'] : $images['topic_nor_read'];
                    $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_unread_own'] : $images['topic_nor_unread'];
                }
            }
            $newest_post_img = '';
            if ($user->data['session_logged_in'] && $topic_item_type == POST_TOPIC_URL) {
                // UPI2DB - BEGIN
                if (!$user->data['upi2db_access']) {
                    // UPI2DB - END
                    if ($topic_rowset[$i]['post_time'] > $user->data['user_lastvisit']) {
                        if (!empty($tracking_topics) || !empty($tracking_forums) || !empty($tracking_all)) {
                            $unread_topics = true;
                            if (!empty($tracking_topics[$topic_id])) {
                                if ($tracking_topics[$topic_id] >= $topic_rowset[$i]['post_time']) {
                                    $unread_topics = false;
                                }
                            }
                            if (!empty($tracking_forums[$forum_id])) {
                                if ($tracking_forums[$forum_id] >= $topic_rowset[$i]['post_time']) {
                                    $unread_topics = false;
                                }
                            }
                            if (!empty($tracking_all)) {
                                if ($tracking_all >= $topic_rowset[$i]['post_time']) {
                                    $unread_topics = false;
                                }
                            }
                            if ($unread_topics) {
                                $folder_image = $folder_new;
                                $folder_alt = $lang['New_posts'];
                                $newest_post_img = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . "?" . POST_TOPIC_URL . "={$topic_id}&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" /></a> ';
                            } else {
                                $folder_image = $folder;
                                $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                                $newest_post_img = '';
                            }
                        } else {
                            $folder_image = $folder_new;
                            $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['New_posts'];
                            $newest_post_img = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . "?" . POST_TOPIC_URL . "={$topic_id}&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" /></a> ';
                        }
                    } else {
                        $folder_image = $folder;
                        $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                        $newest_post_img = '';
                    }
                    // UPI2DB - BEGIN
                } else {
                    viewforum_calc_unread($user->data['upi2db_unread'], $topic_id, $topic_rowset, $i, $folder_new, $folder, $folder_alt, $folder_image, $newest_post_img, $upi2db_status);
                }
                // UPI2DB - END
            } else {
                $folder_image = $folder;
                $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                $newest_post_img = '';
            }
        }
        // generate list of page for the topic
        $topic_pagination = generate_topic_pagination($forum_id, $topic_id, $replies);
        $topic_author = '';
        $first_post_time = '';
        $last_post_time = '';
        $last_post_url = '';
        $views = '';
        switch ($topic_item_type) {
            case POST_USERS_URL:
                $view_topic_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id);
                break;
            default:
                $view_topic_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id);
                $topic_author = $topic_rowset[$i]['user_id'] != ANONYMOUS ? '<a href="' . append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $topic_rowset[$i]['user_id']) . '">' : '';
                $topic_author .= $topic_rowset[$i]['user_id'] != ANONYMOUS ? $topic_rowset[$i]['username'] : ($topic_rowset[$i]['post_username'] != '' ? $topic_rowset[$i]['post_username'] : $lang['Guest']);
                $topic_author .= $topic_rowset[$i]['user_id'] != ANONYMOUS ? '</a>' : '';
                $first_post_time = create_date_ip($config['default_dateformat'], $topic_rowset[$i]['topic_time'], $config['board_timezone']);
                $last_post_time = create_date_ip($config['default_dateformat'], $topic_rowset[$i]['post_time'], $config['board_timezone']);
                $last_post_author = $topic_rowset[$i]['id2'] == ANONYMOUS ? $topic_rowset[$i]['post_username2'] != '' ? $topic_rowset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' : '<a href="' . append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $topic_rowset[$i]['id2']) . '">' . $topic_rowset[$i]['user2'] . '</a>';
                $last_post_url = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $topic_rowset[$i]['topic_last_post_id']) . '#p' . $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
                $views = $topic_rowset[$i]['topic_views'];
                // BEGIN cmx_mod
                $news_label = $topic_rowset[$i]['news_id'] > 0 ? $lang['News'] . ':' : '';
                // END cmx_mod
                break;
        }
        // categories hierarchy v 2 compliancy
        $nav_tree = '';
        if ($display_nav_tree && !empty($topic_rowset[$i]['forum_id'])) {
            if ($cat_hierarchy) {
                if ($tree['auth'][POST_FORUM_URL . $topic_rowset[$i]['forum_id']]['tree.auth_view']) {
                    $nav_tree = make_cat_nav_tree(POST_FORUM_URL . $topic_rowset[$i]['forum_id'], '', '', 'gensmall');
                }
            } else {
                if ($is_auth[$topic_rowset[$i]['forum_id']]['auth_view']) {
                    $nav_tree = '<a href="' . append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $topic_rowset[$i]['forum_id']) . '" class="gensmall">' . $topic_rowset[$i]['forum_name'] . '</a>';
                }
            }
        }
        if (!empty($nav_tree)) {
            $nav_tree = '[ ' . $nav_tree . ' ]';
        }
        // get the type for rupture
        $topic_real_type = $topic_rowset[$i]['topic_type'];
        // if no split between global and standard announcement, group them with standard announcement
        if (!$switch_split_global_announce && $topic_real_type == POST_GLOBAL_ANNOUNCE) {
            $topic_real_type = POST_ANNOUNCE;
        }
        // if no split between announce and sticky, group them with sticky
        if (!$switch_split_announce && $topic_real_type == POST_ANNOUNCE) {
            $topic_real_type = POST_NEWS;
        }
        // if no split between news and global announcement, group them with normal
        if (!$switch_split_news && $topic_real_type == POST_NEWS) {
            $topic_real_type = POST_STICKY;
        }
        // if no split between sticky and normal, group them with normal
        if (!$switch_split_sticky && $topic_real_type == POST_STICKY) {
            $topic_real_type = POST_NORMAL;
        }
        // check if rupture
        $rupt = false;
        // split
        if ($i == 0 || $split_type) {
            if ($i == 0) {
                $rupt = true;
            }
            // check the rupt
            if ($prec_topic_type != $topic_real_type) {
                $rupt = true;
            }
        }
        $prec_topic_type = $topic_real_type;
        // header
        if ($rupt) {
            // close the prec box
            if ($split_box && $i != 0) {
                // footer
                $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all));
                // table closure
                $template->assign_block_vars($tpl . '.row.footer_table', array());
                // spacing
                $template->assign_block_vars($tpl . '.row', array());
                $template->assign_block_vars($tpl . '.row.spacer', array());
                // unset header
                $header_sent = false;
            }
            // get box title
            $main_title = $list_title;
            $sub_title = $list_title;
            switch ($topic_real_type) {
                case POST_BIRTHDAY:
                    $sub_title = $lang['Birthday'];
                    break;
                case POST_NEWS:
                    $sub_title = $lang['News'];
                    break;
                case POST_GLOBAL_ANNOUNCE:
                    $sub_title = $lang['Post_Global_Announcement'];
                    break;
                case POST_ANNOUNCE:
                    $sub_title = $lang['Post_Announcement'];
                    break;
                case POST_STICKY:
                    $sub_title = $lang['Post_Sticky'];
                    break;
                case POST_CALENDAR:
                    $sub_title = $lang['Calendar_event'];
                    break;
                case POST_NORMAL:
                    $sub_title = $lang['Topics'];
                    break;
            }
            $template->assign_block_vars($tpl . '.row', array('L_TITLE' => !$split_box ? $main_title : $sub_title, 'L_REPLIES' => $lang['Replies'], 'L_AUTHOR' => $lang['Author'], 'L_VIEWS' => $lang['Views'], 'L_LASTPOST' => $lang['Last_Post'], 'COLSPAN' => $span_all));
            // open a new box
            if ($split_box || $i == 0) {
                $box_id++;
                $template->assign_block_vars($tpl . '.row.header_table', array('COLSPAN' => $span_left, 'BOX_ID' => $box_id));
                // selection fields
                if ($select_multi) {
                    $template->assign_block_vars($tpl . '.row.header_table.multi_selection', array());
                }
                // set header
                $header_sent = true;
            }
            // not in box, send a row title
            if ($split_type && !$split_box) {
                $template->assign_block_vars($tpl . '.row', array('L_TITLE' => $sub_title, 'COLSPAN' => $span_all));
                $template->assign_block_vars($tpl . '.row.header_row', array());
            }
        }
        // erase the type before the title if split
        if ($split_type && $topic_real_type == $topic_rowset[$i]['topic_type'] && !$force_type_display) {
            $topic_type = '';
        }
        // get the announces dates
        $topic_announces_dates = '';
        // get the calendar dates
        $topic_calendar_dates = '';
        if (function_exists(get_calendar_title)) {
            $topic_calendar_dates = get_calendar_title($topic_rowset[$i]['topic_calendar_time'], $topic_rowset[$i]['topic_calendar_duration']);
        }
        // get the topic icons
        $icon = '';
        if ($icon_installed) {
            $type = $topic_rowset[$i]['topic_type'];
            if ($type == POST_NORMAL) {
                if (defined('POST_CALENDAR') && !empty($topic_rowset[$i]['topic_calendar_time'])) {
                    $type = POST_CALENDAR;
                }
                if (defined('POST_PICTURE') && !empty($topic_rowset[$i]['topic_pic_url'])) {
                    $type = POST_PICTURE;
                }
            }
            $icon = get_icon_title($topic_rowset[$i]['topic_icon'], 1, $type);
        }
        // UPI2DB - BEGIN
        if ($user->data['upi2db_access']) {
            $mark_always_read = mark_always_read($topic_rowset[$i]['topic_type'], $topic_id, $forum_id, 'viewforum', 'icon', $user->data['upi2db_unread'], $start, $folder_image);
        } else {
            $mark_always_read = '<img src="' . $folder_image . '" alt="' . $folder_alt . '" title="' . $folder_alt . '" />';
        }
        // UPI2DB - END
        // send topic to template
        $selected = !empty($select_values) && in_array($topic_rowset[$i]['topic_id'], $select_values);
        $color = !$color;
        $template->assign_block_vars($tpl . '.row', array('ROW_CLASS' => $color || !defined('TOPIC_ALTERNATE_ROW_CLASS') ? $theme['td_class1'] : $theme['td_class2'], 'ROW_FOLDER_CLASS' => $user_replied && defined('USER_REPLIED_CLASS') ? USER_REPLIED_CLASS : ($color || !defined('TOPIC_ALTERNATE_ROW_CLASS') ? $theme['td_class1'] : $theme['td_class2']), 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'TOPIC_FOLDER_IMG' => $folder_image, 'TOPIC_AUTHOR' => $topic_author, 'TOPIC_DESCRIPTION' => $topic_desc, 'GOTO_PAGE' => $topic_pagination['base'], 'GOTO_PAGE_FULL' => $topic_pagination['full'], 'TOPIC_NAV_TREE' => !empty($nav_tree) ? (empty($goto_page) ? '<br />' : '') . $nav_tree : '', 'REPLIES' => $replies, 'NEWEST_POST_IMG' => $newest_post_img, 'TOPIC_ATTACHMENT_IMG' => topic_attachment_image($topic_rowset[$i]['topic_attachment']), 'ICON' => $icon, 'TOPIC_TITLE' => $topic_title, 'TOPIC_ANNOUNCES_DATES' => $topic_announces_dates, 'TOPIC_CALENDAR_DATES' => $topic_calendar_dates, 'TOPIC_TYPE' => $topic_type, 'VIEWS' => $views, 'FIRST_POST_TIME' => $first_post_time, 'LAST_POST_TIME' => $last_post_time, 'LAST_POST_AUTHOR' => $last_post_author, 'LAST_POST_IMG' => $last_post_url, 'L_NEWS' => $news_label, 'L_TOPIC_FOLDER_ALT' => $folder_alt, 'U_VIEW_TOPIC' => $view_topic_url, 'BOX_ID' => $box_id, 'FID' => $topic_rowset[$i]['topic_id'], 'U_MARK_ALWAYS_READ' => $mark_always_read, 'L_SELECT' => $selected && ($select_multi || $select_unique) ? 'checked="checked"' : ''));
        $template->assign_block_vars($tpl . '.row.topic', array());
        if (!empty($topic_rowset[$i]['topic_desc']) && $config['show_topic_description']) {
            $template->assign_block_vars($tpl . '.row.topic.switch_topic_desc', array());
        }
        // selection fields
        if ($select_multi) {
            $template->assign_block_vars($tpl . '.row.topic.multi_selection', array());
        }
        if ($select_unique) {
            $template->assign_block_vars($tpl . '.row.topic.single_selection', array());
        }
        // icons
        if ($icon_installed) {
            $template->assign_block_vars($tpl . '.row.topic.icon', array());
        }
        // nav tree asked
        if ($display_nav_tree && !empty($nav_tree)) {
            $template->assign_block_vars($tpl . '.row.topic.nav_tree', array());
        }
    }
    // end for topic_rowset read
    // send an header if missing
    if (!$header_sent) {
        $template->assign_block_vars($tpl . '.row', array('L_TITLE' => $list_title, 'L_REPLIES' => $lang['Replies'], 'L_AUTHOR' => $lang['Author'], 'L_VIEWS' => $lang['Views'], 'L_LASTPOST' => $lang['Last_Post'], 'COLSPAN' => $span_all));
        // open a new box
        $template->assign_block_vars($tpl . '.row.header_table', array('COLSPAN' => $span_left));
    }
    // no data
    if (sizeof($topic_rowset) == 0) {
        // send no topics notice
        $template->assign_block_vars($tpl . '.row', array('L_NO_TOPICS' => $lang['No_search_match'], 'COLSPAN' => $span_all));
        $template->assign_block_vars($tpl . '.row.no_topics', array());
    }
    // bottom line
    if (!empty($footer)) {
        $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all, 'FOOTER' => $footer));
        $template->assign_block_vars($tpl . '.row.bottom', array());
    }
    // table closure
    $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all));
    $template->assign_block_vars($tpl . '.row.footer_table', array());
    // spacing
    if (empty($footer)) {
        // spacing
        $template->assign_block_vars($tpl . '.row', array());
        $template->assign_block_vars($tpl . '.row.spacer', array());
    }
    // transfert to a var
    $template->assign_var_from_handle('_box', $tpl);
    $res = $template->_tpldata['.'][0]['_box'];
    // restore template saved state
    $template->_tpldata = $sav_tpl;
    // assign value to the main template
    $template->assign_vars(array($box => $res));
}
Example #9
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;
}
Example #10
0
function make_cat_nav_tree($cat_id, $with_link)
{
    global $db, $phpEx;
    global $nav_separator, $nav_link_active;
    if ($nav_link_active) {
        $with_link = true;
    }
    $this_cat = "";
    if ($cat_id > 0) {
        $sql = "SELECT * FROM " . CATEGORIES_TABLE . " WHERE cat_id={$cat_id}";
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not query categorie parm ' . $sql, '', __LINE__, __FILE__, $sql);
        }
        if ($catw = $db->sql_fetchrow($result)) {
            $cat_main = $catw['cat_main'];
            $cat_title = $catw['cat_title'];
            $this_cat = $with_link ? '<a href="' . append_sid("index.{$phpEx}?c={$cat_id}") . '" class="nav">' . $cat_title . '</a>' : $cat_title;
            // vérifier si un parent
            if ($cat_main != $cat_id && $cat_main > 0) {
                $this_cat = make_cat_nav_tree($cat_main, true) . $nav_separator . $this_cat;
            }
        }
    }
    return $this_cat;
}
Example #11
0
        $topic_row = $db->sql_fetchrow($result);
        if (!$topic_row) {
            message_die(GENERAL_MESSAGE, 'Forum_not_exist');
        }
        $forum_topics = $topic_row['forum_topics'] == 0 ? 1 : $topic_row['forum_topics'];
        $forum_name = $topic_row['forum_name'];
        // Begin PNphpBB2 Categories Hierarchie Mod
        $cat_id = $topic_row['cat_id'];
        $topic_title = '';
        // End PNphpBB2 Categories Hierarchie Mod
    } else {
        message_die(GENERAL_MESSAGE, 'Forum_not_exist');
    }
}
// Begin PNphpBB2 Categories Hierarchie Mod
$nav_cat_desc = $nav_separator . make_cat_nav_tree($cat_id, true);
$nav_cat_desc .= $nav_separator . '<a href="' . append_sid("viewforum.{$phpEx}?" . POST_FORUM_URL . "={$forum_id}") . '" class="nav">' . $forum_name . '</a>';
if ($topic_title != '') {
    $nav_cat_desc .= $nav_separator . '<a href="' . append_sid("viewtopic.{$phpEx}?" . POST_TOPIC_URL . "={$topic_id}") . '" class="nav">' . $topic_title . '</a>';
}
// End PNphpBB2 Categories Hierarchie Mod
//
// Start session management
//
$userdata = session_pagestart($user_ip, $forum_id);
init_userprefs($userdata);
//
// End session management
//
// session id check
if ($sid == '' || $sid != $userdata['session_id']) {