-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
222 lines (209 loc) · 8.72 KB
/
index.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
<?php
/*
* MIT Licence
* Copyright (c) 2023 Simon Frankenberger
*
* Please see LICENCE.md for complete licence text.
*/
$start = microtime(true);
error_reporting(E_ALL);
ini_set('display_errors', 'false');
ob_start();
require_once __DIR__ . '/include/config.class.php';
if (Config::getBoolean(Config::SECTION_BASE, 'testing')) {
ini_set('display_errors', 'true');
}
require_once __DIR__ . '/include/functions.inc.php';
require_once __DIR__ . '/include/game_version.inc.php';
require_once __DIR__ . '/include/database.class.php';
verifyInstallation();
if (isLoggedIn()) {
if (!isAdmin() && isRoundOver()) {
session_destroy();
redirectTo('/?p=anmelden', 243);
}
if (!isAdmin() && isGameLocked()) {
session_destroy();
redirectTo('/?p=anmelden', 999);
}
if ($_SESSION['blm_lastAction'] + Config::getInt(Config::SECTION_BASE, 'session_timeout') < time()) {
session_destroy();
redirectTo('/?p=anmelden', 102);
}
Database::getInstance()->begin();
if (getOrDefault($_GET, 'rld', 0) === 0) {
updateLastAction();
}
if (CheckAuftraege($_SESSION['blm_user'])) {
Database::getInstance()->commit();
} else {
Database::getInstance()->rollback();
}
$data = Database::getInstance()->getPlayerBankAndMoneyGroupIdAndBioladenLevelAndDoenerstandLevel($_SESSION['blm_user']);
if ($data === null) {
session_destroy();
redirectTo('/?p=anmelden', 102);
}
$data['Einkommen'] = getIncome($data['Gebaeude' . building_shop], $data['Gebaeude' . building_kebab_stand]);
} else {
$data = array();
}
sendCspHeader();
?><!DOCTYPE html>
<!--
Site generated: <?= date('r', time()) . "\n"; ?>
Client: <?= escapeForOutput($_SERVER['REMOTE_ADDR']) . "\n"; ?>
Server: <?= escapeForOutput($_SERVER['SERVER_ADDR']) . "\n"; ?>
Script: <?= escapeForOutput($_SERVER['PHP_SELF']) . "\n"; ?>
Query-String: <?= escapeForOutput($_SERVER['QUERY_STRING']) . "\n"; ?>
User-Agent: <?= (array_key_exists('HTTP_USER_AGENT', $_SERVER) ? escapeForOutput($_SERVER['HTTP_USER_AGENT']) : 'none') . "\n"; ?>
Referer: <?= (array_key_exists('HTTP_REFERER', $_SERVER) ? escapeForOutput($_SERVER['HTTP_REFERER']) : 'none') . "\n"; ?>
-->
<html lang="de">
<head>
<?php
printHeaderCss(array(
'./styles/style.min.css',
'./styles/mobile.min.css',
'./styles/admin.min.css',
));
printHeaderJs(array(
'./js/functions.min.js',
));
?>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="keywords" content="Bioladenmanager, Evil Eye Productions, Browsergame, Simon Frankenberger"/>
<meta name="language" content="de"/>
<meta name="viewport" content="width=device-width, initial-scale=0.60, maximum-scale=5.0, minimum-scale=0.60">
<title><?= Config::get(Config::SECTION_BASE, 'game_title') . ' - ' . ucfirst(getCurrentPage()); ?></title>
</head>
<body>
<div id="Navigation" class="<?= (isLoggedIn() ? 'online' : 'offline'); ?>">
<div id="Logo"></div>
<?php
if (isLoggedIn()) {
?>
<div class="NaviBox" id="Navi">
<header>Navigation</header>
<?= createNavigationLink('index', 'Startseite'); ?>
<div class="NaviBlock">
<span>Gebäude:</span>
<?= createNavigationLink('gebaeude', 'Gebäude', 'Gebaeude'); ?>
<?= createNavigationLink('plantage', 'Plantage', 'Produktion'); ?>
<?= createNavigationLink('forschungszentrum', 'Forschungszentrum', 'Forschung'); ?>
<?= createNavigationLink('bioladen', 'Bioladen', 'Bioladen'); ?>
</div>
<div class="NaviBlock">
<span>Finanzen:</span>
<?= createNavigationLink('buero', 'Büro'); ?>
<?= createNavigationLink('bank', 'Bank', 'Bank'); ?>
<?= createNavigationLink('vertraege_liste', 'Verträge (' . Database::getInstance()->getOpenContractCount($_SESSION['blm_user']) . ')', 'Vertraege'); ?>
<?= createNavigationLink('marktplatz_liste', 'Marktplatz (' . Database::getInstance()->getMarktplatzCount() . ')', 'Marktplatz'); ?>
<?= createNavigationLink('mafia', 'Mafia', 'Mafia'); ?>
</div>
<div class="NaviBlock">
<span>Persönlich:</span>
<?= createNavigationLink('gruppe', sprintf("Gruppe (%s)", $data['Gruppe'] === null ? '0' : Database::getInstance()->getUnreadGroupMessageCount($data['Gruppe'], $_SESSION['blm_user']) . ' / ' . Database::getInstance()->countPendingGroupDiplomacy($data['Gruppe'])), 'Gruppe'); ?>
<?= createNavigationLink('nachrichten_liste', 'Nachrichten (' . Database::getInstance()->getUnreadMessageCount($_SESSION['blm_user']) . ')', 'Nachrichten'); ?>
<?= createNavigationLink('notizblock', 'Notizblock'); ?>
<?= createNavigationLink('einstellungen', 'Einstellungen'); ?>
<div class="NaviLink">
<a href="./chefbox.php" id="link_chefbox" target="_blank">Chefbox</a>
</div>
<?= (isAdmin() ? createNavigationLink('admin', 'Admin-Bereich') : ''); ?>
</div>
<div class="NaviBlock">
<span>Allgemein:</span>
<?= createNavigationLink('rangliste', 'Rangliste'); ?>
<?= createNavigationLink('statistik', 'Serverstatistik'); ?>
<?= createNavigationLink('regeln', 'Regeln'); ?>
<?= createNavigationLink('hilfe', 'Hilfe'); ?>
<?= createNavigationLink('impressum', 'Impressum / Datenschutz'); ?>
<div class="NaviSpacer"></div>
<div class="NaviLink"><a href="./actions/logout.php" id="link_logout">Abmelden</a></div>
</div>
</div>
<div class="NaviBox">
<header>Statistiken:</header>
<table id="UserStatistik">
<tr>
<td>Benutzer ID:</td>
<td><?php
if ($_SESSION['blm_sitter']) {
printf('%d (Sitter)', $_SESSION['blm_user']);
} else {
printf('%d', $_SESSION['blm_user']);
}
?></td>
</tr>
<tr>
<td>Bargeld:</td>
<td id="stat_money"><?= formatCurrency($data['Geld']); ?></td>
</tr>
<tr>
<td>Bankkonto:</td>
<td id="stat_bank"><?= formatCurrency($data['Bank']); ?></td>
</tr>
<tr>
<td>Grundeinkommen:</td>
<td id="stat_income"><?= formatCurrency($data['Einkommen']); ?></td>
</tr>
<tr>
<td>Letztes Einkommen:</td>
<td><?= formatTime(getLastIncomeTimestamp()); ?></td>
</tr>
<tr>
<td>Serverzeit:</td>
<td class="countup"><?= formatTime(time()); ?></td>
</tr>
<tr>
<td>Nächstes Einkommen:</td>
<td><?= formatTime(getLastIncomeTimestamp() + (Config::getInt(Config::SECTION_BASE, 'cron_interval') * 60)); ?></td>
</tr>
</table>
</div>
<?php
} else {
?>
<div class="NaviBox">
<header>Navigation</header>
<?= createNavigationLink('index', 'Startseite'); ?>
<?= createNavigationLink('anmelden', 'Anmelden'); ?>
<?= createNavigationLink('registrieren', 'Registrieren'); ?>
<?= createNavigationLink('regeln', 'Regeln'); ?>
<div class="NaviSpacer"></div>
<?= createNavigationLink('impressum', 'Impressum / Datenschutz'); ?>
</div>
<?php
}
?>
</div>
<div id="Inhalt">
<?php
include(sprintf('pages/%s.inc.php', getCurrentPage()));
?>
<div id="Footer">
<div>Bioladenmanager 2 Version <?= game_version; ?></div>
<div><a href="./?p=impressum">© 2007-2023, Simon Frankenberger</a></div>
<div>Letzte Änderung: <?= date('d.m.Y H:i', filemtime(__DIR__ . '/include/game_version.inc.php')); ?></div>
</div>
</div>
</body>
</html>
<?php
$dauer = 1000 * (microtime(true) - $start);
?>
<!--
PLT: <?= number_format($dauer, 2); ?>ms
Queries: <?= Database::getInstance()->getQueryCount() . "\n"; ?>
<?php
$warnings = Database::getInstance()->getWarnings();
if (count($warnings) > 0) {
echo "Warnings:\n==================\n";
foreach ($warnings as $i => $warning) {
printf("%d: %s\n", $i, $warning);
error_log($warning);
}
}
?>
-->