public static function getMapByName($name) { $validKeys = array("africa" => "Africa", "antartica" => "Antartica", "asia" => "Asia", "australia" => "Australia", "europe" => "Europe", "north-america" => "North America", "south-america" => "South America"); if (!array_key_exists($name, $validKeys)) { return false; } $name = MapDatabase::sanitize($name); $selectQuery = "SELECT * FROM Maps WHERE mapName=:name"; try { # Get Database $db = Database::getDB(); # Get Map $statement = $db->prepare($selectQuery); $statement->bindParam(":name", $validKeys[$name]); $statement->execute(); $mapSets = $statement->fetchAll(PDO::FETCH_ASSOC); $statement->closeCursor(); foreach ($mapSets as $mapSet) { $mapID = $mapSet["mapID"]; $mapName = $mapSet["mapName"]; $mapURL = $mapSet["mapURL"]; } # Create Map $map = new Map($mapID, $mapName, $mapURL); return $map; } catch (Exception $e) { return false; } }
public static function run() { if (CookieController::cookieExists("session")) { if (($user = CookieController::readSessionCookie()) === false) { header("Location: home"); } else { $maps = MapDatabase::getAllUserMaps($user->getID()); MyTripsView::show($maps); } } else { header("Location: home"); } }
public static function run() { $map = MapDatabase::getMapByName("europe"); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (!isset($_POST["location"])) { MapView::show($map); } else { $location = $_POST["location"]; if (!($newMap = MapDatabase::getMapByName($location))) { MapView::show($map); } else { MapView::show($newMap); } } } else { MapView::show($map); } }
public static function run($map) { if (CookieController::cookieExists("session")) { if (($user = CookieController::readSessionCookie()) !== false) { $map; if ($_SERVER["REQUEST_METHOD"] == "POST") { $mapID = ""; $mapName = ""; $latLng = ""; if (isset($_POST["map-id"])) { $mapID = $_POST["map-id"]; } if (isset($_POST["map-name"])) { $mapName = $_POST["map-name"]; } if (isset($_POST["lat-lng"])) { $latLng = $_POST["lat-lng"]; } $map = new Map($mapID, $mapName, $latLng); if (empty($mapID)) { MapDatabase::addMap($map, $user->getID()); } else { MapDatabase::updateMap($map); } MapView::show($map); } else { if (isset($_GET["selection"])) { $mapID = $_GET["selection"]; $map = MapDatabase::getMap($mapID); } MapView::show($map); } } else { header("Location: home"); } } else { header("Location: home"); } }
<?php include "includer.php"; echo "<h1>All Maps</h1>"; $maps = MapDatabase::getAllMaps(); foreach ($maps as $map) { echo "<fieldset>"; echo "<legend>Map:" . $map["mapID"] . "</legend>"; echo "<iframe width='100%' height='450' frameborder='0' style='border:0' src='" . $map["mapURL"] . "' allowfullscreen></iframe>"; echo $map["mapName"] . " -- " . $map["mapURL"]; echo "</fieldset><br/>"; }
public static function getMapByID($name) { $name = MapDatabase::sanitize($name); $selectQuery = "SELECT * FROM Maps WHERE mapName=:name"; try { # Get Database $db = Database::getDB(); # Get Map $statement = $db->prepare($selectQuery); $statement->bindParam(":name", $validKeys[$name]); $statement->execute(); $mapSets = $statement->fetchAll(PDO::FETCH_ASSOC); $statement->closeCursor(); foreach ($mapSets as $mapSet) { $mapID = $mapSet["mapID"]; $mapName = $mapSet["mapName"]; $mapURL = $mapSet["mapURL"]; } # Create Map $map = new Map($mapID, $mapName, $mapURL); return $map; } catch (Exception $e) { return false; } }