I made some edits to this hack, this allows you to control it via Admin CP Settings so you can modify the settings for it and turn double post checking on and off. Its backwards compatible so this hack will work even if you don't add the settings.
Note:
Please backup your includes/functions_newpost.php before your install these changes.
In file includes/functions_newpost.php find Xenon's original code and replace it with this:
PHP Code:
// ### POST NEW POST ###
// doublepost check
$isdoublepost = false;
$doubleposttime = (intval($vboptions['doubleposttime'])>0?intval($vboptions['doubleposttime']):3600);
if ($type != 'thread' AND $threadinfo['lastpost'] > TIMENOW - $doubleposttime AND $threadinfo['lastposter'] == $post['postusername'] AND $vboptions['doublepostenabled'] == 1) {
$doublepost = $DB_site->query_first("
SELECT postid, pagetext, post.userid
FROM " . TABLE_PREFIX . "post AS post
LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(deletionlog.primaryid = post.postid AND type = 'post')
WHERE threadid = $threadinfo[threadid]
AND dateline > " . (TIMENOW - $doubleposttime) . "
AND visible = 1 AND deletionlog.primaryid IS NULL
ORDER BY dateline DESC
LIMIT 1
");
if ($doublepost['userid'] == $bbuserinfo['userid'])
{
// we truely have a doublepost, now check if the merged post fits the rules!
$oldmsg = $post['message'];
$olderrors = $errors;
$post['message'] = $doublepost['pagetext'] . "\n\n" . $post['message'];
verify_post_errors($type, $post, $errors);
if (sizeof($errors) == 0)
{
// merged post is ok, so do merging
$isdoublepost = true;
$post['postid'] = $doublepost['postid'];
}
else
{
// merging will produce errors so keep it as a single post..
$isdoublepost = false;
$post['message'] = $oldmsg;
}
unset($oldmsg);
$errors = $olderrors;
unset($olderrors);
}
}
if ($isdoublepost)
{
// change this to false if you don't want doubleposts changing post's dateline
$do_bump = (isset($vboptions[doublepostbump])?$vboptions[doublepostbump]:1);
// Yes we have a doublepost, so do unindexing
require_once('./includes/functions_databuild.php');
delete_post_index($doublepost['postid'], $doublepost['title'], $doublepost['pagetext']);
unset($doublepost);
// Update DB
$DB_site->query("
UPDATE " . TABLE_PREFIX . "post
SET pagetext = '" . addslashes($post['message']) . "',
" . iif($do_bump, 'dateline = ' . TIMENOW . ',', '') . "
attach = attach + $totalattachments
WHERE postid = $post[postid]
");
//Delete Eventually parsed cached post
$DB_site->query("DELETE FROM " . TABLE_PREFIX . "post_parsed WHERE postid = " . $post['postid']);
if ($totalattachments > 0 OR $do_bump)
{
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET " . iif($do_bump, 'lastpost = ' . TIMENOW . ',', '') . "
attach = attach + $totalattachments
WHERE threadid = $threadinfo[threadid]
");
}
//Update forum if postdate has changed.
if ($do_bump)
{
$DB_site->query("
UPDATE " . TABLE_PREFIX . "forum
SET lastpost = " . TIMENOW . ",
lastposter = '" . addslashes($post['postusername']) . "',
lastthread = '" . addslashes($threadinfo['title']) . "',
lastthreadid = $threadinfo[threadid],
lasticonid = " . iif($threadinfo['pollid'], -1, $threadinfo['iconid']) . "
WHERE forumid = $foruminfo[forumid]
");
}
}
else
{
$DB_site->query("
INSERT INTO " . TABLE_PREFIX . "post
(threadid, parentid, title, username, userid, dateline, pagetext, allowsmilie,
showsignature, ipaddress, iconid, visible, attach)
VALUES
($threadinfo[threadid], $parentid, '" . addslashes($post['title']) . "',
'" . addslashes($post['postusername']) . "', $bbuserinfo[userid], " . TIMENOW . ",
'" . addslashes($post['message']) . "', $post[enablesmilies], $post[signature],
'" . addslashes($post['ipaddress']) . "', $post[iconid], $post[visible], $totalattachments)
");
$post['postid'] = $DB_site->insert_id();
}
Now to add the options, this can be done manually or with the queries below. I choosed to add them in the Posting settings group.
Manually Add then:
Varname: doublepostenabled
Type: yesno
Value: 1
Title: Check for double posts
Description: If enabled, it will check to see if the user already posted in the thread in a certain time limit, if so, their new post text will be added to their old post.
Varname: doublepostbump
Type: yesno
Value: 1
Title: Double posts bumping
Description: If enabled, and someone double posts, do you want the thread to be bumped because of the changes?
Varname: doubleposttime
Type:
Value: 3600
Title: Double post time
Description: The time in seconds you want to check for double posting.
OR
Queries:
[sql]
INSERT INTO `setting` VALUES ('doublepostenabled', 'posting', '1', '', 'yesno', 250, 0, 0);
INSERT INTO `setting` VALUES ('doublepostbump', 'posting', '1', '', 'yesno', 260, 0, 0);
INSERT INTO `setting` VALUES ('doubleposttime', 'posting', '3600', '3600', '', 270, 0, 0);
INSERT INTO `phrase` VALUES ('', 0, 'setting_doublepostenabled_title', 'Check for double posts', 5000);
INSERT INTO `phrase` VALUES ('', 0, 'setting_doublepostenabled_desc', 'If enabled, it will check to see if the user already posted in the thread in a certain time limit, if so, their new post text will be added to their old post.', 5000);
INSERT INTO `phrase` VALUES ('', 0, 'setting_doublepostbump_title', 'Double posts bumping', 5000);
INSERT INTO `phrase` VALUES ('', 0, 'setting_doublepostbump_desc', 'If enabled, and someone double posts, do you want the thread to be bumped because of the changes?', 5000);
INSERT INTO `phrase` VALUES ('', 0, 'setting_doubleposttime_title', 'Double post time', 5000);
INSERT INTO `phrase` VALUES ('', 0, 'setting_doubleposttime_desc', 'The time in seconds you want to check for double posting.', 5000);
[/sql]