Пример #1
0
// Include Files
include "includes.inc.php";
session_identification();
if (isset($_GET['user_id'])) {
    $user_id = decrypt_get_vars($_GET['id']);
} else {
    $user_id = user_ourself();
}
if (isset($_GET['zoom'])) {
    $zoom = decrypt_get_vars($_GET['zoom']);
} else {
    $zoom = 0;
}
if (isset($_GET['f'])) {
    $flags = decrypt_get_vars($_GET['f']);
} else {
    $flags = -1;
}
$name_array = array("alpha", "beta", "gamma", "delta");
if (substr($_GALAXY['image'], -4) == ".jpg") {
    $img2 = imagecreatefromjpeg($_CONFIG['PATH'] . $_GALAXY['image_dir'] . "/galaxy/" . $_GALAXY['image']);
    $width_scale = imagesx($img2) / 400;
    $height_scale = imagesy($img2) / 400;
} else {
    $img2 = imagecreatefromgif($_CONFIG['PATH'] . $_GALAXY['image_dir'] . "/galaxy/" . $_GALAXY['image']);
    $width_scale = imagesx($img2) / 400;
    $height_scale = imagesy($img2) / 400;
}
$img = imagecreate(400, 400);
$white = imagecolorallocate($img, 255, 255, 255);
function input_check()
{
    $numargs = func_num_args();
    $arg_list = func_get_args();
    if (!validate_request_checksum()) {
        perihelion_die("Refresh Error", "You can only submit this form once.");
    }
    if (!isset($_REQUEST['cmd'])) {
        perihelion_die("", "No command requested.");
        return "";
    }
    // Command is needed. If not present... whooops.
    $cmd = decrypt_get_vars($_REQUEST['cmd']);
    // Browse through all numargs, check the command, if it is ours, decrypt all vars EXCEPT
    // the ne_* vars
    $i = 0;
    for (;;) {
        $tmp_cmd = $arg_list[$i];
        $i++;
        if ($tmp_cmd != $cmd) {
            while ($arg_list[$i] != "0") {
                $i++;
            }
        } else {
            while ($arg_list[$i] != "0") {
                $tmp_var = $arg_list[$i];
                $GLOBALS[$tmp_var] = "";
                // Error if we can't find a mandatory var
                if (substr($tmp_var, 0, 1) == "!") {
                    $tmp_var = substr($tmp_var, 1, 255);
                    if (!isset($_REQUEST[$tmp_var])) {
                        perihelion_die("Internal Error", "Mandatory var not found: " . $tmp_var);
                    }
                }
                if (isset($_REQUEST[$tmp_var])) {
                    // Check if we need decrypting or not
                    if (substr($tmp_var, 0, 3) == "ne_") {
                        $GLOBALS[$tmp_var] = $_REQUEST[$tmp_var];
                    } else {
                        $GLOBALS[$tmp_var] = decrypt_get_vars($_REQUEST[$tmp_var]);
                    }
                }
                $i++;
            }
            return $tmp_cmd;
        }
        $i++;
        if ($i >= $numargs) {
            break;
        }
    }
    // No command found :(
    if (user_is_admin(user_ourself())) {
        $str = "Illegal or no command requested.<br>Command issued: '{$cmd}'";
    } else {
        $str = "Illegal or no command requested.";
    }
    perihelion_die("Internal Error", $str);
}
Пример #3
0
function validate_passwd($value, $empty, &$params, &$formvars)
{
    $result = sql_query("SELECT PASSWORD('" . $value . "') AS passwd");
    $row = sql_fetchrow($result);
    $encrypted_passwd = $row['passwd'];
    $uid = decrypt_get_vars($formvars['uid']);
    $result = sql_query("SELECT * FROM perihelion.u_users WHERE id=" . $uid);
    if ($row = sql_fetchrow($result)) {
        if ($row['login_pass'] == $encrypted_passwd) {
            return true;
        }
    }
    return false;
}
Пример #4
0
function upgrade_speed($_USER, $vessel_id)
{
    // Get global information
    $user = user_get_user($_USER['id']);
    $result = sql_query("SELECT * FROM g_flags WHERE user_id=" . $_USER['id']);
    $flags = sql_fetchrow($result);
    $vessel = vessel_get_vessel($vessel_id);
    // Show Ship and User Capabilities
    echo "<table align=center border=1>";
    echo "<tr><td>";
    echo "<table width=100% border=0 cellpadding=0 cellspacing=0>";
    echo "<tr><th colspan=2>Current Ship Capabilities</th></tr>";
    echo "<tr><td>Impulse Speed: </td><td>" . $vessel['impulse'] . "%</td></tr>";
    echo "<tr><td>Warp Speed:    </td><td>" . number_format($vessel['warp'] / 10, 1) . "</td></tr>";
    echo "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>";
    echo "</table>";
    echo "</td><td>";
    echo "<table width=100% border=0 cellpadding=0 cellspacing=0>";
    echo "<tr><th colspan=2>User Statistics</th></tr>";
    echo "<tr><td>Credits:</td><td>" . $user['credits'] . "</td></tr>";
    echo "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>";
    echo "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>";
    echo "</table>";
    echo "</td></tr>";
    echo "</table>";
    echo "<br>";
    echo "<br>";
    if ($vessel['impulse'] == $user['impulse'] and $vessel['warp'] == $user['warp']) {
        echo "  <table align=center>";
        echo "    <tr><td>Ship Name:          </td><td>" . $vessel['name'] . "</td></tr>";
        echo "    <tr><td>&nbsp;</td><td>No upgrade Possible</td></tr>";
        echo "  </table>";
    }
    // Stage 1: Create Ship and ship name
    if (!isset($stage) || $stage == 1) {
        form_start();
        echo "<input type=hidden name=vid value={$vid}>";
        echo "  <table align=center>";
        echo "    <tr><td>Ship Name:          </td><td>" . $vessel['name'] . "</td></tr>";
        echo "    <tr><td colspan=2></td></tr>";
        echo "    <tr><td>Impulse speed: </td><td>";
        if ($flags['can_warp'] == 1) {
            echo "<input type=hidden name=impulse value=100>100 % (" . $config['s_impulse_costs'] * 100 . " Credits)";
        } else {
            echo " <select name='impulse'>";
            for ($i = $vessel['impulse'] + 1; $i != $user['impulse'] + 1; $i++) {
                echo "<option value=" . $i . ">" . $i . " % (" . ($i - $vessel['impulse']) * $config['s_impulse_costs'] . " Credits)</option>";
            }
            echo " </select>";
        }
        echo "    </td></tr>";
        echo "    <tr><td>Warp Speed: </td><td>";
        if ($flags['can_warp'] == 1) {
            echo " <select name=warp>";
            for ($i = $vessel['warp'] + 1; $i != $user['warp'] + 1; $i++) {
                echo "<option value=" . $i . "> Warp " . number_format($i / 10, 1) . " (" . ($i - $vessel['warp']) * $config['s_warp_costs'] . " Credits)</option>";
            }
            echo " </select>";
        } else {
            echo "<input type=hidden name=warp value=0>";
            echo "None";
        }
        echo "    </td></tr>";
        echo "    <tr><td>&nbsp;</td><td><input type=submit name=submit value=\"Upgrade Ship\"></td></tr>";
        echo "  </table>";
        form_end();
    }
    //  Stage 2: Add or Delete weaponary
    if ($stage == 2 and ($vessel['type'] == VESSEL_TYPE_TRADE or $vessel['type'] == VESSEL_TYPE_EXPLORE)) {
        $stage = 3;
    }
    if ($stage == 2) {
        // Get all weapons we can view
        $visible_weapons = array();
        $result = sql_query("SELECT * FROM g_weapons WHERE user_id=" . $_USER['id']);
        $visible_weapons = csl_create_array($result, "csl_weapon_id");
        // And dump them into the table
        echo "<table border=1 align=center>";
        echo "<tr><th colspan=8>Weaponary</th></tr>";
        echo "<tr>";
        echo "<th>Name</th>";
        echo "<th>Costs</th>";
        echo "<th>Power</th>";
        echo "<th>Attack</th>";
        echo "<th>Defense</th>";
        echo "<th>Qty</th>";
        echo "<th colspan=2>Action</th>";
        echo "</tr>";
        reset($visible_weapons);
        while (list($key, $weapon_id) = each($visible_weapons)) {
            $result = sql_query("SELECT * FROM s_weapons WHERE id=" . $weapon_id);
            $weapon = sql_fetchrow($result);
            echo "<tr>";
            echo "<td>" . $weapon['name'] . "</td>";
            echo "<td>" . $weapon['costs'] . "</td>";
            echo "<td>" . $weapon['power'] . "</td>";
            echo "<td>" . $weapon['attack'] . "</td>";
            echo "<td>" . $weapon['defense'] . "</td>";
            echo "<td><input type=text size=3 maxlength=3 value=0 name=T1></td>";
            echo "<td><b>Add</b></td>";
            echo "<td><b>Delete</b></td>";
            echo "</tr>";
        }
        echo "</table>";
        echo "<br><br>";
    }
    if ($stage == 3) {
        $ok = "Vessel upgrade in process..\n";
        $errors['PARAMS'] = "Incorrect parameters specified...\n";
        $errors['SPEED'] = "Incorrect speed settings...\n";
        $errors['CREDITS'] = "Not enough credits...\n";
        $data['impulse'] = $_POST['impulse'];
        $data['warp'] = $_POST['warp'];
        $data['vid'] = decrypt_get_vars($_POST['vid']);
        comm_send_to_server("VESSELUPGRADE", $data, $ok, $errors);
    }
}
Пример #5
0
}
// Execute create
if ($cmd == "create2") {
    for ($i = 0; $i != ore_get_ore_count(); $i++) {
        $tmp1 = "src_ore_" . $i;
        $tmp2 = "dst_ore_" . $i;
        if (!isset(${$tmp1})) {
            ${$tmp1} = "";
        }
        if (!isset(${$tmp2})) {
            ${$tmp2} = "";
        }
    }
    $vid = decrypt_get_vars($_POST['vid']);
    $src_pid = decrypt_get_vars($_POST['src_pid']);
    $dst_pid = decrypt_get_vars($_POST['dst_pid']);
    $ok = "";
    $errors['PARAMS'] = "Incorrect parameters specified.";
    $errors['SHORTROUTE'] = "The source and destination planets are the same.";
    $errors['INTRADE'] = "The vessel is already part of a traderoute.";
    $data['vid'] = $vid;
    $data['src_pid'] = $src_pid;
    $data['dst_pid'] = $dst_pid;
    // Nasty misuse of the $_REQUEST here, but since we don't know how many ores we have
    // we make direct use of the $_REQUEST array. Normally this is done by the input_check()
    // function.
    for ($i = 0; $i != ore_get_ore_count(); $i++) {
        $tmp1 = "src_ore_" . $i;
        $tmp2 = "dst_ore_" . $i;
        if (array_key_exists($tmp1, $_REQUEST)) {
            $data[$tmp1] = $_REQUEST[$tmp1];
Пример #6
0
        $f = $_POST['f'];
    } else {
        $f = -1;
    }
} else {
    // Get the zoom
    if (!isset($_GET['zoom'])) {
        $zoom = 0;
    } else {
        $zoom = decrypt_get_vars($_GET['zoom']);
    }
    // Get the flags
    if (!isset($_GET['f'])) {
        $f = -1;
    } else {
        $f = decrypt_get_vars($_GET['f']);
    }
}
// Create flags value from the F array;
$flags = -1;
if ($f != -1) {
    $flags = 0;
    if (is_array($f)) {
        foreach ($f as $idx => $key) {
            $flags += pow(2, $idx);
        }
    } else {
        $flags = $f;
    }
}
form_start();
Пример #7
0
<?php

// Include Files
include "includes.inc.php";
// Session Identification
//session_identification ();
session_start();
// We don't need to be logged in to use the help system i think...
print_header();
print_title("Help", "Here we will try to tell you everything you need to know about Perihelion.");
$topic = decrypt_get_vars($_REQUEST['hid']);
$template = new Smarty();
$result = sql_query("SELECT * FROM perihelion.help WHERE id LIKE '{$topic}'");
if (sql_countrows($result) == 0) {
    $template->assign("help", "");
} else {
    $row = sql_fetchrow($result);
    $template->assign("topic", $topic);
    $template->assign("help", convert_px_to_html_tags($row['help']));
}
$template->display($_RUN['theme_path'] . "/help.tpl");
print_footer();
exit;