forked from PhotoboothProject/photobooth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqrcode.php
More file actions
41 lines (36 loc) · 1.15 KB
/
qrcode.php
File metadata and controls
41 lines (36 loc) · 1.15 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
<?php
/** @var array $config */
use Photobooth\Service\RemoteStorageService;
use Photobooth\Utility\PathUtility;
use Photobooth\Utility\QrCodeUtility;
require_once '../lib/boot.php';
$filename = (isset($_GET['filename']) && $_GET['filename']) != '' ? $_GET['filename'] : false;
if ($filename) {
$url = $config['qr']['url'];
if ($config['ftp']['enabled'] && $config['ftp']['useForQr']) {
$remoteStorageService = RemoteStorageService::getInstance();
$url = $remoteStorageService->getWebpageUri();
if ($config['qr']['append_filename']) {
$url .= '/images/';
}
}
if ($config['qr']['append_filename']) {
$url .= $filename;
}
$url = PathUtility::getPublicPath($url, true);
try {
$result = QrCodeUtility::create($url);
header('Content-Type: ' . $result->getMimeType());
echo $result->getString();
} catch (\Exception $e) {
http_response_code(500);
echo 'Error generating QR Code.';
if ($config['dev']['loglevel'] > 1) {
echo $e->getMessage();
}
}
} else {
http_response_code(400);
echo 'No filename defined.';
}
exit();