annotate www/common.inc.php @ 2763:78ad0e51b7b5

Improve wizards.txt parser, add functionality for specifying alternative / additional names as some wizards have used more than one. Also other improvements in wizard data handling.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 12 Mar 2024 15:47:58 +0200
parents 06ce4399639c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1646
2cbce82aa3c3 Use full <?php ?> tag, misc cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1630
diff changeset
1 <?php
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
2 // Globals and definitions
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
3 $errorSet = FALSE;
1977
c34e55de9f29 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1919
diff changeset
4 $errorMsgs = [];
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
5 $statusSet = 0;
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
6 $statusMsg = "";
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
7
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
8
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
9 // Location flags (translated to PHP from liblocfile.h)
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
10 define("LOCF_NONE" , 0x000000);
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
11
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
12 // Marker types
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
13 define("LOCF_M_SCENIC1" , 0x000001); // '?' Scenic marker
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
14 define("LOCF_M_SCENIC2" , 0x000002); // '%' Shrine marker/etc
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
15 define("LOCF_M_PCITY" , 0x000004); // 'C' Player city
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
16 define("LOCF_M_CITY" , 0x000008); // 'c' City
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
17 define("LOCF_M_MASK" , 0x00000f);
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
18
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
19 // Location types
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
20 define("LOCF_T_SHRINE" , 0x000010); // 'S' Raceshrine
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
21 define("LOCF_T_GUILD" , 0x000020); // 'G' Guild
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
22 define("LOCF_T_SS" , 0x000040); // 'P' Player guild/Secret Society
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
23 define("LOCF_T_MONSTER" , 0x000080); // 'M' Special monster
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
24 define("LOCF_T_TRAINER" , 0x000100); // 'T' Guild trainer
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
25 define("LOCF_T_FORT" , 0x000200); // 'F' Regions fort
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
26 define("LOCF_T_MASK" , 0x00fff0);
2037
e82ba6f55708 Refactor how the location filtering works internally to use proper LOC flags.
Matti Hamalainen <ccr@tnsp.org>
parents: 2036
diff changeset
27 define("LOCF_MASK" , (LOCF_M_PCITY | LOCF_M_CITY | LOCF_T_MASK));
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
28
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
29 // Extra flags
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
30 define("LOCF_INVIS" , 0x010000); // '-' Invisible marker / Don't show label
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
31 define("LOCF_CLOSED" , 0x020000); // '!' Area is CLOSED
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
32 define("LOCF_INSTANCED" , 0x040000); // 'I' Location is "instanced" for each player
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
33 define("LOCF_INVALID" , 0x400000); // Possibly invalid location
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
34 define("LOCF_NOMARKER" , 0x800000); // Location has no marker in mapdata or explicitly defined
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
35 define("LOCF_Q_MASK" , 0xff0000);
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
36
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
37
2401
4185a550c48f Rename area creator flags and separate area name flags form them.
Matti Hamalainen <ccr@tnsp.org>
parents: 2326
diff changeset
38 // Creator roles
2620
164aa519640d Use 'author' instead of 'creator' or 'coder'.
Matti Hamalainen <ccr@tnsp.org>
parents: 2619
diff changeset
39 define("AUTHOR_ORIG" , 0x000001); // '@' Original area creator
164aa519640d Use 'author' instead of 'creator' or 'coder'.
Matti Hamalainen <ccr@tnsp.org>
parents: 2619
diff changeset
40 define("AUTHOR_RECODER" , 0x000002); // '!' Converter or recoder of area
164aa519640d Use 'author' instead of 'creator' or 'coder'.
Matti Hamalainen <ccr@tnsp.org>
parents: 2619
diff changeset
41 define("AUTHOR_MAINTAINER" , 0x000004); // '%' Maintainer
164aa519640d Use 'author' instead of 'creator' or 'coder'.
Matti Hamalainen <ccr@tnsp.org>
parents: 2619
diff changeset
42 define("AUTHOR_EXPANDER" , 0x000008); // '&' Expander, adding new things
2401
4185a550c48f Rename area creator flags and separate area name flags form them.
Matti Hamalainen <ccr@tnsp.org>
parents: 2326
diff changeset
43
4185a550c48f Rename area creator flags and separate area name flags form them.
Matti Hamalainen <ccr@tnsp.org>
parents: 2326
diff changeset
44
4185a550c48f Rename area creator flags and separate area name flags form them.
Matti Hamalainen <ccr@tnsp.org>
parents: 2326
diff changeset
45 // Area name flags
4185a550c48f Rename area creator flags and separate area name flags form them.
Matti Hamalainen <ccr@tnsp.org>
parents: 2326
diff changeset
46 define("NAME_ORIG" , 0x000001); // '@' Original area name
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
47
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
48
2591
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
49 // Timestamp accuracy
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
50 define("TS_ACC_DEFAULT" , 0);
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
51 define("TS_ACC_KNOWN" , '!');
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
52 define("TS_ACC_GUESSTIMATE" , '?');
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
53 define("TS_ACC_APPROXIMATE" , '#');
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
54
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
55
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
56 // Location types table
2272
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
57 define("LTI_PAGE_DESC" , 0);
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
58 define("LTI_MENU_TITLE" , 1);
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
59 define("LTI_INVERT_FLAGS" , 2);
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
60 define("LTI_FLAGS" , 3);
1979
3c03ca974e6a Fix issue with "area" selection in location display not actually showing all
Matti Hamalainen <ccr@tnsp.org>
parents: 1977
diff changeset
61
1977
c34e55de9f29 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1919
diff changeset
62 $locationTypes =
c34e55de9f29 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1919
diff changeset
63 [
2272
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
64 //ID => Page description , Menu title , InvFlags, Mask flags
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
65 "" => ["ALL" , "EVERYTHING" , TRUE , 0 ],
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
66 "A" => ["Areas" , "Areas" , TRUE , LOCF_MASK ],
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
67 "S" => ["Race and other shrines" , "Shrines" , FALSE , LOCF_T_SHRINE ],
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
68 "G" => ["Guilds" , "Guilds" , FALSE , LOCF_T_GUILD ],
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
69 "P" => ["Outworld secret societies" , "SS" , FALSE , LOCF_T_SS ],
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
70 "M" => ["Special outworld monsters" , "Monsters" , FALSE , LOCF_T_MONSTER ],
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
71 "c" => ["Major cities" , "Cities" , FALSE , LOCF_M_CITY ],
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
72 "T" => ["Guild trainers" , "Trainers" , FALSE , LOCF_T_TRAINER ],
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
73 "C" => ["Player cities" , "PCities" , FALSE , LOCF_M_PCITY ],
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
74 //"F" => ["Regional Forts" , "Forts" , FALSE , LOCF_T_FORT ],
1977
c34e55de9f29 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1919
diff changeset
75 ];
1064
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
76
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
77
1427
7ea317bda09f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1401
diff changeset
78
2272
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
79 function mpGetLocationTypePrefix($flags)
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
80 {
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
81 switch ($flags & LOCF_M_MASK)
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
82 {
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
83 case LOCF_M_PCITY: return "PCITY ";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
84 case LOCF_M_CITY: return "CITY ";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
85 default:
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
86 switch ($flags & LOCF_T_MASK)
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
87 {
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
88 case LOCF_T_SHRINE: return "SHRINE ";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
89 case LOCF_T_GUILD: return "GUILD ";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
90 case LOCF_T_SS: return "SS ";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
91 case LOCF_T_MONSTER: return "MONSTER ";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
92 case LOCF_T_TRAINER: return "TRAINER ";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
93 case LOCF_T_FORT: return "FORT ";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
94 default: return "";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
95 }
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
96 }
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
97 }
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
98
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
99
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
100 function mpGetLocationTypeStr($flags)
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
101 {
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
102 switch ($flags & LOCF_M_MASK)
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
103 {
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
104 case LOCF_M_PCITY: return "Player City";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
105 case LOCF_M_CITY: return "Major City";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
106 default:
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
107 switch ($flags & LOCF_T_MASK)
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
108 {
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
109 case LOCF_T_SHRINE: return "Race Shrine";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
110 case LOCF_T_GUILD: return "Guild";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
111 case LOCF_T_SS: return "SS";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
112 case LOCF_T_MONSTER: return "Monster";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
113 case LOCF_T_TRAINER: return "Trainer";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
114 case LOCF_T_FORT: return "Fort";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
115 default: return "Area";
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
116 }
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
117 }
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
118 }
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
119
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
120
1900
ed98d2fe4bca Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1891
diff changeset
121 function mpError($msg)
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
122 {
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
123 global $errorSet, $errorMsgs;
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
124 $errorSet = TRUE;
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
125 $errorMsgs[] = $msg;
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
126 return FALSE;
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
127 }
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
128
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
129
1900
ed98d2fe4bca Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1891
diff changeset
130 function mpTrimIfString($val)
1653
59094d808524 Show "last modified" time stamps for each individual non-continent map.
Matti Hamalainen <ccr@tnsp.org>
parents: 1646
diff changeset
131 {
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
132 if (is_string($val))
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
133 return trim($val);
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
134 else
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
135 return $val;
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
136 }
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
137
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
138
1900
ed98d2fe4bca Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1891
diff changeset
139 function mpGetRequestItem($name, $default = "", $allowGet = FALSE)
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
140 {
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
141 if ($allowGet)
1900
ed98d2fe4bca Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1891
diff changeset
142 return isset($_REQUEST[$name]) ? mpTrimIfString($_REQUEST[$name]) : $default;
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
143 else
1900
ed98d2fe4bca Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1891
diff changeset
144 return isset($_POST[$name]) ? mpTrimIfString($_POST[$name]) : $default;
1653
59094d808524 Show "last modified" time stamps for each individual non-continent map.
Matti Hamalainen <ccr@tnsp.org>
parents: 1646
diff changeset
145 }
59094d808524 Show "last modified" time stamps for each individual non-continent map.
Matti Hamalainen <ccr@tnsp.org>
parents: 1646
diff changeset
146
59094d808524 Show "last modified" time stamps for each individual non-continent map.
Matti Hamalainen <ccr@tnsp.org>
parents: 1646
diff changeset
147
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
148 function chentities($str)
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
149 {
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
150 return htmlentities($str, ENT_NOQUOTES, "UTF-8");
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
151 }
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
152
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
153
2619
7758acc2fc41 Change how addition timestamps are displayed.
Matti Hamalainen <ccr@tnsp.org>
parents: 2591
diff changeset
154 function mpLocFormatTime($loc)
2013
06b8dff101da Add helper function mpStrFTime() for formatting timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents: 1979
diff changeset
155 {
2619
7758acc2fc41 Change how addition timestamps are displayed.
Matti Hamalainen <ccr@tnsp.org>
parents: 2591
diff changeset
156 switch ($loc["added_accuracy"])
7758acc2fc41 Change how addition timestamps are displayed.
Matti Hamalainen <ccr@tnsp.org>
parents: 2591
diff changeset
157 {
7758acc2fc41 Change how addition timestamps are displayed.
Matti Hamalainen <ccr@tnsp.org>
parents: 2591
diff changeset
158 case TS_ACC_GUESSTIMATE: return strftime("%b %Y", $loc["added"]);
7758acc2fc41 Change how addition timestamps are displayed.
Matti Hamalainen <ccr@tnsp.org>
parents: 2591
diff changeset
159 case TS_ACC_APPROXIMATE: return strftime("%b %Y", $loc["added"]);
7758acc2fc41 Change how addition timestamps are displayed.
Matti Hamalainen <ccr@tnsp.org>
parents: 2591
diff changeset
160 case TS_ACC_DEFAULT: return strftime("%d %b %Y*", $loc["added"]);
7758acc2fc41 Change how addition timestamps are displayed.
Matti Hamalainen <ccr@tnsp.org>
parents: 2591
diff changeset
161 default: return strftime("%d %b %Y", $loc["added"]);
7758acc2fc41 Change how addition timestamps are displayed.
Matti Hamalainen <ccr@tnsp.org>
parents: 2591
diff changeset
162 }
2013
06b8dff101da Add helper function mpStrFTime() for formatting timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents: 1979
diff changeset
163 }
06b8dff101da Add helper function mpStrFTime() for formatting timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents: 1979
diff changeset
164
06b8dff101da Add helper function mpStrFTime() for formatting timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents: 1979
diff changeset
165
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
166 function mpPrintPageHeader($title, $extra = "", $bodyExtra = "", $useMenu = TRUE)
1061
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
167 {
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
168 global $pageTitle, $pageMapURL, $pageCSS, $pageCharset, $pageLang;
1702
dd123d0a75d9 Sync cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1699
diff changeset
169
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
170 echo
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
171 "<!DOCTYPE html>\n".
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
172 "<html".(isset($pageLang) ? " lang=\"".$pageLang."\"" : "").">\n".
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
173 "<head>\n".
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
174 " <meta charset=\"".$pageCharset."\">\n".
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
175 " <title>".strip_tags($pageTitle)."</title>\n".
1581
59b2f9fe80fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1570
diff changeset
176 " <meta name=\"keywords\" content=\"batmud,map,laenor,lucentium,rothikgen,desolathya,furnachia,mud,mush,mmorpg,mmo,massively,multiplayer,online,network,game,ggr,pupunen\"/>\n".
59b2f9fe80fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1570
diff changeset
177 " <link rel=\"shortcut icon\" href=\"/maps/favicon.ico\" type=\"image/x-icon\" />\n".
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
178 $extra.
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
179 " <link rel=\"stylesheet\" href=\"".$pageCSS."\" type=\"text/css\" />\n".
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
180 "</head>\n".
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
181 "<body".$bodyExtra.">\n";
1687
Matti Hamalainen <ccr@tnsp.org>
parents: 1677
diff changeset
182
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
183 if ($useMenu)
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
184 require "menu.inc.php";
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
185
1687
Matti Hamalainen <ccr@tnsp.org>
parents: 1677
diff changeset
186 echo "<div id=\"contents\">\n";
Matti Hamalainen <ccr@tnsp.org>
parents: 1677
diff changeset
187
1702
dd123d0a75d9 Sync cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1699
diff changeset
188 /*
1696
Matti Hamalainen <ccr@tnsp.org>
parents: 1687
diff changeset
189 // CETA banner expires on 27.8.2017
Matti Hamalainen <ccr@tnsp.org>
parents: 1687
diff changeset
190 if (time() < mktime(0, 0, 0, 8, 27, 2017))
Matti Hamalainen <ccr@tnsp.org>
parents: 1687
diff changeset
191 {
Matti Hamalainen <ccr@tnsp.org>
parents: 1687
diff changeset
192 echo "<div style=\"text-align: center;\"><a href=\"https://suomiceta.wordpress.com/\"><img src=\"/cropped-suomiceta_nettisivubanneri.png\" alt=\"Suomi-CETA\" /></a></div>\n";
Matti Hamalainen <ccr@tnsp.org>
parents: 1687
diff changeset
193 }
1702
dd123d0a75d9 Sync cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1699
diff changeset
194 */
1061
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
195 }
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
196
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
197
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
198 function mpPrintPageFooter($useContents = TRUE)
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
199 {
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
200 if ($useContents)
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
201 echo "</div>\n";
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
202
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
203 echo "</body>\n</html>\n";
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
204 }
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
205
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
206
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
207 function mpGetMTimeStr($mtime)
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
208 {
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
209 // return date("D d.m.Y H:i:s T", $mtime);
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
210 return date("d.m.Y H:i", $mtime);
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
211 }
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
212
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
213
1620
6d620441af7f Rename various functions, and other cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1604
diff changeset
214 function mpFingerURL($name)
1061
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
215 {
2714
06b7c448338b Add countries field to wizard info database.
Matti Hamalainen <ccr@tnsp.org>
parents: 2620
diff changeset
216 return "https://www.bat.org/char/".$name;
1061
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
217 }
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
218
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
219
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
220 function burl($name)
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
221 {
1620
6d620441af7f Rename various functions, and other cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1604
diff changeset
222 // return "<a href=\"".mpFingerURL($name)."\">".$name."</a>";
6d620441af7f Rename various functions, and other cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1604
diff changeset
223 return "<b>".$name."</b>";
1061
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
224 }
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
225
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
226
2272
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
227 function mpGetMapURLLink($data, $link, $name, $gmap)
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
228 {
1557
7826a86e17c4 Do not show GMaps links for those maps that do not exist in Age of Exiles
Matti Hamalainen <ccr@tnsp.org>
parents: 1494
diff changeset
229 global $pageGMapURL, $continentList;
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
230 if ($link)
1450
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
231 {
1557
7826a86e17c4 Do not show GMaps links for those maps that do not exist in Age of Exiles
Matti Hamalainen <ccr@tnsp.org>
parents: 1494
diff changeset
232 $c = $continentList[$data["continent"]];
2416
e2fe94bbca17 Make HTML+JS maps go to continent's main city as default.
Matti Hamalainen <ccr@tnsp.org>
parents: 2401
diff changeset
233
e2fe94bbca17 Make HTML+JS maps go to continent's main city as default.
Matti Hamalainen <ccr@tnsp.org>
parents: 2401
diff changeset
234 $str = "<a class=\"mapLink\" href=\"".
e2fe94bbca17 Make HTML+JS maps go to continent's main city as default.
Matti Hamalainen <ccr@tnsp.org>
parents: 2401
diff changeset
235 $data["continent"].".html#loc".$data["x"]."_".$data["y"].
e2fe94bbca17 Make HTML+JS maps go to continent's main city as default.
Matti Hamalainen <ccr@tnsp.org>
parents: 2401
diff changeset
236 "\">".chentities($name)."</a>";
e2fe94bbca17 Make HTML+JS maps go to continent's main city as default.
Matti Hamalainen <ccr@tnsp.org>
parents: 2401
diff changeset
237
2326
53bea3800a93 Sync some web changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2272
diff changeset
238 if (isset($pageGMapURL) && $gmap &&
53bea3800a93 Sync some web changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2272
diff changeset
239 $c[CTI_HAS_MAP] == TRUE && $c[CTI_REG_CONT] == TRUE) // hasmap & read regular cont must be true
1557
7826a86e17c4 Do not show GMaps links for those maps that do not exist in Age of Exiles
Matti Hamalainen <ccr@tnsp.org>
parents: 1494
diff changeset
240 {
1566
c81828031c1f Cosmetics, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
241 $str .= " <a class=\"gmapLink\" title=\"GMap link\" ".
1557
7826a86e17c4 Do not show GMaps links for those maps that do not exist in Age of Exiles
Matti Hamalainen <ccr@tnsp.org>
parents: 1494
diff changeset
242 "href=\"".$pageGMapURL."?x=".$data["globalx"].
2416
e2fe94bbca17 Make HTML+JS maps go to continent's main city as default.
Matti Hamalainen <ccr@tnsp.org>
parents: 2401
diff changeset
243 "&amp;y=".$data["globaly"]."&amp;zoom=10\">&#x2605;</a>";
1557
7826a86e17c4 Do not show GMaps links for those maps that do not exist in Age of Exiles
Matti Hamalainen <ccr@tnsp.org>
parents: 1494
diff changeset
244 }
7826a86e17c4 Do not show GMaps links for those maps that do not exist in Age of Exiles
Matti Hamalainen <ccr@tnsp.org>
parents: 1494
diff changeset
245 return $str;
1450
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
246 }
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
247 else
1395
eaadfc23248f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 1391
diff changeset
248 return "<b>".chentities($name)."</b>";
eaadfc23248f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 1391
diff changeset
249 }
eaadfc23248f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 1391
diff changeset
250
eaadfc23248f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 1391
diff changeset
251
2272
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
252 function mpGetMapLink($data, $link, $gmap, $ltype)
1395
eaadfc23248f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 1391
diff changeset
253 {
2272
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
254 return mpGetMapURLLink($data, $link,
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
255 ($ltype ? mpGetLocationTypePrefix($data["flags"]) : "").$data["name"], $gmap);
1061
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
256 }
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
257
a74751534847 Move some support code from config.inc.php to common.inc.php. No idea why it was there in the first place ... Historical clutter.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
258
1620
6d620441af7f Rename various functions, and other cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1604
diff changeset
259 function mpChConv($str)
831
ba73f8169384 Convert to UTF-8.
Matti Hamalainen <ccr@tnsp.org>
parents: 827
diff changeset
260 {
ba73f8169384 Convert to UTF-8.
Matti Hamalainen <ccr@tnsp.org>
parents: 827
diff changeset
261 global $pageCharset;
2235
f73f80e533a2 Change loc files to UTF-8. Only one entry really affected, hopefully not
Matti Hamalainen <ccr@tnsp.org>
parents: 2043
diff changeset
262 return iconv("UTF-8", $pageCharset, $str);
831
ba73f8169384 Convert to UTF-8.
Matti Hamalainen <ccr@tnsp.org>
parents: 827
diff changeset
263 }
ba73f8169384 Convert to UTF-8.
Matti Hamalainen <ccr@tnsp.org>
parents: 827
diff changeset
264
926
Matti Hamalainen <ccr@tnsp.org>
parents: 870
diff changeset
265
1620
6d620441af7f Rename various functions, and other cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1604
diff changeset
266 function mpAddLocNames(&$list, $input)
975
af0fc3a965dc Fix all the web-interface PHP crap to work with the new LOC file format. Urgh. This shit could really use some refactoring cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
267 {
1977
c34e55de9f29 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1919
diff changeset
268 $list = [];
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
269 foreach ($input as $name)
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
270 {
975
af0fc3a965dc Fix all the web-interface PHP crap to work with the new LOC file format. Urgh. This shit could really use some refactoring cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
271 $nflags = 0;
af0fc3a965dc Fix all the web-interface PHP crap to work with the new LOC file format. Urgh. This shit could really use some refactoring cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
272 $npos = 0;
af0fc3a965dc Fix all the web-interface PHP crap to work with the new LOC file format. Urgh. This shit could really use some refactoring cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
273
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
274 switch (substr($name, 0, 1))
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
275 {
2620
164aa519640d Use 'author' instead of 'creator' or 'coder'.
Matti Hamalainen <ccr@tnsp.org>
parents: 2619
diff changeset
276 case "@": $npos++; $nflags = AUTHOR_ORIG; break;
164aa519640d Use 'author' instead of 'creator' or 'coder'.
Matti Hamalainen <ccr@tnsp.org>
parents: 2619
diff changeset
277 case "!": $npos++; $nflags = AUTHOR_RECODER; break;
164aa519640d Use 'author' instead of 'creator' or 'coder'.
Matti Hamalainen <ccr@tnsp.org>
parents: 2619
diff changeset
278 case "%": $npos++; $nflags = AUTHOR_MAINTAINER; break;
164aa519640d Use 'author' instead of 'creator' or 'coder'.
Matti Hamalainen <ccr@tnsp.org>
parents: 2619
diff changeset
279 case "&": $npos++; $nflags = AUTHOR_EXPANDER; break;
975
af0fc3a965dc Fix all the web-interface PHP crap to work with the new LOC file format. Urgh. This shit could really use some refactoring cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
280 }
af0fc3a965dc Fix all the web-interface PHP crap to work with the new LOC file format. Urgh. This shit could really use some refactoring cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
281
1977
c34e55de9f29 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1919
diff changeset
282 $list[] = [
975
af0fc3a965dc Fix all the web-interface PHP crap to work with the new LOC file format. Urgh. This shit could really use some refactoring cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
283 "name" => substr($name, $npos),
af0fc3a965dc Fix all the web-interface PHP crap to work with the new LOC file format. Urgh. This shit could really use some refactoring cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
284 "flags" => $nflags
1977
c34e55de9f29 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1919
diff changeset
285 ];
975
af0fc3a965dc Fix all the web-interface PHP crap to work with the new LOC file format. Urgh. This shit could really use some refactoring cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
286 }
af0fc3a965dc Fix all the web-interface PHP crap to work with the new LOC file format. Urgh. This shit could really use some refactoring cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
287 }
af0fc3a965dc Fix all the web-interface PHP crap to work with the new LOC file format. Urgh. This shit could really use some refactoring cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
288
1071
9bb585195456 Change how HCBat is handled in the web-frontend.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
289
1620
6d620441af7f Rename various functions, and other cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1604
diff changeset
290 function mpGetGlobalCoords($continent, $xc, $yc, &$gx, &$gy)
1450
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
291 {
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
292 global $continentList, $worldMap;
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
293 if (isset($continentList[$continent]))
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
294 {
2032
d9c15f7ae4c4 Add defines for continent list array index constants and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 2031
diff changeset
295 $gx = $worldMap["ox"] + $continentList[$continent][CTI_XOFFS] + $xc - 1;
d9c15f7ae4c4 Add defines for continent list array index constants and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 2031
diff changeset
296 $gy = $worldMap["oy"] + $continentList[$continent][CTI_YOFFS] + $yc - 1;
1450
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
297 return TRUE;
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
298 }
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
299 else
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
300 return FALSE;
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
301 }
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
302
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
303
2037
e82ba6f55708 Refactor how the location filtering works internally to use proper LOC flags.
Matti Hamalainen <ccr@tnsp.org>
parents: 2036
diff changeset
304 function mpParseLocFile($filename, &$locations, $applyFilter, $invertFilter, $filterMask)
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 {
621
537fae9ebf1d Synced.
Matti Hamalainen <ccr@tnsp.org>
parents: 620
diff changeset
306 global $locationTypes;
1450
ce0c5f12c201 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 1429
diff changeset
307
816
6341de08bd52 Handle alternative location names better;Add unique location ID generation to handle locations with exactly same primary name.
Matti Hamalainen <ccr@tnsp.org>
parents: 813
diff changeset
308 $file = @fopen(basename($filename.".loc"), "r");
6341de08bd52 Handle alternative location names better;Add unique location ID generation to handle locations with exactly same primary name.
Matti Hamalainen <ccr@tnsp.org>
parents: 813
diff changeset
309 if (!$file) return FALSE;
2015
135b2b595e2c Trailing whitespace cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 2013
diff changeset
310
1891
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
311 while (!feof($file))
68b784c7eae2 Get rid of mgeneric.inc.php here.
Matti Hamalainen <ccr@tnsp.org>
parents: 1702
diff changeset
312 {
1620
6d620441af7f Rename various functions, and other cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1604
diff changeset
313 $inLine = mpChConv(trim(fgets($file)));
368
875548a41c71 New "location added to game" timestamp field in location files; Modified mkloc and PHP glue to handle the change.
Matti Hamalainen <ccr@tnsp.org>
parents: 337
diff changeset
314
816
6341de08bd52 Handle alternative location names better;Add unique location ID generation to handle locations with exactly same primary name.
Matti Hamalainen <ccr@tnsp.org>
parents: 813
diff changeset
315 // Ignore comments and empty lines
6341de08bd52 Handle alternative location names better;Add unique location ID generation to handle locations with exactly same primary name.
Matti Hamalainen <ccr@tnsp.org>
parents: 813
diff changeset
316 if (strlen($inLine) == 0 || $inLine[0] == "#")
6341de08bd52 Handle alternative location names better;Add unique location ID generation to handle locations with exactly same primary name.
Matti Hamalainen <ccr@tnsp.org>
parents: 813
diff changeset
317 continue;
6341de08bd52 Handle alternative location names better;Add unique location ID generation to handle locations with exactly same primary name.
Matti Hamalainen <ccr@tnsp.org>
parents: 813
diff changeset
318
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
319 if (preg_match("/^(\d+)\s*;\s*(\d+)\s*;\s*([0-3][A-Za-z%!\?\-]*)\s*;\s*([^;]+)\s*;\s*(.*?)\s*;\s*(.*?)\s*;\s*(.*?)\s*;\s*(.*?)\s*$/", $inLine, $record))
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
320 {
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
321 // Get location names
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
322 mpAddLocNames($names, preg_split("/\s*\|\s*/", $record[4]));
2015
135b2b595e2c Trailing whitespace cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 2013
diff changeset
323
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
324 // Parse the flags, first skip the label orientation
1427
7ea317bda09f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1401
diff changeset
325 $rawflags = $record[3];
2036
c596f23908cc Fix LOC file label orientation parsing.
Matti Hamalainen <ccr@tnsp.org>
parents: 2035
diff changeset
326 for ($fi = 0; $fi < strlen($rawflags) &&
c596f23908cc Fix LOC file label orientation parsing.
Matti Hamalainen <ccr@tnsp.org>
parents: 2035
diff changeset
327 (ctype_digit($rawflags[$fi]) || $rawflags[$fi] == ' '); $fi++);
c596f23908cc Fix LOC file label orientation parsing.
Matti Hamalainen <ccr@tnsp.org>
parents: 2035
diff changeset
328
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
329 $rawflags = substr($rawflags, $fi);
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
330 $id = $rawflags.$names[0]["name"];
870
51054f3f5d2e Allow inversion of regexp group operator via "^" in the location type filter parameter.
Matti Hamalainen <ccr@tnsp.org>
parents: 831
diff changeset
331
2035
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
332 $flags = LOCF_NONE;
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
333 for ($fi = 0; $fi < strlen($rawflags); $fi++)
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
334 {
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
335 switch ($rawflags[$fi])
1977
c34e55de9f29 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1919
diff changeset
336 {
2035
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
337 case "?": $flags |= LOCF_M_SCENIC1; break;
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
338 case "%": $flags |= LOCF_M_SCENIC2; break;
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
339 case "C": $flags |= LOCF_M_PCITY; break;
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
340 case "c": $flags |= LOCF_M_CITY; break;
816
6341de08bd52 Handle alternative location names better;Add unique location ID generation to handle locations with exactly same primary name.
Matti Hamalainen <ccr@tnsp.org>
parents: 813
diff changeset
341
2035
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
342 case "S": $flags |= LOCF_T_SHRINE; break;
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
343 case "G": $flags |= LOCF_T_GUILD; break;
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
344 case "P": $flags |= LOCF_T_SS; break;
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
345 case "M": $flags |= LOCF_T_MONSTER; break;
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
346 case "T": $flags |= LOCF_T_TRAINER; break;
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
347 case "F": $flags |= LOCF_T_FORT; break;
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
348
2035
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
349 case "-": $flags |= LOCF_INVIS; break;
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
350 case "!": $flags |= LOCF_CLOSED; break;
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
351 case "I": $flags |= LOCF_INVALID; break;
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
352
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
353 default:
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
354 mpError("Location '<b>".$id."</b>' has invalid flag '<b>".$rawflags[$fi]."</b>' <=> ".$filename.")");
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
355 }
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
356 }
2015
135b2b595e2c Trailing whitespace cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 2013
diff changeset
357
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
358 // Is the location visible? Does it match the filter, if any?
2035
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
359 if (($flags & LOCF_INVIS) == 0 &&
2037
e82ba6f55708 Refactor how the location filtering works internally to use proper LOC flags.
Matti Hamalainen <ccr@tnsp.org>
parents: 2036
diff changeset
360 (!$applyFilter || (($flags & $filterMask) ? TRUE : FALSE) != $invertFilter))
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
361 {
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
362 // Check for duplicate locations
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
363 if (isset($locations[$id]))
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
364 {
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
365 mpError("Location '<b>".$id."</b>' already defined (".$locations[$id]["continent"]." <=> ".$filename.")");
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
366 continue;
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
367 }
2015
135b2b595e2c Trailing whitespace cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 2013
diff changeset
368
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
369 // Create primary location name
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
370 $name = $names[0]["name"];
2015
135b2b595e2c Trailing whitespace cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 2013
diff changeset
371
2035
6ba1fd41a8c3 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2032
diff changeset
372 if ($flags & LOCF_CLOSED)
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
373 {
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
374 $name .= " (CLOSED)";
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
375 $ffreeform = $record[8]." This location is closed.";
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
376 }
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
377 else
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
378 {
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
379 $ffreeform = $record[8];
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
380 }
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
381
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
382 mpGetGlobalCoords($filename, $record[1], $record[2], $glx, $gly);
2015
135b2b595e2c Trailing whitespace cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 2013
diff changeset
383
2620
164aa519640d Use 'author' instead of 'creator' or 'coder'.
Matti Hamalainen <ccr@tnsp.org>
parents: 2619
diff changeset
384 // Split author names
2589
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
385 if (strlen($record[5]) > 0)
2620
164aa519640d Use 'author' instead of 'creator' or 'coder'.
Matti Hamalainen <ccr@tnsp.org>
parents: 2619
diff changeset
386 mpAddLocNames($authors, preg_split("/\s*,\s*/", $record[5]));
2589
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
387 else
2620
164aa519640d Use 'author' instead of 'creator' or 'coder'.
Matti Hamalainen <ccr@tnsp.org>
parents: 2619
diff changeset
388 $authors = [];
2589
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
389
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
390 // Get timestamp
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
391 $stamp = $record[6];
2590
f464c7064b81 Minor cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 2589
diff changeset
392 $added = -1;
2591
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
393 $added_accuracy = TS_ACC_DEFAULT;
2589
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
394 if (strlen($stamp) > 0)
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
395 {
2591
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
396 switch ($stamp[0])
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
397 {
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
398 case TS_ACC_KNOWN:
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
399 case TS_ACC_GUESSTIMATE:
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
400 case TS_ACC_APPROXIMATE:
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
401 $added_accuracy = $stamp[0];
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
402 $stamp = substr($stamp, 1);
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
403 break;
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
404 }
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
405
2589
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
406 if (sscanf($stamp, "%02d.%02d.%04d", $aday, $amonth, $ayear) == 3)
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
407 {
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
408 if (($added = mktime(0, 0, 0, $amonth, $aday, $ayear)) === FALSE)
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
409 $added = -1;
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
410 }
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
411 else
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
412 {
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
413 mpError("Location <b>".$record[4]."</b> has invalid timestamp '".$record[6]."'");
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
414 }
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
415 }
2a535f601677 Move parsing of timestamp and coders etc. a bit in preparation for further changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2488
diff changeset
416
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
417 // Add location to array of locations
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
418 $locations[$id] = [
2272
0556b65f137b Cleanups in the web code, show location type again in some places.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
419 "name" => $name, // NOTE! Name field should be the first one in this list due to how we are abusing asort() etc
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
420 "names" => $names,
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
421 "continent" => $filename,
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
422 "x" => $record[1],
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
423 "y" => $record[2],
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
424 "globalx" => $glx,
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
425 "globaly" => $gly,
2037
e82ba6f55708 Refactor how the location filtering works internally to use proper LOC flags.
Matti Hamalainen <ccr@tnsp.org>
parents: 2036
diff changeset
426 "flags" => $flags,
2620
164aa519640d Use 'author' instead of 'creator' or 'coder'.
Matti Hamalainen <ccr@tnsp.org>
parents: 2619
diff changeset
427 "authors" => $authors,
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
428 "added" => $added,
2591
f207279a5f89 Bump loc file spec to v4.1, and implement handling of location addition
Matti Hamalainen <ccr@tnsp.org>
parents: 2590
diff changeset
429 "added_accuracy" => $added_accuracy,
2031
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
430 "url" => strlen($record[7]) ? $record[7] : NULL,
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
431 "freeform" => strlen($ffreeform) ? $ffreeform : NULL,
0aea3a66f2db Refactor PHP .loc file parsing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2015
diff changeset
432 ];
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
433 }
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
434 } else
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
435 {
1900
ed98d2fe4bca Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1891
diff changeset
436 mpError($inLine);
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
437 //return FALSE;
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
438 }
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
439 }
2015
135b2b595e2c Trailing whitespace cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 2013
diff changeset
440
816
6341de08bd52 Handle alternative location names better;Add unique location ID generation to handle locations with exactly same primary name.
Matti Hamalainen <ccr@tnsp.org>
parents: 813
diff changeset
441 fclose($file);
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
442 return TRUE;
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443 }
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
444
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
445
2037
e82ba6f55708 Refactor how the location filtering works internally to use proper LOC flags.
Matti Hamalainen <ccr@tnsp.org>
parents: 2036
diff changeset
446 function mpParseLocFiles($applyFilter,
e82ba6f55708 Refactor how the location filtering works internally to use proper LOC flags.
Matti Hamalainen <ccr@tnsp.org>
parents: 2036
diff changeset
447 $invertFilter = TRUE,
e82ba6f55708 Refactor how the location filtering works internally to use proper LOC flags.
Matti Hamalainen <ccr@tnsp.org>
parents: 2036
diff changeset
448 $filterMask = LOCF_M_PCITY | LOCF_T_FORT)
609
ff42dbb61d1c Updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 602
diff changeset
449 {
1060
b78333d62d5b Combine speciaList into continentList and clean up the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 975
diff changeset
450 global $continentList;
1977
c34e55de9f29 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1919
diff changeset
451 $locations = [];
870
51054f3f5d2e Allow inversion of regexp group operator via "^" in the location type filter parameter.
Matti Hamalainen <ccr@tnsp.org>
parents: 831
diff changeset
452
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
453 foreach ($continentList as $id => $data)
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
454 {
2032
d9c15f7ae4c4 Add defines for continent list array index constants and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 2031
diff changeset
455 if ($data[CTI_REG_CONT])
2037
e82ba6f55708 Refactor how the location filtering works internally to use proper LOC flags.
Matti Hamalainen <ccr@tnsp.org>
parents: 2036
diff changeset
456 mpParseLocFile($id, $locations, $applyFilter, $invertFilter, $filterMask);
1071
9bb585195456 Change how HCBat is handled in the web-frontend.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
457 }
816
6341de08bd52 Handle alternative location names better;Add unique location ID generation to handle locations with exactly same primary name.
Matti Hamalainen <ccr@tnsp.org>
parents: 813
diff changeset
458
609
ff42dbb61d1c Updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 602
diff changeset
459 return $locations;
ff42dbb61d1c Updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 602
diff changeset
460 }
ff42dbb61d1c Updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 602
diff changeset
461
ff42dbb61d1c Updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 602
diff changeset
462
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
463 function mpStoreWizInfoField(&$wizInfo, $field, $data)
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
464 {
2714
06b7c448338b Add countries field to wizard info database.
Matti Hamalainen <ccr@tnsp.org>
parents: 2620
diff changeset
465 $str = trim($data);
06b7c448338b Add countries field to wizard info database.
Matti Hamalainen <ccr@tnsp.org>
parents: 2620
diff changeset
466 if (strlen($str) > 0)
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
467 $wizInfo[$field] = $str;
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
468 }
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
469
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
470
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
471 function mpStoreWizInfoRecordInfo($nline, &$wizInfo, $record)
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
472 {
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
473 // Parse and check names
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
474 $allnames = preg_split("/\s*\|\s*/", trim($record[1]));
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
475 foreach ($allnames as $name)
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
476 {
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
477 if ($name == "" ||
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
478 $name != strtoupper(substr($name, 0, 1)).strtolower(substr($name, 1)))
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
479 {
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
480 mpError("Invalid name in wizard record (line #".$nline."): '".$name."'.");
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
481 }
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
482 }
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
483
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
484 // Use first name as primary "key"
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
485 $keyname = $allnames[0];
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
486 if (isset($wizInfo[$keyname]))
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
487 {
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
488 mpError("Wizard record '".$keyname."' is already set on line #".
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
489 $wizInfo[$keyname]["nline"].", vs line #".$nline);
816
6341de08bd52 Handle alternative location names better;Add unique location ID generation to handle locations with exactly same primary name.
Matti Hamalainen <ccr@tnsp.org>
parents: 813
diff changeset
490 return FALSE;
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
491 }
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
492 else
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
493 {
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
494 $data = [
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
495 "name" => $keyname,
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
496 "names" => array_slice($allnames, 1),
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
497 "areas" => 0,
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
498 "nline" => $nline,
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
499 ];
2714
06b7c448338b Add countries field to wizard info database.
Matti Hamalainen <ccr@tnsp.org>
parents: 2620
diff changeset
500
2735
06ce4399639c Fixes to wizards.txt parser.
Matti Hamalainen <ccr@tnsp.org>
parents: 2730
diff changeset
501 $countries = array_map(
06ce4399639c Fixes to wizards.txt parser.
Matti Hamalainen <ccr@tnsp.org>
parents: 2730
diff changeset
502 function ($item)
06ce4399639c Fixes to wizards.txt parser.
Matti Hamalainen <ccr@tnsp.org>
parents: 2730
diff changeset
503 {
06ce4399639c Fixes to wizards.txt parser.
Matti Hamalainen <ccr@tnsp.org>
parents: 2730
diff changeset
504 return strtolower($item);
06ce4399639c Fixes to wizards.txt parser.
Matti Hamalainen <ccr@tnsp.org>
parents: 2730
diff changeset
505 },
06ce4399639c Fixes to wizards.txt parser.
Matti Hamalainen <ccr@tnsp.org>
parents: 2730
diff changeset
506 array_filter(preg_split("/\s*\|\s*/", $record[2]),
2730
6fadba4046ab Filter out empty country entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 2714
diff changeset
507 function ($item)
6fadba4046ab Filter out empty country entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 2714
diff changeset
508 {
6fadba4046ab Filter out empty country entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 2714
diff changeset
509 return $item != "";
2735
06ce4399639c Fixes to wizards.txt parser.
Matti Hamalainen <ccr@tnsp.org>
parents: 2730
diff changeset
510 }));
2730
6fadba4046ab Filter out empty country entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 2714
diff changeset
511
2714
06b7c448338b Add countries field to wizard info database.
Matti Hamalainen <ccr@tnsp.org>
parents: 2620
diff changeset
512 if (count($countries) > 0)
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
513 $data["countries"] = $countries;
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
514
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
515 mpStoreWizInfoField($data, "homeURL", $record[3]);
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
516 mpStoreWizInfoField($data, "imageURL", $record[4]);
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
517 mpStoreWizInfoField($data, "desc", $record[5]);
2714
06b7c448338b Add countries field to wizard info database.
Matti Hamalainen <ccr@tnsp.org>
parents: 2620
diff changeset
518
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
519 $wizInfo[$keyname] = $data;
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
520
816
6341de08bd52 Handle alternative location names better;Add unique location ID generation to handle locations with exactly same primary name.
Matti Hamalainen <ccr@tnsp.org>
parents: 813
diff changeset
521 return TRUE;
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
522 }
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
523 }
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
524
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
525
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
526 function mpParseWizInfoFile($filename, &$wizInfo)
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
527 {
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
528 $startLine = $nline = 0;
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
529 if (($file = @fopen($filename, "r")) === false)
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
530 return FALSE;
2015
135b2b595e2c Trailing whitespace cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 2013
diff changeset
531
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
532 $contMode = FALSE;
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
533 while (!feof($file))
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
534 {
1620
6d620441af7f Rename various functions, and other cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1604
diff changeset
535 $line = mpChConv(trim(fgets($file)));
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
536 $nline++;
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
537
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
538 if (strlen($line) == 0 || $line[0] == "#")
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
539 continue;
2015
135b2b595e2c Trailing whitespace cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 2013
diff changeset
540
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
541 if ($contMode)
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
542 {
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
543 if (substr($line, -1, 1) == '$')
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
544 {
2735
06ce4399639c Fixes to wizards.txt parser.
Matti Hamalainen <ccr@tnsp.org>
parents: 2730
diff changeset
545 $record[5] .= " ".trim(substr($line, 0, -1));
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
546 $contMode = FALSE;
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
547 mpStoreWizInfoRecordInfo($startLine, $wizInfo, $record);
2439
61c2e037646a Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2416
diff changeset
548 }
61c2e037646a Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2416
diff changeset
549 else
61c2e037646a Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2416
diff changeset
550 {
2735
06ce4399639c Fixes to wizards.txt parser.
Matti Hamalainen <ccr@tnsp.org>
parents: 2730
diff changeset
551 $record[5] .= " ".trim($line);
2439
61c2e037646a Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2416
diff changeset
552 }
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
553 }
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
554 else
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
555 if (preg_match("/^([A-Za-z\|]+);([a-z\|]+)?;(https?:\/\/[^;]+|bat)?;([^;]+)?;([^\$]*)\\\$$/", $line, $record))
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
556 mpStoreWizInfoRecordInfo($nline, $wizInfo, $record);
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
557 else
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
558 if (preg_match("/^([A-Za-z\|]+);([a-z\|]+)?;(https?:\/\/[^;]+|bat)?;([^;]+)?;(.*)$/", $line, $record))
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
559 {
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
560 $startLine = $nline;
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
561 $contMode = TRUE;
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
562 }
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
563 else
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
564 mpError("Wizard record line #".$nline.": ".$line);
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
565 }
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
566
816
6341de08bd52 Handle alternative location names better;Add unique location ID generation to handle locations with exactly same primary name.
Matti Hamalainen <ccr@tnsp.org>
parents: 813
diff changeset
567 fclose($file);
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
568 return TRUE;
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
569 }
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
570
609
ff42dbb61d1c Updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 602
diff changeset
571
2763
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
572 function mpMakeWizInfoAliases($wizInfo)
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
573 {
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
574 $aliases = [];
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
575 foreach ($wizInfo as $name => $data)
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
576 {
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
577 foreach ($data["names"] as $nname)
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
578 $aliases[$nname] = $name;
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
579 }
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
580 return $aliases;
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
581 }
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
582
78ad0e51b7b5 Improve wizards.txt parser, add functionality for specifying alternative /
Matti Hamalainen <ccr@tnsp.org>
parents: 2735
diff changeset
583
1620
6d620441af7f Rename various functions, and other cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1604
diff changeset
584 function mpReadWizInfoFiles()
609
ff42dbb61d1c Updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 602
diff changeset
585 {
1977
c34e55de9f29 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1919
diff changeset
586 $wizInfo = [];
c34e55de9f29 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1919
diff changeset
587 mpParseWizInfoFile("wizards.txt", $wizInfo);
609
ff42dbb61d1c Updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 602
diff changeset
588 return $wizInfo;
ff42dbb61d1c Updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 602
diff changeset
589 }
ff42dbb61d1c Updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 602
diff changeset
590
1387
2b6b38e94bb2 Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1340
diff changeset
591
1620
6d620441af7f Rename various functions, and other cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1604
diff changeset
592 function mpPrintExtraBoxAlphaList($prefix, $table, $class = FALSE)
1148
52550f58cee5 Move alphabetic table printing code to a function in common routines.
Matti Hamalainen <ccr@tnsp.org>
parents: 1140
diff changeset
593 {
1677
9d51b4138e7d CSS updates and related code changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1654
diff changeset
594 echo "<div id=\"extraBox\"".($class !== FALSE ? " class=\"".$class."\"" : "").">\n";
1148
52550f58cee5 Move alphabetic table printing code to a function in common routines.
Matti Hamalainen <ccr@tnsp.org>
parents: 1140
diff changeset
595
1391
7fcea2fce0be More fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1387
diff changeset
596 foreach ($table as $alpha => $locs)
7fcea2fce0be More fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1387
diff changeset
597 {
1148
52550f58cee5 Move alphabetic table printing code to a function in common routines.
Matti Hamalainen <ccr@tnsp.org>
parents: 1140
diff changeset
598 $letter = strtoupper($alpha);
1391
7fcea2fce0be More fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1387
diff changeset
599 echo " <a href=\"#".$prefix.$letter."\">".$letter."</a>&nbsp;\n";
1148
52550f58cee5 Move alphabetic table printing code to a function in common routines.
Matti Hamalainen <ccr@tnsp.org>
parents: 1140
diff changeset
600 }
52550f58cee5 Move alphabetic table printing code to a function in common routines.
Matti Hamalainen <ccr@tnsp.org>
parents: 1140
diff changeset
601
1391
7fcea2fce0be More fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1387
diff changeset
602 echo "</div>\n";
1148
52550f58cee5 Move alphabetic table printing code to a function in common routines.
Matti Hamalainen <ccr@tnsp.org>
parents: 1140
diff changeset
603 }
52550f58cee5 Move alphabetic table printing code to a function in common routines.
Matti Hamalainen <ccr@tnsp.org>
parents: 1140
diff changeset
604
1630
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
605
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
606 function mpSpecialDate($where, $index)
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
607 {
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
608 global $specialDate;
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
609 $str = "";
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
610
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
611 switch ($specialDate)
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
612 {
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
613 case "aprilli":
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
614 for ($ni = 0; $ni < 4; $ni++)
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
615 {
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
616 $str .= "<img src=\"img/".
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
617 (($ni % 2 == 0 && $where == "index") ? "skull.gif" : "uc.gif").
2488
Matti Hamalainen <ccr@tnsp.org>
parents: 2439
diff changeset
618 "\" alt=\"ZOMG\" />";
1630
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
619 }
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
620 break;
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
621 }
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
622
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
623 return $str;
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
624 }
90e6a0eda2ae Implement specialdate.
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
625
337
ca191c3a0ce1 Updates and lots of new ugly glue.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
626 ?>