diff --git a/phpBB/posting.php b/phpBB/posting.php
index d64bfbc830..9b73e1553d 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -23,6 +23,7 @@
***************************************************************************/
include('extension.inc');
include('common.'.$phpEx);
+include('includes/bbcode.'.$phpEx);
//
// Obtain which forum id is required
@@ -46,153 +47,309 @@ init_userprefs($userdata);
//
//
-// Nothing in this file is set, lots of things
-// will change to meet coding standards and new
-// posting code ...
-//
+// Posting specific functions.
+//
-if($submit && !$preview)
+// This function will prepare the message for entry into the database.
+function prepare_message($message, $html_on, $bbocde_on, $smile_on, $bbcode_uid = 0)
{
- switch($mode)
- {
- case 'newtopic':
- echo "Dave likes to submit
";
+ $message = trim($message);
+
+ if(!$html_on)
+ {
+ $message = htmlspecialchars($message);
+ }
+
+ if($bbocde_on)
+ {
+ $message = bbencode_first_pass($message, $bbcode_uid);
+ }
+
+ if($smile_on)
+ {
+ // No smile() function yet, write one...
+ //$message = smile($message);
+ }
+
+ $message = addslashes($message);
+ return($message);
+}
- break;
- case 'reply':
- break;
- case 'editpost':
+//
+// End Posting specific functions.
+//
- break;
- }
-}
-else
+
+//
+// Put AUTH code here
+//
+
+
+switch($mode)
{
-
- switch($mode)
- {
- case 'newtopic':
- if(!isset($HTTP_GET_VARS[POST_FORUM_URL]))
+ case 'newtopic':
+ if(isset($HTTP_POST_VARS['submit']))
+ {
+ if(isset($HTTP_POST_VARS['disable_html']) || !$board_config['allow_html'])
{
- error_die(GENERAL_ERROR, "Sorry, no there is no such forum");
+ $html_on = FALSE;
}
-
- $pagetype = "newtopic";
- $page_title = " $l_postnew";
- $sql = "SELECT forum_name, forum_access
- FROM ".FORUMS_TABLE."
- WHERE forum_id = $forum_id";
- if(!$result = $db->sql_query($sql))
+ else
{
- error_die(SQL_QUERY, "Could not obtain forum/forum access information.", __LINE__, __FILE__);
+ $html_on = TRUE;
}
- $forum_info = $db->sql_fetchrow($result);
- $forum_name = stripslashes($forum_info['forum_name']);
- $forum_access = $forum_info['forum_access'];
-
- if($forum_access == ANONALLOWED)
- {
- $about_posting = "$l_anonusers $l_inthisforum $l_anonhint";
- }
- if($forum_access == REGONLY)
- {
- $about_posting = "$l_regusers $l_inthisforum";
- }
- if($forum_access == MODONLY)
- {
- $about_posting = "$l_modusers $l_inthisforum";
- }
-
- include('includes/page_header.'.$phpEx);
-
- $template->set_filenames(array(
- "body" => "posting_body.tpl",
- "jumpbox" => "jumpbox.tpl")
- );
- $jumpbox = make_jumpbox();
- $template->assign_vars(array(
- "JUMPBOX_LIST" => $jumpbox,
- "SELECT_NAME" => POST_FORUM_URL)
- );
- $template->assign_var_from_handle("JUMPBOX", "jumpbox");
- $template->assign_vars(array(
- "L_POSTNEWIN" => $l_postnewin,
- "FORUM_ID" => $forum_id,
- "FORUM_NAME" => $forum_name,
- "U_VIEW_FORUM" => append_sid("viewforum.$phpEx?".POST_FORUM_URL."=$forum_id"))
- );
-
- if($userdata['session_logged_in'])
+ if(isset($HTTP_POST_VARS['disable_bbcode']) || !$board_config['allow_bbcode'])
{
- $username_input = $userdata["username"];
- $password_input = "";
+ $bbcode_on = FALSE;
}
else
{
- if(!isset($username))
- {
- $username = $userdata["username"];
- }
- $username_input = '';
- $password_input = '';
+ $uid = make_bbcode_uid();
+ $bbocde_on = TRUE;
}
- $subject_input = '';
- $message_input = '';
- if($allow_html)
+
+ if(isset($HTTP_POST_VARS['disable_smile']))
{
- $html_status = $l_htmlis . " " . $l_on;
- $html_toggle = 'sql_query($sql))
+ {
+ $new_topic_id = $db->sql_nextid();
+ $sql = "INSERT INTO ".POSTS_TABLE." (topic_id, forum_id, poster_id, post_time, poster_ip, bbcode_uid)
+ VALUES ($new_topic_id, $forum_id, ".$userdata['user_id'].", $topic_time, '".encode_ip($user_ip)."', '$uid')";
+
+ if($db->sql_query($sql))
+ {
+ $new_post_id = $db->sql_nextid();
+ $sql = "INSERT INTO ".POSTS_TEXT_TABLE." VALUES ($new_post_id, '".$message."')";
+ 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))
+ {
+ include('includes/page_header.'.$phpEx);
+ // If we get here the post has been inserted successfully.
+ $msg = "$l_stored
$l_click $l_here
+ $l_viewmsg
$l_click $l_here $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);
+ }
+ else
+ {
+ error_die(QUERY_ERROR);
+ }
+ }
+ else
+ {
+ if(DEBUG)
+ {
+ $error = $db->sql_error();
+ error_die(QUERY_ERROR, "Error updating topics table.
Reason: ".$error['message']."
Query: $sql", __LINE__, __FILE__);
+ }
+ else
+ {
+ error_die(QUERY_ERROR);
+ }
+ }
+ }
+ else
+ {
+ if(DEBUG)
+ {
+ $error = $db->sql_error();
+ error_die(QUERY_ERROR, "Error inserting data into posts text table.
Reason: ".$error['message']."
Query: $sql", __LINE__, __FILE__);
+ }
+ else
+ {
+ error_die(QUERY_ERROR);
+ }
+ }
+ }
+ else
+ {
+ if(DEBUG)
+ {
+ $error = $db->sql_error();
+ error_die(QUERY_ERROR, "Error inserting data into posts table.
Reason: ".$error['message']."
Query: $sql", __LINE__, __FILE__);
+ }
+ else
+ {
+ error_die(QUERY_ERROR);
+ }
+ }
+ }
else
{
- $bbcode_status = $l_bbcodeis . " " . $l_off;
- }
+ if(DEBUG)
+ {
+ $error = $db->sql_error();
+ error_die(QUERY_ERROR, "Error inserting data into topics text table.
Reason: ".$error['message']."
Query: $sql", __LINE__, __FILE__);
+ }
+ else
+ {
+ error_die(QUERY_ERROR);
+ }
+ }
+
+
+
+ }
+ else if(isset($HTTP_POST_VARS['preview']))
+ {
+
+
+ }
+ 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");
+ }
- $smile_toggle = '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']);
+ $forum_access = $forum_info['forum_access'];
+
+ if($forum_access == ANONALLOWED)
+ {
+ $about_posting = "$l_anonusers $l_inthisforum $l_anonhint";
+ }
+ if($forum_access == REGONLY)
+ {
+ $about_posting = "$l_regusers $l_inthisforum";
+ }
+ if($forum_access == MODONLY)
+ {
+ $about_posting = "$l_modusers $l_inthisforum";
+ }
+
+ include('includes/page_header.'.$phpEx);
+
+ $template->set_filenames(array(
+ "body" => "posting_body.tpl",
+ "jumpbox" => "jumpbox.tpl")
+ );
+ $jumpbox = make_jumpbox();
+ $template->assign_vars(array(
+ "JUMPBOX_LIST" => $jumpbox,
+ "SELECT_NAME" => POST_FORUM_URL)
+ );
+ $template->assign_var_from_handle("JUMPBOX", "jumpbox");
+ $template->assign_vars(array(
+ "L_POSTNEWIN" => $l_postnewin,
+ "FORUM_ID" => $forum_id,
+ "FORUM_NAME" => $forum_name,
+
+ "U_VIEW_FORUM" => append_sid("viewforum.$phpEx?".POST_FORUM_URL."=$forum_id"))
+ );
+
+ if($userdata['session_logged_in'])
+ {
+ $username_input = $userdata["username"];
+ $password_input = "";
+ }
+ else
+ {
+ if(!isset($username))
{
- $smile_toggle .= "checked";
+ $username = $userdata["username"];
}
- $smile_toggle .= "> $l_disable $l_smilies $l_onthispost";
-
- $sig_toggle = '';
+ $password_input = '';
+ }
+ $subject_input = '';
+ $message_input = '';
+ if($board_config['allow_html'])
+ {
+ $html_status = $l_htmlis . " " . $l_on;
+ $html_toggle = '";
+ $smile_toggle = 'assign_vars(array(
+ $sig_toggle = '";
+
+ $template->assign_vars(array(
"L_ABOUT_POST" => $l_aboutpost,
"L_SUBJECT" => $l_subject,
"L_MESSAGE_BODY" => $l_body,
@@ -216,17 +373,16 @@ else
"S_POST_ACTION" => append_sid("posting.$phpEx"),
"S_HIDDEN_FORM_FIELDS" => $hidden_form_fields)
- );
- $template->pparse("body");
- include('includes/page_tail.'.$phpEx);
- break;
- case 'reply':
+ );
+ $template->pparse("body");
+ include('includes/page_tail.'.$phpEx);
+ break;
+ case 'reply':
- break;
- case 'editpost':
+ break;
+ case 'editpost':
- break;
- }
+ break;
}
diff --git a/phpBB/templates/Default/posting_body.tpl b/phpBB/templates/Default/posting_body.tpl
index 9256a4841c..3f80412609 100644
--- a/phpBB/templates/Default/posting_body.tpl
+++ b/phpBB/templates/Default/posting_body.tpl
@@ -46,7 +46,8 @@
{HTML_TOGGLE}
{BBCODE_TOGGLE}
{SMILE_TOGGLE}
{SIG_TOGGLE}
{NOTIFY_TOGGLE}