summaryrefslogtreecommitdiff
path: root/www/index.cgi
diff options
context:
space:
mode:
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 @@
1#!/usr/bin/perl
2
3# A very simple load balancing script:
4# If more than $nlim hits in under $tlim seconds, redirect to $mirror.
5#
6# 2002-01-24 Björn Stenberg <bjorn@haxx.se>
7
8# redirect is triggered by more than:
9$nlim = 10; # accesses in...
10$tlim = 10; # seconds
11$mirror = "http://rockbox.sourceforge.net/bjorn.haxx.se/rockbox/";
12
13open FILE, "+<.load" or die "Can't open .load: $!";
14flock FILE, LOCK_EX;
15@a = <FILE>;
16if ( scalar @a > $nlim ) {
17 $first = shift @a;
18}
19else {
20 $first = $a[0];
21}
22$now = time();
23@a = ( @a, "$now\n" );
24truncate FILE, 0;
25seek FILE, 0, 0;
26for ( @a ) {
27 print FILE $_;
28}
29flock FILE, LOCK_UN;
30close FILE;
31
32$diff = $now - $first;
33if ( $diff < $tlim ) {
34 print "Location: $mirror\n\n";
35}
36else {
37 print "Content-Type: text/html\n\n";
38 open FILE, "<main.html" or die "Can't open main.html: $!\n";
39 print <FILE>;
40 close FILE;
41}