From 426c938bd0336e95a162e5628c769740b8f40da8 Mon Sep 17 00:00:00 2001 From: Silas Date: Thu, 26 Apr 2018 16:28:26 -0400 Subject: [PATCH 1/2] let browser determine http/https --- index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 57dabd2..0fb05be 100644 --- a/index.php +++ b/index.php @@ -30,11 +30,11 @@ if (!empty($_GET['url'])) { file_put_contents($hashfilepath, $url); - $shortUrl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?'.$urlhash; + $shortUrl = $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?'.$urlhash; $qrcode = (new QrCode())->setText($shortUrl); - $content = ''.$shortUrl.'
' + $content = ''.$shortUrl.'
' .''; } elseif (!empty($_GET)) { $urlhash = key($_GET); From c9d8decf3865940062898271145d548331f8ed66 Mon Sep 17 00:00:00 2001 From: Silas Date: Thu, 26 Apr 2018 16:53:01 -0400 Subject: [PATCH 2/2] determine https/http via php server variable to ensure QR code works properly --- index.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 0fb05be..7d208e4 100644 --- a/index.php +++ b/index.php @@ -32,9 +32,15 @@ if (!empty($_GET['url'])) { $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); - $content = ''.$shortUrl.'
' + $content = ''.$shortUrl.'
' .''; } elseif (!empty($_GET)) { $urlhash = key($_GET);