-
Notifications
You must be signed in to change notification settings - Fork 1
/
planet_report.php
543 lines (486 loc) · 20 KB
/
planet_report.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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
<?php
// Blacknova Traders - A web-based massively multiplayer space combat and trading game
// Copyright (C) 2001-2012 Ron Harwood and the BNT development team
//
// 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/>.
//
// File: planet_report.php
include "config/config.php";
updatecookie ();
// New database driven language entries
load_languages($db, $lang, array('main', 'planet', 'port', 'common', 'global_includes', 'global_funcs', 'footer', 'planet_report'), $langvars, $db_logging);
$title = $l_pr_title;
include "header.php";
if (checklogin())
{
die();
}
$PRepType = null;
if (array_key_exists('PRepType', $_GET) == true) //!isset($_GET['PRepType']))
{
$PRepType = $_GET['PRepType'];
}
// Get data about planets
$res = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id='$user_ship_id'");
db_op_result ($db, $res, __LINE__, __FILE__, $db_logging);
$playerinfo = $res->fields;
?>
<div class="tablecell content both-border">
<div class="pad">
<?
// Determine what type of report is displayed and display it's title
if ($PRepType == 1 || !isset($PRepType)) // Display the commodities on the planets
{
$title = $title .": Status";
bigtitle ();
standard_report ();
}
elseif ($PRepType == 2) // Display the production values of your planets and allow changing
{
$title = $title .": Production";
bigtitle ();
planet_production_change ();
}
elseif ($PRepType == 0) // For typing in manually to get a report menu
{
$title = $title . ": Menu";
bigtitle ();
planet_report_menu ();
}
else // Display the menu if no valid options are passed in
{
$title = $title . ": Status";
bigtitle ();
planet_report ();
}
// Begin functions
function planet_report_menu ()
{
global $playerinfo;
global $l_pr_teamlink;
echo "<div style='width:100%; margin:auto; font-size:14px;'>\n";
echo "<strong><a href=\"planet_report.php?PRepType=1\" name=\"Planet Status\">Planet Status</a></strong><br>" .
"Displays the number of each Commodity on the planet (Ore, Organics, Goods, Energy, Colonists, Credits, Fighters, and Torpedoes)<br>" .
"<br>" .
"<strong><a href=\"planet_report.php?PRepType=2\" name=\"Planet Status\">Change Production</a></strong> <strong>Base Required</strong> on Planet<br>" .
"This Report allows you to change the rate of production of commondits on planets that have a base<br>" .
"-- You must travel to the planet to build a base set the planet to coporate or change the name (celebrations and such)<br>";
if ($playerinfo['team'] > 0)
{
echo "<br><strong><a href=team_planets.php>$l_pr_teamlink</a></strong><br> " .
"Commondity Report (like Planet Status) for planets marked Corporate by you and/or your fellow team member<br><br>";
}
echo "</div>\n";
}
function standard_report ()
{
global $db, $db_logging;
global $res;
global $playerinfo;
global $username;
global $sort;
global $query;
global $color_header, $color, $color_line1, $color_line2;
global $l_pr_teamlink, $l_pr_clicktosort;
global $l_sector, $l_name, $l_unnamed, $l_ore, $l_organics, $l_goods, $l_energy, $l_colonists, $l_credits, $l_fighters, $l_torps, $l_base;
global $l_selling, $l_pr_totals, $l_yes, $l_no;
echo "<div style='width:100%; margin:auto; font-size:14px;'>\n";
echo "Planetary report descriptions and <strong><a href=\"planet_report.php?PRepType=0\">menu</a></strong><br><br>" .
"<strong><a href=\"planet_report.php?PRepType=2\">Change Production</a></strong> <strong>Base Required</strong> on Planet<br>";
if ($playerinfo['team'] > 0)
{
echo "<br><strong><a href=team_planets.php>$l_pr_teamlink</a></strong><br> <br>";
}
$query = "SELECT * FROM {$db->prefix}planets WHERE owner=$playerinfo[ship_id]";
if (!empty($sort))
{
$query .= " ORDER BY";
if ($sort == "name")
{
$query .= " $sort ASC";
}
elseif ($sort == "organics" || $sort == "ore" || $sort == "goods" || $sort == "energy" ||$sort == "colonists" || $sort == "credits" || $sort == "fighters")
{
$query .= " $sort DESC, sector_id ASC";
}
elseif ($sort == "torp")
{
$query .= " torps DESC, sector_id ASC";
}
else
{
$query .= " sector_id ASC";
}
}
else
{
$query .= " ORDER BY sector_id ASC";
}
$res = $db->Execute($query);
db_op_result ($db, $res, __LINE__, __FILE__, $db_logging);
$i = 0;
if ($res)
{
while (!$res->EOF)
{
$planet[$i] = $res->fields;
$i++;
$res->MoveNext();
}
}
global $l_pr_noplanet;
$num_planets = $i;
if ($num_planets < 1)
{
echo "<br>" . $l_pr_noplanet;
}
else
{
echo "<br>";
echo "<form action=planet_report_ce.php method=post>";
// Next block of echo's creates the header of the table
echo $l_pr_clicktosort . "<br><br>";
echo "<strong>WARNING:</strong> \"Build\" and \"Take Credits\" will cause your ship to move. <br><br>";
/*
Start table
*/
?>
<div class="planet-table-container">
<?
echo "<table><tbody>";
echo "<tr>";
echo "<td><a href=\"planet_report.php?PRepType=1&sort=sector_id\">Sector</a></td>";
echo "<td><a href=\"planet_report.php?PRepType=1&sort=ore\">Ore</a></td>";
echo "<td><a href=\"planet_report.php?PRepType=1&sort=organics\">Organics</a></td>";
echo "<td><a href=\"planet_report.php?PRepType=1&sort=goods\">Goods</a></td>";
echo "<td><a href=\"planet_report.php?PRepType=1&sort=energy\">Energy</a></td>";
echo "<td><a href=\"planet_report.php?PRepType=1&sort=colonists\">Colonists</a></td>";
echo "<td><a href=\"planet_report.php?PRepType=1&sort=credits\">Credits</a></td>";
echo "<td></td>";
echo "<td><a href=\"planet_report.php?PRepType=1&sort=fighters\">Fighters</a></td>";
echo "<td><a href=\"planet_report.php?PRepType=1&sort=torp\">Torpedoes</a></td>";
// Next block of echo's fils the table and calculates the totals of all the commoditites as well as counting the bases and selling planets
echo "</tr>";
$total_organics = 0;
$total_ore = 0;
$total_goods = 0;
$total_energy = 0;
$total_colonists = 0;
$total_credits = 0;
$total_fighters = 0;
$total_torp = 0;
$total_base = 0;
$total_corp = 0;
$total_selling = 0;
for ($i = 0; $i < $num_planets; $i++)
{
$total_organics += $planet[$i]['organics'];
$total_ore += $planet[$i]['ore'];
$total_goods += $planet[$i]['goods'];
$total_energy += $planet[$i]['energy'];
$total_colonists += $planet[$i]['colonists'];
$total_credits += $planet[$i]['credits'];
$total_fighters += $planet[$i]['fighters'];
$total_torp += $planet[$i]['torps'];
if ($planet[$i]['base'] == "Y")
{
$total_base += 1;
}
if ($planet[$i]['corp'] > 0)
{
$total_corp += 1;
}
if ($planet[$i]['sells'] == "Y")
{
$total_selling += 1;
}
if (empty($planet[$i]['name']))
{
$planet[$i]['name'] = $l_unnamed;
}
if ($playerinfo['team'] > 0)
{
$ranking_colspan_control = 4;
}
else
{
$ranking_colspan_control = 6;
}
echo "<tr>";
echo "<td><a href=rsmove.php?engage=1&destination=". $planet[$i]['sector_id'] . ">". $planet[$i]['sector_id'] ."</a></td>";
echo "<td>" . NUMBER($planet[$i]['ore']) . "</td>";
echo "<td>" . NUMBER($planet[$i]['organics']) . "</td>";
echo "<td>" . NUMBER($planet[$i]['goods']) . "</td>";
echo "<td>" . NUMBER($planet[$i]['energy']) . "</td>";
echo "<td>" . NUMBER($planet[$i]['colonists']) . "</td>";
echo "<td><span class='table_word_gold'>" . NUMBER($planet[$i]['credits']) . "</span></td>";
echo "<td><div class='checkbox-round'><input type='checkbox' id='roundedOne_collect_".$planet[$i]['planet_id']."' name=TPCreds[] value=\"" . $planet[$i]['planet_id'] . "\"><label for='roundedOne_collect_".$planet[$i]['planet_id']."'></label></div></td>";
echo "<td>" . NUMBER($planet[$i]['fighters']) . "</td>";
echo "<td>" . NUMBER($planet[$i]['torps']) . "</td>";
echo "</tr><tr>";
echo "<td colspan='".$ranking_colspan_control."' class='planet-name'>Name: <span class='table_word_green'>" . $planet[$i]['name'] . "</span></td>";
if(base_build_check($planet, $i)=="Yes")
{
$ranking_base_info = "Yes! [<a href='planet_report.php?PRepType=2'>Edit >></a>]";
}
else if(base_build_check($planet, $i)=="No")
{
$ranking_base_info = "<span class='table_word_red'>No</span>";
}
else {
$ranking_base_info = "<span class='table_word_red'>No</span> [".base_build_check($planet, $i)."]";
}
echo "<td colspan='2'><span class='table_word_faded'>Has Base? " . $ranking_base_info . "</span></td>";
if ($playerinfo['team'] > 0)
{
echo "<td colspan='2'><span class='table_word_faded'>Is Corporate? " . ($planet[$i]['corp'] > 0 ? "$l_yes" : "$l_no") . "</span></td>";
}
echo "<td colspan='2'><span class='table_word_faded'>Set To Sell? " . ($planet[$i]['sells'] == 'Y' ? "$l_yes" : "$l_no") . "</span></td>";
echo "</tr>";
if ($color == $color_line1)
{
$color = $color_line2;
}
else
{
$color = $color_line1;
}
}
// the next block displays the totals
echo "<tr>";
echo "<td>Total:</td>";
echo "<td>" . NUMBER($total_ore) . "</td>";
echo "<td>" . NUMBER($total_organics) . "</td>";
echo "<td>" . NUMBER($total_goods) . "</td>";
echo "<td>" . NUMBER($total_energy) . "</td>";
echo "<td>" . NUMBER($total_colonists) . "</td>";
echo "<td colspan='2'><span class='table_word_yellow'>" . NUMBER($total_credits) . "</span></td>";
echo "<td>" . NUMBER($total_fighters) . "</td>";
echo "<td>" . NUMBER($total_torp) . "</td>";
echo "</tr><tr>";
echo "<td colspan='".$ranking_colspan_control."' class='planet-name'></td>";
echo "<td colspan='2'><span class='table_word_faded'>Total With Base: " . NUMBER($total_base) . "</span></td>";
if ($playerinfo['team'] > 0)
{
echo "<td colspan='2'><span class='table_word_faded'>Total Corporate: " . NUMBER($total_corp) . "</span></td>";
}
echo "<td colspan='2'><span class='table_word_faded'>Total Set To Sell: " . NUMBER($total_selling) . "</span></td>";
echo "</tr>";
echo "</tbody></table>";
?>
</div>
<?
echo "<br>";
echo "<input type=submit value=\"Collect Credits\"> <input type=reset value=reset>";
echo "</form>";
}
echo "</div>\n";
}
function planet_production_change()
{
global $db, $db_logging;
global $res;
global $playerinfo;
global $username;
global $sort;
global $query;
global $color_header, $color, $color_line1, $color_line2;
global $l_pr_teamlink, $l_pr_clicktosort;
global $l_pr_noplanet;
global $l_sector, $l_name, $l_unnamed, $l_ore, $l_organics, $l_goods, $l_energy, $l_colonists, $l_credits, $l_fighters;
global $l_torps, $l_base, $l_selling, $l_pr_totals, $l_yes, $l_no;
$query = "SELECT * FROM {$db->prefix}planets WHERE owner=? AND base='Y'";
echo "<div style='width:100%; margin:auto; font-size:14px;'>\n";
echo "Planetary report <strong><a href=\"planet_report.php?PRepType=0\">menu</a></strong><br><br>" .
"<strong><a href=\"planet_report.php?PRepType=1\">Planet Status</a></strong><br>";
if ($playerinfo['team'] > 0)
{
echo "<br><strong><a href=team_planets.php>$l_pr_teamlink</a></strong><br> <br>";
}
if (!empty($sort))
{
$query .= " ORDER BY";
if ($sort == "name")
{
$query .= " $sort ASC";
}
elseif ($sort == "organics" || $sort == "ore" || $sort == "goods" || $sort == "energy" || $sort == "fighters")
{
$query .= " prod_$sort DESC, sector_id ASC";
}
elseif ($sort == "colonists" || $sort == "credits")
{
$query .= " $sort DESC, sector_id ASC";
}
elseif ($sort == "torp")
{
$query .= " prod_torp DESC, sector_id ASC";
}
else
{
$query .= " sector_id ASC";
}
}
else
{
$query .= " ORDER BY sector_id ASC";
}
$res = $db->Execute($query, array($playerinfo['ship_id']));
db_op_result ($db, $res, __LINE__, __FILE__, $db_logging);
$i = 0;
if ($res)
{
while (!$res->EOF)
{
$planet[$i] = $res->fields;
$i++;
$res->MoveNext();
}
}
$num_planets = $i;
if ($num_planets < 1)
{
echo "<br>$l_pr_noplanet";
}
else
{
echo "<form action='planet_report_ce.php' method='post'>\n";
// Next block of echo's creates the header of the table
/*
Start table
*/
?>
<div class="planet-table-container">
<?
echo "<table><tbody>";
echo "<tr>";
echo "<td><a href='planet_report.php?PRepType=2&sort=sector_id'>$l_sector</a></td>";
echo "<td><a href='planet_report.php?PRepType=2&sort=name'>$l_name</a></td>";
echo "<td><a href='planet_report.php?PRepType=2&sort=ore'>$l_ore</a></td>";
echo "<td><a href='planet_report.php?PRepType=2&sort=organics'>$l_organics</a></td>";
echo "<td><a href='planet_report.php?PRepType=2&sort=goods'>$l_goods</a></td>";
echo "<td><a href='planet_report.php?PRepType=2&sort=energy'>$l_energy</a></td>";
echo "<td> <a href='planet_report.php?PRepType=2&sort=colonists'>$l_colonists</a></td>";
echo "<td> <a href='planet_report.php?PRepType=2&sort=credits'>$l_credits</a></td>";
echo "<td><a href='planet_report.php?PRepType=2&sort=fighters'>$l_fighters</a></td>";
echo "<td><a href='planet_report.php?PRepType=2&sort=torp'>$l_torps</a></td>";
if ($playerinfo['team'] > 0)
{
echo "<td>Corp?</strong></td>";
}
echo "<td>$l_selling?</strong></td>";
echo "</tr>";
$total_colonists = 0;
$total_credits = 0;
$total_corp = 0;
$temp_var = 0;
for ($i = 0; $i < $num_planets; $i++)
{
$total_colonists += $planet[$i]['colonists'];
$total_credits += $planet[$i]['credits'];
if (empty($planet[$i]['name']))
{
$planet[$i]['name'] = $l_unnamed;
}
echo "<tr>";
echo "<td><a href=rsmove.php?engage=1&destination=". $planet[$i]['sector_id'] . ">". $planet[$i]['sector_id'] ."</a></td>";
echo "<td>" . $planet[$i]['name'] . "</td>";
echo "<td>" . "<input size=6 type=text name=\"prod_ore[" . $planet[$i]['planet_id'] . "]\" value=\"" . $planet[$i]['prod_ore'] . "\">" . "</td>";
echo "<td>" . "<input size=6 type=text name=\"prod_organics[" . $planet[$i]['planet_id'] . "]\" value=\"" . $planet[$i]['prod_organics'] . "\">" . "</td>";
echo "<td>" . "<input size=6 type=text name=\"prod_goods[" . $planet[$i]['planet_id'] . "]\" value=\"" . $planet[$i]['prod_goods'] . "\">" . "</td>";
echo "<td>" . "<input size=6 type=text name=\"prod_energy[" . $planet[$i]['planet_id'] . "]\" value=\"" . $planet[$i]['prod_energy'] . "\">" . "</td>";
echo "<td>" . NUMBER($planet[$i]['colonists']) . "</td>";
echo "<td><span class='table_word_gold'>" . NUMBER($planet[$i]['credits']) . "</span></td>";
echo "<td>" . "<input size=6 type=text name=\"prod_fighters[" . $planet[$i]['planet_id'] . "]\" value=\"" . $planet[$i]['prod_fighters'] . "\">" . "</td>";
echo "<td>" . "<input size=6 type=text name=\"prod_torp[" . $planet[$i]['planet_id'] . "]\" value=\"" . $planet[$i]['prod_torp'] . "\">" . "</td>";
if ($playerinfo['team'] > 0)
{
echo "<td>" . corp_planet_checkboxes($planet, $i) . "</td>";
}
echo "<td align=center>" . selling_checkboxes($planet, $i) . "</td>";
echo "</tr>";
}
echo "<tr>";
echo "<td colspan='2'><span class='table_word_faded'>Totals:</span></td>";
echo "<td colspan='4'>" . "" . "</td>";
echo "<td>" . NUMBER($total_colonists) . "</td>";
echo "<td><span class='table_word_yellow'>" . NUMBER($total_credits) . "</span></td>";
if ($playerinfo['team'] > 0)
{
echo "<td colspan='4'></td>";
}
else
{
echo "<td colspan='3'></td>";
}
echo "</tr>";
echo "</tbody></table>";
?>
</div>
<?
/*End table*/
echo "<br>\n";
echo "<input type=hidden name=ship_id value=$playerinfo[ship_id]>\n";
echo "<input type=hidden name=team_id value=$playerinfo[team]>\n";
echo "<input type=submit value=submit> <input type=reset value=reset>\n";
echo "</form>\n";
}
echo "</div>\n";
}
function corp_planet_checkboxes($planet, $i)
{
if ($planet[$i]['corp'] <= 0)
{
return("<div class='checkbox-round'><input type='checkbox' id='roundedOne_corp_".$planet[$i]['planet_id']."' name='corp[{$i}]' value='{$planet[$i]['planet_id']}' /><label for='roundedOne_corp_".$planet[$i]['planet_id']."'></label></div>");
}
elseif ($planet[$i]['corp'] > 0)
{
return("<div class='checkbox-round'><input type='checkbox' id='roundedOne_corp_".$planet[$i]['planet_id']."' name='corp[{$i}]' value='{$planet[$i]['planet_id']}' checked /><label for='roundedOne_corp_".$planet[$i]['planet_id']."'></label></div>");
}
}
function selling_checkboxes($planet, $i)
{
if ($planet[$i]['sells'] != 'Y')
{
return("<div class='checkbox-round'><input type='checkbox' id='roundedOne_sell_".$planet[$i]['planet_id']."' name='sells[{$i}]' value='{$planet[$i]['planet_id']}' /><label for='roundedOne_sell_".$planet[$i]['planet_id']."'></label></div>");
}
elseif ($planet[$i]['sells'] == 'Y')
{
return("<div class='checkbox-round'><input type='checkbox' id='roundedOne_sell_".$planet[$i]['planet_id']."' name='sells[{$i}]' value='{$planet[$i]['planet_id']}' checked /><label for='roundedOne_sell_".$planet[$i]['planet_id']."'></label></div>");
}
}
function base_build_check($planet, $i)
{
global $l_yes, $l_no;
global $base_ore, $base_organics, $base_goods, $base_credits;
if ($planet[$i]['base'] == 'Y')
{
return("$l_yes");
}
elseif ($planet[$i]['ore'] >= $base_ore && $planet[$i]['organics'] >= $base_organics && $planet[$i]['goods'] >= $base_goods && $planet[$i]['credits'] >= $base_credits)
{
return("<a href=\"planet_report_ce.php?buildp=" . $planet[$i]['planet_id'] . "&builds=" . $planet[$i]['sector_id'] . "\">Build</a>");
}
else
{
return("$l_no");
}
}
echo "<br><br>";
TEXT_GOTOMAIN();
?>
</div></div>
<?
include "footer.php";
?>