aboutsummaryrefslogtreecommitdiffstats
path: root/web/redirect.php
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2011-05-06 20:09:07 -0400
committerJason A. Donenfeld <Jason@zx2c4.com>2011-05-06 20:09:07 -0400
commitb7641975a6d3cbd0ac4addd336827a88835e6e04 (patch)
tree7374e9d3a0db0fbbe6d369e4636aa35e8fc2871a /web/redirect.php
parentRemove annoying alert. (diff)
downloadPhotoFloat-b7641975a6d3cbd0ac4addd336827a88835e6e04.tar.xz
PhotoFloat-b7641975a6d3cbd0ac4addd336827a88835e6e04.zip
Redirect from zen photo urls.
Diffstat (limited to 'web/redirect.php')
-rw-r--r--web/redirect.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/web/redirect.php b/web/redirect.php
new file mode 100644
index 0000000..d291fb6
--- /dev/null
+++ b/web/redirect.php
@@ -0,0 +1,31 @@
+<?php
+function cachePath($path) {
+ if ($path[0] == '/')
+ $path = substr($path, 1);
+ if ($path[strlen($path) - 1] == '/')
+ $path = substr($path, 0, strlen($path) - 1);
+ $path = str_replace('_-_', '-', str_replace('/', '-', str_replace(' ', '_', str_replace('(', '', str_replace(')', '', str_replace('#', '', str_replace('[', '', str_replace(']', '', str_replace('"', '', str_replace("'", '', strtolower($path)))))))))));
+ while (strpos($path, "--") !== false)
+ $path = str_replace("--", "-", $path);
+ while (strpos($path, "__") !== false)
+ $path = str_replace("__", "_", $path);
+ if (strlen(path) == 0)
+ $path = "root";
+
+ return $path;
+}
+
+$url = $_SERVER["SCRIPT_URL"];
+if ($url[strlen($url) - 1] == '/')
+ $url = substr($url, 0, strlen($url) - 1);
+
+if (strpos(strtolower($url), ".php") == strlen($url) - 4) {
+ $url = substr($url, 0, strlen($url) - 4);
+ $index = strrpos($url, "/");
+ $redirect = "/#".cachePath(substr($url, 0, $index))."/".cachePath(substr($url, $index));
+} else
+ $redirect = "/#".cachePath($url);
+
+header("Location: $redirect");
+
+?> \ No newline at end of file