We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php declare(strict_types=1); |
||
2 | |||
3 | use Smr\Exceptions\GalaxyNotFound; |
||
4 | use Smr\Exceptions\SectorNotFound; |
||
5 | use Smr\Request; |
||
6 | |||
7 | try { |
||
8 | require_once('../bootstrap.php'); |
||
9 | |||
10 | // avoid site caching |
||
11 | header('Expires: Mon, 03 Nov 1976 16:10:00 GMT'); |
||
12 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
||
13 | header('Cache-Control: no-cache'); |
||
14 | header('Pragma: no-cache'); |
||
15 | header('Cache-Control: post-check=0, pre-check=0', false); |
||
16 | |||
17 | // ******************************** |
||
18 | // * |
||
19 | // * S e s s i o n |
||
20 | // * |
||
21 | // ******************************** |
||
22 | |||
23 | // do we have a session? |
||
24 | $session = Smr\Session::getInstance(); |
||
25 | if (!$session->hasAccount() || !$session->hasGame()) { |
||
26 | header('Location: /login.php'); |
||
27 | exit; |
||
28 | } |
||
29 | |||
30 | if (Request::has('sector_id')) { |
||
31 | $sectorID = Request::getInt('sector_id'); |
||
32 | try { |
||
33 | $galaxy = SmrGalaxy::getGalaxyContaining($session->getGameID(), $sectorID); |
||
34 | } catch (SectorNotFound) { |
||
35 | create_error('Invalid sector ID'); |
||
36 | } |
||
37 | } elseif (Request::has('galaxy_id')) { |
||
38 | $galaxyID = Request::getInt('galaxy_id'); |
||
39 | try { |
||
40 | $galaxy = SmrGalaxy::getGalaxy($session->getGameID(), $galaxyID); |
||
41 | } catch (GalaxyNotFound) { |
||
42 | create_error('Invalid galaxy ID'); |
||
43 | } |
||
44 | } |
||
45 | |||
46 | $player = $session->getPlayer(); |
||
47 | $account = $player->getAccount(); |
||
48 | |||
49 | // Create a session to store temporary display options |
||
50 | // Garbage collect here often, since the page is slow anyways (see map_local.php) |
||
51 | if (!session_start(['gc_probability' => 10, 'gc_maxlifetime' => 86400])) { |
||
52 | throw new Exception('Failed to start session'); |
||
53 | } |
||
54 | |||
55 | // Initialize the template |
||
56 | $template = Smr\Template::getInstance(); |
||
57 | |||
58 | // Set temporary options |
||
59 | if ($player->hasAlliance()) { |
||
60 | if (Request::has('change_settings')) { |
||
61 | $_SESSION['show_seedlist_sectors'] = Request::has('show_seedlist_sectors'); |
||
62 | $_SESSION['hide_allied_forces'] = Request::has('hide_allied_forces'); |
||
63 | } |
||
64 | $showSeedlistSectors = $_SESSION['show_seedlist_sectors'] ?? false; |
||
65 | $hideAlliedForces = $_SESSION['hide_allied_forces'] ?? false; |
||
66 | $template->assign('ShowSeedlistSectors', $showSeedlistSectors); |
||
67 | $template->assign('HideAlliedForces', $hideAlliedForces); |
||
68 | $template->assign('CheckboxFormHREF', ''); // Submit to same page |
||
69 | } |
||
70 | |||
71 | // Get the last sector in the last galaxy for form validation |
||
72 | $galaxies = SmrGalaxy::getGameGalaxies($session->getGameID()); |
||
73 | $template->assign('GameGalaxies', $galaxies); |
||
74 | $template->assign('LastSector', $player->getGame()->getLastSectorID()); |
||
75 | |||
76 | if (!isset($galaxy)) { |
||
77 | $galaxy = SmrGalaxy::getGalaxyContaining($player->getGameID(), $player->getSectorID()); |
||
78 | if ($account->isCenterGalaxyMapOnPlayer()) { |
||
79 | $sectorID = $player->getSectorID(); |
||
80 | } |
||
81 | } |
||
82 | |||
83 | // Efficiently construct the caches before proceeding |
||
84 | $galaxy->getSectors(); |
||
85 | $galaxy->getLocations(); |
||
86 | $galaxy->getPlanets(); |
||
87 | $galaxy->getForces(); |
||
88 | $galaxy->getPlayers(); |
||
89 | |||
90 | if (isset($sectorID)) { |
||
91 | $template->assign('FocusSector', $sectorID); |
||
92 | $mapSectors = $galaxy->getMapSectors($sectorID); |
||
93 | } else { |
||
94 | $mapSectors = $galaxy->getMapSectors(); |
||
95 | } |
||
96 | |||
97 | $template->assign('Title', 'Galaxy Map'); |
||
98 | |||
99 | if (!empty($account->getCssLink())) { |
||
100 | $template->assign('ExtraCSSLink', $account->getCssLink()); |
||
101 | } |
||
102 | $template->assign('CSSLink', $account->getCssUrl()); |
||
103 | $template->assign('CSSColourLink', $account->getCssColourUrl()); |
||
104 | $template->assign('FontSize', $account->getFontSize() - 20); |
||
105 | $template->assign('ThisGalaxy', $galaxy); |
||
106 | $template->assign('ThisAccount', $account); |
||
107 | $template->assign('ThisSector', $player->getSector()); |
||
108 | $template->assign('MapSectors', $mapSectors); |
||
109 | $template->assign('ThisShip', $player->getShip()); |
||
110 | $template->assign('ThisPlayer', $player); |
||
111 | |||
112 | // AJAX updates are not set up for the galaxy map at this time |
||
113 | $template->assign('AJAX_ENABLE_REFRESH', false); |
||
114 | |||
115 | $template->display('GalaxyMap.inc.php'); |
||
116 | } catch (Throwable $e) { |
||
117 | handleException($e); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
118 | } |
||
119 |