2001-02-17 08:37:32 +00:00
< ? php
2001-03-07 06:53:39 +00:00
/***************************************************************************
2001-03-09 23:33:06 +00:00
* viewtopic . php
2001-03-07 06:53:39 +00:00
* -------------------
* begin : Saturday , Feb 13 , 2001
* copyright : ( C ) 2001 The phpBB Group
* email : support @ phpbb . com
*
* $Id $
*
*
***************************************************************************/
/***************************************************************************
*
* 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 .
*
*
***************************************************************************/
2001-03-09 14:04:48 +00:00
include ( 'extension.inc' );
2001-03-04 04:17:02 +00:00
include ( 'common.' . $phpEx );
2001-04-19 13:18:57 +00:00
include ( 'includes/bbcode.' . $phpEx );
2001-03-04 04:17:02 +00:00
2001-05-03 22:10:23 +00:00
$page_title = " View Topic - $topic_title " ;
$pagetype = " viewtopic " ;
2001-05-27 22:08:47 +00:00
//
// Start initial var setup
//
2001-03-09 18:20:41 +00:00
if ( ! isset ( $HTTP_GET_VARS [ 'topic' ])) // For backward compatibility
2001-03-09 15:23:03 +00:00
{
$topic_id = $HTTP_GET_VARS [ POST_TOPIC_URL ];
}
2001-03-09 16:43:07 +00:00
else
{
2001-03-09 18:20:41 +00:00
$topic_id = $HTTP_GET_VARS [ 'topic' ];
2001-03-09 16:43:07 +00:00
}
2001-05-29 18:16:46 +00:00
if ( isset ( $HTTP_GET_VARS [ POST_POST_URL ]))
{
$post_id = $HTTP_GET_VARS [ POST_POST_URL ];
}
2001-05-27 22:08:47 +00:00
$start = ( isset ( $HTTP_GET_VARS [ 'start' ])) ? $HTTP_GET_VARS [ 'start' ] : 0 ;
2001-05-24 20:10:34 +00:00
$is_moderator = 0 ;
2001-05-27 22:08:47 +00:00
//
// End initial var setup
//
2001-05-29 18:16:46 +00:00
if ( ! isset ( $topic_id ) && ! isset ( $post_id ))
2001-03-04 04:17:02 +00:00
{
2001-05-27 22:08:47 +00:00
error_die ( GENERAL_ERROR , " You have reached this page in error, please go back and try again " );
2001-03-04 04:17:02 +00:00
}
2001-03-09 14:04:48 +00:00
2001-05-27 22:08:47 +00:00
// This is the single/double 'integrated'
// query to obtain the next/previous
// topic from just the current topic_id
2001-05-16 06:45:44 +00:00
//
2001-05-27 22:08:47 +00:00
// We will make this word, if it's the last thing I
// do ... and it quite possibly will be!
/*
2001-05-16 00:49:06 +00:00
if ( isset ( $HTTP_GET_VARS [ 'view' ]))
{
if ( $HTTP_GET_VARS [ 'view' ] == 'newer' )
{
2001-05-16 00:56:59 +00:00
$operator = " > " ;
2001-05-16 00:49:06 +00:00
}
2001-05-16 00:56:59 +00:00
else if ( $HTTP_GET_VARS [ 'view' ] == 'older' )
2001-05-16 00:49:06 +00:00
{
2001-05-16 00:56:59 +00:00
$operator = " < " ;
}
2001-05-24 20:10:34 +00:00
switch ( $dbms )
2001-05-16 00:56:59 +00:00
{
2001-05-27 22:08:47 +00:00
case 'mysql' :
2001-05-24 20:10:34 +00:00
// And now the stupid MySQL case...I wish they would get around to implementing subselectes...
2001-06-03 23:10:07 +00:00
$sub_query = " SELECT topic_time
FROM " .TOPICS_TABLE. "
2001-05-27 22:08:47 +00:00
WHERE topic_id = $topic_id " ;
2001-05-16 00:56:59 +00:00
if ( $sub_result = $db -> sql_query ( $sub_query ))
{
2001-05-24 20:10:34 +00:00
$resultset = $db -> sql_fetchrowset ( $sub_result );
$sql = " SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies,
2001-05-16 00:49:06 +00:00
f . forum_type , f . forum_name , f . forum_id , u . username , u . user_id
2001-05-24 20:10:34 +00:00
FROM " .TOPICS_TABLE. " t , " .FORUMS_TABLE. " f , " .FORUM_MODS_TABLE. " fm , " .USERS_TABLE. " u
WHERE t . topic_time " . $operator . " " . $resultset[0] ['topic_time']. "
AND f . forum_id = " . $HTTP_GET_VARS[POST_FORUM_URL] . "
AND f . forum_id = t . forum_id
AND fm . forum_id = t . forum_id
AND u . user_id = fm . user_id " ;
2001-05-16 00:56:59 +00:00
$db -> sql_freeresult ( $sub_result );
}
else
{
if ( DEBUG )
2001-05-16 00:49:06 +00:00
{
2001-05-16 00:56:59 +00:00
$dberror = $db -> sql_error ();
error_die ( SQL_QUERY , " Couldn't obtain topic information.<br>Reason: " . $dberror [ 'message' ] . " <br>Query: $sql " , __LINE__ , __FILE__ );
2001-05-16 00:49:06 +00:00
}
else
{
2001-05-16 00:56:59 +00:00
error_die ( SQL_QUERY , " Couldn't obtain topic information. " , __LINE__ , __FILE__ );
2001-05-16 00:49:06 +00:00
}
2001-05-16 00:56:59 +00:00
}
2001-05-27 22:08:47 +00:00
break ;
default :
$sql = " SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies,
f . forum_type , f . forum_name , f . forum_id , u . username , u . user_id
FROM " .TOPICS_TABLE. " t , " .FORUMS_TABLE. " f , " .FORUM_MODS_TABLE. " fm , " .USERS_TABLE. " u
WHERE t . topic_id in
( select max ( topic_id ) from " .TOPICS_TABLE. " WHERE topic_time " . $operator . " ( select topic_time as t_time from " .TOPICS_TABLE. " where topic_id = $topic_id ))
AND f . forum_id = " . $HTTP_GET_VARS[POST_FORUM_URL] . "
AND f . forum_id = t . forum_id
AND fm . forum_id = t . forum_id
AND u . user_id = fm . user_id " ;
2001-05-24 20:10:34 +00:00
break ;
2001-05-16 00:49:06 +00:00
}
}
//
// End.
//
else
{
2001-05-27 22:08:47 +00:00
*/
2001-05-29 18:16:46 +00:00
//
// This is perhaps a bodged(?) way
// of allowing a direct link to a post
// it also allows calculation of which
2001-05-31 23:14:15 +00:00
// page the post should be on. This query
// no longer grabs moderator info for this
// forum ... right now that's fine, but
// if needed it can be easily replaced/added
2001-05-29 18:16:46 +00:00
//
$join_sql_table = ( ! isset ( $post_id )) ? " " : " " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " ;
$join_sql = ( ! isset ( $post_id )) ? " t.topic_id = $topic_id " : " p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id " ;
$count_sql = ( ! isset ( $post_id )) ? " " : " , COUNT(p2.post_id) AS prev_posts " ;
2001-06-05 21:15:19 +00:00
/*
$order_sql = ( ! isset ( $post_id )) ? " " : " GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_name, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_votecreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC " ;
$sql = " SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_name, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_votecreate, f.auth_vote, f.auth_attachments " . $count_sql . "
FROM $join_sql_table " .TOPICS_TABLE. " t , " .FORUMS_TABLE. " f
WHERE $join_sql
AND f . forum_id = t . forum_id
$order_sql " ;
*/
2001-05-31 23:14:15 +00:00
$order_sql = ( ! isset ( $post_id )) ? " " : " GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_name, f.forum_id, fa.auth_view, fa.auth_read, fa.auth_post, fa.auth_reply, fa.auth_edit, fa.auth_delete, fa.auth_votecreate, fa.auth_vote ORDER BY p.post_id ASC " ;
2001-05-29 18:16:46 +00:00
2001-06-03 23:10:07 +00:00
$sql = " SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_name, f.forum_id, fa.auth_view, fa.auth_read, fa.auth_post, fa.auth_reply, fa.auth_edit, fa.auth_delete, fa.auth_votecreate, fa.auth_vote " . $count_sql . "
FROM $join_sql_table " .TOPICS_TABLE. " t , " .FORUMS_TABLE. " f , " .AUTH_FORUMS_TABLE. " fa
WHERE $join_sql
AND f . forum_id = t . forum_id
AND fa . forum_id = f . forum_id
2001-05-29 18:16:46 +00:00
$order_sql " ;
2001-05-27 22:08:47 +00:00
2001-06-05 21:15:19 +00:00
2001-05-27 22:08:47 +00:00
// This closes out the opening braces above
// Needed for the view/next query
//}
2001-03-04 04:17:02 +00:00
if ( ! $result = $db -> sql_query ( $sql ))
2001-03-07 06:53:39 +00:00
{
2001-05-16 00:49:06 +00:00
if ( DEBUG )
{
$dberror = $db -> sql_error ();
error_die ( SQL_QUERY , " Couldn't obtain topic information.<br>Reason: " . $dberror [ 'message' ] . " <br>Query: $sql " , __LINE__ , __FILE__ );
}
else
{
2001-05-27 22:08:47 +00:00
error_die ( SQL_QUERY , " Couldn't obtain topic information. " , __LINE__ , __FILE__ );
2001-05-16 00:49:06 +00:00
}
2001-03-04 04:17:02 +00:00
}
2001-05-27 22:08:47 +00:00
2001-03-04 04:17:02 +00:00
if ( ! $total_rows = $db -> sql_numrows ( $result ))
{
2001-05-27 22:08:47 +00:00
//
// This should be considered temporary since
// it should be moved to the templating file
// when if...else constructs become available
//
/* if ( isset ( $HTTP_GET_VARS [ 'view' ]))
2001-05-16 00:49:06 +00:00
{
error_die ( GENERAL_ERROR , $l_nomoretopics );
}
else
2001-05-27 22:08:47 +00:00
{ */
2001-05-25 07:02:48 +00:00
if ( DEBUG )
{
$error = $db -> sql_error ();
error_die ( GENERAL_ERROR , " The forum/topic you selected does not exist.<br>Reason: " . $error [ 'message' ] . " <br>Query: $sql " , __LINE__ , __FILE__ );
}
else
{
2001-05-27 22:08:47 +00:00
error_die ( GENERAL_ERROR , " The forum you selected does not exist. Please go back and try again. " );
}
// }
2001-03-04 04:17:02 +00:00
}
$forum_row = $db -> sql_fetchrowset ( $result );
2001-05-13 16:02:30 +00:00
$forum_name = stripslashes ( $forum_row [ 0 ][ 'forum_name' ]);
2001-05-27 22:08:47 +00:00
$forum_id = $forum_row [ 0 ][ 'forum_id' ];
2001-05-29 18:16:46 +00:00
$topic_id = $forum_row [ 0 ][ 'topic_id' ];
2001-05-27 22:08:47 +00:00
$total_replies = $forum_row [ 0 ][ 'topic_replies' ] + 1 ;
$topic_title = $forum_row [ 0 ][ 'topic_title' ];
$topic_time = $forum_row [ 0 ][ 'topic_time' ];
2001-04-15 14:14:56 +00:00
2001-05-29 18:16:46 +00:00
if ( ! empty ( $post_id ))
{
$start = floor ( $forum_row [ 0 ][ 'prev_posts' ] / $board_config [ 'posts_per_page' ]) * $board_config [ 'posts_per_page' ];
}
2001-04-15 14:14:56 +00:00
//
// Start session management
//
$userdata = session_pagestart ( $user_ip , $forum_id , $session_length );
init_userprefs ( $userdata );
//
// End session management
//
2001-05-30 20:21:42 +00:00
//
// Start auth check
//
2001-06-01 13:44:12 +00:00
$is_auth = auth ( AUTH_ALL , $forum_id , $userdata , $forum_row [ 0 ]);
2001-05-30 20:21:42 +00:00
2001-06-01 13:44:12 +00:00
if ( ! $is_auth [ 'auth_view' ] || ! $is_auth [ 'auth_view' ])
2001-05-30 20:21:42 +00:00
{
//
// Ooopss, user is not authed
// to read this forum ...
//
include ( 'includes/page_header.' . $phpEx );
2001-06-03 23:10:07 +00:00
2001-05-30 20:21:42 +00:00
$msg = " I am sorry but you are not currently authorised to read this forum. You could try logging on and trying again. If you are logged on then this is a private forum for which you have not been granted access. " ;
$template -> set_filenames ( array (
" reg_header " => " error_body.tpl "
));
$template -> assign_vars ( array (
" ERROR_MESSAGE " => $msg
));
$template -> pparse ( " reg_header " );
include ( 'includes/page_tail.' . $phpEx );
}
//
// End auth check
2001-06-03 23:10:07 +00:00
//
2001-05-30 20:21:42 +00:00
2001-06-05 21:15:19 +00:00
/*
//
// This code allows for individual topic
// read tracking, on small, low volume sites
// it'll probably work very well. However, for
// busy sites the use of a text field in the DB
// combined with the additional UPDATE's required
// in viewtopic may be unacceptable. So, by default
// this code is off, however you may want to play
// ...
//
// psoTFX
//
if ( $userdata [ 'user_id' ] != ANONYMOUS )
{
$unread_topic_list = unserialize ( $userdata [ 'user_topics_unvisited' ]);
if ( isset ( $unread_topic_list [ $forum_id ][ $topic_id ]))
{
unset ( $unread_topic_list [ $forum_id ][ $topic_id ]);
$sql = " UPDATE " . USERS_TABLE . "
SET user_topics_unvisited = '" . serialize($unread_topic_list) . "'
WHERE user_id = " . $userdata['user_id'] ;
if ( ! $s_topic_times = $db -> sql_query ( $sql ))
{
error_die ( SQL_QUERY , " Could not update user topics list. " , __LINE__ , __FILE__ );
}
}
}
*/
2001-05-30 20:21:42 +00:00
2001-03-04 04:17:02 +00:00
for ( $x = 0 ; $x < $total_rows ; $x ++ )
{
2001-05-13 16:02:30 +00:00
$moderators [] = array ( " user_id " => $forum_row [ $x ][ 'user_id' ],
" username " => $forum_row [ $x ][ 'username' ]);
if ( $userdata [ 'user_id' ] == $forum_row [ $x ][ 'user_id' ])
2001-03-09 14:04:48 +00:00
{
$is_moderator = 1 ;
}
2001-03-04 04:17:02 +00:00
}
2001-05-27 22:08:47 +00:00
//
// Get next and previous topic_id's
//
2001-06-03 23:10:07 +00:00
$sql_next_id = " SELECT topic_id
FROM " .TOPICS_TABLE. "
WHERE topic_time > $topic_time
AND forum_id = $forum_id
ORDER BY topic_time ASC
2001-05-27 22:08:47 +00:00
LIMIT 1 " ;
2001-06-03 23:10:07 +00:00
$sql_prev_id = " SELECT topic_id
FROM " .TOPICS_TABLE. "
WHERE topic_time < $topic_time
AND forum_id = $forum_id
ORDER BY topic_time DESC
2001-05-27 22:08:47 +00:00
LIMIT 1 " ;
$result_next = $db -> sql_query ( $sql_next_id );
$result_prev = $db -> sql_query ( $sql_prev_id );
$topic_next_row = $db -> sql_fetchrow ( $result_next );
$topic_prev_row = $db -> sql_fetchrow ( $result_prev );
2001-03-09 14:04:48 +00:00
2001-05-27 22:08:47 +00:00
//
// Go ahead and pull all data for this topic
//
$sql = " SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_avatar, p.post_time, p.post_id, p.bbcode_uid, pt.post_text, pt.post_subject
2001-05-13 16:02:30 +00:00
FROM " .POSTS_TABLE. " p , " .USERS_TABLE. " u , " .POSTS_TEXT_TABLE. " pt
WHERE p . topic_id = $topic_id
2001-06-03 23:10:07 +00:00
AND p . poster_id = u . user_id
2001-05-16 06:45:44 +00:00
AND p . post_id = pt . post_id
2001-03-09 14:04:48 +00:00
ORDER BY p . post_time ASC
2001-05-03 22:10:23 +00:00
LIMIT $start , " . $board_config['posts_per_page'] ;
2001-03-04 04:17:02 +00:00
if ( ! $result = $db -> sql_query ( $sql ))
{
2001-05-27 22:08:47 +00:00
error_die ( SQL_QUERY , " Couldn't obtain post/user information. " , __LINE__ , __FILE__ );
2001-03-04 04:17:02 +00:00
}
if ( ! $total_posts = $db -> sql_numrows ( $result ))
{
2001-05-27 22:08:47 +00:00
//
// Again this should be considered temporary and
// will appear in the templates file at some
// point
//
error_die ( GENERAL_ERROR , " There don't appear to be any posts for this topic. " , __LINE__ , __FILE__ );
2001-03-04 04:17:02 +00:00
}
2001-04-02 14:36:36 +00:00
$sql = " SELECT *
FROM " .RANKS_TABLE. "
ORDER BY rank_min " ;
if ( ! $ranks_result = $db -> sql_query ( $sql ))
{
2001-05-27 22:08:47 +00:00
error_die ( SQL_QUERY , " Couldn't obtain ranks information. " , __LINE__ , __FILE__ );
2001-04-02 14:36:36 +00:00
}
2001-03-04 04:17:02 +00:00
$postrow = $db -> sql_fetchrowset ( $result );
2001-04-02 14:36:36 +00:00
$ranksrow = $db -> sql_fetchrowset ( $ranksresult );
2001-03-04 04:17:02 +00:00
2001-05-27 22:08:47 +00:00
//
// Dump out the page header and
// load viewtopic body template
//
include ( 'includes/page_header.' . $phpEx );
$template -> set_filenames ( array (
" body " => " viewtopic_body.tpl " ,
" jumpbox " => " jumpbox.tpl " )
);
$jumpbox = make_jumpbox ();
$template -> assign_vars ( array (
" JUMPBOX_LIST " => $jumpbox ,
" SELECT_NAME " => POST_FORUM_URL )
);
$template -> assign_var_from_handle ( " JUMPBOX " , " jumpbox " );
$template -> assign_vars ( array (
" FORUM_ID " => $forum_id ,
" FORUM_NAME " => $forum_name ,
" TOPIC_ID " => $topic_id ,
" TOPIC_TITLE " => $topic_title ,
" POST_FORUM_URL " => POST_FORUM_URL ,
" USERS_BROWSING " => $users_browsing )
);
//
// End header
//
2001-05-03 22:10:23 +00:00
//
2001-05-16 06:45:44 +00:00
// Post, reply and other URL generation for
2001-05-03 22:10:23 +00:00
// templating vars
//
2001-05-06 16:16:22 +00:00
$new_topic_url = append_sid ( " posting. " . $phpEx . " ?mode=newtopic& " . POST_FORUM_URL . " = $forum_id " );
2001-05-26 00:25:50 +00:00
$reply_topic_url = append_sid ( " posting. " . $phpEx . " ?mode=reply& " . POST_TOPIC_URL . " = $topic_id & " . POST_FORUM_URL . " = $forum_id " );
2001-05-06 16:16:22 +00:00
$view_forum_url = append_sid ( " viewforum. " . $phpEx . " ? " . POST_FORUM_URL . " = $forum_id " );
2001-05-27 22:08:47 +00:00
$view_prev_topic_url = ( ! empty ( $topic_prev_row [ 'topic_id' ])) ? append_sid ( " viewtopic. " . $phpEx . " ? " . POST_TOPIC_URL . " = " . $topic_prev_row [ 'topic_id' ]) : " " ;
$view_next_topic_url = ( ! empty ( $topic_next_row [ 'topic_id' ])) ? append_sid ( " viewtopic. " . $phpEx . " ? " . POST_TOPIC_URL . " = " . $topic_next_row [ 'topic_id' ]) : " " ;
2001-05-03 22:10:23 +00:00
$template -> assign_vars ( array (
2001-05-26 00:25:50 +00:00
" L_POSTED " => $l_posted ,
2001-05-03 22:10:23 +00:00
" U_POST_NEW_TOPIC " => $new_topic_url ,
2001-05-24 20:10:34 +00:00
" FORUM_NAME " => $forum_name ,
" TOPIC_TITLE " => $topic_title ,
2001-05-03 22:10:23 +00:00
" U_VIEW_FORUM " => $view_forum_url ,
2001-05-27 22:08:47 +00:00
" U_VIEW_OLDER_TOPIC " => $view_prev_topic_url ,
" U_VIEW_NEWER_TOPIC " => $view_next_topic_url ,
2001-05-03 22:10:23 +00:00
" U_POST_REPLY_TOPIC " => $reply_topic_url ));
2001-05-24 20:10:34 +00:00
//
2001-05-27 22:08:47 +00:00
// Update the topic view counter
// If we get here then the page is unlikely
// to fail generating ...
2001-05-24 20:10:34 +00:00
//
2001-06-03 23:10:07 +00:00
$sql = " UPDATE " . TOPICS_TABLE . "
SET topic_views = topic_views + 1
2001-05-27 22:08:47 +00:00
WHERE topic_id = $topic_id " ;
if ( ! $update_result = $db -> sql_query ( $sql ))
{
error_die ( SQL_QUERY , " Couldn't update topic views. " , __LINE__ , __FILE__ );
}
2001-05-24 20:10:34 +00:00
2001-05-03 22:10:23 +00:00
//
// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...
//
2001-03-07 06:53:39 +00:00
for ( $x = 0 ; $x < $total_posts ; $x ++ )
2001-03-04 04:17:02 +00:00
{
2001-05-13 16:02:30 +00:00
$poster = stripslashes ( $postrow [ $x ][ 'username' ]);
$poster_id = $postrow [ $x ][ 'user_id' ];
$post_date = create_date ( $board_config [ 'default_dateformat' ], $postrow [ $x ][ 'post_time' ], $board_config [ 'default_timezone' ]);
$poster_posts = $postrow [ $x ][ 'user_posts' ];
$poster_from = ( $postrow [ $x ][ 'user_from' ]) ? " $l_from : " . $postrow [ $x ][ 'user_from' ] : " " ;
$poster_joined = create_date ( $board_config [ 'default_dateformat' ], $postrow [ $x ][ 'user_regdate' ], $board_config [ 'default_timezone' ]);
2001-06-05 21:15:19 +00:00
$poster_avatar = ( $postrow [ $x ][ 'user_avatar' ] != " " && $userdata [ 'user_id' ] != ANONYMOUS ) ? " <img src= \" " . $board_config [ 'avatar_path' ] . " / " . $postrow [ $x ][ 'user_avatar' ] . " \" > " : " " ;
if ( ! $postrow [ $x ][ 'user_rank' ])
2001-04-02 14:36:36 +00:00
{
2001-06-05 21:15:19 +00:00
for ( $i = 0 ; $i < count ( $ranksrow ); $i ++ )
2001-04-02 14:36:36 +00:00
{
2001-06-05 21:15:19 +00:00
if ( $poster_posts > $ranksrow [ $i ][ 'rank_min' ] && $poster_posts < $ranksrow [ $i ][ 'rank_max' ])
2001-04-02 14:36:36 +00:00
{
2001-06-05 21:15:19 +00:00
$poster_rank = $ranksrow [ $i ][ 'rank_title' ];
$rank_image = ( $ranksrow [ $i ][ 'rank_image' ]) ? " <img src= \" " . $ranksrow [ $i ][ 'rank_image' ] . " \" > " : " " ;
2001-04-02 14:36:36 +00:00
}
}
2001-06-05 21:15:19 +00:00
}
else
{
for ( $i = 0 ; $i < count ( $ranksrow ); $i ++ )
2001-04-02 14:36:36 +00:00
{
2001-06-05 21:15:19 +00:00
if ( $postrow [ $x ][ 'user_rank' ] == $ranksrow [ $i ][ 'rank_special' ])
2001-05-13 16:02:30 +00:00
{
2001-06-05 21:15:19 +00:00
$poster_rank = $ranksrow [ $i ][ 'rank_title' ];
$rank_image = ( $ranksrow [ $i ][ 'rank_image' ]) ? " <img src= \" " . $ranksrow [ $i ][ 'rank_image' ] . " \" > " : " " ;
2001-05-13 16:02:30 +00:00
}
2001-04-02 14:36:36 +00:00
}
}
2001-05-06 16:16:22 +00:00
$profile_img = " <a href= \" " . append_sid ( " profile. $phpEx ?mode=viewprofile& " . POST_USERS_URL . " = $poster_id " ) . " \" ><img src= \" " . $images [ 'profile' ] . " \" alt= \" $l_profileof $poster\ " border = \ " 0 \" ></a> " ;
2001-05-13 16:02:30 +00:00
$email_img = ( $postrow [ $x ][ 'user_viewemail' ] == 1 ) ? " <a href= \" mailto: " . $postrow [ $x ][ 'user_email' ] . " \" ><img src= \" " . $images [ 'email' ] . " \" alt= \" $l_email $poster\ " border = \ " 0 \" ></a> " : " " ;
$www_img = ( $postrow [ $x ][ 'user_website' ]) ? " <a href= \" " . $postrow [ $x ][ 'user_website' ] . " \" ><img src= \" " . $images [ 'www' ] . " \" alt= \" $l_viewsite\ " border = \ " 0 \" ></a> " : " " ;
2001-03-09 14:04:48 +00:00
2001-05-13 16:02:30 +00:00
if ( $postrow [ $x ][ 'user_icq' ])
2001-03-09 14:04:48 +00:00
{
2001-05-13 16:02:30 +00:00
$icq_status_img = " <a href= \" http://wwp.icq.com/ " . $postrow [ $x ][ 'user_icq' ] . " #pager \" ><img src= \" http://online.mirabilis.com/scripts/online.dll?icq= " . $postrow [ $x ][ 'user_icq' ] . " &img=5 \" alt= \" $l_icqstatus\ " border = \ " 0 \" ></a> " ;
$icq_add_img = " <a href= \" http://wwp.icq.com/scripts/search.dll?to= " . $postrow [ $x ][ 'user_icq' ] . " \" ><img src= \" " . $images [ 'icq' ] . " \" alt= \" $l_icq\ " border = \ " 0 \" ></a> " ;
2001-03-09 14:04:48 +00:00
}
else
{
$icq_status_img = " " ;
$icq_add_img = " " ;
}
2001-05-16 06:45:44 +00:00
2001-05-13 16:02:30 +00:00
$aim_img = ( $postrow [ $x ][ 'user_aim' ]) ? " <a href= \" aim:goim?screenname= " . $postrow [ $x ][ 'user_aim' ] . " &message=Hello+Are+you+there? \" ><img src= \" " . $images [ 'aim' ] . " \" border= \" 0 \" ></a> " : " " ;
2001-06-05 21:15:19 +00:00
$msn_img = ( $postrow [ $x ][ 'user_msnm' ]) ? " <a href= \" profile. $phpEx ?mode=viewprofile& " . POST_USERS_URL . " = $poster_id\ " >< img src = \ " " . $images [ 'msn' ] . " \" border= \" 0 \" ></a> " : " " ;
2001-05-13 16:02:30 +00:00
$yim_img = ( $postrow [ $x ][ 'user_yim' ]) ? " <a href= \" http://edit.yahoo.com/config/send_webmesg?.target= " . $postrow [ $x ][ 'user_yim' ] . " &.src=pg \" ><img src= \" " . $images [ 'yim' ] . " \" border= \" 0 \" ></a> " : " " ;
2001-05-16 06:45:44 +00:00
2001-05-26 00:25:50 +00:00
$edit_img = " <a href= \" " . append_sid ( " posting. $phpEx ?mode=editpost& " . POST_POST_URL . " = " . $postrow [ $x ][ 'post_id' ] . " & " . POST_TOPIC_URL . " = $topic_id & " . POST_FORUM_URL . " = $forum_id " ) . " \" ><img src= \" " . $images [ 'edit' ] . " \" alt= \" $l_editdelete\ " border = \ " 0 \" ></a> " ;
2001-06-03 23:10:07 +00:00
$quote_img = " <a href= \" " . append_sid ( " posting. $phpEx ?mode=reply"e=true& " . POST_POST_URL . " = " . $postrow [ $x ][ 'post_id' ] . " & " . POST_TOPIC_URL . " = $topic_id & " . POST_FORUM_URL . " = $forum_id " ) . " \" ><img src= \" " . $images [ 'quote' ] . " \" alt= \" $l_replyquote\ " border = \ " 0 \" ></a> " ;
2001-05-06 16:16:22 +00:00
$pmsg_img = " <a href= \" " . append_sid ( " priv_msgs. $phpEx ?mode=send " ) . " \" ><img src= \" " . $images [ 'pmsg' ] . " \" alt= \" $l_sendpmsg\ " border = \ " 0 \" ></a> " ;
2001-05-16 06:45:44 +00:00
2001-06-01 17:11:16 +00:00
if ( $is_auth [ 'auth_mod' ])
2001-03-09 14:04:48 +00:00
{
2001-06-05 21:15:19 +00:00
$ip_img = " <a href= \" " . append_sid ( " topicadmin. $phpEx ?mode=viewip& " . POST_USERS_URL . " = " . $poster_id ) . " \" ><img src= \" " . $images [ 'ip' ] . " \" alt= \" $l_viewip\ " border = \ " 0 \" ></a> " ;
2001-05-29 18:16:46 +00:00
$delpost_img = " <a href= \" " . append_sid ( " topicadmin. $phpEx ?mode=delpost& " . POST_POST_URL . " = " . $postrow [ $x ][ 'post_id' ]) . " \" ><img src= \" " . $images [ 'delpost' ] . " \" alt= \" $l_delete\ " border = \ " 0 \" ></a> " ;
2001-03-09 14:04:48 +00:00
}
2001-05-16 06:45:44 +00:00
2001-05-27 22:08:47 +00:00
$post_subject = ( $postrow [ $x ][ 'post_subject' ] != " " ) ? stripslashes ( $postrow [ $x ][ 'post_subject' ]) : " Re: " . $topic_title ;
2001-05-13 16:02:30 +00:00
$message = stripslashes ( $postrow [ $x ][ 'post_text' ]);
2001-03-21 07:17:11 +00:00
$bbcode_uid = $postrow [ $x ][ 'bbcode_uid' ];
2001-03-23 01:39:26 +00:00
$user_sig = stripslashes ( $postrow [ $x ][ 'user_sig' ]);
2001-05-03 22:10:23 +00:00
if ( ! $board_config [ 'allow_html' ])
2001-03-09 14:04:48 +00:00
{
2001-03-23 01:39:26 +00:00
$user_sig = strip_tags ( $user_sig );
2001-03-09 14:04:48 +00:00
$message = strip_tags ( $message );
}
2001-05-03 22:10:23 +00:00
if ( $board_config [ 'allow_bbcode' ])
2001-03-09 14:04:48 +00:00
{
// do bbcode stuff here
2001-03-23 01:39:26 +00:00
$sig_uid = make_bbcode_uid ();
$user_sig = bbencode_first_pass ( $user_sig , $sig_uid );
$user_sig = bbencode_second_pass ( $user_sig , $sig_uid );
2001-05-16 06:45:44 +00:00
2001-03-21 07:17:11 +00:00
$message = bbencode_second_pass ( $message , $bbcode_uid );
2001-03-09 14:04:48 +00:00
}
2001-05-16 06:45:44 +00:00
2001-03-21 07:26:10 +00:00
$message = make_clickable ( $message );
2001-05-02 00:50:27 +00:00
$message = str_replace ( " \n " , " <br /> " , $message );
2001-05-16 06:45:44 +00:00
2001-05-27 22:08:47 +00:00
//
// Again this will be handled by the templating
// code at some point
//
2001-03-09 14:04:48 +00:00
if ( ! ( $x % 2 ))
{
2001-05-13 16:02:30 +00:00
$color = " # " . $theme [ 'td_color1' ];
2001-03-09 14:04:48 +00:00
}
else
{
2001-05-13 16:02:30 +00:00
$color = " # " . $theme [ 'td_color2' ];
2001-03-09 14:04:48 +00:00
}
2001-05-16 06:45:44 +00:00
2001-05-28 15:25:23 +00:00
$message = eregi_replace ( " \ [addsig] $ " , " <br /><br />_________________<br /> " . nl2br ( $user_sig ), $message );
2001-05-16 06:45:44 +00:00
2001-05-03 22:10:23 +00:00
$template -> assign_block_vars ( " postrow " , array (
2001-03-17 00:46:26 +00:00
" POSTER_NAME " => $poster ,
" POSTER_RANK " => $poster_rank ,
" RANK_IMAGE " => $rank_image ,
" ROW_COLOR " => $color ,
" POSTER_JOINED " => $poster_joined ,
" POSTER_POSTS " => $poster_posts ,
" POSTER_FROM " => $poster_from ,
2001-06-03 23:10:07 +00:00
" POSTER_AVATAR " => $poster_avatar ,
2001-03-17 00:46:26 +00:00
" POST_DATE " => $post_date ,
2001-05-27 03:11:27 +00:00
" POST_SUBJECT " => $post_subject ,
2001-03-17 00:46:26 +00:00
" MESSAGE " => $message ,
" PROFILE_IMG " => $profile_img ,
" EMAIL_IMG " => $email_img ,
" WWW_IMG " => $www_img ,
" ICQ_STATUS_IMG " => $icq_status_img ,
" ICQ_ADD_IMG " => $icq_add_img ,
" AIM_IMG " => $aim_img ,
" MSN_IMG " => $msn_img ,
" YIM_IMG " => $yim_img ,
" EDIT_IMG " => $edit_img ,
" QUOTE_IMG " => $quote_img ,
" PMSG_IMG " => $pmsg_img ,
" IP_IMG " => $ip_img ,
2001-05-06 17:39:01 +00:00
" DELPOST_IMG " => $delpost_img ,
2001-05-26 00:25:50 +00:00
" U_POST_ID " => $postrow [ $x ][ 'post_id' ]));
2001-03-04 04:17:02 +00:00
}
2001-03-05 01:40:39 +00:00
2001-05-03 22:10:23 +00:00
if ( $total_replies > $board_config [ 'posts_per_page' ])
2001-03-05 01:40:39 +00:00
{
2001-03-09 14:04:48 +00:00
$times = 0 ;
2001-05-03 22:10:23 +00:00
for ( $x = 0 ; $x < $total_replies ; $x += $board_config [ 'posts_per_page' ])
2001-03-09 14:04:48 +00:00
{
$times ++ ;
}
2001-05-03 22:10:23 +00:00
$pages = $times . " $l_pages " ;
2001-03-05 01:40:39 +00:00
}
else
{
2001-05-03 22:10:23 +00:00
$pages = " 1 $l_page " ;
2001-03-05 01:40:39 +00:00
}
2001-03-09 14:04:48 +00:00
2001-05-31 15:39:59 +00:00
$s_auth_can = " " ;
$s_auth_can .= " You " . (( $is_auth [ 'auth_read' ]) ? " <b>can</b> " : " <b>cannot</b> " ) . " read posts in this forum<br> " ;
$s_auth_can .= " You " . (( $is_auth [ 'auth_post' ]) ? " <b>can</b> " : " <b>cannot</b> " ) . " add new topics to this forum<br> " ;
$s_auth_can .= " You " . (( $is_auth [ 'auth_reply' ]) ? " <b>can</b> " : " <b>cannot</b> " ) . " reply to posts in this forum<br> " ;
$s_auth_can .= " You " . (( $is_auth [ 'auth_edit' ]) ? " <b>can</b> " : " <b>cannot</b> " ) . " edit your posts in this forum<br> " ;
$s_auth_can .= " You " . (( $is_auth [ 'auth_delete' ]) ? " <b>can</b> " : " <b>cannot</b> " ) . " delete your posts in this forum<br> " ;
$s_auth_can .= ( $is_auth [ 'auth_mod' ]) ? " You are a moderator of this forum<br> " : " " ;
2001-05-31 23:14:15 +00:00
$s_auth_can .= ( $userdata [ 'user_level' ] == ADMIN ) ? " You are a board admin<br> " : " " ;
2001-05-31 15:39:59 +00:00
2001-06-05 21:15:19 +00:00
if ( $is_auth [ 'auth_mod' ])
{
$topic_mod = " <a href= \" topicadmin. $phpEx ? " . POST_TOPIC_URL . " = $topic_id &mode=delete \" ><img src= \" images/topic_delete.gif \" border= \" 0 \" ></a> " ;
$topic_mod .= " <a href= \" topicadmin. $phpEx ? " . POST_TOPIC_URL . " = $topic_id &mode=move \" ><img src= \" images/topic_move.gif \" border= \" 0 \" ></a> " ;
if ( $forum_row [ 0 ][ 'topic_status' ] == UNLOCKED )
{
$topic_mod .= " <a href= \" topicadmin. $phpEx ? " . POST_TOPIC_URL . " = $topic_id &mode=lock \" ><img src= \" images/topic_lock.gif \" border= \" 0 \" ></a> " ;
}
else
{
$topic_mod .= " <a href= \" topicadmin. $phpEx ? " . POST_TOPIC_URL . " = $topic_id &mode=unlock \" ><img src= \" images/topic_unlock.gif \" border= \" 0 \" ></a> " ;
}
}
2001-05-03 22:10:23 +00:00
$template -> assign_vars ( array (
2001-05-28 15:25:23 +00:00
" PAGINATION " => generate_pagination ( " viewtopic. $phpEx ? " . POST_TOPIC_URL . " = $topic_id " , $total_replies , $board_config [ 'posts_per_page' ], $start ),
" ON_PAGE " => ( floor ( $start / $board_config [ 'posts_per_page' ]) + 1 ),
2001-05-29 18:16:46 +00:00
" TOTAL_PAGES " => ceil (( $total_replies ) / $board_config [ 'posts_per_page' ]),
2001-06-03 23:10:07 +00:00
2001-06-05 21:15:19 +00:00
" S_AUTH_LIST " => $s_auth_can ,
" S_TOPIC_ADMIN " => $topic_mod ,
2001-05-31 15:39:59 +00:00
2001-05-28 15:25:23 +00:00
" L_OF " => $lang [ 'of' ],
" L_PAGE " => $lang [ 'Page' ],
" L_GOTO_PAGE " => $lang [ 'Goto_page' ])
);
2001-03-17 00:46:26 +00:00
$template -> pparse ( " body " );
2001-02-17 08:37:32 +00:00
2001-03-09 23:33:06 +00:00
include ( 'includes/page_tail.' . $phpEx );
2001-02-17 08:37:32 +00:00
2001-05-24 20:10:34 +00:00
?>