View Single Post
  #1  
Old 02-20-2011, 10:42 AM
PokePets PokePets is offline
Premium Member
 
Join Date: Jun 2010
Posts: 228
Gender: Male
Credits: 19,062
PokePets
Default Give people an adoptable/cash on ther birthday!

With this script, users will get an adoptable or cash on ther birthday. Nice gift, not?
Specials thanks to fadillzzz who helped me fixing errors etc.

1) Search in account.php for this;

//Loop out code
$i=0;
while ($i < 1) {

$newmessagenotify=@mysql_result($result,$i,"newmes sagenotify");
$website=@mysql_result($result,$i,"website");
$aim=@mysql_result($result,$i,"aim");
$yahoo=@mysql_result($result,$i,"yahoo");
$msn=@mysql_result($result,$i,"msn");

Under that part of the code, add this;
$birthday=@mysql_result($result,$i,"birthday");

2) We are not done with account.php !
Look for this code;

</p>
<p>MSN Username:
<input name='msn' type='text' id='msn' value='".$msn."'>
<input name='act' type='hidden' id='act' value='changesettings'>
</p>

Under that, add this;
<p>Birthday:
<input name='birthday' type='text' id='birthday' value='".$birthday."'>

!! The birthday must be entered so;
Example for 31 Jan. 31 01
So 2 figures for the day, then a space end then 2 figures for the month.

3) Now we are done with account.php
Open now accountpost.php end look for this part of the code;

$aim = $_POST["aim"];
$aim = secure($aim);

$yim = $_POST["yim"];
$yim = secure($yim);

$msn = $_POST["msn"];
$msn = secure($msn);

Under that, add this;

$birthday= $_POST["birthday"];
$birthday= secure($birthday);

4) We must edit another thing in accountpost.php !
Look for this code;

$query = "UPDATE ".$prefix."users SET msn='".$msn."' WHERE username='".$loggedinname."'";
mysql_query($query);

End ad this;

$query = "UPDATE ".$prefix."users SET birthday='".$birthday."' WHERE username='".$loggedinname."'";
mysql_query($query);

5) Accountpost.php is ready. Now you need to creat 2 new colum in _users ;

Name: alreadybirthday
Type: Varchar 10
Collation: latin1_swedish_ci
Null: No
Default Value: Not

&

Name: birthday
Type: Varchar 10
Collation: latin1_swedish_ci
Null: No

6) We edited our _users table, so we must update our register.php !
Search for ;

//All checks are done, actually create the user's account on the database

$date = date('Y-m-d');

mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1','$email','3','1', '$date', '0','','','','','')");

& change it to

//All checks are done, actually create the user's account on the database

$date = date('Y-m-d');

mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1','$email','3','1', '$date', '0','','','','','','','')");
7) Now users can set ther birthday.
Now you can use this file to give your users a special adoptable on ther birthday;

<?php


// ************************************************** ********************
// Basic Configuration Info
// ************************************************** ********************

include("inc/functions.php");
include("inc/config.php");

$themeurl = grabanysetting("themeurl");

// ************************************************** ********************
// Define our top links by calling getlinks()
// ************************************************** ********************

$links = getlinks();

// ************************************************** ********************
// Define our ads by calling getads()
// ************************************************** ********************

$ads = getads("any");

// ************************************************** ********************
// Grab any settings that we will need for the current page from the DB
// ************************************************** ********************

$browsertitle = grabanysetting("browsertitle");
$sitename = grabanysetting("sitename");
$slogan = grabanysetting("slogan");

// ************************************************** ********************
// Check and see if the user is logged in to the site
// ************************************************** ********************

$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus[username];

// ************************************************** ********************
// End Prepwork - Output the page to the user
// ************************************************** ********************

$query = "SELECT * FROM ".$prefix."users WHERE username='$loggedinname'";
$result = mysql_query($query);
$num = mysql_num_rows($result);

//Loop out code
$i=0;
while ($i < 1) {

$birthday=@mysql_result($result,$i,"birthday") ;
$alreadybirthday=@mysql_result($result,$i,"already birthday") ;
$date = date("d m");
$code = rand(1, 20000);

$i++;
}

if($birthday == $date){

if ($alreadybirthday != "yes"){

$article_title = "Happy Birthday!";
$article_content = "As gift you get a special adoptable!";

mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', 'TYPEOFSPECIALADOPTABLE', 'Happy B-day!','$loggedinname','1','2', '$code', '','no','notfortrade','no')" );

$query = "UPDATE ".$prefix."users SET alreadybirthday='yes' WHERE username='".$loggedinname."'";
mysql_query($query);
}

elseif ($alreadybirthday == "yes"){
$article_title = "Is it your birthday?";
$article_content = "Yes, but you got already a gift!
It's today: ".$date." ! ";
}

}

else{

$article_title = "Is it your birthday";
$article_content = "No :(!
! It's today ".$date." !";

}



// ************************************************** ********************
// Begin Template Definition
// ************************************************** ********************

//Define our current theme
$file = $themeurl;

// Do the template changes and echo the ready template
$template = file_get_contents($file);
//echo $file;

$template = replace(':ARTICLETITLE:',$article_title,$template) ;
$template = replace(':ARTICLECONTENT:',$article_content,$templ ate);
$template = replace(':ARTICLEDATE:',$article_date,$template);

$template = replace(':BROWSERTITLE:',$browsertitle,$template);
$template = replace(':SITENAME:',$sitename,$template);

//Define our links
$template = replace(':LINKSBAR:',$links,$template);

//Get the content for the side bar...
$sidebar = getsidebar();
$template = replace(':SIDEFEED:',$sidebar,$template);

echo $template;

// ************************************************** ********************
// End Template Definition
// ************************************************** ********************
?>

You can do this also with cash etc. , will come soon!

Last edited by PokePets; 02-20-2011 at 10:51 AM.
Reply With Quote