From de94f7312d5d20d494793edd8d182f8ca62d6744 Mon Sep 17 00:00:00 2001 From: Phyks Date: Thu, 10 Oct 2013 14:00:00 +0100 Subject: [PATCH] Refactor * gzip encoding * simplified configuration * various fixes --- config.example.php | 10 ++++++---- index.php | 23 +++++++++++++++-------- process.php | 25 +++++++++---------------- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/config.example.php b/config.example.php index 7558a0b..71dbad9 100644 --- a/config.example.php +++ b/config.example.php @@ -1,5 +1,7 @@ @@ -31,11 +37,11 @@ if (count($_GET) != 1) {

- +

Add this link to your bookmarks to shorten links in one click ! - RĂ©duis moi ! + Short link

@@ -45,6 +51,7 @@ if (count($_GET) != 1) { // Else, we redirect the visitor to the right URL else { // We get the shortened url + // TODO $get = each($_GET); $short = $get['key']; $url = BASE_URL; diff --git a/process.php b/process.php index 2c4b9c2..460039a 100644 --- a/process.php +++ b/process.php @@ -1,10 +1,9 @@ = SAVED_URL) + if (count($data) >= MAX_SAVED_URLS) { // Delete the first element array_shift($data); @@ -15,20 +14,15 @@ function add($that) { } if(empty($_POST['url'])) { - header('location : message.php?m=1'); + header('location : index.php'); } else { - if (is_readable(DATA_DIR.ASSOC_NAME)) - $rawData = file_get_contents(DATA_DIR.ASSOC_NAME); - else - { - touch(DATA_DIR.ASSOC_DIR); - $rawData = ""; + if (is_readable(DATA_FILE)) { + $data = unserialize(gzinflate(file_get_contents(DATA_DIR.ASSOC_NAME))); + } + else { + $data = array(); } - if (empty($rawData)) - $data = array(); - else - $data = unserialize($rawData); } ?> @@ -41,7 +35,6 @@ else {

It was too long !