This repository has been archived by the owner on Nov 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser.php
484 lines (438 loc) · 19.3 KB
/
browser.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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<?php
define('APPLICATION_PATH_ABSOLUTE', dirname(__FILE__));
define('APPLICATION_PATH_RELATIVE', dirname($_SERVER['SCRIPT_NAME']));
define('APPLICATION_PATH_URL', dirname($_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']));
require_once("includes/bootstrap.php");
if (empty($sid) || empty($user_sitterlogin) || !($user_adminsitten == SITTEN_BOTH || $user_adminsitten == SITTEN_ONLY_LOGINS) || $user_id == "guest") {
header("Location: " . APPLICATION_PATH_RELATIVE);
exit;
}
// Get sitterprofile
$serverskin = 1;
$serverskin_typ = 3;
$status = array(
'use' => 1,
'attack' => 2,
'probe' => 3,
'past' => 4,
);
$allianz = getVar("allianz");
if ($user_fremdesitten == false) {
$allianz = $user_allianz;
} else {
$allianz = '';
}
// Get avaible sitter logins
$sql = "SELECT * FROM " . $db_tb_user . " where sitten=1";
if (!empty($allianz)) {
$sql .= " and allianz='" . $allianz . "'";
}
$result = $db->db_query($sql)
or die('Could not query user.');
while ($row = $db->db_fetch_array($result)) {
unset($user);
$user['id'] = $row['id'];
$user['typ'] = $row['budflesol'];
$user['lastsitterlogin'] = $row['lastsitterlogin'];
$user['lastsitteruser'] = $row['lastsitteruser'];
if ($row['lastsitterloggedin'] && $row['lastsitterlogin'] > (CURRENT_UNIX_TIME - 5 * MINUTE)) {
$user['lastsitterloggedin'] = 1;
$user['next_status'] = $status['use'];
} else {
$user['lastsitterloggedin'] = 0;
$user['next_status'] = $status['past'];
}
$user['ikea'] = $row['ikea'];
$user['peitschen'] = $row['peitschen'];
$user['alliance'] = empty($row['allianz']) ? "No Alliance" : $row['allianz'];
$user['group'] = $row['buddlerfrom'];
$user['dauersitten'] = $row['dauersitten'];
$user['dauersittentext'] = $row['dauersittentext'];
$user['dauersittenlast'] = $row['dauersittenlast'];
if (!empty($user['dauersitten']) && (empty($user['dauersittenlast']) || ($user['dauersittenlast'] + $user['dauersitten'] < CURRENT_UNIX_TIME))) {
$user['dauersittendue'] = true;
} else {
$user['dauersittendue'] = false;
}
$url = 'http://icewars.de/index.php?action=login&name=' . $row['id'];
$url .= '&pswd=' . $row['sitterpwd'];
if (!empty($serverskin)) {
$url .= '&serverskin=1';
$url .= '&serverskin_typ=' . $serverskin_typ;
}
$url .= '&sitter=1&ismd5=1&submit=1';
$user['url'] = $url;
/*
$sql = "SELECT * FROM " . $db_tb_sitterauftrag . " WHERE user='" . $row['id'] . "' ORDER BY date DESC";
$result_sitterorder = $db->db_query($sql)
or error(GENERAL_ERROR, 'Could not query config information.', '', __FILE__, __LINE__, $sql);
if ($row_sitterorder = $db->db_fetch_array($result_sitterorder)) {
//$user['next_date'] = $row_sitterorder['date'];
//$user['next_status'] = $user['next_date'] < CURRENT_UNIX_TIME ? 'due' : 'pending';
$user['sitterorder']['planet'] = $row_sitterorder['planet'];
if ($row_sitterorder['typ'] == 'Gebaeude') {
$sql = "SELECT * FROM " . $db_tb_gebaeude . " WHERE id=" . $row_sitterorder['bauid'];
$result_gebaeude = $db->db_query($sql)
or error(GENERAL_ERROR, 'Could not query config information.', '', __FILE__, __LINE__, $sql);
if ($row_gebaeude = $db->db_fetch_array($result_gebaeude)) {
$user['sitterorder']['image'] = $row_gebaeude['bild'];
$user['sitterorder']['text'] = $row_gebaeude['name'];
} else
$user['sitterorder']['text'] = '(unknown building)';
} elseif ($row_sitterorder['typ'] == 'Sonstiges') {
$user['sitterorder']['text'] = $row_sitterorder['auftrag'];
} else
$user['sitterorder']['text'] = 'Sitten';
}
*/
$sql = "SELECT * FROM " . $db_tb_lieferung . " WHERE user_to='" . $row['id'] . "' AND art IN ('Angriff','Sondierung','Sondierung (Schiffe/Def/Ress)','Sondierung (Gebäude/Ress)') AND time>" . (CURRENT_UNIX_TIME - (15 * MINUTE)) . " ORDER BY time DESC";
$result_angriff = $db->db_query($sql)
or error(GENERAL_ERROR, 'Could not query config information.', '', __FILE__, __LINE__, $sql);
while ($row_angriff = $db->db_fetch_array($result_angriff)) {
if ($row_angriff['time'] > (CURRENT_UNIX_TIME - ($row_angriff['art'] == 'Angriff' ? (15 * MINUTE) : (5 * MINUTE)))) {
$key = $row_angriff['art'] == 'Angriff' ? 'attack' : 'probe';
$user[$key][] = array(
'coords' => $row_angriff['coords_to_gal'] . ':' . $row_angriff['coords_to_sys'] . ':' . $row_angriff['coords_to_planet'],
'time' => $row_angriff['time'],
'from' => $row_angriff['user_from'],
);
if (!isset($user['next_date']) || $user['next_date'] > ($row_angriff['time'] + (15 * MINUTE))) {
$user['next_date'] = $row_angriff['time'];
}
if ($user['next_status'] > $status[$key]) {
$user['next_status'] = $status[$key];
}
}
}
if (!isset($user['next_date'])) {
$user['next_date'] = $user['lastsitterlogin'];
}
if ($user['next_date'] > 0) {
$user['next_date_text'] = strftime(CONFIG_DATETIMEFORMAT, $user['next_date']);
}
$users[$row['id']] = $user;
$uview[$user['next_status']][$user['next_date'] . $user['id']] = $user;
}
// Assemble view
$view = array();
foreach ($status as $key) {
if (isset($uview[$key])) {
ksort($uview[$key]);
$view = array_merge($view, $uview[$key]);
}
}
// Get request parameter
if (isset($_REQUEST['login'])) {
$login = $_REQUEST['login'];
}
if (isset($_REQUEST['mode'])) {
$mode = $_REQUEST['mode'];
}
if (empty($mode)) {
$mode = 'index';
}
$action = null;
if (isset($_REQUEST['action'])) {
$action = $_REQUEST['action'];
}
if ($action == 'own') {
$login = $user_sitterlogin;
}
if (isset($_REQUEST['redirect'])) {
$redirect = $_REQUEST['redirect'];
} else {
$redirect = '';
}
$logout = getVar('logout');
if ($logout == 'Ausloggen') {
foreach ($users as $user) {
if ($user['lastsitteruser'] == $user_sitterlogin) {
$user['lastsitterloggedin'] = 0;
}
}
$sql = "UPDATE " . $db_tb_user . " SET lastsitterloggedin=0 WHERE lastsitteruser='" . $user_sitterlogin . "'";
$result = $db->db_query($sql)
or error(GENERAL_ERROR, 'Could not query config information.', '', __FILE__, __LINE__, $sql);
}
$done = getVar('done');
if ($done == 'Erledigt') {
foreach ($users as $user) {
if ($user['lastsitteruser'] == $user_sitterlogin) {
$user['lastsitterloggedin'] = 0;
$sql = "UPDATE " . $db_tb_user . " SET lastsitterloggedin=0,dauersittenlast=" . CURRENT_UNIX_TIME . " WHERE id='" . $user['id'] . "'";
$result = $db->db_query($sql)
or error(GENERAL_ERROR, 'Could not query config information.', '', __FILE__, __LINE__, $sql);
}
}
}
if (empty($login)) {
$mainurl = 'http://icewars.de';
} elseif (isset($users[$login])) {
$login_user = $users[$login];
$mainurl = $login_user['url'];
foreach ($users as $user) {
if ($user['lastsitteruser'] == $user_sitterlogin) {
$user['lastsitterloggedin'] = 0;
}
}
$login_user['lastsitterlogin'] = CURRENT_UNIX_TIME;
$login_user['lastsitteruser'] = $user_sitterlogin;
$login_user['lastsitterloggedin'] = 1;
$sql = "UPDATE " . $db_tb_user . " SET lastsitterloggedin=0 WHERE lastsitteruser='" . $user_sitterlogin . "'";
$result = $db->db_query($sql)
or error(GENERAL_ERROR, 'Could not query config information.', '', __FILE__, __LINE__, $sql);
$sql = "UPDATE " . $db_tb_user . " SET lastsitterlogin=" . $login_user['lastsitterlogin'] . ",lastsitteruser='" . $login_user['lastsitteruser'] . "',lastsitterloggedin=1 WHERE id='" . $login_user['id'] . "'";
$result = $db->db_query($sql)
or error(GENERAL_ERROR, 'Could not query config information.', '', __FILE__, __LINE__, $sql);
$sql = "INSERT INTO " . $db_tb_sitterlog . " (sitterlogin,fromuser,date,action) VALUES ('" . $login_user['id'] . "', '" . $user_sitterlogin . "', '" . $config_date . "', 'login')";
$result = $db->db_query($sql)
or error(GENERAL_ERROR, 'Could not query config information.', '', __FILE__, __LINE__, $sql);
}
// Select page mode
switch ($mode) {
case 'index':
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>Icewars</title>
<script>
var redirectURL = "<?php
if ($redirect == 'planiress') {
echo 'http://sandkasten.icewars.de/game/index.php?action=wirtschaft&typ=planiress';
} else if ($redirect == 'schiff_uebersicht') {
echo 'http://sandkasten.icewars.de/game/index.php?action=mil&typ=schiff_uebersicht';
} else if ($redirect == 'gebaeude_uebersicht') {
echo 'http://sandkasten.icewars.de/game/index.php?action=wirtschaft&typ=geb';
} else if ($redirect == 'forschung_uebersicht') {
echo 'http://sandkasten.icewars.de/game/index.php?action=forschung&forschung_allshow=1';
}
?>";
function setRedirection(url) {
redirectURL = url;
}
function redirect(id) {
if (redirectURL.length) {
contentFrameElement = document.getElementById(id);
url = redirectURL;
redirectURL = "";
contentFrameElement.src = url;
}
}
</script>
</head>
<frameset rows="0,*" cols="*" frameborder="YES" border="0" framespacing="0">
<frame src="?mode=top" name="topFrame" scrolling="NO" noresize>
<frameset rows="*" cols="300,*" framespacing="0" frameborder="YES" border="0">
<frame src="?mode=left&redirect=<?php echo $redirect; echo !empty($login) ? "&login=$login" : ""; echo !empty($action) ? "&action=$action" : ""; echo "&allianz=$allianz"?>" name="left" id="left" scrolling="YES">
<frame src="<?php echo $mainurl ?>" name="main" id="main" onload="redirect(this.id)">
</frameset>
</frameset>
<noframes>
<body>
</body>
</noframes>
</html>
<?php
break;
case 'left':
?>
<html>
<head>
<style type="text/css">
* {
font-family: verdana, serif;
font-size: 11px;
}
body {
color: #ffffff;
background: #111111 url(bilder/bg_space3.png);
}
a:link {
color: #bbbbbb;
}
a:visited {
color: #bbbbbb;
}
body, table, tr, td, form {
margin: 0;
padding: 0;
}
.attack {
color: #ff0000;
}
.probe {
color: #cc9900;
}
.loggedin {
color: #33AA33;
}
.dursitting {
color: #ff00ff;
}
.dursitting_time {
color: #bbbbbb;
}
.dursitting_due {
color: #ff00ff;
}
.time_critical {
color: #ff0000;
}
.time_warning {
color: #cc9900;
}
.time_normal {
color: #bbbbbb;
}
.time {
color: #990066;
}
</style>
</head>
<body onLoad="start();">
<table>
<tr>
<td>
<select id="redirectPage" onchange="parent.document.getElementById('left').src = '?mode=index&redirect=' + options[selectedIndex].value + '&login=<?php echo $user['id']; echo "&allianz=$allianz" ?>';">
<option value="">(Startseite)</option>
<option value="planiress"<?php echo $redirect == 'planiress' ? ' selected' : '' ?>>
Kolo-/Ressübersicht
</option>
<option value="schiff_uebersicht"<?php echo $redirect == 'schiff_uebersicht' ? ' selected' : '' ?>>
Schiffübersicht
</option>
<option value="gebaeude_uebersicht"<?php echo $redirect == 'gebaeude_uebersicht' ? ' selected' : '' ?>>
Gebäudeübersicht
</option>
<option value="forschung_uebersicht"<?php echo $redirect == 'forschung_uebersicht' ? ' selected' : '' ?>>
Forschungsübersicht
</option>
</select>
</td>
<!--<tr>
<td nowrap width="100%">
<a href='?action=own<?php echo "&allianz=$allianz" ?>' target='_top'>Eigener Spieler</a><br>
<a href='http://176.9.109.187/' target='main'>Icewars-Notlogin</a>
</td>
<td nowrap>
</td>
--></tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
<br>
<?php
if (isset($login_user)) {
?>
<form target="_top">
<?php
echo isset($login_user['alliance']) ? '[' . $login_user['alliance'] . ']' : '';
echo $login_user['id'];
echo '<br>';
echo $login_user['typ'];
if (!empty($login_user['group']) && $login_user['group'] != $login_user['id']) {
echo 'von ' . $login_user['group'] . '<br>';
if (!empty($login_user['ikea'])) {
echo "<div style='color:yellow'>IKEA</div>";
} else if (!empty($login_user['peitschen'])) {
echo "<div style='color:pink'>MdP</div>";
}
if (!empty($login_user['dauersitten'])) {
echo "<span class='dursitting'>" . $login_user['dauersittentext'] . "</span>";
echo "<span class='dursitting_time'>(alle " . ($login_user['dauersitten'] / MINUTE) . " Minuten)</span><br>";
}
} else {
echo '<br>';
}
if (!empty($login_user['dauersitten'])) {
echo "<input type='submit' value='Erledigt' name='done' class='submit'>";
}
?>
<input type="submit" value="Ausloggen" name="logout" class="submit">
</form>
<br>
<form name="scan" method="POST" action="index.php" target="iwdb" enctype="multipart/form-data">
<input type="hidden" name="sid" value="<?php echo $sid ?>">
<input type="hidden" name="action" value="newscan">
<input type="hidden" name="seluser" value="<?php echo $login_user['id'] ?>">
Neuer Bericht:<br>
<textarea id="reportText" name="text" rows="2" cols="40"></textarea><br>
<input id="reportSave" type="submit" value="Speichern" name="B1" class="submit">
</form>
<?php } ?>
<br>
<table>
<tr>
<td width="100%">
<span class="time">Uhrzeit</span>
</td>
<td nowrap>
<span class="time"><?php echo strftime(CONFIG_DATETIMEFORMAT, CURRENT_UNIX_TIME); ?></span>
</td>
</tr>
</table>
<?php foreach ($view as $user) { ?>
<table>
<tr>
<td width="100%">
<?php
echo "<a href='?mode=index&redirect={$redirect}&login={$user['id']}&allianz={$allianz}' target='_top'>$user[id]</a>";
?>
</td>
<?php
if (isset($user['next_date_text'])) {
echo '<td nowrap>';
if ($user['next_status'] == $status['attack'] && $user['next_date'] <= CURRENT_UNIX_TIME) {
echo "<span class='time_critical'>";
} elseif ($user['next_status'] == $status['attack'] && $user['next_date'] > CURRENT_UNIX_TIME) {
echo "<span class='time_warning'>";
} else {
echo "<span class='time_normal'>";
}
echo $user['next_date_text'];
echo '</span>';
echo '</td>';
} ?>
</tr>
</table>
<?php if ($user['lastsitterloggedin'] OR (!empty($user['attack']) AND count($user['attack']) > 0) OR (!empty($user['probe']) AND count($user['probe']) > 0)) { ?>
<table>
<tr>
<td width="100%">
<?php
if (!empty($user['attack']) AND count($user['attack']) > 0) {
echo "<div class='attack'>Angriff von " . $user['attack'][0]['from'] . " auf " . $user['attack'][0]['coords'] . "</div>";
}
if (!empty($user['probe']) AND count($user['probe']) > 0) {
echo "<div class='probe'>Sondierung von " . $user['probe'][0]['from'] . " auf " . $user['probe'][0]['coords'] . "</div>";
}
if ($user['lastsitterloggedin']) {
echo "<div class='loggedin'>" . $user['lastsitteruser'] . " ist eingeloggt</div>";
}
if ($user['dauersittendue']) {
echo "<div class='dursitting_due'>" . $user['dauersittentext'] . "</div>";
}
?>
</td>
<td>
</td>
</tr>
</table>
<?php
}
}
?>
</body>
</html>
<?php
break;
default:
doc_message("Fehler: Unbekannter Modus '" . $mode . "'");
}
?>