Version: 1.02, by TCM
Developer Last Online: Sep 2009
Version: 3.0.7
Rating:
Released: 03-31-2005
Last Update: Never
Installs: 1
Template Edits
No support by the author.
Hi, this is my first time posting a "hack", so please tell me if I've done something horribly wrong.
This is a hack I made mainly for as an April fools joke for my board. You select certain users, and whenever anyone posts, the post is listed as if it was posted by one of those users, chosen at random. On my boards, we chose the users Somebody, Nobody and Anybody.
The code goes in the PHP_INCLUDE_START template. Selecting which users you want it to pick from is easy, you just add and remove array entries. For example, if I wanted it to pick from the users "Joe" and "Bob", who have userids 3 and 4, I would enter ...
... where the users are chosen. The full code, with the above example users used, is as follows:
PHP Code:
// vvvvvvvvvvvvv The Computer Mutt's Post As Random User Hack vvvvvvvvvvvvv
if ((($_POST['do'] == 'postthread') and ($_POST['sbutton'] == 'Submit New Thread'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Submit Reply'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Post Quick Reply')))
{
$bodies = array();
// Chose Users To Select From
// The userid will determine who the post appears to be from in the thread,
// The username will determine who the post appears to be from when you're looking at a list a threads (search, browsing forums, forumhome)
$randomuserchoice[1] = array(
'userid' => 3,
'username' => "Joe");
$randomuser = rand(1,count($randomuserchoice));
$bbuserinfo['userid'] = $randomuserchoice[$randomuser]['userid'];
$bbuserinfo['username'] = $randomuserchoice[$randomuser]['username'];
}
// ^^^^^^^^^^^^^ The Computer Mutt's Post As Random User Hack ^^^^^^^^^^^^^
If you want to add conditions to when this will apply, such as only applying it to certain users, or only in a given forum, you'd (obviously) just create an if statement and wrap it around all of the code.
You don't need to use real userids and usernames. When I wanted things to be really crazy, I used ...
... 208 being the number of users my board had at the time, so each post would be given to a random user, but would appear as "Someone" while browsing threads.
My members got a kick out of this, I hope you and yours do to.
-The Computer Mutt
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
// vvvvvvvvvvvvv The Computer Mutt's Post As Random User Hack vvvvvvvvvvvvv
if ((($_POST['do'] == 'postthread') and ($_POST['sbutton'] == 'Submit New Thread'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Submit Reply'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Post Quick Reply')))
{
if ($bbuserinfo['userid'] != 1 || $bbuserinfo['userid'] != 2){ //Put the exempt IDs in here
$bodies = array(171);
$randomuser = rand(1,count($randomuserchoice));
$bbuserinfo['userid'] = $randomuserchoice[$randomuser]['userid'];
$bbuserinfo['username'] = $randomuserchoice[$randomuser]['username'];
}
}
// ^^^^^^^^^^^^^ The Computer Mutt's Post As Random User Hack ^^^^^^^^^^^^^
For quick reply to work, make the IF statement say:
PHP Code:
if ((($_POST['do'] == 'postthread') and ($_POST['sbutton'] == 'Submit New Thread'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Submit Reply'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Post Quick Reply')))
Why does it have to check the button at all though?
I'm not certain, I think it's required to make sure the user can't access anything else of the randomly selected user's. I'll update with the quick-reply change.
@ Flypaper: Isn't you code saying if the user isn't user one OR isn't user two, so it would allow it for all users?
PHP Code:
if (($bbuserinfo['userid'] != 1) AND ($bbuserinfo['userid'] != 2)){
This is how I would do it. I'm steal fairly new at this, but I think it's correct.