/** * @method GET */ function get() { // get token $token = Utilities::ValidateJWTToken(apache_request_headers()); // check if token is not null if ($token != NULL) { // get a reference to the site, user $site = Site::GetBySiteId($token->SiteId); $arr = array(); if (FILES_ON_S3 == true) { $total_size = S3::RetrieveFilesSize($site); } else { $directory = SITES_LOCATION . '/' . $site['FriendlyId'] . '/files/'; //get all files in the directory $files = glob($directory . "*.*"); $total_size = 0; //print each file name foreach ($files as $file) { // get size of file $total_size = $total_size + filesize($file); } $total_size = round($total_size / 1024 / 1024, 2); } // return a json response $response = new Tonic\Response(Tonic\Response::OK); $response->contentType = 'text/html'; $response->body = $total_size; return $response; } else { // return an unauthorized exception (401) return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } }