summaryrefslogtreecommitdiffstats
path: root/www/index.cgi
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-03-27 11:21:50 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-03-27 11:21:50 +0000
commitd6023a7adee17628e0ec4bad02e10199c1165bdb (patch)
treeff133f4507b5c388094401093c224fff22215395 /www/index.cgi
parente8c6b2052b11d85b8836a0c07e493b9562dd11eb (diff)
downloadrockbox-d6023a7adee17628e0ec4bad02e10199c1165bdb.tar.gz
rockbox-d6023a7adee17628e0ec4bad02e10199c1165bdb.tar.bz2
rockbox-d6023a7adee17628e0ec4bad02e10199c1165bdb.zip
Initial version
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@34 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'www/index.cgi')
-rwxr-xr-xwww/index.cgi41
1 files changed, 41 insertions, 0 deletions
diff --git a/www/index.cgi b/www/index.cgi
new file mode 100755
index 0000000000..a340a2e5ac
--- /dev/null
+++ b/www/index.cgi
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+
+# A very simple load balancing script:
+# If more than $nlim hits in under $tlim seconds, redirect to $mirror.
+#
+# 2002-01-24 Bjrn Stenberg <bjorn@haxx.se>
+
+# redirect is triggered by more than:
+$nlim = 10; # accesses in...
+$tlim = 10; # seconds
+$mirror = "http://rockbox.sourceforge.net/bjorn.haxx.se/rockbox/";
+
+open FILE, "+<.load" or die "Can't open .load: $!";
+flock FILE, LOCK_EX;
+@a = <FILE>;
+if ( scalar @a > $nlim ) {
+ $first = shift @a;
+}
+else {
+ $first = $a[0];
+}
+$now = time();
+@a = ( @a, "$now\n" );
+truncate FILE, 0;
+seek FILE, 0, 0;
+for ( @a ) {
+ print FILE $_;
+}
+flock FILE, LOCK_UN;
+close FILE;
+
+$diff = $now - $first;
+if ( $diff < $tlim ) {
+ print "Location: $mirror\n\n";
+}
+else {
+ print "Content-Type: text/html\n\n";
+ open FILE, "<main.html" or die "Can't open main.html: $!\n";
+ print <FILE>;
+ close FILE;
+}