Quote:
Originally Posted by Abe1
Can you please explain more.
|
I think I can explain that problem. In reputation.php, not only the reputation points of a user are updated, but also the reputationlevelid. That way, the reputation level of a user is updated instantly. You just give the reputation points, but do not update the reputationlevelid. So if a user gets 1000 reputation points by post thank you hack, but does not get any reputation the normal way, his reputationlevel will not update.
To fix this problem, a minor change to function add_thanks() is sufficent i think
PHP Code:
if ($vbulletin->options['post_thanks_reputation'])
{
$vbulletin->db->query_write("
INSERT IGNORE INTO ". TABLE_PREFIX ."reputation
(postid, userid, reputation, whoadded, reason, dateline)
VALUES
('".$postinfo['postid']."', '".$postinfo['userid']."', '" . $vbulletin->options['post_thanks_reputation'] . "', '" . $vbulletin->userinfo['userid'] . "', '$vbphrase[post_thanks_thanked_post]', " . TIMENOW . ")
");
if ($vbulletin->db->affected_rows() != 0)
{
////////////////////////////////////////////////
// BEGIN FIX
////////////////////////////////////////////////
// Query copied from reputation.php
// Determine this user's reputationlevelid.
$reputationlevel = $vbulletin->db->query_first_slave("
SELECT reputationlevelid
FROM " . TABLE_PREFIX . "reputationlevel
WHERE " . ($postinfo['reputation'] + $vbulletin->options['post_thanks_reputation']) . " >= minimumreputation
ORDER BY minimumreputation
DESC LIMIT 1
");
// I do not store the new reputation calculated for the query above and use it here again to avoid a potential race condition
$set_user_got .= ", reputation = " . $vbulletin->options['post_thanks_reputation'] . " + reputation, reputationlevelid = " . intval($reputationlevel['reputationlevelid']);
////////////////////////////////////////////////
// END FIX
////////////////////////////////////////////////
}
}
I hope that small note helps you improving that great hack further!