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] - + + if(check_perms('users_warn') && $AuthorID != $LoggedUser['ID']) { + $AuthorInfo = user_info($AuthorID); + if($LoggedUser['Class'] >= $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'); +?> + +