diff options
author | deva <deva> | 2008-10-04 10:38:03 +0000 |
---|---|---|
committer | deva <deva> | 2008-10-04 10:38:03 +0000 |
commit | cce5e7710295021b41d9aaecc503a60fb99256be (patch) | |
tree | 660235be91fb821e976c7ae62347eb368ce87524 /forum/utils/edit.php |
Initial revision
Diffstat (limited to 'forum/utils/edit.php')
-rw-r--r-- | forum/utils/edit.php | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/forum/utils/edit.php b/forum/utils/edit.php new file mode 100644 index 0000000..0af361c --- /dev/null +++ b/forum/utils/edit.php @@ -0,0 +1,89 @@ +<?php +include_once($UTIL_DIR . "/error.php"); +include_once($UTIL_DIR . "/convert.php"); +include_once($UTIL_DIR . "/notify.php"); + +$message = stripslashes($message); +$title = stripslashes($title); + +switch($task) { + case "new": + if($fid) { + include_once("posts.php"); + $tid = time(); + $pid = time(); + $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml"); + $post = new Post($pid, $title, $current_user->uid, time(), $message); + $posts->add($post); + $posts->thread->name = $title; + $posts->thread->tid = $tid; + $posts->thread->lastpost = time(); + $posts->write(); + notify("forum", "New thread: http://www.executionroom.com/forum/?fid=". $fid . "&tid=" . $tid); + } else { + error("No forum id supplied!"); + } + break; + +case "reply": + if($fid && $tid && $pid) { + include_once("posts.php"); + $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml"); + $reply = $posts->getPost($pid); + if($reply) { + $post = new Post($posts->nextkey(), $title, $current_uid, time(), $message); + $reply->add($post); + $posts->thread->lastpost = time(); + $posts->write(); + notify("forum", "New reply: http://www.executionroom.com/forum/?fid=". $fid . "&tid=" . $tid); + } else { + error("Message " . $pid . " not found!"); + } + } else { + error("No message supplied!"); + } + break; + + case "edit": + if($fid && $tid && $pid) { + include_once("posts.php"); + $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml"); + $edit = $posts->getPost($pid); + if($edit) { + if($posts->thread->tid == $edit->pid) $posts->thread->name = $title; + $edit->title = $title; + $edit->message = $message . "\nEdited at: " . date("r", time()); + $posts->thread->lastpost = time(); + $posts->write(); + notify("forum", "Message has been edited: http://www.executionroom.com/forum/?fid=". $fid . "&tid=" . $tid); + } else { + error("Message " . $pid . " not found!"); + } + } else { + error("No message supplied!"); + } + break; + + case "quote": + if($fid && $tid && $pid) { + include_once("posts.php"); + $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml"); + $quote = $posts->getPost($pid); + if($quote) { + $post = new Post($posts->nextkey(), $title, $current_uid, time(), $message); + $quote->add($post); + $posts->thread->lastpost = time(); + $posts->write(); + notify("forum", "New reply (quote): http://www.executionroom.com/forum/?fid=". $fid . "&tid=" . $tid); + } else { + error("Message " . $pid . " not found!"); + } + } else { + error("No message supplied!"); + } + break; + +} +echo "<p><a href=\"?fid=" . $fid . "&tid=" . $tid . "\">Return to thread.</a></p>\n"; + +?>
\ No newline at end of file |