level < User::LEVEL_ADMIN) { if(Core::$user->id != $test->tester_id) throw new Exception("You do not have permission to access this resource."); } $directory = $test->getDirectory(); $path_jpg = $directory . "/" . $name . ".jpg"; $path_pdf = $directory . "/" . $name . ".pdf"; if(file_exists($path_jpg)) { header("Content-Type: image/jpeg"); readfile($path_jpg); } else if(file_exists($path_pdf)) { header("Content-Type: application/pdf"); readfile($path_pdf); } else { header("Content-Type: image/png"); readfile("public/img/blank.png"); } ?>