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";
}
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>";
}
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>";
}
function blackhole_show_blackhole($blackhole_id)
{
    assert(is_numeric($blackhole_id));
    global $_GALAXY;
    if (!anomaly_is_blackhole($blackhole_id)) {
        return;
    }
    $blackhole = anomaly_get_anomaly($blackhole_id);
    $race = user_get_race($blackhole['user_id']);
    $sector = sector_get_sector($blackhole['sector_id']);
    if ($race == "") {
        $race = "-";
    }
    echo "<table border=1 width=500 align=center>";
    echo "  <tr><td align=center><b><i>Sector: " . $sector['name'] . " / Anomaly: " . $blackhole['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'] . "/blackholes/" . $blackhole['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>Blackhole Name        </strong></td><td nowrap width=1%><b>:</b></td>";
    if ($blackhole['unknown'] == 1) {
        form_start();
        echo "<td nowrap>";
        echo "  <input type=hidden name=aid value=" . encrypt_get_vars($blackhole_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>" . $blackhole['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>Radius             </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $blackhole['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>" . $blackhole['distance'] . " km (10<sup>6</sup>)</td></tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Fatalities         </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . blackhole_get_fatalities($blackhole_id) . " ship(s)</td></tr>";
    echo "          </table>";
    echo "        </td>";
    echo "      </tr>";
    echo "    </table>";
    echo "    </td>";
    echo "  </tr>";
    echo "</table>";
    echo "<br><br>";
}
function form_start()
{
    static $_FORMID = NULL;
    if ($_FORMID == NULL) {
        $_FORMID = md5(uniqid(rand(), true));
    }
    // Generate Form id for checking double postings.
    echo "<form method=post action=" . $_SERVER['PHP_SELF'] . ">\n";
    echo "<input type=hidden name=frmid value=" . encrypt_get_vars($_FORMID) . ">\n";
}
Example #6
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)));
}
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 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>&nbsp;</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>&nbsp;" . $preset['name'] . "&nbsp;</td>\n";
        echo "    <td>&nbsp;" . $preset['distance'] . "&nbsp;</td>\n";
        echo "    <td>&nbsp;" . $preset['angle'] . "&nbsp;</td>\n";
        echo "    <td>&nbsp;[ <a href=vesselpreset.php?cmd=" . encrypt_get_vars("delete") . "&uid=" . encrypt_get_vars($user_id) . "&pid=" . encrypt_get_vars($preset['id']) . ">Delete</a> ]&nbsp;</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";
}
Example #9
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 #10
0
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 "      &nbsp;<a href=\"anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']) . "\">Planet " . $planet['name'] . "</a>&nbsp;<br>\n";
        if ($delta_upkeep < 0) {
            echo "      &nbsp;<font color=red>Delta Upkeep: " . $delta_upkeep . "</font>&nbsp;\n";
        } else {
            echo "      &nbsp;Delta Upkeep: " . $delta_upkeep . "&nbsp;\n";
        }
        echo "    </td>\n";
        echo "<td>&nbsp;Current in stock&nbsp;</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>&nbsp;Upkeep per tick&nbsp;</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";
    }
}
Example #11
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
//
function obsolete_show_vessel_table($s_vessel, $user, $stock_ores)
{
    assert(!empty($s_vessel));
    assert(!empty($user));
    assert(!empty($stock_ores));
    global $_GALAXY;
    $cannot_build = false;
    echo "<table border=1 cellpadding=0 cellspacing=0 align=center width=50%>";
    // Vessel name
    echo "  <tr><th colspan=2>" . $s_vessel['name'] . "</th></tr>";
    // Plaatje plus ADS + impulse + warp
    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'] . "/vessels/" . $s_vessel['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>";
    echo "             <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    $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;" . $s_vessel['attack'] . "&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;" . $s_vessel['defense'] . "    &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;" . $s_vessel['strength'] . "   &nbsp; </td>";
    echo "               </tr>";
    echo "               <tr><td colspan=3><hr></td></tr>";
    $class = 't';
    echo "               <tr>";
    echo "                 <td class=" . $class . ">&nbsp;<strong>Impulse</strong> &nbsp;</td>";
    echo "                 <td class=" . $class . "> &nbsp;<strong>:</strong>     &nbsp;</td>";
    echo "                 <td class=" . $class . ">&nbsp;" . $s_vessel['max_impulse'] . " %&nbsp;</td>";
    echo "               </tr>";
    echo "               <tr>";
    echo "                 <td class=" . $class . ">&nbsp;<strong>Warp</strong> &nbsp;</td>";
    echo "                 <td class=" . $class . "> &nbsp;<strong>:</strong>     &nbsp;</td>";
    echo "                 <td class=" . $class . ">&nbsp;" . number_format($s_vessel['max_warp'] / 10, 1) . " &nbsp;</td>";
    echo "               </tr>";
    echo "             </table>";
    echo "    </td>";
    echo "  </tr>";
    // Costs + ores  (initial / upkeep)
    echo "  <tr bgcolor=black><td colspan=2>&nbsp;</td></tr>\n";
    echo "  <tr bgcolor=black><td>";
    $cannot_build = svt_initial_ores($cannot_build, $s_vessel, $user, $stock_ores);
    echo "  </td><td>";
    $cannot_build = svt_upkeep_ores($cannot_build, $s_vessel, $user, $stock_ores);
    echo "  </td></tr>";
    echo "  <tr bgcolor=black><td colspan=2>&nbsp;</td></tr>\n";
    // Print description
    if ($s_vessel['description'] != "") {
        echo "<tr><td colspan=2><table border=0 cellspacing=5><tr><td>" . $s_vessel['description'] . "</td></tr></table></td></tr>";
    }
    // Print building possibility
    if ($cannot_build == false) {
        echo "<tr><th colspan=2><a href=vesselcreate.php?vid=" . encrypt_get_vars($s_vessel['id']) . ">BUILD IT</a></th></tr>";
    } else {
        echo "<tr><th colspan=2>CANNOT BUILD</th></tr>";
    }
    echo "</table>\n";
    echo "<br><br>\n";
}
Example #13
0
function message_create_alliance($user_id)
{
    $user = user_get_user($user_id);
    $race = user_get_race($user['user_id']);
    $result = sql_query("SELECT * FROM g_alliance WHERE id=" . $user['alliance_id']);
    $alliance = sql_fetchrow($result);
    print_remark("Createmessage");
    form_start();
    echo "  <table align=center border=0 width=80%>\n";
    echo "    <tr><th>Send message</th></tr>\n";
    echo "    <tr><td>From:          </td><td>" . $race . " race</td></tr>\n";
    echo "    <tr><td>To:            </td><td>All members of " . $alliance['name'] . "</td></tr>\n";
    echo "    <tr><td>Subject:       </td><td><input type=text name=ne_subject size=50 maxvalue=50></td></tr>\n";
    echo "    <tr><td>Msg:           </td><td><textarea name=ne_msg rows=5 cols=60></textarea></td></tr>\n";
    echo "    <tr><td>&nbsp;         </td><td><input type=submit name=submit value='Send Message'></td></tr>\n";
    echo "  </table>\n";
    echo "  <br><br>\n";
    echo "\n";
    echo "<input type=hidden name=src_uid value=" . encrypt_get_vars($user['user_id']) . ">\n";
    echo "<input type=hidden name=dst_uid value=" . encrypt_get_vars($user['alliance_id']) . ">\n";
    echo "<input type=hidden name=target value=" . encrypt_get_vars("ALLIANCE") . ">\n";
    echo "<input type=hidden name=cmd value=" . encrypt_get_vars("post") . ">\n";
    form_end();
}
function 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;
}
Example #15
0
function print_disoveries($user_id)
{
    assert(is_numeric($user_id));
    global $_GALAXY;
    global $_CONFIG;
    global $_RUN;
    $template = new Smarty();
    $template->debugging = true;
    $user = user_get_user($user_id);
    // Buildings
    $result = sql_query("SELECT COUNT(*) AS count FROM s_buildings");
    $count = sql_fetchrow($result);
    $building_discovered = 0;
    $building_nr = 0;
    $result = sql_query("SELECT * FROM s_buildings");
    while ($building = sql_fetchrow($result)) {
        if ($building['build_level'] > $user['building_level']) {
            $building_href[] = "";
            $building_img[] = $_CONFIG['IMAGE_URL'] . $_GALAXY['image_dir'] . "/general/default.gif";
            $building_text[] = "Not discovered";
        } else {
            $building_href[] = "inventions.php?cmd=" . encrypt_get_vars("showbid") . "&bid=" . encrypt_get_vars($building['id']);
            $building_img[] = $_CONFIG['IMAGE_URL'] . $_GALAXY['image_dir'] . "/buildings/" . $building['image'] . ".jpg";
            $building_text[] = $building['name'];
            $building_discovered++;
        }
        $building_nr++;
    }
    $template->assign("building_discovery_percentage", round($building_discovered / $building_nr * 100, 2));
    $template->assign("building_href", $building_href);
    $template->assign("building_img", $building_img);
    $template->assign("building_text", $building_text);
    $template->assign("building_count", count($building_href));
    // Vessels
    $result = sql_query("SELECT COUNT(*) AS count FROM s_vessels");
    $count = sql_fetchrow($result);
    $vessel_discovered = 0;
    $vessel_nr = 0;
    $result = sql_query("SELECT * FROM s_vessels");
    while ($vessel = sql_fetchrow($result)) {
        if ($vessel['build_level'] > $user['building_level']) {
            $vessel_href[] = "";
            $vessel_img[] = $_CONFIG['IMAGE_URL'] . $_GALAXY['image_dir'] . "/general/default.gif";
            $vessel_text[] = "Not discovered";
        } else {
            $vessel_href[] = "inventions.php?cmd=" . encrypt_get_vars("showvid") . "&vid=" . encrypt_get_vars($vessel['id']);
            $vessel_img[] = $_CONFIG['IMAGE_URL'] . $_GALAXY['image_dir'] . "/vessels/" . $vessel['image'] . ".jpg";
            $vessel_text[] = $vessel['name'];
            $vessel_discovered++;
        }
        $vessel_nr++;
    }
    $template->assign("vessel_discovery_percentage", round($vessel_discovered / $vessel_nr * 100, 2));
    $template->assign("vessel_href", $vessel_href);
    $template->assign("vessel_img", $vessel_img);
    $template->assign("vessel_text", $vessel_text);
    $template->assign("vessel_count", count($vessel_href));
    // Items
    $result = sql_query("SELECT COUNT(*) AS count FROM s_inventions");
    $count = sql_fetchrow($result);
    $item_discovered = 0;
    $item_nr = 0;
    $result = sql_query("SELECT * FROM s_inventions");
    while ($item = sql_fetchrow($result)) {
        if ($item['build_level'] > $user['building_level']) {
            $item_href[] = "";
            $item_img[] = $_CONFIG['IMAGE_URL'] . $_GALAXY['image_dir'] . "/general/default.gif";
            $item_text[] = "Not discovered";
        } else {
            $item_href[] = "inventions.php?cmd=" . encrypt_get_vars("showiid") . "&iid=" . encrypt_get_vars($item['id']);
            $item_img[] = $_CONFIG['IMAGE_URL'] . $_GALAXY['image_dir'] . "/inventions/" . $item['image'] . ".jpg";
            $item_text[] = $item['name'];
            $item_discovered++;
        }
        $item_nr++;
    }
    $template->assign("item_discovery_percentage", round($item_discovered / $item_nr * 100, 2));
    $template->assign("item_href", $item_href);
    $template->assign("item_img", $item_img);
    $template->assign("item_text", $item_text);
    $template->assign("item_count", count($item_href));
    $template->display($_RUN['theme_path'] . "/inventions.tpl");
}
Example #16
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.");
    }
}
Example #17
0
function show_science_tax_ratio_table($science_ratio)
{
    print_remark("Science tax ratio");
    form_start();
    echo "<input type=hidden name=cmd value=" . encrypt_get_vars("setrate") . ">\n";
    echo "<table align=center width=50% border=0>\n";
    echo "  <tr>\n";
    echo "    <td colspan=5 align=left><b>Tax Rate</b></td>\n";
    echo "    <td colspan=6 align=right><b>Science Rate</b></td>\n";
    echo "  </tr>\n";
    echo "  <tr>\n";
    for ($i = 10; $i != 5; $i--) {
        if ($science_ratio == 100 - $i * 10) {
            echo "    <td align=center><b>" . $i * 10 . "%</b></td>\n";
        } else {
            echo "    <td align=center class=ylw>" . $i * 10 . "%</td>\n";
        }
    }
    for ($i = 5; $i != 11; $i++) {
        if ($science_ratio == $i * 10) {
            echo "    <td align=center><b>" . $i * 10 . "%</b></td>\n";
        } else {
            echo "    <td align=center class=ylw>" . $i * 10 . "%</td>\n";
        }
    }
    echo "</tr>\n";
    echo "<tr>\n";
    for ($i = 0; $i != 11; $i++) {
        if ($science_ratio == $i * 10) {
            $ch = "checked";
        } else {
            $ch = "";
        }
        echo "    <td align=center><input type=radio name=ne_science_ratio value=\"" . $i * 10 . "\" " . $ch . "></td>\n";
    }
    echo "  </tr>\n";
    echo "  <tr><td align=center colspan=11><input type=submit name=submit value=\"Set New Tax/Science Ratio\"></td></tr>\n";
    echo "</table>\n";
    form_end();
    echo "<br><br>";
}
Example #18
0
function conview_show_sector($user_id, $sector_id, $planets)
{
    assert(is_numeric($user_id));
    assert(is_numeric($sector_id));
    assert(is_array($planets));
    global $_RUN;
    $tmpvar3 = array();
    // 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, JUST_ONE_ALLOWED);
    $tmp = sql_fetchrow($result);
    if ($tmp['count'] == 0) {
        return;
    }
    // Get sector information
    $sector = sector_get_sector($sector_id);
    // Get planet information for all planets in the sector
    $result = sql_query("SELECT * FROM s_anomalies WHERE sector_id=" . $sector_id . " AND user_id=" . $user_id . " ORDER BY distance", MULTIPLE_ALLOWED);
    while ($planet = sql_fetchrow($result)) {
        // If we can't view the planet, then don't show it...
        if (!in_array($planet['id'], $planets)) {
            continue;
        }
        // Can we show this planet (eg, is it in our $planets-array)
        if (!empty($visible_planets) && !in_array($planet['id'], $visible_planets)) {
            continue;
        }
        $tmpvar = array();
        $tmpvar['name'] = $planet['name'];
        $tmpvar['href'] = "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']);
        if (anomaly_is_planet($planet['id'])) {
            $tmpvar['viewstring'] = "View Planet";
        } else {
            $tmpvar['viewstring'] = "View Anomaly";
        }
        $tmpvar2 = array();
        if (planet_is_habitable($planet['id']) or planet_is_minable($planet['id'])) {
            $tmpvar2['href'] = "surface.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']);
            $tmpvar2['str'] = "Surface View";
            $tmpvar['href_array'][] = $tmpvar2;
            $tmpvar2['href'] = "construct.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']);
            $tmpvar2['str'] = "Construction";
            $tmpvar['href_array'][] = $tmpvar2;
            $tmpvar2['href'] = "manufacture.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']);
            $tmpvar2['str'] = "Manufacturing";
            $tmpvar['href_array'][] = $tmpvar2;
            if (planet_has_vesselbuilding_capability($planet['id'])) {
                $tmpvar2['href'] = "vesselcreate.php?cmd=" . encrypt_get_vars("showaid") . "&aid=" . encrypt_get_vars($planet['id']);
                $tmpvar2['str'] = "Create Vessel";
                $tmpvar['href_array'][] = $tmpvar2;
            } else {
                $tmpvar2['href'] = "";
                $tmpvar2['str'] = "";
                $tmpvar['href_array'][] = $tmpvar2;
            }
        } else {
            $tmpvar2['href'] = "";
            $tmpvar2['str'] = "";
            $tmpvar['href_array'][] = $tmpvar2;
            $tmpvar['href_array'][] = $tmpvar2;
            $tmpvar['href_array'][] = $tmpvar2;
            $tmpvar['href_array'][] = $tmpvar2;
        }
        $tmpvar3[] = $tmpvar;
    }
    // while
    $template = new Smarty();
    $template->debugging = true;
    $template->assign("sector_id", $sector['sector']);
    $template->assign("sector_name", $sector['name']);
    $template->assign("planets", $tmpvar3);
    $template->display($_RUN['theme_path'] . "/conview.tpl");
}
Example #19
0
$item[$i][$j]['href'] = "stats.php?cmd=" . encrypt_get_vars("show");
$item[$i][++$j]['item'] = "Show Rankings";
$item[$i][$j]['href'] = "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("overall");
$item[$i][++$j]['item'] = "Show Users";
$item[$i][$j]['href'] = "user.php?cmd=" . encrypt_get_vars("show");
$item[$i][++$j]['item'] = "Show Alliances";
$item[$i][$j]['href'] = "alliance.php?cmd=" . encrypt_get_vars("show");
$item[$i][++$j]['item'] = "View Preferences";
$item[$i][$j]['href'] = "prefs.php?cmd=" . encrypt_get_vars("show");
$item[$i][++$j]['item'] = "View Manual";
$item[$i][$j]['href'] = "help/index.html";
$item[$i][++$j]['item'] = "Who's Online?";
$item[$i][$j]['href'] = "whoisonline.php";
if (user_is_admin(user_ourself())) {
    $item[$i][++$j]['item'] = "Admin Page";
    $item[$i][$j]['href'] = "admin/admin.php?cmd=" . encrypt_get_vars("choose");
}
$item[$i][++$j]['item'] = "Logout";
$item[$i][$j]['href'] = "logout.php\" target=\"_parent";
$i++;
$j = 0;
// Generate menu inside a string
$menu = "";
for ($i = 0; $i != count($item) + 1; $i++) {
    if (empty($item[$i][0])) {
        continue;
    }
    $menu .= "<nobr><b>" . $item[$i][0] . "</b></nobr><br>\n";
    for ($j = 1; $j != count($item[$i]); ++$j) {
        if (!empty($item[$i][$j]['item'])) {
            $menu .= "<nobr>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><a href=\"" . $item[$i][$j]['href'] . "\">" . $item[$i][$j]['item'] . "</a></b></nobr><br>\n";
Example #20
0
function vessel_show_cargo($vessel_id)
{
    assert(is_numeric($vessel_id));
    global $_GALAXY;
    $vessel = vessel_get_vessel($vessel_id);
    // Get all buildings that are currently build on the planet
    $result = sql_query("SELECT * FROM i_vessels WHERE vessel_id=" . $vessel_id);
    $vessel_cargo = csl_create_array($result, "csl_cargo_id");
    $vessel_cargo = array_count_values($vessel_cargo);
    // Find out if we just travelled through a wormhole, or if we are nearby a wormhole.
    $located_in_wormhole = false;
    $result = sql_query("SELECT * FROM w_wormhole");
    while ($wormhole = sql_fetchrow($result)) {
        if ($vessel['distance'] == $wormhole['distance'] and $vessel['angle'] == $wormhole['angle']) {
            $located_in_wormhole = true;
        }
    }
    // Do not show the array when it's empty...
    if (count($vessel_cargo) == 0) {
        //    echo "<table align=center border=0 width=75%>";
        //    echo "<tr class=wb><th colspan=2>No items on board</th></tr>";
        //    echo "</table>";
        //    echo "<br><br>";
    } else {
        echo "<table align=center border=0 width=75%>";
        echo "<tr class=wb><th colspan=3>Vessel Items</th></tr>";
        echo "<tr class=bl>";
        echo "<th>Quantity</th>";
        echo "<th width=100%>Name</th>";
        echo "<th>&nbsp;</th>";
        echo "</tr>";
        reset($vessel_cargo);
        while (list($cargo_id, $q) = each($vessel_cargo)) {
            $invention = item_get_item($cargo_id);
            if (invention_is_active_on_vessel($invention, $vessel)) {
                $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>";
            echo "  <td>&nbsp;" . $q . "&nbsp;</td>";
            echo "  <td>&nbsp;<img " . $activeimg . ">&nbsp;" . $invention['name'] . "&nbsp;</td>";
            if ($vessel['planet_id'] == 0) {
                echo "  <td nowrap>&nbsp;&nbsp;</td>";
            } else {
                echo "  <td nowrap>&nbsp;<a href=vessel.php?cmd=" . encrypt_get_vars("load_v2p") . "&vid=" . encrypt_get_vars($vessel['id']) . "&aid=" . encrypt_get_vars($vessel['planet_id']) . "&iid=" . encrypt_get_vars($invention['id']) . ">Move to planet</a>&nbsp;</td>";
            }
            echo "</tr>";
        }
        echo "</table>";
        echo "<br><br>";
    }
    // Only show planet cargo when there we are orbitting a planet.
    if ($vessel['planet_id'] == 0) {
        return;
    }
    // Get all buildings that are currently build on the planet
    $surface = planet_get_surface($vessel['planet_id']);
    $planet_cargo = csl($surface['csl_cargo_id']);
    $planet_cargo = array_count_values($planet_cargo);
    // Do not show the array when it's empty...
    if (count($planet_cargo) == 0) {
        //    echo "<table align=center border=0 width=75%>\n";
        //    echo "  <tr class=wb><th colspan=3>No items on planet</th></tr>\n";
        //    echo "</table>\n";
        //    echo "<br><br>\n";
    } else {
        form_start();
        echo "<table align=center border=0 width=75%>\n";
        echo "  <tr class=wb><th colspan=3>Planet Items</th></tr>\n";
        echo "  <tr class=bl>";
        echo "<th>Qty</th>";
        echo "<th width=100%>Name</th>";
        echo "<th>&nbsp;</th>";
        echo "</tr>\n";
        reset($planet_cargo);
        while (list($cargo_id, $q) = each($planet_cargo)) {
            $invention = item_get_item($cargo_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;" . $q . "&nbsp;</td>\n";
            echo "    <td>&nbsp;<img " . $activeimg . ">&nbsp;" . $invention['name'] . "&nbsp;</td>\n";
            echo "    <td nowrap>&nbsp;<a href=vessel.php?cmd=" . encrypt_get_vars("load_p2v") . "&vid=" . encrypt_get_vars($vessel['id']) . "&aid=" . encrypt_get_vars($vessel['planet_id']) . "&iid=" . encrypt_get_vars($invention['id']) . ">Move to vessel</a>&nbsp;</td>\n";
            echo "  </tr>\n";
        }
        echo "</table>\n";
        form_end();
        echo "<br><br>\n";
    }
}
Example #21
0
<?php

// Output Buffering
ob_start();
// Include Files
include "includes.inc.php";
// Make sure we don't use cached session-frames
header("Cache-Control: no-cache, must-revalidate");
session_identification();
$template = new Smarty();
if (user_is_logged_in()) {
    $template->assign("title", "Perihelion - User: "******" - dB: " . $_USER['galaxy_db']);
} else {
    $template->assign("title", "Perihelion - The Game");
}
$template->assign("mainurl", "info.php?cmd=" . encrypt_get_vars("show"));
$template->display($_RUN['theme_path'] . "/index.tpl");
ob_end_flush();
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>&nbsp;<img alt=Active src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/active.gif>&nbsp;<a href=vesselupgrade.php?vid=" . encrypt_get_vars($vessel['id']) . ">" . $vessel['name'] . "</a>&nbsp;</td>";
        } else {
            echo "<td>&nbsp;<img alt=Inactive src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/inactive.gif>&nbsp;" . $vessel['name'] . "</a>&nbsp;</td>";
        }
        echo "<td>&nbsp;Impulse: " . $vessel['impulse'] . "% &nbsp;</td>";
        echo "<td>&nbsp;Warp: ";
        printf("%.1f", $vessel['warp'] / 10);
        echo "&nbsp;</td>";
        echo "<td>&nbsp;{$status}&nbsp;</td>";
        echo "</tr>";
    }
    echo "</table>";
}
Example #23
0
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>&nbsp;</td></tr>\n";
    }
    echo "<tr><td colspan=2>&nbsp;</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>&nbsp;</td></tr>\n";
    }
    echo "<tr><td colspan=2>&nbsp;</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>&nbsp;</td></tr>\n";
    }
    echo "<tr><td colspan=2>&nbsp;</td></tr>\n";
    echo "</table>";
}
Example #24
0
function show_preferences($prefs, $errors_txt = "", $errors = "")
{
    if (!isset($errors)) {
        $errors = array();
    }
    if (!isset($errors_txt)) {
        $errors_txt = array();
    }
    form_start("enctype='multipart/form-data'");
    echo "  <input type=hidden name=cmd value=" . encrypt_get_vars("post") . ">\n";
    echo "  <table align=center border=0>\n";
    echo "  <tr><td colspan=2>&nbsp</td></tr>\n";
    prefs_show_errors($prefs, $errors_txt, $errors);
    echo "  <tr><td colspan=2>&nbsp</td></tr>\n";
    prefs_show_name($prefs, $errors_txt, $errors);
    prefs_show_email($prefs, $errors_txt, $errors);
    prefs_show_city($prefs, $errors_txt, $errors);
    prefs_show_country($prefs, $errors_txt, $errors);
    prefs_show_inform($prefs, $errors_txt, $errors);
    prefs_show_gender($prefs, $errors_txt, $errors);
    prefs_show_birthdate($prefs, $errors_txt, $errors);
    echo "  <tr><td colspan=2>&nbsp</td></tr>\n";
    prefs_show_tag($prefs, $errors_txt, $errors);
    prefs_show_avatar($prefs, $errors_txt, $errors);
    echo "  <tr><td colspan=2>&nbsp</td></tr>\n";
    echo "  <tr><td colspan=2>Only fill this in if you want a new password:</td></tr>\n";
    prefs_show_loginpass($prefs, $errors_txt, $errors);
    prefs_show_loginpass2($prefs, $errors_txt, $errors);
    echo "  <tr><td colspan=2>&nbsp</td></tr>\n";
    echo "  <tr><td colspan=2>&nbsp</td></tr>\n";
    echo "  <tr><td colspan=2>Enter your password for identification:</td></tr>\n";
    prefs_show_validate_pass($prefs, $errors_txt, $errors);
    echo "  <tr><td></td><td><input type=submit name=submit value='Set Preferences'></td></tr>\n";
    echo "  </table>\n";
    form_end();
}
function help_link($help_topic)
{
    assert(is_string($help_topic));
    return "[ <a href='help.php?hid=" . encrypt_get_vars($help_topic) . "' onclick='targetBlank(this.href);return false;'><b>?</b></a> ]";
}
function score_showuser($user_id)
{
    assert(is_numeric($user_id));
    $tables = array("resource", "exploration", "strategic", "overall");
    foreach ($tables as $table) {
        // Get the current ranking of the user
        $rank = score_get_user_rank($table, $user_id);
        // Get the first rank
        list($uid, $name, $points) = score_get_rank($table, 1);
        $ranktable['1'][$table] = "<td>&nbsp;1.&nbsp;</td><td>&nbsp;" . $name . "&nbsp;</td><td>&nbsp;(" . $points . " points)&nbsp</td>";
        if ($rank == score_get_first_rank()) {
            $ranktable['2'][$table] = "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>";
        } else {
            list($uid, $name, $points) = score_get_rank($table, $rank - 1);
            $ranktable['2'][$table] = "<td>&nbsp;" . ($rank - 1) . ".&nbsp;</td><td>&nbsp;" . $name . "&nbsp;</td><td>&nbsp;(" . $points . " points)&nbsp</td>";
        }
        list($uid, $name, $points) = score_get_rank($table, $rank);
        $ranktable['3'][$table] = "<td>&nbsp;<b>" . $rank . ".</b>&nbsp;</td><td>&nbsp;<b>" . $name . "</b>&nbsp;</td><td>&nbsp;<b>(" . $points . " points)</b>&nbsp</td>";
        if ($rank == score_get_last_rank()) {
            $ranktable['4'][$table] = "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>";
        } else {
            list($uid, $name, $points) = score_get_rank($table, $rank + 1);
            $ranktable['4'][$table] = "<td>&nbsp;" . ($rank + 1) . ".&nbsp;</td><td>&nbsp;" . $name . "&nbsp;</td><td>&nbsp;(" . $points . " points)&nbsp</td>";
        }
    }
    echo "<table border=0 width=75% align=center>";
    echo "  <tr class=wb><th colspan=2>Rankings</th></tr>";
    echo "  <tr><td>";
    echo "<table width=100% border=0>";
    echo "  <tr class=bl><th colspan=4><a href=score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("resource") . ">Resource Ranking:</a></th></tr>";
    echo "  <tr class=bl>" . $ranktable['1']['resource'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['2']['resource'] . "</tr>";
    echo "  <tr class=bl>" . $ranktable['3']['resource'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['4']['resource'] . "</tr>";
    echo "</table>";
    echo "</td><td>";
    echo "<table width=100% border=0>";
    echo "  <tr class=bl><th colspan=4><a href=score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("exploration") . ">Exploration Ranking:</a></th></tr>";
    echo "  <tr class=bl>" . $ranktable['1']['exploration'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['2']['exploration'] . "</tr>";
    echo "  <tr class=bl>" . $ranktable['3']['exploration'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['4']['exploration'] . "</tr>";
    echo "</table>";
    echo "</td></tr>";
    echo "<tr><td>";
    echo "<table width=100% border=0>";
    echo "  <tr class=bl><th colspan=4><a href=score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("strategic") . ">Strategic Ranking:</a></th></tr>";
    echo "  <tr class=bl>" . $ranktable['1']['strategic'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['2']['strategic'] . "</tr>";
    echo "  <tr class=bl>" . $ranktable['3']['strategic'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['4']['strategic'] . "</tr>";
    echo "</table>";
    echo "</td><td>";
    echo "<table width=100% border=0>";
    echo "  <tr class=bl><th colspan=4><a href=score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("overall") . ">Overall Ranking:</a></th></tr>";
    echo "  <tr class=bl>" . $ranktable['1']['overall'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['2']['overall'] . "</tr>";
    echo "  <tr class=bl>" . $ranktable['3']['overall'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['4']['overall'] . "</tr>";
    echo "</table>";
    echo "</td></tr>";
    echo "</table>";
    echo "<br><br>";
}
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";
    */
}
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";
}
Example #29
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");
}
function obsolete_show_invention_table($invention, $planet, $user, $stock_ores)
{
    assert(!empty($invention));
    assert(!empty($planet));
    assert(!empty($user));
    assert(!empty($stock_ores));
    global $_GALAXY;
    $cannot_build = false;
    $invention_ores = ore_csl_to_list($invention['initial_ores']);
    $planet_ores = $stock_ores;
    echo "<table border=1 cellpadding=0 cellspacing=0 align=center width=50%>";
    // invention name
    echo "  <tr><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['type']) . "&nbsp;</td>";
    echo "                </tr>";
    echo "                <tr><td colspan=3><hr></td></tr>\n";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Maximum</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . $invention['max'] . "&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'] . "&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'] . "&nbsp;</td>";
    echo "                </tr>";
    echo "              </table>";
    echo "    </td>";
    echo "  </tr>";
    // 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, $user, $planet_ores);
    echo "  </td><td>";
    $cannot_build = smt_upkeep_ores($cannot_build, $invention, $user, $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><td colspan=2><table border=0 cellspacing=5><tr><td>Effect: " . $invention['rule'] . "</td></tr></table></td></tr>";
    }
    if ($invention['description'] != "") {
        echo "<tr><td colspan=2><table border=0 cellspacing=5><tr><td>" . $invention['description'] . "</td></tr></table></td></tr>";
    }
    // Print building possibility
    if ($cannot_build == false) {
        echo "<tr><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><th colspan=2>CANNOT BUILD</th></tr>";
    }
    echo "</table>\n";
    echo "<br><br>\n";
}