changeset 8:ccd5e74fa58e

Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
author df
date Sun, 25 Jan 2009 14:40:37 +0000
parents e30154411e63
children 257e748cd08e
files reproctool.cgi
diffstat 1 files changed, 63 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/reproctool.cgi	Sun Jan 25 12:31:34 2009 +0000
+++ b/reproctool.cgi	Sun Jan 25 14:40:37 2009 +0000
@@ -5,6 +5,7 @@
 
 use CGI;
 use DBI;
+use XML::DOM;
 
 # Settings
 my $img_http_path = '/itemimgs';
@@ -14,19 +15,71 @@
                    -pragma  => 'no-cache',
                    -expires => '-365d');
 
+# 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 die('Items missing');
 my $cols = $cgi->param('cols') || 4;
 
-# Load mineral prices
-my $trit = $cgi->param('trit') || die('No trit price');
-my $pyer = $cgi->param('pyer') || die('No pyer price');
-my $mexa = $cgi->param('mexa') || die('No mexa price');
-my $isog = $cgi->param('isog') || die('No isog price');
-my $nocx = $cgi->param('nocx') || die('No nocx price');
-my $zydr = $cgi->param('zydr') || die('No zydr price');
-my $mega = $cgi->param('mega') || die('No mega price');
-my $morp = $cgi->param('morp') || die('No morp price');
+# Load mineral prices (names are generated above, but i feel
+# it's safe to assume they wont change that often).
+my $trit = $cgi->param('Tritanium') || die('No trit price');
+my $pyer = $cgi->param('Pyerite') || die('No pyer price');
+my $mexa = $cgi->param('Mexallon') || die('No mexa price');
+my $isog = $cgi->param('Isogen') || die('No isog price');
+my $nocx = $cgi->param('Nocxium') || die('No nocx price');
+my $zydr = $cgi->param('Zydrine') || die('No zydr price');
+my $mega = $cgi->param('Megacyte') || die('No mega price');
+my $morp = $cgi->param('Morphite') || die('No morp price');
 
 our @dbparams;
 require './dbparams.cgi';