Thread: Secret Admirer
View Single Post
  #18  
Old 07-06-2003, 10:28 PM
buro9 buro9 is offline
 
Join Date: Feb 2002
Location: London, UK
Posts: 585
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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'] == or
      
$bbuserinfo['usergroupid'] == or
      
$bbuserinfo['usergroupid'] == 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
Attached Files
File Type: php secret_admirer.php (6.8 KB, 9 views)
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01244 seconds
  • Memory Usage 1,825KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_attachment
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete