last post date problem in viewforum

Problems with forum installation, administration, moderation and other phpBB related support.

Moderator: Moderators

last post date problem in viewforum

Postby Jirsh on Wed Jan 10, 2007 10:58 pm

It seems that under the index the last post date is correct but if you go to a forum (viewforum.php) the last post date and time for all is december 31, 1969 @ 6:00pm. Please Help, I am using the latest release.
Jirsh
Registered User
Registered User
 
Posts: 15
Joined: Tue Feb 07, 2006 10:06 pm

Postby PostBot on Fri Jan 12, 2007 11:34 am

Reupload original viewforum.php and maybe includes/functions.php
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby Jirsh on Fri Jan 12, 2007 4:33 pm

Here are the codes...I have alot of mods so I dont want have to start over

http://www.the-gooch.com


viewforum.php

Code: Select all
<?php/*************************************************************************** *                               viewforum.php *                            ------------------- *   begin                : Saturday, Feb 13, 2001 *   copyright            : (C) 2001 The phpBB Group *   email                : support@phpbb.com * *   $Id: viewforum.php,v 1.139.2.12 2004/03/13 15:08:23 acydburn Exp $ * * ***************************************************************************//*************************************************************************** * *   This program is free software; you can redistribute it and/or modify *   it under the terms of the GNU General Public License as published by *   the Free Software Foundation; either version 2 of the License, or *   (at your option) any later version. * ***************************************************************************/define('IN_PHPBB', true);$phpbb_root_path = './';include($phpbb_root_path . 'extension.inc');include($phpbb_root_path . 'common.'.$phpEx);//// Start initial var setup//if ( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) ){    $forum_id = ( isset($HTTP_GET_VARS[POST_FORUM_URL]) ) ? intval($HTTP_GET_VARS[POST_FORUM_URL]) : intval($HTTP_POST_VARS[POST_FORUM_URL]);}else if ( isset($HTTP_GET_VARS['forum'])){    $forum_id = intval($HTTP_GET_VARS['forum']);}else{    $forum_id = '';}$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;$start = ($start < 0) ? 0 : $start;if ( isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) ){    $mark_read = (isset($HTTP_POST_VARS['mark'])) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];}else{    $mark_read = '';}//// End initial var setup////// Check if the user has actually sent a forum ID with his/her request// If not give them a nice error page.//if ( !empty($forum_id) ){    $sql = "SELECT *        FROM " . FORUMS_TABLE . "        WHERE forum_id = $forum_id";    if ( !($result = $db->sql_query($sql)) )    {        message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);    }}else{    message_die(GENERAL_MESSAGE, 'Forum_not_exist');}//// If the query doesn't return any rows this isn't a valid forum. Inform// the user.//if ( !($forum_row = $db->sql_fetchrow($result)) ){    message_die(GENERAL_MESSAGE, 'Forum_not_exist');}//// Start session management//$userdata = session_pagestart($user_ip, $forum_id);init_userprefs($userdata);//// End session management////// Start auth check//$is_auth = array();$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);if ( !$is_auth['auth_read'] || !$is_auth['auth_view'] ){    if ( !$userdata['session_logged_in'] )    {        $redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );        redirect(append_sid("login.$phpEx?redirect=viewforum.$phpEx&$redirect", true));    }    //    // The user is not authed to read this forum ...    //    $message = ( !$is_auth['auth_view'] ) ? $lang['Forum_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);    message_die(GENERAL_MESSAGE, $message);}//// End of auth check////// Handle marking posts//if ( $mark_read == 'topics' ){    // Begin Simple Subforums MOD    $mark_list = ( isset($HTTP_GET_VARS['mark_list']) ) ? explode(',', $HTTP_GET_VARS['mark_list']) : array($forum_id);    $old_forum_id = $forum_id;    // End Simple Subforums MOD    if ( $userdata['session_logged_in'] )    {        $sql = "SELECT MAX(post_time) AS last_post             FROM " . POSTS_TABLE . "             WHERE forum_id = $forum_id";        if ( !($result = $db->sql_query($sql)) )        {            message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);        }        if ( $row = $db->sql_fetchrow($result) )        {            $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();            $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();            if ( ( count($tracking_forums) + count($tracking_topics) ) >= 150 && empty($tracking_forums[$forum_id]) )            {                asort($tracking_forums);                unset($tracking_forums[key($tracking_forums)]);            }            if ( $row['last_post'] > $userdata['user_lastvisit'] )            {                $tracking_forums[$forum_id] = time();                // Begin Simple Subforums MOD                $set_cookie = true;                if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) )                {                    $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f'] = serialize($tracking_forums);                }                // End Simple Subforums MOD            }        }        // Begin Simple Subforums MOD        if( $set_cookie )        {            setcookie($board_config['cookie_name'] . '_f', serialize($tracking_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);        }        $forum_id = $old_forum_id;        // End Simple Subforums MOD        $template->assign_vars(array(            'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">')        );    }    $message = $lang['Topics_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a> ');    message_die(GENERAL_MESSAGE, $message);}//// End handle marking posts//$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : '';$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : '';//// Do the forum Prune//if ( $is_auth['auth_mod'] && $board_config['prune_enable'] ){    if ( $forum_row['prune_next'] < time() && $forum_row['prune_enable'] )    {        include($phpbb_root_path . 'includes/prune.'.$phpEx);        require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);        auto_prune($forum_id);    }}//// End of forum prune////// Obtain list of moderators of each forum// First users, then groups ... broken into two queries//$sql = "SELECT u.user_id, u.username     FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u    WHERE aa.forum_id = $forum_id         AND aa.auth_mod = " . TRUE . "         AND g.group_single_user = 1        AND ug.group_id = aa.group_id         AND g.group_id = aa.group_id         AND u.user_id = ug.user_id     GROUP BY u.user_id, u.username      ORDER BY u.user_id";if ( !($result = $db->sql_query($sql)) ){    message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);}$moderators = array();while( $row = $db->sql_fetchrow($result) ){    $moderators[] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';}$sql = "SELECT g.group_id, g.group_name     FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g     WHERE aa.forum_id = $forum_id        AND aa.auth_mod = " . TRUE . "         AND g.group_single_user = 0        AND g.group_type <> ". GROUP_HIDDEN ."        AND ug.group_id = aa.group_id         AND g.group_id = aa.group_id     GROUP BY g.group_id, g.group_name      ORDER BY g.group_id";if ( !($result = $db->sql_query($sql)) ){    message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);}while( $row = $db->sql_fetchrow($result) ){    $moderators[] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';}    $l_moderators = ( count($moderators) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];$forum_moderators = ( count($moderators) ) ? implode(', ', $moderators) : $lang['None'];unset($moderators);//// Generate a 'Show topics in previous x days' select box. If the topicsdays var is sent// then get it's value, find the number of topics with dates newer than it (to properly// handle pagination) and alter the main query//$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);$previous_days_text = array($lang['All_Topics'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']);if ( !empty($HTTP_POST_VARS['topicdays']) || !empty($HTTP_GET_VARS['topicdays']) ){    $topic_days = ( !empty($HTTP_POST_VARS['topicdays']) ) ? intval($HTTP_POST_VARS['topicdays']) : intval($HTTP_GET_VARS['topicdays']);    $min_topic_time = time() - ($topic_days * 86400);    $sql = "SELECT COUNT(t.topic_id) AS forum_topics         FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p         WHERE t.forum_id = $forum_id             AND p.post_id = t.topic_last_post_id            AND p.post_time >= $min_topic_time";     if ( !($result = $db->sql_query($sql)) )    {        message_die(GENERAL_ERROR, 'Could not obtain limited topics count information', '', __LINE__, __FILE__, $sql);    }    $row = $db->sql_fetchrow($result);    $topics_count = ( $row['forum_topics'] ) ? $row['forum_topics'] : 1;    $limit_topics_time = "AND p.post_time >= $min_topic_time";    if ( !empty($HTTP_POST_VARS['topicdays']) )    {        $start = 0;    }}else{    $topics_count = ( $forum_row['forum_topics'] ) ? $forum_row['forum_topics'] : 1;    $limit_topics_time = '';    $topic_days = 0;}$select_topic_days = '<select name="topicdays">';for($i = 0; $i < count($previous_days); $i++){    $selected = ($topic_days == $previous_days[$i]) ? ' selected="selected"' : '';    $select_topic_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';}$select_topic_days .= '</select>';//// All announcement data, this keeps announcements// on each viewforum page ...//$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username    FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2    WHERE t.forum_id = $forum_id         AND t.topic_poster = u.user_id        AND p.post_id = t.topic_last_post_id        AND p.poster_id = u2.user_id        AND t.topic_type = " . POST_ANNOUNCE . "     ORDER BY t.topic_last_post_id DESC ";if ( !($result = $db->sql_query($sql)) ){   message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);}$topic_rowset = array();$total_announcements = 0;while( $row = $db->sql_fetchrow($result) ){    $topic_rowset[] = $row;    $total_announcements++;}$db->sql_freeresult($result);//// Grab all the basic data (all topics except announcements)// for this forum//$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time     FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2    WHERE t.forum_id = $forum_id        AND t.topic_poster = u.user_id        AND p.post_id = t.topic_first_post_id        AND p2.post_id = t.topic_last_post_id        AND u2.user_id = p2.poster_id         AND t.topic_type <> " . POST_ANNOUNCE . "         $limit_topics_time    ORDER BY t.topic_type DESC, t.topic_last_post_id DESC     LIMIT $start, ".$board_config['topics_per_page'];if ( !($result = $db->sql_query($sql)) ){   message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);}$total_topics = 0;while( $row = $db->sql_fetchrow($result) ){    $topic_rowset[] = $row;    $total_topics++;}$db->sql_freeresult($result);//// Total topics ...//$total_topics += $total_announcements;//// Define censored word matches//$orig_word = array();$replacement_word = array();obtain_word_list($orig_word, $replacement_word);//// Post URL generation for templating vars//$template->assign_vars(array(    'L_DISPLAY_TOPICS' => $lang['Display_topics'],    'U_POST_NEW_TOPIC' => append_sid("posting.$phpEx?mode=newtopic&amp;" . POST_FORUM_URL . "=$forum_id"),    'S_SELECT_TOPIC_DAYS' => $select_topic_days,    'S_POST_DAYS_ACTION' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_id . "&amp;start=$start")));//// User authorisation levels output//$s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />';$s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />';$s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />';$s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />';$s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . '<br />';attach_build_auth_levels($is_auth, $s_auth_can);if ( $is_auth['auth_mod'] ){    $s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;start=" . $start . "&amp;sid=" . $userdata['session_id'] . '">', '</a>');}//// Mozilla navigation bar//$nav_links['up'] = array(    'url' => append_sid('index.'.$phpEx),    'title' => sprintf($lang['Forum_Index'], $board_config['sitename']));//// Dump out the page header and load viewforum template//define('SHOW_ONLINE', true);$page_title = $lang['View_forum'] . ' - ' . $forum_row['forum_name'];include($phpbb_root_path . 'includes/page_header.'.$phpEx);$template->set_filenames(array(    'body' => 'viewforum_body.tpl'));// Begin Simple Subforums MOD$all_forums = array();make_jumpbox_ref('viewforum.'.$phpEx, $forum_id, $all_forums);// End Simple Subforums MOD$template->assign_vars(array(    'FORUM_ID' => $forum_id,    'FORUM_NAME' => $forum_row['forum_name'],    'MODERATORS' => $forum_moderators,    'POST_IMG' => ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'],    'FOLDER_IMG' => $images['folder'],    'FOLDER_NEW_IMG' => $images['folder_new'],    'FOLDER_HOT_IMG' => $images['folder_hot'],    'FOLDER_HOT_NEW_IMG' => $images['folder_hot_new'],    'FOLDER_LOCKED_IMG' => $images['folder_locked'],    'FOLDER_LOCKED_NEW_IMG' => $images['folder_locked_new'],    'FOLDER_STICKY_IMG' => $images['folder_sticky'],    'FOLDER_STICKY_NEW_IMG' => $images['folder_sticky_new'],    'FOLDER_ANNOUNCE_IMG' => $images['folder_announce'],    'FOLDER_ANNOUNCE_NEW_IMG' => $images['folder_announce_new'],    'L_TOPICS' => $lang['Topics'],    'L_REPLIES' => $lang['Replies'],    'L_VIEWS' => $lang['Views'],    'L_POSTS' => $lang['Posts'],    'L_LASTPOST' => $lang['Last_Post'],     'L_MODERATOR' => $l_moderators,     'L_MARK_TOPICS_READ' => $lang['Mark_all_topics'],     'L_POST_NEW_TOPIC' => ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'],     'L_NO_NEW_POSTS' => $lang['No_new_posts'],    'L_NEW_POSTS' => $lang['New_posts'],    'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],     'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],     'L_NO_NEW_POSTS_HOT' => $lang['No_new_posts_hot'],    'L_NEW_POSTS_HOT' => $lang['New_posts_hot'],    'L_ANNOUNCEMENT' => $lang['Post_Announcement'],     'L_STICKY' => $lang['Post_Sticky'],     'L_POSTED' => $lang['Posted'],    'L_JOINED' => $lang['Joined'],    'L_AUTHOR' => $lang['Author'],    'S_AUTH_LIST' => $s_auth_can,     'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL ."=$forum_id"),    'U_MARK_READ' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;mark=topics")));// Begin Simple Subforums MODif( $forum_row['forum_parent'] ){    $parent_id = $forum_row['forum_parent'];    for( $i = 0; $i < count($all_forums); $i++ )    {        if( $all_forums[$i]['forum_id'] == $parent_id )        {            $template->assign_vars(array(                'PARENT_FORUM'            => 1,                'U_VIEW_PARENT_FORUM'    => append_sid("viewforum.$phpEx?" . POST_FORUM_URL .'=' . $all_forums[$i]['forum_id']),                'PARENT_FORUM_NAME'        => $all_forums[$i]['forum_name'],                ));        }    }}else{    $sub_list = array();    for( $i = 0; $i < count($all_forums); $i++ )    {        if( $all_forums[$i]['forum_parent'] == $forum_id )        {            $sub_list[] = $all_forums[$i]['forum_id'];        }    }    if( count($sub_list) )    {        $sub_list[] = $forum_id;        $template->vars['U_MARK_READ'] .= '&amp;mark_list=' . implode(',', $sub_list);    }}// assign additional variables for subforums mod$template->assign_vars(array(    'NUM_TOPICS' => $forum_row['forum_topics'],    'CAN_POST' => $is_auth['auth_post'] ? 1 : 0,    'L_FORUM' => $lang['Forum'],    ));// End Simple Subforums MOD//// End header////// Okay, lets dump out the page ...//if( $total_topics ){    for($i = 0; $i < $total_topics; $i++)    {        $topic_id = $topic_rowset[$i]['topic_id'];        $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'];        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'] . ' ';        }                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 = '';        }        else        {            if( $topic_rowset[$i]['topic_type'] == POST_ANNOUNCE )            {                $folder = $images['folder_announce'];                $folder_new = $images['folder_announce_new'];            }            else if( $topic_rowset[$i]['topic_type'] == POST_STICKY )            {                $folder = $images['folder_sticky'];                $folder_new = $images['folder_sticky_new'];            }            else if( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED )            {                $folder = $images['folder_locked'];                $folder_new = $images['folder_locked_new'];            }            else            {                if($replies >= $board_config['hot_threshold'])                {                    $folder = $images['folder_hot'];                    $folder_new = $images['folder_hot_new'];                }                else                {                    $folder = $images['folder'];                    $folder_new = $images['folder_new'];                }            }            $newest_post_img = '';            if( $userdata['session_logged_in'] )            {                if( $topic_rowset[$i]['post_time'] > $userdata['user_lastvisit'] )                 {                    if( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_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( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )                        {                            if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_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("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_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 = '';            }        }        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 .= ' ] ';        }        else        {            $goto_page = '';        }                $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'], $forum_data[$j]['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'];                $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];        $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];        $template->assign_block_vars('topicrow', array(            'ROW_COLOR' => $row_color,            'ROW_CLASS' => $row_class,            'FORUM_ID' => $forum_id,            'TOPIC_ID' => $topic_id,            'TOPIC_FOLDER_IMG' => $folder_image,             'TOPIC_AUTHOR' => $topic_author,             'GOTO_PAGE' => $goto_page,            'REPLIES' => $replies,            'NEWEST_POST_IMG' => $newest_post_img,             'TOPIC_ATTACHMENT_IMG' => topic_attachment_image($topic_rowset[$i]['topic_attachment']),            'TOPIC_TITLE' => $topic_title,            '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)        );    }    $topics_count -= $total_announcements;    $template->assign_vars(array(        'PAGINATION' => generate_pagination("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start),        'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )),         'L_GOTO_PAGE' => $lang['Goto_page'])    );}else{    //    // No topics    //    $no_topics_msg = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['No_topics_post_one'];    $template->assign_vars(array(        'L_NO_TOPICS' => $no_topics_msg)    );    $template->assign_block_vars('switch_no_topics', array() );}// Begin Simple Subforums MODswitch(SQL_LAYER){    case 'postgresql':        $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id             FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u            WHERE p.post_id = f.forum_last_post_id                 AND u.user_id = p.poster_id                  AND f.forum_parent = '{$forum_id}'                UNION (                    SELECT f.*, NULL, NULL, NULL, NULL                    FROM " . FORUMS_TABLE . " f                    WHERE NOT EXISTS (                        SELECT p.post_time                        FROM " . POSTS_TABLE . " p                        WHERE p.post_id = f.forum_last_post_id                      )                )                ORDER BY cat_id, forum_order";        break;    case 'oracle':        $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id             FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u            WHERE p.post_id = f.forum_last_post_id(+)                AND u.user_id = p.poster_id(+)                AND f.forum_parent = '{$forum_id}'            ORDER BY f.cat_id, f.forum_order";        break;    default:        $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id            FROM (( " . FORUMS_TABLE . " f            LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )            LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )            WHERE f.forum_parent = '{$forum_id}'            ORDER BY f.cat_id, f.forum_order";        break;}if ( !($result = $db->sql_query($sql)) ){    message_die(GENERAL_ERROR, 'Could not query subforums information', '', __LINE__, __FILE__, $sql);}$subforum_data = array();while( $row = $db->sql_fetchrow($result) ){    $subforum_data[] = $row;}$db->sql_freeresult($result);if ( ($total_forums = count($subforum_data)) > 0 ){    //    // Find which forums are visible for this user    //    $is_auth_ary = array();    $is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $subforum_data);    $display_forums = false;    for( $j = 0; $j < $total_forums; $j++ )    {        if ( $is_auth_ary[$subforum_data[$j]['forum_id']]['auth_view'] )        {            $display_forums = true;        }    }        if( !$display_forums )    {        $total_forums = 0;    }}if( $total_forums ){    $template->assign_var('HAS_SUBFORUMS', 1);    $template->assign_block_vars('catrow', array(        'CAT_ID'    => $forum_id,        'CAT_DESC'    => $forum_row['forum_name'],        'U_VIEWCAT' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL ."=$forum_id"),        ));    //    // Obtain a list of topic ids which contain    // posts made since user last visited    //    if ( $userdata['session_logged_in'] )    {        $sql = "SELECT t.forum_id, t.topic_id, p.post_time             FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p             WHERE p.post_id = t.topic_last_post_id                 AND p.post_time > " . $userdata['user_lastvisit'] . "                 AND t.topic_moved_id = 0";         if ( !($result = $db->sql_query($sql)) )        {            message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql);        }        $new_topic_data = array();        while( $topic_data = $db->sql_fetchrow($result) )        {            $new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];        }        $db->sql_freeresult($result);    }    //    // Obtain list of moderators of each forum    // First users, then groups ... broken into two queries    //    $subforum_moderators = array();    $sql = "SELECT aa.forum_id, u.user_id, u.username         FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u        WHERE aa.auth_mod = " . TRUE . "             AND g.group_single_user = 1             AND ug.group_id = aa.group_id             AND g.group_id = aa.group_id             AND u.user_id = ug.user_id         GROUP BY u.user_id, u.username, aa.forum_id         ORDER BY aa.forum_id, u.user_id";    if ( !($result = $db->sql_query($sql, false, true)) )    {        message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);    }    while( $row = $db->sql_fetchrow($result) )    {        $subforum_moderators[$row['forum_id']][] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';    }    $db->sql_freeresult($result);        $sql = "SELECT aa.forum_id, g.group_id, g.group_name         FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g         WHERE aa.auth_mod = " . TRUE . "             AND g.group_single_user = 0             AND g.group_type <> " . GROUP_HIDDEN . "            AND ug.group_id = aa.group_id             AND g.group_id = aa.group_id         GROUP BY g.group_id, g.group_name, aa.forum_id         ORDER BY aa.forum_id, g.group_id";    if ( !($result = $db->sql_query($sql, false, true)) )    {        message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);    }    while( $row = $db->sql_fetchrow($result) )    {        $subforum_moderators[$row['forum_id']][] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' .     $row['group_name'] . '</a>';    }    $db->sql_freeresult($result);    // show subforums    for( $j = 0; $j < $total_forums; $j++ )    {        $subforum_id = $subforum_data[$j]['forum_id'];        if ( $is_auth_ary[$subforum_id]['auth_view'] )        {            $unread_topics = false;            if ( $subforum_data[$j]['forum_status'] == FORUM_LOCKED )            {                $folder_image = $images['forum_locked'];                 $folder_alt = $lang['Forum_locked'];            }            else            {                if ( $userdata['session_logged_in'] )                {                    if ( !empty($new_topic_data[$subforum_id]) )                    {                        $subforum_last_post_time = 0;                        while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$subforum_id]) )                        {                            if ( empty($tracking_topics[$check_topic_id]) )                            {                                $unread_topics = true;                                $subforum_last_post_time = max($check_post_time, $subforum_last_post_time);                            }                            else                            {                                if ( $tracking_topics[$check_topic_id] < $check_post_time )                                {                                    $unread_topics = true;                                    $subforum_last_post_time = max($check_post_time, $subforum_last_post_time);                                }                            }                        }                        if ( !empty($tracking_forums[$subforum_id]) )                        {                            if ( $tracking_forums[$subforum_id] > $subforum_last_post_time )                            {                                $unread_topics = false;                            }                        }                        if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )                        {                            if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $subforum_last_post_time )                            {                                $unread_topics = false;                            }                        }                    }                }                $folder_image = ( $unread_topics ) ? $images['forum_new'] : $images['forum'];                 $folder_alt = ( $unread_topics ) ? $lang['New_posts'] : $lang['No_new_posts'];             }            $posts = $subforum_data[$j]['forum_posts'];            $topics = $subforum_data[$j]['forum_topics'];            if ( $subforum_data[$j]['forum_last_post_id'] )            {                $last_post_time = create_date($board_config['default_dateformat'], $subforum_data[$j]['post_time'], $board_config['board_timezone']);                $last_post = $last_post_time . '<br />';                $last_post .= ( $subforum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($subforum_data[$j]['post_username'] != '' ) ? $subforum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '='  . $subforum_data[$j]['user_id']) . '">' . $subforum_data[$j]['username'] . '</a> ';                                                $last_post .= '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $subforum_data[$j]['forum_last_post_id']) . '#' . $subforum_data[$j]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';            }            else            {                $last_post = $lang['No_Posts'];            }            if ( count($subforum_moderators[$subforum_id]) > 0 )            {                $l_moderators = ( count($subforum_moderators[$subforum_id]) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];                $moderator_list = implode(', ', $subforum_moderators[$subforum_id]);            }            else            {                $l_moderators = '&nbsp;';                $moderator_list = '';            }            $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];            $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];            $template->assign_block_vars('catrow.forumrow',    array(                'ROW_COLOR' => '#' . $row_color,                'ROW_CLASS' => $row_class,                'FORUM_FOLDER_IMG' => $folder_image,                 'FORUM_NAME' => $subforum_data[$j]['forum_name'],                'FORUM_DESC' => $subforum_data[$j]['forum_desc'],                'POSTS' => $subforum_data[$j]['forum_posts'],                'TOPICS' => $subforum_data[$j]['forum_topics'],                'LAST_POST' => $last_post,                'MODERATORS' => $moderator_list,                'ID' => $subforum_data[$j]['forum_id'],                'UNREAD' => intval($unread_topics),                'LAST_POST_TIME' => $last_post_time,                'L_MODERATOR' => $l_moderators,                 'L_FORUM_FOLDER_ALT' => $folder_alt,                 'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$subforum_id"))            );        }    }}// End Simple Subforums MOD//// Parse the page and print//$template->pparse('body');//// Page footer//include($phpbb_root_path . 'includes/page_tail.'.$phpEx);?>

1



includes/functions.php

Code: Select all
<?php
//-- mod : Loewen Enterprise - Donation MOD v1.0.0.1 ----------------------------------------------------
/***************************************************************************
*                               functions.php
*                            -------------------
*   begin                : Saturday, Feb 13, 2001
*   copyright            : (C) 2001 The phpBB Group
*   email                : support@phpbb.com
*
*   $Id: functions.php,v 1.133.2.37 2005/10/30 15:17:14 acydburn Exp $
*
*
***************************************************************************/

/***************************************************************************
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation; either version 2 of the License, or
*   (at your option) any later version.
*
*
***************************************************************************/

function get_db_stat($mode)
{
   global $db;

   switch( $mode )
   {
      case 'usercount':
         $sql = "SELECT COUNT(user_id) AS total
            FROM " . USERS_TABLE . "
            WHERE user_id <> " . ANONYMOUS;
         break;

      case 'newestuser':
         $sql = "SELECT user_id, username
            FROM " . USERS_TABLE . "
            WHERE user_id <> " . ANONYMOUS . "
            ORDER BY user_id DESC
            LIMIT 1";
         break;

      case 'postcount':
      case 'topiccount':
         $sql = "SELECT SUM(forum_topics) AS topic_total, SUM(forum_posts) AS post_total
            FROM " . FORUMS_TABLE;
         break;
   }

   if ( !($result = $db->sql_query($sql)) )
   {
      return false;
   }

   $row = $db->sql_fetchrow($result);

   switch ( $mode )
   {
      case 'usercount':
         return $row['total'];
         break;
      case 'newestuser':
         return $row;
         break;
      case 'postcount':
         return $row['post_total'];
         break;
      case 'topiccount':
         return $row['topic_total'];
         break;
   }

   return false;
}

// added at phpBB 2.0.11 to properly format the username
function phpbb_clean_username($username)
{
   $username = substr(htmlspecialchars(str_replace("\'", "'", trim($username))), 0, 25);
   $username = phpbb_rtrim($username, "\\");
   $username = str_replace("'", "\'", $username);

   return $username;
}

/**
* This function is a wrapper for ltrim, as charlist is only supported in php >= 4.1.0
* Added in phpBB 2.0.18
*/
function phpbb_ltrim($str, $charlist = false)
{
   if ($charlist === false)
   {
      return ltrim($str);
   }

   $php_version = explode('.', PHP_VERSION);

   // php version < 4.1.0
   if ((int) $php_version[0] < 4 || ((int) $php_version[0] == 4 && (int) $php_version[1] < 1))
   {
      while ($str{0} == $charlist)
      {
         $str = substr($str, 1);
      }
   }
   else
   {
      $str = ltrim($str, $charlist);
   }

   return $str;
}
/**
* Our own generator of random values
* This uses a constantly changing value as the base for generating the values
* The board wide setting is updated once per page if this code is called
* With thanks to Anthrax101 for the inspiration on this one
* Added in phpBB 2.0.20
*/
function dss_rand()
{
   global $db, $board_config, $dss_seeded;

   $val = $board_config['rand_seed'] . microtime();
   $val = md5($val);
   $board_config['rand_seed'] = md5($board_config['rand_seed'] . $val . 'a');
   
   if($dss_seeded !== true)
   {
      $sql = "UPDATE " . CONFIG_TABLE . " SET
         config_value = '" . $board_config['rand_seed'] . "'
         WHERE config_name = 'rand_seed'";
      
      if( !$db->sql_query($sql) )
      {
         message_die(GENERAL_ERROR, "Unable to reseed PRNG", "", __LINE__, __FILE__, $sql);
      }

      $dss_seeded = true;
   }

   return substr($val, 4, 16);

}


// added at phpBB 2.0.12 to fix a bug in PHP 4.3.10 (only supporting charlist in php >= 4.1.0)
function phpbb_rtrim($str, $charlist = false)
{
   if ($charlist === false)
   {
      return rtrim($str);
   }
   
   $php_version = explode('.', PHP_VERSION);

   // php version < 4.1.0
   if ((int) $php_version[0] < 4 || ((int) $php_version[0] == 4 && (int) $php_version[1] < 1))
   {
      while ($str{strlen($str)-1} == $charlist)
      {
         $str = substr($str, 0, strlen($str)-1);
      }
   }
   else
   {
      $str = rtrim($str, $charlist);
   }

   return $str;
}

//
// Get Userdata, $user can be username or user_id. If force_str is true, the username will be forced.
//
function get_userdata($user, $force_str = false)
{
   global $db;

   if (!is_numeric($user) || $force_str)
   {
      $user = phpbb_clean_username($user);
   }
   else
   {
      $user = intval($user);
   }

   $sql = "SELECT *
      FROM " . USERS_TABLE . "
      WHERE ";
   $sql .= ( ( is_integer($user) ) ? "user_id = $user" : "username = '" .  str_replace("\'", "''", $user) . "'" ) . " AND user_id <> " . ANONYMOUS;


   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Tried obtaining data for a non-existent user', '', __LINE__, __FILE__, $sql);
   }

   return ( $row = $db->sql_fetchrow($result) ) ? $row : false;
}

function make_jumpbox($action, $match_forum_id = 0)
{
   $list = array();
   return make_jumpbox_ref($action, $match_forum_id, $list);
}

function make_jumpbox_ref($action, $match_forum_id, &$forums_list)
{


   global $template, $userdata, $lang, $db, $nav_links, $phpEx, $SID;

//   $is_auth = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);

   $sql = "SELECT c.cat_id, c.cat_title, c.cat_order
      FROM " . CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f
      WHERE f.cat_id = c.cat_id
      GROUP BY c.cat_id, c.cat_title, c.cat_order
      ORDER BY c.cat_order";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, "Couldn't obtain category list.", "", __LINE__, __FILE__, $sql);
   }
   
   $category_rows = array();
   while ( $row = $db->sql_fetchrow($result) )
   {
      $category_rows[] = $row;
   }

   if ( $total_categories = count($category_rows) )
   {
      $sql = "SELECT *
         FROM " . FORUMS_TABLE . "
         ORDER BY cat_id, forum_order";
      if ( !($result = $db->sql_query($sql)) )
      {
         message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
      }

      $boxstring = '<select name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"><option value="-1">' . $lang['Select_forum'] . '</option>';

      $forum_rows = array();
      while ( $row = $db->sql_fetchrow($result) )
      {
         $forum_rows[] = $row;
         // Begin Simple Subforums MOD
         $forums_list[] = $row;
         // End Simple Subforums MOD


      }

      if ( $total_forums = count($forum_rows) )
      {
         for($i = 0; $i < $total_categories; $i++)
         {
            $boxstring_forums = '';
            for($j = 0; $j < $total_forums; $j++)
            {
               if ( !$forum_rows[$j]['forum_parent'] && $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $forum_rows[$j]['auth_view'] <= AUTH_REG )
               {

//               if ( !$forum_rows[$j]['forum_parent'] && $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $is_auth[$forum_rows[$j]['forum_id']]['auth_view'] )
//               {

                     // Begin Simple Subforums MOD
                     $id = $forum_rows[$j]['forum_id'];
                     // End Simple Subforums MOD


                  $selected = ( $forum_rows[$j]['forum_id'] == $match_forum_id ) ? 'selected="selected"' : '';
                  $boxstring_forums .=  '<option value="' . $forum_rows[$j]['forum_id'] . '"' . $selected . '>' . $forum_rows[$j]['forum_name'] . '</option>';

                  //
                  // Add an array to $nav_links for the Mozilla navigation bar.
                  // 'chapter' and 'forum' can create multiple items, therefore we are using a nested array.
                  //
                  $nav_links['chapter forum'][$forum_rows[$j]['forum_id']] = array (
                     'url' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_rows[$j]['forum_id']),
                     'title' => $forum_rows[$j]['forum_name']
                  );

                  // Begin Simple Subforums MOD
                  for( $k = 0; $k < $total_forums; $k++ )
                  {
                     if ( $forum_rows[$k]['forum_parent'] == $id && $forum_rows[$k]['cat_id'] == $category_rows[$i]['cat_id'] && $forum_rows[$k]['auth_view'] <= AUTH_REG )
                     {
//                     if ( $forum_rows[$k]['forum_parent'] == $id && $forum_rows[$k]['cat_id'] == $category_rows[$i]['cat_id'] && $is_auth[$forum_rows[$k]['forum_id']]['auth_view'] )
//                     {
                        $selected = ( $forum_rows[$k]['forum_id'] == $match_forum_id ) ? 'selected="selected"' : '';
                        $boxstring_forums .=  '<option value="' . $forum_rows[$k]['forum_id'] . '"' . $selected . '>-- ' . $forum_rows[$k]['forum_name'] . '</option>';

                        //
                        // Add an array to $nav_links for the Mozilla navigation bar.
                        // 'chapter' and 'forum' can create multiple items, therefore we are using a nested array.
                        //
                        $nav_links['chapter forum'][$forum_rows[$k]['forum_id']] = array (
                           'url' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_rows[$k]['forum_id']),
                           'title' => $forum_rows[$k]['forum_name']
                        );
                        
                     }
                  }
                  // End Simple Subforums MOD


                        
               }
            }

            if ( $boxstring_forums != '' )
            {
               $boxstring .= '<option value="-1">&nbsp;</option>';
               $boxstring .= '<option value="-1">' . $category_rows[$i]['cat_title'] . '</option>';
               $boxstring .= '<option value="-1">----------------</option>';
               $boxstring .= $boxstring_forums;
            }
         }
      }

      $boxstring .= '</select>';
   }
   else
   {
      $boxstring .= '<select name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"></select>';
   }

   // Let the jumpbox work again in sites having additional session id checks.
//   if ( !empty($SID) )
//   {
      $boxstring .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
//   }

   $template->set_filenames(array(
      'jumpbox' => 'jumpbox.tpl')
   );
   $template->assign_vars(array(
      'L_GO' => $lang['Go'],
      'L_JUMP_TO' => $lang['Jump_to'],
      'L_SELECT_FORUM' => $lang['Select_forum'],

      'S_JUMPBOX_SELECT' => $boxstring,
      'S_JUMPBOX_ACTION' => append_sid($action))
   );
   $template->assign_var_from_handle('JUMPBOX', 'jumpbox');

   return;
}

//
// Initialise user settings on page load
function init_userprefs($userdata)
{
   global $board_config, $theme, $images;
   global $template, $lang, $phpEx, $phpbb_root_path, $db;
   global $nav_links;


   if ( $userdata['user_id'] != ANONYMOUS )
   {
      if ( !empty($userdata['user_lang']))
      {
         $default_lang = phpbb_ltrim(basename(phpbb_rtrim($userdata['user_lang'])), "'");

      }

      if ( !empty($userdata['user_dateformat']) )
      {
         $board_config['default_dateformat'] = $userdata['user_dateformat'];
      }

      if ( isset($userdata['user_timezone']) )
      {
         $board_config['board_timezone'] = $userdata['user_timezone'];
      }
   }

   else
   {
      $default_lang = phpbb_ltrim(basename(phpbb_rtrim($board_config['default_lang'])), "'");
   }

   if ( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $default_lang . '/lang_main.'.$phpEx)) )
   {
      if ( $userdata['user_id'] != ANONYMOUS )
      {
         // For logged in users, try the board default language next
         $default_lang = phpbb_ltrim(basename(phpbb_rtrim($board_config['default_lang'])), "'");
      }
      else
      {
         // For guests it means the default language is not present, try english
         // This is a long shot since it means serious errors in the setup to reach here,
         // but english is part of a new install so it's worth us trying
         $default_lang = 'english';
      }

      if ( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $default_lang . '/lang_main.'.$phpEx)) )
      {
         message_die(CRITICAL_ERROR, 'Could not locate valid language pack');
      }
   }

   // If we've had to change the value in any way then let's write it back to the database
   // before we go any further since it means there is something wrong with it
   if ( $userdata['user_id'] != ANONYMOUS && $userdata['user_lang'] !== $default_lang )
   {
      $sql = 'UPDATE ' . USERS_TABLE . "
         SET user_lang = '" . $default_lang . "'
         WHERE user_lang = '" . $userdata['user_lang'] . "'";

      if ( !($result = $db->sql_query($sql)) )
      {
         message_die(CRITICAL_ERROR, 'Could not update user language info');
      }

      $userdata['user_lang'] = $default_lang;
   }
   elseif ( $userdata['user_id'] === ANONYMOUS && $board_config['default_lang'] !== $default_lang )
   {
      $sql = 'UPDATE ' . CONFIG_TABLE . "
         SET config_value = '" . $default_lang . "'
         WHERE config_name = 'default_lang'";

      if ( !($result = $db->sql_query($sql)) )
      {
         message_die(CRITICAL_ERROR, 'Could not update user language info');
      }
   }

   $board_config['default_lang'] = $default_lang;



   include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx);


//
// MOD Load Calendar Language File
//
   if ( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_calendar.'.$phpEx)) )
   {
      $board_config['default_lang'] = 'english';
   }

   include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_calendar.' . $phpEx);

// End MOD



   if ( defined('IN_ADMIN') )
   {
      if( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.'.$phpEx)) )
      {
         $board_config['default_lang'] = 'english';
      }

      include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx);
   }

   include_attach_lang();

   //
   // Set up style
   //
   if ( !$board_config['override_user_style'] )
   {
      if ( $userdata['user_id'] != ANONYMOUS && $userdata['user_style'] > 0 )
      {
         if ( $theme = setup_style($userdata['user_style']) )
         {
            return;
         }
      }
   }

   $theme = setup_style($board_config['default_style']);

   //
   // 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($phpbb_root_path . 'index.' . $phpEx),
      'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
   );
   $nav_links['search'] = array (
      'url' => append_sid($phpbb_root_path . 'search.' . $phpEx),
      'title' => $lang['Search']
   );
   $nav_links['help'] = array (
      'url' => append_sid($phpbb_root_path . 'faq.' . $phpEx),
      'title' => $lang['FAQ']
   );
   $nav_links['author'] = array (
      'url' => append_sid($phpbb_root_path . 'memberlist.' . $phpEx),
      'title' => $lang['Memberlist']
   );

   return;
}

function setup_style($style)
{
   global $db, $board_config, $template, $images, $phpbb_root_path;

   $sql = 'SELECT *
      FROM ' . THEMES_TABLE . '
      WHERE themes_id = ' . (int) $style;

   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(CRITICAL_ERROR, 'Could not query database for theme info');
   }

   if ( !($row = $db->sql_fetchrow($result)) )
   {
      // We are trying to setup a style which does not exist in the database
      // Try to fallback to the board default (if the user had a custom style)
      // and then any users using this style to the default if it succeeds
      if ( $style != $board_config['default_style'])
      {
         $sql = 'SELECT *
            FROM ' . THEMES_TABLE . '
            WHERE themes_id = ' . (int) $board_config['default_style'];

         if ( !($result = $db->sql_query($sql)) )
         {
            message_die(CRITICAL_ERROR, 'Could not query database for theme info');
         }

         if ( $row = $db->sql_fetchrow($result) )
         {
            $db->sql_freeresult($result);

            $sql = 'UPDATE ' . USERS_TABLE . '
               SET user_style = ' . (int) $board_config['default_style'] . "

               WHERE user_style = $style";
            if ( !($result = $db->sql_query($sql)) )
            {
               message_die(CRITICAL_ERROR, 'Could not update user theme info');
            }
         }
         else
         {
            message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [$style]");
         }
      }
      else
      {
         message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [$style]");
      }

   }

   $template_path = 'templates/' ;
   $template_name = $row['template_name'] ;

   $template = new Template($phpbb_root_path . $template_path . $template_name);

   if ( $template )
   {
      $current_template_path = $template_path . $template_name;
      @include($phpbb_root_path . $template_path . $template_name . '/' . $template_name . '.cfg');

      if ( !defined('TEMPLATE_CONFIG') )
      {
         message_die(CRITICAL_ERROR, "Could not open $template_name template config file", '', __LINE__, __FILE__);
      }

      $img_lang = ( file_exists(@phpbb_realpath($phpbb_root_path . $current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english';

      while( list($key, $value) = @each($images) )
      {
         if ( !is_array($value) )
         {
            $images[$key] = str_replace('{LANG}', 'lang_' . $img_lang, $value);
         }
      }
   }

   return $row;
}

function encode_ip($dotquad_ip)
{
   $ip_sep = explode('.', $dotquad_ip);
   return sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]);
}

function decode_ip($int_ip)
{
   $hexipbang = explode('.', chunk_split($int_ip, 2, '.'));
   return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]);
}

//
// Create date/time from format and timezone
//
function create_date($format, $gmepoch, $tz)
{
   global $board_config, $lang;
   static $translate;

   if ( empty($translate) && $board_config['default_lang'] != 'english' )
   {
      @reset($lang['datetime']);
      while ( list($match, $replace) = @each($lang['datetime']) )
      {
         $translate[$match] = $replace;
      }
   }

   return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz));
}

//
// Pagination routine, generates
// page number sequence
//
function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE)
{
   global $lang;

   $total_pages = ceil($num_items/$per_page);

   if ( $total_pages == 1 )
   {
      return '';
   }

   $on_page = floor($start_item / $per_page) + 1;

   $page_string = '';
   if ( $total_pages > 10 )
   {
      $init_page_max = ( $total_pages > 3 ) ? 3 : $total_pages;

      for($i = 1; $i < $init_page_max + 1; $i++)
      {
         $page_string .= ( $i == $on_page ) ? '<b>' . $i . '</b>' : '<a href="' . append_sid($base_url . "&amp;start=" . ( ( $i - 1 ) * $per_page ) ) . '">' . $i . '</a>';
         if ( $i <  $init_page_max )
         {
            $page_string .= ", ";
         }
      }

      if ( $total_pages > 3 )
      {
         if ( $on_page > 1  && $on_page < $total_pages )
         {
            $page_string .= ( $on_page > 5 ) ? ' ... ' : ', ';

            $init_page_min = ( $on_page > 4 ) ? $on_page : 5;
            $init_page_max = ( $on_page < $total_pages - 4 ) ? $on_page : $total_pages - 4;

            for($i = $init_page_min - 1; $i < $init_page_max + 2; $i++)
            {
               $page_string .= ($i == $on_page) ? '<b>' . $i . '</b>' : '<a href="' . append_sid($base_url . "&amp;start=" . ( ( $i - 1 ) * $per_page ) ) . '">' . $i . '</a>';
               if ( $i <  $init_page_max + 1 )
               {
                  $page_string .= ', ';
               }
            }

            $page_string .= ( $on_page < $total_pages - 4 ) ? ' ... ' : ', ';
         }
         else
         {
            $page_string .= ' ... ';
         }

         for($i = $total_pages - 2; $i < $total_pages + 1; $i++)
         {
            $page_string .= ( $i == $on_page ) ? '<b>' . $i . '</b>'  : '<a href="' . append_sid($base_url . "&amp;start=" . ( ( $i - 1 ) * $per_page ) ) . '">' . $i . '</a>';
            if( $i <  $total_pages )
            {
               $page_string .= ", ";
            }
         }
      }
   }
   else
   {
      for($i = 1; $i < $total_pages + 1; $i++)
      {
         $page_string .= ( $i == $on_page ) ? '<b>' . $i . '</b>' : '<a href="' . append_sid($base_url . "&amp;start=" . ( ( $i - 1 ) * $per_page ) ) . '">' . $i . '</a>';
         if ( $i <  $total_pages )
         {
            $page_string .= ', ';
         }
      }
   }

   if ( $add_prevnext_text )
   {
      if ( $on_page > 1 )
      {
         $page_string = ' <a href="' . append_sid($base_url . "&amp;start=" . ( ( $on_page - 2 ) * $per_page ) ) . '">' . $lang['Previous'] . '</a>&nbsp;&nbsp;' . $page_string;
      }

      if ( $on_page < $total_pages )
      {
         $page_string .= '&nbsp;&nbsp;<a href="' . append_sid($base_url . "&amp;start=" . ( $on_page * $per_page ) ) . '">' . $lang['Next'] . '</a>';
      }

   }

   $page_string = $lang['Goto_page'] . ' ' . $page_string;

   return $page_string;
}

//
// This does exactly what preg_quote() does in PHP 4-ish
// If you just need the 1-parameter preg_quote call, then don't bother using this.
//
function phpbb_preg_quote($str, $delimiter)
{
   $text = preg_quote($str);
   $text = str_replace($delimiter, '\\' . $delimiter, $text);
   
   return $text;
}

//
// Obtain list of naughty words and build preg style replacement arrays for use by the
// calling script, note that the vars are passed as references this just makes it easier
// to return both sets of arrays
//
function obtain_word_list(&$orig_word, &$replacement_word)
{
   global $db;

   //
   // Define censored word matches
   //
   $sql = "SELECT word, replacement
      FROM  " . WORDS_TABLE;
   if( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not get censored words from database', '', __LINE__, __FILE__, $sql);
   }

   if ( $row = $db->sql_fetchrow($result) )
   {
      do
      {
         $orig_word[] = '#\b(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')\b#i';
         $replacement_word[] = $row['replacement'];
      }
      while ( $row = $db->sql_fetchrow($result) );
   }

   return true;
}

//
// This is general replacement for die(), allows templated
// output in users (or default) language, etc.
//
// $msg_code can be one of these constants:
//
// GENERAL_MESSAGE : Use for any simple text message, eg. results
// of an operation, authorisation failures, etc.
//
// GENERAL ERROR : Use for any error which occurs _AFTER_ the
// common.php include and session code, ie. most errors in
// pages/functions
//
// CRITICAL_MESSAGE : Used when basic config data is available but
// a session may not exist, eg. banned users
//
// CRITICAL_ERROR : Used when config data cannot be obtained, eg
// no database connection. Should _not_ be used in 99.5% of cases
//
function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '')
{
   global $db, $template, $board_config, $theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $gen_simple_header, $images;
   global $userdata, $user_ip, $session_length;
   global $starttime;

   if(defined('HAS_DIED'))
   {
      die("message_die() was called multiple times. This isn't supposed to happen. Was message_die() used in page_tail.php?");
   }
   
   define('HAS_DIED', 1);
   

   $sql_store = $sql;
   
   //
   // Get SQL error if we are debugging. Do this as soon as possible to prevent
   // subsequent queries from overwriting the status of sql_error()
   //
   if ( DEBUG && ( $msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR ) )
   {
      $sql_error = $db->sql_error();

      $debug_text = '';

      if ( $sql_error['message'] != '' )
      {
         $debug_text .= '<br /><br />SQL Error : ' . $sql_error['code'] . ' ' . $sql_error['message'];
      }

      if ( $sql_store != '' )
      {
         $debug_text .= "<br /><br />$sql_store";
      }

      if ( $err_line != '' && $err_file != '' )
      {
         $debug_text .= '<br /><br />Line : ' . $err_line . '<br />File : ' . basename($err_file);

      }
   }

   if( empty($userdata) && ( $msg_code == GENERAL_MESSAGE || $msg_code == GENERAL_ERROR ) )
   {
      $userdata = session_pagestart($user_ip, PAGE_INDEX);
      init_userprefs($userdata);
   }

   //
   // If the header hasn't been output then do it
   //
   if ( !defined('HEADER_INC') && $msg_code != CRITICAL_ERROR )
   {
      if ( empty($lang) )
      {
         if ( !empty($board_config['default_lang']) )
         {
            include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx);
         }
         else
         {
            include($phpbb_root_path . 'language/lang_english/lang_main.'.$phpEx);
         }
      }

      if ( empty($template) || empty($theme) )

      {
         $theme = setup_style($board_config['default_style']);
      }

      //
      // Load the Page Header
      //
      if ( !defined('IN_ADMIN') )
      {
         include($phpbb_root_path . 'includes/page_header.'.$phpEx);
      }
      else
      {
         include($phpbb_root_path . 'admin/page_header_admin.'.$phpEx);
      }
   }

   switch($msg_code)
   {
      case GENERAL_MESSAGE:
         if ( $msg_title == '' )
         {
            $msg_title = $lang['Information'];
         }
         break;

      case CRITICAL_MESSAGE:
         if ( $msg_title == '' )
         {
            $msg_title = $lang['Critical_Information'];
         }
         break;

      case GENERAL_ERROR:
         if ( $msg_text == '' )
         {
            $msg_text = $lang['An_error_occured'];
         }

         if ( $msg_title == '' )
         {
            $msg_title = $lang['General_Error'];
         }
         break;

      case CRITICAL_ERROR:
         //
         // Critical errors mean we cannot rely on _ANY_ DB information being
         // available so we're going to dump out a simple echo'd statement
         //
         include($phpbb_root_path . 'language/lang_english/lang_main.'.$phpEx);

         if ( $msg_text == '' )
         {
            $msg_text = $lang['A_critical_error'];
         }

         if ( $msg_title == '' )
         {
            $msg_title = 'phpBB : <b>' . $lang['Critical_Error'] . '</b>';
         }
         break;
   }

   //
   // Add on DEBUG info if we've enabled debug mode and this is an error. This
   // prevents debug info being output for general messages should DEBUG be
   // set TRUE by accident (preventing confusion for the end user!)
   //
   if ( DEBUG && ( $msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR ) )
   {
      if ( $debug_text != '' )
      {
         $msg_text = $msg_text . '<br /><br /><b><u>DEBUG MODE</u></b>' . $debug_text;
      }
   }

   if ( $msg_code != CRITICAL_ERROR )
   {
      if ( !empty($lang[$msg_text]) )
      {
         $msg_text = $lang[$msg_text];
      }

      if ( !defined('IN_ADMIN') )
      {
         $template->set_filenames(array(
            'message_body' => 'message_body.tpl')
         );
      }
      else
      {
         $template->set_filenames(array(
            'message_body' => 'admin/admin_message_body.tpl')
         );
      }

      $template->assign_vars(array(
         'MESSAGE_TITLE' => $msg_title,
         'MESSAGE_TEXT' => $msg_text)
      );
      $template->pparse('message_body');

      if ( !defined('IN_ADMIN') )
      {
         include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
      }
      else
      {
         include($phpbb_root_path . 'admin/page_footer_admin.'.$phpEx);
      }
   }
   else
   {
      echo "<html>\n<body>\n" . $msg_title . "\n<br /><br />\n" . $msg_text . "</body>\n</html>";
   }

   exit;
}

//
// This function is for compatibility with PHP 4.x's realpath()
// function.  In later versions of PHP, it needs to be called
// to do checks with some functions.  Older versions of PHP don't
// seem to need this, so we'll just return the original value.
// dougk_ff7 <October 5, 2002>
function phpbb_realpath($path)
{
   global $phpbb_root_path, $phpEx;

   return (!@function_exists('realpath') || !@realpath($phpbb_root_path . 'includes/functions.'.$phpEx)) ? $path : @realpath($path);
}

function redirect($url)
{
   global $db, $board_config;

   if (!empty($db))
   {
      $db->sql_close();
   }

   if (strstr(urldecode($url), "\n") || strstr(urldecode($url), "\r") || strstr(urldecode($url), ';url'))

   {
      message_die(GENERAL_ERROR, 'Tried to redirect to potentially insecure url.');
   }

   $server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
   $server_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($board_config['server_name']));
   $server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) : '';
   $script_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($board_config['script_path']));
   $script_name = ($script_name == '') ? $script_name : '/' . $script_name;
   $url = preg_replace('#^\/?(.*?)\/?$#', '/\1', trim($url));

   // Redirect via an HTML form for PITA webservers
   if (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')))
   {
      header('Refresh: 0; URL=' . $server_protocol . $server_name . $server_port . $script_name . $url);
      echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="refresh" content="0; url=' . $server_protocol . $server_name . $server_port . $script_name . $url . '"><title>Redirect</title></head><body><div align="center">If your browser does not support meta redirection please click <a href="' . $server_protocol . $server_name . $server_port . $script_name . $url . '">HERE</a> to be redirected</div></body></html>';
      exit;
   }

   // Behave as per HTTP/1.1 spec for others
   header('Location: ' . $server_protocol . $server_name . $server_port . $script_name . $url);
   exit;
}

#======================================================================= |
#==== Start: == Activity Mod Plus ====================================== |
#==== v1.1.0 =========================================================== |
#====
function UpdateTrophyStats()
   {
   global $db, $table_prefix;
      
   $q = "UPDATE ". USERS_TABLE ."
        SET user_trophies = '0'
        WHERE user_trophies <> '0'";
   $r = $db -> sql_query($q);
         
   $q = "SELECT player
         FROM ". $table_prefix ."ina_top_scores
        GROUP BY player";
   $r          = $db -> sql_query($q);
   while($row    = $db -> sql_fetchrow($r))
      {
   $who      = $row['player'];
   
   $q1 = "SELECT COUNT(*) AS trophies
          FROM ". $table_prefix ."ina_top_scores
         WHERE player = '$who'
         GROUP BY player";
   $r1      = $db -> sql_query($q1);
   $row    = $db -> sql_fetchrow($r1);
   $total_trophies   = $row['trophies'];   

   $q2 = "UPDATE ". USERS_TABLE ."
         SET user_trophies = '$total_trophies'
         WHERE user_id = '$who'";
   $r2 = $db -> sql_query($q2);
      }
   return;
   }

function CheckGamesDeletion()
   {
   global $db, $table_prefix, $board_config;
   
   $q = "SELECT config_value
         FROM ". CONFIG_TABLE ."
        WHERE config_name = 'current_ina_date'";
   $r      = $db -> sql_query($q);
   $row    = $db -> sql_fetchrow($r);
   
   $next_deletion    = $row['config_value'];
   $explode_it      = explode("-", $next_deletion);
   $d_month      = $explode_it[1];
   $t_date         = date("Y-m-d");
   $x_date         = explode("-", $t_date);
   $c_month      = $x_date[1];
   
   if($d_month == $c_month){
   }
   else
   {
   if($board_config['ina_delete'] == "1")
      {
   $q    = "TRUNCATE ". iNA_SCORES ."";
   $r   = $db -> sql_query($q);

   $q    = "TRUNCATE ". $table_prefix ."ina_trophy_comments";
   $r   = $db -> sql_query($q);

   $q    = "UPDATE ". CONFIG_TABLE ."
         SET config_value = '$t_date'
         WHERE config_name = 'current_ina_date'";
   $r   = $db -> sql_query($q);
      }         
   }
   return;
   }
#====
#==== Author: aUsTiN [austin@phpbb-amod.com] [http://phpbb-amod.com] === |
#==== End: ==== Activity Mod Plus ====================================== |   
#======================================================================= |


// Add function mkrealdate for Birthday MOD
// the originate php "mktime()", does not work proberly on all OS, especially when going back in time
// before year 1970 (year 0), this function "mkrealtime()", has a mutch larger valid date range,
// from 1901 - 2099. it returns a "like" UNIX timestamp divided by 86400, so
// calculation from the originate php date and mktime is easy.
// mkrealdate, returns the number of day (with sign) from 1.1.1970.

function mkrealdate($day,$month,$birth_year)
{
   // range check months
   if ($month<1 || $month>12) return "error";
   // range check days
   switch ($month)
   {
      case 1: if ($day>31) return "error";break;
      case 2: if ($day>29) return "error";
         $epoch=$epoch+31;break;
      case 3: if ($day>31) return "error";
         $epoch=$epoch+59;break;
      case 4: if ($day>30) return "error" ;
         $epoch=$epoch+90;break;
      case 5: if ($day>31) return "error";
         $epoch=$epoch+120;break;
      case 6: if ($day>30) return "error";
         $epoch=$epoch+151;break;
      case 7: if ($day>31) return "error";
         $epoch=$epoch+181;break;
      case 8: if ($day>31) return "error";
         $epoch=$epoch+212;break;
      case 9: if ($day>30) return "error";
         $epoch=$epoch+243;break;
      case 10: if ($day>31) return "error";
         $epoch=$epoch+273;break;
      case 11: if ($day>30) return "error";
         $epoch=$epoch+304;break;
      case 12: if ($day>31) return "error";
         $epoch=$epoch+334;break;
   }
   $epoch=$epoch+$day;
   $epoch_Y=sqrt(($birth_year-1970)*($birth_year-1970));
   $leapyear=round((($epoch_Y+2) / 4)-.5);
   if (($epoch_Y+2)%4==0)
   {// curent year is leapyear
      $leapyear--;
      if ($birth_year >1970 && $month>=3) $epoch=$epoch+1;
      if ($birth_year <1970 && $month<3) $epoch=$epoch-1;
   } else if ($month==2 && $day>28) return "error";//only 28 days in feb.
   //year
   if ($birth_year>1970)
      $epoch=$epoch+$epoch_Y*365-1+$leapyear;
   else
      $epoch=$epoch-$epoch_Y*365-1-$leapyear;
   return $epoch;
}

// Add function realdate for Birthday MOD
// the originate php "date()", does not work proberly on all OS, especially when going back in time
// before year 1970 (year 0), this function "realdate()", has a mutch larger valid date range,
// from 1901 - 2099. it returns a "like" UNIX date format (only date, related letters may be used, due to the fact that
// the given date value should already be divided by 86400 - leaving no time information left)
// a input like a UNIX timestamp divided by 86400 is expected, so
// calculation from the originate php date and mktime is easy.
// e.g. realdate ("m d Y", 3) returns the string "1 3 1970"

// UNIX users should replace this function with the below code, since this should be faster
//
//function realdate($date_syntax="Ymd",$date=0)
//{ return create_date($date_syntax,$date*86400+1,0); }

function realdate($date_syntax="Ymd",$date=0)
{
   global $lang;
   $i=2;
   if ($date>=0)
   {
       return create_date($date_syntax,$date*86400+1,0);
   } else
   {
      $year= -(date%1461);
      $days = $date + $year*1461;
      while ($days<0)
      {
         $year--;
         $days+=365;
         if ($i++==3)
         {
            $i=0;
            $days++;
         }
      }
   }
   $leap_year = ($i==0) ? TRUE : FALSE;
   $months_array = ($i==0) ?
      array (0,31,60,91,121,152,182,213,244,274,305,335,366) :
      array (0,31,59,90,120,151,181,212,243,273,304,334,365);
   for ($month=1;$month<12;$month++)
   {
      if ($days<$months_array[$month]) break;
   }

   $day=$days-$months_array[$month-1]+1;
   //you may gain speed performance by remove som of the below entry's if they are not needed/used
   return strtr ($date_syntax, array(
      'a' => '',
      'A' => '',
      '\\d' => 'd',
      'd' => ($day>9) ? $day : '0'.$day,
      '\\D' => 'D',
      'D' => $lang['day_short'][($date-3)%7],
      '\\F' => 'F',
      'F' => $lang['month_long'][$month-1],
      'g' => '',
      'G' => '',
      'H' => '',
      'h' => '',
      'i' => '',
      'I' => '',
      '\\j' => 'j',
      'j' => $day,
      '\\l' => 'l',
      'l' => $lang['day_long'][($date-3)%7],
      '\\L' => 'L',
      'L' => $leap_year,
      '\\m' => 'm',
      'm' => ($month>9) ? $month : '0'.$month,
      '\\M' => 'M',
      'M' => $lang['month_short'][$month-1],
      '\\n' => 'n',
      'n' => $month,
      'O' => '',
      's' => '',
      'S' => '',
      '\\t' => 't',
      't' => $months_array[$month]-$months_array[$month-1],
      'w' => '',
      '\\y' => 'y',
      'y' => ($year>29) ? $year-30 : $year+70,
      '\\Y' => 'Y',
      'Y' => $year+1970,
      '\\z' => 'z',
      'z' => $days,
      '\\W' => '',
      'W' => '') );
}
// End add - Birthday MOD

//-- mod : Loewen Enterprise - Donation MOD v1.0.0.1 ----------------------------------------------------
//-- add
function last_donors()
{
   global $db, $phpEx, $theme, $lang, $board_config;
   // Show All
   $count = 0;
   $sql = "SELECT COUNT(*) FROM " . ACCT_HIST_TABLE . " WHERE comment LIKE 'donate from%' GROUP BY user_id";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not query forum donors information', '', __LINE__, __FILE__, $sql);
   }
   if($row = $db->sql_fetchrow($result))
   {
      $count = $row['COUNT(*)'];      
   }
   
   $orderby = "ORDER BY date DESC";
   $selectcolums = "MAX(a.lw_date) as date, SUM(a.lw_money) as lw_money, a.MNY_CURRENCY, u.*";
   if(intval($board_config['list_top_donors']) == 1)
   {
      $orderby = "ORDER BY lw_money DESC";
      $selectcolums = "SUM(a.lw_money) as lw_money, MAX(a.lw_date) as date, a.MNY_CURRENCY, u.*";
   }   
   
   $str_input = intval($board_config['dislay_x_donors']);
      
   $sql = "SELECT $selectcolums from " . ACCT_HIST_TABLE . " a, " . USERS_TABLE . " u where a.comment like 'donate from%' AND u.user_id = a.user_id group by a.user_id"
       .  " $orderby LIMIT $str_input";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not query forum donors information', '', __LINE__, __FILE__, $sql);
   }
   $last_donors = '';

   while( $row = $db->sql_fetchrow($result) )
   {
            $style_color = '';
            if ( $row['user_level'] == ADMIN )
            {
               $row['username'] = '<b>' . $row['username'] . '</b>';
               $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
            }
            else if ( $row['user_level'] == MOD )
            {
               $row['username'] = '<b>' . $row['username'] . '</b>';
               $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
            }
      if($row['user_id'] == ANONYMOUS)
      {
         $last_donors .= '<b>' . $lang['LW_ANONYMOUS_DONOR'] . '</b>(' . $row['MNY_CURRENCY'] . sprintf("%.2f", $row['lw_money']) . '), ';
      }
      else
      {
         $last_donors .= '<b><a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a></b>(' . $row['MNY_CURRENCY'] . sprintf("%.2f", $row['lw_money']) . '), ';
      }
   }
   if($count > $str_input)
   {
      $last_donors .= '<a href="' . append_sid("lwdonors.$phpEx?mode=viewall") . '"' . $style_color .'>' . $lang['LW_MORE_DONORS'] . '</a>';
   }
   if($count == 0)
   {
      $last_donors = $lang['LW_NO_DONORS_YET'];
   }
  return $last_donors;
}
//-- fin mod : Loewen Enterprise - Donation MOD v1.0.0.1 ----------------------------------------------------
//-- mod : Loewen Enterprise - Donation MOD v1.0.2 ----------------------------------------------------
//-- add
   function lw_cal_cash_exchange_rate($currency, $configuration)
   {

      $convertor = 1.0;
      if(strcasecmp($currency, 'USD') == 0)
      {
         $convertor = $configuration['usd_to_primary'];
      }
      else if(strcasecmp($currency, 'EUR') == 0)
      {
         $convertor = $configuration['eur_to_primary'];
      }
      else if(strcasecmp($currency, 'GBP') == 0)
      {
         $convertor = $configuration['gbp_to_primary'];
      }
      else if(strcasecmp($currency, 'CAD') == 0)
      {
         $convertor = $configuration['cad_to_primary'];
      }
      else if(strcasecmp($currency, 'JPY') == 0)
      {
         $convertor = $configuration['jpy_to_primary'];
      }
      else if(strcasecmp($currency, 'AUD') == 0)
      {
         $convertor = $configuration['aud_to_primary'];
      }
      return $convertor;
   }
//-- fin mod : Loewen Enterprise - Donation MOD v1.0.2 ----------------------------------------------------
?>
Jirsh
Registered User
Registered User
 
Posts: 15
Joined: Tue Feb 07, 2006 10:06 pm

Postby DooBDee on Fri Jan 12, 2007 4:36 pm

viewforum.php is incorrect as line endings are not there...and they should be :P redownload appropriate fiel from phpBB.com and apply any changes u made to that file again.
DooBDee
Website Ninja
DooBDee.net
User avatar
DooBDee
Moderator
Moderator
 
Posts: 3530
Joined: Tue Mar 01, 2005 6:28 pm
Location: DooBDee.net

Postby PostBot on Fri Jan 12, 2007 6:36 pm

Looks like you are editing it on Mac. Try to use editor that lets you change line ending to ether windows style or linux style, but not mac style.
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars


Return to phpBB Support

Who is online

Users browsing this forum: No registered users and 0 guests