diff -r e3d7322305bf -r 5e1f1e916419 punbb/viewtopic.php --- a/punbb/viewtopic.php Sun Sep 02 11:00:57 2007 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,398 +0,0 @@ -query('SELECT topic_id FROM '.$pun_db->prefix.'posts WHERE id='.$pid) or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); - if (!$pun_db->num_rows($result)) - message($lang_common['Bad request']); - - $id = $pun_db->result($result); - - // Determine on what page the post is located (depending on $pun_user['disp_posts']) - $result = $pun_db->query('SELECT id FROM '.$pun_db->prefix.'posts WHERE topic_id='.$id.' ORDER BY posted') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); - $num_posts = $pun_db->num_rows($result); - - for ($i = 0; $i < $num_posts; ++$i) - { - $cur_id = $pun_db->result($result, $i); - if ($cur_id == $pid) - break; - } - ++$i; // we started at 0 - - $_GET['p'] = ceil($i / $pun_user['disp_posts']); -} - -// If action=new, we redirect to the first new post (if any) -else if ($action == 'new' && !$pun_user['is_guest']) -{ - $result = $pun_db->query('SELECT MIN(id) FROM '.$pun_db->prefix.'posts WHERE topic_id='.$id.' AND posted>'.$pun_user['last_visit']) or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); - $first_new_post_id = $pun_db->result($result); - - if ($first_new_post_id) - header('Location: viewtopic.php?pid='.$first_new_post_id.'#p'.$first_new_post_id); - else // If there is no new post, we go to the last post - header('Location: viewtopic.php?id='.$id.'&action=last'); - - exit; -} - -// If action=last, we redirect to the last post -else if ($action == 'last') -{ - $result = $pun_db->query('SELECT MAX(id) FROM '.$pun_db->prefix.'posts WHERE topic_id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); - $last_post_id = $pun_db->result($result); - - if ($last_post_id) - { - header('Location: viewtopic.php?pid='.$last_post_id.'#p'.$last_post_id); - exit; - } -} - - -// Fetch some info about the topic -if (!$pun_user['is_guest']) - $result = $pun_db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed FROM '.$pun_db->prefix.'topics AS t INNER JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $pun_db->error()); -else - $result = $pun_db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM '.$pun_db->prefix.'topics AS t INNER JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $pun_db->error()); - -if (!$pun_db->num_rows($result)) - message($lang_common['Bad request']); - -$cur_topic = $pun_db->fetch_assoc($result); - -// Sort out who the moderators are and if we are currently a moderator (or an admin) -$mods_array = ($cur_topic['moderators'] != '') ? unserialize($cur_topic['moderators']) : array(); -$is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array))) ? true : false; - -// Can we or can we not post replies? -if ($cur_topic['closed'] == '0') -{ - if (($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1' || $is_admmod) - $post_link = ''.$lang_topic['Post reply'].''; - else - $post_link = ' '; -} -else -{ - $post_link = $lang_topic['Topic closed']; - - if ($is_admmod) - $post_link .= ' / '.$lang_topic['Post reply'].''; -} - - -// Determine the post offset (based on $_GET['p']) -$num_pages = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']); - -$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p']; -$start_from = $pun_user['disp_posts'] * ($p - 1); - -// Generate paging links -$paging_links = $lang_common['Pages'].': '.pun_paginate($num_pages, $p, 'viewtopic.php?id='.$id); - - -if ($pun_config['o_censoring'] == '1') - $cur_topic['subject'] = censor_words($cur_topic['subject']); - - -$quickpost = false; -if ($pun_config['o_quickpost'] == '1' && - !$pun_user['is_guest'] && - ($cur_topic['post_replies'] == '1' || ($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1')) && - ($cur_topic['closed'] == '0' || $is_admmod)) -{ - $required_fields = array('req_message' => $lang_common['Message']); - $quickpost = true; -} - -if (!$pun_user['is_guest'] && $pun_config['o_subscriptions'] == '1') -{ - if ($cur_topic['is_subscribed']) - // I apologize for the variable naming here. It's a mix of subscription and action I guess :-) - $subscraction = ''."\n"; - else - $subscraction = ''."\n"; -} -else - $subscraction = '
'."\n"; - -$page_title = pun_htmlspecialchars($pun_config['o_board_title'].' / '.$cur_topic['subject']); -define('PUN_ALLOW_INDEX', 1); -require PUN_ROOT.'header.php'; - -?> -
-
- - - -
-
-
- -query('SELECT eu.email, u.title, u.url, u.location, u.use_avatar, 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 '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.table_prefix.'users AS eu ON eu.user_id=u.id INNER JOIN '.$pun_db->prefix.'groups AS g ON g.g_id=u.group_id LEFT JOIN '.$pun_db->prefix.'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 '.$start_from.','.$pun_user['disp_posts'], true) or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); -while ($cur_post = $pun_db->fetch_assoc($result)) -{ - $post_count++; - $user_avatar = ''; - $user_info = array(); - $user_contacts = array(); - $post_actions = array(); - $is_online = ''; - $signature = ''; - - // If the poster is a registered user. - if ($cur_post['poster_id'] > 1) - { - $username = ''.pun_htmlspecialchars($cur_post['username']).''; - $user_title = get_title($cur_post); - - if ($pun_config['o_censoring'] == '1') - $user_title = censor_words($user_title); - - // Format the online indicator - $is_online = ($cur_post['is_online'] == $cur_post['poster_id']) ? ''.$lang_topic['Online'].'' : $lang_topic['Offline']; - - if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0') - { - if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif')) - $user_avatar = ''; - else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg')) - $user_avatar = ''; - else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png')) - $user_avatar = ''; - } - else - $user_avatar = ''; - - // We only show location, register date, post count and the contact links if "Show user info" is enabled - if ($pun_config['o_show_user_info'] == '1') - { - if ($cur_post['location'] != '') - { - if ($pun_config['o_censoring'] == '1') - $cur_post['location'] = censor_words($cur_post['location']); - - $user_info[] = '
'.$lang_topic['From'].': '.pun_htmlspecialchars($cur_post['location']); - } - - $user_info[] = '
'.$lang_common['Registered'].': '.date($pun_config['o_date_format'], $cur_post['registered']); - - if ($pun_config['o_show_post_count'] == '1' || $pun_user['g_id'] >= USER_LEVEL_MEMBER) - $user_info[] = '
'.$lang_common['Posts'].': '.$cur_post['num_posts']; - - // Now let's deal with the contact links (E-mail and URL) - if (($cur_post['email_setting'] == '0' && !$pun_user['is_guest']) || $pun_user['g_id'] >= USER_LEVEL_MEMBER) - $user_contacts[] = ''.$lang_common['E-mail'].''; - else if ($cur_post['email_setting'] == '1' && !$pun_user['is_guest']) - $user_contacts[] = ''.$lang_common['E-mail'].''; - - if ($cur_post['url'] != '') - $user_contacts[] = ''.$lang_topic['Website'].''; - } - - if ($pun_user['g_id'] >= USER_LEVEL_MEMBER) - { - $user_info[] = '
IP: '.$cur_post['poster_ip'].''; - - if ($cur_post['admin_note'] != '') - $user_info[] = '
'.$lang_topic['Note'].': '.pun_htmlspecialchars($cur_post['admin_note']).''; - } - } - // If the poster is a guest (or a user that has been deleted) - else - { - $username = pun_htmlspecialchars($cur_post['username']); - $user_title = get_title($cur_post); - - if ($pun_user['g_id'] >= USER_LEVEL_MEMBER) - $user_info[] = '
IP: '.$cur_post['poster_ip'].''; - - if ($pun_config['o_show_user_info'] == '1' && $cur_post['poster_email'] != '' && !$pun_user['is_guest']) - $user_contacts[] = ''.$lang_common['E-mail'].''; - } - - // Generation post action array (quote, edit, delete etc.) - if (!$is_admmod) - { - if (!$pun_user['is_guest']) - $post_actions[] = '
  • '.$lang_topic['Report'].''; - - if ($cur_topic['closed'] == '0') - { - if ($cur_post['poster_id'] == $pun_user['id']) - { - if ((($start_from + $post_count) == 1 && $pun_user['g_delete_topics'] == '1') || (($start_from + $post_count) > 1 && $pun_user['g_delete_posts'] == '1')) - $post_actions[] = '
  • '.$lang_topic['Delete'].''; - if ($pun_user['g_edit_posts'] == '1') - $post_actions[] = '
  • '.$lang_topic['Edit'].''; - } - - if (($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1') - $post_actions[] = '
  • '.$lang_topic['Quote'].''; - } - } - else - $post_actions[] = '
  • '.$lang_topic['Report'].''.$lang_topic['Link separator'].'
  • '.$lang_topic['Delete'].''.$lang_topic['Link separator'].'
  • '.$lang_topic['Edit'].''.$lang_topic['Link separator'].'
  • '.$lang_topic['Quote'].''; - - - // Switch the background color for every message. - $bg_switch = ($bg_switch) ? $bg_switch = false : $bg_switch = true; - $vtbg = ($bg_switch) ? ' roweven' : ' rowodd'; - - - // Perform the main parsing of the message (BBCode, smilies, censor words etc) - $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']); - - // Do signature parsing/caching - if ($cur_post['signature'] != '' && $pun_user['show_sig'] != '0') - { - if (isset($signature_cache[$cur_post['poster_id']])) - $signature = $signature_cache[$cur_post['poster_id']]; - else - { - $signature = parse_signature($cur_post['signature']); - $signature_cache[$cur_post['poster_id']] = $signature; - } - } - -?> -
    -

    # 

    -
    -
    -
    -
    -
    -
    -
    -'."\n\t\t\t\t\t", $user_info).'
  • '."\n"; ?> -'.implode('  ', $user_contacts).''."\n"; ?> - - -
    -

    1) echo ' Re: '; ?>

    -
    - -'.$lang_topic['Last edit'].' '.pun_htmlspecialchars($cur_post['edited_by']).' ('.format_time($cur_post['edited']).')

    '."\n"; ?> -
    -
    '.$signature.'
    '."\n"; ?> - -
    -
    1) echo '

    '.$is_online.'

    '; ?>
    -
    '.implode($lang_topic['Link separator'].'', $post_actions).'
    '."\n" : '
     
    '."\n" ?> - - - - - -
    -
    - - - - -
    -
    - - -
    -

    -
    -
    -
    -
    - -
    - - - - -
    -
    -
    -

    -
    -
    -
    -query('UPDATE '.$low_prio.$pun_db->prefix.'topics SET num_views=num_views+1 WHERE id='.$id) or error('Unable to update topic', __FILE__, __LINE__, $pun_db->error()); - -$forum_id = $cur_topic['forum_id']; -$footer_style = 'viewtopic'; -require PUN_ROOT.'footer.php';