2001-02-17 08:37:32 +00:00
|
|
|
<?php
|
2001-04-17 07:14:50 +00:00
|
|
|
/***************************************************************************
|
2001-03-07 06:53:39 +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$
|
|
|
|
*
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* 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-03-07 06:53:39 +00:00
|
|
|
include('extension.inc');
|
|
|
|
include('common.'.$phpEx);
|
2001-05-25 00:56:07 +00:00
|
|
|
include('includes/bbcode.'.$phpEx);
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2001-05-17 14:48:39 +00:00
|
|
|
//
|
2001-05-25 00:56:07 +00:00
|
|
|
// Posting specific functions.
|
|
|
|
//
|
2001-04-18 06:26:01 +00:00
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
// This function will prepare the message for entry into the database.
|
2001-05-27 18:08:02 +00:00
|
|
|
function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0)
|
2001-03-07 06:53:39 +00:00
|
|
|
{
|
2001-05-25 00:56:07 +00:00
|
|
|
$message = trim($message);
|
2001-05-25 07:02:48 +00:00
|
|
|
|
|
|
|
if(!$html_on)
|
2001-05-25 00:56:07 +00:00
|
|
|
{
|
|
|
|
$message = htmlspecialchars($message);
|
|
|
|
}
|
2001-05-25 07:02:48 +00:00
|
|
|
|
2001-05-27 18:08:02 +00:00
|
|
|
if($bbcode_on)
|
2001-05-25 00:56:07 +00:00
|
|
|
{
|
|
|
|
$message = bbencode_first_pass($message, $bbcode_uid);
|
|
|
|
}
|
2001-05-25 07:02:48 +00:00
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
if($smile_on)
|
|
|
|
{
|
|
|
|
// No smile() function yet, write one...
|
|
|
|
//$message = smile($message);
|
|
|
|
}
|
2001-05-25 07:02:48 +00:00
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
$message = addslashes($message);
|
|
|
|
return($message);
|
2001-05-25 07:02:48 +00:00
|
|
|
}
|
2001-05-30 20:35:36 +00:00
|
|
|
//
|
|
|
|
// End Posting specific functions.
|
|
|
|
//
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2001-05-30 20:35:36 +00:00
|
|
|
//
|
|
|
|
// Start program proper
|
|
|
|
//
|
|
|
|
if(!isset($HTTP_GET_VARS['forum']) && !isset($HTTP_POST_VARS['forum'])) // For backward compatibility
|
|
|
|
{
|
|
|
|
$forum_id = ($HTTP_GET_VARS[POST_FORUM_URL]) ? $HTTP_GET_VARS[POST_FORUM_URL] : $HTTP_POST_VARS[POST_FORUM_URL];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$forum_id = ($HTTP_GET_VARS['forum']) ? $HTTP_GET_VARS['forum'] : $HTTP_POST_VARS['forum'];
|
|
|
|
}
|
2001-06-06 17:50:24 +00:00
|
|
|
|
2001-05-30 21:23:14 +00:00
|
|
|
$mode = (isset($HTTP_GET_VARS['mode'])) ? $HTTP_GET_VARS['mode'] : ( (isset($HTTP_POST_VARS['mode'])) ? $HTTP_POST_VARS['mode'] : "");
|
2001-05-30 20:35:36 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Start session management
|
2001-05-25 00:56:07 +00:00
|
|
|
//
|
2001-05-30 20:35:36 +00:00
|
|
|
$userdata = session_pagestart($user_ip, PAGE_POSTING, $session_length);
|
|
|
|
init_userprefs($userdata);
|
|
|
|
//
|
|
|
|
// End session management
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Auth code
|
|
|
|
//
|
|
|
|
|
|
|
|
// This is a quick check to see if it works
|
|
|
|
// can probably be placed better ...
|
2001-05-30 21:23:14 +00:00
|
|
|
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($mode)
|
|
|
|
{
|
|
|
|
case 'newtopic':
|
2001-06-07 07:56:45 +00:00
|
|
|
if(isset($HTTP_POST_VARS['annouce']))
|
|
|
|
{
|
|
|
|
$auth_type = AUTH_ANNOUCE;
|
|
|
|
$is_auth_type = "auth_announce";
|
|
|
|
$error_string = "post annoucements";
|
|
|
|
}
|
|
|
|
else if(isset($HTTP_POST_VARS['sticky']))
|
|
|
|
{
|
|
|
|
$auth_type = AUTH_STICKY;
|
|
|
|
$is_auth_type = "auth_sticky";
|
|
|
|
$error_string = "post sticky topics";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$auth_type = AUTH_ALL;
|
|
|
|
$is_auth_type = "auth_post";
|
|
|
|
$error_string = "post new topics";
|
|
|
|
}
|
2001-05-30 20:35:36 +00:00
|
|
|
break;
|
|
|
|
case 'reply':
|
2001-06-11 00:58:08 +00:00
|
|
|
$auth_type = AUTH_ALL;
|
2001-06-01 01:45:50 +00:00
|
|
|
$is_auth_type = "auth_reply";
|
2001-06-06 17:50:24 +00:00
|
|
|
$error_string = "reply to topics";
|
2001-05-30 20:35:36 +00:00
|
|
|
break;
|
|
|
|
case 'editpost':
|
2001-06-01 00:28:50 +00:00
|
|
|
$auth_type = AUTH_EDIT;
|
|
|
|
$is_auth_type = "auth_edit";
|
2001-06-06 17:50:24 +00:00
|
|
|
$error_string = "edit topics";
|
2001-05-30 20:35:36 +00:00
|
|
|
break;
|
|
|
|
case 'delete':
|
2001-06-01 00:28:50 +00:00
|
|
|
$auth_type = AUTH_DELETE;
|
|
|
|
$is_auth_type = "auth_delete";
|
2001-06-06 17:50:24 +00:00
|
|
|
$error_string = "delete topics";
|
2001-05-30 20:35:36 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-06-07 07:56:45 +00:00
|
|
|
$auth_type = AUTH_ALL;
|
|
|
|
$is_auth_type = "auth_all";
|
2001-06-06 17:50:24 +00:00
|
|
|
$error_string = "post new topics";
|
2001-05-30 20:35:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-04-17 07:14:50 +00:00
|
|
|
|
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-06-01 00:28:50 +00:00
|
|
|
if(!$is_auth[$is_auth_type])
|
2001-05-30 20:35:36 +00:00
|
|
|
{
|
|
|
|
//
|
|
|
|
// Ooopss, user is not authed
|
|
|
|
// to read this forum ...
|
|
|
|
//
|
|
|
|
include('includes/page_header.'.$phpEx);
|
2001-06-03 23:10:07 +00:00
|
|
|
|
2001-06-06 17:50:24 +00:00
|
|
|
$msg = "I am sorry but you cannot $error_string in this forum, this function is restricted to " . $is_auth[$is_auth_type . "_type"] . " only.";
|
2001-05-30 20:35:36 +00:00
|
|
|
|
|
|
|
$template->set_filenames(array(
|
|
|
|
"reg_header" => "error_body.tpl"
|
|
|
|
));
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"ERROR_MESSAGE" => $msg
|
|
|
|
));
|
|
|
|
$template->pparse("reg_header");
|
|
|
|
|
|
|
|
include('includes/page_tail.'.$phpEx);
|
|
|
|
}
|
2001-05-30 21:23:14 +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-05-26 00:25:50 +00:00
|
|
|
$error = FALSE;
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2001-05-27 18:08:02 +00:00
|
|
|
//
|
|
|
|
// Set initial conditions
|
|
|
|
//
|
2001-06-11 20:02:01 +00:00
|
|
|
$is_first_post = (($HTTP_GET_VARS['is_first_post'] == 1) || ($HTTP_POST_VARS['is_first_post'] == 1)) ? TRUE : FALSE;
|
2001-06-04 01:35:15 +00:00
|
|
|
$disable_html = (isset($HTTP_POST_VARS['disable_html'])) ? $HTTP_POST_VARS['disable_html'] : !$userdata['user_allowhtml'];
|
|
|
|
$disable_bbcode = (isset($HTTP_POST_VARS['disable_bbcode'])) ? $HTTP_POST_VARS['disable_bbcode'] : !$userdata['user_allowbbcode'];
|
|
|
|
$disable_smilies = (isset($HTTP_POST_VARS['disable_smile'])) ? $HTTP_POST_VARS['disable_smile'] : !$userdata['user_allowsmile'];
|
2001-05-27 18:08:02 +00:00
|
|
|
$attach_sig = (isset($HTTP_POST_VARS['attach_sig'])) ? $HTTP_POST_VARS['attach_sig'] : $userdata['user_attachsig'];
|
|
|
|
$notify = (isset($HTTP_POST_VARS['notify'])) ? $HTTP_POST_VARS['notify'] : $userdata["always_notify"];
|
2001-06-07 07:56:45 +00:00
|
|
|
$annouce = (isset($HTTP_POST_VARS['annouce'])) ? $HTTP_POST_VARS['annouce'] : "";
|
|
|
|
$sticky = (isset($HTTP_POST_VARS['sticky'])) ? $HTTP_POST_VARS['sticky'] : "";
|
2001-06-11 00:58:08 +00:00
|
|
|
$preview = (isset($HTTP_POST_VARS['preview'])) ? TRUE : FALSE;
|
|
|
|
|
2001-06-07 07:56:45 +00:00
|
|
|
|
|
|
|
if($annouce)
|
|
|
|
{
|
|
|
|
$topic_type = ANNOUCE;
|
|
|
|
}
|
|
|
|
else if($sticky)
|
|
|
|
{
|
|
|
|
$topic_type = STICKY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$topic_type = NORMAL;
|
|
|
|
}
|
2001-05-27 18:08:02 +00:00
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
//
|
2001-05-27 03:11:27 +00:00
|
|
|
// Prepare our message and subject on a 'submit'
|
2001-05-26 00:25:50 +00:00
|
|
|
//
|
2001-06-11 00:58:08 +00:00
|
|
|
if(isset($HTTP_POST_VARS['submit']) || $preview)
|
2001-05-25 00:56:07 +00:00
|
|
|
{
|
2001-05-27 03:11:27 +00:00
|
|
|
//
|
|
|
|
// Flood control
|
|
|
|
//
|
2001-06-11 00:58:08 +00:00
|
|
|
if($mode != 'editpost' && !$preview)
|
2001-05-27 03:11:27 +00:00
|
|
|
{
|
2001-06-03 23:10:07 +00:00
|
|
|
$sql = "SELECT max(post_time) AS last_post_time
|
|
|
|
FROM ".POSTS_TABLE."
|
2001-05-27 16:41:33 +00:00
|
|
|
WHERE poster_ip = '$user_ip'";
|
2001-05-27 03:11:27 +00:00
|
|
|
if($result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$db_row = $db->sql_fetchrowset($result);
|
|
|
|
$last_post_time = $db_row[0]['last_post_time'];
|
|
|
|
$current_time = get_gmt_ts();
|
|
|
|
|
|
|
|
if(($current_time - $last_post_time) < $board_config['flood_interval'])
|
|
|
|
{
|
|
|
|
$error = TRUE;
|
2001-05-28 20:23:16 +00:00
|
|
|
$error_msg = $lang['Flood_Error'];
|
2001-05-27 03:11:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// End: Flood control
|
|
|
|
//
|
|
|
|
|
2001-06-11 00:58:08 +00:00
|
|
|
// Handle anon posting with usernames
|
|
|
|
if(isset($HTTP_POST_VARS['username']))
|
|
|
|
{
|
|
|
|
$username = trim(strip_tags(htmlspecialchars(stripslashes($HTTP_POST_VARS['username']))));
|
|
|
|
if(!validate_username($username))
|
|
|
|
{
|
|
|
|
$error = TRUE;
|
|
|
|
if(isset($error_msg))
|
|
|
|
{
|
|
|
|
$error_msg .= "<br />";
|
|
|
|
}
|
|
|
|
$error_msg .= $lang['Bad_username'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$username = "";
|
|
|
|
}
|
|
|
|
|
2001-05-27 03:11:27 +00:00
|
|
|
$subject = trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['subject'])));
|
2001-05-26 00:25:50 +00:00
|
|
|
if($mode == 'newtopic' && empty($subject))
|
|
|
|
{
|
|
|
|
$error = TRUE;
|
|
|
|
if(isset($error_msg))
|
|
|
|
{
|
|
|
|
$error_msg .= "<br />";
|
|
|
|
}
|
2001-05-28 20:23:16 +00:00
|
|
|
$error_msg .= $lang['Empty_subj'];
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-06-07 07:56:45 +00:00
|
|
|
// You can't make it both an annoumcement and a stick topic
|
|
|
|
if($annouce && $sticky)
|
|
|
|
{
|
|
|
|
$error = TRUE;
|
|
|
|
if(isset($error_msg))
|
|
|
|
{
|
|
|
|
$error_msg .= "<br />";
|
|
|
|
}
|
|
|
|
$error_msg .= $lang['Annouce_and_sticky'];
|
|
|
|
}
|
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
if(!empty($HTTP_POST_VARS['message']))
|
|
|
|
{
|
2001-06-11 00:58:08 +00:00
|
|
|
if(!$error && !$preview)
|
2001-05-25 00:56:07 +00:00
|
|
|
{
|
2001-05-27 18:08:02 +00:00
|
|
|
if($disable_html)
|
2001-03-09 23:33:06 +00:00
|
|
|
{
|
2001-05-25 00:56:07 +00:00
|
|
|
$html_on = FALSE;
|
2001-03-09 23:33:06 +00:00
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
else
|
2001-03-09 23:33:06 +00:00
|
|
|
{
|
2001-05-25 00:56:07 +00:00
|
|
|
$html_on = TRUE;
|
2001-03-09 23:33:06 +00:00
|
|
|
}
|
2001-05-25 07:02:48 +00:00
|
|
|
|
2001-05-27 18:08:02 +00:00
|
|
|
if($disable_bbcode)
|
2001-03-09 23:33:06 +00:00
|
|
|
{
|
2001-05-25 00:56:07 +00:00
|
|
|
$bbcode_on = FALSE;
|
2001-03-09 23:33:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-25 00:56:07 +00:00
|
|
|
$uid = make_bbcode_uid();
|
2001-05-27 18:08:02 +00:00
|
|
|
$bbcode_on = TRUE;
|
2001-03-09 23:33:06 +00:00
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-27 18:08:02 +00:00
|
|
|
if($disable_smilies)
|
2001-03-09 23:33:06 +00:00
|
|
|
{
|
2001-05-25 00:56:07 +00:00
|
|
|
$smile_on = FALSE;
|
2001-03-09 23:33:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-25 00:56:07 +00:00
|
|
|
$smile_on = TRUE;
|
2001-03-09 23:33:06 +00:00
|
|
|
}
|
2001-05-25 07:02:48 +00:00
|
|
|
|
2001-05-27 18:08:02 +00:00
|
|
|
$message = prepare_message($HTTP_POST_VARS['message'], $html_on, $bbcode_on, $smile_on, $uid);
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-27 18:08:02 +00:00
|
|
|
if($attach_sig && !empty($userdata['user_sig']))
|
2001-03-09 23:33:06 +00:00
|
|
|
{
|
2001-05-25 00:56:07 +00:00
|
|
|
$message .= "[addsig]";
|
|
|
|
}
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// do stripslashes incase magic_quotes is on.
|
|
|
|
$message = stripslashes($HTTP_POST_VARS['message']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$error = TRUE;
|
|
|
|
if(isset($error_msg))
|
|
|
|
{
|
|
|
|
$error_msg .= "<br />";
|
|
|
|
}
|
2001-05-28 20:23:16 +00:00
|
|
|
$error_msg .= $lang['Empty_msg'];
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch($mode)
|
|
|
|
{
|
|
|
|
case 'newtopic':
|
2001-05-28 20:23:16 +00:00
|
|
|
$page_title = " ".$lang['Postnew'];
|
|
|
|
$section_title = $lang['Post_new_in'];
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-29 19:43:21 +00:00
|
|
|
if($SQL_LAYER != "mysql")
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("BEGIN");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("BEGIN TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
}
|
|
|
|
|
2001-06-11 00:58:08 +00:00
|
|
|
if(isset($HTTP_POST_VARS['submit']) && !$error && !$preview)
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-06-11 00:58:08 +00:00
|
|
|
if($username)
|
|
|
|
{
|
|
|
|
$username = addslashes($username);
|
|
|
|
}
|
2001-05-26 00:25:50 +00:00
|
|
|
$topic_time = get_gmt_ts();
|
2001-05-25 00:56:07 +00:00
|
|
|
$topic_notify = ($HTTP_POST_VARS['notify']) ? $HTTP_POST_VARS['notify'] : 0;
|
2001-06-07 07:56:45 +00:00
|
|
|
$sql = "INSERT INTO ".TOPICS_TABLE." (topic_title, topic_poster, topic_time, forum_id, topic_notify, topic_status, topic_type)
|
|
|
|
VALUES ('$subject', ".$userdata['user_id'].", ".$topic_time.", $forum_id, $topic_notify, ".UNLOCKED.", ".$topic_type.")";
|
2001-05-25 07:02:48 +00:00
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$new_topic_id = $db->sql_nextid();
|
2001-06-11 00:58:08 +00:00
|
|
|
$sql = "INSERT INTO ".POSTS_TABLE." (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, bbcode_uid)
|
|
|
|
VALUES ($new_topic_id, $forum_id, ".$userdata['user_id'].", '".$username."', $topic_time, '$user_ip', '$uid')";
|
2001-05-25 07:02:48 +00:00
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
if($db->sql_query($sql))
|
2001-03-09 23:33:06 +00:00
|
|
|
{
|
2001-05-25 00:56:07 +00:00
|
|
|
$new_post_id = $db->sql_nextid();
|
2001-05-27 03:11:27 +00:00
|
|
|
$sql = "INSERT INTO ".POSTS_TEXT_TABLE." (post_id, post_subject, post_text) VALUES ($new_post_id, '".$subject."', '".$message."')";
|
2001-05-25 00:56:07 +00:00
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$sql = "UPDATE ".TOPICS_TABLE." SET topic_last_post_id = $new_post_id WHERE topic_id = $new_topic_id";
|
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$sql = "UPDATE ".FORUMS_TABLE." SET forum_last_post_id = $new_post_id, forum_posts = forum_posts + 1, forum_topics = forum_topics + 1 WHERE forum_id = $forum_id";
|
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
2001-05-26 00:25:50 +00:00
|
|
|
if($userdata['user_id'] != ANONYMOUS)
|
|
|
|
{
|
|
|
|
$sql = "UPDATE ".USERS_TABLE." SET user_posts = user_posts + 1 WHERE user_id = ".$userdata['user_id'];
|
|
|
|
$db->sql_query($sql);
|
|
|
|
}
|
|
|
|
|
2001-05-29 19:43:21 +00:00
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("COMMIT");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("COMMIT TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
if(!$result)
|
|
|
|
{
|
|
|
|
error_die(SQL_ERROR, "Couldn't commit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
include('includes/page_header.'.$phpEx);
|
|
|
|
// If we get here the post has been inserted successfully.
|
2001-05-29 19:43:21 +00:00
|
|
|
$msg = "$l_stored<br /><br />$l_click <a href=\"".append_sid("viewtopic.$phpEx?".POST_POST_URL."=$new_post_id")."\">$l_here</a>
|
|
|
|
$l_viewmsg<br /><br />$l_click <a href=\"".append_sid("viewforum.$phpEx?".POST_FORUM_URL."=$forum_id")."\">$l_here</a> $l_returntopic";
|
2001-05-25 00:56:07 +00:00
|
|
|
|
|
|
|
$template->set_filenames(array(
|
|
|
|
"reg_header" => "error_body.tpl"
|
|
|
|
));
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"ERROR_MESSAGE" => $msg
|
|
|
|
));
|
|
|
|
$template->pparse("reg_header");
|
2001-05-25 07:02:48 +00:00
|
|
|
|
|
|
|
include('includes/page_tail.'.$phpEx);
|
2001-05-25 00:56:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-29 19:43:21 +00:00
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("ROLLBACK");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("ROLLBACK TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
error_die(QUERY_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-29 19:43:21 +00:00
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("ROLLBACK");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("ROLLBACK TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
if(DEBUG)
|
|
|
|
{
|
|
|
|
$error = $db->sql_error();
|
|
|
|
error_die(QUERY_ERROR, "Error updating topics table.<br>Reason: ".$error['message']."<br>Query: $sql", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error_die(QUERY_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-29 19:43:21 +00:00
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("ROLLBACK");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("ROLLBACK TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
if(DEBUG)
|
|
|
|
{
|
|
|
|
$error = $db->sql_error();
|
|
|
|
error_die(QUERY_ERROR, "Error inserting data into posts text table.<br>Reason: ".$error['message']."<br>Query: $sql", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error_die(QUERY_ERROR);
|
|
|
|
}
|
|
|
|
}
|
2001-03-09 23:33:06 +00:00
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
else
|
|
|
|
{
|
2001-05-29 19:43:21 +00:00
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("ROLLBACK");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("ROLLBACK TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
if(DEBUG)
|
|
|
|
{
|
|
|
|
$error = $db->sql_error();
|
|
|
|
error_die(QUERY_ERROR, "Error inserting data into posts table.<br>Reason: ".$error['message']."<br>Query: $sql", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error_die(QUERY_ERROR);
|
|
|
|
}
|
|
|
|
}
|
2001-05-25 07:02:48 +00:00
|
|
|
}
|
2001-03-09 23:33:06 +00:00
|
|
|
else
|
|
|
|
{
|
2001-05-29 19:43:21 +00:00
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("ROLLBACK");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("ROLLBACK TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
if(DEBUG)
|
|
|
|
{
|
|
|
|
$error = $db->sql_error();
|
|
|
|
error_die(QUERY_ERROR, "Error inserting data into topics text table.<br>Reason: ".$error['message']."<br>Query: $sql", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error_die(QUERY_ERROR);
|
|
|
|
}
|
2001-05-25 07:02:48 +00:00
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
}
|
|
|
|
else if(isset($HTTP_POST_VARS['preview']))
|
|
|
|
{
|
2001-05-25 07:02:48 +00:00
|
|
|
|
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
}
|
2001-06-03 23:10:07 +00:00
|
|
|
|
2001-05-27 16:41:33 +00:00
|
|
|
break;
|
2001-05-26 00:25:50 +00:00
|
|
|
|
|
|
|
case 'reply':
|
|
|
|
$page_title = " $l_reply";
|
|
|
|
$section_title = $l_postreplyto;
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-06-11 00:58:08 +00:00
|
|
|
if(isset($HTTP_POST_VARS['submit']) && !$error && !$preview)
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
2001-05-29 19:43:21 +00:00
|
|
|
if($SQL_LAYER != "mysql")
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("BEGIN");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("BEGIN TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
}
|
|
|
|
|
2001-06-11 00:58:08 +00:00
|
|
|
if($username)
|
|
|
|
{
|
|
|
|
$username = addslashes($username);
|
|
|
|
}
|
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
$new_topic_id = $HTTP_POST_VARS[POST_TOPIC_URL];
|
|
|
|
$topic_time = get_gmt_ts();
|
|
|
|
|
2001-06-11 20:02:01 +00:00
|
|
|
$sql = "INSERT INTO ".POSTS_TABLE." (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, bbcode_uid)
|
|
|
|
VALUES ($new_topic_id, $forum_id, ".$userdata['user_id'].", '".$username."', $topic_time, '$user_ip', '$uid')";
|
2001-05-26 00:25:50 +00:00
|
|
|
|
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$new_post_id = $db->sql_nextid();
|
2001-05-27 03:11:27 +00:00
|
|
|
$sql = "INSERT INTO ".POSTS_TEXT_TABLE." (post_id, post_subject, post_text) VALUES ($new_post_id, '".$subject."', '".$message."')";
|
2001-05-26 00:25:50 +00:00
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$sql = "UPDATE ".TOPICS_TABLE." SET topic_last_post_id = $new_post_id, topic_replies = topic_replies + 1 WHERE topic_id = $new_topic_id";
|
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$sql = "UPDATE ".FORUMS_TABLE." SET forum_last_post_id = $new_post_id, forum_posts = forum_posts + 1 WHERE forum_id = $forum_id";
|
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
|
|
|
if($userdata['user_id'] != ANONYMOUS)
|
|
|
|
{
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
$sql = "UPDATE ".USERS_TABLE." SET user_posts = user_posts + 1 WHERE user_id = ".$userdata['user_id'];
|
|
|
|
$db->sql_query($sql);
|
|
|
|
}
|
|
|
|
include('includes/page_header.'.$phpEx);
|
2001-05-29 19:43:21 +00:00
|
|
|
//
|
2001-05-26 00:25:50 +00:00
|
|
|
// If we get here the post has been inserted successfully.
|
2001-05-29 19:43:21 +00:00
|
|
|
//
|
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("COMMIT");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("COMMIT TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
if(!$result)
|
|
|
|
{
|
|
|
|
error_die(SQL_ERROR, "Couldn't commit");
|
|
|
|
}
|
|
|
|
}
|
2001-06-03 23:10:07 +00:00
|
|
|
|
2001-05-29 19:43:21 +00:00
|
|
|
$msg = "$l_stored<br /><br />$l_click <a href=\"".append_sid("viewtopic.$phpEx?".POST_POST_URL."=$new_post_id#$new_post_id")."\">$l_here</a>$l_viewmsg<br /><br />$l_click <a href=\"".append_sid("viewforum.$phpEx?".POST_FORUM_URL."=$forum_id")."\">$l_here</a> $l_returntopic";
|
2001-05-26 00:25:50 +00:00
|
|
|
|
|
|
|
$template->set_filenames(array(
|
|
|
|
"reg_header" => "error_body.tpl"
|
|
|
|
));
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"ERROR_MESSAGE" => $msg
|
|
|
|
));
|
|
|
|
$template->pparse("reg_header");
|
|
|
|
|
|
|
|
include('includes/page_tail.'.$phpEx);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-29 19:43:21 +00:00
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("ROLLBACK");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("ROLLBACK TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
}
|
2001-05-26 00:25:50 +00:00
|
|
|
error_die(QUERY_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("ROLLBACK");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("ROLLBACK TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
}
|
2001-05-26 00:25:50 +00:00
|
|
|
if(DEBUG)
|
|
|
|
{
|
|
|
|
$error = $db->sql_error();
|
|
|
|
error_die(QUERY_ERROR, "Error updating topics table.<br>Reason: ".$error['message']."<br>Query: $sql", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error_die(QUERY_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-29 19:43:21 +00:00
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("ROLLBACK");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("ROLLBACK TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
}
|
2001-05-26 00:25:50 +00:00
|
|
|
if(DEBUG)
|
|
|
|
{
|
|
|
|
$error = $db->sql_error();
|
|
|
|
error_die(QUERY_ERROR, "Error inserting data into posts text table.<br>Reason: ".$error['message']."<br>Query: $sql", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error_die(QUERY_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-29 19:43:21 +00:00
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
2001-05-30 20:35:36 +00:00
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("ROLLBACK");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("ROLLBACK TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 19:43:21 +00:00
|
|
|
}
|
2001-05-26 00:25:50 +00:00
|
|
|
if(DEBUG)
|
|
|
|
{
|
|
|
|
$error = $db->sql_error();
|
|
|
|
error_die(QUERY_ERROR, "Error inserting data into posts table.<br>Reason: ".$error['message']."<br>Query: $sql", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error_die(QUERY_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2001-05-27 16:41:33 +00:00
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
case 'editpost':
|
|
|
|
$page_title = " $l_editpost";
|
|
|
|
$section_title = $l_editpostin;
|
2001-06-11 00:58:08 +00:00
|
|
|
if(isset($HTTP_POST_VARS['submit']) && !$error && !$preview)
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
|
|
|
if(isset($HTTP_POST_VARS['delete_post']))
|
|
|
|
{
|
2001-05-27 03:11:27 +00:00
|
|
|
|
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-27 03:11:27 +00:00
|
|
|
$post_id = $HTTP_POST_VARS[POST_POST_URL];
|
|
|
|
$new_topic_id = $HTTP_POST_VARS[POST_TOPIC_URL];
|
2001-06-11 20:02:01 +00:00
|
|
|
|
|
|
|
if($SQL_LAYER != "mysql")
|
|
|
|
{
|
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("BEGIN");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("BEGIN TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-27 03:11:27 +00:00
|
|
|
$sql = "UPDATE ".POSTS_TEXT_TABLE." SET post_text = '$message', post_subject = '$subject' WHERE post_id = ".$HTTP_POST_VARS[POST_POST_URL];
|
|
|
|
if($db->sql_query($sql))
|
|
|
|
{
|
|
|
|
if($is_first_post)
|
|
|
|
{
|
|
|
|
// Update topics table here, set notification level and such
|
2001-06-11 20:02:01 +00:00
|
|
|
$sql = "UPDATE ".TOPICS_TABLE." SET topic_title = '$subject', topic_notify = '$notify' WHERE topic_id = ".$HTTP_POST_VARS[POST_TOPIC_URL];
|
|
|
|
if(!$db->sql_query($sql))
|
|
|
|
{
|
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("ROLLBACK");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("ROLLBACK TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(DEBUG)
|
|
|
|
{
|
|
|
|
$error = $db->sql_error();
|
|
|
|
error_die(QUERY_ERROR, "Updating topics table.<br>Reason: ".$error['message']."<br>Query: $sql", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error_die(QUERY_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("COMMIT");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("COMMIT TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(!$result)
|
|
|
|
{
|
|
|
|
error_die(SQL_ERROR, "Couldn't commit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
include('includes/page_header.'.$phpEx);
|
|
|
|
// If we get here the post has been inserted successfully.
|
|
|
|
$msg = "$l_stored<br /><br />$l_click <a href=\"".append_sid("viewtopic.$phpEx?".POST_POST_URL."=$post_id#$post_id")."\">$l_here</a>
|
|
|
|
$l_viewmsg<br /><br />$l_click <a href=\"".append_sid("viewforum.$phpEx?".POST_FORUM_URL."=$forum_id")."\">$l_here</a> $l_returntopic";
|
|
|
|
|
|
|
|
$template->set_filenames(array(
|
|
|
|
"reg_header" => "error_body.tpl"
|
|
|
|
));
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"ERROR_MESSAGE" => $msg
|
|
|
|
));
|
|
|
|
$template->pparse("reg_header");
|
|
|
|
|
|
|
|
include('includes/page_tail.'.$phpEx);
|
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-06-11 20:02:01 +00:00
|
|
|
if(SQL_LAYER != "mysql")
|
|
|
|
{
|
|
|
|
switch($SQL_LAYER)
|
|
|
|
{
|
|
|
|
case 'postgres':
|
|
|
|
$result = $db->sql_query("COMMIT");
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
$result = $db->sql_query("COMMIT TRANSACTION");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(!$result)
|
|
|
|
{
|
|
|
|
error_die(SQL_ERROR, "Couldn't commit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-27 03:11:27 +00:00
|
|
|
include('includes/page_header.'.$phpEx);
|
|
|
|
// If we get here the post has been inserted successfully.
|
2001-05-29 19:43:21 +00:00
|
|
|
$msg = "$l_stored<br /><br />$l_click <a href=\"".append_sid("viewtopic.$phpEx?".POST_POST_URL."=$post_id#$post_id")."\">$l_here</a>
|
|
|
|
$l_viewmsg<br /><br />$l_click <a href=\"".append_sid("viewforum.$phpEx?".POST_FORUM_URL."=$forum_id")."\">$l_here</a> $l_returntopic";
|
2001-05-27 03:11:27 +00:00
|
|
|
|
|
|
|
$template->set_filenames(array(
|
|
|
|
"reg_header" => "error_body.tpl"
|
|
|
|
));
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"ERROR_MESSAGE" => $msg
|
|
|
|
));
|
|
|
|
$template->pparse("reg_header");
|
|
|
|
|
|
|
|
include('includes/page_tail.'.$phpEx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(DEBUG)
|
|
|
|
{
|
|
|
|
$error = $db->sql_error();
|
|
|
|
error_die(QUERY_ERROR, "Error updateing posts text table.<br>Reason: ".$error['message']."<br>Query: $sql", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error_die(QUERY_ERROR);
|
|
|
|
}
|
|
|
|
}
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
}
|
2001-06-11 00:58:08 +00:00
|
|
|
else if(!$preview)
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
|
|
|
$post_id = ($HTTP_GET_VARS[POST_POST_URL]) ? $HTTP_GET_VARS[POST_POST_URL] : $HTTP_POST_VARS[POST_POST_URL];
|
|
|
|
if(!empty($post_id))
|
|
|
|
{
|
|
|
|
|
2001-05-27 03:11:27 +00:00
|
|
|
$sql = "SELECT p.*, pt.post_text, pt.post_subject, u.username, u.user_id, u.user_sig, t.topic_title, t.topic_notify
|
|
|
|
FROM ".POSTS_TABLE." p, ".USERS_TABLE." u, ".TOPICS_TABLE." t, ".POSTS_TEXT_TABLE." pt
|
|
|
|
WHERE (p.post_id = '$post_id')
|
2001-05-27 16:41:33 +00:00
|
|
|
AND pt.post_id = p.post_id
|
|
|
|
AND (p.topic_id = t.topic_id)
|
|
|
|
AND (p.poster_id = u.user_id)";
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
if($result = $db->sql_query($sql))
|
|
|
|
{
|
2001-06-04 00:14:26 +00:00
|
|
|
$postrow = $db->sql_fetchrow($result);
|
|
|
|
|
|
|
|
if($userdata['user_id'] != $postrow['user_id'] && !$is_auth['auth_mod'])
|
|
|
|
{
|
|
|
|
include('includes/page_header.'.$phpEx);
|
|
|
|
|
|
|
|
$msg = "Sorry but you can only edit your own posts.";
|
|
|
|
|
|
|
|
$template->set_filenames(array(
|
|
|
|
"reg_header" => "error_body.tpl"
|
|
|
|
));
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"ERROR_MESSAGE" => $msg
|
|
|
|
));
|
|
|
|
$template->pparse("reg_header");
|
|
|
|
|
|
|
|
include('includes/page_tail.'.$phpEx);
|
|
|
|
}
|
|
|
|
|
|
|
|
$subject = stripslashes($postrow['post_subject']);
|
|
|
|
$message = stripslashes($postrow['post_text']);
|
2001-05-27 03:11:27 +00:00
|
|
|
if(eregi("\[addsig]$", $message))
|
|
|
|
{
|
|
|
|
$attach_sig = TRUE;
|
|
|
|
}
|
|
|
|
$message = eregi_replace("\[addsig]$", "", $message);
|
2001-05-26 00:25:50 +00:00
|
|
|
$message = str_replace("<br />", "\n", $message);
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
// These have not been implemented yet!
|
|
|
|
/*
|
|
|
|
$message = bbdecode($message);
|
|
|
|
$message = desmile($message);
|
|
|
|
*/
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
$message = undo_htmlspecialchars($message);
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
// Special handling for </textarea> tags in the message, which can break the editing form..
|
|
|
|
$message = preg_replace('#</textarea>#si', '</TEXTAREA>', $message);
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
// is_first_post needs functionality!
|
2001-06-04 00:14:26 +00:00
|
|
|
if($postrow['topic_notify'] && $is_first_post)
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
|
|
|
$notify = TRUE;
|
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
if($is_first_post)
|
|
|
|
{
|
2001-06-04 00:14:26 +00:00
|
|
|
$subject = stripslashes($postrow['topic_title']);
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(DEBUG)
|
|
|
|
{
|
|
|
|
$error = $db->error();
|
|
|
|
error_die(QUERY_ERROR, "Error get post information. <br>Reason: ".$error['message']."<br>Query: $sql", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error_die(QUERY_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error_die(GENERAL_ERROR, "Sorry, no there is no such post");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} // end switch
|
|
|
|
|
2001-05-27 16:41:33 +00:00
|
|
|
//
|
|
|
|
// Output page
|
|
|
|
//
|
2001-05-26 00:25:50 +00:00
|
|
|
include('includes/page_header.'.$phpEx);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Start: Error handling
|
|
|
|
//
|
|
|
|
if($error)
|
|
|
|
{
|
|
|
|
$template->set_filenames(array(
|
2001-05-27 16:41:33 +00:00
|
|
|
"reg_header" => "error_body.tpl"
|
2001-05-26 00:25:50 +00:00
|
|
|
));
|
|
|
|
$template->assign_vars(array(
|
2001-05-27 16:41:33 +00:00
|
|
|
"ERROR_MESSAGE" => $error_msg
|
2001-05-26 00:25:50 +00:00
|
|
|
));
|
|
|
|
$template->pparse("reg_header");
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// End: error handling
|
|
|
|
//
|
|
|
|
|
2001-06-11 12:00:31 +00:00
|
|
|
if(empty($username))
|
2001-06-11 00:58:08 +00:00
|
|
|
{
|
2001-06-11 12:00:31 +00:00
|
|
|
$username = $userdata['username'];
|
2001-06-11 00:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Start: Preview Post
|
|
|
|
//
|
|
|
|
if($preview)
|
|
|
|
{
|
|
|
|
$preview_message = $message;
|
|
|
|
$uid = make_bbcode_uid();
|
|
|
|
$preview_message = prepare_message($preview_message, TRUE, TRUE, TRUE, $uid);
|
|
|
|
$preview_message = bbencode_second_pass($preview_message, $uid);
|
|
|
|
$preview_message = make_clickable($preview_message);
|
|
|
|
|
|
|
|
$template->set_filenames(array("preview" => "posting_preview.tpl"));
|
|
|
|
$template->assign_vars(array(
|
2001-06-11 12:00:31 +00:00
|
|
|
"TOPIC_TITLE" => $subject,
|
|
|
|
"POST_SUBJECT" => $subject,
|
|
|
|
"ROW_COLOR" => "#" . $theme['td_color1'],
|
2001-06-11 00:58:08 +00:00
|
|
|
"POSTER_NAME" => $username,
|
|
|
|
"POST_DATE" => create_date($board_config['default_dateformat'], time(), $board_config['default_timezone']),
|
2001-06-11 12:00:31 +00:00
|
|
|
"MESSAGE" => stripslashes(nl2br($preview_message)),
|
|
|
|
|
|
|
|
"L_PREVIEW" => $lang['Preview'],
|
|
|
|
"L_POSTED" => $lang['Posted'])
|
|
|
|
);
|
2001-06-11 00:58:08 +00:00
|
|
|
$template->pparse("preview");
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// End: Preview Post
|
|
|
|
//
|
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
//
|
|
|
|
// Show the same form for each mode.
|
|
|
|
//
|
2001-06-11 20:02:01 +00:00
|
|
|
|
|
|
|
if(!isset($HTTP_GET_VARS[POST_FORUM_URL]) && !isset($HTTP_POST_VARS[POST_FORUM_URL]))
|
|
|
|
{
|
|
|
|
error_die(GENERAL_ERROR, "Sorry, no there is no such forum");
|
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
|
2001-06-03 23:10:07 +00:00
|
|
|
$sql = "SELECT forum_name
|
2001-05-25 07:02:48 +00:00
|
|
|
FROM ".FORUMS_TABLE."
|
2001-05-25 00:56:07 +00:00
|
|
|
WHERE forum_id = $forum_id";
|
|
|
|
if(!$result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
error_die(SQL_QUERY, "Could not obtain forum/forum access information.", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
$forum_info = $db->sql_fetchrow($result);
|
|
|
|
$forum_name = stripslashes($forum_info['forum_name']);
|
|
|
|
|
|
|
|
$template->set_filenames(array(
|
2001-05-27 16:41:33 +00:00
|
|
|
"body" => "posting_body.tpl",
|
|
|
|
"jumpbox" => "jumpbox.tpl")
|
|
|
|
);
|
2001-05-25 00:56:07 +00:00
|
|
|
$jumpbox = make_jumpbox();
|
|
|
|
$template->assign_vars(array(
|
2001-05-27 16:41:33 +00:00
|
|
|
"JUMPBOX_LIST" => $jumpbox,
|
|
|
|
"SELECT_NAME" => POST_FORUM_URL)
|
|
|
|
);
|
2001-05-25 00:56:07 +00:00
|
|
|
$template->assign_var_from_handle("JUMPBOX", "jumpbox");
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
$template->assign_vars(array(
|
2001-05-27 16:41:33 +00:00
|
|
|
"FORUM_ID" => $forum_id,
|
|
|
|
"FORUM_NAME" => $forum_name,
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2001-06-11 12:00:31 +00:00
|
|
|
"L_POSTNEWIN" => $section_title,
|
|
|
|
|
2001-05-27 16:41:33 +00:00
|
|
|
"U_VIEW_FORUM" => append_sid("viewforum.$phpEx?".POST_FORUM_URL."=$forum_id"))
|
|
|
|
);
|
2001-05-26 00:25:50 +00:00
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
if($userdata['session_logged_in'])
|
|
|
|
{
|
|
|
|
$username_input = $userdata["username"];
|
|
|
|
$password_input = "";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-06-11 12:00:31 +00:00
|
|
|
$username_input = '<input type="text" name="username" value="' . $username . '" size="25" maxlength="50">';
|
2001-05-25 00:56:07 +00:00
|
|
|
$password_input = '<input type="password" name="password" size="25" maxlenght="40">';
|
|
|
|
}
|
2001-06-11 12:00:31 +00:00
|
|
|
$subject_input = '<input type="text" name="subject" value="'.$subject.'" size="50" maxlength="255">';
|
|
|
|
$message_input = '<textarea name="message" rows="10" cols="40" wrap="virtual">'.$message.'</textarea>';
|
2001-05-27 16:41:33 +00:00
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
if($board_config['allow_html'])
|
|
|
|
{
|
|
|
|
$html_status = $l_htmlis . " " . $l_on;
|
|
|
|
$html_toggle = '<input type="checkbox" name="disable_html" ';
|
2001-05-27 18:08:02 +00:00
|
|
|
if($disable_html)
|
2001-03-09 23:33:06 +00:00
|
|
|
{
|
2001-05-25 00:56:07 +00:00
|
|
|
$html_toggle .= 'checked';
|
2001-03-09 23:33:06 +00:00
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
$html_toggle .= "> $l_disable $l_html $l_onthispost";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$html_status = $l_htmlis . " " . $l_off;
|
|
|
|
}
|
2001-05-27 16:41:33 +00:00
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
if($board_config['allow_bbcode'])
|
|
|
|
{
|
|
|
|
$bbcode_status = $l_bbcodeis . " " . $l_on;
|
|
|
|
$bbcode_toggle = '<input type="checkbox" name="disable_bbcode" ';
|
2001-05-27 18:08:02 +00:00
|
|
|
if($disable_bbcode)
|
2001-03-09 23:33:06 +00:00
|
|
|
{
|
2001-05-25 00:56:07 +00:00
|
|
|
$bbcode_toggle .= "checked";
|
2001-03-09 23:33:06 +00:00
|
|
|
}
|
2001-05-25 00:56:07 +00:00
|
|
|
$bbcode_toggle .= "> $l_disable $l_bbcode $l_onthispost";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$bbcode_status = $l_bbcodeis . " " . $l_off;
|
|
|
|
}
|
|
|
|
|
2001-05-27 16:41:33 +00:00
|
|
|
if($board_config['allow_smilies'])
|
2001-05-25 00:56:07 +00:00
|
|
|
{
|
2001-05-27 16:41:33 +00:00
|
|
|
$smile_toggle = '<input type="checkbox" name="disable_smile" ';
|
2001-05-27 18:08:02 +00:00
|
|
|
if($disable_smilies)
|
2001-05-27 16:41:33 +00:00
|
|
|
{
|
|
|
|
$smile_toggle .= "checked";
|
|
|
|
}
|
|
|
|
$smile_toggle .= "> $l_disable $l_smilies $l_onthispost";
|
2001-05-25 00:56:07 +00:00
|
|
|
}
|
|
|
|
|
2001-05-27 03:11:27 +00:00
|
|
|
$sig_toggle = '<input type="checkbox" name="attach_sig" ';
|
2001-05-27 18:08:02 +00:00
|
|
|
if($attach_sig)
|
2001-05-25 00:56:07 +00:00
|
|
|
{
|
2001-05-27 03:11:27 +00:00
|
|
|
$sig_toggle .= "checked";
|
2001-05-25 00:56:07 +00:00
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
$sig_toggle .= "> $l_attachsig";
|
|
|
|
|
2001-06-07 07:56:45 +00:00
|
|
|
if($mode == 'newtopic')
|
|
|
|
{
|
|
|
|
if($is_auth['auth_announce'])
|
|
|
|
{
|
|
|
|
$annouce_toggle = '<input type="checkbox" name="annouce" ';
|
|
|
|
if($annouce)
|
|
|
|
{
|
|
|
|
$announce_toggle .= "checked";
|
|
|
|
}
|
|
|
|
$annouce_toggle .= '> '.$lang['Post_Annoucement'];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($is_auth['auth_sticky'])
|
|
|
|
{
|
|
|
|
$sticky_toggle = '<input type="checkbox" name="sticky" ';
|
|
|
|
if($sticky)
|
|
|
|
{
|
|
|
|
$sticky_toggle .= "checked";
|
|
|
|
}
|
|
|
|
$sticky_toggle .= '> '.$lang['Post_Sticky'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
if($mode == 'newtopic' || ($mode == 'editpost' && $notify))
|
2001-05-25 00:56:07 +00:00
|
|
|
{
|
2001-05-26 00:25:50 +00:00
|
|
|
$notify_toggle = '<input type="checkbox" name="notify" ';
|
2001-05-27 18:08:02 +00:00
|
|
|
if($notify)
|
2001-05-26 00:25:50 +00:00
|
|
|
{
|
|
|
|
$notify_toggle .= "checked";
|
|
|
|
}
|
|
|
|
$notify_toggle .= "> $l_notify";
|
2001-05-25 00:56:07 +00:00
|
|
|
}
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
if($mode == 'reply' || $mode == 'editpost')
|
|
|
|
{
|
|
|
|
$topic_id = ($HTTP_GET_VARS[POST_TOPIC_URL]) ? $HTTP_GET_VARS[POST_TOPIC_URL] : $HTTP_POST_VARS[POST_TOPIC_URL];
|
2001-05-27 03:11:27 +00:00
|
|
|
$post_id = ($HTTP_GET_VARS[POST_POST_URL]) ? $HTTP_GET_VARS[POST_POST_URL] : $HTTP_POST_VARS[POST_POST_URL];
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
2001-06-11 20:02:01 +00:00
|
|
|
$hidden_form_fields = "<input type=\"hidden\" name=\"mode\" value=\"$mode\"><input type=\"hidden\" name=\"".POST_FORUM_URL."\" value=\"$forum_id\"><input type=\"hidden\" name=\"".POST_TOPIC_URL."\" value=\"$topic_id\"><input type=\"hidden\" name=\"".POST_POST_URL."\" value=\"$post_id\"><input type=\"hidden\" name=\"is_first_post\" value=\"$is_first_post\">";
|
2001-05-06 16:58:36 +00:00
|
|
|
|
2001-06-11 20:02:01 +00:00
|
|
|
if($mode == 'newtopic')
|
|
|
|
{
|
|
|
|
$post_a = $lang['Post_a'] . " " . $lang['Topic'];
|
|
|
|
}
|
|
|
|
else if($mode == 'reply')
|
|
|
|
{
|
|
|
|
$post_a = $lang['Post_a'] . " " . $lang['Reply'];
|
|
|
|
}
|
|
|
|
else if($mode == 'editpost')
|
|
|
|
{
|
|
|
|
$post_a = $lang['Edit_Post'];
|
|
|
|
}
|
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
$template->assign_vars(array(
|
2001-05-27 16:41:33 +00:00
|
|
|
"L_SUBJECT" => $l_subject,
|
|
|
|
"L_MESSAGE_BODY" => $l_body,
|
|
|
|
"L_OPTIONS" => $l_options,
|
2001-06-11 12:00:31 +00:00
|
|
|
"L_PREVIEW" => $lang['Preview'],
|
2001-05-27 16:41:33 +00:00
|
|
|
"L_SUBMIT" => $l_submit,
|
|
|
|
"L_CANCEL" => $l_cancelpost,
|
2001-06-11 20:02:01 +00:00
|
|
|
"L_POST_A" => $post_a,
|
2001-05-27 16:41:33 +00:00
|
|
|
"USERNAME_INPUT" => $username_input,
|
|
|
|
"PASSWORD_INPUT" => $password_input,
|
|
|
|
"SUBJECT_INPUT" => $subject_input,
|
|
|
|
"MESSAGE_INPUT" => $message_input,
|
|
|
|
"HTML_STATUS" => $html_status,
|
|
|
|
"HTML_TOGGLE" => $html_toggle,
|
|
|
|
"SMILE_TOGGLE" => $smile_toggle,
|
|
|
|
"SIG_TOGGLE" => $sig_toggle,
|
2001-06-07 07:56:45 +00:00
|
|
|
"ANNOUNCE_TOGGLE" => $annouce_toggle,
|
|
|
|
"STICKY_TOGGLE" => $sticky_toggle,
|
2001-05-27 16:41:33 +00:00
|
|
|
"NOTIFY_TOGGLE" => $notify_toggle,
|
|
|
|
"BBCODE_TOGGLE" => $bbcode_toggle,
|
|
|
|
"BBCODE_STATUS" => $bbcode_status,
|
|
|
|
|
|
|
|
"S_POST_ACTION" => append_sid("posting.$phpEx"),
|
|
|
|
"S_HIDDEN_FORM_FIELDS" => $hidden_form_fields)
|
2001-05-25 00:56:07 +00:00
|
|
|
);
|
2001-05-27 16:41:33 +00:00
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
$template->pparse("body");
|
2001-05-27 16:41:33 +00:00
|
|
|
|
2001-05-25 00:56:07 +00:00
|
|
|
include('includes/page_tail.'.$phpEx);
|
2001-05-26 00:25:50 +00:00
|
|
|
?>
|