-
Notifications
You must be signed in to change notification settings - Fork 0
/
doite.php
executable file
·92 lines (66 loc) · 1.79 KB
/
doite.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<html>
<head>
<title>Games</title>
</head>
<body>
<?
require "DB.php";
require "util.php";
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$db = DB::connect("mysqli://games:games@localhost/games");
$db->autocommit(false);
$gid = $db->escapeSimple($_GET["gameid"]);
$date = $db->escapeSimple($_POST["date"]);
$game = $db->escapeSimple($_POST["game"]);
$owner = $db->escapeSimple($_POST["owner"]);
$number = $db->escapeSimple($_POST["number"]);
$club = $db->escapeSimple($_POST["club"]);
$sql = "delete from games where gameid=$gid";
$db->query($sql);
$sql = "delete from scores where gameid=$gid";
$db->query($sql);
$sql = "insert into games (date, number, name, owner, club) values ('$date', $number, '$game', '$owner', '$club')";
$db->query($sql);
$sql = "select gameid from games order by gameid desc limit 1";
$q = $db->query($sql);
$names = array();
if ($q->fetchInto($r))
{
$gameid = $r[0];
for ($i = 1; $i <= 7; $i++)
{
if (isset($_POST["name" . $i]) && $_POST["name" . $i] != "")
{
$name = $db->escapeSimple($_POST["name" . $i]);
$place = $db->escapeSimple($_POST["place" . $i]);
$score = $db->escapeSimple($_POST["score" . $i]);
$sql = "insert into scores (gameid, position, name, points) values ($gameid, $place, '$name', $score)";
$db->query($sql);
$names[] = $name;
}
}
}
$db->query("commit");
$db->autocommit(true);
$eloS = array();
$eloE = array();
foreach ($names as $n)
$eloS[] = getELO($db, $n);
calcAllELOs($db);
calcAllELOs1($db);
foreach ($names as $n)
$eloE[] = getELO($db, $n);
?>
Game Edited! (I hope)
<p>
<?
for ($i = 0; $i < count($names); $i++)
{
$change = $eloE[$i] - $eloS[$i];
echo $names[$i] . ": " . ($change < 0 ? $change : ("+" . $change)) . "<br>";
}
?>
<p>
<a href="index.php">Go Home</a>
</body>
</html>