diff --git a/Website/index.php b/Website/index.php index ee02d25..6d890dd 100644 --- a/Website/index.php +++ b/Website/index.php @@ -1,3 +1,55 @@ +connect_errno > 0) die('Unable to connect to database [' . $shortdb->connect_error . '] - Check dbsettings.php'); + + // This has been depreciated. Still here for backwards compatibility with existing links + if(!empty($_GET['l'])){ + $link = $shortdb->real_escape_string(strtolower(stripslashes(strip_tags($_GET['l'])))); + $link = str_replace('/', '', $link); + $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"); + exit(5); // 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); + + if($key == "stats"){ header("location:http://lob.li/stats.php"); exit(11); } + if($key == "resolv"){ header("location:http://lob.li/resolve.php"); exit(12); } + if($key == "about"){ header("location:http://lob.li/about.php"); exit(13); } + + $link = $shortdb->real_escape_string(strtolower(stripslashes(strip_tags($key)))); + $link = str_replace('/', '', $link); + $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"); + exit(5); // Stop script execution to save on resources + } + } + } + + */ +?>
@@ -18,55 +70,25 @@ -