Просмотр файла viewpost.php

Размер файла: 4.61Kb
<?php
/***************************************************************************
 *                             topics.php
 *                          ----------------------
 *   [email protected] 2010
 *   (C) apwa.ru
 *
 ***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);

$post_id = 0;

if ( isset($HTTP_GET_VARS[POST_POST_URL]))
{
	$post_id = intval($HTTP_GET_VARS[POST_POST_URL]);
}
if (!$topic_id && !$post_id)
{
	message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}

$join_sql_table = (!$post_id) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
$join_sql = (!$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 = (!$post_id) ? '' : ", COUNT(p2.post_id) AS prev_posts";

$order_sql = (!$post_id) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, 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, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . "
	FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . "
	WHERE $join_sql
		AND f.forum_id = t.forum_id
		$order_sql";
		
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, "Невозможно получить информацию о теме", '', __LINE__, __FILE__, $sql);
}

if ( !($forum_topic_data = $db->sql_fetchrow($result)) )
{
	message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}

//---------START--SSESION------//
$userdata = session_pagestart($user_ip, 10000 + $weblog_id);
init_userprefs($userdata);

$forum_id = intval($forum_topic_data['forum_id']);
$forum_name = $forum_topic_data['forum_name'];
$topic_title = $forum_topic_data['topic_title'];
$topic_id = intval($forum_topic_data['topic_id']);
$topic_time = $forum_topic_data['topic_time'];
if ($post_id)
{
	$start = floor(($forum_topic_data['prev_posts'] - 1) / intval($board_config['posts_per_page'])) * intval($board_config['posts_per_page']);
}

//--------SQL--POST----------//
$sql = "SELECT * FROM " . POSTS_TEXT_TABLE . " WHERE post_id = $post_id";

if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, "Could not obtain information", '', __LINE__, __FILE__, $sql);
}
if ( !($rowset = $db->sql_fetchrow($result)) )
{
	message_die(GENERAL_MESSAGE, $lang['Entry_not_exist']);
}

$reply_data = array();
$post_id = intval($rowset['post_id']);
$message = $rowset['post_text'];
$bbcode_uid = $rowset['bbcode_uid'];

//----------------BBCODE--and--SMILES------//

	
if ($bbcode_uid != '')
{
	$message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $message);
}

$message = make_clickable($message);

if ( $board_config['allow_smilies'] )
{		
	$message = smilies_pass($message);		
}

if ($highlight_match)
{
	$message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*>)#i', '<b style="color: red">\1</b>', $message);
}
	
	$message = str_replace("\n", "\n<br />\n", $message);

//--------------PAGE---------------------// 
$page_title = $topic_title;
$template->set_filenames(array(
	'body' => 'viewpost_body.tpl')
);
       
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

$template->assign_vars(array(
        'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"),
        'VIEW_TOPIC' => sprintf($lang['Click_return_topic'], '<-<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>'),
        'U_TOPIC_BOOKMARK' => 'http://' . $board_config['server_name'] . ( ($board_config['server_port'] != '80') ? ':' . $board_config['server_port'] : '' ) . $board_config['script_path'] . "viewpost.$phpEx?p=$post_id", 
	'FORUM_NAME' => $forum_name,
	'TOPIC_TITLE' => 'Re:' . $rowset['post_subject'] . '',			
	'MESSAGE' => $message)
);

$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>