function preset_show_all_presets($user_id) { assert(is_numeric($user_id)); echo "<table align=center widht=75%>\n"; echo " <tr class=wb>\n"; echo " <th>Preset name</th>\n"; echo " <th>Distance</th>\n"; echo " <th>Angle</th>\n"; echo " <th> </th>\n"; echo " </tr>\n"; // Get all presets $result = sql_query("SELECT * FROM g_presets WHERE user_id=" . $user_id); while ($preset = sql_fetchrow($result)) { echo " <tr class=bl>\n"; echo " <td> " . $preset['name'] . " </td>\n"; echo " <td> " . $preset['distance'] . " </td>\n"; echo " <td> " . $preset['angle'] . " </td>\n"; echo " <td> [ <a href=vesselpreset.php?cmd=" . encrypt_get_vars("delete") . "&uid=" . encrypt_get_vars($user_id) . "&pid=" . encrypt_get_vars($preset['id']) . ">Delete</a> ] </td>\n"; echo " </tr>\n"; } // And add room to create a new one... echo " <tr class=bl>\n"; form_start(); echo " <input type=hidden name=cmd value=" . encrypt_get_vars("create") . ">\n"; echo " <input type=hidden name=uid value=" . encrypt_get_vars($user_id) . ">\n"; echo " <td><input type=text name=ne_name size=20 maxlength=20></td>\n"; echo " <td><input type=text name=ne_distance size=6 maxlength=6></td>\n"; echo " <td><input type=text name=ne_angle size=7 maxlength=7></td>\n"; echo " <td><input type=submit name=name=submit value=Add></td>\n"; form_end(); echo " </tr>\n"; echo "</table>\n"; }
function csl_create_array($result, $colnumber) { assert(isset($result)); assert(isset($colnumber)); // Make array $tmp = array(); // Explode all rows into the tmp-array while ($row = sql_fetchrow($result)) { // If it's not an empty string, place a comma after the string if there isn't one already... $char = substr($row[$colnumber], -1); if ($row[$colnumber] != "" and $char != ",") { $row[$colnumber] = $row[$colnumber] . ","; } $tmp = array_merge($tmp, explode(",", $row[$colnumber])); } // This function makes sure we start at row 0 again. This is needed // so we can make a second call to explode_array without having to // do a whole query again... @mysql_data_seek($result, 0); // Since last char is a comma, last entry after explode is bogus // echo "CSL_CREATE_ARRAY BEFORE: "; print_r($tmp); echo "<br>\n"; if (end($tmp) == "") { array_pop($tmp); } reset($tmp); // echo "CSL_CREATE_ARRAY AFTER : "; print_r($tmp); echo "<br>\n"; // And return return $tmp; }
function UserList() { //IF(tahapan_tes='1', 'Kraeplin', IF(tahapan_tes='2', 'PAPI', IF(tahapan_tes='3', 'DISC', IF(tahapan_tes='4', 'WPT', 'Completed')))) AS tahapan $UserQuery = "SELECT tanggal_tes, no_ktp, nama_peserta, CONCAT(usia ,' Tahun') AS usia, posisi, tahapan_tes,\n\t\t\t\t\t\tIF(tahapan_tes='1', 'WPT', IF(tahapan_tes='2', 'PAPI', IF(tahapan_tes='3', 'DISC', IF(tahapan_tes='4', 'Kraeplin', 'Completed')))) AS tahapan\n\t\t\t\t\t\tFROM USER "; $UserQuery .= " ORDER BY tanggal_tes DESC "; $stmt = sql_query($UserQuery); $content = '<div id="title" align="center" style="font-weight:bold; font-size:23px;">Data Peserta</div><br /><br /><br /> <div id="body" align="center" style="width: 900px; margin: auto;"> <table width="900px" class="display" id="tableatendee" > <thead> <tr align="center"> <th style="text-align:center;">Tanggal Tes</th> <th style="text-align:center;">No. KTP</th> <th style="text-align:center;">Nama Peserta</th> <th style="text-align:center;">Usia</th> <th style="text-align:center;">Posisi yang<br />Dilamar</th> <th style="text-align:center;">Tahapan<br />Tes</th> <th style="text-align:center;">Tindakan</th> </tr></thead>'; $content .= '<tbody>'; $i = 0; while ($row = sql_fetchrow($stmt)) { $i++; $content .= "<tr><td align=\"center\">" . getDMYFormatDate($row['tanggal_tes']) . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['no_ktp'] . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['nama_peserta'] . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['usia'] . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['posisi'] . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['tahapan'] . "</td>"; $content .= "<td style='text-align:center'>"; $content .= UserAction($row['no_ktp'], $row['tahapan_tes']); $content .= "</td>"; $content .= "</tr>"; } // if($i=='0') $content .= '<tr><td colspan="9" class="fb12" align="center" bgcolor="#d4e8f6">Data tidak ditemukan</td></tr>'; $content .= '</tbody>'; $content .= '</table><br><br></div>'; echo $content; }
function scan_area($sector, $range) { $result = sql_query("SELECT * FROM s_sectors WHERE id={$sector}"); $sector = sql_fetchrow($result); echo "<table align=center border=1>\n"; echo " <tr><th colspan=4>Scanning from origin " . $sector['name'] . " ( " . $sector['distance'] . " / " . $sector['angle'] . " ) @ " . $range . " lightyears</th></tr>\n"; echo " <tr><td>Name</td><td>Race</td><td>D / A</td><td>Range</td></tr>\n"; $result = sql_query("SELECT * FROM g_vessels ORDER BY user_id"); while ($vessel = sql_fetchrow($result)) { $result2 = sql_query("SELECT * FROM s_species WHERE user_id = " . $vessel['user_id']); $race = sql_fetchrow($result2); if ($vessel['sector_id'] == 0) { $distance = calc_distance($sector['distance'], $sector['angle'], $vessel['distance'], $vessel['angle']); if ($distance <= $range) { echo "<tr><td>" . $vessel['name'] . " (" . $vessel['sector_id'] . ")</td><td>" . $race['name'] . "</td><td>" . $vessel['distance'] . " / " . $vessel['angle'] . "</td><td>" . $distance . "</td></tr>\n"; } } else { $result2 = sql_query("SELECT * FROM s_sectors WHERE id=" . $vessel['sector_id']); $vessel_sector = sql_fetchrow($result2); $distance = calc_distance($sector['distance'], $sector['angle'], $vessel_sector['distance'], $vessel_sector['angle']); if ($distance <= $range) { echo "<tr><td>" . $vessel['name'] . " (" . $vessel['sector_id'] . ")</td><td>" . $race['name'] . "</td><td>SECTOR: " . $vessel_sector['distance'] . " / " . $vessel_sector['angle'] . "</td><td>" . $distance . "</td></tr>\n"; } } } print "</table>"; print "<br><br>"; return; }
function show_users($user_id) { global $_GALAXY; echo "<table border=0 align=center width=60%>\n"; // Show friends echo "<tr><th class=white colspan=2>Friendly Races</th></tr>\n"; $result = sql_query("SELECT gu.* FROM g_users AS gu, g_knownspecies AS gks WHERE FIND_IN_SET( gu.user_id, gks.csl_friend_id ) and gks.user_id=" . $user_id); while ($user = sql_fetchrow($result)) { echo "<tr class=bl><td><a href=user.php?cmd=" . encrypt_get_vars("showdetail") . "&uid=" . encrypt_get_vars($user['user_id']) . ">" . $user['race'] . " Race</a></td><td> </td></tr>\n"; } echo "<tr><td colspan=2> </td></tr>\n"; // Show neutral echo "<tr><th class=white colspan=2>Neutral Races</th></tr>\n"; $result = sql_query("SELECT gu.* FROM g_users AS gu, g_knownspecies AS gks WHERE FIND_IN_SET( gu.user_id, gks.csl_neutral_id ) and gks.user_id=" . $user_id); while ($user = sql_fetchrow($result)) { echo "<tr class=bl><td><a href=user.php?cmd=" . encrypt_get_vars("showdetail") . "&uid=" . encrypt_get_vars($user['user_id']) . ">" . $user['race'] . " Race</a></td><td> </td></tr>\n"; } echo "<tr><td colspan=2> </td></tr>\n"; // Show enemies echo "<tr><th class=white colspan=2>Enemy Races</th></tr>\n"; $result = sql_query("SELECT gu.* FROM g_users AS gu, g_knownspecies AS gks WHERE FIND_IN_SET( gu.user_id, gks.csl_enemy_id ) and gks.user_id=" . $user_id); while ($user = sql_fetchrow($result)) { echo "<tr class=bl><td><a href=user.php?cmd=" . encrypt_get_vars("showdetail") . "&uid=" . encrypt_get_vars($user['user_id']) . ">" . $user['race'] . " Race</a></td><td> </td></tr>\n"; } echo "<tr><td colspan=2> </td></tr>\n"; echo "</table>"; }
function show_owned_convoys($user_id) { assert(is_numeric($user_id)); echo "<table border=1 align=center>"; echo " <tr>"; echo " <th>Convoy Name</th>"; echo " <th>Flag Ship</th>"; echo " <th>Ships</th>"; echo " <th>Status</th>"; echo " </tr>"; $result = sql_query("SELECT c.* FROM s_convoys c, s_vessels v WHERE c.vessel_id=v.id AND v.user_id=" . $user_id); while ($convoy = sql_fetchrow($result)) { // Get the flag ship of the convoy $vesseltype = vessel_get_vessel_type($convoy['id']); // Count the number of ships $result2 = sql_query("SELECT c.* FROM s_convoys c, s_vessels v WHERE c.vessel_id=v.id AND v.user_id=" . $user_id); $tmp = csl_create_array($result2, "vessel_ids"); $shipcount = count($tmp); // Get the status of the convoy $status = $convoy['status']; echo "<tr>"; echo "<td> " . $convoy['name'] . " </td>"; echo "<td> " . $vesseltype['name'] . " </td>"; echo "<td> " . $shipcount . " </td>"; echo "<td> " . $status . " </td>"; echo "</tr>"; } echo "</table>"; }
function wormhole_show_wormhole($wormhole_id) { assert(!empty($wormhole_id)); global $_GALAXY; if (!anomaly_is_wormhole($wormhole_id)) { return; } $wormhole = anomaly_get_anomaly($wormhole_id); $sector = sector_get_sector($wormhole['sector_id']); $race = user_get_race($wormhole['user_id']); $result = sql_query("SELECT * FROM w_wormhole WHERE id=" . $wormhole['id']); $dst_wormhole = sql_fetchrow($result); if ($race == "") { $race = "-"; } echo "<table border=1 width=500 align=center>\n"; echo " <tr><td align=center><b><i>Sector: " . $sector['name'] . " / Anomaly: " . $wormhole['name'] . "</i></b></td></tr>\n"; echo " <tr><td>\n"; echo " <table border=0 cellpadding=0 cellspacing=0 width=100%>\n"; echo " <tr><td width=200>\n"; echo " <table border=0 cellpadding=0 cellspacing=0 width=100%>\n"; echo " <tr><th>Anomaly View</th></tr>\n"; echo " <tr><td width=100%><center><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/wormholes/" . $wormhole['image'] . ".jpg\" width=150 height=150></center></td></tr>\n"; echo " <tr><th> </th></tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " <td> </td>\n"; echo " <td nowrap valign=top>\n"; echo " <table border=0 cellpadding=0 cellspacing=0 width=100%>\n"; echo " <tr><td nowrap width=40%><strong>Wormhole Name </strong></td><td nowrap width=1%><b>:</b></td>\n"; if ($wormhole['unknown'] == 1) { form_start(); echo "<td nowrap>\n"; echo " <input type=hidden name=aid value=" . encrypt_get_vars($wormhole_id) . ">\n"; echo " <input type=hidden name=cmd value=" . encrypt_get_vars("claim") . ">\n"; echo " <input type=text size=15 maxlength=30 name=ne_name>\n"; echo " <input name=submit type=submit value=\"Claim\">\n"; echo "</td>\n"; form_end(); } else { echo "<td nowrap>" . $wormhole['name'] . "</td>\n"; } echo " </tr>\n"; echo " <tr><td colspan=3> </td></tr>\n"; echo " <tr><td nowrap width=40%><strong>Caretaker </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $race . "</td></tr>\n"; echo " <tr><td nowrap width=40%><strong>Radius </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $wormhole['radius'] . " km</td></tr>\n"; echo " <tr><td nowrap width=40%><strong>Distance to sun </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $wormhole['distance'] . " km (10<sup>6</sup>)</td></tr>\n"; echo " <tr><td colspan=3> </td></tr>\n"; echo " <tr><td nowrap width=40%><strong>Destination </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $dst_wormhole['distance'] . " / " . $dst_wormhole['angle'] . "</td></tr>\n"; echo " <tr><td nowrap width=40%><strong>Stability </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . wormhole_get_wormhole_stability($dst_wormhole['next_jump']) . " </td></tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo "</table>\n"; echo "<br><br>\n"; }
function help_set_template_vars(&$template, $prefix = "%") { // NOOOTIENOOOT: You see this is a REFERENCE to the object, not the object itself, since we still use PHP4.0 :( assert(is_object($template)); $result = sql_query("SELECT * FROM perihelion.help WHERE id like '" . $prefix . "_%'"); while ($row = sql_fetchrow($result)) { $template->assign("help_" . strtolower($row['id']), help_link($row['id'])); } }
function score_generate_scoring_table() { global $score_generated; global $score; $tables = array("resource", "exploration", "strategic", "overall"); foreach ($tables as $table) { $result = sql_query("SELECT u.id AS user_id, u.name, s.{$table} AS points FROM perihelion.u_users AS u, perihelion.u_score AS s WHERE u.id = s.user_id ORDER BY s.{$table} DESC"); $i = 0; while ($row = sql_fetchrow($result)) { $i++; $score[$table][$i] = $row; } } $score_generated = true; }
function anomaly_get_anomaly($anomaly_id) { assert(is_numeric($anomaly_id)); global $cache_aga; // Check if we want info for the last userid (most of the time this is true) if ($cache_aga == 0 or $anomaly_id != $cache_aga['id']) { $result = sql_query("SELECT * FROM s_anomalies WHERE id=" . $anomaly_id); $tmp = sql_fetchrow($result); $cache_aga = array(); $cache_aga['id'] = $anomaly_id; $cache_aga['query'] = $tmp; return $tmp; } // Return cached information return $cache_aga['query']; }
function building_get_building($building_id) { assert(is_numeric($building_id)); global $cache_bgb; // Check if we want info for the last userid (most of the time this is true) if ($cache_bgb == 0 or $building_id != $cache_bgb['id']) { $result = sql_query("SELECT * FROM s_buildings WHERE id=" . $building_id); $tmp = sql_fetchrow($result); $cache_bgb = array(); $cache_bgb['id'] = $building_id; $cache_bgb['query'] = $tmp; return $tmp; } // Return cached information return $cache_bgb['query']; }
function sector_get_sector($sector_id) { assert(isset($sector_id)); global $cache_sgs; // Check if we want info for the last userid (most of the time this is true) if ($cache_sgs == 0 or $sector_id != $cache_sgs['id']) { $result = sql_query("SELECT * FROM s_sectors WHERE id=" . $sector_id); $tmp = sql_fetchrow($result); $cache_sgs = array(); $cache_sgs['id'] = $sector_id; $cache_sgs['query'] = $tmp; return $tmp; } // Return cached information return $cache_sgs['query']; }
function warp_scheme($warp) { $result = sql_query("SELECT COUNT(*) AS nr FROM s_sectors"); $tmp = sql_fetchrow($result); $count = $tmp['nr']; if ($count > 30) { $count = 30; echo "WARNING: Only the first 30 sectors are viewed now!!!<br>\n"; } $result = sql_query("SELECT * FROM s_sectors"); print "<table align=center border=1>"; print " <tr><th colspan=" . ($count + 1) . ">Warp Factor " . $warp . "</th></tr>"; print " <tr><th> </th>"; $sector_arr = array(); $result = sql_query("SELECT * FROM s_sectors"); while ($s = sql_fetchrow($result)) { array_push($sector_arr, $s); } // Create top columns reset($sector_arr); foreach ($sector_arr as $sector) { echo "<th> " . $sector['name'] . " </th>"; } echo "</tr>\n"; // And create rows reset($sector_arr); foreach ($sector_arr as $sector) { echo "<tr><th> " . $sector['name'] . " </th>"; for ($i = 1; $i <= $count; $i++) { if ($sector['name'] == $sector_arr[$i - 1]['name']) { echo "<td align=center> </td>"; } else { $sector_ticks = calc_sector_ticks($sector['distance'], $sector['angle'], $sector_arr[$i - 1]['distance'], $sector_arr[$i - 1]['angle'], $warp); echo "<td align=center> " . $sector_ticks . " </td>"; } } echo "</tr>\n"; } print "</table>"; print "<br><br>"; }
function print_users() { global $_CONFIG; global $_RUN; // Hmm, this should be a decent mysql query which filters out the last login_time and login_date per user_id actually... :( $user = array(); $result = sql_query("SELECT * FROM perihelion.u_access ORDER BY logout DESC"); while ($row = sql_fetchrow($result)) { if (!array_key_exists($row['user_id'], $user)) { $user[$row['user_id']]['user_id'] = $row['user_id']; $user[$row['user_id']]['login'] = $row['login']; $user[$row['user_id']]['logout'] = $row['logout']; } else { if ($user[$row['user_id']]['logout'] < $row['logout']) { $user[$row['user_id']]['login'] = $row['login']; $user[$row['user_id']]['logout'] = $row['logout']; } } } foreach ($user as $row) { $account = user_get_perihelion_user($row['user_id']); list($idle, $timestamp) = create_idle_time($row['logout']); // Don't show invisible users.. if (user_is_invisible($row['user_id'])) { continue; } if ($timestamp < $_CONFIG['MAX_SECONDS_IDLE']) { $tmpvar[] = array('href' => "user.php?cmd=" . encrypt_get_vars("showdetail") . "&uid=" . encrypt_get_vars($row['user_id']), 'user' => $account['name'], 'idle' => $idle); } } // Output it... $template = new Smarty(); $template->debugging = true; $template->assign("onlineusers", $tmpvar); $template->display($_RUN['theme_path'] . "/whoisonline.tpl"); }
function show_participated_convoys($_USER) { echo "<table border=1 align=center>"; echo " <tr><th colspan=5>All participated convoys</th></tr>"; echo " <tr>"; echo " <th>Vessel Name</th>"; echo " <th>Convoy Name</th>"; echo " <th>Flag Ship</th>"; echo " <th>Ships</th>"; echo " <th>Status</th>"; echo " </tr>"; $result = sql_query("SELECT * FROM g_vessels WHERE user_id=" . $_USER['id']); while ($vessel = sql_fetchrow($result)) { if ($vessel['convoy_id'] == 0) { continue; } $result2 = sql_query("SELECT * FROM s_convoys WHERE id=" . $vessel['convoy_id']); $convoy = sql_fetchrow($result2); // Get the flag ship of the convoy $flagvessel = vessel_get_vessel($convoy['vessel_id']); // Count the number of ships $result2 = sql_query("SELECT c.* FROM s_convoys c, g_vessels v WHERE c.vessel_id=v.id AND v.user_id=" . $_USER['id']); $tmp = csl_create_array($result2, "csl_vessel_id"); $shipcount = count($tmp); // Get the status of the convoy $status = $convoy['status']; echo "<tr>"; echo "<td> " . $vessel['name'] . " </td>"; echo "<td> " . $convoy['name'] . " </td>"; echo "<td> " . $flagvessel['name'] . " </td>"; echo "<td> " . $shipcount . " </td>"; echo "<td> " . $status . " </td>"; echo "</tr>"; } echo "</table>"; }
$stmt = sql_query($UserQuery); $content .= '<div id="title" align="center" style="font-weight:bold; font-size:23px;">Data Peserta</div><br /><br /><br /> <div class="x_content"> <table width="1000px" class="table table-striped responsive-utilities jambo_table" id="tableatendee" > <thead> <tr align="center"> <th>Tanggal Tes</th> <th>Kondisi</th> <th>No. KTP</th> <th>Posisi yang<br />Dilamar</th> <th>Tahapan<br />Tes</th> <th>Tindakan</th> </tr></thead>'; $content .= '<tbody>'; $i = 0; while ($row = sql_fetchrow($stmt)) { $i++; $content .= "<tr><td align=\"center\">" . getDMYFormatDate($row['tanggal_tes']) . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['no_ktp'] . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['nama_peserta'] . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['posisi'] . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['tahapan'] . "</td>"; $content .= "<td style='text-align:center'>"; $content .= UserAction($row['no_ktp']); $content .= "</td>"; $content .= "</tr>"; } // if($i=='0') $content .= '<tr><td colspan="9" class="fb12" align="center" bgcolor="#d4e8f6">Data tidak ditemukan</td></tr>'; $content .= '</tbody>'; $content .= '</table><br><br></div>'; echo $content; function UserAction($id) { $content .= "\n\t\t\t\t<img src='../images/print.gif' style='cursor:pointer' onmouseout=\"exit();\" \n\t\t\t\t\tonmouseover=\"tooltip2('" . getTooltipMenuRight('Klik untuk print data peserta ini.') . "');\" \n\t\t\t\t\tonclick=\"localJsPrintSuratBalik('" . $id . "');\">\n\t\t\t\t"; return $content;
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 LocalKraeplinForm($UsrDef) { $max = sql_fetchrow(sql_query("SELECT DISTINCT MAX(x) as maxX, MAX(y) as maxY FROM template")); $maxX = $max['maxX']; $maxY = $max['maxY']; $qCell = sql_query("SELECT x,y,value,answer FROM template order by x asc, y asc "); $x = 1; $y = 1; while ($tcell = sql_fetchassoc($qCell)) { // print_r($tcell['x']." ".$tcell['y']." ".$tcell['value']."<br />"); // print_r($x." ".$y." ".$tcell['value']."<br />"); $cell[$x][$y]['x'] = $tcell['x']; $cell[$x][$y]['y'] = $tcell['y']; $cell[$x][$y]['val'] = $tcell['value']; $cell[$x][$y]['ans'] = $tcell['answer']; // $x++; if($x==$maxX+1) $x=1; $y++; if ($y == $maxY + 1) { $y = 1; $x++; } } // echo '<pre>'; // print_r ($cell); // echo '</pre>'; // echo $_SESSION['userid']; $content = '<style> input[type="text"]{ width:30px; text-align:center; border: 0;} input[type=text]::-webkit-outer-spin-button, input[type=text]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; } input[type=text] { -moz-appearance:textfield; } </style>'; $content .= '<div id="title" align="center"><h3>Kraepelin</h3></div>'; $content .= "<div class='col-md-6 col-md-offset-3' style='padding-bottom: 10px;' id='rules'><fieldset class=contentInfo style='margin-top:0 '>\n\t\t\t\t<center><h4>Ketentuan Pengerjaan Tes Kraepelin</h4></center>\n\t\t\t\t<img class='col-md-8 col-md-offset-2' src='images/kraepelin-guide.png' />\n\t\t\t\t\t\t<div class='col-md-12'><ol>\n\t\t\t\t\t\t\t<li>Jumlahkan angka-angka setiap lajurnya dari bawah ke atas.</li>\n\t\t\t\t\t\t\t<li>Tekan panah atas untuk menjumlahkan angka selanjutnya.</li>\n\t\t\t\t\t\t\t<li>Misalnya 8+1=9, maka ditulis angka 9.</li>\n\t\t\t\t\t\t\t<li>Bila angka yang dijumlahkan lebih dari 10, maka tuliskan angka belakangnya saja. Misalnya 17, tuliskan angka 7.</li>\n\t\t\t\t\t\t\t<li>Jika saudara telah mengerjakan sampai dengan lajur paling atas, tetapi belum ada notifikasi pindah. Maka saudara berhenti sejenak sampai ada notifikasi pindah baru saudara dapat pindah ke lajur berikutnya.</li>\n\t\t\t\t\t\t\t<li>Klik tombol start untuk memulai tes.</li>\n\t\t\t\t\t\t\t<li>Jika ada pertanyaan, tanyakan dengan pengawas sebelum menekan tombol start.</li>\n\t\t\t\t\t\t</ol></div></fieldset></div>"; $content .= '<div class="col-md-12" id="btstart" align="center"><input type=button id="btnstart" tabindex="-1" value="Start"></div>'; // $content .= '<div class="col-md-12" id="btstart" align="center"><input type=button id="btnup" value="Up" onclick="up();"></div>'; $content .= '<form action="" method="post" enctype="multipart/form-data" id="formKraeplin">'; $content .= '<input type="hidden" name="hduserid" id="hduserid" value="' . $_SESSION['userid'] . '">'; $content .= '<input type="hidden" name="hdmaxX" id="hdmaxX" value="' . $maxX . '">'; $content .= '<input type="hidden" name="hdmaxY" id="hdmaxY" value="' . $maxY . '">'; $content .= "<table id=tbSheet style='display:none;'>"; for ($yp = $maxY; $yp >= 1; $yp--) { $content .= "<tr>"; for ($xp = 1; $xp <= $maxX; $xp++) { // echo $xp." ".$yp." ".$cell[$xp][$yp]['val']."<br />"; $content .= "<td><span style='font-weight:bold'>" . $cell[$xp][$yp]['val'] . "</span></td><td> "; if ($yp == 1) { $content .= "<input type=hidden name='hdtinggi_" . $xp . "' id='hdtinggi_" . $xp . "' >"; } $content .= "</td>"; if ($xp == $maxX && $yp > 1) { $content .= "</tr><tr>"; for ($xpp = 1; $xpp <= $maxX; $xpp++) { $ypp = $yp - 1; $content .= "<td> </td>"; $content .= "<td><input tabindex='-1' type='text' maxlength = '1' data-x='" . $xpp . "' data-y='" . $ypp . "' class='txtans txtansrow" . $xpp . "' name='txtans_" . $xpp . "_" . $ypp . "' size=1 id='txtans_" . $xpp . "_" . $ypp . "' onkeyup='nextText({$xpp}, {$ypp}, (this).value); ' onClick='this.select(); scrollright({$xpp});' onfocus='this.oldvalue = this.value;' onChange='check({$xpp}, {$ypp}, this)' this.oldvalue = this.value; >"; $content .= "<input type=hidden name='hdinput_" . $xpp . "_" . $ypp . "' id='hdinput_" . $xpp . "_" . $ypp . "' ></td>"; $content .= "<input type=hidden name='hdans_" . $xpp . "_" . $ypp . "' id='hdans_" . $xpp . "_" . $ypp . "' value='" . $cell[$xpp][$ypp]['ans'] . "'></td>"; $content .= "<input type=hidden name='hdstatus_" . $xpp . "_" . $ypp . "' id='hdstatus_" . $xpp . "_" . $ypp . "' value='1'></td>"; $content .= "<input type=hidden name='hdcounter_" . $xpp . "_" . $ypp . "' id='hdcounter_" . $xpp . "_" . $ypp . "' value='0'></td>"; } $content .= "</tr>"; } } // $content .= "</tr>"; } $content .= "</table>"; $content .= "</form>"; echo $content; }
function session_identification($flags = "") { global $_GALAXY; global $_USER; global $_CONFIG; global $_RUN; // Start the session, and check if we are logged in, if not, go to the login page. session_start(); if (!user_is_logged_in()) { session_destroy(); header("Location: " . $_CONFIG['URL'] . "/login.php"); exit; } // Set the userinformation from the session $_USER = $_SESSION['user']; // Set the users theming path and cache it into a session if (!isset($_SESSION['theme_path'])) { $result = sql_query("SELECT * FROM perihelion.t_themes WHERE id=" . $_USER['theme_id']); if ($row = sql_fetchrow($result)) { $_RUN['theme_path'] = $_CONFIG['TEMPLATE_PATH'] . $row['path']; $_RUN['theme_url'] = $_CONFIG['TEMPLATE_URL'] . $row['path']; $_SESSION['theme_path'] = $_RUN['theme_path']; $_SESSION['theme_url'] = $_RUN['theme_url']; } } else { $_RUN['theme_path'] = $_SESSION['theme_path']; $_RUN['theme_url'] = $_SESSION['theme_url']; } // Get the galaxy configuration for this user, pretty shitty, should store this info in a session? $result = sql_query("SELECT * FROM " . $_USER['galaxy_db'] . ".c_config LIMIT 1"); $_GALAXY = sql_fetchrow($result); // We now know which database we use by default, so make sure we do so... sql_query("USE " . $_USER['galaxy_db']); if ($flags == "") { return; } // Check for the flags we need to enter, if we don't have the flags // it means we can't enter the page. $userflags = split(",", $_USER['flags']); $wantflags = split(",", $flags); foreach ($wantflags as $flags) { if (!in_array($flags, $userflags)) { header("Location: " . $_CONFIG['URL'] . "/norights.php"); exit; } } }
function choose_vessel($user_id) { global $_GALAXY; echo "<table align=center border=1>"; echo "<tr><th>Name</th><th>Impulse</th><th>Warp</th><th>Status</th></tr>"; $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)) { // We can only upgrade if we are near a vessel station. if ($vessel['status'] != "ORBIT") { $nocando = 1; } else { // Check if we have a spacedock or vessel construction station $surface = planet_get_surface($vessel['planet_id']); $buildings = csl($surface['csl_building_id']); $vesseltype = vessel_get_vesseltype($vessel['id']); $nocando = 0; if ($vesseltype['type'] == VESSEL_TYPE_BATTLE and !in_array(BUILDING_VESSEL_STATION, $buildings)) { $nocando = 1; } if ($vesseltype['type'] != VESSEL_TYPE_BATTLE and !in_array(BUILDING_SPACEDOCK, $buildings)) { $nocando = 1; } } if ($nocando == 0) { $status = "Nearby a vessel or docking station"; $upgrade = 1; } else { $status = "Not in the vicinity of a vessel station"; $upgrade = 0; } echo "<tr>"; if ($upgrade == 1) { echo "<td> <img alt=Active src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/active.gif> <a href=vesselupgrade.php?vid=" . encrypt_get_vars($vessel['id']) . ">" . $vessel['name'] . "</a> </td>"; } else { echo "<td> <img alt=Inactive src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/inactive.gif> " . $vessel['name'] . "</a> </td>"; } echo "<td> Impulse: " . $vessel['impulse'] . "% </td>"; echo "<td> Warp: "; printf("%.1f", $vessel['warp'] / 10); echo " </td>"; echo "<td> {$status} </td>"; echo "</tr>"; } echo "</table>"; }
function scan_anomalies($vessel_id, $range, $scans, $i) { list($src_distance, $src_angle) = get_correct_da($vessel_id); // Scan for sectors $result = sql_query("SELECT * FROM s_sectors ORDER BY name"); while ($sector = sql_fetchrow($result)) { $distance = calc_distance($src_distance, $src_angle, $sector['distance'], $sector['angle']); if ($distance <= $range and $distance != 0) { $scans[$i]['str'] = "<tr class=bl><td> Sector </td><td> " . $sector['name'] . " </td><td> " . $sector['distance'] . " / " . $sector['angle'] . " </td><td> " . $distance . " </td></tr>\n"; $scans[$i]['range'] = $distance; $i++; } } // Scan for wormhole endpoints $result = sql_query("SELECT * FROM w_wormhole"); while ($worm = sql_fetchrow($result)) { $tmp = anomaly_get_anomaly($worm['id']); $distance = calc_distance($src_distance, $src_angle, $worm['distance'], $worm['angle']); if ($distance <= $range and $distance != 0) { $scans[$i]['str'] = "<tr class=bl><td> Wormhole </td><td> " . $tmp['name'] . " </td><td> " . $worm['distance'] . " / " . $worm['angle'] . " </td><td> " . $distance . " </td></tr>\n"; $scans[$i]['range'] = $distance; $i++; } } return array($scans, $i); }
array_push($errors_txt, "Please enter your home sector name"); array_push($errors, "sector"); } else { $result = sql_query("SELECT * FROM s_sectors WHERE name LIKE '{$sector}'"); $row = sql_fetchrow($result); if (!empty($row)) { array_push($errors_txt, "Sector name already taken!"); array_push($errors, "sector"); } } if (empty($planet)) { array_push($errors_txt, "Please enter your home world name"); array_push($errors, "planet"); } else { $result = sql_query("SELECT * FROM s_anomalies WHERE name LIKE '{$planet}'"); $row = sql_fetchrow($result); if (!empty($row)) { array_push($errors_txt, "Planet name already taken!"); array_push($errors, "planet"); } } // We found errors on the page, try again... if (!empty($errors_txt)) { register($errors_txt, $errors); } else { // Whoohooo, we are to registered correctly print_header(); $ok = ""; $errors['PARAMS'] = "Incorrect parameters specified..\n"; $data['tag'] = $_POST['tag']; $data['name'] = $_POST['name'];
function sector_show_sector($sector_id, $user_id) { assert(!empty($sector_id)); assert(!empty($user_id)); global $_RUN; // Create the submenu where we can easily move between sectors $result = sql_query("SELECT * FROM g_sectors WHERE user_id = " . $user_id); $tmp = sql_fetchrow($result); $sectors = csl($tmp['csl_sector_id']); $idx = array_search($sector_id, $sectors); $first = reset($sectors); $last = end($sectors); if ($idx == 0) { $prev = $sectors[$idx]; } else { $prev = $sectors[$idx - 1]; } if ($idx == count($sectors) - 1) { $next = $sectors[$idx]; } else { $next = $sectors[$idx + 1]; } create_submenu(array("First Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($first), "Previous Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($prev), "Next Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($next), "Last Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($last))); $sector = sector_get_sector($sector_id); $template = new Smarty(); $template->debugging = true; help_set_template_vars($template); $template->assign("sector_id", $sector['sector']); $template->assign("sector_name", $sector['name']); $template->assign("sector_coordinate", $sector['distance'] . " / " . $sector['angle']); if ($sector['user_id'] == UID_NOBODY) { $template->assign("rename_form_visible", "true"); } else { $template->assign("rename_form_visible", "false"); } // And now, do all anomalies $tmp = user_get_all_anomalies_from_user($user_id); $anomalies = csl($tmp['csl_discovered_id']); $undiscovered_anomalies = csl($tmp['csl_undiscovered_id']); $anomalies = csl_merge_fields($anomalies, $tmp['csl_undiscovered_id']); // We didn't find any discovered anomalies in this sector per default $i = 0; $tmpvar = array(); // Get anomaly information for all anomalies in the sector $result = sql_query("SELECT * FROM s_anomalies WHERE sector_id=" . $sector_id . " ORDER BY distance"); while ($anomaly = sql_fetchrow($result)) { // We didn't discover this anomaly yet, continue with another if (!in_array($anomaly['id'], $anomalies)) { continue; } // Thread undiscovered planets different... if (in_array($anomaly['id'], $undiscovered_anomalies)) { $tmp['name'] = "Unknown"; $tmp['class'] = ""; $tmp['population'] = ""; $tmp['owner'] = ""; $tmp['status'] = ""; $tmp['radius'] = $anomaly['radius']; $tmp['distance'] = $anomaly['distance']; $tmpvar[] = $tmp; continue; } // If we are here, we have found an anomaly with we already // discovered and explored, show all the info about it... $state = sql_get_state($anomaly['state_id']); if ($anomaly['user_id'] != 0) { $race = user_get_race($anomaly['user_id']); } else { $race = "Nobody"; } // Show the population status in a different color if ($anomaly['population_capacity'] == 0) { $p = 0; } else { $p = $anomaly['population'] / $anomaly['population_capacity'] * 100; } $popcol = 'people_class1'; if ($p > 50) { $popcol = 'people_class2'; } if ($p > 75) { $popcol = 'people_class3'; } if ($p > 99) { $popcol = 'people_class4'; } if (!anomaly_is_planet($anomaly['id'])) { $anomaly['class'] = ""; $anomaly['population'] = ""; } // Show the class in different colors, A..J are orange... K..M are white... L..Z are red $classcol = "class_normal"; if (planet_is_habitable($anomaly['id'])) { $classcol = 'class_habitable'; } elseif (planet_is_minable($anomaly['id'])) { $classcol = 'class_minable'; } else { $classcol = 'class_unusable'; } $tmp = array(); $tmp['name_href'] = "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']); $tmp['name'] = $anomaly['name']; $tmp['class'] = $anomaly['class']; $tmp['class_class'] = $classcol; if (planet_is_habitable($anomaly['id'])) { $tmp['population'] = $anomaly['population']; } else { $tmp['population'] = "---"; } $tmp['population_class'] = $popcol; $tmp['owner'] = $race; $tmp['status'] = $state; $tmp['radius'] = $anomaly['radius']; $tmp['distance'] = $anomaly['distance']; $tmpvar[] = $tmp; } $template->assign("anomalies", $tmpvar); $template->display($_RUN['theme_path'] . "/sectors-item.tpl"); }
function graphics_print_wormhole($img, $startX, $startY, $size, $wormhole) { global $red; $font = 2; if ($size == 400) { $font = 1; } $result = sql_query("SELECT * FROM w_wormhole WHERE id=" . $wormhole['id']); $worminfo = sql_fetchrow($result); $sector = sector_get_sector($wormhole['sector_id']); list($x1, $y1) = graphics_calc_xy($startX, $startY, $size, $sector['distance'], $sector['angle'], "YES"); list($x2, $y2) = graphics_calc_xy($startX, $startY, $size, $worminfo['distance'], $worminfo['angle'], "YES"); imageline($img, $x1, $y1, $x2, $y2, $red); graphics_set_point($img, $font, $x2, $y2, $wormhole['name'], $red); }
function item_get_item($item_id) { assert(isset($item_id)); global $cache_igi; // Check if we want info for the last userid (most of the time this is true) if ($cache_igi == 0 or $item_id != $cache_igi['id']) { $result = sql_query("SELECT * FROM s_inventions WHERE id=" . $item_id); $tmp = sql_fetchrow($result); $cache_igi = array(); $cache_igi['id'] = $item_id; $cache_igi['query'] = $tmp; return $tmp; } // Return cached information return $cache_igi['query']; }
<?php // ======================================================================================== // Get the global configuration. At this point we // still haven't started our session, and thus our userinfo[] hash is not // known. This query doesn't need the userinfo[] (it uses perihelion db) but // the queries after it does... $result = sql_query("SELECT * FROM perihelion.c_config LIMIT 1"); $sql_config = sql_fetchrow($result); $_CONFIG = array_merge($_CONFIG, $sql_config);
function alliance_discovered_a_member($user_id, $alliance_id) { assert(is_numeric($user_id)); assert(is_numeric($alliance_id)); $tmp = user_get_knownspecies($user_id); $knownusers = csl_merge_fields("", $tmp['csl_friend_id']); $knownusers = csl_merge_fields($knownusers, $tmp['csl_neutral_id']); $knownusers = csl_merge_fields($knownusers, $tmp['csl_enemy_id']); sort($knownusers, SORT_NUMERIC); $result = sql_query("SELECT * FROM g_users WHERE alliance_id=" . $alliance_id); $user = sql_fetchrow($result); if (in_array($user['user_id'], $knownusers)) { return true; } return false; }
function post_preferences($user_id, $prefs) { global $_USER; global $ext; // Now move the avatar if any was uploaded if ($_FILES['avatar']['error'] != 4) { // TODO: Change PATH into config thingie move_uploaded_file($_FILES['avatar']['tmp_name'], "c:\\perihelion\\WWW\\perihelion\\images\\users\\" . $_USER['login_name'] . $ext); } // And set the preferences $ok = ""; $errors['PARAMS'] = "Incorrect parameters specified..\n"; $data['name'] = $prefs['name']; $data['email'] = $prefs['email']; $data['inform'] = $prefs['inform']; $data['gender'] = $prefs['gender']; $data['city'] = $prefs['city']; $data['country'] = $prefs['country']; $data['tag'] = $prefs['tag']; if ($_FILES['avatar']['error'] != 4) { $data['avatar'] = $_USER['login_name'] . $ext; } else { $data['avatar'] = ''; } $data['login_pass'] = $prefs['login_pass']; $data['dob'] = $prefs['doby'] . "-" . $prefs['dobm'] . "-" . $prefs['dobd']; $data['user_id'] = $user_id; comm_send_to_server("SETPREFS", $data, $ok, $errors); $result = sql_query("SELECT * FROM perihelion.u_users WHERE id=" . $user_id); $_USER = sql_fetchrow($result); session_reinit($_USER); }
function localPrintReport($id, $imgkr, $tipe) { $printpage = "<page>"; $printpage .= "<html>"; $printpage .= "<head>"; $printpage .= '<link href="css/custom.css" rel="stylesheet" type="text/css" />'; $printpage .= '<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">'; $printpage .= '<script src="js/bootstrap.min.js"></script>'; $printpage .= "</head>"; $printpage .= "<body>"; list($nama) = sql_fetchrow(sql_query("SELECT nama_peserta FROM user WHERE no_ktp = '" . $_GET['id'] . "'")); // $printpage .= '</form>'; $printpage .= '<style>th {text-align:center;} label {font-weight:normal !important;}</style>'; $printpage .= '<div class="col-md-12" role="main">'; $printpage .= '<div class="col-md-12">'; $printpage .= '<div class="page-title">'; $printpage .= '<div class="title_left">'; $printpage .= '<h3>Report Psikotes <small>Peserta: ' . $nama . '</small></h3>'; $printpage .= '</div>'; if ($tipe == 0) { $printpage .= '<div class="print_right">'; $printpage .= "<a href='javascript(0)' onclick=\"localJsPrintReport('" . $id . "');\" style='padding-left:580'><img src='images/print.gif' style='cursor:pointer' > Print Report</a>"; $printpage .= '</div>'; $imghelp = "images/help.png"; } else { $imghelp = "../images/help.png"; } $printpage .= '</div>'; $printpage .= '<div class="clearfix"></div>'; $printpage .= '<div class="x_title col-md-12">'; $printpage .= '<h2>Kraepelin<small> </small></h2>'; $printpage .= '<div class="clearfix"></div>'; $printpage .= '</div>'; $printpage .= '<div class="row">'; $printpage .= '<div class="col-md-6 col-sm-6 col-xs-6">'; $printpage .= '<div class="x_panel">'; $printpage .= '<div class="x_printpage">'; $printpage .= '<img src="' . $imgkr . '" width="300"/>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '<div class="col-md-6 col-sm-6 col-xs-6">'; $printpage .= '<div class="table-responsive col-md-12">'; $printpage .= '<table class="table table-bordered" style="text-align:center;">'; $printpage .= '<thead>'; $printpage .= '<tr><th class="col-md-4">Aspek</th><th class="col-md-2">Skor</th><th class="col-md-2">PP</th><th class="col-md-4">Klasifikasi</th></tr>'; $printpage .= '</thead>'; $printpage .= '<tbody>'; $printpage .= '<tr><td style="font-weight:bold;">Kecepatan</td><td><label id="lblPankerScore" /></td><td><label id="lblPankerPP" /></td><td><label id="lblPankerCat" /></td></tr>'; $printpage .= '<tr><td style="font-weight:bold;">Ketelitian</td><td><label id="lblTinkerScore" /></td><td><label id="lblTinkerPP" /></td><td><label id="lblTinkerCat" /></td></tr>'; $printpage .= '<tr><td style="font-weight:bold;">Keajekan</td><td><label id="lblJankerScore" /></td><td><label id="lblJankerPP" /></td><td><label id="lblJankerCat" /></td></tr>'; $printpage .= '<tr><td style="font-weight:bold;">Total <img src="' . $imghelp . '" title="Nilai tertinggi + Nilai terendah" style="cursor:pointer;"></td><td><label id="lblTotalScore" /></td><td style="background:#CCC;"> </td><td style="background:#CCC;"> </td></tr>'; $printpage .= '<tr><td style="font-weight:bold;">Kesalahan <img src="' . $imghelp . '" title="Lajur 6-10, 21-25, 36-40" style="cursor:pointer;"></td><td><label id="lblKesalahanScore" /></td><td style="background:#CCC;"> </td><td style="background:#CCC;"> </td></tr>'; $printpage .= '</tbody>'; $printpage .= '</table>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '<div class="clearfix"></div>'; $printpage .= '<div class="x_title col-md-12">'; $printpage .= '<h2>PAPI<small> </small></h2>'; $printpage .= '<div class="clearfix"></div>'; $printpage .= '</div>'; $printpage .= '<div class="row">'; $printpage .= '<div class="col-md-6 col-sm-6">'; $printpage .= '<div class="x_panel">'; $printpage .= '<div class="x_printpage canvasradar">'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '<div class="col-md-6 col-sm-6 col-xs-12">'; $printpage .= '<div class="table-responsive col-md-12">'; $qPAPI = sql_fetchrow(sql_query("SELECT `G`,`L`,`I`,`T`,`V`,`S`,`R`,`D`,`C`,`E`,`N`,`A`,`P`,`X`,`B`,`O`,`Z`,`K`,`F`,`W`\n\t\t\t\t\t\t\t\t\tFROM `hasil_papi` WHERE userid = '" . $id . "'")); $printpage .= '<table class="table table-bordered" style="text-align:center;">'; $printpage .= '<thead>'; $printpage .= '<tr>'; $printpage .= '<th width="10%">G</th><th width="10%">L</th><th width="10%">I</th><th width="10%">T</th><th width="10%">V</th>'; $printpage .= '<th width="10%">S</th><th width="10%">R</th><th width="10%">D</th><th width="10%">C</th><th width="10%">E</th>'; $printpage .= '</tr>'; $printpage .= '</thead>'; $printpage .= '<tbody>'; $printpage .= '<tr>'; $printpage .= '<td>' . $qPAPI['G'] . '</td><td>' . $qPAPI['L'] . '</td><td>' . $qPAPI['I'] . '</td><td>' . $qPAPI['T'] . '</td><td>' . $qPAPI['V'] . '</td>'; $printpage .= '<td>' . $qPAPI['S'] . '</td><td>' . $qPAPI['R'] . '</td><td>' . $qPAPI['D'] . '</td><td>' . $qPAPI['C'] . '</td><td>' . $qPAPI['E'] . '</td>'; $printpage .= '</tr>'; $printpage .= '</tbody>'; $printpage .= '</table>'; $printpage .= '<table class="table table-bordered" style="text-align:center;">'; $printpage .= '<thead>'; $printpage .= '<tr>'; $printpage .= '<th width="10%">N</th><th width="10%">A</th><th width="10%">P</th><th width="10%">X</th><th width="10%">B</th>'; $printpage .= '<th width="10%">O</th><th width="10%">Z</th><th width="10%">K</th><th width="10%">F</th><th width="10%">W</th>'; $printpage .= '</tr>'; $printpage .= '</thead>'; $printpage .= '<tbody>'; $printpage .= '<tr>'; $printpage .= '<td>' . $qPAPI['N'] . '</td><td>' . $qPAPI['A'] . '</td><td>' . $qPAPI['P'] . '</td><td>' . $qPAPI['X'] . '</td><td>' . $qPAPI['B'] . '</td>'; $printpage .= '<td>' . $qPAPI['O'] . '</td><td>' . $qPAPI['Z'] . '</td><td>' . $qPAPI['K'] . '</td><td>' . $qPAPI['F'] . '</td><td>' . $qPAPI['W'] . '</td>'; $printpage .= '</tr>'; $printpage .= '</tbody>'; $printpage .= '</table>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '<div class="clearfix"></div>'; $printpage .= '<div class="x_title col-md-12">'; $printpage .= '<h2>DISC<small> </small></h2>'; $printpage .= '<div class="clearfix"></div>'; $printpage .= '</div>'; $printpage .= '<div class="row">'; $printpage .= '<div class="col-md-3 col-sm-3">'; $printpage .= '<div class="x_panel">'; $printpage .= '<div class="x_printpage">'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '<div class="col-md-3 col-sm-3">'; $printpage .= '<div class="x_panel">'; $printpage .= '<div class="x_printpage">'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '<div class="col-md-3 col-sm-3">'; $printpage .= '<div class="x_panel">'; $printpage .= '<div class="x_printpage">'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '<div class="col-md-3 col-sm-3">'; $printpage .= '<table class="table table-bordered" style="text-align:center;">'; $rDISC = sql_fetchrow(sql_query("SELECT DM, DL, DM-DL AS D3, IM, IL, IM-IL AS I3, SM, SL, SM-SL AS S3, CM, CL, CM-CL AS C3 FROM hasil_disc WHERE userid='{$id}'")); $printpage .= '<thead><tr><th width="25%"> </th><th width="25%">Graph I</th><th width="25%">Graph II</th><th width="25%">Graph III</th></tr></thead>'; $printpage .= '<tbody>'; $printpage .= '<tr style="color:purple; font-weight:bold;"><td>D</td><td>' . $rDISC['DM'] . '</td><td>' . $rDISC['DL'] . '</td><td>' . $rDISC['D3'] . '</td></tr>'; $printpage .= '<tr style="color:red; font-weight:bold;"><td>I</td><td>' . $rDISC['IM'] . '</td><td>' . $rDISC['IL'] . '</td><td>' . $rDISC['I3'] . '</td></tr>'; $printpage .= '<tr style="color:blue; font-weight:bold;"><td>S</td><td>' . $rDISC['SM'] . '</td><td>' . $rDISC['SL'] . '</td><td>' . $rDISC['S3'] . '</td></tr>'; $printpage .= '<tr style="color:green; font-weight:bold;"><td>C</td><td>' . $rDISC['CM'] . '</td><td>' . $rDISC['CL'] . '</td><td>' . $rDISC['C3'] . '</td></tr>'; $printpage .= '</tbody>'; $printpage .= '</table>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '<div class="row">'; $printpage .= '<div class="col-md-6 col-sm-6">'; $printpage .= '<div class="x_panel">'; $printpage .= '<div class="x_title">'; $printpage .= '<h2>WPT<small> </small></h2>'; $printpage .= '<div class="clearfix"></div>'; $printpage .= '</div>'; $printpage .= '<table class="table table-bordered" style="text-align:center;">'; $printpage .= '<thead>'; $printpage .= '<tr><th class="col-md-2">WPT SKOR</th><th class="col-md-2">WPT IQ</th><th class="col-md-2">WPT CLASSIFICATION</th></tr>'; $printpage .= '</thead>'; $printpage .= '<tbody>'; $printpage .= '<tr><td><label id="lblWptSkor" /></td><td><label id="lblWptIQ" /></td><td><label id="lblWptClass" /></td></tr>'; $printpage .= '</tbody>'; $printpage .= '</table>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= '</div>'; $printpage .= "</body>"; $printpage .= "</html>"; $printpage .= "</page>"; return $printpage; }
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"; } }