| 123456789101112131415161718192021222324252627 |
- <?php
- $test = Test::get($id);
- if(!$test) throw new Exception(__("Test not found."));
- if(Core::$user->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");
- }
- ?>
|