PasteSite is open to the public, but with limited features. Register to be able to modify access rights, track your pastes and more...
If you prefer reading light text on a dark background to dark text on a light background, then you might want to try the dark theme.
"Untitled" by Anonymous [Plain Text]Actions:
Replies: |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
<?php
include 'connect.php';
include 'header.php';
if(!isset($_COOKIE['member_id']))
die("Not logged in, please <a href='index.php'>login</a>.");
$Player=$_COOKIE['member_id'];
$cmd=$_GET['cmd'];
$Buy=$_GET['buy'];
$ID=$_POST['ItemId'];
$Query="SELECT * FROM Users WHERE ID='$Player'";
$Query2=mysql_query($Query) or die("Could not get user stats.");
$User=mysql_fetch_array($Query2);
//potions listing
if($cmd==1)
{
print "<div><table><tr><td>Potion Name</td><td> </td><td>Life Healed</td><td> </td><td>Mana Restored</td><td> </td><td>Cost</td><td> </td><td>Quantity</td><td> </td><td>Buy?</td><td> </td><td>Quantity Owned</td></tr>";
$Query=mysql_query("SELECT * FROM Items WHERE ItemClass='Pot1' and Owner='$Player'") or die("Could not find item amount.");
$Amount=mysql_fetch_array($Query);
print "<form method=\"post\" action=\"shop.php?cmd=2&&IC=Pot1\"><tr><td><input type=\"hidden\" name=\"Name\" value=\"Potion of Almost-Useless Healing\" />Potion of Almost-Useless Healing</td><td> </td><td><input type=\"hidden\" name=\"Life\" value=\"50\" />50</td><td> </td><td><input type=\"hidden\" name=\"Mana\" value=\"0\" />0</td><td> </td><td><input type=\"hidden\" name=\"Worth\" value=\"10\" />10g each</td><td> </td><td><input type=\"text\" name=\"Amount\" size=\"4\" value=\"1\" /></td><td> </td><td><input type=\"submit\" value=\"Yes\" /></td><td> </td><td>$Amount[Amount]</td></tr></form>";
$Query=mysql_query("SELECT * FROM Items WHERE ItemClass='Pot2' and Owner='$Player'") or die("Could not find item amount.");
$Amount=mysql_fetch_array($Query);
print "<form method=\"post\" action=\"shop.php?cmd=2&&IC=Pot2\"><tr><td><input type=\"hidden\" name=\"Name\" value=\"Common Weak Herb\" />Common Weak Herb</td><td> </td><td><input type=\"hidden\" name=\"Life\" value=\"0\" />0</td><td> </td><td><input type=\"hidden\" name=\"Mana\" value=\"50\" />50</td><td> </td><td><input type=\"hidden\" name=\"Worth\" value=\"10\" />10g each</td><td> </td><td><input type=\"text\" name=\"Amount\" size=\"4\" value=\"1\" /></td><td> </td><td><input type=\"submit\" value=\"Yes\" /></td><td> </td><td>$Amount[Amount]</td></tr></form>";
print "</table></div>";
print "<p><a href=\"shop.php\">Go Back</a></p>";
}
//buying potions
elseif($cmd==2)
{
$PotClass=$_GET['IC'];
$Amount=$_POST['Amount'];
$Worth=$_POST['Worth']*$Amount;
$PotName=$_POST['Name'];
$Life=$_POST['Life'];
$Mana=$_POST['Mana'];
if($User['Gold']<$Worth)
{
print "Click <a href=\"shop.php?cmd=1\">here</a> to go back.";
die("Not enough gold!");
}
if($Amount<=0)
{
print "Click <a href=\"shop.php?cmd=1\">here</a> to go back.";
die("Input a positive number at \"Amount\" please.");
}
$Query="SELECT * FROM Items WHERE ItemClass='$PotClass' and Owner='$Player'";
$Query2=mysql_query($Query);
$Potions=mysql_fetch_array($Query2);
if($Potions['ID'])
{
$Query="UPDATE Items SET Amount=Amount+'$Amount', Worth=Worth+'$Worth' WHERE ID='$Potions[ID]'";
$Query2=mysql_query($Query) or die("Could not update items.");
}
else
{
$Query="INSERT INTO Items(Name, Owner, ItemClass, Worth, Strength, Intelligence, Amount) VALUES('$PotName', '$Player', '$PotClass', '$Worth', '$Life', '$Mana', '$Amount')";
$Query2=mysql_query($Query) or die("Could not add items.");
}
mysql_query("UPDATE Users SET Gold=Gold-'$Worth' WHERE ID='$Player'") or die("Could not update player.");
print "<div>Potion bought! <a href='shop.php?cmd=1'>Go back</a>.</div>";
}
//sell items listing
elseif($cmd==3)
{
$Query=mysql_query("SELECT * FROM Items WHERE Owner='$Player' AND ItemClass!='Pot1' AND ItemClass!='Pot2'") or die("Could not get inventory listing.");
print "<div><table><tr><td>Item Name</td><td> </td><td>Item Class</td><td> </td><td>Price</td><td> </td><td>Strength</td><td> </td><td>Constitution</td><td> </td><td>Dexterity</td><td> </td><td>Concentration</td><td> </td><td>Intelligence</td><td> </td><td>Sell?</td></tr>";
$Equip="";
while($Item=mysql_fetch_array($Query))
{
if($Item['Equipped']=="yes")
$Item['Name']="$Item[Name] {Equipped}";
echo "<tr><td>$Item[Name]</td><td> </td><td>$Item[ItemClass]</td><td> </td><td>$Item[Worth]</td><td> </td><td>+$Item[Strength]</td><td> </td><td>+$Item[Constitution]</td><td> </td><td>+$Item[Dexterity]</td><td> </td><td>+$Item[Intelligence]</td><td> </td><td>+$Item[Concentration]</td><td> </td><td><form action=\"shop.php?cmd=6\" method=\"post\"><input type=\"hidden\" value=\"$Item[ID]\" name=\"ItemID\" /><input type=\"submit\" name=\"sell\" value=\"sell\" /></form></td></tr>";
}
print "</table></div>";
print "<p><a href=\"shop.php\">Go back</a></p>";
}
//buy items listing
elseif($cmd==4)
{
$Query="SELECT * FROM Items WHERE Worth<='$User[Level]'*'40' ORDER BY Worth ASC";
$Query2=mysql_query($Query) or die("Could not get items.");
print "<div><table><tr><td>Item Name</td><td> </td><td>Item Class</td><td> </td><td>Cost</td><td> </td><td>Strength</td><td> </td><td>Constitution</td><td> </td><td>Dexterity</td><td> </td><td>Concentration</td><td> </td><td>Intelligence</td><td> </td><td>Buy?</td></tr>";
while($Item=mysql_fetch_array($Query2))
{
echo "<tr><td>$Item[Name]</td><td> </td><td>$Item[ItemClass]</td><td> </td><td>".number_format($Item[Worth])."</td><td> </td><td>+$Item[Strength]</td><td> </td><td>+$Item[Constitution]</td><td> </td><td>+$Item[Dexterity]</td><td> </td><td>+$Item[Concentration]</td><td> </td><td>+$Item[Intelligence]</td><td> </td><td><form action=\"shop.php\" method=\"post\"><input type=\"hidden\" value=\"5\" name=\"cmd\" /><input type=\"hidden\" value=\"$Item[Name]\" name=\"Itemname\" /><input type=\"submit\" name=\"buy\" value=\"buy\" /></form></td></tr>";
}
print "</table></div>";
print "<p><a href=\"shop.php\">Go back</a></p>";
}
//buy item
elseif($cmd==5)
{
$Itemname=$_POST['Itemname'];
$Query="SELECT * FROM Items WHERE Name='$Itemname'";
$Query2=mysql_query($Query) or die("Could not get item stats.");
$Item=mysql_fetch_array($Query2);
if($User['Gold']>=$Item['Worth'])
{
if($User['Items']!="")
$Item2="$User[Inventory],$Item[ID]";
else
$Item2="$Item[ID]";
if(strlen($User['Items'])>100)
print "You have too much in your inventory to purchase more. Sell something first.";
else
{
$Update="UPDATE Users SET Gold=Gold-'$Item[Worth]' AND Items='$Item2' WHERE ID='$Player'";
mysql_query($Update) or die("Could not update player stats.");
}
print "You bought a $Item[Name] for $Item[Worth]g";
}
else
print "You do not have enough gold.";
print "<p><a href=\"shop.php?cmd=4\">Go back</a></p>";
}
//sell item
elseif($cmd==6)
{
$Query=mysql_query("SELECT * FROM Items WHERE ID='$ID'") or die("Could not get inventory");
$Item=mysql_fetch_array($Query);
if($User['Items']==0)
{
$Items=0;
}
else
{
$Items=$User['Items']-1;
}
if($Item['Equipped']=="yes")
{
$Strength2=$Item['Strength'];
$Constitution2=$Item['Constitution'];
$Dexterity2=$Item['Dexterity'];
$Concentration2=$Item['Concentration'];
$Intelligence2=$Item['Intelligence'];
$Query2="UPDATE Users SET Strength=Strength-'$Strength', Constitution=Constitution-'$Constitution', Dexterity=Dexterity-'$Dexterity', Intelligence=Intelligence-'$Intelligence', Concentration=Concentration-'$Concentration' WHERE ID='$Player'";
$Query3="UPDATE Items SET Equipped='no' WHERE ID='$Item[ID]'";
mysql_query($Query2) or die("Could not remove weapon.");
mysql_query($Query3) or die("Could not remove weapon.");
mysql_query("UPDATE Users SET Gold=Gold+'$Item[Worth]', Items='$Items' WHERE ID='$Player'") or die("Could not update player.");
mysql_query("DELETE FROM Items WHERE ID='$ID'") or die("Could not remove item.");
echo "<div>Item sold.</div><p><a href=\"shop.php?cmd=3\">Go back</a></p>";
}
else
{
mysql_query("UPDATE Users SET Gold=Gold+'$Item[Worth]', Items='$Items' WHERE ID='$Player'") or die("Could not update player.");
mysql_query("DELETE FROM Items WHERE ID='$ID'") or die("Could not remove item.");
echo "<div>Item sold.</div><p><a href=\"shop.php?cmd=3\">Go back</a></p>";
}
}
else
{
print "<a href=\"shop.php?cmd=1\">Buy Potions</a><br />";
print "<a href=\"shop.php?cmd=3\">Sell Items</a><br />";
print "<a href=\"shop.php?cmd=4\">Buy Items</a>";
}
?>
|