| 123456789101112131415161718192021222324252627 |
- <?php
- $template = Template::get($id);
- if(!$template) throw new Exception(_("Practice form not found."));
- $tests = $_SESSION["practice_tests"];
- $test = $tests[$id] ?? false;
- if(!$test) throw new Exception(_("Practice 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");
- }
- ?>
|