/** * @param string[] $server * @param string $path * @param string[] $headers */ public function Process($server, $path, $headers) { $method = isset($server['REQUEST_METHOD']) ? $server['REQUEST_METHOD'] : false; if (empty($path)) { switch ($method) { case 'POST': break; case 'GET': APIResponse(RESPONSE_200, $this->ToArray()); break; case 'PUT': if (isset($_POST['type'])) { $this->Type = $_POST['type']; } if (isset($_POST['title'])) { $this->Title = $_POST['title']; } if (isset($_POST['description'])) { $this->Description = $_POST['description']; } $this->UpdateDatabase(); APIResponse(RESPONSE_200, $this->ToArray()); break; case 'DELETE': $query = $this->DB->Query("\n UPDATE tblBars\n SET active = 0\n WHERE userID = " . (int) $this->Session->ID . "\n AND id = " . (int) $this->ID . " LIMIT 1;\n "); if ($query) { $this->Session->RefreshBars(); APIResponse(RESPONSE_200); } else { APIResponse(RESPONSE_500); } break; default: break; } } }