Exemple #1
0
function petInfoSetup()
{
    include '../library/server.config.php';
    include_once '../library/opendb.php';
    $string = file_get_contents("../library/pet-types.json");
    $pet_type = json_decode($string, true);
    $db_socket = initSocket();
    $query = "SELECT * FROM " . $configValue['DB_TEAM_TABLE'] . " WHERE id = '" . $_SESSION['curr_id'] . "'";
    $statement = $db_socket->prepare($query);
    $statement->execute();
    if ($statement->rowCount() == 1) {
        //we have pet info in this scope
        $res = $statement->fetchAll();
        for ($i = 1; $i < 5; $i++) {
            $pet_query = "SELECT * FROM " . $configValue['DB_PET_TABLE'] . " WHERE id = '" . $res[0][$i] . "'";
            $pet_stmt = $db_socket->prepare($pet_query);
            $pet_stmt->execute();
            if ($pet_stmt->rowCount() == 1) {
                //we have base pet info at this scope; base stats, equip coordinates
                $pet_res = $pet_stmt->fetchAll();
                $img_uri = $pet_type[$pet_res[0]['type']]['base_img'];
                echo "<div class='pet-select'><img src='http://" . $_SERVER['HTTP_HOST'] . '/' . $img_uri . "' width='100' height='100' />";
                echo "<p>" . $pet_res[0]['name'] . "</p></div>";
            }
        }
    }
    include '../library/closedb.php';
}
Exemple #2
0
function getName()
{
    #currently dont use this function, we need a seperate db other that auth_list to handle
    #non authorization reqlike getting a character name
    include __DIR__ . 'opendb.php';
    $db_socket = initSocket();
    $query = "SELECT charname FROM " . $configValue['DB_USER_TABLE'] . " WHERE id = '" . $_SESSION['curr_id'] . "'";
    $statement = $db_socket->prepare($query);
    $statement->execute();
    if ($statement->rowCount() == 1) {
        $res = $statement->fetchAll();
        echo $res[0]['charname'];
    } else {
        echo '{NO ENTRY}';
    }
    include 'closedb.php';
    return;
}
Exemple #3
0
    $json["shop_ary"] = [];
    for ($i = 0; $i < count($item_json["items"]); $i++) {
        if ($item_json["items"][$i]["rarity"] == "common") {
            array_push($json["shop_ary"], $item_json["items"][$i]);
        }
    }
    echo json_encode($json);
}
//api call to purchase an item
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $string = file_get_contents("../library/item-types.json");
    $item_json = json_decode($string, true);
    //includes for db/variables
    include '../library/server.config.php';
    include_once '../library/opendb.php';
    $db_socket = initSocket();
    $json['error'] = [];
    $target_item = $item_json['items'][$_POST['item_id']];
    if (isset($_POST['user_id'])) {
        $price = $target_item['price'];
        //first check if user has enough neo-shekels to purchase
        $query = "SELECT currency FROM " . $configValue['DB_USER_TABLE'] . " WHERE id=" . $_POST['user_id'];
        $statement = $db_socket->prepare($query);
        $statement->execute();
        if ($statement->rowCount() == 1) {
            $res = $statement->fetchAll();
            if ($price > $res[0]['currency']) {
                $diff = $price - $res[0]['currency'];
                array_push($json['error'], "Not enough neo-shekels! You are short " . $diff . ".");
            } else {
                //make sure there is an empty inv slot