Rev 138 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/usr/bin/perl# Redirect error messages to a log of my choosing. (it's annoying to filter for errors in the shared env)my $error_log_path = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco/logs/" : "/tmp/";close STDERR;open STDERR, '>>', $error_log_path.'vorc_error.log' or warn "Failed to open redirected logfile ($0): $!";#warn "Redirecting errors to ${error_log_path}vorc_error.log";#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }use strict;use cPanelUserConfig;use CGI qw/param cookie header start_html url/;use HTML::Tiny;use tableViewer;use RollerCon;our $h = HTML::Tiny->new( mode => 'html' );my $secure = "";if ($ENV{SCRIPT_NAME} =~ /^\/scores.pl/) {$secure = 0;} else {$secure = 1;}my $cookie_string;our ($EML, $PWD, $LVL);my $RCAUTH_cookie;if ($secure) {$cookie_string = authenticate(2) || die;($EML, $PWD, $LVL) = split /&/, $cookie_string;$RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");}my $pageTitle = "Game Scores";our $DBTABLE = 'v_scores';my %COLUMNS = (# colname => [qw(DisplayName N type status)], status -> static | default | <blank>id => [qw(ID 5 number )],date => [qw(Date 10 date )],dayofweek => [qw(Day 15 select default )],track => [qw(Track 20 select default )],type => [qw(Type 25 select )],time => [qw(Time 30 text default )],team1 => [qw(Team1 35 text static )],team2 => [qw(Team2 40 text static )]);# Set any custom "where" DB filters here...my @whereClause;# If we need to modify line item values, create a subroutine named "modify_$columnname"# It will receive a hashref to the object lineitemsub modify_id {my $t = shift;if ($secure) {if ($t->{team1_score} or $t->{team2_score}) {$t->{id} .= " <A HREF='#' onClick=\"window.open('update_score.pl?GID=$t->{id}','Enter Score','resizable,height=260,width=370'); return false;\">[update score]</a>";} else {$t->{id} .= " <A HREF='#' onClick=\"window.open('update_score.pl?GID=$t->{id}','Enter Score','resizable,height=260,width=370'); return false;\">[enter score]</a>";}}return $t->{id};}sub modify_team1 {my $t = shift;$t->{team1} .= " ($t->{team1_score})" unless !defined $t->{team1_score};$t->{team2} .= " ($t->{team2_score})" unless !defined $t->{team2_score};;if ($t->{team1_score} > 0 or $t->{team2_score} > 0) { #SPIKE SEZ DO SOMETHING HERE RE GAME SCORE OF 0if ($t->{team1_score} > $t->{team2_score}) { $t->{team1} = "<b>$t->{team1}</b>"; } else { $t->{team2} = "<b>$t->{team2}</b>"; }}return $t->{team1};}sub modify_time {my $t = shift;return convertTime $t->{time};}# If we need to modify how a filter works, create a subroutine named "filter_$columnname"# It will receive two fields, the field name and the current filter value (if any)# Uncomment and update if we want to enable clicking on a row to open a new page.##sub addRowClick {# my $t = shift;# return "location.href='view_thing.pl?field=$t->{field}&choice=View'";#}# Call the function to print the table view page (with available options)printTablePage ({ Title => $pageTitle,Table => $DBTABLE,Columns => \%COLUMNS,RCAuth => $RCAUTH_cookie,Where => join (" and ", @whereClause),DisplayYearSelect => 1,});