Keep old way to find short links to not break existing ones

I realized that every single existing link created with v4-2.8 or
earlier would break since it relies on the value of $_GET['l'].
This will keep the old links working, and to reduce server load a
little bit, we will exit after those header statements
This commit is contained in:
Arctic Code 2014-01-29 01:52:03 -06:00
parent b784347291
commit d19f7f8ab8

View File

@ -13,7 +13,7 @@
$catchVal = base_convert($catchVal.$catchid, 10, 36); $catchVal = base_convert($catchVal.$catchid, 10, 36);
$_SESSION['catch'] = $catchid.":".$catchVal; $_SESSION['catch'] = $catchid.":".$catchVal;
/* -- Hopefully depreciated, testing /?id // This has been depreciated. Still here for backwards compatibility with existing links
if(!empty($_GET['l'])){ if(!empty($_GET['l'])){
include('api/dbsettings.php'); include('api/dbsettings.php');
$link = $shortdb->real_escape_string(strtolower(stripslashes(strip_tags($_GET['l'])))); $link = $shortdb->real_escape_string(strtolower(stripslashes(strip_tags($_GET['l']))));
@ -22,11 +22,12 @@
if($row = $result->fetch_assoc()){ if($row = $result->fetch_assoc()){
$link = $row['link']; $link = $row['link'];
header("location:$link"); header("location:$link");
exit(); // Stop script execution to save on resources
} }
} }
} }
*/
// New way to check for valid short links, two characters shorter than the if statement above
if(!empty($_GET)){ if(!empty($_GET)){
$key = key($_GET); $key = key($_GET);
include('api/dbsettings.php'); include('api/dbsettings.php');
@ -36,6 +37,7 @@
if($row = $result->fetch_assoc()){ if($row = $result->fetch_assoc()){
$link = $row['link']; $link = $row['link'];
header("location:$link"); header("location:$link");
exit(); // Stop script execution to save on resources
} }
} }
} }