function go_build_base($planet_id, $sector_id) { global $db; global $db_logging; global $base_ore, $base_organics, $base_goods, $base_credits; global $l_planet_bbuild; global $username; echo "<br>Click <a href=planet_report.php?PRepType=1>here</A> to return to the Planet Status Report<br><br>"; $result = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id='{$user_ship_id}'"); db_op_result($db, $result, __LINE__, __FILE__, $db_logging); $playerinfo = $result->fields; $result2 = $db->Execute("SELECT * FROM {$db->prefix}universe WHERE sector_id={$playerinfo['sector']}"); db_op_result($db, $result2, __LINE__, __FILE__, $db_logging); $sectorinfo = $result2->fields; $result3 = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id={$planet_id}"); db_op_result($db, $result3, __LINE__, __FILE__, $db_logging); $planetinfo = $result3->fields; // Error out and return if the Player isn't the owner of the Planet // verify player owns the planet which is to have the base created on. if ($planetinfo['owner'] != $playerinfo['ship_id']) { echo "<div style='color:#f00; font-size:16px;'>Base Construction Failed!</div>\n"; echo "<div style='color:#f00; font-size:16px;'>Invalid Planet or Sector Information Supplied.</div>\n"; return (bool) false; } if (!is_numeric($planet_id) || !is_numeric($sector_id)) { $ip = $_SERVER['REMOTE_ADDR']; $hack_id = 0x1337; adminlog($db, LOG_ADMIN_PLANETCHEAT, "{$hack_id}|{$ip}|{$planet_id}|{$sector_id}|{$playerinfo['ship_id']}"); echo "<div style='color:#f00; font-size:16px;'>Base Construction Failed!</div>\n"; return (bool) false; } // build a base Real_Space_Move($sector_id); echo "<br>Click <a href=planet.php?planet_id={$planet_id}>here</A> to go to the Planet Menu<br><br>"; if ($planetinfo['ore'] >= $base_ore && $planetinfo['organics'] >= $base_organics && $planetinfo['goods'] >= $base_goods && $planetinfo['credits'] >= $base_credits) { // Create The Base $update1 = $db->Execute("UPDATE {$db->prefix}planets SET base='Y', ore={$planetinfo['ore']}-{$base_ore}, organics={$planetinfo['organics']}-{$base_organics}, goods={$planetinfo['goods']}-{$base_goods}, credits={$planetinfo['credits']}-{$base_credits} WHERE planet_id={$planet_id}"); db_op_result($db, $update1, __LINE__, __FILE__, $db_logging); // Update User Turns $update1b = $db->Execute("UPDATE {$db->prefix}ships SET turns=turns-1, turns_used=turns_used+1 WHERE ship_id={$playerinfo['ship_id']}"); db_op_result($db, $update1b, __LINE__, __FILE__, $db_logging); // Refresh Plant Info $result3 = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id={$planet_id}"); db_op_result($db, $result3, __LINE__, __FILE__, $db_logging); $planetinfo = $result3->fields; // Notify User Of Base Results echo "{$l_planet_bbuild}<br><br>"; // Calc Ownership and Notify User Of Results $ownership = calc_ownership($playerinfo['sector']); if (!empty($ownership)) { echo "{$ownership}<p>"; } } }
function go_build_base($planet_id, $sector_id) { global $db; global $dbtables; global $base_ore, $base_organics, $base_goods, $base_credits; global $l_planet_bbuild; global $username; echo "<BR>Click <A HREF=planet-report.php?PRepType=1>here</A> to return to the Planet Status Report<BR><BR>"; $result = $db->Execute("SELECT * FROM $dbtables[players] WHERE email='$username'"); $playerinfo=$result->fields; $result2 = $db->Execute("SELECT * FROM $dbtables[universe] WHERE sector_id=$playerinfo[sector]"); $sectorinfo=$result2->fields; $result3 = $db->Execute("SELECT * FROM $dbtables[planets] WHERE planet_id=$planet_id"); if($result3) $planetinfo=$result3->fields; $result4 = Real_Space_Move($sector_id); if ($result4 != "ON_PLANET" && $result4 != "HOSTILE") { // build a base if($planetinfo[ore] >= $base_ore && $planetinfo[organics] >= $base_organics && $planetinfo[goods] >= $base_goods && $planetinfo[credits] >= $base_credits) { // ** Create The Base $update1 = $db->Execute("UPDATE $dbtables[planets] SET base='Y', ore=$planetinfo[ore]-$base_ore, organics=$planetinfo[organics]-$base_organics, goods=$planetinfo[goods]-$base_goods, credits=$planetinfo[credits]-$base_credits WHERE planet_id=$planet_id"); // ** Update User Turns $update1b = $db->Execute("UPDATE $dbtables[players] SET turns=turns-1, turns_used=turns_used+1 where player_id=$playerinfo[player_id]"); // ** Refresh Plant Info $result3 = $db->Execute("SELECT * FROM $dbtables[planets] WHERE planet_id=$planet_id"); $planetinfo=$result3->fields; // ** Notify User Of Base Results echo "$l_planet_bbuild<BR><BR>"; // ** Calc Ownership and Notify User Of Results $ownership = calc_ownership($planetinfo[sector_id]); if(!empty($ownership)) { echo "$ownership<p>"; } echo "<BR>Click <A HREF=planet.php?planet_id=$planet_id>here</A> to go to the Planet Menu<BR><BR>"; } } }