Location: PHPKode > projects > Blackbeard's Revenge > headers.php
<?php
session_start(); 
header("Cache-control: private");

echo "<!DOCTYPE HTML PUBLIC \"-\//W3C\//DTD HTML 4.0 Transitional\//EN\">";
echo "<HTML>";
echo "<HEAD>";
echo "<TITLE> Blackbeard's Revenge </TITLE>";
echo "<META NAME=\"Generator\" CONTENT=\"PHP\">";
echo "<META NAME=\"Author\" CONTENT=\"Brian Austin\">";
echo "<META NAME=\"Keywords\" CONTENT=\"Blackbeard, Revenge, Pirate\">";
echo "<META NAME=\"Description\" CONTENT=\"Blackbeard's Revenge\">";
echo "</HEAD>";
echo "<LINK rel=\"stylesheet\" href=\"main.css\" type=\"text/css\">";

//Constants for character sheet
define ("MAXAGE", 40);
define ("MINAGE", 21);
define ("AGESCALER", .4);
//------------------------
define ("MAXCHAR", 100);
define ("MINCHAR", 1);
define ("CHARSCALER", 2);
//------------------------
define ("MAXGUNN", 389);
define ("MINGUNN", 1);
define ("GUNNSCALER", 7.78);
//------------------------
define ("MAXSAIL", 259);
define ("MINSAIL", 1);
define ("SAILSCALER", 5.18);
//------------------------
define ("MAXEXP", 900000000);
define ("MINEXP", 1);
define ("EXPSCALER", 18000000);
//------------------------
define ("MAXHULL", 300);
define ("MINHULL", 1);
define ("HULLSCALER", 24);

//------------------------
define ("MAXARMOR", 55);
define ("MINARMOR", 1);
define ("ARMORSCALER", 24);
define ("ARMORCOST", 350);

//------------------------
define ("MAXCANNON", 120);
define ("MINCANNON", 1);
define ("CANNONSCALER", 10);
define ("CANNONCOST", 150);

//ship information (will be located in a database)
//define ("SHIPMAX", 4);

if($_POST["login"])
{
//game info
	$_SESSION['attack'] = false;
	
	$_SESSION['turns'] = 5;
	//Opponent variables
	$_SESSION["opponentshipnum"] = 0;
	//$_SESSION["opponentshiphull"] = 0;
	//$_SESSION["opponentshipmaxhull"] = 0;
}
//else
//{
//	$_SESSION['playergold'];
//}

function DisplayMessage($message)
{
	//Displays a general message in the standard message area
	echo "<table class=\"data\" style=\"width:100%;height:60px;border-bottom:1px solid black\">";
	echo "<tr><td class=\"message\">";
	echo $message;
	echo "</td></tr></table>";
}

function LoadPlayer($uid)
{
	global $DEBUG;
	echo "LoadPlayers()<br>";
	//Load player ship stats
	$query = "SELECT * FROM players, ships WHERE players.uid = ships.ownerid AND players.uid = ".$uid." ";
	if($DEBUG) echo $query;
	if($DEBUG) echo "<Br>";
	$result = db_query($query);
	if($DEBUG) echo "query() = ". $result ."<br>";
	$_SESSION[user]=db_fetch_assoc($result);
	if($DEBUG) echo "SESSION[user] = ". $_SESSION[user] ."<br>";		
	
}

function SavePlayerShip()
{
	if($DEBUG) echo "Save my Ship<br>";
	if($DEBUG) echo "uid = " .$_SESSION['uid']." ";
	//Save updated ship information
	$sql = "UPDATE ships SET 
		cannon = ".$_SESSION['mycannons'].", 
		armour = ".$_SESSION['myarmor'].", 
		manuver = 0, 
		hull = ".$_SESSION['myshiphull'].", 
		cargo = 0 
		WHERE ownerid =".$_SESSION['uid']." ";

	if($DEBUG) echo $sql;
	db_query($sql) or die(db_error(LINK));
	if (db_affected_rows(LINK)<=0){
		//echo("`\$Error`^: Your account was not created for an unknown reason, please try again. ");
		//No updates made
	}

	//Save updated player information
	$sql = "UPDATE players SET				
			level = ".$_SESSION['playerlevel'].",
			shipname = '".$_SESSION['myshipname']."',
			experience = ".$_SESSION['experience'].",
			gold = ".$_SESSION['playergold'].",				
			charisma = ".$_SESSION['mycharisma'].",
			gunnery = ".$_SESSION['mygunnery'].",
			sailing = ".$_SESSION['mysailing'].",
			maps = ".$_SESSION['playermaps'].",
			turns = ".$_SESSION['turns']."
			WHERE uid=". $_SESSION['uid'] ." ";

	if($DEBUG) echo $sql;
	db_query($sql) or die(db_error(LINK));
	if (db_affected_rows(LINK)<=0){
		//echo("`\$Error`^: Your account was not created for an unknown reason, please try again. ");
		//No updates made
	}	
}


function LoadShips(){

	$query = "SELECT * FROM shiptype"; // WHERE id = ".$shiptype;
	if($DEBUG) echo $query;
	if($DEBUG) echo "<Br>";
	$result = db_query($query);
	if($DEBUG) echo "query() = ". $result ."<br>";
	$_SESSION[ships] = db_fetch_assoc($result);
	if($DEBUG) echo "SESSION[ships] = ". $_SESSION[ships] ."<br>";

	$x=0;
	while($row = db_fetch_assoc($result)){
		$_SESSION[ships][$x] = $row;
		$x++;
	}
}

function LoadEnemyShip($shipnum)
{
	$query = "SELECT * FROM shiptype WHERE id = ". $shipnum ."";
	if($DEBUG) echo $query;
	if($DEBUG) echo "<Br>";
	$result = db_query($query);
	if($DEBUG) echo "query() = ". $result ."<br>";
	$_SESSION[enemy] = db_fetch_assoc($result);
	if($DEBUG) echo "result() = ". $row ."<br>";
		
	/*if($row["password"] == $playerpassword)
	{
				
		$_SESSION['ShipName']  = $_SESSION[enemy]["class"];
		$_SESSION['ShipClass'] = $_SESSION[enemy]["class"];
			//-----------------------------------
		$_SESSION['ShipBaseCannon'] = $_SESSION[enemy]["basecannon"];
		$_SESSION['ShipMaxCannon']  = $_SESSION[enemy]["maxcannon"];
			//-----------------------------------
		$_SESSION['ShipBaseArmour'] = $_SESSION[enemy]["basearmour"];
		$_SESSION['ShipMaxArmour']  = $_SESSION[enemy]["maxarmour"];
			//-----------------------------------
		$_SESSION['ShipBaseManuver'] = $_SESSION[enemy]["basemanuver"];
		$_SESSION['ShipMaxManuver']  = $_SESSION[enemy]["maxmanuver"];
			//-----------------------------------
		$_SESSION['ShipBaseHull'] = $_SESSION[enemy]["basehull"];
		$_SESSION['ShipMaxHull']  = $$_SESSION[enemy]["maxhull"];
			//-----------------------------------
		$_SESSION['ShipBaseCrew']	= $_SESSION[enemy]["mincrew"];
		$_SESSION['ShipMaxCrew']	= $_SESSION[enemy]["maxcrew"];
		    //-----------------------------------
		$_SESSION['ShipMaxBooty']      = $_SESSION[enemy]["maxbooty"];	
		$_SESSION['ShipMaxExperience'] = $_SESSION[enemy]["maxexperience"];
		$_SESSION['ShipBaseValue']     = $_SESSION[enemy]["basevalue"];
		$_SESSION['ShipImage']         = $_SESSION[enemy]["shipimage"];*/

		$_SESSION[enemy]['basesailing']   = 5 * $_SESSION[user]['level'];
		$_SESSION[enemy]['basegunnery']   = 2 * $_SESSION[user]['level'];	
	//}

}

function ClearEnemyShip()
{
	//$_SESSION[enemy]["shipnum"] = 0;
	$_SESSION[enemy]["class"] = "No ship sighted";
	$_SESSION[enemy]["name"] = "None";
		//-----------------------------------
	$_SESSION[enemy]["basecannon"] = 0;
	$_SESSION[enemy]["maxcannon"] = 0;
		//-----------------------------------
	$_SESSION[enemy]["basearmour"] = 0;
	$_SESSION[enemy]["maxarmour"] = 0;
		//-----------------------------------
	$_SESSION[enemy]["basemanuver"] = 0;
	$_SESSION[enemy]["maxmanuver"] = 0;
		//-----------------------------------
	$_SESSION[enemy]["basehull"] = 999;
	$_SESSION[enemy]["maxhull"] = 999;
		//-----------------------------------
	$_SESSION[enemy]["mincrew"] = 0;
	$_SESSION[enemy]["maxcrew"] = 0;
		//-----------------------------------
	$_SESSION[enemy]["maxbooty"] = 0;	
	$_SESSION[enemy]["maxexperience"] = 0;
	$_SESSION[enemy]["basevalue"] = 0;
	$_SESSION[enemy]["shipimage"] = "none.png";

	$_SESSION[enemy]['basesailing']   = 1;
	$_SESSION[enemy]['basegunnery']   = 1;
}

function SaveNewPlayerShip()
{


	//Save updated ship information
	$sql = "UPDATE ships SET ownerid = 0 WHERE ownerid =".$_SESSION['uid']." ";

	if($DEBUG) echo $sql;
	db_query($sql) or die(db_error(LINK));
	if (db_affected_rows(LINK)<=0){
		//echo("`\$Error`^: Your account was not created for an unknown reason, please try again. ");
		//No updates made
	}


	$sql = "INSERT INTO ships 
						(ownerid,
						classname,
						shiptype,
						cannon,
						armour,
						manuver,
						hull,
						cargo,
						value						
					) VALUES (					
						".$_SESSION['uid'].",
						'".$_SESSION['myshipclass']."',	
						".$_SESSION['myshiptype'].",
						".$_SESSION['mycannons'].",
						".$_SESSION['myarmor'].",						
						".$_SESSION['myshipmanuver'].",
						".$_SESSION['myshiphull'].",
						0,
						".$_SESSION['myshipvalue'].")";

	if($DEBUG) echo $sql;
	db_query($sql) or die(db_error(LINK));
	if (db_affected_rows(LINK)<=0){
		//echo("`\$Error`^: Your account was not created for an unknown reason, please try again. ");
		//No updates made
	}

}

?>
Return current item: Blackbeard's Revenge