diff --git a/README.md b/README.md
new file mode 100644
index 0000000..a6fd2e9
--- /dev/null
+++ b/README.md
@@ -0,0 +1,4 @@
+shortURL
+========
+
+Forked from http://git.cphyc.me/cgit.cgi/tinyURL
diff --git a/misc/bg.png b/bg.png
similarity index 100%
rename from misc/bg.png
rename to bg.png
diff --git a/config.example.php b/config.example.php
new file mode 100644
index 0000000..7558a0b
--- /dev/null
+++ b/config.example.php
@@ -0,0 +1,5 @@
+ 1 || count($_GET) < 1)
-{
- if (isset($_GET['add']) && $_GET['url'])
+if (count($_GET) != 1) {
+ if (isset($_GET['add']) && !empty($_GET['url'])) {
$default_url = htmlspecialchars($_GET['url']);
- else
+ }
+ else {
$default_url = "";
+ }
?>
-
-
-
-
- Réduis moi!
-
-
-
-
-
C'est trop long ...
-
-
-
+
+
+
+
+ Shorten me
+
+
+
+
It's too long…
+
+
+
= $_CONFIG['SAVED_URL'])
- {
- // Delete the first element
- array_shift($data);
- }
- // Add that to the array
- array_push($data, $that);
- return $data;
+function add($that) {
+ global $_CONFIG;
+ global $data;
+ if (count($data) >= SAVED_URL)
+ {
+ // Delete the first element
+ array_shift($data);
+ }
+ // Add that to the array
+ array_push($data, $that);
+ return $data;
}
-if(empty($_POST['url']))
-{
- header('location : message.php?m=1');
+if(empty($_POST['url'])) {
+ header('location : message.php?m=1');
+}
+else {
+ if (is_readable(DATA_DIR.ASSOC_NAME))
+ $rawData = file_get_contents(DATA_DIR.ASSOC_NAME);
+ else
+ {
+ touch(DATA_DIR.ASSOC_DIR);
+ $rawData = "";
+ }
+ if (empty($rawData))
+ $data = array();
+ else
+ $data = unserialize($rawData);
}
-else
-{
- if (is_readable($_CONFIG['DATA_DIR'].$_CONFIG['ASSOC_NAME']))
- $rawData = file_get_contents($_CONFIG['DATA_DIR'].$_CONFIG['ASSOC_NAME']);
- else
- {
- touch($_CONFIG['DATA_DIR'].$_CONFIG['ASSOC_DIR']);
- $rawData = "";
- }
- if (empty($rawData))
- $data = array();
- else
- $data = unserialize($rawData);
- }
?>
-
-
- Réduit moi !
-
-
-
-
-
C'était trop long !
+
+
+ Shorten me !
+
+
+
+
It was too long !
$url, "short"=>$short);
- // Add the association at the end of $data array
- $data = add($array);
- // Save it in the file
- file_put_contents($_CONFIG['DATA_DIR'].$_CONFIG['ASSOC_NAME'], serialize($data));
- // Echoes the result
- $new_url = $_CONFIG['BASE_URL'].'/?'.$short;
+if (isset($_POST['short']) && $_POST['short'] != "") {
+ $short = htmlspecialchars($_POST['short']);
+}
+else {
+ $short = dechex(crc32($_POST['url']));
+}
+if (isset($_POST['url']) && $_POST['url'] != "") {
+ $url = htmlspecialchars($_POST['url']);
+ $array = array("url"=>$url, "short"=>$short);
+ // Add the association at the end of $data array
+ $data = add($array);
+ // Save it in the file
+ file_put_contents(DATA_DIR.ASSOC_NAME, serialize($data));
+ // Echoes the result
+ $new_url = $BASE_URL.'/?'.$short;
?>
-