<?php require_once "lib/load.php"; if (!require_params("id", "action")) { die; } $action = $_REQUEST["action"]; $game = Game::loadGame($_REQUEST["id"]); switch ($action) { case 'up': case 'down': case 'left': case 'right': echo json_encode($game->move($action)); break; default: throw new Exception("Unknown action."); break; }
<?php User::requireLoggedIn(); if (require_params("new")) { Game::newGame($_REQUEST["new"]); } if (require_params("reset_dungeon")) { $game = Game::load(); $game->delete(); header("Location: /game"); die; } if (require_params("reset_messages")) { $_SESSION["user"]->json_data["read_messages"] = array(); $_SESSION["user"]->save(); header("Location: /game"); die; } if (true) { $game = Game::load(); ?> <h2><?php echo $game->name; ?> </h2> <a href="?reset_dungeon=true">Reset dungeon</a> <a href="?reset_messages=true">Reset read messages</a> <div id="game-container" class="game-tile"></div> <script type="text/javascript"> TLOR.setup($('#game-container'), <?php
<?php require_once "lib/load.php"; $redirect = "/"; if (isset($_SERVER["HTTP_REFERER"])) { $redirect = $_SERVER["HTTP_REFERER"]; } if (require_params("username", "password")) { $user = User::login($_REQUEST["username"], $_REQUEST["password"]); $redirect = "/game"; } header("Location: " . $redirect);
<?php if (require_params("username", "email", "password") && Captcha::validate($_POST)) { $user = User::create($_REQUEST["username"], $_REQUEST["email"], $_REQUEST["password"]); if ($user) { $_SESSION["user"] = $user; ?> <script type="text/javascript">window.location="/game";</script><?php } } $captcha = new Captcha(); $captcha->generateCaptcha(); ?> <h2>Register</h2> <form id="register" method="POST"> <table> <tr> <td><label for="username">Username</label></td> <td><input id="username" name="username" type="text" placeholder="Username" /></td> </tr> <tr> <td><label for="email">Email</label></td> <td><input id="email" name="email" type="email" placeholder="Email" /></td> </tr> <tr> <td><label for="password">Password</label></td> <td><input id="password" name="password" type="password" placeholder="Password" /></td> </tr> <tr>
function require_get_params($keys) { require_params($keys, $_GET, 'GET'); }