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 act_code() { global $PHP_SELF; global $name; global $act_code; global $password; if ($act_code != "") { $sth = mysql_query("select ac.code from users as u,activationcodes as ac where u.id=ac.uid and u.name='{$name}'"); $code = mysql_fetch_array($sth); if ($code["code"] == $act_code) { mysql_query("update users set active=1 where name='{$name}'"); return 1; } else { return 0; } } else { echo "<body bgcolor=\"black\"><center><font color=\"white\">"; echo "<form action=\"" . $PHP_SELF . "\" method=post>"; table_start(); echo "<p>Please enter your Activation Code</p>"; table_form_text("", "act_code", ""); table_end(); form_hidden("name", $name); form_hidden("password", $password); form_submit("Submit"); echo "</form></center></font>"; echo "</body>"; table_end(); return 0; } }
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 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 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 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(); }