<?php /*DEBUG ON*/ error_reporting(E_ALL); ini_set('display_errors', '1'); /**/ include_once "classes/Database.php"; include_once "classes/Server.php"; include_once "classes/Key.php"; include_once "classes/User.php"; include_once "classes/databases/Mock.php"; $db = new Mock(); $db->connect(); $endpoints = array("server", "key"); $arrEndpoint = explode('/', $_SERVER['REQUEST_URI']); $endpoint = $arrEndpoint[2]; $id = $arrEndpoint[3]; $method = $_SERVER['REQUEST_METHOD']; if ($method == 'POST' && array_key_exists('HTTP_X_HTTP_METHOD', $_SERVER)) { if ($_SERVER['HTTP_X_HTTP_METHOD'] == 'DELETE') { $method = 'DELETE'; } else { if ($_SERVER['HTTP_X_HTTP_METHOD'] == 'PUT') { $method = 'PUT'; } else { throw new Exception("Unexpected Header"); } } } if (!in_array($endpoint, $endpoints)) { throw new Exception("Unavailable Endpoint");