Verzeichnisstruktur phpBB-2.0.0


Veröffentlicht
03.04.2002

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

posting.php

Zuletzt modifiziert: 09.10.2024, 12:50 - Dateigröße: 34.56 KiB


 0001  <?php
 0002  /***************************************************************************
 0003   *                                posting.php
 0004   *                            -------------------
 0005   *   begin                : Saturday, Feb 13, 2001
 0006   *   copyright            : (C) 2001 The phpBB Group
 0007   *   email                : support@phpbb.com
 0008   *
 0009   *   $Id$
 0010   *
 0011   *
 0012   ***************************************************************************/
 0013   
 0014  /***************************************************************************
 0015   *
 0016   *   This program is free software; you can redistribute it and/or modify
 0017   *   it under the terms of the GNU General Public License as published by
 0018   *   the Free Software Foundation; either version 2 of the License, or
 0019   *   (at your option) any later version.
 0020   *
 0021   ***************************************************************************/
 0022   
 0023  define('IN_PHPBB', true);
 0024  $phpbb_root_path = './';
 0025  include($phpbb_root_path . 'extension.inc');
 0026  include($phpbb_root_path . 'common.'.$phpEx);
 0027  include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
 0028  include($phpbb_root_path . 'includes/functions_post.'.$phpEx);
 0029   
 0030  //
 0031  // Check and set various parameters
 0032  //
 0033  $params = array('submit' => 'post', 'preview' => 'preview', 'delete' => 'delete', 'poll_delete' => 'poll_delete', 'poll_add' => 'add_poll_option', 'poll_edit' => 'edit_poll_option', 'mode' => 'mode');
 0034  while( list($var, $param) = @each($params) )
 0035  {
 0036      if ( !empty($HTTP_POST_VARS[$param]) || !empty($HTTP_GET_VARS[$param]) )
 0037      {
 0038          $$var = ( !empty($HTTP_POST_VARS[$param]) ) ? htmlspecialchars($HTTP_POST_VARS[$param]) : htmlspecialchars($HTTP_GET_VARS[$param]);
 0039      }
 0040      else
 0041      {
 0042          $$var = '';
 0043      }
 0044  }
 0045   
 0046  $confirm = isset($HTTP_POST_VARS['confirm']) ? true : false;
 0047  $sid = (isset($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : 0;
 0048   
 0049  $params = array('forum_id' => POST_FORUM_URL, 'topic_id' => POST_TOPIC_URL, 'post_id' => POST_POST_URL);
 0050  while( list($var, $param) = @each($params) )
 0051  {
 0052      if ( !empty($HTTP_POST_VARS[$param]) || !empty($HTTP_GET_VARS[$param]) )
 0053      {
 0054          $$var = ( !empty($HTTP_POST_VARS[$param]) ) ? intval($HTTP_POST_VARS[$param]) : intval($HTTP_GET_VARS[$param]);
 0055      }
 0056      else
 0057      {
 0058          $$var = '';
 0059      }
 0060  }
 0061   
 0062  $refresh = $preview || $poll_add || $poll_edit || $poll_delete;
 0063  $orig_word = $replacement_word = array();
 0064   
 0065  //
 0066  // Set topic type
 0067  //
 0068  $topic_type = ( !empty($HTTP_POST_VARS['topictype']) ) ? intval($HTTP_POST_VARS['topictype']) : POST_NORMAL;
 0069  $topic_type = ( in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE)) ) ? $topic_type : POST_NORMAL;
 0070   
 0071  //
 0072  // If the mode is set to topic review then output
 0073  // that review ...
 0074  //
 0075  if ( $mode == 'topicreview' )
 0076  {
 0077      require($phpbb_root_path . 'includes/topic_review.'.$phpEx);
 0078   
 0079      topic_review($topic_id, false);
 0080      exit;
 0081  }
 0082  else if ( $mode == 'smilies' )
 0083  {
 0084      generate_smilies('window', PAGE_POSTING);
 0085      exit;
 0086  }
 0087   
 0088  //
 0089  // Start session management
 0090  //
 0091  $userdata = session_pagestart($user_ip, PAGE_POSTING);
 0092  init_userprefs($userdata);
 0093  //
 0094  // End session management
 0095  //
 0096   
 0097  //
 0098  // Was cancel pressed? If so then redirect to the appropriate
 0099  // page, no point in continuing with any further checks
 0100  //
 0101  if ( isset($HTTP_POST_VARS['cancel']) )
 0102  {
 0103      if ( $post_id )
 0104      {
 0105          $redirect = "viewtopic.$phpEx?" . POST_POST_URL . "=$post_id";
 0106          $post_append = "#$post_id";
 0107      }
 0108      else if ( $topic_id )
 0109      {
 0110          $redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id";
 0111          $post_append = '';
 0112      }
 0113      else if ( $forum_id )
 0114      {
 0115          $redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id";
 0116          $post_append = '';
 0117      }
 0118      else
 0119      {
 0120          $redirect = "index.$phpEx";
 0121          $post_append = '';
 0122      }
 0123   
 0124      redirect(append_sid($redirect, true) . $post_append);
 0125  }
 0126   
 0127  //
 0128  // What auth type do we need to check?
 0129  //
 0130  $is_auth = array();
 0131  switch( $mode )
 0132  {
 0133      case 'newtopic':
 0134          if ( $topic_type == POST_ANNOUNCE )
 0135          {
 0136              $is_auth_type = 'auth_announce';
 0137          }
 0138          else if ( $topic_type == POST_STICKY )
 0139          {
 0140              $is_auth_type = 'auth_sticky';
 0141          }
 0142          else
 0143          {
 0144              $is_auth_type = 'auth_post';
 0145          }
 0146          break;
 0147      case 'reply':
 0148      case 'quote':
 0149          $is_auth_type = 'auth_reply';
 0150          break;
 0151      case 'editpost':
 0152          $is_auth_type = 'auth_edit';
 0153          break;
 0154      case 'delete':
 0155      case 'poll_delete':
 0156          $is_auth_type = 'auth_delete';
 0157          break;
 0158      case 'vote':
 0159          $is_auth_type = 'auth_vote';
 0160          break;
 0161      case 'topicreview':
 0162          $is_auth_type = 'auth_read';
 0163          break;
 0164      default:
 0165          message_die(GENERAL_MESSAGE, $lang['No_post_mode']);
 0166          break;
 0167  }
 0168   
 0169  //
 0170  // Here we do various lookups to find topic_id, forum_id, post_id etc.
 0171  // Doing it here prevents spoofing (eg. faking forum_id, topic_id or post_id
 0172  //
 0173  $error_msg = '';
 0174  $post_data = array();
 0175  switch ( $mode )
 0176  {
 0177      case 'newtopic':
 0178          if ( empty($forum_id) )
 0179          {
 0180              message_die(GENERAL_MESSAGE, $lang['Forum_not_exist']);
 0181          }
 0182   
 0183          $sql = "SELECT * 
 0184              FROM " . FORUMS_TABLE . " 
 0185              WHERE forum_id = $forum_id";
 0186          break;
 0187   
 0188      case 'reply':
 0189      case 'vote':
 0190          if ( empty( $topic_id) )
 0191          {
 0192              message_die(GENERAL_MESSAGE, $lang['No_topic_id']);
 0193          }
 0194   
 0195          $sql = "SELECT f.*, t.topic_status, t.topic_title, t.topic_type  
 0196              FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t
 0197              WHERE t.topic_id = $topic_id
 0198                  AND f.forum_id = t.forum_id";
 0199          break;
 0200   
 0201      case 'quote':
 0202      case 'editpost':
 0203      case 'delete':
 0204      case 'poll_delete':
 0205          if ( empty($post_id) )
 0206          {
 0207              message_die(GENERAL_MESSAGE, $lang['No_post_id']);
 0208          }
 0209   
 0210          $select_sql = (!$submit) ? ', t.topic_title, p.enable_bbcode, p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, pt.post_subject, pt.post_text, pt.bbcode_uid, u.username, u.user_id, u.user_sig, u.user_sig_bbcode_uid' : '';
 0211          $from_sql = ( !$submit ) ? ", " . POSTS_TEXT_TABLE . " pt, " . USERS_TABLE . " u" : '';
 0212          $where_sql = ( !$submit ) ? "AND pt.post_id = p.post_id AND u.user_id = p.poster_id" : '';
 0213   
 0214          $sql = "SELECT f.*, t.topic_id, t.topic_status, t.topic_type, t.topic_first_post_id, t.topic_last_post_id, t.topic_vote, p.post_id, p.poster_id" . $select_sql . " 
 0215              FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $from_sql . " 
 0216              WHERE p.post_id = $post_id 
 0217                  AND t.topic_id = p.topic_id 
 0218                  AND f.forum_id = p.forum_id
 0219                  $where_sql";
 0220          break;
 0221   
 0222      default:
 0223          message_die(GENERAL_MESSAGE, $lang['No_valid_mode']);
 0224  }
 0225   
 0226  if ( ($result = $db->sql_query($sql)) && ($post_info = $db->sql_fetchrow($result)) )
 0227  {
 0228      $db->sql_freeresult($result);
 0229   
 0230      $forum_id = $post_info['forum_id'];
 0231      $forum_name = $post_info['forum_name'];
 0232   
 0233      $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $post_info);
 0234   
 0235      if ( $post_info['forum_status'] == FORUM_LOCKED && !$is_auth['auth_mod']) 
 0236      { 
 0237         message_die(GENERAL_MESSAGE, $lang['Forum_locked']); 
 0238      } 
 0239      else if ( $mode != 'newtopic' && $post_info['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod']) 
 0240      { 
 0241         message_die(GENERAL_MESSAGE, $lang['Topic_locked']); 
 0242      } 
 0243   
 0244      if ( $mode == 'editpost' || $mode == 'delete' || $mode == 'poll_delete' )
 0245      {
 0246          $topic_id = $post_info['topic_id'];
 0247   
 0248          $post_data['poster_post'] = ( $post_info['poster_id'] == $userdata['user_id'] ) ? true : false;
 0249          $post_data['first_post'] = ( $post_info['topic_first_post_id'] == $post_id ) ? true : false;
 0250          $post_data['last_post'] = ( $post_info['topic_last_post_id'] == $post_id ) ? true : false;
 0251          $post_data['last_topic'] = ( $post_info['forum_last_post_id'] == $post_id ) ? true : false;
 0252          $post_data['has_poll'] = ( $post_info['topic_vote'] ) ? true : false; 
 0253          $post_data['topic_type'] = $post_info['topic_type'];
 0254          $post_data['poster_id'] = $post_info['poster_id'];
 0255   
 0256          if ( $post_data['first_post'] && $post_data['has_poll'] )
 0257          {
 0258              $sql = "SELECT * 
 0259                  FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr 
 0260                  WHERE vd.topic_id = $topic_id 
 0261                      AND vr.vote_id = vd.vote_id 
 0262                  ORDER BY vr.vote_option_id";
 0263              if ( !($result = $db->sql_query($sql)) )
 0264              {
 0265                  message_die(GENERAL_ERROR, 'Could not obtain vote data for this topic', '', __LINE__, __FILE__, $sql);
 0266              }
 0267   
 0268              $poll_options = array();
 0269              $poll_results_sum = 0;
 0270              if ( $row = $db->sql_fetchrow($result) )
 0271              {
 0272                  $poll_title = $row['vote_text'];
 0273                  $poll_id = $row['vote_id'];
 0274                  $poll_length = $row['vote_length'] / 86400;
 0275   
 0276                  do
 0277                  {
 0278                      $poll_options[$row['vote_option_id']] = $row['vote_option_text']; 
 0279                      $poll_results_sum += $row['vote_result'];
 0280                  }
 0281                  while ( $row = $db->sql_fetchrow($result) );
 0282              }
 0283              $db->sql_freeresult($result);
 0284   
 0285              $post_data['edit_poll'] = ( ( !$poll_results_sum || $is_auth['auth_mod'] ) && $post_data['first_post'] ) ? true : 0;
 0286          }
 0287          else 
 0288          {
 0289              $post_data['edit_poll'] = ($post_data['first_post'] && $is_auth['auth_pollcreate']) ? true : false;
 0290          }
 0291          
 0292          //
 0293          // Can this user edit/delete the post/poll?
 0294          //
 0295          if ( $post_info['poster_id'] != $userdata['user_id'] && !$is_auth['auth_mod'] )
 0296          {
 0297              $message = ( $delete || $mode == 'delete' ) ? $lang['Delete_own_posts'] : $lang['Edit_own_posts'];
 0298              $message .= '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');
 0299   
 0300              message_die(GENERAL_MESSAGE, $message);
 0301          }
 0302          else if ( !$post_data['last_post'] && !$is_auth['auth_mod'] && ( $mode == 'delete' || $delete ) )
 0303          {
 0304              message_die(GENERAL_MESSAGE, $lang['Cannot_delete_replied']);
 0305          }
 0306          else if ( !$post_data['edit_poll'] && !$is_auth['auth_mod'] && ( $mode == 'poll_delete' || $poll_delete ) )
 0307          {
 0308              message_die(GENERAL_MESSAGE, $lang['Cannot_delete_poll']);
 0309          }
 0310      }
 0311      else
 0312      {
 0313          if ( $mode == 'quote' )
 0314          {
 0315              $topic_id = $post_info['topic_id'];
 0316          }
 0317          if ( $mode == 'newtopic' )
 0318          {
 0319              $post_data['topic_type'] = POST_NORMAL;
 0320          }
 0321   
 0322          $post_data['first_post'] = ( $mode == 'newtopic' ) ? true : 0;
 0323          $post_data['last_post'] = false;
 0324          $post_data['has_poll'] = false;
 0325          $post_data['edit_poll'] = false;
 0326      }
 0327      if ( $mode == 'poll_delete' && !isset($poll_id) )
 0328      {
 0329          message_die(GENERAL_MESSAGE, $lang['No_such_post']);
 0330      }
 0331  }
 0332  else
 0333  {
 0334      message_die(GENERAL_MESSAGE, $lang['No_such_post']);
 0335  }
 0336   
 0337  //
 0338  // The user is not authed, if they're not logged in then redirect
 0339  // them, else show them an error message
 0340  //
 0341  if ( !$is_auth[$is_auth_type] )
 0342  {
 0343      if ( $userdata['session_logged_in'] )
 0344      {
 0345          message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_' . $is_auth_type], $is_auth[$is_auth_type . "_type"]));
 0346      }
 0347   
 0348      switch( $mode )
 0349      {
 0350          case 'newtopic':
 0351              $redirect = "mode=newtopic&" . POST_FORUM_URL . "=" . $forum_id;
 0352              break;
 0353          case 'reply':
 0354          case 'topicreview':
 0355              $redirect = "mode=reply&" . POST_TOPIC_URL . "=" . $topic_id;
 0356              break;
 0357          case 'quote':
 0358          case 'editpost':
 0359              $redirect = "mode=quote&" . POST_POST_URL ."=" . $post_id;
 0360              break;
 0361      }
 0362   
 0363      redirect(append_sid("login.$phpEx?redirect=posting.$phpEx&" . $redirect, true));
 0364  }
 0365   
 0366  //
 0367  // Set toggles for various options
 0368  //
 0369  if ( !$board_config['allow_html'] )
 0370  {
 0371      $html_on = 0;
 0372  }
 0373  else
 0374  {
 0375      $html_on = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : TRUE ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_html'] : $userdata['user_allowhtml'] );
 0376  }
 0377   
 0378  if ( !$board_config['allow_bbcode'] )
 0379  {
 0380      $bbcode_on = 0;
 0381  }
 0382  else
 0383  {
 0384      $bbcode_on = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : TRUE ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_bbcode'] : $userdata['user_allowbbcode'] );
 0385  }
 0386   
 0387  if ( !$board_config['allow_smilies'] )
 0388  {
 0389      $smilies_on = 0;
 0390  }
 0391  else
 0392  {
 0393      $smilies_on = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : TRUE ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] );
 0394  }
 0395   
 0396  if ( ($submit || $refresh) && $is_auth['auth_read'])
 0397  {
 0398      $notify_user = ( !empty($HTTP_POST_VARS['notify']) ) ? TRUE : 0;
 0399  }
 0400  else
 0401  {
 0402      if ( $mode != 'newtopic' && $userdata['session_logged_in'] && $is_auth['auth_read'] )
 0403      {
 0404          $sql = "SELECT topic_id 
 0405              FROM " . TOPICS_WATCH_TABLE . "
 0406              WHERE topic_id = $topic_id 
 0407                  AND user_id = " . $userdata['user_id'];
 0408          if ( !($result = $db->sql_query($sql)) )
 0409          {
 0410              message_die(GENERAL_ERROR, 'Could not obtain topic watch information', '', __LINE__, __FILE__, $sql);
 0411          }
 0412   
 0413          $notify_user = ( $db->sql_fetchrow($result) ) ? TRUE : $userdata['user_notify'];
 0414          $db->sql_freeresult($result);
 0415      }
 0416      else
 0417      {
 0418          $notify_user = ( $userdata['session_logged_in'] && $is_auth['auth_read'] ) ? $userdata['user_notify'] : 0;
 0419      }
 0420  }
 0421   
 0422  $attach_sig = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['attach_sig']) ) ? TRUE : 0 ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? 0 : $userdata['user_attachsig'] );
 0423   
 0424  // --------------------
 0425  //  What shall we do?
 0426  //
 0427  if ( ( $delete || $poll_delete || $mode == 'delete' ) && !$confirm )
 0428  {
 0429      //
 0430      // Confirm deletion
 0431      //
 0432      $s_hidden_fields = '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />';
 0433      $s_hidden_fields .= ( $delete || $mode == "delete" ) ? '<input type="hidden" name="mode" value="delete" />' : '<input type="hidden" name="mode" value="poll_delete" />';
 0434      $s_hidden_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
 0435   
 0436      $l_confirm = ( $delete || $mode == 'delete' ) ? $lang['Confirm_delete'] : $lang['Confirm_delete_poll'];
 0437   
 0438      //
 0439      // Output confirmation page
 0440      //
 0441      include($phpbb_root_path . 'includes/page_header.'.$phpEx);
 0442   
 0443      $template->set_filenames(array(
 0444          'confirm_body' => 'confirm_body.tpl')
 0445      );
 0446   
 0447      $template->assign_vars(array(
 0448          'MESSAGE_TITLE' => $lang['Information'],
 0449          'MESSAGE_TEXT' => $l_confirm,
 0450   
 0451          'L_YES' => $lang['Yes'],
 0452          'L_NO' => $lang['No'],
 0453   
 0454          'S_CONFIRM_ACTION' => append_sid("posting.$phpEx"),
 0455          'S_HIDDEN_FIELDS' => $s_hidden_fields)
 0456      );
 0457   
 0458      $template->pparse('confirm_body');
 0459   
 0460      include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
 0461  }
 0462  else if ( $mode == 'vote' )
 0463  {
 0464      //
 0465      // Vote in a poll
 0466      //
 0467      if ( !empty($HTTP_POST_VARS['vote_id']) )
 0468      {
 0469          $vote_option_id = intval($HTTP_POST_VARS['vote_id']);
 0470   
 0471          $sql = "SELECT vd.vote_id    
 0472              FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
 0473              WHERE vd.topic_id = $topic_id 
 0474                  AND vr.vote_id = vd.vote_id 
 0475                  AND vr.vote_option_id = $vote_option_id
 0476              GROUP BY vd.vote_id";
 0477          if ( !($result = $db->sql_query($sql)) )
 0478          {
 0479              message_die(GENERAL_ERROR, 'Could not obtain vote data for this topic', '', __LINE__, __FILE__, $sql);
 0480          }
 0481   
 0482          if ( $vote_info = $db->sql_fetchrow($result) )
 0483          {
 0484              $vote_id = $vote_info['vote_id'];
 0485   
 0486              $sql = "SELECT * 
 0487                  FROM " . VOTE_USERS_TABLE . "  
 0488                  WHERE vote_id = $vote_id 
 0489                      AND vote_user_id = " . $userdata['user_id'];
 0490              if ( !($result2 = $db->sql_query($sql)) )
 0491              {
 0492                  message_die(GENERAL_ERROR, 'Could not obtain user vote data for this topic', '', __LINE__, __FILE__, $sql);
 0493              }
 0494   
 0495              if ( !($row = $db->sql_fetchrow($result2)) )
 0496              {
 0497                  $sql = "UPDATE " . VOTE_RESULTS_TABLE . " 
 0498                      SET vote_result = vote_result + 1 
 0499                      WHERE vote_id = $vote_id 
 0500                          AND vote_option_id = $vote_option_id";
 0501                  if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
 0502                  {
 0503                      message_die(GENERAL_ERROR, 'Could not update poll result', '', __LINE__, __FILE__, $sql);
 0504                  }
 0505   
 0506                  $sql = "INSERT INTO " . VOTE_USERS_TABLE . " (vote_id, vote_user_id, vote_user_ip) 
 0507                      VALUES ($vote_id, " . $userdata['user_id'] . ", '$user_ip')";
 0508                  if ( !$db->sql_query($sql, END_TRANSACTION) )
 0509                  {
 0510                      message_die(GENERAL_ERROR, "Could not insert user_id for poll", "", __LINE__, __FILE__, $sql);
 0511                  }
 0512   
 0513                  $message = $lang['Vote_cast'];
 0514              }
 0515              else
 0516              {
 0517                  $message = $lang['Already_voted'];
 0518              }
 0519              $db->sql_freeresult($result2);
 0520          }
 0521          else
 0522          {
 0523              $message = $lang['No_vote_option'];
 0524          }
 0525          $db->sql_freeresult($result);
 0526   
 0527          $template->assign_vars(array(
 0528              'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">')
 0529          );
 0530          $message .=  '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');
 0531          message_die(GENERAL_MESSAGE, $message);
 0532      }
 0533      else
 0534      {
 0535          redirect(append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
 0536      }
 0537  }
 0538  else if ( $submit || $confirm )
 0539  {
 0540      //
 0541      // Submit post/vote (newtopic, edit, reply, etc.)
 0542      //
 0543      $return_message = '';
 0544      $return_meta = '';
 0545   
 0546      // session id check
 0547      if ($sid == '' || $sid != $userdata['session_id'])
 0548      {
 0549          $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['Session_invalid'] : $lang['Session_invalid'];
 0550      }
 0551   
 0552      switch ( $mode )
 0553      {
 0554          case 'editpost':
 0555          case 'newtopic':
 0556          case 'reply':
 0557              $username = ( !empty($HTTP_POST_VARS['username']) ) ? $HTTP_POST_VARS['username'] : '';
 0558              $subject = ( !empty($HTTP_POST_VARS['subject']) ) ? trim($HTTP_POST_VARS['subject']) : '';
 0559              $message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : '';
 0560              $poll_title = ( isset($HTTP_POST_VARS['poll_title']) && $is_auth['auth_pollcreate'] ) ? $HTTP_POST_VARS['poll_title'] : '';
 0561              $poll_options = ( isset($HTTP_POST_VARS['poll_option_text']) && $is_auth['auth_pollcreate'] ) ? $HTTP_POST_VARS['poll_option_text'] : '';
 0562              $poll_length = ( isset($HTTP_POST_VARS['poll_length']) && $is_auth['auth_pollcreate'] ) ? $HTTP_POST_VARS['poll_length'] : '';
 0563              $bbcode_uid = '';
 0564   
 0565              prepare_post($mode, $post_data, $bbcode_on, $html_on, $smilies_on, $error_msg, $username, $bbcode_uid, $subject, $message, $poll_title, $poll_options, $poll_length);
 0566   
 0567              if ( $error_msg == '' )
 0568              {
 0569                  $topic_type = ( $topic_type != $post_data['topic_type'] && !$is_auth['auth_sticky'] && !$is_auth['auth_announce'] ) ? $post_data['topic_type'] : $topic_type;
 0570   
 0571                  submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, $bbcode_uid, str_replace("\'", "''", $username), str_replace("\'", "''", $subject), str_replace("\'", "''", $message), str_replace("\'", "''", $poll_title), $poll_options, $poll_length);
 0572              }
 0573              break;
 0574   
 0575          case 'delete':
 0576          case 'poll_delete':
 0577              if ($error_msg != '')
 0578              {
 0579                  message_die(GENERAL_MESSAGE, $error_msg);
 0580              }
 0581   
 0582              delete_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id);
 0583              break;
 0584      }
 0585   
 0586      if ( $error_msg == '' )
 0587      {
 0588          if ( $mode != 'editpost' )
 0589          {
 0590              $user_id = ( $mode == 'reply' || $mode == 'newtopic' ) ? $userdata['user_id'] : $post_data['poster_id'];
 0591              update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);
 0592          }
 0593   
 0594          if ($error_msg == '' && $mode != 'poll_delete')
 0595          {
 0596              user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user);
 0597          }
 0598   
 0599          if ( $mode == 'newtopic' || $mode == 'reply' )
 0600          {
 0601              $tracking_topics = ( !empty($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
 0602              $tracking_forums = ( !empty($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
 0603   
 0604              if ( count($tracking_topics) + count($tracking_forums) == 100 && empty($tracking_topics[$topic_id]) )
 0605              {
 0606                  asort($tracking_topics);
 0607                  unset($tracking_topics[key($tracking_topics)]);
 0608              }
 0609   
 0610              $tracking_topics[$topic_id] = time();
 0611   
 0612              setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
 0613          }
 0614   
 0615          $template->assign_vars(array(
 0616              'META' => $return_meta)
 0617          );
 0618          message_die(GENERAL_MESSAGE, $return_message);
 0619      }
 0620  }
 0621   
 0622  if( $refresh || isset($HTTP_POST_VARS['del_poll_option']) || $error_msg != '' )
 0623  {
 0624      $username = ( !empty($HTTP_POST_VARS['username']) ) ? htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['username']))) : '';
 0625      $subject = ( !empty($HTTP_POST_VARS['subject']) ) ? htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['subject']))) : '';
 0626      $message = ( !empty($HTTP_POST_VARS['message']) ) ? htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['message']))) : '';
 0627   
 0628      $poll_title = ( !empty($HTTP_POST_VARS['poll_title']) ) ? htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['poll_title']))) : '';
 0629      $poll_length = ( isset($HTTP_POST_VARS['poll_length']) ) ? max(0, intval($HTTP_POST_VARS['poll_length'])) : 0;
 0630   
 0631      $poll_options = array();
 0632      if ( !empty($HTTP_POST_VARS['poll_option_text']) )
 0633      {
 0634          while( list($option_id, $option_text) = @each($HTTP_POST_VARS['poll_option_text']) )
 0635          {
 0636              if( isset($HTTP_POST_VARS['del_poll_option'][$option_id]) )
 0637              {
 0638                  unset($poll_options[$option_id]);
 0639              }
 0640              else if ( !empty($option_text) ) 
 0641              {
 0642                  $poll_options[intval($option_id)] = htmlspecialchars(trim(stripslashes($option_text)));
 0643              }
 0644          }
 0645      }
 0646   
 0647      if ( isset($poll_add) && !empty($HTTP_POST_VARS['add_poll_option_text']) )
 0648      {
 0649          $poll_options[] = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['add_poll_option_text'])));
 0650      }
 0651   
 0652      if ( $mode == 'newtopic' || $mode == 'reply')
 0653      {
 0654          $user_sig = ( $userdata['user_sig'] != '' && $board_config['allow_sig'] ) ? $userdata['user_sig'] : '';
 0655      }
 0656      else if ( $mode == 'editpost' )
 0657      {
 0658          $user_sig = ( $post_info['user_sig'] != '' && $board_config['allow_sig'] ) ? $post_info['user_sig'] : '';
 0659          $userdata['user_sig_bbcode_uid'] = $post_info['user_sig_bbcode_uid'];
 0660      }
 0661      
 0662      if( $preview )
 0663      {
 0664          $orig_word = array();
 0665          $replacement_word = array();
 0666          obtain_word_list($orig_word, $replacement_word);
 0667   
 0668          $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';
 0669          $preview_message = stripslashes(prepare_message(addslashes(unprepare_message($message)), $html_on, $bbcode_on, $smilies_on, $bbcode_uid));
 0670          $preview_subject = $subject;
 0671          $preview_username = $username;
 0672   
 0673          //
 0674          // Finalise processing as per viewtopic
 0675          //
 0676          if( !$html_on )
 0677          {
 0678              if( $user_sig != '' || !$userdata['user_allowhtml'] )
 0679              {
 0680                  $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', '&lt;\2&gt;', $user_sig);
 0681              }
 0682          }
 0683   
 0684          if( $attach_sig && $user_sig != '' && $userdata['user_sig_bbcode_uid'] )
 0685          {
 0686              $user_sig = bbencode_second_pass($user_sig, $userdata['user_sig_bbcode_uid']);
 0687          }
 0688   
 0689          if( $bbcode_on )
 0690          {
 0691              $preview_message = bbencode_second_pass($preview_message, $bbcode_uid);
 0692          }
 0693   
 0694          if( !empty($orig_word) )
 0695          {
 0696              $preview_username = ( !empty($username) ) ? preg_replace($orig_word, $replacement_word, $preview_username) : '';
 0697              $preview_subject = ( !empty($subject) ) ? preg_replace($orig_word, $replacement_word, $preview_subject) : '';
 0698              $preview_message = ( !empty($preview_message) ) ? preg_replace($orig_word, $replacement_word, $preview_message) : '';
 0699          }
 0700   
 0701          if( $user_sig != '' )
 0702          {
 0703              $user_sig = make_clickable($user_sig);
 0704          }
 0705          $preview_message = make_clickable($preview_message);
 0706   
 0707          if( $smilies_on )
 0708          {
 0709              if( $userdata['user_allowsmile'] && $user_sig != '' )
 0710              {
 0711                  $user_sig = smilies_pass($user_sig);
 0712              }
 0713   
 0714              $preview_message = smilies_pass($preview_message);
 0715          }
 0716   
 0717          if( $attach_sig && $user_sig != '' )
 0718          {
 0719              $preview_message = $preview_message . '<br /><br />_________________<br />' . $user_sig;
 0720          }
 0721   
 0722          $preview_message = str_replace("\n", '<br />', $preview_message);
 0723   
 0724          $template->set_filenames(array(
 0725              'preview' => 'posting_preview.tpl')
 0726          );
 0727   
 0728          $template->assign_vars(array(
 0729              'TOPIC_TITLE' => $preview_subject,
 0730              'POST_SUBJECT' => $preview_subject,
 0731              'POSTER_NAME' => $preview_username,
 0732              'POST_DATE' => create_date($board_config['default_dateformat'], time(), $board_config['board_timezone']),
 0733              'MESSAGE' => $preview_message,
 0734   
 0735              'L_POST_SUBJECT' => $lang['Post_subject'], 
 0736              'L_PREVIEW' => $lang['Preview'],
 0737              'L_POSTED' => $lang['Posted'], 
 0738              'L_POST' => $lang['Post'])
 0739          );
 0740          $template->assign_var_from_handle('POST_PREVIEW_BOX', 'preview');
 0741      }
 0742      else if( $error_msg != '' )
 0743      {
 0744          $template->set_filenames(array(
 0745              'reg_header' => 'error_body.tpl')
 0746          );
 0747          $template->assign_vars(array(
 0748              'ERROR_MESSAGE' => $error_msg)
 0749          );
 0750          $template->assign_var_from_handle('ERROR_BOX', 'reg_header');
 0751      }
 0752  }
 0753  else
 0754  {
 0755      //
 0756      // User default entry point
 0757      //
 0758      if ( $mode == 'newtopic' )
 0759      {
 0760          $user_sig = ( $userdata['user_sig'] != '' ) ? $userdata['user_sig'] : '';
 0761   
 0762          $username = ($userdata['session_logged_in']) ? $userdata['username'] : '';
 0763          $poll_title = '';
 0764          $poll_length = '';
 0765          $subject = '';
 0766          $message = '';
 0767      }
 0768      else if ( $mode == 'reply' )
 0769      {
 0770          $user_sig = ( $userdata['user_sig'] != '' ) ? $userdata['user_sig'] : '';
 0771   
 0772          $username = ( $userdata['session_logged_in'] ) ? $userdata['username'] : '';
 0773          $subject = '';
 0774          $message = '';
 0775   
 0776      }
 0777      else if ( $mode == 'quote' || $mode == 'editpost' )
 0778      {
 0779          $subject = ( $post_data['first_post'] ) ? $post_info['topic_title'] : $post_info['post_subject'];
 0780          $message = $post_info['post_text'];
 0781   
 0782          if ( $mode == 'editpost' )
 0783          {
 0784              $attach_sig = ( $post_info['enable_sig'] && $post_info['user_sig'] != '' ) ? TRUE : 0; 
 0785              $user_sig = $post_info['user_sig'];
 0786   
 0787              $html_on = ( $post_info['enable_html'] ) ? true : false;
 0788              $bbcode_on = ( $post_info['enable_bbcode'] ) ? true : false;
 0789              $smilies_on = ( $post_info['enable_smilies'] ) ? true : false;
 0790          }
 0791          else
 0792          {
 0793              $attach_sig = ( $userdata['user_attachsig'] ) ? TRUE : 0;
 0794              $user_sig = $userdata['user_sig'];
 0795          }
 0796   
 0797          if ( $post_info['bbcode_uid'] != '' )
 0798          {
 0799              $message = preg_replace('/\:(([a-z0-9]:)?)' . $post_info['bbcode_uid'] . '/s', '', $message);
 0800          }
 0801   
 0802          $message = str_replace('<', '&lt;', $message);
 0803          $message = str_replace('>', '&gt;', $message);
 0804          $message = str_replace('<br />', "\n", $message);
 0805   
 0806          if ( $mode == 'quote' )
 0807          {
 0808              $orig_word = array();
 0809              $replacement_word = array();
 0810              obtain_word_list($orig_word, $replace_word);
 0811   
 0812              $msg_date =  create_date($board_config['default_dateformat'], $postrow['post_time'], $board_config['board_timezone']);
 0813   
 0814              // Use trim to get rid of spaces placed there by MS-SQL 2000
 0815              $quote_username = ( trim($post_info['post_username']) != '' ) ? $post_info['post_username'] : $post_info['username'];
 0816              $message = '[quote="' . $quote_username . '"]' . $message . '[/quote]';
 0817   
 0818              if ( !empty($orig_word) )
 0819              {
 0820                  $subject = ( !empty($subject) ) ? preg_replace($orig_word, $replace_word, $subject) : '';
 0821                  $message = ( !empty($message) ) ? preg_replace($orig_word, $replace_word, $message) : '';
 0822              }
 0823   
 0824              if ( !preg_match('/^Re:/', $subject) && strlen($subject) > 0 )
 0825              {
 0826                  $subject = 'Re: ' . $subject;
 0827              }
 0828   
 0829              $mode = 'reply';
 0830          }
 0831          else
 0832          {
 0833              $username = ( $post_info['user_id'] == ANONYMOUS && !empty($post_info['post_username']) ) ? $post_info['post_username'] : '';
 0834          }
 0835      }
 0836  }
 0837   
 0838  //
 0839  // Signature toggle selection
 0840  //
 0841  if( $user_sig != '' )
 0842  {
 0843      $template->assign_block_vars('switch_signature_checkbox', array());
 0844  }
 0845   
 0846  //
 0847  // HTML toggle selection
 0848  //
 0849  if ( $board_config['allow_html'] )
 0850  {
 0851      $html_status = $lang['HTML_is_ON'];
 0852      $template->assign_block_vars('switch_html_checkbox', array());
 0853  }
 0854  else
 0855  {
 0856      $html_status = $lang['HTML_is_OFF'];
 0857  }
 0858   
 0859  //
 0860  // BBCode toggle selection
 0861  //
 0862  if ( $board_config['allow_bbcode'] )
 0863  {
 0864      $bbcode_status = $lang['BBCode_is_ON'];
 0865      $template->assign_block_vars('switch_bbcode_checkbox', array());
 0866  }
 0867  else
 0868  {
 0869      $bbcode_status = $lang['BBCode_is_OFF'];
 0870  }
 0871   
 0872  //
 0873  // Smilies toggle selection
 0874  //
 0875  if ( $board_config['allow_smilies'] )
 0876  {
 0877      $smilies_status = $lang['Smilies_are_ON'];
 0878      $template->assign_block_vars('switch_smilies_checkbox', array());
 0879  }
 0880  else
 0881  {
 0882      $smilies_status = $lang['Smilies_are_OFF'];
 0883  }
 0884   
 0885  if( !$userdata['session_logged_in'] || ( $mode == 'editpost' && $post_info['poster_id'] == ANONYMOUS ) )
 0886  {
 0887      $template->assign_block_vars('switch_username_select', array());
 0888  }
 0889   
 0890  //
 0891  // Notify checkbox - only show if user is logged in
 0892  //
 0893  if ( $userdata['session_logged_in'] && $is_auth['auth_read'] )
 0894  {
 0895      if ( $mode != 'editpost' || ( $mode == 'editpost' && $post_info['poster_id'] != ANONYMOUS ) )
 0896      {
 0897          $template->assign_block_vars('switch_notify_checkbox', array());
 0898      }
 0899  }
 0900   
 0901  //
 0902  // Delete selection
 0903  //
 0904  if ( $mode == 'editpost' && ( ( $is_auth['auth_delete'] && $post_data['last_post'] && ( !$post_data['has_poll'] || $post_data['edit_poll'] ) ) || $is_auth['auth_mod'] ) )
 0905  {
 0906      $template->assign_block_vars('switch_delete_checkbox', array());
 0907  }
 0908   
 0909  //
 0910  // Topic type selection
 0911  //
 0912  $topic_type_toggle = '';
 0913  if ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] ) )
 0914  {
 0915      $template->assign_block_vars('switch_type_toggle', array());
 0916   
 0917      if( $is_auth['auth_sticky'] )
 0918      {
 0919          $topic_type_toggle .= '<input type="radio" name="topictype" value="' . POST_STICKY . '"';
 0920          if ( $post_data['topic_type'] == POST_STICKY || $topic_type == POST_STICKY )
 0921          {
 0922              $topic_type_toggle .= ' checked="checked"';
 0923          }
 0924          $topic_type_toggle .= ' /> ' . $lang['Post_Sticky'] . '&nbsp;&nbsp;';
 0925      }
 0926   
 0927      if( $is_auth['auth_announce'] )
 0928      {
 0929          $topic_type_toggle .= '<input type="radio" name="topictype" value="' . POST_ANNOUNCE . '"';
 0930          if ( $post_data['topic_type'] == POST_ANNOUNCE || $topic_type == POST_ANNOUNCE )
 0931          {
 0932              $topic_type_toggle .= ' checked="checked"';
 0933          }
 0934          $topic_type_toggle .= ' /> ' . $lang['Post_Announcement'] . '&nbsp;&nbsp;';
 0935      }
 0936   
 0937      if ( $topic_type_toggle != '' )
 0938      {
 0939          $topic_type_toggle = $lang['Post_topic_as'] . ': <input type="radio" name="topictype" value="' . POST_NORMAL .'"' . ( ( $post_data['topic_type'] == POST_NORMAL || $topic_type == POST_NORMAL ) ? ' checked="checked"' : '' ) . ' /> ' . $lang['Post_Normal'] . '&nbsp;&nbsp;' . $topic_type_toggle;
 0940      }
 0941  }
 0942   
 0943  $hidden_form_fields = '<input type="hidden" name="mode" value="' . $mode . '" />';
 0944  $hidden_form_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
 0945   
 0946  switch( $mode )
 0947  {
 0948      case 'newtopic':
 0949          $page_title = $lang['Post_a_new_topic'];
 0950          $hidden_form_fields .= '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
 0951          break;
 0952   
 0953      case 'reply':
 0954          $page_title = $lang['Post_a_reply'];
 0955          $hidden_form_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
 0956          break;
 0957   
 0958      case 'editpost':
 0959          $page_title = $lang['Edit_Post'];
 0960          $hidden_form_fields .= '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />';
 0961          break;
 0962  }
 0963   
 0964  // Generate smilies listing for page output
 0965  generate_smilies('inline', PAGE_POSTING);
 0966   
 0967  //
 0968  // Include page header
 0969  //
 0970  include($phpbb_root_path . 'includes/page_header.'.$phpEx);
 0971   
 0972  $template->set_filenames(array(
 0973      'body' => 'posting_body.tpl', 
 0974      'pollbody' => 'posting_poll_body.tpl', 
 0975      'reviewbody' => 'posting_topic_review.tpl')
 0976  );
 0977  make_jumpbox('viewforum.'.$phpEx);
 0978   
 0979  $template->assign_vars(array(
 0980      'FORUM_NAME' => $forum_name,
 0981      'L_POST_A' => $page_title,
 0982      'L_POST_SUBJECT' => $lang['Post_subject'], 
 0983   
 0984      'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
 0985  );
 0986   
 0987  //
 0988  // This enables the forum/topic title to be output for posting
 0989  // but not for privmsg (where it makes no sense)
 0990  //
 0991  $template->assign_block_vars('switch_not_privmsg', array());
 0992   
 0993  //
 0994  // Output the data to the template
 0995  //
 0996  $template->assign_vars(array(
 0997      'USERNAME' => $username,
 0998      'SUBJECT' => $subject,
 0999      'MESSAGE' => $message,
 1000      'HTML_STATUS' => $html_status,
 1001      'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">', '</a>'), 
 1002      'SMILIES_STATUS' => $smilies_status, 
 1003   
 1004      'L_SUBJECT' => $lang['Subject'],
 1005      'L_MESSAGE_BODY' => $lang['Message_body'],
 1006      'L_OPTIONS' => $lang['Options'],
 1007      'L_PREVIEW' => $lang['Preview'],
 1008      'L_SPELLCHECK' => $lang['Spellcheck'],
 1009      'L_SUBMIT' => $lang['Submit'],
 1010      'L_CANCEL' => $lang['Cancel'],
 1011      'L_CONFIRM_DELETE' => $lang['Confirm_delete'],
 1012      'L_DISABLE_HTML' => $lang['Disable_HTML_post'], 
 1013      'L_DISABLE_BBCODE' => $lang['Disable_BBCode_post'], 
 1014      'L_DISABLE_SMILIES' => $lang['Disable_Smilies_post'], 
 1015      'L_ATTACH_SIGNATURE' => $lang['Attach_signature'], 
 1016      'L_NOTIFY_ON_REPLY' => $lang['Notify'], 
 1017      'L_DELETE_POST' => $lang['Delete_post'],
 1018   
 1019      'L_BBCODE_B_HELP' => $lang['bbcode_b_help'], 
 1020      'L_BBCODE_I_HELP' => $lang['bbcode_i_help'], 
 1021      'L_BBCODE_U_HELP' => $lang['bbcode_u_help'], 
 1022      'L_BBCODE_Q_HELP' => $lang['bbcode_q_help'], 
 1023      'L_BBCODE_C_HELP' => $lang['bbcode_c_help'], 
 1024      'L_BBCODE_L_HELP' => $lang['bbcode_l_help'], 
 1025      'L_BBCODE_O_HELP' => $lang['bbcode_o_help'], 
 1026      'L_BBCODE_P_HELP' => $lang['bbcode_p_help'], 
 1027      'L_BBCODE_W_HELP' => $lang['bbcode_w_help'], 
 1028      'L_BBCODE_A_HELP' => $lang['bbcode_a_help'], 
 1029      'L_BBCODE_S_HELP' => $lang['bbcode_s_help'], 
 1030      'L_BBCODE_F_HELP' => $lang['bbcode_f_help'], 
 1031      'L_EMPTY_MESSAGE' => $lang['Empty_message'],
 1032   
 1033      'L_FONT_COLOR' => $lang['Font_color'], 
 1034      'L_COLOR_DEFAULT' => $lang['color_default'], 
 1035      'L_COLOR_DARK_RED' => $lang['color_dark_red'], 
 1036      'L_COLOR_RED' => $lang['color_red'], 
 1037      'L_COLOR_ORANGE' => $lang['color_orange'], 
 1038      'L_COLOR_BROWN' => $lang['color_brown'], 
 1039      'L_COLOR_YELLOW' => $lang['color_yellow'], 
 1040      'L_COLOR_GREEN' => $lang['color_green'], 
 1041      'L_COLOR_OLIVE' => $lang['color_olive'], 
 1042      'L_COLOR_CYAN' => $lang['color_cyan'], 
 1043      'L_COLOR_BLUE' => $lang['color_blue'], 
 1044      'L_COLOR_DARK_BLUE' => $lang['color_dark_blue'], 
 1045      'L_COLOR_INDIGO' => $lang['color_indigo'], 
 1046      'L_COLOR_VIOLET' => $lang['color_violet'], 
 1047      'L_COLOR_WHITE' => $lang['color_white'], 
 1048      'L_COLOR_BLACK' => $lang['color_black'], 
 1049   
 1050      'L_FONT_SIZE' => $lang['Font_size'], 
 1051      'L_FONT_TINY' => $lang['font_tiny'], 
 1052      'L_FONT_SMALL' => $lang['font_small'], 
 1053      'L_FONT_NORMAL' => $lang['font_normal'], 
 1054      'L_FONT_LARGE' => $lang['font_large'], 
 1055      'L_FONT_HUGE' => $lang['font_huge'], 
 1056   
 1057      'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'], 
 1058      'L_STYLES_TIP' => $lang['Styles_tip'], 
 1059   
 1060      'U_VIEWTOPIC' => ( $mode == 'reply' ) ? append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postorder=desc") : '', 
 1061      'U_REVIEW_TOPIC' => ( $mode == 'reply' ) ? append_sid("posting.$phpEx?mode=topicreview&amp;" . POST_TOPIC_URL . "=$topic_id") : '', 
 1062   
 1063      'S_HTML_CHECKED' => ( !$html_on ) ? 'checked="checked"' : '', 
 1064      'S_BBCODE_CHECKED' => ( !$bbcode_on ) ? 'checked="checked"' : '', 
 1065      'S_SMILIES_CHECKED' => ( !$smilies_on ) ? 'checked="checked"' : '', 
 1066      'S_SIGNATURE_CHECKED' => ( $attach_sig ) ? 'checked="checked"' : '', 
 1067      'S_NOTIFY_CHECKED' => ( $notify_user ) ? 'checked="checked"' : '', 
 1068      'S_TYPE_TOGGLE' => $topic_type_toggle, 
 1069      'S_TOPIC_ID' => $topic_id, 
 1070      'S_POST_ACTION' => append_sid("posting.$phpEx"),
 1071      'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields)
 1072  );
 1073   
 1074  //
 1075  // Poll entry switch/output
 1076  //
 1077  if( ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['edit_poll']) ) && $is_auth['auth_pollcreate'] )
 1078  {
 1079      $template->assign_vars(array(
 1080          'L_ADD_A_POLL' => $lang['Add_poll'],  
 1081          'L_ADD_POLL_EXPLAIN' => $lang['Add_poll_explain'],   
 1082          'L_POLL_QUESTION' => $lang['Poll_question'],   
 1083          'L_POLL_OPTION' => $lang['Poll_option'],  
 1084          'L_ADD_OPTION' => $lang['Add_option'],
 1085          'L_UPDATE_OPTION' => $lang['Update'],
 1086          'L_DELETE_OPTION' => $lang['Delete'], 
 1087          'L_POLL_LENGTH' => $lang['Poll_for'],  
 1088          'L_DAYS' => $lang['Days'], 
 1089          'L_POLL_LENGTH_EXPLAIN' => $lang['Poll_for_explain'], 
 1090          'L_POLL_DELETE' => $lang['Delete_poll'],
 1091          
 1092          'POLL_TITLE' => $poll_title,
 1093          'POLL_LENGTH' => $poll_length)
 1094      );
 1095   
 1096      if( $mode == 'editpost' && $post_data['edit_poll'] && $post_data['has_poll'])
 1097      {
 1098          $template->assign_block_vars('switch_poll_delete_toggle', array());
 1099      }
 1100   
 1101      if( !empty($poll_options) )
 1102      {
 1103          while( list($option_id, $option_text) = each($poll_options) )
 1104          {
 1105              $template->assign_block_vars('poll_option_rows', array(
 1106                  'POLL_OPTION' => str_replace('"', '&quot;', $option_text), 
 1107   
 1108                  'S_POLL_OPTION_NUM' => $option_id)
 1109              );
 1110          }
 1111      }
 1112   
 1113      $template->assign_var_from_handle('POLLBOX', 'pollbody');
 1114  }
 1115   
 1116  //
 1117  // Topic review
 1118  //
 1119  if( $mode == 'reply' && $is_auth['auth_read'] )
 1120  {
 1121      require($phpbb_root_path . 'includes/topic_review.'.$phpEx);
 1122      topic_review($topic_id, true);
 1123   
 1124      $template->assign_block_vars('switch_inline_mode', array());
 1125      $template->assign_var_from_handle('TOPIC_REVIEW_BOX', 'reviewbody');
 1126  }
 1127   
 1128  $template->pparse('body');
 1129   
 1130  include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
 1131   
 1132  ?>