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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
85f79c765ab1 missing semicolon
jeskko
parents: 255
diff changeset
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
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
10 //
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
11 // Generic settings
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
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
a0f377c415ee Nicer style / cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
15
a0f377c415ee Nicer style / cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
16 $pageTitle1 = "BatMUD: The Age of Exiles";
282
43d3d2e943aa Bump version.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
17 $pageTitle2 = "Google Maps Hack";
183
a0f377c415ee Nicer style / cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
18 $pageBy = "by Jeskko &amp; Ggr";
a0f377c415ee Nicer style / cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
19 $pageTitle = $pageTitle1." - ".$pageTitle2." ".$pageBy;
a0f377c415ee Nicer style / cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
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
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
23
305
585a8fb4a286 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 304
diff changeset
24 $jsLibs =
585a8fb4a286 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 304
diff changeset
25 [
262
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
26 "map.js",
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
27 "lib/util.js",
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
28 "lib/markerwithlabel_packed.js",
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
29 "lib/markermanager_packed.js",
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
30 "world.js",
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
31 "icons.js",
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
32 "markers.js",
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
33 "nav.js",
305
585a8fb4a286 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 304
diff changeset
34 ];
262
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
35
305
585a8fb4a286 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 304
diff changeset
36 $jsTokens = ["x", "y", "zoom", "token", "name"];
262
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
37
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
38
219
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
39 //
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
40 // Handle CSS stuff
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
41 //
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
42 $pageCSSCookie = "gmapcss";
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
43 if (isset($_GET["css"]))
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
44 {
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
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
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
56 }
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
57 else
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
58 {
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
59 $pageCSSIndex = isset($_COOKIE[$pageCSSCookie]) ? intval($_COOKIE[$pageCSSCookie]) : 1;
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
60 }
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
61 $pageCSS = "css/mapstyle".$pageCSSIndex.".css";
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
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) ? "&amp;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
0a14a25a5f15 Rename a stylesheet file.
Matti Hamalainen <ccr@tnsp.org>
parents: 290
diff changeset
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
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
77 " </head>\n".
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
78 " <body>\n";
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
79
253
c7abc2cce799 Add urchin include.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
80 @include "urchin.inc.php";
c7abc2cce799 Add urchin include.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
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
a0f377c415ee Nicer style / cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
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
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
88 <div class="controls">
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
89 <?php
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
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
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
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
1e1f3c9967d4 Add CSS selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 218
diff changeset
94 </div>
167
01720e81667e Separate configuration variables into config.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
95 </div>
19
7d7eb223cb51 Work on layout.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
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
7d7eb223cb51 Work on layout.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
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
f8eeb66cdb07 initial commit of new map
jeskko
parents:
diff changeset
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">&nbsp;</div>
19
7d7eb223cb51 Work on layout.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
114 </div>
200
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 198
diff changeset
115 <?php
262
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
116
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
117 foreach ($jsLibs as $libName)
305
585a8fb4a286 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 304
diff changeset
118 {
262
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
119 echo " <script type=\"text/javascript\" src=\"".$libName."\"></script>\n";
305
585a8fb4a286 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 304
diff changeset
120 }
250
ee5492ccba8e Add configurable base URL.
Matti Hamalainen <ccr@tnsp.org>
parents: 243
diff changeset
121
305
585a8fb4a286 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 304
diff changeset
122 $jsData = [];
262
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
123 foreach ($jsTokens as $key)
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
124 {
309
8e686cda5c6e Fix potential XSS :S
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
125 if (isset($_GET[$key]) && strlen($sval = $_GET[$key]) > 0)
262
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
126 {
309
8e686cda5c6e Fix potential XSS :S
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
127 $jsData[$key] = is_numeric($sval) ? intval($sval) : strval($sval);
262
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
128 }
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
129 }
250
ee5492ccba8e Add configurable base URL.
Matti Hamalainen <ccr@tnsp.org>
parents: 243
diff changeset
130
262
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
131 echo
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
132 " <script type=\"text/javascript\">\n".
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
133 " pmapBaseURL = \"".$pageBaseURL."\";\n".
309
8e686cda5c6e Fix potential XSS :S
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
134 " pmapInitializeMap(".json_encode($jsData).");\n".
262
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
135 " </script>\n".
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
136 " </body>\n".
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
137 "</html>\n";
200
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 198
diff changeset
138 ?>