Currency for leveling up / Adoptable shop (Fixed again)

Forum
Last Post
Threads / Messages
Status
Not open for further replies.

kisazeky

Member
Member
Joined
Mar 14, 2009
Messages
44
Points
0
Mysidian Dollar
11,537
[size=medium]Note with this update! Please, re-run the queries to add the shop adoptables, if you have already installed it. Thanks.[/size]

[size=large]Important!! A way to prevent people stealing shop adoptables![/size]

Open adopt.php and find something like this in the code (it won't be exactly like mine):

PHP:
if($newID != $aID){
$stop = 1;
$article_title = "Oops";
$article_date = date('Y-m-d');
$article_content = "This Digimon is not available for adoption.";
}

below it, insert this:

PHP:
if($memberlevel != free){
$stop = 1;
$article_content = "You cannot adopt this pet for free!.";
}


[size=large]Earning money on level up
[/size]
Step 1: Run this here MySQL query to add the money field in your users table:

PHP:
ALTER TABLE users
ADD money INT(11) NULL DEFAULT '0'

Step 2: This is where the magic happens.

Download levelup.php and edit it to suit your site. Replace the number 10 with your desired amount of currency per level up.

Step 3: This is important if you still want people to be able to register. :p

Edit register2.php and find this line:
PHP:
mysql_query("INSERT INTO users VALUES ('', '$username', '$pass1','$email','free',)");

Replace it with:
PHP:
mysql_query("INSERT INTO users VALUES ('', '$username', '$pass1','$email','free','0')");

[size=large]Show the total amount of money to your users[/size]

Add this....

PHP:
if ($isloggedin == "yes"){
$query = "SELECT * FROM `users` WHERE `username` = '".$luser."'";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i=0;
	while ($i < 1) {
	
	$money =@mysql_result($result,$i,"money");
	$i++;
			}
$template = replace(':WELCOMEORREGISTER:','',$template);
$template = replace(':LOGINORACCT:', '<p>Hi, '.$username.'
<p>Currency name: '.$money.'
<p><a href="logout.php">Log out</a>' ,$template);

In between ...
PHP:
//$isloggedin = "no";
and...
PHP:
}
else{

//User is not logged in

On all of your pages.

[size=large]
Shop to buy adoptables[/size]

Step 1:

Download shop.php, buy.php, and buyconfirm.php and upload them to your main folder.

Step 2:

Add adoptables for sale by running a query like this. Do not change the shop part unless you know what you're doing.
PHP:
INSERT INTO adoptables VALUES ('', 'name','level 0 image','shop','cost')

Then add the rank images, too. Put the image urls in place of the numbers. 1 will have its level 1 image, 2 the level 2 image, etc.

PHP:
INSERT INTO adoptable_rankimages VALUES ('name','1','2','3','4','5','6','7','8')
 
RE: [In Development] Currency for leveling up

Well, using your system of altering the users table will break the user registration system. :p

You would want to also find in register2.php:

PHP:
mysql_query("INSERT INTO users VALUES ('', '$username', '$pass1','$email','free')");

Replace With:

PHP:
mysql_query("INSERT INTO users VALUES ('', '$username', '$pass1','$email','free','0')");

You need to add the extra column in there for the user's money. If the columns don't match, MySQL freaks out and new users are not registered correctly.

Also, I would change:

Code:
ALTER TABLE users
ADD money VARCHAR(11) NULL DEFAULT '0'

To:

Code:
ALTER TABLE users
ADD money INT

Use INT when only a number is expected. :)

Brandon
 
RE: [In Development] Currency for leveling up

So Brandon, would i be able to fuse this with my idea i was working on? If so, how?
 
RE: [In Development] Currency for leveling up

Killgore said:
So Brandon, would i be able to fuse this with my idea i was working on? If so, how?

I would suggest do the same, except add a second column to the database to account for pearls and emeralds.
 
RE: [In Development] Currency for leveling up

Okay. But there's still the dilemma that there's a chance of getting one out of five colors for each pearl or emerald. I'm guessing I'd need to create a field for each color pearl and emerald?
 
RE: [In Development] Currency for leveling up

PHP:
$color = "";
$number = rand(1,5); // Get random number between 1 and 5

if($number == 1){
$color = "redpebbleimage.gif";
}
else if($number == 2){
$color = "greenpebbleimage.gif";
}
else if(... and so on

Just do that to assign a random pebble image and save in the db. :)
 
RE: [In Development] Currency for leveling up

Does it work right now?
 
RE: [In Development] Currency for leveling up

Yes rosepose, getting currency for leveling up works. Just make sure to include Brandon's amendment or else people can't register anymore. :p

What's in progress still is the shop for buying adoptables with the money.
 
RE: [In Development] Currency for leveling up

Could you edit the first post and add Brandon's extra part because I fail at this stuff...Thanks.
 
RE: [In Development] Currency for leveling up

Thanks :) I'll try to add this to SE if the host decides to work ><
 
RE: [In Development] Currency for leveling up

Ashje said:
Could you edit the first post and add Brandon's extra part because I fail at this stuff...Thanks.

Done. ^^
 
RE: [In Development] Currency for leveling up

This looks great :3 I've sent you a PM on the SE forums, kisazeky...
 
RE: [In Development] Currency for leveling up

Just a quick question: Where do I put the login message? Because there's text in between the two fields you tell us to paste the code into.
 
RE: [In Development] Currency for leveling up

kisazeky said:
Ashje said:
Could you edit the first post and add Brandon's extra part because I fail at this stuff...Thanks.

Done. ^^

Awesome thanks =)


rosepose said:
Just a quick question: Where do I put the login message? Because there's text in between the two fields you tell us to paste the code into.

I have that problem as well. I tried replacing and adding to the original text but it all doesn't work. rosepose, I suggest you back up your system before doing any of this.
 
RE: [In Development] Currency for leveling up

MR, CAN I ASK YOU SOMETHING!!!??


HOW CAN I CHANGE THE "DIGIMON" THING THAT SHOWS WHEN I VISIT A PET??

AND HOW CAN I CHANGE THE CURRENCY?? I THINK IT SAYS "BITS"..

I DONT EVEN KNOW WHAT "BITS" MEANS..
 
RE: [In Development] Currency for leveling up

rosepose said:
Just a quick question: Where do I put the login message? Because there's text in between the two fields you tell us to paste the code into.

Put the login message in the place where you say "Welcome back, $username" or whatever.
 
RE: [In Development] Currency for leveling up

I like it ^^ Thanks ^^ I am going to add it to my site right away!
 
RE: [In Development] Currency for leveling up

This doesn't work. It shows this error: "Parse error: syntax error, unexpected T_ELSE in /home/--------/public_html/index.php on line 160"

It won't show it when you go there now because I reversed Step 3 but if I were to put it in then that error would appear.

I followed everything exactly. This is my index.php file:

Code:
<?php

// Easy Adoptables Script by Brandon Rusnak
// Get our includes out of the way

include("inc/functions.php");
include("inc/config.php");
include("inc/settings.php");
include("inc/nbbc.php");  // BBCODE Parser
$bbcode = new BBCode;

// Connect to our database

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql database!');
mysql_select_db($dbname);


//Set up our login info...
$username = "";
$password = "";

//Check for cookie

if (isset($_COOKIE['adoptu']) and isset($_COOKIE['adoptp'])){

$username = $_COOKIE['adoptu'];
$password = $_COOKIE['adoptp'];

$username = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $username);
$password = preg_replace("/[^a-zA-Z0-9s]/", "", $password);

//Run login operation
$query = "SELECT * FROM users WHERE username = '$username'";
$result = mysql_query($query);
$num = mysql_numrows($result);

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

$luser=@mysql_result($result,$i,"username");
$lpass=@mysql_result($result,$i,"password");

$i++;
}

	if($username == $luser and $password == $lpass){
		$isloggedin = "yes";
	}
	else{
	if (isset($_COOKIE['adoptu'])){
	$past = time() - 10; 
	setcookie("adoptu",$username,$past);
	}

	if (isset($_COOKIE['adoptp'])){
	$past = time() - 10; 
	setcookie("adoptp",$password,$past);
	}
	$isloggedin = "no";
	}

}
else
{
//User is not logged in
$isloggedin = "no";

} 



// Define our Template File

$file = $current_theme;



// Get our content for the index page

$query = "SELECT * FROM article_content WHERE page = 'index'";
$result = mysql_query($query);
$num = mysql_numrows($result);

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

$article_title=mysql_result($result,$i,"title");
$article_date=mysql_result($result,$i,"date");
$article_content=mysql_result($result,$i,"content");

$i++;
}

$article_title = stripslashes($article_title);
$article_content = stripslashes($article_content);

$article_content = $bbcode->Parse($article_content);

// Run the BBCODE parser on the content

// Should we show the extra pages in the nav bar?

$link1 = "";
if($show_extra_page1 == "yes"){
$link1 = "<li><a href='$extra_page1_link'>$extra_page1_name<span class='tab-l'></span><span class='tab-r'></span></a></li>"; 
}

$link2 = "";
if($show_extra_page2 == "yes"){
$link2 = "<li><a href='$extra_page2_link'>$extra_page2_name<span class='tab-l'></span><span class='tab-r'></span></a></li>"; 
}

// Do the template changes and echo the ready template

$template = file_get_contents($file);
$template = replace(':SITETITLE:',$site_title,$template);
$template = replace(':SITENAME:',$site_name,$template);
$template = replace(':ARTICLETITLE:',$article_title,$template);
$template = replace(':ARTICLEDATE:',$article_date,$template);
$template = replace(':ARTICLECONTENT:',$article_content,$template);
$template = replace(':LINK1:',$link1,$template);
$template = replace(':LINK2:',$link2,$template);
$template = replace(':LINK3:',$link3,$template);

//Get the featured adoptable...
$featured = getfeatured();
$template = replace(':FEATURED:',$featured,$template);

//Ad Management
$header = @file_get_contents("ads/header.txt");
$footer = @file_get_contents("ads/footer.txt");
$tower = @file_get_contents("ads/tower.txt");

$header = stripslashes($header);
$footer = stripslashes($footer);
$tower = stripslashes($tower);

$template = replace(':HEADERAD:',$header,$template);
$template = replace(':FOOTERAD:',$footer,$template);
$template = replace(':TOWERAD:',$tower,$template);

//Is the user logged in?
//$isloggedin = "no";
if ($isloggedin == "yes"){
$query = "SELECT * FROM `users` WHERE `username` = '".$luser."'";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i=0;
    while ($i < 1) {
    
    $money =@mysql_result($result,$i,"money");
    $i++;
            }
$template = replace(':WELCOMEORREGISTER:','',$template);
$template = replace(':LOGINORACCT:', '<p>Hi, '.$username.'
<p>Currency name: '.$money.'
<p><a href="logout.php">Log out</a>' ,$template); 
else{

//User is not logged in
$template = replace(':WELCOMEORREGISTER:','<u>Member Login:</u>',$template);
$loginform = "<form name='form1' method='post' action='login.php'>
  <p>Username: 
    <input name='username' type='text' id='username'>
</p>
  <p>Password: 
    <input name='password' type='password' id='password'>
</p>
  <p>
    <input type='submit' name='Submit' value='Submit'>
  </p>
  <p>Don't have an account?<br>
  <a href='register.php'>Register Free</a>  </p>
</form>
";
$template = replace(':LOGINORACCT:', $loginform ,$template);
}

echo $template;
?>

Please help. Thanks =)
 
RE: [In Development] Currency for leveling up

Ashje said:
This doesn't work. It shows this error: "Parse error: syntax error, unexpected T_ELSE in /home/--------/public_html/index.php on line 160"

It won't show it when you go there now because I reversed Step 3 but if I were to put it in then that error would appear.

I followed everything exactly. This is my index.php file:

Code:
<?php

// Easy Adoptables Script by Brandon Rusnak
// Get our includes out of the way

include("inc/functions.php");
include("inc/config.php");
include("inc/settings.php");
include("inc/nbbc.php");  // BBCODE Parser
$bbcode = new BBCode;

// Connect to our database

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql database!');
mysql_select_db($dbname);


//Set up our login info...
$username = "";
$password = "";

//Check for cookie

if (isset($_COOKIE['adoptu']) and isset($_COOKIE['adoptp'])){

$username = $_COOKIE['adoptu'];
$password = $_COOKIE['adoptp'];

$username = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $username);
$password = preg_replace("/[^a-zA-Z0-9s]/", "", $password);

//Run login operation
$query = "SELECT * FROM users WHERE username = '$username'";
$result = mysql_query($query);
$num = mysql_numrows($result);

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

$luser=@mysql_result($result,$i,"username");
$lpass=@mysql_result($result,$i,"password");

$i++;
}

	if($username == $luser and $password == $lpass){
		$isloggedin = "yes";
	}
	else{
	if (isset($_COOKIE['adoptu'])){
	$past = time() - 10; 
	setcookie("adoptu",$username,$past);
	}

	if (isset($_COOKIE['adoptp'])){
	$past = time() - 10; 
	setcookie("adoptp",$password,$past);
	}
	$isloggedin = "no";
	}

}
else
{
//User is not logged in
$isloggedin = "no";

} 



// Define our Template File

$file = $current_theme;



// Get our content for the index page

$query = "SELECT * FROM article_content WHERE page = 'index'";
$result = mysql_query($query);
$num = mysql_numrows($result);

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

$article_title=mysql_result($result,$i,"title");
$article_date=mysql_result($result,$i,"date");
$article_content=mysql_result($result,$i,"content");

$i++;
}

$article_title = stripslashes($article_title);
$article_content = stripslashes($article_content);

$article_content = $bbcode->Parse($article_content);

// Run the BBCODE parser on the content

// Should we show the extra pages in the nav bar?

$link1 = "";
if($show_extra_page1 == "yes"){
$link1 = "<li><a href='$extra_page1_link'>$extra_page1_name<span class='tab-l'></span><span class='tab-r'></span></a></li>"; 
}

$link2 = "";
if($show_extra_page2 == "yes"){
$link2 = "<li><a href='$extra_page2_link'>$extra_page2_name<span class='tab-l'></span><span class='tab-r'></span></a></li>"; 
}

// Do the template changes and echo the ready template

$template = file_get_contents($file);
$template = replace(':SITETITLE:',$site_title,$template);
$template = replace(':SITENAME:',$site_name,$template);
$template = replace(':ARTICLETITLE:',$article_title,$template);
$template = replace(':ARTICLEDATE:',$article_date,$template);
$template = replace(':ARTICLECONTENT:',$article_content,$template);
$template = replace(':LINK1:',$link1,$template);
$template = replace(':LINK2:',$link2,$template);
$template = replace(':LINK3:',$link3,$template);

//Get the featured adoptable...
$featured = getfeatured();
$template = replace(':FEATURED:',$featured,$template);

//Ad Management
$header = @file_get_contents("ads/header.txt");
$footer = @file_get_contents("ads/footer.txt");
$tower = @file_get_contents("ads/tower.txt");

$header = stripslashes($header);
$footer = stripslashes($footer);
$tower = stripslashes($tower);

$template = replace(':HEADERAD:',$header,$template);
$template = replace(':FOOTERAD:',$footer,$template);
$template = replace(':TOWERAD:',$tower,$template);

//Is the user logged in?
//$isloggedin = "no";
if ($isloggedin == "yes"){
$query = "SELECT * FROM `users` WHERE `username` = '".$luser."'";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i=0;
    while ($i < 1) {
    
    $money =@mysql_result($result,$i,"money");
    $i++;
            }
$template = replace(':WELCOMEORREGISTER:','',$template);
$template = replace(':LOGINORACCT:', '<p>Hi, '.$username.'
<p>Currency name: '.$money.'
<p><a href="logout.php">Log out</a>' ,$template); 
else{

//User is not logged in
$template = replace(':WELCOMEORREGISTER:','<u>Member Login:</u>',$template);
$loginform = "<form name='form1' method='post' action='login.php'>
  <p>Username: 
    <input name='username' type='text' id='username'>
</p>
  <p>Password: 
    <input name='password' type='password' id='password'>
</p>
  <p>
    <input type='submit' name='Submit' value='Submit'>
  </p>
  <p>Don't have an account?<br>
  <a href='register.php'>Register Free</a>  </p>
</form>
";
$template = replace(':LOGINORACCT:', $loginform ,$template);
}

echo $template;
?>

Please help. Thanks =)

With yours, you were missing one of these: "}"

This is the correct code :)

Code:
<?php

// Easy Adoptables Script by Brandon Rusnak
// Get our includes out of the way

include("inc/functions.php");
include("inc/config.php");
include("inc/settings.php");
include("inc/nbbc.php");  // BBCODE Parser
$bbcode = new BBCode;

// Connect to our database

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql database!');
mysql_select_db($dbname);


//Set up our login info...
$username = "";
$password = "";

//Check for cookie

if (isset($_COOKIE['adoptu']) and isset($_COOKIE['adoptp'])){

$username = $_COOKIE['adoptu'];
$password = $_COOKIE['adoptp'];

$username = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $username);
$password = preg_replace("/[^a-zA-Z0-9s]/", "", $password);

//Run login operation
$query = "SELECT * FROM users WHERE username = '$username'";
$result = mysql_query($query);
$num = mysql_numrows($result);

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

$luser=@mysql_result($result,$i,"username");
$lpass=@mysql_result($result,$i,"password");

$i++;
}

    if($username == $luser and $password == $lpass){
        $isloggedin = "yes";
    }
    else{
    if (isset($_COOKIE['adoptu'])){
    $past = time() - 10;
    setcookie("adoptu",$username,$past);
    }

    if (isset($_COOKIE['adoptp'])){
    $past = time() - 10;
    setcookie("adoptp",$password,$past);
    }
    $isloggedin = "no";
    }

}
else
{
//User is not logged in
$isloggedin = "no";

}



// Define our Template File

$file = $current_theme;



// Get our content for the index page

$query = "SELECT * FROM article_content WHERE page = 'index'";
$result = mysql_query($query);
$num = mysql_numrows($result);

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

$article_title=mysql_result($result,$i,"title");
$article_date=mysql_result($result,$i,"date");
$article_content=mysql_result($result,$i,"content");

$i++;
}

$article_title = stripslashes($article_title);
$article_content = stripslashes($article_content);

$article_content = $bbcode->Parse($article_content);

// Run the BBCODE parser on the content

// Should we show the extra pages in the nav bar?

$link1 = "";
if($show_extra_page1 == "yes"){
$link1 = "<li><a href='$extra_page1_link'>$extra_page1_name<span class='tab-l'></span><span class='tab-r'></span></a></li>";
}

$link2 = "";
if($show_extra_page2 == "yes"){
$link2 = "<li><a href='$extra_page2_link'>$extra_page2_name<span class='tab-l'></span><span class='tab-r'></span></a></li>";
}

// Do the template changes and echo the ready template

$template = file_get_contents($file);
$template = replace(':SITETITLE:',$site_title,$template);
$template = replace(':SITENAME:',$site_name,$template);
$template = replace(':ARTICLETITLE:',$article_title,$template);
$template = replace(':ARTICLEDATE:',$article_date,$template);
$template = replace(':ARTICLECONTENT:',$article_content,$template);
$template = replace(':LINK1:',$link1,$template);
$template = replace(':LINK2:',$link2,$template);
$template = replace(':LINK3:',$link3,$template);

//Get the featured adoptable...
$featured = getfeatured();
$template = replace(':FEATURED:',$featured,$template);

//Ad Management
$header = @file_get_contents("ads/header.txt");
$footer = @file_get_contents("ads/footer.txt");
$tower = @file_get_contents("ads/tower.txt");

$header = stripslashes($header);
$footer = stripslashes($footer);
$tower = stripslashes($tower);

$template = replace(':HEADERAD:',$header,$template);
$template = replace(':FOOTERAD:',$footer,$template);
$template = replace(':TOWERAD:',$tower,$template);

//Is the user logged in?
//$isloggedin = "no";
if ($isloggedin == "yes"){
$query = "SELECT * FROM `users` WHERE `username` = '".$luser."'";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i=0;
    while ($i < 1) {
    
    $money =@mysql_result($result,$i,"money");
    $i++;
            }
$template = replace(':WELCOMEORREGISTER:','',$template);
$template = replace(':LOGINORACCT:', '<p>Hi, '.$username.'
<p>Currency name: '.$money.'
<p><a href="logout.php">Log out</a>' ,$template);

}
else{

//User is not logged in
$template = replace(':WELCOMEORREGISTER:','<u>Member Login:</u>',$template);
$loginform = "<form name='form1' method='post' action='login.php'>
  <p>Username:
    <input name='username' type='text' id='username'>
</p>
  <p>Password:
    <input name='password' type='password' id='password'>
</p>
  <p>
    <input type='submit' name='Submit' value='Submit'>
  </p>
  <p>Don't have an account?<br>
  <a href='register.php'>Register Free</a>  </p>
</form>
";
$template = replace(':LOGINORACCT:', $loginform ,$template);
}

echo $template;
?>

:p
 
RE: [In Development] Currency for leveling up

I like it but.....I can't put it on....I can't find the right place for it :(
 
Status
Not open for further replies.

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top