]> git.ipfire.org Git - ipfire.org.git/commitdiff
Replaced the old perl redirector by a new one in python.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 15 Aug 2008 11:52:17 +0000 (13:52 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 15 Aug 2008 11:52:17 +0000 (13:52 +0200)
source/index.pl [deleted symlink]
source/index.py [new symlink]
www/index.pl [deleted file]
www/index.py [new file with mode: 0755]

diff --git a/source/index.pl b/source/index.pl
deleted file mode 120000 (symlink)
index 568c5b2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../www/index.pl
\ No newline at end of file
diff --git a/source/index.py b/source/index.py
new file mode 120000 (symlink)
index 0000000..122a725
--- /dev/null
@@ -0,0 +1 @@
+../www/index.py
\ No newline at end of file
diff --git a/www/index.pl b/www/index.pl
deleted file mode 100755 (executable)
index 746e263..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/perl
-
-my $lang = "en";
-
-# Set language to german, else use english site
-if ($ENV{'HTTP_ACCEPT_LANGUAGE'} =~ /^de(.*)/) {
-       $lang = "de";
-}
-
-print "Status: 302 Moved\n";
-print "Pragma: no-cache\n";
-
-if ($ENV{'SERVER_NAME'} eq "source.ipfire.org") {
-       print "Location: /$lang/source.shtml\n";
-} elsif ($ENV{'SERVER_NAME'} eq "tracker.ipfire.org") {
-       print "Location: /$lang/tracker.shtml\n";
-} else {
-       print "Location: http://www.ipfire.org/$lang/index.shtml\n";
-}
-
-# End http header...
-print "\n";
diff --git a/www/index.py b/www/index.py
new file mode 100755 (executable)
index 0000000..6b954ad
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+
+import os
+import re
+
+sites = (
+                       ("ipfire.org", ("www.ipfire.org", None)),
+                       ("www.ipfire.org", (None, "index.shtml")),
+                       ("source.ipfire.org", (None, "source.shtml")),
+                       ("tracker.ipfire.org", (None, "tracker.shtml")),
+                       ("download.ipfire.org", (None, "download.shtml")),
+               )
+
+# Check language...
+if re.search(re.compile("^de(.*)"), os.environ["HTTP_ACCEPT_LANGUAGE"]):
+       language = "de"
+else:
+       language = "en"
+
+print "Status: 302 Moved"
+print "Pragma: no-cache"
+
+location = ""
+
+for (servername, destination) in sites:
+       if servername == os.environ["SERVER_NAME"]:
+               if destination[0]:
+                       location = "http://%s" % destination[0]
+               if destination[1]:
+                       location += "/%s/%s" % (language, destination[1])
+               break
+
+print "Location: %s" % location
+print # End the header