<?
require "../../configmain.php";
require "../../global.php";
connectdb();?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><?
if ($banner == '1'){
echo $bannercode;
}
?><?
$useram = mysql_query("SELECT * FROM usr WHERE usr ='$user'");
$usera = mysql_fetch_array($useram);
$costm = mysql_query("SELECT cost, name, lc, mc, hc, fa, level FROM buildingtype WHERE buid ='$btype'");
$cost = mysql_fetch_array($costm);
$buildl = mysql_query("SELECT * FROM buildinglocation WHERE horz='$horz' and vert='$vert' and town ='$town'");
$buildloc = mysql_fetch_array($buildl);
if ($usera[1] != $password){
echo "incorrect password please log in again";
}
if ($usera[1] == $password){
if ($usera[9] <= $cost[0]){
echo "Not enough money to purchase land<br>You have $usera[9] money but the area costs $cost[0]<br>";
}
if($usera[8]<$cost[6]){
echo"you are not a high enough level to build this, sorry<br>";
}
if($usera[8]>=$cost[6]){
if ($usera[9] >= $cost[0]){
echo "You have enough money to Build a $cost[1]<br>";
$owner=$buildloc[4];
$owner2 = $owner;
if ($owner2 == $user){
echo "You own this land and can build here<br>";
if ($buildloc[3] == '0'){
$cb='1';//check to see if there are enough workers
$townm = mysql_query("SELECT * FROM towns WHERE tid ='$town'");
$towna = mysql_fetch_array($townm);
$uneploylc=$towna[10]-$towna[11];
$uneploymc=$towna[12]-$towna[13];
$uneployhc=$towna[14]-$towna[15];
$uneployfa=$towna[16]-$towna[17];
if($uneploylc<$cost[2] OR $uneploymc<$cost[3] OR $uneployhc<$cost[4] OR $uneployfa<$cost[5]){
$cb='0';
echo"Not enough workers in the town<br>";
}
if($cb=='1'){
$res = mysql_query("UPDATE buildinglocation SET buid ='$btype' where town='$town' and vert='$vert' and horz='$horz'");
$umoney = $usera[9] - $cost[0];
$res2 = mysql_query("UPDATE usr SET money='$umoney' where usr='$user'");
$newlc=$towna[11]+$cost[2];
$newmc=$towna[13]+$cost[3];
$newhc=$towna[15]+$cost[4];
$newfa=$towna[17]+$cost[5];
$res2 = mysql_query("UPDATE towns SET lce='$newlc' where tid='$town'");
$res2 = mysql_query("UPDATE towns SET mce='$newmc' where tid='$town'");
$res2 = mysql_query("UPDATE towns SET hce='$newhc' where tid='$town'");
$res2 = mysql_query("UPDATE towns SET fae='$newfa' where tid='$town'");
echo "Congratulations, you have build a $cost[1] (id is $btype)<br>";
}
}
if ($buildloc[3] != '0'){
echo "This is not a construction site";
}
}
if ($owner2 != $user){
echo "Some one else owns this land, you can not build here<br>";
}
}}
}
?> <br>
<br>
<a href="/world/location.php?&map=<?echo $town;?>&vert=<?echo $vert;?>&horz=<?echo $horz;?>">Return
to the building location</a><br>
<a href="/world/town.php?&map=<?echo $town;?>"">Return
to the town map </a> </p>
</body>
</html>