Mercurial > hg > batmud > gmap2
annotate index.php @ 317:5a902083a216 gmap2
Use PHP cookie options array and set SameSite policy.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 03 Dec 2020 06:26:08 +0200 |
parents | 8e686cda5c6e |
children |
rev | line source |
---|---|
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
1 <?php |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
2 require "config.inc.php"; |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
3 |
255
d9e51ab58503
Improve the bootstrap configuration process.
Matti Hamalainen <ccr@tnsp.org>
parents:
253
diff
changeset
|
4 if (!isset($pageBaseURL) || !isset($gmapsKey) || !isset($gmapsVersion)) |
d9e51ab58503
Improve the bootstrap configuration process.
Matti Hamalainen <ccr@tnsp.org>
parents:
253
diff
changeset
|
5 { |
256 | 6 echo "Some settings are missing. Please check your configuration."; |
255
d9e51ab58503
Improve the bootstrap configuration process.
Matti Hamalainen <ccr@tnsp.org>
parents:
253
diff
changeset
|
7 exit; |
d9e51ab58503
Improve the bootstrap configuration process.
Matti Hamalainen <ccr@tnsp.org>
parents:
253
diff
changeset
|
8 } |
d9e51ab58503
Improve the bootstrap configuration process.
Matti Hamalainen <ccr@tnsp.org>
parents:
253
diff
changeset
|
9 |
219 | 10 // |
11 // Generic settings | |
12 // | |
288
4e6886674e40
Check markers.json file for latest update timestamp.
Matti Hamalainen <ccr@tnsp.org>
parents:
285
diff
changeset
|
13 $lastMTime = filemtime("markers.json"); |
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
14 $pageCharset = "UTF-8"; |
183 | 15 |
16 $pageTitle1 = "BatMUD: The Age of Exiles"; | |
282 | 17 $pageTitle2 = "Google Maps Hack"; |
183 | 18 $pageBy = "by Jeskko & Ggr"; |
19 $pageTitle = $pageTitle1." - ".$pageTitle2." ".$pageBy; | |
20 | |
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
21 $dataCopyrights = "Map data by BAT ry, Ggr, Slobber and Jeskko"; |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
22 |
219 | 23 |
305 | 24 $jsLibs = |
25 [ | |
262 | 26 "map.js", |
27 "lib/util.js", | |
28 "lib/markerwithlabel_packed.js", | |
29 "lib/markermanager_packed.js", | |
30 "world.js", | |
31 "icons.js", | |
32 "markers.js", | |
33 "nav.js", | |
305 | 34 ]; |
262 | 35 |
305 | 36 $jsTokens = ["x", "y", "zoom", "token", "name"]; |
262 | 37 |
38 | |
219 | 39 // |
40 // Handle CSS stuff | |
41 // | |
42 $pageCSSCookie = "gmapcss"; | |
43 if (isset($_GET["css"])) | |
44 { | |
45 $pageCSSIndex = intval($_GET["css"]); | |
317
5a902083a216
Use PHP cookie options array and set SameSite policy.
Matti Hamalainen <ccr@tnsp.org>
parents:
309
diff
changeset
|
46 |
5a902083a216
Use PHP cookie options array and set SameSite policy.
Matti Hamalainen <ccr@tnsp.org>
parents:
309
diff
changeset
|
47 $coptions = [ |
5a902083a216
Use PHP cookie options array and set SameSite policy.
Matti Hamalainen <ccr@tnsp.org>
parents:
309
diff
changeset
|
48 "expires" => time() + 365*24*60*60, |
5a902083a216
Use PHP cookie options array and set SameSite policy.
Matti Hamalainen <ccr@tnsp.org>
parents:
309
diff
changeset
|
49 "path" => "/", |
5a902083a216
Use PHP cookie options array and set SameSite policy.
Matti Hamalainen <ccr@tnsp.org>
parents:
309
diff
changeset
|
50 "samesite" => "Strict", |
5a902083a216
Use PHP cookie options array and set SameSite policy.
Matti Hamalainen <ccr@tnsp.org>
parents:
309
diff
changeset
|
51 "secure" => false, |
5a902083a216
Use PHP cookie options array and set SameSite policy.
Matti Hamalainen <ccr@tnsp.org>
parents:
309
diff
changeset
|
52 "httponly" => false, |
5a902083a216
Use PHP cookie options array and set SameSite policy.
Matti Hamalainen <ccr@tnsp.org>
parents:
309
diff
changeset
|
53 ]; |
5a902083a216
Use PHP cookie options array and set SameSite policy.
Matti Hamalainen <ccr@tnsp.org>
parents:
309
diff
changeset
|
54 |
5a902083a216
Use PHP cookie options array and set SameSite policy.
Matti Hamalainen <ccr@tnsp.org>
parents:
309
diff
changeset
|
55 setcookie($pageCSSCookie, $pageCSSIndex, $coptions); |
219 | 56 } |
57 else | |
58 { | |
59 $pageCSSIndex = isset($_COOKIE[$pageCSSCookie]) ? intval($_COOKIE[$pageCSSCookie]) : 1; | |
60 } | |
61 $pageCSS = "css/mapstyle".$pageCSSIndex.".css"; | |
62 | |
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
63 echo |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
64 "<!DOCTYPE html>\n". |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
65 "<html>\n". |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
66 " <head>\n". |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
67 " <meta name=\"keywords\" content=\"batmud,map,laenor,lucentium,rothikgen,desolathya,furnachia,mud,mush,moo,online,massively,multiplayer,game,mmorpg,jeskko\" />\n". |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
68 " <meta charset=\"".$pageCharset."\">\n". |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
69 " <meta http-equiv=\"Content-type\" content=\"text/html;charset=".$pageCharset."\">\n". |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
70 " <title>".$pageTitle."</title>\n". |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
71 " <meta name=\"description\" content=\"".$pageTitle."\"/>\n". |
304
2388ebb0567b
The 'sensor' parameter is not required by GMaps API anymore, re: https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
72 " <script src=\"https://maps.googleapis.com/maps/api/js?v=". |
2388ebb0567b
The 'sensor' parameter is not required by GMaps API anymore, re: https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
73 $gmapsVersion.(isset($gmapsKey) ? "&key=".$gmapsKey: ""). |
2388ebb0567b
The 'sensor' parameter is not required by GMaps API anymore, re: https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
74 "\" type=\"text/javascript\"></script>\n". |
293 | 75 " <link rel=\"stylesheet\" href=\"css/common.css\" type=\"text/css\" />\n". |
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
76 " <link rel=\"stylesheet\" href=\"".$pageCSS."\" type=\"text/css\" />\n". |
262 | 77 " </head>\n". |
78 " <body>\n"; | |
79 | |
253 | 80 @include "urchin.inc.php"; |
81 ?> | |
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
82 <div id="header"> |
216
ccb8e748a03f
Some stylesheet and HTML work.
Matti Hamalainen <ccr@tnsp.org>
parents:
200
diff
changeset
|
83 <a id="headlogo" href="http://www.bat.org/"></a> |
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
84 <div id="headcontent"> |
183 | 85 <h1><?php echo $pageTitle1 ?></h1> |
290
8e120dadd0a5
Improve layout and stylesheets slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
86 <div class="subtitle"><?php echo $pageTitle2 ?> <span class="credits"><?php echo $pageBy ?></span></div> |
8e120dadd0a5
Improve layout and stylesheets slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
87 <div class="version">Updated <span class="timestamp"><?php echo date("D d.m.Y H:i:s T", $lastMTime); ?></span></div> |
219 | 88 <div class="controls"> |
89 <?php | |
90 for ($i = 1; $i <= 4; $i++) | |
285
81547bf400a6
Add explanatory titles to certain UI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
91 echo " <a class=\"stylesel\" href=\"?css=".$i."\" title=\"Switch to site style #".$i."\">".$i."</a>\n"; |
219 | 92 ?> |
285
81547bf400a6
Add explanatory titles to certain UI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
93 <a href="javascript:pmapMakeLink()" title="Create a URL link pointing to the current view.">Make link</a> |
219 | 94 </div> |
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
95 </div> |
19 | 96 </div> |
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
97 <div id="map"></div> |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
98 <div id="copyrights"><?php echo $dataCopyrights ?></div> |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
99 <div id="sidebar"> |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
100 <div id="sidetop"></div> |
275
e336d0d18c8f
Remove forced style def from HTML.
Matti Hamalainen <ccr@tnsp.org>
parents:
271
diff
changeset
|
101 <div id="sidebox"> |
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
102 <div id="controls"></div> |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
103 <div id="sidecontent"></div> |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
104 </div> |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
105 <div id="sidebottom"></div> |
19 | 106 </div> |
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
107 <div id="sidecoll"> |
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
108 <div id="collbuttondiv"> |
198
66ac93b63482
HTML5 compatibility cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
197
diff
changeset
|
109 <a href="javascript:pmapToggleSideBar()"><img src="img/right.gif" id="collbutton" alt="Collapse or uncollapse menus"></a> |
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
110 </div> |
0 | 111 </div> |
167
01720e81667e
Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
112 <div id="footer"> |
216
ccb8e748a03f
Some stylesheet and HTML work.
Matti Hamalainen <ccr@tnsp.org>
parents:
200
diff
changeset
|
113 <div id="footercontent"> </div> |
19 | 114 </div> |
200 | 115 <?php |
262 | 116 |
117 foreach ($jsLibs as $libName) | |
305 | 118 { |
262 | 119 echo " <script type=\"text/javascript\" src=\"".$libName."\"></script>\n"; |
305 | 120 } |
250 | 121 |
305 | 122 $jsData = []; |
262 | 123 foreach ($jsTokens as $key) |
124 { | |
309 | 125 if (isset($_GET[$key]) && strlen($sval = $_GET[$key]) > 0) |
262 | 126 { |
309 | 127 $jsData[$key] = is_numeric($sval) ? intval($sval) : strval($sval); |
262 | 128 } |
129 } | |
250 | 130 |
262 | 131 echo |
132 " <script type=\"text/javascript\">\n". | |
133 " pmapBaseURL = \"".$pageBaseURL."\";\n". | |
309 | 134 " pmapInitializeMap(".json_encode($jsData).");\n". |
262 | 135 " </script>\n". |
136 " </body>\n". | |
137 "</html>\n"; | |
200 | 138 ?> |