Empty commit

This commit is contained in:
Git 2012-10-19 08:00:17 +00:00
parent 89a5553560
commit 9b52af5dc1
4 changed files with 89 additions and 64 deletions

View File

@ -235,5 +235,18 @@ public static function warn_user($UserID, $Duration, $Reason) {
WHERE UserID=\''.db_string($UserID).'\'');
}
}
/**
* Update the notes of a user
* @param unknown $UserID ID of user
* @param unknown $AdminComment Comment to update with
*/
public static function update_user_notes($UserID, $AdminComment) {
global $DB;
$DB->query('UPDATE users_info SET
AdminComment=CONCAT(\''.db_string($AdminComment).'\',AdminComment)
WHERE UserID=\''.db_string($UserID).'\'');
}
}
?>

View File

@ -1425,10 +1425,12 @@ CREATE TABLE `users_votes` (
`UserID` int(10) unsigned NOT NULL,
`GroupID` int(10) NOT NULL,
`Type` enum('Up','Down') DEFAULT NULL,
`Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`UserID`,`GroupID`),
KEY `GroupID` (`GroupID`),
KEY `UserID` (`UserID`),
KEY `Type` (`Type`),
KEY `Time` (`Time`),
CONSTRAINT `users_votes_ibfk_1` FOREIGN KEY (`GroupID`) REFERENCES `torrents_group` (`ID`) ON DELETE CASCADE,
CONSTRAINT `users_votes_ibfk_2` FOREIGN KEY (`UserID`) REFERENCES `users_main` (`ID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

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

View File

@ -1,5 +1,6 @@
<?php
if (!check_perms('users_warn')) { error(404);
if (!check_perms('users_warn')) {
error(404);
}
Misc::assert_isset_request($_POST, array('reason', 'privatemessage', 'body', 'length', 'groupid', 'postid', 'userid'));
@ -7,47 +8,49 @@
$PrivateMessage = db_string($_POST['privatemessage']);
$Body = db_string($_POST['body']);
$Length = $_POST['length'];
$GroupID = (int)$_POST['groupid'];
$PostID = (int)$_POST['postid'];
$UserID = (int)$_POST['userid'];
$Key = (int)$_POST['key'];
$GroupID = (int) $_POST['groupid'];
$PostID = (int) $_POST['postid'];
$UserID = (int) $_POST['userid'];
$Key = (int) $_POST['key'];
$SQLTime = sqltime();
$UserInfo = Users::user_info($UserID);
if($UserInfo['Class'] > $LoggedUser['Class']) {
error(403);
if ($UserInfo['Class'] > $LoggedUser['Class']) {
error(403);
}
$URL = "https://". SSL_SITE_URL."/torrents.php?id=$GroupID&postid=$PostID#post$PostID";
$URL = "https://" . SSL_SITE_URL . "/torrents.php?id=$GroupID&postid=$PostID#post$PostID";
if ($Length != 'verbal') {
$Time = ((int)$Length) * (7 * 24 * 60 * 60);
Tools::warn_user($UserID, $Time, "$URL - ". $Reason);
$Subject = "You have received a warning";
$PrivateMessage = "You have received a $Length week warning for [url=$URL]this post.[/url]\n\n" . $PrivateMessage;
$Time = ((int) $Length) * (7 * 24 * 60 * 60);
Tools::warn_user($UserID, $Time, "$URL - " . $Reason);
$Subject = "You have received a warning";
$PrivateMessage = "You have received a $Length week warning for [url=$URL]this post.[/url]\n\n" . $PrivateMessage;
$WarnTime = time_plus($Time);
$AdminComment = date("Y-m-d").' - Warned until '.$WarnTime.' by '.$LoggedUser['Username']." for $URL \nReason: $Reason\n\n";
$AdminComment = date("Y-m-d") . ' - Warned until ' . $WarnTime . ' by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
} else {
$Subject = "You have received a verbal warning";
$PrivateMessage = "You have received a verbal warning for [url=$URL]this post.[/url]\n\n" . $PrivateMessage;
$AdminComment = date("Y-m-d") . ' - Verbally warned by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
}
$DB -> query("INSERT INTO users_warnings_forums (UserID, Comment) VALUES('$UserID', '" . db_string($AdminComment) . "')
$Subject = "You have received a verbal warning";
$PrivateMessage = "You have received a verbal warning for [url=$URL]this post.[/url]\n\n" . $PrivateMessage;
$AdminComment = date("Y-m-d") . ' - Verbally warned by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
}
$DB->query("INSERT INTO users_warnings_forums (UserID, Comment) VALUES('$UserID', '" . db_string($AdminComment)
. "')
ON DUPLICATE KEY UPDATE Comment = CONCAT('" . db_string($AdminComment) . "', Comment)");
Tools::update_user_notes($UserID, $AdminComment);
Misc::send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage);
// Mainly
$DB -> query("SELECT
$DB->query("SELECT
tc.Body,
tc.AuthorID,
tc.GroupID,
tc.AddedTime
FROM torrents_comments AS tc
WHERE tc.ID='$PostID'");
list($OldBody, $AuthorID, $GroupID, $AddedTime) = $DB -> next_record();
list($OldBody, $AuthorID, $GroupID, $AddedTime) = $DB->next_record();
$DB -> query("SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page FROM torrents_comments WHERE GroupID = $GroupID AND ID <= $PostID");
list($Page) = $DB -> next_record();
$DB->query("SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page FROM torrents_comments WHERE GroupID = $GroupID AND ID <= $PostID");
list($Page) = $DB->next_record();
// Perform the update
$DB -> query("UPDATE torrents_comments SET
$DB->query("UPDATE torrents_comments SET
Body = '$Body',
EditedUserID = '" . db_string($LoggedUser['ID']) . "',
EditedTime = '" . sqltime() . "'
@ -55,13 +58,16 @@
// Update the cache
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
$Cache -> begin_transaction('torrent_comments_' . $GroupID . '_catalogue_' . $CatalogueID);
$Cache->begin_transaction('torrent_comments_' . $GroupID . '_catalogue_' . $CatalogueID);
$Cache -> update_row($_POST['key'], array('ID' => $_POST['postid'], 'AuthorID' => $AuthorID, 'AddedTime' => $AddedTime, 'Body' => $_POST['body'], 'EditedUserID' => db_string($LoggedUser['ID']), 'EditedTime' => sqltime(), 'Username' => $LoggedUser['Username']));
$Cache -> commit_transaction(0);
$Cache->update_row($_POST['key'], array('ID' => $_POST['postid'], 'AuthorID' => $AuthorID, 'AddedTime' => $AddedTime, 'Body' => $_POST['body'],
'EditedUserID' => db_string($LoggedUser['ID']), 'EditedTime' => sqltime(), 'Username' => $LoggedUser['Username']));
$Cache->commit_transaction(0);
$DB -> query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
VALUES ('torrents', " . db_string($_POST['postid']) . ", " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
$DB->query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
VALUES ('torrents', " . db_string($_POST['postid']) . ", " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody)
. "')");
header("Location: torrents.php?id=$GroupID&postid=$PostID#post$PostID");
?>;
?>
;