From 4f923b809b4e38e0639e253f428fb6c4df03ee67 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 27 Nov 2014 15:55:25 +0100 Subject: More structured + better UI --- header/index.php | 16 +++++--- header/robots.txt | 2 + ifconfig/index.php | 2 +- index.php | 7 +--- linkshorter/class/db.php | 73 ------------------------------------- linkshorter/config.php | 3 +- linkshorter/css/style.css | 68 ---------------------------------- linkshorter/goto.php | 2 +- linkshorter/index.php | 10 ++--- linkshorter/view/templ-head.php | 5 ++- linkshorter/view/templ-index.php | 17 ++++++--- linkshorter/view/templ-notfound.php | 14 +++++++ tools/class/redis.php | 73 +++++++++++++++++++++++++++++++++++++ tools/config.php | 11 +++++- 14 files changed, 136 insertions(+), 167 deletions(-) create mode 100644 header/robots.txt delete mode 100644 linkshorter/class/db.php delete mode 100644 linkshorter/css/style.css create mode 100644 linkshorter/view/templ-notfound.php create mode 100644 tools/class/redis.php 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/"); +} ?> @@ -22,7 +29,7 @@ else } ?> - + @@ -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 @@ - - Check HTTP Headers online! - Header: ' . htmlentities($_REQUEST['url']) .''; - } - ?> + Tools | iamfabulous.de diff --git a/linkshorter/class/db.php b/linkshorter/class/db.php deleted file mode 100644 index 7713487..0000000 --- a/linkshorter/class/db.php +++ /dev/null @@ -1,73 +0,0 @@ -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 index 4b38311..298d9f0 100644 --- a/linkshorter/config.php +++ b/linkshorter/config.php @@ -1,7 +1,8 @@ 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 @@ ". SHORTDOMAIN . htmlentities($options["short"]) .""); } 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 @@ + @@ -9,7 +12,7 @@ .grey { color: #737373;} - + 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 @@
@@ -13,27 +16,31 @@
- +
- +

Options:

+
+ +
+
- +
- +
- +
Choose how long the shortlink should be valid. (In seconds) 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 @@ + +
+
+

Failure - Not Found

+
+

The requested URL ('') wasn't found on this server.

+
+
+ diff --git a/tools/class/redis.php b/tools/class/redis.php new file mode 100644 index 0000000..7713487 --- /dev/null +++ b/tools/class/redis.php @@ -0,0 +1,73 @@ +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/tools/config.php b/tools/config.php index d4b6071..eb4b329 100644 --- a/tools/config.php +++ b/tools/config.php @@ -1,3 +1,12 @@