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