2003-07-18 21:38:51 +00:00
|
|
|
<?php
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
require_once('../inc/forum.inc');
|
|
|
|
require_once('../inc/util.inc');
|
|
|
|
require_once('../inc/subscribe.inc');
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2004-12-27 03:42:11 +00:00
|
|
|
db_init();
|
|
|
|
|
2004-09-04 23:37:49 +00:00
|
|
|
$logged_in_user = get_logged_in_user(true);
|
|
|
|
$logged_in_user = getForumPreferences($logged_in_user);
|
|
|
|
|
2005-04-20 21:11:20 +00:00
|
|
|
$thread = getThread(get_int('thread'));
|
|
|
|
$forum = getForum($thread->forum);
|
|
|
|
$category = getCategory($forum->category);
|
|
|
|
$helpdesk = $category->is_helpdesk;
|
|
|
|
|
|
|
|
if (!$thread){
|
|
|
|
error("No such thread found");
|
|
|
|
}
|
2005-04-25 18:44:17 +00:00
|
|
|
if ($thread->hidden) {
|
|
|
|
//If the thread has been hidden, do not display it, or allow people to continue to post
|
|
|
|
//to it.
|
|
|
|
error_page(
|
|
|
|
"This thread has been hidden for administrative purposes.");
|
|
|
|
}
|
2005-04-20 21:11:20 +00:00
|
|
|
if ($logged_in_user->total_credit<$forum->post_min_total_credit || $logged_in_user->expavg_credit<$forum->post_min_expavg_credit){
|
|
|
|
//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(
|
|
|
|
"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.");
|
|
|
|
}
|
|
|
|
if (time()-$logged_in_user->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
|
|
|
|
error_page(
|
|
|
|
"You cannot reply to any more posts right now. Please wait a while before trying again.<br />
|
|
|
|
This delay has been enforced to protect against abuse of the system.");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-04 23:37:49 +00:00
|
|
|
|
2003-07-24 22:56:20 +00:00
|
|
|
if (!empty($_GET['thread']) && !empty($_POST['content'])) {
|
2004-10-10 03:04:29 +00:00
|
|
|
$_GET['thread'] = stripslashes($_GET['thread']);
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2004-10-10 03:04:29 +00:00
|
|
|
if (!empty($_GET['post'])) {
|
2005-02-13 06:13:33 +00:00
|
|
|
$parent_post = $_GET['post'];
|
2004-10-10 03:04:29 +00:00
|
|
|
} else {
|
2005-02-13 06:13:33 +00:00
|
|
|
$parent_post = NULL;
|
2004-10-10 03:04:29 +00:00
|
|
|
}
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-11-28 22:35:01 +00:00
|
|
|
if ($_POST['add_signature']=="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
|
|
|
}
|
|
|
|
|
|
|
|
replyToThread($_GET['thread'], $logged_in_user->id, $_POST['content'], $parent_post, $add_signature);
|
|
|
|
notify_subscribers($_GET['thread']);
|
|
|
|
header('Location: forum_thread.php?id='.$_GET['thread']);
|
2003-07-18 21:38:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-14 00:56:20 +00:00
|
|
|
if (empty($_GET['thread'])) {
|
2005-02-13 06:13:33 +00:00
|
|
|
// TODO: Standard error page.
|
|
|
|
echo "No thread ID specified.<br>";
|
|
|
|
exit();
|
2003-08-14 00:56:20 +00:00
|
|
|
}
|
|
|
|
|
2003-07-24 22:56:20 +00:00
|
|
|
if (!empty($_GET['post'])) {
|
2003-07-26 00:19:21 +00:00
|
|
|
$post = getPost($_GET['post']);
|
2003-08-01 20:30:25 +00:00
|
|
|
}
|
|
|
|
|
2003-12-01 06:08:22 +00:00
|
|
|
|
2003-07-24 22:56:20 +00:00
|
|
|
|
2003-08-15 01:01:00 +00:00
|
|
|
// TODO: Write a function for this.
|
|
|
|
if ($helpdesk) {
|
2005-02-23 00:42:14 +00:00
|
|
|
page_head('Questions and answers');
|
2003-08-22 19:09:32 +00:00
|
|
|
} else {
|
2005-02-13 06:13:33 +00:00
|
|
|
page_head('Message boards');
|
2003-08-15 01:01:00 +00:00
|
|
|
}
|
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
show_forum_title($forum, $thread, $helpdesk);
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-11-30 21:05:57 +00:00
|
|
|
start_forum_table(array("Author", "Message"));
|
2003-07-26 00:19:21 +00:00
|
|
|
|
2003-08-01 20:30:25 +00:00
|
|
|
// TODO: Use the same sorting method that the user had in the thread view.
|
|
|
|
|
|
|
|
show_posts($thread, 'modified-new',-2, false, false, $helpdesk);
|
2003-12-01 06:08:22 +00:00
|
|
|
show_message_row($thread, $category, $post);
|
2003-07-26 00:19:21 +00:00
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
end_forum_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
|
|
|
|
2003-12-01 06:08:22 +00:00
|
|
|
function show_message_row($thread, $category, $post=NULL) {
|
2003-07-24 22:56:20 +00:00
|
|
|
global $logged_in_user;
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2005-02-16 00:24:53 +00:00
|
|
|
$x1 = "Message:".html_info().post_warning();
|
|
|
|
$x2 = "";
|
2003-12-01 06:08:22 +00:00
|
|
|
if ($post) {
|
2005-02-16 00:24:53 +00:00
|
|
|
$x2 .=" reply to <a href=#$post->id>Message ID $post->id</a>:";
|
2003-12-01 06:08:22 +00:00
|
|
|
}
|
|
|
|
if ($category->is_helpdesk) {
|
2005-02-16 00:24:53 +00:00
|
|
|
$x2 .= "<br><b>
|
2003-12-01 06:08:22 +00:00
|
|
|
Please use this form ONLY to answer or
|
|
|
|
discuss this particular question or problem.
|
|
|
|
";
|
|
|
|
}
|
2005-02-16 00:24:53 +00:00
|
|
|
$x2 .= "<form action=forum_reply.php?thread=$thread->id";
|
2003-07-24 22:56:20 +00:00
|
|
|
|
|
|
|
if ($post) {
|
2005-02-16 00:24:53 +00:00
|
|
|
$x2 .= "&post=$post->id";
|
2003-07-24 22:56:20 +00:00
|
|
|
}
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2005-02-16 00:24:53 +00:00
|
|
|
$x2 .= " method=post><textarea name=content rows=18 cols=80>";
|
|
|
|
if ($post) $x2 .= quote_text(stripslashes($post->content), 80);
|
|
|
|
if ($logged_in_user->no_signature_by_default==0){
|
|
|
|
$enable_signature="checked=\"true\"";
|
|
|
|
} else {
|
|
|
|
$enable_signature="";
|
|
|
|
}
|
|
|
|
$x2 .= "</textarea><p>
|
|
|
|
<input type=submit value=\"Post reply\">
|
2003-11-28 22:35:01 +00:00
|
|
|
|
2004-09-04 23:37:49 +00:00
|
|
|
<input name=add_signature value=add_it ".$enable_signature." type=checkbox>Add my signature to this reply
|
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
|
|
|
";
|
2003-07-24 22:56:20 +00:00
|
|
|
|
2005-02-16 00:24:53 +00:00
|
|
|
row2($x1, $x2);
|
2003-07-24 22:56:20 +00:00
|
|
|
}
|
|
|
|
|
2003-07-26 00:19:21 +00:00
|
|
|
function quote_text($text, $cols) {
|
2003-07-28 22:17:16 +00:00
|
|
|
$quoteChar = ">";
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2003-07-28 22:17:16 +00:00
|
|
|
$lines = explode("\n", $text);
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2003-07-28 22:17:16 +00:00
|
|
|
$lineChars = strlen($quoteChar);
|
|
|
|
$final = $quoteChar;
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2003-07-28 22:17:16 +00:00
|
|
|
for ($i = 0; $i < count($lines); $i++) {
|
|
|
|
$words = explode(" ", $lines[$i]);
|
2003-08-22 19:09:32 +00:00
|
|
|
|
|
|
|
for ($j = 0; $j < count($words); $j++) {
|
2003-07-28 22:17:16 +00:00
|
|
|
$wordLen = strlen($words[$j]);
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2003-07-28 22:17:16 +00:00
|
|
|
if (($lineChars + $wordLen) >= $cols) {
|
|
|
|
$final = $final . "\n" . $quoteChar;
|
|
|
|
$lineChars = strlen($quoteChar);
|
|
|
|
}
|
2003-08-22 19:09:32 +00:00
|
|
|
$final = $final . " " . $words[$j];
|
|
|
|
$lineChars += $wordLen + 1;
|
2003-07-28 22:17:16 +00:00
|
|
|
}
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2003-07-28 22:17:16 +00:00
|
|
|
$final = $final . "\n" . $quoteChar;
|
|
|
|
$lineChars = strlen($quoteChar);
|
2003-07-26 00:19:21 +00:00
|
|
|
}
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2003-07-28 22:17:16 +00:00
|
|
|
return $final;
|
2003-07-26 00:19:21 +00:00
|
|
|
}
|
2003-11-28 22:35:01 +00:00
|
|
|
?>
|