From 92babb43a2a0041a71b54db35cbc9d2fba908a63 Mon Sep 17 00:00:00 2001
From: root
Date: Thu, 27 Nov 2014 02:41:21 +0100
Subject: Rewrote the linkshorter.
---
linkshorter/goto.php | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
(limited to 'linkshorter/goto.php')
diff --git a/linkshorter/goto.php b/linkshorter/goto.php
index d77e1e2..f42705f 100644
--- a/linkshorter/goto.php
+++ b/linkshorter/goto.php
@@ -1,13 +1,26 @@
get($_GET["goto"]);
-if( ! $url || $url == "" ){
- do_output("
This url wasn't found on this server.
", "404 Not Found", false, "404 - Not found
");
+if ( ! isset($_REQUEST["short"]) || $_REQUEST["short"] == "" ){
+ header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
+ _do_output("Failure!", "Requested ID not found.");
}
-header($_SERVER['SERVER_PROTOCOL'] . " 301 Moved Permanently");
-header("Location: ".$url);
-exit;
+$db = new Database(REDIS_CONNECT, REDIS_SELECT);
+
+if ( ! $db->exists($_REQUEST["short"])){
+
+ require 'view/templ-notfound.php';
+
+} else {
+ $options = json_decode( $db->get($_REQUEST["short"]), true );
+
+ if ( $options["password"] == "" ){
+ redirect($options["url"]);
+ } else {
+ require 'view/templ-password.php';
+ }
+}
--
cgit v1.2.3