X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Findex.pl;h=9bf692ce288ef7f0461f82d4d5e69edfe3d9f7d4;hb=11849d4e65deae4c901913281176130508c8cbfe;hp=a4c16fd949c74e63e3e2afeb5e12295c2901f12d;hpb=c69d85040be1d4a1d3b1293f7fe1777cd3085cb6;p=wloh diff --git a/www/index.pl b/www/index.pl index a4c16fd..9bf692c 100755 --- a/www/index.pl +++ b/www/index.pl @@ -9,8 +9,10 @@ use POSIX; use Devel::Peek; use HTML::Entities; use Encode; +use utf8; use locale; require '../config.pm'; +require '../common.pm'; my $cgi = CGI->new; @@ -25,9 +27,8 @@ binmode STDOUT, ':utf8'; my %players = (); my %ratings = (); +my %ratings_stddev = (); my @matches = (); -my %parms = (); -my $match_stddev; sub sanitize { return HTML::Entities::encode_entities(shift); @@ -38,15 +39,142 @@ sub color { return int(255.0 * ($x ** (1.80))); } -sub make_table { - my $used_ratings = shift; +sub get_divisions { + my ($dbh, $locale, $season) = @_; + + my @divisions = (); + + my $q = $dbh->prepare('SELECT DISTINCT(divisjon) FROM fotballserier se JOIN fotballspraak sp ON se.spraak=sp.id WHERE kultur=? AND sesong=? ORDER BY divisjon'); + $q->execute($locale, $season); + + while (my $ref = $q->fetchrow_hashref) { + push @divisions, $ref->{'divisjon'}; + } + + return @divisions; +} + +sub get_subdivisions { + my ($dbh, $locale, $season, $division) = @_; + + my @subdivisions = (); + + my $q = $dbh->prepare('SELECT DISTINCT(avdeling) FROM fotballserier se JOIN fotballspraak sp ON se.spraak=sp.id WHERE kultur=? AND sesong=? AND divisjon=? ORDER BY avdeling'); + $q->execute($locale, $season, $division); + + while (my $ref = $q->fetchrow_hashref) { + push @subdivisions, $ref->{'avdeling'}; + } + + return @subdivisions; +} + +sub print_division_selector { + my ($dbh, $locale, $divisions, $subdivisions, $division, $subdivision) = @_; print <<"EOF"; +