[問題]這mod我整錯咩??rank_gain_access_1.0

phpBB 2 MOD Support
無論是官方或非官方認證之外掛,安裝與使用問題討論。
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

主題已鎖定
nathan
星球普通子民
星球普通子民
文章: 11
註冊時間: 2004-02-12 19:51
聯繫:

[問題]這mod我整錯咩??rank_gain_access_1.0

文章 nathan »

代碼: 選擇全部

############################################################## 
## MOD Title :       Rank Gain Access 
## MOD Author :    Poupoune < kristff@hotmail.com > (N/A) http://www.phpbb-fr.com 
## 
## MOD Description :    Allows you to choose in the board the way to give members access 
##  to a given rank, by with the the classical way according to the number 
##  of posts of the member, or according to  how many points the member owns 
##  gained with a system point. The MOD is compliant with the Cash MOD of Xore 
##  and the Point System of eXplosive. If no system points is installed, the 
##  option of choosing the rank according to how many points the member has 
##  will be disabled.           
## 
## MOD Version : 1.0.0 
## 
## Installation Level: Moderate 
## Installation Time:  10 minute(s) 
## Files to edit :   8 
##    includes/constants.php 
##   admin/admin_ranks.php 
##   includes/usercp_register.php 
##   includes/usercp_viewprofile.php 
##   viewtopic.php 
##   language/lang_english/lang_admin.php 
##   templates/subSilver/admin/ranks_list_body.tpl 
##   templates/subSilver/admin/ranks_edit_body.tpl 
##      
## Files included :   0 
## 
############################################################## 
## Pour des raisons de s嶰urit? vous 皻es prier de consulter 
## r嶲uli鋨ement http://forums.phpbb-fr.com afin d'obtenir la 
## derni鋨e version de ce MOD. 
## T幨嶰harger ce MOD ?partir des sites autres que phpBB-fr.com 
## peut 皻re dangereux pour votre forum phpBB. 
## Par cons廦uent, phpBB-fr.com n'assurera aucun support pour 
## les MODs absents de leur base de donn嶪s, consultable sur: 
## http://forums.phpbb-fr.com/ 
############################################################## 
## Author Notes : 
## 
## If you use Cash MOD of Xore as a point system, you will have to 
## create a currency named 'points' that add a user_points field 
## to the users table, to make the MOD works well. 
## 
############################################################## 
## MOD History: 
## 
##   05-07-2004 - Version 1.0.0 
## 
############################################################## 
## Avant d'ajouter ce MOD ?votre forum, il vous est fortement conseill? 
## d'effectuer une sauvegarde des 幨幦ents que vous allez modifier. 
############################################################## 

# 
#-----[ SQL ]---------------------------------------------- 
# 

ALTER TABLE phpbb_ranks ADD rank_choose_minimum tinyint(1) not null; 

# 
#-----[ OPEN ]---------------------------------------------- 
# 

includes/constants.php 

# 
#-----[ FIND ]---------------------------------------------- 
# 

define('USER_AVATAR_GALLERY', 3); 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

// Rank gain access MOD 
define('USER_POINTS_MINIMUM', 1); 
define('USER_POSTS_MINIMUM', 0); 


# 
#-----[ OPEN ]---------------------------------------------- 
# 

admin/admin_ranks.php 

# 
#-----[ FIND ]---------------------------------------------- 
# 

    $rank_is_special = ( $rank_info['rank_special'] ) ? "checked=\"checked\"" : ""; 
    $rank_is_not_special = ( !$rank_info['rank_special'] ) ? "checked=\"checked\"" : ""; 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

  $rank_minimum_posts = ( !$rank_info['rank_choose_minimum'] ) ? "checked=\"checked\"" : ""; 
  $rank_minimum_points = ( $rank_info['rank_choose_minimum'] ) ? "checked=\"checked\"" : ""; 
    
  $sql = "SELECT * FROM " . USERS_TABLE ." 
     WHERE user_points";    
  
  if( !$result = $db->sql_query($sql) ) 
  { 
\n    $lock_points = 'disabled'; 
    $template->assign_block_vars('switch_no_point_explain', array() ); 
  } 
  else 
  { 
     $lock_points = ''; 
     $template->assign_block_vars('switch_point_system_explain', array() ); 
  } 


# 
#-----[ FIND ]---------------------------------------------- 
# 

    "MINIMUM" => ( $rank_is_special ) ? "" : $rank_info['rank_min'], 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

    "RANK_MINIMUM_POSTS" => $rank_minimum_posts, 
    "RANK_MINIMUM_POINTS" => $rank_minimum_points, 
    "LOCK_POINTS" => $lock_points, 

# 
#-----[ FIND ]---------------------------------------------- 
# 

    "L_RANK_SPECIAL" => $lang['Rank_special'], 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

    "L_RANK_CHOOSE_MINIMUM" => $lang['Rank_choose_minimum'], 
    "L_RANK_POINT_SYSTEM_EXPLAIN" => $lang['Rank_point_system_explain'], 
    "L_RANK_NO_POINT_EXPLAIN" => $lang['Rank_no_point_explain'], 
    "L_POINTS" => $lang['Points'], 
    "L_POSTS" => $lang['Posts'], 

# 
#-----[ FIND ]---------------------------------------------- 
# 

    $special_rank = ( $HTTP_POST_VARS['special_rank'] == 1 ) ? TRUE : 0; 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

    $rank_choose_minimum = ( $HTTP_POST_VARS['rank_choose_minimum'] == 1 ) ? TRUE : 0; 

# 
#-----[ FIND ]---------------------------------------------- 
# 

    $sql = "UPDATE " . RANKS_TABLE . " 
      SET 

# 
#-----[ IN-LINE FIND ]---------------------------------------------- 
# 

rank_image = '" . str_replace("\'", "''", $rank_image) . "'    

# 
#-----[ IN-LINE AFTER, ADD ]---------------------------------------------- 
# 

, rank_choose_minimum = $rank_choose_minimum    


# 
#-----[ FIND ]---------------------------------------------- 
# 

$sql = "INSERT INTO " . RANKS_TABLE . " 

# 
#-----[ IN-LINE FIND ]---------------------------------------------- 
# 

, rank_image    

# 
#-----[ IN-LINE AFTER, ADD ]---------------------------------------------- 
# 

, rank_choose_minimum    

# 
#-----[ FIND ]---------------------------------------------- 
# 

)"; 

# 
#-----[ BEFORE, ADD ]---------------------------------------------- 
# 

, $rank_choose_minimum 

# 
#-----[ FIND ]---------------------------------------------- 
# 

      "L_RANK_MINIMUM" => $lang['Rank_minimum'], 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

      "L_RANK_CHOOSE_MINIMUM" => $lang['Rank_choose_minimum'], 

# 
#-----[ FIND ]---------------------------------------------- 
# 

      $special_rank = $rank_rows[$i]['rank_special']; 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

      $rank_choose_minimum = $rank_rows[$i]['rank_choose_minimum']; 

# 
#-----[ FIND ]---------------------------------------------- 
# 

      "SPECIAL_RANK" => ( $special_rank == 1 ) ? $lang['Yes'] : $lang['No'], 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

      "RANK_CHOOSE_MINIMUM" => ( $rank_choose_minimum == 1 ) ? $lang['Points'] : $lang['Posts'], 

# 
#-----[ FIND ]---------------------------------------------- 
# 

      "L_RANK_MINIMUM" => $lang['Rank_minimum'], 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

      "L_RANK_CHOOSE_MINIMUM" => $lang['Rank_choose_minimum'], 

# 
#-----[ FIND ]---------------------------------------------- 
# 

      $special_rank = $rank_rows[$i]['rank_special']; 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

      $rank_choose_minimum = $rank_rows[$i]['rank_choose_minimum']; 

# 
#-----[ FIND ]---------------------------------------------- 
# 

      $rank_is_special = ( $special_rank ) ? $lang['Yes'] : $lang['No']; 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

      $rank_selected_minimum = ( $rank_choose_minimum ) ? $lang['Points'] : $lang['Posts']; 

# 
#-----[ FIND ]---------------------------------------------- 
# 

      "SPECIAL_RANK" => $rank_is_special, 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

      "RANK_CHOOSE_MINIMUM" => $rank_selected_minimum, 

# 
#-----[ OPEN ]---------------------------------------------- 
# 

includes/usercp_viewprofile.php 

# 
#-----[ FIND ]---------------------------------------------- 
# 

else 
{ 
  for($i = 0; $i < count($ranksrow); $i++) 
  { 
    if ( $profiledata['user_posts'] >= $ranksrow[$i]['rank_min'] && !$ranksrow[$i]['rank_special'] ) 
    { 
      $poster_rank = $ranksrow[$i]['rank_title']; 
      $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : ''; 
    } 
  } 
} 

# 
#-----[ REPLACE WITH ]---------------------------------------------- 
# 

else 
{ 
  for($i = 0; $i < count($ranksrow); $i++) 
  { 
    if( $ranksrow[$i]['rank_choose_minimum'] == USER_POSTS_MINIMUM ) 
    { 
      if ( $profiledata['user_posts'] >= $ranksrow[$i]['rank_min'] && !$ranksrow[$i]['rank_special'] ) 
      { 
   $poster_rank = $ranksrow[$i]['rank_title']; 
   $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : ''; 
      } 
    } 
    if ( $ranksrow[$i]['rank_choose_minimum'] == USER_POINTS_MINIMUM ) 
    { 
      if ( $profiledata['user_points'] >= $ranksrow[$i]['rank_min'] && !$ranksrow[$i]['rank_special'] ) 
      { 
        $poster_rank = $ranksrow[$i]['rank_title']; 
        $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : ''; 
      } 
    }  
  } 
} 

# 
#-----[ OPEN ]---------------------------------------------- 
# 

viewtopic.php 

# 
#-----[ FIND ]---------------------------------------------- 
# 

  else 
  { 
    for($j = 0; $j < count($ranksrow); $j++) 
    { 
      if ( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] ) 
      { 
        $poster_rank = $ranksrow[$j]['rank_title']; 
   $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : ''; 
      } 
    } 
  } 

# 
#-----[ REPLACE WITH ]---------------------------------------------- 
# 

  else 
  { 
    for($j = 0; $j < count($ranksrow); $j++) 
    { 
      if ( $ranksrow[$j]['rank_choose_minimum'] == USER_POSTS_MINIMUM ) 
      { 
        if ( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] ) 
   { 
     $poster_rank = $ranksrow[$j]['rank_title']; 
     $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : ''; 
   } 
      } 
      if ( $ranksrow[$j]['rank_choose_minimum'] == USER_POINTS_MINIMUM )  
      { 
        if ( $postrow[$i]['user_points'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] ) 
   { 
     $poster_rank = $ranksrow[$j]['rank_title']; 
     $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : ''; 
   } 
      }  
    } 
  } 

# 
#-----[ OPEN ]---------------------------------------------- 
# 

language/lang_english/lang_admin.php 

# 
#-----[ FIND ]---------------------------------------------- 
# 

$lang['Rank_minimum'] = ' 

# 
#-----[ REPLACE WITH ]---------------------------------------------- 
# 

// D嶵ut Rank gain access MOD 
$lang['Rank_minimum'] = 'Minimum Posts / Points'; 
$lang['Points'] = 'Points'; 
$lang['Posts'] = 'Posts'; 
$lang['Rank_choose_minimum'] = 'Choice of attribution of ranks'; 
$lang['Rank_point_system_explain'] = 'A compliant points system has been detected on this board'; 
$lang['Rank_no_point_explain'] = 'No compliant points system has been installed on this board'; 
// Fin rank gain access MOD 

# 
#-----[ OPEN ]---------------------------------------------- 
# 

templates/subSilver/admin/ranks_list_body.tpl 

# 
#-----[ FIND ]---------------------------------------------- 
# 

<th class="thTop">{L_RANK_MINIMUM}</th> 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

<th class="thTop">{L_RANK_CHOOSE_MINIMUM}</th> 

# 
#-----[ FIND ]---------------------------------------------- 
# 

<td class="{ranks.ROW_CLASS}" align="center">{ranks.RANK_MIN}</td> 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

<td class="{ranks.ROW_CLASS}" align="center">{ranks.RANK_CHOOSE_MINIMUM}</td> 

# 
#-----[ OPEN ]---------------------------------------------- 
# 

templates/subSilver/admin/ranks_edit_body.tpl 

# 
#-----[ FIND ]---------------------------------------------- 
# 

  <tr> 
    <td class="row1"><span class="gen">{L_RANK_SPECIAL}</span></td> 
    <td class="row2"><input type="radio" name="special_rank" value="1" {SPECIAL_RANK} />{L_YES}   <input type="radio" name="special_rank" value="0" {NOT_SPECIAL_RANK} /> {L_NO}</td> 
  </tr> 

# 
#-----[ AFTER, ADD ]---------------------------------------------- 
# 

  <tr> 
    <td class="row1"><span class="gen">{L_RANK_CHOOSE_MINIMUM}</span><br /> 
    <span class="gensmall"> 
    <!-- BEGIN switch_point_system_explain --> 
    {L_RANK_POINT_SYSTEM_EXPLAIN}* 
    <!-- END switch_point_system_explain --> 
    <!-- BEGIN switch_no_point_explain --> 
    {L_RANK_NO_POINT_EXPLAIN}* 
    <!-- END switch_no_point_explain --> 
    </span></td> 
    <td class="row2"><input type="radio" name="rank_choose_minimum" value="0" {RANK_MINIMUM_POSTS} />{L_POSTS}   <input type="radio" name="rank_choose_minimum" {LOCK_POINTS} value="1" {RANK_MINIMUM_POINTS} /> {L_POINTS}</td> 
  </tr> 

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoF 
nathan
星球普通子民
星球普通子民
文章: 11
註冊時間: 2004-02-12 19:51
聯繫:

文章 nathan »

admin_ranks

代碼: 選擇全部

<?php 
/*************************************************************************** 
 *                              admin_ranks.php 
 *                            ------------------- 
 *   begin                : Thursday, Jul 12, 2001 
 *   copyright            : (C) 2001 The phpBB Group 
 *   email                : support@phpbb.com 
 * 
 *   $Id: admin_ranks.php,v 1.13.2.4 2004/03/25 15:57:20 acydburn Exp $ 
 * 
 ***************************************************************************/ 

/*************************************************************************** 
 * 
 *   This program is free software; you can redistribute it and/or modify 
 *   it under the terms of the GNU General Public License as published by 
 *   the Free Software Foundation; either version 2 of the License, or 
 *   (at your option) any later version. 
 * 
 ***************************************************************************/ 

define('IN_PHPBB', 1); 

if( !empty($setmodules) ) 
{ 
   $file = basename(__FILE__); 
   $module['Users']['Ranks'] = "$file"; 
   return; 
} 

// 
// Let's set the root dir for phpBB 
// 
$phpbb_root_path = "./../"; 
require($phpbb_root_path . 'extension.inc'); 
require('./pagestart.' . $phpEx); 

if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) 
{ 
   $mode = ($HTTP_GET_VARS['mode']) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; 
   $mode = htmlspecialchars($mode); 
} 
else 
{ 
   // 
   // These could be entered via a form button 
   // 
   if( isset($HTTP_POST_VARS['add']) ) 
   { 
      $mode = "add"; 
   } 
   else if( isset($HTTP_POST_VARS['save']) ) 
   { 
      $mode = "save"; 
   } 
   else 
   { 
      $mode = ""; 
   } 
} 


if( $mode != "" ) 
{ 
   if( $mode == "edit" || $mode == "add" ) 
   { 
      // 
      // They want to add a new rank, show the form. 
      // 
      $rank_id = ( isset($HTTP_GET_VARS['id']) ) ? intval($HTTP_GET_VARS['id']) : 0; 
       
      $s_hidden_fields = ""; 
       
      if( $mode == "edit" ) 
      { 
         if( empty($rank_id) ) 
         { 
            message_die(GENERAL_MESSAGE, $lang['Must_select_rank']); 
         } 

         $sql = "SELECT * FROM " . RANKS_TABLE . " 
            WHERE rank_id = $rank_id"; 
         if(!$result = $db->sql_query($sql)) 
         { 
            message_die(GENERAL_ERROR, "Couldn't obtain rank data", "", __LINE__, __FILE__, $sql); 
         } 
          
         $rank_info = $db->sql_fetchrow($result); 
         $s_hidden_fields .= '<input type="hidden" name="id" value="' . $rank_id . '" />'; 

      } 
      else 
      { 
         $rank_info['rank_special'] = 0; 
      } 

      $s_hidden_fields .= '<input type="hidden" name="mode" value="save" />'; 

      $rank_is_special = ( $rank_info['rank_special'] ) ? "checked=\"checked\"" : ""; 
      $rank_is_not_special = ( !$rank_info['rank_special'] ) ? "checked=\"checked\"" : "";  $rank_minimum_posts = ( !$rank_info['rank_choose_minimum'] ) ? "checked=\"checked\"" : "";  $rank_minimum_points = ( $rank_info['rank_choose_minimum'] ) ? "checked=\"checked\"" : "";  $sql = "SELECT * FROM " . USERS_TABLE ."     WHERE user_points";  if( !$result = $db->sql_query($sql) )  {    $lock_points = 'disabled';    $template->assign_block_vars('switch_no_point_explain', array() );  }  else  {     $lock_points = '';     $template->assign_block_vars('switch_point_system_explain', array() );  } 
       
      $template->set_filenames(array( 
         "body" => "admin/ranks_edit_body.tpl") 
      ); 

      $template->assign_vars(array( 
         "RANK" => $rank_info['rank_title'], 
         "SPECIAL_RANK" => $rank_is_special,      "RANK_CHOOSE_MINIMUM" => $rank_selected_minimum, 
         "NOT_SPECIAL_RANK" => $rank_is_not_special, 
         "MINIMUM" => ( $rank_is_special ) ? "" : $rank_info['rank_min'],    "RANK_MINIMUM_POSTS" => $rank_minimum_posts,    "RANK_MINIMUM_POINTS" => $rank_minimum_points,    "LOCK_POINTS" => $lock_points, 
         "IMAGE" => ( $rank_info['rank_image'] != "" ) ? $rank_info['rank_image'] : "", 
         "IMAGE_DISPLAY" => ( $rank_info['rank_image'] != "" ) ? '<img src="../' . $rank_info['rank_image'] . '" />' : "", 
          
         "L_RANKS_TITLE" => $lang['Ranks_title'], 
         "L_RANKS_TEXT" => $lang['Ranks_explain'], 
         "L_RANK_TITLE" => $lang['Rank_title'], 
         "L_RANK_SPECIAL" => $lang['Rank_special'],    "L_RANK_CHOOSE_MINIMUM" => $lang['Rank_choose_minimum'],    "L_RANK_POINT_SYSTEM_EXPLAIN" => $lang['Rank_point_system_explain'],    "L_RANK_NO_POINT_EXPLAIN" => $lang['Rank_no_point_explain'],    "L_POINTS" => $lang['Points'],    "L_POSTS" => $lang['Posts'], 
         "L_RANK_MINIMUM" => $lang['Rank_minimum'],      "L_RANK_CHOOSE_MINIMUM" => $lang['Rank_choose_minimum'],      "L_RANK_CHOOSE_MINIMUM" => $lang['Rank_choose_minimum'], 
         "L_RANK_IMAGE" => $lang['Rank_image'], 
         "L_RANK_IMAGE_EXPLAIN" => $lang['Rank_image_explain'], 
         "L_SUBMIT" => $lang['Submit'], 
         "L_RESET" => $lang['Reset'], 
         "L_YES" => $lang['Yes'], 
         "L_NO" => $lang['No'], 
          
         "S_RANK_ACTION" => append_sid("admin_ranks.$phpEx"), 
         "S_HIDDEN_FIELDS" => $s_hidden_fields) 
      ); 
       
   } 
   else if( $mode == "save" ) 
   { 
      // 
      // Ok, they sent us our info, let's update it. 
      // 
       
      $rank_id = ( isset($HTTP_POST_VARS['id']) ) ? intval($HTTP_POST_VARS['id']) : 0; 
      $rank_title = ( isset($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ""; 
      $special_rank = ( $HTTP_POST_VARS['special_rank'] == 1 ) ? TRUE : 0;    $rank_choose_minimum = ( $HTTP_POST_VARS['rank_choose_minimum'] == 1 ) ? TRUE : 0; 
      $min_posts = ( isset($HTTP_POST_VARS['min_posts']) ) ? intval($HTTP_POST_VARS['min_posts']) : -1; 
      $rank_image = ( (isset($HTTP_POST_VARS['rank_image'])) ) ? trim($HTTP_POST_VARS['rank_image']) : ""; 

      if( $rank_title == "" ) 
      { 
         message_die(GENERAL_MESSAGE, $lang['Must_select_rank']); 
      } 

      if( $special_rank == 1 ) 
      { 
         $max_posts = -1; 
         $min_posts = -1; 
      } 

      // 
      // The rank image has to be a jpg, gif or png 
      // 
      if($rank_image != "") 
      { 
         if ( !preg_match("/(\.gif|\.png|\.jpg)$/is", $rank_image)) 
         { 
            $rank_image = ""; 
         } 
      } 

      if ($rank_id) 
      { 
         if (!$special_rank) 
         { 
            $sql = "UPDATE " . USERS_TABLE . " 
               SET user_rank = 0 
               WHERE user_rank = $rank_id"; 

            if( !$result = $db->sql_query($sql) ) 
            { 
               message_die(GENERAL_ERROR, $lang['No_update_ranks'], "", __LINE__, __FILE__, $sql); 
            } 
         } 
         $sql = "UPDATE " . RANKS_TABLE . " 
            SET rank_title = '" . str_replace("\'", "''", $rank_title) . "', rank_special = $special_rank, rank_min = $min_posts, rank_image = '" . str_replace("\'", "''", $rank_image) . "', rank_choose_minimum = $rank_choose_minimum 
            WHERE rank_id = $rank_id"; 

         $message = $lang['Rank_updated']; 
      } 
      else 
      { 
         $sql = "INSERT INTO " . RANKS_TABLE . " (rank_title, rank_special, rank_min, rank_image, rank_choose_minimum) 
            VALUES ('" . str_replace("\'", "''", $rank_title) . "', $special_rank, $min_posts, '" . str_replace("\'", "''", $rank_image) . "', $rank_choose_minimum)"; 

         $message = $lang['Rank_added']; 
      } 
       
      if( !$result = $db->sql_query($sql) ) 
      { 
         message_die(GENERAL_ERROR, "Couldn't update/insert into ranks table", "", __LINE__, __FILE__, $sql); 
      } 

      $message .= "<br /><br />" . sprintf($lang['Click_return_rankadmin'], "<a href=\"" . append_sid("admin_ranks.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); 

      message_die(GENERAL_MESSAGE, $message); 

   } 
   else if( $mode == "delete" ) 
   { 
      // 
      // Ok, they want to delete their rank 
      // 
       
      if( isset($HTTP_POST_VARS['id']) || isset($HTTP_GET_VARS['id']) ) 
      { 
         $rank_id = ( isset($HTTP_POST_VARS['id']) ) ? intval($HTTP_POST_VARS['id']) : intval($HTTP_GET_VARS['id']); 
      } 
      else 
      { 
         $rank_id = 0; 
      } 
       
      if( $rank_id ) 
      { 
         $sql = "DELETE FROM " . RANKS_TABLE . " 
            WHERE rank_id = $rank_id"; 
          
         if( !$result = $db->sql_query($sql) ) 
         { 
            message_die(GENERAL_ERROR, "Couldn't delete rank data", "", __LINE__, __FILE__, $sql); 
         } 
          
         $sql = "UPDATE " . USERS_TABLE . " 
            SET user_rank = 0 
            WHERE user_rank = $rank_id"; 

         if( !$result = $db->sql_query($sql) ) 
         { 
            message_die(GENERAL_ERROR, $lang['No_update_ranks'], "", __LINE__, __FILE__, $sql); 
         } 

         $message = $lang['Rank_removed'] . "<br /><br />" . sprintf($lang['Click_return_rankadmin'], "<a href=\"" . append_sid("admin_ranks.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); 

         message_die(GENERAL_MESSAGE, $message); 

      } 
      else 
      { 
         message_die(GENERAL_MESSAGE, $lang['Must_select_rank']); 
      } 
   } 
   else 
   { 
      // 
      // They didn't feel like giving us any information. Oh, too bad, we'll just display the 
      // list then... 
      // 
      $template->set_filenames(array( 
         "body" => "admin/ranks_list_body.tpl") 
      ); 
       
      $sql = "SELECT * FROM " . RANKS_TABLE . " 
         ORDER BY rank_min, rank_title"; 
      if( !$result = $db->sql_query($sql) ) 
      { 
         message_die(GENERAL_ERROR, "Couldn't obtain ranks data", "", __LINE__, __FILE__, $sql); 
      } 
       
      $rank_rows = $db->sql_fetchrowset($result); 
      $rank_count = count($rank_rows); 
       
      $template->assign_vars(array( 
         "L_RANKS_TITLE" => $lang['Ranks_title'], 
         "L_RANKS_TEXT" => $lang['Ranks_explain'], 
         "L_RANK" => $lang['Rank_title'], 
         "L_RANK_MINIMUM" => $lang['Rank_minimum'], 
         "L_SPECIAL_RANK" => $lang['Special_rank'], 
         "L_EDIT" => $lang['Edit'], 
         "L_DELETE" => $lang['Delete'], 
         "L_ADD_RANK" => $lang['Add_new_rank'], 
         "L_ACTION" => $lang['Action'], 
          
         "S_RANKS_ACTION" => append_sid("admin_ranks.$phpEx")) 
      ); 
       
      for( $i = 0; $i < $rank_count; $i++) 
      { 
         $rank = $rank_rows[$i]['rank_title']; 
         $special_rank = $rank_rows[$i]['rank_special'];      $rank_choose_minimum = $rank_rows[$i]['rank_choose_minimum'];      $rank_choose_minimum = $rank_rows[$i]['rank_choose_minimum']; 
         $rank_id = $rank_rows[$i]['rank_id']; 
         $rank_min = $rank_rows[$i]['rank_min']; 

         if($special_rank) 
         { 
            $rank_min = $rank_max = "-"; 
         } 
          
         $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; 
         $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; 
    
         $template->assign_block_vars("ranks", array( 
            "ROW_COLOR" => "#" . $row_color, 
            "ROW_CLASS" => $row_class, 
            "RANK" => $rank, 
            "RANK_MIN" => $rank_min, 

            "SPECIAL_RANK" => ( $special_rank == 1 ) ? $lang['Yes'] : $lang['No'],      "RANK_CHOOSE_MINIMUM" => ( $rank_choose_minimum == 1 ) ? $lang['Points'] : $lang['Posts'], 

            "U_RANK_EDIT" => append_sid("admin_ranks.$phpEx?mode=edit&id=$rank_id"), 
            "U_RANK_DELETE" => append_sid("admin_ranks.$phpEx?mode=delete&id=$rank_id")) 
         ); 
      } 
   } 
} 
else 
{ 
   // 
   // Show the default page 
   // 
   $template->set_filenames(array( 
      "body" => "admin/ranks_list_body.tpl") 
   ); 
    
   $sql = "SELECT * FROM " . RANKS_TABLE . " 
      ORDER BY rank_min ASC, rank_special ASC"; 
   if( !$result = $db->sql_query($sql) ) 
   { 
      message_die(GENERAL_ERROR, "Couldn't obtain ranks data", "", __LINE__, __FILE__, $sql); 
   } 
   $rank_count = $db->sql_numrows($result); 

   $rank_rows = $db->sql_fetchrowset($result); 
    
   $template->assign_vars(array( 
      "L_RANKS_TITLE" => $lang['Ranks_title'], 
      "L_RANKS_TEXT" => $lang['Ranks_explain'], 
      "L_RANK" => $lang['Rank_title'], 
      "L_RANK_MINIMUM" => $lang['Rank_minimum'], 
      "L_SPECIAL_RANK" => $lang['Rank_special'], 
      "L_EDIT" => $lang['Edit'], 
      "L_DELETE" => $lang['Delete'], 
      "L_ADD_RANK" => $lang['Add_new_rank'], 
      "L_ACTION" => $lang['Action'], 
       
      "S_RANKS_ACTION" => append_sid("admin_ranks.$phpEx")) 
   ); 
    
   for($i = 0; $i < $rank_count; $i++) 
   { 
      $rank = $rank_rows[$i]['rank_title']; 
      $special_rank = $rank_rows[$i]['rank_special']; 
      $rank_id = $rank_rows[$i]['rank_id']; 
      $rank_min = $rank_rows[$i]['rank_min']; 
       
      if( $special_rank == 1 ) 
      { 
         $rank_min = $rank_max = "-"; 
      } 

      $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; 
      $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; 

      $rank_is_special = ( $special_rank ) ? $lang['Yes'] : $lang['No'];      $rank_selected_minimum = ( $rank_choose_minimum ) ? $lang['Points'] : $lang['Posts']; 
       
      $template->assign_block_vars("ranks", array( 
         "ROW_COLOR" => "#" . $row_color, 
         "ROW_CLASS" => $row_class, 
         "RANK" => $rank, 
         "SPECIAL_RANK" => $rank_is_special, 
         "RANK_MIN" => $rank_min, 

         "U_RANK_EDIT" => append_sid("admin_ranks.$phpEx?mode=edit&id=$rank_id"), 
         "U_RANK_DELETE" => append_sid("admin_ranks.$phpEx?mode=delete&id=$rank_id")) 
      ); 
   } 
} 

$template->pparse("body"); 

include('./page_footer_admin.'.$phpEx); 

?>
nathan
星球普通子民
星球普通子民
文章: 11
註冊時間: 2004-02-12 19:51
聯繫:

文章 nathan »

constants

代碼: 選擇全部

<?php 
/*************************************************************************** 
 *                               constants.php 
 *                            ------------------- 
 *   begin                : Saturday', Feb 13', 2001 
 *   copyright            : ('C) 2001 The phpBB Group 
 *   email                : support@phpbb.com 
 * 
 *   $Id: constants.php,v 1.47.2.4 2003/06/10 00:39:51 psotfx Exp $ 
 * 
 * 
 ***************************************************************************/ 

/*************************************************************************** 
 * 
 *   This program is free software; you can redistribute it and/or modify 
 *   it under the terms of the GNU General Public License as published by 
 *   the Free Software Foundation; either version 2 of the License', or 
 *   ('at your option) any later version. 
 * 
 ***************************************************************************/ 

if ( !defined('IN_PHPBB') ) 
{ 
   die("Hacking attempt"); 
} 

// Debug Level 
//define('DEBUG', 1); // Debugging on 
define('DEBUG', 1); // Debugging off 


// User Levels <- Do not change the values of USER or ADMIN 
define('DELETED', -1); 
define('ANONYMOUS', -1); 

define('USER', 0); 
define('ADMIN', 1); 
define('MOD', 2); 


// User related 
define('USER_ACTIVATION_NONE', 0); 
define('USER_ACTIVATION_SELF', 1); 
define('USER_ACTIVATION_ADMIN', 2); 

define('USER_AVATAR_NONE', 0); 
define('USER_AVATAR_UPLOAD', 1); 
define('USER_AVATAR_REMOTE', 2); 
define('USER_AVATAR_GALLERY', 3);// Rank gain access MODdefine('USER_POINTS_MINIMUM', 1);define('USER_POSTS_MINIMUM', 0); 


// Group settings 
define('GROUP_OPEN', 0); 
define('GROUP_CLOSED', 1); 
define('GROUP_HIDDEN', 2); 


// Forum state 
define('FORUM_UNLOCKED', 0); 
define('FORUM_LOCKED', 1); 


// Topic status 
define('TOPIC_UNLOCKED', 0); 
define('TOPIC_LOCKED', 1); 
define('TOPIC_MOVED', 2); 
define('TOPIC_WATCH_NOTIFIED', 1); 
define('TOPIC_WATCH_UN_NOTIFIED', 0); 


// Topic types 
define('POST_NORMAL', 0); 
define('POST_STICKY', 1); 
define('POST_ANNOUNCE', 2); 
define('POST_GLOBAL_ANNOUNCE', 3); 
define('POST_COMMEND', 4); 


// SQL codes 
define('BEGIN_TRANSACTION', 1); 
define('END_TRANSACTION', 2); 


// Error codes 
define('GENERAL_MESSAGE', 200); 
define('GENERAL_ERROR', 202); 
define('CRITICAL_MESSAGE', 203); 
define('CRITICAL_ERROR', 204); 


// Private messaging 
define('PRIVMSGS_READ_MAIL', 0); 
define('PRIVMSGS_NEW_MAIL', 1); 
define('PRIVMSGS_SENT_MAIL', 2); 
define('PRIVMSGS_SAVED_IN_MAIL', 3); 
define('PRIVMSGS_SAVED_OUT_MAIL', 4); 
define('PRIVMSGS_UNREAD_MAIL', 5); 


// URL PARAMETERS 
define('POST_TOPIC_URL', 't'); 
define('POST_CAT_URL', 'c'); 
define('POST_FORUM_URL', 'f'); 
define('POST_USERS_URL', 'u'); 
define('POST_POST_URL', 'p'); 
define('POST_GROUPS_URL', 'g'); 

// Session parameters 
define('SESSION_METHOD_COOKIE', 100); 
define('SESSION_METHOD_GET', 101); 


// Page numbers for session handling 
define('PAGE_INDEX', 0); 
define('PAGE_LOGIN', -1); 
define('PAGE_SEARCH', -2); 
define('PAGE_REGISTER', -3); 
define('PAGE_PROFILE', -4); 
define('PAGE_VIEWONLINE', -6); 
define('PAGE_VIEWMEMBERS', -7); 
define('PAGE_FAQ', -8); 
define('PAGE_POSTING', -9); 
define('PAGE_PRIVMSGS', -10); 
define('PAGE_GROUPCP', -11); 
define('PAGE_LINKS', -14); 
define('PAGE_TOPIC_OFFSET', 5000); 


// Auth settings 
define('AUTH_LIST_ALL', 0); 
define('AUTH_ALL', 0); 

define('AUTH_REG', 1); 
define('AUTH_ACL', 2); 
define('AUTH_MOD', 3); 
define('AUTH_ADMIN', 5); 

define('AUTH_VIEW', 1); 
define('AUTH_READ', 2); 
define('AUTH_POST', 3); 
define('AUTH_REPLY', 4); 
define('AUTH_EDIT', 5); 
define('AUTH_DELETE', 6); 
define('AUTH_ANNOUNCE', 7); 
define('AUTH_STICKY', 8); 
define('AUTH_POLLCREATE', 9); 
define('AUTH_VOTE', 10); 
define('AUTH_ATTACH', 11); 
define('AUTH_GLOBALANNOUNCE', 13); 
define('HIDDEN_CAT', 0); 
define('AUTH_COMMEND', 12); 


// Table names 
define('AUTH_ACCESS_TABLE', $table_prefix.'auth_access'); 
define('BANLIST_TABLE', $table_prefix.'banlist'); 
define('CATEGORIES_TABLE', $table_prefix.'categories'); 
define('CONFIG_TABLE', $table_prefix.'config'); 
define('DISALLOW_TABLE', $table_prefix.'disallow'); 
define('FORUMS_TABLE', $table_prefix.'forums'); 
define('GROUPS_TABLE', $table_prefix.'groups'); 
define('POSTS_TABLE', $table_prefix.'posts'); 
define('POSTS_TEXT_TABLE', $table_prefix.'posts_text'); 
define('PRIVMSGS_TABLE', $table_prefix.'privmsgs'); 
define('PRIVMSGS_TEXT_TABLE', $table_prefix.'privmsgs_text'); 
define('PRIVMSGS_IGNORE_TABLE', $table_prefix.'privmsgs_ignore'); 
define('PRUNE_TABLE', $table_prefix.'forum_prune'); 
define('RANKS_TABLE', $table_prefix.'ranks'); 
define('SEARCH_TABLE', $table_prefix.'search_results'); 
define('SEARCH_WORD_TABLE', $table_prefix.'search_wordlist'); 
define('SEARCH_MATCH_TABLE', $table_prefix.'search_wordmatch'); 
define('SESSIONS_TABLE', $table_prefix.'sessions'); 
define('SMILIES_TABLE', $table_prefix.'smilies'); 
define('THEMES_TABLE', $table_prefix.'themes'); 
define('THEMES_NAME_TABLE', $table_prefix.'themes_name'); 
define('TOPICS_TABLE', $table_prefix.'topics'); 
define('TOPICS_WATCH_TABLE', $table_prefix.'topics_watch'); 
define('USER_GROUP_TABLE', $table_prefix.'user_group'); 
define('USERS_TABLE', $table_prefix.'users'); 
define('WORDS_TABLE', $table_prefix.'words'); 
define('VOTE_DESC_TABLE', $table_prefix.'vote_desc'); 
define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results'); 
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters'); 
define('LINKS_TABLE', $table_prefix.'links'); 
define('LINK_CATEGORIES_TABLE', $table_prefix.'link_categories'); 
define('LINK_CONFIG_TABLE', $table_prefix.'link_config'); 

?>
nathan
星球普通子民
星球普通子民
文章: 11
註冊時間: 2004-02-12 19:51
聯繫:

文章 nathan »

ranks_edit_body

代碼: 選擇全部

<h1>{L_RANKS_TITLE}</h1> 

<p>{L_RANKS_TEXT}</p> 

<form action="{S_RANK_ACTION}" method="post"><table class="forumline" cellpadding="4" cellspacing="1" border="0" align="center"> 
   <tr> 
      <th colspan="2">{L_RANKS_TITLE}</th> 
   </tr> 
   <tr> 
      <td class="row1" width="38%"><span class="gen">{L_RANK_TITLE}:</span></td> 
      <td class="row2"><input class="post" type="text" name="title" size="35" maxlength="40" value="{RANK}" /></td> 
   </tr> 
   <tr> 
      <td class="row1"><span class="gen">{L_RANK_SPECIAL}</span></td> 
      <td class="row2"><input type="radio" name="special_rank" value="1" {SPECIAL_RANK} />{L_YES}   <input type="radio" name="special_rank" value="0" {NOT_SPECIAL_RANK} /> {L_NO}</td> 
   </tr>  <tr>    <td class="row1"><span class="gen">{L_RANK_CHOOSE_MINIMUM}</span><br />    <span class="gensmall">    <!-- BEGIN switch_point_system_explain -->    {L_RANK_POINT_SYSTEM_EXPLAIN}*    <!-- END switch_point_system_explain -->    <!-- BEGIN switch_no_point_explain -->    {L_RANK_NO_POINT_EXPLAIN}*    <!-- END switch_no_point_explain -->    </span></td>    <td class="row2"><input type="radio" name="rank_choose_minimum" value="0" {RANK_MINIMUM_POSTS} />{L_POSTS}   <input type="radio" name="rank_choose_minimum" {LOCK_POINTS} value="1" {RANK_MINIMUM_POINTS} /> {L_POINTS}</td>  </tr> 
   <tr> 
      <td class="row1" width="38%"><span class="gen">{L_RANK_MINIMUM}:</span></td> 
      <td class="row2"><input class="post" type="text" name="min_posts" size="5" maxlength="10" value="{MINIMUM}" /></td> 
   </tr> 
   <tr> 
      <td class="row1" width="38%"><span class="gen">{L_RANK_IMAGE}:</span><br /> 
      <span class="gensmall">{L_RANK_IMAGE_EXPLAIN}</span></td> 
      <td class="row2"><input class="post" type="text" name="rank_image" size="40" maxlength="255" value="{IMAGE}" /><br />{IMAGE_DISPLAY}</td> 
   </tr> 
   <tr> 
      <td class="cat" colspan="2" align="center"><input type="submit" name="submit" value="{L_SUBMIT}" class="mainoption" />  <input type="reset" value="{L_RESET}" class="liteoption" /></td> 
   </tr> 
</table> 
{S_HIDDEN_FIELDS}</form> 
nathan
星球普通子民
星球普通子民
文章: 11
註冊時間: 2004-02-12 19:51
聯繫:

文章 nathan »

ranks_list_body \r

代碼: 選擇全部

<h1>{L_RANKS_TITLE}</h1> 

<p>{L_RANKS_TEXT}</p> 

<form method="post" action="{S_RANKS_ACTION}"><table cellspacing="1" cellpadding="4" border="0" align="center" class="forumline"> 
   <tr> 
      <th>{L_RANK}</th> 
        <th>{L_RANK_MINIMUM}</th><th class="thTop">{L_RANK_CHOOSE_MINIMUM}</th> 
      <th>{L_SPECIAL_RANK}</th> 
      <th>{L_EDIT}</th> 
      <th>{L_DELETE}</th> 
   </tr> 
   <!-- BEGIN ranks --> 
   <tr> 
      <td class="{ranks.ROW_CLASS}" align="center">{ranks.RANK}</td> 
        <td class="{ranks.ROW_CLASS}" align="center">{ranks.RANK_MIN}</td><td class="{ranks.ROW_CLASS}" align="center">{ranks.RANK_CHOOSE_MINIMUM}</td> 
      <td class="{ranks.ROW_CLASS}" align="center">{ranks.SPECIAL_RANK}</td> 
      <td class="{ranks.ROW_CLASS}" align="center"><a href="{ranks.U_RANK_EDIT}">{L_EDIT}</a></td> 
      <td class="{ranks.ROW_CLASS}" align="center"><a href="{ranks.U_RANK_DELETE}">{L_DELETE}</a></td> 
   </tr> 
   <!-- END ranks -->          
   <tr> 
      <td class="cat" align="center" colspan="6"><input type="submit" class="mainoption" name="add" value="{L_ADD_RANK}" /></td> 
   </tr> 
</table></form> 
nathan
星球普通子民
星球普通子民
文章: 11
註冊時間: 2004-02-12 19:51
聯繫:

文章 nathan »

usercp_viewprofile

代碼: 選擇全部

<?php 
/*************************************************************************** 
 *                           usercp_viewprofile.php 
 *                            ------------------- 
 *   begin                : Saturday, Feb 13, 2001 
 *   copyright            : (C) 2001 The phpBB Group 
 *   email                : support@phpbb.com 
 * 
 *   $Id: usercp_viewprofile.php,v 1.5.2.2 2004/07/11 16:46:20 acydburn Exp $ 
 * 
 * 
 ***************************************************************************/ 

/*************************************************************************** 
 * 
 *   This program is free software; you can redistribute it and/or modify 
 *   it under the terms of the GNU General Public License as published by 
 *   the Free Software Foundation; either version 2 of the License, or 
 *   (at your option) any later version. 
 * 
 * 
 ***************************************************************************/ 

if ( !defined('IN_PHPBB') ) 
{ 
   die("Hacking attempt"); 
   exit; 
} 
\r
if ( empty($HTTP_GET_VARS[POST_USERS_URL]) || $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS ) 
{ 
   message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']); 
} 
$profiledata = get_userdata($HTTP_GET_VARS[POST_USERS_URL]); 

$sql = "SELECT * 
   FROM " . RANKS_TABLE . " 
   ORDER BY rank_special, rank_min"; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
   message_die(GENERAL_ERROR, 'Could not obtain ranks information', '', __LINE__, __FILE__, $sql); 
} 

$ranksrow = array(); 
while ( $row = $db->sql_fetchrow($result) ) 
{ 
   $ranksrow[] = $row; 
} 
$db->sql_freeresult($result); 

// 
// Output page header and profile_view template 
// 
$template->set_filenames(array( 
   'body' => 'profile_view_body.tpl') 
); 
make_jumpbox('viewforum.'.$phpEx); 

// 
// Calculate the number of days this user has been a member ($memberdays) 
// Then calculate their posts per day 
// 
$regdate = $profiledata['user_regdate']; 
$memberdays = max(1, round( ( time() - $regdate ) / 86400 )); 
$posts_per_day = $profiledata['user_posts'] / $memberdays; 

// Get the users percentage of total posts 
if ( $profiledata['user_posts'] != 0  ) 
{ 
   $total_posts = get_db_stat('postcount'); 
   $percentage = ( $total_posts ) ? min(100, ($profiledata['user_posts'] / $total_posts) * 100) : 0; 
} 
else 
{ 
   $percentage = 0; 
} 

$avatar_img = ''; 
if ( $profiledata['user_avatar_type'] && $profiledata['user_allowavatar'] ) 
{ 
   switch( $profiledata['user_avatar_type'] ) 
   { 
      case USER_AVATAR_UPLOAD: 
         $avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : ''; 
         break; 
      case USER_AVATAR_REMOTE: 
         $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $profiledata['user_avatar'] . '" alt="" border="0" />' : ''; 
         break; 
      case USER_AVATAR_GALLERY: 
         $avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : ''; 
         break; 
   } 
} 

if ( $profiledata['user_session_time'] >= (time()-60) ) 
{ 
   if ( $profiledata['user_allow_viewonline'] ) 
   { 
      $online_status_img = '<a href="' . append_sid("viewonline.$phpEx") . '"><img src="' . $images['icon_online'] . '" alt="' . sprintf($lang['is_online'], $profiledata['username']) . '" title="' . sprintf($lang['is_online'], $profiledata['username']) . '" border="0" /></a>'; 
   } 
   else if ( ( $userdata['user_level'] == ADMIN ) || ( $userdata['user_id'] == $profiledata['user_id'] ) ) 
   { 
      $online_status_img = '<a href="' . append_sid("viewonline.$phpEx") . '"><img src="' . $images['icon_hidden'] . '" alt="' . sprintf($lang['is_hidden'], $profiledata['username']) . '" title="' . sprintf($lang['is_hidden'], $profiledata['username']) . '" border="0" /></a>'; 
   } 
   else 
   { 
      $online_status_img = '<img src="' . $images['icon_offline'] . '" alt="' . sprintf($lang['is_offline'], $profiledata['username']) . '" title="' . sprintf($lang['is_offline'], $profiledata['username']) . '" border="0" />'; 
   } 
} 
else 
{ 
   $online_status_img = '<img src="' . $images['icon_offline'] . '" alt="' . sprintf($lang['is_offline'], $profiledata['username']) . '" title="' . sprintf($lang['is_offline'], $profiledata['username']) . '" border="0" />'; 
} 

$poster_rank = ''; 
$rank_image = ''; 
if ( $profiledata['user_rank'] ) 
{ 
   for($i = 0; $i < count($ranksrow); $i++) 
   { 
      if ( $profiledata['user_rank'] == $ranksrow[$i]['rank_id'] && $ranksrow[$i]['rank_special'] ) 
      { 
         $poster_rank = $ranksrow[$i]['rank_title']; 
         $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : ''; 
      } 
   } 
} 
else{  for($i = 0; $i < count($ranksrow); $i++)  {    if( $ranksrow[$i]['rank_choose_minimum'] == USER_POSTS_MINIMUM )    {      if ( $profiledata['user_posts'] >= $ranksrow[$i]['rank_min'] && !$ranksrow[$i]['rank_special'] )      {   $poster_rank = $ranksrow[$i]['rank_title'];   $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';      }    }    if ( $ranksrow[$i]['rank_choose_minimum'] == USER_POINTS_MINIMUM )    {      if ( $profiledata['user_points'] >= $ranksrow[$i]['rank_min'] && !$ranksrow[$i]['rank_special'] )      {        $poster_rank = $ranksrow[$i]['rank_title'];        $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';      }    }  }} 

$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=" . $profiledata['user_id']); 
$pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>'; 
$pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>'; 

if ( !empty($profiledata['user_viewemail']) || $userdata['user_level'] == ADMIN ) 
{ 
   $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $profiledata['user_id']) : 'mailto:' . $profiledata['user_email']; 

   $email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>'; 
   $email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>'; 
} 
else 
{ 
\n   $email_img = ' '; 
   $email = ' '; 
} 

$www_img = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : ' '; 
$www = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . $profiledata['user_website'] . '</a>' : ' '; 

if ( !empty($profiledata['user_icq']) ) 
{ 
   $icq_status_img = '<a href="http://wwp.icq.com/' . $profiledata['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $profiledata['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>'; 
   $icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" border="0" /></a>'; 
   $icq =  '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '">' . $lang['ICQ'] . '</a>'; 
} 
else 
{ 
   $icq_status_img = ' '; 
   $icq_img = ' '; 
   $icq = ' '; 
} 

$aim_img = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : ' '; 
$aim = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : ' '; 

$msn_img = ( $profiledata['user_msnm'] ) ? $profiledata['user_msnm'] : ' '; 
$msn = $msn_img; 

$yim_img = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : ''; 
$yim = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.src=pg">' . $lang['YIM'] . '</a>' : ''; 

$temp_url = append_sid("search.$phpEx?search_author=" . urlencode($profiledata['username']) . "&showresults=posts"); 
$search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . $lang['Search_user_posts'] . '" border="0" /></a>'; 
$search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>'; 

$user_points = $profiledata['user_points']; 
$user_money = $profiledata['user_money']; 

if(($userdata['user_level'] == MOD && $userdata['user_id'] != $profiledata['user_id']) || $userdata['user_level'] == ADMIN) 
{ 
   if($userdata['user_level'] == MOD && $profiledata['user_level'] != ADMIN) 
   { 
      $template->assign_block_vars('switch_icash_edit', array()); 
   } 
   else if($userdata['user_level'] == ADMIN) 
   { 
      $template->assign_block_vars('switch_icash_edit', array()); 
   } 
   $access_icash_sumbit = 1; 
} 

if($userdata['user_id'] != $profiledata['user_id']) 
{ 
   $template->assign_block_vars('switch_icash_donate', array()); 
   $access_icash_sumbit = 1; 
} 

if($access_icash_sumbit == 1) 
{ 
   $template->assign_block_vars('switch_icash_sumbit', array()); 
} 

if ( !empty($profiledata['user_gender'])) 
{ 
   switch ($profiledata['user_gender']) 
   { 
      case 1: 
         $gender = $lang['Male']; 
         break; 
      case 2: 
         $gender = $lang['Female']; 
         break; 
      default: 
         $gender = $lang['No_gender_specify']; 
   } 
} 
else 
{ 
   $gender = $lang['No_gender_specify']; 
} 

// 
// Generate page 
// 
$page_title = $lang['Viewing_profile']; 
include($phpbb_root_path . 'includes/page_header.'.$phpEx); 
display_upload_attach_box_limits($profiledata['user_id']); 

$template->assign_vars(array( 
   'USERNAME' => $profiledata['username'], 
   'JOINED' => create_date($lang['DATE_FORMAT'], $profiledata['user_regdate'], $board_config['board_timezone']), 
   'POSTER_RANK' => $poster_rank, 
   'RANK_IMAGE' => $rank_image, 
   'POSTS_PER_DAY' => $posts_per_day, 
   'POSTS' => $profiledata['user_posts'], 
   'PERCENTAGE' => $percentage . '%', 
   'POST_DAY_STATS' => sprintf($lang['User_post_day_stats'], $posts_per_day), 
   'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage), 

   'SEARCH_IMG' => $search_img, 
   'SEARCH' => $search, 
   'PM_IMG' => $pm_img, 
   'PM' => $pm, 
   'EMAIL_IMG' => $email_img, 
   'EMAIL' => $email, 
   'WWW_IMG' => $www_img, 
   'WWW' => $www, 
   'ICQ_STATUS_IMG' => $icq_status_img, 
   'ICQ_IMG' => $icq_img, 
   'ICQ' => $icq, 
   'AIM_IMG' => $aim_img, 
   'AIM' => $aim, 
   'MSN_IMG' => $msn_img, 
   'MSN' => $msn, 
   'YIM_IMG' => $yim_img, 
   'YIM' => $yim, 
   'POINTS' => $user_points, 
   'MONEY' => $user_money, 
   'L_POINTS' => $board_config['icash_points'], 
   'L_MONEY' => $board_config['icash_money'], 
   'L_INCREASE' => $lang['icash_increase'], 
   'L_DECREASE' => $lang['icash_decrease'], 
   'L_SET' => $lang['icash_set'], 
   'L_DONATE' => $lang['icash_donate'], 

   'LOCATION' => ( $profiledata['user_from'] ) ? $profiledata['user_from'] : ' ', 
   'OCCUPATION' => ( $profiledata['user_occ'] ) ? $profiledata['user_occ'] : ' ', 
   'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : ' ', 
   'AVATAR_IMG' => $avatar_img, 
   'GENDER' => $gender, 
       
   'L_VIEWING_PROFILE' => sprintf($lang['Viewing_user_profile'], $profiledata['username']), 
   'L_ABOUT_USER' => sprintf($lang['About_user'], $profiledata['username']), 
   'L_AVATAR' => $lang['Avatar'], 
   'L_POSTER_RANK' => $lang['Poster_rank'], 
   'L_JOINED' => $lang['Joined'], 
   'L_TOTAL_POSTS' => $lang['Total_posts'], 
   'L_SEARCH_USER_POSTS' => sprintf($lang['Search_user_posts'], $profiledata['username']), 
   'L_CONTACT' => $lang['Contact'], 
   'L_EMAIL_ADDRESS' => $lang['Email_address'], 
   'L_EMAIL' => $lang['Email'], 
   'L_PM' => $lang['Private_Message'], 
   'L_ICQ_NUMBER' => $lang['ICQ'], 
   'L_YAHOO' => $lang['YIM'], 
   'L_AIM' => $lang['AIM'], 
   'L_MESSENGER' => $lang['MSNM'], 
   'L_WEBSITE' => $lang['Website'], 
   'L_LOCATION' => $lang['Location'], 
   'L_OCCUPATION' => $lang['Occupation'], 
   'L_INTERESTS' => $lang['Interests'], 
   'L_GENDER' => $lang['Gender'], 

   'ONLINE_STATUS_IMG' => $online_status_img, 
   'L_ONLINE_STATUS' => $lang['Online_status'], 

   'U_SEARCH_USER' => append_sid("search.$phpEx?search_author=" . urlencode($profiledata['username'])), 
   'S_PROFILE_CASH_ACTION' => append_sid("icash.$phpEx?u=".$profiledata['user_id']), 
   'S_PROFILE_ACTION' => append_sid("profile.$phpEx")) 
); 

$template->pparse('body'); 

include($phpbb_root_path . 'includes/page_tail.'.$phpEx); 

?>
nathan
星球普通子民
星球普通子民
文章: 11
註冊時間: 2004-02-12 19:51
聯繫:

文章 nathan »

viewtopic

代碼: 選擇全部

[code:1:fb854c77a4]<?php 
/*************************************************************************** 
* viewtopic.php 
* ------------------- 
* begin : Saturday, Feb 13, 2001 
* copyright : (C) 2001 The phpBB Group 
* email : support@phpbb.com 
* 
* $Id: viewtopic.php,v 1.186.2.36 2004/07/11 16:46:18 acydburn Exp $ 
* 
* 
***************************************************************************/ 

/*************************************************************************** 
* 
* This program is free software; you can redistribute it and/or modify 
* it under the terms of the GNU General Public License as published by 
* the Free Software Foundation; either version 2 of the License, or 
* (at your option) any later version. 
* 
***************************************************************************/ 

define('IN_PHPBB', true); 
$phpbb_root_path = './'; 
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.'.$phpEx); 
include($phpbb_root_path . 'includes/bbcode.'.$phpEx); 

// 
// Start initial var setup 
// 
$topic_id = $post_id = 0; 
$vote_id = array(); 
if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) ) 
{ 
$topic_id = intval($HTTP_GET_VARS[POST_TOPIC_URL]); 
} 
else if ( isset($HTTP_GET_VARS['topic']) ) 
{ 
$topic_id = intval($HTTP_GET_VARS['topic']); 
} 

if ( isset($HTTP_GET_VARS[POST_POST_URL])) 
{ 
$post_id = intval($HTTP_GET_VARS[POST_POST_URL]); 
} 


$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0; 

if ( !isset($topic_id) && !isset($post_id) ) 
{ 
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist'); 
} 

// 
// Find topic id if user requested a newer 
// or older topic 
// 
if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) ) 
{ 
if ( $HTTP_GET_VARS['view'] == 'newest' ) 
{ 
if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_GET_VARS['sid']) ) 
{ 
$session_id = isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid'] : $HTTP_GET_VARS['sid']; 

if (!preg_match('/^[A-Za-z0-9]*$/', $session_id)) 
{ 
$session_id = ''; 
} 

if ( $session_id ) 
{ 
$sql = "SELECT p.post_id 
FROM " . POSTS_TABLE . " p, " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u 
WHERE s.session_id = '$session_id' 
AND u.user_id = s.session_user_id 
AND p.topic_id = $topic_id 
AND p.post_time >= u.user_lastvisit 
ORDER BY p.post_time ASC 
LIMIT 1"; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, 'Could not obtain newer/older topic information', '', __LINE__, __FILE__, $sql); 
} 

if ( !($row = $db->sql_fetchrow($result)) ) 
{ 
message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit'); 
} 

$post_id = $row['post_id']; 

if (isset($HTTP_GET_VARS['sid'])) 
{ 
redirect("viewtopic.$phpEx?sid=$session_id&" . POST_POST_URL . "=$post_id#$post_id"); 
} 
else 
{ 
redirect("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id"); 
} 
} 
} 

redirect(append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true)); 
} 
else if ( $HTTP_GET_VARS['view'] == 'next' || $HTTP_GET_VARS['view'] == 'previous' ) 
{ 
$sql_condition = ( $HTTP_GET_VARS['view'] == 'next' ) ? '>' : '<'; 
$sql_ordering = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'ASC' : 'DESC'; 

$sql = "SELECT t.topic_id 
FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2 
WHERE 
t2.topic_id = $topic_id 
AND t.forum_id = t2.forum_id 
AND t.topic_last_post_id $sql_condition t2.topic_last_post_id 
ORDER BY t.topic_last_post_id $sql_ordering 
LIMIT 1"; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, "Could not obtain newer/older topic information", '', __LINE__, __FILE__, $sql); 
} 

if ( $row = $db->sql_fetchrow($result) ) 
{ 
$topic_id = intval($row['topic_id']); 
} 
else 
{ 
$message = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics'; 
message_die(GENERAL_MESSAGE, $message); 
} 
} 
} 

// 
// This rather complex gaggle of code handles querying for topics but 
// also allows for direct linking to a post (and the calculation of which 
// page the post is on and the correct display of viewtopic) 
// 
$join_sql_table = ( empty($post_id) ) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 "; 
$join_sql = ( empty($post_id) ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id"; 
$count_sql = ( empty($post_id) ) ? '' : ", COUNT(p2.post_id) AS prev_posts"; 

$order_sql = ( empty($post_id) ) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, 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_commend, f.auth_pollcreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC"; 

$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, 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_commend, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . " 
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . " 
WHERE $join_sql 
AND f.forum_id = t.forum_id 
$order_sql"; 
attach_setup_viewtopic_auth($order_sql, $sql); 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, "Could not obtain topic information", '', __LINE__, __FILE__, $sql); 
} 

if ( !($forum_topic_data = $db->sql_fetchrow($result)) ) 
{ 
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist'); 
} 

$forum_id = intval($forum_topic_data['forum_id']); 

// 
// Start session management 
// 
$userdata = session_pagestart($user_ip, $forum_id); 
init_userprefs($userdata); 
// 
// End session management 
// 

// 
// Start auth check 
// 
$is_auth = array(); 
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_topic_data); 

if( !$is_auth['auth_view'] || !$is_auth['auth_read'] ) 
{ 
if ( !$userdata['session_logged_in'] ) 
{ 
$redirect = ( isset($post_id) ) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id"; 
$redirect .= ( isset($start) ) ? "&start=$start" : ''; 
redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&$redirect", true)); 
} 

$message = ( !$is_auth['auth_view'] ) ? $lang['Topic_post_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']); 

message_die(GENERAL_MESSAGE, $message); 
} 
// 
// End auth check 
// 

$forum_name = $forum_topic_data['forum_name']; 
$topic_title = $forum_topic_data['topic_title']; 
$topic_id = intval($forum_topic_data['topic_id']); 
$topic_time = $forum_topic_data['topic_time']; 

if ( !empty($post_id) ) 
{ 
$start = floor(($forum_topic_data['prev_posts'] - 1) / intval($board_config['posts_per_page'])) * intval($board_config['posts_per_page']); 
} 

// 
// Is user watching this thread? 
// 
if( $userdata['session_logged_in'] ) 
{ 
$can_watch_topic = TRUE; 

$sql = "SELECT notify_status 
FROM " . TOPICS_WATCH_TABLE . " 
WHERE topic_id = $topic_id 
AND user_id = " . $userdata['user_id']; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, "Could not obtain topic watch information", '', __LINE__, __FILE__, $sql); 
} 

if ( $row = $db->sql_fetchrow($result) ) 
{ 
if ( isset($HTTP_GET_VARS['unwatch']) ) 
{ 
if ( $HTTP_GET_VARS['unwatch'] == 'topic' ) 
{ 
$is_watching_topic = 0; 

$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : ''; 
$sql = "DELETE $sql_priority FROM " . TOPICS_WATCH_TABLE . " 
WHERE topic_id = $topic_id 
AND user_id = " . $userdata['user_id']; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, "Could not delete topic watch information", '', __LINE__, __FILE__, $sql); 
} 
} 

$template->assign_vars(array( 
'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start") . '">') 
); 

$message = $lang['No_longer_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start") . '">', '</a>'); 
message_die(GENERAL_MESSAGE, $message); 
} 
else 
{ 
$is_watching_topic = TRUE; 

if ( $row['notify_status'] ) 
{ 
$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : ''; 
$sql = "UPDATE $sql_priority " . TOPICS_WATCH_TABLE . " 
SET notify_status = 0 
WHERE topic_id = $topic_id 
AND user_id = " . $userdata['user_id']; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, "Could not update topic watch information", '', __LINE__, __FILE__, $sql); 
} 
} 
} 
} 
else 
{ 
if ( isset($HTTP_GET_VARS['watch']) ) 
{ 
if ( $HTTP_GET_VARS['watch'] == 'topic' ) 
{ 
$is_watching_topic = TRUE; 

$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : ''; 
$sql = "INSERT $sql_priority INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status) 
VALUES (" . $userdata['user_id'] . ", $topic_id, 0)"; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, "Could not insert topic watch information", '', __LINE__, __FILE__, $sql); 
} 
} 

$template->assign_vars(array( 
'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start") . '">') 
); 

$message = $lang['You_are_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start") . '">', '</a>'); 
message_die(GENERAL_MESSAGE, $message); 
} 
else 
{ 
$is_watching_topic = 0; 
} 
} 
} 
else 
{ 
if ( isset($HTTP_GET_VARS['unwatch']) ) 
{ 
if ( $HTTP_GET_VARS['unwatch'] == 'topic' ) 
{ 
redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&" . POST_TOPIC_URL . "=$topic_id&unwatch=topic", true)); 
} 
} 
else 
{ 
$can_watch_topic = 0; 
$is_watching_topic = 0; 
} 
} 

// 
// Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed 
// then get it's value, find the number of topics with dates newer than it (to properly 
// handle pagination) and alter the main query 
// 
$valid = FALSE; 
if( $userdata['session_logged_in'] ) 
{ 
$sql = "SELECT p.poster_id, p.topic_id 
FROM " . POSTS_TABLE . " p 
WHERE p.topic_id = $topic_id 
AND p.poster_id = " . $userdata['user_id']; 
$resultat = $db->sql_query($sql); 
$valid = $db->sql_numrows($resultat) ? TRUE : FALSE; 
} 
if (!($valid)) $valid = $is_auth['auth_mod'] ? TRUE : FALSE; 

$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364); 
$previous_days_text = array($lang['All_Posts'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']); 

if( !empty($HTTP_POST_VARS['postdays']) || !empty($HTTP_GET_VARS['postdays']) ) 
{ 
$post_days = ( !empty($HTTP_POST_VARS['postdays']) ) ? intval($HTTP_POST_VARS['postdays']) : intval($HTTP_GET_VARS['postdays']); 
$min_post_time = time() - (intval($post_days) * 86400); 

$sql = "SELECT COUNT(p.post_id) AS num_posts 
FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p 
WHERE t.topic_id = $topic_id 
AND p.topic_id = t.topic_id 
AND p.post_time >= $min_post_time"; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, "Could not obtain limited topics count information", '', __LINE__, __FILE__, $sql); 
} 

$total_replies = ( $row = $db->sql_fetchrow($result) ) ? intval($row['num_posts']) : 0; 

$limit_posts_time = "AND p.post_time >= $min_post_time "; 

if ( !empty($HTTP_POST_VARS['postdays'])) 
{ 
$start = 0; 
} 
} 
else 
{ 
$total_replies = intval($forum_topic_data['topic_replies']) + 1; 

$limit_posts_time = ''; 
$post_days = 0; 
} 

$select_post_days = '<select name="postdays">'; 
for($i = 0; $i < count($previous_days); $i++) 
{ 
$selected = ($post_days == $previous_days[$i]) ? ' selected="selected"' : ''; 
$select_post_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>'; 
} 
$select_post_days .= '</select>'; 

// 
// Decide how to order the post display 
// 
if ( !empty($HTTP_POST_VARS['postorder']) || !empty($HTTP_GET_VARS['postorder']) ) 
{ 
$post_order = (!empty($HTTP_POST_VARS['postorder'])) ? htmlspecialchars($HTTP_POST_VARS['postorder']) : htmlspecialchars($HTTP_GET_VARS['postorder']); 
$post_time_order = ($post_order == "asc") ? "ASC" : "DESC"; 
} 
else 
{ 
$post_order = 'asc'; 
$post_time_order = 'ASC'; 
} 

$select_post_order = '<select name="postorder">'; 
if ( $post_time_order == 'ASC' ) 
{ 
$select_post_order .= '<option value="asc" selected="selected">' . $lang['Oldest_First'] . '</option><option value="desc">' . $lang['Newest_First'] . '</option>'; 
} 
else 
{ 
$select_post_order .= '<option value="asc">' . $lang['Oldest_First'] . '</option><option value="desc" selected="selected">' . $lang['Newest_First'] . '</option>'; 
} 
$select_post_order .= '</select>'; 

// 
// Go ahead and pull all data for this topic 
// 
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, u.user_allow_viewonline, u.user_session_time, u.user_money, u.user_points, u.user_gender, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid 
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt 
WHERE p.topic_id = $topic_id 
$limit_posts_time 
AND pt.post_id = p.post_id 
AND u.user_id = p.poster_id 
ORDER BY p.post_time $post_time_order 
LIMIT $start, ".$board_config['posts_per_page']; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql); 
} 

$postrow = array(); 
if ($row = $db->sql_fetchrow($result)) 
{ 
do 
{ 
$postrow[] = $row; 
} 
while ($row = $db->sql_fetchrow($result)); 
$db->sql_freeresult($result); 

$total_posts = count($postrow); 
} 
else 
{ 
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); 
sync('topic', $topic_id); 

message_die(GENERAL_MESSAGE, $lang['No_posts_topic']); 
} 

$resync = FALSE; 
if ($forum_topic_data['topic_replies'] + 1 < $start + count($postrow)) 
{ 
$resync = TRUE; 
} 
elseif ($start + $board_config['posts_per_page'] > $forum_topic_data['topic_replies']) 
{ 
$row_id = intval($forum_topic_data['topic_replies']) % intval($board_config['posts_per_page']); 
if ($postrow[$row_id]['post_id'] != $forum_topic_data['topic_last_post_id'] || $start + count($postrow) < $forum_topic_data['topic_replies']) 
{ 
$resync = TRUE; 
} 
} 
elseif (count($postrow) < $board_config['posts_per_page']) 
{ 
$resync = TRUE; 
} 

if ($resync) 
{ 
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); 
sync('topic', $topic_id); 

$result = $db->sql_query('SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . $topic_id); 
$row = $db->sql_fetchrow($result); 
$total_replies = $row['total']; 
} 

$sql = "SELECT * 
FROM " . RANKS_TABLE . " 
ORDER BY rank_special, rank_min"; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql); 
} 

$ranksrow = array(); 
while ( $row = $db->sql_fetchrow($result) ) 
{ 
$ranksrow[] = $row; 
} 
$db->sql_freeresult($result); 

// 
// Define censored word matches 
// 
$orig_word = array(); 
$replacement_word = array(); 
obtain_word_list($orig_word, $replacement_word); 

// 
// Censor topic title 
// 
if ( count($orig_word) ) 
{ 
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title); 
} 

// 
// Was a highlight request part of the URI? 
// 
$highlight_match = $highlight = ''; 
if (isset($HTTP_GET_VARS['highlight'])) 
{ 
// Split words and phrases 
$words = explode(' ', trim(htmlspecialchars(urldecode($HTTP_GET_VARS['highlight'])))); 

for($i = 0; $i < sizeof($words); $i++) 
{ 
if (trim($words[$i]) != '') 
{ 
$highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', phpbb_preg_quote($words[$i], '#')); 
} 
} 
unset($words); 

$highlight = urlencode($HTTP_GET_VARS['highlight']); 
} 

// 
// Post, reply and other URL generation for 
// templating vars 
// 
$new_topic_url = append_sid("posting.$phpEx?mode=newtopic&" . POST_FORUM_URL . "=$forum_id"); 
$reply_topic_url = append_sid("posting.$phpEx?mode=reply&" . POST_TOPIC_URL . "=$topic_id"); 
$view_forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"); 
$view_prev_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=previous"); 
$view_next_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=next"); 

// 
// Mozilla navigation bar 
// 
$nav_links['prev'] = array( 
'url' => $view_prev_topic_url, 
'title' => $lang['View_previous_topic'] 
); 
$nav_links['next'] = array( 
'url' => $view_next_topic_url, 
'title' => $lang['View_next_topic'] 
); 
$nav_links['up'] = array( 
'url' => $view_forum_url, 
'title' => $forum_name 
); 

$reply_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $images['reply_locked'] : $images['reply_new']; 
$reply_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['Reply_to_topic']; 
$post_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new']; 
$post_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic']; 

// 
// Set a cookie for this topic 
// 
if ( $userdata['session_logged_in'] ) 
{ 
$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array(); 
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array(); 

if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) ) 
{ 
$topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; 
} 
else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) ) 
{ 
$topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; 
} 
else 
{ 
$topic_last_read = $userdata['user_lastvisit']; 
} 

if ( count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id]) ) 
{ 
asort($tracking_topics); 
unset($tracking_topics[key($tracking_topics)]); 
} 

$tracking_topics[$topic_id] = time(); 

setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); 
} 

// 
// Load templates 
// 
$template->set_filenames(array( 
'body' => 'viewtopic_body.tpl') 
); 
make_jumpbox('viewforum.'.$phpEx, $forum_id); 

// 
// Output page header 
// 
$page_title = $lang['View_topic'] .' - ' . $topic_title; 
include($phpbb_root_path . 'includes/page_header.'.$phpEx); 

// 
// User authorisation levels output 
// 
$s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />'; 
$s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />'; 
$s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />'; 
$s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />'; 
$s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . '<br />'; 
attach_build_auth_levels($is_auth, $s_auth_can); 

$topic_mod = ''; 

if ( $is_auth['auth_mod'] ) 
{ 
$s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'] . '">', '</a>'); 

$topic_mod .= ( $is_auth['auth_delete'] ) ? "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=delete&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['Delete_topic'] . '" title="' . $lang['Delete_topic'] . '" border="0" /></a> ' : ""; 

$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=move&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['Move_topic'] . '" title="' . $lang['Move_topic'] . '" border="0" /></a> '; 

$topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) ? "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=lock&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_lock'] . '" alt="' . $lang['Lock_topic'] . '" title="' . $lang['Lock_topic'] . '" border="0" /></a> ' : "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=unlock&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_unlock'] . '" alt="' . $lang['Unlock_topic'] . '" title="' . $lang['Unlock_topic'] . '" border="0" /></a> '; 

$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=split&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_split'] . '" alt="' . $lang['Split_topic'] . '" title="' . $lang['Split_topic'] . '" border="0" /></a> '; 

$normal_button = "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=normalise&sid=" . $userdata['session_id'] . '"><img src="' . $images['folder'] . '" alt="' . $lang['Normal_topic'] . '" title="' . $lang['Normal_topic'] . '" border="0" /></a> '; 
$sticky_button = ( $is_auth['auth_sticky'] ) ? "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=sticky&sid=" . $userdata['session_id'] . '"><img src="' . $images['folder_sticky'] . '" alt="' . $lang['Sticky_topic'] . '" title="' . $lang['Sticky_topic'] . '" border="0" /></a> ' : ""; 
$announce_button = ( $is_auth['auth_announce'] ) ? "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=announce&sid=" . $userdata['session_id'] . '"><img src="' . $images['folder_announce'] . '" alt="' . $lang['Announce_topic'] . '" title="' . $lang['Announce_topic'] . '" border="0" /></a> ' : ""; 
$commend_button = ( $is_auth['auth_commend'] ) ? "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=commend&sid=" . $userdata['session_id'] . '"><img src="' . $images['folder_commend'] . '" alt="' . $lang['Commend_topic'] . '" title="' . $lang['Commend_topic'] . '" border="0" /></a> ' : ""; 
$global_announce_button = ( $is_auth['auth_globalannounce'] ) ? "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=global_announce&sid=" . $userdata['session_id'] . '"><img src="' . $images['folder_global_announce'] . '" alt="' . $lang['Global_Announce_topic'] . '" title="' . $lang['Global_Announce_topic'] . '" border="0" /></a> ' : ""; 

switch( $forum_topic_data['topic_type'] ) 
{ 
case POST_NORMAL: 
$topic_mod .= $sticky_button . $announce_button . $global_announce_button . $commend_button; 
break; 
case POST_STICKY: 
$topic_mod .= $announce_button . $commend_button . $global_announce_button . $normal_button; 
break; 
case POST_GLOBAL_ANNOUNCE: 
$topic_mod .= $sticky_button . $commend_button . $announce_button . $normal_button; 
break; 
case POST_ANNOUNCE: 
$topic_mod .= $sticky_button . $commend_button . $global_announce_button . $normal_button; 
break; 
case POST_COMMEND: 
$topic_mod .= $sticky_button . $announce_button . $global_announce_button . $normal_button; 
break; 
} 
} 

// 
// Topic watch information 
// 
$s_watching_topic = ''; 
if ( $can_watch_topic ) 
{ 
if ( $is_watching_topic ) 
{ \r
$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&unwatch=topic&start=$start&sid=" . $userdata['session_id'] . '">' . $lang['Stop_watching_topic'] . '</a>'; 
$s_watching_topic_img = ( isset($images['topic_un_watch']) ) ? "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&unwatch=topic&start=$start&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_un_watch'] . '" alt="' . $lang['Stop_watching_topic'] . '" title="' . $lang['Stop_watching_topic'] . '" border="0"></a>' : ''; 
} 
else 
{ 
$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&watch=topic&start=$start&sid=" . $userdata['session_id'] . '">' . $lang['Start_watching_topic'] . '</a>'; 
$s_watching_topic_img = ( isset($images['Topic_watch']) ) ? "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&watch=topic&start=$start&sid=" . $userdata['session_id'] . '"><img src="' . $images['Topic_watch'] . '" alt="' . $lang['Start_watching_topic'] . '" title="' . $lang['Start_watching_topic'] . '" border="0"></a>' : ''; 
} 
} 

// 
// If we've got a hightlight set pass it on to pagination, 
// I get annoyed when I lose my highlight after the first page. 
// 
$pagination = ( $highlight != '' ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start); 

$sql = "SELECT * 
FROM " . FORUMS_TABLE . " 
WHERE forum_id = $forum_id"; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql); 
} 

if ( !is_null($userdata[$board_config['access_point']]) ) 
{ 
if (!empty($board_config['access_name']) && !empty($board_config['access_point'])) 
{ 
if ($userdata['user_id'] == ANONYMOUS) 
{ 
if (($forum_row['forum_access'] > $userdata[$board_config['access_point']]) && ($forum_row['forum_access'] != 0)) 
{ 
message_die(GENERAL_ERROR, sprintf($lang['access_error2'], "<a href=\"" . append_sid("index.$phpEx") . "\">", "</a>"), $lang['access_error']); 
} 
} 
else if (($userdata['user_level'] != ADMIN || !($is_auth['auth_mod']))) 
{ 
if (($forum_row['forum_access'] > $userdata[$board_config['access_point']]) && ($forum_row['forum_access'] != 0)) 
{ 
message_die(GENERAL_ERROR, sprintf($lang['access_error1'], $forum_row['forum_access'], $board_config['access_name'], "<a href=\"" . append_sid("index.$phpEx") . "\">", "</a>"), $lang['access_error']); 
} 
} 
} 
} 

// 
// Send vars to template 
// 
$template->assign_vars(array( 
'FORUM_ID' => $forum_id, 
'FORUM_NAME' => $forum_name, 
'TOPIC_ID' => $topic_id, 
'TOPIC_TITLE' => $topic_title, 
'PAGINATION' => $pagination, 
'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / intval($board_config['posts_per_page']) ) + 1 ), ceil( $total_replies / intval($board_config['posts_per_page']) )), 

'POST_IMG' => $post_img, 
'REPLY_IMG' => $reply_img, 

'L_AUTHOR' => $lang['Author'], 
'L_MESSAGE' => $lang['Message'], 
'L_POSTED' => $lang['Posted'], 
'L_POST_SUBJECT' => $lang['Post_subject'], 
'L_VIEW_NEXT_TOPIC' => $lang['View_next_topic'], 
'L_VIEW_PREVIOUS_TOPIC' => $lang['View_previous_topic'], 
'L_POST_NEW_TOPIC' => $post_alt, 
'L_POST_REPLY_TOPIC' => $reply_alt, 
'L_BACK_TO_TOP' => $lang['Back_to_top'], 
'L_DISPLAY_POSTS' => $lang['Display_posts'], 
'L_LOCK_TOPIC' => $lang['Lock_topic'], 
'L_UNLOCK_TOPIC' => $lang['Unlock_topic'], 
'L_MOVE_TOPIC' => $lang['Move_topic'], 
'L_SPLIT_TOPIC' => $lang['Split_topic'], 
'L_DELETE_TOPIC' => $lang['Delete_topic'], 
'L_GOTO_PAGE' => $lang['Goto_page'], 

'S_TOPIC_LINK' => POST_TOPIC_URL, 
'S_SELECT_POST_DAYS' => $select_post_days, 
'S_SELECT_POST_ORDER' => $select_post_order, 
'S_POST_DAYS_ACTION' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . "&start=$start"), 
'S_AUTH_LIST' => $s_auth_can, 
'S_TOPIC_ADMIN' => $topic_mod, 
'S_WATCH_TOPIC' => $s_watching_topic, 
'S_WATCH_TOPIC_IMG' => $s_watching_topic_img, 

'U_VIEW_TOPIC' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start&postdays=$post_days&postorder=$post_order&highlight=$highlight"), 
'U_VIEW_FORUM' => $view_forum_url, 
'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url, 
'U_VIEW_NEWER_TOPIC' => $view_next_topic_url, 
'U_POST_NEW_TOPIC' => $new_topic_url, 
'U_POST_REPLY_TOPIC' => $reply_topic_url) 
); 

// 
// Does this topic contain a poll? 
// 
if ( !empty($forum_topic_data['topic_vote']) ) 
{ 
$s_hidden_fields = ''; 

$sql = "SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vd.vote_max, vd.vote_voted, vd.vote_hide, vd.vote_tothide, vr.vote_option_id, vr.vote_option_text, vr.vote_result 
FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr 
WHERE vd.topic_id = $topic_id 
AND vr.vote_id = vd.vote_id 
ORDER BY vr.vote_option_id ASC"; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, "Could not obtain vote data for this topic", '', __LINE__, __FILE__, $sql); 
} 

if ( $vote_info = $db->sql_fetchrowset($result) ) 
{ 
$db->sql_freeresult($result); 
$vote_options = count($vote_info); 

$vote_id = $vote_info[0]['vote_id']; 
$vote_title = $vote_info[0]['vote_text']; 
$max_vote = $vote_info[0]['vote_max']; 
$voted_vote = $vote_info[0]['vote_voted']; 
$hide_vote = $vote_info[0]['vote_hide']; 
$tothide_vote = $vote_info[0]['vote_tothide']; 

$sql = "SELECT vote_id 
FROM " . VOTE_USERS_TABLE . " 
WHERE vote_id = $vote_id 
AND vote_user_id = " . intval($userdata['user_id']); 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, "Could not obtain user vote data for this topic", '', __LINE__, __FILE__, $sql); 
} 

$user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0; 
$db->sql_freeresult($result); 

if ( isset($HTTP_GET_VARS['vote']) || isset($HTTP_POST_VARS['vote']) ) 
{ 
$view_result = ( ( ( isset($HTTP_GET_VARS['vote']) ) ? $HTTP_GET_VARS['vote'] : $HTTP_POST_VARS['vote'] ) == 'viewresult' ) ? TRUE : 0; 
} 
else 
{ 
$view_result = 0; 
} 

$poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0; 

if ( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) 
{ 
$template->set_filenames(array( 
'pollbox' => 'viewtopic_poll_result.tpl') 
); 

$vote_results_sum = 0; 

for($i = 0; $i < $vote_options; $i++) 
{ 
$vote_results_sum += $vote_info[$i]['vote_result']; 
} 

$vote_graphic = 0; 
$vote_graphic_max = count($images['voting_graphic']); 

for($i = 0; $i < $vote_options; $i++) 
{ 
$vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0; 
$vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']); 

$vote_graphic_img = $images['voting_graphic'][$vote_graphic]; 
$vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0; 

if ( count($orig_word) ) 
{ 
$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']); 
} 

$hide_vote_bl = ''; 
$hide_vote_zr = '0'; 
$total_votes_1 = $lang['Total_votes'] ; 
$total_votes_2 = $vote_results_sum ; 
if ( ( $poll_expired == 0 ) && ( $hide_vote == 1 ) && ( $vote_info[0]['vote_length'] <> 0 ) ) 
{ 
if ( $tothide_vote == 1 ) 
{ 
$total_votes_1 = '' ; 
$total_votes_2 = '' ; 
} 
$poll_expires_c = $lang['Results_after']; 
$template->assign_block_vars("poll_option", array( 
'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'], 
'POLL_OPTION_RESULT' => $hide_vote_bl, 
'POLL_OPTION_PERCENT' => $hide_vote_bl, 
'POLL_OPTION_IMG' => $vote_graphic_img, 
'POLL_OPTION_IMG_WIDTH' => $hide_vote_zr) 
); 
} 
else 
{ 
$poll_expires_c = ''; 
$template->assign_block_vars("poll_option", array( 
'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'], 
'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'], 
'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)), 

'POLL_OPTION_IMG' => $vote_graphic_img, 
'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length) 
); 
} 
} 

if ( ( $poll_expired == 0 ) && ( $vote_info[0]['vote_length'] <> 0 ) ) 
{ 
$poll_expire_1 = (( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] ) - time() ); 
$poll_expire_2 = intval($poll_expire_1/86400); 
$poll_expire_a = $poll_expire_2*86400; 
$poll_expire_3 = intval(($poll_expire_1 - ($poll_expire_a))/3600); 
$poll_expire_b = $poll_expire_3*3600; 
$poll_expire_4 = intval((($poll_expire_1 - ($poll_expire_a) - ($poll_expire_b)))/60); 
$poll_comma = ', '; 
$poll_space = ' '; 
$poll_expire_2 == '0' ? $poll_expire_6='' : ( ( $poll_expire_3 == 0 && $poll_expire_4 == 0 ) ? $poll_expire_6=$poll_expire_2.$poll_space.$lang['Days'] : $poll_expire_6=$poll_expire_2.$poll_space.$lang['Days'].$poll_comma ) ; 
$poll_expire_3 == '0' ? $poll_expire_7='' : ( $poll_expire_4 == 0 ? $poll_expire_7=$poll_expire_3.$poll_space.$lang['Hours'] : $poll_expire_7=$poll_expire_3.$poll_space.$lang['Hours'].$poll_comma ) ; 
$poll_expire_4 == '0' ? $poll_expire_8='' : $poll_expire_8=$poll_expire_4.$poll_space.$lang['Minutes'] ; 
$poll_expires_d = $lang['Poll_expires']; 
} 
else 
{ 
$poll_expires_6 = ''; 
$poll_expires_7 = ''; 
$poll_expires_8 = ''; 
$poll_expires_d = ''; 
} 
$voted_vote_nb = $voted_vote; 
$template->assign_vars(array( 
'VOTED_SHOW' => $lang['Voted_show'], 
'L_TOTAL_VOTES' => $total_votes_1, 
'L_RESULTS_AFTER' => $poll_expires_c, 
'L_POLL_EXPIRES' => $poll_expires_d, 
'POLL_EXPIRES' => ($poll_expire_6.$poll_expire_7.$poll_expire_8), 
'TOTAL_VOTES' => $total_votes_2) 
); 

} 
else 
{ 
$template->set_filenames(array( 
'pollbox' => 'viewtopic_poll_ballot.tpl') 
); 

if ( $max_vote > 1 ) 
{ 
$vote_box = 'checkbox'; 
} 
else $vote_box = 'radio'; 

for($i = 0; $i < $vote_options; $i++) 
{ 
if ( count($orig_word) ) 
{ 
$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']); 
} 

$template->assign_block_vars("poll_option", array( 
'POLL_VOTE_BOX' => $vote_box, 
'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'], 
'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text']) 
); 
} 

$template->assign_vars(array( 
'L_SUBMIT_VOTE' => $lang['Submit_vote'], 
'L_VIEW_RESULTS' => $lang['View_results'], 

'U_VIEW_RESULTS' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&vote=viewresult")) 
); 

$s_hidden_fields = '<input type="hidden" name="topic_id" value="' . $topic_id . '" /><input type="hidden" name="mode" value="vote" />'; 
} 

if ( $max_vote > 1 ) 
{ 
$vote_br = '<br>'; 
$max_vote_nb = $max_vote; 
} 
else 
{ 
$vote_br = ''; 
$lang['Max_voting_1_explain'] = ''; 
$lang['Max_voting_2_explain'] = ''; 
$lang['Max_voting_3_explain'] = ''; 
$max_vote_nb = ''; 
} 

if ( count($orig_word) ) 
{ 
$vote_title = preg_replace($orig_word, $replacement_word, $vote_title); 
} 

$s_hidden_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />'; 

$template->assign_vars(array( 
'POLL_QUESTION' => $vote_title, 

'POLL_VOTE_BR' => $vote_br, 
'MAX_VOTING_1_EXPLAIN' => $lang['Max_voting_1_explain'], 
'MAX_VOTING_2_EXPLAIN' => $lang['Max_voting_2_explain'], 
'MAX_VOTING_3_EXPLAIN' => $lang['Max_voting_3_explain'], 
'max_vote' => $max_vote_nb, 
'voted_vote' => $voted_vote_nb, 

'S_HIDDEN_FIELDS' => $s_hidden_fields, 
'S_POLL_ACTION' => append_sid("posting.$phpEx?mode=vote&" . POST_TOPIC_URL . "=$topic_id")) 
); 

$template->assign_var_from_handle('POLL_DISPLAY', 'pollbox'); 
} 
} 

init_display_post_attachments($forum_topic_data['topic_attachment']); 

// 
// Update the topic view counter 
// 
$sql = "UPDATE " . TOPICS_TABLE . " 
SET topic_views = topic_views + 1 
WHERE topic_id = $topic_id"; 
if ( !$db->sql_query($sql) ) 
{ 
message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql); 
} 

// 
// Okay, let's do the loop, yeah come on baby let's do the loop 
// and it goes like this ... 
// 
for($i = 0; $i < $total_posts; $i++) 
{ 
$poster_id = $postrow[$i]['user_id']; 
$poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $postrow[$i]['username']; 

$post_date = create_date('Y-m-d G:i', $postrow[$i]['post_time'], $board_config['board_timezone']); 

$poster_posts = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Posts'] . ': ' . $postrow[$i]['user_posts'] . '<br />' : ''; 

$poster_from = ( $postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[$i]['user_from'] . '<br />' : ''; 

$poster_joined = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Joined'] . ': ' . create_date($lang['DATE_FORMAT'], $postrow[$i]['user_regdate'], $board_config['board_timezone']) . '<br />' : ''; 

$poster_money = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $board_config['icash_money'] . ': ' . $postrow[$i]['user_money'] . '<br />' : ''; 

$poster_points = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $board_config['icash_points'] . ': ' . $postrow[$i]['user_points'] . '<br />' : ''; 

$poster_avatar = ''; 
if ( $postrow[$i]['user_avatar_type'] && $poster_id != ANONYMOUS && $postrow[$i]['user_allowavatar'] ) 
{ 
switch( $postrow[$i]['user_avatar_type'] ) 
{ 
case USER_AVATAR_UPLOAD: 
$poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : ''; 
break; 
case USER_AVATAR_REMOTE: 
$poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : ''; 
break; 
case USER_AVATAR_GALLERY: 
$poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : ''; 
break; 
} 
} 

// 
// Define the little post icon 
// 
if ( $userdata['session_logged_in'] && $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read ) 
{ 
$mini_post_img = $images['icon_minipost_new']; 
$mini_post_alt = $lang['New_post']; 
} 
else 
{ 
$mini_post_img = $images['icon_minipost']; 
$mini_post_alt = $lang['Post']; 
} 

$mini_post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#' . $postrow[$i]['post_id']; 

// 
// Generate ranks, set them to empty string initially. 
// 
$poster_rank = ''; 
$rank_image = ''; 
$gender_image = ''; 
if ( $postrow[$i]['user_id'] == ANONYMOUS ) 
{ 
} 
else if ( $postrow[$i]['user_rank'] ) 
{ 
for($j = 0; $j < count($ranksrow); $j++) 
{ 
if ( $postrow[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] ) 
{ 
$poster_rank = $ranksrow[$j]['rank_title']; 
$rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : ''; 
} 
} 
} 
else { for($j = 0; $j < count($ranksrow); $j++) { if ( $ranksrow[$j]['rank_choose_minimum'] == USER_POSTS_MINIMUM ) { if ( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] ) { $poster_rank = $ranksrow[$j]['rank_title']; $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : ''; } } if ( $ranksrow[$j]['rank_choose_minimum'] == USER_POINTS_MINIMUM ) { if ( $postrow[$i]['user_points'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] ) { $poster_rank = $ranksrow[$j]['rank_title']; $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : ''; } } } } // 
// Handle anon users posting with usernames 
// 
if ( $poster_id == ANONYMOUS && $postrow[$i]['post_username'] != '' ) 
{ 
$poster = $postrow[$i]['post_username']; 
$poster_rank = $lang['Guest']; 
} 

$temp_url = ''; 

if ( $poster_id != ANONYMOUS ) 
{ 
$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$poster_id"); 
$profile_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_profile'] . '" alt="' . $lang['Read_profile'] . '" title="' . $lang['Read_profile'] . '" border="0" /></a>'; 
$profile = '<a href="' . $temp_url . '">' . $lang['Read_profile'] . '</a>'; 

$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=$poster_id"); 
$pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>'; 
$pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>'; 

switch ($postrow[$i]['user_gender']) 
{ 
case 1 : 
$gender_image = $lang['Gender'].": <img src=\"" . $images['icon_minigender_male'] . "\" alt=\"" . $lang['Gender']. ":".$lang['Male']."\" title=\"" . $lang['Gender'] . ":".$lang['Male']. "\" border=\"0\" /><br />"; 
break; 
case 2 : 
$gender_image = $lang['Gender'].": <img src=\"" . $images['icon_minigender_female'] . "\" alt=\"" . $lang['Gender']. ":".$lang['Female']. "\" title=\"" . $lang['Gender'] . ":".$lang['Female']. "\" border=\"0\" /><br />"; 
break; 
default : 
$gender_image=""; 
} 

if ( !empty($postrow[$i]['user_viewemail']) || $is_auth['auth_mod'] ) 
{ 
$email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $poster_id) : 'mailto:' . $postrow[$i]['user_email']; 

$email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>'; 
$email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>'; 
} 
else 
{ 
$email_img = ''; 
$email = ''; 
} 

$www_img = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : ''; 
$www = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : ''; 

if ( !empty($postrow[$i]['user_icq']) ) 
{ 
$icq_status_img = '<a href="http://wwp.icq.com/' . $postrow[$i]['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $postrow[$i]['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>'; 
$icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[$i]['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" border="0" /></a>'; 
$icq = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[$i]['user_icq'] . '">' . $lang['ICQ'] . '</a>'; 
} 
else 
{ 
$icq_status_img = ''; 
$icq_img = ''; 
$icq = ''; 
} 

$aim_img = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : ''; 
$aim = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : ''; 

$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$poster_id"); 
$msn_img = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '"><img src="' . $images['icon_msnm'] . '" alt="' . $lang['MSNM'] . '" title="' . $lang['MSNM'] . '" border="0" /></a>' : ''; 
$msn = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $lang['MSNM'] . '</a>' : ''; 

$yim_img = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : ''; 
$yim = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&.src=pg">' . $lang['YIM'] . '</a>' : ''; 
} 
else 
{ 
$profile_img = ''; 
$profile = ''; 
$pm_img = ''; 
$pm = ''; 
$email_img = ''; 
$email = ''; \r
$www_img = ''; 
$www = ''; 
$icq_status_img = ''; 
$icq_img = ''; 
$icq = ''; 
$aim_img = ''; 
$aim = ''; 
$msn_img = ''; 
$msn = ''; 
$yim_img = ''; 
$yim = ''; 
} 

$temp_url = append_sid("posting.$phpEx?mode=quote&" . POST_POST_URL . "=" . $postrow[$i]['post_id']); 
$quote_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_quote'] . '" alt="' . $lang['Reply_with_quote'] . '" title="' . $lang['Reply_with_quote'] . '" border="0" /></a>'; 
$quote = '<a href="' . $temp_url . '">' . $lang['Reply_with_quote'] . '</a>'; 

$temp_url = append_sid("search.$phpEx?search_author=" . urlencode($postrow[$i]['username']) . "&showresults=posts"); 
$search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . $lang['Search_user_posts'] . '" border="0" /></a>'; 
$search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>'; 

if ( ( $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] ) 
{ 
$temp_url = append_sid("posting.$phpEx?mode=editpost&" . POST_POST_URL . "=" . $postrow[$i]['post_id']); 
$edit_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_edit'] . '" alt="' . $lang['Edit_delete_post'] . '" title="' . $lang['Edit_delete_post'] . '" border="0" /></a>'; 
$edit = '<a href="' . $temp_url . '">' . $lang['Edit_delete_post'] . '</a>'; 
} 
else 
{ 
$edit_img = ''; 
$edit = ''; 
} 

if ( $is_auth['auth_mod'] ) 
{ 
$temp_url = "modcp.$phpEx?mode=ip&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&" . POST_TOPIC_URL . "=" . $topic_id . "&sid=" . $userdata['session_id']; 
$ip_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_ip'] . '" alt="' . $lang['View_IP'] . '" title="' . $lang['View_IP'] . '" border="0" /></a>'; 
$ip = '<a href="' . $temp_url . '">' . $lang['View_IP'] . '</a>'; 

$temp_url = "posting.$phpEx?mode=delete&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&sid=" . $userdata['session_id']; 
$delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>'; 
$delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>'; 
} 
else 
{ 
$ip_img = ''; 
$ip = ''; 

if ( $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id'] ) 
{ 
$temp_url = "posting.$phpEx?mode=delete&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&sid=" . $userdata['session_id']; 
$delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>'; 
$delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>'; 
} 
else 
{ 
$delpost_img = ''; 
$delpost = ''; 
} 
} 

$post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : ''; 

$message = $postrow[$i]['post_text']; 
$bbcode_uid = $postrow[$i]['bbcode_uid']; 

$user_sig = ( $postrow[$i]['enable_sig'] && $postrow[$i]['user_sig'] != '' && $board_config['allow_sig'] ) ? $postrow[$i]['user_sig'] : ''; 
$user_sig_bbcode_uid = $postrow[$i]['user_sig_bbcode_uid']; 

// 
// Note! The order used for parsing the message _is_ important, moving things around could break any 
// output 
// 

// 
// If the board has HTML off but the post has HTML 
// on then we process it, else leave it alone 
// 
if ( !$board_config['allow_html'] ) 
{ 
if ( $user_sig != '' && $userdata['user_allowhtml'] ) 
{ 
$user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\\2>", $user_sig); 
} 

if ( $postrow[$i]['enable_html'] ) 
{ 
$message = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\\2>", $message); 
} 
} 

// 
// Parse message and/or sig for BBCode if reqd 
// 
if ( $board_config['allow_bbcode'] ) 
{ 
if ( $user_sig != '' && $user_sig_bbcode_uid != '' ) 
{ 
$user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $user_sig); 
$user_sig = bbencode_third_pass($user_sig, $user_sig_bbcode_uid, $valid); 
} 

if ( $bbcode_uid != '' ) 
{ 
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); 
$message = bbencode_third_pass($message, $bbcode_uid, $valid); 
} 
} 

if ( $user_sig != '' ) 
{ 
$user_sig = make_clickable($user_sig); 
} 
$message = make_clickable($message); 

// 
// Parse smilies 
// 
if ( $board_config['allow_smilies'] ) 
{ 
if ( $postrow[$i]['user_allowsmile'] && $user_sig != '' ) 
{ 
$user_sig = smilies_pass($user_sig); 
} 

if ( $postrow[$i]['enable_smilies'] ) 
{ 
$message = smilies_pass($message); 
} 
} 

// 
// Highlight active words (primarily for search) 
// 
if ($highlight_match) 
{ 
// This was shamelessly 'borrowed' from volker at multiartstudio dot de 
// via php.net's annotated manual 
$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\\\\1</b></span>', '\\\0')", '>' . $message . '<'), 1, -1)); 
} 

// 
// Replace naughty words 
// 
if (count($orig_word)) 
{ 
$post_subject = preg_replace($orig_word, $replacement_word, $post_subject); 

if ($user_sig != '') 
{ 
$user_sig = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\\0')", '>' . $user_sig . '<'), 1, -1)); 
} 

$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\\0')", '>' . $message . '<'), 1, -1)); 
} 

// 
// Replace newlines (we use this rather than nl2br because 
// till recently it wasn't XHTML compliant) 
// 
if ( $user_sig != '' ) 
{ 
$user_sig = '<br />_________________<br />' . str_replace("
", "
<br />
", $user_sig); 
} 

$message = str_replace("
", "
<br />
", $message); 

// 
// Editing information 
// 
if ( $postrow[$i]['post_edit_count'] ) 
{ 
$l_edit_time_total = ( $postrow[$i]['post_edit_count'] == 1 ) ? $lang['Edited_time_total'] : $lang['Edited_times_total']; 

$l_edited_by = '<br /><br />' . sprintf($l_edit_time_total, $poster, create_date('Y-m-d G:i', $postrow[$i]['post_edit_time'], $board_config['board_timezone']), $postrow[$i]['post_edit_count']); 
} 
else 
{ 
$l_edited_by = ''; 
} 

$online_status_img = ''; 

if ( $poster_id != ANONYMOUS ) 
{ 
if ( $postrow[$i]['user_
主題已鎖定

回到「外掛問題討論」