From fa7fec092cdea083e6459ef4ac3766c943e2978e Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Fri, 20 Oct 2023 16:04:07 -0500 Subject: [PATCH 1/8] Added qr code scans count to database --- data/goURL.sql | 2 ++ src/lilURL.php | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/data/goURL.sql b/data/goURL.sql index 98b7a5b..75a77a1 100644 --- a/data/goURL.sql +++ b/data/goURL.sql @@ -27,6 +27,7 @@ CREATE TABLE IF NOT EXISTS `tblURLs` ( `submitDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `createdBy` varchar(25) DEFAULT NULL, `redirects` int(11) unsigned DEFAULT 0, + `qrCodeScans` int(11) unsigned DEFAULT 0, `lastRedirect` timestamp NULL, `maliciousCheck` enum('checked', 'unchecked', 'protected')NOT NULL DEFAULT 'unchecked', PRIMARY KEY (`urlID`) @@ -35,6 +36,7 @@ CREATE TABLE IF NOT EXISTS `tblURLs` ( -- ALTER TABLE `tblURLs` ADD COLUMN `groupID` int(10) unsigned NULL AFTER `urlID`; -- ALTER TABLE `tblURLs` ADD COLUMN `lastRedirect` timestamp NULL AFTER `redirects`; -- ALTER TABLE `tblURLs` ADD COLUMN `maliciousCheck` enum('checked', 'unchecked', 'protected') NOT NULL DEFAULT 'unchecked' AFTER `lastRedirect`; +-- ALTER TABLE `tblURLs` ADD COLUMN `qrCodeScans` int(11) unsigned DEFAULT 0 AFTER `redirects`; DROP TABLE IF EXISTS `tblGroups`; CREATE TABLE IF NOT EXISTS `tblGroups` ( diff --git a/src/lilURL.php b/src/lilURL.php index 0b62b7d..9aaba96 100755 --- a/src/lilURL.php +++ b/src/lilURL.php @@ -36,6 +36,7 @@ class lilURL const PDO_PLACEHOLDER_LONG_URL = ':longURL'; const PDO_PLACEHOLDER_CREATED_BY = ':createdBy'; const PDO_PLACEHOLDER_REDIRECTS = ':redirects'; + const PDO_PLACEHOLDER_QR_CODE_SCANS = ':qrCodeScans'; const PDO_PLACEHOLDER_GROUP_ID = ':groupID'; const PDO_PLACEHOLDER_GROUP_NAME = ':groupName'; const PDO_PLACEHOLDER_UID = ':uid'; @@ -754,7 +755,10 @@ public function deleteURL($urlID, $uid) public function resetRedirectCount($id) { return $this->db->update( self::TABLE_URLS, - array(ltrim(self::PDO_PLACEHOLDER_REDIRECTS, ':') => 0), + array( + ltrim(self::PDO_PLACEHOLDER_REDIRECTS, ':') => 0, + ltrim(self::PDO_PLACEHOLDER_QR_CODE_SCANS, ':') => 0, + ), self::WHERE_URL_ID, array(self::PDO_PLACEHOLDER_URL_ID => $id) ); From e976b2bbee3dc873155b410f5b47081c9efa41a0 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Fri, 20 Oct 2023 16:05:10 -0500 Subject: [PATCH 2/8] Added to the output data --- www/templates/linkinfo.php | 3 +++ www/templates/manage.php | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/www/templates/linkinfo.php b/www/templates/linkinfo.php index d819330..84089c3 100644 --- a/www/templates/linkinfo.php +++ b/www/templates/linkinfo.php @@ -41,6 +41,9 @@
Redirect Count
redirects ?? ''); ?>
+
QR Code Scans
+
qrCodeScans ?? ''); ?>
+
Last Redirect
lastRedirect) { diff --git a/www/templates/manage.php b/www/templates/manage.php index 6f0bd38..9cc886a 100644 --- a/www/templates/manage.php +++ b/www/templates/manage.php @@ -24,7 +24,7 @@ class="dcf-w-100% go_responsive_table flush-left dcf-table dcf-txt-sm" Short URL Long URL Group - Redirects + QR Code Scans Last Redirect Created on Actions @@ -70,6 +70,9 @@ class="dcf-w-100% go_responsive_table flush-left dcf-table dcf-txt-sm" redirects ?? ''); ?> + + qrCodeScans ?? ''); ?> + From 9407c8b641238cdbfac8a901918f6abf0f2a1ed2 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Fri, 20 Oct 2023 16:05:48 -0500 Subject: [PATCH 3/8] Added to QR codes and increment if found --- src/goController.php | 4 ++-- src/lilURL.php | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/goController.php b/src/goController.php index 0a0b1be..acaca3a 100644 --- a/src/goController.php +++ b/src/goController.php @@ -397,7 +397,7 @@ private function handleRouteURLQRCodePNG() $this->handle404(FALSE); } - $shortURL = $this->lilurl->getShortURL($this->goId); + $shortURL = $this->lilurl->getShortURL($this->goId) . '?qr'; $pngPrefix = __DIR__ . '/../data/qr/'; $qrCodeHash = hash("sha512", $shortURL); $qrCache = $pngPrefix . 'cache/' . $this->qrCachePrefix . hash("sha512", $shortURL) . '.png'; @@ -449,7 +449,7 @@ private function handleRouteURLQRCodeSVG() $this->handle404(false); } - $shortURL = $this->lilurl->getShortURL($this->goId); + $shortURL = $this->lilurl->getShortURL($this->goId) . '?qr'; $svgPrefix = __DIR__ . '/../data/qr/'; $qrCodeHash = hash("sha512", $shortURL); $qrCache = $svgPrefix . 'cache/' . $this->qrCachePrefix . hash("sha512", $shortURL) . '.svg'; diff --git a/src/lilURL.php b/src/lilURL.php index 9aaba96..91d5fb7 100755 --- a/src/lilURL.php +++ b/src/lilURL.php @@ -125,6 +125,9 @@ protected function trackHit($id) if (!$this->checkForBots()) { // track system redirect $this->incrementRedirectCount($id); + if (isset($_GET['qr'])) { + $this->incrementQRCodeScanCount($id); + } } $accountId = $this->getGaAccount(); @@ -987,4 +990,10 @@ private function incrementRedirectCount($id) { array(self::PDO_PLACEHOLDER_URL_ID => $id) ); } + + private function incrementQRCodeScanCount($id) { + return $this->db->run('UPDATE ' . self::TABLE_URLS . ' SET qrCodeScans = qrCodeScans + 1 WHERE ' . self::WHERE_URL_ID, + array(self::PDO_PLACEHOLDER_URL_ID => $id) + ); + } } From de65432895721f176023319da53bef5856fc775e Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Fri, 20 Oct 2023 16:06:11 -0500 Subject: [PATCH 4/8] Fix bug with reset redirects button --- www/templates/manage.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/www/templates/manage.php b/www/templates/manage.php index 9cc886a..81abd2c 100644 --- a/www/templates/manage.php +++ b/www/templates/manage.php @@ -115,8 +115,7 @@ class="dcf-btn dcf-btn-secondary" title="Reset redirect count for urlID ?? ''); ?> URL" - onclick="return confirm('Are you sure you want to reset the redirect count for \' - urlID ?? ''); ?>\'?');" + onclick=" return confirm('Are you sure you want to reset the redirect count for \'urlID ?? ''); ?>\'?');" > Reset Redirects From ceae98e8507caa679161c55d0d7b894be867bdf9 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Fri, 20 Oct 2023 16:06:33 -0500 Subject: [PATCH 5/8] Added not about what redirects is counting --- www/templates/manage.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/www/templates/manage.php b/www/templates/manage.php index 81abd2c..c15ad66 100644 --- a/www/templates/manage.php +++ b/www/templates/manage.php @@ -24,6 +24,7 @@ class="dcf-w-100% go_responsive_table flush-left dcf-table dcf-txt-sm" Short URL Long URL Group + Redirects* QR Code Scans Last Redirect Created on @@ -67,7 +68,7 @@ class="dcf-w-100% go_responsive_table flush-left dcf-table dcf-txt-sm" groupName) ? htmlspecialchars($url->groupName) : 'N/A'; ?> - + redirects ?? ''); ?> @@ -156,6 +157,9 @@ class="dcf-btn dcf-btn-primary dcf-mr-6" +
+ * "Redirects" is the total number of redirects this includes the + "QR Codes Scans" as well as normal redirects.
From 3adddcd12737ca6b73c0b5677dc9c6ab349ac6d7 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Fri, 20 Oct 2023 16:12:35 -0500 Subject: [PATCH 6/8] Added more help text --- www/templates/manage.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/www/templates/manage.php b/www/templates/manage.php index c15ad66..a6caa3a 100644 --- a/www/templates/manage.php +++ b/www/templates/manage.php @@ -25,7 +25,7 @@ class="dcf-w-100% go_responsive_table flush-left dcf-table dcf-txt-sm" Long URL Group Redirects* - QR Code Scans + QR Code Scans** Last Redirect Created on Actions @@ -71,7 +71,7 @@ class="dcf-w-100% go_responsive_table flush-left dcf-table dcf-txt-sm" redirects ?? ''); ?> - + qrCodeScans ?? ''); ?> * "Redirects" is the total number of redirects this includes the "QR Codes Scans" as well as normal redirects. +
+ ** Any QR Codes downloaded before {DATE} will not be counted in "QR Codes Scans", + please replace your old QR Codes to be able to take advantage of this metric From 39ea172dfb8bce0c795e0c25e819a6ef898a2600 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Tue, 24 Oct 2023 08:16:04 -0500 Subject: [PATCH 7/8] Removed stars and added note at the bottom of the page --- www/templates/manage.php | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/www/templates/manage.php b/www/templates/manage.php index a6caa3a..a0c7bd8 100644 --- a/www/templates/manage.php +++ b/www/templates/manage.php @@ -24,8 +24,8 @@ class="dcf-w-100% go_responsive_table flush-left dcf-table dcf-txt-sm" Short URL Long URL Group - Redirects* - QR Code Scans** + Redirects + QR Code Scans Last Redirect Created on Actions @@ -68,10 +68,10 @@ class="dcf-w-100% go_responsive_table flush-left dcf-table dcf-txt-sm" groupName) ? htmlspecialchars($url->groupName) : 'N/A'; ?> - + redirects ?? ''); ?> - + qrCodeScans ?? ''); ?> Add URL - - -
- * "Redirects" is the total number of redirects this includes the - "QR Codes Scans" as well as normal redirects. -
- ** Any QR Codes downloaded before {DATE} will not be counted in "QR Codes Scans", - please replace your old QR Codes to be able to take advantage of this metric + +
+ + Note: +
    +
  • +
  • + "Redirects" is the total number of redirects, this includes the + "QR Codes Scans" as well as normal redirects. +
  • +
  • + Any QR Codes downloaded before October 2023 will not be counted in "QR Codes Scans", + please replace your old QR Codes to be able to take advantage of this metric. +
  • +
From c100ac9c3951b2813f5e07fd032d98c5011e0d9e Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Tue, 24 Oct 2023 08:28:10 -0500 Subject: [PATCH 8/8] Remove stank --- src/lilURL.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lilURL.php b/src/lilURL.php index 91d5fb7..16f608d 100755 --- a/src/lilURL.php +++ b/src/lilURL.php @@ -992,7 +992,11 @@ private function incrementRedirectCount($id) { } private function incrementQRCodeScanCount($id) { - return $this->db->run('UPDATE ' . self::TABLE_URLS . ' SET qrCodeScans = qrCodeScans + 1 WHERE ' . self::WHERE_URL_ID, + return $this->db->run( + 'UPDATE ' + . self::TABLE_URLS + . ' SET qrCodeScans = qrCodeScans + 1 WHERE ' + . self::WHERE_URL_ID, array(self::PDO_PLACEHOLDER_URL_ID => $id) ); }