determine https/http via php server variable to ensure QR code works properly
This commit is contained in:
parent
426c938bd0
commit
c9d8decf38
1 changed files with 7 additions and 1 deletions
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue