MyBB Community Forums

Full Version: Create a posthash?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do you create a posthash value in Mybb?
Need this last value to complete my script.
Fixed.

It's:
mt_srand ((double) microtime() * 1000000);
$posthash = md5($mybb->user['uid'].mt_rand());
So from a php noob perspective... how do I do this for 7 attachments which have no posthash? Do I do this in myPHPadmin?
This should reset ALL posthashes to a random md5 hash for each post and attachment. In phpMyAdmin, execute all three lines in one go.

SET @salt=CONCAT(RAND(),RAND(),RAND(),RAND());
UPDATE mybb_posts SET posthash=MD5(CONCAT(@salt, '-', pid, '-', uid, '-', @salt));
UPDATE mybb_attachments SET posthash=MD5(CONCAT(@salt, '-', pid, '-', uid, '-', @salt));

It shouldn't cause any problems as long as no one is creating/editing a post with attachments at the time you run this.
thank you Frostchutz! It works, I've updated the other related thread with a link to your post. Thank you!