Mercurial > hg > reproctool-df
annotate reproctool.cgi @ 24:266c93756c1b
Putting inputs next to each other again
author | Dominic Cleal <dominic@computerkb.co.uk> |
---|---|
date | Sun, 25 Jan 2009 17:03:23 +0000 |
parents | 5ae40a1161e6 |
children | ccbd8fa63b9f |
rev | line source |
---|---|
0 | 1 #!/usr/bin/perl -T |
2 | |
3 use warnings; | |
4 use strict; | |
5 | |
6 use CGI; | |
7 use DBI; | |
17
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
8 use LWP::UserAgent; |
0 | 9 |
10 # Settings | |
11 my $img_http_path = '/itemimgs'; | |
12 | |
13 my $cgi = new CGI; | |
14 print $cgi->header(-type => 'text/html', | |
15 -pragma => 'no-cache', | |
16 -expires => '-365d'); | |
17 | |
12
6d5296efb9ef
Shows user-errors to output, not dying
Dominic Cleal <dominic@computerkb.co.uk>
parents:
11
diff
changeset
|
18 sub user_error |
6d5296efb9ef
Shows user-errors to output, not dying
Dominic Cleal <dominic@computerkb.co.uk>
parents:
11
diff
changeset
|
19 { |
6d5296efb9ef
Shows user-errors to output, not dying
Dominic Cleal <dominic@computerkb.co.uk>
parents:
11
diff
changeset
|
20 my $text = shift; |
6d5296efb9ef
Shows user-errors to output, not dying
Dominic Cleal <dominic@computerkb.co.uk>
parents:
11
diff
changeset
|
21 print<<END; |
6d5296efb9ef
Shows user-errors to output, not dying
Dominic Cleal <dominic@computerkb.co.uk>
parents:
11
diff
changeset
|
22 <html><head><title>Error</title></head> |
13 | 23 <body><font color="#FF0000"><b>Error:</b></font> $text</body></html> |
12
6d5296efb9ef
Shows user-errors to output, not dying
Dominic Cleal <dominic@computerkb.co.uk>
parents:
11
diff
changeset
|
24 END |
6d5296efb9ef
Shows user-errors to output, not dying
Dominic Cleal <dominic@computerkb.co.uk>
parents:
11
diff
changeset
|
25 exit; |
6d5296efb9ef
Shows user-errors to output, not dying
Dominic Cleal <dominic@computerkb.co.uk>
parents:
11
diff
changeset
|
26 } |
6d5296efb9ef
Shows user-errors to output, not dying
Dominic Cleal <dominic@computerkb.co.uk>
parents:
11
diff
changeset
|
27 |
24
266c93756c1b
Putting inputs next to each other again
Dominic Cleal <dominic@computerkb.co.uk>
parents:
21
diff
changeset
|
28 # Inputs |
266c93756c1b
Putting inputs next to each other again
Dominic Cleal <dominic@computerkb.co.uk>
parents:
21
diff
changeset
|
29 my $cols = $cgi->param('cols') || 4; |
266c93756c1b
Putting inputs next to each other again
Dominic Cleal <dominic@computerkb.co.uk>
parents:
21
diff
changeset
|
30 my $str_items = $cgi->param('items'); |
266c93756c1b
Putting inputs next to each other again
Dominic Cleal <dominic@computerkb.co.uk>
parents:
21
diff
changeset
|
31 |
8
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
32 # Generate the first page, where eve-central mineral prices are prefilled. |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
33 # TODO: depending on the traffic, cache these eve-central prices. |
24
266c93756c1b
Putting inputs next to each other again
Dominic Cleal <dominic@computerkb.co.uk>
parents:
21
diff
changeset
|
34 |
17
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
35 unless ($str_items) |
8
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
36 { |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
37 my $eveCentralURL = 'http://eve-central.com/api/evemon'; |
17
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
38 my $ua = LWP::UserAgent->new; |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
39 $ua->agent('reproctool'); |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
40 my $resp = $ua->request(HTTP::Request->new(GET => $eveCentralURL)); |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
41 |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
42 my %marks; |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
43 $marks{$_} = 1 foreach ('Tritanium', 'Pyerite', 'Mexallon', 'Isogen', |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
44 'Nocxium', 'Zydrine', 'Megacyte', 'Morphite'); |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
45 |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
46 if ($resp->is_success) |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
47 { |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
48 foreach (split(/[\n\r]/, $resp->content)) |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
49 { |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
50 next unless (/<name>(.+)<\/name>.*<price>([0-9\.]+)<\/price>/i); |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
51 $marks{$1} = $2; |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
52 } |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
53 } |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
54 |
8
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
55 # What evenutally will be printed. |
17
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
56 print<<END; |
8
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
57 <html> |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
58 <body> |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
59 |
17
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
60 <form method="post"> |
8
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
61 <textarea rows="5" cols="80" name="items"></textarea> |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
62 <table border="0" cellspacing="4"> |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
63 <tr> |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
64 END |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
65 # Lists the name of the minerals. |
17
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
66 print "<td>$_</td>\n" foreach (keys %marks); |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
67 print "</tr><tr>"; |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
68 |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
69 foreach (keys %marks) |
8
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
70 { |
17
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
71 my $sname = lc substr($_, 0, 4); |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
72 my $fmt = sprintf('%.2f', $marks{$_}); |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
73 print "<td><input type='text' name='$sname' size='7' value='$fmt' /></td>\n"; |
8
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
74 } |
17
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
75 |
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
76 print <<END; |
8
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
77 </tr> |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
78 </table> |
18
67f13a371c18
Adding columns input
Dominic Cleal <dominic@computerkb.co.uk>
parents:
17
diff
changeset
|
79 Columns: <input type='text' name='cols' size='2' value='4' /><br /><br /> |
8
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
80 <input type="submit" /> |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
81 </form> |
21
5ae40a1161e6
Added eve central credit (still need to cache some vals, got an idea on that dom?)
df
parents:
20
diff
changeset
|
82 <br /> |
5ae40a1161e6
Added eve central credit (still need to cache some vals, got an idea on that dom?)
df
parents:
20
diff
changeset
|
83 Mineral prices are empire averages from <a href="http://www.eve-central.com/">Eve-central</a>. |
8
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
84 </body> |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
85 </html> |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
86 END |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
87 |
17
a79168f03fc4
Replacing XML::DOM with LWP and regex, tidying code
Dominic Cleal <dominic@computerkb.co.uk>
parents:
16
diff
changeset
|
88 exit; |
8
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
89 } |
ccd5e74fa58e
Untested xml import of prices from evecentral. solution is a dead end, as the rammsrdi.com dont support dom xlm.
df
parents:
7
diff
changeset
|
90 |
0 | 91 # Load mineral prices |
15
50d8619bce32
Improving mineral errors
Dominic Cleal <dominic@computerkb.co.uk>
parents:
14
diff
changeset
|
92 my $trit = $cgi->param('trit') || user_error('No tritanium price'); |
50d8619bce32
Improving mineral errors
Dominic Cleal <dominic@computerkb.co.uk>
parents:
14
diff
changeset
|
93 my $pyer = $cgi->param('pyer') || user_error('No pyerite price'); |
50d8619bce32
Improving mineral errors
Dominic Cleal <dominic@computerkb.co.uk>
parents:
14
diff
changeset
|
94 my $mexa = $cgi->param('mexa') || user_error('No mexallon price'); |
50d8619bce32
Improving mineral errors
Dominic Cleal <dominic@computerkb.co.uk>
parents:
14
diff
changeset
|
95 my $isog = $cgi->param('isog') || user_error('No isogen price'); |
50d8619bce32
Improving mineral errors
Dominic Cleal <dominic@computerkb.co.uk>
parents:
14
diff
changeset
|
96 my $nocx = $cgi->param('nocx') || user_error('No nocxium price'); |
50d8619bce32
Improving mineral errors
Dominic Cleal <dominic@computerkb.co.uk>
parents:
14
diff
changeset
|
97 my $zydr = $cgi->param('zydr') || user_error('No zydrine price'); |
50d8619bce32
Improving mineral errors
Dominic Cleal <dominic@computerkb.co.uk>
parents:
14
diff
changeset
|
98 my $mega = $cgi->param('mega') || user_error('No megacyte price'); |
50d8619bce32
Improving mineral errors
Dominic Cleal <dominic@computerkb.co.uk>
parents:
14
diff
changeset
|
99 my $morp = $cgi->param('morp') || user_error('No morphite price'); |
0 | 100 |
3
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
101 our @dbparams; |
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
102 require './dbparams.cgi'; |
1
c39512d94605
Adding dbparams config
Dominic Cleal <dominic@computerkb.co.uk>
parents:
0
diff
changeset
|
103 my $db = DBI->connect(@dbparams) |
0 | 104 or die("Database connection failure: $DBI::errstr"); |
105 | |
106 # Strip out line endings | |
107 $str_items =~ s/[\n\r]+//g; | |
108 | |
109 # If the items string contains the contract info too, strip it out | |
110 $str_items = $1 if ($str_items =~ /The container .+ contains the following items:(.+)/); | |
111 $str_items = $1 if ($str_items =~ /(.+)Are you sure you want to continue?/); | |
112 | |
9
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
113 my @item_names = split(/\s*,\s*/, $str_items); |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
114 |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
115 # SQL fragment to match all items |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
116 my $sql_typenames = ''; |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
117 $sql_typenames = 'types.typeName = ?' if ($#item_names >= 0); |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
118 $sql_typenames .= " OR types.typeName = ?" foreach (1..$#item_names); |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
119 |
0 | 120 # SQL lookup for reprocessing amounts |
121 my $sql_reprocess = <<END; | |
122 SELECT | |
123 types.typeID, | |
124 types.typeName, | |
9
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
125 groups.groupName, |
3
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
126 attrs.valueInt, -- metaLevel |
0 | 127 types.basePrice, |
128 graphics.icon, | |
3
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
129 SUM(CASE WHEN m1.requiredTypeID = 34 THEN m1.quantity ELSE 0 END), -- [Tritanium] |
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
130 SUM(CASE WHEN m1.requiredTypeID = 35 THEN m1.quantity ELSE 0 END), -- [Pyerite] |
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
131 SUM(CASE WHEN m1.requiredTypeID = 36 THEN m1.quantity ELSE 0 END), -- [Mexallon] |
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
132 SUM(CASE WHEN m1.requiredTypeID = 37 THEN m1.quantity ELSE 0 END), -- [Isogen] |
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
133 SUM(CASE WHEN m1.requiredTypeID = 38 THEN m1.quantity ELSE 0 END), -- [Nocxium] |
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
134 SUM(CASE WHEN m1.requiredTypeID = 39 THEN m1.quantity ELSE 0 END), -- [Zydrine] |
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
135 SUM(CASE WHEN m1.requiredTypeID = 40 THEN m1.quantity ELSE 0 END), -- [Megacyte] |
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
136 SUM(CASE WHEN m1.requiredTypeID = 11399 THEN m1.quantity ELSE 0 END) -- [Morphite] |
0 | 137 FROM invTypes types |
11
f749981ad862
Fixes items with no metalevel attribute, improves sorting
Dominic Cleal <dominic@computerkb.co.uk>
parents:
10
diff
changeset
|
138 LEFT JOIN dgmTypeAttributes attrs ON types.typeID = attrs.typeID AND attrs.attributeID = 633 |
0 | 139 INNER JOIN typeActivityMaterials m1 ON types.typeID = m1.typeID |
9
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
140 INNER JOIN invGroups groups ON types.groupID = groups.groupID |
0 | 141 INNER JOIN eveGraphics graphics ON types.graphicID = graphics.graphicID |
9
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
142 WHERE $sql_typenames |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
143 GROUP BY types.typeID |
11
f749981ad862
Fixes items with no metalevel attribute, improves sorting
Dominic Cleal <dominic@computerkb.co.uk>
parents:
10
diff
changeset
|
144 ORDER BY groups.categoryID DESC, groupName ASC, typeName ASC |
0 | 145 END |
146 my $pre_reprocess = $db->prepare($sql_reprocess); | |
147 | |
9
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
148 # Execute, bring back one row per item |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
149 my ($tid, $tname, $gname, $meta, $basePrice, $icon, |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
150 $ttrit, $tpyer, $tmexa, $tisog, $tnocx, $tzydr, $tmega, $tmorp); |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
151 |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
152 $pre_reprocess->execute(@item_names) or die("Can't lookup items: $DBI::errstr"); |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
153 $pre_reprocess->bind_columns(undef, \$tid, \$tname, \$gname, \$meta, \$basePrice, |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
154 \$icon, \$ttrit, \$tpyer, \$tmexa, \$tisog, |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
155 \$tnocx, \$tzydr, \$tmega, \$tmorp); |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
156 |
0 | 157 my @output = (); |
9
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
158 while ($pre_reprocess->fetch()) |
0 | 159 { |
160 my $item = {}; | |
9
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
161 my $isk = ($trit * $ttrit) + ($pyer * $tpyer) + ($mexa * $tmexa) + |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
162 ($isog * $tisog) + ($nocx * $tnocx) + ($zydr * $tzydr) + |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
163 ($mega * $tmega) + ($morp * $tmorp); |
20
877806fb69a3
Fixed double use of var, and added reprocessing details in ALT
df
parents:
18
diff
changeset
|
164 my $repDetails = sprintf( "Trit=%d Py=%d Mex=%d Iso=%d Nocx=%d Zyd=%d Mega=%d Morp=%d", |
877806fb69a3
Fixed double use of var, and added reprocessing details in ALT
df
parents:
18
diff
changeset
|
165 $ttrit, $tpyer, $tmexa, $tisog, $tnocx, $tzydr, $tmega, $tmorp ); |
9
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
166 |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
167 $meta = 0 unless defined $meta; |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
168 $item = { id => $tid, name => $tname, meta => $meta, icon => $icon, |
20
877806fb69a3
Fixed double use of var, and added reprocessing details in ALT
df
parents:
18
diff
changeset
|
169 price => $basePrice, reprocessIsk => $isk, reprocessDetails => $repDetails }; |
9
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
170 |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
171 # If this item exists multiple times in the input, then they weren't stacked |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
172 # so output it multiple times |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
173 my @matching_in = grep({ $_ eq $tname } @item_names); |
6b98a17fbe22
Changing to a single SQL query for type-based sorting and efficiency
Dominic Cleal <dominic@computerkb.co.uk>
parents:
7
diff
changeset
|
174 push @output, $item foreach (0..$#matching_in); |
0 | 175 } |
176 | |
177 my $col = 0; | |
178 print<<END; | |
179 <html> | |
180 <head> | |
181 <style type="text/css"> | |
182 .meta4, .meta5, .meta6, .meta7, .meta8, .meta9 | |
183 { | |
5
42268fc087a9
Improving IGB integration with links and images
Dominic Cleal <dominic@computerkb.co.uk>
parents:
4
diff
changeset
|
184 color: #FF0000; |
0 | 185 } |
3
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
186 .item |
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
187 { |
4
4351c0bf33d4
Improving IGB formatting
Dominic Cleal <dominic@computerkb.co.uk>
parents:
3
diff
changeset
|
188 text-align: center; |
3
e640eb6cefc3
Making DB stuff more generic, fixing missing mineral
Dominic Cleal <dominic@computerkb.co.uk>
parents:
1
diff
changeset
|
189 } |
0 | 190 </style> |
191 </head> | |
4
4351c0bf33d4
Improving IGB formatting
Dominic Cleal <dominic@computerkb.co.uk>
parents:
3
diff
changeset
|
192 |
0 | 193 <body> |
194 <table> | |
195 END | |
196 | |
10
de10d02dc715
Using item images for non-IGB browsers
Dominic Cleal <dominic@computerkb.co.uk>
parents:
9
diff
changeset
|
197 my $igb = ($ENV{HTTP_USER_AGENT} =~ /EVE-minibrowser/i); |
de10d02dc715
Using item images for non-IGB browsers
Dominic Cleal <dominic@computerkb.co.uk>
parents:
9
diff
changeset
|
198 |
0 | 199 for my $item (@output) |
200 { | |
201 if ($col == $cols) | |
202 { | |
203 print "</tr><tr>\n"; | |
204 $col = 0; | |
205 } | |
206 | |
5
42268fc087a9
Improving IGB integration with links and images
Dominic Cleal <dominic@computerkb.co.uk>
parents:
4
diff
changeset
|
207 my ($style, $img, $text, $link, $colour); |
0 | 208 |
209 if (defined $item->{id}) | |
210 { | |
211 $style = "meta$item->{meta}"; | |
10
de10d02dc715
Using item images for non-IGB browsers
Dominic Cleal <dominic@computerkb.co.uk>
parents:
9
diff
changeset
|
212 if ($igb) |
de10d02dc715
Using item images for non-IGB browsers
Dominic Cleal <dominic@computerkb.co.uk>
parents:
9
diff
changeset
|
213 { |
de10d02dc715
Using item images for non-IGB browsers
Dominic Cleal <dominic@computerkb.co.uk>
parents:
9
diff
changeset
|
214 $img = "typeicon:$item->{id}"; |
de10d02dc715
Using item images for non-IGB browsers
Dominic Cleal <dominic@computerkb.co.uk>
parents:
9
diff
changeset
|
215 $link = "showinfo:$item->{id}"; |
de10d02dc715
Using item images for non-IGB browsers
Dominic Cleal <dominic@computerkb.co.uk>
parents:
9
diff
changeset
|
216 } |
de10d02dc715
Using item images for non-IGB browsers
Dominic Cleal <dominic@computerkb.co.uk>
parents:
9
diff
changeset
|
217 else |
de10d02dc715
Using item images for non-IGB browsers
Dominic Cleal <dominic@computerkb.co.uk>
parents:
9
diff
changeset
|
218 { |
de10d02dc715
Using item images for non-IGB browsers
Dominic Cleal <dominic@computerkb.co.uk>
parents:
9
diff
changeset
|
219 $img = "$img_http_path/icons/icons_items_png/64_64/icon$item->{icon}.png"; |
de10d02dc715
Using item images for non-IGB browsers
Dominic Cleal <dominic@computerkb.co.uk>
parents:
9
diff
changeset
|
220 } |
de10d02dc715
Using item images for non-IGB browsers
Dominic Cleal <dominic@computerkb.co.uk>
parents:
9
diff
changeset
|
221 |
0 | 222 if ($item->{meta} == 4) |
223 { | |
224 $text = $item->{name}; | |
5
42268fc087a9
Improving IGB integration with links and images
Dominic Cleal <dominic@computerkb.co.uk>
parents:
4
diff
changeset
|
225 $colour = "#FF0000"; |
0 | 226 } |
227 else | |
228 { | |
20
877806fb69a3
Fixed double use of var, and added reprocessing details in ALT
df
parents:
18
diff
changeset
|
229 $text = $item->{reprocessIsk}; |
0 | 230 } |
231 } | |
232 else | |
233 { | |
234 $text = 'Unknown item'; | |
5
42268fc087a9
Improving IGB integration with links and images
Dominic Cleal <dominic@computerkb.co.uk>
parents:
4
diff
changeset
|
235 $img = "typeicon:07_15"; |
0 | 236 } |
237 | |
5
42268fc087a9
Improving IGB integration with links and images
Dominic Cleal <dominic@computerkb.co.uk>
parents:
4
diff
changeset
|
238 print "<td width='64' class='item'>"; |
42268fc087a9
Improving IGB integration with links and images
Dominic Cleal <dominic@computerkb.co.uk>
parents:
4
diff
changeset
|
239 print "<a href='$link'>" if defined $link; |
14
9b8670ac1bcc
Adding title attr to images
Dominic Cleal <dominic@computerkb.co.uk>
parents:
13
diff
changeset
|
240 print "<img src='$img' width='64' height='64' border='1' "; |
20
877806fb69a3
Fixed double use of var, and added reprocessing details in ALT
df
parents:
18
diff
changeset
|
241 print "title=\"$item->{name}\" alt=\"$item->{name} ($item->{reprocessDetails})\" />"; |
5
42268fc087a9
Improving IGB integration with links and images
Dominic Cleal <dominic@computerkb.co.uk>
parents:
4
diff
changeset
|
242 print "</a>" if defined $link; |
42268fc087a9
Improving IGB integration with links and images
Dominic Cleal <dominic@computerkb.co.uk>
parents:
4
diff
changeset
|
243 print "<br />"; |
42268fc087a9
Improving IGB integration with links and images
Dominic Cleal <dominic@computerkb.co.uk>
parents:
4
diff
changeset
|
244 print "<font color='$colour'>" if defined $colour; |
42268fc087a9
Improving IGB integration with links and images
Dominic Cleal <dominic@computerkb.co.uk>
parents:
4
diff
changeset
|
245 print $text; |
42268fc087a9
Improving IGB integration with links and images
Dominic Cleal <dominic@computerkb.co.uk>
parents:
4
diff
changeset
|
246 print "</font>" if defined $colour; |
0 | 247 print "</td>\n"; |
248 | |
249 $col++; | |
250 } | |
251 | |
252 print<<END; | |
253 </tr> | |
254 </table> | |
255 </body> | |
256 </html> | |
257 END | |
258 |