determine https/http via php server variable to ensure QR code works properly

This commit is contained in:
Silas 2018-04-26 16:53:01 -04:00
parent 426c938bd0
commit c9d8decf38

View file

@ -32,9 +32,15 @@ if (!empty($_GET['url'])) {
$shortUrl = $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?'.$urlhash; $shortUrl = $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?'.$urlhash;
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
$shortUrl = 'https://'.$shortUrl;
} else {
$shortUrl = 'http://'.$shortUrl;
}
$qrcode = (new QrCode())->setText($shortUrl); $qrcode = (new QrCode())->setText($shortUrl);
$content = '<a href="//'.$shortUrl.'">'.$shortUrl.'</a><br>' $content = '<a href="'.$shortUrl.'">'.$shortUrl.'</a><br>'
.'<img src="data:'.$qrcode->getContentType().';base64,'.base64_encode($qrcode->get()).'">'; .'<img src="data:'.$qrcode->getContentType().';base64,'.base64_encode($qrcode->get()).'">';
} elseif (!empty($_GET)) { } elseif (!empty($_GET)) {
$urlhash = key($_GET); $urlhash = key($_GET);