comparison reproctool.cgi @ 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
comparison
equal deleted inserted replaced
7:e30154411e63 8:ccd5e74fa58e
3 use warnings; 3 use warnings;
4 use strict; 4 use strict;
5 5
6 use CGI; 6 use CGI;
7 use DBI; 7 use DBI;
8 use XML::DOM;
8 9
9 # Settings 10 # Settings
10 my $img_http_path = '/itemimgs'; 11 my $img_http_path = '/itemimgs';
11 12
12 my $cgi = new CGI; 13 my $cgi = new CGI;
13 print $cgi->header(-type => 'text/html', 14 print $cgi->header(-type => 'text/html',
14 -pragma => 'no-cache', 15 -pragma => 'no-cache',
15 -expires => '-365d'); 16 -expires => '-365d');
16 17
18 # Generate the first page, where eve-central mineral prices are prefilled.
19 # TODO: depending on the traffic, cache these eve-central prices.
20 my $str_items;
21 if (! ($str_items = $cgi->param('items')) )
22 {
23 my $min;
24 my $eveCentralURL = 'http://eve-central.com/api/evemon';
25 my $xmlParser = XML::DOM::Parser->new();
26 my $xmlDoc = $xmlParser->parsefile($eveCentralURL);
27
28 # What evenutally will be printed.
29 my $inputPage = <<END;
30 <html>
31 <body>
32
33 <form action="/cgi-bin/reproctool/reproctool.cgi" method="post">
34 <textarea rows="5" cols="80" name="items"></textarea>
35 <table border="0" cellspacing="4">
36 <tr>
37 END
38 # Lists the name of the minerals.
39 foreach $min ($xmlDoc->getElementsByTagName('mineral'))
40 {
41 $inputPage .= sprintf( " <td>%s</td>\n",
42 $min->getElementsByTagName('name')->item(0)->getFirstChild->getNodeValue );
43 }
44
45 $inputPage .= <<END;
46 </tr>
47 <tr>
48 END
49 foreach $min ($xmlDoc->getElementsByTagName('mineral'))
50 {
51 $inputPage .= sprintf( " <td><input type=\"text\" name=\"%s\" size=\"5\" value=\"%.2f\" /></td>\n",
52 $min->getElementsByTagName('name')->item(0)->getFirstChild->getNodeValue,
53 $min->getElementsByTagName('price')->item(0)->getFirstChild->getNodeValue );
54 }
55
56 $inputPage .= <<END;
57 </tr>
58 </table>
59 <input type="submit" />
60 </form>
61
62 </body>
63 </html>
64 END
65
66 print $inputPage;
67 exit 0;
68 }
69
17 # Inputs 70 # Inputs
18 my $str_items = $cgi->param('items') or die('Items missing');
19 my $cols = $cgi->param('cols') || 4; 71 my $cols = $cgi->param('cols') || 4;
20 72
21 # Load mineral prices 73 # Load mineral prices (names are generated above, but i feel
22 my $trit = $cgi->param('trit') || die('No trit price'); 74 # it's safe to assume they wont change that often).
23 my $pyer = $cgi->param('pyer') || die('No pyer price'); 75 my $trit = $cgi->param('Tritanium') || die('No trit price');
24 my $mexa = $cgi->param('mexa') || die('No mexa price'); 76 my $pyer = $cgi->param('Pyerite') || die('No pyer price');
25 my $isog = $cgi->param('isog') || die('No isog price'); 77 my $mexa = $cgi->param('Mexallon') || die('No mexa price');
26 my $nocx = $cgi->param('nocx') || die('No nocx price'); 78 my $isog = $cgi->param('Isogen') || die('No isog price');
27 my $zydr = $cgi->param('zydr') || die('No zydr price'); 79 my $nocx = $cgi->param('Nocxium') || die('No nocx price');
28 my $mega = $cgi->param('mega') || die('No mega price'); 80 my $zydr = $cgi->param('Zydrine') || die('No zydr price');
29 my $morp = $cgi->param('morp') || die('No morp price'); 81 my $mega = $cgi->param('Megacyte') || die('No mega price');
82 my $morp = $cgi->param('Morphite') || die('No morp price');
30 83
31 our @dbparams; 84 our @dbparams;
32 require './dbparams.cgi'; 85 require './dbparams.cgi';
33 my $db = DBI->connect(@dbparams) 86 my $db = DBI->connect(@dbparams)
34 or die("Database connection failure: $DBI::errstr"); 87 or die("Database connection failure: $DBI::errstr");