Location: PHPKode > projects > Crown of Evanion > final/castle.php
*   This file is part of 'Crown of Evanion'.
*    'Crown of Evanion' is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*    'Crown of Evanion' is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    GNU General Public License for more details.
*    You should have received a copy of the GNU General Public License
*    along with 'Crown of Evanion'; if not, write to the Free Software
*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

$title = "Royal Castle";

if(!$Username) {
	header("location: login.php");

echo "<div align=\"center\"><p class=\"drag\"><a href=$PHP_SELF?page=staff>Kingdom Rulers</a> | <a href=$PHP_SELF?page=donate>Donate to the Kingdom</a> | <a href=$PHP_SELF?page=funds>Royal Treasury Report</a> | <a href=$PHP_SELF?page=honor>Honor Plaque</a> | <a href=$PHP_SELF?page=search>User Registry</a></p>";

$errors = array(
'1' => "<h5>You must enter a number.</h5>",
'2' => "<h5>You must donate a positive amount.</h5>",
'3' => "<h5>You don't have that much money to donate.</h5>",

if(!$page) {
	echo "<div align=\"center\">
	<p>Welcome to His Majesty's Royal Court. His Kingship Himself resides within these walls, protecting you all from eminent dangers. Do not become disruptive; for if He must rise to deal with you, you may not walk out in one peice.</p>";

if($page == "staff") {
	$select = mysql_query("SELECT username,status,usertitle FROM users WHERE status > 2");
	echo "<p>The following individuals are members of His Majesty's Royal Court. They help him run His kingdom.</p>
	while ($staff = mysql_fetch_array($select)) {
		echo "<li>$staff[username] - $staff[usertitle]</li>";
	echo "</OL>";

if($page == "donate") {
	echo "
	<p>His Royal Treasurer collects donations for The Kingdom here in his office.</p>
	<p>How much would you like to donate?</p>
	<form action=\"$PHP_SELF\" method=\"POST\">
	<input type=\"hidden\" name=\"page\" value=\"donatepro\">
	<input type=\"text\" name=\"donated\">
	<input type=\"submit\" value=\"Donate\">

if($page == "donatepro") {
	$donated = $_POST['donated'];
	if(!ereg('[0-9]',$donated)) {
		header("location: $PHP_SELF?error=1");
	if($donated <= 0) {
		header("location: $PHP_SELF?error=2");
	if($donated > $Money) {
		header("location: $PHP_SELF?error=3");
	mysql_query("UPDATE users SET money = money-$donated WHERE id = '$UserID'");
	mysql_query("UPDATE funds SET amount = amount+$donated WHERE fund = 'donations'");
	mysql_query("UPDATE users SET donated = donated+$donated WHERE id = '$UserID'");
	echo "The Kingdom thanks you for your generous contribution!";

if($page == "funds") {
	$select = mysql_query("SELECT * FROM funds WHERE fund = 'shops'");
	$fund1 = mysql_fetch_array($select);
	echo "<p>Shop Revenue: $fund1[amount] Money</p>";
	$select = mysql_query("SELECT * FROM funds WHERE fund = 'donations'");
	$fund2 = mysql_fetch_array($select);
	echo "<p>Donations: $fund2[amount] Money</p>";
	$select = mysql_query("SELECT * FROM funds WHERE fund = 'treasure'");
	$fund3 = mysql_fetch_array($select);
	echo "<p>Treasure: $fund3[amount] Money</p>";
	$total = $fund1[amount]+$fund2[amount]+$fund3[amount];	
	echo "<p>Total: $total Money</p>";

if($page == "honor") {
	echo "<h3>Honor Plaque</h3>
	<p>This plaque displays the most honored of our citizens. These individuals either won a great battle, found a great amount of bugs, or did some other nobel deed.</p>
	$select = mysql_query("SELECT * FROM honor ORDER BY points DESC");
	while ($honored = mysql_fetch_array($select)) {
		echo "<li>$honored[user]</li>";

if($page == "search") {
	if(!$who) {
		echo "<p>Who would you like to look up in the registry?</p>
		<form action=\"$PHP_SELF\" method=\"POST\">
		<input type=\"hidden\" name=\"page\" value=\"search\">
		<input type=\"text\" name=\"who\">
		<input type=\"submit\" value=\"Search!\">
	if($who) {
		$who = $_POST['who'];
		$who = str_replace(" ","",$who);
		$who = str_replace("&","",$who);
		$select = mysql_query("SELECT id,username FROM users WHERE username LIKE '$who'");
		while($users = mysql_fetch_array($select)) {
			echo "<p><strong>User:</strong> $users[username]</p>";
		$select = mysql_query("SELECT name FROM dragons WHERE name LIKE '$who'");
		while($dragons = mysql_fetch_array($select)) {
			echo "<p><strong>Dragon:</strong> $dragons[name]</p>";
echo "</div>";
Return current item: Crown of Evanion