mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 14:48:53 +00:00
Got started on the posting functions. Can post new topics as Anonymous, yay!
git-svn-id: file:///svn/phpbb/trunk@323 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
f3b1ccdebc
commit
48312a6566
2 changed files with 280 additions and 123 deletions
|
@ -23,6 +23,7 @@
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
include('extension.inc');
|
include('extension.inc');
|
||||||
include('common.'.$phpEx);
|
include('common.'.$phpEx);
|
||||||
|
include('includes/bbcode.'.$phpEx);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Obtain which forum id is required
|
// Obtain which forum id is required
|
||||||
|
@ -46,40 +47,196 @@ init_userprefs($userdata);
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Nothing in this file is set, lots of things
|
// Posting specific functions.
|
||||||
// will change to meet coding standards and new
|
|
||||||
// posting code ...
|
|
||||||
//
|
//
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// End Posting specific functions.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Put AUTH code here
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
switch($mode)
|
switch($mode)
|
||||||
{
|
{
|
||||||
case 'newtopic':
|
case 'newtopic':
|
||||||
echo "Dave likes to submit<br>";
|
if(isset($HTTP_POST_VARS['submit']))
|
||||||
|
{
|
||||||
|
if(isset($HTTP_POST_VARS['disable_html']) || !$board_config['allow_html'])
|
||||||
|
{
|
||||||
|
$html_on = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$html_on = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
if(isset($HTTP_POST_VARS['disable_bbcode']) || !$board_config['allow_bbcode'])
|
||||||
case 'reply':
|
{
|
||||||
|
$bbcode_on = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$uid = make_bbcode_uid();
|
||||||
|
$bbocde_on = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
if(isset($HTTP_POST_VARS['disable_smile']))
|
||||||
case 'editpost':
|
{
|
||||||
|
$smile_on = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$smile_on = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
$message = prepare_message($HTTP_POST_VARS['message'], $html_on, $bbocde_on, $smile_on, $uid);
|
||||||
|
|
||||||
|
if(isset($HTTP_POST_VARS['attach_sig']) && !empty($userdata['user_sig']))
|
||||||
|
{
|
||||||
|
$message .= "[addsig]";
|
||||||
|
}
|
||||||
|
$subject = trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['subject'])));
|
||||||
|
$topic_time = gmmktime(date("h, i, s, m, d, Y"));
|
||||||
|
$topic_notify = ($HTTP_POST_VARS['notify']) ? $HTTP_POST_VARS['notify'] : 0;
|
||||||
|
$sql = "INSERT INTO ".TOPICS_TABLE." (topic_title, topic_poster, topic_time, forum_id, topic_notify, topic_status)
|
||||||
|
VALUES ('$subject', ".$userdata['user_id'].", ".$topic_time.", $forum_id, $topic_notify, ".UNLOCKED.")";
|
||||||
|
|
||||||
|
if($db->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<br />$l_click <a href=\"".append_sid("viewtopic.$phpEx?".POST_TOPIC_URL."=$new_topic_id")."\">$l_here</a>
|
||||||
|
$l_viewmsg<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);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error_die(QUERY_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(DEBUG)
|
||||||
switch($mode)
|
|
||||||
{
|
{
|
||||||
case 'newtopic':
|
$error = $db->sql_error();
|
||||||
if(!isset($HTTP_GET_VARS[POST_FORUM_URL]))
|
error_die(QUERY_ERROR, "Error updating topics table.<br>Reason: ".$error['message']."<br>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.<br>Reason: ".$error['message']."<br>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.<br>Reason: ".$error['message']."<br>Query: $sql", __LINE__, __FILE__);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error_die(QUERY_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
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");
|
error_die(GENERAL_ERROR, "Sorry, no there is no such forum");
|
||||||
}
|
}
|
||||||
|
|
||||||
$pagetype = "newtopic";
|
$pagetype = "newtopic";
|
||||||
$page_title = " $l_postnew";
|
$page_title = " $l_postnew";
|
||||||
|
|
||||||
$sql = "SELECT forum_name, forum_access
|
$sql = "SELECT forum_name, forum_access
|
||||||
FROM ".FORUMS_TABLE."
|
FROM ".FORUMS_TABLE."
|
||||||
WHERE forum_id = $forum_id";
|
WHERE forum_id = $forum_id";
|
||||||
|
@ -140,7 +297,7 @@ else
|
||||||
}
|
}
|
||||||
$subject_input = '<input type="text" name="subject" value="'.$subject.'" size="50" maxlenght="255">';
|
$subject_input = '<input type="text" name="subject" value="'.$subject.'" size="50" maxlenght="255">';
|
||||||
$message_input = '<textarea name="message" rows="10" cols="35" wrap="virtual">'.$message.'</textarea>';
|
$message_input = '<textarea name="message" rows="10" cols="35" wrap="virtual">'.$message.'</textarea>';
|
||||||
if($allow_html)
|
if($board_config['allow_html'])
|
||||||
{
|
{
|
||||||
$html_status = $l_htmlis . " " . $l_on;
|
$html_status = $l_htmlis . " " . $l_on;
|
||||||
$html_toggle = '<input type="checkbox" name="disable_html" ';
|
$html_toggle = '<input type="checkbox" name="disable_html" ';
|
||||||
|
@ -154,7 +311,7 @@ else
|
||||||
{
|
{
|
||||||
$html_status = $l_htmlis . " " . $l_off;
|
$html_status = $l_htmlis . " " . $l_off;
|
||||||
}
|
}
|
||||||
if($allow_bbcode)
|
if($board_config['allow_bbcode'])
|
||||||
{
|
{
|
||||||
$bbcode_status = $l_bbcodeis . " " . $l_on;
|
$bbcode_status = $l_bbcodeis . " " . $l_on;
|
||||||
$bbcode_toggle = '<input type="checkbox" name="disable_bbcode" ';
|
$bbcode_toggle = '<input type="checkbox" name="disable_bbcode" ';
|
||||||
|
@ -190,7 +347,7 @@ else
|
||||||
}
|
}
|
||||||
$notify_toggle .= "> $l_notify";
|
$notify_toggle .= "> $l_notify";
|
||||||
|
|
||||||
$hidden_form_fields = "<input type=\"hidden\" name=\"mode\" value=\"$mode\"><input type=\"hidden\" name=\"forum_id\" value=\"$forum_id\"><input type=\"hidden\" name=\"topic_id\" value=\"$topic_id\">";
|
$hidden_form_fields = "<input type=\"hidden\" name=\"mode\" value=\"$mode\"><input type=\"hidden\" name=\"".POST_FORUM_URL."\" value=\"$forum_id\"><input type=\"hidden\" name=\"topic_id\" value=\"$topic_id\">";
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
"L_ABOUT_POST" => $l_aboutpost,
|
"L_ABOUT_POST" => $l_aboutpost,
|
||||||
|
@ -227,7 +384,6 @@ else
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -46,7 +46,8 @@
|
||||||
{HTML_TOGGLE}<br>{BBCODE_TOGGLE}<br>{SMILE_TOGGLE}<br>{SIG_TOGGLE}<br>{NOTIFY_TOGGLE}</td>
|
{HTML_TOGGLE}<br>{BBCODE_TOGGLE}<br>{SMILE_TOGGLE}<br>{SIG_TOGGLE}<br>{NOTIFY_TOGGLE}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="tableheader">
|
<tr class="tableheader">
|
||||||
<td align="center" colspan="2">{S_HIDDEN_POST_FIELDS}<input type="submit" name="preview" value="{L_PREVIEW}"> <input type="submit" name="submit" value="{L_SUBMIT}"> <input type="submit" name="cancel" value="{L_CANCEL}"></td>
|
<td align="center" colspan="2">{S_HIDDEN_FORM_FIELDS}
|
||||||
|
<input type="submit" name="preview" value="{L_PREVIEW}"> <input type="submit" name="submit" value="{L_SUBMIT}"> <input type="submit" name="cancel" value="{L_CANCEL}"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Add table
Reference in a new issue