Hi everyone,
Well i decided to update the boring old crystal temple. you maybe thinking what are the updates. The updates are listed below.
Updates
You can Buy crystals from the crystal temple
You can refill your brave
You can refill your will
New and better look
Its a simple update
<?php
include "globals.php";
$_GET['spend'] = isset($_GET['spend']) && is_string($_GET['spend']) ? strtolower(trim($_GET['spend'])) : "";
if(!$_GET['spend'])
{
echo "Welcome to the crystal temple!
";
echo sprintf("You have [b]%s[/b] crystals.
", number_format($ir['crystals']));
echo "What would you like to spend your crystals on?
";
echo "
";
echo "<table width = '65%' cellspacing = '1' class = 'table' />
<tr />
<th />Action</th>
<th />Price/Per Trade</th>
<th />Refill/Trade</th>
</tr>";
echo sprintf("<tr /><td />Energy Refill</td>
<td />%s Crystals</td>
<td />[url='crystaltemple.php?spend=refill']Refill[/url]</td></tr>", number_format($set['ct_refillprice']));
echo sprintf("<tr /><td />Brave Refill</td>
<td />%s Crystals</td>
<td />[url='crystaltemple.php?spend=refillb']Refill[/url]</td></tr>", number_format($set['ct_refillprice']));
echo sprintf("<tr /><td />Will Refill</td>
<td />%s Crystals</td>
<td />[url='crystaltemple.php?spend=refillw']Refill[/url]</td></tr>", number_format($set['ct_refillprice']));
echo sprintf("<tr /><td />IQ Trade</td>
<td />%s IQ per Crystal</td>
<td />[url='crystaltemple.php?spend=iq']Trade[/url]</td></tr>", number_format($set['ct_iqpercrys']));
echo sprintf("<tr /><td />Money Trade</td>
<td />\$%s per Crystal</td>
<td />[url='crystaltemple.php?spend=money']Trade[/url]</td></tr>", number_format($set['ct_moneypercrys']));
echo sprintf("<tr /><td />Buying Crystals</td>
<td />\$%s each</td>
<td />[url='crystaltemple.php?spend=crystals']Buy[/url]</td></tr>", number_format(200));
echo "</table>";
}
else
{
if($_GET['spend'] == 'refill')
{
if($ir['crystals'] < $set['ct_refillprice'])
{
echo "You don't have enough crystals!";
$h->endpage();
exit;
}
if($ir['energy'] == $ir['maxenergy'])
{
echo "You already have full energy.";
$h->endpage();
exit;
}
$RefilEnergy = sprintf("UPDATE users SET energy = maxenergy, crystals = crystals - %u WHERE (userid = %u)", $set['ct_refillprice'], $userid);
$db->query($RefilEnergy);
echo sprintf("You have paid %s crystals to refil your energy bar.", number_format($set['ct_refillprice']));
}
else if($_GET['spend'] == 'refillb')
{
if($ir['crystals'] < $set['ct_refillbprice'])
{
echo "You don't have enough crystals!";
$h->endpage();
exit;
}
if($ir['brave'] == $ir['maxbrave'])
{
echo "You already have full brave.";
$h->endpage();
exit;
}
$RefilBrave = sprintf("UPDATE users SET brave = maxbrave, crystals = crystals - %u WHERE (userid = %u)", $set['ct_refillbprice'], $userid);
$db->query($RefilBrave);
echo sprintf("You have paid %s crystals to refil your brave bar.", number_format($set['ct_refillprice']));
}
else if($_GET['spend'] == 'refillw')
{
if($ir['crystals'] < $set['ct_refillwprice'])
{
echo "You don't have enough crystals!";
$h->endpage();
exit;
}
if($ir['will'] == $ir['maxwill'])
{
echo "You already have full will.";
$h->endpage();
exit;
}
$RefilWill = sprintf("UPDATE users SET will = maxwill, crystals = crystals - %u WHERE (userid = %u)", $set['ct_refillwprice'], $userid);
$db->query($RefilWill);
echo sprintf("You have paid %s crystals to refil your will bar.", number_format($set['ct_refillprice']));
}
else if($_GET['spend'] == 'iq')
{
echo "Type in the amount of crystals you want to swap for IQ.
";
echo sprintf("You have [b]%s[/b] crystals.
", number_format($ir['crystals']));
echo sprintf("One crystal = %s IQ.", number_format($set['ct_iqpercrys']));
echo "<form action='crystaltemple.php?spend=iq2' method='post'>";
echo "<input type='text' name='crystals' />
";
echo "<input type='submit' value='Swap' />";
echo "</form>";
}
else if($_GET['spend'] == 'iq2')
{
$_POST['crystals'] = (float) $_POST['crystals'];
if($_POST['crystals'] <= 0 || $_POST['crystals'] > $ir['crystals'])
{
echo "Error, you either do not have enough crystals or did not fill out the form.
[url='crystaltemple.php?spend=iq']Back[/url]";
$h->endpage();
exit;
}
$iqgain = ($_POST['crystals'] * $set['ct_iqpercrys']);
$TakeCrystals = sprintf("UPDATE users SET crystals = crystals - %s WHERE (userid = %u)", $_POST['crystals'], $userid);
$GiveIQ = sprintf("UPDATE userstats SET IQ = IQ + %s WHERE (userid = %u)", $iqgain, $userid);
$db->query($TakeCrystals);
$db->query($GiveIQ);
echo sprintf("You traded %s crystals for %s IQ.", number_format($_POST['crystals']), number_format($iqgain));
}
else if($_GET['spend'] == 'money')
{
echo "Type in the amount of crystals you want to swap for money.
";
echo sprintf("You have [b]%s[/b] crystals.
", number_format($ir['crystals']));
echo sprintf("One crystal = \$%s.", number_format($set['ct_moneypercrys']));
echo "<form action='crystaltemple.php?spend=money2' method='post'>";
echo "<input type='text' name='crystals' />
";
echo "<input type='submit' value='Swap' />";
echo "</form>";
}
else if($_GET['spend'] == 'money2')
{
$_POST['crystals'] = (float) $_POST['crystals'];
if($_POST['crystals'] <= 0 || $_POST['crystals'] > $ir['crystals'])
{
echo "Error, you either do not have enough crystals or did not fill out the form.
[url='crystaltemple.php?spend=money']Back[/url]";
$h->endpage();
exit;
}
$moneygain = ($_POST['crystals']*$set['ct_moneypercrys']);
$SellCrystals = sprintf("UPDATE users SET crystals = crystals - %s, money = money + %s WHERE (userid = %u)", $_POST['crystals'], $moneygain, $userid);
$db->query($SellCrystals);
echo sprintf("You traded %s crystals for \$%s.", number_format($_POST['crystals']), number_format($moneygain));
}
else if($_GET['spend'] == 'crystals')
{
echo "Type in the amount of crystals you want.
";
echo sprintf("You have [b]\$%s[/b].
", number_format($ir['money']));
echo sprintf("\$%s per crystal.", number_format(200));
echo "<form action='crystaltemple.php?spend=crystals2' method='post'>";
echo "<input type='text' name='crystals' />
";
echo "<input type='submit' value='Purchase' />";
echo "</form>";
}
else if($_GET['spend'] == 'crystals2')
{
$_POST['crystals'] = (float) $_POST['crystals'];
$cost = ($_POST['crystals'] * 200);
if($_POST['crystals'] <= 0 || $cost > $ir['money'])
{
echo sprintf("%s crystals costs \$%s. You don't have enough!", number_format($_POST['crystals']), number_format($cost));
echo "
[url='crystaltemple.php?spend=crystals']Back[/url]";
$h->endpage();
exit;
}
$crysgain = ($_POST['crystals'] * 200);
$BuyCrystals = sprintf("UPDATE users SET money = money - %s, crystals = crystals + %s WHERE (userid = %u)", $crysgain, $_POST['crystals'], $userid);
$db->query($BuyCrystals);
$s = ($_POST['crystals'] == 1) ? "" : "s";
echo sprintf("You bought %s crystal%s for \$%s.", number_format($_POST['crystals']), $s, number_format($crysgain));
}
}
$h->endpage();
?>
Screenshot
http://img509.imageshack.us/img509/462/imagecm2.png
If you find any errors post them and i will try and fix them.
Add one me if you like it or use it.
Thanks.