function stock_show_sector($sector_id, $user_id) { assert(!empty($sector_id)); assert(!empty($user_id)); global $_CONFIG; // Check how many planets we own in this sector. If none, don't show anything... $result = sql_query("SELECT COUNT(*) AS count FROM s_anomalies WHERE sector_id = " . $sector_id . " AND user_id=" . $user_id); $tmp = sql_fetchrow($result); if ($tmp['count'] == 0) { return; } // Get sector information $sector = sector_get_sector($sector_id); // Only show a table if we got rows in it... $first_row = true; // Get planet information for all planets in the sector $result = sql_query("SELECT * from s_anomalies WHERE user_id=" . $user_id . " AND type='P' AND sector_id=" . $sector['id']); while ($planet = sql_fetchrow($result)) { $result2 = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $planet['id']); $ores = sql_fetchrow($result2); $stock_ores = ore_csl_to_list($ores['stock_ores']); $upkeep_ores = ore_csl_to_list($planet['upkeep_ores']); for ($i = 0; $i != ore_get_ore_count(); $i++) { $fo = "ore" . $i . "c"; ${$fo} = "white"; if ($upkeep_ores[$i] == 0) { $ticks_left = 0; } else { $ticks_left = $stock_ores[$i] / $upkeep_ores[$i]; if ($ticks_left < 50) { ${$fo} = "yellow"; } if ($ticks_left < 25) { ${$fo} = "orange"; } if ($ticks_left < 10) { ${$fo} = "red"; } } } $user = user_get_user($planet['user_id']); if ($user['science_ratio'] == 100 or $planet['happieness'] == 0) { $planet_income = 0; } else { $planet_income = $planet['population'] / (100 / (100 - $user['science_ratio'])); $planet_income = $planet_income / $_CONFIG['h_credits_dividor']; $planet_income = $planet_income / (100 / $planet['happieness']); } $planet_upkeep = $planet['upkeep_costs']; $delta_upkeep = intval($planet_income - $planet_upkeep); // Only show a table if we have rows in it... if ($first_row) { $first_row = false; print_remark("Sector table"); echo "<table align=center border=0>\n"; echo " <tr class=wb><td colspan=" . (ore_get_ore_count() + 2) . "><b><i>Sector " . $sector['sector'] . ": " . $sector['name'] . "</i></b></td></tr>\n"; echo " <tr class=bl><th colspan=2>Name</th>"; for ($i = 0; $i != ore_get_ore_count(); $i++) { echo "<th>" . ore_get_ore_name($i) . "</th>"; } echo "</tr>\n"; } echo " <tr class=bl>\n"; echo " <td rowspan=2 valign=top>\n"; echo " <a href=\"anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']) . "\">Planet " . $planet['name'] . "</a> <br>\n"; if ($delta_upkeep < 0) { echo " <font color=red>Delta Upkeep: " . $delta_upkeep . "</font> \n"; } else { echo " Delta Upkeep: " . $delta_upkeep . " \n"; } echo " </td>\n"; echo "<td> Current in stock </td>"; for ($i = 0; $i != ore_get_ore_count(); $i++) { $fo = "ore" . $i . "c"; echo "<td align=right><font color=" . ${$fo} . ">" . $stock_ores[$i] . "</font></td>"; } echo "</tr>\n"; echo " <tr class=bl>"; echo "<td> Upkeep per tick </td>"; for ($i = 0; $i != ore_get_ore_count(); $i++) { $fo = "ore" . $i . "c"; echo "<td align=right><font color=" . ${$fo} . ">" . $upkeep_ores[$i] . "</font></td>"; } echo "</tr>\n"; } // while if ($first_row == false) { echo "</table>\n"; // Close last sector echo "<br><br>\n"; } }
function show_invention_levels($uid) { $user = user_get_user($uid); print_remark("Invention table"); echo "<table align=center border=0 width=75%>\n"; echo " <tr valign=top><td valign=top>\n"; echo " <table align=center border=0 width=100%>\n"; echo " <tr><td>General improvement: </td><td>" . $user['invention_level'] . " Points</td></tr>\n"; echo " <tr><td colspan=2 class=ylw>Invent new general inventions.</td></tr>\n"; echo " <tr><td colspan=2> </td></tr>\n"; echo " <tr><td>Building improvement: </td><td>" . $user['building_level'] . " Points</td></tr>\n"; echo " <tr><td colspan=2 class=ylw>Invent and improve buildings. Higher ratings will invent different types of buildings.</td></tr>\n"; echo " <tr><td colspan=2> </td></tr>\n"; echo " </table>\n"; if ($user['impulse'] > 0) { echo " </td><td>\n"; echo " <table align=center border=0 width=100%>\n"; echo " <tr><td>Vessel improvement: </td><td>" . $user['vessel_level'] . " Points</td></tr>\n"; echo " <tr><td colspan=2 class=ylw>Invent and improve vessels. Higher ratings will invent different types of vessels, faster possible speeds and weaponry.</td></tr>\n"; echo " <tr><td colspan=2> </td></tr>\n"; echo " <tr><td>Space exploration: </td><td>" . $user['explore_level'] . " Points</td></tr>\n"; echo " <tr><td colspan=2 class=ylw>Explore new regions of space. Higher ratings will discover more planets and sectors and can intercept messages from further away.</td></tr>\n"; echo " <tr><td colspan=2> </td></tr>\n"; echo " </table>\n"; } echo " </td></tr>\n"; echo "</table>\n"; echo "<br><br>\n"; }
/** * Print a given user row detailed * * @param $data_row * @param $stat_issue_count * @param $group_index * @return mixed */ function print_user_row($data_row, $stat_issue_count, $group_index) { global $print; /** group 1 */ if ($group_index == 1) { /** assigned_project_id is always null, so check current selected project and subprojects, * if the user has permission to see info */ $user_permission = userprojectapi::check_user_permission(); } else { $assigned_project_id = $data_row['assigned_project_id']; $user_permission = userprojectapi::check_user_has_level($assigned_project_id); } if ($user_permission) { echo '<tr class="info" data-level="2" data-status="1">' . PHP_EOL; echo '<td></td>' . PHP_EOL; if ($print) { echo '<td></td>' . PHP_EOL; userprojectapi::get_cell_highlighting($data_row, 1, 'nowrap'); echo '</td>' . PHP_EOL; } else { if ($group_index == 1) { print_chackbox($data_row); } else { echo '<td></td>' . PHP_EOL; } print_user_avatar($data_row, $group_index); } if ($group_index == 1) { print_user_name($data_row); print_real_name($data_row); } print_layer_one_project($data_row, $print, $group_index); $project_hierarchy_depth = userprojectapi::get_project_hierarchy_depth(helper_get_current_project()); if ($group_index != 1) { if ($project_hierarchy_depth > 1) { print_bug_layer_project($data_row, $print); } if ($project_hierarchy_depth > 2) { print_version_layer_project($data_row, $print); } print_target_version($data_row, $print); } $stat_issue_count = print_amount_of_issues($data_row, $group_index, $stat_issue_count, $print); print_remark($data_row, $group_index, $print); echo '</tr>' . PHP_EOL; } return $stat_issue_count; }
function obsolete_conview_show_sector($user_id, $sector_id, $planets) { assert(is_numeric($user_id)); assert(is_numeric($sector_id)); assert(is_array($planets)); // Check how many planets we own in this sector. If none, don't show anything... $result = sql_query("SELECT COUNT(*) AS count FROM s_anomalies WHERE sector_id = " . $sector_id . " AND user_id=" . $user_id); $tmp = sql_fetchrow($result); if ($tmp['count'] == 0) { return; } // Get sector information $sector = sector_get_sector($sector_id); // Only show a table when we have rows, which means: create table on printing the first row $first_row = true; // Get planet information for all planets in the sector $result = sql_query("SELECT * FROM s_anomalies WHERE sector_id=" . $sector_id . " AND user_id=" . $user_id . " ORDER BY distance"); while ($planet = sql_fetchrow($result)) { // If we can't view the planet, then don't show it... if (!in_array($planet['id'], $planets)) { continue; } if ($first_row) { $first_row = false; print_remark("Sector " . $sector['sector']); echo "<table align=center border=0>\n"; echo " <tr class=wb><th colspan=6>Sector " . $sector['sector'] . ": " . $sector['name'] . "</th></tr>\n"; } // Can we show this planet (eg, is it in our $planets-array) if (!empty($visible_planets) && !in_array($planet['id'], $visible_planets)) { continue; } // Show entry echo " <tr class=bl>\n"; if (anomaly_is_planet($planet['id'])) { echo " <td> Planet " . $planet['name'] . " </td>\n"; echo " <td><a href=\"anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']) . "\"> View Planet Info </a></td>\n"; } else { echo " <td> Anomaly " . $planet['name'] . " </td>\n"; echo " <td><a href=\"anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']) . "\"> View Anomaly Info </a></td>\n"; } if (planet_is_habitable($planet['id']) or planet_is_minable($planet['id'])) { echo " <td><a href=\"surface.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']) . "\"> Surface View </a></td>\n"; echo " <td><a href=\"construct.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']) . "\"> Construction </a></td>\n"; echo " <td><a href=\"manufacture.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']) . "\"> Manufacture </a></td>\n"; if (planet_has_vesselbuilding_capability($planet['id'])) { echo " <td><a href=\"vesselcreate.php?cmd=" . encrypt_get_vars("showaid") . "&aid=" . encrypt_get_vars($planet['id']) . "\"> Create Vessel </a></td>\n"; } else { echo " <td> </td>\n"; } } else { echo " <th colspan=4>No Construction Possible</th>\n"; } echo " </tr>\n"; } // while if ($first_row == false) { echo "</table>\n"; // Close last sector echo "<br><br>\n"; } }
function message_create_alliance($user_id) { $user = user_get_user($user_id); $race = user_get_race($user['user_id']); $result = sql_query("SELECT * FROM g_alliance WHERE id=" . $user['alliance_id']); $alliance = sql_fetchrow($result); print_remark("Createmessage"); form_start(); echo " <table align=center border=0 width=80%>\n"; echo " <tr><th>Send message</th></tr>\n"; echo " <tr><td>From: </td><td>" . $race . " race</td></tr>\n"; echo " <tr><td>To: </td><td>All members of " . $alliance['name'] . "</td></tr>\n"; echo " <tr><td>Subject: </td><td><input type=text name=ne_subject size=50 maxvalue=50></td></tr>\n"; echo " <tr><td>Msg: </td><td><textarea name=ne_msg rows=5 cols=60></textarea></td></tr>\n"; echo " <tr><td> </td><td><input type=submit name=submit value='Send Message'></td></tr>\n"; echo " </table>\n"; echo " <br><br>\n"; echo "\n"; echo "<input type=hidden name=src_uid value=" . encrypt_get_vars($user['user_id']) . ">\n"; echo "<input type=hidden name=dst_uid value=" . encrypt_get_vars($user['alliance_id']) . ">\n"; echo "<input type=hidden name=target value=" . encrypt_get_vars("ALLIANCE") . ">\n"; echo "<input type=hidden name=cmd value=" . encrypt_get_vars("post") . ">\n"; form_end(); }
function trade_show_routes($user_id) { assert(is_numeric($user_id)); global $_GALAXY; $firstrow = 1; $result = sql_query("SELECT * FROM a_trades"); while ($traderoute = sql_fetchrow($result)) { $src_planet = anomaly_get_anomaly($traderoute['src_planet_id']); $dst_planet = anomaly_get_anomaly($traderoute['dst_planet_id']); // We don't own the source or destination planet... skip it.. if ($src_planet['user_id'] != $user_id and $dst_planet['user_id'] != $user_id) { continue; } $vessel = vessel_get_vessel($traderoute['vessel_id']); $ore1 = ""; $ore2 = ""; if ($traderoute['src_ore'] == ORE_NONE) { $ore1 = "None, "; } elseif ($traderoute['src_ore'] == ORE_ALL) { $ore1 = "All ores, "; } else { $ores = csl($traderoute['src_ore']); foreach ($ores as $ore) { $ore1 .= ore_get_ore_name($ore) . ", "; } } // Chop off last comma $ore1 = substr_replace($ore1, "", -2); if ($traderoute['dst_ore'] == ORE_NONE) { $ore2 = "None, "; } elseif ($traderoute['dst_ore'] == ORE_ALL) { $ore2 = "All ores, "; } else { $ores = csl($traderoute['dst_ore']); foreach ($ores as $ore) { $ore2 .= ore_get_ore_name($ore) . ", "; } } // Chop off last comma $ore2 = substr_replace($ore2, "", -2); if ($firstrow == 1) { $firstrow = 0; print_remark("Vessel table"); echo "<table align=center width=80% border=0>\n"; echo " <tr class=wb>"; echo "<th>Vessel</th>"; echo "<th>Source</th>"; echo "<th>Ores</th>"; echo "<th>Destination</th>"; echo "<th>Ores</th>"; echo "</tr>\n"; } echo " <tr class=bl>\n"; echo " <td> <img src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/ships/trade.jpg> <a href=vessel.php?cmd=" . encrypt_get_vars("showvid") . "&vid=" . encrypt_get_vars($vessel['id']) . ">" . $vessel['name'] . "</a> </td>\n"; echo " <td> <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($src_planet['id']) . ">" . $src_planet['name'] . "</a> </td>\n"; echo " <td> " . $ore1 . " </td>\n"; echo " <td> <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($dst_planet['id']) . ">" . $dst_planet['name'] . "</a> </td>\n"; echo " <td> " . $ore2 . " </td>\n"; echo " </tr>\n"; } if ($firstrow == 0) { echo "</table>\n"; echo "<br><br>\n"; } else { print_line("There are currently no traderoutes available."); } }
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"; }
function mining_show_sector($sector_id, $user_id) { assert(!empty($sector_id)); assert(!empty($user_id)); // Check how many planets we own in this sector. If none, don't show anything... $result = sql_query("SELECT COUNT(*) AS count FROM s_anomalies WHERE sector_id = " . $sector_id . " AND user_id=" . $user_id); $tmp = sql_fetchrow($result); if ($tmp['count'] == 0) { return; } // Get sector information $sector = sector_get_sector($sector_id); // Only show a table if we got rows in it... $first_row = true; // Get planet information for all planets in the sector $result = sql_query("SELECT * from s_anomalies WHERE user_id=" . $user_id . " AND type='P' AND sector_id=" . $sector['id']); while ($planet = sql_fetchrow($result)) { # if (!in_array ($planet['id'], $planets)) continue; $result2 = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $planet['id']); $ores = sql_fetchrow($result2); $cur_ores = ore_csl_to_list($ores['cur_ores']); $max_ores = ore_csl_to_list($ores['max_ores']); for ($i = 0; $i != ore_get_ore_count(); $i++) { $fo = "ore" . $i . "c"; if ($max_ores[$i] == 0) { $tmp = 0; } else { $tmp = $cur_ores[$i] / $max_ores[$i] * 100; } ${$fo} = "white"; if ($tmp > 50) { ${$fo} = "yellow"; } if ($tmp > 75) { ${$fo} = "orange"; } if ($tmp > 99) { ${$fo} = "red"; } } # Only show a table if we have rows in it... if ($first_row) { $first_row = false; print_remark("Sector table"); echo "<table align=center border=0>\n"; echo " <tr class=wb><td colspan=" . (ore_get_ore_count() + 2) . "><b><i>Sector " . $sector['sector'] . ": " . $sector['name'] . "</i></b></td></tr>\n"; echo " <tr class=bl><th>Name</th>"; for ($i = 0; $i != ore_get_ore_count(); $i++) { echo "<th>" . ore_get_ore_name($i) . "</th>"; } echo "</tr>\n"; } if (!planet_is_minable($planet['id'])) { echo " <tr class=bl>"; echo "<td> Planet " . $planet['name'] . " </td>"; echo "<th colspan=" . ore_get_ore_count() . ">No mining possible</th>"; echo "</tr>\n"; } else { echo " <tr class=bl>"; echo "<td> <a href=\"anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']) . "\">Planet " . $planet['name'] . "</a> </td>"; for ($i = 0; $i != ore_get_ore_count(); $i++) { $fo = "ore" . $i . "c"; echo "<td><font color=" . ${$fo} . ">" . $cur_ores[$i] . "</font></td>"; } echo "</tr>\n"; } } // while if ($first_row == false) { echo "</table>\n"; // Close last sector echo "<br><br>\n"; } }