-
Notifications
You must be signed in to change notification settings - Fork 1
/
up.php
184 lines (169 loc) · 7.92 KB
/
up.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php include("top.php"); ?>
hi this is elmastats you can compare your times to other mans and stuff<br/><br/>
<?php
if (isset($_SESSION["nick"])) {
?>
<b>Upload stats</b><br/>
<form enctype="multipart/form-data" action="up.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000"/>
<table border="0" cellpadding="0" cellspacing="2">
<tr>
<td>State file (*.dat): </td>
<td><input name="uploadedfile" type="file"/></td>
<td><input type="submit" value="Upload"/></td>
</tr>
</table>
</form>
<?php
$targets = loadTargets();
if (sizeof($_POST) > 0) {
$file = $_FILES["uploadedfile"]["name"];
if (strlen($file) > 0) {
echo("<br/>");
if (endswith(basename($_FILES["uploadedfile"]["name"]), ".dat")) {
if (filesize($_FILES["uploadedfile"]["tmp_name"]) == 67910) {
$path = "statefilesz/" . $_SESSION["nick"] . ".dat";
$showimp = false;
if (file_exists($path)) {
rename($path, "statefilesz/" . $_SESSION["nick"] . "_old.dat");
$showimp = true;
}
if (move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], $path)) {
chmod($path, 0644);
echo("<span style=\"color: #00CC00\">Stats uploaded! Click <a href=\"player.php?player=" . $_SESSION["nick"] . "\">here</a> to see your page.</span><br/>");
echo("!!!ATTENTION!!! Remember to <a href=\"uprec.php\">upload your recs</a> too for extra coolness<br/>");
if ($showimp) {
$cTimes = stateTimes($_SESSION["nick"] . "_old", $users[$_SESSION["nick"]]["elmaname"]);
$nTimes = stateTimes($_SESSION["nick"], $users[$_SESSION["nick"]]["elmaname"]);
unlink("statefilesz/" . $_SESSION["nick"] . "_old.dat");
$date = date("d/m/y - H:i:s");
$oldtt = 0;
$newtt = 0;
$improvements = array();
$deprovments = array();
for ($x = 0;$x < 54;$x++) {
$oldtt += ($cTimes[$x+1][1] == 0 ? 60000 : $cTimes[$x+1][1]);
$newtt += ($nTimes[$x+1][1] == 0 ? 60000 : $nTimes[$x+1][1]);
$oldTarget = target($cTimes[$x+1][1], $x+1);
$newTarget = target($nTimes[$x+1][1], $x+1);
$in = $x+1 . ". ";
if ($x+1 > 9) $in = ($x+1) . ". ";
$in .= $intnames[$x+1];
for ($y = 0;$y < 20-strlen($intnames[$x+1]);$y++) $in .= " ";
if ($nTimes[$x+1][1] < $cTimes[$x+1][1] && $nTimes[$x+1][1] > 0 && $cTimes[$x+1][1] > 0) {
//Improvement
$improvements[] = $in . sttime("", 1, $cTimes[$x+1][1], false, false, $oldTarget) . " -> " . sttime("", 1, $nTimes[$x+1][1], false, false, $newTarget) . "<br/>";
//$lines = file("newtajms");
//$lines[] = "[" . $date . "] " . . "\n";
/*if (count($lines) > 29) {
for ($y = 1;$y < count($lines);$y++) {
$lines[$y-1] = $lines[$y];
}
$lines = array_splice($lines, 30);
}*/
$in = $x+1 . ". ";
if ($x+1 > 9) $in = ($x+1) . ". ";
$in .= $intnames[$x+1];
//old
$fh = fopen("newtajms", "a");
fwrite($fh, "<tr><td>" . man($_SESSION["nick"]) . "</td><td>" . $in . "</td><td>" . formatElmaTime($cTimes[$x+1][1]) . " -> " . formatElmaTime($nTimes[$x+1][1]) . "</td><td>" . $date . "</td></tr>\n");
fclose($fh);
//new
$fh = fopen("newtajms2", "a");
fwrite($fh, $_SESSION["nick"] . "|" . ($x+1) . "|" . $cTimes[$x+1][1] . "|" . $nTimes[$x+1][1] . "|" . time() . "\n");
fclose($fh);
} elseif ($nTimes[$x+1][1] > $cTimes[$x+1][1] && $nTimes[$x+1][1] > 0 && $cTimes[$x+1][1] > 0) {
//Deimprovement
$deprovments[] = $in . sttime("", 1, $cTimes[$x+1][1], false, false, $oldTarget) . " -> " . sttime("", 1, $nTimes[$x+1][1], false, false, $newTarget) . "<br/>";
} elseif ($nTimes[$x+1][1] > 0 && $cTimes[$x+1][1] == 0) {
//Finished unfinished lev
$improvements[] = $in . sttime("", 1, $nTimes[$x+1][1], false, false, $newTarget) . "<br/>";
} elseif ($nTimes[$x+1][1] == 0 && $cTimes[$x+1][1] > 0) {
//Definished finished lev
$deprovments[] = $in . sttime("", 1, $cTimes[$x+1][1], false, false, $oldTarget) . " -> N/A<br/>";
}
}
if(count($improvements) > 0) {
echo("<br/>");
echo("<span style='color:green;font-size:16px;font-weight:bold;'>Improvements</span>");
echo("<br/>");
foreach($improvements as $imp) {
echo($imp);
}
}
if(count($deprovments) > 0) {
echo("<br/>");
echo("<span style='color:red;font-size:16px;font-weight:bold;'>Deprovements</span>");
echo("<br/>");
foreach($deprovments as $dep) {
echo($dep);
}
}
if ($newtt < $oldtt) {
echo("<br/>Total time " . coloredtttime($oldtt) . " -> " . coloredtttime($newtt) . "<br/>");
if (floor($newtt/6000) < floor($oldtt/6000)) {
$fh = fopen("newttz", "a");
fwrite($fh, $_SESSION["nick"] . "|" . floor($newtt/6000) . "|" . time() . "\n");
fclose($fh);
echo("GZ! " . floor($newtt/6000) . " club :D<br/>");
}
//add to history
if (file_exists("statefileszh/" . $_SESSION["nick"])) {
$n = 0;
while (file_exists("historyz/" . $_SESSION["nick"] . "_" . $n)) $n++;
copy("statefileszh/" . $_SESSION["nick"], "historyz/" . $_SESSION["nick"] . "_" . $n);
$fh = fopen("historyz/" . $_SESSION["nick"] . "_" . $n, "a");
fwrite($fh, time() . "\n");
fclose($fh);
}
}
if ($newtt > $oldtt) {
echo("<br/>Total time " . coloredtttime($oldtt) . " -> " . coloredtttime($newtt) . "<br/>");
}
}
} else {
echo("<span style=\"color: #FF0000\">Error uploading the file!</span><br/>");
}
} else {
echo("<span style=\"color: #FF0000\">File is empty! or u is upload vrong file..</span><br/>");
}
} else {
echo("<span style=\"color: #FF0000\">Wrong filetype!</span><br/>");
}
}
}
?>
<?php
} else {
?>
<b>Log in</b> (or if you haven't got an acc, pls <a href="register.php">register</a>)<br/><br/>
<form enctype="multipart/form-data" action="<?php echo($_SERVER["PHP_SELF"]); ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="300000000000"/>
<table border="0" cellpadding="0" cellspacing="2">
<tr>
<td>Nick: </td>
<td><input type="text" name="nick" size="18"/></td>
</tr>
<tr>
<td>Pwd: </td>
<td><input type="password" name="pwd" size="18"/></td>
</tr>
<tr>
<td>Remember me: </td>
<td><input type="checkbox" name="remembar" value="ye"/></td>
</tr>
<tr><th colspan="2"> </th></tr>
<tr>
<td colspan="2"><center><input type="submit" value="Log in"/></center></td>
</tr>
</table>
</form>
<br/>
<!--<a href="lostpwd.php">Forgot password??</a><br/>-->
<?php
if (strlen($status) > 0) {
echo("<br/><span style=\"color: #FF0000\">" . $status . "</span><br/>");
}
}
?>
<?php include("tpo.php"); ?>