/** * @method POST */ function remove() { // get an authuser $token = Utilities::ValidateJWTToken(apache_request_headers()); if ($token != NULL) { // check if authorized // validate that the user can remove the site $user = User::GetByUserId($token->UserId); if ($user['SiteAdmin'] == 1) { parse_str($this->request->data, $request); // parse request $siteId = $request['siteId']; $site = Site::GetBySiteId($siteId); $directory = SITES_LOCATION . '/' . $site['FriendlyId']; // Get the directory name $oldname = SITES_LOCATION . '/' . $site['FriendlyId']; // Set the directory to be removed $newname = SITES_LOCATION . '/removed-' . $site['FriendlyId']; if (file_exists($oldname)) { // Renames the directory rename($oldname, $newname); } // remove site from Amazon S3 if (FILES_ON_S3 == true) { // get site $site = Site::GetBySiteId($siteId); // remove site S3::RemoveSite($site); } // remove site from DB Site::Remove($siteId); return new Tonic\Response(Tonic\Response::OK); } else { // unauthorized access return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } } else { // unauthorized access return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } return new Tonic\Response(Tonic\Response::NOTIMPLEMENTED); }