function show_possible_vessels_on_planet($anomaly_id)
{
    assert(is_numeric($anomaly_id));
    $anomaly = anomaly_get_anomaly($anomaly_id);
    // No construction possible when we don't have the right buildings...
    if (!planet_has_vesselbuilding_capability($anomaly_id)) {
        print_subtitle("Planet " . $anomaly['name'] . " has no vessel construction capability.");
        create_submenu(array("Planet view" => "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly_id), "Surface view" => "surface.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly_id)));
        return;
    }
    print_subtitle("Vessel construction on planet " . $anomaly['name']);
    $user = user_get_user($anomaly['user_id']);
    $result = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $anomaly_id);
    $ores = sql_fetchrow($result);
    $result = sql_query("SELECT * FROM s_vessels ORDER BY id");
    while ($vessel = sql_fetchrow($result)) {
        $cannot_build = true;
        // Can we build it?
        if ($vessel['build_level'] <= $user['vessel_level']) {
            $cannot_build = false;
        }
        if ($cannot_build == false) {
            vessel_show_type_details($vessel['id'], $anomaly_id, $anomaly['user_id'], $ores['stock_ores']);
        }
    }
}
Example #2
0
function show_score($table, $offset, $user_id)
{
    assert(is_string($table));
    assert(is_string($offset));
    assert(is_numeric($user_id));
    global $_CONFIG;
    // Define minimum and maximum ranking for this page
    if ($offset == "") {
        $offset = 1;
    }
    $min = $offset;
    $max = $offset + $_CONFIG['SCORE_VIEWSIZE'];
    if ($max > score_get_last_rank()) {
        $max = score_get_last_rank();
    }
    // Print nice title
    if ($table == "overall") {
        $str = "Overall Ranking";
    }
    if ($table == "resource") {
        $str = "Resource Ranking";
    }
    if ($table == "strategic") {
        $str = "Strategic Ranking";
    }
    if ($table == "exploration") {
        $str = "Exploration Ranking";
    }
    print_subtitle($str);
    // Create sub menu
    create_submenu(array("Resource Ranking" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("resource"), "Exploration Ranking" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("exploration"), "Strategic Ranking" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("strategic"), "Overall Ranking" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("overall")));
    $pagecount = round((score_get_last_rank() - score_get_first_rank()) / $_CONFIG['SCORE_VIEWSIZE'] + 0.5);
    $pages = array();
    for ($i = 1; $i != $pagecount + 1; $i++) {
        $a = array("P{$i}" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars($table) . "&ofs=" . encrypt_get_vars(($i - 1) * $_CONFIG['SCORE_VIEWSIZE'] + 1));
        $pages = array_merge($pages, $a);
    }
    create_submenu($pages);
    // Print the table
    $cls = "bl";
    echo "<table border=0 align=center width=75%>\n";
    echo "  <tr class=wb><th colspan=3>" . $str . "</th><tr>\n";
    for ($i = $min; $i != $max + 1; $i++) {
        list($uid, $name, $points) = score_get_rank($table, $i);
        if ($uid == $user_id) {
            echo "<tr class=" . $cls . "><td>&nbsp;<b><big>" . $i . ".</big></b>&nbsp;</td><td>&nbsp;<b><big>" . $name . "</big></b>&nbsp;</td><td>&nbsp;<b><big>(" . $points . " points)</big></b>&nbsp</td></tr>\n";
        } else {
            echo "<tr class=" . $cls . "><td>&nbsp;" . $i . ".&nbsp;</td><td>&nbsp;" . $name . "&nbsp;</td><td>&nbsp;(" . $points . " points)&nbsp</td></tr>\n";
        }
        if ($cls == "bl") {
            $cls = "lbl";
        } else {
            $cls = "bl";
        }
    }
    echo "</table>";
    echo "<br><br>";
}
Example #3
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)));
}
Example #4
0
function vessel_show_details($vessel_id)
{
    assert(is_numeric($vessel_id));
    $vessel = vessel_get_vessel($vessel_id);
    $vesseltype = vessel_get_vesseltype($vessel_id);
    vessel_show_vessel_details($vessel_id);
    scan_scan_area($vessel_id, 1000);
    if ($vesseltype['type'] == VESSEL_TYPE_TRADE) {
        vessel_show_trade_details($vessel_id);
    }
    if ($vesseltype['type'] == VESSEL_TYPE_EXPLORE) {
        vessel_show_explore_details($vessel_id);
    }
    if ($vesseltype['type'] == VESSEL_TYPE_BATTLE) {
        vessel_show_battle_details($vessel_id);
    }
    vessel_show_cargo($vessel_id);
    create_submenu(array("Move Vessel" => "vesselmove.php?cmd=" . encrypt_get_vars("showvid") . "&vid=" . encrypt_get_vars($vessel_id)));
}
Example #5
0
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");
}
Example #6
0
<?php

// Include Files
include "includes.inc.php";
// Session Identification
session_identification();
print_header();
print_title("Surface");
$cmd = input_check("show", "aid", 0);
if ($cmd == "show") {
    if ($aid == "") {
        $aid = user_get_home_planet(user_ourself());
    }
    show_surface($aid);
}
create_submenu(array("View Planet Info" => "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($aid), "View Surface Info" => "surface.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($aid)));
print_footer();
exit;
// ============================================================================================
//
//
// Description:
//
//
// Parameters:
//
//
// Returns:
//
//
function show_surface($planet_id)
Example #7
0
print_title("Alliances", "An alliance is a coorperation between 2 or more users. Create your own alliance and increase it's size by let other users join in on your alliance.");
$cmd = input_check("create", 0, "show", "aid", 0, "partjoin", "!frmid", "aid", "uid", 0, "requestjoin", "!frmid", "rid", 0);
if ($cmd == "create") {
    create_alliance();
}
if ($cmd == "show") {
    show_alliance(user_ourself(), $aid);
}
if ($cmd == "partjoin") {
    partjoin_alliance($aid, $uid);
    show_alliance(user_ourself(), $aid);
}
if ($cmd == "requestjoin") {
    request_join_alliance($rid);
}
create_submenu(array("Show Alliances" => "alliance.php?cmd=" . encrypt_get_vars("show"), "Create New Alliance" => "alliance.php?cmd=" . encrypt_get_vars("create")));
print_footer();
exit;
// ============================================================================
// Show_Alliance()
//
// Description:
//   Shows the alliance $alliance_id in the context of the user_id.
//   When alliance_id is empty, all alliances known to the user are shown.
//
// Parameters:
//    $user_id      User ID that views. This doesn't have to be the current user
//                  who plays the game (but most of the time it is).
//    $alliance_id  Alliance ID to view. If empty then all alliances that are
//                  known to the user are shown
//
Example #8
0
            $data[$tmp2] = "";
        }
    }
    if (comm_send_to_server("TRADECREATE", $data, $ok, $errors) == 1) {
        // Make sure we move our vessel to the source planet. After this, the heartbeat deamon
        // takes over and start moving the vessel from source to destination and back...
        $vessel = vessel_get_vessel($vid);
        $data = "";
        $data['vid'] = $vid;
        $data['did'] = $src_pid;
        $data['uid'] = $vessel['user_id'];
        comm_send_to_server("MOVE", $data, "", "");
        print_line("Traderoute created.\n");
    }
}
create_submenu(array("Show Traderoutes" => "trade.php?cmd=" . encrypt_get_vars("show"), "Create Traderoutes" => "trade.php?cmd=" . encrypt_get_vars("create"), "Delete Traderoutes" => "trade.php?cmd=" . encrypt_get_vars("delete")));
print_footer();
exit;
// ============================================================================================
//
//
// Description:
//
//
// Parameters:
//
//
// Returns:
//
//
function trade_create_route($user_id)
function planet_show_planet($planet_id)
{
    assert(!empty($planet_id));
    global $_GALAXY;
    global $_CONFIG;
    global $_RUN;
    if (!anomaly_is_planet($planet_id)) {
        return;
    }
    $planet = anomaly_get_anomaly($planet_id);
    $result = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $planet_id);
    $ore = sql_fetchrow($result);
    $stock_ore = ore_csl_to_list($ore['stock_ores']);
    $race = user_get_race($planet['user_id']);
    $sector = sector_get_sector($planet['sector_id']);
    $result = sql_query("SELECT * FROM s_state WHERE id=" . $planet['state_id']);
    $state = sql_fetchrow($result);
    if ($race == "") {
        $race = "-";
    }
    $extra_attack = 0;
    $extra_defense = 0;
    $attack = $planet['cur_attack'];
    $defense = $planet['cur_attack'];
    // Count all ships and their attack/defense currently in orbit around the planet
    $result = sql_query("SELECT COUNT(*) FROM g_vessels AS g, s_vessels AS s WHERE g.planet_id=" . $planet_id . " AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_BATTLE . "' AND status='ORBIT' AND created=1");
    $tmp = sql_fetchrow($result);
    $battle_vessels = $tmp[0];
    $result = sql_query("SELECT COUNT(*) FROM g_vessels AS g, s_vessels AS s WHERE g.planet_id=" . $planet_id . " AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_TRADE . "' AND status='ORBIT' AND created=1");
    $tmp = sql_fetchrow($result);
    $trade_vessels = $tmp[0];
    $result = sql_query("SELECT COUNT(*) FROM g_vessels AS g, s_vessels AS s WHERE g.planet_id=" . $planet_id . " AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_EXPLORE . "' AND status='ORBIT' AND created=1");
    $tmp = sql_fetchrow($result);
    $explore_vessels = $tmp[0];
    $result = sql_query("SELECT SUM(cur_attack) AS CA, SUM(cur_defense) AS CD FROM g_vessels AS g WHERE g.planet_id=" . $planet_id . " AND status='ORBIT' AND created=1");
    $tmp = sql_fetchrow($result);
    if (isset($tmp['CA'])) {
        $extra_attack = $extra_attack + $tmp['CA'];
    }
    if (isset($tmp['CD'])) {
        $extra_defense = $extra_defense + $tmp['CD'];
    }
    $template = new Smarty();
    $template->debugging = true;
    $template->assign("sector_name", $sector['name']);
    $template->assign("planet_name", $planet['name']);
    $template->assign("image", $_CONFIG['IMAGE_URL'] . $_GALAXY['image_dir'] . "/planets/" . $planet['image'] . ".jpg");
    if ($planet['unknown'] == 1) {
        $template->assign("cmd", encrypt_get_vars("claim"));
        $template->assign("formid", generate_form_id());
        $template->assign("aid", encrypt_get_vars($planet_id));
        $template->assign("rename_form_visible", "true");
    } else {
        $template->assign("rename_form_visible", "false");
    }
    $template->assign("class", $planet['class']);
    $template->assign("race", $race);
    $template->assign("state", $state['name']);
    $template->assign("happieness", planet_get_happy_string($planet['happieness']));
    $template->assign("healtieness", planet_get_healty_string($planet['sickness']));
    $template->assign("population", $planet['population']);
    $template->assign("radius", $planet['radius']);
    $template->assign("distance", $planet['distance']);
    $template->assign("water", $planet['water']);
    $template->assign("temperature", $planet['temperature']);
    for ($i = 0; $i != ore_get_ore_count(); $i++) {
        $tmp = array();
        $tmp['name'] = ore_get_ore_name($i);
        $tmp['stock'] = $stock_ore[$i];
        $tmpvar[] = $tmp;
    }
    $template->assign("ores", $tmpvar);
    $template->assign("attack", $attack);
    $template->assign("extra_attack", $extra_attack);
    $template->assign("defense", $defense);
    $template->assign("extra_defense", $extra_defense);
    $template->assign("strength", $planet['cur_strength']);
    $template->assign("orbit_battle", $trade_vessels);
    $template->assign("orbit_trade", $battle_vessels);
    $template->assign("orbit_explore", $explore_vessels);
    $template->assign("description", convert_px_to_html_tags($planet['description']));
    $template->display($_RUN['theme_path'] . "/planet-details.tpl");
    $commands = array();
    // If we have at least 1 ship in orbit, we can view them here...
    if ($explore_vessels + $trade_vessels + $battle_vessels > 0) {
        $commands['View Vessels'] = "vessel.php?cmd=" . encrypt_get_vars("showaid") . "&aid=" . encrypt_get_vars($planet_id);
    }
    // If it's a solid-class planet (lower than M), we can view the surface.
    if (planet_is_habitable($planet_id) or planet_is_minable($planet_id)) {
        $commands['View Surface'] = "surface.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet_id);
    }
    // If it's our planet we might construct and manufacture,..
    if (anomaly_am_i_owner($planet['id'])) {
        $commands['Change Description'] = "anomaly.php?cmd=" . encrypt_get_vars("description") . "&aid=" . encrypt_get_vars($planet_id);
        // Only minable or habitable or lower can construct
        if (planet_is_habitable($planet_id) or planet_is_minable($planet_id)) {
            $commands['Construct'] = "construct.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet_id);
            $commands['Manufacture'] = "manufacture.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet_id);
        }
        if (planet_has_vesselbuilding_capability($planet_id)) {
            $commands['Create Vessel'] = "vesselcreate.php?cmd=" . encrypt_get_vars("showaid") . "&aid=" . encrypt_get_vars($planet_id);
        }
    }
    create_submenu($commands);
}
Example #10
0
function select_destination($vessel_id)
{
    assert(is_numeric($vessel_id));
    $vessel = vessel_get_vessel($vessel_id);
    $result = sql_query("SELECT * FROM g_flags WHERE user_id=" . $vessel['user_id']);
    $flags = sql_fetchrow($result);
    print_subtitle("Select destination for vessel " . $vessel['name']);
    print_remark("Select_destination");
    echo "<table align=center border=0>\n";
    echo "  <tr><td valign=top>\n";
    vessel_select_automatic($vessel_id);
    if ($flags['can_warp']) {
        echo "  </td></tr><tr><td valign=top>\n";
        vessel_select_preset($vessel_id);
        echo "  </td></tr><tr><td valign=top>\n";
        vessel_select_manual($vessel_id);
    }
    echo "  </td></tr>\n";
    echo "</table>\n";
    create_submenu(array("Show Vessel" => "vessel.php?cmd=" . encrypt_get_vars("showvid") . "&vid=" . encrypt_get_vars($vessel_id)));
    echo "<br><br>\n";
}
Example #11
0
    }
    if (!isset($_REQUEST['ww_k'])) {
        $_REQUEST['ww_k'] = array("", "", "", "", "", "", "", "");
    }
    if (!isset($_REQUEST['ww_v'])) {
        $_REQUEST['ww_v'] = array("", "", "", "", "", "", "", "");
    }
    show_www_table($_REQUEST['ww_cmd'], $_REQUEST['ww_k'], $_REQUEST['ww_v']);
}
if ($cmd == "manualwww2") {
    print_subtitle("Jump to encrypted page.");
    show_www_table($_REQUEST['ww_cmd'], $_REQUEST['ww_k'], $_REQUEST['ww_v']);
    echo "<hr>\n";
    www_execute($_REQUEST['ww_cmd'], $_REQUEST['ww_k'], $_REQUEST['ww_v']);
}
create_submenu(array("PX_Server" => "admin.php?cmd=" . encrypt_get_vars("pxserver"), "Manual WWW" => "admin.php?cmd=" . encrypt_get_vars("manualwww"), "New Sector" => "createnewsector.php", "New User" => "createnewuser.php", "ScanArea" => "scanarea.php", "Ticks" => "ticks.php", "zoomtables" => "zoomtables.php", "test users" => "createtest.php"));
print_footer();
exit;
// ================================================================================
function show_px_table($px_cmd, $px_k, $px_v)
{
    form_start();
    echo "<input type=hidden name=cmd value=" . encrypt_get_vars("pxserver2") . ">\n";
    echo "<table align=center>\n";
    echo "  <tr>";
    echo "<td>Command</td>";
    echo "<td><input type=text size=50 name=px_cmd value='" . $px_cmd . "'></td>";
    echo "</tr>\n";
    for ($i = 0; $i != 16; $i++) {
        echo "  <tr>";
        echo "<td><input type=text size=15 name=px_k[" . $i . "] value='" . $px_k[$i] . "'></td>";