forked from thekabal/tki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ibank.php
191 lines (174 loc) · 7.47 KB
/
ibank.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
<?php declare(strict_types = 1);
/**
* ibank.php from The Kabal Invasion.
* The Kabal Invasion is a Free & Opensource (FOSS), web-based 4X space/strategy game.
*
* @copyright 2020 The Kabal Invasion development team, Ron Harwood, and the BNT development team
*
* @license GNU AGPL version 3.0 or (at your option) any later version.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once './common.php';
$login = new Tki\Login();
$login->checkLogin($pdo_db, $lang, $tkireg, $tkitimer, $template);
// Database driven language entries
$langvars = Tki\Translate::load($pdo_db, $lang, array('common', 'footer',
'ibank', 'insignias', 'news', 'regional',
'universal'));
$title = $langvars['l_ibank_title'];
$body_class = 'ibank';
$header = new Tki\Header();
$header->display($pdo_db, $lang, $template, $title, $body_class);
$players_gateway = new \Tki\Players\PlayersGateway($pdo_db);
$playerinfo = $players_gateway->selectPlayerInfo($_SESSION['username']);
$ibank_gateway = new Tki\Ibank\IbankGateway($pdo_db);
$bank_account = $ibank_gateway->selectIbankAccount($playerinfo['ship_id']);
echo "<body class='" . $body_class . "'>";
echo "<center>";
echo '<img src="' . $template->getVariables('template_dir') . '/images/div1.png" alt="" style="width: 600px; height:21px">';
echo '<div style="width:600px; max-width:600px;" class="ibank">';
echo '<table style="width:600px; height:350px;" border="0px">';
echo '<tr><td style="background-image:URL(' . $template->getVariables('template_dir') . '/images/ibankscreen.png); background-repeat:no-repeat;" align="center">';
echo '<table style="width:550px; height:300px;" border="0px">';
if (!$tkireg->allow_ibank)
{
Tki\Ibank::ibankError($pdo_db, $lang, $langvars['l_ibank_malfunction'], "main.php", $tkireg, $tkitimer, $template);
}
// Detect if this variable exists, and filter it. Returns false if anything wasn't right.
$command = null;
$command = filter_input(INPUT_GET, 'command', FILTER_SANITIZE_STRING);
if (($command === null) || (strlen(trim($command)) === 0))
{
$command = false;
}
// Detect if this variable exists, and filter it. Returns false if anything wasn't right.
$amount = null;
$amount = (int) filter_input(INPUT_POST, 'amount', FILTER_SANITIZE_NUMBER_INT);
if ($amount === 0)
{
$amount = 0;
}
// Detect if this variable exists, and filter it. Returns false if anything wasn't right.
$dplanet_id = null;
$dplanet_id = (int) filter_input(INPUT_POST, 'dplanet_id', FILTER_SANITIZE_NUMBER_INT);
if ($dplanet_id === 0)
{
$dplanet_id = 0;
}
// Detect if this variable exists, and filter it. Returns false if anything wasn't right.
$minimum = (int) filter_input(INPUT_POST, 'minimum', FILTER_SANITIZE_NUMBER_INT);
if ($minimum === 0)
{
$minimum = 0;
}
// Detect if this variable exists, and filter it. Returns false if anything wasn't right.
$maximum = (int) filter_input(INPUT_POST, 'maximum', FILTER_SANITIZE_NUMBER_INT);
if ($maximum === 0)
{
$maximum = 0;
}
if ($command == 'login') // Main menu
{
Tki\Ibank::ibankLogin($pdo_db, $tkireg, $playerinfo, $bank_account);
}
elseif ($command == 'withdraw') // Withdraw menu
{
Tki\IbankWithdraw::before($pdo_db, $lang, $bank_account);
}
elseif ($command == 'withdraw2') // Withdraw operation
{
Tki\IbankWithdraw::after($pdo_db, $lang, $playerinfo, $amount, $bank_account, $tkireg, $tkitimer, $template);
}
elseif ($command == 'deposit') // Deposit menu
{
Tki\IbankDeposit::before($pdo_db, $lang, $bank_account, $playerinfo);
}
elseif ($command == 'deposit2') // Deposit operation
{
Tki\IbankDeposit::after($pdo_db, $lang, $playerinfo, $amount, $bank_account, $tkireg, $tkitimer, $template);
}
elseif ($command == 'transfer') // Main transfer menu
{
Tki\IbankTransferMain::main($pdo_db, $lang, $playerinfo, $tkireg);
}
elseif ($command == 'transfer2') // Specific transfer menu (ship or planet)
{
Tki\IbankTransferSpecific::specific($pdo_db, $lang, $langvars, $tkireg, $tkitimer, $playerinfo, $ship_id, $splanet_id, $dplanet_id, $template);
}
elseif ($command == 'transfer3') // Transfer operation
{
Tki\IbankTransferFinal::final($pdo_db, $lang, $playerinfo, $ship_id, $splanet_id, $dplanet_id, $amount, $tkireg, $tkitimer, $template);
}
elseif ($command == 'loans') // Loans menu
{
Tki\Ibank::ibankLoans($pdo_db, $lang, $tkireg, $playerinfo, $bank_account);
}
elseif ($command == 'borrow') // Borrow operation
{
Tki\Ibank::ibankBorrow($pdo_db, $lang, $tkireg, $tkitimer, $playerinfo, $bank_account, $amount, $template);
}
elseif ($command == 'repay') // Repay operation
{
Tki\Ibank::ibankRepay($pdo_db, $lang, $playerinfo, $bank_account, $amount, $tkireg, $tkitimer, $template);
}
elseif ($command == 'consolidate') // Consolidate menu
{
Tki\IbankConsolidate::before($pdo_db, $lang, $tkireg, $dplanet_id);
}
elseif ($command == 'consolidate2') // Consolidate compute
{
Tki\IbankConsolidate::after($pdo_db, $lang, $playerinfo, $tkireg, $tkitimer, $dplanet_id, $minimum, $maximum, $template);
}
elseif ($command == 'consolidate3') // Consolidate operation
{
Tki\IbankConsolidate::third($pdo_db, $lang, $playerinfo, $tkireg, $tkitimer, $dplanet_id, $minimum, $maximum, $template);
}
else
{
echo "
<tr>
<td width='25%' valign='bottom' align='left'><a href=\"main.php\">" . $langvars['l_ibank_quit'] . "</a></td>
<td width='50%' style='text-align:left;'>
<pre style='text-align:left;' class='term'>
IIIIIIIIII GGGGGGGGGGGGG BBBBBBBBBBBBBBBBB
I::::::::I GGG::::::::::::G B::::::::::::::::B
I::::::::I GG:::::::::::::::G B::::::BBBBBB:::::B
II::::::II G:::::GGGGGGGG::::G BB:::::B B:::::B
I::::I G:::::G GGGGGG B::::B B:::::B
I::::I G:::::G B::::B B:::::B
I::::I G:::::G B::::BBBBBB:::::B
I::::I G:::::G GGGGGGGGGG B:::::::::::::BB
I::::I G:::::G G::::::::G B::::BBBBBB:::::B
I::::I G:::::G GGGGG::::G B::::B B:::::B
I::::I G:::::G G::::G B::::B B:::::B
I::::I G:::::G G::::G B::::B B:::::B
II::::::II G:::::GGGGGGGG::::G BB:::::BBBBBB::::::B
I::::::::I GG:::::::::::::::G B:::::::::::::::::B
I::::::::I GGG::::::GGG:::G B::::::::::::::::B
IIIIIIIIII GGGGGG GGGG BBBBBBBBBBBBBBBBB
</pre>
<center class='term'>";
echo $langvars['l_ibank_title'];
echo "(tm)<br>";
echo $langvars['l_ibank_humor'];
echo "<br> </center></td>
<td width='25%' valign='bottom' align='right'><a href=\"ibank.php?command=login\">" . $langvars['l_ibank_login'] . "</a></td>";
}
echo "</table></td></tr></table></div>";
echo '<img src="' . $template->getVariables('template_dir') . '/images/div2.png" alt="" style="width: 600px; height:21px">';
echo '</center>';
$footer = new Tki\Footer();
$footer->display($pdo_db, $lang, $tkireg, $tkitimer, $template);