# HG changeset patch # User Dominic Cleal # Date 1232814188 0 # Node ID 9c46727ce7ab614302ba8f9ba24f3e6b27fa1065 Initial version diff -r 000000000000 -r 9c46727ce7ab reproctool.cgi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reproctool.cgi Sat Jan 24 16:23:08 2009 +0000 @@ -0,0 +1,151 @@ +#!/usr/bin/perl -T + +use warnings; +use strict; + +use CGI; +use DBI; + +# Settings +my $db_path = 'qr100-sqlite3-v1.db'; +my $img_http_path = '/itemimgs'; + +my $cgi = new CGI; +print $cgi->header(-type => 'text/html', + -pragma => 'no-cache', + -expires => '-365d'); + +# 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'); + +my $db = DBI->connect("DBI:SQLite:$db_path") + or die("Database connection failure: $DBI::errstr"); + +# Strip out line endings +$str_items =~ s/[\n\r]+//g; + +# If the items string contains the contract info too, strip it out +$str_items = $1 if ($str_items =~ /The container .+ contains the following items:(.+)/); +$str_items = $1 if ($str_items =~ /(.+)Are you sure you want to continue?/); + +# SQL lookup for reprocessing amounts +my $sql_reprocess = <prepare($sql_reprocess); + +my @output = (); +for my $sitem (split(/\s*,\s*/, $str_items)) +{ + my ($tid, $tname, $meta, $basePrice, $icon, + $ttrit, $tpyer, $tmexa, $tisog, $tnocx, $tzydr, $tmega); + + $pre_reprocess->execute($sitem) or die("Can't lookup $sitem: $DBI::errstr"); + $pre_reprocess->bind_columns(undef, \$tid, \$tname, \$meta, \$basePrice, + \$icon, \$ttrit, \$tpyer, \$tmexa, \$tisog, \$tnocx, \$tzydr, \$tmega); + + my $item = {}; + if ($pre_reprocess->fetch()) + { + my $isk = ($trit * $ttrit) + ($pyer * $tpyer) + ($mexa * $tmexa) + + ($isog * $tisog) + ($nocx * $tnocx) + ($zydr * $tzydr) + + ($mega * $tmega); + + $item = { id => $tid, name => $tname, meta => $meta, icon => $icon, + price => $basePrice, reprocess => $isk }; + } + push @output, $item; +} + +my $col = 0; +print< + + + + + +END + +for my $item (@output) +{ + if ($col == $cols) + { + print "\n"; + $col = 0; + } + + my ($style, $img, $text); + + if (defined $item->{id}) + { + $style = "meta$item->{meta}"; + $img = "icons/icons_items_png/64_64/icon$item->{icon}.png"; + if ($item->{meta} == 4) + { + $text = $item->{name}; + } + else + { + $text = $item->{reprocess}; + } + } + else + { + $text = 'Unknown item'; + $img = "icons/icons_items_png/64_64/icon07_15.png"; + } + + print "\n"; + + $col++; +} + +print< +
"; + print "$item->{name}
$text"; + print "
+ + +END + diff -r 000000000000 -r 9c46727ce7ab reproctool.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reproctool.htm Sat Jan 24 16:23:08 2009 +0000 @@ -0,0 +1,32 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
TritaniumPyeriteMexallonIsogenNocxiumZydrineMegacyteMorphite
+ +
+ + + \ No newline at end of file