summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linkshorter/class/db.php73
-rw-r--r--linkshorter/config.php7
-rw-r--r--linkshorter/css/style.css68
-rw-r--r--linkshorter/db.php16
-rw-r--r--linkshorter/error.php13
-rw-r--r--linkshorter/functions.php71
-rw-r--r--linkshorter/goto.php29
-rw-r--r--linkshorter/header.php18
-rw-r--r--linkshorter/index.php155
-rw-r--r--linkshorter/insert.php36
-rw-r--r--linkshorter/nginx.conf5
-rw-r--r--linkshorter/style.css21
-rw-r--r--linkshorter/view/templ-head.php15
-rw-r--r--linkshorter/view/templ-index.php55
-rw-r--r--linkshorter/view/templ-output.php12
-rw-r--r--linkshorter/view/templ-password.php35
16 files changed, 372 insertions, 257 deletions
diff --git a/linkshorter/class/db.php b/linkshorter/class/db.php
new file mode 100644
index 0000000..7713487
--- /dev/null
+++ b/linkshorter/class/db.php
@@ -0,0 +1,73 @@
+<?php
+
+class Database {
+
+ private $db;
+ public $error;
+
+ public function __construct($connect = false, $db = false){
+ $this->db = new Redis();
+
+ if ( ! $connect || ! $db )
+ return;
+
+ $this->connect($connect, $db);
+ }
+
+ public function connect($connect, $db){
+ try {
+ $this->db->connect($connect);
+ } catch (Exception $e){
+ $this->error = $e;
+ return false;
+ }
+
+ try {
+ $this->db->select($db);
+ } catch (Exception $e){
+ $this->error = $e;
+ return false;
+ }
+
+ try {
+ $this->db->ping();
+ } catch (Exception $e){
+ $this->error = $e;
+ return false;
+ }
+
+ return true;
+ }
+
+ public function expire($key, $ttl){
+ try {
+ $this->db->setTimeout($key, $ttl);
+ } catch (Exception $e){
+ $this->error = $e;
+ return false;
+ }
+ }
+
+ public function set($key, $value, $ttl = null){
+ if ( is_null($ttl) )
+ return $this->db->set($key, $value);
+ else
+ return $this->db->set($key, $value, (int)$ttl);
+ }
+
+ public function get($key){
+ return $this->db->get($key);
+ }
+
+ public function exists($key){
+ return $this->db->exists($key);
+ }
+
+ public function __destruct(){
+ try {
+ $this->db->close();
+ } catch (Exception $e){
+ return false;
+ }
+ }
+}
diff --git a/linkshorter/config.php b/linkshorter/config.php
new file mode 100644
index 0000000..4b38311
--- /dev/null
+++ b/linkshorter/config.php
@@ -0,0 +1,7 @@
+<?php
+
+define("REDIS_CONNECT", "/var/run/redis/redis.sock");
+define("REDIS_SELECT", 10);
+define("SHORTDOMAIN", "http://s.moehm.org/");
+define("ADMINDOMAIN", SHORTDOMAIN);
+define("PEPPER", "secretstring");
diff --git a/linkshorter/css/style.css b/linkshorter/css/style.css
new file mode 100644
index 0000000..b5aa321
--- /dev/null
+++ b/linkshorter/css/style.css
@@ -0,0 +1,68 @@
+html {
+ position: relative;
+ min-height: 100%;
+}
+
+body {
+ margin-bottom: 60px;
+}
+
+a {
+ color: #3083D6;
+}
+
+/* navbar */
+
+.navbar-default {
+ background-color: #3083D6 ;
+ border-color: #3083D6 ;
+ background: #3083D6 ;
+}
+
+.navbar-default .navbar-brand {
+ color: white;
+}
+
+.navbar-default .navbar-brand:hover,
+.navbar-default .navbar-brand:focus {
+}
+
+.navbar-default .navbar-nav > li > a {
+ color: white;
+}
+
+.noscript {
+ background-color: #dd5148;
+ color: white;
+}
+
+/* footer */
+
+.footer {
+ background-color: #3083D6 ;
+ border-color: #3083D6 ;
+ background: #3083D6 ;
+ color: white ;
+ position: absolute;
+ bottom: 0;
+ width: 100%;
+}
+
+.footer-a {
+ color: white;
+}
+
+.footer-a:hover {
+ color: white;
+ text-decoration: underline;
+}
+
+.underline {
+ text-decoration: underline;
+}
+
+.actives {
+ color: white !important;
+ text-decoration: underline;
+ font-weight: bold;
+}
diff --git a/linkshorter/db.php b/linkshorter/db.php
deleted file mode 100644
index 4dcf58a..0000000
--- a/linkshorter/db.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-$db = new Redis();
-$db->connect('/var/run/redis/redis.sock');
-
-try {
- $db->ping();
-} catch (Exception $e){
- do_output("<p>No connection to the database established.</p>", "500 Server Failure", false, "<h1>Redis went away</h1>");
-}
-
-try {
- $db->select(1);
-} catch (Exception $e){
- do_output("<p>No connection to the database established.</p>", "500 Server Failure", false, "<h1>Redis went away</h1>");
-}
diff --git a/linkshorter/error.php b/linkshorter/error.php
deleted file mode 100644
index 92ba713..0000000
--- a/linkshorter/error.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-require 'functions.php';
-ob_start("sanitize_output");
-
-switch($_GET["e"]){
- case("404"):
- do_output("<p><strong>The requested url ( ".htmlentities($_SERVER['REQUEST_URI'])." ) wasn't found on this server.</strong></p>", "404 Not Found", false, "<h1>400 - Not Found</h1>");
- break;
-
- default:
- do_output("<p>There was a failure and your request can't be proceeded.</p>", "500 Error", false, "<h1>Error!</h1>");
-}
diff --git a/linkshorter/functions.php b/linkshorter/functions.php
index 7fa8cff..720fb4d 100644
--- a/linkshorter/functions.php
+++ b/linkshorter/functions.php
@@ -1,59 +1,32 @@
<?php
-function do_output($reason, $httpcode, $ajax = true, $heading = NULL){
- header ($_SERVER['SERVER_PROTOCOL'] . " " . $httpcode);
- if( $ajax ){
- echo $reason;
- ob_end_flush();
- exit;
- }
-?>
-<!doctype html>
-<html>
-<head>
- <meta charset="utf-8">
- <title>Link Shorter</title>
- <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
- <!--style>html{position:relative;min-height:100%}body{margin-bottom:60px}.footer{position:absolute;bottom:0;width:100%}#copyright-text{text-decoration:underline;color:#333}</style-->
- <style>
- <?php echo file_get_contents("../tools/style.css"); ?>
- </style>
- <noscript><style>.navbar{margin-bottom:0;}</style></noscript>
- <link rel='shortcut icon' href='../tools/favicon.ico' type='image/x-icon'>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
-</head>
- <?php require("../tools/navbar.php"); ?>
-<div class="container text-center pagination-centered">
- <div class="row">
- <?php echo $heading; ?>
- <hr>
- </div>
- <div class="text-center">
- <?php echo $reason; ?>
- </div>
-</div>
- <?php require("../tools/footer.php"); ?>
-</body>
-<?php
- ob_end_flush();
+function _do_output($heading, $reason){
+
+ require 'view/templ-output.php';
+
exit;
+
}
-function sanitize_output($buffer) {
+function getToken(){
- $search = array(
- '/\>[^\S ]+/s', // strip whitespaces after tags, except space
- '/[^\S ]+\</s', // strip whitespaces before tags, except space
- '/(\s)+/s' // shorten multiple whitespace sequences
- );
+ $db = $GLOBALS["db"];
- $replace = array(
- '>',
- '<',
- '\\1'
- );
+ do {
+ $arr = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
- $buffer = preg_replace($search, $replace, $buffer);
+ $short="";
+ for ($i=0;$i<5;$i++){
+ $r = mt_rand(0, count($arr)-1);
+ $short.=$arr[$r];
+ }
+ } while( $db->exists($short) );
- return $buffer;
+ return $short;
+}
+
+function redirect($goto){
+ header($_SERVER["SERVER_PROTOCOL"] . " 301 Moved Permanently");
+ header("Location: " . $goto);
+ exit;
}
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';
+ }
+}
diff --git a/linkshorter/header.php b/linkshorter/header.php
deleted file mode 100644
index c207321..0000000
--- a/linkshorter/header.php
+++ /dev/null
@@ -1,18 +0,0 @@
- <nav class="navbar navbar-default navbar-custom" role="navigation">
- <div class="container">
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbarCollapse">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="/">Home</a>
- </div>
- <div class="collapse navbar-collapse" id="navbarCollapse">
- <ul class="nav navbar-nav">
- <li>
- <a href="/rules" >Help</a>
- </li>
- </ul>
- </div>
- </div>
- </nav>
diff --git a/linkshorter/index.php b/linkshorter/index.php
index 1d56be5..c60bc82 100644
--- a/linkshorter/index.php
+++ b/linkshorter/index.php
@@ -1,114 +1,77 @@
<?php
require 'functions.php';
-require 'db.php';
+require 'config.php';
+require 'class/db.php';
-//ob_start("sanitize_output");
-ob_start();
+if ( ! isset($_REQUEST['url']) || $_REQUEST['url'] == "" ){
+if ( ! isset($_REQUEST['checkpassword']) || $_REQUEST['checkpassword'] != 1 )
-if ( $_SERVER['REQUEST_METHOD'] != 'POST'){
+ require 'view/templ-index.php';
-/*
- $key = "lscache_" . md5( strtolower($_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"].$_SERVER["QUERY_STRING"]));
- if ( $db->exists($key) ) {
- header("X-Cache: Hit");
- echo $db->get($key);
- ob_end_flush();
- exit;
+ else {
+
+ if ( ! isset($_REQUEST["short"]) || $_REQUEST["short"] == "" ){
+ header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
+ _do_output("Failure!", "Requested ID not found.");
+ }
+
+ $db = new Database(REDIS_CONNECT, REDIS_SELECT);
+
+ $options = json_decode( $db->get($_REQUEST["short"]), true );
+
+ if ( password_verify( $_REQUEST["password"] . PEPPER, $options["password"] ) )
+ redirect($options["url"]);
+ else
+ _do_output("Failure!", "Wrong password supplied");
}
-*/
-
-?>
-<!doctype html>
-<html>
-<head>
- <meta charset="utf-8">
- <title>Link Shorter</title>
- <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
- <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
- <style>
- <?php echo file_get_contents("../tools/style.css"); ?>
- </style>
- <noscript><style>.navbar{margin-bottom:0;}</style></noscript>
- <link rel='shortcut icon' href='../tools/favicon.ico' type='image/x-icon'>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
-</head>
- <?php require("../tools/navbar.php"); ?>
- <div class="container">
- <div class="text-center">
- <div class="row center-block vertical-center">
- <form class="form-horizontal " method="POST">
- <fieldset>
-
- <legend class="text-centered"><h1>Amazing Linkshorter</h1>
- <p>Short your link and use a easy to remembery query string</p>
- </legend>
-
- <div class="form-group">
- <label class="col-md-4 control-label" for="url">Link:</label>
- <div class="col-md-5">
- <input id="url" name="url" placeholder="http://www.moehm.org/" class="form-control input-md" required="" type="text">
-
- </div>
- </div>
-
- <div class="form-group">
- <label class="col-md-4 control-label" for="short">(optional)</label>
- <div class="col-md-4">
- <input id="short" name="short" placeholder="Your own query string here." class="form-control input-md" type="text">
-
- </div>
- </div>
-
- <div class="form-group">
- <label class="col-md-4 control-label" for="singlebutton"></label>
- <div class="col-md-4">
- <button id="singlebutton" name="singlebutton" class="btn btn-primary" type="submit">Short!</button>
- </div>
- </div>
-
- </fieldset>
- </form>
- </div>
- </div>
- </div>
- <?php require("../tools/footer.php"); ?>
-</body>
-<?php
- $html = ob_get_contents();
- $db->set($key, $html, 3600);
- ob_end_flush();
} else {
- if ( empty($_POST["url"]) || $_POST["url"] == "" ){
- do_output("<p>We need a link to be shortened.</p>", "400 Client Failed", false, "<h1>Missing URL</h1>");
- }
+ $url = trim($_REQUEST['url']);
- if ( ! preg_match("/^[a-z]+:\/\/[a-z0-9_]+/i", $_POST["url"]) ){
- do_output("<p>Only schemas like http:// or ftp:// are supported.</p>", "400 Client Failed", false, "<h1>This does not look like an url</h1>");
+ if( ! preg_match("/^https?:\/\//", $url) ){
+ $heading = "Failure!";
+ $reason = "This doesn't look like a valid URL.";
+ _do_output($heading, $reason);
}
+ $options = array("url" => $url);
+ if ( ! isset($_REQUEST["short"]) || $_REQUEST["short"] == "" )
+ $options["short"] = "";
+ else
+ $options["short"] = $_REQUEST["short"];
+
+ if ( ! isset($_REQUEST["ttl"]) || $_REQUEST["ttl"] == "" )
+ $options["ttl"] = "";
+ else {
+ if ( ! preg_match( "/^[0-9]+$/", trim($_REQUEST["ttl"]) ) ){
+ _do_output("Failure", "Your Lifetime doesn't look like a valid number.");
+ }
+ $options["ttl"] = $_REQUEST["ttl"];
+ }
- $hash = md5($_POST["url"]);
- if( ! empty($_POST["short"]) && $_POST["short"] != "" ) {
- $short = $_POST["short"];
- if ( $db->exists($short) == 1 && $_POST["url"] != $db->get($short) )
- do_output("<p>Someone else has already a registered entry under '".htmlentities($short)."'.</p>", "422 Unprocessable Entity", false, "<h1>Query string already exists.</h1>");
+ if ( ! isset($_REQUEST["password"]) || $_REQUEST["password"] == "" )
+ $options["password"] = "";
+ else
+ $options["password"] = password_hash($_REQUEST["password"] . PEPPER, PASSWORD_DEFAULT);
+
+ $db = new Database(REDIS_CONNECT, REDIS_SELECT);
+
+ if ( $options["short"] != "" && $db->exists($options["short"]) )
+ _do_output("Failure", "Query string '".htmlentities($options["short"])."' already taken. Please choose a different one.");
+
+ if ( $options["short"] == "" )
+ $options["short"] = getToken();
+
+ if ( $options["ttl"] != "" ){
+ if ( ! $db->set($options["short"], json_encode($options), $options["ttl"]) ){
+ _do_output("Failure", "Database went away. :(");
+ }
} else {
- if( ! $short = $db->get($hash) ){
- $arr = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
-
- do {
- $short="";
- for ($i=0;$i<5;$i++){
- $r = mt_rand(0, count($arr)-1);
- $short.=$arr[$r];
- }
- } while ( $db->exists($short) );
- $db->set($hash, $short);
+ if ( ! $db->set($options["short"], json_encode($options)) ){
+ _do_output("Failure", "Database went away. :(");
}
}
- $db->set($short, $_POST["url"]);
- do_output("<p>Your short link for <a href=\"".htmlentities($_POST["url"])."\">".htmlentities($_POST["url"])."</a> is <br> http://s.moehm.org/".$short."</p>", "200 OK", false, "<h1>Success</h1>");
+ _do_output("Success!", "Your shortlink is " . SHORTDOMAIN . htmlentities($options["short"]) . ".");
}
diff --git a/linkshorter/insert.php b/linkshorter/insert.php
deleted file mode 100644
index 94d01a3..0000000
--- a/linkshorter/insert.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-if ( $_SERVER['REQUEST_METHOD'] != 'POST'){
- header($_SERVER['SERVER_PROTOCOL'] . " 301 Moved Permanently");
- header("Location: http://". $_SERVER["HTTP_HOST"] . "/");
- exit;
-}
-
-require 'functions.php';
-
-if ( empty($_POST["url"]) || $_POST["url"] == "" ){
- failure("<p>We need a link to be shortened.</p>", false, "400 Client Failed", "<h1>Missing URL</h1>");
-}
-
-if ( ! preg_match("/^[a-z]+:\/\/[a-z0-9_]+/i", $_POST["url"]) ){
- failure("<p>Only schemas like http:// or ftp:// are supported.</p>", false, "400 Client Failed", "<h1>This does not look like an url</h1>");
-}
-
-require 'db.php';
-
-$hash = md5($_POST["url"]);
-if( ! $short = $db->get($hash)){
-
- $arr = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
-
- $short="";
- for ($i=0;$i<5;$i++){
- $r = mt_rand(0, count($arr)-1);
- $short.=$arr[$r];
- }
-
- $db->set($short, $_POST["url"]);
- $db->set($hash, $short);;
-}
-
-failure("<p>Your short link for <a href=\"".htmlentities($_POST["url"])."\">".htmlentities($_POST["url"])."</a> is <br> <a href=\"http://".$_SERVER["HTTP_HOST"] . "/-" . $short ."\">http://".$_SERVER["HTTP_HOST"]."/-".$short."</a></p>", false, "200 OK", "<h1>Success</h1>");
diff --git a/linkshorter/nginx.conf b/linkshorter/nginx.conf
new file mode 100644
index 0000000..a4af9cb
--- /dev/null
+++ b/linkshorter/nginx.conf
@@ -0,0 +1,5 @@
+location = / {}
+
+location / {
+ rewrite ^/(.*) /goto.php?short=$1 last;
+}
diff --git a/linkshorter/style.css b/linkshorter/style.css
deleted file mode 100644
index c762039..0000000
--- a/linkshorter/style.css
+++ /dev/null
@@ -1,21 +0,0 @@
-html {
- position: relative;
- min-height: 100%;
-}
-
-body {
- margin-bottom: 60px;
-}
-
-/* footer */
-
-.footer {
- position: absolute;
- bottom: 0;
- width: 100%;
-}
-
-#copyright-text {
- text-decoration: underline;
- color: #333;
-}
diff --git a/linkshorter/view/templ-head.php b/linkshorter/view/templ-head.php
new file mode 100644
index 0000000..abc29bf
--- /dev/null
+++ b/linkshorter/view/templ-head.php
@@ -0,0 +1,15 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title><?php echo $title; ?></title>
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
+ <style>
+ <?php echo file_get_contents("../tools/style.css"); ?>
+ .grey { color: #737373;}
+ </style>
+ <link rel='shortcut icon' href='../tools/favicon.ico' type='image/x-icon'>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+</head>
+ <?php require("../tools/navbar.php"); ?>
+
diff --git a/linkshorter/view/templ-index.php b/linkshorter/view/templ-index.php
new file mode 100644
index 0000000..b78b5c7
--- /dev/null
+++ b/linkshorter/view/templ-index.php
@@ -0,0 +1,55 @@
+<?php
+ $title= "Link Shorter";
+ require 'view/templ-head.php';
+?>
+ <div class="container">
+ <div class="text-center">
+ <div class="row center-block vertical-center">
+ <form class="form-horizontal " method="POST" action="">
+ <fieldset>
+
+ <legend class="text-centered"><h1>Amazing Linkshorter</h1><p>Short your link and use a easy to remembery query string.</p></legend>
+
+ <div class="form-group">
+ <label class="col-md-4 control-label" for="url">Link:</label>
+ <div class="col-md-5">
+ <input id="url" name="url" placeholder="http://www.moehm.org/" class="form-control input-md" required="" type="text">
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-md-4 control-label grey" for="short">(optional)</label>
+ <div class="col-md-4">
+ <input id="short" name="short" placeholder="Your own query string here." class="form-control input-md" type="text">
+ </div>
+ </div>
+
+ <!-- Password input-->
+ <div class="form-group">
+ <label class="col-md-4 control-label grey" for="password">(optional)</label>
+ <div class="col-md-4">
+ <input id="password" name="password" placeholder="Protect your link with a password." class="form-control input-md" type="password">
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-md-4 control-label grey" for="ttl">(optional)</label>
+ <div class="col-md-4">
+ <input id="ttl" name="ttl" class="form-control input-md" type="number">
+ <span class="help-block text-left">Choose how long the shortlink should be valid. (In seconds)</span>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-md-4 control-label" for="singlebutton"></label>
+ <div class="col-md-4">
+ <button id="singlebutton" name="singlebutton" class="btn btn-primary" type="submit">Short!</button>
+ </div>
+ </div>
+
+ </fieldset>
+ </form>
+ </div>
+ </div>
+ </div>
+ <?php require("../tools/footer.php"); ?>
diff --git a/linkshorter/view/templ-output.php b/linkshorter/view/templ-output.php
new file mode 100644
index 0000000..0ca6d29
--- /dev/null
+++ b/linkshorter/view/templ-output.php
@@ -0,0 +1,12 @@
+<?php
+ $title= $heading;
+ require 'view/templ-head.php';
+?>
+<div class="container text-center pagination-centered">
+ <div class="row">
+ <h1><?php echo $heading; ?></h1>
+ <hr>
+ <h4><?php echo $reason; ?></h4>
+ </div>
+</div>
+ <?php require("../tools/footer.php"); ?>
diff --git a/linkshorter/view/templ-password.php b/linkshorter/view/templ-password.php
new file mode 100644
index 0000000..2be90f3
--- /dev/null
+++ b/linkshorter/view/templ-password.php
@@ -0,0 +1,35 @@
+<?php
+ $title= "Passwort Required | Link Shorter";
+ require 'view/templ-head.php';
+?>
+<div class="container text-center pagination-centered">
+ <div class="row">
+ <form class="form-horizontal" action="<?php echo ADMINDOMAIN; ?>" method="POST">
+ <fieldset>
+
+ <!-- Form Name -->
+ <legend><h1>Password Required</h1><p>Enter the correct password and you will be redirected.</p></legend>
+
+ <!-- Password input-->
+ <div class="form-group">
+ <label class="col-md-4 control-label" for="password">Password</label>
+ <div class="col-md-4">
+ <input id="password" name="password" placeholder="Password" class="form-control input-md" required="" type="password">
+ </div>
+ </div>
+ <input type="hidden" name="checkpassword" value="1">
+ <input type="hidden" name="short" value="<?php echo htmlentities($_REQUEST ["short"]); ?>">
+
+ <div class="form-group">
+ <label class="col-md-4 control-label" for="singlebutton"></label>
+ <div class="col-md-4">
+ <button id="singlebutton" name="singlebutton" class="btn btn-info" type="submit">Short!</button>
+ </div>
+ </div>
+
+ </fieldset>
+ </form>
+
+ </div>
+</div>
+ <?php require("../tools/footer.php"); ?>