From 92babb43a2a0041a71b54db35cbc9d2fba908a63 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 27 Nov 2014 02:41:21 +0100 Subject: Rewrote the linkshorter. --- linkshorter/insert.php | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 linkshorter/insert.php (limited to 'linkshorter/insert.php') 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 @@ -We need a link to be shortened.

", false, "400 Client Failed", "

Missing URL

"); -} - -if ( ! preg_match("/^[a-z]+:\/\/[a-z0-9_]+/i", $_POST["url"]) ){ - failure("

Only schemas like http:// or ftp:// are supported.

", false, "400 Client Failed", "

This does not look like an url

"); -} - -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("

Your short link for ".htmlentities($_POST["url"])." is
http://".$_SERVER["HTTP_HOST"]."/-".$short."

", false, "200 OK", "

Success

"); -- cgit v1.2.3