daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3. *
  4. * @package Itschi
  5. * @since 2007/05/25
  6. *
  7. */
  8.  
  9. include('base.php');
  10.  
  11. $last_time = 0;
  12.  
  13. $res = $db->query(
  14.  
  15.     (($user->row) ? '
  16.  
  17.     SELECT t.*, f.*, tr.mark_time, fr.mark_time as forum_mark_time
  18.     FROM ' . TOPICS_TABLE . ' t
  19.         LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tr ON tr.topic_id = t.topic_id AND tr.user_id = ' . $user->row['user_id'] . '
  20.         LEFT JOIN ' . FORUMS_TRACK_TABLE . ' fr ON fr.forum_id = t.forum_id AND fr.user_id = ' . $user->row['user_id'] . '
  21.     ' : '
  22.  
  23.     SELECT t.*, f.*
  24.     FROM ' . TOPICS_TABLE . ' t
  25.  
  26.     ') . '
  27.  
  28.         LEFT JOIN ' . FORUMS_TABLE . ' f ON f.forum_id = t.forum_id
  29.     WHERE t.topic_id = ' . (int)$_GET['id']
  30. );
  31.  
  32. $row = $db->fetch_array($res);
  33. $db->free_result($res);
  34.  
  35. $user_level = ($user->row) ? $user->row['user_level'] + 1 : 0;
  36.  
  37. if (!$row)
  38. {
  39.     message_box('Das Thema existiert nicht', 'forum.php', 'zur&uuml;ck zum Forum');
  40. }
  41. else if ($user_level < $row['forum_level'])
  42. {
  43.     message_box('Du bist nicht berechtigt das Thema zu sehen', 'forum.php', 'zur&uuml;ck zum Forum');
  44. }
  45.  
  46. if ($user->row)
  47. {
  48.     if (isset($_GET['delete']))
  49.     {
  50.         include('includes/functions_topic.php');
  51.  
  52.         delete_topic_post($_GET['delete']);
  53.     }
  54.     else if (isset($_POST['option']))
  55.     {
  56.         include('includes/functions_topic.php');
  57.  
  58.         poll_vote($row, $_POST['option']);
  59.     }
  60.     else if (isset($_GET['close']))
  61.     {
  62.         include('includes/functions_topic.php');
  63.  
  64.         close_topic($row);
  65.     }
  66.     else if (isset($_GET['important']))
  67.     {
  68.         include('includes/functions_topic.php');
  69.  
  70.         important_topic($row);
  71.     }
  72. }
  73.  
  74. $track_post = '';
  75.  
  76. function set_page($topic_id, $post_id)
  77. {
  78.     global $db, $config;
  79.  
  80.     $res = $db->query('
  81.  
  82.         SELECT COUNT(*) FROM ' . POSTS_TABLE . '
  83.         WHERE topic_id = ' . $topic_id . '
  84.             AND post_id <= ' . (int)$post_id
  85.     );
  86.  
  87.     $row = $db->result($res, 0);
  88.     $db->free_result($res);
  89.  
  90.     $_GET['page'] = ceil($row/$config['posts_perpage']);
  91. }
  92.  
  93. if (isset($_GET['p']))
  94. {
  95.     set_page($row['topic_id'], $_GET['p']);
  96. }
  97.  
  98. if (isset($_GET['view']))
  99. {
  100.     $res2 = $db->query('
  101.  
  102.         SELECT post_id
  103.         FROM ' . POSTS_TABLE . '
  104.         WHERE topic_id = ' . $row['topic_id'] . '
  105.              AND post_time > ' . (int)max($row['mark_time'], $row['forum_mark_time'], $user->row['user_register']) . '
  106.         ORDER BY post_time ASC LIMIT 1
  107.     ');
  108.  
  109.     $row2 = $db->fetch_array($res2);
  110.     $db->free_result($res2);
  111.  
  112.     $track_post = $row2['post_id'];
  113.     set_page($row['topic_id'], $row2['post_id']);
  114. }
  115.  
  116. $db->query('
  117.  
  118.     UPDATE ' . TOPICS_TABLE . '
  119.     SET topic_views = topic_views + 1
  120.     WHERE topic_id = ' . $row['topic_id']
  121. );
  122.  
  123. if ($row['poll_title'])
  124. {
  125.     if ($user->row)
  126.     {
  127.         $res = $db->query('
  128.  
  129.             SELECT topic_id FROM ' . POLL_VOTES_TABLE . '
  130.             WHERE topic_id = ' . $row['topic_id'] . '
  131.                 AND user_id = ' . $user->row['user_id']
  132.  
  133.         );
  134.  
  135.         $voted = $db->fetch_array($res);
  136.         $db->free_result($res);
  137.     }
  138.     else
  139.     {
  140.         $voted = false;
  141.     }
  142.  
  143.     $user_voted = (!$user->row || isset($_GET['result']) || ($row['poll_time'] < time() && $row['poll_time'] != 0) || $voted);
  144.  
  145.     $res2 = $db->query('
  146.  
  147.         SELECT option_id, option_text, option_votes
  148.         FROM ' . POLL_OPTIONS_TABLE . '
  149.         WHERE topic_id = ' . $row['topic_id'] . '
  150.         ORDER BY option_id
  151.  
  152.     ');
  153.  
  154.     while ($row2 = $db->fetch_array($res2))
  155.     {
  156.         $pro = ($user_voted) ? (int)@round($row2['option_votes']/$row['poll_votes']*100, 0) : '';
  157.  
  158.         $tpl->block_assign('options', array(
  159.             'ID'    =>  $row2['option_id'],
  160.             'VOTES' =>  $row2['option_votes'],
  161.             'PRO'   =>  $pro,
  162.             'TEXT'  =>  htmlspecialchars($row2['option_text']),
  163.             'PIXEL' =>  ceil($pro*2.5+7)
  164.         ));
  165.     }
  166.  
  167.     $db->free_result($res2);
  168.  
  169.     $tpl->assign(array(
  170.         'POLL_TITLE'    =>  htmlspecialchars($row['poll_title']),
  171.         'POLL_VOTES'    =>  $row['poll_votes'],
  172.         'USER_VOTED'    =>  $user_voted
  173.     ));
  174. }
  175.  
  176. $page = (isset($_GET['page'])) ? max($_GET['page'], 1) : 1;
  177. $pages_num = ceil(($row['topic_posts']+1)/$config['posts_perpage']);
  178.  
  179. $res2 = $db->query('
  180.  
  181.     SELECT p.*, u.user_id, u.usertitel, u.username, u.user_rank, u.user_level, u.user_posts, u.user_avatar, u.user_signatur, u.user_signatur_bbcodes, u.user_signatur_smilies, u.user_signatur_urls
  182.     FROM ' . POSTS_TABLE . ' p
  183.         LEFT JOIN ' . USERS_TABLE . ' u ON u.user_id = p.user_id
  184.     WHERE p.topic_id = ' . $row['topic_id'] . '
  185.     ORDER BY p.post_id ASC
  186.     LIMIT ' . ($page * $config['posts_perpage'] - $config['posts_perpage']) . ', ' . $config['posts_perpage']
  187. );
  188.  
  189. while ($row2 = $db->fetch_array($res2))
  190. {
  191.     $last_time = $row2['post_time'];
  192.  
  193.     $tpl->block_assign('posts', array(
  194.         'ID'            =>  $row2['post_id'],
  195.         'TIME'          =>  date('d.m.y H:i', $row2['post_time']),
  196.         'TEXT'          =>  replace($row2['post_text'], $row2['enable_bbcodes'], $row2['enable_smilies'], $row2['enable_urls']),
  197.         'TRACK'         =>  ($track_post == $row2['post_id']) ? 'post' : $row2['post_id'],
  198.         'IS_TOPIC'      =>  $row2['is_topic'],
  199.         'EDIT_USER_ID'      =>  $row2['post_edit_user_id'],
  200.         'EDIT_USERNAME'     =>  $row2['post_edit_username'],
  201.         'EDIT_TIME'     =>  ($row2['post_edit_user_id']) ? date('d.m.y H:i', $row2['post_edit_time']) : '',
  202.         'EDIT_USER_LEGEND'  =>  $user->legend($row2['post_edit_user_level']),
  203.         'USERNAME'      =>  $row2['username'],
  204.         'USERTITEL'     =>  $row2['user_usertitel'],
  205.         'USER_ID'       =>  $row2['user_id'],
  206.         'USER_POSTS'        =>  number_format($row2['user_posts'], 0, '', '.'),
  207.         'USER_AVATAR'       =>  ($row2['user_avatar']) ? $row2['user_avatar'] : $config['default_avatar'],
  208.         'USER_LEGEND'       =>  $user->legend($row2['user_level']),
  209.         'USER_RANK'     =>  $user->rank($row2['user_id'], $row2['user_rank'], $row2['user_posts']),
  210.         'USER_RANK_ICON'    =>  $user->rank_icon($row2['user_id'], $row2['user_rank'], $row2['user_posts']),
  211.         'USER_SIGNATUR'     =>  ($row2['enable_signatur'] && $row2['user_signatur']) ? replace($row2['user_signatur'], $row2['user_signatur_bbcodes'], $row2['user_signatur_smilies'], $row2['user_signatur_urls']) : false
  212.     ));
  213. }
  214.  
  215. $db->free_result($res2);
  216.  
  217. if ($user->row && max($user->row['user_register'], $row['forum_mark_time'], $row['mark_time']) < $last_time)
  218. {
  219.     include('includes/functions_topic.php');
  220.  
  221.     mark_topic( $row['user_usertitel'], $row['topic_id'], $row['forum_id'], $row['forum_last_post_time'], $row['forum_mark_time'], $last_time);
  222. }
  223.  
  224. $tpl->assign(array(
  225.     'TITLE_TAG'     =>  'Forum | ' . htmlspecialchars($row['topic_title']) . ' | ',
  226.     'IS_MOD'        =>  ($user->row['user_level'] == ADMIN || $user->row['user_level'] == MOD),
  227.     'FORUM_ID'      =>  $row['forum_id'],
  228.     'FORUM_NAME'        =>  $row['forum_name'],
  229.     'FORUM_CLOSED'      =>  $row['forum_closed'],
  230.     'TOPIC_ID'      =>  $row['topic_id'],
  231.     'TOPIC_TITLE'       =>  htmlspecialchars($row['topic_title']),
  232.     'TOPIC_POSTS'       =>  number_format($row['topic_posts'], 0, '', '.'),
  233.     'TOPIC_CLOSED'      =>  $row['topic_closed'],
  234.     'TOPIC_IMPORTANT'   =>  $row['topic_important'],
  235.     'AVATAR'        =>  $config['default_avatar'],
  236.     'PAGE'          =>  $page,
  237.     'PAGES_NUM'     =>  $pages_num,
  238.     'USERTITEL'     =>  $row['user_usertitel'],
  239.     'PAGES'         =>  ($pages_num > 1) ? pages($pages_num, $page, 'viewtopic.php?id=' . $row['topic_id'] . '&page=') : ''
  240. ));
  241.  
  242. $tpl->display('viewtopic.tpl');
  243.  
  244. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top