| 12345678910111213141516171819202122 |
- <?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 = $directory . "/" . $name . ".jpg";
- if(file_exists($path)) {
- header("Content-Type: image/jpeg");
- readfile($path);
- }
- else {
- header("Content-Type: image/png");
- readfile("public/img/blank.png");
- }
- ?>
|