-
Notifications
You must be signed in to change notification settings - Fork 1
/
natl_old.php
168 lines (160 loc) · 6.03 KB
/
natl_old.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php include("top.php"); ?>
<?php
$unicks = array();
$c = 0;
$nousers = true;
$eror = false;
$cnames = countries();
if ($_GET["country"] == "") {
echo("<b>Choose nationality</b><br/>");
$nc = array();
foreach ($users as $cItem) {
if ($cItem["country"] != "") {
$duplicate = false;
foreach ($nc as $nk => $n) if ($cItem["country"] == $nk) $duplicate = true;
if (!$duplicate) {
$nc[$cItem["country"]] = 1;
} else {
$nc[$cItem["country"]] += 1;
}
/*$utimes = stateTimes($cItem["nick"], $cItem["elmaname"]);
$tt = 0;
for ($x = 0;$x < 54;$x++) {
if ($utimes[$x+1][1] == 0) {
$tt += 60000;
} else {
$tt += $utimes[$x+1][1];
}
}
$nc[$cItem["country"]]["tt"] += $tt;*/
}
}
/*usort($ntt, "cmp");
echo("<table class=\"times\">");
$x = 0;
foreach ($ntt as $n => $tt) {
$x++;
echo("<tr class=\"times\"><td class=\"times\" width=\"20px\">" . $x . ".</td>");
echo("<td class=\"times\" width=\"200px\">");
echo(flag($n) . " <a href=\"natl.php?country=" . $n . "\">" . $cnames[strtoupper($n)] . "</a></td>");
echo("<td class=\"times\" width=\"81px\">" . formatElmaTime($tt) . "</td>");
$wry = "s"; if ($ncc[$n] == 1) $wry = "";
echo("<td class=\"times\">" . $ncc[$n] . " kuski" . $wry . "</td></tr>");
}
echo("</table>");*/
function cmpc($a, $b) {
if ($a == $b) return 0;
return ($a > $b) ? -1 : 1;
}
uasort($nc, "cmpc");
echo("<table>");
foreach ($nc as $nk => $n) {
echo("<tr><td width=\"200px\">");
echo(flag($nk) . " <a href=\"natl.php?country=" . $nk . "\">" . $cnames[strtoupper($nk)] . "</a><br/>");
echo("</td><td>" . $n . " kuski" . ($n == 1 ? "" : "s") . "</td></tr>");
}
echo("</table>");
$eror = true;
}
$country = $cnames[strtoupper($_GET["country"])];
foreach ($users as $cItem) {
if ($cItem["country"] == $_GET["country"]) {
if ($nousers) {
$nousers = false;
if ($_GET["country"] != "") echo(flag($cItem["country"]) . " <b>" . $country . "</b><br/><br/>");
}
$unicks[$c] = $cItem["nick"];
$c++;
}
}
if ($nousers) {
if ($country == "") {
echo("<span style=\"color: #FF0000\">Non-existing country!</span><br/>");
} else {
echo("<span style=\"color: #FF0000\">No kuskis from " . $country . "!</span><br/>");
}
$eror = true;
}
if (!$eror) {
$utimes = array();
for ($x = 0;$x < $c;$x++) {
$utimes[$x] = stateTimes($unicks[$x], $users[$unicks[$x]]["elmaname"]);
}
echo("<b>National totaltime table for " . $country . "</b><br/><br/>");
echo("<table class=\"times\">");
echo("<tr><th class=\"times\" width=\"20px\"></th><th class=\"times\" width=\"180px\">Kuski</th>");
echo("<th class=\"times\" width=\"81px\"><center>TT</center></th>");
echo("<th class=\"times\" width=\"265px\"><center>Updated</center></th></tr>");
$tts = array();
$cItem = array();
for ($y = 0;$y < $c;$y++) {
$ctt = 0;
$cItem["nick"] = $unicks[$y];
for ($x = 0;$x < 54;$x++) {
$cTime = $utimes[$y][$x+1][1];
if ($cTime == 0) $cTime = 60000;
$ctt += $cTime;
}
if ($ctt < 60000*54) {
$cItem["time"] = $ctt;
$tts[] = $cItem;
}
}
usort($tts, "cmp");
for ($y = 0;$y < count($tts);$y++) {
$str = "";
if ($y > 0) $str = " title=\"+" . formatElmaTime($tts[$y]["time"]-$tts[0]["time"]) . " to " . $tts[0]["nick"] . "'s TT\"";
echo("<tr><td class=\"times\" width=\"20px\">" . ($y+1) . ". </td>");
echo("<td class=\"times\" width=\"180px\">" . man($tts[$y]["nick"]) . "</td>");
echo("<td class=\"times\" width=\"81px\"" . $str . "><center>" . formatElmaTime($tts[$y]["time"]) . "</center></td>");
echo("<td class=\"times\" width=\"265px\"> " . date("d/m/y - H:i:s", ttime(filemtime("statefilesz/" . $tts[$y]["nick"] . ".dat"))) .
" (" . timeSince(filemtime("statefilesz/" . $tts[$y]["nick"] . ".dat")) . " ago)</td></tr>");
}
echo("</table><br/><br/>");
$topnum = $_GET["top"];
if ($topnum == 0) $topnum = 10;
$victories = array();
echo("<b>Top " . $topnum . "s for all internals</b><br/><br/>");
echo("<div class=\"lefty\">");
for ($x = 0;$x < 54;$x++) {
$top = array();
for ($y = 0;$y < $c;$y++) {
$cItem["nick"] = $unicks[$y];
$cItem["time"] = $utimes[$y][$x+1][1];
if ($cItem["time"] == 0) $cItem["time"] = 60000;
if ($cItem["time"] < 60000) $top[] = $cItem;
}
usort($top, "cmp");
echo("<table class=\"times\">");
echo("<tr><th class=\"times\" width=\"20px\">" . ($x+1) . ".</th>");
echo("<th class=\"times\" width=\"180px\">" . internal($x+1) . "</th>");
echo("<th class=\"times\" width=\"81px\"></th></tr>");
for ($y = 0;$y < $topnum;$y++) {
if ($top[$y]["nick"] != "") {
echo("<tr>");
echo("<td class=\"times\" width=\"20px\">" . ($y+1) . ".</td>");
echo("<td class=\"times\" width=\"180px\">" . man($top[$y]["nick"]) . "</td>");
$str = "";
if ($y > 0) $str = " title=\"+" . formatElmaTime($top[$y]["time"]-$top[0]["time"]) . " to " . $top[0]["nick"] . "'s time\"";
echo("<td class=\"times\" width=\"81px\"" . $str . "><center>" . sttime($top[$y]["nick"], $x+1, $top[$y]["time"]) . "</center></td>");
echo("</tr>");
}
}
$victories[$top[0]["nick"]] += 1;
echo("</table>");
echo("<br/>");
if ($x == 26) echo("</div><div class=\"lefty\">");
}
echo("</div>");
echo("<div class=\"lefty\">");
echo("<br/><b>National records</b><br/><br/>");
echo("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
foreach ($victories as $man => $v) {
echo("<tr><td>" . man($man) . " </td>");
echo("<td>" . $v . " records</td></tr>");
}
echo("</table>");
echo("</div>");
}
?>
<?php include("tpo.php"); ?>