mjshirley Posted August 4, 2007 Share Posted August 4, 2007 I've been working on a project: http://www.wowroster.net/Forums/viewforum/f=101.html I have had a lot of help getting the code ported over for use with the WoW Roster. As it is now, the code works on the first import. When another person uploads their data, if there is a duplicate found, it won't skip the duplicate it just dies. I'm hoping someone can give me some in site to the cause and solution. Download here: http://gatherer.dragonkillers.us/gatherer_0.9b.zip Requires WoWRoster here: http://www.wowroster.net/Downloads/get=3.html Additionally you will need the Gatherer.lua, Cartographer_Herbalism.lua, Cartographer_Mining.lua and CharacterProfiler.lua here: http://gatherer.dragonkillers.us/lua.zip Anyone that can help me get this puppy working or at least show me where I have gone wrong with it has me gratitude. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/63348-problem-checking-for-duplicates-and-skipping/ Share on other sites More sharing options...
mjshirley Posted August 5, 2007 Author Share Posted August 5, 2007 <?php /****************************** * $Id: $ ******************************/ ini_set('display_errors', 1); error_reporting(E_ALL); if ( !defined('ROSTER_INSTALLED') ) { exit('Detected invalid access to this file!'); } require_once(dirname(__FILE__).'/localization.php'); $gatherwords = &$wordings[$roster_conf['roster_lang']]; function processGatherer($luaData, $gatherwords) { global $wowdb, $gatherwords; $query = "SELECT `map`,`number` FROM `".GATHERER_TABLE."`;"; $result = $wowdb->query($query) or die_quietly($wowdb->error(),'Database Error',basename(__FILE__),__LINE__,$query); if($wowdb->num_rows($result) > 0) { $dbData = array(); while($row = $wowdb->fetch_assoc($result)) { $coords = toXY($row['number']); $xPos = $coords['xPos']; $yPos = $coords['yPos']; $dbData[$row['map']]['x'] = $xPos; $dbData[$row['map']]['y'] = $yPos; $dbData[$row['map']]['id'] = $row['number']; } } $wowdb->free_result($result); $wowdb->resetMessages(); $inserts = ''; foreach ($luaData as $index => $zone) { if(is_array($zone)) { foreach ($zone as $map => $nodeInfo) { foreach ($nodeInfo as $nodeNumber => $nodeInfo2) { foreach ($nodeInfo2 as $varName => $value) { if(is_array($value)) { $xPos = substr($value['1'], 0, 6); $yPos = substr($value['2'], 0, 6); $id = toID($xPos, $yPos); $gtype = ( isset($nodeInfo2['gtype']) ? $nodeInfo2['gtype'] : 'Unknown' ); if( isset($dbData) && ((isset($dbData[$map]['id']) && ($dbData[$map]['id'] != $id) || ($dbData[$map]['y'] != $yPos && $dbData[$map]['x'] != $xPos)))) { continue; } else { if(!empty($inserts)) { $inserts .= ", "; } $inserts .= "( '".$id."', '".$nodeNumber."', '".$wowdb->escape($map)."', '".$wowdb->escape($gtype)."', '".$index."' )"; } } } } } } } if(!empty($inserts)) { $query = "INSERT INTO `".GATHERER_TABLE."` (`number`, `nodeNumber`, `map`, `nodeType`, `continent`) VALUES "; $query = $query . $inserts . ';'; $result = $wowdb->query($query) or die_quietly($wowdb->error(),'Database Error',basename(__FILE__),__LINE__,$query); } } //Do not remove $gatherwords from this, it doesn't work globally for some reason. function processCartoHerb($luaData, $gatherwords) { global $wowdb; $query = "SELECT `map`,`number` FROM `".GATHERER_TABLE."` where `nodeType` = 'HERB';"; $result = $wowdb->query($query) or die_quietly($wowdb->error(),'Database Error',basename(__FILE__),__LINE__,$query); if($wowdb->num_rows($result) > 0) { $dbData = array(); while($row = $wowdb->fetch_assoc($result)) { $coords = toXY($row['number']); $xPos = $coords['xPos']; $yPos = $coords['yPos']; $dbData[$row['map']]['x'] = $xPos; $dbData[$row['map']]['y'] = $yPos; $dbData[$row['map']]['id'] = $row['number']; } } $wowdb->free_result($result); $wowdb->resetMessages(); $inserts = ''; foreach ($luaData as $zone => $data) { $old = array( "'", ' ', 'SHATTERAH_CITY', 'SHATTRATH_CITY', 'THE_BARRENS', 'BLADES_EDGE_MOUNTAINS', 'NETHERSTORM', 'THE_HINTERLANDS', 'GHOSTLANDS'); $new = array( '', '_', 'SHATTRATH', 'SHATTRATH', 'BARRENS', 'BLADES_EDGE_MOUNTAINS', 'NETHERSTORM', 'HINTERLANDS', 'GHOSTLANDS'); $map = str_replace($old, $new, strtoupper($zone)); if(is_array($data)) { foreach ($data as $number => $herb) { $coords = toXY($number); $xPos = $coords['xPos']; $yPos = $coords['yPos']; $id = toID($xPos, $yPos); $gtype = 'HERB'; $index = $gatherwords['zonecont'][$map]; $nodeNumber = array_search($herb, $gatherwords['node_names']['HERB']); if( isset($dbData) && isset($dbData[$map]) && ((isset($dbData[$map]['id']) && ($dbData[$map]['id'] != $id) || ($dbData[$map]['y'] != $yPos && $dbData[$map]['x'] != $xPos)))) { continue; } else { if(!empty($inserts)) { $inserts .= ", "; } $inserts .= "( '".$id."', '".$nodeNumber."', '".$wowdb->escape($map)."', '".$wowdb->escape($gtype)."', '".$index."' )"; } } } } if(!empty($inserts)) { $query = "INSERT INTO `".GATHERER_TABLE."` (`number`, `nodeNumber`, `map`, `nodeType`, `continent`) VALUES "; $query = $query . $inserts . ';'; $result = $wowdb->query($query) or die_quietly($wowdb->error(),'Database Error',basename(__FILE__),__LINE__,$query); } } function processCartoMine($luaData, $gatherwords) { global $wowdb; $query = "SELECT `map`,`number` FROM `".GATHERER_TABLE."` where `nodeType` = 'MINE';"; $result = $wowdb->query($query) or die_quietly($wowdb->error(),'Database Error',basename(__FILE__),__LINE__,$query); if($wowdb->num_rows($result) > 0) { $dbData = array(); while($row = $wowdb->fetch_assoc($result)) { $coords = toXY($row['number']); $xPos = $coords['xPos']; $yPos = $coords['yPos']; $dbData[$row['map']]['x'] = $xPos; $dbData[$row['map']]['y'] = $yPos; $dbData[$row['map']]['id'] = $row['number']; } } $wowdb->free_result($result); $wowdb->resetMessages(); $inserts = ''; foreach ($luaData as $zone => $data) { $old = array( "'", ' ', 'SHATTERAH_CITY', 'SHATTRATH_CITY', 'THE_BARRENS', 'BLADES_EDGE_MOUNTAINS', 'NETHERSTORM', 'THE_HINTERLANDS', 'GHOSTLANDS'); $new = array( '', '_', 'SHATTRATH', 'SHATTRATH', 'BARRENS', 'BLADES_EDGE_MOUNTAINS', 'NETHERSTORM', 'HINTERLANDS', 'GHOSTLANDS'); $map = str_replace($old, $new, strtoupper($zone)); if(is_array($data)) { foreach ($data as $number => $mine) { $coords = toXY($number); $xPos = $coords['xPos']; $yPos = $coords['yPos']; $id = toID($xPos, $yPos); $gtype = 'MINE'; $index = $gatherwords['zonecont'][$map]; $nodeNumber = array_search($mine, $gatherwords['node_names']['MINE']); if( isset($dbData) && isset($dbData[$map]) && ((isset($dbData[$map]['id']) && ($dbData[$map]['id'] != $id) || ($dbData[$map]['y'] != $yPos && $dbData[$map]['x'] != $xPos)))) { continue; } else { if(!empty($inserts)) { $inserts .= ", "; } $inserts .= "( '".$id."', '".$nodeNumber."', '".$wowdb->escape($map)."', '".$wowdb->escape($gtype)."', '".$index."' )"; } } } } if(!empty($inserts)) { $query = "INSERT INTO `".GATHERER_TABLE."` (`number`, `nodeNumber`, `map`, `nodeType`, `continent`) VALUES "; $query = $query . $inserts . ';'; $result = $wowdb->query($query) or die_quietly($wowdb->error(),'Database Error',basename(__FILE__),__LINE__,$query); } } function toID($xPos, $yPos) { return round($xPos * 10000, 0) + (round($yPos * 10000, 0) * 10001); } function toXY($num) { $return['xPos'] = ($num % 10001) / 10000; $return['yPos'] = floor($num / 10001) / 10000; return $return; } Quote Link to comment https://forums.phpfreaks.com/topic/63348-problem-checking-for-duplicates-and-skipping/#findComment-315804 Share on other sites More sharing options...
Fadion Posted August 5, 2007 Share Posted August 5, 2007 man it is a 230 lines script. Only copying and pasting it to dreamweaver to see the lines number took me 1 minute lol. Guess u have to write the part of the code u think causes the problem, so someone can debug it easily. Quote Link to comment https://forums.phpfreaks.com/topic/63348-problem-checking-for-duplicates-and-skipping/#findComment-315833 Share on other sites More sharing options...
dbo Posted August 5, 2007 Share Posted August 5, 2007 Gotta dig the foreach loops nested 4 layers deep. That obliterates processing time. I'd almost wager to bet that your problem is that the script takes too long to execute and dies as a result. Quote Link to comment https://forums.phpfreaks.com/topic/63348-problem-checking-for-duplicates-and-skipping/#findComment-315838 Share on other sites More sharing options...
mjshirley Posted August 8, 2007 Author Share Posted August 8, 2007 That's the thing... I'm not sure what part it's tripping on... Quote Link to comment https://forums.phpfreaks.com/topic/63348-problem-checking-for-duplicates-and-skipping/#findComment-318842 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.