From 8b8d2866589ca4b45ff2fa0a9516579b76bfbc8d Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Fri, 19 Aug 2022 00:34:28 +0200 Subject: [PATCH] Fix redirect script not woring --- redirect.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/redirect.php b/redirect.php index e2f1b17..8c8ff44 100644 --- a/redirect.php +++ b/redirect.php @@ -56,9 +56,9 @@ function insert_lookup($url) { $STATEMENTS['Insert']->bind_param('s', $url); if (!$STATEMENTS['Insert']->execute()) { - throw new Exception($SQL['Handle']->errno." ".$SQL['Handle']->error); + throw new Exception("".$SQL['Handle']->errno." ".$SQL['Handle']->error); } else if (!$STATEMENTS['Insert']->get_result()) { - throw new Exception($SQL['Handle']->errno." ".$SQL['Handle']->error); + throw new Exception("".$SQL['Handle']->errno." ".$SQL['Handle']->error); } } @@ -68,7 +68,7 @@ function increment_lookup($url) { $STATEMENTS['Increment']->bind_param('s', $url); if (!$STATEMENTS['Increment']->execute()) { - throw new Exception($SQL['Handle']->errno." ".$SQL['Handle']->error); + throw new Exception("".$SQL['Handle']->errno." ".$SQL['Handle']->error); } } @@ -106,22 +106,20 @@ try { // Try and redirect user according to the full provided URI $location = null; // Try and identify a redirect by the full URI. $location = redirect_lookup($url); - if ($location == null) { + if (!($location != null)) { // Try and identify a redirect by the path. $location = redirect_lookup($url_parts["path"]); } if ($location != null) { header("Location: ".$location, true, 307); - } else { - header("Location: https://www.xaymar.com/404.html"); + die(); } // In all other cases, just redirect to 404. header("Location: https://www.xaymar.com/404.html"); } catch(Exception $e) { - //header("Service Unavailable", true, 503); header("Retry-After: 30", true, 503); echo($e); } -//die(); \ No newline at end of file +die(); \ No newline at end of file