Loading...   


#!/usr/bin/perl

use LWP::UserAgent;
use HTTP::Request::Common qw(GET);
use HTTP::Cookies;
use HTML::TagParser;
use URI::Fetch;

my $ua = LWP::UserAgent->new;

# Define user agent type
$ua->agent('Mozilla/8.0');

# Cookies
$ua->cookie_jar(
	HTTP::Cookies->new(
		file => 'mycookies.txt',
		autosave => 1
	)
);

$itemid = $ARGV[0];

# Request object
my $req = GET 'http://lucy.allakhazam.com/itemraw.html?id=' . $itemid . '&setcookie=1';

# Make the request
my $res = $ua->request($req);

# Check the response
if ($res->is_success) {
	$content = $res->content;
} else {
	#print $res->status_line . "\n";
}

$Line = 1; $SP = 0; $n=1;
my $html = HTML::TagParser->new($content); # Get web page HTML  
if($html != 0){
	my @list = $html->getElementsByTagName("title");
	foreach my $elem (@list) { $title = $elem->innerText; }
	@elems = $html->getElementsByTagName("td");
	#@elems = $html->getElementsByClassName("spellview");
	foreach my $elem (@elems) {  
		$text = $elem->innerText;
		if(substr($text, 0, 5) eq "AkzID"){ $SP = 1; $Line = 1; $occ++; } ### Queue to start printing
		if($SP == 1 && $occ == 2){
			if($Line == 2){ ### Value
				#print "'" . $elem->innerText() . "'\n";
				$LucyItem[$n][1] = $text;
				$n++; ### Increment the field #
				$Line = 1; next;
			}
			if($Line == 1){ ### Field
				if($text eq ""){ last; }
				#print "'" . $elem->innerText() . "' = ";
				$LucyItem[$n][0] = $text;
				$Line++; next;
			}			
		}
	}
}

$n = 1;
while($LucyItem[$n][0]){
	#print $LucyItem[$n][0] . " = " . $LucyItem[$n][1] . "\n";
	#if($LucyItem[$n][0]=~/Name/i){ print $LucyItem[$n][1]. ""; }
	$n++;
}

use DBI;
use DBD::mysql;
# CONFIG VARIABLES
my $confile = "eqemu_config.xml"; #default
open(F, "<$confile") or die "Unable to open config: $confile\n";
my $indb = 0;
while(<F>) {
	s/\r//g;
	if(/<database>/i) { $indb = 1; }
	next unless($indb == 1);
	if(/<\/database>/i) { $indb = 0; last; }
	if(/<host>(.*)<\/host>/i) { $host = $1; } 
	elsif(/<username>(.*)<\/username>/i) { $user = $1; } 
	elsif(/<password>(.*)<\/password>/i) { $pass = $1; } 
	elsif(/<db>(.*)<\/db>/i) { $db = $1; }
}
# DATA SOURCE NAME
$dsn = "dbi:mysql:$db:localhost:3306";
# PERL DBI CONNECT
if(!$connect){ $connect = DBI->connect($dsn, $user, $pass); }
if(!$connect2){ $connect2 = DBI->connect($dsn, $user, $pass); }

%ItemFields = (
	1 => ["id"],
	2 => ["minstatus"],
	3 => ["Name"],
	4 => ["aagi"],
	5 => ["ac"],
	6 => ["accuracy"],
	7 => ["acha"],
	8 => ["adex"],
	9 => ["aint"],
	10 => ["artifactflag"],
	11 => ["asta"],
	12 => ["astr"],
	13 => ["attack"],
	14 => ["augrestrict"],
	15 => ["augslot1type"],
	16 => ["augslot1visible"],
	17 => ["augslot2type"],
	18 => ["augslot2visible"],
	19 => ["augslot3type"],
	20 => ["augslot3visible"],
	21 => ["augslot4type"],
	22 => ["augslot4visible"],
	23 => ["augslot5type"],
	24 => ["augslot5visible"],
	25 => ["augtype"],
	26 => ["avoidance"],
	27 => ["awis"],
	28 => ["bagsize"],
	29 => ["bagslots"],
	30 => ["bagtype"],
	31 => ["bagwr"],
	32 => ["banedmgamt"],
	33 => ["banedmgraceamt"],
	34 => ["banedmgbody"],
	35 => ["banedmgrace"],
	36 => ["bardtype"],
	37 => ["bardvalue"],
	38 => ["book"],
	39 => ["casttime"],
	40 => ["casttime_"],
	41 => ["charmfile"],
	42 => ["charmfileid"],
	43 => ["classes"],
	44 => ["color"],
	45 => ["combateffects"],
	46 => ["extradmgskill"],
	47 => ["extradmgamt"],
	48 => ["price"],
	49 => ["cr"],
	50 => ["damage"],
	51 => ["damageshield"],
	52 => ["deity"],
	53 => ["delay"],
	54 => ["augdistiller"],
	55 => ["dotshielding"],
	56 => ["dr"],
	57 => ["clicktype"],
	58 => ["clicklevel2"],
	59 => ["elemdmgtype"],
	60 => ["elemdmgamt"],
	61 => ["endur"],
	62 => ["factionamt1"],
	63 => ["factionamt2"],
	64 => ["factionamt3"],
	65 => ["factionamt4"],
	66 => ["factionmod1"],
	67 => ["factionmod2"],
	68 => ["factionmod3"],
	69 => ["factionmod4"],
	70 => ["filename"],
	71 => ["focuseffect"],
	72 => ["fr"],
	73 => ["fvnodrop"],
	74 => ["haste"],
	75 => ["clicklevel"],
	76 => ["hp"],
	77 => ["regen"],
	78 => ["icon"],
	79 => ["idfile"],
	80 => ["itemclass"],
	81 => ["itemtype"],
	82 => ["ldonprice"],
	83 => ["ldontheme"],
	84 => ["ldonsold"],
	85 => ["light"],
	86 => ["lore"],
	87 => ["loregroup"],
	88 => ["magic"],
	89 => ["mana"],
	90 => ["manaregen"],
	91 => ["enduranceregen"],
	92 => ["material"],
	93 => ["maxcharges"],
	94 => ["mr"],
	95 => ["nodrop"],
	96 => ["norent"],
	97 => ["pendingloreflag"],
	98 => ["pr"],
	99 => ["procrate"],
	100 => ["races"],
	101 => ["`range`"],
	102 => ["reclevel"],
	103 => ["recskill"],
	104 => ["reqlevel"],
	105 => ["sellrate"],
	106 => ["shielding"],
	107 => ["size"],
	108 => ["skillmodtype"],
	109 => ["skillmodvalue"],
	110 => ["slots"],
	111 => ["clickeffect"],
	112 => ["spellshield"],
	113 => ["strikethrough"],
	114 => ["stunresist"],
	115 => ["summonedflag"],
	116 => ["tradeskills"],
	117 => ["favor"],
	118 => ["weight"],
	119 => ["UNK012"],
	120 => ["UNK013"],
	121 => ["benefitflag"],
	122 => ["UNK054"],
	123 => ["UNK059"],
	124 => ["booktype"],
	125 => ["recastdelay"],
	126 => ["recasttype"],
	127 => ["guildfavor"],
	128 => ["UNK123"],
	129 => ["UNK124"],
	130 => ["attuneable"],
	131 => ["nopet"],
	132 => ["updated"],
	133 => ["comment"],
	134 => ["UNK127"],
	135 => ["pointtype"],
	136 => ["potionbelt"],
	137 => ["potionbeltslots"],
	138 => ["stacksize"],
	139 => ["notransfer"],
	140 => ["stackable"],
	141 => ["UNK134"],
	142 => ["UNK137"],
	143 => ["proceffect"],
	144 => ["proctype"],
	145 => ["proclevel2"],
	146 => ["proclevel"],
	147 => ["UNK142"],
	148 => ["worneffect"],
	149 => ["worntype"],
	150 => ["wornlevel2"],
	151 => ["wornlevel"],
	152 => ["UNK147"],
	153 => ["focustype"],
	154 => ["focuslevel2"],
	155 => ["focuslevel"],
	156 => ["UNK152"],
	157 => ["scrolleffect"],
	158 => ["scrolltype"],
	159 => ["scrolllevel2"],
	160 => ["scrolllevel"],
	161 => ["UNK157"],
	162 => ["serialized"],
	163 => ["verified"],
	164 => ["serialization"],
	165 => ["source"],
	166 => ["UNK033"],
	167 => ["lorefile"],
	168 => ["UNK014"],
	169 => ["svcorruption"],
	170 => ["UNK038"],
	171 => ["UNK060"],
	172 => ["augslot1unk2"],
	173 => ["augslot2unk2"],
	174 => ["augslot3unk2"],
	175 => ["augslot4unk2"],
	176 => ["augslot5unk2"],
	177 => ["UNK120"],
	178 => ["UNK121"],
	179 => ["questitemflag"],
	180 => ["UNK132"],
	181 => ["clickunk5"],
	182 => ["clickunk6"],
	183 => ["clickunk7"],
	184 => ["procunk1"],
	185 => ["procunk2"],
	186 => ["procunk3"],
	187 => ["procunk4"],
	188 => ["procunk6"],
	189 => ["procunk7"],
	190 => ["wornunk1"],
	191 => ["wornunk2"],
	192 => ["wornunk3"],
	193 => ["wornunk4"],
	194 => ["wornunk5"],
	195 => ["wornunk6"],
	196 => ["wornunk7"],
	197 => ["focusunk1"],
	198 => ["focusunk2"],
	199 => ["focusunk3"],
	200 => ["focusunk4"],
	201 => ["focusunk5"],
	202 => ["focusunk6"],
	203 => ["focusunk7"],
	204 => ["scrollunk1"],
	205 => ["scrollunk2"],
	206 => ["scrollunk3"],
	207 => ["scrollunk4"],
	208 => ["scrollunk5"],
	209 => ["scrollunk6"],
	210 => ["scrollunk7"],
	211 => ["UNK193"],
	212 => ["purity"],
	213 => ["evolvinglevel"],
	214 => ["clickname"],
	215 => ["procname"],
	216 => ["wornname"],
	217 => ["focusname"],
	218 => ["scrollname"],
	219 => ["dsmitigation"],
	220 => ["heroic_str"],
	221 => ["heroic_int"],
	222 => ["heroic_wis"],
	223 => ["heroic_agi"],
	224 => ["heroic_dex"],
	225 => ["heroic_sta"],
	226 => ["heroic_cha"],
	227 => ["heroic_pr"],
	228 => ["heroic_dr"],
	229 => ["heroic_fr"],
	230 => ["heroic_cr"],
	231 => ["heroic_mr"],
	232 => ["heroic_svcorrup"],
	233 => ["healamt"],
	234 => ["spelldmg"],
	235 => ["clairvoyance"],
	236 => ["backstabdmg"],
	237 => ["created"],
	238 => ["elitematerial"],
	239 => ["ldonsellbackrate"],
	240 => ["scriptfileid"],
	241 => ["expendablearrow"],
	242 => ["powersourcecapacity"],
	243 => ["bardeffect"],
	244 => ["bardeffecttype"],
	245 => ["bardlevel2"],
	246 => ["bardlevel"],
	247 => ["bardunk1"],
	248 => ["bardunk2"],
	249 => ["bardunk3"],
	250 => ["bardunk4"],
	251 => ["bardunk5"],
	252 => ["bardname"],
	253 => ["bardunk7"],
	254 => ["UNK214"],
	255 => ["UNK219"],
	256 => ["UNK220"],
	257 => ["UNK221"],
	258 => ["UNK222"],
	259 => ["UNK223"],
	260 => ["UNK224"],
	261 => ["UNK225"],
	262 => ["UNK226"],
	263 => ["UNK227"],
	264 => ["UNK228"],
	265 => ["UNK229"],
	266 => ["UNK230"],
	267 => ["UNK231"],
	268 => ["UNK232"],
	269 => ["UNK233"],
	270 => ["UNK234"],
	271 => ["UNK235"],
	272 => ["UNK236"],
	273 => ["UNK237"],
	274 => ["UNK238"],
	275 => ["UNK239"],
	276 => ["UNK240"],
	277 => ["UNK241"],
	278 => ["UNK242"],
);

$query = "SELECT id, minstatus, Name, aagi, ac, accuracy, acha, adex, aint, artifactflag, asta, astr, attack, augrestrict, augslot1type, augslot1visible, augslot2type, augslot2visible, augslot3type, augslot3visible, augslot4type, augslot4visible, augslot5type, augslot5visible, augtype, avoidance, awis, bagsize, bagslots, bagtype, bagwr, banedmgamt, banedmgraceamt, banedmgbody, banedmgrace, bardtype, bardvalue, book, casttime, casttime_, charmfile, charmfileid, classes, color, combateffects, extradmgskill, extradmgamt, price, cr, damage, damageshield, deity, delay, augdistiller, dotshielding, dr, clicktype, clicklevel2, elemdmgtype, elemdmgamt, endur, factionamt1, factionamt2, factionamt3, factionamt4, factionmod1, factionmod2, factionmod3, factionmod4, filename, focuseffect, fr, fvnodrop, haste, clicklevel, hp, regen, icon, idfile, itemclass, itemtype, ldonprice, ldontheme, ldonsold, light, lore, loregroup, magic, mana, manaregen, enduranceregen, material, maxcharges, mr, nodrop, norent, pendingloreflag, pr, procrate, races, `range`, reclevel, recskill, reqlevel, sellrate, shielding, size, skillmodtype, skillmodvalue, slots, clickeffect, spellshield, strikethrough, stunresist, summonedflag, tradeskills, favor, weight, UNK012, UNK013, benefitflag, UNK054, UNK059, booktype, recastdelay, recasttype, guildfavor, UNK123, UNK124, attuneable, nopet, updated, comment, UNK127, pointtype, potionbelt, potionbeltslots, stacksize, notransfer, stackable, UNK134, UNK137, proceffect, proctype, proclevel2, proclevel, UNK142, worneffect, worntype, wornlevel2, wornlevel, UNK147, focustype, focuslevel2, focuslevel, UNK152, scrolleffect, scrolltype, scrolllevel2, scrolllevel, UNK157, serialized, verified, serialization, source, UNK033, lorefile, UNK014, svcorruption, UNK038, UNK060, augslot1unk2, augslot2unk2, augslot3unk2, augslot4unk2, augslot5unk2, UNK120, UNK121, questitemflag, UNK132, clickunk5, clickunk6, clickunk7, procunk1, procunk2, procunk3, procunk4, procunk6, procunk7, wornunk1, wornunk2, wornunk3, wornunk4, wornunk5, wornunk6, wornunk7, focusunk1, focusunk2, focusunk3, focusunk4, focusunk5, focusunk6, focusunk7, scrollunk1, scrollunk2, scrollunk3, scrollunk4, scrollunk5, scrollunk6, scrollunk7, UNK193, purity, evolvinglevel, clickname, procname, wornname, focusname, scrollname, dsmitigation, heroic_str, heroic_int, heroic_wis, heroic_agi, heroic_dex, heroic_sta, heroic_cha, heroic_pr, heroic_dr, heroic_fr, heroic_cr, heroic_mr, heroic_svcorrup, healamt, spelldmg, clairvoyance, backstabdmg, created, elitematerial, ldonsellbackrate, scriptfileid, expendablearrow, powersourcecapacity, bardeffect, bardeffecttype, bardlevel2, bardlevel, bardunk1, bardunk2, bardunk3, bardunk4, bardunk5, bardname, bardunk7, UNK214, UNK219, UNK220, UNK221, UNK222, UNK223, UNK224, UNK225, UNK226, UNK227, UNK228, UNK229, UNK230, UNK231, UNK232, UNK233, UNK234, UNK235, UNK236, UNK237, UNK238, UNK239, UNK240, UNK241, UNK242 FROM items WHERE `id` = " . $itemid;
$query_handle = $connect->prepare($query); 
$query_handle->execute();
while (@row = $query_handle->fetchrow_array()) { 
	for($i =0; $i<=277; $i++){
		#print "EQEMU Field " . $ItemFields{($i + 1)}[0] . " " . $row[$i] . "\n";
		$EQEmuItem[$i][0] = $ItemFields{($i + 1)}[0];
		$EQEmuItem[$i][1] = $row[$i];
	}
}

$query = "SELECT `lucyfield`, `eqemufield` FROM `eqemu_lucyfields`";
$query_handle = $connect->prepare($query); 
$query_handle->execute();
while (@row = $query_handle->fetchrow_array()) { 
	if($row[1] ne ""){ $Identified{$row[0]}[0] = 1; }
	if($row[1] ne ""){ $EQEmuUsed{$row[1]}[0] = 1; } 
}

### Let's try to compare fields

#print $title . "\n";
for($i =0; $i<=277; $i++){
	$n=1;
	while($LucyItem[$n][0]){
		if($LucyItem[$n][1] eq $EQEmuItem[$i][1]){ 
			if($LucyItem[$n][1] != 0 && $LucyItem[$n][1] != -1 && $LucyItem[$n][1] != 1 && $LucyItem[$n][1] ne ""){
				if($LucyItem[$n][2] != 1 && $Reserve[$i] != 1 && $Identified{$LucyItem[$n][0]}[0] != 1 && $EQEmuUsed{$EQEmuItem[$i][0]}[0] != 1){
					print "Match (Lucy to EQEMU) - ID $itemid ";
					print "'" . $LucyItem[$n][0] . "' - '" . $EQEmuItem[$i][0] . "' ";
					print "# '" . $LucyItem[$n][1] . "' - '" . $EQEmuItem[$i][1] . "'\n";
					$LucyItem[$n][2] = 1; ### Set Found bit
					$Reserve[$i] = 1; ### Reserve this found value so something else doesn't think that it belongs to them
				}
			}
		}
		$n++;
	}
}

Raw Paste Data