From d19f7f8ab8972169e78a69738628064e1bb834ee Mon Sep 17 00:00:00 2001 From: Arctic Code Date: Wed, 29 Jan 2014 01:52:03 -0600 Subject: [PATCH] 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 --- index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index ddafe1d..5c81c85 100644 --- a/index.php +++ b/index.php @@ -13,7 +13,7 @@ $catchVal = base_convert($catchVal.$catchid, 10, 36); $_SESSION['catch'] = $catchid.":".$catchVal; -/* -- Hopefully depreciated, testing /?id + // This has been depreciated. Still here for backwards compatibility with existing links if(!empty($_GET['l'])){ include('api/dbsettings.php'); $link = $shortdb->real_escape_string(strtolower(stripslashes(strip_tags($_GET['l'])))); @@ -22,11 +22,12 @@ if($row = $result->fetch_assoc()){ $link = $row['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)){ $key = key($_GET); include('api/dbsettings.php'); @@ -36,6 +37,7 @@ if($row = $result->fetch_assoc()){ $link = $row['link']; header("location:$link"); + exit(); // Stop script execution to save on resources } } }