diff options
| author | root | 2014-11-27 02:41:21 +0100 |
|---|---|---|
| committer | root | 2014-11-27 02:41:21 +0100 |
| commit | 92babb43a2a0041a71b54db35cbc9d2fba908a63 (patch) | |
| tree | 8971101b53b6a6b12a092b456dc11a4dbfc034a3 /linkshorter/goto.php | |
| parent | 2b24f3ef0e800f878177973eefcb28380a292503 (diff) | |
| download | tools.iamfabulous.de-92babb43a2a0041a71b54db35cbc9d2fba908a63.tar.gz | |
Rewrote the linkshorter.
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'; + } +} |
