diff --git a/src/api/wishes.php b/src/api/wishes.php index 33706385..9304493c 100644 --- a/src/api/wishes.php +++ b/src/api/wishes.php @@ -142,11 +142,11 @@ switch ($_SERVER['REQUEST_METHOD']) { } /** Update */ - $wish_title = empty($wish_title) ? null : substr($wish_title, 0, 128); - $wish_description = empty($wish_description) ? null : $wish_description ; - $wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? null : $wish_image ; - $wish_url = empty($wish_url) ? null : $wish_url ; - $wish_priority = empty($wish_priority) ? null : $wish_priority ; + $wish_title = empty($wish_title) ? null : substr($wish_title, 0, 128) ; + $wish_description = empty($wish_description) ? null : $wish_description ; + $wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? null : $wish_image ; + $wish_url = empty($wish_url) ? null : Wish::getAffiliateLink($wish_url); + $wish_priority = empty($wish_priority) ? null : $wish_priority ; $database ->query( @@ -229,10 +229,10 @@ switch ($_SERVER['REQUEST_METHOD']) { } /** Update */ - $wish_title = empty($wish_title) ? null : substr($wish_title, 0, 128); - $wish_description = empty($wish_description) ? null : $wish_description ; - $wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? null : $wish_image ; - $wish_url = empty($wish_url) ? null : $wish_url ; + $wish_title = empty($wish_title) ? null : substr($wish_title, 0, 128) ; + $wish_description = empty($wish_description) ? null : $wish_description ; + $wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? null : $wish_image ; + $wish_url = empty($wish_url) ? null : Wish::getAffiliateLink($wish_url); $database ->query( diff --git a/src/assets/css/home.css b/src/assets/css/home.css index d9ed5ef6..cb2505d3 100644 --- a/src/assets/css/home.css +++ b/src/assets/css/home.css @@ -39,6 +39,7 @@ --gap: 0.5rem; gap: var(--gap); + margin-bottom: 1em; } .flex.why-wishthis > ul { flex: 0 0 calc(50% - var(--gap) / 2); diff --git a/src/classes/wishthis/Wish.php b/src/classes/wishthis/Wish.php index 5bd852bb..d942fe9b 100644 --- a/src/classes/wishthis/Wish.php +++ b/src/classes/wishthis/Wish.php @@ -68,6 +68,25 @@ class Wish return $wish; } + public static function getAffiliateLink(string $url): string + { + $urlParts = parse_url($url); + + if (isset($urlParts['query'])) { + \parse_str($urlParts['query'], $urlParameters); + } else { + $urlParameters = array(); + } + + if (\str_contains($urlParts['host'], 'amazon')) { + $urlParameters['tag'] = 'grandel-21'; + $urlParts['query'] = \http_build_query($urlParameters); + $url = $urlParts['scheme'] . '://' . $urlParts['host'] . $urlParts['path'] . '?' . $urlParts['query']; + } + + return $url; + } + /** * Non-Static */ diff --git a/src/pages/changelog.php b/src/pages/changelog.php index 793fab60..0caa3dad 100644 --- a/src/pages/changelog.php +++ b/src/pages/changelog.php @@ -124,6 +124,12 @@ $page->navigation(); echo __('After creating an account your language is automatically set to your browser\'s (if it is available), instead of defaulting to en_GB.'); ?> +
= __('As a non-commercial project it remains') ?>
+= __('As an open source project it remains') ?>
= __('Plese note that wishthis automatically converts amazon links to affiliate links to help support the project financially.') ?>
= __('Currently the email address is used as a unique identifier and does not have to be verified. You may enter a fake address.') ?>
-= __('wishthis is not a commercial project and is not interested in sending you marketing emails or selling your information to third parties. Although possible to do otherwise, it is strongly recommend to enter your real email address in case you need to recover your password or receive important notifications. These do not exist yet, but some future features and options might require sending you an email (e. g. when a wish has been fulfilled).') ?>
+= __('wishthis is not interested in sending you marketing emails or selling your information to third parties. Although possible to do otherwise, it is strongly recommend to enter your real email address in case you need to recover your password or receive important notifications. These do not exist yet, but some future features and options might require sending you an email (e. g. when a wish has been fulfilled).') ?>
= sprintf(