$conn = new PDO("pgsql:host=localhost;dbname=gis2;", "gis"); $um = new UserManager($conn); $cget = clean_input($_GET, null); $cpost = clean_input($_POST, null); switch ($action) { case "add": if ($_SERVER['REQUEST_METHOD'] == 'POST') { $userid = $um->getUserIdFromCredentials(); if ($userid < 0) { header("HTTP/1.1 401 Unauthorized"); } else { if (isset($cpost["id"]) && ctype_digit($cpost["id"])) { $wr = new Walkroute($conn, $cpost["id"]); $wr->updateRoute($cpost["route"]); } else { $j = Walkroute::addWR($conn, $cpost["route"], $userid, $format); echo $j; } } } else { header("HTTP/1.1 400 Bad Request"); echo "Please use a POST request"; } break; case "addWaypoint": $badreq = true; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $userid = $um->getUserIdFromCredentials(); if ($userid <= 0) { header("HTTP/1.1 401 Unauthorized"); $badreq = false;