X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Findex.pl;h=a039cea1cf9831a66782b1916c42f9780abe25f4;hb=1fac0677bbcba5dec26e11aa661c97e38f6c3d40;hp=e80188efc0818f3297d5047141f30055525b65ed;hpb=c9d5bebbd7b33157827eff8f656b4a792a1bff0b;p=wloh diff --git a/www/index.pl b/www/index.pl index e80188e..a039cea 100755 --- a/www/index.pl +++ b/www/index.pl @@ -7,8 +7,14 @@ use CGI::Carp qw( fatalsToBrowser ); use DBI; use POSIX; use Devel::Peek; +use HTML::Entities; +use Encode; +use utf8; use locale; require '../config.pm'; +require '../common.pm'; + +my $cgi = CGI->new; my $dbh = DBI->connect($config::local_connstr, $config::local_username, $config::local_password) or die "connect: " . $DBI::errstr; @@ -21,14 +27,11 @@ binmode STDOUT, ':utf8'; my %players = (); my %ratings = (); +my %ratings_stddev = (); my @matches = (); -my %parms = (); -my $match_stddev; sub sanitize { - $_ = shift; - y/ \t\n<>&/_/; - return $_; + return HTML::Entities::encode_entities(shift); } sub color { @@ -36,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"; +