diff options
Diffstat (limited to 'linkshorter/goto.php')
| -rw-r--r-- | linkshorter/goto.php | 29 |
1 files changed, 21 insertions, 8 deletions
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 @@ <?php + +require 'class/db.php'; +require 'config.php'; require 'functions.php'; -ob_start("sanitize_output"); -require 'db.php'; -$url = $db->get($_GET["goto"]); -if( ! $url || $url == "" ){ - do_output("<p>This url wasn't found on this server.</p>", "404 Not Found", false, "<h1>404 - Not found</h1>"); +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'; + } +} |
