try { $pdo = connectToEncryptedMySQL("/etc/apache2/encrypted-config/ng-abq-dev.ini"); $method = array_key_exists("HTTP_X_HTTP_METHOD", $_SERVER) ? $_SERVER["HTTP_X_HTTP_METHOD"] : $_SERVER["REQUEST_METHOD"]; $id = filter_input(INPUT_GET, "id", FILTER_VALIDATE_INT); $profileId = filter_input(INPUT_GET, "profileId", FILTER_VALIDATE_INT); if ($method === "GET") { //set XSRF cookie setXsrfCookie(); if (empty($id) === false) { $event = Beta\Event::getEventByEventId($pdo, $id); if ($event !== null) { $reply->data = $event; } } else { if (empty($profileId) === false) { $events = Beta\Event::getEventByEventProfileId($pdo, $profileId)->toArray(); if ($events !== null) { $reply->data = $events; } } else { $events = Beta\Event::getAllEvents($pdo)->toArray(); if ($events !== null) { $reply->data = $events; } } } } else { if ($method === "PUT" || $method === "POST") { verifyXsrf(); $requestContent = file_get_contents("php://input"); $requestObject = json_decode($requestContent);