2005-01-18 13:00:38 +00:00
|
|
|
<?php
|
2006-06-16 23:53:56 +00:00
|
|
|
/**
|
|
|
|
* When a moderator does something to a post, this page actually
|
|
|
|
* commits those changes to the database.
|
|
|
|
**/
|
2005-01-18 13:00:38 +00:00
|
|
|
|
|
|
|
require_once("../inc/forum.inc");
|
2006-07-01 20:03:48 +00:00
|
|
|
require_once("../inc/forum_email.inc");
|
2006-06-16 23:53:56 +00:00
|
|
|
require_once("../inc/forum_std.inc");
|
2005-01-18 13:00:38 +00:00
|
|
|
|
|
|
|
db_init();
|
2006-06-16 23:53:56 +00:00
|
|
|
|
|
|
|
$user = re_get_logged_in_user();
|
2007-02-08 19:54:05 +00:00
|
|
|
check_tokens($user->getAuthenticator());
|
2006-06-16 23:53:56 +00:00
|
|
|
|
|
|
|
if (!$user->isSpecialUser(S_MODERATOR)) {
|
2005-02-13 21:33:02 +00:00
|
|
|
// Can't moderate without being moderator
|
2006-06-16 23:53:56 +00:00
|
|
|
error_page("You are not authorized to moderate this post.");
|
2005-02-13 21:33:02 +00:00
|
|
|
}
|
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
// See if "action" is provided - either through post or get
|
2005-05-23 19:05:44 +00:00
|
|
|
if (!post_str('action', true)) {
|
|
|
|
if (!get_str('action', true)){
|
|
|
|
error_page("You must specify an action...");
|
|
|
|
} else {
|
|
|
|
$action = get_str('action');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$action = post_str('action');
|
2005-01-18 13:00:38 +00:00
|
|
|
}
|
2005-02-13 21:33:02 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
$post = new Post(get_int('id'));
|
|
|
|
$thread = $post->getThread();
|
2005-01-18 13:00:38 +00:00
|
|
|
|
2005-05-23 19:05:44 +00:00
|
|
|
if ($action=="hide"){
|
2006-06-16 23:53:56 +00:00
|
|
|
$result = $post->hide();
|
|
|
|
if ($thread->getPostCount() == 0) {
|
|
|
|
$result = $thread->hide();
|
|
|
|
}
|
2005-05-23 19:05:44 +00:00
|
|
|
} elseif ($action=="unhide"){
|
2006-06-16 23:53:56 +00:00
|
|
|
$result = $post->unhide();
|
2005-05-23 19:05:44 +00:00
|
|
|
} elseif ($action=="move"){
|
2006-06-16 23:53:56 +00:00
|
|
|
$destination_thread = new Thread(post_int('threadid'));
|
|
|
|
$result = $post->move($destination_thread);
|
2006-10-21 19:52:37 +00:00
|
|
|
if ($thread->getPostCount() == 0) {
|
|
|
|
$thread->hide();
|
|
|
|
}
|
2006-08-08 20:32:37 +00:00
|
|
|
} elseif ($action=="banish_user"){
|
2006-10-17 05:40:33 +00:00
|
|
|
if (!$user->isSpecialUser(S_ADMIN)) {
|
|
|
|
// Can't banish without being administrator
|
|
|
|
error_page("You are not authorized to banish this user.");
|
|
|
|
}
|
2007-03-24 14:57:30 +00:00
|
|
|
$userid = post_int('userid');
|
2006-08-08 22:26:13 +00:00
|
|
|
$user = newUser($userid);
|
2006-08-08 20:32:37 +00:00
|
|
|
if (!$user) {
|
|
|
|
error_page("no user");
|
|
|
|
}
|
2007-03-24 14:57:30 +00:00
|
|
|
$duration = post_int('duration');
|
|
|
|
if ($duration == -1) {
|
|
|
|
$t = 2147483647; // Maximum integer value
|
|
|
|
} else {
|
|
|
|
$t = time() + $duration;
|
|
|
|
}
|
|
|
|
$reason = post_str("reason", true);
|
2006-08-08 20:32:37 +00:00
|
|
|
$query = "update forum_preferences set banished_until=$t where userid=$userid";
|
|
|
|
$result = mysql_query($query);
|
|
|
|
if ($result) {
|
2007-03-24 14:57:30 +00:00
|
|
|
echo "User $user->name has been banished.";
|
|
|
|
send_banish_email($user, $t, $reason);
|
2006-08-08 20:32:37 +00:00
|
|
|
} else {
|
|
|
|
echo "DB failure for $query";
|
|
|
|
echo mysql_error();
|
|
|
|
}
|
|
|
|
page_tail();
|
|
|
|
exit();
|
2005-01-18 13:00:38 +00:00
|
|
|
} else {
|
2006-06-16 23:53:56 +00:00
|
|
|
error_page("Unknown action ");
|
2005-01-18 13:00:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($result) {
|
2005-05-23 19:05:44 +00:00
|
|
|
if (post_str('reason', true)){
|
2007-01-01 21:18:49 +00:00
|
|
|
send_moderation_email($post, post_str("reason"), $action);
|
|
|
|
} else {
|
|
|
|
send_moderation_email($post, "None given", $action);
|
2005-01-18 13:00:38 +00:00
|
|
|
}
|
2006-06-16 23:53:56 +00:00
|
|
|
header('Location: forum_thread.php?id='.$thread->getID());
|
2005-01-18 13:00:38 +00:00
|
|
|
} else {
|
2006-06-16 23:53:56 +00:00
|
|
|
error_page("Moderation failed");
|
2005-01-18 13:00:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|