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