From b62f922cb132fb0a98a6ce9724ee1a11895153d8 Mon Sep 17 00:00:00 2001 From: Arctic Code Date: Wed, 29 Jan 2014 01:31:27 -0600 Subject: [PATCH] Make short links two characters shorter By breaking up the $_GET array and grabbing the key (what used to be l), ignoring the value, we can shorten links by two more characters. This is kinda hacky since it does this for multiple get values -- Still need to test to see what happens with multiple link ids. I assume it will just go with the first id given --- index.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/index.php b/index.php index d41fdc6..d74135c 100644 --- a/index.php +++ b/index.php @@ -13,6 +13,7 @@ $catchVal = base_convert($catchVal.$catchid, 10, 36); $_SESSION['catch'] = $catchid.":".$catchVal; +/* -- Hopefully depreciated, testing /?id if(!empty($_GET['l'])){ include('api/dbsettings.php'); $link = $shortdb->real_escape_string(strtolower(stripslashes(strip_tags($_GET['l'])))); @@ -24,6 +25,21 @@ } } } +*/ + + if(!empty($_GET)){ + foreach($_GET as $key=>$value){ + include('api/dbsettings.php'); + $link = $shortdb->real_escape_string(strtolower(stripslashes(strip_tags($key)))); + $sql = "SELECT * FROM `links` WHERE `shortlink` = '$link' LIMIT 1;"; + if($result = $shortdb->query($sql)){ + if($row = $result->fetch_assoc()){ + $link = $row['link']; + header("location:$link"); + } + } + } + } if(isset($_GET['newbg'])){ echo "";