#!/usr/bin/perl

$mozilla = "Mozilla";
$imode = "DoCoMo";
$jsky = "J-PHONE";
$ezweb = "UP\.Browser";
$doti = "ASTEL";
$lmode = "L-mode";
$pda = "Windows CE|PalmScape|sharp pda browser|WorldTALK|DreamPassport|WebTV|Sonybrowser2|PDA";

# i-modeでは、相対パスはダメなようです。
# また順番に気をつけないとうまく振り分けられない場合があるようです

$agent = $ENV{'HTTP_USER_AGENT'};
if ($agent =~ /$pda/) {
print "Location: http://www2.sapporo-u.ac.jp/~jichikai/mobile/index.html\n";
} elsif ($agent =~ /$imode/) {
print "Location: http://www2.sapporo-u.ac.jp/~jichikai/mobile/index.html\n";
} elsif ($agent =~ /$lmode/) {
print "Location: http://www2.sapporo-u.ac.jp/~jichikai/mobile/index.html\n";
} elsif ($agent =~ /$jsky/) {
print "Location: http://www2.sapporo-u.ac.jp/~jichikai/mobile/index.html\n";
} elsif ($agent =~ /$ezweb/) {
print "Location: http://www2.sapporo-u.ac.jp/~jichikai/mobile/index.html\n";
} elsif ($agent =~ /$doti/) {
print "Location: http://www2.sapporo-u.ac.jp/~jichikai/mobile/index.html\n";
} elsif ($agent =~ /$mozilla/) {
print "Location: http://www2.sapporo-u.ac.jp/~jichikai/index2.html\n";
} else { 
print "Location: http://www2.sapporo-u.ac.jp/~jichikai/index.html\n";
}

print "Content-type: text/html\n\n";
