diff --git a/classes/script_start.php b/classes/script_start.php index 58df09fe..e7db54c5 100644 --- a/classes/script_start.php +++ b/classes/script_start.php @@ -2431,6 +2431,28 @@ function freeleech_groups($GroupIDs, $FreeNeutral = 1, $FreeLeechType = 0) { } } +/** + * Used to check if keys in $_POST and $_GET are all set + * This reduces if statement redundancy for alot of variables + */ +function isset_request($Request, $Keys=NULL, $AllowEmpty = False, $Error=0) { + if(isset($Keys)) { + foreach($Keys as $K) { + if(!isset($Request[$K]) || ($AllowEmpty == False && $Request[$K] == '')) { + error($Error); + break; + } + } + } + else { + foreach($Request as $R) { + if(!isset($R) || ($AllowEmpty == False && $R == '')) { + error($Error); + break; + } + } + } +} $Debug->set_flag('ending function definitions'); //Include /sections/*/index.php diff --git a/sections/forums/index.php b/sections/forums/index.php index 2786f298..b2cf0d53 100644 --- a/sections/forums/index.php +++ b/sections/forums/index.php @@ -75,6 +75,9 @@ case 'add_poll_option': require(SERVER_ROOT.'/sections/forums/add_poll_option.php'); break; + case 'take_warn': + require(SERVER_ROOT.'/sections/forums/take_warn.php'); + break; default: error(0); } @@ -131,7 +134,10 @@ require(SERVER_ROOT.'/sections/forums/edit_rules.php'); break; case 'thread_subscribe': - break; + break; + case 'warn': + require(SERVER_ROOT.'/sections/forums/warn.php'); + break; default: error(404); } diff --git a/sections/forums/take_warn.php b/sections/forums/take_warn.php new file mode 100644 index 00000000..9d9cd609 --- /dev/null +++ b/sections/forums/take_warn.php @@ -0,0 +1,81 @@ + query('UPDATE users_info SET + Warned=\'' . db_string($WarnTime) . '\', + WarnedTimes=WarnedTimes+1, + AdminComment=CONCAT(\'' . db_string($AdminComment) . '\',AdminComment) + WHERE UserID=\'' . db_string($UserID) . '\''); +} +send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage); + +//edit the post +$DB -> query("SELECT + 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 + 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(); + +// Perform the update +$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 +} 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); +} +$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); +} + +$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"); + +header("Location: forums.php?action=viewthread&postid=$PostID#post$PostID"); +?> diff --git a/sections/forums/thread.php b/sections/forums/thread.php index 4fe74f95..9f9b3378 100644 --- a/sections/forums/thread.php +++ b/sections/forums/thread.php @@ -72,7 +72,7 @@ $PostNum = 1; } list($Page,$Limit) = page_limit($PerPage, min($ThreadInfo['Posts'],$PostNum)); -if(($Page-1)*$PerPage >= $ThreadInfo['Posts']) { +if(($Page-1)*$PerPage > $ThreadInfo['Posts']) { $Page = ceil($ThreadInfo['Posts']/$PerPage); } list($CatalogueID,$CatalogueLimit) = catalogue_limit($Page,$PerPage,THREAD_CATALOGUE); @@ -408,7 +408,15 @@ [Report] -   += $AuthorInfo['Class']) { ?> + - [Warn] + +   diff --git a/sections/forums/warn.php b/sections/forums/warn.php new file mode 100644 index 00000000..6f2a1e1f --- /dev/null +++ b/sections/forums/warn.php @@ -0,0 +1,62 @@ + query("SELECT + p.Body, t.ForumID + FROM forums_posts as p JOIN forums_topics as t on p.TopicID = t.ID + WHERE p.ID='$PostID'"); +list($PostBody, $ForumID) = $DB -> next_record(); +show_header('Warn User'); +?> + +
+
+

Warning

+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Reason: + +
Length: +
Private Message: + +
Edit Post: + +
+ +
+
+
diff --git a/sections/requests/requests.php b/sections/requests/requests.php index 44cebb52..e7a2503f 100644 --- a/sections/requests/requests.php +++ b/sections/requests/requests.php @@ -296,6 +296,7 @@ if(check_perms('site_vote')){?> [Requests I've voted on] + [Bookmarked requests] [Torrents] [Artists] diff --git a/sections/torrents/details.php b/sections/torrents/details.php index d36aa0a0..cd40c897 100644 --- a/sections/torrents/details.php +++ b/sections/torrents/details.php @@ -802,6 +802,12 @@ function filelist($Str) { # [Report] + = $AuthorInfo['Class']) { ?> + - [Warn] + - [Quote] - [Edit] - [Delete] diff --git a/sections/torrents/index.php b/sections/torrents/index.php index d2ba0538..9feb1373 100644 --- a/sections/torrents/index.php +++ b/sections/torrents/index.php @@ -382,6 +382,12 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) { error(403); } break; + case 'warn' : + include(SERVER_ROOT.'/sections/torrents/warn.php'); + break; + case 'take_warn' : + include(SERVER_ROOT.'/sections/torrents/take_warn.php'); + break; default: enforce_login(); diff --git a/sections/torrents/take_warn.php b/sections/torrents/take_warn.php new file mode 100644 index 00000000..7203c665 --- /dev/null +++ b/sections/torrents/take_warn.php @@ -0,0 +1,65 @@ + query('UPDATE users_info SET + Warned=\'' . db_string($WarnTime) . '\', + WarnedTimes=WarnedTimes+1, + AdminComment=CONCAT(\'' . db_string($AdminComment) . '\',AdminComment) + WHERE UserID=\'' . db_string($UserID) . '\''); +} +send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage); + +// Mainly +$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(); + +$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 + Body = '$Body', + EditedUserID = '" . db_string($LoggedUser['ID']) . "', + EditedTime = '" . sqltime() . "' + WHERE ID='$PostID'"); + +// 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 -> 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) . "')"); + +header("Location: torrents.php?id=$GroupID&postid=$PostID#post$PostID"); +?>; diff --git a/sections/torrents/warn.php b/sections/torrents/warn.php new file mode 100644 index 00000000..a34f6067 --- /dev/null +++ b/sections/torrents/warn.php @@ -0,0 +1,66 @@ + query("SELECT + tc.Body, + tc.AddedTime + FROM torrents_comments AS tc + WHERE tc.ID='" . db_string($PostID) . "'"); +list($PostBody) = $DB -> next_record(); + +show_header('Warn User'); +?> + +
+
+

Warning

+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Reason: + +
Length: +
Private Message: + +
Edit Post: +
+ +
+
+