Gazelle/sections/artist/take_warn.php

80 lines
3.1 KiB
PHP
Raw Normal View History

2012-10-27 08:00:09 +00:00
<?php
2013-05-14 08:00:34 +00:00
if (!check_perms('users_warn')) {
error(404);
2012-10-27 08:00:09 +00:00
}
2012-10-29 08:00:20 +00:00
Misc::assert_isset_request($_POST, array('reason', 'privatemessage', 'body', 'length', 'artistid', 'postid', 'userid'));
2012-10-27 08:00:09 +00:00
2013-03-10 08:00:41 +00:00
$Reason = $_POST['reason'];
$PrivateMessage = $_POST['privatemessage'];
$Body = $_POST['body'];
2012-10-27 08:00:09 +00:00
$Length = $_POST['length'];
$ArtistID = (int)$_POST['artistid'];
$PostID = (int)$_POST['postid'];
$UserID = (int)$_POST['userid'];
$Key = (int)$_POST['key'];
$SQLTime = sqltime();
2012-10-29 08:00:20 +00:00
$UserInfo = Users::user_info($UserID);
2013-05-05 08:00:31 +00:00
if ($UserInfo['Class'] > $LoggedUser['Class']) {
2012-10-29 08:00:20 +00:00
error(403);
2012-10-27 08:00:09 +00:00
}
$URL = "https://". SSL_SITE_URL."/artist.php?id=$ArtistID&postid=$PostID#post$PostID";
if ($Length != 'verbal') {
2012-10-29 08:00:20 +00:00
$Time = ((int)$Length) * (7 * 24 * 60 * 60);
2013-07-10 00:08:53 +00:00
Tools::warn_user($UserID, $Time, "$URL - $Reason");
2013-05-05 08:00:31 +00:00
$Subject = 'You have received a warning';
2013-07-10 00:08:53 +00:00
$PrivateMessage = "You have received a $Length week warning for [url=$URL]this artist comment.[/url]\n\n$PrivateMessage";
2012-10-27 08:00:09 +00:00
$WarnTime = time_plus($Time);
2013-07-10 00:08:53 +00:00
$AdminComment = date('Y-m-d') . " - Warned until $WarnTime by " . $LoggedUser['Username'] . "\nReason: $URL - $Reason\n\n";
2012-10-27 08:00:09 +00:00
} else {
2013-05-05 08:00:31 +00:00
$Subject = 'You have received a verbal warning';
2013-07-10 00:08:53 +00:00
$PrivateMessage = "You have received a verbal warning for [url=$URL]this post.[/url]\n\n$PrivateMessage";
2013-05-05 08:00:31 +00:00
$AdminComment = date('Y-m-d') . ' - Verbally warned by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
2013-07-10 00:08:53 +00:00
Tools::update_user_notes($UserID, $AdminComment);
2012-10-29 08:00:20 +00:00
}
2013-05-05 08:00:31 +00:00
$DB->query("
INSERT INTO users_warnings_forums (UserID, Comment)
VALUES('$UserID', '" . db_string($AdminComment) . "')
2012-10-29 08:00:20 +00:00
ON DUPLICATE KEY UPDATE Comment = CONCAT('" . db_string($AdminComment) . "', Comment)");
Misc::send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage);
2012-10-27 08:00:09 +00:00
// Mainly
2013-05-05 08:00:31 +00:00
$DB->query("
SELECT
ac.Body,
ac.AuthorID,
ac.ArtistID,
ac.AddedTime
2012-10-29 08:00:20 +00:00
FROM artist_comments AS ac
2013-07-10 00:08:53 +00:00
WHERE ac.ID = '$PostID'");
2012-10-29 08:00:20 +00:00
list($OldBody, $AuthorID, $ArtistID, $AddedTime) = $DB->next_record();
2012-10-27 08:00:09 +00:00
2013-05-05 08:00:31 +00:00
$DB->query("
SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
FROM artist_comments
WHERE ArtistID = $ArtistID
AND ID <= $PostID");
2012-10-29 08:00:20 +00:00
list($Page) = $DB->next_record();
2012-10-27 08:00:09 +00:00
// Perform the update
2013-05-05 08:00:31 +00:00
$DB->query("
UPDATE artist_comments
SET
Body = '" . db_string($Body) . "',
EditedUserID = '" . db_string($LoggedUser['ID']) . "',
EditedTime = '" . sqltime() . "'
2013-07-10 00:08:53 +00:00
WHERE ID = '$PostID'");
2012-10-27 08:00:09 +00:00
// Update the cache
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
2013-07-10 00:08:53 +00:00
$Cache->begin_transaction("artist_comments_$ArtistID" . "_catalogue_$CatalogueID");
2012-10-27 08:00:09 +00:00
2013-03-10 08:00:41 +00:00
$Cache->update_row($_POST['key'], array('ID' => $_POST['postid'], 'AuthorID' => $AuthorID, 'AddedTime' => $AddedTime, 'Body' => $Body, 'EditedUserID' => db_string($LoggedUser['ID']), 'EditedTime' => sqltime(), 'Username' => $LoggedUser['Username']));
2012-10-29 08:00:20 +00:00
$Cache->commit_transaction(0);
2012-10-27 08:00:09 +00:00
2013-05-05 08:00:31 +00:00
$DB->query("
INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
VALUES ('artist', " . db_string($_POST['postid']) . ', ' . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
2012-10-27 08:00:09 +00:00
header("Location: artist.php?id=$ArtistID&postid=$PostID#post$PostID");
2012-10-29 08:00:20 +00:00
?>