function show_score($table, $offset, $user_id) { assert(is_string($table)); assert(is_string($offset)); assert(is_numeric($user_id)); global $_CONFIG; // Define minimum and maximum ranking for this page if ($offset == "") { $offset = 1; } $min = $offset; $max = $offset + $_CONFIG['SCORE_VIEWSIZE']; if ($max > score_get_last_rank()) { $max = score_get_last_rank(); } // Print nice title if ($table == "overall") { $str = "Overall Ranking"; } if ($table == "resource") { $str = "Resource Ranking"; } if ($table == "strategic") { $str = "Strategic Ranking"; } if ($table == "exploration") { $str = "Exploration Ranking"; } print_subtitle($str); // Create sub menu create_submenu(array("Resource Ranking" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("resource"), "Exploration Ranking" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("exploration"), "Strategic Ranking" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("strategic"), "Overall Ranking" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("overall"))); $pagecount = round((score_get_last_rank() - score_get_first_rank()) / $_CONFIG['SCORE_VIEWSIZE'] + 0.5); $pages = array(); for ($i = 1; $i != $pagecount + 1; $i++) { $a = array("P{$i}" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars($table) . "&ofs=" . encrypt_get_vars(($i - 1) * $_CONFIG['SCORE_VIEWSIZE'] + 1)); $pages = array_merge($pages, $a); } create_submenu($pages); // Print the table $cls = "bl"; echo "<table border=0 align=center width=75%>\n"; echo " <tr class=wb><th colspan=3>" . $str . "</th><tr>\n"; for ($i = $min; $i != $max + 1; $i++) { list($uid, $name, $points) = score_get_rank($table, $i); if ($uid == $user_id) { echo "<tr class=" . $cls . "><td> <b><big>" . $i . ".</big></b> </td><td> <b><big>" . $name . "</big></b> </td><td> <b><big>(" . $points . " points)</big></b> </td></tr>\n"; } else { echo "<tr class=" . $cls . "><td> " . $i . ". </td><td> " . $name . " </td><td> (" . $points . " points) </td></tr>\n"; } if ($cls == "bl") { $cls = "lbl"; } else { $cls = "bl"; } } echo "</table>"; echo "<br><br>"; }
function sector_show_all_sectors($user_id) { assert(isset($user_id)); global $_RUN; $homesector = sector_get_sector(user_get_home_sector($user_id)); // Get all anomaly counts from the sectors the user has discovered. We DONT want to count // the anomalies that the user did not already discovered. Hence the big SQL statement :) $result = sql_query("SELECT a.sector_id, COUNT(*) AS qty FROM s_anomalies AS a, g_anomalies AS g WHERE g.user_id = " . $user_id . " AND ( FIND_IN_SET( a.id, g.csl_discovered_id ) OR FIND_IN_SET( a.id, g.csl_undiscovered_id) ) GROUP BY a.sector_id"); while ($count = sql_fetchrow($result)) { $anomaly_count[$count['sector_id']] = $count['qty']; } $result = sql_query("SELECT s.* FROM s_sectors AS s, g_sectors AS g WHERE g.user_id = " . $user_id . " AND FIND_IN_SET(s.id, g.csl_sector_id)"); while ($sector = sql_fetchrow($result)) { $distance = calc_distance($homesector['distance'], $homesector['angle'], $sector['distance'], $sector['angle']); if ($sector['user_id'] == 0) { $owner = '<font color=red>unclaimed</font>'; } else { $tmp = user_get_user($sector['user_id']); $owner = $tmp['race']; } $tmp = array(); $tmp['href'] = "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($sector['id']); $tmp['id'] = $sector['sector']; $tmp['name'] = $sector['name']; $tmp['qty'] = $anomaly_count[$sector['id']]; $tmp['owner'] = $owner; $tmp['coordinate'] = $sector['distance'] . " / " . $sector['angle']; $tmp['distance'] = round($distance); $tmp['unround_distance'] = $distance; $sector_rows[] = $tmp; } uasort($sector_rows, "show_all_sectors_cmp"); print_subtitle("All known sectors and their planets"); foreach ($sector_rows as $sector) { $tmp = array(); $tmp['id'] = $sector['id']; $tmp['name'] = $sector['name']; $tmp['qty'] = $sector['qty']; $tmp['owner'] = $sector['owner']; $tmp['coordinate'] = $sector['coordinate']; $tmp['distance'] = $sector['distance']; $tmp['href'] = $sector['href']; $tmpvar[] = $tmp; } $template = new Smarty(); $template->debugging = true; help_set_template_vars($template); $template->assign("sectors", $tmpvar); if (isset($_REQUEST['pager_pos'])) { $template->assign("pager_pos", $_REQUEST['pager_pos']); } else { $template->assign("pager_pos", 0); } $template->assign("theme_path", $_RUN['theme_path']); $template->display($_RUN['theme_path'] . "/sectors-all.tpl"); }
function mining_show_all_sectors($user_id) { print_subtitle("All owned sectors and their planets with mining stations"); // Get all sectors that we own $result = sql_query("SELECT * FROM g_sectors WHERE user_id=" . $user_id); $tmp = sql_fetchrow($result); $sectors = split(",", $tmp['csl_sector_id']); array_pop($sectors); // Last one is a , so it makes an empty field, don't use it.. foreach ($sectors as $sector) { mining_show_sector($sector, $user_id); } }
function edit_description($anomaly_id) { assert(is_numeric($anomaly_id)); $anomaly = anomaly_get_anomaly($anomaly_id); print_subtitle("Edit description for " . $anomaly['name']); echo " <center>\n"; form_start(); echo " <input type=hidden name=aid value=" . encrypt_get_vars($anomaly_id) . ">\n"; echo " <input type=hidden name=cmd value=" . encrypt_get_vars("description2") . ">\n"; echo " <textarea name=ne_description maxlength=255 rows=10 cols=80>"; echo px2html4edit($anomaly['description']); echo "</textarea>\n"; echo " <input name=submit type=submit value=\"Change Description\">\n"; form_end(); echo " </center>\n"; create_submenu(array("Back to planet view" => "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly_id))); }
function vessel_select_vessel_by_user($user_id, $href_url, $title, $showtrades) { assert(is_numeric($user_id)); assert(!empty($href_url)); assert(!empty($title)); assert(!empty($showtrades)); global $_RUN; print_subtitle($title); $template = new Smarty(); $template->debugging = true; $result = sql_query("SELECT g.* FROM g_vessels AS g, s_vessels AS s WHERE g.user_id=" . $user_id . " AND g.created=1 AND g.vessel_id = s.id ORDER BY s.type, g.id"); while ($vessel = sql_fetchrow($result)) { if ($showtrades == NO_SHOW_TRADEROUTES) { $result2 = sql_query("SELECT * FROM a_trades WHERE vessel_id = " . $vessel['id']); if (!sql_fetchrow($result2)) { $tmpvar[] = vessel_show_table_row($vessel['id'], $href_url); } } else { $tmpvar[] = vessel_show_table_row($vessel['id'], $href_url); } } $template->assign("vessels", $tmpvar); $template->display($_RUN['theme_path'] . "/vessel-user.tpl"); }
function show_surface($planet_id) { global $_GALAXY; // Get global information from the user $planet = anomaly_get_anomaly($planet_id); $user = user_get_user($planet['user_id']); $sector = sector_get_sector($planet['sector_id']); $totals = calc_planet_totals($planet_id); // Generate text color for the power if ($totals['power_out'] == 0) { $power_p = 0; } else { $power_p = $totals['power_in'] / $totals['power_out'] * 100; } $power_color = "white"; if ($power_p > 50) { $power_color = "yellow"; } if ($power_p > 75) { $power_color = "orange"; } if ($power_p > 99) { $power_color = "red"; } // Generate text color for the crew if ($planet['population_capacity'] == 0) { $crew_p = 0; } else { $crew_p = $planet['population'] / $planet['population_capacity'] * 100; } $crew_color = "white"; if ($crew_p > 50) { $crew_color = "yellow"; } if ($crew_p > 75) { $crew_color = "orange"; } if ($crew_p > 99) { $crew_color = "red"; } print_subtitle("Surface View on planet " . $planet['name']); // ------------------------------------------------------------------ echo "<table width=75% align=center border=1>\n"; echo " <tr><th colspan=2>Global Information on<br>Sector " . $sector['name'] . " / Planet " . $planet['name'] . "</th></tr>\n"; echo " <tr><td>\n"; echo " <table width=100% border=0 cellpadding=0 cellspacing=0>\n"; echo " <tr><td> Power Generated </td><td> " . $totals['power_out'] . " </td></tr>\n"; echo " <tr><td> Power Needed </td><td> " . $totals['power_in'] . " </td></tr>\n"; echo " <tr><td> <font color={$power_color}><b>Power Left </b></font> </td><td> <font color={$power_color}><b>" . ($totals['power_out'] - $totals['power_in']) . "</b></font> </td></tr>\n"; echo " </table>\n"; echo " </td><td>\n"; echo " <table width=100% border=0 cellpadding=0 cellspacing=0>\n"; echo " <tr><td> <font color={$crew_color}>Inhabitants</font> </td><td> <font color={$crew_color}>" . $planet['population'] . "</font> </td></tr>\n"; echo " <tr><td> <font color={$crew_color}>Capacity</font> </td><td> <font color={$crew_color}>" . $planet['population_capacity'] . "</font> </td></tr>\n"; echo " <tr><td> </td><td> </td></tr>\n"; echo " </table>\n"; echo " </td></tr>\n"; echo "</table>\n"; echo "<br>\n"; echo "<br>\n"; // Get all buildings and cargo on the planet $surface = planet_get_surface($planet_id); $current_buildings = csl($surface['csl_building_id']); $current_buildings = array_count_values($current_buildings); $current_cargo = csl($surface['csl_cargo_id']); $current_cargo = array_count_values($current_cargo); // ------------------------------------------------------------------ // Show current buildings on the surface // echo "<table width=75% align=center border=0 cellpadding=0 cellspacing=0>\n"; echo "<table width=75% align=center border=0>\n"; echo " <tr class=wb><th colspan=5>Buildings on the planet</th></tr>\n"; echo " <tr class=bl>"; echo "<th>Qty</th>"; echo "<th>Name</th>"; echo "<th>Power In</th>"; echo "<th>Power Out</th>"; echo "<th>Description</th>"; echo "</tr>\n"; reset($current_buildings); while (list($building_id, $quantity) = each($current_buildings)) { $building = building_get_building(building_active_or_inactive($building_id)); if (building_is_active($building_id)) { } else { } if (building_is_active($building_id)) { $active = "<img alt=Active src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/active.gif>"; echo " <tr class=bl>\n"; echo " <td> " . $quantity . " </td>\n"; echo " <td> " . $active . " " . $building['name'] . " </td>\n"; echo " <td> " . $building['power_in'] . " </td>\n"; echo " <td> " . $building['power_out'] . " </td>\n"; echo " <td> " . $building['rule'] . " </td>\n"; echo " </tr>\n"; } else { $active = "<img alt=Inactive src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/inactive.gif>"; echo " <tr class=bl>\n"; echo " <td><font color=red> " . $quantity . " </font></td>\n"; echo " <td><font color=red> " . $active . " " . $building['name'] . " </font></td>\n"; echo " <td colspan=3><font color=red> Building not active </font></td>\n"; echo " </tr>\n"; } } echo "</table>\n"; echo "<br><br>\n"; // ------------------------------------------------------------------ // Show current items on the surface echo "<table width=75% align=center border=0>\n"; echo " <tr class=wb><th colspan=5>Cargo and machines on planet</th></tr>\n"; echo " <tr class=bl>"; echo "<th>Qty</th>"; echo "<th>Name</th>"; echo "<th>Description</th>"; echo "</tr>\n"; reset($current_cargo); while (list($item_id, $quantity) = each($current_cargo)) { $invention = item_get_item($item_id); if (invention_is_active_on_planet($invention)) { $activeimg = "alt=Active src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/active.gif"; } else { $activeimg = "alt=Inactive src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/inactive.gif"; } echo " <tr class=bl>\n"; echo " <td> " . $quantity . " </td>\n"; echo " <td> <img " . $activeimg . "> " . $invention['name'] . " </td>\n"; echo " <td> " . $invention['rule'] . " </td>\n"; echo " </tr>\n"; } echo "</table>\n"; echo "<br><br>\n"; }
function show_constructions($anomaly_id) { assert(is_numeric($anomaly_id)); // Get global information stuff $planet = anomaly_get_anomaly($anomaly_id); $user = user_get_user($planet['user_id']); // And get the ores from the planet $result = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $anomaly_id); $ores = sql_fetchrow($result); // Get all buildings that are currently build on the planet $surface = planet_get_surface($anomaly_id); $current_buildings = csl($surface['csl_building_id']); // If we've got an headquarter and it's inactive, we cannot build anything.. :( if (in_array(BUILDING_HEADQUARTER_INACTIVE, $current_buildings)) { print_line("Your headquarter is currently inactive due to insufficent resources for its upkeep. You cannot build anything on this planet until you replenish your resources."); $cannot_build = true; return; } print_subtitle("Construction on planet " . $planet['name']); // And get all buildings, compare wether or not we may build them... $result = sql_query("SELECT * FROM s_buildings ORDER BY id"); while ($building = sql_fetchrow($result)) { // Default, we can build this $cannot_build = false; // Stage -1: Check planet class when we want to build a headquarter if ($building['id'] == BUILDING_HEADQUARTER) { if (!planet_is_habitable($anomaly_id)) { $cannot_build = true; } } // Stage 0: Check building_level if ($building['build_level'] > $user['building_level']) { $cannot_build = true; } // Stage 1: Building Count Check // Build counter check if ($building['max'] > 0) { $times_already_build = 0; for ($i = 0; $i != count($current_buildings); $i++) { if (building_active_or_inactive($current_buildings[$i]) == $building['id']) { $times_already_build++; } } // Cannot build cause we already have MAX buildings of this kind.. :( // building['max'] = 0 means unlimited buildings... if ($times_already_build == $building['max']) { $cannot_build = true; } } // Stage 2: Dependency Check // Get all dependencies $buildings_needed = csl($building['csl_depends']); // Do we need them? If not, skip dependency-check. if (!empty($building['csl_depends'])) { $deps_found = count($buildings_needed); // Count to zero... while (list($key, $building_dep_id) = each($buildings_needed)) { if ($building_dep_id == "") { $deps_found--; continue; } // Get all dependencies if (in_array($building_dep_id, $current_buildings)) { $deps_found--; // Found in current_buildings? // Decrease counter } } } else { // No need for deps $deps_found = 0; // Zero is good... } // Not all dependencies found, we cannot build it.. :( if ($deps_found > 0) { $cannot_build = true; } // Stage 3: Show building if we can build it.. if ($cannot_build == false) { building_show_details($building['id'], $planet['id'], $user['user_id'], $ores['stock_ores']); } } }
function vessel_show_vessels_orbiting_planet($planet_id) { assert(is_numeric($planet_id)); $planet = anomaly_get_anomaly($planet_id); if (!anomaly_is_planet($planet_id)) { print_subtitle("This is not a planet!"); return; } print_subtitle("All vessels orbiting planet " . $planet['name']); $firstrow = 1; $userid = 0; $result = sql_query("SELECT g.* FROM g_vessels AS g, s_vessels AS s WHERE g.status='ORBIT' AND g.planet_id={$planet_id} AND g.created=1 AND s.id = g.vessel_id ORDER BY g.user_id, s.type"); while ($vessel = sql_fetchrow($result)) { if ($vessel['user_id'] != $userid) { $userid = $vessel['user_id']; if ($firstrow == 0) { echo "</table>\n"; echo "<br><br>\n"; } else { $firstrow = 0; } echo "<table align=center border=0>\n"; echo " <tr class=wb>"; echo "<th>Name</th>"; echo "<th>Type</th>"; echo "<th>Status</th>"; echo "<th>Coords</th>"; echo "<th>Race</th>"; echo "</tr>\n"; } vessel_show_table_row($vessel['id'], $_SERVER['PHP_SELF'], "SHOW_SPECIES"); } echo "</table>\n"; echo "<br><br>\n"; }
function passtrough($url) { assert(!empty($url)); print_header("<meta http-equiv=\"refresh\" CONTENT=\"1; URL={$url}\">"); print_subtitle("<b>Loading...</b>"); print_line("<a href=\"{$url}\">Click here if you are not being redirected...</a>"); print_footer(); }
function obsolete_show_vessels($planet_id) { assert(!empty($planet_id)); global $_USER; // Get global information from the user $user = user_get_user($_USER['id']); $planet = anomaly_get_anomaly($planet_id); // And get the ores from the planet $result = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $planet_id); $ores = sql_fetchrow($result); $stock_ores = ore_csl_to_list($ores['stock_ores']); print_subtitle("Create vessel on planet " . $planet['name']); // And get all buildings, compare wether or not we may build them... $result = sql_query("SELECT * FROM s_vessels ORDER BY id"); while ($vessel = sql_fetchrow($result)) { // Default, we can build this $cannot_build = false; // Stage 3: Show building if we can build it.. if ($cannot_build == false) { show_vessel_table($vessel, $user, $stock_ores); } } }
function show_inventions($anomaly_id) { assert(!empty($anomaly_id)); // Get global information stuff $planet = anomaly_get_anomaly($anomaly_id); $user = user_get_user($planet['user_id']); // And get the ores from the planet $result = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $anomaly_id); $ores = sql_fetchrow($result); $stock_ores = $ores['stock_ores']; // Get all buildings that are currently build on the planet $surface = planet_get_surface($anomaly_id); $current_buildings = csl($surface['csl_building_id']); $current_cargo = $surface['csl_cargo_id']; print_subtitle("Produceable on planet " . $planet['name']); // Get all items, compare wether or not we may build them... $result = sql_query("SELECT * FROM s_inventions ORDER BY type, id"); while ($item = sql_fetchrow($result)) { // Default, we can build this $cannot_build = false; // Stage 1: Item Count Check if ($item['max'] > 0) { $times_already_build = 0; for ($i = 0; $i != count($current_cargo); $i++) { if ($current_cargo[$i] == $item['id']) { $times_already_build++; } } // Cannot build cause we already have MAX items of this kind.. :( if ($times_already_build == $item['max']) { $cannot_build = true; } } // Stage 2: Dependency Check // Get all dependencies $items_needed = csl($item['csl_depends']); // Do we need them? If not, skip dependency-check. if (!empty($item['csl_depends'])) { $deps_found = count($items_needed); // Count to zero... while (list($key, $item_dep_id) = each($items_needed)) { if ($item_dep_id == "") { $deps_found--; continue; } // Get all dependencies if (in_array($item_dep_id, $current_buildings)) { $deps_found--; // Found in current_items? // Decrease counter } } } else { // No need for deps $deps_found = 0; // Zero is good... } // Not all dependencies found, we cannot build it.. :( if ($deps_found > 0) { $cannot_build = true; } // Stage 3: Show building if we can build it.. if ($cannot_build == false) { invention_show_details($item['id'], $planet['id'], $user['user_id'], $stock_ores); } } }
function select_destination($vessel_id) { assert(is_numeric($vessel_id)); $vessel = vessel_get_vessel($vessel_id); $result = sql_query("SELECT * FROM g_flags WHERE user_id=" . $vessel['user_id']); $flags = sql_fetchrow($result); print_subtitle("Select destination for vessel " . $vessel['name']); print_remark("Select_destination"); echo "<table align=center border=0>\n"; echo " <tr><td valign=top>\n"; vessel_select_automatic($vessel_id); if ($flags['can_warp']) { echo " </td></tr><tr><td valign=top>\n"; vessel_select_preset($vessel_id); echo " </td></tr><tr><td valign=top>\n"; vessel_select_manual($vessel_id); } echo " </td></tr>\n"; echo "</table>\n"; create_submenu(array("Show Vessel" => "vessel.php?cmd=" . encrypt_get_vars("showvid") . "&vid=" . encrypt_get_vars($vessel_id))); echo "<br><br>\n"; }
} if ($cmd == "manualwww") { print_subtitle("Jump to encrypted page."); if (!isset($_REQUEST['ww_cmd'])) { $_REQUEST['ww_cmd'] = ""; } if (!isset($_REQUEST['ww_k'])) { $_REQUEST['ww_k'] = array("", "", "", "", "", "", "", ""); } if (!isset($_REQUEST['ww_v'])) { $_REQUEST['ww_v'] = array("", "", "", "", "", "", "", ""); } show_www_table($_REQUEST['ww_cmd'], $_REQUEST['ww_k'], $_REQUEST['ww_v']); } if ($cmd == "manualwww2") { print_subtitle("Jump to encrypted page."); show_www_table($_REQUEST['ww_cmd'], $_REQUEST['ww_k'], $_REQUEST['ww_v']); echo "<hr>\n"; www_execute($_REQUEST['ww_cmd'], $_REQUEST['ww_k'], $_REQUEST['ww_v']); } create_submenu(array("PX_Server" => "admin.php?cmd=" . encrypt_get_vars("pxserver"), "Manual WWW" => "admin.php?cmd=" . encrypt_get_vars("manualwww"), "New Sector" => "createnewsector.php", "New User" => "createnewuser.php", "ScanArea" => "scanarea.php", "Ticks" => "ticks.php", "zoomtables" => "zoomtables.php", "test users" => "createtest.php")); print_footer(); exit; // ================================================================================ function show_px_table($px_cmd, $px_k, $px_v) { form_start(); echo "<input type=hidden name=cmd value=" . encrypt_get_vars("pxserver2") . ">\n"; echo "<table align=center>\n"; echo " <tr>"; echo "<td>Command</td>";