Location: PHPKode > projects > Merchant Empires > merchempires/merchantempires/bank_anonymous_display.php
<?php
/****************************************************************************
*    Copyright (C) 2000 Bryan Brunton
*
*    This program 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.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with this program; if not, write to the Free Software
*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/

page_open(array("sess" => "ME_Session_Uncached", "auth" => "ME_Auth", "user" => "ME_User"));
$sess->register("player_id");
$sess->register("player_dead");

include("./lib/player.php");
include("./lib/sector.php");
include("./lib/ship.php");
include("./merchantempiresdefines.php");
include("./lib/player_redirect.php");

$s1 = new ME_Sector;
$s1->get_sector($player_id);
$sector_id = $s1->f("sector_id");
?>

<html><head><title>Merchant Empires: Anonymous Bank</title>
<link rel=stylesheet href="./merchantempires.css" type=text/css>
</head><body text=white background="./images/createbg.gif"><?php

include("./templates/header.html");
?>

<table width=100%><tr>
<td width=100 vAlign=top><?php

$player = new ME_Player;
$player->get_player($player_id);
$player_dead = $player->f("dead");
$game_id = $player->f("game_id");
$ship = new ME_Ship;
$ship->get_ship($player_id);

$ship->add_parameter("time", date ("Y H:i:s"));
echo $ship->get_transform("./xslt/mainmenu.xslt", $ship->get_xml());
?>

</td>
<td vAlign=top align=left width=0>&nbsp;</td>
<td vAlign=top width=500><?php

$db = new ME_DB_Xml;
$db->query("SELECT * from locations where sector_id = '$sector_id' and type='Bank'");
$db->add_parameter("current_screen", "bank_anonymous");
echo $db->get_transform("./xslt/menu_top_bank.xslt", $db->get_xml());

$db = new ME_DB;
$db->query("select game_id, interestrate from games where game_id = '$game_id'");
$db->next_record();	
$interestrate = $db->f("interestrate");

$error = 0;

// Check if there was a submission
while (is_array($HTTP_POST_VARS)
  && list($key, $val) = each($HTTP_POST_VARS)) {

	switch ($key) {
		case "anonymous_access":
			$account_id = (int) $account_id;

   		if (empty($password) || empty($account_id)) {
				$error = "Please fill out all of the fields.";
				break;
			}

			$db = new ME_DB;
			$db->query("select * from accounts where public_account_id = '$account_id' and game_id = '$game_id'");
			$db->next_record();			
			
			if ( $db->nf() == 0 ) {
        $error = "No such account on record.";
				break;
			}

			if ( $password <> $db->f("password") )  {
      	$error = "Incorrect password.";
				break;
			}


?>
<table border=0 cellPadding=0 cellSpacing=0 width=500>
	<tr>
		<td bgColor=#003399>
			<table border=0 cellpadding=5 cellspacing=1 width=100%>
				<tr>
					<td bgColor=#000033>
					<font color=#ffffff face=arial,helvetica,swiss size=3>
					Anonymous Account : <?php

echo $account_id;
?>        </font>
					</td>
				</tr>
  			<tr>
        	<td bgColor=#000000><br>
						<font color=#3333FF face=arial,helvetica,swiss size=3><b>Account Status</b></font><br>
						&nbsp;<FONT color=#cccccc face=arial,helvetica,swiss size=2>Balance: </font><?php

echo $db->f("balance") . "<br>";
?>
						&nbsp;<FONT color=#cccccc face=arial,helvetica,swiss size=2>Interest:</font> <?php

echo $interestrate . "<br>";
?>
					</td>
				</tr>
				<tr>
        	<td bgColor=#000000><br>
						<font color=#3333FF face=arial,helvetica,swiss size=3><b>Transaction History</b></font><br>
						<FONT color=#cccccc face=arial,helvetica,swiss size=2><?php

						$transactions = array();
						$transactions = explode(",", $db->f("transactions"));

						while (list($key, $val) = each($transactions)) {		
							echo "&nbsp;&nbsp;" . stripslashes($val) . "<br>";
						}
?>					
					</td>
				</tr>
				<tr>
        	<td bgColor=#000000><br>
						<form method="POST" action=<?php $sess->purl(URL . "bank_transaction.php") ?>>
						<font color=#3333FF face=arial,helvetica,swiss size=3><b>Transaction</b></font><br>
						<table>
						<tr>
						<td>
						&nbsp;<FONT color=#cccccc face=arial,helvetica,swiss size=2>Amount: </font>
						</td>
						<td>
						<input type="textbox" name="amount">
						<input type="hidden" name="account_id" value=<?php echo $account_id ?>>
						<input type="hidden" name="password" value=<?php echo $password; ?>>
						</td>
						</tr>
						<tr>
						<td>
						</td>
						<td>
						<input type="submit" name="deposit_anonymous" value="Deposit">
						<input type="submit" name="withdraw_anonymous" value="Withdraw">
						</td>
						</tr>
            </table>
						</form>
					</td>
				</tr>
			</table>
		<td>
  </tr>
</table><?php

	}
}

if ( $error ) {	
	$db = new ME_DB_Xml;
	$db->add_parameter("title", "Error");
	$db->add_parameter("message", $error);
	echo $db->get_transform("./xslt/message_box.xslt", "");		
}
?>

</td>
<td valign=top align=right width=100%><?php

include("./messages_display.php");
echo $player->get_transform("./xslt/player.xslt", $player->get_xml());
include("./ship_display.php");
?>

</td></tr></table>
</body></html><?php

page_close();
?>
Return current item: Merchant Empires