2003-07-18 21:38:51 +00:00
|
|
|
<?php
|
2007-09-29 12:53:16 +00:00
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
// Use this file you can post a reply to a thread.
|
|
|
|
// Both input (form) and action take place here.
|
|
|
|
|
2006-07-01 20:03:48 +00:00
|
|
|
require_once('../inc/forum_email.inc');
|
2004-02-02 23:34:39 +00:00
|
|
|
require_once('../inc/forum.inc');
|
2007-04-19 18:22:38 +00:00
|
|
|
require_once('../inc/akismet.inc');
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
$logged_in_user = get_logged_in_user(true);
|
|
|
|
BoincForumPrefs::lookup($logged_in_user);
|
2006-08-08 20:32:37 +00:00
|
|
|
check_banished($logged_in_user);
|
2004-09-04 23:37:49 +00:00
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
$thread = BoincThread::lookup_id(get_int('thread'));
|
2006-11-10 17:09:09 +00:00
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($thread->locked && !$logged_in_user->prefs->privilege(S_MODERATOR)
|
|
|
|
&& !$logged_in_user->prefs->privilege(S_ADMIN)) {
|
2006-11-10 17:09:09 +00:00
|
|
|
error_page("This thread is locked. Only forum moderators and administrators are allowed to post there.");
|
|
|
|
}
|
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
$forum = BoincForum::lookup_id($thread->forum);
|
|
|
|
$category = BoincCategory::lookup_id($forum->category);
|
2005-04-20 21:11:20 +00:00
|
|
|
|
2005-05-10 16:08:05 +00:00
|
|
|
$sort_style = get_str('sort', true);
|
|
|
|
$filter = get_str('filter', true);
|
2006-06-16 23:53:56 +00:00
|
|
|
$content = post_str('content', true);
|
2007-09-29 12:53:16 +00:00
|
|
|
$preview = post_str("preview", true);
|
2006-06-16 23:53:56 +00:00
|
|
|
$parent_post_id = get_int('post', true);
|
2007-10-31 19:26:02 +00:00
|
|
|
$parent_post = null;
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($parent_post_id) {
|
|
|
|
$parent_post = BoincPost::lookup_id($parent_post_id);
|
|
|
|
if ($parent_post->thread != $thread->id) {
|
|
|
|
error_page("wrong thread");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$parent_post_id = 0;
|
|
|
|
}
|
2005-05-10 16:08:05 +00:00
|
|
|
|
|
|
|
if ($filter != "false"){
|
|
|
|
$filter = true;
|
|
|
|
} else {
|
|
|
|
$filter = false;
|
|
|
|
}
|
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($thread->hidden) {
|
2005-04-25 18:44:17 +00:00
|
|
|
//If the thread has been hidden, do not display it, or allow people to continue to post
|
|
|
|
//to it.
|
|
|
|
error_page(
|
2007-11-12 20:57:15 +00:00
|
|
|
"This thread has been hidden for administrative purposes."
|
|
|
|
);
|
2005-04-25 18:44:17 +00:00
|
|
|
}
|
2005-05-10 16:08:05 +00:00
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
if (!$logged_in_user->prefs->privilege(S_MODERATOR) && ($logged_in_user->total_credit<$forum->post_min_total_credit || $logged_in_user->expavg_credit<$forum->post_min_expavg_credit)) {
|
2005-04-20 21:11:20 +00:00
|
|
|
//If user haven't got enough credit (according to forum regulations)
|
|
|
|
//We do not tell the (ab)user how much this is - no need to make it easy for them to break the system.
|
|
|
|
error_page(
|
2007-11-12 20:57:15 +00:00
|
|
|
"In order to reply to a post in ".$forum->title." you must have a certain amount of credit.
|
|
|
|
This is to prevent and protect against abuse of the system."
|
|
|
|
);
|
2005-04-20 21:11:20 +00:00
|
|
|
}
|
2005-05-10 16:08:05 +00:00
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
if (time()-$logged_in_user->prefs->last_post <$forum->post_min_interval){
|
|
|
|
// If the user is posting faster than forum regulations allow
|
|
|
|
// Tell the user to wait a while before creating any more posts
|
2005-04-20 21:11:20 +00:00
|
|
|
error_page(
|
|
|
|
"You cannot reply to any more posts right now. Please wait a while before trying again.<br />
|
2007-11-12 20:57:15 +00:00
|
|
|
This delay has been enforced to protect against abuse of the system."
|
|
|
|
);
|
2005-04-20 21:11:20 +00:00
|
|
|
}
|
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
if (!$sort_style) {
|
2007-11-12 20:57:15 +00:00
|
|
|
$sort_style = $logged_in_user->prefs->thread_sorting;
|
2005-05-10 16:08:05 +00:00
|
|
|
} else {
|
2007-11-12 20:57:15 +00:00
|
|
|
$logged_in_user->prefs->update("thread_sorting=$sort_style");
|
2005-05-10 16:08:05 +00:00
|
|
|
}
|
2005-04-20 21:11:20 +00:00
|
|
|
|
2007-09-29 12:53:16 +00:00
|
|
|
if ($content && (!$preview)){
|
2006-06-16 23:53:56 +00:00
|
|
|
if (post_str('add_signature',true)=="add_it"){
|
2005-02-13 06:13:33 +00:00
|
|
|
$add_signature=true; // set a flag and concatenate later
|
2004-10-10 03:04:29 +00:00
|
|
|
} else {
|
2005-02-13 06:13:33 +00:00
|
|
|
$add_signature=false;
|
2004-10-10 03:04:29 +00:00
|
|
|
}
|
2007-11-12 20:57:15 +00:00
|
|
|
check_tokens($logged_in_user->authenticator);
|
2007-04-19 18:22:38 +00:00
|
|
|
akismet_check($logged_in_user, $content);
|
2007-11-12 20:57:15 +00:00
|
|
|
create_post($content, $parent_post_id, $logged_in_user, $forum, $thread, $add_signature);
|
|
|
|
header('Location: forum_thread.php?id='.$thread->id);
|
2003-07-18 21:38:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-02 14:43:02 +00:00
|
|
|
page_head(tra("Message boards"));
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2007-11-10 00:32:42 +00:00
|
|
|
show_forum_title($logged_in_user, $category, $forum, $thread, true);
|
2007-09-29 12:53:16 +00:00
|
|
|
|
|
|
|
if ($preview == tra("Preview")) {
|
|
|
|
$options = new output_options;
|
|
|
|
echo "<div id=\"preview\">\n";
|
|
|
|
echo "<div class=\"header\">".tra("Preview")."</div>\n";
|
|
|
|
echo output_transform($content, $options);
|
|
|
|
echo "</div>\n";
|
|
|
|
}
|
|
|
|
|
2007-11-02 14:43:02 +00:00
|
|
|
start_forum_table(array(tra("Author"), tra("Message")));
|
2003-07-26 00:19:21 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
show_message_row($thread, $parent_post);
|
|
|
|
show_posts($thread, $sort_style, $filter, $logged_in_user, true);
|
2007-11-12 20:57:15 +00:00
|
|
|
end_table();
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-08-15 01:01:00 +00:00
|
|
|
page_tail();
|
2003-07-24 22:56:20 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
function show_message_row($thread, $parent_post) {
|
2003-07-24 22:56:20 +00:00
|
|
|
global $logged_in_user;
|
2007-09-29 12:53:16 +00:00
|
|
|
global $content;
|
|
|
|
global $preview;
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2005-02-16 00:24:53 +00:00
|
|
|
$x1 = "Message:".html_info().post_warning();
|
|
|
|
$x2 = "";
|
2006-06-16 23:53:56 +00:00
|
|
|
if ($parent_post) {
|
2007-11-12 20:57:15 +00:00
|
|
|
$x2 .=" reply to <a href=#".$parent_post->id.">Message ID ".$parent_post->id."</a>:";
|
2003-12-01 06:08:22 +00:00
|
|
|
}
|
2007-11-12 20:57:15 +00:00
|
|
|
$x2 .= "<form action=forum_reply.php?thread=".$thread->id;
|
2003-07-24 22:56:20 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
if ($parent_post) {
|
2007-11-12 20:57:15 +00:00
|
|
|
$x2 .= "&post=".$parent_post->id;
|
2003-07-24 22:56:20 +00:00
|
|
|
}
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2007-02-08 19:54:05 +00:00
|
|
|
$x2 .= " method=\"post\">\n";
|
2007-11-12 20:57:15 +00:00
|
|
|
$x2 .= form_tokens($logged_in_user->authenticator);
|
2007-02-08 19:54:05 +00:00
|
|
|
$x2 .= "<textarea name=\"content\" rows=\"18\" cols=\"80\">";
|
2007-09-29 12:53:16 +00:00
|
|
|
if ($preview) {
|
2007-09-29 15:47:12 +00:00
|
|
|
$x2 .= stripslashes(htmlspecialchars($content));
|
2007-09-29 12:53:16 +00:00
|
|
|
} else {
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($parent_post) $x2 .= quote_text(stripslashes(htmlspecialchars($parent_post->content)), 80)."\n";
|
2007-09-29 12:53:16 +00:00
|
|
|
}
|
2007-11-12 20:57:15 +00:00
|
|
|
if (!$logged_in_user->prefs->no_signature_by_default){
|
2005-02-16 00:24:53 +00:00
|
|
|
$enable_signature="checked=\"true\"";
|
|
|
|
} else {
|
|
|
|
$enable_signature="";
|
|
|
|
}
|
2007-09-29 12:53:16 +00:00
|
|
|
$x2 .= "</textarea><p>
|
|
|
|
<input type=\"submit\" name=\"preview\" value=\"".tra("Preview")."\">
|
|
|
|
<input type=\"submit\" value=\"Post reply\">
|
2003-11-28 22:35:01 +00:00
|
|
|
|
2007-09-29 12:53:16 +00:00
|
|
|
<input name=\"add_signature\" id=\"add_signature\" value=\"add_it\" ".$enable_signature." type=\"checkbox\">
|
2007-09-29 15:47:12 +00:00
|
|
|
<label for=\"add_signature\">Add my signature to this reply</label>
|
2003-11-28 22:35:01 +00:00
|
|
|
|
2003-12-01 06:08:22 +00:00
|
|
|
</form>
|
2005-02-13 06:13:33 +00:00
|
|
|
";
|
2005-02-16 00:24:53 +00:00
|
|
|
row2($x1, $x2);
|
2003-07-24 22:56:20 +00:00
|
|
|
}
|
|
|
|
|
2005-04-28 09:32:22 +00:00
|
|
|
function quote_text($text, $cols = 0) {
|
2005-05-08 01:33:03 +00:00
|
|
|
/* $cols is depricated. */
|
2005-05-13 19:14:19 +00:00
|
|
|
$text = "[quote]" . $text . "[/quote]";
|
2005-04-28 09:32:22 +00:00
|
|
|
return $text;
|
2003-07-26 00:19:21 +00:00
|
|
|
}
|
2007-11-12 20:57:15 +00:00
|
|
|
$cvs_version_tracker[]="\$Id$";
|
2003-11-28 22:35:01 +00:00
|
|
|
?>
|