2003-07-18 21:38:51 +00:00
|
|
|
<?php
|
2003-08-13 22:08:12 +00:00
|
|
|
|
|
|
|
require_once('../include/template.inc');
|
2003-07-18 21:38:51 +00:00
|
|
|
require_once('forum.inc');
|
|
|
|
require_once('../util.inc');
|
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
require_once('subscribe.inc');
|
|
|
|
|
2003-07-24 22:56:20 +00:00
|
|
|
if (!empty($_GET['thread']) && !empty($_POST['content'])) {
|
2003-08-13 22:08:12 +00:00
|
|
|
$_GET['thread'] = stripslashes(strip_tags($_GET['thread']));
|
2003-07-24 22:56:20 +00:00
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
if (!empty($_GET['post'])) {
|
|
|
|
$parent_post = $_GET['post'];
|
|
|
|
} else {
|
|
|
|
$parent_post = NULL;
|
|
|
|
}
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-07-26 00:19:21 +00:00
|
|
|
$user = get_logged_in_user(true, '../');
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-07-24 22:56:20 +00:00
|
|
|
$thread = getThread($_GET['thread']);
|
|
|
|
$thread->reply($user->id, $_POST['content'], $parent_post);
|
2003-07-25 20:27:34 +00:00
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
notify_subscribers($thread);
|
2003-07-25 20:27:34 +00:00
|
|
|
|
2003-07-18 21:38:51 +00:00
|
|
|
header('Location: thread.php?id='.$thread->id);
|
|
|
|
}
|
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
$logged_in_user = get_logged_in_user(true, '../');
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
//if (empty($_SESSION['authenticator']))
|
|
|
|
// get_logged_in_user(true, '../');
|
2003-07-24 22:56:20 +00:00
|
|
|
|
2003-07-18 21:38:51 +00:00
|
|
|
doHeader('Forum');
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
$helpdesk = false;
|
|
|
|
|
|
|
|
if (!empty($_GET['helpdesk'])) {
|
|
|
|
$helpdesk = true;
|
|
|
|
}
|
|
|
|
|
2003-07-24 22:56:20 +00:00
|
|
|
$thread = getThread($_GET['thread']);
|
2003-07-18 21:38:51 +00:00
|
|
|
$forum = getForum($thread->forum);
|
2003-07-24 22:56:20 +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-08-13 22:08:12 +00:00
|
|
|
start_forum_table(array("Author", "Message"), array(150, NULL));
|
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-07-26 00:19:21 +00:00
|
|
|
show_message_row($thread, $post);
|
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
end_forum_table();
|
2003-07-18 21:38:51 +00:00
|
|
|
|
|
|
|
doFooter();
|
2003-07-24 22:56:20 +00:00
|
|
|
|
2003-07-29 01:15:00 +00:00
|
|
|
function show_message_row($thread, $post=NULL) {
|
2003-07-24 22:56:20 +00:00
|
|
|
global $logged_in_user;
|
|
|
|
|
|
|
|
echo "
|
|
|
|
<tr class = \"row1\" style=\"vertical-align:top\">
|
|
|
|
<td>
|
2003-07-25 20:27:34 +00:00
|
|
|
<a name=\"input\"></a>
|
2003-07-24 22:56:20 +00:00
|
|
|
<p style=\"font-weight:bold\">
|
|
|
|
";
|
|
|
|
|
|
|
|
if ($logged_in_user->has_profile) {
|
|
|
|
echo "<a href=\"../view_profile.php?userid=", $logged_in_user->id, "\">", $logged_in_user->name, "</a>";
|
|
|
|
} else {
|
|
|
|
echo $logged_in_user->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "
|
|
|
|
</p>
|
|
|
|
<p style=\"font-size:8pt\">
|
|
|
|
Joined: ", date('M j, Y', $logged_in_user->create_time), "
|
|
|
|
</p>
|
|
|
|
</td>
|
|
|
|
<td>
|
2003-07-26 00:19:21 +00:00
|
|
|
<p style=\"font-size:8pt\">Your Message";
|
|
|
|
if ($post) echo " in response to <a href=#$post->id>Message ID $post->id</a>";
|
|
|
|
echo "</p>
|
2003-07-24 22:56:20 +00:00
|
|
|
<form action='reply.php?thread=", $thread->id;
|
|
|
|
|
|
|
|
if ($post) {
|
|
|
|
echo "&post=", $post->id;
|
|
|
|
}
|
2003-07-26 00:19:21 +00:00
|
|
|
|
2003-07-24 22:56:20 +00:00
|
|
|
echo "' method=\"post\">
|
2003-07-28 22:17:16 +00:00
|
|
|
<textarea name=\"content\" rows=\"18\" cols=\"80\">";
|
|
|
|
if ($post) echo quote_text($post->content, 80);
|
2003-07-26 00:19:21 +00:00
|
|
|
echo "</textarea><p>
|
2003-07-24 22:56:20 +00:00
|
|
|
<input type=\"submit\" value=\"Post reply\"></p>
|
|
|
|
</form>
|
|
|
|
";
|
|
|
|
|
|
|
|
echo "</td></tr>";
|
|
|
|
}
|
|
|
|
|
2003-07-26 00:19:21 +00:00
|
|
|
function quote_text($text, $cols) {
|
2003-07-28 22:17:16 +00:00
|
|
|
$quoteChar = ">";
|
|
|
|
|
|
|
|
$lines = explode("\n", $text);
|
2003-07-26 00:19:21 +00:00
|
|
|
|
2003-07-28 22:17:16 +00:00
|
|
|
$lineChars = strlen($quoteChar);
|
|
|
|
$final = $quoteChar;
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($lines); $i++) {
|
|
|
|
$words = explode(" ", $lines[$i]);
|
|
|
|
|
|
|
|
for ($j = 0; $j < count($words); $j++) {
|
|
|
|
$wordLen = strlen($words[$j]);
|
|
|
|
|
|
|
|
if (($lineChars + $wordLen) >= $cols) {
|
|
|
|
$final = $final . "\n" . $quoteChar;
|
|
|
|
$lineChars = strlen($quoteChar);
|
|
|
|
}
|
|
|
|
$final = $final . " " . $words[$j];
|
|
|
|
$lineChars += $wordLen + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$final = $final . "\n" . $quoteChar;
|
|
|
|
$lineChars = strlen($quoteChar);
|
2003-07-26 00:19:21 +00:00
|
|
|
}
|
|
|
|
|
2003-07-28 22:17:16 +00:00
|
|
|
return $final;
|
2003-07-26 00:19:21 +00:00
|
|
|
}
|
2003-07-24 22:56:20 +00:00
|
|
|
?>
|