Example #1
0
function reply()
{
    global $PHP_SELF;
    global $uid;
    global $id;
    $sth = mysql_query("select * from mail where id='{$id}'");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    $mail = mysql_fetch_array($sth);
    if ($mail["uid"] != $uid) {
        show_error("I'm not stupid guy! :)");
        return 0;
    }
    if (!(substr($mail["subject"], 0, 4) == "RE: ")) {
        $subject = "RE: " . $mail["subject"];
    } else {
        $subject = $mail["subject"];
    }
    $sth = mysql_query("select name from users where id='" . $mail["fuid"] . "'");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    $user = mysql_fetch_array($sth);
    echo "<form action=\"" . $PHP_SELF . "\" method=post>\n";
    table_border_start("Send new message");
    table_form_text("Send to", "name", $user["name"]);
    table_form_text("Subject", "subject", $subject);
    table_form_textarea("Message", "text", $mail["text"]);
    table_form_submit("Send message", "send");
    echo "</form>";
    table_end();
}
Example #2
0
function show_info()
{
    global $uid;
    global $pid;
    $sth = mysql_query("select * from planets p,popgain g where p.id={$pid} and p.uid={$uid} and p.id=g.pid");
    if (!$sth || mysql_num_rows($sth) == 0) {
        show_error("Jailhouse rock!");
        return 0;
    }
    center_headline("Information Screen");
    $planet = mysql_fetch_assoc($sth);
    table_border_start("center", "", "#302859", "#100666", "#D2CCF9");
    echo "<tr>\n";
    echo " <td rowspan=\"14\">\n";
    echo "   <img src=\"arts/" . $planet["type"] . ".jpg\">\n";
    echo " <td>\n";
    echo "</tr>\n";
    table_head_text(array("Information"), "2");
    table_text_open();
    table_text_design("Owner", "", "center", "1", "head");
    $sth = mysql_query("select u.name,ifnull(a.name,'none') as aname from users u left join alliance a on a.id=u.alliance where u.id=" . $planet["uid"]);
    if (!$sth || mysql_num_rows($sth) == 0) {
        show_error("Database failure!");
        return 0;
    }
    $owner = mysql_fetch_assoc($sth);
    table_text_design($owner["name"], "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("System", "", "center", "1", "head");
    table_text_design(get_systemname($planet["sid"]), "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("Alliance", "", "center", "1", "head");
    table_text_design($owner["aname"], "", "center", "1", "text");
    table_text_close();
    if ($planet["gain"] > 0) {
        $gain = "<span style=\"color: lime\">+" . $planet["gain"] * 100 . "%</span>";
    } else {
        $gain = "+/-0%";
    }
    table_text_open();
    table_text_design("Population", "", "center", "1", "head");
    table_text_design(get_poplevel_by_pop($planet["population"]) . " " . $gain . " (" . $planet["max_poplevel"] . ")", "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("Planettype", "", "center", "1", "head");
    switch ($planet["type"]) {
        case "O":
            $type = "Origin Class";
            break;
        case "M":
            $type = "Mars Class";
            break;
        case "A":
            $type = "Ancient Class";
            break;
        case "D":
            $type = "Desert Class";
            break;
        case "E":
            $type = "Eden Class";
            break;
        case "G":
            $type = "Gas Giant Class";
            break;
        case "H":
            $type = "Heavy Grav Class";
            break;
        case "I":
            $type = "Ice Class";
            break;
        case "R":
            $type = "Rock Class";
            break;
        case "T":
            $type = "Toxic Class";
            break;
    }
    define("planet_raw_metal", "8.5");
    define("planet_raw_energy", "8.5");
    define("planet_raw_mopgas", "8.5");
    define("planet_raw_erkunum", "8.5");
    define("planet_raw_gortium", "8.5");
    define("planet_raw_susebloom", "8.5");
    define("planet_no_upgrade_factor", "1");
    $sth = mysql_query("select * from planets where id={$pid}");
    $population_factor = log10($planet["population"] / 1000) + 3;
    $sth = mysql_query("select * from final_prod_factors where pid=" . $pid);
    if (!$sth) {
        show_error("ERR::GET PROD_FACTORS");
        return false;
    }
    if (mysql_num_rows($sth) == 1) {
        $factors = mysql_fetch_assoc($sth);
    } else {
        $factors = false;
    }
    $metal_plus = round($factors["metal"] * ($planet["metal"] / 100) * (planet_raw_metal * $population_factor));
    $energy_plus = round($factors["energy"] * ($planet["energy"] / 100) * planet_raw_energy * $population_factor);
    $mopgas_plus = round($factors["mopgas"] * ($planet["mopgas"] / 100) * planet_raw_mopgas * $population_factor);
    $erkunum_plus = round($factors["erkunum"] * ($planet["erkunum"] / 100) * planet_raw_erkunum * $population_factor);
    $gortium_plus = round($factors["gortium"] * ($planet["gortium"] / 100) * planet_raw_gortium * $population_factor);
    $susebloom_plus = round($factors["susebloom"] * ($planet["susebloom"] / 100) * planet_raw_susebloom * $population_factor);
    table_text_design($type, "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("Production factor", "", "center", "1", "head");
    table_text_design($planet["production_factor"] * 100 . "%", "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("<img src='arts/metal.gif' title='Metal' alt='Metal'>", "", "center", "1", "head");
    table_text_design($metal_plus, "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("<img src='arts/energy.gif' title='Energy' alt='Energy'>", "", "center", "1", "head");
    table_text_design($energy_plus, "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("<img src='arts/mopgas.gif' title='Mopgas' alt='Mopgas'>", "", "center", "1", "head");
    table_text_design($mopgas_plus, "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("<img src='arts/erkunum.gif' title='Erkunum' alt='Erkunum'>", "", "center", "1", "head");
    table_text_design($erkunum_plus, "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("<img src='arts/gortium.gif' title='Gortium' alt='Gortium'>", "", "center", "1", "head");
    table_text_design($gortium_plus, "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("<img src='arts/susebloom.gif' title='Susebloom' alt='Susebloom'>", "", "center", "1", "head");
    table_text_design($susebloom_plus, "", "center", "1", "text");
    table_text_close();
    table_end();
    echo "<br><br>\n";
    echo "<center>\n";
    //  echo("<a href=\"planet.php?pid=".$planet["id"]."\" target=\"anzeige_frame\">fleet orders</a>\n");
    echo "</center>\n";
    echo "<br>\n";
    $query = mysql_query("SELECT ps.*, p.pic, p.description, p.name FROM planetary_shields ps \nINNER JOIN production p USING (prod_id) WHERE pid={$pid}") or die(mysql_error());
    if (mysql_num_rows($query) > 0) {
        table_start("center", "500");
        table_head_text(array("Shield generators installed on {$planet['name']}"), "5");
        table_text_open("head");
        table_text_design("&nbsp;", "50px", "", "", "head");
        table_text_design("Building", "300", "", "", "head");
        table_text_design("Max", "50", "center", "", "head");
        table_text_design("Power", "50", "center", "", "head");
        table_text_design("Load", "50", "center", "", "head");
        while ($result = mysql_fetch_assoc($query)) {
            table_text_open("text", "center");
            table_text_design("<a href='" . $_SERVER["PHP_SELF"] . "?act=print_building_info&prod_id=" . $result["prod_id"] . "'><img src='arts/" . $result["pic"] . "' alt='" . $result["description"] . "' border='0' width=\"50px\" height=\"50px\" /></a>", "50px", "", "", "text", "2");
            table_text_design($result["name"], "300", "", "", "text", "2");
            table_text_design($result["max_value"], "50", "", "", "text", "2");
            table_text_design($result["value"], "50", "", "", "text", "2");
            table_text_design($result["regeneration"] + $result["regeneration_bonus"], "50", "", "", "text", "2");
            table_text_close();
        }
        table_end();
    }
    echo "<br>\n";
    table_start("center", "500");
    table_head_text(array("Units stationed on " . $planet["name"]), "5");
    table_text(array("&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;"), "center", "100", "", "text");
    table_text_open("head");
    table_text_design("Infantry", "200", "center", "2", "head");
    table_text_design("&nbsp;", "100", "", "", "head");
    table_text_design("Fleet", "200", "center", "2", "head");
    table_text_close();
    $sth = mysql_query("select sum(count) from infantery as i,production as p where i.pid=" . $pid . " and i.prod_id=p.prod_id\n      and p.typ='I'");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    $inf = mysql_fetch_row($sth);
    if ($inf[0] == "") {
        $inf[0] = "No troops";
    }
    table_text_open("text", "center");
    table_text_design("Infantry", "", "", "", "text");
    table_text_design($inf[0], "", "", "", "text");
    table_text_design("&nbsp;", "100", "", "", "none");
    table_text_design("Europa Class", "", "", "", "text");
    table_text_design(get_fcount_by_type($uid, "L", $pid), "", "", "", "text");
    table_text_close();
    $sth = mysql_query("select sum(count) from infantery as i,production as p where i.pid=" . $pid . " and i.prod_id=p.prod_id and p.typ='T'");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    $inf = mysql_fetch_row($sth);
    if ($inf[0] == "") {
        $inf[0] = "No Vehicles";
    }
    table_text_open("text", "center");
    table_text_design("Vehicles", "", "", "", "text");
    table_text_design($inf[0], "", "", "", "text");
    table_text_design("&nbsp;", "100", "", "", "none");
    table_text_design("Zeus Class", "", "", "", "text");
    table_text_design(get_fcount_by_type($uid, "M", $pid), "", "", "", "text");
    table_text_close();
    table_text_open("text", "center");
    table_text_design("&nbsp;");
    table_text_design("&nbsp;");
    table_text_design("&nbsp;", "100", "", "", "none");
    table_text_design("Olymp Class", "", "", "", "text");
    table_text_design(get_fcount_by_type($uid, "H", $pid), "", "", "", "text");
    table_text_close();
    table_end();
}
function foreignreply()
{
    global $id;
    global $uid;
    global $PHP_SELF;
    if (has_alliance_lock($uid)) {
        show_message("You can't use any alliance options due to an alliance lock!");
        return false;
    }
    $sth = mysql_query("select *,a.name as aname, u.name as uname from foreignforum as f,alliance as a,users as u where (f.id={$id} or f.fid={$id}) order by f.time desc");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    if (mysql_num_rows($sth) == 0) {
        show_error("Sending all processes the TERM signal");
        return 0;
    }
    $posting = mysql_fetch_array($sth);
    echo "<form action=\"" . $PHP_SELF . "\" method=post>";
    table_start("center", "500");
    table_text_open("head");
    table_text_design("<strong>" . $posting["aname"] . "</strong> (" . $posting["uname"] . "", "100", "", "", "head");
    table_text_design($posting["time"], "400", "right", "", "smallhead");
    table_text_close();
    table_text_open("head", "left");
    table_text_design("&nbsp;", "100", "", "", "smallhead");
    table_text_design("" . $posting["text"] . "", "400", "", "", "text");
    table_text_close();
    table_end();
    echo "<br>\n";
    table_border_start("center", "500", "#302859", "#140f55", "#f1edfc");
    table_head_text(array("Reply"), "2");
    table_form_textarea("Content", "content");
    form_hidden("id", $id);
    table_form_submit("Post", "proc_foreignreply");
    table_end();
    echo "</form>";
}
Example #4
0
function show_planet()
{
    global $uid;
    global $pid;
    $sth = mysql_query("select * from planets where id={$pid}");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    $planet = mysql_fetch_array($sth);
    if ($planet["name"] == "unnamed") {
        $planet["name"] = get_planetname($planet["id"]);
    }
    center_headline("Planet " . $planet["name"]);
    if ($planet["uid"] == 0) {
        $owner["name"] = "Nobody";
    } else {
        $sth = mysql_query("select u.name from users as u where u.id=" . $planet["uid"]);
        if (!$sth) {
            show_error("Database failure!");
            return 0;
        }
        $owner = mysql_fetch_array($sth);
        $sth = mysql_query("select a.name from alliance as a,users as u where a.id=u.alliance and u.id=" . $planet["uid"]);
        if (mysql_num_rows($sth) == 0) {
            $alliance["name"] = "No alliance";
        } else {
            $alliance = mysql_fetch_array($sth);
        }
    }
    table_border_start("center", "", "#302859", "#100666", "#D2CCF9");
    echo "<tr>\n";
    echo " <td rowspan=\"13\">\n";
    echo "   <img src=\"arts/" . $planet["type"] . ".jpg\">\n";
    echo " <td>\n";
    echo "</tr>\n";
    table_head_text(array("Information"), "2");
    table_text_open();
    table_text_design("Owner", "", "center", "1", "head");
    table_text_design($owner["name"], "", "center", "1", "text");
    table_text_close();
    if ($planet["uid"] != 0) {
        table_text_open();
    }
    table_text_design("Alliance", "", "center", "1", "head");
    table_text_design($alliance["name"], "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("Population", "", "center", "1", "head");
    table_text_design($planet["population"], "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("Planettype", "", "center", "1", "head");
    table_text_design($planet["type"], "", "center", "1", "text");
    table_text_close();
    if ($planet["uid"] == 0) {
        switch ($planet["type"]) {
            case "E":
                $bewohnbar = true;
                break;
            case "O":
                $bewohnbar = true;
                break;
            case "M":
                $bewohnbar = true;
                break;
            case "D":
                $bewohnbar = true;
                break;
            case "I":
                $bewohnbar = true;
                break;
            case "A":
                $bewohnbar = true;
                break;
            case "R":
                $bewohnbar = true;
                break;
            default:
                $bewohnbar = false;
        }
        if ($bewohnbar) {
            table_text_open();
            table_text_design("Habitable", "", "center", "1", "head");
            table_text_design("<font color=\"green\">Yes</font>", "", "center", "1", "text");
            table_text_close();
        } else {
            table_text_open();
            table_text_design("Habitable", "", "center", "1", "head");
            table_text_design("<font color=\"red\">No</font>", "", "center", "1", "text");
            table_text_close();
        }
    }
    table_text_open();
    table_text_design("<img src=\"arts/metal.gif\" title=\"Metal\" alt=\"Metal\">", "", "center", "1", "head");
    table_text_design($planet["metal"], "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("<img src=\"arts/energy.gif\" title=\"Energy\" alt=\"Energy\">", "", "center", "1", "head");
    table_text_design($planet["energy"], "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("<img src=\"arts/mopgas.gif\" title=\"Mopgas\" alt=\"Mopgas\">", "", "center", "1", "head");
    table_text_design($planet["mopgas"], "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("<img src=\"arts/erkunum.gif\" title=\"Erkunum\" alt=\"Erkunum\">", "", "center", "1", "head");
    table_text_design($planet["erkunum"], "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("<img src=\"arts/gortium.gif\" title=\"Gortium\" alt=\"Gortium\">", "", "center", "1", "head");
    table_text_design($planet["gortium"], "", "center", "1", "text");
    table_text_close();
    table_text_open();
    table_text_design("<img src=\"arts/susebloom.gif\" title=\"Susebloom\" alt=\"Susebloom\">", "", "center", "1", "head");
    table_text_design($planet["susebloom"], "", "center", "1", "text");
    table_text_close();
    table_end();
    echo "<br><br>\n";
    echo "<center>\n";
    echo "<a href=\"plmapgen.php?id=" . $planet["sid"] . "\" target=\"_parent\">view solar system</a>\n";
    if ($planet["uid"] == $uid) {
        echo "<a href=\"production.php?act=Production&pid=" . $planet["id"] . "\">production</a>\n";
    }
    echo "</center>\n";
    echo "<br><br>\n";
    return $bewohnbar;
}