コード例 #1
0
function overview()
{
    global $uid;
    $sth = mysql_query("select b.prod_id,b.count,b.side,p.name,p.typ,b.initiative,b.agility,b.hull,b.weaponpower,b.shield,b.ecm,b.target1,b.sensor,b.weaponskill,b.special,b.armor,b.num_attacks,s.initiative,s.agility,s.hull,s.weaponpower,s.shield,s.ecm,s.target1,s.sensor,s.weaponskill,s.special,s.armor,s.num_attacks from battle_" . $uid . " b, production p, shipvalues s where b.prod_id=p.prod_id and b.prod_id=s.prod_id order by side");
    echo "<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"POST\">";
    table_start("center", "700");
    table_head_text(array("Battlesimulator"), 20);
    if (!$sth || mysql_num_rows($sth) == 0) {
        table_text(array("No ships"), "", "", "", "text");
    } else {
        table_head_text(array("Side", "Name", "Type", "count", "initiative", "agility", "hull", "power", "shield", "ecm", "target1", "sensors", "skill", "special", "armor", "num_attacks", "mail"));
        while (list($prod_id, $count, $side, $name, $typ, $cur_ini, $cur_agi, $cur_hull, $cur_pow, $cur_shield, $cur_ecm, $cur_tar1, $cur_sen, $cur_skill, $cur_spec, $cur_arm, $cur_num, $ini, $agi, $hull, $pow, $shield, $ecm, $tar1, $sen, $skill, $spec, $arm, $num) = mysql_fetch_row($sth)) {
            table_text(array($side, $name, $typ, "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][count]\" size=\"4\" value=\"" . $count . "\">", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][initiative]\" size=\"3\" value=\"" . $cur_ini . "\"> (" . $ini . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][agility]\" size=\"3\" value=\"" . $cur_agi . "\"> (" . $agi . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][hull]\" size=\"3\" value=\"" . $cur_hull . "\"> (" . $hull . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][weaponpower]\" size=\"3\" value=\"" . $cur_pow . "\"> (" . $pow . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][shield]\" size=\"3\" value=\"" . $cur_shield . "\"> (" . $shield . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][ecm]\" size=\"3\" value=\"" . $cur_ecm . "\"> (" . $ecm . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][target1]\" size=\"3\" value=\"" . $cur_tar1 . "\"> (" . $tar1 . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][sensor]\" size=\"3\" value=\"" . $cur_sen . "\"> (" . $sen . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][weaponskill]\" size=\"3\" value=\"" . $cur_skill . "\"> (" . $skill . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][special]\" size=\"3\" value=\"" . $cur_spec . "\"> (" . $spec . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][armor]\" size=\"3\" value=\"" . $cur_arm . "\"> (" . $arm . ")", "<input type=\"text\" name=\"battle[" . $side . "][" . $prod_id . "][num_attacks]\" size=\"3\" value=\"" . $cur_num . "\"> (" . $num . ")", "<a href=\"" . $_SERVER["PHP_SELF"] . "?act=suggest&side=" . $side . "&prod_id=" . $prod_id . "\">suggest change</a>"), "", "", "", "text");
        }
    }
    table_form_submit("Change", "proc_change_values");
    table_end();
    echo "</form>";
    $sth = mysql_query("select prod_id,name from production where typ in ('L','M','H','I') \norder by name");
    if (!$sth) {
        show_error("database failersdfiosd");
        return false;
    }
    echo "<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"POST\">";
    table_start("center", "500");
    table_head_text(array("Add ships"), "2");
    while (list($prod_id, $name) = mysql_fetch_row($sth)) {
        $select[$name] = $prod_id;
    }
    table_form_select("Ship", "prod_id", $select, "2", "text", "text");
    table_form_select("Side", "side", array(1 => 1, 2 => 2), "2", "text", "text");
    table_form_text("Count", "count");
    table_form_submit("Add ships", "proc_add_ships");
    table_end();
    echo "</form>";
    echo "<br>";
    echo "<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"POST\">";
    table_start("center", "500");
    table_head_text(array("Config"), "2");
    table_form_select("Combat rounds", "rounds", array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 10 => 10), "1", "text", "text");
    table_form_select("Fraction limit", "fraction", array(100 => 100, 250 => 250, 500 => 500, 1000 => 1000, 2000 => 2000, "no limit" => 0), "250", "text", "text");
    table_form_select("Orbital Dig-In factor (Side 1)", "digino", array("no dig-in" => 0, 20 => 20, 40 => 40, 60 => 60, 65 => 65, 70 => 70, 75 => 75, 80 => 80, 85 => 85, 90 => 90, 95 => 95, 99 => 99), "0", "text", "text");
    table_form_select("Orbital Dig-In bonus (Side 1)", "diginob", array("no bonus" => 0, 5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 55 => 55), "0", "text", "text");
    table_form_select("Planetary Dig-In factor (Side 1)", "diginp", array("no dig-in" => 0, 20 => 20, 40 => 40, 60 => 60, 65 => 65, 70 => 70, 75 => 75, 80 => 80, 85 => 85, 90 => 90, 95 => 95, 99 => 99), "70", "text", "text");
    table_form_select("Planetary Dig-In bonus (Side 1)", "diginpb", array("no bonus" => 0, 5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 55 => 55), "20", "text", "text");
    table_form_select("Overall combat boost", "boost", array("no boost" => 1, 2 => 2, 3 => 3, 5 => 5), "1", "text", "text");
    table_form_select("Verbosity", "verbosity", array("Results only" => 0, "Overview" => 1, "Full details" => 2), "1", "text", "text");
    table_form_submit("Execute battle", "execute_battle");
    table_end();
    echo "</form>";
    //print "<a href=\"".$_SERVER["PHP_SELF"]."?act=execute_battle\">Execute battle</a>";
}
コード例 #2
0
function mailforms()
{
    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 id from alliance where leader='{$uid}'");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    if (mysql_num_rows($sth) == 0) {
        show_error("You're not leader of an alliance!");
        return 0;
    }
    $aid = mysql_fetch_array($sth);
    $sth = mysql_query("select * from mailforms where aid='" . $aid["id"] . "'");
    if (!$sth) {
        show_error("Database Failure!");
        return 0;
    }
    if (mysql_num_rows($sth) < 3) {
        show_message("You didn't fill out every mailform!");
    }
    $option_arr["Invitation"] = "I";
    $option_arr["Kick"] = "K";
    $option_arr["Resign"] = "R";
    center_headline("Mailforms");
    echo "<form action=\"" . $PHP_SELF . "\" method=post>";
    table_start("center");
    table_form_select("Mailform", "typ", $option_arr);
    table_form_submit("Edit", "edit_mailform");
    table_end();
    echo "</form>";
}
コード例 #3
0
function show_preferences()
{
    global $uid;
    global $skin;
    global $PHP_SELF;
    $sth = mysql_query("select * from skins");
    while ($skins = mysql_fetch_array($sth)) {
        $options[$skins["name"]] = $skins["id"];
    }
    $sth = mysql_query("select admin from users where id={$uid}");
    if (!$sth) {
        show_error("Database failuer!");
        return 0;
    }
    $admin = mysql_fetch_array($sth);
    if ($admin["admin"] != "") {
        show_message("<a href='adminarea.php'>Enter Admin Area</a>");
    }
    $map_info = new map_info($uid);
    if ($map_info->has_map_anims() == 1) {
        $checked = "checked";
    }
    echo "<form method=POST action=\"" . $PHP_SELF . "\">";
    table_start("center", "400");
    table_head_text(array("Appearence"), "2");
    table_text(array("&nbsp;"), "", "", "2", "head");
    table_form_select("Skin", "skin_new", $options, $skin, "head", "text");
    table_form_submit("Change", "change_skin", "", "text");
    table_end();
    echo "</form>\n";
    //runelord: map_sizes
    $sth = mysql_query("select map_size from options where uid=" . $uid);
    if (!$sth || !mysql_num_rows($sth)) {
        show_error("oops, DB Failure");
        return 0;
    }
    list($current_map_size) = mysql_fetch_row($sth);
    $map_sizes_output = "<select name=\"map_size\" size=\"1\">";
    $sth = mysql_query("SELECT * FROM map_sizes ORDER BY width ASC");
    if (!$sth || !mysql_num_rows($sth)) {
        show_error("Database Failureeeeerrerererererere");
        return 0;
    }
    while ($map_sizes = mysql_fetch_array($sth)) {
        if ($current_map_size == $map_sizes["id"]) {
            $map_sizes_output .= "<option selected value=\"" . $map_sizes["id"] . "\">" . $map_sizes["width"] . " : " . $map_sizes["height"] . "</option>";
        } else {
            $map_sizes_output .= "<option value=\"" . $map_sizes["id"] . "\">" . $map_sizes["width"] . " : " . $map_sizes["height"] . "</option>";
        }
    }
    $map_sizes_output .= "</select>";
    echo "<form method=POST action=\"" . $PHP_SELF . "\">";
    table_start("center", "400");
    table_head_text(array("Map Settings"), "2");
    table_text(array("&nbsp;"), "", "", "2", "head");
    table_text(array("Map Size"), "", "", "2", "head");
    table_text(array($map_sizes_output), "", "", "2", "text");
    table_form_submit("Change", "change_map_size", "", "text");
    echo "</form>\n";
    echo "<form method=POST action=\"" . $PHP_SELF . "\">";
    table_text(array("&nbsp;"), "", "", "2", "head");
    table_text(array("Animations (KSVG needs disabled animations)", "<input type=\"checkbox\" name=\"animations\" value=\"1\" {$checked}>"), "", "", "", "head");
    table_form_submit("Change", "change_anims", "", "text");
    table_end();
    echo "</form>\n";
    table_start("center", "400");
    echo "<form method=POST action=\"" . $PHP_SELF . "\">";
    table_text(array("Change Password", "&nbsp;"), "", "", "", "head");
    table_text_open();
    table_text_design("Old Password", "300", "left", "", "text");
    table_text_design("<input type=\"password\" align=\"right\" name=\"old\">", "100", "right", "", "text");
    table_text_close();
    table_text_open();
    table_text_design("New Password", "300", "left", "", "text");
    table_text_design("<input type=\"password\" align=\"right\" name=\"new1\">", "100", "right", "", "text");
    table_text_close();
    table_text_open();
    table_text_design("Re-type new Password", "300", "left", "", "text");
    table_text_design("<input type=\"password\" align=\"right\" name=\"new2\">", "100", "right", "", "text");
    table_text_close();
    table_form_submit("Set", "change_pw", "", "text");
    table_end();
    echo "</form>";
}
コード例 #4
0
function start_mission()
{
    global $id;
    global $uid;
    global $PHP_SELF;
    global $imperium;
    global $pid;
    $sth = mysql_query("select sum(population) from planets where uid={$uid}");
    if (!$sth) {
        show_error("Database error!");
        return 0;
    }
    $pop = mysql_fetch_row($sth);
    $spies = floor($pop[0] / 1000);
    $sth = mysql_query("select sum(count) from covertops where uid={$uid}");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    $count = mysql_fetch_row($sth);
    if ($count[0] == NULL) {
        $count[0] = 0;
    }
    if ($count[0] == 0 and $spies == 0) {
        show_message("You don't have enough population to do any covertops!");
        return 0;
    }
    $sth = mysql_query("select * from covertopsmissions as c , research as r where c.techdepend=r.t_id and r.uid={$uid} and c.id={$id}");
    if (!$sth) {
        show_error("Database error!");
        return 0;
    }
    if (mysql_num_rows($sth) == 0) {
        show_message("bbbblllllllllllll");
        return 0;
    }
    $covertops = mysql_fetch_array($sth);
    if ($spies - $count[0] < $covertops["count"]) {
        show_message("You don't have enough free spies!");
        return 0;
    }
    $sth = mysql_query("select c.id from covertopsmissions as c,ressources as r where c.metal<=r.metal and c.energy<=r.energy and c.mopgas<=r.mopgas and c.erkunum<=r.erkunum and c.gortium<=r.gortium and c.susebloom<=r.susebloom and r.uid={$uid} and c.id={$id}");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    if (mysql_num_rows($sth) == 0) {
        show_error("You don't have enough ressources to start this mission!");
        show_status();
        return 0;
    }
    if ($imperium != "") {
        //$sth=mysql_query("select id from users where imperium='".addslashes($imperium)."' and id!=$uid");
        $sth = mysql_query("select id from users where imperium='" . $imperium . "' and id!={$uid}");
        if (!$sth) {
            show_error("Database error!");
            return 0;
        }
        if (mysql_num_rows($sth) == 0) {
            show_message("Hund! 1");
            return 0;
        }
        if ($covertops["targettype"] == "P" && $pid == "") {
            $sth = mysql_query("select id from users where imperium='{$imperium}'");
            if (!$sth) {
                show_error("Database failure13!");
                return 0;
            }
            $uid_target = mysql_fetch_array($sth);
            $sth = mysql_query("select id,name from planets where uid=" . $uid_target["id"] . " order by name");
            if (!$sth) {
                show_error("Database failure!12");
                return 0;
            }
            while ($planets = mysql_fetch_array($sth)) {
                if ($planets["name"] == "Unnamed") {
                    $planets["name"] = get_planetname($planets["id"]);
                }
                $select[$planets["name"]] = $planets["id"];
            }
            echo "<form action=\"" . $PHP_SELF . "\" method=post>";
            table_start("center", "500");
            table_head_text(array("Mission: " . $covertops["descr"]), "2");
            table_text(array("&nbsp;"), "", "", "2", "center", "head");
            table_text_open("text", "center");
            table_text_design("<img src='arts/idnummer.jpg' width='75' height='50' alt='" . $covertops["descr"] . "'>", "75");
            table_text_design($covertops["descr"], "425");
            table_text_close();
            table_text_open("text", "center");
            table_text_design("Target empire", "75");
            table_text_design($imperium, "425");
            table_text_close();
            table_text_open("text", "center");
            table_text_design("Time", "75");
            table_text_design($covertops["time"], "425");
            table_text_close();
            table_text_open("text", "center");
            table_text_design("Special Info", "75");
            table_text_design("dummy", "425");
            table_text_close();
            table_form_select("Select the targetplanet", "pid", $select, "2", "text", "text");
            table_form_submit("Start", "start_mission", "2", "text");
            table_end();
            form_hidden("imperium", $imperium);
            form_hidden("id", $id);
            echo "</form>";
            table_end();
        } elseif ($covertops["targettype"] == "P") {
            $sth = mysql_query("select id from planets where id={$pid} and uid!={$uid} and uid!=0");
            if (!$sth) {
                show_error("Database failure!1");
                return 0;
            }
            if (mysql_num_rows($sth) == 0) {
                show_error("Hund! 2");
                return 0;
            }
            proc_start_mission($covertops["id"], $uid, $pid);
            show_status();
        } else {
            $sth = mysql_query("select id from users where id!={$uid} and imperium='{$imperium}'");
            if (!$sth) {
                show_error("Database failure1!");
                return 0;
            }
            if (mysql_num_rows($sth) == 0) {
                show_message("Du Klobrillenvergewaltiger!");
                return 0;
            }
            $target_uid = mysql_fetch_array($sth);
            proc_start_mission($covertops["id"], $uid, $target_uid["id"]);
            show_status();
        }
    } else {
        $sth = mysql_query("select imperium from users where id!={$uid} order by imperium");
        if (!$sth) {
            show_error("Database failure!");
            return 0;
        }
        while ($imperiums = mysql_fetch_array($sth)) {
            $select[$imperiums["imperium"]] = $imperiums["imperium"];
        }
        echo "<form action=\"" . $PHP_SELF . "\" method=post>";
        table_start("center", "500");
        table_head_text(array("Mission: " . $covertops["descr"]), "2");
        table_text(array("&nbsp;"), "", "", "2", "head");
        table_text_open("text", "center");
        table_text_design("<img src='arts/o" . $covertops["id"] . ".jpg' width='75' height='50' alt='" . $covertops["descr"] . "'>", "75");
        table_text_design($covertops["descr"], "425");
        table_text_close();
        table_text_open("text", "center");
        table_text_design("Time", "75");
        table_text_design($covertops["time"], "425", "head");
        table_text_close();
        table_text_open("text", "center");
        table_text_design("Special Info", "75");
        table_text_design("dummy", "425", "head");
        table_text_close();
        table_form_select("Select the target empire", "imperium", $select, "", "text", "text");
        table_form_submit("Start", "start_mission", "2", "text");
        table_end();
        form_hidden("id", $id);
        echo "</form>";
    }
}