function get_planetDetail($pid)
{
    global $uid;
    global $map_info;
    $sth = mysql_query("select * from planets where id='" . $pid . "'");
    if (!$sth || !mysql_num_rows($sth)) {
        return false;
    }
    $p_info = mysql_fetch_array($sth);
    // erzeuge den user tag, der alles nötige über den Besitzer des Planet enthält
    if ($p_info["uid"]) {
        $sth = mysql_query("select u.name, u.imperium, a.name as aname, a.color, a.symbol from users u LEFT JOIN alliance a ON u.alliance = a.id where u.id=" . $p_info["uid"]);
        if (!$sth || !mysql_num_rows($sth)) {
            return false;
        }
        $u_info = mysql_fetch_array($sth);
        $p_relation = get_uids_relation($uid, $p_info["uid"]);
        $user_tag = create_user_tag($p_info["uid"], htmlspecialchars($u_info["name"]), htmlspecialchars($u_info["imperium"]), htmlspecialchars($u_info["aname"]), $u_info["color"], $u_info["symbol"], $p_relation);
    } else {
        $p_relation = false;
    }
    // erzeuge den resource tag, der den derzeitigen resourcen output wiedergibt
    $resource_tag = create_resource_tag($p_info["metal"], $p_info["energy"], $p_info["mopgas"], $p_info["erkunum"], $p_info["gortium"], $p_info["susebloom"], $p_info["popgain"]);
    // erzeuge den planeten tag, das alle nötigen infos des planeten enthält
    if ($p_info["name"] == "Unnamed") {
        $p_info["name"] = get_planetname($pid);
    }
    if ($p_relation == "same" || $p_relation == "allie") {
        $planet_tag = create_planet_tag($pid, htmlspecialchars($p_info["name"]), $p_info["type"], PIC_ROOT . $p_info["pic"], $p_info["start"], get_poplevel_by_pop($p_info["population"]));
        $building_tag = create_buildings_tag($pid);
        $production_tag = create_production_tag($pid);
    } else {
        $planet_tag = create_planet_tag($pid, htmlspecialchars($p_info["name"]), $p_info["type"], PIC_ROOT . $p_info["pic"], $p_info["start"]);
        if (can_scan_planet_surface($pid)) {
            $building_tag = create_buildings_tag($pid);
        }
    }
    echo "<SR_REQUEST type=\"planet_info\">";
    echo $user_tag;
    echo $resource_tag;
    echo $planet_tag;
    echo $building_tag;
    echo $production_tag;
    echo "</SR_REQUEST>";
}
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();
}