<?php // <-- don't copy this
if($action == 'show_thread')
{
$thread_id = (int) $_REQUEST['id'];
$page = (int) $_REQUEST['page'];
$thread_name = $SQL->query("SELECT `players`.`name`, `z_forum`.`post_topic` FROM `players`, `z_forum` WHERE `z_forum`.`first_post` = ".(int) $thread_id." AND `z_forum`.`id` = `z_forum`.`first_post` AND `players`.`id` = `z_forum`.`author_guid` LIMIT 1")->fetch();
if(!empty($thread_name['name']))
{
$posts_count = $SQL->query("SELECT COUNT(`z_forum`.`id`) AS posts_count FROM `players`, `z_forum` WHERE `players`.`id` = `z_forum`.`author_guid` AND `z_forum`.`first_post` = ".(int) $thread_id)->fetch();
for($i = 0; $i < $posts_count['posts_count'] / $threads_per_page; $i++)
{
if($i != $page)
$links_to_pages .= '<a href="?subtopic=forum&action=show_thread&id='.$thread_id.'&page='.$i.'">'.($i + 1).'</a> ';
else
$links_to_pages .= '<b>'.($i + 1).' </b>';
}
$threads = $SQL->query("SELECT `players`.`name`, `players`.`group_id`, `players`.`account_id`, `players`.`world_id`, `players`.`rank_id`, `players`.`vocation`, `players`.`promotion`, `players`.`level`, `z_forum`.`id`,`z_forum`.`first_post`, `z_forum`.`section`,`z_forum`.`post_text`, `z_forum`.`post_topic`, `z_forum`.`post_date`, `z_forum`.`post_smile`, `z_forum`.`author_aid`, `z_forum`.`author_guid`, `z_forum`.`last_edit_aid`, `z_forum`.`edit_date` FROM `players`, `z_forum` WHERE `players`.`id` = `z_forum`.`author_guid` AND `z_forum`.`first_post` = ".(int) $thread_id." ORDER BY `z_forum`.`post_date` LIMIT ".$posts_per_page." OFFSET ".($page * $posts_per_page))->fetchAll();
if(isset($threads[0]['name']))
$SQL->query("UPDATE `z_forum` SET `views`=`views`+1 WHERE `id` = ".(int) $thread_id);
$main_content .= '<a href="?subtopic=forum">Boards</a> >> <a href="?subtopic=forum&action=show_board&id='.$threads[0]['section'].'">'.$sections[$threads[0]['section']].'</a> >> <b>'.$thread_name['post_topic'].'</b>';
$g = array(1 => '', 2 => array('Helper', 'red'), 3 => array('Tutor', 'blue'), 4 => array('Gamemaster', 'yellow'), 5 => array('Community Manager', 'orange'), 6 => array('God', 'red'));
//OPEN|CLOSE FUNCTION
if(isThreadOpen($thread_id)) {
$main_content .= '<br /><br /><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'"><img src="images/post.gif" border="0" /></a><br /><br />Page: '.$links_to_pages.'<br /><table width="100%"><tr bgcolor="'.$config['site']['lightborder'].'" width="100%"><td colspan="2"><font size="4"><b>'.htmlspecialchars($thread_name['post_topic']).'</b></font><font size="1"><br />by <a href="?subtopic=characters&name='.urlencode($thread_name['name']).'">'.$thread_name['name'].'</a></font></td></tr><tr bgcolor="'.$config['site']['vdarkborder'].'"><td width="200"><font color="white" size="1"><b>Author</b></font></td><td> </td></tr>';}
else
$main_content .= '<br /><br /><strong>Thread Closed!</strong><br /><br />Page: '.$links_to_pages.'<br /><table width="100%"><tr bgcolor="'.$config['site']['lightborder'].'" width="100%"><td colspan="2"><font size="4"><b>'.htmlspecialchars($thread_name['post_topic']).'</b></font><font size="1"><br />by <a href="?subtopic=characters&name='.urlencode($thread_name['name']).'">'.$thread_name['name'].'</a></font></td></tr><tr bgcolor="'.$config['site']['vdarkborder'].'"><td width="200"><font color="white" size="1"><b>Author</b></font></td><td> </td></tr>';
foreach($threads as $thread)
{
if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
$main_content .= '<tr bgcolor="'.$bgcolor.'"><td valign="top"><a href="?subtopic=characters&name='.urlencode($thread['name']).'">'.$thread['name'].'</a><br />';
if($thread['group_id'] != 1)
$main_content .= '<font class="ff_smallinfo" size="1" color="'.$g[$thread['group_id']][1].'">'.$g[$thread['group_id']][0].'<br/>'.($thread['group_id'] > 3 ? '<img class="PostIcon" src="http://otland.net/images/forum/god_post_icon.png" border="0"/><br/>' : '').'</font>';
$main_content .= '<br /><font size="1">Profession: '.$vocation_name[$thread['world_id']][$thread['promotion']][$thread['vocation']].'<br />Level: '.$thread['level'].'<br />';
$rank = new OTS_GuildRank();
$rank->load($thread['rank_id']);
if($rank->isLoaded())
{
$guild = $rank->getGuild();
if($guild->isLoaded())
$main_content .= $rank->getName().' of <a href="?subtopic=guilds&action=show&guild='.$guild->getId().'">'.$guild->getName().'</a><br />';
}
$posts = $SQL->query("SELECT COUNT(`id`) AS 'posts' FROM `z_forum` WHERE `author_aid`=".(int) $thread['account_id'])->fetch();
$main_content .= '<br />Posts: '.(int) $posts['posts'].'<br /></font></td><td valign="top">'.showPost(htmlspecialchars($thread['?']), htmlspecialchars($thread['post_text']), $thread['post_smile']).'</td></tr>
<tr bgcolor="'.$bgcolor.'"><td><font size="1">'.date('d.m.y H:i:s', $thread['post_date']);
if($thread['edit_date'] > 0)
{
if($thread['last_edit_aid'] != $thread['author_aid'])
$main_content .= '<br />Edited by moderator';
else
$main_content .= '<br />Edited by '.$thread['name'];
$main_content .= '<br />on '.date('d.m.y H:i:s', $thread['edit_date']);
}
$main_content .= '</font></td><td>';
if($logged && $group_id_of_acc_logged >= $group_not_blocked)
if($thread['first_post'] != $thread['id'])
$main_content .= '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove post of '.$thread['name'].'?\')"><font color="red">REMOVE POST</font></a>';
else
$main_content .= '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><font color="red">REMOVE THREAD</font></a>';
if($logged && ($thread['account_id'] == $account_logged->getId() || $group_id_of_acc_logged >= $group_not_blocked))
//OPEN|CLOSE FUNCTION
if(isThreadOpen($thread_id)) {
$main_content .= '<br/><a href="?subtopic=forum&action=edit_post&id='.$thread['id'].'">EDIT POST</a>';}
else
$main_content .= '';
if($logged)
if(isThreadOpen($thread_id)) {
$main_content .= '<br/><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'"e='.$thread['id'].'">Quote</a>';}
else
$main_content .= '';
$main_content .= '</td></tr>';
}
//OPEN|CLOSE FUNCTION
if(isThreadOpen($thread_id)) {
$main_content .= '</table><br /><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'"><img src="images/post.gif" border="0" /></a><br /><center>Pages:<br />'.$links_to_pages.'<br /></center>'; }
else
$main_content .= '</table><br /><strong>Thread Closed!</strong>';
}
else
$main_content .= 'Thread with this ID does not exits.';
}