2001-02-17 08:37:32 +00:00
|
|
|
<?php
|
2001-04-17 07:14:50 +00:00
|
|
|
/***************************************************************************
|
2001-08-26 13:53:41 +00:00
|
|
|
* posting.php
|
2001-04-17 07:14:50 +00:00
|
|
|
* -------------------
|
|
|
|
* begin : Saturday, Feb 13, 2001
|
|
|
|
* copyright : (C) 2001 The phpBB Group
|
|
|
|
* email : support@phpbb.com
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2001-08-30 22:20:23 +00:00
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2001-07-13 16:14:37 +00:00
|
|
|
$phpbb_root_path = "./";
|
|
|
|
include($phpbb_root_path . 'extension.inc');
|
|
|
|
include($phpbb_root_path . 'common.'.$phpEx);
|
|
|
|
include($phpbb_root_path . 'includes/post.'.$phpEx);
|
|
|
|
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
|
2002-01-03 11:06:22 +00:00
|
|
|
include($phpbb_root_path . 'includes/search.'.$phpEx);
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2001-10-16 11:12:32 +00:00
|
|
|
// -----------------------
|
|
|
|
// Page specific functions
|
|
|
|
//
|
2001-11-09 13:15:36 +00:00
|
|
|
|
2001-10-16 11:12:32 +00:00
|
|
|
function topic_review($topic_id, $is_inline_review)
|
|
|
|
{
|
|
|
|
global $db, $board_config, $template, $lang, $images, $theme, $phpEx;
|
2002-01-12 17:00:32 +00:00
|
|
|
global $userdata, $user_ip;
|
2001-10-16 11:12:32 +00:00
|
|
|
global $orig_word, $replacement_word;
|
|
|
|
global $starttime;
|
|
|
|
|
|
|
|
if( !$is_inline_review )
|
|
|
|
{
|
|
|
|
if( !isset($topic_id) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_MESSAGE, 'Topic_not_exist');
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get topic info ...
|
|
|
|
//
|
|
|
|
$sql = "SELECT 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
|
|
|
|
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
|
|
|
|
WHERE t.topic_id = $topic_id
|
|
|
|
AND f.forum_id = t.forum_id";
|
|
|
|
if(!$result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain topic information", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !$total_rows = $db->sql_numrows($result) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
|
|
|
|
}
|
|
|
|
$forum_row = $db->sql_fetchrow($result);
|
|
|
|
|
|
|
|
$forum_id = $forum_row['forum_id'];
|
|
|
|
|
|
|
|
//
|
|
|
|
// Start session management
|
|
|
|
//
|
2002-01-12 17:00:32 +00:00
|
|
|
$userdata = session_pagestart($user_ip, $forum_id, $board_config['session_length']);
|
2001-10-16 11:12:32 +00:00
|
|
|
init_userprefs($userdata);
|
|
|
|
//
|
|
|
|
// End session management
|
|
|
|
//
|
|
|
|
|
|
|
|
$is_auth = array();
|
|
|
|
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Go ahead and pull all data for this topic
|
|
|
|
//
|
2001-11-24 17:17:32 +00:00
|
|
|
$sql = "SELECT u.username, u.user_id, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
|
2001-10-16 11:12:32 +00:00
|
|
|
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
|
|
|
|
WHERE p.topic_id = $topic_id
|
|
|
|
AND p.poster_id = u.user_id
|
|
|
|
AND p.post_id = pt.post_id
|
|
|
|
ORDER BY p.post_time DESC
|
|
|
|
LIMIT " . $board_config['posts_per_page'];
|
|
|
|
if(!$result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain post/user information.", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$total_posts = $db->sql_numrows($result))
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "There don't appear to be any posts for this topic.", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
$postrow = $db->sql_fetchrowset($result);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Define censored word matches
|
|
|
|
//
|
|
|
|
if( empty($orig_word) && empty($replacement_word) )
|
|
|
|
{
|
|
|
|
$orig_word = array();
|
|
|
|
$replacement_word = array();
|
|
|
|
obtain_word_list($orig_word, $replacement_word);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Dump out the page header and load viewtopic body template
|
|
|
|
//
|
|
|
|
if( !$is_inline_review )
|
|
|
|
{
|
|
|
|
$gen_simple_header = TRUE;
|
|
|
|
|
|
|
|
$page_title = $lang['Review_topic'] ." - $topic_title";
|
|
|
|
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
|
|
|
|
|
|
|
$template->set_filenames(array(
|
|
|
|
"reviewbody" => "posting_topic_review.tpl")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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 = $postrow[$i]['username'];
|
|
|
|
|
|
|
|
$post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);
|
|
|
|
|
|
|
|
$mini_post_img = '<img src="' . $images['icon_minipost'] . '" alt="' . $lang['Post'] . '" />';
|
|
|
|
|
|
|
|
//
|
|
|
|
// Handle anon users posting with usernames
|
|
|
|
//
|
|
|
|
if( $poster_id == ANONYMOUS && $postrow[$i]['post_username'] != '' )
|
|
|
|
{
|
|
|
|
$poster = $postrow[$i]['post_username'];
|
|
|
|
$poster_rank = $lang['Guest'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$post_subject = ( $postrow[$i]['post_subject'] != "" ) ? $postrow[$i]['post_subject'] : "";
|
|
|
|
|
|
|
|
$message = $postrow[$i]['post_text'];
|
|
|
|
$bbcode_uid = $postrow[$i]['bbcode_uid'];
|
|
|
|
|
|
|
|
//
|
|
|
|
// If the board has HTML off but the post has HTML
|
|
|
|
// on then we process it, else leave it alone
|
|
|
|
//
|
|
|
|
if( !$board_config['allow_html'] )
|
|
|
|
{
|
|
|
|
if( $postrow[$i]['enable_html'] )
|
|
|
|
{
|
|
|
|
$message = preg_replace("#(<)([\/]?.*?)(>)#is", "<\\2>", $message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $bbcode_uid != "" )
|
|
|
|
{
|
|
|
|
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:[0-9a-z\:]+\]/si", "]", $message);
|
|
|
|
}
|
|
|
|
|
|
|
|
$message = make_clickable($message);
|
|
|
|
|
|
|
|
if( count($orig_word) )
|
|
|
|
{
|
|
|
|
$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
|
|
|
|
$message = preg_replace($orig_word, $replacement_word, $message);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $board_config['allow_smilies'] && $postrow[$i]['enable_smilies'] )
|
|
|
|
{
|
|
|
|
$message = smilies_pass($message);
|
|
|
|
}
|
|
|
|
|
|
|
|
$message = str_replace("\n", "<br />", $message);
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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,
|
|
|
|
|
|
|
|
"MINI_POST_IMG" => $mini_post_img,
|
|
|
|
"POSTER_NAME" => $poster,
|
|
|
|
"POST_DATE" => $post_date,
|
|
|
|
"POST_SUBJECT" => $post_subject,
|
|
|
|
"MESSAGE" => $message)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"L_POSTED" => $lang['Posted'],
|
|
|
|
"L_POST_SUBJECT" => $lang['Post_subject'],
|
|
|
|
"L_TOPIC_REVIEW" => $lang['Topic_review'])
|
|
|
|
);
|
|
|
|
|
|
|
|
if( !$is_inline_review )
|
|
|
|
{
|
|
|
|
$template->pparse("reviewbody");
|
|
|
|
|
|
|
|
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// End page specific functions
|
|
|
|
// ---------------------------
|
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
// -------------------------------------------
|
|
|
|
// Do some initial checks, set basic variables,
|
|
|
|
// etc.
|
2001-05-17 14:48:39 +00:00
|
|
|
//
|
2001-11-26 14:07:33 +00:00
|
|
|
$html_entities_match = array("#&#", "#<#", "#>#", "#\"#");
|
|
|
|
$html_entities_replace = array("&", "<", ">", """);
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
$submit = ( isset($HTTP_POST_VARS['submit']) ) ? TRUE : 0;
|
|
|
|
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? TRUE : 0;
|
|
|
|
$preview = ( isset($HTTP_POST_VARS['preview']) ) ? TRUE : 0;
|
|
|
|
$confirm = ( isset($HTTP_POST_VARS['confirm']) ) ? TRUE : 0;
|
|
|
|
$delete = ( isset($HTTP_POST_VARS['delete']) ) ? TRUE : 0;
|
|
|
|
$poll_delete = ( isset($HTTP_POST_VARS['poll_delete']) ) ? TRUE : 0;
|
|
|
|
|
|
|
|
$poll_add_option = ( isset($HTTP_POST_VARS['add_poll_option']) ) ? TRUE : 0;
|
|
|
|
$poll_edit_option = ( isset($HTTP_POST_VARS['edit_poll_option']) ) ? TRUE : 0;
|
|
|
|
$poll_delete_option = ( isset($HTTP_POST_VARS['del_poll_option']) ) ? TRUE : 0;
|
|
|
|
|
|
|
|
$refresh = $preview || $poll_add_option || $poll_edit_option || $poll_delete_option;
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2001-07-04 00:34:33 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
// Mode, topic_id, post_id and forum_id settings
|
2001-07-04 00:34:33 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
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'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$mode = "";
|
|
|
|
}
|
|
|
|
|
2001-08-30 22:20:23 +00:00
|
|
|
if( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) )
|
2001-05-30 20:35:36 +00:00
|
|
|
{
|
2001-07-20 00:26:56 +00:00
|
|
|
$forum_id = (isset($HTTP_POST_VARS[POST_FORUM_URL])) ? $HTTP_POST_VARS[POST_FORUM_URL] : $HTTP_GET_VARS[POST_FORUM_URL];
|
2001-05-30 20:35:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-10 22:32:39 +00:00
|
|
|
$forum_id = "";
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-07-10 22:32:39 +00:00
|
|
|
if( isset($HTTP_GET_VARS[POST_POST_URL]) || isset($HTTP_POST_VARS[POST_POST_URL]) )
|
|
|
|
{
|
2001-07-20 00:26:56 +00:00
|
|
|
$post_id = (isset($HTTP_POST_VARS[POST_POST_URL])) ? $HTTP_POST_VARS[POST_POST_URL] : $HTTP_GET_VARS[POST_POST_URL];
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$post_id = "";
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-07-10 22:32:39 +00:00
|
|
|
if( isset($HTTP_GET_VARS[POST_TOPIC_URL]) || isset($HTTP_POST_VARS[POST_TOPIC_URL]) )
|
|
|
|
{
|
2001-07-20 00:26:56 +00:00
|
|
|
$topic_id = (isset($HTTP_POST_VARS[POST_TOPIC_URL])) ? $HTTP_POST_VARS[POST_TOPIC_URL] : $HTTP_GET_VARS[POST_TOPIC_URL];
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$topic_id = "";
|
2001-05-30 20:35:36 +00:00
|
|
|
}
|
2001-06-06 17:50:24 +00:00
|
|
|
|
2001-09-15 22:11:20 +00:00
|
|
|
|
2001-08-10 22:00:12 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
// Was cancel pressed? If so then redirect to the appropriate
|
|
|
|
// page, no point in continuing with any further checks
|
2001-08-10 22:00:12 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $cancel )
|
2001-08-10 22:00:12 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
if($post_id != "")
|
|
|
|
{
|
2001-10-14 18:22:32 +00:00
|
|
|
$redirect = "viewtopic.$phpEx?" . POST_POST_URL . "=$post_id";
|
|
|
|
$post_append = "#$post_id";
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
else if($topic_id != "")
|
|
|
|
{
|
2001-09-07 00:23:40 +00:00
|
|
|
$redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id";
|
2001-10-14 18:22:32 +00:00
|
|
|
$post_append = "";
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
else if($forum_id != "")
|
|
|
|
{
|
2001-09-07 00:23:40 +00:00
|
|
|
$redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id";
|
2001-10-14 18:22:32 +00:00
|
|
|
$post_append = "";
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-07 00:23:40 +00:00
|
|
|
$redirect = "index.$phpEx";
|
2001-10-14 18:22:32 +00:00
|
|
|
$post_append = "";
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
2001-10-14 18:22:32 +00:00
|
|
|
header("Location:" . append_sid($redirect) . $post_append, true);
|
2001-08-10 22:00:12 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Continue var definitions
|
|
|
|
//
|
2001-08-10 22:00:12 +00:00
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-10 22:00:12 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
2001-10-16 11:12:32 +00:00
|
|
|
// If the mode is set to topic review then output
|
|
|
|
// that review ...
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
2001-10-16 11:12:32 +00:00
|
|
|
if( $mode == "topicreview" )
|
2001-08-10 22:00:12 +00:00
|
|
|
{
|
2001-10-16 11:12:32 +00:00
|
|
|
topic_review($topic_id, false);
|
|
|
|
exit;
|
2001-08-10 22:00:12 +00:00
|
|
|
}
|
2001-12-16 18:13:34 +00:00
|
|
|
else if( $mode == "smilies" )
|
|
|
|
{
|
2001-12-29 15:18:34 +00:00
|
|
|
generate_smilies("window", PAGE_POSTING);
|
2001-12-16 18:13:34 +00:00
|
|
|
exit;
|
|
|
|
}
|
2001-08-10 22:00:12 +00:00
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Start session management
|
|
|
|
//
|
|
|
|
$userdata = session_pagestart($user_ip, PAGE_POSTING, $board_config['session_length']);
|
|
|
|
init_userprefs($userdata);
|
|
|
|
//
|
|
|
|
// End session management
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Set toggles for various options
|
|
|
|
//
|
|
|
|
if( !$board_config['allow_html'] )
|
|
|
|
{
|
|
|
|
$html_on = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-25 18:26:05 +00:00
|
|
|
$html_on = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : TRUE ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_html'] : $userdata['user_allowhtml'] );
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
2001-05-30 20:35:36 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( !$board_config['allow_bbcode'] )
|
2001-06-13 17:36:58 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$bbcode_on = 0;
|
2001-06-13 17:36:58 +00:00
|
|
|
}
|
2001-07-10 22:32:39 +00:00
|
|
|
else
|
|
|
|
{
|
2001-09-25 18:26:05 +00:00
|
|
|
$bbcode_on = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : TRUE ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_bbcode'] : $userdata['user_allowbbcode'] );
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !$board_config['allow_smilies'] )
|
|
|
|
{
|
|
|
|
$smilies_on = 0;
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
else
|
|
|
|
{
|
2001-09-25 18:26:05 +00:00
|
|
|
$smilies_on = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : TRUE ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] );
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-25 18:26:05 +00:00
|
|
|
$attach_sig = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['attach_sig']) ) ? TRUE : 0 ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? 0 : $userdata['user_attachsig'] );
|
2001-08-10 22:00:12 +00:00
|
|
|
|
2001-07-10 22:32:39 +00:00
|
|
|
//
|
2001-08-30 22:20:23 +00:00
|
|
|
// Here we do various lookups to find topic_id, forum_id, post_id etc.
|
2001-08-10 22:00:12 +00:00
|
|
|
// Doing it here prevents spoofing (eg. faking forum_id, topic_id or post_id
|
2001-07-10 22:32:39 +00:00
|
|
|
//
|
|
|
|
if( $mode != "newtopic" )
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $mode == "reply" || $mode == "quote" || $mode == "vote" )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
if( ( $mode == "reply" || $mode == "vote" ) && $topic_id )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "SELECT f.forum_id, f.forum_status, f.forum_name, t.topic_status
|
2001-08-30 22:20:23 +00:00
|
|
|
FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t
|
|
|
|
WHERE t.topic_id = $topic_id
|
2001-07-24 17:51:21 +00:00
|
|
|
AND f.forum_id = t.forum_id";
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
else if( $mode == "quote" && $post_id )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "SELECT f.forum_id, f.forum_status, f.forum_name, t.topic_id, t.topic_status
|
2001-08-30 22:20:23 +00:00
|
|
|
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
|
|
|
|
WHERE p.post_id = $post_id
|
|
|
|
AND t.topic_id = p.topic_id
|
2001-07-24 17:51:21 +00:00
|
|
|
AND f.forum_id = t.forum_id";
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$message = ( $mode == "quote" ) ? $lang['No_post_id'] : $lang['No_topic_id'];
|
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-10 14:57:52 +00:00
|
|
|
else if( $mode == "editpost" || $mode == "delete" )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $post_id )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "SELECT p2.post_id, t.topic_id, t.topic_status, t.topic_last_post_id, t.topic_vote, f.forum_id, f.forum_name, f.forum_status, f.forum_last_post_id
|
|
|
|
FROM " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
|
|
|
|
WHERE p.post_id = $post_id
|
|
|
|
AND p2.topic_id = p.topic_id
|
|
|
|
AND t.topic_id = p.topic_id
|
2001-08-30 22:20:23 +00:00
|
|
|
AND f.forum_id = t.forum_id
|
2001-09-06 00:29:07 +00:00
|
|
|
ORDER BY p2.post_time ASC
|
2001-07-10 22:32:39 +00:00
|
|
|
LIMIT 1";
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_MESSAGE, $lang['No_post_id']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_MESSAGE, $lang['No_valid_mode']);
|
|
|
|
}
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $result = $db->sql_query($sql) )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
|
|
|
$check_row = $db->sql_fetchrow($result);
|
|
|
|
|
|
|
|
$forum_id = $check_row['forum_id'];
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
$forum_name = $check_row['forum_name'];
|
2001-08-30 22:20:23 +00:00
|
|
|
$topic_status = $check_row['topic_status'];
|
2001-07-24 17:51:21 +00:00
|
|
|
$forum_status = $check_row['forum_status'];
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-10-10 14:57:52 +00:00
|
|
|
if( $mode == "editpost" || $mode == "delete" )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$topic_id = $check_row['topic_id'];
|
|
|
|
|
|
|
|
$is_first_post_topic = ($check_row['post_id'] == $post_id) ? TRUE : 0;
|
|
|
|
$is_last_post_topic = ($check_row['topic_last_post_id'] == $post_id) ? TRUE : 0;
|
2001-08-30 22:20:23 +00:00
|
|
|
$is_last_post_forum = ($check_row['forum_last_post_id'] == $post_id) ? TRUE : 0;
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
$post_has_poll = ($check_row['topic_vote']) ? TRUE : 0;
|
|
|
|
|
|
|
|
if( $is_first_post_topic && $post_has_poll )
|
|
|
|
{
|
|
|
|
$sql = "SELECT vd.vote_id, 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";
|
|
|
|
if( !$result = $db->sql_query($sql) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain vote data for this topic", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $vote_rows = $db->sql_numrows($result) )
|
|
|
|
{
|
|
|
|
$rowset = $db->sql_fetchrowset($result);
|
|
|
|
|
|
|
|
$vote_id = $rowset[0]['vote_id'];
|
|
|
|
|
|
|
|
$vote_results_sum = 0;
|
|
|
|
for($i = 0; $i < $vote_rows; $i++ )
|
|
|
|
{
|
|
|
|
$vote_results_sum += $rowset[$i]['vote_result'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$can_edit_poll = ( !$vote_results_sum ) ? TRUE : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$can_edit_poll = 0;
|
|
|
|
}
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $mode == "quote" )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
|
|
|
$topic_id = $check_row['topic_id'];
|
|
|
|
}
|
2001-07-15 15:45:09 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$is_first_post_topic = 0;
|
|
|
|
$is_last_post_topic = 0;
|
|
|
|
$post_has_poll = 0;
|
|
|
|
$can_edit_poll = 0;
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-24 17:51:21 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $lang['No_such_post']);
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "SELECT forum_name, forum_status
|
|
|
|
FROM " . FORUMS_TABLE . "
|
2001-07-24 17:51:21 +00:00
|
|
|
WHERE forum_id = $forum_id";
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $result = $db->sql_query($sql) )
|
2001-07-24 17:51:21 +00:00
|
|
|
{
|
|
|
|
$check_row = $db->sql_fetchrow($result);
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$forum_status = $check_row['forum_status'];
|
|
|
|
$forum_name = $check_row['forum_name'];
|
2001-07-24 17:51:21 +00:00
|
|
|
$topic_status = TOPIC_UNLOCKED;
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
$is_first_post_topic = TRUE;
|
|
|
|
$is_last_post_topic = 0;
|
|
|
|
$post_has_poll = 0;
|
|
|
|
$can_edit_poll = 0;
|
|
|
|
|
2001-07-24 17:51:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_MESSAGE, $lang['Forum_not_exist']);
|
|
|
|
}
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
2001-05-30 20:35:36 +00:00
|
|
|
|
2001-10-16 11:12:32 +00:00
|
|
|
//
|
|
|
|
// Set topic type
|
|
|
|
//
|
|
|
|
if( isset($HTTP_POST_VARS['topictype']) )
|
|
|
|
{
|
2001-10-17 23:05:46 +00:00
|
|
|
if( $HTTP_POST_VARS['topictype'] == "announce" )
|
2001-10-16 11:12:32 +00:00
|
|
|
{
|
|
|
|
$topic_type = POST_ANNOUNCE;
|
|
|
|
}
|
2001-10-16 16:23:33 +00:00
|
|
|
else if( $HTTP_POST_VARS['topictype'] == "sticky" )
|
2001-10-16 11:12:32 +00:00
|
|
|
{
|
|
|
|
$topic_type = POST_STICKY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$topic_type = POST_NORMAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$topic_type = POST_NORMAL;
|
|
|
|
}
|
|
|
|
|
2001-07-10 22:32:39 +00:00
|
|
|
//
|
|
|
|
// Auth checks
|
2001-05-30 20:35:36 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
$auth_type = AUTH_ALL;
|
|
|
|
switch( $mode )
|
2001-05-30 20:35:36 +00:00
|
|
|
{
|
|
|
|
case 'newtopic':
|
2001-10-17 23:05:46 +00:00
|
|
|
if( $topic_type == POST_ANNOUNCE )
|
2001-06-07 07:56:45 +00:00
|
|
|
{
|
|
|
|
$is_auth_type = "auth_announce";
|
2001-07-04 00:34:33 +00:00
|
|
|
$auth_string = $lang['can_post_announcements'];
|
2001-06-07 07:56:45 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
else if( $topic_type == POST_STICKY )
|
2001-06-07 07:56:45 +00:00
|
|
|
{
|
|
|
|
$is_auth_type = "auth_sticky";
|
2001-07-04 00:34:33 +00:00
|
|
|
$auth_string = $lang['can_post_sticky_topics'];
|
2001-06-07 07:56:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$is_auth_type = "auth_post";
|
2001-07-04 00:34:33 +00:00
|
|
|
$auth_string = $lang['can_post_new_topics'];
|
2001-06-07 07:56:45 +00:00
|
|
|
}
|
2001-05-30 20:35:36 +00:00
|
|
|
break;
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-05-30 20:35:36 +00:00
|
|
|
case 'reply':
|
2001-07-06 01:09:42 +00:00
|
|
|
case 'quote':
|
|
|
|
$is_auth_type = "auth_reply";
|
|
|
|
$auth_string = $lang['can_reply_to_topics'];
|
|
|
|
break;
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-05-30 20:35:36 +00:00
|
|
|
case 'editpost':
|
2001-06-01 00:28:50 +00:00
|
|
|
$is_auth_type = "auth_edit";
|
2001-07-04 00:34:33 +00:00
|
|
|
$auth_string = $lang['can_edit_topics'];
|
2001-05-30 20:35:36 +00:00
|
|
|
break;
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-05-30 20:35:36 +00:00
|
|
|
case 'delete':
|
2001-06-01 00:28:50 +00:00
|
|
|
$is_auth_type = "auth_delete";
|
2001-07-04 00:34:33 +00:00
|
|
|
$auth_string = $lang['can_delete_topics'];
|
2001-05-30 20:35:36 +00:00
|
|
|
break;
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
case 'vote':
|
|
|
|
$is_auth_type = "auth_vote";
|
|
|
|
$auth_string = $lang['can_vote'];
|
|
|
|
break;
|
|
|
|
|
2001-10-16 11:12:32 +00:00
|
|
|
case 'topicreview':
|
|
|
|
$is_auth_type = "auth_read";
|
|
|
|
$auth_string = $lang['can_read'];
|
|
|
|
break;
|
|
|
|
|
2001-05-30 20:35:36 +00:00
|
|
|
default:
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $lang['No_post_mode']);
|
2001-05-30 20:35:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Do required auth check
|
|
|
|
//
|
2001-05-30 20:35:36 +00:00
|
|
|
$is_auth = auth($auth_type, $forum_id, $userdata);
|
2001-06-01 01:45:50 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// The user is not authed, if they're not logged in then redirect
|
|
|
|
// them, else show them an error message
|
|
|
|
//
|
|
|
|
if( !$is_auth[$is_auth_type] )
|
2001-05-30 20:35:36 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
if( !$userdata['session_logged_in'] )
|
2001-07-20 00:26:56 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
switch( $mode )
|
2001-07-20 00:26:56 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
case 'newtopic':
|
|
|
|
$redirect = "mode=newtopic&" . POST_FORUM_URL . "=$forum_id";
|
|
|
|
break;
|
|
|
|
case 'reply':
|
2001-10-16 11:12:32 +00:00
|
|
|
case 'topicreview':
|
2001-09-06 00:29:07 +00:00
|
|
|
$redirect = "mode=reply&" . POST_TOPIC_URL . "=$topic_id";
|
|
|
|
break;
|
|
|
|
case 'quote':
|
|
|
|
$redirect = "mode=quote&" . POST_POST_URL ."=$post_id";
|
|
|
|
break;
|
|
|
|
case 'editpost':
|
|
|
|
$redirect = "mode=editpost&" . POST_POST_URL ."=$post_id&" . POST_TOPIC_URL . "=$topic_id";
|
|
|
|
break;
|
2001-07-20 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2001-10-14 18:22:32 +00:00
|
|
|
header("Location: " . append_sid("login.$phpEx?redirect=posting.$phpEx&" . $redirect, true));
|
2001-07-20 00:26:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-24 15:57:31 +00:00
|
|
|
$message = sprintf($lang['Sorry_' . $is_auth_type], $is_auth[$is_auth_type . "_type"]);
|
2001-07-20 00:26:56 +00:00
|
|
|
}
|
2001-05-30 20:35:36 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
2001-05-30 20:35:36 +00:00
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
//
|
2001-05-30 20:35:36 +00:00
|
|
|
// End Auth
|
2001-05-25 00:56:07 +00:00
|
|
|
//
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2001-12-15 14:19:29 +00:00
|
|
|
//
|
|
|
|
// Is topic or forum locked?
|
|
|
|
//
|
|
|
|
if( $forum_status == FORUM_LOCKED && !$is_auth['auth_mod'])
|
|
|
|
{
|
|
|
|
message_die(GENERAL_MESSAGE, $lang['Forum_locked']);
|
|
|
|
}
|
|
|
|
else if( $topic_status == TOPIC_LOCKED && !$is_auth['auth_mod'])
|
|
|
|
{
|
|
|
|
message_die(GENERAL_MESSAGE, $lang['Topic_locked']);
|
|
|
|
}
|
|
|
|
|
2001-09-18 01:24:47 +00:00
|
|
|
//
|
|
|
|
// Notify on reply
|
|
|
|
//
|
|
|
|
if( ( $mode == "reply" || $mode == "editpost" ) && $topic_id )
|
|
|
|
{
|
|
|
|
if( $submit || $refresh )
|
|
|
|
{
|
|
|
|
$notify_user = ( !empty($HTTP_POST_VARS['notify']) ) ? TRUE : 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$sql = "SELECT topic_id
|
|
|
|
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, "Couldn't obtain topic watch information", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
$notify_user = ( $db->sql_numrows($result) ) ? TRUE : $userdata['user_notify'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$notify_user = ( $submit || $preview ) ? ( ( !empty($HTTP_POST_VARS['notify']) ) ? TRUE : 0 ) : $userdata['user_notify'];
|
|
|
|
}
|
|
|
|
|
2001-07-10 22:32:39 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
// End variable checks and definitions
|
|
|
|
// -----------------------------------
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------
|
|
|
|
// All initial checks complete, we can not start the major
|
|
|
|
// posting related code
|
2001-05-26 00:25:50 +00:00
|
|
|
//
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $submit && $mode != "vote" )
|
|
|
|
{
|
2001-11-26 01:37:25 +00:00
|
|
|
$post_username = trim(strip_tags($HTTP_POST_VARS['username']));
|
|
|
|
if( !empty($post_username) )
|
2001-05-27 03:11:27 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
if( !validate_username(stripslashes($post_username)) )
|
2001-06-11 00:58:08 +00:00
|
|
|
{
|
|
|
|
$error = TRUE;
|
2001-07-10 22:32:39 +00:00
|
|
|
if(!empty($error_msg))
|
2001-06-11 00:58:08 +00:00
|
|
|
{
|
|
|
|
$error_msg .= "<br />";
|
|
|
|
}
|
2001-11-25 23:31:04 +00:00
|
|
|
$error_msg .= $lang['Invalid_username'];
|
2001-06-11 00:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$post_username = "";
|
2001-06-11 00:58:08 +00:00
|
|
|
}
|
|
|
|
|
2002-01-25 12:58:24 +00:00
|
|
|
$post_subject = trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['subject'])));
|
2001-12-15 22:05:25 +00:00
|
|
|
if( ( $mode == "newtopic" || ( $mode == "editpost" && $is_first_post_topic ) ) && empty($post_subject) )
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
|
|
|
$error = TRUE;
|
2001-09-06 00:29:07 +00:00
|
|
|
if( !empty($error_msg) )
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
|
|
|
$error_msg .= "<br />";
|
|
|
|
}
|
2001-06-12 13:34:27 +00:00
|
|
|
$error_msg .= $lang['Empty_subject'];
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-11-27 17:36:04 +00:00
|
|
|
$post_message = trim($HTTP_POST_VARS['message']);
|
2001-11-26 01:37:25 +00:00
|
|
|
if( !empty($post_message) )
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
if( !$error )
|
2001-05-25 00:56:07 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $bbcode_on )
|
2001-03-09 23:33:06 +00:00
|
|
|
{
|
2001-07-04 00:34:33 +00:00
|
|
|
$bbcode_uid = make_bbcode_uid();
|
2001-03-09 23:33:06 +00:00
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-11-26 01:37:25 +00:00
|
|
|
$post_message = prepare_message($post_message, $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$error = TRUE;
|
2001-07-10 22:32:39 +00:00
|
|
|
if(!empty($error_msg))
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
|
|
|
$error_msg .= "<br />";
|
|
|
|
}
|
2001-07-10 22:32:39 +00:00
|
|
|
$error_msg .= $lang['Empty_message'];
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Handle poll stuff
|
|
|
|
//
|
|
|
|
$topic_vote = 0;
|
|
|
|
|
|
|
|
if( $mode == "newtopic" || $mode == "editpost" )
|
|
|
|
{
|
|
|
|
if( $is_auth['auth_pollcreate'] && $is_first_post_topic )
|
|
|
|
{
|
2002-01-25 12:58:24 +00:00
|
|
|
$poll_title = ( isset($HTTP_POST_VARS['poll_title']) ) ? trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['poll_title']))) : "";
|
2001-09-06 00:29:07 +00:00
|
|
|
$poll_length = ( isset($HTTP_POST_VARS['poll_length']) ) ? intval($HTTP_POST_VARS['poll_length']) : 0;
|
|
|
|
if( $poll_length < 0 )
|
|
|
|
{
|
|
|
|
$poll_length = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$poll_options = 0;
|
|
|
|
$poll_option_list = array();
|
|
|
|
if( isset($HTTP_POST_VARS['poll_option_text']) )
|
|
|
|
{
|
|
|
|
while( list($option_id, $option_text) = each($HTTP_POST_VARS['poll_option_text']) )
|
|
|
|
{
|
2002-01-25 12:58:24 +00:00
|
|
|
$poll_option_list[$option_id] = trim(strip_tags(htmlspecialchars($option_text)));
|
2001-09-06 00:29:07 +00:00
|
|
|
$poll_options++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $poll_title == "" && $poll_options )
|
|
|
|
{
|
|
|
|
$error = TRUE;
|
|
|
|
if(!empty($error_msg))
|
|
|
|
{
|
|
|
|
$error_msg .= "<br />";
|
|
|
|
}
|
|
|
|
$error_msg .= $lang['Empty_poll_title'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $poll_title != "" )
|
|
|
|
{
|
|
|
|
if( $poll_options < 2 )
|
|
|
|
{
|
|
|
|
$error = TRUE;
|
|
|
|
if(!empty($error_msg))
|
|
|
|
{
|
|
|
|
$error_msg .= "<br />";
|
|
|
|
}
|
|
|
|
$error_msg .= $lang['To_few_poll_options'];
|
|
|
|
}
|
|
|
|
else if( $poll_options > $board_config['max_poll_options'] )
|
|
|
|
{
|
|
|
|
$error = TRUE;
|
|
|
|
if(!empty($error_msg))
|
|
|
|
{
|
|
|
|
$error_msg .= "<br />";
|
|
|
|
}
|
|
|
|
$error_msg .= $lang['To_many_poll_options'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $poll_title != "" && $poll_options >= 2 && $poll_options <= $board_config['max_poll_options'] )
|
|
|
|
{
|
|
|
|
$topic_vote = 1;
|
|
|
|
$sql_topic_vote_edit = ", topic_vote = 1";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
|
2001-07-06 01:09:42 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
// Submit or confirm ... big chunk of code ... can probably be
|
|
|
|
// still further reduced, will look at it later, possibly for
|
|
|
|
// 2.2
|
2001-07-06 01:09:42 +00:00
|
|
|
//
|
2001-10-10 14:57:52 +00:00
|
|
|
if( ( $submit || $confirm || $mode == "delete" ) && !$error )
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$current_time = time();
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Which mode was selected?
|
|
|
|
//
|
|
|
|
if( $mode == "newtopic" || $mode == "reply" )
|
2001-07-06 01:09:42 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Flood control
|
|
|
|
//
|
2001-12-19 14:12:51 +00:00
|
|
|
$where_sql = ( $userdata['user_id'] == ANONYMOUS ) ? "poster_ip = '$user_ip'" : "poster_id = " . $userdata['user_id'];
|
2002-01-12 17:00:32 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "SELECT MAX(post_time) AS last_post_time
|
|
|
|
FROM " . POSTS_TABLE . "
|
2001-12-19 14:12:51 +00:00
|
|
|
WHERE $where_sql";
|
2001-09-06 00:29:07 +00:00
|
|
|
if($result = $db->sql_query($sql))
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$db_row = $db->sql_fetchrow($result);
|
2001-07-04 00:34:33 +00:00
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
if( $last_post_time = $db_row['last_post_time'] )
|
2001-03-09 23:33:06 +00:00
|
|
|
{
|
2002-01-12 17:00:32 +00:00
|
|
|
if( ($current_time - $last_post_time) < $board_config['flood_interval'] )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_MESSAGE, $lang['Flood_Error']);
|
|
|
|
}
|
2001-05-25 07:02:48 +00:00
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// End Flood control
|
|
|
|
//
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $mode == "newtopic" )
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote)
|
2001-12-21 15:51:31 +00:00
|
|
|
VALUES ('" . str_replace("\'", "''", $post_subject) . "', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)";
|
2002-01-12 17:00:32 +00:00
|
|
|
$result = $db->sql_query($sql, BEGIN_TRANSACTION);
|
|
|
|
if( !$result )
|
2001-07-06 01:09:42 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Error inserting data into topics table", "", __LINE__, __FILE__, $sql);
|
2001-06-11 00:58:08 +00:00
|
|
|
}
|
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
$new_topic_id = $db->sql_nextid();
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Handle poll ...
|
|
|
|
//
|
|
|
|
if( $is_auth['auth_pollcreate'] && $topic_vote )
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "INSERT INTO " . VOTE_DESC_TABLE . " (topic_id, vote_text, vote_start, vote_length)
|
2001-12-21 15:51:31 +00:00
|
|
|
VALUES ($new_topic_id, '" . str_replace("\'", "''", $poll_title) . "', $current_time, " . ( $poll_length * 86400 ) . ")";
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $result = $db->sql_query($sql) )
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$new_vote_id = $db->sql_nextid();
|
2001-07-04 00:34:33 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$poll_option_id = 1;
|
|
|
|
while( list($option_id, $option_text) = each($poll_option_list) )
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "INSERT INTO " . VOTE_RESULTS_TABLE . " (vote_id, vote_option_id, vote_option_text, vote_result)
|
2001-12-21 15:51:31 +00:00
|
|
|
VALUES ($new_vote_id, $poll_option_id, '" . str_replace("\'", "''", $option_text) . "', 0)";
|
2001-09-06 00:29:07 +00:00
|
|
|
if( !$result = $db->sql_query($sql) )
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
// Rollback ...
|
|
|
|
if(SQL_LAYER == "mysql")
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql_del_t = "DELETE FROM " . TOPICS_TABLE . "
|
|
|
|
WHERE topic_id = $topic_id";
|
|
|
|
$db->sql_query($sql_del_t);
|
|
|
|
$sql_del_v = "DELETE FROM " . VOTE_DESC_TABLE . "
|
|
|
|
WHERE vote_id = $new_vote_id";
|
|
|
|
$db->sql_query($sql_del_v);
|
|
|
|
}
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't insert new poll options", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
$poll_option_id++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(SQL_LAYER == "mysql")
|
|
|
|
{
|
|
|
|
// Rollback ...
|
|
|
|
$sql_del_t = "DELETE FROM " . TOPICS_TABLE . "
|
|
|
|
WHERE topic_id = $topic_id";
|
|
|
|
$db->sql_query($sql_del_t);
|
|
|
|
}
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't insert new poll information", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$new_topic_id = $topic_id;
|
|
|
|
}
|
2001-08-14 00:29:39 +00:00
|
|
|
|
2001-11-24 17:17:32 +00:00
|
|
|
$sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig)
|
2001-12-21 15:51:31 +00:00
|
|
|
VALUES ($new_topic_id, $forum_id, " . $userdata['user_id'] . ", '" . str_replace("\'", "''", $post_username) . "', $current_time, '$user_ip', $bbcode_on, $html_on, $smilies_on, $attach_sig)";
|
2001-09-06 00:29:07 +00:00
|
|
|
$result = ($mode == "reply") ? $db->sql_query($sql, BEGIN_TRANSACTION) : $db->sql_query($sql);
|
|
|
|
|
2001-11-09 13:15:36 +00:00
|
|
|
if( $result )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
|
|
|
$new_post_id = $db->sql_nextid();
|
|
|
|
|
2001-11-24 17:17:32 +00:00
|
|
|
$sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text)
|
2001-12-21 15:51:31 +00:00
|
|
|
VALUES ($new_post_id, '" . str_replace("\'", "''", $post_subject) . "', '$bbcode_uid', '" . str_replace("\'", "''", $post_message) . "')";
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-11-09 13:15:36 +00:00
|
|
|
if( $db->sql_query($sql) )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
|
|
|
$sql = "UPDATE " . TOPICS_TABLE . "
|
|
|
|
SET topic_last_post_id = $new_post_id";
|
|
|
|
if($mode == "reply")
|
|
|
|
{
|
|
|
|
$sql .= ", topic_replies = topic_replies + 1 ";
|
|
|
|
}
|
|
|
|
$sql .= " WHERE topic_id = $new_topic_id";
|
|
|
|
|
2001-11-09 13:15:36 +00:00
|
|
|
if( $db->sql_query($sql) )
|
2001-10-16 13:10:09 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "UPDATE " . FORUMS_TABLE . "
|
|
|
|
SET forum_last_post_id = $new_post_id, forum_posts = forum_posts + 1";
|
2001-11-09 13:15:36 +00:00
|
|
|
if( $mode == "newtopic" )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
|
|
|
$sql .= ", forum_topics = forum_topics + 1";
|
|
|
|
}
|
2001-10-16 17:15:25 +00:00
|
|
|
|
|
|
|
$sql .= " WHERE forum_id = $forum_id";
|
2001-10-16 13:10:09 +00:00
|
|
|
|
2001-11-09 13:15:36 +00:00
|
|
|
if( $db->sql_query($sql) )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
|
|
|
$sql = "UPDATE " . USERS_TABLE . "
|
|
|
|
SET user_posts = user_posts + 1
|
|
|
|
WHERE user_id = " . $userdata['user_id'];
|
|
|
|
|
2001-11-09 13:15:36 +00:00
|
|
|
if( $db->sql_query($sql, END_TRANSACTION))
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
2002-01-12 17:00:32 +00:00
|
|
|
add_search_words($new_post_id, stripslashes($post_message), stripslashes($post_subject));
|
2001-11-09 13:15:36 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Email users who are watching this topic
|
|
|
|
//
|
2001-09-18 01:24:47 +00:00
|
|
|
if( $mode == "reply" )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
2002-01-07 18:50:30 +00:00
|
|
|
$sql = "SELECT u.user_id, u.username, u.user_email, u.user_lang, t.topic_title
|
2001-09-06 00:29:07 +00:00
|
|
|
FROM " . TOPICS_WATCH_TABLE . " tw, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u
|
|
|
|
WHERE tw.topic_id = $new_topic_id
|
|
|
|
AND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . " )
|
|
|
|
AND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "
|
|
|
|
AND t.topic_id = tw.topic_id
|
|
|
|
AND u.user_id = tw.user_id";
|
|
|
|
if( $result = $db->sql_query($sql) )
|
2001-08-14 00:29:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$email_set = $db->sql_fetchrowset($result);
|
|
|
|
$update_watched_sql = "";
|
2001-08-14 00:29:39 +00:00
|
|
|
|
2001-10-05 14:13:58 +00:00
|
|
|
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
|
|
|
|
$emailer = new emailer($board_config['smtp_delivery']);
|
|
|
|
|
|
|
|
$email_headers = "From: " . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\r\n";
|
2001-11-17 17:51:59 +00:00
|
|
|
|
2001-11-27 18:26:03 +00:00
|
|
|
if( isset($HTTP_SERVER_VARS['PATH_INFO']) && dirname($HTTP_SERVER_VARS['PATH_INFO']) != '/')
|
2001-11-27 17:59:27 +00:00
|
|
|
{
|
2001-11-27 18:26:03 +00:00
|
|
|
$path = dirname($HTTP_SERVER_VARS['PATH_INFO']);
|
|
|
|
}
|
|
|
|
else if( dirname($HTTP_SERVER_VARS['SCRIPT_NAME']) != '/')
|
|
|
|
{
|
|
|
|
$path = dirname($HTTP_SERVER_VARS['SCRIPT_NAME']);
|
2001-11-27 17:59:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-27 18:26:03 +00:00
|
|
|
$path = '';
|
2001-11-27 17:59:27 +00:00
|
|
|
}
|
2001-12-19 16:59:44 +00:00
|
|
|
|
|
|
|
$orig_word = array();
|
|
|
|
$replacement_word = array();
|
|
|
|
obtain_word_list($orig_word, $replacement_word);
|
|
|
|
|
|
|
|
$topic_title = preg_replace($orig_word, $replacement_word, $email_set[0]['topic_title']);
|
2001-11-27 17:59:27 +00:00
|
|
|
|
2001-10-14 22:32:38 +00:00
|
|
|
$server_name = ( isset($HTTP_SERVER_VARS['HTTP_HOST']) ) ? $HTTP_SERVER_VARS['HTTP_HOST'] : $HTTP_SERVER_VARS['SERVER_NAME'];
|
2001-11-19 23:56:00 +00:00
|
|
|
$protocol = ( !empty($HTTP_SERVER_VARS['HTTPS']) ) ? ( ( $HTTP_SERVER_VARS['HTTPS'] == "on" ) ? "https://" : "http://" ) : "http://";
|
2001-10-05 14:13:58 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
for($i = 0; $i < count($email_set); $i++)
|
|
|
|
{
|
|
|
|
if( $email_set[$i]['user_email'] != "")
|
2001-08-14 00:29:39 +00:00
|
|
|
{
|
2002-01-07 18:50:30 +00:00
|
|
|
$emailer->use_template("topic_notify", $email_set[$i]['user_lang']);
|
2001-09-11 22:52:56 +00:00
|
|
|
$emailer->email_address($email_set[$i]['user_email']);
|
2001-09-06 00:29:07 +00:00
|
|
|
$emailer->set_subject($lang['Topic_reply_notification']);
|
|
|
|
$emailer->extra_headers($email_headers);
|
2001-08-14 00:29:39 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$emailer->assign_vars(array(
|
2001-09-25 18:26:05 +00:00
|
|
|
"EMAIL_SIG" => str_replace("<br />", "\n", "-- \n" . $board_config['board_email_sig']),
|
2001-09-06 00:29:07 +00:00
|
|
|
"USERNAME" => $email_set[$i]['username'],
|
|
|
|
"SITENAME" => $board_config['sitename'],
|
2001-12-19 16:59:44 +00:00
|
|
|
"TOPIC_TITLE" => $topic_title,
|
2001-09-25 18:26:05 +00:00
|
|
|
|
2001-11-18 18:11:42 +00:00
|
|
|
"U_TOPIC" => $protocol . $server_name . $path . "/viewtopic.$phpEx?" . POST_POST_URL . "=$new_post_id#$new_post_id",
|
|
|
|
"U_STOP_WATCHING_TOPIC" => $protocol . $server_name . $path . "/viewtopic.$phpEx?" . POST_TOPIC_URL . "=$new_topic_id&unwatch=topic")
|
2001-09-06 00:29:07 +00:00
|
|
|
);
|
2001-08-14 00:29:39 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$emailer->send();
|
|
|
|
$emailer->reset();
|
2001-08-14 00:29:39 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if($update_watched_sql != "")
|
|
|
|
{
|
|
|
|
$update_watched_sql .= ", ";
|
2001-08-14 00:29:39 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
$update_watched_sql .= $email_set[$i]['user_id'];
|
2001-08-14 00:29:39 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
2001-08-14 00:29:39 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if($update_watched_sql != "")
|
|
|
|
{
|
|
|
|
$sql = "UPDATE " . TOPICS_WATCH_TABLE . "
|
|
|
|
SET notify_status = " . TOPIC_WATCH_NOTIFIED . "
|
|
|
|
WHERE topic_id = $new_topic_id
|
|
|
|
AND user_id IN ($update_watched_sql)";
|
|
|
|
$db->sql_query($sql);
|
2001-08-14 00:29:39 +00:00
|
|
|
}
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
2001-08-14 00:29:39 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Handle notification request ...
|
|
|
|
//
|
2001-09-18 01:24:47 +00:00
|
|
|
if( isset($notify_user) )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
|
|
|
if($mode == "reply")
|
2001-08-14 00:29:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "SELECT *
|
|
|
|
FROM " . TOPICS_WATCH_TABLE . "
|
|
|
|
WHERE topic_id = $new_topic_id
|
|
|
|
AND user_id = " . $userdata['user_id'];
|
|
|
|
if( !$result = $db->sql_query($sql) )
|
2001-08-14 00:29:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain topic watch information", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
2001-08-14 00:29:39 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $db->sql_numrows($result) )
|
|
|
|
{
|
2001-09-18 01:24:47 +00:00
|
|
|
if( !$notify_user )
|
2001-08-14 00:29:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "
|
|
|
|
WHERE topic_id = $new_topic_id
|
|
|
|
AND user_id = " . $userdata['user_id'];
|
2001-08-14 13:37:28 +00:00
|
|
|
if( !$result = $db->sql_query($sql) )
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Couldn't delete topic watch information", "", __LINE__, __FILE__, $sql);
|
2001-08-14 13:37:28 +00:00
|
|
|
}
|
2001-08-14 00:29:39 +00:00
|
|
|
}
|
|
|
|
}
|
2001-09-18 01:24:47 +00:00
|
|
|
else if( $notify_user )
|
2001-08-14 00:29:39 +00:00
|
|
|
{
|
2001-08-30 22:20:23 +00:00
|
|
|
$sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)
|
2001-08-14 00:29:39 +00:00
|
|
|
VALUES (" . $userdata['user_id'] . ", $new_topic_id, 0)";
|
|
|
|
if( !$result = $db->sql_query($sql) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't insert topic watch information", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-09-18 01:24:47 +00:00
|
|
|
else if( $notify_user )
|
2001-08-09 22:21:55 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)
|
|
|
|
VALUES (" . $userdata['user_id'] . ", $new_topic_id, 0)";
|
|
|
|
if( !$result = $db->sql_query($sql) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't insert topic watch information", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
|
|
|
|
|
|
|
|
if( count($tracking_topics) == 150 && empty($tracking_topics['' . $new_topic_id . '']) )
|
|
|
|
{
|
|
|
|
asort($tracking_topics);
|
|
|
|
unset($tracking_topics[key($tracking_topics)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
$tracking_topics['' . $new_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']);
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// If we get here the post has been inserted successfully.
|
|
|
|
//
|
|
|
|
$template->assign_vars(array(
|
2001-10-14 15:49:52 +00:00
|
|
|
"META" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$new_post_id") . '#' . $new_post_id . '">')
|
2001-09-06 00:29:07 +00:00
|
|
|
);
|
|
|
|
|
2001-11-03 16:15:00 +00:00
|
|
|
$message = $lang['Stored'] . "<br /><br />" . sprintf($lang['Click_view_message'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$new_post_id") . "#$new_post_id\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_forum'], "<a href=\"" . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . "\">", "</a>");
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-11-03 16:15:00 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Error updating users table", "", __LINE__, __FILE__, $sql);
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Error updating forums table", "", __LINE__, __FILE__, $sql);
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Error updating topics table", "", __LINE__, __FILE__, $sql);
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
// Rollback
|
|
|
|
if(SQL_LAYER == "mysql")
|
|
|
|
{
|
|
|
|
$sql = "DELETE FROM " . POSTS_TABLE . "
|
|
|
|
WHERE post_id = $new_post_id";
|
|
|
|
$db->sql_query($sql);
|
|
|
|
}
|
|
|
|
message_die(GENERAL_ERROR, "Error inserting data into posts text table", "", __LINE__, __FILE__, $sql);
|
2001-07-06 01:09:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Error inserting data into posts table", "", __LINE__, __FILE__, $sql);
|
2001-07-06 01:09:42 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// End of mode = newtopic || reply
|
|
|
|
//
|
2001-06-11 20:02:01 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
2001-10-10 14:57:52 +00:00
|
|
|
else if( $mode == "editpost" || $mode == "delete" )
|
2001-07-06 01:09:42 +00:00
|
|
|
{
|
2001-08-30 22:20:23 +00:00
|
|
|
$sql = "SELECT poster_id
|
|
|
|
FROM " . POSTS_TABLE . "
|
2001-07-10 22:32:39 +00:00
|
|
|
WHERE post_id = $post_id";
|
|
|
|
if($result = $db->sql_query($sql))
|
2001-07-06 01:09:42 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$row = $db->sql_fetchrow($result);
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-11-23 19:01:51 +00:00
|
|
|
$poster_id = $row['poster_id'];
|
|
|
|
|
|
|
|
if( $userdata['user_id'] != $poster_id && !$is_auth['auth_mod'])
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-10-10 14:57:52 +00:00
|
|
|
$message = ( $delete || $mode == "delete" ) ? $lang['Delete_own_posts'] : $lang['Edit_own_posts'];
|
2001-11-03 16:15:00 +00:00
|
|
|
$message .="<br /><br />" . sprintf($lang['Click_return_topic'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . "\">", "</a>");
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain post information", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
2001-08-30 22:20:23 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// The user has chosen to delete a post or a poll
|
|
|
|
//
|
2001-10-10 14:57:52 +00:00
|
|
|
if( ( $delete || $mode == "delete" ) && ( ( $is_auth['auth_delete'] && !$is_last_post_topic && !$is_auth['auth_mod'] ) ) )
|
|
|
|
{
|
2001-11-03 16:15:00 +00:00
|
|
|
$message = $lang['Cannot_delete_replied'] . "<br /><br />" . sprintf($lang['Click_return_topic'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . "\">", "</a>");
|
|
|
|
|
2001-10-10 14:57:52 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
|
|
|
}
|
|
|
|
else if( ( $delete || $poll_delete || $mode == "delete" ) && ( ( $is_auth['auth_delete'] && $is_last_post_topic ) || $is_auth['auth_mod'] ) )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-08-30 22:20:23 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
// Output a confirmation message if the user
|
|
|
|
// chose to delete this post
|
2001-07-06 01:09:42 +00:00
|
|
|
//
|
2001-10-10 14:57:52 +00:00
|
|
|
if( ( $delete || $poll_delete || $mode == "delete" ) && !$confirm )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$s_hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_TOPIC_URL . '" value="'. $topic_id . '" /><input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />';
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-10-10 14:57:52 +00:00
|
|
|
$s_hidden_fields .= ( $delete || $mode == "delete" ) ? '<input type="hidden" name="delete" value="true" />' : '<input type="hidden" name="poll_delete" value="true" />';
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-10-10 14:57:52 +00:00
|
|
|
$l_confirm = ( ( $delete || $mode == "delete" ) ? $lang['Confirm_delete'] : $lang['Confirm_delete_poll'] );
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-07-11 00:02:24 +00:00
|
|
|
//
|
|
|
|
// Output confirmation page
|
|
|
|
//
|
2001-07-13 16:14:37 +00:00
|
|
|
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
2001-07-11 00:02:24 +00:00
|
|
|
|
|
|
|
$template->set_filenames(array(
|
|
|
|
"confirm_body" => "confirm_body.tpl")
|
|
|
|
);
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"MESSAGE_TITLE" => $lang['Information'],
|
2001-09-06 00:29:07 +00:00
|
|
|
"MESSAGE_TEXT" => $l_confirm,
|
2001-08-30 22:20:23 +00:00
|
|
|
|
|
|
|
"L_YES" => $lang['Yes'],
|
|
|
|
"L_NO" => $lang['No'],
|
2001-07-11 00:02:24 +00:00
|
|
|
|
2001-08-30 22:20:23 +00:00
|
|
|
"S_CONFIRM_ACTION" => append_sid("posting.$phpEx"),
|
2001-07-11 00:02:24 +00:00
|
|
|
"S_HIDDEN_FIELDS" => $s_hidden_fields)
|
|
|
|
);
|
|
|
|
$template->pparse("confirm_body");
|
|
|
|
|
2001-07-13 16:14:37 +00:00
|
|
|
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
2001-07-04 00:34:33 +00:00
|
|
|
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
2001-10-10 14:57:52 +00:00
|
|
|
else if( $confirm && ( $delete || $poll_delete || $mode == "delete" ) )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Delete poll
|
|
|
|
//
|
|
|
|
if( $is_first_post_topic && $post_has_poll && ( $can_edit_poll || $is_auth['auth_mod'] ) )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "DELETE FROM " . VOTE_USERS_TABLE . "
|
|
|
|
WHERE vote_id = " . $rowset[0]['vote_id'];
|
|
|
|
if($db->sql_query($sql, BEGIN_TRANSACTION))
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "DELETE FROM " . VOTE_RESULTS_TABLE . "
|
|
|
|
WHERE vote_id = " . $rowset[0]['vote_id'];
|
2001-07-10 22:32:39 +00:00
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "DELETE FROM " . VOTE_DESC_TABLE . "
|
|
|
|
WHERE vote_id = " . $rowset[0]['vote_id'];
|
|
|
|
if($db->sql_query($sql, END_TRANSACTION))
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// If we're just deleting the poll then show results
|
|
|
|
// and jump back to topic
|
|
|
|
//
|
|
|
|
if( $poll_delete )
|
|
|
|
{
|
|
|
|
$sql = "UPDATE " . TOPICS_TABLE . "
|
|
|
|
SET topic_vote = 0
|
|
|
|
WHERE topic_id = $topic_id";
|
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$template->assign_vars(array(
|
2001-10-14 15:49:52 +00:00
|
|
|
"META" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">')
|
2001-09-06 00:29:07 +00:00
|
|
|
);
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-11-03 16:15:00 +00:00
|
|
|
$message = $lang['Poll_delete'] . "<br /><br />" . sprintf($lang['Click_return_topic'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . "\">", "</a>");
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-11-03 16:15:00 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't update topics vote information", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
2001-11-15 22:09:20 +00:00
|
|
|
else if( !$is_last_post_topic )
|
|
|
|
{
|
|
|
|
$sql = "UPDATE " . TOPICS_TABLE . "
|
|
|
|
SET topic_vote = 0
|
|
|
|
WHERE topic_id = $topic_id";
|
|
|
|
if( !$result = $db->sql_query($sql) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't update topic poll field", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't delete from vote descriptions table", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Couldn't delete from vote results table", "", __LINE__, __FILE__, $sql);
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
else
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Couldn't delete from vote users table", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
2001-10-10 14:57:52 +00:00
|
|
|
else if( $post_has_poll && !$can_edit_poll && $poll_delete )
|
|
|
|
{
|
2001-11-03 16:15:00 +00:00
|
|
|
$message = $lang['Cannot_delete_poll'] . "<br /><br />" . sprintf($lang['Click_return_topic'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . "\">", "</a>");
|
|
|
|
|
2001-10-10 14:57:52 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
|
|
|
}
|
|
|
|
else if( !$is_first_post_topic && $poll_delete )
|
|
|
|
{
|
2001-11-03 16:15:00 +00:00
|
|
|
$message = $lang['Post_has_no_poll'] . "<br /><br />" . sprintf($lang['Click_return_topic'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . "\">", "</a>");
|
|
|
|
|
2001-10-10 14:57:52 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-10-10 14:57:52 +00:00
|
|
|
if( $delete || $mode == "delete" )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
2001-11-23 19:01:51 +00:00
|
|
|
$sql = "UPDATE " . USERS_TABLE . "
|
|
|
|
SET user_posts = user_posts - 1
|
|
|
|
WHERE user_id = " . $poster_id;
|
|
|
|
if( !$db->sql_query($sql, BEGIN_TRANSACTION) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_MESSAGE, "Couldn't update users post count", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
2001-11-23 01:04:31 +00:00
|
|
|
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
|
|
|
|
WHERE post_id = $post_id";
|
2001-11-23 19:01:51 +00:00
|
|
|
$result = $db->sql_query($sql);
|
2001-11-23 01:04:31 +00:00
|
|
|
if( !$result )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't delete word match entry for this post", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
2001-11-23 19:01:51 +00:00
|
|
|
//
|
|
|
|
// Removes redundant words from wordlist table
|
|
|
|
//
|
2001-11-23 01:04:31 +00:00
|
|
|
remove_unmatched_words();
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-11-23 01:04:31 +00:00
|
|
|
$sql = "DELETE FROM " . POSTS_TEXT_TABLE . "
|
2001-09-06 00:29:07 +00:00
|
|
|
WHERE post_id = $post_id";
|
2001-11-23 01:04:31 +00:00
|
|
|
if( $db->sql_query($sql) )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
2001-11-23 01:04:31 +00:00
|
|
|
$sql = "DELETE FROM " . POSTS_TABLE . "
|
2001-09-06 00:29:07 +00:00
|
|
|
WHERE post_id = $post_id";
|
2001-07-10 22:32:39 +00:00
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $is_last_post_topic && $is_first_post_topic )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Delete the topic completely, updating the forum_last_post_id
|
2001-09-18 01:24:47 +00:00
|
|
|
// if necessary and removing any users currently watching this topic
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
if( $db->sql_query($sql) )
|
|
|
|
{
|
2001-11-23 01:04:31 +00:00
|
|
|
$sql = "DELETE FROM " . TOPICS_TABLE . "
|
2001-09-06 00:29:07 +00:00
|
|
|
WHERE topic_id = $topic_id";
|
2001-09-18 01:24:47 +00:00
|
|
|
if( $db->sql_query($sql) )
|
|
|
|
{
|
|
|
|
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "
|
|
|
|
WHERE topic_id = $topic_id";
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-09-18 01:24:47 +00:00
|
|
|
$sql_forum_upd = "forum_posts = forum_posts - 1, forum_topics = forum_topics - 1";
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-09-18 01:24:47 +00:00
|
|
|
$if_die_msg = "Error deleting from topics watch table";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Error deleting from topics table", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
else
|
2001-08-09 22:21:55 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Error deleting from post table", "", __LINE__, __FILE__, $sql);
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
else if( $is_last_post_topic )
|
2001-08-09 22:21:55 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Delete the post and update the _last_post_id's of both
|
|
|
|
// the topic and forum if necessary
|
|
|
|
//
|
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$sql = "SELECT MAX(post_id) AS new_last_post_id
|
|
|
|
FROM " . POSTS_TABLE . "
|
|
|
|
WHERE topic_id = $topic_id";
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if($result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$row = $db->sql_fetchrow($result);
|
2001-08-30 22:20:23 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "UPDATE " . TOPICS_TABLE . "
|
|
|
|
SET topic_replies = topic_replies - 1, topic_last_post_id = " . $row['new_last_post_id'] . "
|
|
|
|
WHERE topic_id = $topic_id";
|
2001-08-30 22:20:23 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql_forum_upd = "forum_posts = forum_posts - 1";
|
|
|
|
|
|
|
|
$if_die_msg = "Error updating topics table";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Error obtaining new last topic id", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Error deleting from post table", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
else if( $is_auth['auth_mod'] )
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// It's not last and it's not both first and last so it's somewhere in
|
|
|
|
// the middle(!) Only moderators can delete these posts, all we need do
|
|
|
|
// is update the forums table data as necessary
|
|
|
|
//
|
|
|
|
$sql = "UPDATE " . TOPICS_TABLE . "
|
|
|
|
SET topic_replies = topic_replies - 1
|
|
|
|
WHERE topic_id = $topic_id";
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql_forum_upd = "forum_posts = forum_posts - 1";
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$if_die_msg = "Couldn't delete from posts table";
|
|
|
|
}
|
2001-07-10 22:32:39 +00:00
|
|
|
|
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
// Updating the forum is common to all three possibilities,
|
|
|
|
// _remember_ we're still in a transaction here!
|
2001-07-10 22:32:39 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $db->sql_query($sql) )
|
|
|
|
{
|
|
|
|
if( $is_last_post_forum )
|
|
|
|
{
|
|
|
|
$sql = "SELECT MAX(post_id) AS new_post_id
|
|
|
|
FROM " . POSTS_TABLE . "
|
|
|
|
WHERE forum_id = $forum_id";
|
|
|
|
|
|
|
|
if($result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain new last post id for the forum", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
2001-10-10 10:45:54 +00:00
|
|
|
$last_post_id_forum = ( !empty($row['new_post_id']) ) ? $row['new_post_id'] : 0;
|
|
|
|
|
|
|
|
$new_last_sql = ", forum_last_post_id = " . $last_post_id_forum;
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$new_last_sql = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql = "UPDATE " . FORUMS_TABLE . "
|
|
|
|
SET " . $sql_forum_upd . $new_last_sql . "
|
|
|
|
WHERE forum_id = $forum_id";
|
|
|
|
|
|
|
|
if($db->sql_query($sql, END_TRANSACTION))
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// If we get here the post has been deleted successfully.
|
|
|
|
//
|
2001-11-05 02:40:41 +00:00
|
|
|
$message = $lang['Deleted'];
|
2001-08-30 22:20:23 +00:00
|
|
|
|
2001-11-09 13:15:36 +00:00
|
|
|
if( !$is_first_post_topic || !$is_last_post_topic )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
|
|
|
$template->assign_vars(array(
|
2001-10-14 15:49:52 +00:00
|
|
|
"META" => '<meta http-equiv="refresh" content="3;url= ' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">')
|
2001-09-06 00:29:07 +00:00
|
|
|
);
|
|
|
|
|
2001-11-03 16:15:00 +00:00
|
|
|
$message .= "<br /><br />" . sprintf($lang['Click_return_topic'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . "\">", "</a>");
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$template->assign_vars(array(
|
2001-10-14 15:49:52 +00:00
|
|
|
"META" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">')
|
2001-09-06 00:29:07 +00:00
|
|
|
);
|
|
|
|
}
|
2001-11-03 16:15:00 +00:00
|
|
|
$message .= "<br /><br />" . sprintf($lang['Click_return_forum'], "<a href=\"" . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . "\">", "</a>");
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-11-03 16:15:00 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Error updating forums table", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2001-07-10 22:32:39 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, $if_die_msg, "", __LINE__, __FILE__, $sql);
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Error deleting from posts table", "", __LINE__, __FILE__, $sql);
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Error deleting from posts text table", "", __LINE__, __FILE__, $sql);
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-10-14 18:22:32 +00:00
|
|
|
header("Location: " . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
|
2001-07-10 22:32:39 +00:00
|
|
|
}
|
2001-07-06 01:09:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
if( !$is_last_post_topic && ( !$is_auth['auth_mod'] || $row['poster_id'] == $userdata['user_id'] ) )
|
2001-07-15 15:45:09 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$edited_sql = ", post_edit_time = $current_time, post_edit_count = post_edit_count + 1 ";
|
2001-07-15 15:45:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$edited_sql = "";
|
|
|
|
}
|
2001-08-09 22:21:55 +00:00
|
|
|
|
2001-09-18 01:24:47 +00:00
|
|
|
//
|
|
|
|
// Handle changing user notification
|
|
|
|
//
|
|
|
|
if( isset($notify_user) )
|
|
|
|
{
|
|
|
|
$sql = "SELECT *
|
|
|
|
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, "Couldn't obtain topic watch information", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $db->sql_numrows($result) )
|
|
|
|
{
|
|
|
|
if( !$notify_user )
|
|
|
|
{
|
|
|
|
$sql = "DELETE 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, "Couldn't delete topic watch information", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( $notify_user )
|
|
|
|
{
|
|
|
|
$sql = "INSERT 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, "Couldn't insert topic watch information", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-23 19:01:51 +00:00
|
|
|
//
|
|
|
|
// Clear out the old matches
|
|
|
|
//
|
2001-11-23 01:04:31 +00:00
|
|
|
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
|
|
|
|
WHERE post_id = $post_id";
|
|
|
|
$result = $db->sql_query($sql, BEGIN_TRANSACTION);
|
|
|
|
if( !$result )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't delete word match entry for this post", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
2001-11-09 13:15:36 +00:00
|
|
|
|
2001-08-30 22:20:23 +00:00
|
|
|
$sql = "UPDATE " . POSTS_TABLE . "
|
2001-11-24 17:17:32 +00:00
|
|
|
SET enable_bbcode = $bbcode_on, enable_html = $html_on, enable_smilies = $smilies_on, enable_sig = $attach_sig" . $edited_sql . "
|
2001-07-06 01:09:42 +00:00
|
|
|
WHERE post_id = $post_id";
|
2001-11-23 01:04:31 +00:00
|
|
|
if($db->sql_query($sql))
|
2001-07-06 01:09:42 +00:00
|
|
|
{
|
2001-08-30 22:20:23 +00:00
|
|
|
$sql = "UPDATE " . POSTS_TEXT_TABLE . "
|
2001-12-21 15:51:31 +00:00
|
|
|
SET post_text = '" . str_replace("\'", "''", $post_message) . "', bbcode_uid = '$bbcode_uid', post_subject = '" . str_replace("\'", "''", $post_subject) . "'
|
2001-11-23 19:01:51 +00:00
|
|
|
WHERE post_id = $post_id";
|
2001-07-06 01:09:42 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $is_first_post_topic )
|
2001-07-06 01:09:42 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $db->sql_query($sql) )
|
2001-07-04 00:34:33 +00:00
|
|
|
{
|
2002-01-12 17:00:32 +00:00
|
|
|
add_search_words($post_id, stripslashes($post_message), stripslashes($post_subject));
|
2001-11-23 01:04:31 +00:00
|
|
|
remove_unmatched_words();
|
2001-11-09 13:15:36 +00:00
|
|
|
|
2001-07-06 01:09:42 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
// Update topics table here
|
2001-07-06 01:09:42 +00:00
|
|
|
//
|
2001-08-30 22:20:23 +00:00
|
|
|
$sql = "UPDATE " . TOPICS_TABLE . "
|
2001-12-21 15:51:31 +00:00
|
|
|
SET topic_title = '" . str_replace("\'", "''", $post_subject) . "', topic_type = $topic_type" . $sql_topic_vote_edit . "
|
2001-07-10 22:32:39 +00:00
|
|
|
WHERE topic_id = $topic_id";
|
2001-07-04 00:34:33 +00:00
|
|
|
if($db->sql_query($sql, END_TRANSACTION))
|
2001-06-11 20:02:01 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Update of voting required?
|
|
|
|
//
|
|
|
|
if( $is_auth['auth_pollcreate'] && $topic_vote )
|
|
|
|
{
|
|
|
|
if( $post_has_poll && ( $can_edit_poll || $is_auth['auth_mod'] ) )
|
|
|
|
{
|
|
|
|
$sql = "SELECT vote_option_id, vote_result
|
|
|
|
FROM " . VOTE_RESULTS_TABLE . "
|
|
|
|
WHERE vote_id = $vote_id
|
|
|
|
ORDER BY vote_option_id ASC";
|
|
|
|
if( !$result = $db->sql_query($sql) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain vote data results for this topic", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $db->sql_numrows($result) )
|
|
|
|
{
|
|
|
|
$old_poll_result = array();
|
|
|
|
while( $row = $db->sql_fetchrow($result) )
|
|
|
|
{
|
|
|
|
$old_poll_result[$row['vote_option_id']] = $row['vote_result'];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Previous entry with no results (or a moderator), update
|
|
|
|
//
|
|
|
|
$sql = "UPDATE " . VOTE_DESC_TABLE . "
|
2001-12-21 15:51:31 +00:00
|
|
|
SET vote_text = '" . str_replace("\'", "''", $poll_title) . "', vote_length = " . ( $poll_length * 86400 ) . "
|
2001-09-06 00:29:07 +00:00
|
|
|
WHERE topic_id = $topic_id";
|
|
|
|
if( $result = $db->sql_query($sql, BEGIN_TRANSACTION) )
|
|
|
|
{
|
|
|
|
$sql = "DELETE FROM " . VOTE_RESULTS_TABLE . "
|
|
|
|
WHERE vote_id = $vote_id";
|
|
|
|
if( $result = $db->sql_query($sql) )
|
|
|
|
{
|
|
|
|
$poll_option_id = 1;
|
|
|
|
while( list($option_id, $option_text) = each($poll_option_list) )
|
|
|
|
{
|
|
|
|
$vote_result = ( $old_poll_result[$option_id] ) ? $old_poll_result[$option_id] : 0;
|
|
|
|
|
|
|
|
$sql = "INSERT INTO " . VOTE_RESULTS_TABLE . " (vote_id, vote_option_id, vote_option_text, vote_result)
|
2001-12-21 15:51:31 +00:00
|
|
|
VALUES ($vote_id, $poll_option_id, '" . str_replace("\'", "''", $option_text) . "', $vote_result)";
|
2001-09-07 16:59:44 +00:00
|
|
|
if( !$result = $db->sql_query($sql) )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't insert new poll options", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
$poll_option_id++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't delete existing options", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Failed to obtain row set for this poll", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// No previous entry, create new
|
|
|
|
//
|
|
|
|
$sql = "INSERT INTO " . VOTE_DESC_TABLE . " (topic_id, vote_text, vote_start, vote_length)
|
2001-12-21 15:51:31 +00:00
|
|
|
VALUES ($topic_id, '" . str_replace("\'", "''", $poll_title) . "', $current_time, " . ( $poll_length * 86400 ) . ")";
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $result = $db->sql_query($sql, BEGIN_TRANSACTION) )
|
|
|
|
{
|
|
|
|
$new_vote_id = $db->sql_nextid();
|
|
|
|
|
|
|
|
$poll_option_id = 1;
|
|
|
|
while( list($option_id, $option_text) = each($poll_option_list) )
|
|
|
|
{
|
|
|
|
$sql = "INSERT INTO " . VOTE_RESULTS_TABLE . " (vote_id, vote_option_id, vote_option_text, vote_result)
|
2001-12-21 15:51:31 +00:00
|
|
|
VALUES ($new_vote_id, $poll_option_id, '" . str_replace("\'", "''", $option_text) . "', 0)";
|
2001-09-07 16:59:44 +00:00
|
|
|
if( !$result = $db->sql_query($sql) )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
|
|
|
// Rollback ...
|
|
|
|
if(SQL_LAYER == "mysql")
|
|
|
|
{
|
|
|
|
$sql_del_v = "DELETE FROM " . VOTE_DESC_TABLE . "
|
|
|
|
WHERE vote_id = $new_vote_id";
|
|
|
|
$db->sql_query($sql_del_v);
|
|
|
|
}
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't insert new poll options", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
$poll_option_id++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-12 13:34:27 +00:00
|
|
|
//
|
2001-06-11 20:02:01 +00:00
|
|
|
// If we get here the post has been inserted successfully.
|
2001-06-12 13:34:27 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
$template->assign_vars(array(
|
2001-10-14 15:49:52 +00:00
|
|
|
"META" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id") . '#' . $post_id . '">')
|
2001-09-06 00:29:07 +00:00
|
|
|
);
|
2001-06-12 13:34:27 +00:00
|
|
|
|
2001-11-03 16:15:00 +00:00
|
|
|
$message = $lang['Stored'] . "<br /><br />" . sprintf($lang['Click_view_message'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id") . "#$post_id\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_topic'], "<a href=\"" . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . "\">", "</a>");
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-11-03 16:15:00 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
2001-06-11 20:02:01 +00:00
|
|
|
}
|
2001-07-04 00:34:33 +00:00
|
|
|
else
|
2001-06-11 20:02:01 +00:00
|
|
|
{
|
2001-07-06 01:09:42 +00:00
|
|
|
message_die(GENERAL_ERROR, "Updating topics table", "", __LINE__, __FILE__, $sql);
|
2001-06-11 20:02:01 +00:00
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-01-12 17:00:32 +00:00
|
|
|
add_search_words($post_id, stripslashes($post_message), stripslashes($post_subject));
|
2001-11-23 01:04:31 +00:00
|
|
|
remove_unmatched_words();
|
2001-11-09 13:15:36 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $db->sql_query($sql, END_TRANSACTION) )
|
2001-07-06 01:09:42 +00:00
|
|
|
{
|
|
|
|
//
|
|
|
|
// If we get here the post has been inserted successfully.
|
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
$template->assign_vars(array(
|
2001-10-14 15:49:52 +00:00
|
|
|
"META" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id") . '#' . $post_id . '">')
|
2001-09-06 00:29:07 +00:00
|
|
|
);
|
2001-07-10 22:32:39 +00:00
|
|
|
|
2001-12-28 16:25:31 +00:00
|
|
|
$message = $lang['Stored'] . "<br /><br />" . sprintf($lang['Click_view_message'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id") . "#$post_id\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_forum'], "<a href=\"" . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . "\">", "</a>");
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-11-03 16:15:00 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
2001-07-06 01:09:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
message_die(GENERAL_ERROR, "Error updating posts text table", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Error updating posts text table", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// End of mode = editpost
|
|
|
|
//
|
|
|
|
}
|
|
|
|
else if( $mode == "vote" )
|
|
|
|
{
|
|
|
|
|
|
|
|
if( !empty($HTTP_POST_VARS['vote_id']) )
|
|
|
|
{
|
|
|
|
$vote_option_id = $HTTP_POST_VARS['vote_id'];
|
|
|
|
|
|
|
|
$sql = "SELECT vd.vote_id, MAX(vr.vote_option_id) AS max_vote_option
|
|
|
|
FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
|
|
|
|
WHERE vd.topic_id = $topic_id
|
|
|
|
AND vr.vote_id = vd.vote_id
|
|
|
|
GROUP BY vd.vote_id";
|
|
|
|
if( !$result = $db->sql_query($sql) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain vote data for this topic", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $vote_options = $db->sql_numrows($result) )
|
|
|
|
{
|
|
|
|
$vote_info = $db->sql_fetchrow($result);
|
|
|
|
|
|
|
|
if( $vote_info['max_vote_option'] < $vote_option_id )
|
|
|
|
{
|
|
|
|
$template->assign_vars(array(
|
2001-10-14 15:49:52 +00:00
|
|
|
"META" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "= $topic_id") . '">')
|
2001-09-06 00:29:07 +00:00
|
|
|
);
|
|
|
|
|
2001-11-03 16:15:00 +00:00
|
|
|
$message = $lang['No_vote_option'] . "<br /><br />" . sprintf($lang['Click_view_message'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . "\">", "</a>");
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
|
|
|
}
|
|
|
|
|
|
|
|
$vote_id = $vote_info['vote_id'];
|
|
|
|
|
|
|
|
$sql = "SELECT *
|
|
|
|
FROM " . VOTE_USERS_TABLE . "
|
|
|
|
WHERE vote_id = $vote_id
|
|
|
|
AND vote_user_id = " . $userdata['user_id'];
|
|
|
|
if( !$result = $db->sql_query($sql) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain user vote data for this topic", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
$user_voted = ( $db->sql_numrows($result) ) ? TRUE : 0;
|
|
|
|
|
|
|
|
if( !$user_voted )
|
|
|
|
{
|
|
|
|
$sql = "UPDATE " . VOTE_RESULTS_TABLE . "
|
|
|
|
SET vote_result = vote_result + 1
|
|
|
|
WHERE vote_id = $vote_id
|
|
|
|
AND vote_option_id = $vote_option_id";
|
|
|
|
if( $db->sql_query($sql, BEGIN_TRANSACTION) )
|
|
|
|
{
|
|
|
|
$sql = "INSERT INTO " . VOTE_USERS_TABLE . " (vote_id, vote_user_id, vote_user_ip)
|
|
|
|
VALUES ($vote_id, " . $userdata['user_id'] . ", '$user_ip')";
|
|
|
|
if( $db->sql_query($sql, END_TRANSACTION) )
|
2001-08-09 22:21:55 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
$template->assign_vars(array(
|
2001-10-14 15:49:52 +00:00
|
|
|
"META" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">')
|
2001-09-06 00:29:07 +00:00
|
|
|
);
|
|
|
|
|
2001-11-03 16:15:00 +00:00
|
|
|
$message = $lang['Vote_cast'] . "<br /><br />" . sprintf($lang['Click_view_message'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . "\">", "</a>");
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if(SQL_LAYER == "mysql")
|
|
|
|
{
|
|
|
|
$sql_rewind = "UPDATE " . VOTE_RESULTS_TABLE . "
|
|
|
|
SET vote_option_result = vote_option_result - 1
|
|
|
|
WHERE vote_id = $vote_id
|
|
|
|
AND vote_option_id = $vote_option_id";
|
|
|
|
$db->sql_query($sql_rewind);
|
|
|
|
}
|
|
|
|
|
|
|
|
message_die(GENERAL_ERROR, "Error updating vote users table", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Error updating vote results table", "", __LINE__, __FILE__, $sql);
|
2001-07-06 01:09:42 +00:00
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$template->assign_vars(array(
|
2001-10-14 15:49:52 +00:00
|
|
|
"META" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">')
|
2001-09-06 00:29:07 +00:00
|
|
|
);
|
|
|
|
|
2001-11-03 16:15:00 +00:00
|
|
|
$message = $lang['Already_voted'] . "<br /><br />" . sprintf($lang['Click_view_message'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . "\">", "</a>");
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-03 16:15:00 +00:00
|
|
|
$message = $lang['No_vote_option'] . "<br /><br />" . sprintf($lang['Click_view_message'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . "\">", "</a>");
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
message_die(GENERAL_MESSAGE, $message);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// End of mode = vote
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( $preview || $refresh || $error )
|
|
|
|
{
|
|
|
|
|
|
|
|
//
|
|
|
|
// If we're previewing or refreshing then obtain the data
|
|
|
|
// passed to the script, process it a little, do some checks
|
|
|
|
// where neccessary, etc.
|
|
|
|
//
|
|
|
|
$post_username = ( isset($HTTP_POST_VARS['username']) ) ? trim(strip_tags(stripslashes($HTTP_POST_VARS['username']))) : "";
|
|
|
|
$post_subject = ( isset($HTTP_POST_VARS['subject']) ) ? trim(strip_tags(stripslashes($HTTP_POST_VARS['subject']))) : "";
|
2001-11-26 14:07:33 +00:00
|
|
|
$post_message = ( isset($HTTP_POST_VARS['message']) ) ? trim($HTTP_POST_VARS['message']) : "";
|
2001-09-06 00:29:07 +00:00
|
|
|
$post_message = preg_replace('#<textarea>#si', '<textarea>', $post_message);
|
|
|
|
|
|
|
|
$poll_title = ( isset($HTTP_POST_VARS['poll_title']) ) ? trim(strip_tags(stripslashes($HTTP_POST_VARS['poll_title']))) : "";
|
|
|
|
$poll_length = ( isset($HTTP_POST_VARS['poll_length']) ) ? intval($HTTP_POST_VARS['poll_length']) : 0;
|
|
|
|
|
|
|
|
$poll_options = 0;
|
|
|
|
$poll_option_list = array();
|
2001-12-03 12:21:53 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( isset($HTTP_POST_VARS['del_poll_option']) )
|
|
|
|
{
|
|
|
|
if( isset($HTTP_POST_VARS['poll_option_text']) )
|
|
|
|
{
|
|
|
|
while( list($option_id, $option_text) = each($HTTP_POST_VARS['poll_option_text']) )
|
|
|
|
{
|
|
|
|
if( !isset($HTTP_POST_VARS['del_poll_option'][$option_id]) )
|
|
|
|
{
|
|
|
|
$poll_option_list[$option_id] = trim(strip_tags(stripslashes($option_text)));
|
|
|
|
$poll_options++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( isset($HTTP_POST_VARS['poll_option_text']) )
|
|
|
|
{
|
|
|
|
@reset($HTTP_POST_VARS['poll_option_text']);
|
|
|
|
while( list($option_id, $option_text) = each($HTTP_POST_VARS['poll_option_text']) )
|
|
|
|
{
|
2001-09-07 00:23:40 +00:00
|
|
|
$poll_option_list[$option_id] = trim(strip_tags(preg_replace($html_entities_match, $html_entities_replace, stripslashes($option_text))));
|
2001-09-06 00:29:07 +00:00
|
|
|
$poll_options++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( isset($HTTP_POST_VARS['add_poll_option']) )
|
|
|
|
{
|
|
|
|
if( $poll_options < $board_config['max_poll_options'] )
|
|
|
|
{
|
|
|
|
$new_poll_option = trim(strip_tags(stripslashes($HTTP_POST_VARS['add_poll_option_text'])));
|
|
|
|
|
|
|
|
if($new_poll_option != "")
|
|
|
|
{
|
|
|
|
$poll_option_list[] = $new_poll_option;
|
|
|
|
}
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
2001-07-06 01:09:42 +00:00
|
|
|
else
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$error = TRUE;
|
|
|
|
if(!empty($error_msg))
|
2001-08-09 22:21:55 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$error_msg .= "<br />";
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
$error_msg .= $lang['To_many_poll_options'];
|
2001-07-06 01:09:42 +00:00
|
|
|
}
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
2001-07-06 01:09:42 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Do mode specific things
|
|
|
|
//
|
|
|
|
if( $mode == "newtopic" )
|
|
|
|
{
|
|
|
|
|
|
|
|
$page_title = $lang['Post_a_new_topic'];
|
|
|
|
$display_poll = ( $is_auth['auth_pollcreate'] ) ? TRUE : 0;
|
|
|
|
|
|
|
|
$user_sig = ( $userdata['user_sig'] != "" ) ? $userdata['user_sig'] : "";
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( $mode == "reply" )
|
|
|
|
{
|
|
|
|
|
|
|
|
$page_title = $lang['Post_a_reply'];
|
|
|
|
$display_poll = 0;
|
|
|
|
|
|
|
|
$user_sig = ( $userdata['user_sig'] != "" ) ? $userdata['user_sig'] : "";
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( $mode == "editpost" )
|
|
|
|
{
|
|
|
|
$page_title = $lang['Edit_Post'];
|
|
|
|
|
|
|
|
$sql = "SELECT u.user_id, u.user_sig
|
|
|
|
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
|
|
|
|
WHERE p.post_id = $post_id
|
|
|
|
AND u.user_id = p.poster_id";
|
|
|
|
if($result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$postrow = $db->sql_fetchrow($result);
|
|
|
|
|
|
|
|
if($userdata['user_id'] != $postrow['user_id'] && !$is_auth['auth_mod'])
|
|
|
|
{
|
|
|
|
message_die(GENERAL_MESSAGE, $lang['Sorry_edit_own_posts']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$user_sig = ( $postrow['user_sig'] != "" ) ? $postrow['user_sig'] : "";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain post and post text", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $is_auth['auth_pollcreate'] && $is_first_post_topic )
|
|
|
|
{
|
|
|
|
$display_poll = ( !$post_has_poll || ( $post_has_poll && ( $is_auth['auth_mod'] || $can_edit_poll ) ) ) ? TRUE : 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$display_poll = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// This is the entry point for posting, some basic variables
|
|
|
|
// are set, for editpost/quote the original message is obtained
|
|
|
|
// and for editpost a check is done to ensure the user isn't
|
|
|
|
// trying to edit someone elses post ( additional checks on polling
|
|
|
|
// capability are also carried out )
|
|
|
|
//
|
|
|
|
|
|
|
|
if( $mode == "newtopic" )
|
2001-07-11 00:02:24 +00:00
|
|
|
{
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$page_title = $lang['Post_a_new_topic'];
|
|
|
|
|
|
|
|
$display_poll = ( $is_auth['auth_pollcreate'] ) ? TRUE : 0;
|
|
|
|
$poll_title = "";
|
|
|
|
$poll_length = 0;
|
|
|
|
|
|
|
|
$user_sig = ( $userdata['user_sig'] != "" ) ? $userdata['user_sig'] : "";
|
|
|
|
|
|
|
|
$post_username = ($userdata['session_logged_in']) ? $userdata['username'] : "";
|
|
|
|
$post_subject = "";
|
|
|
|
$post_message = "";
|
2001-07-11 00:02:24 +00:00
|
|
|
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
else if( $mode == "reply" )
|
|
|
|
{
|
|
|
|
|
|
|
|
$page_title = $lang['Post_a_reply'];
|
|
|
|
|
|
|
|
$display_poll = 0;
|
|
|
|
$poll_title = "";
|
|
|
|
$poll_length = 0;
|
|
|
|
|
|
|
|
$user_sig = ( $userdata['user_sig'] != "" ) ? $userdata['user_sig'] : "";
|
|
|
|
|
|
|
|
$post_username = ($userdata['session_logged_in']) ? $userdata['username'] : "";
|
|
|
|
$post_subject = "";
|
|
|
|
$post_message = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( $mode == "editpost" || $mode == "quote" && ( !$preview && !$refresh ) )
|
2001-07-06 01:09:42 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-11-24 17:17:32 +00:00
|
|
|
$sql = "SELECT p.*, pt.post_text, pt.post_subject, pt.bbcode_uid, u.username, u.user_id, u.user_sig, t.topic_title, t.topic_type, t.topic_vote
|
2001-09-06 00:29:07 +00:00
|
|
|
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . TOPICS_TABLE . " t, " . POSTS_TEXT_TABLE . " pt
|
|
|
|
WHERE p.post_id = $post_id
|
|
|
|
AND pt.post_id = p.post_id
|
|
|
|
AND p.topic_id = t.topic_id
|
|
|
|
AND p.poster_id = u.user_id";
|
|
|
|
if($result = $db->sql_query($sql))
|
2001-07-06 01:09:42 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$postrow = $db->sql_fetchrow($result);
|
2001-07-06 01:09:42 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $mode == "editpost" )
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-07-06 01:09:42 +00:00
|
|
|
if($userdata['user_id'] != $postrow['user_id'] && !$is_auth['auth_mod'])
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-07-06 01:09:42 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $lang['Sorry_edit_own_posts']);
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
2001-06-04 00:14:26 +00:00
|
|
|
|
2001-09-18 01:24:47 +00:00
|
|
|
$post_user_id = $postrow['user_id'];
|
2001-12-04 22:02:30 +00:00
|
|
|
$post_username = ( $post_user_id == ANONYMOUS && $postrow['post_username'] != "" ) ? $postrow['post_username'] : $postrow['username'];
|
2001-09-06 00:29:07 +00:00
|
|
|
$post_subject = $postrow['post_subject'];
|
|
|
|
$post_message = $postrow['post_text'];
|
2001-10-24 22:52:24 +00:00
|
|
|
$post_bbcode_uid = $postrow['bbcode_uid'];
|
2001-12-11 08:55:17 +00:00
|
|
|
$post_bbcode_enabled = ($postrow['enable_bbcode'] == 1);
|
2001-08-10 23:13:41 +00:00
|
|
|
|
2001-09-07 00:23:40 +00:00
|
|
|
if( $mode == "editpost" )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
2001-09-07 00:23:40 +00:00
|
|
|
$attach_sig = ( $postrow['enable_sig'] && $postrow['user_sig'] != "" ) ? TRUE : 0;
|
|
|
|
$user_sig = $postrow['user_sig'];
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
2001-09-07 00:23:40 +00:00
|
|
|
else
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
2001-09-07 00:23:40 +00:00
|
|
|
$attach_sig = ( $userdata['user_attachsig'] ) ? TRUE : 0;
|
|
|
|
$user_sig = $userdata['user_sig'];
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-11 08:55:17 +00:00
|
|
|
if ($post_bbcode_enabled)
|
|
|
|
{
|
|
|
|
$post_message = preg_replace("/\:(([a-z0-9]:)?)$post_bbcode_uid/si", "", $post_message);
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
$post_message = str_replace("<br />", "\n", $post_message);
|
|
|
|
$post_message = preg_replace('#</textarea>#si', '</textarea>', $post_message);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Finish off edit/quote grab by doing specific
|
|
|
|
// things for each mode
|
|
|
|
//
|
|
|
|
if( $mode == "quote" )
|
|
|
|
{
|
|
|
|
$page_title = $lang['Post_a_reply'];
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-09-08 18:24:34 +00:00
|
|
|
$msg_date = create_date($board_config['default_dateformat'], $postrow['post_time'], $board_config['board_timezone']);
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-11-25 23:31:04 +00:00
|
|
|
$post_message = "[quote=\"" . $post_username . "\"]\n" . $post_message . "\n[/quote]";
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
$mode = "reply";
|
|
|
|
}
|
|
|
|
else if( $mode == "editpost" )
|
|
|
|
{
|
|
|
|
$page_title = $lang['Edit_Post'];
|
2001-06-16 14:29:49 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$html_on = ( $postrow['enable_html'] && $board_config['allow_html'] ) ? TRUE : 0;
|
|
|
|
$bbcode_on = ( $postrow['enable_bbcode'] && $board_config['allow_bbcode'] ) ? TRUE : 0;
|
|
|
|
$smilies_on = ( $postrow['enable_smilies'] && $board_config['allow_smilies'] ) ? TRUE : 0;
|
2001-08-30 22:20:23 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $is_first_post_topic )
|
|
|
|
{
|
|
|
|
$post_subject = $postrow['topic_title'];
|
|
|
|
$topic_type = $postrow['topic_type'];
|
2001-06-16 14:29:49 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $is_auth['auth_pollcreate'] && ( $can_edit_poll || $is_auth['auth_mod'] ) )
|
2001-07-06 01:09:42 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sql = "SELECT vd.vote_text, vd.vote_length, vr.vote_option_id, vr.vote_option_text
|
|
|
|
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, "Couldn't obtain vote data for this topic", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$vote_results_sum = 0;
|
2001-09-07 00:23:40 +00:00
|
|
|
if( $row = $db->sql_fetchrow($result) )
|
2001-08-10 23:13:41 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$poll_title = $row['vote_text'];
|
|
|
|
$poll_length = $row['vote_length'];
|
2001-07-15 15:45:09 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$poll_option_list[$row['vote_option_id']] = $row['vote_option_text'];
|
2001-09-07 00:23:40 +00:00
|
|
|
while( $row = $db->sql_fetchrow($result) )
|
|
|
|
{
|
|
|
|
$poll_option_list[$row['vote_option_id']] = $row['vote_option_text'];
|
|
|
|
}
|
2001-08-10 23:13:41 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
$poll_length = $poll_length / 86400;
|
|
|
|
|
|
|
|
$display_poll = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$display_poll = ( $is_auth['auth_pollcreate'] && !$post_has_poll ) ? TRUE : 0;
|
|
|
|
$poll_length = 0;
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
2001-06-16 14:29:49 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$display_poll = 0;
|
|
|
|
}
|
2001-07-06 01:09:42 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain post and post text", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
}
|
2001-07-06 01:09:42 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
// Major posting code complete
|
|
|
|
// ---------------------------
|
2001-05-26 00:25:50 +00:00
|
|
|
|
2001-06-11 00:58:08 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
// --------------------
|
|
|
|
// Generate page output
|
2001-08-10 23:13:41 +00:00
|
|
|
//
|
|
|
|
|
2001-06-11 00:58:08 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
// Include page header
|
2001-06-11 00:58:08 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
2001-07-15 15:45:09 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$template->set_filenames(array(
|
|
|
|
"body" => "posting_body.tpl",
|
|
|
|
"pollbody" => "posting_poll_body.tpl",
|
2001-10-16 11:12:32 +00:00
|
|
|
"jumpbox" => "jumpbox.tpl",
|
|
|
|
"reviewbody" => "posting_topic_review.tpl")
|
2001-09-06 00:29:07 +00:00
|
|
|
);
|
2001-07-04 00:34:33 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$jumpbox = make_jumpbox();
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"L_GO" => $lang['Go'],
|
|
|
|
"L_JUMP_TO" => $lang['Jump_to'],
|
|
|
|
"L_SELECT_FORUM" => $lang['Select_forum'],
|
2001-09-07 12:32:47 +00:00
|
|
|
|
|
|
|
"S_JUMPBOX_LIST" => $jumpbox,
|
|
|
|
"S_JUMPBOX_ACTION" => append_sid("viewforum.$phpEx"))
|
2001-09-06 00:29:07 +00:00
|
|
|
);
|
|
|
|
$template->assign_var_from_handle("JUMPBOX", "jumpbox");
|
2001-08-15 22:54:48 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$template->assign_vars(array(
|
|
|
|
"FORUM_NAME" => $forum_name,
|
|
|
|
"L_POST_A" => $page_title,
|
2002-01-12 17:00:32 +00:00
|
|
|
"L_POST_SUBJECT" => $lang['Post_subject'],
|
2001-08-15 22:54:48 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
"U_VIEW_FORUM" => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Output preview of post if requested
|
|
|
|
//
|
|
|
|
if( $preview && !$error )
|
|
|
|
{
|
|
|
|
$orig_word = array();
|
|
|
|
$replacement_word = array();
|
|
|
|
$result = obtain_word_list($orig_word, $replacement_word);
|
2001-08-15 22:54:48 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $bbcode_on )
|
2001-08-10 22:00:12 +00:00
|
|
|
{
|
|
|
|
$bbcode_uid = make_bbcode_uid();
|
|
|
|
}
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
$preview_subject = $post_subject;
|
2001-11-26 14:07:33 +00:00
|
|
|
$preview_message = stripslashes(prepare_message($post_message, $html_on, $bbcode_on, $smilies_on, $bbcode_uid));
|
2001-08-09 22:21:55 +00:00
|
|
|
|
2001-08-10 22:00:12 +00:00
|
|
|
//
|
|
|
|
// Finalise processing as per viewtopic
|
|
|
|
//
|
|
|
|
if( !$html_on )
|
|
|
|
{
|
2001-09-25 18:26:05 +00:00
|
|
|
if( $user_sig != "" || !$userdata['user_allowhtml'] )
|
2001-08-10 22:00:12 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$user_sig = preg_replace("#(<)([\/]?.*?)(>)#is", "<\\2>", $user_sig);
|
2001-08-10 22:00:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-25 18:26:05 +00:00
|
|
|
if( $attach_sig && $user_sig != "" && $userdata['user_sig_bbcode_uid'] )
|
2001-08-10 23:13:41 +00:00
|
|
|
{
|
2001-09-25 18:26:05 +00:00
|
|
|
$user_sig = bbencode_second_pass($user_sig, $userdata['user_sig_bbcode_uid']);
|
2001-08-10 23:13:41 +00:00
|
|
|
}
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $bbcode_on )
|
2001-08-09 22:21:55 +00:00
|
|
|
{
|
2001-08-10 22:00:12 +00:00
|
|
|
$preview_message = bbencode_second_pass($preview_message, $bbcode_uid);
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
if( $attach_sig && $user_sig != "" )
|
2001-08-09 22:21:55 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$preview_message = $preview_message . "<br /><br />_________________<br />" . $user_sig;
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
|
|
|
|
2001-08-15 22:54:48 +00:00
|
|
|
if( count($orig_word) )
|
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$preview_subject = preg_replace($orig_word, $replacement_word, $preview_subject);
|
2001-08-15 22:54:48 +00:00
|
|
|
$preview_message = preg_replace($orig_word, $replacement_word, $preview_message);
|
|
|
|
}
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $smilies_on )
|
2001-08-09 22:21:55 +00:00
|
|
|
{
|
2001-08-10 22:00:12 +00:00
|
|
|
$preview_message = smilies_pass($preview_message);
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
2001-08-10 22:00:12 +00:00
|
|
|
|
2001-06-11 00:58:08 +00:00
|
|
|
$preview_message = make_clickable($preview_message);
|
2001-08-09 22:21:55 +00:00
|
|
|
$preview_message = str_replace("\n", "<br />", $preview_message);
|
2001-06-11 00:58:08 +00:00
|
|
|
|
2001-07-15 15:45:09 +00:00
|
|
|
$template->set_filenames(array(
|
|
|
|
"preview" => "posting_preview.tpl")
|
|
|
|
);
|
2001-06-11 00:58:08 +00:00
|
|
|
$template->assign_vars(array(
|
2001-08-30 22:20:23 +00:00
|
|
|
"TOPIC_TITLE" => $preview_subject,
|
|
|
|
"POST_SUBJECT" => $preview_subject,
|
2001-09-06 00:29:07 +00:00
|
|
|
"POSTER_NAME" => $username,
|
2001-09-08 18:24:34 +00:00
|
|
|
"POST_DATE" => create_date($board_config['default_dateformat'], time(), $board_config['board_timezone']),
|
2001-08-09 22:21:55 +00:00
|
|
|
"MESSAGE" => $preview_message,
|
2001-08-30 22:20:23 +00:00
|
|
|
|
2001-06-11 12:00:31 +00:00
|
|
|
"L_PREVIEW" => $lang['Preview'],
|
|
|
|
"L_POSTED" => $lang['Posted'])
|
|
|
|
);
|
2001-11-09 13:15:36 +00:00
|
|
|
$template->assign_var_from_handle("POST_PREVIEW_BOX", "preview");
|
2001-06-11 00:58:08 +00:00
|
|
|
}
|
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
// End preview output
|
2001-06-11 00:58:08 +00:00
|
|
|
//
|
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
// Start Error handling
|
2001-05-26 00:25:50 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $error )
|
2001-06-11 20:02:01 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$template->set_filenames(array(
|
|
|
|
"reg_header" => "error_body.tpl")
|
|
|
|
);
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"ERROR_MESSAGE" => $error_msg)
|
|
|
|
);
|
2001-11-09 13:15:36 +00:00
|
|
|
$template->assign_var_from_handle("ERROR_BOX", "reg_header");
|
2001-06-13 17:36:58 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// End error handling
|
|
|
|
//
|
2001-08-10 22:00:12 +00:00
|
|
|
|
2001-12-16 18:13:34 +00:00
|
|
|
//
|
|
|
|
// Send smilies to template
|
|
|
|
//
|
2001-12-29 15:18:34 +00:00
|
|
|
generate_smilies("inline", PAGE_POSTING);
|
2001-12-16 18:13:34 +00:00
|
|
|
|
2001-08-10 22:00:12 +00:00
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
// User not logged in so offer up a username
|
|
|
|
// field box
|
2001-08-10 22:00:12 +00:00
|
|
|
//
|
2001-09-18 01:24:47 +00:00
|
|
|
if( !$userdata['session_logged_in'] || ( $mode == "editpost" && $post_user_id == ANONYMOUS ) )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
|
|
|
$template->assign_block_vars("username_select", array());
|
|
|
|
}
|
2001-08-10 22:00:12 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// HTML toggle selection
|
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $board_config['allow_html'] )
|
2001-06-13 17:36:58 +00:00
|
|
|
{
|
2001-11-15 16:26:41 +00:00
|
|
|
$html_status = $lang['HTML_is_ON'];
|
2001-08-10 22:00:12 +00:00
|
|
|
$template->assign_block_vars("html_checkbox", array());
|
2001-06-13 17:36:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-15 16:26:41 +00:00
|
|
|
$html_status = $lang['HTML_is_OFF'];
|
2001-06-13 17:36:58 +00:00
|
|
|
}
|
|
|
|
|
2001-08-10 22:00:12 +00:00
|
|
|
//
|
|
|
|
// BBCode toggle selection
|
|
|
|
//
|
2001-06-13 17:36:58 +00:00
|
|
|
if($board_config['allow_bbcode'])
|
|
|
|
{
|
2001-11-15 16:26:41 +00:00
|
|
|
$bbcode_status = $lang['BBCode_is_ON'];
|
2001-08-10 22:00:12 +00:00
|
|
|
$template->assign_block_vars("bbcode_checkbox", array());
|
2001-06-13 17:36:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-15 16:26:41 +00:00
|
|
|
$bbcode_status = $lang['BBCode_is_OFF'];
|
2001-06-13 17:36:58 +00:00
|
|
|
}
|
2001-05-27 16:41:33 +00:00
|
|
|
|
2001-08-10 22:00:12 +00:00
|
|
|
//
|
|
|
|
// Smilies toggle selection
|
|
|
|
//
|
2001-06-13 17:36:58 +00:00
|
|
|
if($board_config['allow_smilies'])
|
|
|
|
{
|
2001-11-15 16:26:41 +00:00
|
|
|
$smilies_status = $lang['Smilies_are_ON'];
|
2001-08-10 22:00:12 +00:00
|
|
|
$template->assign_block_vars("smilies_checkbox", array());
|
2001-06-13 17:36:58 +00:00
|
|
|
}
|
2001-07-23 16:43:10 +00:00
|
|
|
else
|
|
|
|
{
|
2001-11-15 16:26:41 +00:00
|
|
|
$smilies_status = $lang['Smilies_are_OFF'];
|
2001-07-23 16:43:10 +00:00
|
|
|
}
|
|
|
|
|
2001-08-10 22:00:12 +00:00
|
|
|
//
|
2001-08-10 23:13:41 +00:00
|
|
|
// Signature toggle selection - only show if
|
|
|
|
// the user has a signature
|
2001-08-10 22:00:12 +00:00
|
|
|
//
|
2001-08-10 23:13:41 +00:00
|
|
|
if( $user_sig != "" )
|
2001-06-13 17:36:58 +00:00
|
|
|
{
|
2001-08-10 22:00:12 +00:00
|
|
|
$template->assign_block_vars("signature_checkbox", array());
|
|
|
|
}
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Notify checkbox - only show if user is logged in
|
|
|
|
//
|
|
|
|
if( $userdata['session_logged_in'] )
|
|
|
|
{
|
2001-09-18 01:24:47 +00:00
|
|
|
if( $mode != "editpost" || ( $mode == "editpost" && $post_user_id != ANONYMOUS ) )
|
|
|
|
{
|
|
|
|
$template->assign_block_vars("notify_checkbox", array());
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
|
2001-08-10 22:00:12 +00:00
|
|
|
//
|
|
|
|
// Delete selection
|
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $mode == 'editpost' && ( ( $is_auth['auth_delete'] && $is_last_post_topic && ( !$post_has_poll || $can_edit_poll ) ) || $is_auth['auth_mod'] ) )
|
2001-08-10 22:00:12 +00:00
|
|
|
{
|
|
|
|
$template->assign_block_vars("delete_checkbox", array());
|
2001-06-13 17:36:58 +00:00
|
|
|
}
|
|
|
|
|
2001-08-10 22:00:12 +00:00
|
|
|
//
|
|
|
|
// Topic type selection
|
|
|
|
//
|
2001-07-04 00:34:33 +00:00
|
|
|
$topic_type_radio = '';
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $mode == 'newtopic' || ( $mode == 'editpost' && $is_first_post_topic ) )
|
2001-06-13 17:36:58 +00:00
|
|
|
{
|
2001-08-10 22:00:12 +00:00
|
|
|
$template->assign_block_vars("type_toggle", array());
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $is_auth['auth_announce'] )
|
2001-06-13 17:36:58 +00:00
|
|
|
{
|
2001-07-04 00:34:33 +00:00
|
|
|
$announce_toggle = '<input type="radio" name="topictype" value="announce"';
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $topic_type == POST_ANNOUNCE )
|
2001-05-25 00:56:07 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$announce_toggle .= ' checked="checked"';
|
2001-05-25 00:56:07 +00:00
|
|
|
}
|
2001-08-10 22:00:12 +00:00
|
|
|
$announce_toggle .= ' /> ' . $lang['Post_Announcement'] . ' ';
|
2001-06-13 17:36:58 +00:00
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $is_auth['auth_sticky'] )
|
2001-06-13 17:36:58 +00:00
|
|
|
{
|
2001-07-04 00:34:33 +00:00
|
|
|
$sticky_toggle = '<input type="radio" name="topictype" value="sticky"';
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $topic_type == POST_STICKY )
|
2001-06-07 07:56:45 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$sticky_toggle .= ' checked="checked"';
|
2001-06-07 07:56:45 +00:00
|
|
|
}
|
2001-08-10 22:00:12 +00:00
|
|
|
$sticky_toggle .= ' /> ' . $lang['Post_Sticky'] . ' ';
|
2001-07-04 00:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( $is_auth['auth_announce'] || $is_auth['auth_sticky'] )
|
|
|
|
{
|
2001-08-10 22:00:12 +00:00
|
|
|
$topic_type_toggle = $lang['Post_topic_as'] . ': <input type="radio" name="topictype" value="normal"';
|
2001-09-06 00:29:07 +00:00
|
|
|
if( $topic_type == POST_NORMAL )
|
2001-05-25 00:56:07 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
$topic_type_toggle .= ' checked="checked"';
|
2001-05-25 00:56:07 +00:00
|
|
|
}
|
2001-10-17 23:05:46 +00:00
|
|
|
$topic_type_toggle .= ' /> ' . $lang['Post_Normal'] . ' ' . $sticky_toggle . $announce_toggle;
|
2001-06-13 17:36:58 +00:00
|
|
|
}
|
|
|
|
}
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2001-07-10 22:32:39 +00:00
|
|
|
//
|
|
|
|
// Define hidden fields
|
|
|
|
//
|
2001-09-06 00:29:07 +00:00
|
|
|
$hidden_form_fields = '<input type="hidden" name="mode" value="' . $mode . '" />';
|
2001-06-13 17:36:58 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
switch($mode)
|
2001-08-10 22:00:12 +00:00
|
|
|
{
|
2001-09-06 00:29:07 +00:00
|
|
|
case 'newtopic':
|
|
|
|
$hidden_form_fields .= '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
|
|
|
|
break;
|
2001-08-09 22:21:55 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
case 'reply':
|
|
|
|
$hidden_form_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'editpost':
|
|
|
|
$hidden_form_fields .= '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />';
|
|
|
|
break;
|
2001-08-10 22:00:12 +00:00
|
|
|
}
|
2001-08-09 22:21:55 +00:00
|
|
|
|
2001-12-04 18:08:43 +00:00
|
|
|
//
|
|
|
|
// If post_message is not empty (as per a preview or error )
|
|
|
|
// then stripslashes
|
|
|
|
//
|
2001-12-05 00:00:39 +00:00
|
|
|
if( !empty($post_message) && ( $preview || $error || $refresh ) )
|
2001-12-04 18:08:43 +00:00
|
|
|
{
|
|
|
|
$post_message = stripslashes(preg_replace($html_entities_match, $html_entities_replace, $post_message));
|
|
|
|
}
|
|
|
|
|
2001-12-16 18:13:34 +00:00
|
|
|
//
|
|
|
|
// This enables the forum/topic title to be output for posting
|
|
|
|
// but not for privmsg (where it makes no sense)
|
|
|
|
//
|
|
|
|
$template->assign_block_vars("switch_not_privmsg", array());
|
|
|
|
|
2001-08-10 22:00:12 +00:00
|
|
|
//
|
|
|
|
// Output the data to the template
|
|
|
|
//
|
2001-06-13 17:36:58 +00:00
|
|
|
$template->assign_vars(array(
|
2001-09-07 00:23:40 +00:00
|
|
|
"USERNAME" => preg_replace($html_entities_match, $html_entities_replace, $post_username),
|
|
|
|
"SUBJECT" => preg_replace($html_entities_match, $html_entities_replace, $post_subject),
|
2001-09-06 00:29:07 +00:00
|
|
|
"MESSAGE" => $post_message,
|
2001-06-13 17:36:58 +00:00
|
|
|
"HTML_STATUS" => $html_status,
|
2001-12-16 18:13:34 +00:00
|
|
|
"BBCODE_STATUS" => sprintf($bbcode_status, '<a href="' . append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">', '</a>'),
|
2001-09-06 00:29:07 +00:00
|
|
|
"SMILIES_STATUS" => $smilies_status,
|
2001-09-07 00:23:40 +00:00
|
|
|
"POLL_TITLE" => preg_replace($html_entities_match, $html_entities_replace, $poll_title),
|
2001-09-06 00:29:07 +00:00
|
|
|
"POLL_LENGTH" => $poll_length,
|
2001-06-13 17:36:58 +00:00
|
|
|
|
|
|
|
"L_SUBJECT" => $lang['Subject'],
|
|
|
|
"L_MESSAGE_BODY" => $lang['Message_body'],
|
|
|
|
"L_OPTIONS" => $lang['Options'],
|
|
|
|
"L_PREVIEW" => $lang['Preview'],
|
2001-11-15 16:35:09 +00:00
|
|
|
"L_SPELLCHECK" => $lang['Spellcheck'],
|
2001-11-24 15:57:31 +00:00
|
|
|
"L_SUBMIT" => $lang['Submit'],
|
|
|
|
"L_CANCEL" => $lang['Cancel'],
|
2001-08-30 22:20:23 +00:00
|
|
|
"L_CONFIRM_DELETE" => $lang['Confirm_delete'],
|
2001-11-15 16:26:41 +00:00
|
|
|
"L_DISABLE_HTML" => $lang['Disable_HTML_post'],
|
|
|
|
"L_DISABLE_BBCODE" => $lang['Disable_BBCode_post'],
|
|
|
|
"L_DISABLE_SMILIES" => $lang['Disable_Smilies_post'],
|
2001-09-06 00:29:07 +00:00
|
|
|
"L_ATTACH_SIGNATURE" => $lang['Attach_signature'],
|
|
|
|
"L_NOTIFY_ON_REPLY" => $lang['Notify'],
|
2001-08-30 22:20:23 +00:00
|
|
|
"L_DELETE_POST" => $lang['Delete_post'],
|
|
|
|
|
2001-12-16 18:13:34 +00:00
|
|
|
"L_BBCODE_B_HELP" => $lang['bbcode_b_help'],
|
|
|
|
"L_BBCODE_I_HELP" => $lang['bbcode_i_help'],
|
|
|
|
"L_BBCODE_U_HELP" => $lang['bbcode_u_help'],
|
|
|
|
"L_BBCODE_Q_HELP" => $lang['bbcode_q_help'],
|
|
|
|
"L_BBCODE_C_HELP" => $lang['bbcode_c_help'],
|
|
|
|
"L_BBCODE_L_HELP" => $lang['bbcode_l_help'],
|
|
|
|
"L_BBCODE_O_HELP" => $lang['bbcode_o_help'],
|
|
|
|
"L_BBCODE_P_HELP" => $lang['bbcode_p_help'],
|
|
|
|
"L_BBCODE_W_HELP" => $lang['bbcode_w_help'],
|
|
|
|
"L_BBCODE_A_HELP" => $lang['bbcode_a_help'],
|
|
|
|
"L_BBCODE_S_HELP" => $lang['bbcode_s_help'],
|
|
|
|
"L_BBCODE_F_HELP" => $lang['bbcode_f_help'],
|
|
|
|
"L_EMPTY_MESSAGE" => $lang['Empty_message'],
|
|
|
|
|
|
|
|
"L_FONT_COLOR" => $lang['Font_color'],
|
|
|
|
"L_COLOR_DEFAULT" => $lang['color_default'],
|
|
|
|
"L_COLOR_DARK_RED" => $lang['color_dark_red'],
|
|
|
|
"L_COLOR_RED" => $lang['color_red'],
|
|
|
|
"L_COLOR_ORANGE" => $lang['color_orange'],
|
|
|
|
"L_COLOR_BROWN" => $lang['color_brown'],
|
|
|
|
"L_COLOR_YELLOW" => $lang['color_yellow'],
|
|
|
|
"L_COLOR_GREEN" => $lang['color_green'],
|
|
|
|
"L_COLOR_OLIVE" => $lang['color_olive'],
|
|
|
|
"L_COLOR_CYAN" => $lang['color_cyan'],
|
|
|
|
"L_COLOR_BLUE" => $lang['color_blue'],
|
|
|
|
"L_COLOR_DARK_BLUE" => $lang['color_dark_blue'],
|
|
|
|
"L_COLOR_INDIGO" => $lang['color_indigo'],
|
|
|
|
"L_COLOR_VIOLET" => $lang['color_violet'],
|
|
|
|
"L_COLOR_WHITE" => $lang['color_white'],
|
|
|
|
"L_COLOR_BLACK" => $lang['color_black'],
|
|
|
|
|
|
|
|
"L_FONT_SIZE" => $lang['Font_size'],
|
|
|
|
"L_FONT_TINY" => $lang['font_tiny'],
|
|
|
|
"L_FONT_SMALL" => $lang['font_small'],
|
|
|
|
"L_FONT_NORMAL" => $lang['font_normal'],
|
|
|
|
"L_FONT_LARGE" => $lang['font_large'],
|
|
|
|
"L_FONT_HUGE" => $lang['font_huge'],
|
|
|
|
|
|
|
|
"L_BBCODE_CLOSE_TAGS" => $lang['Close_Tags'],
|
|
|
|
"L_STYLES_TIP" => $lang['Styles_tip'],
|
|
|
|
|
2001-10-16 11:12:32 +00:00
|
|
|
"U_VIEWTOPIC" => ( $mode == "reply" ) ? append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postorder=desc") : "",
|
|
|
|
"U_REVIEW_TOPIC" => ( $mode == "reply" ) ? append_sid("posting.$phpEx?mode=topicreview&" . POST_TOPIC_URL . "=$topic_id") : "",
|
2001-10-14 15:49:52 +00:00
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
"S_HTML_CHECKED" => (!$html_on) ? "checked=\"checked\"" : "",
|
|
|
|
"S_BBCODE_CHECKED" => (!$bbcode_on) ? "checked=\"checked\"" : "",
|
|
|
|
"S_SMILIES_CHECKED" => (!$smilies_on) ? "checked=\"checked\"" : "",
|
|
|
|
"S_SIGNATURE_CHECKED" => ($attach_sig) ? "checked=\"checked\"" : "",
|
|
|
|
"S_NOTIFY_CHECKED" => ($notify_user) ? "checked=\"checked\"" : "",
|
|
|
|
"S_TYPE_TOGGLE" => $topic_type_toggle,
|
|
|
|
"S_TOPIC_ID" => $topic_id,
|
2001-06-13 17:36:58 +00:00
|
|
|
"S_POST_ACTION" => append_sid("posting.$phpEx"),
|
|
|
|
"S_HIDDEN_FORM_FIELDS" => $hidden_form_fields)
|
|
|
|
);
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Poll entry switch/output
|
|
|
|
//
|
|
|
|
if( $display_poll )
|
|
|
|
{
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"L_ADD_A_POLL" => $lang['Add_poll'],
|
|
|
|
"L_ADD_POLL_EXPLAIN" => $lang['Add_poll_explain'],
|
|
|
|
"L_POLL_QUESTION" => $lang['Poll_question'],
|
|
|
|
"L_POLL_OPTION" => $lang['Poll_option'],
|
|
|
|
"L_ADD_OPTION" => $lang['Add_option'],
|
|
|
|
"L_UPDATE_OPTION" => $lang['Update'],
|
|
|
|
"L_DELETE_OPTION" => $lang['Delete'],
|
|
|
|
"L_POLL_LENGTH" => $lang['Poll_for'],
|
|
|
|
"L_DAYS" => $lang['Days'],
|
|
|
|
"L_POLL_LENGTH_EXPLAIN" => $lang['Poll_for_explain'],
|
|
|
|
"L_POLL_DELETE" => $lang['Delete_poll'],
|
|
|
|
|
|
|
|
"POLL_LENGTH" => $poll_length)
|
|
|
|
);
|
|
|
|
|
|
|
|
if( $mode == "editpost" && ( $can_edit_poll || $is_auth['auth_mod'] ) && $post_has_poll )
|
|
|
|
{
|
|
|
|
$template->assign_block_vars("poll_delete_toggle", array());
|
|
|
|
}
|
|
|
|
|
|
|
|
if( is_array($poll_option_list) )
|
|
|
|
{
|
|
|
|
while( list($option_id, $option_text) = each($poll_option_list) )
|
|
|
|
{
|
|
|
|
$template->assign_block_vars("poll_option_rows", array(
|
2001-09-07 00:23:40 +00:00
|
|
|
"POLL_OPTION" => preg_replace($html_entities_match, $html_entities_replace, $option_text),
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
|
|
"S_POLL_OPTION_NUM" => $option_id)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_var_from_handle("POLLBOX", "pollbody");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-10-16 11:12:32 +00:00
|
|
|
//
|
|
|
|
// Topic review
|
|
|
|
//
|
|
|
|
if( $mode == "reply" )
|
|
|
|
{
|
|
|
|
topic_review($topic_id, true);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Enable inline mode ...
|
|
|
|
//
|
|
|
|
$template->assign_block_vars("switch_inline_mode", array());
|
|
|
|
$template->assign_var_from_handle("TOPIC_REVIEW_BOX", "reviewbody");
|
|
|
|
}
|
|
|
|
|
2001-09-06 00:29:07 +00:00
|
|
|
//
|
|
|
|
// Parse and print the body
|
|
|
|
//
|
2001-06-13 17:36:58 +00:00
|
|
|
$template->pparse("body");
|
|
|
|
|
2001-07-13 16:14:37 +00:00
|
|
|
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
2001-06-13 17:36:58 +00:00
|
|
|
|
2001-12-18 20:35:17 +00:00
|
|
|
?>
|