From: Michael Tremer Date: Fri, 15 Aug 2008 11:52:17 +0000 (+0200) Subject: Replaced the old perl redirector by a new one in python. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2580619ca80505a44a0558e3b9221ac558bce375;p=ipfire.org.git Replaced the old perl redirector by a new one in python. --- diff --git a/source/index.pl b/source/index.pl deleted file mode 120000 index 568c5b2b..00000000 --- a/source/index.pl +++ /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 index 00000000..122a725f --- /dev/null +++ b/source/index.py @@ -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 index 746e2634..00000000 --- a/www/index.pl +++ /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 index 00000000..6b954ad1 --- /dev/null +++ b/www/index.py @@ -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