Smilie Permissions Mod by Oxpus Support

This forum is now closed as part of retiring phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.

Smilie Permissions Mod by Oxpus Support

Postby shaggy073077 » Tue Oct 18, 2005 11:54 pm

I have a problem with the smilie permissions mod by oxpus. I have went to his website: http://www.oxpus.de and unfortunetly I donot understand that type of language (only english) and there's no english link so support there is out of the question.

When I log onto the ACP I get the following error on the left pane
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in C:\apache\Apache2\htdocs\forum\admin\admin_smilies.php on line 307

Here is my admin_smilies.php file:
Code: Select all
<?php
/***************************************************************************
*                               admin_smilies.php
*                              -------------------
*     begin                : Thu May 31, 2001
*     copyright            : (C) 2001 The phpBB Group
*     email                : support@phpbb.com
*
*     $Id: admin_smilies.php,v 1.22.2.14 2005/05/06 20:50:09 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.
*
***************************************************************************/

/**************************************************************************
*   This file will be used for modifying the smiley settings for a board.
**************************************************************************/

define('IN_PHPBB', 1);

//
// First we do the setmodules stuff for the admin cp.
//
if( !empty($setmodules) )
{
   $filename = basename(__FILE__);
   $module['General']['Smilies'] = $filename;

   return;
}

//
// Load default header
//
if( isset($HTTP_GET_VARS['export_pack']) )
{
   if ( $HTTP_GET_VARS['export_pack'] == "send" )
   {   
      $no_page_header = true;
   }
}

$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_post.' . $phpEx);

//
// Check to see what mode we should operate in.
//
if( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
{
   $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
   $mode = htmlspecialchars($mode);
}
else
{
   $mode = "";
}

$delimeter  = '=+:';

//
// Read a listing of uploaded smilies for use in the add or edit smliey code...
//
$dir = @opendir($phpbb_root_path . $board_config['smilies_path']);

while($file = @readdir($dir))
{
   if( !@is_dir(phpbb_realpath($phpbb_root_path . $board_config['smilies_path'] . '/' . $file)) )
   {
      $img_size = @getimagesize($phpbb_root_path . $board_config['smilies_path'] . '/' . $file);

      if( $img_size[0] && $img_size[1] )
      {
         $smiley_images[] = $file;
      }
      else if( eregi('.pak$', $file) )
      {   
         $smiley_paks[] = $file;
      }
   }
}
if (isset($smiley_images)) sort ($smiley_images);
if (isset($smiley_paks)) sort ($smiley_paks);

@closedir($dir);

//
// Select main mode
//
if( isset($HTTP_GET_VARS['import_pack']) || isset($HTTP_POST_VARS['import_pack']) )
{
   //
   // Import a list a "Smiley Pack"
   //
   $smile_pak = ( isset($HTTP_POST_VARS['smile_pak']) ) ? $HTTP_POST_VARS['smile_pak'] : $HTTP_GET_VARS['smile_pak'];
   $clear_current = ( isset($HTTP_POST_VARS['clear_current']) ) ? $HTTP_POST_VARS['clear_current'] : $HTTP_GET_VARS['clear_current'];
   $replace_existing = ( isset($HTTP_POST_VARS['replace']) ) ? $HTTP_POST_VARS['replace'] : $HTTP_GET_VARS['replace'];

   if ( !empty($smile_pak) )
   {
      //
      // The user has already selected a smile_pak file.. Import it.
      //
      if( !empty($clear_current)  )
      {
         $sql = "DELETE
            FROM " . SMILIES_TABLE;
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't delete current smilies", "", __LINE__, __FILE__, $sql);
         }
      }
      else
      {
         $sql = "SELECT code
            FROM ". SMILIES_TABLE;
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't get current smilies", "", __LINE__, __FILE__, $sql);
         }

         $cur_smilies = $db->sql_fetchrowset($result);

         for( $i = 0; $i < count($cur_smilies); $i++ )
         {
            $k = $cur_smilies[$i]['code'];
            $smiles[$k] = 1;
         }
      }

      $fcontents = @file($phpbb_root_path . $board_config['smilies_path'] . '/'. $smile_pak);

      if( empty($fcontents) )
      {
         message_die(GENERAL_ERROR, "Couldn't read smiley pak file", "", __LINE__, __FILE__, $sql);
      }

      for( $i = 0; $i < count($fcontents); $i++ )
      {
         $smile_data = explode($delimeter, trim(addslashes($fcontents[$i])));

         for( $j = 2; $j < count($smile_data); $j++)
         {
            //
            // Replace > and < with the proper html_entities for matching.
            //
            $smile_data[$j] = str_replace("<", "&lt;", $smile_data[$j]);
            $smile_data[$j] = str_replace(">", "&gt;", $smile_data[$j]);
            $k = $smile_data[$j];

            if( $smiles[$k] == 1 )
            {
               if( !empty($replace_existing) )
               {
                  $sql = "UPDATE " . SMILIES_TABLE . "
                     SET smile_url = '" . str_replace("\'", "''", $smile_data[0]) . "', emoticon = '" . str_replace("\'", "''", $smile_data[1]) . "'
                     WHERE code = '" . str_replace("\'", "''", $smile_data[$j]) . "'";
               }
               else
               {
                  $sql = '';
               }
            }
            else
            {
               $sql = "INSERT INTO " . SMILIES_TABLE . " (code, smile_url, emoticon)
                  VALUES('" . str_replace("\'", "''", $smile_data[$j]) . "', '" . str_replace("\'", "''", $smile_data[0]) . "', '" . str_replace("\'", "''", $smile_data[1]) . "')";
            }

            if( $sql != '' )
            {
               $result = $db->sql_query($sql);
               if( !$result )
               {
                  message_die(GENERAL_ERROR, "Couldn't update smilies!", "", __LINE__, __FILE__, $sql);
               }
            }
         }
      }

      $message = $lang['smiley_import_success'] . "<br /><br />" . sprintf($lang['Click_return_smileadmin'], "<a href=\"" . append_sid("admin_smilies.$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
   {
      //
      // Display the script to get the smile_pak cfg file...
      //
      $smile_paks_select = "<select name='smile_pak'><option value=''>" . $lang['Select_pak'] . "</option>";
      while( list($key, $value) = @each($smiley_paks) )
      {
         if ( !empty($value) )
         {
            $smile_paks_select .= "<option>" . $value . "</option>";
         }
      }
      $smile_paks_select .= "</select>";

      $hidden_vars = "<input type='hidden' name='mode' value='import'>";   

      $template->set_filenames(array(
         "body" => "admin/smile_import_body.tpl")
      );

      $template->assign_vars(array(
         "L_SMILEY_TITLE" => $lang['smiley_title'],
         "L_SMILEY_EXPLAIN" => $lang['smiley_import_inst'],
         "L_SMILEY_IMPORT" => $lang['smiley_import'],
         "L_SELECT_LBL" => $lang['choose_smile_pak'],
         "L_IMPORT" => $lang['import'],
         "L_CONFLICTS" => $lang['smile_conflicts'],
         "L_DEL_EXISTING" => $lang['del_existing_smileys'],
         "L_REPLACE_EXISTING" => $lang['replace_existing'],
         "L_KEEP_EXISTING" => $lang['keep_existing'],

         "S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx"),
         "S_SMILE_SELECT" => $smile_paks_select,
         "S_HIDDEN_FIELDS" => $hidden_vars)
      );

      $template->pparse("body");
   }
}
else if( isset($HTTP_POST_VARS['export_pack']) || isset($HTTP_GET_VARS['export_pack']) )
{
   //
   // Export our smiley config as a smiley pak...
   //
   if ( $HTTP_GET_VARS['export_pack'] == "send" )
   {   
      $sql = "SELECT *
         FROM " . SMILIES_TABLE;
      if( !$result = $db->sql_query($sql) )
      {
         message_die(GENERAL_ERROR, "Could not get smiley list", "", __LINE__, __FILE__, $sql);
      }

      $resultset = $db->sql_fetchrowset($result);

      $smile_pak = "";
      for($i = 0; $i < count($resultset); $i++ )
      {
         $smile_pak .= $resultset[$i]['smile_url'] . $delimeter;
         $smile_pak .= $resultset[$i]['emoticon'] . $delimeter;
         $smile_pak .= $resultset[$i]['code'] . "\n";
      }

      header("Content-Type: text/x-delimtext; name=\"smiles.pak\"");
      header("Content-disposition: attachment; filename=smiles.pak");

      echo $smile_pak;

      exit;
   }

   $message = sprintf($lang['export_smiles'], "<a href=\"" . append_sid("admin_smilies.$phpEx?export_pack=send", true) . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_smileadmin'], "<a href=\"" . append_sid("admin_smilies.$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( isset($HTTP_POST_VARS['add']) || isset($HTTP_GET_VARS['add']) )
{
   //
   // Admin has selected to add a smiley.
   //
   $smilie_access = '<select name="access_level">';
   $smilie_access .= '<option value="'.ADMIN.'">'.$lang['Forum_ADMIN'].'</option>';
   $smilie_access .= '<option value="'.MOD.'">'.$lang['Forum_MOD'].'</option>';
   $smilie_access .= '<option value="'.USER.'" SELECTED>'.$lang['Forum_ALL'].'</option>';
   $smilie_access .= '</select>';
   $template->set_filenames(array(
      "body" => "admin/smile_edit_body.tpl")
   );

   $filename_list = "";
   for( $i = 0; $i < count($smiley_images); $i++ )
   {
      $filename_list .= '<option value="' . $smiley_images[$i] . '">' . $smiley_images[$i] . '</option>';
   }

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

   $template->assign_vars(array(
      "L_SMILEY_TITLE" => $lang['smiley_title'],
      "L_SMILEY_CONFIG" => $lang['smiley_config'],
      "L_SMILEY_EXPLAIN" => $lang['smile_desc'],
      "L_SMILEY_CODE" => $lang['smiley_code'],
      "L_SMILEY_URL" => $lang['smiley_url'],
      "L_SMILEY_EMOTION" => $lang['smiley_emot'],
      "L_SUBMIT" => $lang['Submit'],
      "L_RESET" => $lang['Reset'],
      "L_SMILEY_ACCESS" => $lang['Permissions'],

      "SMILEY_ACCESS" => $smilie_access

      "SMILEY_IMG" => $phpbb_root_path . $board_config['smilies_path'] . '/' . $smiley_images[0],

      "S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx"),
      "S_HIDDEN_FIELDS" => $s_hidden_fields,
      "S_FILENAME_OPTIONS" => $filename_list,
      "S_SMILEY_BASEDIR" => $phpbb_root_path . $board_config['smilies_path'])
   );

   $template->pparse("body");
}
else if ( $mode != "" )
{
   switch( $mode )
   {
      case 'delete':
         //
         // Admin has selected to delete a smiley.
         //

         $smiley_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id'];
         $smiley_id = intval($smiley_id);

         $sql = "DELETE FROM " . SMILIES_TABLE . "
            WHERE smilies_id = " . $smiley_id;
         $result = $db->sql_query($sql);
         if( !$result )
         {
            message_die(GENERAL_ERROR, "Couldn't delete smiley", "", __LINE__, __FILE__, $sql);
         }

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

         message_die(GENERAL_MESSAGE, $message);
         break;

      case 'edit':
         //
         // Admin has selected to edit a smiley.
         //

         $smiley_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id'];
         $smiley_id = intval($smiley_id);

         $sql = "SELECT *
            FROM " . SMILIES_TABLE . "
            WHERE smilies_id = " . $smiley_id;
         $result = $db->sql_query($sql);
         if( !$result )
         {
            message_die(GENERAL_ERROR, 'Could not obtain emoticon information', "", __LINE__, __FILE__, $sql);
         }
         $smile_data = $db->sql_fetchrow($result);

         $filename_list = "";
         for( $i = 0; $i < count($smiley_images); $i++ )
         {
            if( $smiley_images[$i] == $smile_data['smile_url'] )
            {
               $smiley_selected = "selected=\"selected\"";
               $smiley_edit_img = $smiley_images[$i];
            }
            else
            {
               $smiley_selected = "";
            }

            $filename_list .= '<option value="' . $smiley_images[$i] . '"' . $smiley_selected . '>' . $smiley_images[$i] . '</option>';
         }

         $template->set_filenames(array(
            "body" => "admin/smile_edit_body.tpl")
         );
                  $smilie_access = '<select name="access_level">';
         $smilie_access .= '<option value="'.ADMIN.'">'.$lang['Forum_ADMIN'].'</option>';
         $smilie_access .= '<option value="'.MOD.'">'.$lang['Forum_MOD'].'</option>';
         $smilie_access .= '<option value="'.USER.'">'.$lang['Forum_ALL'].'</option>';
         $smilie_access .= '</select>';

         $access = $smile_data['access_level'];
         $smilie_access = str_replace('value="'.$access.'">', 'value="'.$access.'" SELECTED>', $smilie_access);
         $s_hidden_fields = '<input type="hidden" name="mode" value="save" /><input type="hidden" name="smile_id" value="' . $smile_data['smilies_id'] . '" />';

         $template->assign_vars(array(
            "SMILEY_CODE" => $smile_data['code'],
            "SMILEY_EMOTICON" => $smile_data['emoticon'],
            "SMILEY_ACCESS" => $smilie_access,

            "L_SMILEY_ACCESS" => $lang['Permissions'],

            "L_SMILEY_TITLE" => $lang['smiley_title'],
            "L_SMILEY_CONFIG" => $lang['smiley_config'],
            "L_SMILEY_EXPLAIN" => $lang['smile_desc'],
            "L_SMILEY_CODE" => $lang['smiley_code'],
            "L_SMILEY_URL" => $lang['smiley_url'],
            "L_SMILEY_EMOTION" => $lang['smiley_emot'],
            "L_SUBMIT" => $lang['Submit'],
            "L_RESET" => $lang['Reset'],

            "SMILEY_IMG" => $phpbb_root_path . $board_config['smilies_path'] . '/' . $smiley_edit_img,

            "S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx"),
            "S_HIDDEN_FIELDS" => $s_hidden_fields,
            "S_FILENAME_OPTIONS" => $filename_list,
            "S_SMILEY_BASEDIR" => $phpbb_root_path . $board_config['smilies_path'])
         );

         $template->pparse("body");
         break;

      case "save":
         //
         // Admin has submitted changes while editing a smiley.
         //

         //
         // Get the submitted data, being careful to ensure that we only
         // accept the data we are looking for.
         //
         $smile_code = ( isset($HTTP_POST_VARS['smile_code']) ) ? trim($HTTP_POST_VARS['smile_code']) : trim($HTTP_GET_VARS['smile_code']);
         $smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? trim($HTTP_POST_VARS['smile_url']) : trim($HTTP_GET_VARS['smile_url']);
         $smile_emotion = ( isset($HTTP_POST_VARS['smile_emotion']) ) ? trim($HTTP_POST_VARS['smile_emotion']) : trim($HTTP_GET_VARS['smile_emotion']);
         $smile_id = ( isset($HTTP_POST_VARS['smile_id']) ) ? intval($HTTP_POST_VARS['smile_id']) : intval($HTTP_GET_VARS['smile_id']);
                        $smile_access = ( isset($HTTP_POST_VARS['access_level']) ) ? intval($HTTP_POST_VARS['access_level']) : intval($HTTP_GET_VARS['access_level']);
         // If no code was entered complain ...
         if ($smile_code == '' || $smile_url == '')
         {
            message_die(MESSAGE, $lang['Fields_empty']);
         }

         //
         // Convert < and > to proper htmlentities for parsing.
         //
         $smile_code = str_replace('<', '&lt;', $smile_code);
         $smile_code = str_replace('>', '&gt;', $smile_code);

         //
         // Proceed with updating the smiley table.
         //
         $sql = "UPDATE " . SMILIES_TABLE . "
            SET code = '" . str_replace("\'", "''", $smile_code) . "', smile_url = '" . str_replace("\'", "''", $smile_url) . "', emoticon = '" . str_replace("\'", "''", $smile_emotion) . "', access_level = $smile_access
            WHERE smilies_id = $smile_id";
         if( !($result = $db->sql_query($sql)) )
         {
            message_die(GENERAL_ERROR, "Couldn't update smilies info", "", __LINE__, __FILE__, $sql);
         }

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

         message_die(GENERAL_MESSAGE, $message);
         break;

      case "savenew":
         //
         // Admin has submitted changes while adding a new smiley.
         //

         //
         // Get the submitted data being careful to ensure the the data
         // we recieve and process is only the data we are looking for.
         //
         $smile_code = ( isset($HTTP_POST_VARS['smile_code']) ) ? $HTTP_POST_VARS['smile_code'] : $HTTP_GET_VARS['smile_code'];
         $smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? $HTTP_POST_VARS['smile_url'] : $HTTP_GET_VARS['smile_url'];
         $smile_emotion = ( isset($HTTP_POST_VARS['smile_emotion']) ) ? $HTTP_POST_VARS['smile_emotion'] : $HTTP_GET_VARS['smile_emotion'];
         $smile_access = ( isset($HTTP_POST_VARS['access_level']) ) ? intval($HTTP_POST_VARS['access_level']) : intval($HTTP_GET_VARS['access_level']);
         $smile_code = trim($smile_code);
         $smile_url = trim($smile_url);
         $smile_emotion = trim($smile_emotion);

         // If no code was entered complain ...
         if ($smile_code == '' || $smile_url == '')
         {
            message_die(MESSAGE, $lang['Fields_empty']);
         }

         //
         // Convert < and > to proper htmlentities for parsing.
         //
         $smile_code = str_replace('<', '&lt;', $smile_code);
         $smile_code = str_replace('>', '&gt;', $smile_code);

         //
         // Save the data to the smiley table.
         //
         $sql = "INSERT INTO " . SMILIES_TABLE . " (code, smile_url, emoticon, access_level)
            VALUES ('" . str_replace("\'", "''", $smile_code) . "', '" . str_replace("\'", "''", $smile_url) . "', '" . str_replace("\'", "''", $smile_emotion) . "', $smile_access)";
         $result = $db->sql_query($sql);
         if( !$result )
         {
            message_die(GENERAL_ERROR, "Couldn't insert new smiley", "", __LINE__, __FILE__, $sql);
         }

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

         message_die(GENERAL_MESSAGE, $message);
         break;
   }
}
else
{

   //
   // This is the main display of the page before the admin has selected
   // any options.
   //
   $sql = "SELECT *
      FROM " . SMILIES_TABLE;
   $result = $db->sql_query($sql);
   if( !$result )
   {
      message_die(GENERAL_ERROR, "Couldn't obtain smileys from database", "", __LINE__, __FILE__, $sql);
   }

   $smilies = $db->sql_fetchrowset($result);

   $template->set_filenames(array(
      "body" => "admin/smile_list_body.tpl")
   );

   $template->assign_vars(array(
      "L_ACTION" => $lang['Action'],
      "L_SMILEY_TITLE" => $lang['smiley_title'],
      "L_SMILEY_TEXT" => $lang['smile_desc'],
      "L_DELETE" => $lang['Delete'],
      "L_EDIT" => $lang['Edit'],
      "L_SMILEY_ADD" => $lang['smile_add'],
      "L_CODE" => $lang['Code'],
      "L_EMOT" => $lang['Emotion'],
      "L_SMILE" => $lang['Smile'],
      "L_SMILE_ACCESS" => $lang['Permissions'],
      "L_IMPORT_PACK" => $lang['import_smile_pack'],
      "L_EXPORT_PACK" => $lang['export_smile_pack'],
      
      "S_HIDDEN_FIELDS" => $s_hidden_fields,
      "S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx"))
   );

   //
   // Loop throuh the rows of smilies setting block vars for the template.
   //
   for($i = 0; $i < count($smilies); $i++)
   {
      //
      // Replace htmlentites for < and > with actual character.
      //
      $smilies[$i]['code'] = str_replace('&lt;', '<', $smilies[$i]['code']);
      $smilies[$i]['code'] = str_replace('&gt;', '>', $smilies[$i]['code']);
      
      $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
      $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

      $template->assign_block_vars("smiles", array(
         "ROW_COLOR" => "#" . $row_color,
         "ROW_CLASS" => $row_class,
         
         "SMILEY_IMG" =>  $phpbb_root_path . $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'],
         "CODE" => $smilies[$i]['code'],
         "EMOT" => $smilies[$i]['emoticon'],
         "ACCESS" => display_smilies_access($smilies[$i]['access_level']),
         
         "U_SMILEY_EDIT" => append_sid("admin_smilies.$phpEx?mode=edit&amp;id=" . $smilies[$i]['smilies_id']),
         "U_SMILEY_DELETE" => append_sid("admin_smilies.$phpEx?mode=delete&amp;id=" . $smilies[$i]['smilies_id']))
      );
   }

   //
   // Spit out the page.
   //
   $template->pparse("body");
}

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

?>

There maybe more errors as I look into this mod some more to see if it's installed properly.

Any support, comments and help would be appericated. Thanks
shaggy073077
Registered User
 
Posts: 28
Joined: Mon Jul 14, 2003 10:06 pm

Postby shaggy073077 » Tue Oct 18, 2005 11:59 pm

Same error in viewtopic.php This time Parse error: parse error, unexpected T_IF in C:\apache\Apache2\htdocs\forum\viewtopic.php on line 1094
Error
Here's my viewtopic.php file:
Code: Select all
<?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.43 2005/07/19 20:01:21 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);
include($phpbb_root_path . 'includes/functions_post.'.$phpEx);

//
// Start initial var setup
//
$topic_id = $post_id = 0;
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_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_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";
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&amp;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&amp;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&amp;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&amp;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
//
$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, 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($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']);
   $highlight_match = phpbb_rtrim($highlight_match, "\\");
}

//
// Post, reply and other URL generation for
// templating vars
//
$new_topic_url = append_sid("posting.$phpEx?mode=newtopic&amp;" . POST_FORUM_URL . "=$forum_id");
$reply_topic_url = append_sid("posting.$phpEx?mode=reply&amp;" . 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&amp;view=previous");
$view_next_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;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 />';

$topic_mod = '';

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

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

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

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

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

//
// Topic watch information
//
$s_watching_topic = '';
if ( $can_watch_topic )
{
   if ( $is_watching_topic )
   {
      $s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start&amp;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&amp;unwatch=topic&amp;start=$start&amp;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&amp;watch=topic&amp;start=$start&amp;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&amp;watch=topic&amp;start=$start&amp;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&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start);

//
// 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 . "&amp;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&amp;start=$start&amp;postdays=$post_days&amp;postorder=$post_order&amp;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, 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'];

      $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']);
            }

            $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)
            );
         }

         $template->assign_vars(array(
            'L_TOTAL_VOTES' => $lang['Total_votes'],
            'TOTAL_VOTES' => $vote_results_sum)
         );

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

         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_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&amp;postdays=$post_days&amp;postorder=$post_order&amp;vote=viewresult"))
         );

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

      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,

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

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

//
// 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($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);

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

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

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

   $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 = '';
   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 ( $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 />' : '';
         }
      }
   }

   //
   // 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&amp;" . 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&amp;" . 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>';

      if ( !empty($postrow[$i]['user_viewemail']) || $is_auth['auth_mod'] )
      {
         $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&amp;" . 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'] . '&amp;message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : '';
      $aim = ( $postrow[$i]['user_aim'] ) ? 'AIM Status:<IMG SRC="http://big.oscar.aol.com/' . $postrow[$i]['user_aim'] . '?on_url=http://localhost/online.gif&off_url=http://localhost/offline.gif">' : '';
      
      $temp_url = append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id");
         $msn_img = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '#msn"><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'] . '&amp;.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
      $yim = ( $postrow[$i]['user_yim'] ) ? 'YIM Status:<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&amp;.src=pg"><img src="http://opi.yahoo.com/online?u=' . $postrow[$i]['user_yim'] . '&m=g&t=1" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
   }
   else
   {
      $profile_img = '';
      $profile = '';
      $pm_img = '';
      $pm = '';
      $email_img = '';
      $email = '';
      $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&amp;" . 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']) . "&amp;showresults=posts");
   $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '" border="0" /></a>';
   $search = '<a href="' . $temp_url . '">' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '</a>';

   if ( ( $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] )
   {
      $temp_url = append_sid("posting.$phpEx?mode=editpost&amp;" . 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&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;" . POST_TOPIC_URL . "=" . $topic_id . "&amp;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&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;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&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;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'] || !$userdata['user_allowhtml'])
   {
      if ( $user_sig != '' )
      {
         $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $user_sig);
      }

      if ( $postrow[$i]['enable_html'] )
      {
         $message = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $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);
      }

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

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

   //
   // Parse smilies
   //
   if ( $board_config['allow_smilies'] )
   {
      $access_level = smilies_access()
      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(" . str_replace('\\', '\\\\', addslashes($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("\n", "\n<br />\n", $user_sig);
   }

   $message = str_replace("\n", "\n<br />\n", $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($board_config['default_dateformat'], $postrow[$i]['post_edit_time'], $board_config['board_timezone']), $postrow[$i]['post_edit_count']);
   }
   else
   {
      $l_edited_by = '';
   }

   //
   // Again this will be handled by the templating
   // code at some point
   //
   $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
   $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

   $template->assign_block_vars('postrow', array(
      'ROW_COLOR' => '#' . $row_color,
      'ROW_CLASS' => $row_class,
      'POSTER_NAME' => $poster,
      'POSTER_RANK' => $poster_rank,
      'RANK_IMAGE' => $rank_image,
      'POSTER_JOINED' => $poster_joined,
      'POSTER_POSTS' => $poster_posts,
      'POSTER_FROM' => $poster_from,
      'POSTER_AVATAR' => $poster_avatar,
      'POST_DATE' => $post_date,
      'POST_SUBJECT' => $post_subject,
      'MESSAGE' => $message,
      'SIGNATURE' => $user_sig,
      'EDITED_MESSAGE' => $l_edited_by,

      'MINI_POST_IMG' => $mini_post_img,
      'PROFILE_IMG' => $profile_img,
      'PROFILE' => $profile,
      '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,
      'EDIT_IMG' => $edit_img,
      'EDIT' => $edit,
      'QUOTE_IMG' => $quote_img,
      'QUOTE' => $quote,
      'IP_IMG' => $ip_img,
      'IP' => $ip,
      'DELETE_IMG' => $delpost_img,
      'DELETE' => $delpost,

      'L_MINI_POST_ALT' => $mini_post_alt,

      'U_MINI_POST' => $mini_post_url,
      'U_POST_ID' => $postrow[$i]['post_id'])
   );
}

$template->pparse('body');

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

?>


And something else. Here's the readme.txt file that is in the zip for installation:
[code]##############################################################
## MOD Title: Smiley Permissions
## MOD Author: OXPUS < webmaster@oxpus.de > (Karsten Ude) http://www.oxpus.de
## MOD Description: This mod will set the permissions for the usable smilies on posts.
## MOD Version: 1.0.1
##
## Installation Level: Easy
## Installation Time: 2-5 Minutes
## Files To Edit: 7
## posting.php
## viewtopic.php
## includes/bbcode.php
## includes/functions_post.php
## admin/admin_smilies.php
## templates/subSilver/admin/smile_edit_body.tpl
## templates/subSilver/admin/smile_list_body.tpl
##
## Included Files: n/a
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
## Instead entering the given SQL-Statement, you can upload the file db_update.php
## to your phpbb root directory and run this with your browser.
## This file will do all nessassary changes in the database for you.
## After using this file, please delete it to avoid errors.
##
##############################################################
## MOD History:
##
## 2004-09-26 - Version 1.0.1
## - Fix displaying smilies for all userlevel
## For update undo the changes on bbcode.php.
## Look for the code into the update folder.
##
## 2004-02-14 - Version 1.0.0
## - First release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ SQL ]------------------------------------------
#
ALTER TABLE phpbb_smilies ADD access_level TINYINT(1) DEFAULT '0' NOT NULL;

#
#-----[ OPEN ]------------------------------------------
#
posting.php

#
#-----[ FIND ]------------------------------------------
#
if( $smilies_on )
{

#
#-----[ AFTER, ADD ]------------------------------------------
#
$access_level = smilies_access();

#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php

#
#-----
shaggy073077
Registered User
 
Posts: 28
Joined: Mon Jul 14, 2003 10:06 pm

Postby waiting on God » Wed Oct 19, 2005 4:52 am

Try this MOD. It's in english, as well as the site. If you need support they will be able to help you there.

http://www.phpbbhacks.com/download/2330

WOG
My nick, Waiting on God, means that I am waiting on God to do something wonderful! :D

"I don't know everything. Never said I did. I just know a lot of things, some of it useless, some of it important. It's up to you which is which."

http://www.truechristians.net
.
waiting on God
Registered User
 
Posts: 270
Joined: Tue Feb 15, 2005 12:30 pm

Postby 3Di » Wed Oct 19, 2005 4:59 am

IMO it is a shame to post Miles/KiloMeters of code while Online Tools like http://pastebin.com exist..
Give Peace A Chance.. Pass ON It!
Image
User avatar
3Di
Registered User
 
Posts: 7983
Joined: Mon Apr 04, 2005 11:09 pm
Location: 45°26' N, 09°10' E


Return to [2.0.x] MOD Requests

Who is online

Users browsing this forum: No registered users and 2 guests