Fix redirect script not woring

This commit is contained in:
Michael Fabian 'Xaymar' Dirks
2022-08-19 00:34:28 +02:00
parent 62092f222a
commit 8b8d286658
+6 -8
View File
@@ -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();
die();