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>&nbsp;</th></tr>\n";
    echo "          </table>\n";
    echo "        </td>\n";
    echo "        <td>&nbsp;</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>&nbsp;</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Caretaker          </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $race . "</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Radius             </strong></td><td nowrap width=1%><b>:</b>&nbsp;</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>&nbsp;</td><td nowrap>" . $wormhole['distance'] . " km (10<sup>6</sup>)</td></tr>\n";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Destination        </strong></td><td nowrap width=1%><b>:</b>&nbsp;</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>&nbsp;</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 starbase_show_starbase($starbase_id)
{
    assert(!empty($starbase_id));
    global $_GALAXY;
    if (!anomaly_is_starbase($starbase_id)) {
        return;
    }
    $starbase = anomaly_get_anomaly($starbase_id);
    $sector = sector_get_sector($starbase['sector_id']);
    $race = user_get_race($starbase['user_id']);
    if ($race == "") {
        $race = "-";
    }
    echo "<table border=1 width=500 align=center>";
    echo "  <tr><td align=center><b><i>Starbase: " . $starbase['name'] . "</i></b></td></tr>";
    echo "  <tr><td>";
    echo "    <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "      <tr><td width=200>";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "            <tr><th>Starbase View</th></tr>";
    echo "            <tr><td width=100%><center><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/starbase/" . $starbase['image'] . ".jpg\" width=150 height=150></center></td></tr>";
    echo "            <tr><th>&nbsp;</th></tr>";
    echo "          </table>";
    echo "        </td>";
    echo "        <td>&nbsp;</td>";
    echo "        <td nowrap valign=top>";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "            <tr><td nowrap width=40%><strong>Starbase Name        </strong></td><td nowrap width=1%><b>:</b></td>";
    if ($starbase['unknown'] == 1) {
        form_start();
        echo "<td nowrap>";
        echo "  <input type=hidden name=aid value=" . encrypt_get_vars($starbase_id) . ">";
        echo "  <input type=hidden name=cmd value=" . encrypt_get_vars("claim") . ">";
        echo "  <input type=text size=15 maxlength=30 name=ne_name> ";
        echo "  <input name=submit type=submit value=\"Claim\">";
        echo "</td>";
        form_end();
    } else {
        echo "<td nowrap>" . $starbase['name'] . "</td>";
    }
    echo "             </tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Caretaker   </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $race . "</td></tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Attack      </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $starbase['cur_attack'] . "</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Defense     </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $starbase['cur_defense'] . "</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Strength    </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $starbase['cur_strength'] . "</td></tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "          </table>";
    echo "        </td>";
    echo "      </tr>";
    echo "    </table>";
    echo "    </td>";
    echo "  </tr>";
    echo "</table>";
    echo "<br><br>";
}
Пример #3
0
function nebula_show_nebula($nebula_id)
{
    assert(!empty($nebula_id));
    global $_GALAXY;
    if (!anomaly_is_nebula($nebula_id)) {
        return;
    }
    $nebula = anomaly_get_anomaly($nebula_id);
    $sector = sector_get_sector($nebula['sector_id']);
    $race = user_get_race($nebula['user_id']);
    if ($race == "") {
        $race = "-";
    }
    echo "<table border=1 width=500 align=center>";
    echo "  <tr><td align=center><b><i>Sector: " . $sector['name'] . " / Anomaly: " . $nebula['name'] . "</i></b></td></tr>";
    echo "  <tr><td>";
    echo "    <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "      <tr><td width=200>";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "            <tr><th>Anomaly View</th></tr>";
    echo "            <tr><td width=100%><center><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/nebulas/" . $nebula['image'] . ".jpg\" width=150 height=150></center></td></tr>";
    echo "            <tr><th>&nbsp;</th></tr>";
    echo "          </table>";
    echo "        </td>";
    echo "        <td>&nbsp;</td>";
    echo "        <td nowrap valign=top>";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "            <tr><td nowrap width=40%><strong>Nebula Name        </strong></td><td nowrap width=1%><b>:</b></td>";
    if ($nebula['unknown'] == 1) {
        form_start();
        echo "<td nowrap>";
        echo "  <input type=hidden name=aid value=" . encrypt_get_vars($nebula_id) . ">";
        echo "  <input type=hidden name=cmd value=" . encrypt_get_vars("claim") . ">";
        echo "  <input type=text size=15 maxlength=30 name=ne_name> ";
        echo "  <input name=submit type=submit value=\"Claim\">";
        echo "</td>";
        form_end();
    } else {
        echo "<td nowrap>" . $nebula['name'] . "</td>";
    }
    echo "             </tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Caretaker          </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $race . "</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Cloud Radius     </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $nebula['radius'] . " km</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Distance to sun    </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $nebula['distance'] . " km (10<sup>6</sup>)</td></tr>";
    echo "          </table>";
    echo "        </td>";
    echo "      </tr>";
    echo "    </table>";
    echo "    </td>";
    echo "  </tr>";
    echo "</table>";
    echo "<br><br>";
}
Пример #4
0
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)));
}
Пример #5
0
function anomaly_is_starbase($anomaly_id)
{
    assert(is_numeric($anomaly_id));
    $anomaly = anomaly_get_anomaly($anomaly_id);
    if ($anomaly['type'] == ANOMALY_STARBASE) {
        return true;
    }
    return false;
}
Пример #6
0
function invention_show_details($invention_id, $planet_id, $user_id, $stock_ores)
{
    assert(is_numeric($invention_id));
    assert(is_numeric($planet_id));
    assert(is_numeric($user_id));
    assert(is_string($stock_ores));
    global $_GALAXY;
    $build_option = 1;
    // Check our mode, we can just look at details, or let the user build
    if ($planet_id == 0 and $user_id == 0 and $stock_ores == "") {
        $build_option = 0;
    }
    $invention = item_get_item($invention_id);
    if ($build_option) {
        $cannot_build = false;
        $user = user_get_user($user_id);
        $planet = anomaly_get_anomaly($planet_id);
        $planet_ores = csl($stock_ores);
        $invention_ores = ore_csl_to_list($invention['initial_ores']);
    } else {
        $planet_ores = ore_csl_to_list("");
        $invention_ores = ore_csl_to_list("");
    }
    echo "<table border=1 cellpadding=0 cellspacing=0 align=center width=50%>";
    // invention name
    echo "  <tr class=wb><th colspan=2>" . $invention['name'] . "</th></tr>";
    // Plaatje plus ADS etc
    echo "  <tr>";
    echo "    <td align=center valign=top bgcolor=black>";
    echo "              <table border=0 cellpadding=0 cellspacing=0>";
    echo "                <tr>";
    echo "                   <td >";
    echo "                    <table align=left border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "                      <tr><td width=100><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/inventions/" . $invention['image'] . ".jpg\" width=150 height=150></td></tr>";
    echo "                    </table>";
    echo "                 </td>";
    echo "               </tr>";
    echo "             </table>";
    echo "    </td>";
    echo "    <td align=left valign=top bgcolor=black>";
    $class = 't';
    echo "             <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Function</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . item_get_type($invention['id']) . "&nbsp;</td>";
    echo "                </tr>";
    echo "                <tr><td colspan=3><hr></td></tr>\n";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Maximum Stock</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . $invention['max'] . " pcs&nbsp;</td>";
    echo "                </tr>";
    echo "                <tr><td colspan=3><hr></td></tr>\n";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Attack</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . $invention['attack'] . " pts&nbsp;</td>";
    echo "                </tr>";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Defense</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . $invention['defense'] . " pts&nbsp;</td>";
    echo "                </tr>";
    echo "              </table>";
    echo "    </td>";
    echo "  </tr>";
    if ($build_option) {
        // Costs + ores  (initial / upkeep)
        echo "  <tr bgcolor=black><td colspan=2>&nbsp;</td></tr>\n";
        echo "  <tr bgcolor=black><td>";
        $cannot_build = smt_initial_ores($cannot_build, $invention_id, $user_id, $planet_ores);
        echo "  </td><td>";
        $cannot_build = smt_upkeep_ores($cannot_build, $invention_id, $user_id, $planet_ores);
        echo "  </td></tr>";
        echo "  <tr bgcolor=black><td colspan=2>&nbsp;</td></tr>\n";
    } else {
        echo "  <tr bgcolor=black><td colspan=2>&nbsp;</td></tr>\n";
        echo "  <tr bgcolor=black><td>";
        smt_initial_ores(0, $invention_id, $user_id, $planet_ores);
        echo "  </td><td>";
        smt_upkeep_ores(0, $invention_id, $user_id, $planet_ores);
        echo "  </td></tr>";
        echo "  <tr bgcolor=black><td colspan=2>&nbsp;</td></tr>\n";
    }
    // Print rule and description
    if ($invention['rule'] != "") {
        echo "<tr bgcolor=black><td colspan=2><table border=0 cellspacing=5><tr><td>Effect: " . $invention['rule'] . "</td></tr></table></td></tr>";
    }
    if ($invention['description'] != "") {
        echo "<tr bgcolor=black><td colspan=2 ><table border=0 cellspacing=5><tr><td>" . $invention['description'] . "</td></tr></table></td></tr>";
    }
    // Print building possibility
    if ($build_option) {
        if ($cannot_build == false) {
            echo "<tr bgcolor=black><th colspan=2><a href=manufacture.php?cmd=" . encrypt_get_vars("manufacture") . "&iid=" . encrypt_get_vars($invention['id']) . "&aid=" . encrypt_get_vars($planet['id']) . ">BUILD IT</a></th></tr>";
        } else {
            echo "<tr bgcolor=black><th colspan=2>CANNOT BUILD</th></tr>";
        }
    }
    echo "</table>\n";
    echo "<br><br>\n";
}
function building_show_details($building_id, $planet_id, $user_id, $stock_ores)
{
    assert(is_numeric($building_id));
    assert(is_numeric($planet_id));
    assert(is_numeric($user_id));
    assert(is_string($stock_ores));
    global $_GALAXY;
    global $_CONFIG;
    $build_option = 1;
    // Check our mode, we can just look at details, or let the user build
    if ($planet_id == 0 and $user_id == 0 and $stock_ores == "") {
        $build_option = 0;
    }
    $building = building_get_building($building_id);
    if ($build_option) {
        $cannot_build = false;
        $planet = anomaly_get_anomaly($planet_id);
        $totals = calc_planet_totals($planet_id);
        $planet_ores = ore_csl_to_list($stock_ores);
        $building_ores = ore_csl_to_list($building['initial_ores']);
    } else {
        $cannot_build = true;
        $totals['power_out'] = 0;
        $totals['power_in'] = 0;
        $planet_ores = ore_csl_to_list("");
        $building_ores = ore_csl_to_list("");
    }
    $href = "construct.php?cmd=" . encrypt_get_vars("build") . "&bid=" . encrypt_get_vars($building_id) . "&aid=" . encrypt_get_vars($planet_id);
    $template = new Template($_CONFIG['TEMPLATE_PATH'] . "/building-details.tpl", E_YAPTER_ALL);
    $template->set("name", $building['name']);
    $template->set("image", $_CONFIG['IMAGE_URL'] . $_GALAXY['image_dir'] . "/buildings/" . $building['image'] . ".jpg");
    $template->set("construction_href", $href);
    $template->set("description", $building['description']);
    $template->set("rule", $building['rule']);
    $template->set("class", "");
    $template->set("power_needed", $building['power_in']);
    $template->set("power_output", $building['power_out']);
    $template->set("attack", $building['attack']);
    $template->set("defense", $building['defense']);
    $template->set("strength", $building['strength']);
    if ($build_option) {
        $template->hide("block_build");
        $template->hide("block_build2");
    } else {
        $template->hide("block_nobuild");
        $template->hide("block_nobuild2");
    }
    $template->parse();
    $template->spit();
    /*
        echo "<table border=1 cellpadding=0 cellspacing=0 align=center width=50%>";
    
    // Building name
        echo "  <tr><th colspan=2>".$building['name']."</th></tr>";
    
    // Plaatje plus ADS etc
        echo "  <tr>";
        echo "    <td align=center valign=top bgcolor=black>";
        echo "              <table border=0 cellpadding=0 cellspacing=0>";
        echo "                <tr>";
        echo "                   <td >";
        echo "                    <table align=left border=0 cellpadding=0 cellspacing=0 width=100%>";
        echo "                      <tr><td width=100><img src=\"".$_CONFIG['URL'].$_GALAXY['image_dir']."/buildings/".$building['image'].".jpg\" width=150 height=150></td></tr>";
        echo "                    </table>";
        echo "                 </td>";
        echo "               </tr>";
        echo "             </table>";
        echo "    </td>";
        echo "    <td align=left valign=top>";
        if ($build_option) {
          if (($totals['power_out']-$totals['power_in']) < $building['power_in']) {
              $class="f";
              $cannot_build = true;
          } else {
              $class="t";
          }
        } else {
          $class="t";
        }
        echo "             <table border=0 cellpadding=0 cellspacing=0 width=100%>";
        echo "                <tr>";
        echo "                  <td class=".$class.">&nbsp;<strong>Power Needed</strong>&nbsp;</td>";
        echo "                  <td class=".$class.">&nbsp;<strong>:</strong>&nbsp;</td>";
        echo "                  <td class=".$class.">&nbsp;".$building['power_in']." uts&nbsp;</td>";
        echo "                </tr>";
        $class = 't';
        echo "                <tr>";
        echo "                  <td class=".$class.">&nbsp;<strong>Power Output</strong>&nbsp;</td>";
        echo "                  <td class=".$class.">&nbsp;<strong>:</strong>&nbsp;</td>";
        echo "                  <td class=".$class.">&nbsp;".$building['power_out']." uts&nbsp;</td>";
        echo "                </tr>";
        echo "<tr><td colspan=3><hr></td></tr>";
        $class = 't';
        echo "                <tr>";
        echo "                  <td class=".$class.">&nbsp;<strong>Attack</strong>&nbsp;</td>";
        echo "                  <td class=".$class.">&nbsp;<strong>:</strong>&nbsp;</td>";
        echo "                  <td class=".$class.">&nbsp;".$building['attack']." pts&nbsp;</td>";
        echo "                </tr>";
        echo "                <tr>";
        echo "                  <td class=".$class.">&nbsp;<strong>Defense</strong>&nbsp;</td>";
        echo "                  <td class=".$class.">&nbsp;<strong>:</strong>&nbsp;</td>";
        echo "                  <td class=".$class.">&nbsp;".$building['defense']." pts&nbsp;</td>";
        echo "                </tr>";
        echo "                <tr>";
        echo "                  <td class=".$class.">&nbsp;<strong>Strength</strong>&nbsp;</td>";
        echo "                  <td class=".$class.">&nbsp;<strong>:</strong>&nbsp;</td>";
        echo "                  <td class=".$class.">&nbsp;".$building['strength']." pts&nbsp;</td>";
        echo "                </tr>";
        echo "              </table>";
        echo "    </td>";
        echo "  </tr>";
    
        if ($build_option) {
          // Costs + ores  (initial / upkeep)
          echo "  <tr><td colspan=2>&nbsp;</td></tr>\n";
          echo "  <tr><td>";
          $cannot_build = sbt_initial_ores ($cannot_build, $building_id, $user_id, $planet_ores);
          echo "  </td><td>";
          $cannot_build = sbt_upkeep_ores ($cannot_build, $building_id, $user_id, $planet_ores);
          echo "  </td></tr>";
          echo "  <tr><td colspan=2>&nbsp;</td></tr>\n";
        } else {
          echo "  <tr><td colspan=2>&nbsp;</td></tr>\n";
          echo "  <tr><td>";
          sbt_initial_ores (0, $building_id, $user_id, $planet_ores);
          echo "  </td><td>";
          sbt_upkeep_ores (0, $building_id, $user_id, $planet_ores);
          echo "  </td></tr>";
          echo "  <tr><td colspan=2>&nbsp;</td></tr>\n";
        }
    
    // Print rule and description
        if ($building['rule'] != "") {
          echo "<tr><td colspan=2><table border=0 cellspacing=5><tr><td>Effect: ".$building['rule']."</td></tr></table></td></tr>";
        }
    
        if ($building['description'] != "") {
          echo "<tr><td colspan=2><table border=0 cellspacing=5><tr><td>".$building['description']."</td></tr></table></td></tr>";
        }
    
    // Print building possibility
        if ($build_option) {
          if ($cannot_build == false) {
            echo "<tr><th colspan=2><a href=construct.php?cmd=".encrypt_get_vars ("build").
                                                        "&bid=".encrypt_get_vars ($building['id']).
                                                        "&aid=".encrypt_get_vars ($planet['id']).
                                                        ">BUILD IT</a></th></tr>";
          } else {
            echo "<tr><th colspan=2>CANNOT BUILD</th></tr>";
          }
       }
        echo "</table>\n";
        echo "<br><br>\n";
    */
}
Пример #8
0
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']);
        }
    }
}
Пример #9
0
function queue_print($user_id)
{
    assert(is_numeric($user_id));
    global $_RUN;
    $totalcount = 0;
    $template = new Smarty();
    $template->debugging = true;
    // Buildings
    $count = 0;
    $tmpvar = array();
    $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_BUILD . "' AND user_id=" . $user_id);
    while ($queue = sql_fetchrow($result)) {
        $totalcount++;
        $count++;
        $building = building_get_building($queue['building_id']);
        $planet = anomaly_get_anomaly($queue['planet_id']);
        $tmpvar['what'][] = "Building " . $building['name'] . " on " . $planet['name'];
        $tmpvar['ticks'][] = $queue['ticks'];
    }
    $tmpvar['count'] = $count;
    $template->assign("building", $tmpvar);
    // Items
    $count = 0;
    $tmpvar = array();
    $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_INVENTION . "' AND user_id=" . $user_id);
    while ($queue = sql_fetchrow($result)) {
        $totalcount++;
        $count++;
        $item = item_get_item($queue['building_id']);
        $planet = anomaly_get_anomaly($queue['planet_id']);
        $tmpvar['what'][] = "Manufacturing " . $item['name'] . " on " . $planet['name'];
        $tmpvar['ticks'][] = $queue['ticks'];
    }
    $tmpvar['count'] = $count;
    $template->assign("item", $tmpvar);
    // Vessels
    $count = 0;
    $tmpvar = array();
    $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_VESSEL . "' AND user_id=" . $user_id);
    while ($queue = sql_fetchrow($result)) {
        $totalcount++;
        $count++;
        $vessel = vessel_get_vessel($queue['vessel_id']);
        $planet = anomaly_get_anomaly($queue['planet_id']);
        $tmpvar['what'][] = "Building " . $vessel['name'] . " on " . $planet['name'];
        $tmpvar['ticks'][] = $queue['ticks'];
    }
    $tmpvar['count'] = $count;
    $template->assign("vessel", $tmpvar);
    // Upgrade (NOTE: THESE ARE ALSO PART OF THE VESSEL[] ARRAY
    $count = 0;
    $tmpvar = array();
    $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_UPGRADE . "' AND user_id=" . $user_id);
    while ($queue = sql_fetchrow($result)) {
        $totalcount++;
        $count++;
        $vessel = vessel_get_vessel($queue['vessel_id']);
        $planet = anomaly_get_anomaly($queue['planet_id']);
        $tmpvar['what'][] = "Upgrading " . $vessel['name'] . " on " . $planet['name'];
        $tmpvar['ticks'][] = $queue['ticks'];
    }
    $tmpvar['count'] = $count;
    $template->assign("vessel", $tmpvar);
    // Flights
    $count = 0;
    $tmpvar = array();
    $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_FLIGHT . "' AND user_id=" . $user_id);
    while ($queue = sql_fetchrow($result)) {
        $totalcount++;
        $count++;
        $result2 = sql_query("SELECT * FROM g_vessels WHERE id=" . $queue['vessel_id']);
        $vessel = sql_fetchrow($result2);
        if ($vessel['dst_planet_id'] == 0) {
            if ($vessel['dst_sector_id'] == 0) {
                $tmpvar['what'][] = "Flying " . $vessel['name'] . " to outer space.";
            } else {
                $sector = sector_get_sector($vessel['dst_sector_id']);
                $tmpvar['what'][] = "Flying " . $vessel['name'] . " to sector " . $sector['name'];
            }
        } else {
            $planet = anomaly_get_anomaly($vessel['dst_planet_id']);
            $tmpvar['what'][] = "Flying " . $vessel['name'] . " to " . $planet['name'];
        }
        $tmpvar['ticks'][] = $queue['ticks'];
    }
    $tmpvar['count'] = $count;
    $template->assign("flight", $tmpvar);
    $template->assign("itemcount", $totalcount);
    $template->display($_RUN['theme_path'] . "/order-queue.tpl");
}
Пример #10
0
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";
}
Пример #11
0
function planet_is_minable($planet_id)
{
    assert(is_numeric($planet_id));
    global $_GALAXY;
    $planet = anomaly_get_anomaly($planet_id);
    if ($planet['class'] == "") {
        return false;
    }
    $i = strpos($_GALAXY['class_minable'], $planet['class']);
    if ($i === false) {
        return false;
    }
    return true;
}
Пример #12
0
function get_correct_da($vessel_id)
{
    assert(isset($vessel_id));
    $vessel = vessel_get_vessel($vessel_id);
    if (vessel_is_in_orbit($vessel_id) and $vessel['planet_id'] == 0) {
        $src_distance = $vessel['distance'];
        $src_angle = $vessel['angle'];
    } elseif (vessel_is_in_orbit($vessel_id) and $vessel['planet_id'] != 0) {
        $planet = anomaly_get_anomaly($vessel['planet_id']);
        $sector = sector_get_sector($planet['sector_id']);
        $src_distance = $sector['distance'];
        $src_angle = $sector['angle'];
    } else {
        $src_distance = $vessel['distance'];
        $src_angle = $vessel['angle'];
    }
    return array($src_distance, $src_angle);
}
Пример #13
0
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);
        }
    }
}
Пример #14
0
function vessel_get_current_status($vessel_id, $create_hyperlink = true)
{
    assert(is_numeric($vessel_id));
    assert(is_bool($create_hyperlink));
    $vessel = vessel_get_vessel($vessel_id);
    $status = "Unknown status";
    // Are we in orbit?
    if (vessel_is_in_orbit($vessel_id)) {
        $anomaly = anomaly_get_anomaly($vessel['planet_id']);
        if (anomaly_is_planet($anomaly['id'])) {
            if ($create_hyperlink) {
                $status = "Orbiting planet <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']) . ">" . $anomaly['name'] . "</a>";
            } else {
                $status = "Orbiting planet " . $anomaly['name'];
            }
        }
        if (anomaly_is_nebula($anomaly['id'])) {
            if ($create_hyperlink) {
                $status = "Hiding in nebula <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']) . ">" . $anomaly['name'] . "</a>";
            } else {
                $status = "Hiding in nebula " . $anomaly['name'];
            }
        }
        if (anomaly_is_starbase($anomaly['id'])) {
            if ($create_hyperlink) {
                $status = "Docking at starbase <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']) . ">" . $anomaly['name'] . "</a>";
            } else {
                $status = "Docking at starbase " . $anomaly['name'];
            }
        }
    }
    // Is the vessel flying?
    if (vessel_is_flying($vessel_id)) {
        if ($vessel['dst_planet_id'] == 0) {
            // Are we flying to a sector or deep space?
            if ($vessel['dst_sector_id'] == 0) {
                $status = "Flying to " . $vessel['dst_distance'] . " / " . $vessel['dst_angle'];
            } else {
                $tmp = sector_get_sector($vessel['dst_sector_id']);
                if ($create_hyperlink) {
                    $status = "Flying to sector <a href=sector.php?id=" . encrypt_get_vars($tmp['id']) . ">" . $tmp['name'] . "</a>";
                } else {
                    $status = "Flying to sector " . $tmp['name'];
                }
            }
        } else {
            // Are we flying to a planet?
            $tmp_anomaly = anomaly_get_anomaly($vessel['dst_planet_id']);
            if (anomaly_is_planet($tmp_anomaly['id'])) {
                if (anomaly_is_discovered_by_user($tmp_anomaly['id'], user_ourself())) {
                    if ($create_hyperlink) {
                        $status = "Flying to planet <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($tmp_anomaly['id']) . ">" . $tmp_anomaly['name'] . "</a>";
                    } else {
                        $status = "Flying to planet " . $tmp_anomaly['name'];
                    }
                } else {
                    $status = "Flying to an unknown anomaly.";
                }
            }
            if (anomaly_is_starbase($tmp_anomaly['id'])) {
                $status = "Flying to starbase " . $tmp_anomaly['name'];
            }
            if (anomaly_is_nebula($tmp_anomaly['id'])) {
                $status = "Flying to nebula " . $tmp_anomaly['name'];
            }
            if (anomaly_is_wormhole($tmp_anomaly['id'])) {
                $status = "Flying to wormhole " . $tmp_anomaly['name'];
            }
        }
    }
    // Are we halted in deep space?
    if (vessel_is_in_space($vessel_id) and $vessel['sector_id'] == 0) {
        $status = "Located in deep space (" . $vessel['distance'] . " / " . $vessel['angle'] . ")";
    }
    // Or are we bordering a sector?
    if (vessel_is_in_space($vessel_id) and $vessel['sector_id'] != 0) {
        $sector = sector_get_sector($vessel['sector_id']);
        $status = "Bordering sector " . $sector['name'];
    }
    if (vessel_in_traderoute($vessel_id)) {
        $status = "Part of traderoute.";
    }
    // TODO: change this into vessel_is_in_convoy ($vessel_id)
    if ($vessel['status'] == "CONVOY") {
        $result = sql_query("SELECT * FROM s_convoys WHERE id=" . $vessel['convoy_id']);
        $tmp = sql_fetchrow($result);
        if ($create_hyperlink) {
            $status = "Part of convoy <a href=convoy.php?id=" . encrypt_get_vars($tmp['id']) . ">" . $tmp['name'] . "</a>";
        } else {
            $status = "Part of convoy " . $tmp['name'];
        }
    }
    return $status;
}
Пример #15
0
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>&nbsp;<img src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/ships/trade.jpg>&nbsp;<a href=vessel.php?cmd=" . encrypt_get_vars("showvid") . "&vid=" . encrypt_get_vars($vessel['id']) . ">" . $vessel['name'] . "</a>&nbsp;</td>\n";
        echo "    <td>&nbsp;<a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($src_planet['id']) . ">" . $src_planet['name'] . "</a>&nbsp;</td>\n";
        echo "    <td>&nbsp;" . $ore1 . "&nbsp;</td>\n";
        echo "    <td>&nbsp;<a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($dst_planet['id']) . ">" . $dst_planet['name'] . "</a>&nbsp;</td>\n";
        echo "    <td>&nbsp;" . $ore2 . "&nbsp;</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 blackhole_get_fatalities($blackhole_id)
{
    assert(is_numeric($blackhole_id));
    $blackhole = anomaly_get_anomaly($blackhole_id);
    return $blackhole['population'];
}
Пример #17
0
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);
        }
    }
}
Пример #18
0
function user_showinfo($user_id, $extended_info = USER_SHOWINFO_NORMAL)
{
    assert(is_numeric($user_id));
    $user = user_get_user($user_id);
    $px_user = user_get_perihelion_user($user_id);
    $result = sql_query("SELECT * FROM perihelion.u_access WHERE user_id=" . $user_id . " ORDER BY login DESC LIMIT 1");
    $access = sql_fetchrow($result);
    sql_query("USE " . $px_user['galaxy_db']);
    $result = sql_query("SELECT SUM(population) FROM s_anomalies WHERE user_id=" . $user_id);
    $row = sql_fetchrow($result);
    $people = $row['0'];
    $result = sql_query("SELECT COUNT(*) FROM s_sectors WHERE user_id=" . $user_id);
    $row = sql_fetchrow($result);
    $sectors_owned = $row['0'];
    $result = sql_query("SELECT COUNT(*) FROM s_anomalies WHERE user_id=" . $user_id);
    $row = sql_fetchrow($result);
    $planets_owned = $row['0'];
    $result = sql_query("SELECT DISTINCT sector_id, COUNT(*) FROM s_anomalies WHERE user_id=" . $user_id . " GROUP BY sector_id");
    $sector_count = sql_countrows($result);
    $sector = sector_get_sector(user_get_home_sector($user_id));
    $planet = anomaly_get_anomaly(user_get_home_planet($user_id));
    $race = user_get_race($user_id);
    $result = sql_query("SELECT * FROM g_alliance WHERE id=" . $user['alliance_id']);
    $alliance = sql_fetchrow($result);
    if ($user['alliance_id'] != 0) {
        $result = sql_query("SELECT COUNT(*) AS count FROM g_users WHERE alliance_id = " . $alliance['id']);
        $tmp = sql_fetchrow($result);
        $alliance_size = $tmp['count'];
    }
    $status = "Unknown";
    if (user_is_friend(user_ourself(), $user_id)) {
        $status = "Single side friend";
    }
    if (user_is_mutual_friend(user_ourself(), $user_id)) {
        $status = "Mutual friend";
    }
    if (user_is_neutral(user_ourself(), $user_id)) {
        $status = "Neutral";
    }
    if (user_is_enemy(user_ourself(), $user_id)) {
        $status = "Enemy";
    }
    if (user_ourself() == $user_id) {
        $status = "";
    }
    echo "<table border=0 align=center width=60%>";
    echo "<tr><th class=white colspan=2>" . $px_user['name'] . "</th><th>&nbsp;</th></tr>";
    echo "<tr><th colspan=2><b>" . $px_user['tag'] . "</b></th></tr>";
    echo "<tr valign=top>";
    echo "  <td width=120>";
    echo "    <img width=100 height=100 src='images/users/" . $px_user['avatar'] . "'><br>";
    echo "    <br>";
    if ($user['alliance_id'] != 0) {
        echo "    <img width=100 height=100 src='images/users/" . $alliance['avatar'] . "'><br>";
    }
    echo "  </td>";
    echo "  <td><table border=0 nowrap>";
    echo "        <tr class=bl><td>&nbsp;Full Name       &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['name'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;User ID         &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['id'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;City            &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['city'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Country         &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['country'] . "&nbsp;</td></tr>";
    echo "        <tr><td colspan=3>&nbsp;</td></tr>";
    if ($status != "") {
        echo "        <tr class=bl><td>&nbsp;Diplomatic Status &nbsp;</td><td>:</td><td>&nbsp;" . $status . "&nbsp;</td></tr>";
    }
    echo "        <tr class=bl><td>&nbsp;Race              &nbsp;</td><td>:</td><td>&nbsp;" . $race . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Home Planet       &nbsp;</td><td>:</td><td>&nbsp;" . $planet['name'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Home Sector       &nbsp;</td><td>:</td><td>&nbsp;" . $sector['name'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Population        &nbsp;</td><td>:</td><td>&nbsp;" . $people . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Sectors Owned     &nbsp;</td><td>:</td><td>&nbsp;" . $sectors_owned . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Planets Owned     &nbsp;</td><td>:</td><td>&nbsp;" . $planets_owned . " planet(s) in " . $sector_count . " sector(s)&nbsp;</td></tr>";
    if ($user['alliance_id'] != 0) {
        echo "        <tr class=bl><td>&nbsp;Alliance        &nbsp;</td><td>:</td><td>&nbsp;<a href=alliance.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($alliance['id']) . ">" . $alliance['name'] . "</a>&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Alliance Size   &nbsp;</td><td>:</td><td>&nbsp;" . $alliance_size . " user(s)&nbsp;</td></tr>";
    }
    echo "        <tr><td colspan=3>&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Times logged in   &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['login_count'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Last login        &nbsp;</td><td>:</td><td>&nbsp;" . $access['login'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Last action       &nbsp;</td><td>:</td><td>&nbsp;" . $access['logout'] . "&nbsp;</td></tr>";
    if ($extended_info == USER_SHOWINFO_EXTENDED) {
        if ($px_user['gender'] == "M") {
            $gender = "Male";
        } else {
            $gender = "Female";
        }
        echo "        <tr><td colspan=3>&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Email      &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['email'] . "&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Login Name &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['login_name'] . "&nbsp;</td></tr>";
        echo "        <tr><td colspan=3>&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;City       &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['city'] . "&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Country    &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['country'] . "&nbsp;</td></tr>";
        echo "        <tr><td colspan=3>&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Birthday   &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['birthday'] . "&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Gender     &nbsp;</td><td>:</td><td>&nbsp;" . $gender . "&nbsp;</td></tr>";
    }
    if ($user_id != user_ourself()) {
        echo "<tr><th colspan=3>";
        echo "[ <a href=message.php?uid=" . encrypt_get_vars($user_id) . ">Send Message</a> ]";
        echo "</th></tr>";
        echo "<tr><th colspan=3>";
        echo "[ <a href=user.php?cmd=" . encrypt_get_vars("relation") . "&uid=" . encrypt_get_vars($user_id) . "&wid=" . encrypt_get_vars(RELATION_FRIEND) . ">Set as friend</a>  ] - ";
        echo "[ <a href=user.php?cmd=" . encrypt_get_vars("relation") . "&uid=" . encrypt_get_vars($user_id) . "&wid=" . encrypt_get_vars(RELATION_NEUTRAL) . ">Set as neutral</a>  ] - ";
        echo "[ <a href=user.php?cmd=" . encrypt_get_vars("relation") . "&uid=" . encrypt_get_vars($user_id) . "&wid=" . encrypt_get_vars(RELATION_ENEMY) . ">Set as enemy</a> ]";
        echo "</th></tr>";
    }
    echo "  </table></td>";
    echo "</tr>";
    echo "</table>";
    echo "<br><br>";
}
Пример #19
0
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>&nbsp;Power Generated&nbsp;</td><td>&nbsp;" . $totals['power_out'] . "&nbsp;</td></tr>\n";
    echo "      <tr><td>&nbsp;Power Needed&nbsp;</td><td>&nbsp;" . $totals['power_in'] . "&nbsp;</td></tr>\n";
    echo "      <tr><td>&nbsp;<font color={$power_color}><b>Power Left </b></font>&nbsp;</td><td>&nbsp;<font color={$power_color}><b>" . ($totals['power_out'] - $totals['power_in']) . "</b></font>&nbsp;</td></tr>\n";
    echo "    </table>\n";
    echo "  </td><td>\n";
    echo "    <table width=100% border=0 cellpadding=0 cellspacing=0>\n";
    echo "      <tr><td>&nbsp;<font color={$crew_color}>Inhabitants</font>&nbsp;</td><td>&nbsp;<font color={$crew_color}>" . $planet['population'] . "</font>&nbsp;</td></tr>\n";
    echo "      <tr><td>&nbsp;<font color={$crew_color}>Capacity</font>&nbsp;</td><td>&nbsp;<font color={$crew_color}>" . $planet['population_capacity'] . "</font>&nbsp;</td></tr>\n";
    echo "      <tr><td>&nbsp;</td><td>&nbsp;</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>&nbsp;" . $quantity . "&nbsp;</td>\n";
            echo "    <td>&nbsp;" . $active . "&nbsp;" . $building['name'] . "&nbsp;</td>\n";
            echo "    <td>&nbsp;" . $building['power_in'] . "&nbsp;</td>\n";
            echo "    <td>&nbsp;" . $building['power_out'] . "&nbsp;</td>\n";
            echo "    <td>&nbsp;" . $building['rule'] . "&nbsp;</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>&nbsp;" . $quantity . "&nbsp;</font></td>\n";
            echo "    <td><font color=red>&nbsp;" . $active . "&nbsp;" . $building['name'] . "&nbsp;</font></td>\n";
            echo "    <td colspan=3><font color=red>&nbsp;Building not active&nbsp;</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>&nbsp;" . $quantity . "&nbsp;</td>\n";
        echo "    <td>&nbsp;<img " . $activeimg . ">&nbsp;" . $invention['name'] . "&nbsp;</td>\n";
        echo "    <td>&nbsp;" . $invention['rule'] . "&nbsp;</td>\n";
        echo "  </tr>\n";
    }
    echo "</table>\n";
    echo "<br><br>\n";
}
Пример #20
0
function show_info($user_id)
{
    global $_USER;
    global $_CONFIG;
    global $_RUN;
    $user = user_get_user($user_id);
    // User Information
    $template = new Smarty();
    help_set_template_vars($template, "INFO");
    $planets_owned = info_get_planetown_count($user_id);
    $template->assign("stardate", info_get_stardate());
    $template->assign("credits", $user['credits']);
    $template->assign("population", info_get_population_count($user_id));
    $template->assign("sectors_owned", info_get_sectorown_count($user_id));
    $template->assign("planets_owned", $planets_owned);
    list($minable_count, $habitable_count, $unusable_count, $starbase_count, $wormhole_count, $blackhole_count, $anomalie_count) = info_get_anomaly_statistics($user_id);
    $template->assign("minable_count", $minable_count);
    $template->assign("minable_percentage", round($minable_count / $planets_owned * 100, 2));
    $template->assign("habitable_count", $habitable_count);
    $template->assign("habitable_percentage", round($habitable_count / $planets_owned * 100, 2));
    $template->assign("unusable_count", $unusable_count);
    $template->assign("unusable_percentage", round($unusable_count / $planets_owned * 100, 2));
    $template->assign("wormhole_count", $wormhole_count);
    $template->assign("wormhole_percentage", round($wormhole_count / $planets_owned * 100, 2));
    $template->assign("starbase_count", $starbase_count);
    $template->assign("starbase_percentage", round($starbase_count / $planets_owned * 100, 2));
    $template->assign("anomalie_count", $anomalie_count);
    $template->assign("anomalie_percentage", round($anomalie_count / $planets_owned * 100, 2));
    // Tactical Information
    list($total_vessels, $evd, $tvd, $bvd) = info_get_vessel_statistics($user_id);
    $template->assign("total_vessels", $total_vessels);
    $template->assign("bvd", $bvd);
    $template->assign("bvd_percentage", round($bvd / $total_vessels * 100, 2));
    $template->assign("tvd", $tvd);
    $template->assign("tvd_percentage", round($tvd / $total_vessels * 100, 2));
    $template->assign("evd", $evd);
    $template->assign("evd_percentage", round($evd / $total_vessels * 100, 2));
    list($weak_ship_id, $ws_a) = user_get_weakest_ship($user_id);
    $weak_ship = vessel_get_vessel($weak_ship_id);
    $template->assign("weakship_name", $weak_ship['name']);
    $template->assign("weakship_href", "vessel.php?cmd=" . encrypt_get_vars("show") . "&vid=" . encrypt_get_vars($weak_ship_id));
    $template->assign("weakship_percentage", $ws_a);
    list($strong_ship_id, $ss_a) = user_get_strongest_ship($user_id);
    $strong_ship = vessel_get_vessel($strong_ship_id);
    $template->assign("strongship_name", $strong_ship['name']);
    $template->assign("strongship_href", "vessel.php?cmd=" . encrypt_get_vars("show") . "&vid=" . encrypt_get_vars($strong_ship_id));
    $template->assign("strongship_percentage", $ss_a);
    list($weak_planet_id, $wp_a) = user_get_weakest_planet($user_id);
    $weak_planet = anomaly_get_anomaly($weak_planet_id);
    $template->assign("weakplanet_name", $weak_planet['name']);
    $template->assign("weakplanet_href", "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($weak_planet_id));
    $template->assign("weakplanet_percentage", $wp_a);
    list($strong_planet_id, $sp_a) = user_get_strongest_planet($user_id);
    $strong_planet = anomaly_get_anomaly($strong_planet_id);
    $template->assign("strongplanet_name", $strong_planet['name']);
    $template->assign("strongplanet_href", "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($strong_planet_id));
    $template->assign("strongplanet_percentage", $sp_a);
    // Other Information
    list($bd, $vd, $id) = info_get_invention_statistics($user_id);
    $template->assign("buildings_discovered_percentage", $bd);
    $template->assign("vessels_discovered_percentage", $vd);
    $template->assign("inventions_discovered_percentage", $id);
    $template->assign("impulse_discovered", $user['impulse']);
    $template->assign("warp_discovered", number_format($user['warp'] / 10, 1));
    // Server status
    if (check_heartbeat_online()) {
        $template->assign("heartbeat_status", "online");
    } else {
        $template->assign("heartbeat_status", "offline");
    }
    if (check_server_online()) {
        $template->assign("commserver_status", "online");
        $result = sql_query("SELECT * FROM perihelion.pxs_info WHERE galaxy_id LIKE '" . $_USER['galaxy_db'] . "'");
        $server_status = sql_fetchrow($result);
        $result = sql_query("SELECT UNIX_TIMESTAMP()");
        $row = sql_fetchrow($result);
        $server_status['uptime'] = $row['0'] - $server_status['uptime'];
        $template->assign("commserver_uptime", calculate_uptime($server_status['uptime']));
        $template->assign("commserver_spawns", $server_status['spawns']);
        $template->assign("commserver_commands", $server_status['commands']);
        $template->assign("commserver_status_ok", $server_status['status_ok']);
        $template->assign("commserver_status_err", $server_status['status_err']);
    } else {
        $template->assign("commserver_status", "offline");
    }
    if (check_mysql_online()) {
        $template->assign("mysql_status", "online");
        // Get the mysql status and make it a nice hash
        $result = sql_query("SHOW STATUS");
        while ($row = sql_fetchrow($result)) {
            $sql_status[$row['Variable_name']] = $row['Value'];
        }
        $template->assign("mysql_uptime", calculate_uptime($sql_status['Uptime']));
        $template->assign("mysql_queries", $sql_status['Questions']);
        $template->assign("mysql_select", $sql_status['Com_select']);
        $template->assign("mysql_insert", $sql_status['Com_insert']);
        $template->assign("mysql_update", $sql_status['Com_update']);
        $template->assign("mysql_bytes_received", $sql_status['Bytes_received']);
        $template->assign("mysql_bytes_sent", $sql_status['Bytes_sent']);
    } else {
        $template->assign("mysql_status", "offline");
    }
    $template->display($_RUN['theme_path'] . "/info.tpl");
}