forked from PhotoboothProject/photobooth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqrcode.php
33 lines (29 loc) · 1.05 KB
/
qrcode.php
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
<?php
use Photobooth\Utility\PathUtility;
use Photobooth\Utility\QrCodeUtility;
require_once '../lib/boot.php';
$filename = (isset($_GET['filename']) && $_GET['filename']) != '' ? $_GET['filename'] : false;
if ($filename || !$config['qr']['append_filename']) {
if ($config['ftp']['enabled'] && $config['ftp']['useForQr']) {
$url = $config['ftp']['processedTemplate'] . DIRECTORY_SEPARATOR . $filename;
} elseif ($config['qr']['append_filename']) {
$url = PathUtility::getPublicPath($config['qr']['url'] . $filename, true);
} else {
$url = PathUtility::getPublicPath($config['qr']['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();