OK, so this is the first draft... I wouldn't even call it a Beta Hack yet... it's just an outline of the idea. And you'll have to forgive any dodgy PHP (or point it out to me!) as this isn't my main language and I sorta make this stuff up.
So... first you need to create a database table:
Code:
CREATE TABLE `secret_admirer` (
`userid` INT( 10 ) NOT NULL ,
`admiresuserid` INT( 10 ) NOT NULL ,
`datecreated` INT( 10 ) NOT NULL ,
PRIMARY KEY ( `userid` , `admiresuserid` )
) TYPE = MYISAM ;
Note that it has a dual-column primary key to prevent duplicates existing.
Next... upload the attached file into the root of your form... i.e. the one in which index.php, member.php, etc exist. Usually /forum if you've followed standard naming conventions. The file should be called secret_admirer.php
Now... you need to edit member.php
Find:
PHP Code:
// ############################### start aim message ###############################
if ($action=="aimmessage") {
$templatesused = 'aimmessage';
include("./global.php");
$aim = htmlspecialchars( $aim );
eval("dooutput(\"".gettemplate("aimmessage")."\");");
}
And below it add:
PHP Code:
// HACK : START : SECRET ADMIRER
// ############################### start admire ################################
if ($action=="admire") {
$templatesused = 'secret_admirer_page, secret_admirer_duplicate_page';
include("./secret_admirer.php");
include("./global.php");
$userid = verifyid("user",$userid);
//
// We only let registered users, mods and such use this... no-one awaiting
// confirmation or unregistered, as their email may be fake.
//
if (!$bbuserinfo['userid'] or
$bbuserinfo['usergroupid'] == 1 or
$bbuserinfo['usergroupid'] == 3 or
$bbuserinfo['usergroupid'] == 4 or
$bbuserinfo['usergroupid'] == 9) {
show_nopermission();
}
//
// Call the create function... this returns true or false:
// true = added successfully
// false = duplicate - it's been added before
//
if (secretAdmirerCreate($bbuserinfo['userid'],$userid)) {
//
// Successfully added admiration, so print out a helpful message
//
eval("dooutput(\"".gettemplate("secret_admirer_page")."\");");
} else {
//
// Duplicated, so advise
//
eval("dooutput(\"".gettemplate("secret_admirer_duplicate_page")."\");");
}
exit;
}
// HACK : END : SECRET ADMIRER
You now need to add some templates to your system, these are just draft pieces of text to outline what each template does:
- secret_admirer_page = "Your admiration for that user has now been registered and the user has been notified that someone admires them.<br/>
<br/>
If the user registers an admiration for you in return, then you will both be notified."
- secret_admirer_duplicate_page = "You've already registered your admiration for that user."
- secret_admirer_alert_pm = "Someone admires you!"
- secret_admirer_alert_email = "Someone admires you!"
- secret_admirer_match_pm = "$admiredUser[username] admires you!"
- secret_admirer_match_email = "$admiredUser[username] admires you!"
Finally... modify the "getinfo" template to add a link to it somewhere:
<a href="member.php?s=$session[sessionhash]&action=admire&userid=$userinfo[userid]">Click here to register your secret admiration for $userinfo[username]</a>
Then... all the user has to do is click that link, and the system records their admiration... sends an alert to the other person (which will advise them to register their admiration for others in the hope of matching)... and when a match is made... the two users are both informed... otherwise, it's all secret
So yeah, first draft... six hours of plodding through... hope it all makes sense and looks good.
Please give feedback over this week, and I'll attempt to do changes which I feel are appropriate. For me though, what I've done fulfils my needs... thought about adding management stuff, but decided that this is one feature that should be totally anonymous and secretive... for privacy's sake.
Cheers
David K