changeset 22:c0dec130ce74

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 11 Jan 2011 13:45:00 +0200
parents f9211d1917b7
children 35f0c0ce0c51
files index.php itemfixes.inc.php
diffstat 2 files changed, 35 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/index.php	Tue Jan 11 13:32:55 2011 +0200
+++ b/index.php	Tue Jan 11 13:45:00 2011 +0200
@@ -29,6 +29,7 @@
   "\" size=\"".$len."\" id=\"".$id."\" value=\"".htmlentities($value)."\" />\n";
 }
 
+
 function printCheckBox($id, $label, $value = FALSE)
 {
   global $jsData;
@@ -38,6 +39,7 @@
   "<label for=\"".$id."\">".htmlentities($label)."</label>";
 }
 
+
 function printOptionSelect($id, $size, $multi = FALSE)
 {
   echo "<select ".($multi ? " multiple=\"multiple\"" : "")." size=\"".$size."\" id=\"".$id."\"><option></option></select>";
@@ -126,6 +128,8 @@
         $data["items"][] = $desc;
     }
     
+    $fixNumbersMatch = join("|", array_keys($fixNumbers));
+    
     foreach ($postData as $line) {
       // Trim whitespace
       $str = trim($line);
@@ -136,7 +140,7 @@
         $str = $m[1];
       
       // Discard multi-item lines
-      if (preg_match("/^(many|two|three|four|five|six|seven|eight|nine|ten)\s+(.+?)( labeled as .+|)$/", $str, $m)) {
+      if (preg_match("/^(many|".$fixNumbersMatch.")\s+(.+?)( labeled as .+|)$/", $str, $m)) {
         if (!isset($fixNumbers[$m[1]])) {
           $ignored[$str] = "Unparsed stack of many";
         } else {
@@ -173,8 +177,17 @@
       foreach ($ignored as $name => $reason) {
         echo " <tr><td>".htmlentities($name)."</td><td>".htmlentities($reason)."</td></tr>\n";
       }
+      $filename = "ignored.txt";
+      $outFile = @fopen($filename, "a");
+      if ($outFile !== FALSE) {
+        @chmod($filename, 0600);
+        foreach ($ignored as $name => $reason) {
+          fwrite($outFile, $name."§".$reason."\n");
+        }
+        fclose($outFile);
+      }
 
-$encData = base64_encode(serialize($data));
+      $encData = base64_encode(serialize($data));
 ?>
 </table>
 
--- a/itemfixes.inc.php	Tue Jan 11 13:32:55 2011 +0200
+++ b/itemfixes.inc.php	Tue Jan 11 13:45:00 2011 +0200
@@ -2,27 +2,36 @@
 
 // Multi-stack item fixups
 $fixItemTable = array(
-  "(purple|green) gloves" => 'a ${1} glove',
-  "bracelet mades of green crystal" => "bracelet made of green crystal",
-  "alchemist moulded rings" => "alchemist moulded ring",
+  "^(purple|green) gloves" => 'a ${1} glove',
+  "^bracelet mades of green crystal" => "bracelet made of green crystal",
+  "^alchemist moulded rings" => "alchemist moulded ring",
 
   // Generic rings
-  "(heavy black metal|steel) rings" => "a ${1} ring",
+  "^(heavy black metal|steel) rings" => "a ${1} ring",
 
   // Damiens
-  "arm protectors called Damien \(\S+\)" => "an arm protector called Damien (${1})",
+  "^arm protectors called Damien \(\S+\)" => "an arm protector called Damien (${1})",
+  "^a book of eternal youth ([a-z ]+)" => "a book of eternal youth",
   
   // Containers  
-  "white cloth packs for holding salves" => "white cloth pack for holding salves",
-  "(small|HUGE) shiny boxes for storing minerals" => 'a ${1} shiny box for storing minerals',
-  "(small|HUGE) sturdy packs for storing potions" => 'a ${1} sturdy pack for storing potions',
+  "^white cloth packs for holding salves" => "white cloth pack for holding salves",
+  "^(small|HUGE) shiny boxes for storing minerals" => 'a ${1} shiny box for storing minerals',
+  "^(small|HUGE) sturdy packs for storing potions" => 'a ${1} sturdy pack for storing potions',
+  "^small crystal box \([a-z ]+\)" => "small crystal box"
 );
 
 
 $fixNumbers = array(
-  "one" => 1, "two" => 2, "three" => 3, "four" => 4,
-  "five" => 5, "six" => 6, "seven" => 7, "eight" => 8,
-  "nine" => 9, "ten" => 10
+  "one"     => 1,
+  "two"     => 2,
+  "three"   => 3,
+  "four"    => 4,
+  "five"    => 5,
+  "six"     => 6,
+  "seven"   => 7,
+  "eight"   => 8,
+  "nine"    => 9,
+  "ten"     => 10
 );
 
 ?>
\ No newline at end of file