From 7ccce637587328e51c2beb644d424965a337f137 Mon Sep 17 00:00:00 2001 From: Shadez Date: Thu, 29 Apr 2010 15:25:34 +0900 Subject: [PATCH] [168] Implemented multi realms support. For more info read comments in configuration.php --- character-achievements.php | 21 +- character-arenateams.php | 19 +- character-calendar.php | 19 +- character-feed-data.php | 7 +- character-feed.php | 17 +- character-model.php | 9 +- character-reputation.php | 19 +- character-select.php | 6 +- character-sheet.php | 14 +- character-statistics.php | 21 +- character-talents.php | 19 +- includes/armory_loader.php | 30 ++- includes/classes/class.arenateams.php | 20 +- includes/classes/class.characters.php | 8 +- includes/classes/class.connector.php | 56 ++++- includes/classes/class.guilds.php | 4 +- includes/classes/class.search.php | 211 ++++++++++-------- includes/classes/class.utils.php | 4 +- includes/classes/configuration.php.default | 36 ++- sql/updates/armory_r168_armory_realm_data.sql | 13 ++ 20 files changed, 352 insertions(+), 201 deletions(-) create mode 100644 sql/updates/armory_r168_armory_realm_data.sql diff --git a/character-achievements.php b/character-achievements.php index fadbaeb0c..98f26ac1a 100644 --- a/character-achievements.php +++ b/character-achievements.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 149 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -55,13 +55,16 @@ $isCharacter = $characters->IsCharacter(); $characters->_structCharacter(); $achievements->guid = $characters->guid; +if(!isset($_GET['r']) || !$armory->currentRealmInfo) { + $isCharacter = false; +} // Get page cache if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { if($achievement_category > 0) { - $cache_id = $utils->GenerateCacheId('character-achievements-c'.$achievement_category, $characters->name, $armory->armoryconfig['defaultRealmName']); + $cache_id = $utils->GenerateCacheId('character-achievements-c'.$achievement_category, $characters->name, $armory->currentRealmInfo['name']); } else { - $cache_id = $utils->GenerateCacheId('character-achievements', $characters->name, $armory->armoryconfig['defaultRealmName']); + $cache_id = $utils->GenerateCacheId('character-achievements', $characters->name, $armory->currentRealmInfo['name']); } if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; @@ -162,12 +165,12 @@ $tabUrl = false; $guilds->guid = $characters->guid; if($isCharacter && $guilds->extractPlayerGuildId()) { - $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); - $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); } elseif($isCharacter) { - $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); - $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); + $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); + $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); } /** Header **/ $xml->XMLWriter()->startElement('page'); @@ -201,7 +204,7 @@ 'gender' => '', 'genderId' => $characters->gender, 'guildName' => ($guilds->guid) ? $guilds->guildName : '', - 'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : '', + 'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : '', 'lastModified' => '', 'level' => $characters->level, 'name' => $characters->name, @@ -209,7 +212,7 @@ 'prefix' => $characters->character_title['prefix'], 'race' => $characters->returnRaceText(), 'raceId' => $characters->race, - 'realm' => $armory->armoryconfig['defaultRealmName'], + 'realm' => $armory->currentRealmInfo['name'], 'suffix' => $characters->character_title['suffix'], 'titeId' => $characters->character_title['titleId'], ); diff --git a/character-arenateams.php b/character-arenateams.php index c4ccb2aae..bbab07d41 100644 --- a/character-arenateams.php +++ b/character-arenateams.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 149 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -44,9 +44,12 @@ } $characters->GetCharacterGuid(); $isCharacter = $characters->IsCharacter(); +if(!isset($_GET['r']) || !$armory->currentRealmInfo) { + $isCharacter = false; +} // Get page cache if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-arenateams', $characters->name, $armory->armoryconfig['defaultRealmName']); + $cache_id = $utils->GenerateCacheId('character-arenateams', $characters->name, $armory->currentRealmInfo['name']); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); @@ -59,12 +62,12 @@ $arenateams->guid = $characters->guid; $tabUrl = false; if($isCharacter && $guilds->extractPlayerGuildId()) { - $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); - $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); } elseif($isCharacter) { - $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); - $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); + $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); + $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); } /** Header **/ $xml->XMLWriter()->startElement('page'); @@ -99,7 +102,7 @@ 'gender' => '', 'genderId' => $characters->gender, 'guildName' => ($guilds->guildName) ? $guilds->guildName : '', - 'guildUrl' => ($guilds->guildName) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : '', + 'guildUrl' => ($guilds->guildName) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : '', 'lastModified' => '', 'level' => $characters->level, 'name' => $characters->name, @@ -107,7 +110,7 @@ 'prefix' => (isset($characters->character_title['prefix'])) ? $characters->character_title['prefix'] : null, 'race' => $characters->returnRaceText(), 'raceId' => $characters->race, - 'realm' => $armory->armoryconfig['defaultRealmName'], + 'realm' => $armory->currentRealmInfo['name'], 'suffix' => (isset($characters->character_title['suffix'])) ? $characters->character_title['suffix'] : null, 'titeId' => (isset($characters->character_title['titleId'])) ? $characters->character_title['titleId'] : null, ); diff --git a/character-calendar.php b/character-calendar.php index b712fab39..912c3f1df 100644 --- a/character-calendar.php +++ b/character-calendar.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 149 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -43,9 +43,12 @@ $isCharacter = $characters->IsCharacter(); $characters->_structCharacter(); $achievements->guid = $characters->guid; +if(!isset($_GET['r']) || !$armory->currentRealmInfo) { + $isCharacter = false; +} // Get page cache if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-calendar', $characters->name, $armory->armoryconfig['defaultRealmName']); + $cache_id = $utils->GenerateCacheId('character-calendar', $characters->name, $armory->currentRealmInfo['name']); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); @@ -56,12 +59,12 @@ $tabUrl = false; $guilds->guid = $characters->guid; if($isCharacter && $guilds->extractPlayerGuildId()) { - $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); - $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); } elseif($isCharacter) { - $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); - $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); + $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); + $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); } /** Header **/ // Load XSLT template @@ -98,7 +101,7 @@ 'gender' => '', 'genderId' => $characters->gender, 'guildName' => ($guilds->guid) ? $guilds->guildName : '', - 'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : '', + 'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : '', 'lastModified' => '', 'level' => $characters->level, 'name' => $characters->name, @@ -106,7 +109,7 @@ 'prefix' => $characters->character_title['prefix'], 'race' => $characters->returnRaceText(), 'raceId' => $characters->race, - 'realm' => $armory->armoryconfig['defaultRealmName'], + 'realm' => $armory->currentRealmInfo['name'], 'suffix' => $characters->character_title['suffix'], 'titeId' => $characters->character_title['titleId'], ); diff --git a/character-feed-data.php b/character-feed-data.php index dab30685c..d9425821e 100644 --- a/character-feed-data.php +++ b/character-feed-data.php @@ -40,6 +40,9 @@ } $characters->GetCharacterGuid(); $isCharacter = $characters->IsCharacter(); +if(!isset($_GET['r']) || !$armory->currentRealmInfo) { + $isCharacter = false; +} // Get page cache if(isset($_GET['full'])) { if($isCharacter) { @@ -54,7 +57,7 @@ $cache_name = 'character-feed-data'; } if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId($cache_name, $characters->name, $armory->armoryconfig['defaultRealmName']); + $cache_id = $utils->GenerateCacheId($cache_name, $characters->name, $armory->currentRealmInfo['name']); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); @@ -76,7 +79,7 @@ } $xml->XMLWriter()->startElement('character'); $xml->XMLWriter()->writeAttribute('name', $characters->name); - $xml->XMLWriter()->writeAttribute('characterUrl', sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name))); + $xml->XMLWriter()->writeAttribute('characterUrl', sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name))); $xml->XMLWriter()->endElement(); //character if(isset($feed_item['title'])) { $xml->XMLWriter()->startElement('title'); diff --git a/character-feed.php b/character-feed.php index 1fdd49533..81e1ec69c 100644 --- a/character-feed.php +++ b/character-feed.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 160 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -42,18 +42,21 @@ $characters->GetCharacterGuid(); $isCharacter = $characters->IsCharacter(); $characters->_structCharacter(); +if(!isset($_GET['r']) || !$armory->currentRealmInfo) { + $isCharacter = false; +} /** Basic info **/ $tabUrl = false; $achievements->guid = $characters->guid; $guilds->guid = $characters->guid; $arenateams->guid = $characters->guid; if($isCharacter && $guilds->extractPlayerGuildId()) { - $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); - $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); } elseif($isCharacter) { - $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); - $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); + $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); + $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); } $xml->LoadXSLT('character/feed.xsl'); /** Header **/ @@ -90,7 +93,7 @@ 'gender' => null, 'genderId' => $characters->gender, 'guildName' => ($guilds->guid) ? $guilds->guildName : null, - 'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : null, + 'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : null, 'lastModified' => null, 'level' => $characters->level, 'name' => $characters->name, @@ -98,7 +101,7 @@ 'prefix' => $characters->character_title['prefix'], 'race' => $characters->returnRaceText(), 'raceId' => $characters->race, - 'realm' => $armory->armoryconfig['defaultRealmName'], + 'realm' => $armory->currentRealmInfo['name'], 'suffix' => $characters->character_title['suffix'], 'titeId' => $characters->character_title['titleId'], ); diff --git a/character-model.php b/character-model.php index 70e7a804d..4b49d2260 100644 --- a/character-model.php +++ b/character-model.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 146 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -40,9 +40,12 @@ } $characters->GetCharacterGuid(); $isCharacter = $characters->IsCharacter(); +if(!isset($_GET['r']) || !$armory->currentRealmInfo) { + $isCharacter = false; +} // Get page cache if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-model', $characters->name, $armory->armoryconfig['defaultRealmName']); + $cache_id = $utils->GenerateCacheId('character-model', $characters->name, $armory->currentRealmInfo['name']); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); @@ -57,7 +60,7 @@ $xml->XMLWriter()->startElement('tabInfo'); $xml->XMLWriter()->writeAttribute('tab', 'character'); $xml->XMLWriter()->writeAttribute('tabGroup', 'character'); -$xml->XMLWriter()->writeAttribute('tabUrl', ($characters->IsCharacter()) ? sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)) : '' ); +$xml->XMLWriter()->writeAttribute('tabUrl', ($characters->IsCharacter()) ? sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)) : '' ); $xml->XMLWriter()->endElement(); //tabInfo if(!$isCharacter) { $xml->XMLWriter()->startElement('characterInfo'); diff --git a/character-reputation.php b/character-reputation.php index 63a1705f2..054f04515 100644 --- a/character-reputation.php +++ b/character-reputation.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 149 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -43,9 +43,12 @@ $isCharacter = $characters->IsCharacter(); $characters->_structCharacter(); $achievements->guid = $characters->guid; +if(!isset($_GET['r']) || !$armory->currentRealmInfo) { + $isCharacter = false; +} // Get page cache if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-reputation', $characters->name, $armory->armoryconfig['defaultRealmName']); + $cache_id = $utils->GenerateCacheId('character-reputation', $characters->name, $armory->currentRealmInfo['name']); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); @@ -58,12 +61,12 @@ $tabUrl = false; $guilds->guid = $characters->guid; if($isCharacter && $guilds->extractPlayerGuildId()) { - $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); - $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); } elseif($isCharacter) { - $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); - $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); + $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); + $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); } /** Header **/ $xml->XMLWriter()->startElement('page'); @@ -98,7 +101,7 @@ 'gender' => '', 'genderId' => $characters->gender, 'guildName' => ($guilds->guid) ? $guilds->guildName : '', - 'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : '', + 'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : '', 'lastModified' => '', 'level' => $characters->level, 'name' => $characters->name, @@ -106,7 +109,7 @@ 'prefix' => $characters->character_title['prefix'], 'race' => $characters->returnRaceText(), 'raceId' => $characters->race, - 'realm' => $armory->armoryconfig['defaultRealmName'], + 'realm' => $armory->currentRealmInfo['name'], 'suffix' => $characters->character_title['suffix'], 'titeId' => $characters->character_title['titleId'], ); diff --git a/character-select.php b/character-select.php index e0de394de..2ebdab7e9 100644 --- a/character-select.php +++ b/character-select.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 122 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -47,7 +47,9 @@ $isCharacter = $characters->IsCharacter(); $characters->_structCharacter(); $achievements->guid = $characters->guid; - +if(!isset($_GET['r']) || !$armory->currentRealmInfo) { + $isCharacter = false; +} /** Header **/ $xml->XMLWriter()->startElement('page'); $xml->XMLWriter()->writeAttribute('globalSearch', 1); diff --git a/character-sheet.php b/character-sheet.php index 899a9fb2f..f89e3a037 100644 --- a/character-sheet.php +++ b/character-sheet.php @@ -46,7 +46,7 @@ $isCharacter = $characters->IsCharacter(); // Get page cache if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-sheet', $characters->name, $armory->armoryconfig['defaultRealmName']); + $cache_id = $utils->GenerateCacheId('character-sheet', $characters->name, $armory->currentRealmInfo['name']); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); @@ -62,12 +62,12 @@ $arenateams->guid = $characters->guid; $tabUrl = false; if($isCharacter && $guilds->extractPlayerGuildId()) { - $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); - $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); } elseif($isCharacter) { - $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); - $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); + $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); + $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); } /** Header **/ $xml->XMLWriter()->startElement('page'); @@ -101,7 +101,7 @@ 'gender' => '', 'genderId' => $characters->gender, 'guildName' => ($guilds->guildName) ? $guilds->guildName : '', - 'guildUrl' => ($guilds->guildName) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : '', + 'guildUrl' => ($guilds->guildName) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : '', 'lastModified' => date('d M Y'), 'level' => $characters->level, 'name' => $characters->name, @@ -109,7 +109,7 @@ 'prefix' => (isset($characters->character_title['prefix'])) ? $characters->character_title['prefix'] : null, 'race' => $characters->returnRaceText(), 'raceId' => $characters->race, - 'realm' => $armory->armoryconfig['defaultRealmName'], + 'realm' => $armory->currentRealmInfo['name'], 'suffix' => (isset($characters->character_title['suffix'])) ? $characters->character_title['suffix'] : null, 'titeId' => (isset($characters->character_title['titleId'])) ? $characters->character_title['titleId'] : null, ); diff --git a/character-statistics.php b/character-statistics.php index c66acf291..d538cc0cd 100644 --- a/character-statistics.php +++ b/character-statistics.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 149 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -52,13 +52,16 @@ $isCharacter = $characters->IsCharacter(); $characters->_structCharacter(); $achievements->guid = $characters->guid; +if(!isset($_GET['r']) || !$armory->currentRealmInfo) { + $isCharacter = false; +} // Get page cache if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { if($achievement_category > 0) { - $cache_id = $utils->GenerateCacheId('character-statistics-c'.$achievement_category, $characters->name, $armory->armoryconfig['defaultRealmName']); + $cache_id = $utils->GenerateCacheId('character-statistics-c'.$achievement_category, $characters->name, $armory->currentRealmInfo['name']); } else { - $cache_id = $utils->GenerateCacheId('character-statistics', $characters->name, $armory->armoryconfig['defaultRealmName']); + $cache_id = $utils->GenerateCacheId('character-statistics', $characters->name, $armory->currentRealmInfo['name']); } if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; @@ -99,12 +102,12 @@ $tabUrl = false; $guilds->guid = $characters->guid; if($isCharacter && $guilds->extractPlayerGuildId()) { - $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); - $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); } elseif($isCharacter) { - $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); - $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); + $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); + $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); } /** Header **/ $xml->XMLWriter()->startElement('page'); @@ -139,7 +142,7 @@ 'gender' => '', 'genderId' => $characters->gender, 'guildName' => ($guilds->guid) ? $guilds->guildName : '', - 'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : '', + 'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : '', 'lastModified' => '', 'level' => $characters->level, 'name' => $characters->name, @@ -147,7 +150,7 @@ 'prefix' => $characters->character_title['prefix'], 'race' => $characters->returnRaceText(), 'raceId' => $characters->race, - 'realm' => $armory->armoryconfig['defaultRealmName'], + 'realm' => $armory->currentRealmInfo['name'], 'suffix' => $characters->character_title['suffix'], 'titeId' => $characters->character_title['titleId'], ); diff --git a/character-talents.php b/character-talents.php index e558cabe6..16947ab2d 100644 --- a/character-talents.php +++ b/character-talents.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 149 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -43,9 +43,12 @@ } $characters->GetCharacterGuid(); $isCharacter = $characters->IsCharacter(); +if(!isset($_GET['r']) || !$armory->currentRealmInfo) { + $isCharacter = false; +} // Get page cache if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-talents', $characters->name, $armory->armoryconfig['defaultRealmName']); + $cache_id = $utils->GenerateCacheId('character-talents', $characters->name, $armory->currentRealmInfo['name']); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); @@ -58,12 +61,12 @@ $guilds->guid = $characters->guid; $tabUrl = false; if($isCharacter && $guilds->extractPlayerGuildId()) { - $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); - $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); + $charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName())); } elseif($isCharacter) { - $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); - $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)); + $tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); + $charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)); } /** Header **/ $xml->XMLWriter()->startElement('page'); @@ -98,7 +101,7 @@ 'gender' => '', 'genderId' => $characters->gender, 'guildName' => ($guilds->guid) ? $guilds->guildName : '', - 'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : '', + 'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : '', 'lastModified' => '', 'level' => $characters->level, 'name' => $characters->name, @@ -106,7 +109,7 @@ 'prefix' => $characters->character_title['prefix'], 'race' => $characters->returnRaceText(), 'raceId' => $characters->race, - 'realm' => $armory->armoryconfig['defaultRealmName'], + 'realm' => $armory->currentRealmInfo['name'], 'suffix' => $characters->character_title['suffix'], 'titeId' => $characters->character_title['titleId'], ); diff --git a/includes/armory_loader.php b/includes/armory_loader.php index 49eb2e11d..1795c8624 100644 --- a/includes/armory_loader.php +++ b/includes/armory_loader.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 164 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -30,14 +30,28 @@ if(!@include('classes/class.connector.php')) { die('Error: can not load connector class!'); } -define('DB_VERSION', 'armory_r164'); -define('ARMORY_REVISION', 164); +define('DB_VERSION', 'armory_r168'); +define('ARMORY_REVISION', 168); $armory = new Connector; +/* Check DbVersion */ +$dbVersion = $armory->aDB->selectCell("SELECT `version` FROM `armory_db_version`"); +if($dbVersion != DB_VERSION) { + if(empty($dbVersion)) { + echo 'Fatal error: incorrect Armory DB name
'; + } + die(sprintf('DbVersion error: current version is %s but expected %s.', $dbVersion, DB_VERSION)); +} /* Check maintenance */ if($armory->armoryconfig['maintenance'] == true && !defined('MAINTENANCE_PAGE')) { header('Location: maintenance.xml'); } -if($armory->armoryconfig['server_version'] > 0) { +if(isset($armory->currentRealmInfo['version']) && $armory->currentRealmInfo['version'] > 0) { + $file_ver = (int) $armory->currentRealmInfo['version']; + if(!@include('UpdateFields'.$file_ver.'.php')) { + die('Error: can not load UpdateFields'.$file_ver.'.php.!'); + } +} +elseif(!isset($armory->currentRealmInfo['version']) && $armory->armoryconfig['server_version'] > 0) { $file_ver = (int) $armory->armoryconfig['server_version']; if(!@include('UpdateFields'.$file_ver.'.php')) { die('Error: can not load UpdateFields'.$file_ver.'.php.!'); @@ -153,14 +167,6 @@ } $search = new SearchMgr; } - -$dbVersion = $armory->aDB->selectCell("SELECT `version` FROM `armory_db_version`"); -if($dbVersion != DB_VERSION) { - if(empty($dbVersion)) { - echo 'Fatal error: incorrect Armory DB name
'; - } - die(sprintf('DbVersion error: current version is %s but expected %s.', $dbVersion, DB_VERSION)); -} // start XML parser if(!@include('classes/class.xmlhandler.php')) { die('Error: can not load XML handler class!'); diff --git a/includes/classes/class.arenateams.php b/includes/classes/class.arenateams.php index 2abbba9c1..8ee66ce51 100644 --- a/includes/classes/class.arenateams.php +++ b/includes/classes/class.arenateams.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 153 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -71,14 +71,14 @@ public function GetArenaTeamInfo() { $arenateaminfo['data']['battleGroup'] = $this->armoryconfig['defaultBGName']; $arenateaminfo['data']['lastSeasonRanking'] = 0; $arenateaminfo['data']['name'] = $this->teamname; - $arenateaminfo['data']['realm'] = $this->armoryconfig['defaultRealmName']; - $arenateaminfo['data']['realmUrl'] = sprintf('b=%s&r=%s&ts=%d', urlencode($this->armoryconfig['defaultBGName']), urlencode($this->armoryconfig['defaultRealmName']), $this->teamtype); + $arenateaminfo['data']['realm'] = $this->currentRealmInfo['name']; + $arenateaminfo['data']['realmUrl'] = sprintf('b=%s&r=%s&ts=%d', urlencode($this->armoryconfig['defaultBGName']), urlencode($this->currentRealmInfo['name']), $this->teamtype); $arenateaminfo['data']['relevance'] = 0; $arenateaminfo['data']['season'] = 0; $arenateaminfo['data']['size'] = $this->teamtype; $arenateaminfo['data']['teamSize'] = $this->teamtype; - $arenateaminfo['data']['teamUrl'] = sprintf('r=%s&t=%s', urlencode($this->armoryconfig['defaultRealmName']), urlencode($this->teamname)); - $arenateaminfo['data']['url'] = sprintf('r=%s&ts=%d&t=%s', urlencode($this->armoryconfig['defaultRealmName']), $this->teamtype, urlencode($this->teamname)); + $arenateaminfo['data']['teamUrl'] = sprintf('r=%s&t=%s', urlencode($this->currentRealmInfo['name']), urlencode($this->teamname)); + $arenateaminfo['data']['url'] = sprintf('r=%s&ts=%d&t=%s', urlencode($this->currentRealmInfo['name']), $this->teamtype, urlencode($this->teamname)); $arenateaminfo['emblem'] = self::GetArenaTeamEmblem(); if(is_array($this->players)) { $arenateaminfo['members'] = $this->players; @@ -147,10 +147,10 @@ public function GetTeamList() { for($i=0;$i<$count_players;$i++) { if($this->players[$i]['guildId'] = $this->cDB->selectCell("SELECT `guildid` FROM `guild_member` WHERE `guid`=?", $this->players[$i]['guid'])) { $this->players[$i]['guild'] = $this->cDB->selectCell("SELECT `name` FROM `guild` WHERE `guildid`=?", $this->players[$i]['guildId']); - $this->players[$i]['guildUrl'] = sprintf('r=%s&gn=%s', urlencode($this->armoryconfig['defaultRealmName']), urlencode($this->players[$i]['guild'])); + $this->players[$i]['guildUrl'] = sprintf('r=%s&gn=%s', urlencode($this->currentRealmInfo['name']), urlencode($this->players[$i]['guild'])); } $this->players[$i]['battleGroup'] = $this->armoryconfig['defaultBGName']; - $this->players[$i]['charUrl'] = sprintf('r=%s&cn=%s', urlencode($this->armoryconfig['defaultRealmName']), urlencode($this->players[$i]['name'])); + $this->players[$i]['charUrl'] = sprintf('r=%s&cn=%s', urlencode($this->currentRealmInfo['name']), urlencode($this->players[$i]['name'])); unset($this->players[$i]['guid']); } } @@ -189,13 +189,13 @@ public function BuildArenaLadderList($type, $page, $num = false) { $result_areanteams[$i]['data']['factionId'] = Characters::GetCharacterFaction($result_areanteams[$i]['data']['race']); //$result_areanteams[$i]['data']['factionId'] = 1; $result_areanteams[$i]['data']['lastSeasonRanking'] = ''; - $result_areanteams[$i]['data']['realm'] = $this->armoryconfig['defaultRealmName']; - $result_areanteams[$i]['data']['realmUrl'] = sprintf('b=%s&r=%s&ts=%d&select=%s', urlencode($this->armoryconfig['defaultBGName']), urlencode($this->armoryconfig['defaultRealmName']), $type, urlencode($team['name'])); + $result_areanteams[$i]['data']['realm'] = $this->currentRealmInfo['name']; + $result_areanteams[$i]['data']['realmUrl'] = sprintf('b=%s&r=%s&ts=%d&select=%s', urlencode($this->armoryconfig['defaultBGName']), urlencode($this->currentRealmInfo['name']), $type, urlencode($team['name'])); $result_areanteams[$i]['data']['relevance'] = 0; $result_areanteams[$i]['data']['season'] = 0; $result_areanteams[$i]['data']['size'] = $type; $result_areanteams[$i]['data']['teamSize'] = $type; - $result_areanteams[$i]['data']['teamUrl'] = sprintf('r=%s&ts=%d&t=%s', urlencode($this->armoryconfig['defaultBGName']), urlencode($this->armoryconfig['defaultRealmName']), $type, urlencode($team['name'])); + $result_areanteams[$i]['data']['teamUrl'] = sprintf('r=%s&ts=%d&t=%s', urlencode($this->armoryconfig['defaultBGName']), urlencode($this->currentRealmInfo['name']), $type, urlencode($team['name'])); $result_areanteams[$i]['emblem'] = self::GetArenaTeamEmblem($team['arenateamid']); unset($result_areanteams[$i]['data']['arenateamid']); unset($result_areanteams[$i]['data']['captainguid']); diff --git a/includes/classes/class.characters.php b/includes/classes/class.characters.php index 328556b5b..887899342 100644 --- a/includes/classes/class.characters.php +++ b/includes/classes/class.characters.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 167 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -305,7 +305,7 @@ public function returnCharacterUrl() { if(!$this->guid) { return false; } - $url_string = 'r=' . urlencode($this->armoryconfig['defaultRealmName']) . '&cn=' . urlencode($this->name); + $url_string = 'r=' . urlencode($this->currentRealmInfo['name']) . '&cn=' . urlencode($this->name); if($guildID = $this->GetDataField(PLAYER_GUILDID)) { $url_string .= '&gn=' . urlencode($this->cDB->selectCell("SELECT `name` FROM `guild` WHERE `guildid`=? LIMIT 1", $guildID)); } @@ -1755,12 +1755,12 @@ public function GetCharacterFeed($full = false) { if($achievement_info['categoryId'] == 81) { // Feats of strenght $feed_data[$i]['title'] = sprintf('%s [%s].', $_strings[14], $achievement_info['title']); - $feed_data[$i]['desc'] = sprintf('%s [%s]', $_strings[14], urlencode($this->armoryconfig['defaultRealmName']), urlencode($this->name), $tooltip, $achievement_info['title']); + $feed_data[$i]['desc'] = sprintf('%s [%s]', $_strings[14], urlencode($this->currentRealmInfo['name']), urlencode($this->name), $tooltip, $achievement_info['title']); } else { $points_string = sprintf($_strings[18], $achievement_info['points']); $feed_data[$i]['title'] = sprintf('%s [%s].', $_strings[13], $achievement_info['title']); - $feed_data[$i]['desc'] = sprintf('%s [%s] %s.', $_strings[13], urlencode($this->armoryconfig['defaultRealmName']), urlencode($this->name), $tooltip, $achievement_info['title'], $points_string); + $feed_data[$i]['desc'] = sprintf('%s [%s] %s.', $_strings[13], urlencode($this->currentRealmInfo['name']), urlencode($this->name), $tooltip, $achievement_info['title'], $points_string); } $feed_data[$i]['tooltip'] = $tooltip; break; diff --git a/includes/classes/class.connector.php b/includes/classes/class.connector.php index 46af579ad..00ac20e4d 100644 --- a/includes/classes/class.connector.php +++ b/includes/classes/class.connector.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 133 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -52,6 +52,11 @@ /** Locale (0 - en_gb, 2 - fr_fr, 3 - de_de, etc.)**/ public $_loc; + /** Links for multirealm info **/ + public $realmData; + public $connectionData; + public $currentRealmInfo; + /** * Initialize database & template handlers, sets up sql/site configs * @category Main system functions @@ -67,14 +72,47 @@ public function __construct() { } $this->mysqlconfig = $ArmoryConfig['mysql']; $this->armoryconfig = $ArmoryConfig['settings']; + $this->realmData = $ArmoryConfig['multiRealm']; $this->aDB = DbSimple_Generic::connect('mysql://'.$this->mysqlconfig['user_armory'].':'.$this->mysqlconfig['pass_armory'].'@'.$this->mysqlconfig['host_armory'].'/'.$this->mysqlconfig['name_armory']); - $this->cDB = DbSimple_Generic::connect('mysql://'.$this->mysqlconfig['user_characters'].':'.$this->mysqlconfig['pass_characters'].'@'.$this->mysqlconfig['host_characters'].'/'.$this->mysqlconfig['name_characters']); - $this->rDB = DbSimple_Generic::connect('mysql://'.$this->mysqlconfig['user_realmd'].':'.$this->mysqlconfig['pass_realmd'].'@'.$this->mysqlconfig['host_realmd'].'/'.$this->mysqlconfig['name_realmd']); - $this->wDB = DbSimple_Generic::connect('mysql://'.$this->mysqlconfig['user_mangos'].':'.$this->mysqlconfig['pass_mangos'].'@'.$this->mysqlconfig['host_mangos'].'/'.$this->mysqlconfig['name_mangos']); $this->aDB->query("SET NAMES ?", $this->mysqlconfig['charset_armory']); - $this->cDB->query("SET NAMES ?", $this->mysqlconfig['charset_characters']); + $this->rDB = DbSimple_Generic::connect('mysql://'.$this->mysqlconfig['user_realmd'].':'.$this->mysqlconfig['pass_realmd'].'@'.$this->mysqlconfig['host_realmd'].'/'.$this->mysqlconfig['name_realmd']); + if(isset($_GET['r'])) { + $realmName = urldecode($_GET['r']); + $realm_info = $this->aDB->selectRow("SELECT `id`, `version` FROM `armory_realm_data` WHERE `name`=?", $realmName); + if(!$realm_info) { + $this->cDB = DbSimple_Generic::connect('mysql://'.$this->mysqlconfig['user_characters'].':'.$this->mysqlconfig['pass_characters'].'@'.$this->mysqlconfig['host_characters'].'/'.$this->mysqlconfig['name_characters']); + $this->wDB = DbSimple_Generic::connect('mysql://'.$this->mysqlconfig['user_mangos'].':'.$this->mysqlconfig['pass_mangos'].'@'.$this->mysqlconfig['host_mangos'].'/'.$this->mysqlconfig['name_mangos']); + $this->cDB->query("SET NAMES ?", $this->mysqlconfig['charset_characters']); + $this->wDB->query("SET NAMES ?", $this->mysqlconfig['charset_mangos']); + } + elseif(isset($this->realmData[$realm_info['id']])) { + $this->connectionData = $this->realmData[$realm_info['id']]; + $this->cDB = DbSimple_Generic::connect('mysql://'.$this->connectionData['user_characters'].':'.$this->connectionData['pass_characters'].'@'.$this->connectionData['host_characters'].'/'.$this->connectionData['name_characters']); + $this->cDB->query("SET NAMES ?", $this->connectionData['charset_characters']); + $this->currentRealmInfo = array('name' => $this->connectionData['name'], 'id' => $realm_info['id'], 'version' => $realm_info['version'], 'connected' => true); + if(isset($this->connectionData['name_mangos'])) { + $this->wDB = DbSimple_Generic::connect('mysql://'.$this->connectionData['user_mangos'].':'.$this->connectionData['pass_mangos'].'@'.$this->connectionData['host_mangos'].'/'.$this->connectionData['name_mangos']); + $this->wDB->query("SET NAMES ?", $this->connectionData['charset_mangos']); + } + else { + $this->wDB = DbSimple_Generic::connect('mysql://'.$this->mysqlconfig['user_mangos'].':'.$this->mysqlconfig['pass_mangos'].'@'.$this->mysqlconfig['host_mangos'].'/'.$this->mysqlconfig['name_mangos']); + $this->wDB->query("SET NAMES ?", $this->mysqlconfig['charset_mangos']); + } + } + else { + $this->cDB = DbSimple_Generic::connect('mysql://'.$this->mysqlconfig['user_characters'].':'.$this->mysqlconfig['pass_characters'].'@'.$this->mysqlconfig['host_characters'].'/'.$this->mysqlconfig['name_characters']); + $this->wDB = DbSimple_Generic::connect('mysql://'.$this->mysqlconfig['user_mangos'].':'.$this->mysqlconfig['pass_mangos'].'@'.$this->mysqlconfig['host_mangos'].'/'.$this->mysqlconfig['name_mangos']); + $this->cDB->query("SET NAMES ?", $this->mysqlconfig['charset_characters']); + $this->wDB->query("SET NAMES ?", $this->mysqlconfig['charset_mangos']); + } + } + else { + $this->cDB = DbSimple_Generic::connect('mysql://'.$this->mysqlconfig['user_characters'].':'.$this->mysqlconfig['pass_characters'].'@'.$this->mysqlconfig['host_characters'].'/'.$this->mysqlconfig['name_characters']); + $this->wDB = DbSimple_Generic::connect('mysql://'.$this->mysqlconfig['user_mangos'].':'.$this->mysqlconfig['pass_mangos'].'@'.$this->mysqlconfig['host_mangos'].'/'.$this->mysqlconfig['name_mangos']); + $this->cDB->query("SET NAMES ?", $this->mysqlconfig['charset_characters']); + $this->wDB->query("SET NAMES ?", $this->mysqlconfig['charset_mangos']); + } $this->rDB->query("SET NAMES ?", $this->mysqlconfig['charset_realmd']); - $this->wDB->query("SET NAMES ?", $this->mysqlconfig['charset_mangos']); $user_locale = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)); if($user_locale && $http_locale = self::IsAllowedLocale($user_locale)) { $this->_locale = (isset($_SESSION['armoryLocale'])) ? $_SESSION['armoryLocale'] : $http_locale; @@ -100,11 +138,11 @@ public function __construct() { $this->_loc = 3; break; /* - case 'cn_cn': //(?) - $this->_loc = 4; + case 'zh_cn': + $this->_loc = 4; // China break; case 'zh_tw': - $this->_loc = 5; + $this->_loc = 5; // Taiwan break; */ case 'es_es': diff --git a/includes/classes/class.guilds.php b/includes/classes/class.guilds.php index 3fcd3d2b9..a26640a2d 100644 --- a/includes/classes/class.guilds.php +++ b/includes/classes/class.guilds.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 153 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -229,7 +229,7 @@ public function BuildGuildList() { $countMembers = count($memberListTmp); for($i=0;$i<$countMembers;$i++) { $memberListTmp[$i]['achPoints'] = Achievements::calculateAchievementPoints($memberListTmp[$i]['guid']); - $memberListTmp[$i]['url'] = sprintf('r=%s&cn=%s&gn=%s', urlencode($this->armoryconfig['defaultRealmName']), urlencode($memberListTmp[$i]['name']), urlencode($this->guildName)); + $memberListTmp[$i]['url'] = sprintf('r=%s&cn=%s&gn=%s', urlencode($this->currentRealmInfo['name']), urlencode($memberListTmp[$i]['name']), urlencode($this->guildName)); } return $memberListTmp; } diff --git a/includes/classes/class.search.php b/includes/classes/class.search.php index c19bf4c17..df888cdfd 100644 --- a/includes/classes/class.search.php +++ b/includes/classes/class.search.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 159 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -580,119 +580,152 @@ public function SearchArenaTeams($num=false) { if(!$this->searchQuery) { return false; } + $results = array(); // Full results + $current_realm = array(); + $count_results = 0; // All realms results + $count_results_currrent_realm = 0; // Current realm results + $db = null; // Temporary handler if($num == true) { - $teamsNum = $this->cDB->selectCell(" - SELECT COUNT(`arenateamid`) - FROM `arena_team` - WHERE `name` LIKE ? LIMIT 200", '%'.$this->searchQuery.'%'); - return $teamsNum; - } - $arenateams = $this->cDB->select(" - SELECT `arena_team`.`name`, `arena_team`.`type` AS `size`, `arena_team_stats`.`rating`, `characters`.`race` - FROM `arena_team` AS `arena_team` - LEFT JOIN `arena_team_stats` AS `arena_team_stats` ON `arena_team`.`arenateamid`=`arena_team_stats`.`arenateamid` - LEFT JOIN `characters` AS `characters` ON `arena_team`.`captainguid`=`characters`.`guid` - WHERE `arena_team`.`name` LIKE ? LIMIT 200", '%'.$this->searchQuery.'%'); - if(!$arenateams) { - return false; + foreach($this->realmData as $realm_info) { + $count_results_currrent_realm = 0; + $db = DbSimple_Generic::connect('mysql://'.$realm_info['user_characters'].':'.$realm_info['pass_characters'].'@'.$realm_info['host_characters'].'/'.$realm_info['name_characters']); + $db->query("SET NAMES ?", $realm_info['charset_characters']); + $count_results_currrent_realm = $db->selectCell("SELECT COUNT(`arenateamid`) FROM `arena_team` WHERE `name` LIKE ? LIMIT 200", '%'.$this->searchQuery.'%'); + $count_results = $count_results + $count_results_currrent_realm; + } + return $count_results; + } + foreach($this->realmData as $realm_info) { + $db = DbSimple_Generic::connect('mysql://'.$realm_info['user_characters'].':'.$realm_info['pass_characters'].'@'.$realm_info['host_characters'].'/'.$realm_info['name_characters']); + $db->query("SET NAMES ?", $realm_info['charset_characters']); + $current_realm = $db->select(" + SELECT `arena_team`.`name`, `arena_team`.`type` AS `size`, `arena_team_stats`.`rating`, `characters`.`race` + FROM `arena_team` AS `arena_team` + LEFT JOIN `arena_team_stats` AS `arena_team_stats` ON `arena_team`.`arenateamid`=`arena_team_stats`.`arenateamid` + LEFT JOIN `characters` AS `characters` ON `arena_team`.`captainguid`=`characters`.`guid` + WHERE `arena_team`.`name` LIKE ? LIMIT 200", '%'.$this->searchQuery.'%'); + if(!$current_realm) { + continue; + } + $count_current_realm = count($current_realm); + foreach($current_realm as $realm) { + $realm['teamSize'] = $realm['size']; + $realm['battleGroup'] = $this->armoryconfig['defaultBGName']; + $realm['factionId'] = Characters::GetCharacterFaction($realm['race']); + $realm['relevance'] = 100; + $realm['realm'] = $realm_info['name']; + $realm['url'] = sprintf('r=%s&ts=%d&t=%s', urlencode($realm_info['name']), $realm['size'], urlencode($realm['name'])); + unset($realm['race']); + $results[] = $realm; + } } - $arena_count = count($arenateams); - for($i=0;$i<$arena_count;$i++) { - $arenateams[$i]['teamSize'] = $arenateams[$i]['size']; - $arenateams[$i]['realm'] = $this->armoryconfig['defaultRealmName']; - $arenateams[$i]['battleGroup'] = $this->armoryconfig['defaultBGName']; - $arenateams[$i]['factionId'] = Characters::GetCharacterFaction($arenateams[$i]['race']); - $arenateams[$i]['relevance'] = 100; - $arenateams[$i]['url'] = sprintf('r=%s&ts=%d&t=%s', urlencode($this->armoryconfig['defaultRealmName']), $arenateams[$i]['size'], urlencode($arenateams[$i]['name'])); - unset($arenateams[$i]['race']); + if($results) { + return $results; } - return $arenateams; + return false; } - public function SearchGuilds($num=false) { + public function SearchGuilds($num = false) { if(!$this->searchQuery) { return false; } + $results = array(); // Full results + $current_realm = array(); + $count_results = 0; // All realms results + $count_results_currrent_realm = 0; // Current realm results + $db = null; // Temporary handler if($num == true) { - $guildsNum = $this->cDB->selectCell(" - SELECT COUNT(`guildid`) - FROM `guild` - WHERE `name` LIKE ? LIMIT 200", '%'.$this->searchQuery.'%'); - return $guildsNum; - } - $guilds = $this->cDB->select(" - SELECT `guild`.`name`, `characters`.`race` - FROM `guild` AS `guild` - LEFT JOIN `characters` AS `characters` ON `guild`.`leaderguid`=`characters`.`guid` - WHERE `guild`.`name` LIKE ? LIMIT 200", '%'.$this->searchQuery.'%'); - if(!$guilds) { - return false; + foreach($this->realmData as $realm_info) { + $count_results_currrent_realm = 0; + $db = DbSimple_Generic::connect('mysql://'.$realm_info['user_characters'].':'.$realm_info['pass_characters'].'@'.$realm_info['host_characters'].'/'.$realm_info['name_characters']); + $db->query("SET NAMES ?", $realm_info['charset_characters']); + $count_results_currrent_realm = $db->selectCell("SELECT COUNT(`guildid`) FROM `guild` WHERE `name` LIKE ? LIMIT 200", '%'.$this->searchQuery.'%'); + $count_results = $count_results + $count_results_currrent_realm; + } + return $count_results; + } + foreach($this->realmData as $realm_info) { + $db = DbSimple_Generic::connect('mysql://'.$realm_info['user_characters'].':'.$realm_info['pass_characters'].'@'.$realm_info['host_characters'].'/'.$realm_info['name_characters']); + $db->query("SET NAMES ?", $realm_info['charset_characters']); + $current_realm = $db->select("SELECT `guild`.`name`, `characters`.`race` FROM `guild` AS `guild` LEFT JOIN `characters` AS `characters` ON `guild`.`leaderguid`=`characters`.`guid` WHERE `guild`.`name` LIKE ? LIMIT 200", '%'.$this->searchQuery.'%'); + if(!$current_realm) { + continue; + } + $count_current_realm = count($current_realm); + foreach($current_realm as $realm) { + $realm['battleGroup'] = $this->armoryconfig['defaultBGName']; + $realm['factionId'] = Characters::GetCharacterFaction($realm['race']); + $realm['relevance'] = 100; + $realm['realm'] = $realm_info['name']; + $realm['url'] = sprintf('r=%s&gn=%s', urlencode($realm_info['name']), urlencode($realm['name'])); + unset($realm['race']); + $results[] = $realm; + } } - $guilds_count = count($guilds); - for($i=0;$i<$guilds_count;$i++) { - $guilds[$i]['battleGroup'] = $this->armoryconfig['defaultBGName']; - $guilds[$i]['factionId'] = Characters::GetCharacterFaction($guilds[$i]['race']); - $guilds[$i]['relevance'] = 100; - $guilds[$i]['realm'] = $this->armoryconfig['defaultRealmName']; - $guilds[$i]['url'] = sprintf('r=%s&gn=%s', urlencode($this->armoryconfig['defaultRealmName']), urlencode($guilds[$i]['name'])); - unset($guilds[$i]['race']); + if($results) { + return $results; } - return $guilds; + return false; } - public function SearchCharacters($num=false) { + public function SearchCharacters($num = false) { if(!$this->searchQuery) { return false; } - $results_data = array(); - $cur_realm_data = array(); - $results_count = 0; + $results = array(); // Full results + $current_realm = array(); + $count_results = 0; // All realms results + $count_results_currrent_realm = 0; // Current realm results + $characters_data = array(); // Temp results + $db = null; // Temporary handler if($num == true) { - $count_chars = $this->cDB->select("SELECT `guid`, `level`, `account` FROM `characters` WHERE `name` LIKE ? AND `level` >= ? LIMIT 200", '%'.$this->searchQuery.'%', $this->armoryconfig['minlevel']); - $count_result = count($count_chars); - for($i=0;$i<$count_result;$i++) { - if(self::IsCharacterAllowedForSearch($count_chars[$i]['guid'], $count_chars[$i]['level'], $count_chars[$i]['account'])) { - $results_count++; + foreach($this->realmData as $realm_info) { + $count_results_currrent_realm = 0; + $db = DbSimple_Generic::connect('mysql://'.$realm_info['user_characters'].':'.$realm_info['pass_characters'].'@'.$realm_info['host_characters'].'/'.$realm_info['name_characters']); + $db->query("SET NAMES ?", $realm_info['charset_characters']); + $characters_data[] = $db->select("SELECT `guid`, `level`, `account` FROM `characters` WHERE `name` LIKE ? AND `level` >= ? LIMIT 200", '%'.$this->searchQuery.'%', $this->armoryconfig['minlevel']); + } + $count_result_chars = count($characters_data); + for($i=0;$i<$count_result_chars;$i++) { + if(self::IsCharacterAllowedForSearch($characters_data[$i][0]['guid'], $characters_data[$i][0]['level'], $characters_data[$i][0]['account'])) { + $count_results++; } } - } - else { - $cur_realm_data = $this->cDB->select(" - SELECT `guid`, `name`, `class` AS `classId`, `gender` AS `genderId`, `race` AS `raceId`, `level`, `account` - FROM `characters` - WHERE `name` LIKE ? LIMIT 200", '%'.$this->searchQuery.'%'); - $count_data = count($cur_realm_data); - for($j=0;$j<$count_data;$j++) { - if(!self::IsCharacterAllowedForSearch($cur_realm_data[$j]['guid'], $cur_realm_data[$j]['level'], $cur_realm_data[$j]['account'])) { + return $count_results; + } + foreach($this->realmData as $realm_info) { + $db = DbSimple_Generic::connect('mysql://'.$realm_info['user_characters'].':'.$realm_info['pass_characters'].'@'.$realm_info['host_characters'].'/'.$realm_info['name_characters']); + $db->query("SET NAMES ?", $realm_info['charset_characters']); + $current_realm = $db->select("SELECT `guid`, `name`, `class` AS `classId`, `gender` AS `genderId`, `race` AS `raceId`, `level`, `account` FROM `characters` WHERE `name` LIKE ?", '%'.$this->searchQuery.'%'); + if(!$current_realm) { + continue; + } + $count_current_realm = count($current_realm); + foreach($current_realm as $realm) { + if(!self::IsCharacterAllowedForSearch($realm['guid'], $realm['level'], $realm['account'])) { continue; } - if($cur_realm_data[$j]['guildId'] = $this->cDB->selectCell("SELECT `guildid` FROM `guild_member` WHERE `guid`=?", $cur_realm_data[$j]['guid'])) { - $cur_realm_data[$j]['guild'] = $this->cDB->selectCell("SELECT `name` FROM `guild` WHERE `guildid`=?", $cur_realm_data[$j]['guildId']); - $cur_realm_data[$j]['guildUrl'] = sprintf('r=%s&gn=%s', urlencode($this->armoryconfig['defaultRealmName']), urlencode($cur_realm_data[$j]['guild'])); + if($realm['guildId'] = $db->selectCell("SELECT `guildid` FROM `guild_member` WHERE `guid`=?", $realm['guid'])) { + $realm['guild'] = $db->selectCell("SELECT `name` FROM `guild` WHERE `guildid`=?", $realm['guildId']); + $realm['guildUrl'] = sprintf('r=%s&gn=%s', urlencode($realm_info['name']), urlencode($realm['guild'])); } - $cur_realm_data[$j]['url'] = 'r='.urlencode($this->armoryconfig['defaultRealmName']).'&cn='.urlencode($cur_realm_data[$j]['name']); - $cur_realm_data[$j]['relevance'] = 100; // TODO - $cur_realm_data[$j]['battleGroup'] = $this->armoryconfig['defaultBGName']; - $cur_realm_data[$j]['battleGroupId'] = 1; - $cur_realm_data[$j]['class'] = $this->aDB->selectCell("SELECT `name_".$this->_locale."` FROM `armory_classes` WHERE `id`=?", $cur_realm_data[$j]['classId']); - $cur_realm_data[$j]['race'] = $this->aDB->selectCell("SELECT `name_".$this->_locale."` FROM `armory_races` WHERE `id`=?", $cur_realm_data[$j]['raceId']); - $cur_realm_data[$j]['realm'] = $this->armoryconfig['defaultRealmName']; - $cur_realm_data[$j]['factionId'] = Characters::GetCharacterFaction($cur_realm_data[$j]['raceId']); - $cur_realm_data[$j]['faction'] = ($cur_realm_data[$j]['factionId'] == 0) ? Utils::GetArmoryString(11) : Utils::GetArmoryString(12); - $cur_realm_data[$j]['searchRank'] = $j+1; - unset($cur_realm_data[$j]['guid']); // Do not show guid in XML result - unset($cur_realm_data[$j]['account']); // Do not show account in XML result + $realm['url'] = sprintf('r=%s&cn=%s', urlencode($realm_info['name']), $realm['name']); + $realm['relevance'] = 100; + $realm['battleGroup'] = $this->armoryconfig['defaultBGName']; + $realm['battleGroupId'] = 1; + $realm['class'] = $this->aDB->selectCell("SELECT `name_".$this->_locale."` FROM `armory_classes` WHERE `id`=?", $realm['classId']); + $realm['race'] = $this->aDB->selectCell("SELECT `name_".$this->_locale."` FROM `armory_races` WHERE `id`=?", $realm['raceId']); + $realm['realm'] = $realm_info['name']; + $realm['factionId'] = Characters::GetCharacterFaction($realm['raceId']); + $realm['searchRank'] = 1; //??? + unset($realm['account'], $realm['guid']); + $results[] = $realm; } } - if($num == true) { - return $results_count; - } - elseif(!$cur_realm_data) { - return false; - } - else { - return $cur_realm_data; + if($results) { + return $results; } + return false; } public function IsExtendedCost() { diff --git a/includes/classes/class.utils.php b/includes/classes/class.utils.php index 4db70476e..d14b2e470 100644 --- a/includes/classes/class.utils.php +++ b/includes/classes/class.utils.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 155 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -129,7 +129,7 @@ public function GetAllCharacters() { for($i=0;$i<$count;$i++) { $chars[$i]['account'] = strtoupper($_SESSION['username']); $chars[$i]['factionId'] = Characters::GetCharacterFaction($chars[$i]['raceId']); - $chars[$i]['realm'] = $this->armoryconfig['defaultRealmName']; + $chars[$i]['realm'] = $this->currentRealmInfo['name']; $chars[$i]['relevance'] = '100'; $chars[$i]['url'] = 'r='.urlencode($chars[$i]['realm']).'&cn='.urlencode($chars[$i]['name']); } diff --git a/includes/classes/configuration.php.default b/includes/classes/configuration.php.default index ac349678f..e4f615f75 100644 --- a/includes/classes/configuration.php.default +++ b/includes/classes/configuration.php.default @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 157 + * @revision 168 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -68,6 +68,38 @@ $ArmoryConfig['settings']['cache_lifetime'] = 86400; // In seconds; default - $ArmoryConfig['settings']['minlevel'] = 10; // Character must have this level or higher to be shown in Armory $ArmoryConfig['settings']['minGmLevelToShow'] = 3; // Show characters : 0 - only players, 1 - moderators, 2 - GMs, 3 - everyone $ArmoryConfig['settings']['defaultLocale'] = 'ru_ru'; // Can be 'ru_ru' or 'en_gb' -$ArmoryConfig['settings']['showScriptInfo'] = true; // Display script info (generation time, etc.) ? (true/false) +$ArmoryConfig['settings']['showScriptInfo'] = true; // Display script info (generation time, etc.) ? (true/false) (not used now) $ArmoryConfig['settings']['maintenance'] = false; // Disable site? (true/false) + +/* + Multirealms info + + $ArmoryConfig[1]['name'] MUST be added to `armory_realm_data` table: + # INSERT INTO `armory_realm_data` (`id`, `name`, `version`) VALUES ('1', 'MaNGOS1', '333'); + Without it multirealm wouldn't work. +*/ + +$ArmoryConfig['multiRealm'][1]['name'] = 'MaNGOS1'; +$ArmoryConfig['multiRealm'][1]['host_characters'] = 'localhost'; +$ArmoryConfig['multiRealm'][1]['user_characters'] = 'root'; +$ArmoryConfig['multiRealm'][1]['pass_characters'] = ''; +$ArmoryConfig['multiRealm'][1]['name_characters'] = 'characters'; +$ArmoryConfig['multiRealm'][1]['charset_characters'] = 'UTF8'; +$ArmoryConfig['multiRealm'][1]['host_mangos'] = 'localhost'; +$ArmoryConfig['multiRealm'][1]['user_mangos'] = 'root'; +$ArmoryConfig['multiRealm'][1]['pass_mangos'] = ''; +$ArmoryConfig['multiRealm'][1]['name_mangos'] = 'mangos'; +$ArmoryConfig['multiRealm'][1]['charset_mangos'] = 'UTF8'; + +$ArmoryConfig['multiRealm'][2]['name'] = 'MaNGOS2'; +$ArmoryConfig['multiRealm'][2]['host_characters'] = 'localhost'; +$ArmoryConfig['multiRealm'][2]['user_characters'] = 'root'; +$ArmoryConfig['multiRealm'][2]['pass_characters'] = ''; +$ArmoryConfig['multiRealm'][2]['name_characters'] = 'characters_2'; +$ArmoryConfig['multiRealm'][2]['charset_characters'] = 'UTF8'; +$ArmoryConfig['multiRealm'][2]['host_mangos'] = 'localhost'; +$ArmoryConfig['multiRealm'][2]['user_mangos'] = 'root'; +$ArmoryConfig['multiRealm'][2]['pass_mangos'] = ''; +$ArmoryConfig['multiRealm'][2]['name_mangos'] = 'mangos'; +$ArmoryConfig['multiRealm'][2]['charset_mangos'] = 'UTF8'; ?> \ No newline at end of file diff --git a/sql/updates/armory_r168_armory_realm_data.sql b/sql/updates/armory_r168_armory_realm_data.sql new file mode 100644 index 000000000..15a0ec60c --- /dev/null +++ b/sql/updates/armory_r168_armory_realm_data.sql @@ -0,0 +1,13 @@ +UPDATE `armory_db_version` SET `version` = 'armory_r168'; + +DROP TABLE IF EXISTS `armory_realm_data`; +CREATE TABLE `armory_realm_data` ( + `id` smallint(6) NOT NULL, + `name` text NOT NULL, + `version` smallint(6) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `armory_realm_data` VALUES +(1, 'MaNGOS1', 333), +(2, 'MaNGOS2', 333); \ No newline at end of file