Empty commit

This commit is contained in:
Git 2012-07-23 08:00:17 +00:00
parent 5f8c596d41
commit 0382cdb557
2 changed files with 34 additions and 15 deletions

View File

@ -49,6 +49,7 @@
$TopicID = $_POST['thread']; $TopicID = $_POST['thread'];
$ThreadInfo = get_thread_info($TopicID); $ThreadInfo = get_thread_info($TopicID);
$ForumID = $ThreadInfo['ForumID']; $ForumID = $ThreadInfo['ForumID'];
$SQLTime = sqltime();
if(!check_forumperm($ForumID)) { error(403); } if(!check_forumperm($ForumID)) { error(403); }
if(!check_forumperm($ForumID, 'Write') || $LoggedUser['DisablePosting'] || $ThreadInfo['IsLocked'] == "1" && !check_perms('site_moderate_forums')) { error(403); } if(!check_forumperm($ForumID, 'Write') || $LoggedUser['DisablePosting'] || $ThreadInfo['IsLocked'] == "1" && !check_perms('site_moderate_forums')) { error(403); }
@ -61,11 +62,16 @@
//Now lets handle the special case of merging posts, we can skip bumping the thread and all that fun //Now lets handle the special case of merging posts, we can skip bumping the thread and all that fun
if ($ThreadInfo['LastPostAuthorID'] == $LoggedUser['ID'] && ((!check_perms('site_forums_double_post') && !in_array($ForumID, $ForumsDoublePost)) || isset($_POST['merge']))) { if ($ThreadInfo['LastPostAuthorID'] == $LoggedUser['ID'] && ((!check_perms('site_forums_double_post') && !in_array($ForumID, $ForumsDoublePost)) || isset($_POST['merge']))) {
//Get the id for this post in the database to append //Get the id for this post in the database to append
$DB->query("SELECT ID FROM forums_posts WHERE TopicID='$TopicID' AND AuthorID='".$LoggedUser['ID']."' ORDER BY ID DESC LIMIT 1"); $DB->query("SELECT ID, Body FROM forums_posts WHERE TopicID='$TopicID' AND AuthorID='".$LoggedUser['ID']."' ORDER BY ID DESC LIMIT 1");
list($PostID) = $DB->next_record(); list($PostID, $OldBody) = $DB->next_record(MYSQLI_NUM, false);
//Edit the post //Edit the post
$DB->query("UPDATE forums_posts SET Body = CONCAT(Body,'"."\n\n".db_string($Body)."'), EditedUserID = '".$LoggedUser['ID']."', EditedTime = '".sqltime()."' WHERE ID='$PostID'"); $DB->query("UPDATE forums_posts SET Body = CONCAT(Body,'"."\n\n".db_string($Body)."'), EditedUserID = '".$LoggedUser['ID']."', EditedTime = '".$SQLTime."' WHERE ID='$PostID'");
//Store edit history
$DB->query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
VALUES ('forums', ".$PostID.", ".$LoggedUser['ID'].", '".$SQLTime."', '".db_string($OldBody)."')");
$Cache->delete_value("forums_edits_$PostID");
//Get the catalogue it is in //Get the catalogue it is in
$CatalogueID = floor((POSTS_PER_PAGE*ceil($ThreadInfo['Posts']/POSTS_PER_PAGE)-POSTS_PER_PAGE)/THREAD_CATALOGUE); $CatalogueID = floor((POSTS_PER_PAGE*ceil($ThreadInfo['Posts']/POSTS_PER_PAGE)-POSTS_PER_PAGE)/THREAD_CATALOGUE);
@ -76,13 +82,19 @@
} else { } else {
$Key = ($ThreadInfo['Posts']%THREAD_CATALOGUE)-1; $Key = ($ThreadInfo['Posts']%THREAD_CATALOGUE)-1;
} }
if($ThreadInfo['StickyPostID'] == $PostID) {
$ThreadInfo['StickyPost']['Body'] .= "\n\n$Body";
$ThreadInfo['StickyPost']['EditedUserID'] = $LoggedUser['ID'];
$ThreadInfo['StickyPost']['EditedTime'] = $SQLTime;
$Cache->cache_value('thread_'.$TopicID.'_info', $ThreadInfo, 0);
}
//Edit the post in the cache //Edit the post in the cache
$Cache->begin_transaction('thread_'.$TopicID.'_catalogue_'.$CatalogueID); $Cache->begin_transaction('thread_'.$TopicID.'_catalogue_'.$CatalogueID);
$Cache->update_row($Key, array( $Cache->update_row($Key, array(
'Body'=>$Cache->MemcacheDBArray[$Key]['Body']."\n\n".$Body, 'Body'=>$Cache->MemcacheDBArray[$Key]['Body']."\n\n".$Body,
'EditedUserID'=>$LoggedUser['ID'], 'EditedUserID'=>$LoggedUser['ID'],
'EditedTime'=>sqltime(), 'EditedTime'=>$SQLTime,
'Username'=>$LoggedUser['Username'] 'Username'=>$LoggedUser['Username']
)); ));
$Cache->commit_transaction(0); $Cache->commit_transaction(0);
@ -91,7 +103,7 @@
} else { } else {
//Insert the post into the posts database //Insert the post into the posts database
$DB->query("INSERT INTO forums_posts (TopicID, AuthorID, AddedTime, Body) $DB->query("INSERT INTO forums_posts (TopicID, AuthorID, AddedTime, Body)
VALUES ('$TopicID', '".$LoggedUser['ID']."', '".sqltime()."', '".db_string($Body)."')"); VALUES ('$TopicID', '".$LoggedUser['ID']."', '".$SQLTime."', '".db_string($Body)."')");
$PostID = $DB->inserted_id(); $PostID = $DB->inserted_id();
@ -101,7 +113,7 @@
LastPostID = '$PostID', LastPostID = '$PostID',
LastPostAuthorID = '".$LoggedUser['ID']."', LastPostAuthorID = '".$LoggedUser['ID']."',
LastPostTopicID = '$TopicID', LastPostTopicID = '$TopicID',
LastPostTime = '".sqltime()."' LastPostTime = '".$SQLTime."'
WHERE ID = '$ForumID'"); WHERE ID = '$ForumID'");
//Update the topic //Update the topic
@ -109,7 +121,7 @@
NumPosts = NumPosts+1, NumPosts = NumPosts+1,
LastPostID = '$PostID', LastPostID = '$PostID',
LastPostAuthorID = '".$LoggedUser['ID']."', LastPostAuthorID = '".$LoggedUser['ID']."',
LastPostTime = '".sqltime()."' LastPostTime = '".$SQLTime."'
WHERE ID = '$TopicID'"); WHERE ID = '$TopicID'");
//if cache exists modify it, if not, then it will be correct when selected next, and we can skip this block //if cache exists modify it, if not, then it will be correct when selected next, and we can skip this block
@ -122,7 +134,7 @@
unset($Forum[$TopicID]); unset($Forum[$TopicID]);
$Thread['NumPosts'] = $Thread['NumPosts']+1; //Increment post count $Thread['NumPosts'] = $Thread['NumPosts']+1; //Increment post count
$Thread['LastPostID'] = $PostID; //Set postid for read/unread $Thread['LastPostID'] = $PostID; //Set postid for read/unread
$Thread['LastPostTime'] = sqltime(); //Time of last post $Thread['LastPostTime'] = $SQLTime; //Time of last post
$Thread['LastPostAuthorID'] = $LoggedUser['ID']; //Last poster id $Thread['LastPostAuthorID'] = $LoggedUser['ID']; //Last poster id
$Part2 = array($TopicID=>$Thread); //Bumped thread $Part2 = array($TopicID=>$Thread); //Bumped thread
@ -145,7 +157,7 @@
'IsSticky' => $IsSticky, 'IsSticky' => $IsSticky,
'NumPosts' => $NumPosts, 'NumPosts' => $NumPosts,
'LastPostID' => $PostID, 'LastPostID' => $PostID,
'LastPostTime' => sqltime(), 'LastPostTime' => $SQLTime,
'LastPostAuthorID' => $LoggedUser['ID'], 'LastPostAuthorID' => $LoggedUser['ID'],
'NoPoll' => $NoPoll 'NoPoll' => $NoPoll
)); //Bumped )); //Bumped
@ -176,7 +188,7 @@
'LastPostID'=>$PostID, 'LastPostID'=>$PostID,
'LastPostAuthorID'=>$LoggedUser['ID'], 'LastPostAuthorID'=>$LoggedUser['ID'],
'LastPostTopicID'=>$TopicID, 'LastPostTopicID'=>$TopicID,
'LastPostTime'=>sqltime(), 'LastPostTime'=>$SQLTime,
'Title'=>$ThreadInfo['Title'], 'Title'=>$ThreadInfo['Title'],
'IsLocked'=>$ThreadInfo['IsLocked'], 'IsLocked'=>$ThreadInfo['IsLocked'],
'IsSticky'=>$ThreadInfo['IsSticky'] 'IsSticky'=>$ThreadInfo['IsSticky']
@ -196,7 +208,7 @@
$Cache->insert('', array( $Cache->insert('', array(
'ID'=>$PostID, 'ID'=>$PostID,
'AuthorID'=>$LoggedUser['ID'], 'AuthorID'=>$LoggedUser['ID'],
'AddedTime'=>sqltime(), 'AddedTime'=>$SQLTime,
'Body'=>$Body, 'Body'=>$Body,
'EditedUserID'=>0, 'EditedUserID'=>0,
'EditedTime'=>'0000-00-00 00:00:00', 'EditedTime'=>'0000-00-00 00:00:00',

View File

@ -29,6 +29,7 @@
$Body = db_string($_POST['body']); //Don't URL Decode $Body = db_string($_POST['body']); //Don't URL Decode
$PostID = $_POST['post']; $PostID = $_POST['post'];
$Key = $_POST['key']; $Key = $_POST['key'];
$SQLTime = sqltime();
// Mainly // Mainly
$DB->query("SELECT $DB->query("SELECT
@ -68,7 +69,7 @@
$DB->query("UPDATE forums_posts SET $DB->query("UPDATE forums_posts SET
Body = '$Body', Body = '$Body',
EditedUserID = '$UserID', EditedUserID = '$UserID',
EditedTime = '".sqltime()."' EditedTime = '".$SQLTime."'
WHERE ID='$PostID'"); WHERE ID='$PostID'");
$CatalogueID = floor((POSTS_PER_PAGE*$Page-POSTS_PER_PAGE)/THREAD_CATALOGUE); $CatalogueID = floor((POSTS_PER_PAGE*$Page-POSTS_PER_PAGE)/THREAD_CATALOGUE);
@ -83,15 +84,21 @@
'AddedTime'=>$Cache->MemcacheDBArray[$Key]['AddedTime'], 'AddedTime'=>$Cache->MemcacheDBArray[$Key]['AddedTime'],
'Body'=>$_POST['body'], //Don't url decode. 'Body'=>$_POST['body'], //Don't url decode.
'EditedUserID'=>$LoggedUser['ID'], 'EditedUserID'=>$LoggedUser['ID'],
'EditedTime'=>sqltime(), 'EditedTime'=>$SQLTime,
'Username'=>$LoggedUser['Username'] 'Username'=>$LoggedUser['Username']
)); ));
$Cache->commit_transaction(3600*24*5); $Cache->commit_transaction(3600*24*5);
} }
//$Cache->delete('thread_'.$TopicID.'_page_'.$Page); // Delete thread cache $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) $DB->query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
VALUES ('forums', ".$PostID.", ".$UserID.", '".sqltime()."', '".db_string($OldBody)."')"); VALUES ('forums', ".$PostID.", ".$UserID.", '".$SQLTime."', '".db_string($OldBody)."')");
$Cache->delete_value("forums_edits_$PostID"); $Cache->delete_value("forums_edits_$PostID");
// This gets sent to the browser, which echoes it in place of the old body // This gets sent to the browser, which echoes it in place of the old body
echo $Text->full_format($_POST['body']); echo $Text->full_format($_POST['body']);