Go Back   EQEmulator Home > EQEmulator Forums > Development > EQEmu Operations Center

EQEmu Operations Center Web development tools

Reply
 
Thread Tools Display Modes
  #1  
Old 11-01-2013, 07:42 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default Zone Cloning / Door cloning to new versions!

My Firefox doesn't seem to want to load the EoC zone tools so I decided to write one myself and share with anyone that wanted to use it.



Here is what a cloned zone would look like in George's NPC editor it adds the version to the "new" NPCS.





The doors that are cloned KEEP the same DOORID so any script you may use to open doors by DOORID in certain zones will work across all the versions!

Here is what that looks like...




The script allows you to choose CLONE NPCS OR DOORS... or BOTH!
Cloning NPCS also places them in newly cloned spawngroups and correct spawn2 locations as well.

Here is my VERSION 1 of Gukbottom.. you can see the level 74 Ghoul Executioner and that the doors are correctly in place!




Lastly the script prints out a BACKUP.TXT file!
Inside this file it has a 100% reversal of that zone version you made.





Very simple to use if you have perl DBI !


1. Edit the database information inside the script
2. Edit the zone / version you want to copy from and what version to copy TO!
3. MIN NPC -- lowest ID it will copy from I have this at 1000 because I don't like it copying my "CUSTOM" npcs where their NPCID must remain low. Like my NPC that handles Weapon graphics.
4. COPYDOORS / COPYNPCS -- put both to 0 and script does nothing.. turn either to 1 and it copies JUST THAT!

example... Copydoors 1 and COPYNPCS 0 would only copy doors and ignore all NPC DATA. So you could copy a zones doors and just make your own custom NPCS for a new version!


I hope that is enough explanation, but if you have questions or concerns just PM me or reply here and I will help ya when I can





Here is the script!


HOW TO RUN A PERL SCRIPT FROM CMD PROMPT!

Open command prompt ... and change directory to where the file is located..

Code:
cd c:\directorytogoto
Once you are in the directory just type...


perl FILENAME.pl


AND BAM you are done!






Code:
use Getopt::Std;
my $BACKUP = "BACKUP.txt"; #default
open(DUMB, ">>$BACKUP") or die "Unable to find backup file!: $BACKUP\n";


	sub DBI_CONNECT {
		use DBI;
		$database = "peq_new";
		$host = "localhost";
		$username = "USER";
		$password = "PASS";
		$dbh = DBI->connect("DBI:mysql:database=$database;host=$host", "$username", "$password", {RaiseError => 1});
		return $dbh;
	}
	

	#DEFINE
	$zone = "gukbottom";		#Zone to copy from
	$version = 0;      	    	#Version to copy from
	$versionset = 2;			#Version to copy to
	$minNPC = 1000;				#Min NPC ID to copy from zone
	$COPYDOORS = 1;				#Set to 1 to copy doors from the copy version
	$COPYNPCS = 1;				#COPY ZONE set to 1.. turn to 0 if you only want the doors!
	#END DEFINE
	
	$space = "_";
	
	my $TIME = localtime;
	my $line = "##ZONE = $zone - VERSION = $versionset -- $TIME \n";
	print DUMB $line; #write to the file
	
	$dbh       = DBI_CONNECT();
	
	
if($COPYNPCS == 1)
{	
	
	$query = "SELECT distinct se.spawngroupID, se.npcID, se.chance FROM spawnentry se
				INNER JOIN spawn2 s ON se.spawngroupID = s.spawngroupID
				INNER JOIN npc_types n ON se.npcID = n.id
				INNER JOIN spawngroup sg ON sg.id = se.spawngroupID
				WHERE s.zone = '$zone' and s.version = $version and se.npcID >= $minNPC ORDER by se.spawngroupID ASC" ;
	$sth = $dbh->prepare($query);
	$sth->execute();
	
	$n = 0;
	
	
	while (@row = $sth->fetchrow_array())
	{
		$n++;
		$SpawnEntries[$n] = [@row];
		#print "@row \n";
		#print "$n -- $SpawnEntries[$n][0] -- $SpawnEntries[$n][1] -- $SpawnEntries[$n][2] \n";
		#$lastone = $row[0];
		
		
	}
	print "$n \n";
	#return;
	$query = "SELECT distinct n.id FROM spawnentry se
				INNER JOIN spawn2 s ON se.spawngroupID = s.spawngroupID
				INNER JOIN npc_types n ON se.npcID = n.id
				INNER JOIN spawngroup sg ON sg.id = se.spawngroupID
				WHERE s.zone = '$zone' and s.version = $version and n.id >= $minNPC ORDER by n.id ASC";
	$sth = $dbh->prepare($query);
	$sth->execute();
	
	while ($id = $sth->fetchrow_array())
	{
		
		push(@oldnpcs, $id);
	
	}

#	print "\n $oldnpcs[5] \n";
	
	foreach $old_npc (@oldnpcs)
	{
		$query = "SELECT max(id) FROM npc_types";
		$sth = $dbh->prepare($query);
		$sth->execute();
		
		$maxid = $sth->fetchrow_array()+1;
		
		push(@newnpcs, $maxid);
		
		
		#INSERT NEW NPC
		$dbh->do("INSERT INTO `npc_types` 
				(`id`,`name`,`lastname`,`level`,`race`,`class`,`bodytype`,`hp`,`mana`,`gender`,`texture`,`helmtexture`,`size`,`hp_regen_rate`,`mana_regen_rate`,`loottable_id`,`merchant_id`,`alt_currency_id`,
`npc_spells_id`,`npc_faction_id`,`adventure_template_id`,`trap_template`,`mindmg`,`maxdmg`,`attack_count`,`special_abilities`,`aggroradius`,`face`,`luclin_hairstyle`,`luclin_haircolor`,`luclin_eyecolor`,`luclin_eyecolor2`,
`luclin_beardcolor`,`luclin_beard`,`drakkin_heritage`,`drakkin_tattoo`,`drakkin_details`,`armortint_id`,`armortint_red`,`armortint_green`,`armortint_blue`,`d_meele_texture1`,`d_meele_texture2`,`prim_melee_type`,`sec_melee_type`,
`runspeed`,`MR`,`CR`,`DR`,`FR`,`PR`,`Corrup`,`see_invis`,`see_invis_undead`,`qglobal`,`AC`,`npc_aggro`,`spawn_limit`,`attack_speed`,`findable`,`STR`,`STA`,`DEX`,`AGI`,`_INT`,`WIS`,`CHA`,`see_hide`,`see_improved_hide`,
`trackable`,`isbot`,`exclude`,`ATK`,`Accuracy`,`slow_mitigation`,`version`,`maxlevel`,`scalerate`,`private_corpse`,`unique_spawn_by_name`,`underwater`,`isquest`,`emoteid`,`spellscale`,`healscale`) 
				SELECT distinct $maxid, n.`name`, n.`lastname`, n.`level`, n.`race`, n.`class`, n.`bodytype`, n.`hp`, n.`mana`, n.`gender`, n.`texture`, n.`helmtexture`, n.`size`, n.`hp_regen_rate`, n.`mana_regen_rate`, 
n.`loottable_id`, n.`merchant_id`, n.`alt_currency_id`, n.`npc_spells_id`, n.`npc_faction_id`, n.`adventure_template_id`, n.`trap_template`, n.`mindmg`, n.`maxdmg`, n.`attack_count`, n.`special_abilities`, n.`aggroradius`, n.`face`, 
n.`luclin_hairstyle`, n.`luclin_haircolor`, n.`luclin_eyecolor`, n.`luclin_eyecolor2`, n.`luclin_beardcolor`, n.`luclin_beard`, n.`drakkin_heritage`, n.`drakkin_tattoo`, n.`drakkin_details`, n.`armortint_id`, n.`armortint_red`, n.`armortint_green`, 
n.`armortint_blue`, n.`d_meele_texture1`, n.`d_meele_texture2`, n.`prim_melee_type`, n.`sec_melee_type`, n.`runspeed`, n.`MR`, n.`CR`, n.`DR`, n.`FR`, n.`PR`, n.`Corrup`, n.`see_invis`, n.`see_invis_undead`, n.`qglobal`, n.`AC`, 
n.`npc_aggro`, n.`spawn_limit`, n.`attack_speed`, n.`findable`, n.`STR`, n.`STA`, n.`DEX`, n.`AGI`, n.`_INT`, n.`WIS`, n.`CHA`, n.`see_hide`, n.`see_improved_hide`, n.`trackable`, n.`isbot`, n.`exclude`, n.`ATK`, n.`Accuracy`, 
n.`slow_mitigation`, $versionset, n.`maxlevel`, n.`scalerate`, n.`private_corpse`, n.`unique_spawn_by_name`, n.`underwater`, n.`isquest`, n.`emoteid`, n.`spellscale`, n.`healscale`
				FROM npc_types n WHERE n.id = $old_npc");
		my $line = "DELETE FROM `npc_types` WHERE `id` = $maxid;\n";
		print DUMB $line; #write to the file
	}
	
	$sth       = $dbh->prepare("SELECT  count(distinct s.spawngroupid) from spawn2 s 
								INNER JOIN spawnentry se ON se.spawngroupID = s.spawngroupID
								WHERE s.version = $version and s.zone = '$zone' and se.npcID >= $minNPC");
	
	$sth->execute();
	
	$spawncount = $sth->fetchrow_array();
	
	
	#print "$spawncount \n";
	
	
	$sth = $dbh->prepare("SELECT distinct sg.* FROM spawnentry se
				INNER JOIN spawn2 s ON se.spawngroupID = s.spawngroupID
				INNER JOIN npc_types n ON se.npcID = n.id
				INNER JOIN spawngroup sg ON sg.id = se.spawngroupID
				WHERE s.zone = '$zone' and s.version = $version and se.npcID >= $minNPC ORDER by sg.ID ASC
				");
	$sth->execute();
	
	
	$B = 0;
	while (@SG = $sth->fetchrow_array())
	{
		$B++;
		$SpawnGroups[$B] = [@SG];
		#print "@SG \n";
	}
	
	
	
	for $M (1 .. $spawncount)
	{
		$sth       = $dbh->prepare("SELECT MAX(id) FROM spawngroup");
		$sth->execute();
		$SGID = $sth->fetchrow_array() + 1;
		$dbh->do("INSERT INTO `spawngroup` 
					(`id`, `name`, `spawn_limit`, `dist`, `max_x`, `min_x`, `max_y`, `min_y`, `delay`, `despawn`, `despawn_timer`) 
					VALUES ($SGID, '$zone$space$SGID', $SpawnGroups[$M][2], $SpawnGroups[$M][3], $SpawnGroups[$M][4], $SpawnGroups[$M][5], $SpawnGroups[$M][6], $SpawnGroups[$M][7], $SpawnGroups[$M][8], $SpawnGroups[$M][9], $SpawnGroups[$M][10])");
		my $line = "DELETE FROM `spawngroup` WHERE `id` = $SGID;\n";
		print DUMB $line; #write to the file
		push(@SPAWNGROUPS, $SGID);
		#print "$M";
	}
	
	$F = 0;
	for $SE (1 .. $n)
	{
		
		if($LastSpawnG == $SpawnEntries[$SE][0])
		{
			$F--;
		}
		
		$SG = $SPAWNGROUPS[$F];
		$SPOTS = FINDSPOT($SpawnEntries[$SE][1]);
		$npcID = $newnpcs[$SPOTS];
		$chance = $SpawnEntries[$SE][2];
		#print "$SE -- $SG ... $npcID ... $chance \n";
		$dbh->do("INSERT INTO `spawnentry` 
					(`spawngroupID`, `npcID`, `chance`) 
					VALUES ($SG, $npcID, $chance)");
		my $line = "DELETE FROM `spawnentry` WHERE `spawngroupID` = $SG and `npcID` = $npcID;\n";
		print DUMB $line; #write to the file
		$LastSpawnG = $SpawnEntries[$SE][0];
		$F++;
		
		#print "$SG $npcID $chance \n";
	}
	
	
	
	
	$sth       = $dbh->prepare("SELECT distinct s.spawngroupid, s.x, s.y, s.z, s.heading, s.respawntime, s.variance, s.pathgrid, s._condition, s.cond_value, s.enabled, s.animation FROM spawn2 s 
								INNER JOIN spawnentry se ON se.spawngroupID = s.spawngroupID
								WHERE zone = '$zone' AND version = $version and se.npcID >= $minNPC ORDER by s.spawngroupid ASC");
		$sth->execute();
		$g = 0;
		
		while ( ($spawnGID, $x, $y, $z, $heading, $respawntime, $variance, $pathgrid, $condition, $convalue, $enabled, $animation) = $sth->fetchrow_array())
		{
			if($spawnGID eq $spawnlast)
			{
				$g--;
			}
			#print "$g -- $SPAWNGROUPS[$g] -- $x, $y, $z \n";
			$dbh->do("INSERT INTO `spawn2` 
					(`id`, `spawngroupID`, `zone`, `version`, `x`, `y`, `z`, `heading`, `respawntime`, `variance`, `pathgrid`, `_condition`, `cond_value`, `enabled`, `animation`) 
					VALUES ('', $SPAWNGROUPS[$g], '$zone', $versionset, $x, $y, $z, $heading, $respawntime, $variance, $pathgrid, $condition, $convalue, $enabled, $animation)");
		$spawnlast = $spawnGID;
		$g++;
			$sth
			
		}
		my $line = "DELETE FROM `spawn2` WHERE `version` = $versionset and `zone` = '$zone';\n";
		print DUMB $line; #write to the file
		
		$sth->finish;
		
}
		if($COPYDOORS == 1)
		{
			$dbh->do("INSERT INTO `doors`
						(`id`, `doorid`, `zone`, `version`, `name`, `pos_y`, `pos_x`, `pos_z`, `heading`, `opentype`, `guild`, `lockpick`, `keyitem`, `nokeyring`, `triggerdoor`, `triggertype`, `doorisopen`, `door_param`, `dest_zone`, `dest_instance`, `dest_x`, `dest_y`, `dest_z`, `dest_heading`, `invert_state`, `incline`, `size`, `buffer`, `client_version_mask`, `is_ldon_door`) 
						SELECT '', `doorid`, `zone`, $versionset, `name`, `pos_y`, `pos_x`, `pos_z`, `heading`, `opentype`, `guild`, `lockpick`, `keyitem`, `nokeyring`, `triggerdoor`, `triggertype`, `doorisopen`, `door_param`, `dest_zone`, `dest_instance`, `dest_x`, `dest_y`, `dest_z`, `dest_heading`, `invert_state`, `incline`, `size`, `buffer`, `client_version_mask`, `is_ldon_door`
						FROM `doors` WHERE zone = '$zone' and version = $version");
						
						my $line = "\n ### ADDED DOORS !! \n\n";
						print DUMB $line; #write to the file
						my $line = "DELETE FROM doors WHERE zone = '$zone' and version = $versionset;\n\n";
						print DUMB $line; #write to the file
		}
		
		
		
		my $line = "\n ### END OF -- ZONE = $zone - VERSION = $versionset -- $TIME\n\n";
		print DUMB $line; #write to the file
	print "FINISHED! Copying $zone to Version $versionset!";
	
	
	close (DUMB); #since we're done with it...
	
	
	sub FINDSPOT 
	{
		for $i (0 .. $#oldnpcs)
		{
			#print "$oldnpcs[$i] \n";
			if($oldnpcs[$i] == $_[0])
			{
				return $i;
			}
		}
	}
	
	
	
	
	$dbh->disconnect;

Last edited by Akkadius; 11-02-2013 at 12:03 AM.. Reason: Wide ass page
Reply With Quote
  #2  
Old 11-01-2013, 09:09 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Doing this is duplication of work unecessarily that already works 100%.

All you had to do is reply to the original post that was made when you first made the claim.

My Firefox works just fine, I test on Chrome and Firefox (IE Can go die in a fire) - if yours doesn't work than you either need to update or stop blocking javascript because EoC uses it for performance and simplicity of the interface. Posted pictures below to prove I had tested this for you.

If you wanted to make one yourself just for the sake of doing it then that is your call. I've already gone through the pain of making sure that the schematic imports go smoothly given certain scenarios exist that you may not have been anticipating originally.

I may come off like a dick - probably because I am and I'm tired as shit from moving, but either way here is the details:

EOC Does the following:
  • Cloning Doors
  • Cloning Objects
  • Cloning NPC's into new or existing NPC types data
  • Cloning new or existing grids
  • Importing from a completely different database
  • All of these from one version to another
  • Does full zone copies within seconds
  • Full deletion of versions





Here's the database calls that copy all of the schemas: (AJAX)

The below code does not consider injection because there is no database to inject but your own.

Code:
	if($_GET['ZoneID'] && $_GET['ImportSelector'] == 1){
	
		/* 2nd DB Connection Stuff */
		$Query = "SELECT * FROM `zone` WHERE `zoneidnumber` = ". $_GET['ZoneID'] . " LIMIT 1";
		$QueryResult = mysql_query($Query, $db2);
		while($row = mysql_fetch_array($QueryResult)){
			echo '<br><br><h1><FONT COLOR="YELLOW">' . $row['long_name'] . '</FONT></h1>';
			$ZoneSN = $row['short_name'];
		}
		echo '<br>';
		$Query = "SELECT version, COUNT(*) AS total FROM `spawn2` WHERE `zone` = '". $ZoneSN . "' GROUP by `version`";
		$QueryResult = mysql_query($Query, $db2);
		while($row = mysql_fetch_array($QueryResult)){
			echo '<h4> Version: ' . $row['version'] . ' Spawn Count: ' . $row['total'] . '</h4>';
		}
		echo '<br><h2>Import Options</h2>';
		$Query = "SELECT version, COUNT(*) AS total FROM `spawn2` WHERE `zone`  = '". $ZoneSN . "' GROUP by `version`";
		$QueryResult = mysql_query($Query, $db2);
		echo '<table>';
		echo '<tr><td>Source Version (2nd DB)</td><td><select id="VersionSourceR">'; 
		while($row = mysql_fetch_array($QueryResult)){
			echo '<option value="'. $row['version'] . '">Version '. $row['version'] . ' (' . $row['total'] . ')</option>';
		}
		echo '</select></td><td><a href="javascript:;" onclick="ListZoneRemote('. $_GET['ZoneID'] .', document.getElementById(\'VersionSourceR\').value)">List this zone</a></td></tr>';
		
		
		/* 1st DB Connection Stuff */
		$Query = "SELECT version, COUNT(*) AS total FROM `spawn2` WHERE `zone`  = '". $ZoneSN . "' GROUP by `version`";
		$QueryResult = mysql_query($Query, $db);
		while($row = mysql_fetch_array($QueryResult)){
			echo '<option value="'. $row['version'] . '">Version '. $row['version'] . ' (' . $row['total'] . ')</option>';
			$VersionData[$row['version']] = $row['total'];
		}
		echo '<tr><td>Destination Version (Primary DB)</td><td><select id="VersionDestD">';
		for($i = 0; $i <= 100; $i++){
			if($VersionData[$i]){ $VVersion = $VersionData[$i]; } else { $VVersion = 0; }
			echo '<option value="' . $i . '">Version '. $i . ' (' . $VVersion . ')</option>';
		}
		echo '</select></td><td><a href="javascript:;" onclick="ListZoneLocal('. $_GET['ZoneID'] .', document.getElementById(\'VersionDestD\').value)">List this zone</a></td>';
		echo '<tr><td>Import Doors? </td><td><select id="importdoors"><option value="0">No</option><option value="1">Yes</option></select></td></tr>';
		echo '<tr><td>Import Objects? </td><td><select id="importobjects"><option value="0">No</option><option value="1">Yes</option></select></td></tr>';
		echo '</tr></table>';
		echo '<br><input type="button" value="Import!" class="btnIconLeft mr10" onclick="CopyZoneVersionExtToLoc('. $_GET['ZoneID'] . ', document.getElementById(\'VersionSourceR\').value, document.getElementById(\'VersionDestD\').value, document.getElementById(\'importdoors\').value, document.getElementById(\'importobjects\').value)">';
		echo '<div id="CopyZoneVersionExtToLoc"></div>';
	}
	if($_GET['ZoneID'] && isset($_GET['Version']) && $_GET['ListZone']){
		$Query = "SELECT * FROM `zone` WHERE `zoneidnumber` = ". $_GET['ZoneID'] . " LIMIT 1";
		$QueryResult = mysql_query($Query, $db2);
		if($_GET['Version']){ $Version = $_GET['Version']; } else{ $Version = 0; }
		while($row = mysql_fetch_array($QueryResult)){ $ZoneSN = $row['short_name']; }
		$Query = "SELECT
			npc_types.id,
			npc_types.name,
			npc_types.lastname,
			npc_types.level,
			npc_types.race,
			spawnentry.chance,
			spawn2.zone,
			spawn2.`version`,
			spawn2.pathgrid
			FROM
			npc_types
			Inner Join spawnentry ON npc_types.id = spawnentry.npcID
			Inner Join spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID
			WHERE spawn2.zone = '". $ZoneSN . "' AND spawn2.version = ". $Version . "
			ORDER BY npc_types.id";
			#echo $Query;
		echo '<div class="widget">
				<div class="head opened" id="opened"><h5>\'' . $ZoneSN . '\' 2nd DB (Remote)</h5></div>
				<div class="body">';
			AutoDataTableZone($Query, $db2);
	}
	if($_GET['ZoneID'] && isset($_GET['Version']) && $_GET['ListZoneLocal']){
		$Query = "SELECT * FROM `zone` WHERE `zoneidnumber` = ". $_GET['ZoneID'] . " LIMIT 1";
		$QueryResult = mysql_query($Query, $db);
		while($row = mysql_fetch_array($QueryResult)){ $ZoneSN = $row['short_name']; }
		$Query = "SELECT
			npc_types.id,
			npc_types.name,
			npc_types.lastname,
			npc_types.level,
			npc_types.race,
			spawnentry.chance,
			spawn2.zone,
			spawn2.`version`,
			spawn2.pathgrid
			FROM
			npc_types
			Inner Join spawnentry ON npc_types.id = spawnentry.npcID
			Inner Join spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID
			WHERE spawn2.zone = '". $ZoneSN . "' AND spawn2.version = ". $_GET['Version'] . "
			ORDER BY npc_types.id";
		echo '<div class="widget">
				<div class="head opened" id="opened2"><h5>\'' . $ZoneSN . '\' 1st DB (Primary)</h5></div>
				<div class="body">';
			AutoDataTableZone($Query, $db);
	}
	if($_GET['ZoneID'] && $_GET['CopyTool'] == "importzone"){
		$Query = "SELECT * FROM `zone` WHERE `zoneidnumber` = ". $_GET['ZoneID'] . " LIMIT 1";
		$QueryResult = mysql_query($Query, $db);
		while($row = mysql_fetch_array($QueryResult)){ $ZoneSN = $row['short_name']; }
			echo '<br><h4>Zone Importer</h4><br>
			<!-- Login form area -->
				<div class="loginWrapper">
					<center><img src="../images/eqemu.png" alt="" /><br><img src="images/eoc-fd.png" alt=""/></center>
					<div class="loginPanel">
						<div class="head"><h5 class="iUser">Connect to a 2nd Database...</h5></div>
						<form action="zonetools.php?ImportMode=1" id="valid" class="mainForm" method="post">
							<fieldset>
								<div class="loginRow">
									<label for="req1">IP:Port</label>
									<div class="loginInput"><input type="text" id="dbservipport2" name="dbservipport2" value="'. $_COOKIE['dbip2'] . '" class="validate[required]" /></div>
									<div class="fix"></div>
								</div>
								
								<div class="loginRow">
									<label for="req2">DB Name</label>
									<div class="loginInput"><input type="text" id="dbname2" name="dbname2" value="'. $_COOKIE['dbname2'] . '" class="validate[required]" /></div>
									<div class="fix"></div>
								</div>
								
								<div class="loginRow">
									<label for="req2">DB User</label>
									<div class="loginInput"><input type="text" id="dbuser2" name="dbuser2" value="'. $_COOKIE['dbuser2'] . '" class="validate[required]"  /></div>
									<div class="fix"></div>
								</div>
								
								<div class="loginRow">
									<label for="req2">DB Pass</label>
									<div class="loginInput"><input type="password" id="dbpass2" name="dbpass2" value="'. $_COOKIE['dbpass2'] . '" class="validate[required]" /></div>
									<div class="fix"></div>
								</div>
								<input type="button" value="Check Connection" class="basicBtn submitForm" onclick="TestDBAuth(document.getElementById(\'dbservipport2\').value, document.getElementById(\'dbname2\').value, document.getElementById(\'dbuser2\').value, document.getElementById(\'dbpass2\').value)" />
								<div id="DBAUTH"></div>
							</fieldset>
						</form>
					</div>
				</div>';
	}	
	if($_GET['ZoneID'] && $_GET['CopyTool'] == "copyzone"){
		$Query = "SELECT * FROM `zone` WHERE `zoneidnumber` = ". $_GET['ZoneID'] . " LIMIT 1";
		$QueryResult = mysql_query($Query, $db);
		while($row = mysql_fetch_array($QueryResult)){ $ZoneSN = $row['short_name']; }
	
		echo '<br><h4>Copy Zone Version</h4><br>';
		$Query = "SELECT version, COUNT(*) AS total FROM `spawn2` WHERE `zone`  = '". $ZoneSN . "' GROUP by `version`";
		$QueryResult = mysql_query($Query, $db);
		echo '<table>';
		echo '<tr><td>Source Version</td><td><select id="VersionSource">'; 
		while($row = mysql_fetch_array($QueryResult)){
			echo '<option value="'. $row['version'] . '">Version '. $row['version'] . ' (' . $row['total'] . ')</option>';
			$VersionData[$row['version']] = $row['total'];
		}
		echo '</select></td></tr>';
		
		echo '<tr><td>Destination Version</td><td><select id="VersionDest">';
		for($i = 0; $i <= 100; $i++){
			if($VersionData[$i]){ $VVersion = $VersionData[$i]; } else { $VVersion = 0; }
			echo '<option value="' . $i . '">Version '. $i . ' (' . $VVersion . ')</option>';
		}
		echo '</select></td></tr></table>';
		echo '<br><h4>Options</h4>';
		echo 'NPC Data: <select id="NPCDATA" onchange="ToggleOtherOptions(this.value)"><option value="existing">Use Existing Data</option><option value="copy">Copy NPC\'s into New Data</option></select><br>'; 
		echo '<div id="NPCGRIDS"></div>';
		echo '<br><input type="button" value="Copy!" class="btnIconLeft mr10" onclick="CopyZoneVersion('. $_GET['ZoneID'] . ', document.getElementById(\'VersionSource\').value, document.getElementById(\'VersionDest\').value, document.getElementById(\'NPCDATA\').value, document.getElementById(\'NPCGRIDS\').value)">';
		echo '<br><div id="ZoneToolCopyZoneSelectOP2"></div>';
	}
	if($_GET['NPCGRIDSSHOW'] == "copy"){
		echo 'NPC Grids: <select id="NPCGRIDS"><option value="existing">Use Existing Data</option><option value="copy">Copy Grids into New ID\'s</option></select><br>'; 
	}
	if($_GET['ZoneID'] && $_GET['ImportTool'] && isset($_GET['Source']) && isset($_GET['Dest'])){
		$Query = "SELECT * FROM `zone` WHERE `zoneidnumber` = ". $_GET['ZoneID'] . " LIMIT 1";
		$QueryResult = mysql_query($Query, $db2);
		while($row = mysql_fetch_array($QueryResult)){ $ZoneSN = $row['short_name']; }
		#echo $db1 . ' ' . $db2  . '<br>'; 	
		/* Cache the Data for after reference */
		#echo var_dump($_GET);
		#return;
		
		if($_GET['Doors'] == 1){
			echo 'Doors is getting dumped yo<br>';
			/* Doors */
			$result = mysql_query('SELECT MAX(id) + 1 AS id FROM `doors`', $db);
			$row = mysql_fetch_assoc($result);
			$ID = $row['id'];
			$result = mysql_query('SELECT MAX(doorid) + 1 AS id FROM `doors` WHERE `zone` = "' . $ZoneSN .'" AND (version = ' . $_GET['Source'] . ' or version = -1);', $db);
			$row = mysql_fetch_assoc($result);
			$DoorID = $row['doorid'];
			
			$Query = "SELECT * FROM `doors` WHERE `zone` = '" . $ZoneSN . "' AND (version = " . $_GET['Source'] . " OR version = -1)";
			$QueryResult = mysql_query($Query, $db2);
			while ($row = mysql_fetch_array($QueryResult)) { 
				// Do Stuff here
				$InsertQuery = "INSERT INTO `doors` (";
				$InsertQuery2 = "";
				$n = 0; $f = 0;
				foreach ($row as $k=>$v){
					if($n > 0 && !is_numeric($k)){
						$type  = mysql_field_type($QueryResult, $f);
						$name  = mysql_field_name($QueryResult, $f);
						#if($type == "int" && $v == ""){ echo 'FOUND INTEGER WITH NO VALUE (' . $f . ': ' . $name . ' - ' . $k .') k ' . $k . ' v '. $v . '<br>'; }
						if($type == "int" && $v == ""){ $v = 0; }
						$InsertQuery .= $k . ", ";
						if($k == "id"){ $InsertQuery2 .= "'" . $ID . "', "; }
						else if($k == "version"){ $InsertQuery2 .= "'" . $_GET['Dest'] . "', "; }
						else if($k == "doorid"){ $InsertQuery2 .= "'" . $DoorID . "', "; }
						else{ $InsertQuery2 .= "'" . $v . "', "; }
						$f++;
					}
					$n++;
				}
				#$NewReferenceList[$row['id']] = $ID;
				$ID++;
				$DoorID++;
				$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
				mysql_query($Query, $db);
				#echo $Query . '<br>';
			}
		}
		
		if($_GET['Objects'] == 1){
			echo 'Objects is getting dumped yo<br>';
			/* Objects */
			$result = mysql_query('SELECT MAX(id) + 1 AS id FROM `object`', $db);
			$row = mysql_fetch_assoc($result);
			$ID = $row['id'];
			$Query = "SELECT * FROM `object` WHERE `zoneid` = " . $_GET['ZoneID'] . " AND (version = " . $_GET['Source'] . " OR version = -1)";
			$QueryResult = mysql_query($Query, $db2);
			while ($row = mysql_fetch_array($QueryResult)) { 
				// Do Stuff here
				$InsertQuery = "INSERT INTO `object` (";
				$InsertQuery2 = "";
				$n = 0; $f = 0;
				foreach ($row as $k=>$v){
					if($n > 0 && !is_numeric($k)){
						$type  = mysql_field_type($QueryResult, $f);
						$name  = mysql_field_name($QueryResult, $f);
						#if($type == "int" && $v == ""){ echo 'FOUND INTEGER WITH NO VALUE (' . $f . ': ' . $name . ' - ' . $k .') k ' . $k . ' v '. $v . '<br>'; }
						if($type == "int" && $v == ""){ $v = 0; }
						$InsertQuery .= $k . ", ";
						if($k == "id"){ $InsertQuery2 .= "'" . $ID . "', "; }
						else if($k == "version"){ $InsertQuery2 .= "'" . $_GET['Dest'] . "', "; }
						else{ $InsertQuery2 .= "'" . $v . "', "; }
						$f++;
					}
					$n++;
				}
				$ID++;
				$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
				mysql_query($Query, $db);
				#echo $Query . '<br>';
			}
		}
		
		/* Grids */ 
		$result = mysql_query('SELECT MAX(id) + 1 AS id FROM `grid` WHERE `zoneid` = "'. $_GET['ZoneID'] . '"', $db);
		$row = mysql_fetch_assoc($result);
		$ID = $row['id'];

		$Query = "SELECT * FROM `grid` WHERE `zoneid` = '". $_GET['ZoneID'] . "'";
		$QueryResult = mysql_query($Query, $db2);
		while ($row = mysql_fetch_array($QueryResult)) { 
			$n = 0;
			$InsertQuery = "INSERT INTO `grid` (";
			$InsertQuery2 = "";
			foreach ($row as $k=>$v){
				if($n > 0 && !is_numeric($k)){
					$InsertQuery .= $k . ", ";
					if($k == "id"){ $InsertQuery2 .= "'" . $ID . "', "; }
					else{ $InsertQuery2 .= "'" . $v . "', "; }
				}
				$n++;
			}
			$GridList[$row['id']] = $ID;
			$ID++;
			$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
			mysql_query($Query, $db);
			#echo $Query . '<br>';
		}
		
		$Query = "SELECT * FROM `grid_entries` WHERE `zoneid` = '". $_GET['ZoneID'] . "'";
		$QueryResult = mysql_query($Query, $db2);
		while ($row = mysql_fetch_array($QueryResult)) { 
			$n = 0;
			$InsertQuery = "INSERT INTO `grid_entries` (";
			$InsertQuery2 = "";
			foreach ($row as $k=>$v){
				if($n > 0 && !is_numeric($k)){
					$InsertQuery .= $k . ", ";
					if($k == "gridid"){ $InsertQuery2 .= "'" . $GridList[$row['gridid']] . "', "; }
					else{ $InsertQuery2 .= "'" . $v . "', "; }
				}
				$n++;
			}
			$GridList[$row['id']] = $ID;
			$ID++;
			$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
			mysql_query($Query, $db);
			#echo $Query . '<br>';
		}
		
		/* npc_types */
		$result = mysql_query('SELECT MAX(id) + 1 AS id FROM `npc_types`', $db);
		$row = mysql_fetch_assoc($result);
		$ID = $row['id'];
		$Query = "SELECT
			npc_types.*
			FROM
			spawnentry
			Inner Join spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID
			Inner Join npc_types ON npc_types.id = spawnentry.npcID WHERE `zone` = '" . $ZoneSN . "'  AND spawn2.version = " . $_GET['Source'] . " GROUP by npc_types.id";
		$QueryResult = mysql_query($Query, $db2);
		while ($row = mysql_fetch_array($QueryResult)) { 
			// Do Stuff here
			$InsertQuery = "INSERT INTO `npc_types` (";
			$InsertQuery2 = "";
			$n = 0; $f = 0;
			#$fields = mysql_num_fields($QueryResult);
			#for ($i=0; $i < $fields; $i++) {
			#	$type  = mysql_field_type($QueryResult, $i);
			#	$name  = mysql_field_name($QueryResult, $i);
			#	echo $i . ' ' . $name . ' <br>';
			#}
			foreach ($row as $k=>$v){
				if($n > 0 && !is_numeric($k)){
					$type  = mysql_field_type($QueryResult, $f);
					$name  = mysql_field_name($QueryResult, $f);
					#if($type == "int" && $v == ""){ echo 'FOUND INTEGER WITH NO VALUE (' . $f . ': ' . $name . ' - ' . $k .') k ' . $k . ' v '. $v . '<br>'; }
					if($type == "int" && $v == ""){ $v = 0; }
					$InsertQuery .= $k . ", ";
					if($k == "id"){ $InsertQuery2 .= "'" . $ID . "', "; }
					else{ $InsertQuery2 .= "'" . $v . "', "; }
					$f++;
				}
				$n++;
			}
			$NewReferenceList[$row['id']] = $ID;
			$ID++;
			$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
			mysql_query($Query, $db);
			#echo $Query . '<br>';
		}
		
		/* spawngroup */
		$result = mysql_query('SELECT MAX(id) + 1 AS id FROM `spawngroup`', $db);
		$row = mysql_fetch_assoc($result);
		$ID = $row['id'];
		$Query = "SELECT
			spawngroup.*
			FROM
			spawn2
			Inner Join spawngroup ON spawngroup.id = spawn2.spawngroupID
			WHERE spawn2.zone = '" . $ZoneSN . "' AND spawn2.version = " . $_GET['Source'] . "";
		$QueryResult = mysql_query($Query, $db2);
		while ($row = mysql_fetch_array($QueryResult)) {
			$n = 0;
			$InsertQuery = "INSERT INTO `spawngroup` (";
			$InsertQuery2 = "";
			foreach ($row as $k=>$v){
				if($n > 0 && !is_numeric($k)){
					$InsertQuery .= $k . ", ";
					if($k == "id"){ $InsertQuery2 .= "'" . $ID . "', "; }
					else if($k == "name"){ $InsertQuery2 .= "'" . $ZoneSN . '_' . $ID . "', "; }
					else{ $InsertQuery2 .= "'" . $v . "', "; }
				}
				$n++;
			}
			$SpawnGroup[$row['id']] = $ID;
			$ID++;
			$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
			##echo $Query . '<br>';
			mysql_query($Query, $db);
			#echo $Query . '<br>';
		}
		
		/* spawnentry */	
		$Query = "SELECT
			spawnentry.spawngroupID,
			spawnentry.npcID,
			spawnentry.chance
			FROM
			spawnentry
			Inner Join spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID
			WHERE spawn2.zone = '" . $ZoneSN . "' AND spawn2.version = " . $_GET['Source'] . "";
		$QueryResult = mysql_query($Query, $db2);
		while ($row = mysql_fetch_array($QueryResult)) { 
			$n = 0;
			$InsertQuery = "INSERT INTO `spawnentry` (";
			$InsertQuery2 = "";
			$NValid = 0;
			foreach ($row as $k=>$v){
				if($n > 0 && !is_numeric($k)){
					if($row['npcID'] != 0){
						$InsertQuery .= $k . ", ";
						if($k == "spawngroupID"){ $InsertQuery2 .= "'" . $SpawnGroup[$row['spawngroupID']] . "', "; }
						else if($k == "npcID"){ $InsertQuery2 .= "'" . $NewReferenceList[$row['npcID']] . "', "; }
						else{ $InsertQuery2 .= "'" . $v . "', "; }
					} else{ $NValid = 1; }
				}
				$n++;
			}
			$NewSpawnGroupReferenceList[$row['spawngroupID']] = $ID;
			$ID++;
			if($NValid != 1){
				$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
				mysql_query($Query, $db);
				#echo $NewSpawnGroupReferenceList[$row['spawngroupID']] . ' ' . $row['spawngroupID'] . '<br>';
				#echo $Query . '<br>';
			}
		}
		
		/* spawn2 */
		$result = mysql_query('SELECT MAX(id) + 1 AS id FROM `spawn2`', $db);
		$row = mysql_fetch_assoc($result);
		$ID = $row['id'];
		
		$Query = "SELECT * FROM `spawn2` WHERE `zone` = '" . $ZoneSN . "' AND spawn2.version = " . $_GET['Source'] . "";
		$QueryResult = mysql_query($Query, $db2);
		while ($row = mysql_fetch_array($QueryResult)) {
			if($NewSpawnGroupReferenceList[$row['spawngroupID']]){
				$n = 0;
				$InsertQuery = "INSERT INTO `spawn2` (";
				$InsertQuery2 = "";
				foreach ($row as $k=>$v){
					if($n > 0 && !is_numeric($k)){
						$InsertQuery .= $k . ", ";
						if($GridList[$row['pathgrid']]){ $GRID = $GridList[$row['pathgrid']]; } else{ $GRID = 0; } 
						if($k == "id"){ $InsertQuery2 .= "'" . $ID . "', "; }
						else if($k == "spawngroupID"){ $InsertQuery2 .= "'" . $SpawnGroup[$row['spawngroupID']] . "', "; }
						else if($k == "version"){ $InsertQuery2 .= "'" . $_GET['Dest'] . "', "; }
						else if($k == "pathgrid" && $_GET['NPCGRIDS']){ $InsertQuery2 .= "'" . $GRID . "', "; }
						else{ $InsertQuery2 .= "'" . $v . "', "; }
					}
					$n++;
				}
				$NewReferenceList[$row['id']] = $ID;
				$ID++;
				$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
				##echo $Query . '<br>';
				mysql_query($Query, $db);
				#echo $Query . '<br>';
			}
		}
		echo '<br>Copy should be successful! Refresh your zone selection<br>';
	}
	if($_GET['ZoneID'] && $_GET['CopyToolSubmit']){
		$Query = "SELECT * FROM `zone` WHERE `zoneidnumber` = ". $_GET['ZoneID'] . " LIMIT 1";
		$QueryResult = mysql_query($Query, $db);
		while($row = mysql_fetch_array($QueryResult)){ $ZoneSN = $row['short_name']; }
		
		$result = mysql_query('SELECT MAX(id) + 1 AS id FROM `spawn2`', $db);
		$row = mysql_fetch_assoc($result);
		$ID = $row['id'];
		
		if($_GET['NPCDATA'] == "existing"){
			$Query = "SELECT * FROM `spawn2` WHERE `zone` = '". $ZoneSN . "' AND `version` = " . $_GET['Source'] . "";
			$QueryResult = mysql_query($Query, $db);
			while ($row = mysql_fetch_array($QueryResult)) {
				$n = 0;
				$InsertQuery = "INSERT INTO `spawn2` (";
				$InsertQuery2 = "";
				foreach ($row as $k=>$v){
					if($n > 0 && !is_numeric($k)){
						$InsertQuery .= $k . ", ";
						if($k == "version"){ $InsertQuery2 .= "'" . $_GET['Dest'] . "', "; }
						else if($k == "id"){ $InsertQuery2 .= "'" . $ID . "', "; }
						else{ $InsertQuery2 .= "'" . $v . "', "; }
					}
					$n++;
				}
				$ID++;
				$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
				mysql_query($Query, $db);
			}
			echo '<br><h4>Newly Created Zone Data</h4><br>';
			AutoDataTableZone("SELECT * FROM `spawn2` WHERE `zone` = '". $ZoneSN . "' AND `version` = " . $_GET['Dest'] . "");
		}
		else if($_GET['NPCDATA'] == "copy"){
			/* Cache the Data for after reference */

			if($_GET['NPCGRIDS']){
				/* Grids */
				$result = mysql_query('SELECT MAX(id) + 1 AS id FROM `grid` WHERE `zoneid` = "'. $_GET['ZoneID'] . '"', $db);
				$row = mysql_fetch_assoc($result);
				$ID = $row['id'];
				
				$Query = "SELECT * FROM `grid` WHERE `zoneid` = '". $_GET['ZoneID'] . "'";
				$QueryResult = mysql_query($Query, $db);
				##echo $Query . '<br>';
				while ($row = mysql_fetch_array($QueryResult)) { 
					$n = 0;
					$InsertQuery = "INSERT INTO `grid` (";
					$InsertQuery2 = "";
					foreach ($row as $k=>$v){
						if($n > 0 && !is_numeric($k)){
							$InsertQuery .= $k . ", ";
							if($k == "id"){ $InsertQuery2 .= "'" . $ID . "', "; }
							else{ $InsertQuery2 .= "'" . $v . "', "; }
						}
						$n++;
					}
					$GridList[$row['id']] = $ID;
					$ID++;
					$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
					mysql_query($Query, $db);
					##echo $Query . '<br>';
				}
				
				$Query = "SELECT * FROM `grid_entries` WHERE `zoneid` = '". $_GET['ZoneID'] . "'";
				$QueryResult = mysql_query($Query, $db);
				##echo $Query . '<br>';
				while ($row = mysql_fetch_array($QueryResult)) { 
					$n = 0;
					$InsertQuery = "INSERT INTO `grid_entries` (";
					$InsertQuery2 = "";
					foreach ($row as $k=>$v){
						if($n > 0 && !is_numeric($k)){
							$InsertQuery .= $k . ", ";
							if($k == "gridid"){ $InsertQuery2 .= "'" . $GridList[$row['gridid']] . "', "; }
							else{ $InsertQuery2 .= "'" . $v . "', "; }
						}
						$n++;
					}
					$GridList[$row['id']] = $ID;
					$ID++;
					$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
					mysql_query($Query, $db);
					##echo $Query . '<br>';
				}
				
				
			}	
			
			/* npc_types */
			$result = mysql_query('SELECT MAX(id) + 1 AS id FROM `npc_types`', $db);
			$row = mysql_fetch_assoc($result);
			$ID = $row['id'];
			$Query = "SELECT
				npc_types.*
				FROM
				spawnentry
				Inner Join spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID
				Inner Join npc_types ON npc_types.id = spawnentry.npcID WHERE `zone` = '" . $ZoneSN . "' AND spawn2.version = " . $_GET['Source'] . " GROUP by npc_types.id";
			$QueryResult = mysql_query($Query, $db);
			##echo $Query . '<br>';
			while ($row = mysql_fetch_array($QueryResult)) { 
				// Do Stuff here
				$n = 0;
				$InsertQuery = "INSERT INTO `npc_types` (";
				$InsertQuery2 = "";
				foreach ($row as $k=>$v){
					if($n > 0 && !is_numeric($k)){
						$InsertQuery .= $k . ", ";
						if($k == "id"){ $InsertQuery2 .= "'" . $ID . "', "; }
						else{ $InsertQuery2 .= "'" . $v . "', "; }
					}
					$n++;
				}
				$NewReferenceList[$row['id']] = $ID;
				$ID++;
				$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
				mysql_query($Query, $db);
				##echo $Query . '<br>';
			}
			
			/* spawngroup */
			$result = mysql_query('SELECT MAX(id) + 1 AS id FROM `spawngroup`', $db);
			$row = mysql_fetch_assoc($result);
			$ID = $row['id'];
			$Query = "SELECT
				spawngroup.*
				FROM
				spawn2
				Inner Join spawngroup ON spawngroup.id = spawn2.spawngroupID
				WHERE spawn2.zone = '" . $ZoneSN . "' AND spawn2.version = " . $_GET['Source'] . "";
			$QueryResult = mysql_query($Query, $db);
			##echo $Query . '<br>';
			while ($row = mysql_fetch_array($QueryResult)) {
				$n = 0;
				$InsertQuery = "INSERT INTO `spawngroup` (";
				$InsertQuery2 = "";
				foreach ($row as $k=>$v){
					if($n > 0 && !is_numeric($k)){
						$InsertQuery .= $k . ", ";
						if($k == "id"){ $InsertQuery2 .= "'" . $ID . "', "; }
						else if($k == "name"){ $InsertQuery2 .= "'" . $ZoneSN . '_' . $ID . "', "; }
						else{ $InsertQuery2 .= "'" . $v . "', "; }
					}
					$n++;
				}
				$SpawnGroup[$row['id']] = $ID;
				$ID++;
				$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
				##echo $Query . '<br>';
				mysql_query($Query, $db);
			}
			
			/* spawnentry */	
			$Query = "SELECT
				spawnentry.spawngroupID,
				spawnentry.npcID,
				spawnentry.chance
				FROM
				spawnentry
				Inner Join spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID
				WHERE spawn2.zone = '" . $ZoneSN . "' AND spawn2.version = " . $_GET['Source'] . "";
			$QueryResult = mysql_query($Query, $db);
			##echo $Query . '<br>';
			while ($row = mysql_fetch_array($QueryResult)) { 
				$n = 0;
				$InsertQuery = "INSERT INTO `spawnentry` (";
				$InsertQuery2 = "";
				$NValid = 0;
				foreach ($row as $k=>$v){
					if($n > 0 && !is_numeric($k)){
						if($row['npcID'] != 0){
							$InsertQuery .= $k . ", ";
							if($k == "spawngroupID"){ $InsertQuery2 .= "'" . $SpawnGroup[$row['spawngroupID']] . "', "; }
							else if($k == "npcID"){ $InsertQuery2 .= "'" . $NewReferenceList[$row['npcID']] . "', "; }
							else{ $InsertQuery2 .= "'" . $v . "', "; }
						} else{ $NValid = 1; }
					}
					$n++;
				}
				$NewSpawnGroupReferenceList[$row['spawngroupID']] = $ID;
				$ID++;
				if($NValid != 1){
					$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
					mysql_query($Query, $db);
					#echo $NewSpawnGroupReferenceList[$row['spawngroupID']] . ' ' . $row['spawngroupID'] . '<br>';
					##echo $Query . '<br>';
				}
			}
			
			/* spawn2 */
			$result = mysql_query('SELECT MAX(id) + 1 AS id FROM `spawn2`', $db);
			$row = mysql_fetch_assoc($result);
			$ID = $row['id'];
			
			$Query = "SELECT * FROM `spawn2` WHERE `zone` = '" . $ZoneSN . "' and version = " . $_GET['Source'] . "";
			$QueryResult = mysql_query($Query, $db);
			##echo $Query . '<br>';
			while ($row = mysql_fetch_array($QueryResult)) {
				if($NewSpawnGroupReferenceList[$row['spawngroupID']]){
					#echo $row['spawngroupID'] . ' ' . $NewSpawnGroupReferenceList[$row['spawngroupID']] . '<br>';
				
					$n = 0;
					$InsertQuery = "INSERT INTO `spawn2` (";
					$InsertQuery2 = "";
					foreach ($row as $k=>$v){
						if($n > 0 && !is_numeric($k)){
							$InsertQuery .= $k . ", ";
							if($GridList[$row['pathgrid']]){ $GRID = $GridList[$row['pathgrid']]; } else{ $GRID = 0; } 
							if($k == "id"){ $InsertQuery2 .= "'" . $ID . "', "; }
							else if($k == "spawngroupID"){ $InsertQuery2 .= "'" . $SpawnGroup[$row['spawngroupID']] . "', "; }
							else if($k == "version"){ $InsertQuery2 .= "'" . $_GET['Dest'] . "', "; }
							else if($k == "pathgrid" && $_GET['NPCGRIDS']){ $InsertQuery2 .= "'" . $GRID . "', "; }
							else{ $InsertQuery2 .= "'" . $v . "', "; }
						}
						$n++;
					}
					$NewReferenceList[$row['id']] = $ID;
					$ID++;
					$Query = substr($InsertQuery, 0, -2) . ') VALUES ('. substr($InsertQuery2, 0, -2) . ');';
					##echo $Query . '<br>';
					mysql_query($Query, $db);
				}
			}
			echo '<br>Copy should be successful! Refresh your zone selection<br>';
		}
	}
	
	
	if($_GET['ZoneID'] && $_GET['CopyTool'] == "deletezone"){
		$Query = "SELECT * FROM `zone` WHERE `zoneidnumber` = ". $_GET['ZoneID'] . " LIMIT 1";
		$QueryResult = mysql_query($Query, $db);
		while($row = mysql_fetch_array($QueryResult)){ $ZoneSN = $row['short_name']; }
	
		echo '<br><h4>Delete Zone Version</h4>';
		$Query = "SELECT version, COUNT(*) AS total FROM `spawn2` WHERE `zone`  = '". $ZoneSN . "' GROUP by `version`";
		$QueryResult = mysql_query($Query, $db);
		echo '<table>';
		echo '<tr><td>Version</td><td><select id="VersionToDelete" onchange="DeleteZoneVersion('. $_GET['ZoneID'] . ', this.value)">'; 
		echo '<option value="">Select...</option>';
		while($row = mysql_fetch_array($QueryResult)){
			echo '<option value="'. $row['version'] . '">Version '. $row['version'] . ' (' . $row['total'] . ')</option>';
			$VersionData[$row['version']] = $row['total'];
		}
		echo '</select></td></tr></table>';
		echo '<br><h4>Options</h4>';
		echo '<table>';
		echo '<tr><td>NPC Data: </td><td><select id="DeleteOption"><option value="partial">Partial: (This zone only had spawn entries from the original)</option><option value="full">Full: Use this when you made a full unique copy from one version to another</option></select></td></tr>'; 
		echo '<tr><td>Delete Objects?</td><td> <input type="checkbox" value="1" id="objdelete"></td></tr>';
		echo '<tr><td>Delete Doors? </td><td><input type="checkbox" value="1" id="doordelete"></td></tr>';
		echo '</tr></table>';
		echo '<br><div id="ZoneToolDeleteData"></div>';
	}
	if($_GET['ZoneID'] && isset($_GET['VersionToDelete']) && !$_GET['Submit']){
		$Query = "SELECT * FROM `zone` WHERE `zoneidnumber` = ". $_GET['ZoneID'] . " LIMIT 1";
		$QueryResult = mysql_query($Query, $db);
		while($row = mysql_fetch_array($QueryResult)){ $ZoneSN = $row['short_name']; }
		echo '<input type="button" value="DELETE!" class="btnIconLeft mr10" onclick="DeleteZoneVersionSubmit('. $_GET['ZoneID'] . ', document.getElementById(\'VersionToDelete\').value, document.getElementById(\'DeleteOption\').value, document.getElementById(\'objdelete\').value, document.getElementById(\'doordelete\').value)">';
		echo '<br><br><h4>Spawn2 Data that will be purged:</h4>';
		AutoDataTableZone("SELECT * FROM `spawn2` WHERE `zone` = '". $ZoneSN . "' AND `version` = " . $_GET['VersionToDelete'], $db);
	}
	if($_GET['ZoneID'] && isset($_GET['VersionToDelete']) && $_GET['Submit'] == 1){
		if($_GET['DeleteType'] == "partial"){
			$Query = "SELECT * FROM `zone` WHERE `zoneidnumber` = ". $_GET['ZoneID'] . " LIMIT 1";
			$QueryResult = mysql_query($Query, $db);
			while($row = mysql_fetch_array($QueryResult)){ $ZoneSN = $row['short_name']; $ZoneLN = $row['long_name']; }
			mysql_query("DELETE FROM `spawn2` WHERE `zone` = '". $ZoneSN . "' AND `version` = '". $_GET['VersionToDelete'] . "';", $db);
			echo '<h4>' . $ZoneLN . ' with Version ' . $_GET['VersionToDelete'] . ' has been deleted!</h4>';
		}
		if($_GET['DeleteType'] == "full"){
			$Query = "SELECT * FROM `zone` WHERE `zoneidnumber` = ". $_GET['ZoneID'] . " LIMIT 1";
			$QueryResult = mysql_query($Query, $db);
			while($row = mysql_fetch_array($QueryResult)){ $ZoneSN = $row['short_name']; $ZoneLN = $row['long_name']; }

			$Query = "SELECT
				spawn2.pathgrid 
				FROM
				(npc_types) 
				INNER JOIN spawnentry ON npc_types.id = spawnentry.npcID
				INNER JOIN spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID
				WHERE spawn2.zone = '". $ZoneSN . "' AND spawn2.version = '". $_GET['VersionToDelete'] . "'";
			#echo $Query;
			$QueryAdd1 = ""; $QueryAdd2 = "";
			$QueryResult = mysql_query($Query, $db);
			while($row = mysql_fetch_array($QueryResult)){
				if($row['pathgrid'] > 0){
					$QueryAdd1 .= " OR id='". $row['pathgrid'] . "'";
					$QueryAdd2 .= " OR gridid='". $row['pathgrid'] . "'";
				}
			}
			mysql_query("DELETE FROM grid WHERE id='999999999999' ". $QueryAdd1 . ";", $db);
			mysql_query("DELETE FROM grid_entries WHERE gridid='999999999999' ". $QueryAdd2 . ";", $db);
			
			$Query = "SELECT DISTINCT spawnentry.npcID,spawn2.spawngroupID FROM spawnentry, npc_types, spawngroup, spawn2 WHERE (spawnentry.npcID=npc_types.id) AND (spawnentry.spawngroupID=spawngroup.id) AND (spawn2.spawngroupID = spawnentry.spawngroupID) AND (spawn2.zone='" . $ZoneSN . "') AND (spawn2.version='" . $_GET['VersionToDelete'] . "') ORDER BY npc_types.id";
			$QueryResult = mysql_query($Query, $db);
			while($row = mysql_fetch_array($QueryResult)){
				mysql_query("DELETE FROM spawnentry WHERE spawngroupID='" . $row['spawngroupID'] . "';", $db);
				mysql_query("DELETE FROM spawngroup WHERE id='" . $row['spawngroupID'] . "';", $db);
				mysql_query("DELETE FROM npc_types WHERE id='" . $row['npcID'] . "' AND id > 999;", $db);
			}
			mysql_query("DELETE FROM spawn2 WHERE zone='" . $ZoneSN . "' AND  spawn2.version='" . $_GET['VersionToDelete'] . "'", $db);
		}
		if($_GET['ObjectsDelete'] == 1){ mysql_query("DELETE FROM object WHERE zoneid = " . $_GET['ZoneID'] . " AND version = ". $_GET['VersionToDelete'] . ";", $db); }
		if($_GET['DoorsDelete'] == 1){ mysql_query("DELETE FROM doors WHERE zone = " . $ZoneSN . " AND version = " . $GET['VersionToDelete'] . ";", $db); }
		#echo var_dump($_GET);
		echo 'Zone Version has been deleted successfully!<br>';
	}
Reply With Quote
  #3  
Old 11-01-2013, 11:05 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

With nothing blocked this is all it does for me on Firefox.

I'd suggest people use EoC for sure.. but I refuse to use a different browser because I am stubborn.

Reply With Quote
  #4  
Old 11-01-2013, 11:28 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Natedog, before you perform this request on the dropdown. Can you please do a 'Inspect Element' on your Firefox and tell me what its going on in the console.

I understand loyalty to a browser, I used to use FF.

You should see a GET request to the below url. If you have a Javascript which is what I suspect you have, you can also see this in the console.


Last edited by Akkadius; 11-01-2013 at 11:33 PM..
Reply With Quote
  #5  
Old 11-01-2013, 11:45 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

Opened page didn't click the dropdown just inspected the element.

Reply With Quote
  #6  
Old 11-01-2013, 11:49 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

That can be ignored, I need to know what happens when you trigger a dropdown selection.
Reply With Quote
  #7  
Old 11-01-2013, 11:53 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

Clicked dropdown and this is what it shows in console (had console open when i clicked it)

Reply With Quote
  #8  
Old 11-01-2013, 11:58 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Does it at all show anywhere what line it bombed on? Or what it did with that?

eoccustom.js is where the ajax calls are defined.
Reply With Quote
  #9  
Old 11-02-2013, 12:03 AM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

I click the error and it says it is breaking here...

Reply With Quote
  #10  
Old 11-02-2013, 12:11 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

It is hard for me to suggest something more because I don't have access to your browser, but it seems you are using a plugin that might be messing up AJAX requests.

Do other tools in the EoC hang like this? Task Editor? NPC Editor? Item Editor?

EDIT: Also can you manually visit this page?

http://eoc.akkadius.com/AllaClone/eo...=11&Selector=1

This is a typical request.

EDIT2: Do you have heightened security settings set to not trust certain types of scripts? This can happen with FF.

Last edited by Akkadius; 11-02-2013 at 12:20 AM..
Reply With Quote
  #11  
Old 11-02-2013, 12:21 AM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

I had the site completely whitelisted on everything except 1 thing... Adblock

Whitelisted the site to show ads.. and it works now :p
Reply With Quote
  #12  
Old 11-02-2013, 12:23 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Quote:
Originally Posted by NatedogEZ View Post
I had the site completely whitelisted on everything except 1 thing... Adblock

Whitelisted the site to show ads.. and it works now :p
Hah! I knew it! Glad you could get it working

BTW, if you set a doors version to -1, it will load in all instances. I've done this to my whole doors table that isn't already in a version above 0. This was implemented over a year ago. I wish we had better documentation medium.

Also, nice job on the Perl script - I apologize for the crabass I've been. Moving sucks.
Reply With Quote
  #13  
Old 11-02-2013, 12:27 AM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

Ah didn't know that about doors... but my 2ndary versions will have the exits blocked by random objects which I do not want to appear in the normal zone.

I guess I can set the normal doors to -1 though that will save some time for sure :p
Reply With Quote
  #14  
Old 11-02-2013, 12:31 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Quote:
Originally Posted by NatedogEZ View Post
Ah didn't know that about doors... but my 2ndary versions will have the exits blocked by random objects which I do not want to appear in the normal zone.

I guess I can set the normal doors to -1 though that will save some time for sure :p
For sure you can have -1 coexist with 1 or 2 or 3, just need to make sure that your door id's jive.

You could have the same door id used in versions 1, 2, or 3 you just can't have more than one of the same id load or you will have issues.

Keeps from having to duplicate thousands of doors for no reason
Reply With Quote
  #15  
Old 11-04-2013, 01:03 AM
knowom's Avatar
knowom
Discordant
 
Join Date: Jun 2006
Posts: 371
Default

Wait so did he have adblock turned on and it was blocking the javascript?
__________________
"We are all on the same team, and I think not enough people realize this."
- Leetsauce
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 06:37 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3