function print_table_head($arr, $col = "#000000", $colspan = NULL) { table_text_open("head"); foreach ($arr as $text) { table_text_design($text, "", "", $colspan, "head"); } table_text_close(); }
function show_menu() { global $PHP_SELF; global $skin; center_headline("Communications"); table_start("center", "500"); table_text_open("", "center"); table_text_design("<a href=\"communication.php?act=show_alliance\"><img src=\"skins/" . $skin . "_alliance.jpg\" border=\"0\" width=\"50\" height=\"50\" alt=\"Alliance Menu\"></A>", "163", "center"); table_text_design("<a href=\"database.php\"><img src=\"skins/" . $skin . "_database.jpg\" border=\"0\" width=\"50\" height=\"50\" alt=\"Galactic Database\"></A>", "163", "center"); table_text_design("<a href=\"communication.php?act=show_journal\"><img src=\"skins/" . $skin . "_notebook.jpg\" border=\"0\" width=\"50\" height=\"50\" alt=\"Personal journal\"></A>", "163", "center"); table_text_design("<a href=\"mail.php\"><img src=\"skins/" . $skin . "_mail.jpg\" border=\"0\" width=\"50\" height=\"50\" alt=\"Mailbox\"></A>", "164", "center"); table_text_close(); table_text_open(""); table_text_design("Alliance Menu", "", "center"); table_text_design("Galactic Database", "", "center"); table_text_design("Journal", "", "center"); table_text_design("Mailbox", "", "center"); table_text_close(); table_end(); echo "<br><br>\n"; }
function show_rankings_menu() { global $PHP_SELF; echo "<br />"; echo "<a name=\"top\" />\n"; table_start("center", "500", 4); table_head_text(array("Rankings"), "5"); table_text_open("text"); table_text_design("<br>", "", "", "5", "text"); table_text_close(); table_text_open("head"); table_text_design("Users", "", "", "2", "head"); table_text_design(" ", "", "", "", "head"); table_text_design("Alliances", "", "", "2", "head"); table_text_close(); table_text_open("head"); table_text_design("· <a href=\"" . $PHP_SELF . "\">Score</a>", "", "", "2", "text"); table_text_design(" ", "", "", "", "text"); table_text_design("· <a href=\"" . $PHP_SELF . "?act=show_alliance_rankings\">Score</a>", "", "", "2", "text"); table_text_close(); table_text_open("text"); table_text_design("· <a href=\"" . $PHP_SELF . "?act=show_planets_rankings\">Planets (Top 100)</a>", "", "", "2", "text"); table_text_design(" ", "", "", "", "text"); table_text_design(" ", "", "", "2", "text"); table_text_close(); table_text_open("text"); table_text_design("· <a href=\"" . $PHP_SELF . "?act=show_ships_rankings\">Ships (Top 100)</a>", "", "", "2", "text"); table_text_design(" ", "", "", "", "text"); table_text_design(" ", "", "", "2", "text"); table_text_close(); table_text_open("text"); table_text_design("<br>", "", "", "5", "text"); table_text_close(); }
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 building_edit() { global $uid; global $id; global $PHP_SELF; $sth = mysql_query("select admin,name from users where id={$uid}"); if (!$sth) { show_message("Databse Failure"); return 0; } if (mysql_num_rows($sth) == 0) { show_message("Forbidden"); return 0; } $admin = mysql_fetch_array($sth); if ($admin["admin"] == "") { show_message("Forbidden"); return 0; } else { if ($id == 'new') { echo "<a href=\"" . $PHP_SELF . "?act=buildings&order=name\">back</a>"; $sth = mysql_query("insert into production (typ,tech,name,description) values ('P','999','new','no description')"); if (!$sth) { show_message("Databse Failure : creating new building step 1"); return 0; } /* $sth=mysql_query("select prod_id from production where tech=999 and name='new' and description='no description' and typ='P'"); if (!$sth) { show_message("Databse Failure : creating new building step 2"); return 0; } $newid = mysql_fetch_array($sth); $sth=mysql_query("insert into shipvalues (prod_id,special) values ('".$newid["prod_id"]."','NULL')"); if (!$sth) { show_message("Databse Failure : creating new ship step 3"); return 0; } */ show_message("Empty Buildingslot created, plz edit at least Description,tech or name before creaating a new ship or ERRORS may accure!"); } else { $sth = mysql_query("select * from production where prod_id='{$id}'"); if (!$sth) { show_message("Databse Failure"); return 0; } $building = mysql_fetch_array($sth); $sth = mysql_query("select name,t_id from tech"); if (!$sth) { show_message("Databse Failuret"); return 0; } $sth1 = mysql_query("select name, prod_id from production where not (prod_id='{$id}')"); if (!$sth1) { show_message("Databse Failurep"); return 0; } echo "<a href=\"" . $PHP_SELF . "?act=buildings&order=name\">back</a>"; table_start("center", "500"); table_head_text(array("Editing building " . $building["name"]), "3"); table_text(array(" "), "", "", "3", "text"); table_text(array("variable", "old", "new"), "", "", "", "head"); echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=name&tid=" . $building["prod_id"] . "\" method=post>"; table_text(array("Name", $building["name"], "<input type=\"Text\" name=\"new\" value=\"" . $building["name"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text"); echo "</form>\n"; echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=prod_id&tid=" . $building["prod_id"] . "\" method=post>"; table_text(array("Id", $building["prod_id"], "<input type=\"Text\" name=\"new\" value=\"" . $building["prod_id"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text"); echo "</form>\n"; echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=typ&tid=" . $building["prod_id"] . "\" method=post>"; table_text_open(); table_text_design("Type", "", "", "", "text"); table_text_design($building["typ"], "", "", "", "text"); table_text_design("<select name=\"new\"> \n <option value=\"P\" selected>P \n <option value=\"O\">O \n </select><input type=\"Submit\" name=\"f1\" value=\"set\">\n</form>\n", "", "", "", "text"); table_text_close(); echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=com_time&tid=" . $building["prod_id"] . "\" method=post>"; table_text(array("Time", $building["com_time"], "<input type=\"Text\" name=\"new\" value=\"" . $building["com_time"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text"); echo "</form>\n"; echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=tech&tid=" . $building["prod_id"] . "\" method=post>"; table_text_open(); table_text_design("Tech", "", "", "text"); table_text_design($building["tech"], "", "", "text"); echo "<td><select name=\"new\">"; while ($techs = mysql_fetch_array($sth)) { if ($techs["t_id"] == $building["tech"]) { echo "<option value=\"" . $techs[t_id] . "\" selected>" . $techs["name"] . "\n"; } else { echo "<option value=\"" . $techs[t_id] . "\">" . $techs["name"] . "\n"; } } echo "</select><input type=\"Submit\" name=\"f1\" value=\"set\">\n</td>\n</form>\n"; table_text_close(); echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=p_depend&tid=" . $building["prod_id"] . "\" method=post>"; table_text_open(); table_text_design("Production_depend", "", "", "text"); table_text_design($building["p_depend"], "", "", "text"); echo "<td><select name=\"new\">"; while ($productions = mysql_fetch_array($sth1)) { if ($productions["prod_id"] == $building["p_depend"]) { echo "<option value=\"" . $productions[prod_id] . "\" selected>" . $productions["name"] . "\n"; } else { echo "<option value=\"" . $productions[prod_id] . "\">" . $productions["name"] . "\n"; } } echo "</select><input type=\"Submit\" name=\"f1\" value=\"set\">\n</td>\n</form>\n"; table_text_close(); echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=special&tid=" . $building["prod_id"] . "\" method=post>"; table_text(array("Special", $building["special"], "<input type=\"Text\" name=\"new\" value=\"" . $building["special"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text"); echo "</form>\n"; echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=metal&tid=" . $building["prod_id"] . "\" method=post>"; table_text(array("Metal", $building["metal"], "<input type=\"Text\" name=\"new\" value=\"" . $building["metal"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text"); echo "</form>\n"; echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=energy&tid=" . $building["prod_id"] . "\" method=post>"; table_text(array("Energy", $building["energy"], "<input type=\"Text\" name=\"new\" value=\"" . $building["energy"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text"); echo "</form>\n"; echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=mopgas&tid=" . $building["prod_id"] . "\" method=post>"; table_text(array("Mopgas", $building["mopgas"], "<input type=\"Text\" name=\"new\" value=\"" . $building["mopgas"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text"); echo "</form>\n"; echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=erkunum&tid=" . $building["prod_id"] . "\" method=post>"; table_text(array("Erkunum", $building["erkunum"], "<input type=\"Text\" name=\"new\" value=\"" . $building["erkunum"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text"); echo "</form>\n"; echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=gortium&tid=" . $building["prod_id"] . "\" method=post>"; table_text(array("Gortium", $building["gortium"], "<input type=\"Text\" name=\"new\" value=\"" . $building["gortium"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text"); echo "</form>\n"; echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=susebloom&tid=" . $building["prod_id"] . "\" method=post>"; table_text(array("Susebloom", $building["susebloom"], "<input type=\"Text\" name=\"new\" value=\"" . $building["susebloom"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text"); echo "</form>\n"; echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=description&tid=" . $building["prod_id"] . "\" method=post>"; table_text(array("Description", $building["description"], "<input type=\"Text\" name=\"new\" value=\"" . $building["description"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text"); echo "</form>\n"; echo "<form action=\"" . $PHP_SELF . "?act=del_building&id=" . $building["prod_id"] . "\" method=post>"; echo "<input type=\"Submit\" name=\"f1\" value=\"Delete building - all active buildings of this type will be deleted too\" disabled>"; echo "</form>\n"; table_end(); } } }
function show_diplomacy() { global $uid; global $start; global $PHP_SELF; if (has_alliance_lock($uid)) { show_message("You can't use any alliance options due to an alliance lock!"); return false; } $aid = get_alliance($uid); $is_leader = is_leader($uid, $aid); $sth = mysql_query("select a.name, d.alliance2, d.status, if(status = 0, 0,(if(status=1, 2, 1))) as my_order from diplomacy d, alliance a where d.alliance1='" . $aid . "' and a.id = d.alliance2 order by my_order, a.name"); if (!$sth) { echo "ERR::DIPLOMACY, could not get relationships"; return false; } table_start("center", "500"); table_head_text(array("Galactic diplomacy status"), 2); table_text_open("head", "center"); table_text_design(" ", "27", "left", "", "head"); table_text_design(" ", "", "left", "", "head"); table_text_close(); if (mysql_num_rows($sth) > 0) { while ($diplomacy = mysql_fetch_assoc($sth)) { if ($diplomacy["status"] == 0) { $dip_image = "arts/alliance_enemy.gif"; $alt = "Enemy"; } elseif ($diplomacy["status"] == 2) { $dip_image = "arts/alliance_friend.gif"; $alt = "Enemy"; } else { $dip_image = false; $alt = false; } table_text_open("head", "center"); table_text_design("<img src=\"" . $dip_image . "\" width=\"25\" height=\"25\" alt=\"" . $alt . "\" border=\"0\" />", "27", "center", "", "text"); table_text_design("<a href=\"database.php?act=info_alliance&aid=" . $diplomacy["alliance2"] . "\">" . $diplomacy["name"] . "</a>", "", "left", "", "text"); table_text_close(); } } else { table_text(array("no relations to other alliances"), "center", "", "2", "text"); } table_end(); //***********************+ $alliances = get_alliances($aid, true); table_start("center", "500"); table_head_text(array("Status"), 2); table_text(array(" "), "", "", 2, "head"); if (sizeof($alliances) == 0) { table_text(array("No alliances so far"), "", "", 2, "text"); } else { for ($i = 0; $i < sizeof($alliances); $i++) { table_text(array(get_alliance_name($alliances[$i]), get_diplomatic_status_text(get_diplomatic_status($aid, $alliances[$i]))), "", "", "", "text"); if (is_leader($uid, $aid)) { $pending_status = get_pending_diplomacy_change($aid, $alliances[$i]); $f_pending_status = get_pending_diplomacy_change($alliances[$i], $aid); if ($pending_status) { table_text(array(" ", get_diplomatic_status_text($pending_status) . " status pending <a href=\"" . $PHP_SELF . "?act=drop_pending&aid2=" . $alliances[$i] . "&aid1=" . $aid . "\">Drop</a>"), "", "", "", "head"); } elseif ($f_pending_status) { table_text(array(" ", get_diplomatic_status_text($f_pending_status) . " status awaiting your approval <a href=\"" . $PHP_SELF . "?act=drop_pending&aid1=" . $alliances[$i] . "&aid2=" . $aid . "\">Drop</a> <a href=\"" . $PHP_SELF . "?act=accept_pending&faid=" . $alliances[$i] . "\">Accept</a>"), "", "", "", "head"); } else { table_text(array(" ", "<a href=\"" . $PHP_SELF . "?act=change_diplomacy&faid=" . $alliances[$i] . "&new_status=0\" onclick=\"javascript:return confirm('Are you sure you want to declare war?');\">Change to <span style=\"color: #FF0000\">Enemy</span></a> | <a href=\"" . $PHP_SELF . "?act=change_diplomacy&faid=" . $alliances[$i] . "&new_status=1\">Change to <span style=\"color: #FFFF00\">Neutral</span></a> | <a href=\"" . $PHP_SELF . "?act=change_diplomacy&faid=" . $alliances[$i] . "&new_status=2\">Change to <span style=\"color: #00FF00\">Friend</span></a>"), "", "", "", "head"); } } } } table_text(array(" "), "", "", 2, "head"); table_end(); }
function show_fleet() { global $fid; global $uid; $no_scan = 100; $sth = mysql_query("select u.alliance,u.id from fleet_info as f,users as u where u.id=f.uid and f.fid={$fid} limit 1"); if (!$sth) { show_error("Database failure!"); return 0; } if (mysql_num_rows($sth) == 0) { show_error("Either this fleet doesn't exist or you are trying to hack :)"); return 0; } $sth = mysql_query("select alliance from users where id={$uid}"); if (!$sth) { show_error("Database failure!"); return 0; } $u_alliance = mysql_fetch_array($sth); $sth = mysql_query("select u.alliance,u.id from users as u,fleet_info as f where f.uid=u.id and f.fid={$fid} and u.alliance!=0"); if (!$sth) { show_error("Database failure!"); return 0; } if (mysql_num_rows($sth) == 0) { $allowed = false; } else { $f_alliance = mysql_fetch_array($sth); if ($f_alliance["id"] == $uid) { $allowed = true; } elseif ($f_alliance["alliance"] == $u_alliance["alliance"] and $u_alliance != 0) { $allowed = true; } else { $allowed = false; } } if (!$allowed) { $sth = mysql_query("select sid from fleet_info where fid={$fid}"); if (!$sth) { show_error("Database failure!"); return 0; } $system = mysql_fetch_array($sth); $sth = mysql_query("select fid from fleet_info where uid={$uid} and sid=" . $system["sid"]); if (!$sth) { show_error("Database failure!"); return 0; } if (mysql_num_rows($sth) > 0) { $allowed = true; } } if (!$allowed) { $sth = mysql_query("select p.id,p.uid,p.name,s.x,s.y from planets as p,systems as s where uid={$uid} and p.sid=s.id"); if (!$sth) { show_error("Database failure!"); return 0; } $allowed = false; while ($planets = mysql_fetch_array($sth) and !$allowed) { $sth1 = mysql_query("select max(s.radius) from scanradius as s,constructions as o where s.prod_id=o.prod_id and o.pid=" . $planets["id"]); if (!$sth1) { show_error("Dataabse failure!"); return 0; } $radius = mysql_fetch_row($sth1); if ($radius[0] == NULL) { $radius[0] = $no_scan; } $sth1 = mysql_query("select * from systems as s,fleet_info as f where (s.x-" . $planets["x"] . ")*(s.x-" . $planets["x"] . ")+(s.y-" . $planets["y"] . ")*(s.y-" . $planets["y"] . ")<=" . $radius[0] . "*" . $radius[0] . " and f.sid=s.id and f.fid={$fid}"); if (!$sth1) { show_error("Database failure!"); return 0; } if (mysql_num_rows($sth1) > 0) { $allowed = true; } } } if (!$allowed) { show_error("Your scanning abilities aren't sufficient to view this fleet!"); return 0; } $sth = mysql_query("select f.count,f.fid,f.prod_id,p.name from fleet as f, production as p where p.prod_id=f.prod_id and f.fid={$fid}"); if (!$sth) { show_error("Database failure!"); return 0; } if (mysql_num_rows($sth) == 0) { show_error("Either this fleet doesn't exist or you are trying to hack :)"); return 0; } table_start("center", "500"); table_head_text(array("Fleet Overview"), "2"); while ($fleet = mysql_fetch_array($sth)) { table_text_open("head", "center"); table_text_design($fleet["name"], "250", "", "", "text"); table_text_design($fleet["count"], "250", "", "", "text"); table_text_close(); } }
function show_battlereports() { table_start("center", "500"); table_head_text(array("Battlereports"), "1"); table_text(array("<a href=\"battlereport.php?act=show_own\">Battlereports</a>"), "", "", "", "text"); table_text_open("head"); table_text_close(); table_end(); echo "<br><br>"; }
function status() { global $uid; $sth = mysql_query("select * from researching where uid={$uid}"); if (!$sth) { show_message("Database Failure!"); return 0; } $status = mysql_fetch_array($sth); table_start("center", "500"); table_head_text(array("Current research"), "5"); table_text(array(" "), "", "", "5", "text"); if ($status != "") { $sth2 = mysql_query("select * from tech where t_id=" . $status["t_id"] . ""); $tech = mysql_fetch_array($sth2); table_text(array("<br><strong>" . $tech["name"] . "</strong>"), "center", "", "5", "head"); table_text(array("<img src='arts/t" . $tech["t_id"] . "big.jpg' width='100' height='100' alt='" . $tech["name"] . "' align='left'>\n <br>" . $tech["description"] . "\n <br><a href='manual/tech" . $tech["t_id"] . ".html'>learn more</a>"), "center", "", "5", "text"); table_text_open(); table_text_design("Time left:", "100", "center", "3", "head"); table_text_design($status["time"], "400", "center", "2", "text"); table_text_close(); print_advancements($status["t_id"]); table_end(); } else { table_text(array("<br><strong>No Research established</strong>"), "center", "", "5", "head"); table_end(); } echo "<br><br>\n"; // mop: research_queue holen $queue = get_research_queue($uid); table_start("center", "500"); table_head_text(array("Research queue"), sizeof($queue)); table_text(array(" "), "", "", sizeof($queue), "text"); if (sizeof($queue) == 0) { table_text(array("<br><strong>Research queue is empty</strong>"), "center", "", sizeof($queue), "head"); } else { $output_arr = array(); $option_arr = array(); for ($i = 0; $i < sizeof($queue); $i++) { $t_id = $queue[$i]; $sth2 = mysql_query("select * from tech where t_id=" . $t_id); $tech = mysql_fetch_assoc($sth2); $output_arr[] = "<img src='arts/t" . $t_id . ".jpg' alt='" . $tech["name"] . "' align='center'>"; // mop: optionen dazu bauen $options = ""; if ($i != 0) { $options .= "<a href=\"" . $_SERVER["PHP_SELF"] . "?act=qmove&direction=l&tid=" . $t_id . "\"><</a>"; } $options .= "<a href=\"" . $_SERVER["PHP_SELF"] . "?act=qremove&tid=" . $t_id . "\">x</a>"; if ($i != sizeof($queue) - 1) { $options .= "<a href=\"" . $_SERVER["PHP_SELF"] . "?act=qmove&direction=r&tid=" . $t_id . "\">></a>"; } $option_arr[] = $options; } table_text($output_arr, "center"); table_text($option_arr, "center"); } table_end(); echo "<br><br>\n"; }
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 show_info() { global $uid; global $pid; $sth = mysql_query("select * from planets p,popgain g where p.id={$pid} and p.uid={$uid} and p.id=g.pid"); if (!$sth || mysql_num_rows($sth) == 0) { show_error("Jailhouse rock!"); return 0; } center_headline("Information Screen"); $planet = mysql_fetch_assoc($sth); table_border_start("center", "", "#302859", "#100666", "#D2CCF9"); echo "<tr>\n"; echo " <td rowspan=\"14\">\n"; echo " <img src=\"arts/" . $planet["type"] . ".jpg\">\n"; echo " <td>\n"; echo "</tr>\n"; table_head_text(array("Information"), "2"); table_text_open(); table_text_design("Owner", "", "center", "1", "head"); $sth = mysql_query("select u.name,ifnull(a.name,'none') as aname from users u left join alliance a on a.id=u.alliance where u.id=" . $planet["uid"]); if (!$sth || mysql_num_rows($sth) == 0) { show_error("Database failure!"); return 0; } $owner = mysql_fetch_assoc($sth); table_text_design($owner["name"], "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("System", "", "center", "1", "head"); table_text_design(get_systemname($planet["sid"]), "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("Alliance", "", "center", "1", "head"); table_text_design($owner["aname"], "", "center", "1", "text"); table_text_close(); if ($planet["gain"] > 0) { $gain = "<span style=\"color: lime\">+" . $planet["gain"] * 100 . "%</span>"; } else { $gain = "+/-0%"; } table_text_open(); table_text_design("Population", "", "center", "1", "head"); table_text_design(get_poplevel_by_pop($planet["population"]) . " " . $gain . " (" . $planet["max_poplevel"] . ")", "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("Planettype", "", "center", "1", "head"); switch ($planet["type"]) { case "O": $type = "Origin Class"; break; case "M": $type = "Mars Class"; break; case "A": $type = "Ancient Class"; break; case "D": $type = "Desert Class"; break; case "E": $type = "Eden Class"; break; case "G": $type = "Gas Giant Class"; break; case "H": $type = "Heavy Grav Class"; break; case "I": $type = "Ice Class"; break; case "R": $type = "Rock Class"; break; case "T": $type = "Toxic Class"; break; } define("planet_raw_metal", "8.5"); define("planet_raw_energy", "8.5"); define("planet_raw_mopgas", "8.5"); define("planet_raw_erkunum", "8.5"); define("planet_raw_gortium", "8.5"); define("planet_raw_susebloom", "8.5"); define("planet_no_upgrade_factor", "1"); $sth = mysql_query("select * from planets where id={$pid}"); $population_factor = log10($planet["population"] / 1000) + 3; $sth = mysql_query("select * from final_prod_factors where pid=" . $pid); if (!$sth) { show_error("ERR::GET PROD_FACTORS"); return false; } if (mysql_num_rows($sth) == 1) { $factors = mysql_fetch_assoc($sth); } else { $factors = false; } $metal_plus = round($factors["metal"] * ($planet["metal"] / 100) * (planet_raw_metal * $population_factor)); $energy_plus = round($factors["energy"] * ($planet["energy"] / 100) * planet_raw_energy * $population_factor); $mopgas_plus = round($factors["mopgas"] * ($planet["mopgas"] / 100) * planet_raw_mopgas * $population_factor); $erkunum_plus = round($factors["erkunum"] * ($planet["erkunum"] / 100) * planet_raw_erkunum * $population_factor); $gortium_plus = round($factors["gortium"] * ($planet["gortium"] / 100) * planet_raw_gortium * $population_factor); $susebloom_plus = round($factors["susebloom"] * ($planet["susebloom"] / 100) * planet_raw_susebloom * $population_factor); table_text_design($type, "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("Production factor", "", "center", "1", "head"); table_text_design($planet["production_factor"] * 100 . "%", "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("<img src='arts/metal.gif' title='Metal' alt='Metal'>", "", "center", "1", "head"); table_text_design($metal_plus, "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("<img src='arts/energy.gif' title='Energy' alt='Energy'>", "", "center", "1", "head"); table_text_design($energy_plus, "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("<img src='arts/mopgas.gif' title='Mopgas' alt='Mopgas'>", "", "center", "1", "head"); table_text_design($mopgas_plus, "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("<img src='arts/erkunum.gif' title='Erkunum' alt='Erkunum'>", "", "center", "1", "head"); table_text_design($erkunum_plus, "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("<img src='arts/gortium.gif' title='Gortium' alt='Gortium'>", "", "center", "1", "head"); table_text_design($gortium_plus, "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("<img src='arts/susebloom.gif' title='Susebloom' alt='Susebloom'>", "", "center", "1", "head"); table_text_design($susebloom_plus, "", "center", "1", "text"); table_text_close(); table_end(); echo "<br><br>\n"; echo "<center>\n"; // echo("<a href=\"planet.php?pid=".$planet["id"]."\" target=\"anzeige_frame\">fleet orders</a>\n"); echo "</center>\n"; echo "<br>\n"; $query = mysql_query("SELECT ps.*, p.pic, p.description, p.name FROM planetary_shields ps \nINNER JOIN production p USING (prod_id) WHERE pid={$pid}") or die(mysql_error()); if (mysql_num_rows($query) > 0) { table_start("center", "500"); table_head_text(array("Shield generators installed on {$planet['name']}"), "5"); table_text_open("head"); table_text_design(" ", "50px", "", "", "head"); table_text_design("Building", "300", "", "", "head"); table_text_design("Max", "50", "center", "", "head"); table_text_design("Power", "50", "center", "", "head"); table_text_design("Load", "50", "center", "", "head"); while ($result = mysql_fetch_assoc($query)) { table_text_open("text", "center"); table_text_design("<a href='" . $_SERVER["PHP_SELF"] . "?act=print_building_info&prod_id=" . $result["prod_id"] . "'><img src='arts/" . $result["pic"] . "' alt='" . $result["description"] . "' border='0' width=\"50px\" height=\"50px\" /></a>", "50px", "", "", "text", "2"); table_text_design($result["name"], "300", "", "", "text", "2"); table_text_design($result["max_value"], "50", "", "", "text", "2"); table_text_design($result["value"], "50", "", "", "text", "2"); table_text_design($result["regeneration"] + $result["regeneration_bonus"], "50", "", "", "text", "2"); table_text_close(); } table_end(); } echo "<br>\n"; table_start("center", "500"); table_head_text(array("Units stationed on " . $planet["name"]), "5"); table_text(array(" ", " ", " ", " ", " "), "center", "100", "", "text"); table_text_open("head"); table_text_design("Infantry", "200", "center", "2", "head"); table_text_design(" ", "100", "", "", "head"); table_text_design("Fleet", "200", "center", "2", "head"); table_text_close(); $sth = mysql_query("select sum(count) from infantery as i,production as p where i.pid=" . $pid . " and i.prod_id=p.prod_id\n and p.typ='I'"); if (!$sth) { show_error("Database failure!"); return 0; } $inf = mysql_fetch_row($sth); if ($inf[0] == "") { $inf[0] = "No troops"; } table_text_open("text", "center"); table_text_design("Infantry", "", "", "", "text"); table_text_design($inf[0], "", "", "", "text"); table_text_design(" ", "100", "", "", "none"); table_text_design("Europa Class", "", "", "", "text"); table_text_design(get_fcount_by_type($uid, "L", $pid), "", "", "", "text"); table_text_close(); $sth = mysql_query("select sum(count) from infantery as i,production as p where i.pid=" . $pid . " and i.prod_id=p.prod_id and p.typ='T'"); if (!$sth) { show_error("Database failure!"); return 0; } $inf = mysql_fetch_row($sth); if ($inf[0] == "") { $inf[0] = "No Vehicles"; } table_text_open("text", "center"); table_text_design("Vehicles", "", "", "", "text"); table_text_design($inf[0], "", "", "", "text"); table_text_design(" ", "100", "", "", "none"); table_text_design("Zeus Class", "", "", "", "text"); table_text_design(get_fcount_by_type($uid, "M", $pid), "", "", "", "text"); table_text_close(); table_text_open("text", "center"); table_text_design(" "); table_text_design(" "); table_text_design(" ", "100", "", "", "none"); table_text_design("Olymp Class", "", "", "", "text"); table_text_design(get_fcount_by_type($uid, "H", $pid), "", "", "", "text"); table_text_close(); table_end(); }
function invite_buddy() { global $PHP_SELF; echo "<table width=\"280\" class=\"list\">\n"; table_text_open(); table_text_design("invite a user", "240", "center", "2", "top"); table_text_close(); echo "<form action=\"" . $PHP_SELF . "\" method=post>"; echo "<tr><td class=\"list\"><input name=\"buddy\"><input type=hidden name=\"act\" value=\"proc_invite_buddy\"><input type=\"submit\" value=\"send\"></td></tr>"; echo "</table>\n"; echo "</form>"; }
function print_ship_info($prod_id) { if ($info = get_ship_info($prod_id)) { table_start("center", "500"); table_head_text(array("Ships info for " . $info["name"]), "6"); table_text_open("head"); table_text_design(" ", "500", "", "2", "head"); table_text_close(); $info["p_depend"] = get_name_by_prod_id($info["p_depend"]); switch ($info["target1"]) { case "L": $info["target1"] = "Europe Class"; break; case "M": $info["target1"] = "Zeus Class"; break; case "H": $info["target1"] = "Olymp Class"; break; } switch ($info["special"]) { case "E": $info["special"] = "Freezes enemy ships"; break; case "R": $info["special"] = "Capable of stealing ships"; break; case "S": $info["special"] = "Detects cloaked ships"; break; case "C": $info["special"] = "Cloaked"; break; default: $info["special"] = "Nothing"; } foreach (array("name" => "Name", "metal" => "Metal", "energy" => "Energy", "mopgas" => "Mopgas", "erkunum" => "Erkunum", "gortium" => "Gortium", "susebloom" => "Susebloom", "rname" => "Needs tech", "p_depend" => "Needs building", "initiative" => "Initiative", "agility" => "Agility", "warpreload" => "Reload time", "hull" => "Hull", "tonnage" => "Tonnage", "weaponpower" => "Weaponpower", "shield" => "Shield", "ecm" => "ECM", "sensor" => "Sensor", "weaponskill" => "Weaponskill", "target1" => "Attacks", "special" => "Special abilities", "num_attacks" => "Number of attacks") as $key => $show) { table_text_open("text"); table_text_design($show, "250", "", "", "text"); table_text_design($info[$key], "250", "", "", "text"); table_text_close(); } table_end(); } else { show_error("Can't get ship info!"); return 0; } }
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 admiral_pool() { global $uid; $sth = mysql_query("select * from admirals where uid={$uid} and fid=0"); if (!$sth) { show_error("Database error!"); return 0; } if (mysql_num_rows($sth) == 0) { return 0; } center_headline("Admiral Pool"); table_start("center", "500"); table_head_text(array("Admirals"), "7"); table_text(array(" "), "", "", "7", "text"); table_text_open(); table_text_design(" ", "50", "", "", "head"); table_text_design("Name", "200", "", "", "head"); table_text_design("Rank", "75", "", "", "head"); table_text_design("Initiative", "75", "", "", "head"); table_text_design("Agility", "75", "", "", "head"); table_text_design("Sensor", "75", "", "", "head"); table_text_design("Weaponskill", "75", "", "", "head"); table_text_close(); while ($admiral = mysql_fetch_array($sth)) { if ($admiral["value"] < 1000) { $level = 0; } else { $level = floor(log10($admiral["value"] / 1000) / log10(2) + 1); } table_text_open(); table_text_design("<img src=\"portraits/" . $admiral["pic"] . "\" border=\"0\" alt=\"" . $admiral["name"] . "\">", $admiral["name"], "200", "center", "", "text"); table_text_design($admiral["name"], "75", "center", "", "text"); table_text_design($level, "75", "center", "", "text"); foreach (array("initiative", "agility", "sensor", "weaponskill") as $dummy => $value) { if (calculate_admiral_level($admiral["used_xp"]) < $level) { $upgrade = "<a href=\"" . $PHP_SELF . "?act=upgrade_admiral_pool&id=" . $admiral["id"] . "&value=" . $value . "\"><img src=\"arts/plus.jpg\" border=\"0\" width=\"10\"></a>"; } else { $upgrade = ""; } table_text_design($upgrade . $admiral[$value], "75", "center", "", "text"); } table_text_close(); } table_end(); }