More work on posting. Editing now works. Also replies can have subjects.

git-svn-id: file:///svn/phpbb/trunk@336 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
James Atkinson 2001-05-27 03:11:27 +00:00
parent 1fc155f93d
commit 9889b8ba53
8 changed files with 214 additions and 138 deletions

View file

@ -108,6 +108,7 @@ else
$board_config['default_lang'] = stripslashes($config['default_lang']);
$board_config['board_email'] = stripslashes(str_replace("<br />", "\n", $config['email_sig']));
$board_config['board_email_from'] = stripslashes($config['email_from']);
$board_config['flood_interval'] = $config['flood_interval'];
}
include('language/lang_'.$board_config['default_lang'].'.'.$phpEx);

View file

@ -57,6 +57,7 @@ CREATE TABLE phpbb_config (
hot_threshold int(10),
email_sig varchar(255),
email_from varchar(100),
flood_interval int(4) NOT NULL,
default_theme int(11) DEFAULT '1' NOT NULL,
default_lang varchar(255),
default_dateformat varchar(14) DEFAULT 'd M Y H:i' NOT NULL,
@ -161,6 +162,7 @@ DROP TABLE IF EXISTS phpbb_posts_text;
CREATE TABLE phpbb_posts_text (
post_id int(10) DEFAULT '0' NOT NULL,
post_subject varchar(255),
post_text text,
PRIMARY KEY (post_id)
);

View file

@ -108,6 +108,7 @@ CREATE TABLE phpbb_config (
system_timezone int4 NOT NULL,
sys_template varchar(50) NOT NULL,
override_themes int2 NOT NULL,
flood_interval int NOT NULL,
selected int2 NOT NULL,
CONSTRAINT phpbb_config_pkey PRIMARY KEY (config_id)
);

View file

@ -276,7 +276,8 @@ function create_date($format, $gmepoch, $tz)
//
function get_gmt_ts()
{
return(gmmktime(gmdate("H, i, s, m, d, Y")));
$time = time();
return($time);
}
//

View file

@ -365,7 +365,10 @@ $l_htmlis = "$l_html is";
$l_bbcodeis = "$l_bbcode is";
$l_notify = "Notify by email when replies are posted";
// "
$l_flooderror = "Your last post was less then ".$board_config['flood_interval']." seconds ago. You must wait befor you post again!";
// Newtopic
$l_postnew = "Post New Topic";
$l_postnewin = "Post New Topic in:";

View file

@ -80,7 +80,6 @@ function prepare_message($message, $html_on, $bbocde_on, $smile_on, $bbcode_uid
// End Posting specific functions.
//
//
// Put AUTH code here
//
@ -92,6 +91,30 @@ $error = FALSE;
//
if(isset($HTTP_POST_VARS['submit']))
{
//
// Flood control
//
if($mode != 'editpost')
{
$enc_ip = encode_ip($user_ip);
$sql = "SELECT max(post_time) AS last_post_time FROM ".POSTS_TABLE." WHERE poster_ip = '$enc_ip'";
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;
$error_msg = $l_flooderror;
}
}
}
//
// End: Flood control
//
$subject = trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['subject'])));
if($mode == 'newtopic' && empty($subject))
{
@ -181,7 +204,7 @@ switch($mode)
if($db->sql_query($sql))
{
$new_post_id = $db->sql_nextid();
$sql = "INSERT INTO ".POSTS_TEXT_TABLE." VALUES ($new_post_id, '".$message."')";
$sql = "INSERT INTO ".POSTS_TEXT_TABLE." (post_id, post_subject, post_text) VALUES ($new_post_id, '".$subject."', '".$message."')";
if($db->sql_query($sql))
{
$sql = "UPDATE ".TOPICS_TABLE." SET topic_last_post_id = $new_post_id WHERE topic_id = $new_topic_id";
@ -290,7 +313,7 @@ switch($mode)
if($db->sql_query($sql))
{
$new_post_id = $db->sql_nextid();
$sql = "INSERT INTO ".POSTS_TEXT_TABLE." VALUES ($new_post_id, '".$message."')";
$sql = "INSERT INTO ".POSTS_TEXT_TABLE." (post_id, post_subject, post_text) VALUES ($new_post_id, '".$subject."', '".$message."')";
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";
@ -377,9 +400,46 @@ switch($mode)
}
else
{
$post_id = $HTTP_POST_VARS[POST_POST_URL];
$new_topic_id = $HTTP_POST_VARS[POST_TOPIC_URL];
$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
}
else
{
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#$post_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
{
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);
}
}
}
}
else
@ -388,7 +448,7 @@ switch($mode)
if(!empty($post_id))
{
$sql = "SELECT p.*, pt.post_text, u.username, u.user_id, u.user_sig, t.topic_title, t.topic_notify
$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')
AND pt.post_id = p.post_id
@ -398,8 +458,13 @@ switch($mode)
if($result = $db->sql_query($sql))
{
$postrow = $db->sql_fetchrowset($result);
$subject = stripslashes($postrow[0]['post_subject']);
$message = stripslashes($postrow[0]['post_text']);
$message = eregi_replace("\[addsig]$", "\n_________________\n" . stripslashes($postrow[0]['user_sig']), $message);
if(eregi("\[addsig]$", $message))
{
$attach_sig = TRUE;
}
$message = eregi_replace("\[addsig]$", "", $message);
$message = str_replace("<br />", "\n", $message);
// These have not been implemented yet!
@ -574,15 +639,12 @@ if($error)
}
$smile_toggle .= "> $l_disable $l_smilies $l_onthispost";
if($mode != 'editpost')
{
$sig_toggle = '<input type="checkbox" name="attach_sig" ';
if($attach_sig || $userdata['user_attachsig'] == 1)
{
$sig_toggle .= "checked";
}
$sig_toggle .= "> $l_attachsig";
}
if($mode == 'newtopic' || ($mode == 'editpost' && $notify))
{
@ -597,8 +659,9 @@ if($error)
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];
$post_id = ($HTTP_GET_VARS[POST_POST_URL]) ? $HTTP_GET_VARS[POST_POST_URL] : $HTTP_POST_VARS[POST_POST_URL];
}
$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\">";
$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\">";
$template->assign_vars(array(
"L_ABOUT_POST" => $l_aboutpost,

View file

@ -59,11 +59,11 @@
<table border="0" width="100%" cellpadding="3" cellspacing="1">
<tr class="tableheader">
<td width="15%">Author</td>
<td>{TOPIC_TITLE}</td>
<td colspan="2">{TOPIC_TITLE}</td>
</tr>
<!-- BEGIN postrow -->
<tr bgcolor="{postrow.ROW_COLOR}" class="tablebody">
<td width="20%" align="left" valign="top" nowrap>
<td width="20%" align="left" valign="top" nowrap rowspan="2">
<a name="{postrow.U_POST_ID}">
<font style="{font-size: 10pt; font-weight: bold;}">{postrow.POSTER_NAME}</font><br>
{postrow.POSTER_RANK}<br>
@ -72,8 +72,11 @@
<font style="{font-size: 8pt;}">
{L_JOINED}: {postrow.POSTER_JOINED}<br>{L_POSTS}: {postrow.POSTER_POSTS}<br>{postrow.POSTER_FROM}</font>
</td>
<td>
<img src="images/posticon.gif"><font style="{font-size: 8pt;}">{L_POSTED}: {postrow.POST_DATE}</font><hr>
<td><i><b>{postrow.POST_SUBJECT}</b></i></td>
<td align="right" width="15%"><img src="images/posticon.gif"><font style="{font-size: 8pt;}">{L_POSTED}: {postrow.POST_DATE}</font></td>
</tr>
<tr bgcolor="{postrow.ROW_COLOR}" class="tablebody">
<td colspan="3">
{postrow.MESSAGE}<hr>
{postrow.PROFILE_IMG}&nbsp;{postrow.EMAIL_IMG}&nbsp;{postrow.WWW_IMG}&nbsp;{postrow.ICQ_STATUS_IMG}&nbsp;{postrow.ICQ_ADD_IMG}&nbsp;{postrow.AIM_IMG}&nbsp;{postrow.YIM_IMG}&nbsp;{postrow.MSN_IMG}&nbsp;<img src="images/div.gif">&nbsp;{postrow.EDIT_IMG}&nbsp;{postrow.QUOTE_IMG}&nbsp;{postrow.PMSG_IMG}&nbsp;<img src="images/div.gif">&nbsp;{postrow.IP_IMG}&nbsp;{postrow.DELPOST_IMG}
</td>

View file

@ -201,7 +201,7 @@ if(!isset($start))
$start = 0;
}
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, p.post_time, p.post_id, p.bbcode_uid, pt.post_text
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, p.post_time, p.post_id, p.bbcode_uid, pt.post_text, pt.post_subject
FROM ".POSTS_TABLE." p, ".USERS_TABLE." u, ".POSTS_TEXT_TABLE." pt
WHERE p.topic_id = $topic_id
AND p.poster_id = u.user_id
@ -321,6 +321,7 @@ for($x = 0; $x < $total_posts; $x++)
$delpost_img = "<a href=\"".append_sid("topicadmin.$phpEx?mode=delpost$post_id=".$postrow[$x]['post_id'])."\"><img src=\"".$images['delpost']."\" alt=\"$l_delete\" border=\"0\"></a>";
}
$post_subject = stripslashes($postrow[$x]['post_subject']);
$message = stripslashes($postrow[$x]['post_text']);
$bbcode_uid = $postrow[$x]['bbcode_uid'];
$user_sig = stripslashes($postrow[$x]['user_sig']);
@ -365,6 +366,7 @@ for($x = 0; $x < $total_posts; $x++)
"POSTER_POSTS" => $poster_posts,
"POSTER_FROM" => $poster_from,
"POST_DATE" => $post_date,
"POST_SUBJECT" => $post_subject,
"MESSAGE" => $message,
"PROFILE_IMG" => $profile_img,
"EMAIL_IMG" => $email_img,