+ 'u.email, u.title, u.url, u.location, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online',
+ 'FROM' => 'posts AS p',
+ 'JOINS' => array(
+ array(
+ 'INNER JOIN' => 'users AS u',
+ 'ON' => 'u.id=p.poster_id'
+ ),
+ array(
+ 'INNER JOIN' => 'groups AS g',
+ 'ON' => 'g.g_id=u.group_id'
+ ),
+ array(
+ 'LEFT JOIN' => 'online AS o',
+ 'ON' => '(o.user_id=u.id AND o.user_id!=1 AND o.idle=0)'
+ ),
+ ),
+ 'WHERE' => 'p.topic_id='.$id,
+ 'ORDER BY' => 'p.id',
+ 'LIMIT' => $pun_page['start_from'].','.$pun_user['disp_posts']
+);
+
+($hook = get_hook('vt_qr_get_posts')) ? eval($hook) : null;
+$result = $pun_db->query_build($query, true) or error(__FILE__, __LINE__);
+while ($cur_post = $pun_db->fetch_assoc($result))
+{
+ ($hook = get_hook('vt_post_loop_start')) ? eval($hook) : null;
+
+ ++$pun_page['item_count'];
+
+ $signature = '';
+ $pun_page['user_ident'] = array();
+ $pun_page['user_info'] = array();
+ $pun_page['post_options'] = array();
+ $pun_page['message'] = array();
+
+ // Generate the post heading
+ $pun_page['item_ident'] = array(
+ 'num' => '
'.($pun_page['start_from'] + $pun_page['item_count']).'',
+ 'user' => '
'.($cur_topic['posted'] == $cur_post['posted'] ? sprintf($lang_topic['Topic by'], htmlspecialchars($cur_post['username'])) : sprintf($lang_topic['Reply by'], htmlspecialchars($cur_post['username']))).'',
+ 'date' => '
'.format_time($cur_post['posted']).''
+ );
+
+ $pun_page['item_head'] = '
'.implode(' ', $pun_page['item_ident']).'';
+
+ // Generate author identification
+ if ($cur_post['poster_id'] > 1 && $pun_config['o_avatars'] == '1' && $pun_user['show_avatars'] != '0')
+ {
+ if (file_exists($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif') && $img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
+ $pun_page['user_ident'][] = '
';
+ else if (file_exists($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg') && $img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
+ $pun_page['user_ident'][] = '
';
+ else if (file_exists($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png') && $img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
+ $pun_page['user_ident'][] = '
';
+ }
+
+ if ($cur_post['poster_id'] > 1)
+ {
+ $pun_page['user_ident'][] = '
'.htmlspecialchars($cur_post['username']).'';
+ $pun_page['user_info'][] = '
'.$lang_topic['Title'].' '.get_title($cur_post).'';
+
+ if ($cur_post['is_online'] == $cur_post['poster_id'])
+ $pun_page['user_info'][] = '
'.$lang_topic['Status'].' '.$lang_topic['Online'].'';
+ else
+ $pun_page['user_info'][] = '
'.$lang_topic['Status'].' '.$lang_topic['Offline'].'';
+ }
+ else
+ {
+ $pun_page['user_ident'][] = '
'.htmlspecialchars($cur_post['username']).'';
+ $pun_page['user_info'][] = '
'.$lang_topic['Title'].' '.get_title($cur_post).'';
+ }
+
+ // Generate author information
+ if ($cur_post['poster_id'] > 1 && $pun_config['o_show_user_info'] == '1')
+ {
+
+ $pun_page['user_info'][] = '
'.$lang_topic['Registered'].' '.format_time($cur_post['registered'], true).'';
+
+ if ($cur_post['location'] != '')
+ {
+ if ($pun_config['o_censoring'] == '1')
+ $cur_post['location'] = censor_words($cur_post['location']);
+
+ $pun_page['user_info'][] = '
'.$lang_topic['From'].' '.htmlspecialchars($cur_post['location']).'';
+ }
+
+ if ($pun_config['o_show_post_count'] == '1' || $pun_user['is_admmod'])
+ $pun_page['user_info'][] = '
'.$lang_topic['Posts'].' '.$cur_post['num_posts'].'';
+
+ if ($pun_user['is_admmod'])
+ {
+ $pun_page['user_info'][] = '
'.$lang_topic['IP'].' '.$cur_post['poster_ip'].'';
+
+ if ($cur_post['admin_note'] != '')
+ $pun_page['user_info'][] = '
'.$lang_topic['Note'].' '.htmlspecialchars($cur_post['admin_note']).'';
+ }
+ }
+
+ // Generate author contact details
+ if ($pun_config['o_show_user_info'] == '1')
+ {
+ if ($cur_post['poster_id'] > 1)
+ {
+ if ($cur_post['url'] != '')
+ $pun_page['post_options'][] = '
'.sprintf($lang_topic['Visit website'], htmlspecialchars($cur_post['username'])).'';
+ if (($cur_post['email_setting'] == '0' && !$pun_user['is_guest']) || $pun_user['is_admmod'])
+ $pun_page['post_options'][] = '
'.$lang_common['E-mail'].' '.htmlspecialchars($cur_post['username']).'';
+ else if ($cur_post['email_setting'] == '1' && !$pun_user['is_guest'])
+ $pun_page['post_options'][] = '
'.$lang_common['E-mail'].' '.htmlspecialchars($cur_post['username']).'';
+ }
+ else
+ {
+ if ($cur_post['poster_email'] != '' && !$pun_user['is_guest'])
+ $pun_page['post_options'][] = '
'.$lang_common['E-mail'].' '.htmlspecialchars($cur_post['username']).'';
+ }
+ }
+
+ // Generate the post options links
+ if (!$pun_user['is_guest'])
+ {
+ $pun_page['post_options'][] = '
'.$lang_topic['Report'].' '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'';
+
+ if (!$pun_user['is_admmod'])
+ {
+ if ($cur_topic['closed'] == '0')
+ {
+ if ($cur_post['poster_id'] == $pun_user['id'])
+ {
+ if (($pun_page['start_from'] + $pun_page['item_count']) == 1 && $pun_user['g_delete_topics'] == '1')
+ $pun_page['post_options'][] = '
'.$lang_topic['Delete topic'].'';
+ if (($pun_page['start_from'] + $pun_page['item_count']) > 1 && $pun_user['g_delete_posts'] == '1')
+ $pun_page['post_options'][] = '
'.$lang_topic['Delete'].' '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'';
+ if ($pun_user['g_edit_posts'] == '1')
+ $pun_page['post_options'][] = '
'.$lang_topic['Edit'].' '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'';
+ }
+
+ if (($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1')
+ $pun_page['post_options'][] = '
'.$lang_topic['Quote'].' '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'';
+ }
+ }
+ else
+ {
+ if (($pun_page['start_from'] + $pun_page['item_count']) == 1)
+ $pun_page['post_options'][] = '
'.$lang_topic['Delete topic'].'';
+ else
+ $pun_page['post_options'][] = '
'.$lang_topic['Delete'].' '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'';
+
+ $pun_page['post_options'][] = '
'.$lang_topic['Edit'].' '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'';
+ $pun_page['post_options'][] = '
'.$lang_topic['Quote'].' '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'';
+ }
+ }
+
+ // Give the post some class
+ $pun_page['item_status'] = array(
+ 'post',
+ ($pun_page['item_count'] % 2 == 0) ? 'odd' : 'even'
+ );
+
+ if ($pun_page['item_count'] == 1)
+ $pun_page['item_status'][] = 'firstpost';
+
+ if (($pun_page['start_from'] + $pun_page['item_count']) == $pun_page['finish_at'])
+ $pun_page['item_status'][] = 'lastpost';
+
+ if ($cur_post['id'] == $cur_topic['first_post_id'])
+ $pun_page['item_status'][] = 'topicpost';
+ else
+ $pun_page['item_status'][] = 'replypost';
+
+
+ // Generate the post title
+ if ($cur_post['id'] == $cur_topic['first_post_id'])
+ $pun_page['item_subject'] = $lang_common['Topic'].': '.$cur_topic['subject'];
+ else
+ $pun_page['item_subject'] = $lang_common['Re'].' '.$cur_topic['subject'];
+
+ // Perform the main parsing of the message (BBCode, smilies, censor words etc)
+ $pun_page['message'][] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
+
+ if ($cur_post['edited'] != '')
+ $pun_page['message'][] = '
'.sprintf($lang_topic['Last edited'], htmlspecialchars($cur_post['edited_by']), format_time($cur_post['edited'])).'
';
+
+ // Do signature parsing/caching
+ if ($cur_post['signature'] != '' && $pun_user['show_sig'] != '0' && $pun_config['o_signatures'] == '1')
+ {
+ if (!isset($signature_cache[$cur_post['poster_id']]))
+ $signature_cache[$cur_post['poster_id']] = parse_signature($cur_post['signature']);
+
+ $pun_page['message'][] = '
'."\n\t\t\t\t\t\t\t\t".''."\n\t\t\t\t\t\t\t\t".$signature_cache[$cur_post['poster_id']]."\n\t\t\t\t\t\t\t".'
';
+ }
+
+ ($hook = get_hook('vt_row_pre_display')) ? eval($hook) : null;
+
+?>
+
+
+