diff index.php @ 22:c0dec130ce74

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 11 Jan 2011 13:45:00 +0200
parents f9211d1917b7
children 35f0c0ce0c51
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>