Fix glitchy redirects
This commit is contained in:
+10
-9
@@ -52,7 +52,8 @@ STR;
|
||||
|
||||
function insert_lookup($url) {
|
||||
global $STATEMENTS;
|
||||
|
||||
global $SQL;
|
||||
|
||||
$STATEMENTS['Insert']->bind_param('s', $url);
|
||||
if (!$STATEMENTS['Insert']->execute()) {
|
||||
throw new Exception($SQL['Handle']->errno." ".$SQL['Handle']->error);
|
||||
@@ -63,17 +64,17 @@ function insert_lookup($url) {
|
||||
|
||||
function increment_lookup($url) {
|
||||
global $STATEMENTS;
|
||||
|
||||
global $SQL;
|
||||
|
||||
$STATEMENTS['Increment']->bind_param('s', $url);
|
||||
if (!$STATEMENTS['Increment']->execute()) {
|
||||
throw new Exception($SQL['Handle']->errno." ".$SQL['Handle']->error);
|
||||
} else if (!$STATEMENTS['Increment']->get_result()) {
|
||||
throw new Exception($SQL['Handle']->errno." ".$SQL['Handle']->error);
|
||||
}
|
||||
}
|
||||
|
||||
function redirect_lookup($url) {
|
||||
global $STATEMENTS;
|
||||
global $SQL;
|
||||
|
||||
$STATEMENTS['LookUp']->bind_param('s', $url);
|
||||
if (!$STATEMENTS['LookUp']->execute()) {
|
||||
@@ -103,7 +104,7 @@ try { // Try and redirect user according to the full provided URI
|
||||
$url_parts = parse_url($url);
|
||||
|
||||
$location = null;
|
||||
// Try and identify a redirect by the full URI.
|
||||
// Try and identify a redirect by the full URI.
|
||||
$location = redirect_lookup($url);
|
||||
if ($location == null) {
|
||||
// Try and identify a redirect by the path.
|
||||
@@ -118,9 +119,9 @@ try { // Try and redirect user according to the full provided URI
|
||||
// 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);
|
||||
die($e);
|
||||
//header("Service Unavailable", true, 503);
|
||||
header("Retry-After: 30", true, 503);
|
||||
echo($e);
|
||||
}
|
||||
|
||||
die();
|
||||
//die();
|
||||
Reference in New Issue
Block a user