-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathview.php
More file actions
82 lines (71 loc) · 3.22 KB
/
view.php
File metadata and controls
82 lines (71 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
use Photobooth\Enum\FolderEnum;
use Photobooth\Service\ApplicationService;
use Photobooth\Service\LanguageService;
use Photobooth\Utility\ComponentUtility;
use Photobooth\Utility\PathUtility;
require_once __DIR__ . '/lib/boot.php';
$imageParam = $_GET['image'] ?? '';
$image = basename((string) $imageParam);
if ($image === '') {
http_response_code(400);
echo 'No image specified.';
exit();
}
$imagePath = FolderEnum::IMAGES->absolute() . DIRECTORY_SEPARATOR . $image;
if (!is_file($imagePath)) {
http_response_code(404);
echo 'Image not found.';
exit();
}
$extension = strtolower(pathinfo($imagePath, PATHINFO_EXTENSION));
$isVideo = in_array($extension, ['mp4', 'mov', 'webm'], true);
$mime = match ($extension) {
'png' => 'image/png',
'gif' => 'image/gif',
default => 'image/jpeg',
};
$imageUrl = PathUtility::getPublicPath(FolderEnum::IMAGES->value . '/' . rawurlencode($image));
$downloadUrl = PathUtility::getPublicPath('api/download.php?image=' . rawurlencode($image));
$languageService = LanguageService::getInstance();
$pageTitle = ApplicationService::getInstance()->getTitle() . ' - ' . $languageService->translate('viewer_photo_title');
$photoswipe = false;
$remoteBuzzer = false;
include PathUtility::getAbsolutePath('template/components/main.head.php');
?>
<body class="viewer-page">
<main class="viewer">
<div class="viewer__inner">
<header class="viewer__header">
<div class="viewer__title">
<?php if ($config['event']['enabled']): ?>
<span class="viewer__title-line"><?= htmlspecialchars($config['event']['textLeft']) ?></span>
<?php if (!empty($config['event']['symbol'])): ?>
<span class="viewer__title-line">
<i class="fa <?= htmlspecialchars($config['event']['symbol']) ?>" aria-hidden="true"></i>
</span>
<?php endif; ?>
<span class="viewer__title-line"><?= htmlspecialchars($config['event']['textRight']) ?></span>
<?php else: ?>
<span class="viewer__title-line"><?= htmlspecialchars(ApplicationService::getInstance()->getTitle()) ?></span>
<?php endif; ?>
</div>
</header>
<div class="viewer__accent"></div>
<div class="viewer__media" aria-label="Captured media preview">
<?php if ($isVideo): ?>
<video src="<?=$imageUrl?>" controls playsinline controlsList="nodownload">
<?=htmlspecialchars($languageService->translate('viewer_video_fallback'))?>
</video>
<?php else: ?>
<img id="viewer-image" src="<?=$imageUrl?>" alt="Captured photo">
<?php endif; ?>
</div>
<div class="viewer__actions buttonbar">
<?= ComponentUtility::renderButtonLink('download', $config['icons']['download'], $downloadUrl, true, ['download' => 'download']) ?>
</div>
</div>
</main>
<?php include PathUtility::getAbsolutePath('template/components/main.footer.php'); ?>
</body>
</html>