Mercurial > hg > batmud > chester
comparison index.php @ 22:c0dec130ce74
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 11 Jan 2011 13:45:00 +0200 |
parents | f9211d1917b7 |
children | 35f0c0ce0c51 |
comparison
equal
deleted
inserted
replaced
21:f9211d1917b7 | 22:c0dec130ce74 |
---|---|
27 echo "<label for=\"".$id."\">".htmlentities($label).": </label>". | 27 echo "<label for=\"".$id."\">".htmlentities($label).": </label>". |
28 "<input type=\"text\" name=\"".$id."\" maxlength=\"".$len. | 28 "<input type=\"text\" name=\"".$id."\" maxlength=\"".$len. |
29 "\" size=\"".$len."\" id=\"".$id."\" value=\"".htmlentities($value)."\" />\n"; | 29 "\" size=\"".$len."\" id=\"".$id."\" value=\"".htmlentities($value)."\" />\n"; |
30 } | 30 } |
31 | 31 |
32 | |
32 function printCheckBox($id, $label, $value = FALSE) | 33 function printCheckBox($id, $label, $value = FALSE) |
33 { | 34 { |
34 global $jsData; | 35 global $jsData; |
35 $jsData .= "document.getElementById(\"".$id."\").checked = ".($value ? "true" : "false").";\n"; | 36 $jsData .= "document.getElementById(\"".$id."\").checked = ".($value ? "true" : "false").";\n"; |
36 | 37 |
37 echo "<input type=\"checkbox\" id=\"".$id."\" value=\"".$value."\" ".($value ? "checked=\"checked\"" : "")." />". | 38 echo "<input type=\"checkbox\" id=\"".$id."\" value=\"".$value."\" ".($value ? "checked=\"checked\"" : "")." />". |
38 "<label for=\"".$id."\">".htmlentities($label)."</label>"; | 39 "<label for=\"".$id."\">".htmlentities($label)."</label>"; |
39 } | 40 } |
41 | |
40 | 42 |
41 function printOptionSelect($id, $size, $multi = FALSE) | 43 function printOptionSelect($id, $size, $multi = FALSE) |
42 { | 44 { |
43 echo "<select ".($multi ? " multiple=\"multiple\"" : "")." size=\"".$size."\" id=\"".$id."\"><option></option></select>"; | 45 echo "<select ".($multi ? " multiple=\"multiple\"" : "")." size=\"".$size."\" id=\"".$id."\"><option></option></select>"; |
44 } | 46 } |
124 global $data; | 126 global $data; |
125 for ($i = 0; $i < $num; $i++) | 127 for ($i = 0; $i < $num; $i++) |
126 $data["items"][] = $desc; | 128 $data["items"][] = $desc; |
127 } | 129 } |
128 | 130 |
131 $fixNumbersMatch = join("|", array_keys($fixNumbers)); | |
132 | |
129 foreach ($postData as $line) { | 133 foreach ($postData as $line) { |
130 // Trim whitespace | 134 // Trim whitespace |
131 $str = trim($line); | 135 $str = trim($line); |
132 if ($str == "") continue; | 136 if ($str == "") continue; |
133 | 137 |
134 // Strip glows and counters from item "handle" | 138 // Strip glows and counters from item "handle" |
135 if (preg_match("/^(.+?)\s+(<.+? glow>|\(\d+\/\d+\)|\[\d+\/\d+\])$/", $str, $m)) | 139 if (preg_match("/^(.+?)\s+(<.+? glow>|\(\d+\/\d+\)|\[\d+\/\d+\])$/", $str, $m)) |
136 $str = $m[1]; | 140 $str = $m[1]; |
137 | 141 |
138 // Discard multi-item lines | 142 // Discard multi-item lines |
139 if (preg_match("/^(many|two|three|four|five|six|seven|eight|nine|ten)\s+(.+?)( labeled as .+|)$/", $str, $m)) { | 143 if (preg_match("/^(many|".$fixNumbersMatch.")\s+(.+?)( labeled as .+|)$/", $str, $m)) { |
140 if (!isset($fixNumbers[$m[1]])) { | 144 if (!isset($fixNumbers[$m[1]])) { |
141 $ignored[$str] = "Unparsed stack of many"; | 145 $ignored[$str] = "Unparsed stack of many"; |
142 } else { | 146 } else { |
143 $n = $fixNumbers[$m[1]]; | 147 $n = $fixNumbers[$m[1]]; |
144 $changed = 0; | 148 $changed = 0; |
171 <tr><th>Item</th><th>Reason</th></tr> | 175 <tr><th>Item</th><th>Reason</th></tr> |
172 <? | 176 <? |
173 foreach ($ignored as $name => $reason) { | 177 foreach ($ignored as $name => $reason) { |
174 echo " <tr><td>".htmlentities($name)."</td><td>".htmlentities($reason)."</td></tr>\n"; | 178 echo " <tr><td>".htmlentities($name)."</td><td>".htmlentities($reason)."</td></tr>\n"; |
175 } | 179 } |
176 | 180 $filename = "ignored.txt"; |
177 $encData = base64_encode(serialize($data)); | 181 $outFile = @fopen($filename, "a"); |
182 if ($outFile !== FALSE) { | |
183 @chmod($filename, 0600); | |
184 foreach ($ignored as $name => $reason) { | |
185 fwrite($outFile, $name."§".$reason."\n"); | |
186 } | |
187 fclose($outFile); | |
188 } | |
189 | |
190 $encData = base64_encode(serialize($data)); | |
178 ?> | 191 ?> |
179 </table> | 192 </table> |
180 | 193 |
181 <form action="<? echo $pageIndex; ?>" method="post"> | 194 <form action="<? echo $pageIndex; ?>" method="post"> |
182 <input type="hidden" value="<? echo $encData ?>" name="data" /> | 195 <input type="hidden" value="<? echo $encData ?>" name="data" /> |