Fix redirect script not woring
This commit is contained in:
+6
-8
@@ -56,9 +56,9 @@ function insert_lookup($url) {
|
|||||||
|
|
||||||
$STATEMENTS['Insert']->bind_param('s', $url);
|
$STATEMENTS['Insert']->bind_param('s', $url);
|
||||||
if (!$STATEMENTS['Insert']->execute()) {
|
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()) {
|
} 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);
|
$STATEMENTS['Increment']->bind_param('s', $url);
|
||||||
if (!$STATEMENTS['Increment']->execute()) {
|
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;
|
$location = null;
|
||||||
// Try and identify a redirect by the full URI.
|
// Try and identify a redirect by the full URI.
|
||||||
$location = redirect_lookup($url);
|
$location = redirect_lookup($url);
|
||||||
if ($location == null) {
|
if (!($location != null)) {
|
||||||
// Try and identify a redirect by the path.
|
// Try and identify a redirect by the path.
|
||||||
$location = redirect_lookup($url_parts["path"]);
|
$location = redirect_lookup($url_parts["path"]);
|
||||||
}
|
}
|
||||||
if ($location != null) {
|
if ($location != null) {
|
||||||
header("Location: ".$location, true, 307);
|
header("Location: ".$location, true, 307);
|
||||||
} else {
|
die();
|
||||||
header("Location: https://www.xaymar.com/404.html");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// In all other cases, just redirect to 404.
|
// In all other cases, just redirect to 404.
|
||||||
header("Location: https://www.xaymar.com/404.html");
|
header("Location: https://www.xaymar.com/404.html");
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
//header("Service Unavailable", true, 503);
|
|
||||||
header("Retry-After: 30", true, 503);
|
header("Retry-After: 30", true, 503);
|
||||||
echo($e);
|
echo($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//die();
|
die();
|
||||||
Reference in New Issue
Block a user