summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot2014-11-27 15:55:25 +0100
committerroot2014-11-27 15:55:25 +0100
commit4f923b809b4e38e0639e253f428fb6c4df03ee67 (patch)
tree20d9d9ad9dae0316dad27358b4239b6f18f80e87
parent311ad398e06cd2eba270ea70ca5a326d03b490f9 (diff)
downloadtools.iamfabulous.de-4f923b809b4e38e0639e253f428fb6c4df03ee67.tar.gz
More structured + better UI
-rw-r--r--header/index.php16
-rw-r--r--header/robots.txt2
-rw-r--r--ifconfig/index.php2
-rw-r--r--index.php7
-rw-r--r--linkshorter/config.php3
-rw-r--r--linkshorter/css/style.css68
-rw-r--r--linkshorter/goto.php2
-rw-r--r--linkshorter/index.php10
-rw-r--r--linkshorter/view/templ-head.php5
-rw-r--r--linkshorter/view/templ-index.php17
-rw-r--r--linkshorter/view/templ-notfound.php14
-rw-r--r--tools/class/redis.php (renamed from linkshorter/class/db.php)0
-rw-r--r--tools/config.php11
13 files changed, 63 insertions, 94 deletions
diff --git a/header/index.php b/header/index.php
index a41912a..b57643d 100644
--- a/header/index.php
+++ b/header/index.php
@@ -4,6 +4,13 @@ if ( isset($_REQUEST['url']) && $_REQUEST['url'] != "" )
$set = true;
else
$set = false;
+
+require '../tools/config.php';
+
+if ( $_SERVER["HTTP_HOST"] == "header.iamfabulous.de"){
+ header($_SERVER["SERVER_PROTOCOL"] . " 301 Moved Permanently");
+ header("Location: " . __domain_ . "/header/");
+}
?>
<!doctype html>
<html>
@@ -22,7 +29,7 @@ else
}
?>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel='shortcut icon' href='../tools/favicon.ico' type='image/x-icon'>
+ <link rel='shortcut icon' href='<?php echo __domain_; ?>/tools/favicon.ico' type='image/x-icon'>
</head>
<body>
<?php require("../tools/navbar.php"); ?>
@@ -33,10 +40,9 @@ else
if ( $set ){
function getInfo($url, $method = "get", $customHeader = array()){
- $redis = new Redis();
- $redis ->connect("/var/run/redis/redis.sock");
- $redis->ping();
- $redis->select(9);
+ require '../tools/class/redis.php';
+
+ $redis = new Database(REDIS_CONNECT, 9);
$key = md5( $url . $method . serialize($customHeader) );
diff --git a/header/robots.txt b/header/robots.txt
new file mode 100644
index 0000000..1f53798
--- /dev/null
+++ b/header/robots.txt
@@ -0,0 +1,2 @@
+User-agent: *
+Disallow: /
diff --git a/ifconfig/index.php b/ifconfig/index.php
index b87d316..83e03ed 100644
--- a/ifconfig/index.php
+++ b/ifconfig/index.php
@@ -19,7 +19,7 @@ if ( empty($_GET) ){
if ( ! isset($_GET["ip"]) || $_GET["ip"] == "" ){
$ip = $_SERVER["REMOTE_ADDR"];
} else {
- if( preg_match("/([0-9]+\.){3}[0-9]+/", $ip) ){
+ if( preg_match("/([0-9]+\.){3}[0-9]+/", $_GET["ip"]) ){
$ip = $_GET["ip"];
} else {
$ip = gethostbyname($_GET["ip"]);
diff --git a/index.php b/index.php
index 7996b07..c190d2e 100644
--- a/index.php
+++ b/index.php
@@ -8,12 +8,7 @@
<?php echo file_get_contents("./tools/style.css"); ?>
</style>
<noscript><style>.navbar{margin-bottom:0;}</style></noscript>
- <?php if ( ! $set) { ?>
- <title>Check HTTP Headers online!</title>
- <?php } else {
- echo '<title>Header: ' . htmlentities($_REQUEST['url']) .'</title>';
- }
- ?>
+ <title>Tools | iamfabulous.de</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel='shortcut icon' href='../tools/favicon.ico' type='image/x-icon'>
</head>
diff --git a/linkshorter/config.php b/linkshorter/config.php
index 4b38311..298d9f0 100644
--- a/linkshorter/config.php
+++ b/linkshorter/config.php
@@ -1,7 +1,8 @@
<?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");
+
+require '../tools/config.php';
diff --git a/linkshorter/css/style.css b/linkshorter/css/style.css
deleted file mode 100644
index b5aa321..0000000
--- a/linkshorter/css/style.css
+++ /dev/null
@@ -1,68 +0,0 @@
-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/goto.php b/linkshorter/goto.php
index f42705f..f459dc6 100644
--- a/linkshorter/goto.php
+++ b/linkshorter/goto.php
@@ -1,6 +1,6 @@
<?php
-require 'class/db.php';
+require '../tools/class/redis.php';
require 'config.php';
require 'functions.php';
diff --git a/linkshorter/index.php b/linkshorter/index.php
index cca4f20..8d05977 100644
--- a/linkshorter/index.php
+++ b/linkshorter/index.php
@@ -1,18 +1,18 @@
<?php
require 'functions.php';
require 'config.php';
-require 'class/db.php';
+require '../tools/class/redis.php';
if ( ! isset($_REQUEST['url']) || $_REQUEST['url'] == "" ){
-if ( ! isset($_REQUEST['checkpassword']) || $_REQUEST['checkpassword'] != 1 )
+ if ( ! isset($_REQUEST['checkpassword']) || $_REQUEST['checkpassword'] != 1 )
require 'view/templ-index.php';
else {
if ( ! isset($_REQUEST["short"]) || $_REQUEST["short"] == "" ){
- header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
- _do_output("Failure!", "Requested ID not found.");
+ require 'view/templ-notfound.php';
+ exit;
}
$db = new Database(REDIS_CONNECT, REDIS_SELECT);
@@ -73,5 +73,5 @@ if ( ! isset($_REQUEST['checkpassword']) || $_REQUEST['checkpassword'] != 1 )
}
}
- _do_output("Success!", "Your short link is " . SHORTDOMAIN . htmlentities($options["short"]) . ".");
+ _do_output("Success!", "Your short link is <a href=\"" . SHORTDOMAIN . htmlentities($options["short"]) . "\" title=\"".htmlentities($options["url"])."\">". SHORTDOMAIN . htmlentities($options["short"]) ."</a>");
}
diff --git a/linkshorter/view/templ-head.php b/linkshorter/view/templ-head.php
index 2eee43c..4dd76d5 100644
--- a/linkshorter/view/templ-head.php
+++ b/linkshorter/view/templ-head.php
@@ -1,3 +1,6 @@
+<?php
+ require '../tools/config.php';
+?>
<!doctype html>
<html>
<head>
@@ -9,7 +12,7 @@
<?php echo file_get_contents("../tools/style.css"); ?>
.grey { color: #737373;}
</style>
- <link rel='shortcut icon' href='../tools/favicon.ico' type='image/x-icon'>
+ <link rel='shortcut icon' href='<?php echo __domain_; ?>/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
index 17b042e..46ff6a8 100644
--- a/linkshorter/view/templ-index.php
+++ b/linkshorter/view/templ-index.php
@@ -1,6 +1,9 @@
<?php
$title= "Link Shorter";
require 'view/templ-head.php';
+
+ if ( $_scheme . $_SERVER["HTTP_HOST"] != __domain_ )
+ redirect(__domain_ . "/linkshorter/");
?>
<div class="container">
<div class="text-center">
@@ -13,27 +16,31 @@
<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">
+ <input id="url" name="url" placeholder="Enter a URL to shorten..." 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>
+ <h4>Options:</h4>
+ </div>
+
+ <div class="form-group">
+ <label class="col-md-4 control-label grey" for="short">Query String</label>
<div class="col-md-4">
- <input id="short" name="short" placeholder="Your own query string here." class="form-control input-md" type="text">
+ <input id="short" name="short" placeholder="Your own query string here. (optional)" 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>
+ <label class="col-md-4 control-label grey" for="password">Password</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>
+ <label class="col-md-4 control-label grey" for="ttl">Expires</label>
<div class="col-md-4">
<input id="ttl" name="ttl" class="form-control input-md" type="number" min="0">
<span class="help-block text-left">Choose how long the shortlink should be valid. (In seconds)</span>
diff --git a/linkshorter/view/templ-notfound.php b/linkshorter/view/templ-notfound.php
new file mode 100644
index 0000000..66d654b
--- /dev/null
+++ b/linkshorter/view/templ-notfound.php
@@ -0,0 +1,14 @@
+<?php
+ header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
+ header("X-Request-Id: " . $_REQUEST["short"]);
+ $title= "404 Not Found";
+ require 'view/templ-head.php';
+?>
+<div class="container text-center pagination-centered">
+ <div class="row">
+ <h1>Failure - Not Found</h1>
+ <hr>
+ <h4>The requested URL ('<?php echo htmlentities($_SERVER["REQUEST_URI"]); ?>') wasn't found on this server.</h4>
+ </div>
+</div>
+ <?php require("../tools/footer.php"); ?>
diff --git a/linkshorter/class/db.php b/tools/class/redis.php
index 7713487..7713487 100644
--- a/linkshorter/class/db.php
+++ b/tools/class/redis.php
diff --git a/tools/config.php b/tools/config.php
index d4b6071..eb4b329 100644
--- a/tools/config.php
+++ b/tools/config.php
@@ -1,3 +1,12 @@
<?php
-define("__domain_", "http://tools.iamfabulous.de");
+$_scheme = "http://";
+
+if ( isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] != "")
+ $_scheme = "https://";
+
+if ( ! defined("__domain_") )
+ define("__domain_", $_scheme."tools.iamfabulous.de");
+
+if ( ! defined("REDIS_CONNECT") )
+ define("REDIS_CONNECT", "/var/run/redis/redis.sock");