home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / includes / topic_review.php < prev    next >
PHP Script  |  2004-01-10  |  11KB  |  263 lines

  1. <?php
  2. /***************************************************************************
  3.  *                              topic_review.php
  4.  *                            -------------------
  5.  *   begin                : Saturday, Feb 13, 2001
  6.  *   copyright            : (C) 2001 The phpBB Group
  7.  *   email                : support@phpbb.com
  8.  *
  9.  *   $Id: topic_review.php,v 1.5.2.1 2002/05/03 15:58:35 the_systech Exp $
  10.  *
  11.  *
  12.  ***************************************************************************/
  13. /***************************************************************************
  14. * phpbb2 forums port version 2.0.5 (c) 2003 - Nuke Cops (http://nukecops.com)
  15. *
  16. * Ported by Nuke Cops to phpbb2 standalone 2.0.5 Test
  17. * and debugging completed by the Elite Nukers and site members.
  18. *
  19. * You run this package at your sole risk. Nuke Cops and affiliates cannot
  20. * be held liable if anything goes wrong. You are advised to test this
  21. * package on a development system. Backup everything before implementing
  22. * in a production environment. If something goes wrong, you can always
  23. * backout and restore your backups.
  24. *
  25. * Installing and running this also means you agree to the terms of the AUP
  26. * found at Nuke Cops.
  27. *
  28. * This is version 2.0.5 of the phpbb2 forum port for PHP-Nuke. Work is based
  29. * on Tom Nitzschner's forum port version 2.0.6. Tom's 2.0.6 port was based
  30. * on the phpbb2 standalone version 2.0.3. Our version 2.0.5 from Nuke Cops is
  31. * now reflecting phpbb2 standalone 2.0.5 that fixes some bugs and the
  32. * invalid_session error message.
  33. ***************************************************************************/
  34. /***************************************************************************
  35.  *   This file is part of the phpBB2 port to Nuke 6.0 (c) copyright 2002
  36.  *   by Tom Nitzschner (tom@toms-home.com)
  37.  *   http://bbtonuke.sourceforge.net (or http://www.toms-home.com)
  38.  *
  39.  *   As always, make a backup before messing with anything. All code
  40.  *   release by me is considered sample code only. It may be fully
  41.  *   functual, but you use it at your own risk, if you break it,
  42.  *   you get to fix it too. No waranty is given or implied.
  43.  *
  44.  *   Please post all questions/request about this port on http://bbtonuke.sourceforge.net first,
  45.  *   then on my site. All original header code and copyright messages will be maintained
  46.  *   to give credit where credit is due. If you modify this, the only requirement is
  47.  *   that you also maintain all original copyright messages. All my work is released
  48.  *   under the GNU GENERAL PUBLIC LICENSE. Please see the README for more information.
  49.  *
  50.  ***************************************************************************/
  51. /***************************************************************************
  52.  *
  53.  *   This program is free software; you can redistribute it and/or modify
  54.  *   it under the terms of the GNU General Public License as published by
  55.  *   the Free Software Foundation; either version 2 of the License, or
  56.  *   (at your option) any later version.
  57.  *
  58.  *
  59.  ***************************************************************************/
  60.  
  61. function topic_review($topic_id, $is_inline_review)
  62. {
  63.         global $db, $board_config, $template, $lang, $images, $theme, $phpEx, $phpbb_root_path;
  64.         global $userdata, $user_ip;
  65.         global $orig_word, $replacement_word;
  66.         global $starttime;
  67.  
  68.         if ( !$is_inline_review )
  69.         {
  70.                 if ( !isset($topic_id) )
  71.                 {
  72.                         message_die(GENERAL_MESSAGE, 'Topic_not_exist');
  73.                 }
  74.  
  75.                 //
  76.                 // Get topic info ...
  77.                 //
  78.                 $sql = "SELECT t.topic_title, 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
  79.                         FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
  80.                         WHERE t.topic_id = $topic_id
  81.                                 AND f.forum_id = t.forum_id";
  82.                 if ( !($result = $db->sql_query($sql)) )
  83.                 {
  84.                         message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
  85.                 }
  86.  
  87.                 if ( !($forum_row = $db->sql_fetchrow($result)) )
  88.                 {
  89.                         message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
  90.                 }
  91.  
  92.                 $forum_id = $forum_row['forum_id'];
  93.                 $topic_title = $forum_row['topic_title'];
  94.  
  95.                 //
  96.                 // Start session management
  97.                 //
  98.                 $userdata = session_pagestart($user_ip, $forum_id, $nukeuser);
  99.                 init_userprefs($userdata);
  100.                 //
  101.                 // End session management
  102.                 //
  103.  
  104.                 $is_auth = array();
  105.                 $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
  106.  
  107.                 if ( !$is_auth['auth_read'] )
  108.                 {
  109.                         message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']));
  110.                 }
  111.         }
  112.  
  113.         //
  114.         // Define censored word matches
  115.         //
  116.         if ( empty($orig_word) && empty($replacement_word) )
  117.         {
  118.                 $orig_word = array();
  119.                 $replacement_word = array();
  120.  
  121.                 obtain_word_list($orig_word, $replacement_word);
  122.         }
  123.  
  124.         //
  125.         // Dump out the page header and load viewtopic body template
  126.         //
  127.         if ( !$is_inline_review )
  128.         {
  129.                 $gen_simple_header = TRUE;
  130.  
  131.                 $page_title = $lang['Topic_review'] . ' - ' . $topic_title;
  132.                 include("includes/page_header_review.php");
  133.  
  134.                 $template->set_filenames(array(
  135.                         'reviewbody' => 'posting_topic_review.tpl')
  136.                 );
  137.         }
  138.  
  139.         //
  140.         // Go ahead and pull all data for this topic
  141.         //
  142.         $sql = "SELECT u.username, u.user_id, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid
  143.                 FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
  144.                 WHERE p.topic_id = $topic_id
  145.                         AND p.poster_id = u.user_id
  146.                         AND p.post_id = pt.post_id
  147.                 ORDER BY p.post_time DESC
  148.                 LIMIT " . $board_config['posts_per_page'];
  149.         if ( !($result = $db->sql_query($sql)) )
  150.         {
  151.                 message_die(GENERAL_ERROR, 'Could not obtain post/user information', '', __LINE__, __FILE__, $sql);
  152.         }
  153.  
  154.         //
  155.         // Okay, let's do the loop, yeah come on baby let's do the loop
  156.         // and it goes like this ...
  157.         //
  158.         if ( $row = $db->sql_fetchrow($result) )
  159.         {
  160.                 $mini_post_img = $images['icon_minipost'];
  161.                 $mini_post_alt = $lang['Post'];
  162.  
  163.                 $i = 0;
  164.                 do
  165.                 {
  166.                         $poster_id = $row['user_id'];
  167.                         $poster = $row['username'];
  168.  
  169.                         $post_date = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
  170.  
  171.                         //
  172.                         // Handle anon users posting with usernames
  173.                         //
  174.                         if( $poster_id == ANONYMOUS && $row['post_username'] != '' )
  175.                         {
  176.                                 $poster = $row['post_username'];
  177.                                 $poster_rank = $lang['Guest'];
  178.                         }
  179.                         elseif ( $poster_id == ANONYMOUS )
  180.                         {
  181.                                 $poster = $lang['Guest'];
  182.                                 $poster_rank = '';
  183.                         }
  184.  
  185.                         $post_subject = ( $row['post_subject'] != '' ) ? $row['post_subject'] : '';
  186.  
  187.                         $message = $row['post_text'];
  188.                         $bbcode_uid = $row['bbcode_uid'];
  189.  
  190.                         //
  191.                         // If the board has HTML off but the post has HTML
  192.                         // on then we process it, else leave it alone
  193.                         //
  194.                         if ( !$board_config['allow_html'] && $row['enable_html'] )
  195.                         {
  196.                                 $message = preg_replace('#(<)([\/]?.*?)(>)#is', '<\2>', $message);
  197.                         }
  198.  
  199.                         if ( $bbcode_uid != "" )
  200.                         {
  201.                                 $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
  202.                         }
  203.  
  204.                         $message = make_clickable($message);
  205.  
  206.                         if ( count($orig_word) )
  207.                         {
  208.                                 $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
  209.                                 $message = preg_replace($orig_word, $replacement_word, $message);
  210.                         }
  211.  
  212.                         if ( $board_config['allow_smilies'] && $row['enable_smilies'] )
  213.                         {
  214.                                 $message = smilies_pass($message);
  215.                         }
  216.  
  217.                         $message = str_replace("\n", '<br />', $message);
  218.  
  219.                         //
  220.                         // Again this will be handled by the templating
  221.                         // code at some point
  222.                         //
  223.                         $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
  224.                         $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
  225.  
  226.                         $template->assign_block_vars('postrow', array(
  227.                                 'ROW_COLOR' => '#' . $row_color,
  228.                                 'ROW_CLASS' => $row_class,
  229.  
  230.                                 'MINI_POST_IMG' => $mini_post_img,
  231.                                 'POSTER_NAME' => $poster,
  232.                                 'POST_DATE' => $post_date,
  233.                                 'POST_SUBJECT' => $post_subject,
  234.                                 'MESSAGE' => $message,
  235.  
  236.                                 'L_MINI_POST_ALT' => $mini_post_alt)
  237.                         );
  238.  
  239.                         $i++;
  240.                 }
  241.                 while ( $row = $db->sql_fetchrow($result) );
  242.         }
  243.         else
  244.         {
  245.                 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist', '', __LINE__, __FILE__, $sql);
  246.         }
  247.  
  248.         $template->assign_vars(array(
  249.                 'L_AUTHOR' => $lang['Author'],
  250.                 'L_MESSAGE' => $lang['Message'],
  251.                 'L_POSTED' => $lang['Posted'],
  252.                 'L_POST_SUBJECT' => $lang['Post_subject'],
  253.                 'L_TOPIC_REVIEW' => $lang['Topic_review'])
  254.         );
  255.  
  256.         if ( !$is_inline_review )
  257.         {
  258.                 $template->pparse('reviewbody');
  259.                 include("includes/page_tail_review.php");
  260.         }
  261. }
  262.  
  263. ?>