2003-07-19 00:26:18 +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');
|
2003-07-19 00:26:18 +00:00
|
|
|
|
2004-12-27 03:42:11 +00:00
|
|
|
db_init();
|
|
|
|
|
2004-04-13 23:55:05 +00:00
|
|
|
$logged_in_user = get_logged_in_user();
|
2005-01-18 13:00:38 +00:00
|
|
|
|
2005-02-13 21:33:02 +00:00
|
|
|
$postid = get_int("id");
|
|
|
|
$post = getPost($postid);
|
|
|
|
if (!$post) {
|
|
|
|
error_page("No such post");
|
|
|
|
}
|
2005-01-18 13:00:38 +00:00
|
|
|
|
2003-08-14 00:56:20 +00:00
|
|
|
if ($_POST['submit']) {
|
2003-07-19 00:26:18 +00:00
|
|
|
$thread = getThread($post->thread);
|
2004-04-13 23:55:05 +00:00
|
|
|
|
2005-01-18 13:00:38 +00:00
|
|
|
if (time() > $post->timestamp + MAXIMUM_EDIT_TIME){
|
2005-04-20 21:11:20 +00:00
|
|
|
echo "You can no longer edit this post.<br />Posts can only be edited at most ".(MAXIMUM_EDIT_TIME/60)." minutes after they have been created.";
|
2005-01-18 13:00:38 +00:00
|
|
|
exit();
|
|
|
|
}
|
2004-04-13 23:55:05 +00:00
|
|
|
if ($logged_in_user->id != $post->user) {
|
|
|
|
// Can't edit other's posts.
|
|
|
|
echo "You are not authorized to edit this post.";
|
|
|
|
exit();
|
|
|
|
}
|
2003-07-19 00:26:18 +00:00
|
|
|
|
2005-01-18 13:00:38 +00:00
|
|
|
|
2003-08-14 00:56:20 +00:00
|
|
|
updatePost($post->id, $_POST['content']);
|
2004-04-17 22:52:16 +00:00
|
|
|
if ($post->parent_post==0 and $thread->owner==$logged_in_user->id){
|
2004-04-13 23:55:05 +00:00
|
|
|
updateThread($thread->id, $_POST['title']);
|
|
|
|
}
|
2003-08-14 00:56:20 +00:00
|
|
|
|
2004-05-30 21:47:11 +00:00
|
|
|
header('Location: forum_thread.php?id='.$thread->id);
|
2003-07-19 00:26:18 +00:00
|
|
|
}
|
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2004-05-11 22:49:23 +00:00
|
|
|
page_head('Forum');
|
2003-07-19 00:26:18 +00:00
|
|
|
|
2005-02-13 06:13:33 +00:00
|
|
|
$thread = getThread($post->thread);
|
|
|
|
$forum = getForum($thread->forum);
|
|
|
|
$category = getCategory($forum->category);
|
|
|
|
if (time() > $post->timestamp + MAXIMUM_EDIT_TIME){
|
2005-04-20 21:11:20 +00:00
|
|
|
echo "You can no longer edit this post.<br />Posts can only be edited at most ".(MAXIMUM_EDIT_TIME/60)." minutes after they have been created.";
|
2005-01-18 13:00:38 +00:00
|
|
|
exit();
|
2005-02-13 06:13:33 +00:00
|
|
|
}
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2003-07-19 00:26:18 +00:00
|
|
|
if ($logged_in_user->id != $post->user) {
|
|
|
|
// Can't edit other's posts.
|
|
|
|
echo "You are not authorized to edit this post.";
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
show_forum_title($forum, $thread, $category->is_helpdesk);
|
2003-07-19 00:26:18 +00:00
|
|
|
|
2004-06-01 18:55:59 +00:00
|
|
|
echo "<form action=forum_edit.php?id=$post->id method=POST>\n";
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2004-06-07 03:34:07 +00:00
|
|
|
start_table();
|
|
|
|
row1("Edit your post");
|
2004-04-17 22:52:16 +00:00
|
|
|
if ($post->parent_post==0 and $thread->owner==$logged_in_user->id) {
|
2004-04-13 23:55:05 +00:00
|
|
|
//If this is the first post enable the user to change title
|
2004-06-07 03:34:07 +00:00
|
|
|
row2(
|
|
|
|
"Thread title",
|
|
|
|
"<input type=text name=title value=\"".stripslashes($thread->title)."\">"
|
|
|
|
);
|
2004-04-13 23:55:05 +00:00
|
|
|
};
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2004-06-07 03:34:07 +00:00
|
|
|
row2(
|
|
|
|
"Message content",
|
|
|
|
"<textarea name=\"content\" rows=12 cols=80>".stripslashes($post->content)."</textarea>"
|
|
|
|
);
|
|
|
|
row2(
|
|
|
|
"",
|
|
|
|
"<input type=submit name=submit value=OK>"
|
|
|
|
);
|
|
|
|
|
|
|
|
end_table();
|
2003-08-13 22:08:12 +00:00
|
|
|
|
|
|
|
echo "</form>";
|
|
|
|
|
2003-08-15 01:01:00 +00:00
|
|
|
page_tail();
|
2003-07-19 00:26:18 +00:00
|
|
|
|
2003-12-04 22:42:51 +00:00
|
|
|
?>
|