annotate herbs/index.php @ 87:95781f84cbe7

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 09 Oct 2017 18:47:12 +0300
parents 7ec0ad742009
children eb5b6db2b250
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1 <?php
87
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
2 $pageTitle = "Some stupid plants (original by Jeskko, improved by Ggr)";
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
3
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
4 $terrainData = array(
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
5 array("light forests" , "lf", "f"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
6 array("heavy forests" , "hf", "F"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
7 array("plains" , "pl", "."),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
8 array("valleys" , "va", "v"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
9 array("fields" , "fi", "y"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
10 array("highlands" , "hg", "H"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
11 array("hills" , "hi", "h"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
12 array("desert" , "de", "d"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
13 array("swamps" , "sw", "s"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
14 array("abandoned ruins" , "ru", "#"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
15 array("shores" , "sh", "z"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
16 array("beaches" , "be", "b"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
17 array("jungles" , "ju", "j"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
18 array("tundra" , "tu", "t"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
19 array("shallow water" , "wa", "S"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
20 array("mountains" , "mo", "^"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
21 array("badlands" , "ba", "x"),
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
22 );
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
23
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
24 $seasonData = array(
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
25 "spring" => 0x01,
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
26 "summer" => 0x02,
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
27 "autumn" => 0x04,
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
28 "winter" => 0x08,
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
29 );
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
30
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
31
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
32 function tlGetTerrainDataByName($name)
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
33 {
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
34 global $terrainData;
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
35 foreach ($terrainData as $rkey => $rdata)
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
36 {
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
37 if ($rdata[0] == $name)
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
38 return $rkey;
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
39 }
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
40
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
41 die("Unsupported terrain type '".$name."'.\n");
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
42 }
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
43
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
44
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
45 function tlGetTerrainDataByCode($val)
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
46 {
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
47 global $terrainData;
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
48 foreach ($terrainData as $rkey => $rdata)
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
49 {
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
50 if ($rdata[1] == $val)
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
51 return $rkey;
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
52 }
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
53
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
54 return -1;
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
55 }
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
56
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
57
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
58 function tlGetSeasonFromName($name, $fail = FALSE)
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
59 {
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
60 global $seasonData;
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
61 foreach ($seasonData as $rkey => $rval)
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
62 {
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
63 if ($rkey == $name)
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
64 return $rval;
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
65 }
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
66
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
67 if ($fail)
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
68 die("Invalid season name '".$name."'.\n");
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
69 else
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
70 return 0;
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
71 }
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
72
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
73
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
74 function tlGetSeasonsFromFlags($val)
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
75 {
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
76 $res = array();
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
77 global $seasonData;
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
78 foreach ($seasonData as $rkey => $rval)
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
79 {
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
80 if ($val & $rval)
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
81 $res[] = $rkey;
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
82 }
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
83
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
84 return $res;
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
85 }
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
86
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
87
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
88 //
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
89 // Parse data from CSV input
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
90 //
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
91 $herbData = array();
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
92 if (($fh = @fopen("herbs.csv", "r")) !== FALSE)
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
93 {
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
94 while ($data = fgetcsv($fh, 1000, ";"))
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
95 {
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
96 $sdata = 0;
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
97 foreach (preg_split("/, */", $data[1]) as $value)
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
98 {
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
99 if ($value != "")
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
100 $sdata |= tlGetSeasonFromName($value, TRUE);
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
101 }
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
102
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
103 $rdata = array();
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
104 foreach (preg_split("/, */", $data[2]) as $value)
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
105 {
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
106 if ($value != "")
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
107 $rdata[] = tlGetTerrainDataByName($value);
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
108 }
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
109
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
110 $herbData[] = array(
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
111 "name" => $data[0],
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
112 "seasons" => $sdata,
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
113 "terrains" => $rdata,
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
114 "pair" => $data[3],
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
115 "info" => $data[4],
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
116 );
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
117 }
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
118 fclose($fh);
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
119 }
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
120
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
121
87
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
122 echo
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
123 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
124 "<html>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
125 " <head>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
126 " <title>".$pageTitle."</title>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
127 " <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
128 " </head>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
129 "<body>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
130 "<table>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
131 " <caption>".$pageTitle."</caption>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
132 " <tr>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
133 " <th>Plant name</th>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
134 " <th>Seasons</th>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
135 " <th>Terrain types</th>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
136 " <th>Herb pair</th>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
137 " <th>Information</th>\n".
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
138 " </tr>\n";
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
139
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
140
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
141 $sefilter = FALSE;
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
142 $trfilter = FALSE;
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
143 if (isset($_GET["terrain"]))
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
144 {
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
145 $data = tlGetTerrainDataByCode(strtolower(trim($_GET["terrain"])));
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
146 if ($data >= 0)
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
147 $trfilter = $data;
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
148 }
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
149
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
150
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
151 if (isset($_GET["season"]))
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
152 {
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
153 $data = tlGetSeasonFromName(strtolower(trim($_GET["season"])));
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
154 if ($data > 0)
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
155 $sefilter = $data;
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
156 }
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
157
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
158 $row = 0;
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
159 foreach ($herbData as $data)
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
160 {
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
161 if ($trfilter !== FALSE && array_search($trfilter, $data["terrains"]) === FALSE)
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
162 continue;
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
163
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
164 if ($sefilter !== FALSE && ($data["seasons"] & $sefilter) == 0)
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
165 continue;
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
166
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
167 $seasons = array_map(function($x) {
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
168 return "<a href=\"?season=".$x."\">".$x."</a>";
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
169 }, tlGetSeasonsFromFlags($data["seasons"]));
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
170
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
171 $row++;
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
172 echo
87
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
173 " <tr class=\"".(($row % 2) ? "even" : "odd")."\">".
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
174 "<td>".$data["name"]."</td>".
82
3428ff77ff47 More work, adding filtering.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
175 "<td>".implode(", ", $seasons)."</td>".
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
176 "<td>";
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
177
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
178 foreach ($data["terrains"] as $rkey)
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
179 {
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
180 $rdata = $terrainData[$rkey];
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
181 echo "<a href=\"?terrain=".$rdata[1]."\"><span class=\"".$rdata[1]."\">".$rdata[2]."</span></a>";
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
182 }
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
183
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
184 echo
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
185 "</td>".
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
186 "<td>".$data["pair"]."</td>".
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
187 "<td>".$data["info"]."</td>".
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
188 "</tr>\n";
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
189 }
87
95781f84cbe7 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
190
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
191 ?>
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
192 </table>
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
193 </body>
78
03c54e5b60aa Improve this silly thing as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
194 </html>