commit d787d726b7ec4670ed74d6f895e5d50a918afcc9 Author: Simon Lieb Date: Tue Jul 9 19:47:59 2013 +0200 Shuri - Simple shortener. diff --git a/index.php b/index.php new file mode 100644 index 0000000..d2e809b --- /dev/null +++ b/index.php @@ -0,0 +1,53 @@ +./?'.$urlhash.'
'; + echo 'As long as there is not collision you can shorten it up to 3 characters.'; + return 0; +} else if(!empty($_GET)) { + $urlhash = key($_GET); + + $hashfolder = substr($urlhash, 0, 2); + $hashfile = substr($urlhash, 2); + + $hashfolderpath = './db/' . $hashfolder; + $hashfilepath = $hashfolderpath . '/' . $hashfile; + + $findfiles = glob($hashfilepath . '*'); + + if(empty($findfiles)) { + echo 'No files.'; + return 1; + } else if (count($findfiles) > 1) { + foreach($findfiles as $file) { + $file = str_replace('/', '', substr($file, 5)); + echo './?'.$file.'
'; + } + return 1; + } + + $fullfilepath = current($findfiles); + + header('Location:' . file_get_contents($fullfilepath)); + return 0; +} + +echo './?url=<url>'; +return 0;