-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtop.php
273 lines (257 loc) · 9.98 KB
/
top.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<?php
//header("Refresh: 0; url=http://oz.kiev.ua/nw/");
//die();
session_start();
error_reporting(0);
if ($_GET["logout"] == 1) {
session_unset("nick");
session_destroy();
}
//functions
//include("../func.php");
include("func.php");
$sxtime = mtime();
$timezone = 5;
//updates in acc.php
$acc_status = "";
if (endsWith($_SERVER["PHP_SELF"], "acc.php")) {
//Check if userNAME is updated in acc.php
/*if ($_POST["nick"] != $_SESSION["nick"] && isset($_SESSION["nick"]) && $_POST["nick"] != "") {
rename("usersz/" . $_SESSION["nick"], "usersz/" . $_POST["nick"]);
//$users[$_POST["nick"]] = $users[$_SESSION["nick"]];
$prnick = $_SESSION["nick"];
$_SESSION["nick"] = $_POST["nick"];
}*/
}
//load users
$users = array(array());
$handle = opendir("usersz/");
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") $users[$file] = loadUser($file);
}
closedir($handle);
uksort($users, "cmpa");
//update user if changed in acc.php
if (endsWith($_SERVER["PHP_SELF"], "acc.php")) {
if (sizeof($_POST) > 0) {
$acc_status .= "<br/>";
$error = false;
//Skip nick testing
/*if ($users[$_POST["nick"]]["nick"] != "" && $users[$_POST["nick"]]["nick"] != $_SESSION["nick"]) {
$acc_status .= "<span style=\"color: #FF0000\">Another user with this nick already exists</span><br/>";
$error = true;
}
if (strlen($_POST["nick"]) < 2) {
$acc_status .= "<span style=\"color: #FF0000\">Nick must be at least 2 chars</span><br/>";
$error = true;
} elseif (strlen($_POST["nick"]) > 10) {
$acc_status .= "<span style=\"color: #FF0000\">Nick cant be longer than 10 chars (faks up tabels)</span><br/>";
$error = true;
}
if (illegalChars($_POST["nick"])) {
$acc_status .= "<span style=\"color: #FF0000\">Nick contains illegal chars (" . illegalChars("", true) . ")</span><br/>";
$error = true;
}*/
if ($_POST["pwd"] != $_POST["pwd2"] && $_POST["pwd"] != "") {
$acc_status .= "<span style=\"color: #FF0000\">Passwords don't match</span><br/>";
$error = true;
} elseif(strlen($_POST["pwd"]) < 3 && $_POST["pwd"] != "") {
$acc_status .= "<span style=\"color: #FF0000\">Password must be at least 3 chars</span><br/>";
$error = true;
} elseif(strlen($_POST["pwd"]) > 30 && $_POST["pwd"] != "") {
$acc_status .= "<span style=\"color: #FF0000\">Password can't be longer than 30 chars</span><br/>";
$error = true;
}
if (strlen($_POST["team"]) > 12 && $_POST["team"] != "") {
$acc_status .= "<span style=\"color: #FF0000\">Team name can't be longer than 12 chars</span><br/>";
$error = true;
}
if ($error == false) {
$fh = fopen("usersz/" . $_SESSION["nick"], "w");
//fwrite($fh, $_POST["nick"]. "\n");
fwrite($fh, $_SESSION["nick"] . "\n");
fwrite($fh, $_POST["elmaname"] . "\n");
if ($_POST["country"] != "NULL") {
fwrite($fh, strtolower($_POST["country"]) . "\n");
} else {
fwrite($fh, strtolower($users[$_SESSION["nick"]]["country"]) . "\n");
}
fwrite($fh, $_POST["team"] . "\n");
if ($_POST["pwd"] != "") {
fwrite($fh, strtolower(md5(md5($_POST["pwd"]))) . "\n");
} else {
fwrite($fh, strtolower($users[$_SESSION["nick"]]["pwd"]) . "\n");
}
fwrite($fh, $users[$_SESSION["nick"]]["registered"] . "\n");
fwrite($fh, $_POST["email"] . "\n");
fwrite($fh, $_POST["theme"] . "\n");
fwrite($fh, $_POST["timezone"] . "\n");
fwrite($fh, $_POST["timeformat"] . "\n");
fclose($fh);
$users[$_SESSION["nick"]] = loadUser($_SESSION["nick"]);
$acc_status .= "<span style=\"color: #00CC00\">User updated!</span><br/>";
}
}
}
//update user if changed in adm.php
$admins = array("Labs", "Kopaka", "Arzenik");
if (endsWith($_SERVER["PHP_SELF"], "adm.php")) {
if (sizeof($_POST) > 0 && in_array($_SESSION["nick"], $admins)) {
$adm_acc_status .= "<br/>";
$error = false;
if ($_POST["pwd"] != $_POST["pwd2"] && $_POST["pwd"] != "") {
$adm_acc_status .= "<span style=\"color: #FF0000\">Passwords don't match</span><br/>";
$error = true;
} elseif(strlen($_POST["pwd"]) < 3 && $_POST["pwd"] != "") {
$adm_acc_status .= "<span style=\"color: #FF0000\">Password must be at least 3 chars</span><br/>";
$error = true;
} elseif(strlen($_POST["pwd"]) > 30 && $_POST["pwd"] != "") {
$adm_acc_status .= "<span style=\"color: #FF0000\">Password can't be longer than 30 chars</span><br/>";
$error = true;
}
if (strlen($_POST["team"]) > 12 && $_POST["team"] != "") {
$adm_acc_status .= "<span style=\"color: #FF0000\">Team name can't be longer than 12 chars</span><br/>";
$error = true;
}
if ($error == false) {
$fh = fopen("usersz/" . $_POST["OGnick"], "w");
//fwrite($fh, $_POST["nick"]. "\n");
fwrite($fh, $_POST["OGnick"] . "\n");
fwrite($fh, $_POST["elmaname"] . "\n");
if ($_POST["country"] != "NULL") {
fwrite($fh, strtolower($_POST["country"]) . "\n");
} else {
fwrite($fh, strtolower($users[$_POST["OGnick"]]["country"]) . "\n");
}
fwrite($fh, $_POST["team"] . "\n");
if ($_POST["pwd"] != "") {
fwrite($fh, strtolower(md5(md5($_POST["pwd"]))) . "\n");
} else {
fwrite($fh, strtolower($users[$_POST["OGnick"]]["pwd"]) . "\n");
}
fwrite($fh, $users[$_POST["OGnick"]]["registered"] . "\n");
fwrite($fh, $_POST["email"] . "\n");
fwrite($fh, $_POST["theme"] . "\n");
fwrite($fh, $_POST["timezone"] . "\n");
fwrite($fh, $_POST["timeformat"] . "\n");
fclose($fh);
$users[$_POST["OGnick"]] = loadUser($_POST["OGnick"]);
$adm_acc_status .= "<span style=\"color: #00CC00\">User updated!</span><br/>";
}
}
}
//Load intnames
$intnames = array();
$lines = file("intnames.txt");
$i = 0;
foreach ($lines as $line_num => $line) {
$i++;
$line = str_replace("\r\n", "\n", $line);
$intnames[$i] = substr($line, 0, strlen($line)-1);
}
//User stuff
if (strlen($_POST["nick"]) > 0 && !isset($_SESSION["nick"])) {
$status = "";
foreach ($users as $cItem) {
if ($_POST["nick"] == $cItem["nick"]) {
$exists = true;
if (md5(md5($_POST["pwd"])) == $cItem["pwd"]) {
//Logged in
$_SESSION["nick"] = $_POST["nick"];
if ($_POST["remembar"] == "ye")
setcookie(session_name(),$_COOKIE[session_name()],time()+60*60*24*365,$params["path"],$params["domain"],$params["secure"],$params["httponly"]);
} else {
//Wrong pwd
$status = "Wrong password!";
}
}
}
if (!$exists) {
$status = "User doesn't exist!";
}
}
//Log :D
viewCounterAdd();
writeLog(getIp() . " -> " . $_SERVER["PHP_SELF"] . (isset($_SESSION["nick"]) ? " (user: " . $_SESSION["nick"] . ")" : ""));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>elmastats</title>
<link href="css/<?php
if (isset($_SESSION["nick"])) {
echo($users[$_SESSION["nick"]]["theme"] . ".css");
} else {
echo("Default.css");
}
//echo("refreshed.css");
//<a href="https://www.youtube.com/watch?v=jl4d2IVBXPU">restore old theme tutorial</a>
echo("?" . time());
?>" rel="stylesheet" type="text/css"/>
<link href="css/hi.css?<?php echo(time()); ?>" rel="stylesheet" type="text/css"/>
<link rel="shortcut icon" href="favicon.ico"/>
<script type="text/javascript" src="tabber.js"></script>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
</head>
<body>
<div id="main">
<a class="header" href="index.php"></a>
<div id="ads">
<?php //add mopolauta link elmastatssdfsdf ?>
<a href="https://elma.online/cup/WC9/" target="_blank">World Cup 9</a> /
<a href="http://www.moposite.com/records_elma_wrs.php" target="_blank">Latest wr table</a> /
<a href="http://elma.online" target="_blank">Elma Online</a> /
<a href="http://mopolauta.moposite.com/" target="_blank">mopolauta</a> /
<a href="https://multiwr.elma.online/" target="_blank">Internal multi wr</a>
</div>
<div id="left">
<?php if (isset($_SESSION["nick"])) { ?>
<div class="menuheader">
<?php
echo("<div id=\"ahead\">" . man($_SESSION["nick"]));
$utimes = stateTimes($_SESSION["nick"], $users[$_SESSION["nick"]]["elmaname"]);
if ($utimes != NULL) {
$tt = 0;
for ($x = 0;$x < 54;$x++) $tt += ($utimes[$x+1][1] > 0 ? $utimes[$x+1][1] : 60000);
echo("<br/>TT: " . coloredtttime($tt));
}
echo("</div>");
?>
</div>
<a href="up.php">upload stats</a><br/>
<a href="uprec.php">upload recs</a><br/>
<a href="acc.php">acc settings</a><br/>
<a href="up.php?logout=1">log out</a><br/>
<?php } else { ?>
<div class="menuheader"><b>user menu</b></div>
<a href="up.php">log in</a><br/>
<a href="register.php">register</a><br/>
<?php } ?>
<br/>
<div class="menuheader"><b>main menu</b></div>
<a href="index.php">main page</a><br/>
<a href="top10.php">top10s</a><br/>
<a href="tts.php">totaltimes</a><br/>
<a href="natl.php">national stats</a><br/>
<a href="recs.php">top10 recs</a><br/>
<a href="compare.php">compare</a><br/>
<a href="targets.php">target times</a><br/>
<a href="players.php">players</a><br/>
<a href="teams.php">teams</a><br/>
<br/>
<div class="menuheader"><b>internals</b></div>
<table><tr>
<?php
for ($x = 0;$x < 54;$x++) {
echo("<td width=\"20px\">" . internal($x+1, true, false, false, false) . "</td>");
if (($x+1)%6 == 0 && $x < 53) echo("</tr><tr>");
}
?>
</tr></table>
<br/>
<div class="menuheader"><b>other stuff</b><br/></div>
<a href="suggestions.php">suggestions</a><br/>
<a href="site.php">site stats</a><br/>
<a href="about.php">about</a><br/>
</div>
<div id="mid">