| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- /**
- * File for changing the game mode.
- *
- * Implements an action function to be called from the {@see Controller}.
- *
- * @category Action
- */
- /**
- * Sets the score for a team.
- *
- * Reads the POST parameters looking for the following KEYS:
- * player
- * team
- * score
- * Validates the data and sets the score.
- *
- * @return int 201 on success, HTTP error codes on failure.
- * @category Action
- */
- function action(){
- $player = filter_input(INPUT_GET, "player");
- $mode = filter_input(INPUT_GET, "mode");
- if (mode != GAME_MODE_ID::NORMAL && mode != GAME_MODE_ID::RTA){
- return 400;
- }
- $statement = get_context()->get_db()->prepare("
- UPDATE player
- SET mode = :mode
- WHERE id = :id;
- ");
- $statement->bindValue(":mode", $mode, SQLITE3_TEXT);
- $statement->bindValue(":id", $player, SQLITE3_TEXT);
- $statement->execute();
- header("HTTP/1.1 201 OK");
- die();
- return 201;
- }
|