Gazelle/sections/forums/take_warn.php

110 lines
3.7 KiB
PHP
Raw Normal View History

2012-08-27 08:00:24 +00:00
<?php
2012-10-19 08:00:17 +00:00
if (!check_perms('users_warn')) {
error(404);
2012-08-27 08:00:24 +00:00
}
2012-10-11 08:00:15 +00:00
Misc::assert_isset_request($_POST, array('reason', 'privatemessage', 'body', 'length', 'postid', 'userid'));
2012-08-27 08:00:24 +00:00
2013-03-10 08:00:41 +00:00
$Reason = $_POST['reason'];
$PrivateMessage = $_POST['privatemessage'];
$Body = $_POST['body'];
2012-08-27 08:00:24 +00:00
$Length = $_POST['length'];
2013-09-06 08:00:41 +00:00
$PostID = (int)$_POST['postid'];
$UserID = (int)$_POST['userid'];
$Key = (int)$_POST['key'];
2012-08-27 08:00:24 +00:00
$SQLTime = sqltime();
2012-08-29 08:00:17 +00:00
2012-10-11 08:00:15 +00:00
$UserInfo = Users::user_info($UserID);
2012-10-19 08:00:17 +00:00
if ($UserInfo['Class'] > $LoggedUser['Class']) {
error(403);
2012-08-29 08:00:17 +00:00
}
2013-04-17 08:00:58 +00:00
$URL = 'https://' . SSL_SITE_URL . "/forums.php?action=viewthread&amp;postid=$PostID#post$PostID";
2012-08-27 08:00:24 +00:00
if ($Length != 'verbal') {
2012-10-19 08:00:17 +00:00
$Time = ((int) $Length) * (7 * 24 * 60 * 60);
Tools::warn_user($UserID, $Time, "$URL - " . $Reason);
2013-04-17 08:00:58 +00:00
$Subject = 'You have received a warning';
2013-03-10 08:00:41 +00:00
$PrivateMessage = "You have received a $Length week warning for [url=$URL]this post[/url].\n\n" . $PrivateMessage;
2012-10-19 08:00:17 +00:00
2012-08-28 08:00:14 +00:00
$WarnTime = time_plus($Time);
2013-04-17 08:00:58 +00:00
$AdminComment = date('Y-m-d') . ' - Warned until ' . $WarnTime . ' by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
2012-08-28 08:00:14 +00:00
2012-08-27 08:00:24 +00:00
} else {
2013-04-17 08:00:58 +00:00
$Subject = 'You have received a verbal warning';
2013-03-10 08:00:41 +00:00
$PrivateMessage = "You have received a verbal warning for [url=$URL]this post[/url].\n\n" . $PrivateMessage;
2013-04-17 08:00:58 +00:00
$AdminComment = date('Y-m-d') . ' - Verbally warned by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
Tools::update_user_notes($UserID, $AdminComment);
2012-08-27 08:00:24 +00:00
}
2012-08-28 08:00:14 +00:00
2013-06-04 08:00:34 +00:00
$DB->query("
2013-09-06 08:00:41 +00:00
INSERT INTO users_warnings_forums
(UserID, Comment)
VALUES
('$UserID', '" . db_string($AdminComment) . "')
ON DUPLICATE KEY UPDATE
Comment = CONCAT('" . db_string($AdminComment) . "', Comment)");
2012-10-11 08:00:15 +00:00
Misc::send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage);
2012-08-27 08:00:24 +00:00
//edit the post
2013-06-04 08:00:34 +00:00
$DB->query("
SELECT
2013-04-17 08:00:58 +00:00
p.Body,
p.AuthorID,
p.TopicID,
t.ForumID,
CEIL( (SELECT COUNT(ID)
FROM forums_posts
WHERE forums_posts.TopicID = p.TopicID
AND forums_posts.ID <= '$PostID')/" . POSTS_PER_PAGE
. ") AS Page
2013-06-04 08:00:34 +00:00
FROM forums_posts as p
JOIN forums_topics as t on p.TopicID = t.ID
2013-09-06 08:00:41 +00:00
JOIN forums as f ON t.ForumID = f.ID
WHERE p.ID = '$PostID'");
2012-10-19 08:00:17 +00:00
list($OldBody, $AuthorID, $TopicID, $ForumID, $Page) = $DB->next_record();
2012-08-27 08:00:24 +00:00
// Perform the update
2013-06-04 08:00:34 +00:00
$DB->query("
UPDATE forums_posts
SET Body = '" . db_string($Body) . "',
EditedUserID = '$UserID',
EditedTime = '$SQLTime'
2013-09-06 08:00:41 +00:00
WHERE ID = '$PostID'");
2012-08-27 08:00:24 +00:00
$CatalogueID = floor((POSTS_PER_PAGE * $Page - POSTS_PER_PAGE) / THREAD_CATALOGUE);
2012-10-19 08:00:17 +00:00
$Cache->begin_transaction('thread_' . $TopicID . '_catalogue_' . $CatalogueID);
if ($Cache->MemcacheDBArray[$Key]['ID'] != $PostID) {
$Cache->cancel_transaction();
2013-06-27 08:01:06 +00:00
$Cache->delete_value('thread_' . $TopicID . '_catalogue_' . $CatalogueID);
2012-10-19 08:00:17 +00:00
//just clear the cache for would be cache-screwer-uppers
2012-08-27 08:00:24 +00:00
} else {
2013-06-04 08:00:34 +00:00
$Cache->update_row($Key, array(
'ID' => $Cache->MemcacheDBArray[$Key]['ID'],
'AuthorID' => $Cache->MemcacheDBArray[$Key]['AuthorID'],
'AddedTime' => $Cache->MemcacheDBArray[$Key]['AddedTime'],
'Body' => $Body, //Don't url decode.
'EditedUserID' => $LoggedUser['ID'],
'EditedTime' => $SQLTime,
'Username' => $LoggedUser['Username']));
2012-10-19 08:00:17 +00:00
$Cache->commit_transaction(3600 * 24 * 5);
2012-08-27 08:00:24 +00:00
}
2013-08-28 23:08:41 +00:00
$ThreadInfo = Forums::get_thread_info($TopicID);
2013-10-01 23:08:42 +00:00
if ($ThreadInfo === null) {
error(404);
}
2012-08-27 08:00:24 +00:00
if ($ThreadInfo['StickyPostID'] == $PostID) {
2013-03-10 08:00:41 +00:00
$ThreadInfo['StickyPost']['Body'] = $Body;
2012-10-19 08:00:17 +00:00
$ThreadInfo['StickyPost']['EditedUserID'] = $LoggedUser['ID'];
$ThreadInfo['StickyPost']['EditedTime'] = $SQLTime;
$Cache->cache_value('thread_' . $TopicID . '_info', $ThreadInfo, 0);
2012-08-27 08:00:24 +00:00
}
2013-06-04 08:00:34 +00:00
$DB->query("
INSERT INTO comments_edits
(Page, PostID, EditUser, EditTime, Body)
VALUES
('forums', $PostID, $UserID, '$SQLTime', '" . db_string($OldBody) . "')");
2012-10-19 08:00:17 +00:00
$Cache->delete_value("forums_edits_$PostID");
2012-08-27 08:00:24 +00:00
header("Location: forums.php?action=viewthread&postid=$PostID#post$PostID");
?>