Beispiel #1
0
function wire($w)
{
    global $wires;
    if ($wires[$w] === NULL) {
        $wires[$w] = (int) gate($w);
    }
    return $wires[$w];
}
function getGate()
{
    $gate = gate();
    return $gate;
}
            echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=susebloom&tid=" . $building["prod_id"] . "\" method=post>";
            table_text(array("Susebloom", $building["susebloom"], "<input type=\"Text\" name=\"new\" value=\"" . $building["susebloom"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text");
            echo "</form>\n";
            echo "<form action=\"" . $PHP_SELF . "?act=edit&table=production&var=description&tid=" . $building["prod_id"] . "\" method=post>";
            table_text(array("Description", $building["description"], "<input type=\"Text\" name=\"new\" value=\"" . $building["description"] . "\"><input type=\"Submit\" name=\"f1\" value=\"set\">"), "", "", "", "text");
            echo "</form>\n";
            echo "<form action=\"" . $PHP_SELF . "?act=del_building&id=" . $building["prod_id"] . "\" method=post>";
            echo "<input type=\"Submit\" name=\"f1\" value=\"Delete building - all active buildings of this type will be deleted too\" disabled>";
            echo "</form>\n";
            table_end();
        }
    }
}
switch ($act) {
    case "enter":
        gate();
        break;
    case "users":
        list_users();
        break;
    case "user_mod":
        user_mod();
        break;
    case "edit":
        edit();
        break;
    case "delete_user":
        delete_user();
        break;
    case "messenges":
        messenges();
    $target_file = $target_dir . basename($fn);
    $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
    if (!empty($fn)) {
        $file = $_FILES['edit_image'];
        $check = getimagesize($_FILES["edit_image"]["tmp_name"]);
        if ($check !== false) {
            $file_path = $target_dir . $file['name'];
            move_uploaded_file($file['tmp_name'], $file_path);
            $image = $file['name'];
            //call function to modify Welcome gate
            updateGate($name, $cost, $image, $id);
        }
    } else {
        updateGateWithoutImage($name, $cost, $id);
    }
    $row = gate();
    $resp = $row;
    echo json_encode($resp);
} elseif (isset($_POST['add_stage_name'])) {
    //adding new stage decoration
    $stageName = $_POST['add_stage_name'];
    $stageCost = $_POST['add_stage_price'];
    $target_dir = '../../assets/img/stage/';
    $fn = $_FILES["add_stage_image"]["name"];
    $target_file = $target_dir . basename($fn);
    $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
    if (!empty($fn)) {
        $file = $_FILES['add_stage_image'];
        $check = getimagesize($_FILES["add_stage_image"]["tmp_name"]);
        if ($check !== false) {
            $file_path = $target_dir . $file['name'];