function overview() { global $uid; $sth = mysql_query("select b.prod_id,b.count,b.side,p.name,p.typ,b.initiative,b.agility,b.hull,b.weaponpower,b.shield,b.ecm,b.target1,b.sensor,b.weaponskill,b.special,b.armor,b.num_attacks,s.initiative,s.agility,s.hull,s.weaponpower,s.shield,s.ecm,s.target1,s.sensor,s.weaponskill,s.special,s.armor,s.num_attacks from battle_" . $uid . " b, production p, shipvalues s where b.prod_id=p.prod_id and b.prod_id=s.prod_id order by side"); echo "<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"POST\">"; table_start("center", "700"); table_head_text(array("Battlesimulator"), 20); if (!$sth || mysql_num_rows($sth) == 0) { table_text(array("No ships"), "", "", "", "text"); } else { table_head_text(array("Side", "Name", "Type", "count", "initiative", "agility", "hull", "power", "shield", "ecm", "target1", "sensors", "skill", "special", "armor", "num_attacks", "mail")); while (list($prod_id, $count, $side, $name, $typ, $cur_ini, $cur_agi, $cur_hull, $cur_pow, $cur_shield, $cur_ecm, $cur_tar1, $cur_sen, $cur_skill, $cur_spec, $cur_arm, $cur_num, $ini, $agi, $hull, $pow, $shield, $ecm, $tar1, $sen, $skill, $spec, $arm, $num) = mysql_fetch_row($sth)) { table_text(array($side, $name, $typ, "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][count]\" size=\"4\" value=\"" . $count . "\">", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][initiative]\" size=\"3\" value=\"" . $cur_ini . "\"> (" . $ini . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][agility]\" size=\"3\" value=\"" . $cur_agi . "\"> (" . $agi . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][hull]\" size=\"3\" value=\"" . $cur_hull . "\"> (" . $hull . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][weaponpower]\" size=\"3\" value=\"" . $cur_pow . "\"> (" . $pow . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][shield]\" size=\"3\" value=\"" . $cur_shield . "\"> (" . $shield . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][ecm]\" size=\"3\" value=\"" . $cur_ecm . "\"> (" . $ecm . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][target1]\" size=\"3\" value=\"" . $cur_tar1 . "\"> (" . $tar1 . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][sensor]\" size=\"3\" value=\"" . $cur_sen . "\"> (" . $sen . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][weaponskill]\" size=\"3\" value=\"" . $cur_skill . "\"> (" . $skill . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][special]\" size=\"3\" value=\"" . $cur_spec . "\"> (" . $spec . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][armor]\" size=\"3\" value=\"" . $cur_arm . "\"> (" . $arm . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][num_attacks]\" size=\"3\" value=\"" . $cur_num . "\"> (" . $num . ")", "<a href=\"" . $_SERVER["PHP_SELF"] . "?act=suggest&side=" . $side . "&prod_id=" . $prod_id . "\">suggest change</a>"), "", "", "", "text"); } } table_form_submit("Change", "proc_change_values"); table_end(); echo "</form>"; $sth = mysql_query("select prod_id,name from production where typ in ('L','M','H','I') \norder by name"); if (!$sth) { show_error("database failersdfiosd"); return false; } echo "<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"POST\">"; table_start("center", "500"); table_head_text(array("Add ships"), "2"); while (list($prod_id, $name) = mysql_fetch_row($sth)) { $select[$name] = $prod_id; } table_form_select("Ship", "prod_id", $select, "2", "text", "text"); table_form_select("Side", "side", array(1 => 1, 2 => 2), "2", "text", "text"); table_form_text("Count", "count"); table_form_submit("Add ships", "proc_add_ships"); table_end(); echo "</form>"; echo "<br>"; echo "<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"POST\">"; table_start("center", "500"); table_head_text(array("Config"), "2"); table_form_select("Combat rounds", "rounds", array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 10 => 10), "1", "text", "text"); table_form_select("Fraction limit", "fraction", array(100 => 100, 250 => 250, 500 => 500, 1000 => 1000, 2000 => 2000, "no limit" => 0), "250", "text", "text"); table_form_select("Orbital Dig-In factor (Side 1)", "digino", array("no dig-in" => 0, 20 => 20, 40 => 40, 60 => 60, 65 => 65, 70 => 70, 75 => 75, 80 => 80, 85 => 85, 90 => 90, 95 => 95, 99 => 99), "0", "text", "text"); table_form_select("Orbital Dig-In bonus (Side 1)", "diginob", array("no bonus" => 0, 5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 55 => 55), "0", "text", "text"); table_form_select("Planetary Dig-In factor (Side 1)", "diginp", array("no dig-in" => 0, 20 => 20, 40 => 40, 60 => 60, 65 => 65, 70 => 70, 75 => 75, 80 => 80, 85 => 85, 90 => 90, 95 => 95, 99 => 99), "70", "text", "text"); table_form_select("Planetary Dig-In bonus (Side 1)", "diginpb", array("no bonus" => 0, 5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 55 => 55), "20", "text", "text"); table_form_select("Overall combat boost", "boost", array("no boost" => 1, 2 => 2, 3 => 3, 5 => 5), "1", "text", "text"); table_form_select("Verbosity", "verbosity", array("Results only" => 0, "Overview" => 1, "Full details" => 2), "1", "text", "text"); table_form_submit("Execute battle", "execute_battle"); table_end(); echo "</form>"; //print "<a href=\"".$_SERVER["PHP_SELF"]."?act=execute_battle\">Execute battle</a>"; }
function alliance_findform() { global $uid; global $PHP_SELF; $sth = mysql_query("select * from alliance"); if (!$sth) { show_error("Database failure!"); return 0; } echo "<br><br>\n"; table_start("center", "500"); table_head_text(array("Find Alliance"), "2"); table_text(array(" ", " "), "", "", "", "head"); echo "<form method=post action=\"" . $PHP_SELF . "\">\n"; table_form_text("Alliance", "name", "" . $name . "", "20", "20", "text"); table_form_submit("Find", "find_alliance", "0"); table_end(); echo "</form><br><br>\n"; }
function reply() { global $PHP_SELF; global $uid; global $id; $sth = mysql_query("select * from mail where id='{$id}'"); if (!$sth) { show_error("Database failure!"); return 0; } $mail = mysql_fetch_array($sth); if ($mail["uid"] != $uid) { show_error("I'm not stupid guy! :)"); return 0; } if (!(substr($mail["subject"], 0, 4) == "RE: ")) { $subject = "RE: " . $mail["subject"]; } else { $subject = $mail["subject"]; } $sth = mysql_query("select name from users where id='" . $mail["fuid"] . "'"); if (!$sth) { show_error("Database failure!"); return 0; } $user = mysql_fetch_array($sth); echo "<form action=\"" . $PHP_SELF . "\" method=post>\n"; table_border_start("Send new message"); table_form_text("Send to", "name", $user["name"]); table_form_text("Subject", "subject", $subject); table_form_textarea("Message", "text", $mail["text"]); table_form_submit("Send message", "send"); echo "</form>"; table_end(); }
function show_preferences() { global $uid; global $skin; global $PHP_SELF; $sth = mysql_query("select * from skins"); while ($skins = mysql_fetch_array($sth)) { $options[$skins["name"]] = $skins["id"]; } $sth = mysql_query("select admin from users where id={$uid}"); if (!$sth) { show_error("Database failuer!"); return 0; } $admin = mysql_fetch_array($sth); if ($admin["admin"] != "") { show_message("<a href='adminarea.php'>Enter Admin Area</a>"); } $map_info = new map_info($uid); if ($map_info->has_map_anims() == 1) { $checked = "checked"; } echo "<form method=POST action=\"" . $PHP_SELF . "\">"; table_start("center", "400"); table_head_text(array("Appearence"), "2"); table_text(array(" "), "", "", "2", "head"); table_form_select("Skin", "skin_new", $options, $skin, "head", "text"); table_form_submit("Change", "change_skin", "", "text"); table_end(); echo "</form>\n"; //runelord: map_sizes $sth = mysql_query("select map_size from options where uid=" . $uid); if (!$sth || !mysql_num_rows($sth)) { show_error("oops, DB Failure"); return 0; } list($current_map_size) = mysql_fetch_row($sth); $map_sizes_output = "<select name=\"map_size\" size=\"1\">"; $sth = mysql_query("SELECT * FROM map_sizes ORDER BY width ASC"); if (!$sth || !mysql_num_rows($sth)) { show_error("Database Failureeeeerrerererererere"); return 0; } while ($map_sizes = mysql_fetch_array($sth)) { if ($current_map_size == $map_sizes["id"]) { $map_sizes_output .= "<option selected value=\"" . $map_sizes["id"] . "\">" . $map_sizes["width"] . " : " . $map_sizes["height"] . "</option>"; } else { $map_sizes_output .= "<option value=\"" . $map_sizes["id"] . "\">" . $map_sizes["width"] . " : " . $map_sizes["height"] . "</option>"; } } $map_sizes_output .= "</select>"; echo "<form method=POST action=\"" . $PHP_SELF . "\">"; table_start("center", "400"); table_head_text(array("Map Settings"), "2"); table_text(array(" "), "", "", "2", "head"); table_text(array("Map Size"), "", "", "2", "head"); table_text(array($map_sizes_output), "", "", "2", "text"); table_form_submit("Change", "change_map_size", "", "text"); echo "</form>\n"; echo "<form method=POST action=\"" . $PHP_SELF . "\">"; table_text(array(" "), "", "", "2", "head"); table_text(array("Animations (KSVG needs disabled animations)", "<input type=\"checkbox\" name=\"animations\" value=\"1\" {$checked}>"), "", "", "", "head"); table_form_submit("Change", "change_anims", "", "text"); table_end(); echo "</form>\n"; table_start("center", "400"); echo "<form method=POST action=\"" . $PHP_SELF . "\">"; table_text(array("Change Password", " "), "", "", "", "head"); table_text_open(); table_text_design("Old Password", "300", "left", "", "text"); table_text_design("<input type=\"password\" align=\"right\" name=\"old\">", "100", "right", "", "text"); table_text_close(); table_text_open(); table_text_design("New Password", "300", "left", "", "text"); table_text_design("<input type=\"password\" align=\"right\" name=\"new1\">", "100", "right", "", "text"); table_text_close(); table_text_open(); table_text_design("Re-type new Password", "300", "left", "", "text"); table_text_design("<input type=\"password\" align=\"right\" name=\"new2\">", "100", "right", "", "text"); table_text_close(); table_form_submit("Set", "change_pw", "", "text"); table_end(); echo "</form>"; }
function broadcast_msg() { global $uid; global $PHP_SELF; // check ob im parlament $sth = mysql_query("select 1 from alliance where leader = {$uid} or devminister = {$uid} or forminister = {$uid} or milminister = {$uid}"); if (!$sth) { show_error("ERR::BROADCAST MSG"); return false; } if (mysql_num_rows($sth) == 0) { show_message("You can't broadcast, since you're not in the parliament."); return false; } else { table_start("center", "500"); table_text(array("Broadcast"), "left", "", "2", "smallhead"); echo "<form action=\"" . $PHP_SELF . "\" method=post>"; table_form_text("Message (max 255)", "message", "", "50", "255", "text"); table_form_submit("Broadcast", "proc_broadcast", "0"); echo "</form><br><br>"; } }
function start_mission() { global $id; global $uid; global $PHP_SELF; global $imperium; global $pid; $sth = mysql_query("select sum(population) from planets where uid={$uid}"); if (!$sth) { show_error("Database error!"); return 0; } $pop = mysql_fetch_row($sth); $spies = floor($pop[0] / 1000); $sth = mysql_query("select sum(count) from covertops where uid={$uid}"); if (!$sth) { show_error("Database failure!"); return 0; } $count = mysql_fetch_row($sth); if ($count[0] == NULL) { $count[0] = 0; } if ($count[0] == 0 and $spies == 0) { show_message("You don't have enough population to do any covertops!"); return 0; } $sth = mysql_query("select * from covertopsmissions as c , research as r where c.techdepend=r.t_id and r.uid={$uid} and c.id={$id}"); if (!$sth) { show_error("Database error!"); return 0; } if (mysql_num_rows($sth) == 0) { show_message("bbbblllllllllllll"); return 0; } $covertops = mysql_fetch_array($sth); if ($spies - $count[0] < $covertops["count"]) { show_message("You don't have enough free spies!"); return 0; } $sth = mysql_query("select c.id from covertopsmissions as c,ressources as r where c.metal<=r.metal and c.energy<=r.energy and c.mopgas<=r.mopgas and c.erkunum<=r.erkunum and c.gortium<=r.gortium and c.susebloom<=r.susebloom and r.uid={$uid} and c.id={$id}"); if (!$sth) { show_error("Database failure!"); return 0; } if (mysql_num_rows($sth) == 0) { show_error("You don't have enough ressources to start this mission!"); show_status(); return 0; } if ($imperium != "") { //$sth=mysql_query("select id from users where imperium='".addslashes($imperium)."' and id!=$uid"); $sth = mysql_query("select id from users where imperium='" . $imperium . "' and id!={$uid}"); if (!$sth) { show_error("Database error!"); return 0; } if (mysql_num_rows($sth) == 0) { show_message("Hund! 1"); return 0; } if ($covertops["targettype"] == "P" && $pid == "") { $sth = mysql_query("select id from users where imperium='{$imperium}'"); if (!$sth) { show_error("Database failure13!"); return 0; } $uid_target = mysql_fetch_array($sth); $sth = mysql_query("select id,name from planets where uid=" . $uid_target["id"] . " order by name"); if (!$sth) { show_error("Database failure!12"); return 0; } while ($planets = mysql_fetch_array($sth)) { if ($planets["name"] == "Unnamed") { $planets["name"] = get_planetname($planets["id"]); } $select[$planets["name"]] = $planets["id"]; } echo "<form action=\"" . $PHP_SELF . "\" method=post>"; table_start("center", "500"); table_head_text(array("Mission: " . $covertops["descr"]), "2"); table_text(array(" "), "", "", "2", "center", "head"); table_text_open("text", "center"); table_text_design("<img src='arts/idnummer.jpg' width='75' height='50' alt='" . $covertops["descr"] . "'>", "75"); table_text_design($covertops["descr"], "425"); table_text_close(); table_text_open("text", "center"); table_text_design("Target empire", "75"); table_text_design($imperium, "425"); table_text_close(); table_text_open("text", "center"); table_text_design("Time", "75"); table_text_design($covertops["time"], "425"); table_text_close(); table_text_open("text", "center"); table_text_design("Special Info", "75"); table_text_design("dummy", "425"); table_text_close(); table_form_select("Select the targetplanet", "pid", $select, "2", "text", "text"); table_form_submit("Start", "start_mission", "2", "text"); table_end(); form_hidden("imperium", $imperium); form_hidden("id", $id); echo "</form>"; table_end(); } elseif ($covertops["targettype"] == "P") { $sth = mysql_query("select id from planets where id={$pid} and uid!={$uid} and uid!=0"); if (!$sth) { show_error("Database failure!1"); return 0; } if (mysql_num_rows($sth) == 0) { show_error("Hund! 2"); return 0; } proc_start_mission($covertops["id"], $uid, $pid); show_status(); } else { $sth = mysql_query("select id from users where id!={$uid} and imperium='{$imperium}'"); if (!$sth) { show_error("Database failure1!"); return 0; } if (mysql_num_rows($sth) == 0) { show_message("Du Klobrillenvergewaltiger!"); return 0; } $target_uid = mysql_fetch_array($sth); proc_start_mission($covertops["id"], $uid, $target_uid["id"]); show_status(); } } else { $sth = mysql_query("select imperium from users where id!={$uid} order by imperium"); if (!$sth) { show_error("Database failure!"); return 0; } while ($imperiums = mysql_fetch_array($sth)) { $select[$imperiums["imperium"]] = $imperiums["imperium"]; } echo "<form action=\"" . $PHP_SELF . "\" method=post>"; table_start("center", "500"); table_head_text(array("Mission: " . $covertops["descr"]), "2"); table_text(array(" "), "", "", "2", "head"); table_text_open("text", "center"); table_text_design("<img src='arts/o" . $covertops["id"] . ".jpg' width='75' height='50' alt='" . $covertops["descr"] . "'>", "75"); table_text_design($covertops["descr"], "425"); table_text_close(); table_text_open("text", "center"); table_text_design("Time", "75"); table_text_design($covertops["time"], "425", "head"); table_text_close(); table_text_open("text", "center"); table_text_design("Special Info", "75"); table_text_design("dummy", "425", "head"); table_text_close(); table_form_select("Select the target empire", "imperium", $select, "", "text", "text"); table_form_submit("Start", "start_mission", "2", "text"); table_end(); form_hidden("id", $id); echo "</form>"; } }
function fleet($sth) { global $uid; global $PHP_SELF; global $pid; if (mysql_num_rows($sth) > 0) { echo "<form action=\"" . $PHP_SELF . "\" method=post>"; table_head_text(array("Ships currently in production"), "8"); table_text(array(" ", "Shipname", "Count", "Ressources per week", "Priority", "ETC", " ", "Count"), "center", "", 1, "head"); while ($fleet = mysql_fetch_assoc($sth)) { table_text_open("text", "center"); table_text_design("<a href='" . $fleet["manual"] . "' target=\"_blank\"><img src='arts/" . $fleet["pic"] . "' border='0' title='" . $fleet["description"] . "' align='center'></a><br><a href=\"" . $PHP_SELF . "?act=print_ship_info&prod_id=" . $fleet["prod_id"] . "\">Info</a>", "80", "", "", "text"); table_text_design($fleet["name"], "300", "", "", "text"); table_text_design($fleet["count"], "100", "", "", "text"); table_text_design(ressources_html(get_ressources_per_week($fleet)), "100", "", "", "text"); table_text_design("ETC :" . ($fleet["com_time"] - $fleet["time"]), "", "", "", "text"); $higher = false; $lower = false; switch ($fleet["priority"]) { case 2: $text = "<span style=\"color: red\">High</span>"; $lower = true; break; case 1: $text = "<span style=\"color: white\">Normal</span>"; $lower = true; $higher = true; break; case 0: $text = "<span style=\"color: green\">Low</span>"; $higher = true; break; } $base_prio = "<a href=\"" . $_SERVER["PHP_SELF"] . "?act=fprio&prod_id=" . $fleet["prod_id"] . "&pid=" . $fleet["planet_id"] . "&time=" . $fleet["time"] . "&change=%d\">%s</a>"; $priority = ""; if ($lower) { $priority .= sprintf($base_prio, -1, "-") . "<br>"; } $priority .= $text; if ($higher) { $priority .= "<br>" . sprintf($base_prio, 1, "+"); } table_text_design($priority, "", "center", "", "text"); table_text_design("<input type=\"checkbox\" name=\"prod_id[" . $fleet["prod_id"] . "]\" value=\"Y\">", "", "", "", "text"); table_text_design("<input type=\"hidden\" name=\"time[" . $fleet["prod_id"] . "]\" value=\"" . $fleet["time"] . "\"><input type=\"text\" name=\"count[" . $fleet["prod_id"] . "]\" size=\"3\" value=\"" . $fleet["count"] . "\">", "", "", "", "text"); table_text_close(); } table_text(array("<input type=\"hidden\" name=\"pid\" value=\"" . $pid . "\"><input type=\"hidden\" name=\"act\" value=\"fscrap\"><input type=\"submit\" value=\"Scrap\"></form>"), "right", "", "8"); } else { table_text(array("Your Fleet Production is IDLE")); } table_end(); echo "<br>\n"; $sth = mysql_query("select ifnull(sum(p.tonnage),0) from production_slots p,constructions c where c.pid=" . $pid . " and c.prod_id=p.prod_id and p.types='L,M,H'"); if (!$sth) { show_error("ERR::GET PRODUCTION SLOTS"); return false; } list($avail_tonnage) = mysql_fetch_row($sth); $sth = mysql_query("select ifnull(sum(f.count*s.tonnage),0) from s_production f,shipvalues s where f.planet_id=" . $pid . " and s.prod_id=f.prod_id"); if (!$sth) { show_error("ERR::GET USED PRODUCTION SLOTS"); return false; } list($used_tonnage) = mysql_fetch_row($sth); table_start("center", "500"); table_head_text(array("Production slots"), "3"); table_text_open(); table_text_design(" ", "", "center", "3", "text"); table_text_close(); table_text(array("Used Tonnage", "Maximum Tonnage", "Remaining Tonnage"), "center", "", 1, "head"); table_text(array($used_tonnage, $avail_tonnage, $avail_tonnage - $used_tonnage), "center", "", 1, "text"); table_end(); echo "<br><br>"; table_start("center", "500"); table_head_text(array("Shipconstruction"), "5"); table_text_open(); table_text_design(" ", "", "center", "5", "text"); table_text_close(); table_text(array("Shipname", "Ressources", "Tonnage", "Time", " "), "center", "", 1, "head"); echo "<form action=\"" . $PHP_SELF . "\" method=post>"; $sth = mysql_query("select p.*,s.tonnage from production as p,shipvalues s,research as r where (p.typ='L' or p.typ='M' or p.typ='H') and r.uid='{$uid}' and p.tech=r.t_id and s.prod_id=p.prod_id"); while ($fleet = mysql_fetch_array($sth)) { $darf_bauen = false; if ($fleet["p_depend"] == NULL) { $darf_bauen = true; } else { $darf_bauen = construction_exists($fleet["p_depend"], $pid); } if ($darf_bauen) { $ress = ""; if ($fleet["metal"] != 0) { $ress = $ress . "<img src=\"arts/metal.jpg\" title=\"Metal\" alt=\"Metal\" border=\"0\">" . $fleet["metal"] . " "; } if ($fleet["energy"] != 0) { $ress = $ress . "<img src=\"arts/energy.jpg\" title=\"Energy\" alt=\"Energy\" border=\"0\">" . $fleet["energy"] . " "; } if ($fleet["mopgas"] != 0) { $ress = $ress . "<img src=\"arts/mopgas.jpg\" title=\"Mopgas\" alt=\"Mopgas\" border=\"0\">" . $fleet["mopgas"] . " "; } if ($fleet["erkunum"] != 0) { $ress = $ress . "<img src=\"arts/erkunum.jpg\" title=\"erkunum\" alt=\"erkunum\" border=\"0\">" . $fleet["erkunum"] . " "; } if ($fleet["gortium"] != 0) { $ress = $ress . "<img src=\"arts/gortium.jpg\" title=\"Gortium\" alt=\"Gortium\" border=\"0\">" . $fleet["gortium"] . " "; } if ($fleet["susebloom"] != 0) { $ress = $ress . "<img src=\"arts/susebloom.jpg\" title=\"Susebloom\" alt=\"Susebloom\" border=\"0\">" . $fleet["susebloom"] . " "; } if ($fleet["colonists"] != 0) { $ress = $ress . "<img src=\"arts/colonists.png\" title=\"Colonists\" alt=\"Colonists\" border=\"0\">" . $fleet["colonists"] . " "; } table_text_open("text"); table_text_design("<a href='" . $fleet["manual"] . "' target=\"_blank\">" . $fleet["name"] . "</a><br><a href=\"" . $PHP_SELF . "?act=print_ship_info&prod_id=" . $fleet["prod_id"] . "\">Info</a>", "250", "", "", "text"); table_text_design($ress, "125", "", "", "text"); table_text_design($fleet["tonnage"], "50", "", "", "text"); table_text_design("ETA: " . $fleet["com_time"], "50", "", "", "text"); table_text_design("<input size='5' maxlength='6' name=\"fleet[" . $fleet["prod_id"] . "]\"><input type=image src='skins/" . $skin . "_production.jpg' width='25' height='25' alt='begin construction' border='0'>", "80", "", "", "text"); table_text_close(); } } echo "<input type=hidden name=\"pid\" value=\"{$pid}\">"; echo "<input type=hidden name=\"act\" value=\"fproduction\">"; echo "</form>"; return 0; echo "<form action=\"" . $PHP_SELF . "\" method=post>"; table_head_text(array("Pic", "Name", "Time", "Ressources", "Count")); $sth = mysql_query("select p.* from production as p,research as r where (p.typ='L' or p.typ='M' or p.typ='H') and r.uid='{$uid}' and p.tech=r.t_id"); while ($fleet = mysql_fetch_array($sth)) { $ress = ""; if ($fleet["metal"] != 0) { $ress = $ress . "<img src=\"arts/metal.jpg\" title=\"Metal\" alt=\"Metal\" border=\"0\">" . $fleet["metal"] . " "; } if ($fleet["energy"] != 0) { $ress = $ress . "<img src=\"arts/energy.jpg\" title=\"Energy\" alt=\"Energy\" border=\"0\">" . $fleet["energy"] . " "; } if ($fleet["mopgas"] != 0) { $ress = $ress . "<img src=\"arts/mopgas.jpg\" title=\"Mopgas\" alt=\"Mopgas\" border=\"0\">" . $fleet["mopgas"] . " "; } if ($fleet["erkunum"] != 0) { $ress = $ress . "<img src=\"arts/erkunum.jpg\" title=\"erkunum\" alt=\"erkunum\" border=\"0\">" . $fleet["erkunum"] . " "; } if ($fleet["gortium"] != 0) { $ress = $ress . "<img src=\"arts/gortium.jpg\" title=\"Gortium\" alt=\"Gortium\" border=\"0\">" . $fleet["gortium"] . " "; } if ($fleet["susebloom"] != 0) { $ress = $ress . "<img src=\"arts/susebloom.jpg\" title=\"Susebloom\" alt=\"Susebloom\" border=\"0\">" . $fleet["susebloom"] . " "; } if ($fleet["colonists"] != 0) { $ress = $ress . "<img src=\"arts/colonists.png\" title=\"Colonists\" alt=\"Colonists\" border=\"0\">" . $fleet["colonists"] . " "; } table_form_text(array("<img src=\"arts/" . $fleet["pic"] . "\" border=\"0\" width=\"25\" height=\"25\" alt=\"" . $fleet["description"] . "\">", $fleet["name"], $fleet["com_time"], $ress), "fleet[" . $fleet["prod_id"] . "]"); } echo "<input type=hidden name=\"pid\" value=\"{$pid}\">"; table_form_submit("Start", "fproduction", "4"); echo "</form>"; }
function transfer_infantery($uid, $fid, $pid) { global $PHP_SELF; $sth = mysql_query("select id from planets where uid='" . $uid . "' and id='" . $pid . "'"); if (mysql_num_rows($sth) == 0) { return 0; } $planet = mysql_fetch_array($sth); $planetname = get_planetname($planet["id"]); $sth = mysql_query("select uid,name from fleet_info where uid={$uid} and fid={$fid}"); if (!$sth) { show_error("Database failure!"); return 0; } if (mysql_num_rows($sth) == 0) { show_error("Stop that!"); return 0; } $itsFleet = mysql_fetch_array($sth); $sth = mysql_query("select i.*,p.name,v.tonnage as storage from infantery as i,production as p,shipvalues as v where i.pid={$pid} and i.uid={$uid} and i.prod_id=p.prod_id and i.prod_id = v.prod_id order by prod_id"); if (mysql_num_rows($sth) > 0) { echo "<form action=\"" . $PHP_SELF . "?who=1\" method=post>"; table_start("center", "500"); table_head_text(array("planet " . $planetname, "5")); table_text(array("unit", "count", "tonnage / unit", "total tonnage", " "), "", "", "", "smallhead"); while ($infantery = mysql_fetch_array($sth)) { $tempTotalSpace = $infantery["count"] * $infantery["storage"]; table_text(array($infantery["name"], $infantery["count"], $infantery["storage"] . " t", $tempTotalSpace . " t", "<input name=\"count[" . $infantery["prod_id"] . "]\">"), "", "", "", "text"); } form_hidden("fid", $fid); form_hidden("pid", $pid); table_form_submit("Transfer to fleet " . $itsFleet["name"], "transfer", 5); table_end(); echo "</form>"; } $sth = mysql_query("select sum(f.count*i.storage) from fleet as f,inf_transporters as i where f.fid={$fid} and i.prod_id = f.prod_id"); // $sth=mysql_query("select sum(f.count*i.storage) from inf_transporters as i,fleet as f where f.fid=$fid"); if (!$sth) { show_error("Database failure!"); return 0; } $total_space = mysql_fetch_row($sth); $sth = mysql_query("select i.count,iv.tonnage as storage,p.name,i.prod_id from inf_transports as i,shipvalues as iv,production as p where p.prod_id=i.prod_id and p.prod_id=iv.prod_id and i.prod_id=iv.prod_id and i.fid={$fid}"); if (mysql_num_rows($sth) > 0) { $spacetaken = 0; echo "<form action=\"" . $PHP_SELF . "?who=2\" method=post>"; table_start("center", "500"); table_head_text(array("Fleet"), "5"); table_text(array("unit", "count", "space/unit", "space used", " "), "", "", "", "smallhead"); while ($infantery = mysql_fetch_array($sth)) { table_text(array($infantery["name"], $infantery["count"], $infantery["storage"] . " t", $infantery["storage"] * $infantery["count"] . " t", "<input name=\"count[" . $infantery["prod_id"] . "]\">"), "", "", "", "text"); $spacetaken += $infantery["storage"] * $infantery["count"]; } table_text(array(" "), "", "", "5", "head"); table_text_open(); table_text_design("Total space", "", "", "3", "head"); table_text_design($total_space[0] . " t", "", "", "2", "text"); table_text_close(); table_text_open(); table_text_design("space used", "", "", "3", "head"); table_text_design($spacetaken . " t", "", "", "2", "text"); table_text_close(); table_text_open(); table_text_design("space left", "", "", "3", "head"); table_text_design($total_space[0] - $spacetaken . " t", "", "", "2", "text"); table_text_close(); form_hidden("fid", $fid); form_hidden("pid", $pid); table_form_submit("Transfer to planet", "transfer", 5); table_end(); echo "</form>"; } }
function print_form_submit($text, $act) { table_form_submit($text, $act); }
function browse_fleets() { global $uid; $GLOBALS["ses"]->page_birth(); $tables = "fleet_info fi, fleet f, production p,systems s left join planets pl on pl.id=fi.pid left join planets pl2 on fi.tpid=pl2.id left join systems s2 on fi.tsid=s2.id left join admirals a on fi.fid=a.fid"; $order = "fi.fid,p.name"; $fields = array(); $setact = "browse_fleets"; $instance = "fleetbrowser"; $prikey = "fi.fid"; $form[] = array("type" => "text", "text" => "Fleetname", "varname" => "fleet_name", "size" => "40"); $where[] = array("where" => "fi.name like '%{fleet_name}%'"); $form[] = array("type" => "text", "text" => "Planet", "varname" => "planet_name", "size" => "40"); $where[] = array("where" => "pl.name like '%{planet_name}%'"); $form[] = array("type" => "text", "text" => "System", "varname" => "system_name", "size" => "40"); $where[] = array("where" => "s.name like '%{system_name}%'"); echo "<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"POST\">\n"; $search = new searchform("fleet_search", $setact, "Search", $form, $where); $search->do_output = false; table_start("center", "500", 2); table_head_text(array("Search"), 2); table_form_text("Fleet", "fleet_name", $_POST["fleet_name"]); table_form_text("Planet", "planet_name", $_POST["planet_name"]); table_form_text("System", "system_name", $_POST["system_name"]); table_form_submit("Search", $setact); table_end(); $where_addon = $search->print_searchform(); echo "</form>\n"; if (!$where_addon) { $where_addon = "where"; } else { $where_addon .= " and"; } $where = $where_addon . " fi.uid=" . $uid . " and fi.fid=f.fid and f.prod_id=p.prod_id and s.id=fi.sid"; $browser = new dbbrowser($tables, $order, $fields, $setact, $instance, $prikey, $GLOBALS["db"]); $browser->tabellenkopftext = "Fleet Management"; $browser->zeilenfarbe = "text"; $browser->zeilenfarbe2 = "text"; $browser->fastpagefarbe = "head"; $browser->navigationfarbe = "head"; $browser->gruppenfarbe = "head"; $browser->tablehead_bgcolor = "head"; $browser->showgroup = 1; $browser->fixed_grouper = "fi.fid"; $browser->fixed_groupshow = "concat('<span style=\"color: lime\"><a href=\"" . $_SERVER["PHP_SELF"] . "?act=show_admiral&fid=',fi.fid,'\">',ifnull(concat(a.name,'(',if(a.value=0,0,floor((log10(value/1000)/log10(2))+1)),')'),'Noone'),'</a></span> " . "commanding fleet <span style=\"color: cyan\"><a href=\"" . $_SERVER["PHP_SELF"] . "?act=rename&fid=',fi.fid,'\">',fi.name,'</a></span><br><span style=\"color: yellow\">',sum(count),'</span> " . "ships at <span style=\"color: pink\">',ifnull(concat(pl.name,' (',s.name,')'),concat('System ',s.name)),'</span> " . "targeting <span style=\"color: orange\">',ifnull(ifnull(concat(pl2.name,' (',s2.name,')'),concat('System ',s2.name)),'No target'),'</span>'" . ",' (<span style=\"color: magenta\">',elt(fi.mission+1,if(tsid=0,'Defend','Moving'),'Invade','Bomb','','Colonize'),'</span>)')"; // missionsausgabe $browser->gruppenkopf = "<table><tr><td>{klappe} <input type='checkbox' name=\"fleet[{key}]\" value=\"Y\"></td><td>{gname}: <b><a href=\"{PHP_SELF}?act={setact}&{rname}={rwert}\">{gwert}</a></b> Shiptypes: <b>{ganzahl}</b></td></tr></table>"; $browser->navigation = "<div align=\"center\">\n\t\t[ <a href=\"{PHP_SELF}?act={setact}&page={last_page}\"><< back</a> ]\n\t\t \n\t\t | <b>{max_entrys}</b> Entries on <b>{max_pages}</b> pages | Page: <b>{page}</b> | \n\t\t \n\t\t[ <a href=\"{PHP_SELF}?act={setact}&page={next_page}\">forward >></a> ]\n\t\t</div>"; $browser->zusatz_head = array("Shipname", "Shipcount", "Reload"); $browser->zusatz_body = array("{p.name}", "<table><tr><td width=\"60\">{f.count}</td><td><input name=\"fleet_{fi.fid}[{f.prod_id}]\" value=\"0\" size=\"7\"></td></tr></table>", "{f.reload}"); $browser->extra_fields = array("p.name", "f.count", "f.reload", "f.prod_id"); $browser->browser_footer = "<span style=\"text-align: right\"><input type='submit' name='act' value='Join'><input type='submit' name='act' value='Transfer'><input type='submit' name='act' value='Create new fleet'></span>"; $browser->group_output = 1; echo "<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"POST\">"; $browser->browse($where); echo "</form>"; $GLOBALS["ses"]->page_end(); }