changeset 16:257e748cd08e

Merging -df
author Dominic Cleal <dominic@computerkb.co.uk>
date Sun, 25 Jan 2009 14:46:32 +0000
parents 50d8619bce32 (current diff) ccd5e74fa58e (diff)
children a79168f03fc4
files reproctool.cgi
diffstat 1 files changed, 53 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/reproctool.cgi	Sun Jan 25 14:11:12 2009 +0000
+++ b/reproctool.cgi	Sun Jan 25 14:46:32 2009 +0000
@@ -5,6 +5,7 @@
 
 use CGI;
 use DBI;
+use XML::DOM;
 
 # Settings
 my $img_http_path = '/itemimgs';
@@ -24,6 +25,58 @@
     exit;
 }
 
+# Generate the first page, where eve-central mineral prices are prefilled.
+# TODO: depending on the traffic, cache these eve-central prices.
+my $str_items;
+if (! ($str_items = $cgi->param('items')) )
+{
+    my $min;
+    my $eveCentralURL = 'http://eve-central.com/api/evemon';
+    my $xmlParser = XML::DOM::Parser->new();
+    my $xmlDoc = $xmlParser->parsefile($eveCentralURL);
+
+    # What evenutally will be printed.
+    my $inputPage = <<END;
+<html>
+<body>
+
+<form action="/cgi-bin/reproctool/reproctool.cgi" method="post">
+    <textarea rows="5" cols="80" name="items"></textarea>
+    <table border="0" cellspacing="4">
+        <tr>
+END
+    # Lists the name of the minerals.
+    foreach $min ($xmlDoc->getElementsByTagName('mineral'))
+    {
+      $inputPage .= sprintf( "             <td>%s</td>\n",
+                             $min->getElementsByTagName('name')->item(0)->getFirstChild->getNodeValue );
+    }
+
+$inputPage .= <<END;
+        </tr>
+        <tr>
+END
+    foreach $min ($xmlDoc->getElementsByTagName('mineral'))
+    {
+      $inputPage .= sprintf( "             <td><input type=\"text\" name=\"%s\" size=\"5\" value=\"%.2f\" /></td>\n",
+                             $min->getElementsByTagName('name')->item(0)->getFirstChild->getNodeValue,
+                             $min->getElementsByTagName('price')->item(0)->getFirstChild->getNodeValue );
+    }
+
+  $inputPage .= <<END;
+        </tr>
+    </table>
+    <input type="submit" />
+</form>
+
+</body>
+</html>
+END
+
+  print $inputPage;
+  exit 0;
+}
+
 # Inputs
 my $str_items = $cgi->param('items') or user_error('Items missing');
 my $cols = $cgi->param('cols') || 4;