示例#1
0
function checkLoginStatus($getPage_connection2)
{
    $loginArray = array("status" => false, "loggingIn" => false);
    $loggingIn = false;
    $resetLoginVars = false;
    $checkCreds = false;
    if (!isset($_SESSION["login"])) {
        $_SESSION["login"] = 0;
    }
    // if
    // if not logged in,
    if ($_SESSION["login"] != 1) {
        // attempting login
        // if login info has been submitted
        if (isset($_POST["username"]) && isset($_POST["password"])) {
            $cleaned_username = cleanString($_POST["username"], true);
            $cleaned_password = cleanString($_POST["password"], true);
            if (strlen($cleaned_username) >= 1 && strlen($cleaned_password) >= 1) {
                $loggingIn = true;
            }
            // if
        }
        // if
        if ($loggingIn === true) {
            $userInfo1 = getUserInfoByName($getPage_connection2, $cleaned_username);
            if ($userInfo1["id"] >= 1) {
                $final_salt = '$2y$09$' . $userInfo1["salt"] . '$';
                $created_password = crypt($cleaned_password . $userInfo1["salt"], $final_salt);
                $created_string = hash('sha512', $created_password . $userInfo1["token"]);
                $actual_string = hash('sha512', $userInfo1["password"] . $userInfo1["token"]);
                if ($actual_string == $created_string) {
                    $_SESSION["user_id"] = $userInfo1["id"];
                    $_SESSION["username"] = $cleaned_username;
                    $_SESSION["login_string"] = $created_string;
                    $_SESSION["login"] = 1;
                    $_SESSION["nation_id"] = $userInfo1["id"];
                    $_SESSION["admin"] = $userInfo1["admin"];
                    $new_date = date("Y-m-d H:i:s");
                    $nationInfoLogin = getNationInfo($getPage_connection2, $_SESSION["nation_id"]);
                    setUserInfo($getPage_connection2, $userInfo1["id"], $userInfo1["name"], $userInfo1["avatar"], $userInfo1["joined"], $new_date, $userInfo1["password"], $userInfo1["salt"], $userInfo1["token"], $userInfo1["thread"], $userInfo1["admin"]);
                    $_SESSION["success_message"] = "User has logged in successfully!";
                    $_SESSION["pageTypeInfo"] = getPageTypeInfo($getPage_connection2, "map");
                    $loginArray["status"] = true;
                    $loginArray["loggingIn"] = true;
                    $_POST["continent"] = $nationInfoLogin["home"];
                    $_SESSION["continent_id"] = $nationInfoLogin["home"];
                    $_SESSION["nation_id"] = $nationInfoLogin["id"];
                    $_SESSION["prev_xpos"] = 1;
                    $_SESSION["prev_ypos"] = 1;
                    $_SESSION["xpos"] = 1;
                    $_SESSION["ypos"] = 1;
                    $_POST["overlay"] = "nations";
                    $_GET["overlay"] = "nations";
                    $_SESSION["prev_overlay"] = "nations";
                    $_SESSION["overlay"] = "nations";
                    $mapMemoryInfo = getMapMemoryInfo($getPage_connection2, $_SESSION["user_id"]);
                    $_SESSION["terrainMapContents"] = $mapMemoryInfo["terrain"];
                    $_SESSION["terrainMapContentsTokens"] = $mapMemoryInfo["terraintokens"];
                    $_SESSION["controlMapContents"] = $mapMemoryInfo["control"];
                    $_SESSION["controlMapContentsTokens"] = $mapMemoryInfo["controltokens"];
                    $_SESSION["claimsMapContents"] = $mapMemoryInfo["claims"];
                    $_SESSION["claimsMapContentsTokens"] = $mapMemoryInfo["claimstokens"];
                    $_SESSION["unitsMapContents"] = $mapMemoryInfo["units"];
                    $_SESSION["unitsMapContentsTokens"] = $mapMemoryInfo["unitstokens"];
                    $_SESSION["nationsMapContents"] = $mapMemoryInfo["nations"];
                    $_SESSION["nationsMapContentsTokens"] = $mapMemoryInfo["nationstokens"];
                } else {
                    $resetLoginVars = true;
                    $_SESSION["warning_message"] = "Cannot complete action: invalid user password credentials submitted.";
                }
                // else
            } else {
                $resetLoginVars = true;
                $_SESSION["warning_message"] = "Cannot complete action: invalid user name credentials submitted.";
            }
            // else
        } else {
            $resetLoginVars = true;
        }
        // else
    } else {
        $resetLoginVars = false;
        $checkCreds = true;
    }
    // else
    if ($checkCreds === true) {
        // check creds 50% of time...
        $rand_cred = mt_rand(1, 10);
        if ($rand_cred > 5) {
            // checking for login details match
            if (isset($_SESSION["login_string"])) {
                if (isset($_SESSION["user_id"])) {
                    $userInfo1 = array("id" => 0, "name" => "", "password" => "", "salt" => "", "token" => 0, "thread" => 0, "admin" => 0);
                    if ($stmt654 = $getPage_connection2->prepare("SELECT id,name,password,salt,token,thread,admin FROM users WHERE id=? LIMIT 1")) {
                        $stmt654->bind_param("i", $_SESSION["user_id"]);
                        $stmt654->execute();
                        $stmt654->bind_result($r_id, $r_name, $r_password, $r_salt, $r_token, $r_thread, $r_admin);
                        $stmt654->fetch();
                        $userInfo1["id"] = $r_id;
                        $userInfo1["name"] = $r_name;
                        $userInfo1["password"] = $r_password;
                        $userInfo1["salt"] = $r_salt;
                        $userInfo1["token"] = $r_token;
                        $userInfo1["thread"] = $r_thread;
                        $userInfo1["admin"] = $r_admin;
                        $stmt654->close();
                    } else {
                        $resetLoginVars = true;
                    }
                    // else
                    // if match, assign user details
                    if ($_SESSION["login_string"] == hash('sha512', $userInfo1["password"] . $userInfo1["token"])) {
                        $_SESSION["login"] = 1;
                        $loginArray["status"] = true;
                        $loginArray["loggingIn"] = false;
                        $_SESSION["success_message"] = "";
                        $_SESSION["user_id"] = $userInfo1["id"];
                        // unique ID number of user
                        $_SESSION["username"] = $userInfo1["name"];
                        // unique string name of user
                        $_SESSION["nation_id"] = $userInfo1["id"];
                        // nation
                        $_SESSION["admin"] = $userInfo1["admin"];
                        // admin
                    } else {
                        $resetLoginVars = true;
                    }
                    // else
                } else {
                    $resetLoginVars = true;
                }
                // else
            } else {
                $resetLoginVars = true;
            }
            // else
        } else {
            $_SESSION["login"] = 1;
            $loginArray["status"] = true;
            $loginArray["loggingIn"] = false;
            $resetLoginVars = false;
        }
        // else
    }
    // if
    if ($resetLoginVars === true) {
        $_SESSION["login"] = 0;
        $loginArray["status"] = false;
        $loginArray["loggingIn"] = false;
        $_SESSION["success_message"] = "";
        $_SESSION["user_id"] = 0;
        $_SESSION["username"] = "";
        $_SESSION["nation_id"] = 0;
        $_SESSION["admin"] = 0;
        $resetLoginVars = false;
    }
    // if
    return $loginArray;
}
function deactivateAccount($getPage_connection2)
{
    if ($_SESSION["action"] == "yes") {
        if (strlen($_SESSION["current_password"]) > 0) {
            $userInfo1 = getUserInfoByName($getPage_connection2, $_SESSION["username"]);
            if ($userInfo1["id"] >= 1) {
                $final_salt = '$2y$09$' . $userInfo1["salt"] . '$';
                $created_password = crypt($_SESSION["current_password"] . $userInfo1["salt"], $final_salt);
                $created_string = hash('sha512', $created_password . $userInfo1["token"]);
                $actual_string = hash('sha512', $userInfo1["password"] . $userInfo1["token"]);
                if ($actual_string == $created_string) {
                    // setup inaccessible passwords
                    setUserInfo($getPage_connection2, $userInfo1["id"], $userInfo1["name"], $userInfo1["avatar"], $userInfo1["joined"], $userInfo1["lastplayed"], "aaaaaaab", "aaaaaaab", 1212, $userInfo1["thread"], $userInfo1["admin"]);
                    resetSession(false);
                    $_SESSION["success_message"] = "User de-activation has been registered successfully!";
                } else {
                    $_SESSION["warning_message"] = "Cannot complete action: invalid user password credentials submitted.";
                }
                // else
            } else {
                $_SESSION["warning_message"] = "Cannot complete action: invalid user submitted.";
            }
            // else
        } else {
            $_SESSION["warning_message"] = "Cannot complete action: invalid user password credentials submitted.";
        }
        // else
    } else {
        $_SESSION["warning_message"] = "Cannot complete action: invalid action.";
    }
    // else
}
function changeSettings($getPage_connection2)
{
    if ($_SESSION["action"] == "change") {
        if (strlen($_SESSION["current_password"]) > 0) {
            $userInfo1 = getUserInfoByName($getPage_connection2, $_SESSION["username"]);
            if ($userInfo1["id"] >= 1) {
                $final_salt = '$2y$09$' . $userInfo1["salt"] . '$';
                $created_password = crypt($_SESSION["current_password"] . $userInfo1["salt"], $final_salt);
                $created_string = hash('sha512', $created_password . $userInfo1["token"]);
                $actual_string = hash('sha512', $userInfo1["password"] . $userInfo1["token"]);
                if ($actual_string == $created_string) {
                    if ($_SESSION["setting_password"] == $_SESSION["setting_password_confirm"]) {
                        if (strlen($_SESSION["setting_password"]) >= 8 && strlen($_SESSION["setting_password"]) <= 35 && (strlen($_SESSION["setting_password_confirm"]) >= 8 && strlen($_SESSION["setting_password_confirm"]) <= 35)) {
                            $new_salt = "";
                            $allowed_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./';
                            $chars_length = 63;
                            for ($i = 0; $i < 51; $i++) {
                                $new_salt .= $allowed_chars[mt_rand(0, $chars_length)];
                            }
                            // for
                            $new_token = mt_rand(1000, 9999);
                            $final_salt = '$2y$09$' . $new_salt . '$';
                            $created_password = crypt($_SESSION["setting_password"] . $new_salt, $final_salt);
                            setUserInfo($getPage_connection2, $userInfo1["id"], $userInfo1["name"], $userInfo1["avatar"], $userInfo1["joined"], $userInfo1["lastplayed"], $created_password, $new_salt, $new_token, $userInfo1["thread"], $userInfo1["admin"]);
                            $created_string2 = hash('sha512', $created_password . $new_token);
                            $_SESSION["user_id"] = $userInfo1["id"];
                            $_SESSION["username"] = $userInfo1["name"];
                            $_SESSION["login_string"] = $created_string2;
                            $_SESSION["login"] = 1;
                            $_SESSION["nation_id"] = $userInfo1["id"];
                            $_SESSION["admin"] = $userInfo1["admin"];
                            $_SESSION["pageTypeInfo"] = getPageTypeInfo($getPage_connection2, "map");
                            $_SESSION["success_message"] = "User has been updated successfully!";
                        } else {
                            $_SESSION["warning_message"] = "Cannot complete action: New password must be 8-35 characters.";
                        }
                        // else
                    } else {
                        $_SESSION["warning_message"] = "Cannot complete action: new password not submitted correctly.  Check to make sure both new password fields are identically submitted.";
                    }
                    // else
                } else {
                    $_SESSION["warning_message"] = "Cannot complete action: invalid user password credentials submitted.";
                }
                // else
            } else {
                $_SESSION["warning_message"] = "Cannot complete action: invalid user submitted.";
            }
            // else
        } else {
            $_SESSION["warning_message"] = "Cannot complete action: invalid user password credentials submitted.";
        }
        // else
    } else {
        $_SESSION["warning_message"] = "Cannot complete action: invalid action.";
    }
    // else
}
function registerUser($getPage_connection2)
{
    if ($_SESSION["action"] == "register") {
        if (strlen($_SESSION["register_username"]) >= 5 && strlen($_SESSION["register_username"]) <= 35) {
            if (strlen($_SESSION["register_password"]) >= 8 && strlen($_SESSION["register_password"]) <= 35 && strlen($_SESSION["register_confirm_password"]) >= 8 && strlen($_SESSION["register_confirm_password"]) <= 35) {
                if ($_SESSION["register_confirm_password"] == $_SESSION["register_password"]) {
                    $userInfoA = getUserInfoByName($getPage_connection2, $_SESSION["register_username"]);
                    if ($userInfoA["id"] >= 1) {
                        $_SESSION["warning_message"] = "Cannot complete action: Username is already in use.";
                    } else {
                        $new_salt = "";
                        $new_username = $_SESSION["register_username"];
                        $new_avatar = "images/users/avatar.png";
                        $allowed_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./';
                        $chars_length = 63;
                        for ($i = 0; $i < 51; $i++) {
                            $new_salt .= $allowed_chars[mt_rand(0, $chars_length)];
                        }
                        // for
                        $new_date = date("Y-m-d H:i:s");
                        $new_token = mt_rand(1000, 9999);
                        $new_thread = mt_rand(100, 999);
                        $final_salt = '$2y$09$' . $new_salt . '$';
                        $created_password = crypt($_SESSION["register_password"] . $new_salt, $final_salt);
                        addUserInfo($getPage_connection2, $new_username, $new_avatar, $new_date, $new_date, $created_password, $new_salt, $new_token, $new_thread, 0);
                        $new_userid = $getPage_connection2->insert_id;
                        $new_name = $_SESSION["register_nation"];
                        $new_formal = $_SESSION["register_formal"];
                        addProductionInfo($getPage_connection2, $new_userid, 100, array(0 => 2, 1 => 2, 2 => 2, 3 => 2, 4 => 2, 5 => 2, 6 => 2, 7 => 2), array(0 => 2, 1 => 2, 2 => 2, 3 => 2, 4 => 2, 5 => 2, 6 => 2, 7 => 2));
                        addRankingInfo($getPage_connection2, $new_userid, 999, 999, 999, 999, 999);
                        $new_routes = array(0 => 0);
                        $new_worth = array(0 => 0);
                        $new_offers = array(0 => 0);
                        addTradeInfo($getPage_connection2, $new_userid, $new_routes, 0);
                        $capitalBuilt = false;
                        $availableTiles = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0);
                        $finalTiles = array(0 => 0, 1 => 0);
                        $availableContinent = 0;
                        if ($stmt = $getPage_connection2->prepare("SELECT id FROM continents ORDER BY id ASC")) {
                            $stmt->execute();
                            $stmt->store_result();
                            $stmt->bind_result($r_id);
                            while ($stmt->fetch()) {
                                $next_continents = $r_id;
                                $availableTiles = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0);
                                $counter1 = 0;
                                if ($stmt2 = $getPage_connection2->prepare("SELECT id FROM tilesmap ORDER BY id ASC")) {
                                    $stmt2->execute();
                                    $stmt2->store_result();
                                    $stmt2->bind_result($r_id1);
                                    while ($stmt2->fetch()) {
                                        $next_tiles = $r_id1;
                                        $tileInfoD = getTileInfoByID($getPage_connection2, $next_tiles);
                                        if ($tileInfoD["continent"] == $next_continents && $tileInfoD["owner"] == 0 && $tileInfoD["terrain"] != 2) {
                                            $tileInfoDWest = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"]);
                                            $tileInfoDNorthWest = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] - 1);
                                            $tileInfoDNorth = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] - 1);
                                            $tileInfoDNorthEast = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"] - 1);
                                            $tileInfoDEast = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"]);
                                            $tileInfoDSouthEast = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"] + 1);
                                            $tileInfoDSouth = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"], $tileInfoD["ypos"] + 1);
                                            $tileInfoDSouthWest = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] + 1);
                                            if ($tileInfoDWest["continent"] == $next_continents && $tileInfoDWest["owner"] == 0 && $tileInfoDWest["terrain"] != 2 || $tileInfoDNorthWest["continent"] == $next_continents && $tileInfoDNorthWest["owner"] == 0 && $tileInfoDNorthWest["terrain"] != 2 || $tileInfoDNorth["continent"] == $next_continents && $tileInfoDNorth["owner"] == 0 && $tileInfoDNorth["terrain"] != 2 || $tileInfoDNorthEast["continent"] == $next_continents && $tileInfoDNorthEast["owner"] == 0 && $tileInfoDNorthEast["terrain"] != 2 || $tileInfoDEast["continent"] == $next_continents && $tileInfoDEast["owner"] == 0 && $tileInfoDEast["terrain"] != 2 || $tileInfoDSouthEast["continent"] == $next_continents && $tileInfoDSouthEast["owner"] == 0 && $tileInfoDSouthEast["terrain"] != 2 || $tileInfoDSouth["continent"] == $next_continents && $tileInfoDSouth["owner"] == 0 && $tileInfoDSouth["terrain"] != 2 || $tileInfoDSouthWest["continent"] == $next_continents && $tileInfoDSouthWest["owner"] == 0 && $tileInfoDSouthWest["terrain"] != 2) {
                                                $availableTiles[$counter1] = $tileInfoD["id"];
                                                $counter1++;
                                            }
                                            // if
                                        }
                                        // if
                                        if ($counter1 == 4) {
                                            $availableContinent = $next_continents;
                                        }
                                        // if
                                    }
                                    // while
                                    $stmt2->close();
                                } else {
                                }
                                // else
                                if ($counter1 == 4) {
                                    break;
                                }
                                // if
                            }
                            // while
                            $stmt->close();
                        } else {
                        }
                        // else
                        // get available tiles from newly created continent if no continent is available
                        if ($availableContinent < 1) {
                            $continent1 = generateContinent($getPage_connection2);
                            $next_continents = $continent1;
                            $availableContinent = $next_continents;
                            $availableTiles = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0);
                            $next_tiles = 1;
                            $counter1 = 0;
                            if ($stmt = $getPage_connection2->prepare("SELECT id FROM tilesmap ORDER BY id ASC")) {
                                $stmt->execute();
                                $stmt->store_result();
                                $stmt->bind_result($r_id);
                                while ($stmt->fetch()) {
                                    $next_tiles = $r_id;
                                    $tileInfoD = getTileInfoByID($getPage_connection2, $next_tiles);
                                    if ($tileInfoD["continent"] == $next_continents && $tileInfoD["owner"] == 0 && ($tileInfoD["terrain"] != 2 && $tileInfoD["terrain"] != 3)) {
                                        $tileInfoDWest = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"]);
                                        $tileInfoDNorthWest = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] - 1);
                                        $tileInfoDNorth = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] - 1);
                                        $tileInfoDNorthEast = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"] - 1);
                                        $tileInfoDEast = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"]);
                                        $tileInfoDSouthEast = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"] + 1);
                                        $tileInfoDSouth = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"], $tileInfoD["ypos"] + 1);
                                        $tileInfoDSouthWest = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] + 1);
                                        if ($tileInfoDWest["continent"] == $next_continents && $tileInfoDWest["owner"] == 0 && ($tileInfoDWest["terrain"] != 2 && $tileInfoDWest["terrain"] != 3) || $tileInfoDNorthWest["continent"] == $next_continents && $tileInfoDNorthWest["owner"] == 0 && ($tileInfoDNorthWest["terrain"] != 2 && $tileInfoDNorthWest["terrain"] != 3) || $tileInfoDNorth["continent"] == $next_continents && $tileInfoDNorth["owner"] == 0 && ($tileInfoDNorth["terrain"] != 2 && $tileInfoDNorth["terrain"] != 3) || $tileInfoDNorthEast["continent"] == $next_continents && $tileInfoDNorthEast["owner"] == 0 && ($tileInfoDNorthEast["terrain"] != 2 && $tileInfoDNorthEast["terrain"] != 3) || $tileInfoDEast["continent"] == $next_continents && $tileInfoDEast["owner"] == 0 && ($tileInfoDEast["terrain"] != 2 && $tileInfoDEast["terrain"] != 3) || $tileInfoDSouthEast["continent"] == $next_continents && $tileInfoDSouthEast["owner"] == 0 && ($tileInfoDSouthEast["terrain"] != 2 && $tileInfoDSouthEast["terrain"] != 3) || $tileInfoDSouth["continent"] == $next_continents && $tileInfoDSouth["owner"] == 0 && ($tileInfoDSouth["terrain"] != 2 && $tileInfoDSouth["terrain"] != 3) || $tileInfoDSouthWest["continent"] == $next_continents && $tileInfoDSouthWest["owner"] == 0 && ($tileInfoDSouthWest["terrain"] != 2 && $tileInfoDSouthWest["terrain"] != 3)) {
                                            $availableTiles[$counter1] = $tileInfoD["id"];
                                            $counter1++;
                                        }
                                        // if
                                    }
                                    // if
                                }
                                // while
                                $stmt->close();
                            } else {
                            }
                            // else
                        }
                        // if
                        $sameTile = true;
                        $randTiles = array(0 => 0, 1 => 0);
                        while ($sameTile === true) {
                            $randTiles[0] = mt_rand(1, count($availableTiles) - 2);
                            $randDirection = mt_rand(1, 2);
                            if ($randDirection == 1) {
                                $randTiles[1] = $randTiles[0] - 1;
                            } else {
                                if ($randDirection == 2) {
                                    $randTiles[1] = $randTiles[0] + 1;
                                }
                            }
                            // else if
                            if ($randTiles[0] == $randTiles[1]) {
                                $sameTile = true;
                            } else {
                                $sameTile = false;
                            }
                            // else
                        }
                        // while
                        $finalTiles[0] = $availableTiles[$randTiles[0]];
                        $finalTiles[1] = $availableTiles[$randTiles[1]];
                        $claims = array(0 => 0);
                        for ($c = 0; $c < 3; $c++) {
                            if (isset($finalTiles[$c])) {
                                if ($finalTiles[$c] > 0) {
                                    addClaimInfo($getPage_connection2, 10, $new_userid, $finalTiles[$c]);
                                }
                                // if
                            }
                            // if
                        }
                        // for
                        for ($j = 0; $j < 3; $j++) {
                            if (isset($finalTiles[$j])) {
                                if ($finalTiles[$j] > 0) {
                                    $tileInfo2 = getTileInfoByID($getPage_connection2, $finalTiles[$j]);
                                    setTileInfo($getPage_connection2, $tileInfo2["id"], $tileInfo2["continent"], $tileInfo2["xpos"], $tileInfo2["ypos"], $tileInfo2["terrain"], $tileInfo2["resources"], $tileInfo2["improvements"], $new_userid, $tileInfo2["claims"], $tileInfo2["population"]);
                                    if ($capitalBuilt === false) {
                                        addImprovementInfo($getPage_connection2, $tileInfo2["continent"], $tileInfo2["xpos"], $tileInfo2["ypos"], 1, 1, array(0 => 0), array(0 => $new_userid), "Capital City");
                                        // add capital
                                        addImprovementInfo($getPage_connection2, $tileInfo2["continent"], $tileInfo2["xpos"], $tileInfo2["ypos"], 4, 1, array(0 => 0), array(0 => $new_userid), "First Farm");
                                        // add farm
                                        $capitalBuilt = true;
                                    }
                                    // if
                                }
                                // if
                            }
                            // if
                        }
                        // for
                        addNationInfo($getPage_connection2, $new_userid, $new_name, $availableContinent, $new_formal, "", 12, 5000, 0, 3, 2500, 5, 0, 5, 0, array(0 => 0), array(0 => 0), array(0 => 5, 1 => 0, 2 => 0, 3 => 5, 4 => 2, 5 => 5, 6 => 0, 7 => 5), array(0 => 5, 1 => 5, 2 => 5, 3 => 5), 2000, 0);
                        // go through y positions
                        for ($y = 1; $y < 21; $y++) {
                            // go through x positions
                            for ($x = 1; $x < 21; $x++) {
                                $mapContentString = "";
                                $mapContentToken = 0;
                                for ($qw = 0; $qw < 5; $qw++) {
                                    if ($qw == 0) {
                                        $_SESSION["overlay"] = "terrain";
                                    } else {
                                        if ($qw == 1) {
                                            $_SESSION["overlay"] = "control";
                                        } else {
                                            if ($qw == 2) {
                                                $_SESSION["overlay"] = "claims";
                                            } else {
                                                if ($qw == 3) {
                                                    $_SESSION["overlay"] = "units";
                                                } else {
                                                    if ($qw == 4) {
                                                        $_SESSION["overlay"] = "nations";
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    // else if
                                    $mapContent_generated = array("", 0);
                                    $mapContent_generated = generateMapTile($getPage_connection2, $availableContinent, $x, $y);
                                    $mapContentString = $mapContent_generated[0];
                                    $mapContentToken = $mapContent_generated[1];
                                    $_SESSION["terrainMapContentsTokens"] = array(0);
                                    $_SESSION["terrainMapContents"] = array(0);
                                    $_SESSION["controlMapContentsTokens"] = array(0);
                                    $_SESSION["controlMapContents"] = array(0);
                                    $_SESSION["claimsMapContentsTokens"] = array(0);
                                    $_SESSION["claimsMapContents"] = array(0);
                                    $_SESSION["unitsMapContentsTokens"] = array(0);
                                    $_SESSION["unitsMapContents"] = array(0);
                                    $_SESSION["nationsMapContentsTokens"] = array(0);
                                    $_SESSION["nationsMapContents"] = array(0);
                                    if ($_SESSION["overlay"] == "terrain") {
                                        $_SESSION["terrainMapContentsTokens"][$y][$x] = $mapContentToken;
                                        $_SESSION["terrainMapContents"][$y][$x] = $mapContentString;
                                    } else {
                                        if ($_SESSION["overlay"] == "control") {
                                            $_SESSION["controlMapContentsTokens"][$y][$x] = $mapContentToken;
                                            $_SESSION["controlMapContents"][$y][$x] = $mapContentString;
                                        } else {
                                            if ($_SESSION["overlay"] == "claims") {
                                                $_SESSION["claimsMapContentsTokens"][$y][$x] = $mapContentToken;
                                                $_SESSION["claimsMapContents"][$y][$x] = $mapContentString;
                                            } else {
                                                if ($_SESSION["overlay"] == "units") {
                                                    $_SESSION["unitsMapContentsTokens"][$y][$x] = $mapContentToken;
                                                    $_SESSION["unitsMapContents"][$y][$x] = $mapContentString;
                                                } else {
                                                    if ($_SESSION["overlay"] == "nations") {
                                                        $_SESSION["nationsMapContentsTokens"][$y][$x] = $mapContentToken;
                                                        $_SESSION["nationsMapContents"][$y][$x] = $mapContentString;
                                                    } else {
                                                        $_SESSION["nationsMapContentsTokens"][$y][$x] = $mapContentToken;
                                                        $_SESSION["nationsMapContents"][$y][$x] = $mapContentString;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    // else
                                }
                                // for
                            }
                            // for
                        }
                        // for
                        addMapMemoryInfo($getPage_connection2, $new_userid, $_SESSION["terrainMapContents"], $_SESSION["controlMapContents"], $_SESSION["claimsMapContents"], $_SESSION["unitsMapContents"], $_SESSION["nationsMapContents"], $_SESSION["terrainMapContentsTokens"], $_SESSION["controlMapContentsTokens"], $_SESSION["claimsMapContentsTokens"], $_SESSION["unitsMapContentsTokens"], $_SESSION["nationsMapContentsTokens"]);
                        $_SESSION["success_message"] = "User has been registered successfully!";
                    }
                    // else
                } else {
                    $_SESSION["warning_message"] = "Cannot complete action: Passwords are not matching, double check your password fields.";
                }
                // else
            } else {
                $_SESSION["warning_message"] = "Cannot complete action: Password must be 8-35 characters.";
            }
            // else
        } else {
            $_SESSION["warning_message"] = "Cannot complete action: Username must be 8-35 characters.";
        }
        // else
    } else {
        $_SESSION["warning_message"] = "Cannot complete action: registration is invalid.";
    }
    // else
}