From f6206bbf376cd4256a2f8efa908348eec5ee5074 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Tue, 18 Oct 2022 16:51:06 -0500 Subject: [PATCH 01/11] added logic for displaying remove url button --- www/templates/linkinfo.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/www/templates/linkinfo.php b/www/templates/linkinfo.php index a0af85ff..9c4e98a2 100644 --- a/www/templates/linkinfo.php +++ b/www/templates/linkinfo.php @@ -91,9 +91,38 @@ + + lastRedirect) || empty($link->lastRedirect)): ?> + + + lastRedirect); + $twoYearsAgo = strtotime("-2 years"); + ?> + + $lastRedirect):?> + + +

This Link has been used in the past two years so you will be unable to delete it for now.

+ + + + + +
+

+ This Link has NOT been used in the past two years. You may delete it if you want but once its gone it is gone. + +

+
+ Date: Thu, 20 Oct 2022 12:05:58 -0500 Subject: [PATCH 02/11] added method for checking for old links --- src/lilURL.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lilURL.php b/src/lilURL.php index 3162711b..6d205518 100755 --- a/src/lilURL.php +++ b/src/lilURL.php @@ -23,6 +23,8 @@ class lilURL const MAX_RANDOM_ID_BUMP_LENGTH = 5; const MAX_RANDOM_ID_ATTEMPTS = 15000000; + const MIN_YEARS_OLD_LINK = 2; + // Tables const TABLE_GROUPS = 'tblGroups'; const TABLE_GROUP_USERS = 'tblGroupUsers'; @@ -632,9 +634,18 @@ public function userHasURLAccess($urlID, $uid) { return $this->userOwnsURL($urlID, $uid) || $this->userHasGroupURLAccess($urlID, $uid); } + public function checkOldURL($urlID) { + $result = $this->db->run( + 'SELECT count(*) AS oldURL FROM ' . self::TABLE_URLS . ' WHERE ' . self::WHERE_URL_ID . ' AND ((lastRedirect <= DATE_SUB(CURDATE(), INTERVAL ' . self::MIN_YEARS_OLD_LINK . ' YEAR)) OR (lastRedirect IS NULL AND submitDate <= DATE_SUB(CURDATE(), INTERVAL ' . self::MIN_YEARS_OLD_LINK . ' YEAR)));', + array(self::PDO_PLACEHOLDER_URL_ID => $urlID), + TRUE + ); + return $result->oldURL > 0; + } + public function deleteURL($urlID, $uid) { - if ($this->userHasURLAccess($urlID, $uid)) { + if ($this->userHasURLAccess($urlID, $uid) || $this->checkOldURL($urlID)) { return $this->db->delete( self::TABLE_URLS, self::WHERE_URL_ID . ' LIMIT 1', From 6aa0ce8026f43286564cd6b5713412e15a9879da Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Thu, 20 Oct 2022 12:06:19 -0500 Subject: [PATCH 03/11] implemented new logic for old links and form --- www/templates/linkinfo.php | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/www/templates/linkinfo.php b/www/templates/linkinfo.php index 9c4e98a2..ac99a366 100644 --- a/www/templates/linkinfo.php +++ b/www/templates/linkinfo.php @@ -92,19 +92,19 @@ - lastRedirect) || empty($link->lastRedirect)): ?> - - - lastRedirect); - $twoYearsAgo = strtotime("-2 years"); - ?> - $lastRedirect):?> - - -

This Link has been used in the past two years so you will be unable to delete it for now.

- + checkOldURL($link->urlID)): ?> +
+ +

+ This Link has NOT been used or created in the past two years. You may delete it if you want but once its gone it is gone. + +

+
+ +

+ This Link has been used or created in the past two years so you will be unable to delete it for now. +

@@ -113,16 +113,3 @@ - - -
-

- This Link has NOT been used in the past two years. You may delete it if you want but once its gone it is gone. - -

-
- Date: Thu, 20 Oct 2022 12:06:57 -0500 Subject: [PATCH 04/11] changed flashbag message to include URL --- src/goController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/goController.php b/src/goController.php index 5d06e1a7..97e4b601 100644 --- a/src/goController.php +++ b/src/goController.php @@ -189,10 +189,10 @@ private function handleRouteManage() { $deleted = $this->lilurl->deleteURL($urlID, $this->auth->getUserId()); if ($deleted) { - $this->flashBag->setParams(self::FLASHBAG_HEADING_DELETE_SUCCESSFUL, '

Your URL has been deleted.

', $this->flashBag::FLASH_BAG_TYPE_SUCCESS); + $this->flashBag->setParams(self::FLASHBAG_HEADING_DELETE_SUCCESSFUL, '

The URL '' . htmlspecialchars($_POST['urlID']) . '' has been deleted.

', $this->flashBag::FLASH_BAG_TYPE_SUCCESS); $this->redirect($this->lilurl->getBaseUrl(self::ROUTE_PATH_LINKS)); } else { - $this->flashBag->setParams(self::FLASHBAG_HEADING_DELETE_FAILED, '

Your URL has NOT been deleted.

', $this->flashBag::FLASH_BAG_TYPE_ERROR); + $this->flashBag->setParams(self::FLASHBAG_HEADING_DELETE_FAILED, '

The URL '' . htmlspecialchars($_POST['urlID']) . '' has NOT been deleted.

', $this->flashBag::FLASH_BAG_TYPE_ERROR); $this->redirect($this->lilurl->getBaseUrl(self::ROUTE_PATH_LINKS)); } From 6db9c26e0d1b96900d3ba65927273b2f5dcd3488 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Thu, 20 Oct 2022 12:15:10 -0500 Subject: [PATCH 05/11] Changed verbiage --- www/templates/linkinfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/templates/linkinfo.php b/www/templates/linkinfo.php index ac99a366..da1dd01d 100644 --- a/www/templates/linkinfo.php +++ b/www/templates/linkinfo.php @@ -97,13 +97,13 @@

- This Link has NOT been used or created in the past two years. You may delete it if you want but once its gone it is gone. + This URL has NOT been used or created in the past two years. You may delete it if you want but once its gone it is gone.

- This Link has been used or created in the past two years so you will be unable to delete it for now. + This URL has been used or created in the past two years so you will be unable to delete it for now.

From cdba00db395382fa547abcfc82910ff50baf2084 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Thu, 20 Oct 2022 13:29:38 -0500 Subject: [PATCH 06/11] changed verbiage --- www/templates/linkinfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/templates/linkinfo.php b/www/templates/linkinfo.php index da1dd01d..436b9f0f 100644 --- a/www/templates/linkinfo.php +++ b/www/templates/linkinfo.php @@ -103,7 +103,7 @@

- This URL has been used or created in the past two years so you will be unable to delete it for now. + This URL has been used or created in the past two years, so you will be unable to delete it for now.

From 8471ebc924f71f2c59e24944aaa11e42f9ead448 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Thu, 20 Oct 2022 13:33:36 -0500 Subject: [PATCH 07/11] changed verbiage --- www/templates/linkinfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/templates/linkinfo.php b/www/templates/linkinfo.php index 436b9f0f..e615d3e1 100644 --- a/www/templates/linkinfo.php +++ b/www/templates/linkinfo.php @@ -97,7 +97,7 @@

- This URL has NOT been used or created in the past two years. You may delete it if you want but once its gone it is gone. + This URL has NOT been used or created in the past two years. You may delete if you would like to use this URL for a different purpose.

From 275ee812cf9318706d886ef1230831ed0b0756c6 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Thu, 20 Oct 2022 13:34:52 -0500 Subject: [PATCH 08/11] changed verbiage --- www/templates/linkinfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/templates/linkinfo.php b/www/templates/linkinfo.php index e615d3e1..6541d7bb 100644 --- a/www/templates/linkinfo.php +++ b/www/templates/linkinfo.php @@ -97,7 +97,7 @@

- This URL has NOT been used or created in the past two years. You may delete if you would like to use this URL for a different purpose. + This URL has NOT been used or created in the past two years. You may delete this URL if you would like to use it for a different purpose.

From aa3faaabc3601546c12aa6fff252e2c31c924b58 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Thu, 20 Oct 2022 13:37:08 -0500 Subject: [PATCH 09/11] Changed Verbiage --- www/templates/linkinfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/templates/linkinfo.php b/www/templates/linkinfo.php index 6541d7bb..111c9b95 100644 --- a/www/templates/linkinfo.php +++ b/www/templates/linkinfo.php @@ -103,7 +103,7 @@

- This URL has been used or created in the past two years, so you will be unable to delete it for now. + This URL has been used or created in the past two years, so you will be unable to delete it for now, but you can always ask the person who created to delete it.

From cf2d74d78413b5019f635fb9ff086e792ef18690 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Thu, 20 Oct 2022 13:48:21 -0500 Subject: [PATCH 10/11] Changed verbiage --- www/templates/linkinfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/templates/linkinfo.php b/www/templates/linkinfo.php index 111c9b95..493707c9 100644 --- a/www/templates/linkinfo.php +++ b/www/templates/linkinfo.php @@ -103,7 +103,7 @@

- This URL has been used or created in the past two years, so you will be unable to delete it for now, but you can always ask the person who created to delete it. + This URL has been used or created in the past two years. You will be unable to delete it for now, but you can always ask the person who created the URL to delete it.

From c200da4f5653a1798e9bc0026abc9a95e35447a5 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Thu, 20 Oct 2022 14:02:30 -0500 Subject: [PATCH 11/11] Changed formatting --- src/lilURL.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lilURL.php b/src/lilURL.php index 6d205518..b5a13ed5 100755 --- a/src/lilURL.php +++ b/src/lilURL.php @@ -634,7 +634,8 @@ public function userHasURLAccess($urlID, $uid) { return $this->userOwnsURL($urlID, $uid) || $this->userHasGroupURLAccess($urlID, $uid); } - public function checkOldURL($urlID) { + public function checkOldURL($urlID) + { $result = $this->db->run( 'SELECT count(*) AS oldURL FROM ' . self::TABLE_URLS . ' WHERE ' . self::WHERE_URL_ID . ' AND ((lastRedirect <= DATE_SUB(CURDATE(), INTERVAL ' . self::MIN_YEARS_OLD_LINK . ' YEAR)) OR (lastRedirect IS NULL AND submitDate <= DATE_SUB(CURDATE(), INTERVAL ' . self::MIN_YEARS_OLD_LINK . ' YEAR)));', array(self::PDO_PLACEHOLDER_URL_ID => $urlID),