Exemple #1
0
function trade_create_route($user_id)
{
    assert(is_numeric($user_id));
    $found_at_least_one_ship = false;
    $result = sql_query("SELECT g.* FROM g_vessels AS g, s_vessels AS s WHERE g.user_id={$user_id} AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_TRADE . "'");
    while ($vessel = sql_fetchrow($result)) {
        if (!vessel_in_traderoute($vessel['id'])) {
            $found_at_least_one_ship = true;
        }
    }
    if ($found_at_least_one_ship == false) {
        print_line("You do not have any tradeships currently available for setting up a traderoute");
        return;
    }
    print_remark("Create form");
    form_start();
    echo "  <input type=hidden name=cmd value=" . encrypt_get_vars("create2") . ">\n";
    echo "  <table align=center>\n";
    echo "  <tr>\n";
    echo "    <td>&nbsp;Vessel: &nbsp;</td>\n";
    echo "    <td>\n";
    echo "      <select name=vid>\n";
    $result = sql_query("SELECT g.* FROM g_vessels AS g, s_vessels AS s WHERE g.user_id={$user_id} AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_TRADE . "'");
    while ($vessel = sql_fetchrow($result)) {
        if (!trade_is_vessel_in_route($vessel['id'])) {
            echo "        <option value=" . encrypt_get_vars($vessel['id']) . ">" . $vessel['name'] . "</option>\n";
        }
    }
    echo "      </select>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "  <tr><td>&nbsp;</td></tr>\n";
    echo "  <tr>\n";
    echo "    <td>&nbsp;Source Planet: &nbsp;</td>\n";
    echo "    <td>\n";
    echo "      <select name=src_pid>\n";
    $result = sql_query("SELECT a.*,s.name AS sectorname FROM s_anomalies AS a, s_sectors AS s WHERE a.user_id={$user_id} AND a.type='P' AND a.sector_id = s.id");
    while ($planet = sql_fetchrow($result)) {
        if (anomaly_is_planet($planet['id']) and planet_is_minable($planet['id'])) {
            echo "        <option value=" . encrypt_get_vars($planet['id']) . ">" . $planet['sectorname'] . " / " . $planet['name'] . "</option>\n";
        }
    }
    echo "      </select>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "  <tr>\n";
    echo "    <td>&nbsp;Ores: &nbsp;</td>\n";
    echo "    <td>";
    echo "      <table border=0 cellspacing=0 colspacing=0>\n";
    echo "        <tr>";
    for ($i = 0; $i != ore_get_ore_count(); $i++) {
        if ($i % 3 == 0) {
            echo "        </tr>\n";
            echo "        <tr>\n";
        }
        echo "          <td><input type=checkbox name=src_ore_" . $i . ">" . ore_get_ore_name($i) . "</td>\n";
    }
    echo "        </tr>\n";
    echo "      </table>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "  <tr><td colspan=2>&nbsp;</td></tr>\n";
    echo "  <tr>\n";
    echo "    <td>&nbsp;Destination Planet: &nbsp;</td>\n";
    echo "    <td>\n";
    echo "      <select name=dst_pid>\n";
    $result = sql_query("SELECT * FROM g_anomalies WHERE user_id={$user_id}");
    $planetlist = csl_create_array($result, 'csl_discovered_id');
    // Get all planets which we own...
    foreach ($planetlist as $planet_id) {
        $planet = anomaly_get_anomaly($planet_id);
        if ($planet['user_id'] == 0) {
            continue;
        }
        if ($planet['user_id'] != $user_id) {
            continue;
        }
        if (user_is_mutual_friend($user_id, $planet['user_id']) and anomaly_is_planet($planet['id']) and planet_is_minable($planet['id'])) {
            $sector = sector_get_sector($planet['sector_id']);
            echo "        <option value=" . encrypt_get_vars($planet['id']) . ">" . $sector['name'] . " / " . $planet['name'] . "</option>\n";
        }
    }
    // And now, all other planets with a different user_id
    foreach ($planetlist as $planet_id) {
        $planet = anomaly_get_anomaly($planet_id);
        if ($planet['user_id'] == 0) {
            continue;
        }
        if ($planet['user_id'] == $user_id) {
            continue;
        }
        if (user_is_mutual_friend($user_id, $planet['user_id']) and anomaly_is_planet($planet['id']) and planet_is_minable($planet)) {
            $sector = sector_get_sector($planet['sector_id']);
            $race = user_get_race($planet['user_id']);
            echo "        <option value=" . encrypt_get_vars($planet['id']) . ">(" . $race . ") " . $sector['name'] . " / " . $planet['name'] . "</option>\n";
        }
    }
    echo "      </select>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "  <tr>\n";
    echo "    <td>&nbsp;Ores: &nbsp;</td>\n";
    echo "    <td>\n";
    echo "      <table border=0 cellspacing=0 colspacing=0>\n";
    echo "        <tr>\n";
    for ($i = 0; $i != ore_get_ore_count(); $i++) {
        if ($i % 3 == 0) {
            echo "      </tr>\n";
            echo "      <tr>\n";
        }
        echo "        <td><input type=checkbox name=dst_ore_" . $i . ">" . ore_get_ore_name($i) . "</td>\n";
    }
    echo "     </tr>\n";
    echo "    </table>\n";
    echo "      </td>\n";
    echo "    </tr>\n";
    echo "    <tr><td colspan=2>&nbsp;</td></tr>\n";
    echo "    <tr><td></td><td><input type=submit name=submit value='create traderoute'></td></tr>\n";
    echo "  </table>\n";
    form_end();
}
    $size = $size / 4;
    $startX += $ox[$factor] * $size;
    $startY += $oy[$factor] * $size;
}
// Zoom image to destination
imagecopyresized($img, $img2, 0, 0, $startX * $width_scale, $startY * $height_scale, 400, 400, $size * $width_scale, $size * $height_scale);
// And print a nice stringy at the top left
$str = "Grid " . $zoom;
$font = 2;
imagestring($img, $font, 6, 3, $str, $black);
imagestring($img, $font, 5, 2, $str, $white);
if ($user_id != 0 and flags_is_checked($flags, FLAGS_SECTORS)) {
    $result = sql_query("SELECT  s.* FROM s_sectors AS s, g_sectors AS g WHERE FIND_IN_SET( s.id, g.csl_sector_id ) and g.user_id=" . $user_id);
    while ($sector = sql_fetchrow($result)) {
        $color = $yellow;
        if (user_is_mutual_friend($user_id, $sector['user_id']) and $sector['user_id'] != $user_id) {
            if (!flags_is_checked($flags, FLAGS_SECTOR_FRIEND)) {
                continue;
            }
            $color = $green;
        }
        if (user_is_enemy($user_id, $sector['user_id'])) {
            if (!flags_is_checked($flags, FLAGS_SECTOR_ENEMY)) {
                continue;
            }
            $color = $red;
        }
        if (user_is_neutral($user_id, $sector['user_id']) or $sector['user_id'] == UID_NOBODY) {
            if (!flags_is_checked($flags, FLAGS_SECTOR_NEUTRAL)) {
                continue;
            }
function user_showinfo($user_id, $extended_info = USER_SHOWINFO_NORMAL)
{
    assert(is_numeric($user_id));
    $user = user_get_user($user_id);
    $px_user = user_get_perihelion_user($user_id);
    $result = sql_query("SELECT * FROM perihelion.u_access WHERE user_id=" . $user_id . " ORDER BY login DESC LIMIT 1");
    $access = sql_fetchrow($result);
    sql_query("USE " . $px_user['galaxy_db']);
    $result = sql_query("SELECT SUM(population) FROM s_anomalies WHERE user_id=" . $user_id);
    $row = sql_fetchrow($result);
    $people = $row['0'];
    $result = sql_query("SELECT COUNT(*) FROM s_sectors WHERE user_id=" . $user_id);
    $row = sql_fetchrow($result);
    $sectors_owned = $row['0'];
    $result = sql_query("SELECT COUNT(*) FROM s_anomalies WHERE user_id=" . $user_id);
    $row = sql_fetchrow($result);
    $planets_owned = $row['0'];
    $result = sql_query("SELECT DISTINCT sector_id, COUNT(*) FROM s_anomalies WHERE user_id=" . $user_id . " GROUP BY sector_id");
    $sector_count = sql_countrows($result);
    $sector = sector_get_sector(user_get_home_sector($user_id));
    $planet = anomaly_get_anomaly(user_get_home_planet($user_id));
    $race = user_get_race($user_id);
    $result = sql_query("SELECT * FROM g_alliance WHERE id=" . $user['alliance_id']);
    $alliance = sql_fetchrow($result);
    if ($user['alliance_id'] != 0) {
        $result = sql_query("SELECT COUNT(*) AS count FROM g_users WHERE alliance_id = " . $alliance['id']);
        $tmp = sql_fetchrow($result);
        $alliance_size = $tmp['count'];
    }
    $status = "Unknown";
    if (user_is_friend(user_ourself(), $user_id)) {
        $status = "Single side friend";
    }
    if (user_is_mutual_friend(user_ourself(), $user_id)) {
        $status = "Mutual friend";
    }
    if (user_is_neutral(user_ourself(), $user_id)) {
        $status = "Neutral";
    }
    if (user_is_enemy(user_ourself(), $user_id)) {
        $status = "Enemy";
    }
    if (user_ourself() == $user_id) {
        $status = "";
    }
    echo "<table border=0 align=center width=60%>";
    echo "<tr><th class=white colspan=2>" . $px_user['name'] . "</th><th>&nbsp;</th></tr>";
    echo "<tr><th colspan=2><b>" . $px_user['tag'] . "</b></th></tr>";
    echo "<tr valign=top>";
    echo "  <td width=120>";
    echo "    <img width=100 height=100 src='images/users/" . $px_user['avatar'] . "'><br>";
    echo "    <br>";
    if ($user['alliance_id'] != 0) {
        echo "    <img width=100 height=100 src='images/users/" . $alliance['avatar'] . "'><br>";
    }
    echo "  </td>";
    echo "  <td><table border=0 nowrap>";
    echo "        <tr class=bl><td>&nbsp;Full Name       &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['name'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;User ID         &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['id'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;City            &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['city'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Country         &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['country'] . "&nbsp;</td></tr>";
    echo "        <tr><td colspan=3>&nbsp;</td></tr>";
    if ($status != "") {
        echo "        <tr class=bl><td>&nbsp;Diplomatic Status &nbsp;</td><td>:</td><td>&nbsp;" . $status . "&nbsp;</td></tr>";
    }
    echo "        <tr class=bl><td>&nbsp;Race              &nbsp;</td><td>:</td><td>&nbsp;" . $race . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Home Planet       &nbsp;</td><td>:</td><td>&nbsp;" . $planet['name'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Home Sector       &nbsp;</td><td>:</td><td>&nbsp;" . $sector['name'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Population        &nbsp;</td><td>:</td><td>&nbsp;" . $people . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Sectors Owned     &nbsp;</td><td>:</td><td>&nbsp;" . $sectors_owned . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Planets Owned     &nbsp;</td><td>:</td><td>&nbsp;" . $planets_owned . " planet(s) in " . $sector_count . " sector(s)&nbsp;</td></tr>";
    if ($user['alliance_id'] != 0) {
        echo "        <tr class=bl><td>&nbsp;Alliance        &nbsp;</td><td>:</td><td>&nbsp;<a href=alliance.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($alliance['id']) . ">" . $alliance['name'] . "</a>&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Alliance Size   &nbsp;</td><td>:</td><td>&nbsp;" . $alliance_size . " user(s)&nbsp;</td></tr>";
    }
    echo "        <tr><td colspan=3>&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Times logged in   &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['login_count'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Last login        &nbsp;</td><td>:</td><td>&nbsp;" . $access['login'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Last action       &nbsp;</td><td>:</td><td>&nbsp;" . $access['logout'] . "&nbsp;</td></tr>";
    if ($extended_info == USER_SHOWINFO_EXTENDED) {
        if ($px_user['gender'] == "M") {
            $gender = "Male";
        } else {
            $gender = "Female";
        }
        echo "        <tr><td colspan=3>&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Email      &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['email'] . "&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Login Name &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['login_name'] . "&nbsp;</td></tr>";
        echo "        <tr><td colspan=3>&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;City       &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['city'] . "&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Country    &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['country'] . "&nbsp;</td></tr>";
        echo "        <tr><td colspan=3>&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Birthday   &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['birthday'] . "&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Gender     &nbsp;</td><td>:</td><td>&nbsp;" . $gender . "&nbsp;</td></tr>";
    }
    if ($user_id != user_ourself()) {
        echo "<tr><th colspan=3>";
        echo "[ <a href=message.php?uid=" . encrypt_get_vars($user_id) . ">Send Message</a> ]";
        echo "</th></tr>";
        echo "<tr><th colspan=3>";
        echo "[ <a href=user.php?cmd=" . encrypt_get_vars("relation") . "&uid=" . encrypt_get_vars($user_id) . "&wid=" . encrypt_get_vars(RELATION_FRIEND) . ">Set as friend</a>  ] - ";
        echo "[ <a href=user.php?cmd=" . encrypt_get_vars("relation") . "&uid=" . encrypt_get_vars($user_id) . "&wid=" . encrypt_get_vars(RELATION_NEUTRAL) . ">Set as neutral</a>  ] - ";
        echo "[ <a href=user.php?cmd=" . encrypt_get_vars("relation") . "&uid=" . encrypt_get_vars($user_id) . "&wid=" . encrypt_get_vars(RELATION_ENEMY) . ">Set as enemy</a> ]";
        echo "</th></tr>";
    }
    echo "  </table></td>";
    echo "</tr>";
    echo "</table>";
    echo "<br><br>";
}