} else { $query = new GameQuery(); $game = $query->findOneByName($_GET["name"]); if ($game == null) { header("Location: /"); /* Redirect browser */ exit; } } if (!array_key_exists("platform", $_GET)) { $platform = "windows"; } else { $platform = $_GET["platform"]; } $query = new PlatformQuery(); $platform = $query->findOneByName($platform); if ($platform == null) { throw new Exception("Invalid platform specified"); } // Getting the rating queries the database each time, so we do it once here: $header = $game->getRatingHeaderForPlatform($platform); $rating = $game->getRatingForPlatform($platform); $user = Auth::getCurrentUser(); if (Auth::checkIfAuthenticated() && array_key_exists("submit_game_review", $_POST) && array_key_exists("submit_game_rating", $_POST)) { $new_review = $_POST["submit_game_review"]; $new_rating = $_POST["submit_game_rating"]; $review = UserReview::getUserReview($game, $platform, $user); if ($review == null) { $review = new UserReview(); $review->setGame($game); $review->setPlatform($platform);