Mercurial > hg > reproctool-df
comparison reproctool.cgi @ 16:257e748cd08e
Merging -df
author | Dominic Cleal <dominic@computerkb.co.uk> |
---|---|
date | Sun, 25 Jan 2009 14:46:32 +0000 |
parents | 50d8619bce32 ccd5e74fa58e |
children | a79168f03fc4 |
comparison
equal
deleted
inserted
replaced
15:50d8619bce32 | 16:257e748cd08e |
---|---|
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; |
20 print<<END; | 21 print<<END; |
21 <html><head><title>Error</title></head> | 22 <html><head><title>Error</title></head> |
22 <body><font color="#FF0000"><b>Error:</b></font> $text</body></html> | 23 <body><font color="#FF0000"><b>Error:</b></font> $text</body></html> |
23 END | 24 END |
24 exit; | 25 exit; |
26 } | |
27 | |
28 # Generate the first page, where eve-central mineral prices are prefilled. | |
29 # TODO: depending on the traffic, cache these eve-central prices. | |
30 my $str_items; | |
31 if (! ($str_items = $cgi->param('items')) ) | |
32 { | |
33 my $min; | |
34 my $eveCentralURL = 'http://eve-central.com/api/evemon'; | |
35 my $xmlParser = XML::DOM::Parser->new(); | |
36 my $xmlDoc = $xmlParser->parsefile($eveCentralURL); | |
37 | |
38 # What evenutally will be printed. | |
39 my $inputPage = <<END; | |
40 <html> | |
41 <body> | |
42 | |
43 <form action="/cgi-bin/reproctool/reproctool.cgi" method="post"> | |
44 <textarea rows="5" cols="80" name="items"></textarea> | |
45 <table border="0" cellspacing="4"> | |
46 <tr> | |
47 END | |
48 # Lists the name of the minerals. | |
49 foreach $min ($xmlDoc->getElementsByTagName('mineral')) | |
50 { | |
51 $inputPage .= sprintf( " <td>%s</td>\n", | |
52 $min->getElementsByTagName('name')->item(0)->getFirstChild->getNodeValue ); | |
53 } | |
54 | |
55 $inputPage .= <<END; | |
56 </tr> | |
57 <tr> | |
58 END | |
59 foreach $min ($xmlDoc->getElementsByTagName('mineral')) | |
60 { | |
61 $inputPage .= sprintf( " <td><input type=\"text\" name=\"%s\" size=\"5\" value=\"%.2f\" /></td>\n", | |
62 $min->getElementsByTagName('name')->item(0)->getFirstChild->getNodeValue, | |
63 $min->getElementsByTagName('price')->item(0)->getFirstChild->getNodeValue ); | |
64 } | |
65 | |
66 $inputPage .= <<END; | |
67 </tr> | |
68 </table> | |
69 <input type="submit" /> | |
70 </form> | |
71 | |
72 </body> | |
73 </html> | |
74 END | |
75 | |
76 print $inputPage; | |
77 exit 0; | |
25 } | 78 } |
26 | 79 |
27 # Inputs | 80 # Inputs |
28 my $str_items = $cgi->param('items') or user_error('Items missing'); | 81 my $str_items = $cgi->param('items') or user_error('Items missing'); |
29 my $cols = $cgi->param('cols') || 4; | 82 my $cols = $cgi->param('cols') || 4; |