Subversion Repositories VORC

Rev

Rev 56 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#!/usr/bin/perl
2
 
56 bgadell 3
# Redirect error messages to a log of my choosing. (it's annoying to filter for errors in the shared env)
4
my $error_log_path = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco/logs/" : "/tmp/";
5
close STDERR;
6
open STDERR, '>>', $error_log_path.'vorc_error.log' or warn "Failed to open redirected logfile ($0): $!";
7
#warn "Redirecting errors to ${error_log_path}vorc_error.log";
8
 
2 - 9
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
10
 
8 - 11
use cPanelUserConfig;
2 - 12
use CGI qw/:standard/;
13
use RollerCon;
14
use Spreadsheet::WriteExcel;
15
use DateTime;
16
use DateTime::Duration;
17
 
18
my $cookie_string = authenticate(2) || die;
19
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
20
my $user = getUser($EML);
21
my $username = $user->{derby_name};
22
my $RCid = $user->{RCid};
23
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
24
 
25
my $GID = param('GID');
26
my $T1  = param('T1');
27
my $T2  = param('T2');
28
my $action = param('action');
29
 
30
die unless $GID;
31
 
35 - 32
my $dbh = getRCDBH;
2 - 33
my $gethan = $dbh->prepare("select * from v_scores where id = ?");
34
my $puthan = $dbh->prepare("replace into score (gid, team1_score, team2_score) values (?, ?, ?)");
35
 
36
my $savestatus = "";
37
my $reload = "";
38
if ($action eq "Save") {
39
	if ($T1 eq '' or $T2 eq '') {
40
		$savestatus = "<font color=red><b>ERROR:</b> Missing Score!</font>";
41
	} else {
42
		$savestatus = "Saved!";
43
		$reload = 'onload="reloadParent()"';
44
		$puthan->execute($GID, $T1, $T2) or $savestatus="<font color=red><b>ERROR:</b> Error Saving!</font>";
45
	}
46
}
47
 
48
$gethan->execute($GID);
49
my ($game) = $gethan->fetchrow_hashref();
50
 
51
print CGI::header(-cookie=>$RCAUTH_cookie);
52
 
53
print<<page1;
54
<HTML><HEAD>
55
	<TITLE>RC17 Game Score Recorder</TITLE>
56
	<link rel="stylesheet" type="text/css" href="/rollercon.css">
57
</HEAD>
58
<body text="#000000" bgcolor="#FFFFFF" link="#000000" vlink="#000000" alink="#FF0000" $reload>
59
 
60
	<form action="update_score.pl" method=GET name=ScoreUpdate>
61
	$savestatus
62
	<table>
63
	<tr>
64
		<td colspan=2>Game: $game->{id}<input type=hidden name=GID value=$game->{id}> - $game->{dayofweek} - $game->{track} - $game->{time}</TD>
65
	</tr><tr>
66
		<td>$game->{team1}</td><td><input type=text name=T1 size=4 value=$game->{team1_score}></td>
67
	</tr><tr>
68
		<td>$game->{team2}</td><td><input type=text name=T2 size=4 value=$game->{team2_score}></td>
69
	</tr><tr>
70
		<td colspan=2><input type=Submit name=action value=Reset> <input type=Submit name=action value=Save> <input type=Reset value=Cancel onClick=window.close();></td>
71
	</tr>
72
	</table>
73
	</form>
74
 
75
page1
76
 
77
if ($savestatus ne '') {
78
	print<<refresh;
79
	<SCRIPT language="JavaScript">
80
	<!--
81
			function sleep(milliseconds) {
82
			  var start = new Date().getTime();
83
			  for (var i = 0; i < 1e7; i++) {
84
			    if ((new Date().getTime() - start) > milliseconds){
85
			      break;
86
			    }
87
			  }
88
			}
89
 
90
			function reloadParent() {
35 - 91
	      window.opener.location.reload();
92
	      setTimeout(() => { window.close(); }, 3000);
2 - 93
			}
94
 
95
	//-->
96
	</SCRIPT>
97
 
98
refresh
99
}
100
 
101
print "</BODY></HTML>\n";