diff --git a/character-achievements.php b/character-achievements.php index f72e54a41..e734aa7bc 100644 --- a/character-achievements.php +++ b/character-achievements.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -76,7 +76,7 @@ $characters->BuildCharacter($name, $realmId, true, true); $isCharacter = $characters->CheckPlayer(); $achievements = $characters->GetAchievementMgr(); -if($_GET['r'] === false || !Armory::$currentRealmInfo) { +if($_GET['r'] === false || !$characters->GetRealmName()) { $isCharacter = false; } // Get page cache @@ -86,7 +86,7 @@ $cache_id = $utils->GenerateCacheId('character-achievements-c'.$achievement_category, $utils->GenerateCacheIdForComparisons($comparisonData)); } else { - $cache_id = $utils->GenerateCacheId('character-achievements-c'.$achievement_category, $characters->GetName(), Armory::$currentRealmInfo['name']); + $cache_id = $utils->GenerateCacheId('character-achievements-c'.$achievement_category, $characters->GetName(), $characters->GetRealmName()); } } else { @@ -94,7 +94,7 @@ $cache_id = $utils->GenerateCacheId('character-achievements', $utils->GenerateCacheIdForComparisons($comparisonData)); } else { - $cache_id = $utils->GenerateCacheId('character-achievements', $characters->GetName(), Armory::$currentRealmInfo['name']); + $cache_id = $utils->GenerateCacheId('character-achievements', $characters->GetName(), $characters->GetRealmName()); } } if($cache_data = $utils->GetCache($cache_id)) { diff --git a/character-arenateams.php b/character-arenateams.php index 59c670ab0..ac5fe90e1 100644 --- a/character-arenateams.php +++ b/character-arenateams.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -47,12 +47,12 @@ $realmId = $utils->GetRealmIdByName($_GET['r']); $characters->BuildCharacter($name, $realmId, true, true); $isCharacter = $characters->CheckPlayer(); -if($_GET['r'] === false || !Armory::$currentRealmInfo) { +if($_GET['r'] === false || !$characters->GetRealmName()) { $isCharacter = false; } // Get page cache if($characters->GetGUID() > 0 && $isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-arenateams', $characters->GetName(), Armory::$currentRealmInfo['name']); + $cache_id = $utils->GenerateCacheId('character-arenateams', $characters->GetName(), $characters->GetRealmName()); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); diff --git a/character-calendar.php b/character-calendar.php index 93291e84e..9a75773b2 100644 --- a/character-calendar.php +++ b/character-calendar.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 465 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -45,12 +45,12 @@ $characters->BuildCharacter($name, $realmId, true, true); $isCharacter = $characters->CheckPlayer(); $achievements = $characters->GetAchievementMgr(); -if($_GET['r'] === false || !Armory::$currentRealmInfo) { +if($_GET['r'] === false || !$characters->GetRealmName()) { $isCharacter = false; } // Get page cache if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-calendar', $characters->GetName(), Armory::$currentRealmInfo['name']); + $cache_id = $utils->GenerateCacheId('character-calendar', $characters->GetName(), $characters->GetRealmName()); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); diff --git a/character-feed-atom.php b/character-feed-atom.php index 7e9def367..a5467bc93 100644 --- a/character-feed-atom.php +++ b/character-feed-atom.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -48,9 +48,11 @@ $_GET['r'] = false; } $realmId = $utils->GetRealmIdByName($_GET['r']); +$characters->SetOptions(LOAD_NOTHING); +$characters->SetOptions(array('load_feeds' => true)); $characters->BuildCharacter($name, $realmId, true, true); $isCharacter = $characters->CheckPlayer(); -if($_GET['r'] === false || !Armory::$currentRealmInfo) { +if($_GET['r'] === false || !$characters->GetRealmName()) { $isCharacter = false; } header('Content-type: text/xml'); diff --git a/character-feed-data.php b/character-feed-data.php index 6521f38d2..f7eb49a02 100644 --- a/character-feed-data.php +++ b/character-feed-data.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -42,9 +42,11 @@ $_GET['r'] = false; } $realmId = $utils->GetRealmIdByName($_GET['r']); +$characters->SetOptions(LOAD_NOTHING); +$characters->SetOptions(array('load_feeds' => true)); $characters->BuildCharacter($name, $realmId, true, true); $isCharacter = $characters->CheckPlayer(); -if($_GET['r'] === false || !Armory::$currentRealmInfo) { +if($_GET['r'] === false || !$characters->GetRealmName()) { $isCharacter = false; } // Get page cache @@ -61,7 +63,7 @@ $cache_name = 'character-feed-data'; } if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId($cache_name, $characters->GetName(), Armory::$currentRealmInfo['name']); + $cache_id = $utils->GenerateCacheId($cache_name, $characters->GetName(), $characters->GetRealmName()); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); @@ -83,7 +85,7 @@ } $xml->XMLWriter()->startElement('character'); $xml->XMLWriter()->writeAttribute('name', $characters->GetName()); - $xml->XMLWriter()->writeAttribute('characterUrl', sprintf('r=%s&cn=%s', urlencode(Armory::$currentRealmInfo['name']), urlencode($characters->GetName()))); + $xml->XMLWriter()->writeAttribute('characterUrl', sprintf('r=%s&cn=%s', urlencode($characters->GetRealmName()), urlencode($characters->GetName()))); $xml->XMLWriter()->endElement(); //character if(isset($feed_item['title'])) { $xml->XMLWriter()->startElement('title'); diff --git a/character-feed.php b/character-feed.php index f63561999..5728232a8 100644 --- a/character-feed.php +++ b/character-feed.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -44,7 +44,7 @@ $realmId = $utils->GetRealmIdByName($_GET['r']); $characters->BuildCharacter($name, $realmId, true, true); $isCharacter = $characters->CheckPlayer(); -if($_GET['r'] === false || !Armory::$currentRealmInfo) { +if($_GET['r'] === false || !$characters->GetRealmName()) { $isCharacter = false; } $tabUrl = $characters->GetUrlString(); diff --git a/character-model-embed.php b/character-model-embed.php index cb98f2f9b..e2c3a2eef 100644 --- a/character-model-embed.php +++ b/character-model-embed.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -45,12 +45,12 @@ $characters->BuildCharacter($name, $realmId, true, true); $isCharacter = $characters->CheckPlayer(); $achievements = $characters->GetAchievementMgr(); -if($_GET['r'] === false || !Armory::$currentRealmInfo) { +if($_GET['r'] === false || !$characters->GetRealmName()) { $isCharacter = false; } // Get page cache if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-model-embed', $characters->GetName(), Armory::$currentRealmInfo['name']); + $cache_id = $utils->GenerateCacheId('character-model-embed', $characters->GetName(), $characters->GetRealmName()); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); diff --git a/character-model.php b/character-model.php index df02a6e3d..b42597f2e 100644 --- a/character-model.php +++ b/character-model.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -42,14 +42,15 @@ $_GET['r'] = false; } $realmId = $utils->GetRealmIdByName($_GET['r']); +$characters->SetOptions(LOAD_NOTHING); $characters->BuildCharacter($name, $realmId, true, true, 1); $isCharacter = $characters->CheckPlayer(); -if($_GET['r'] === false || !Armory::$currentRealmInfo) { +if($_GET['r'] === false || !$characters->GetRealmName()) { $isCharacter = false; } // Get page cache if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-model', $characters->GetName(), Armory::$currentRealmInfo['name']); + $cache_id = $utils->GenerateCacheId('character-model', $characters->GetName(), $characters->GetRealmName()); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); @@ -64,7 +65,7 @@ $xml->XMLWriter()->startElement('tabInfo'); $xml->XMLWriter()->writeAttribute('tab', 'character'); $xml->XMLWriter()->writeAttribute('tabGroup', 'character'); -$xml->XMLWriter()->writeAttribute('tabUrl', ($isCharacter) ? sprintf('r=%s&cn=%s', urlencode(Armory::$currentRealmInfo['name']), urlencode($characters->GetName())) : null); +$xml->XMLWriter()->writeAttribute('tabUrl', ($isCharacter) ? sprintf('r=%s&cn=%s', urlencode($characters->GetRealmName()), urlencode($characters->GetName())) : null); $xml->XMLWriter()->endElement(); //tabInfo if(!$isCharacter) { $xml->XMLWriter()->startElement('characterInfo'); @@ -126,7 +127,7 @@ ); $xml->XMLWriter()->startElement('character'); -if($utils->IsAccountHaveCurrentCharacter($characters->GetGUID(), Armory::$currentRealmInfo['id'])) { +if($utils->IsAccountHaveCurrentCharacter($characters->GetGUID(), $characters->GetRealmID())) { $xml->XMLWriter()->writeAttribute('owned', 1); } $xml->XMLWriter()->startElement('models'); diff --git a/character-reputation.php b/character-reputation.php index e64254e6f..f226152e3 100644 --- a/character-reputation.php +++ b/character-reputation.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -45,12 +45,12 @@ $characters->BuildCharacter($name, $realmId, true, true); $isCharacter = $characters->CheckPlayer(); $achievements = $characters->GetAchievementMgr(); -if($_GET['r'] === false || !Armory::$currentRealmInfo) { +if($_GET['r'] === false || !$characters->GetRealmName()) { $isCharacter = false; } // Get page cache if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-reputation', $characters->GetName(), Armory::$currentRealmInfo['name']); + $cache_id = $utils->GenerateCacheId('character-reputation', $characters->GetName(), $characters->GetRealmName()); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); diff --git a/character-sheet.php b/character-sheet.php index 0df8e8b3c..c0446fff2 100644 --- a/character-sheet.php +++ b/character-sheet.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -47,14 +47,15 @@ $_GET['r'] = false; } $realmId = $utils->GetRealmIdByName($_GET['r']); +$characters->SetOptions(LOAD_ALL); $characters->BuildCharacter($name, $realmId, true, true); $isCharacter = $characters->CheckPlayer(); -if($_GET['r'] === false || !Armory::$currentRealmInfo) { +if($_GET['r'] === false || !$characters->GetRealmName()) { $isCharacter = false; } // Get page cache if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-sheet', $characters->GetName(), Armory::$currentRealmInfo['name']); + $cache_id = $utils->GenerateCacheId('character-sheet', $characters->GetName(), $characters->GetRealmName()); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); diff --git a/character-statistics.php b/character-statistics.php index 8605a196b..d16fc5b16 100644 --- a/character-statistics.php +++ b/character-statistics.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 465 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -67,14 +67,13 @@ $i++; } } - // $name = $comparisonData[0]['name']; } $realmId = $utils->GetRealmIdByName($_GET['r']); $characters->BuildCharacter($name, $realmId, true, true); $isCharacter = $characters->CheckPlayer(); $achievements = $characters->GetAchievementMgr(); -if($_GET['r'] === false || !Armory::$currentRealmInfo) { +if($_GET['r'] === false || !$characters->GetRealmName()) { $isCharacter = false; } // Get page cache @@ -84,7 +83,7 @@ $cache_id = $utils->GenerateCacheId('character-statistics-c'.$achievement_category, $utils->GenerateCacheIdForComparisons($comparisonData)); } else { - $cache_id = $utils->GenerateCacheId('character-statistics-c'.$achievement_category, $characters->GetName(), Armory::$currentRealmInfo['name']); + $cache_id = $utils->GenerateCacheId('character-statistics-c'.$achievement_category, $characters->GetName(), $characters->GetRealmName()); } } else { @@ -92,7 +91,7 @@ $cache_id = $utils->GenerateCacheId('character-statistics', $utils->GenerateCacheIdForComparisons($comparisonData)); } else { - $cache_id = $utils->GenerateCacheId('character-statistics', $characters->GetName(), Armory::$currentRealmInfo['name']); + $cache_id = $utils->GenerateCacheId('character-statistics', $characters->GetName(), $characters->GetRealmName()); } } if($cache_data = $utils->GetCache($cache_id)) { diff --git a/character-talents.php b/character-talents.php index fac38ef3b..8e7a81623 100644 --- a/character-talents.php +++ b/character-talents.php @@ -46,12 +46,12 @@ $realmId = $utils->GetRealmIdByName($_GET['r']); $characters->BuildCharacter($name, $realmId, true, true); $isCharacter = $characters->CheckPlayer(); -if($_GET['r'] === false || !Armory::$currentRealmInfo) { +if($_GET['r'] === false || !$characters->GetRealmName()) { $isCharacter = false; } // Get page cache if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) { - $cache_id = $utils->GenerateCacheId('character-talents', $characters->GetName(), Armory::$currentRealmInfo['name']); + $cache_id = $utils->GenerateCacheId('character-talents', $characters->GetName(), $characters->GetRealmName()); if($cache_data = $utils->GetCache($cache_id)) { echo $cache_data; echo sprintf('', $cache_id); diff --git a/guild-bank-contents.php b/guild-bank-contents.php index dc7c26a91..1bd779bf8 100644 --- a/guild-bank-contents.php +++ b/guild-bank-contents.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 455 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -37,8 +37,7 @@ else { $guilds->guildName = false; } -$serverType = Armory::$aDB->selectCell("SELECT `type` FROM `ARMORYDBPREFIX_realm_data` WHERE `name` = '%s' LIMIT 1", $utils->escape($_GET['r'])); -$isGuild = $guilds->InitGuild($serverType); +$isGuild = $guilds->InitGuild(Armory::$currentRealmInfo['type']); if(!$isGuild) { // Load XSLT template $xml->LoadXSLT('error/error.xsl'); diff --git a/guild-bank-log.php b/guild-bank-log.php index 12a2e12b0..cefaaa205 100644 --- a/guild-bank-log.php +++ b/guild-bank-log.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 455 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -36,8 +36,7 @@ else { $guilds->guildName = false; } -$serverType = Armory::$aDB->selectCell("SELECT `type` FROM `ARMORYDBPREFIX_realm_data` WHERE `name` = '%s' LIMIT 1", $utils->escape($_GET['r'])); -$isGuild = $guilds->InitGuild($serverType); +$isGuild = $guilds->InitGuild(Armory::$currentRealmInfo['type']); if(!$isGuild) { // Load XSLT template $xml->LoadXSLT('error/error.xsl'); diff --git a/guild-info.php b/guild-info.php index 9994307b9..637b49207 100644 --- a/guild-info.php +++ b/guild-info.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -36,8 +36,7 @@ else { $guilds->guildName = false; } -$serverType = Armory::$aDB->selectCell("SELECT `type` FROM `ARMORYDBPREFIX_realm_data` WHERE `name` = '%s' LIMIT 1", $utils->escape($_GET['r'])); -$isGuild = $guilds->InitGuild($serverType); +$isGuild = $guilds->InitGuild(Armory::$currentRealmInfo['type']); if(!$isGuild) { // Load XSLT template $xml->LoadXSLT('error/error.xsl'); diff --git a/guild-stats.php b/guild-stats.php index 42fc1ca43..1173e7d06 100644 --- a/guild-stats.php +++ b/guild-stats.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -36,8 +36,7 @@ else { $guilds->guildName = false; } -$serverType = Armory::$aDB->selectCell("SELECT `type` FROM `ARMORYDBPREFIX_realm_data` WHERE `name` = '%s' LIMIT 1", $utils->escape($_GET['r'])); -$isGuild = $guilds->InitGuild($serverType); +$isGuild = $guilds->InitGuild(Armory::$currentRealmInfo['type']); if(!$isGuild) { // Load XSLT template $xml->LoadXSLT('error/error.xsl'); diff --git a/includes/armory_loader.php b/includes/armory_loader.php index b9a7f7ba8..977357424 100644 --- a/includes/armory_loader.php +++ b/includes/armory_loader.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 455 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -25,12 +25,18 @@ if(!defined('__ARMORY__')) { die('Direct access to this file not allowed!'); } +session_start(); // Detect armory directory define('__ARMORYDIRECTORY__', dirname(dirname(__FILE__))); if(!defined('__ARMORYDIRECTORY__') || __ARMORYDIRECTORY__ == null) { die('Fatal error: unable to detect armory directory!'); } -session_start(); +if(!@include(__ARMORYDIRECTORY__ . '/includes/UpdateFields.php')) { + die('Error: unable to load UpdateFields.php!'); +} +if(!@include(__ARMORYDIRECTORY__ . '/includes/defines.php')) { + die('Error: unable to load defines.php!'); +} if(!@include(__ARMORYDIRECTORY__ . '/includes/classes/class.armory.php')) { die('Error: unable to load Armory class!'); } @@ -99,50 +105,13 @@ header('Location: maintenance.xml'); exit; } -if(!@include(__ARMORYDIRECTORY__ . '/includes/UpdateFields.php')) { - die('Error: unable to load UpdateFields.php!'); -} -if(!@include(__ARMORYDIRECTORY__ . '/includes/defines.php')) { - die('Error: unable to load defines.php!'); -} if(!defined('skip_utils_class')) { if(!@include(__ARMORYDIRECTORY__ . '/includes/classes/class.utils.php')) { die('Error: unable to load utils class!'); } $utils = new Utils(); - /** - * Check realm data - * This will automaticaly add missing realms to `armory_realm_data` table (if MySQL user have "INSERT" access to Armory database) - **/ - $utils->CheckConfigRealmData(); // Check $_GET variable $utils->CheckVariablesForPage(); - /* - // Check sessions count - // May be not required? - //TODO: think about this feature - $sess_count = $utils->GetSessionsCount(); - if($sess_count >= Armory::$armoryconfig['maxSessionCount'] && !$utils->IsCorrectSession() && !defined('LIMIT_PAGE')) { - header('Location: limit.xml'); - exit; - } - elseif($sess_count < Armory::$armoryconfig['maxSessionCount'] && !$utils->IsCorrectSession()) { - // we can create session - $utils->CreateNewSession(); - if(defined('LIMIT_PAGE')) { - header('Location: index.xml'); - exit; - } - } - elseif($sess_count < Armory::$armoryconfig['maxSessionCount'] && $utils->IsCorrectSession()) { - // just update - $utils->UpdateSession(); - if(defined('LIMIT_PAGE')) { - header('Location: index.xml'); - exit; - } - } - */ } /** Login **/ if(isset($_GET['login']) && $_GET['login'] == 1) { @@ -264,7 +233,7 @@ } // Start XML parser if(!@include(__ARMORYDIRECTORY__ . '/includes/classes/class.xmlhandler.php')) { - die('Error: unable to load XML handler class!'); + die('Error: unable to load XML Handler Class!'); } $xml = new XMLHandler(Armory::GetLocale()); if(!defined('RSS_FEED')) { diff --git a/includes/classes/class.achievements.php b/includes/classes/class.achievements.php index 3820cc2b2..200662653 100644 --- a/includes/classes/class.achievements.php +++ b/includes/classes/class.achievements.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -80,10 +80,6 @@ public function InitAchievements($player_guid, $db, $check = true) { $this->achId = 0; $this->m_count = 0; $this->pts = 0; - if($check == true && !$this->db->selectCell("SELECT 1 FROM `characters` WHERE `guid`=%d LIMIT 1", $player_guid)) { - Armory::Log()->writeError('%s : player with guid %d was not found in `characters` table!', __METHOD__, $player_guid); - return false; - } $this->guid = $player_guid; self::CalculateAchievementPoints(); self::CountCharacterAchievements(); @@ -448,9 +444,6 @@ public function LoadAchievementPage($page_id, $faction) { foreach($achievements_data as $achievement) { $this->achId = $achievement['id']; $completed = self::IsAchievementCompleted($this->achId); - if($completed) { - Armory::Log()->writeLog('%s : ach #%d is completed for player %d', __METHOD__, $this->achId, $this->guid); - } $parentId = Armory::$aDB->selectCell("SELECT `parentAchievement` FROM `ARMORYDBPREFIX_achievement` WHERE `id`=%d", $this->achId); if($completed) { $return_data['completed'][$this->achId]['data'] = $achievement; diff --git a/includes/classes/class.arenateams.php b/includes/classes/class.arenateams.php index e23344a76..5bb1f0f25 100644 --- a/includes/classes/class.arenateams.php +++ b/includes/classes/class.arenateams.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -81,7 +81,7 @@ public function GetArenaTeamInfo() { } $arenateaminfo = array(); switch(Armory::$currentRealmInfo['type']) { - case 'mangos': + case SERVER_MANGOS: $sql = " `games_week` AS `gamesPlayed`, `wins_week` AS `gamesWon`, @@ -89,7 +89,7 @@ public function GetArenaTeamInfo() { `games_season` AS `seasonGamesPlayed`, `wins_season` AS `seasonGamesWon`"; break; - case 'trinity': + case SERVER_TRINITY: $sql = " `games` AS `gamesPlayed`, `wins` AS `gamesWon`, @@ -176,7 +176,7 @@ public function GetCharacterArenaTeamInfo() { * @return bool **/ public function GetTeamList() { - if(Armory::$currentRealmInfo['type'] == 'mangos') { + if(Armory::$currentRealmInfo['type'] == SERVER_MANGOS) { $this->players = Armory::$cDB->select(" SELECT `arena_team_member`.`played_season` AS `seasonGamesPlayed`, @@ -191,7 +191,7 @@ public function GetTeamList() { LEFT JOIN `characters` AS `characters` ON `characters`.`guid`=`arena_team_member`.`guid` WHERE `arena_team_member`.`arenateamid`=%d", $this->arenateamid); } - elseif(Armory::$currentRealmInfo['type'] == 'trinity') { + elseif(Armory::$currentRealmInfo['type'] == SERVER_TRINITY) { switch($this->teamtype) { case 2: default: @@ -265,7 +265,7 @@ public function BuildArenaLadderList($type, $page, $num = false, $order = 'ratin // Special sorting switch($realm_info['type']) { default: - case 'mangos': + case SERVER_MANGOS: $realmArenaTeamInfo = $db->select(" SELECT `arena_team`.`arenateamid`, @@ -284,7 +284,7 @@ public function BuildArenaLadderList($type, $page, $num = false, $order = 'ratin WHERE `arena_team`.`type`=%d AND `arena_team_stats`.`rank` > 0 ORDER BY `lose` %s LIMIT %d, 20", $type, $sort, $page); break; - case 'trinity': + case SERVER_TRINITY: $realmArenaTeamInfo = $db->select(" SELECT `arena_team`.`arenateamid`, @@ -308,7 +308,7 @@ public function BuildArenaLadderList($type, $page, $num = false, $order = 'ratin else { switch($realm_info['type']) { default: - case 'mangos': + case SERVER_MANGOS: $realmArenaTeamInfo = $db->select(" SELECT `arena_team`.`arenateamid`, @@ -326,7 +326,7 @@ public function BuildArenaLadderList($type, $page, $num = false, $order = 'ratin WHERE `arena_team`.`type`=%d AND `arena_team_stats`.`rank` > 0 ORDER BY %s %s LIMIT %d, 20", $type, $order, $sort, $page); break; - case 'trinity': + case SERVER_TRINITY: $realmArenaTeamInfo = $db->select(" SELECT `arena_team`.`arenateamid`, diff --git a/includes/classes/class.armory.php b/includes/classes/class.armory.php index f88cc1ad6..9b7321d0e 100644 --- a/includes/classes/class.armory.php +++ b/includes/classes/class.armory.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -91,14 +91,12 @@ public static function InitializeArmory() { else { $realmName = urldecode($_GET['r']); } - $realm_info = self::$aDB->selectRow("SELECT `id`, `version` FROM `ARMORYDBPREFIX_realm_data` WHERE `name`='%s'", $realmName); - if(isset(self::$realmData[$realm_info['id']])) { - self::$connectionData = self::$realmData[$realm_info['id']]; + $realm_id = self::FindRealm($realmName); + if(isset(self::$realmData[$realm_id])) { + self::$connectionData = self::$realmData[$realm_id]; self::$cDB = new ArmoryDatabaseHandler(self::$connectionData['host_characters'], self::$connectionData['user_characters'], self::$connectionData['pass_characters'], self::$connectionData['name_characters'], self::$connectionData['charset_characters']); - self::$currentRealmInfo = array('name' => self::$connectionData['name'], 'id' => $realm_info['id'], 'type' => self::$connectionData['type'], 'connected' => true); - if(isset(self::$connectionData['name_world'])) { - self::$wDB = new ArmoryDatabaseHandler(self::$connectionData['host_world'], self::$connectionData['user_world'], self::$connectionData['pass_world'], self::$connectionData['name_world'], self::$connectionData['charset_world']); - } + self::$currentRealmInfo = array('name' => self::$connectionData['name'], 'id' => $realm_id, 'type' => self::$connectionData['type'], 'connected' => true); + self::$wDB = new ArmoryDatabaseHandler(self::$connectionData['host_world'], self::$connectionData['user_world'], self::$connectionData['pass_world'], self::$connectionData['name_world'], self::$connectionData['charset_world']); } } $realm_info = self::$realmData[1]; @@ -226,5 +224,15 @@ public static function SetLocale($locale, $locale_id) { self::$_loc = $locale_id; return true; } + + public static function FindRealm($realm_name) { + $realm_name = urldecode($realm_name); + foreach(self::$realmData as $realm) { + if($realm['name'] == $realm_name) { + return $realm['id']; + } + } + return 0; + } } ?> \ No newline at end of file diff --git a/includes/classes/class.characters.php b/includes/classes/class.characters.php index 78ac2d328..020c5c030 100644 --- a/includes/classes/class.characters.php +++ b/includes/classes/class.characters.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 451 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -256,6 +256,49 @@ **/ private $char_data = array(); + /** + * + **/ + private $load_options = array(); + + public function Characters() { + // Reset load options + $this->load_options = array( + 'load_achievements' => true, // Achievement Manager + 'load_inventory' => false, // Inventory + 'load_feeds' => false, // Character Feed + 'load_data' => false, // Data field + 'load_info' => true // Class, race info + ); + return true; + } + + public function SetOptions($options) { + if(!is_array($options)) { + switch($options) { + case LOAD_ALL: + default: + foreach($this->load_options as $opt_key => $opt_value) { + $this->load_options[$opt_key] = true; + } + return true; + break; + case LOAD_NOTHING: + foreach($this->load_options as $opt_key => $opt_value) { + $this->load_options[$opt_key] = false; + } + return true; + break; + } + } + foreach($options as $op_key => $op_value) { + if(isset($this->load_options[$op_key])) { + $this->load_options[$op_key] = $op_value; + } + } + return true; + } + /** * Init character, load data from DB, checks for requirements, etc. * @category Characters class @@ -287,7 +330,7 @@ public function BuildCharacter($name, $realmId = 1, $full = true, $initialBuild return false; } // Set server type (SERVER_MANGOS or SERVER_TRINITY) - $this->m_server = Armory::$aDB->selectCell("SELECT `type` FROM `ARMORYDBPREFIX_realm_data` WHERE `id`=%d", $realmId); + $this->m_server = $realm_info['type']; if($this->m_server == UNK_SERVER) { Armory::Log()->writeError('%s : unknown server type! Unable to initialize characters class (character name: %s, realmId: %d)', __METHOD__, $name, $realmId); return false; @@ -343,14 +386,14 @@ public function BuildCharacter($name, $realmId = 1, $full = true, $initialBuild Armory::Log()->writeError('%s: unable to get data from characters DB for player %s (realmId: %d, expected realmName: %s, currentRealmName: %s)', __METHOD__, $name, $realmId, (isset($_GET['r'])) ? $_GET['r'] : 'none', $realm_info['name']); return false; } - if($full == true && $loadType == 0) { + if($this->load_options['load_data'] == true) { // Character data required for character-sheet.xml page only. - if(!$this->db->selectCell("SELECT 1 FROM `armory_character_stats` WHERE `guid`=%d LIMIT 1", $player_data['guid'])) { + $this->char_data = $this->db->selectCell("SELECT `data` FROM `armory_character_stats` WHERE `guid` = %d LIMIT 1", $player_data['guid']); + if(!$this->char_data) { Armory::Log()->writeError('%s : player %d (%s) has no data in `armory_character_stats` table (SQL update to Characters DB was not applied? / Character was not saved in game? / Server core was not patched?)', __METHOD__, $player_data['guid'], $player_data['name']); unset($player_data); return false; } - $this->char_data = $this->db->selectCell("SELECT `data` FROM `armory_character_stats` WHERE `guid` = %d LIMIT 1", $player_data['guid']); $this->HandleCharacterData(); } // Can we display this character? @@ -394,7 +437,7 @@ public function BuildCharacter($name, $realmId = 1, $full = true, $initialBuild } } $this->HandleEquipmentCacheData(); - if($full == true && $loadType == 0) { + if($this->load_options['load_info'] == true) { // Get race and class strings $race_class = Armory::$aDB->selectRow(" SELECT @@ -414,23 +457,21 @@ public function BuildCharacter($name, $realmId = 1, $full = true, $initialBuild if($this->chosenTitle > 0) { $this->HandleChosenTitleInfo(); } - if(defined('load_item_class') && defined('load_itemprototype_class')) { - // Load items - $this->LoadInventory(); - } + } + if($this->load_options['load_inventory'] == true) { + // Load items + $this->LoadInventory(); } $this->realmName = $realm_info['name']; $this->realmID = $realm_info['id']; - unset($realm_info); - // Initialize achievement manager - if(defined('load_achievements_class') && class_exists('Achievements')) { + if($this->load_options['load_achievements']) { + // Initialize achievement manager $this->m_achievementMgr = new Achievements; $this->m_achievementMgr->InitAchievements($this->guid, $this->db, true); - if($full) { - // Load Feed data - $this->LoadFeedData(); - // Character feed feature requires Achievements class! - } + } + if($this->load_options['load_feeds']) { + // Load Feed data + $this->LoadFeedData(); } // Everything correct if($initialBuild == true) { @@ -439,6 +480,7 @@ public function BuildCharacter($name, $realmId = 1, $full = true, $initialBuild Armory::Log()->writeLog('%s : WARNING: %s\'s (GUID: %d) level is more than GT_MAX_LEVEL (%d) - %d. This may cause some errors at data generation.', __METHOD__, $this->GetName(), $this->GetGUID(), GT_MAX_LEVEL, $this->GetLevel()); } } + unset($realm_info); return true; } @@ -1046,7 +1088,7 @@ public function GetTalentTab($tab_count = -1) { /** * Calculates and returns array with character talent specs. !Required $this->guid and $this->class! - * Depends on Armory::$currentRealmInfo['type'] ('mangos' or 'trinity' realm) + * Depends on $this->m_server value (SERVER_MANGOS or SERVER_TRINITY) * @category Character class * @access public * @return array @@ -1187,23 +1229,19 @@ public function CalculateCharacterTalentBuild() { if(!isset($tab_class[$i])) { continue; } - switch(Armory::$currentRealmInfo['type']) { - case 'mangos': - $current_tab = Armory::$aDB->select("SELECT `TalentID`, `TalentTab`, `Row`, `Col` FROM `ARMORYDBPREFIX_talents` WHERE `TalentTab`=%d ORDER BY `TalentTab`, `Row`, `Col`", $tab_class[$i]); - if(!$current_tab) { - continue; + $current_tab = Armory::$aDB->select("SELECT `TalentID`, `TalentTab`, `Row`, `Col` FROM `ARMORYDBPREFIX_talents` WHERE `TalentTab`=%d ORDER BY `TalentTab`, `Row`, `Col`", $tab_class[$i]); + if(!$current_tab) { + continue; + } + foreach($current_tab as $tab) { + for($j = 0; $j < 2; $j++) { + if(isset($specs_talents[$j][$tab['TalentID']])) { + $talent_data[$j] .= $specs_talents[$j][$tab['TalentID']]; } - foreach($current_tab as $tab) { - for($j = 0; $j < 2; $j++) { - if(isset($specs_talents[$j][$tab['TalentID']])) { - $talent_data[$j] .= $specs_talents[$j][$tab['TalentID']]; - } - else { - $talent_data[$j] .= 0; - } - } + else { + $talent_data[$j] .= 0; } - break; + } } } } diff --git a/includes/classes/class.dbhandler.php b/includes/classes/class.dbhandler.php index 57e7e66b6..244986be8 100644 --- a/includes/classes/class.dbhandler.php +++ b/includes/classes/class.dbhandler.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 451 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -92,6 +92,9 @@ public function ArmoryDatabaseHandler($host, $user, $password, $dbName, $charset $this->armory_prefix = $prefix; $this->server_version = $this->selectCell("SELECT VERSION()"); $this->connected = true; + ///*if(defined('TEST_CONNECTION')) { + Armory::Log()->writeLog('%s : test connection: connected: %s', __METHOD__, var_export($this->databaseInfo)); + //*/} return true; } @@ -284,6 +287,9 @@ public function __destruct() { @mysql_close($this->connectionLink); $this->DropLastErrors(); $this->DropCounters(); + ///*if(defined('TEST_CONNECTION')) { + Armory::Log()->writeLog('%s : test connection: closed', __METHOD__); + //*/} return true; } diff --git a/includes/classes/class.guilds.php b/includes/classes/class.guilds.php index ddccd0090..7a3c92c48 100644 --- a/includes/classes/class.guilds.php +++ b/includes/classes/class.guilds.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -214,6 +214,8 @@ public function BuildGuildList() { $countMembers = count($memberListTmp); for($i = 0; $i < $countMembers; $i++) { $pl = new Characters(); + $pl->SetOptions(LOAD_NOTHING); + $pl->SetOptions(array('load_achievements' => true)); $pl->BuildCharacter($memberListTmp[$i]['name'], Armory::$currentRealmInfo['id'], false); $memberListTmp[$i]['achPoints'] = $pl->GetAchievementMgr()->GetAchievementPoints(); $memberListTmp[$i]['url'] = sprintf('r=%s&cn=%s&gn=%s', urlencode(Armory::$currentRealmInfo['name']), urlencode($memberListTmp[$i]['name']), urlencode($this->guildName)); diff --git a/includes/classes/class.items.php b/includes/classes/class.items.php index dd43e5610..774989a6f 100644 --- a/includes/classes/class.items.php +++ b/includes/classes/class.items.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -739,7 +739,7 @@ public function GetItemSocketInfo($guid, $item, $socketNum, $item_guid = 0, $ser $serverType = Armory::$currentRealmInfo['type']; } switch($serverType) { - case 'mangos': + case SERVER_MANGOS: $socketfield = array( 1 => ITEM_FIELD_ENCHANTMENT_3_2, 2 => ITEM_FIELD_ENCHANTMENT_4_2, @@ -758,7 +758,7 @@ public function GetItemSocketInfo($guid, $item, $socketNum, $item_guid = 0, $ser WHERE `owner_guid`=%d AND `guid`=%d", $socketfield[$socketNum], $guid, $item_guid); } break; - case 'trinity': + case SERVER_TRINITY: $socketfield = array( 1 => 6, 2 => 9, diff --git a/includes/classes/class.utils.php b/includes/classes/class.utils.php index a7393bd42..fe8438c83 100644 --- a/includes/classes/class.utils.php +++ b/includes/classes/class.utils.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -311,17 +311,12 @@ public function GetActiveCharacter() { if(!isset($_SESSION['accountId'])) { return false; } - return Armory::$aDB->selectRow(" - SELECT - `ARMORYDBPREFIX_login_characters`.`guid`, - `ARMORYDBPREFIX_login_characters`.`name`, - `ARMORYDBPREFIX_login_characters`.`race`, - `ARMORYDBPREFIX_login_characters`.`realm_id`, - `ARMORYDBPREFIX_realm_data`.`name` AS `realmName` - FROM `ARMORYDBPREFIX_login_characters` AS `ARMORYDBPREFIX_login_characters` - LEFT JOIN `ARMORYDBPREFIX_realm_data` AS `ARMORYDBPREFIX_realm_data` ON `ARMORYDBPREFIX_realm_data`.`id`=`ARMORYDBPREFIX_login_characters`.`realm_id` - WHERE `ARMORYDBPREFIX_login_characters`.`account`=%d AND `ARMORYDBPREFIX_login_characters`.`selected`=1 LIMIT 1 - ", $_SESSION['accountId']); + $char_data = Armory::$aDB->selectRow("SELECT `guid`, `name`, `race`, `realm_id` FROM `ARMORYDBPREFIX_login_characters` WHERE `account`=%d AND `selected`=1 LIMIT 1", $_SESSION['accountId']); + if(!$char_data) { + return false; + } + $char_data['realmName'] = Armory::$realmData[$char_data['realm_id']]['name']; + return $char_data; } /** @@ -383,14 +378,14 @@ public function GetBookmarks() { } $result = array(); foreach($bookmarks_data as $bookmark) { - $realm = Armory::$aDB->selectRow("SELECT `id`, `name` FROM `ARMORYDBPREFIX_realm_data` WHERE `name`='%s'", $bookmark['realm']); - if(!$realm) { + $realm_id = Armory::FindRealm($bookmark['realm']); + if($realm_id == 0) { continue; } - elseif(!isset(Armory::$realmData[$realm['id']])) { + elseif(!isset(Armory::$realmData[$realm_id])) { continue; } - $realm_info = Armory::$realmData[$realm['id']]; + $realm_info = Armory::$realmData[$realm_id]; $db = new ArmoryDatabaseHandler($realm_info['host_characters'], $realm_info['user_characters'], $realm_info['pass_characters'], $realm_info['name_characters'], $realm_info['charset_characters']); if(!$db) { continue; @@ -424,14 +419,14 @@ public function AddBookmark($name, $realmName) { // Unable to store more than 60 bookmarks for single account return false; } - $realm = Armory::$aDB->selectRow("SELECT `id`, `name` FROM `ARMORYDBPREFIX_realm_data` WHERE `name`='%s'", $realmName); + $realm_id = Armory::FindRealm($realmName); if(!$realm) { return false; } - elseif(!isset(Armory::$realmData[$realm['id']])) { + elseif(!isset(Armory::$realmData[$realm_id])) { return false; } - $realm_info = Armory::$realmData[$realm['id']]; + $realm_info = Armory::$realmData[$realm_id]; $db = new ArmoryDatabaseHandler($realm_info['host_characters'], $realm_info['user_characters'], $realm_info['pass_characters'], $realm_info['name_characters'], $realm_info['charset_characters']); if(!$db) { return false; @@ -510,7 +505,7 @@ public function ComputePetBonus($stat, $value, $unitClass) { return $value * $warlock_pet_bonus[$stat]; } else { - return 0; + return -1; } } elseif($unitClass == CLASS_HUNTER) { @@ -518,10 +513,10 @@ public function ComputePetBonus($stat, $value, $unitClass) { return $value * $hunter_pet_bonus[$stat]; } else { - return 0; + return -1; } } - return 0; + return -1; } /** @@ -758,7 +753,7 @@ public function GetAttackPowerForStat($statIndex, $effectiveStat, $class) { case CLASS_DRUID: $baseStr = min($effectiveStat,20); $moreStr = $effectiveStat-$baseStr; - $ap = $baseStr + 2*$moreStr; + $ap = $baseStr + 2 * $moreStr; break; default: $ap = $effectiveStat - 10; @@ -774,8 +769,8 @@ public function GetAttackPowerForStat($statIndex, $effectiveStat, $class) { break; } } - if($ap < 0) { - $ap = 0; + if($ap <= 0) { + return -1; } return $ap; } @@ -792,12 +787,15 @@ public function GetAttackPowerForStat($statIndex, $effectiveStat, $class) { **/ public function GetCritChanceFromAgility($rating, $class, $agility) { if(!is_array($rating)) { - return 0; + return -1; } $base = array(3.1891, 3.2685, -1.532, -0.295, 3.1765, 3.1890, 2.922, 3.454, 2.6222, 20, 7.4755); $ratingkey = array_keys($rating); if(isset($ratingkey[$class]) && isset($rating[$ratingkey[$class]]) && isset($base[$class-1])) { - return $base[$class-1] + $agility*$rating[$ratingkey[$class]]*100; + return $base[$class-1] + $agility * $rating[$ratingkey[$class]] * 100; + } + else { + return -1; } } @@ -1291,16 +1289,16 @@ public function GetPetTalentCalculatorData($key) { * @return int **/ public function IsRealm($rName) { - $realmId = Armory::$aDB->selectCell("SELECT `id` FROM `ARMORYDBPREFIX_realm_data` WHERE `name`='%s'", $rName); + $realmId = Armory::FindRealm($rName); if($realmId > 0) { return $realmId; } - Armory::Log()->writeError('%s : unable to find id for realm %s (armory_realm_data)', __METHOD__, $rName); + Armory::Log()->writeError('%s : unable to find id for realm "%s".', __METHOD__, $rName); return false; } /** - * Returns realm ID from DB + * Returns realm ID * @category Utils class * @access public * @param string $rName @@ -1414,37 +1412,6 @@ public function IsItemComparisonAllowed() { } } - /** - * Checks all realms for correct configs (in configuration.php and `armory_realm_data` table) - * and inserts data to DB if something missing. - * @category Utils class - * @access public - * @return bool - **/ - public function CheckConfigRealmData() { - if(!Armory::$realmData || !is_array(Armory::$realmData) || !isset(Armory::$realmData[1])) { - Armory::Log()->writeError('%s : unable to detect correct multiRealm config. Please, make sure that you have read INSTALL file and have configured Armory correctly.', __METHOD__); - return false; - } - $allIds = array(); - foreach(Armory::$realmData as $myRealm) { - $tmpData = Armory::$aDB->selectRow("SELECT `id`, `name`, `type` FROM `ARMORYDBPREFIX_realm_data` WHERE `name`='%s' LIMIT 1", $myRealm['name']); - if((!$tmpData || !is_array($tmpData)) || ($tmpData['id'] != $myRealm['id'] || $tmpData['name'] != $myRealm['name'] || $tmpData['type'] == UNK_SERVER)) { - $replace = Armory::$aDB->query("REPLACE INTO `ARMORYDBPREFIX_realm_data` (`id`, `name`, `type`) VALUES (%d, '%s', %d)", $myRealm['id'], $myRealm['name'], self::GetServerTypeByString($myRealm['type'])); - if($replace) { - Armory::Log()->writeLog('%s : realm data for realm "%s" was successfully added to `armory_realm_data` table.', __METHOD__, $myRealm['name']); - } - else { - Armory::Log()->writeError('%s : realm data for realm "%s" was not added to `%s_realm_data` table. Please, execute this query manually: "REPLACE INTO `%s_realm_data` (`id`, `name`, `type`) VALUES (%d, \'%s\', %d);"', __METHOD__, $myRealm['name'], Armory::$armoryconfig['db_prefix'], Armory::$armoryconfig['db_prefix'], $myRealm['id'], $myRealm['name'], self::GetServerTypeByString($myRealm['type'])); - } - } - $allIds[] = $myRealm['id']; - } - // Drop wrong realms from armory_realm_data table - Armory::$aDB->query("DELETE FROM `ARMORYDBPREFIX_realm_data` WHERE `id` NOT IN (%s)", $allIds); - return true; - } - /** * Returns true if script should use XMLWriter::WriteRaw() instead of special methods. * Required for fr/de/es locales. @@ -1497,7 +1464,6 @@ public function IsAchievementsComparison($returnFirstRealmName = false) { $data = array(); for($i = 0; $i < $totalCount; $i++) { if(!isset($realms[$i]) || !isset($chars[$i])) { - Armory::Log()->writeError('%s : data check for loop %d was failed, ignore.', __METHOD__, $i); continue; } $data[$i] = array('name' => $chars[$i], 'realm' => $realms[$i]); @@ -1596,36 +1562,6 @@ public function GetRaceBitMaskByRaceId($raceId) { return $mask; } - /** - * Returns realm type for provided $realm_id. - * Warning: if detection fails, realm with provided ID will be deleted from allowed realms! - * @category Utils class - * @access public - * @param int $realm_id - * @return mixed - **/ - public function GetRealmType($realm_id) { - if(!isset(Armory::$realmData[$realm_id]) || !isset(Armory::$realmData[$realm_id]['name_world'])) { - Armory::Log()->writeError('%s : unable to detect realm type: world database config not found', __METHOD__); - return false; - } - $realm_info = Armory::$realmData[$realm_id]; - $db = new ArmoryDatabaseHandler($realm_info['host_world'], $realm_info['user_world'], $realm_info['pass_world'], $realm_info['name_world'], $realm_info['charset_world']); - if(!$db->TestLink()) { - Armory::Log()->writeError('%s : unable to connect to MySQL database ("%s":"%s":"%s":"%s")', __METHOD__, $realm_info['host_world'], str_replace(substr($realm_info['user_world'], 2, 3), '***', $realm_info['user_world']), str_replace(substr($realm_info['pass_world'], 2, 3), '***', $realm_info['pass_world']), $realm_info['name_world']); - return false; - } - if($tmp = $db->selectCell("SELECT 1 FROM `mangos_string` LIMIT 1")) { - return 'mangos'; - } - elseif($tmp = $db->selectCell("SELECT 1 FROM `trinity_string` LIMIT 1")) { - return 'trinity'; - } - Armory::Log()->writeError('%s : unable to detect realm type, realm info with ID #%d was removed from allowed realms', __METHOD__, $realm_id); - unset($realm_id, $realm_info, Armory::$realmData[$realm_id], $db); - return false; - } - /** * Generate cache ID (md5 hash) for comparison cases (achievements/statistics). * @category Utils class diff --git a/includes/classes/configuration.php.default b/includes/classes/configuration.php.default index 3bf8ac7e3..b13355606 100644 --- a/includes/classes/configuration.php.default +++ b/includes/classes/configuration.php.default @@ -3,8 +3,8 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 - * @copyright (c) 2009-2011 Shadez + * @revision 456 + * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * * This program is free software; you can redistribute it and/or modify @@ -145,7 +145,7 @@ $ArmoryConfig['settings']['defaultLocale'] = 'en_gb'; $ArmoryConfig['settings']['maintenance'] = false; $ArmoryConfig['settings']['useDebug'] = true; $ArmoryConfig['settings']['logLevel'] = 2; -$ArmoryConfig['settings']['configVersion'] = '2812201001'; +$ArmoryConfig['settings']['configVersion'] = '1801201101'; $ArmoryConfig['settings']['checkVersionType'] = 'show'; ############################################################################################## @@ -158,7 +158,7 @@ $ArmoryConfig['settings']['checkVersionType'] = 'show'; # Realm name. Must be unique. # # type -# Server type ('mangos' or 'trinity'). +# Server type (SERVER_MANGOS or SERVER_TRINITY). # # host_* # MySQL server host for characters/world database. @@ -182,7 +182,7 @@ $ArmoryConfig['settings']['checkVersionType'] = 'show'; $ArmoryConfig['multiRealm'][1]['id'] = 1; $ArmoryConfig['multiRealm'][1]['name'] = 'Armory Realm'; -$ArmoryConfig['multiRealm'][1]['type'] = 'mangos'; +$ArmoryConfig['multiRealm'][1]['type'] = SERVER_MANGOS; $ArmoryConfig['multiRealm'][1]['host_characters'] = 'localhost'; $ArmoryConfig['multiRealm'][1]['user_characters'] = 'root'; $ArmoryConfig['multiRealm'][1]['pass_characters'] = ''; @@ -196,7 +196,7 @@ $ArmoryConfig['multiRealm'][1]['charset_world'] = 'UTF8'; $ArmoryConfig['multiRealm'][2]['id'] = 2; $ArmoryConfig['multiRealm'][2]['name'] = 'Armory Realm 2'; -$ArmoryConfig['multiRealm'][2]['type'] = 'trinity'; +$ArmoryConfig['multiRealm'][2]['type'] = SERVER_TRINITY; $ArmoryConfig['multiRealm'][2]['host_characters'] = 'localhost'; $ArmoryConfig['multiRealm'][2]['user_characters'] = 'root'; $ArmoryConfig['multiRealm'][2]['pass_characters'] = ''; diff --git a/includes/defines.php b/includes/defines.php index 205fd31b3..d931234fe 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -847,4 +847,7 @@ /** Bookmarks and selected characters **/ define('MAX_BOOKMARKS_COUNT', 60); define('MAX_SELECTED_CHARACTERS_COUNT', 5); + +define('LOAD_ALL', 1); +define('LOAD_NOTHING', 2); ?> \ No newline at end of file diff --git a/includes/revision_nr.php b/includes/revision_nr.php index 740da37df..fa83c711c 100644 --- a/includes/revision_nr.php +++ b/includes/revision_nr.php @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/item-tooltip.php b/item-tooltip.php index f1e3a5993..3f6f98e1e 100644 --- a/item-tooltip.php +++ b/item-tooltip.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -36,6 +36,8 @@ $name = (isset($_GET['cn'])) ? $_GET['cn'] : null; $realmId = (isset($_GET['r'])) ? $utils->GetRealmIdByName($_GET['r']) : 1; if($name != null) { + $characters->SetOptions(LOAD_NOTHING); + $characters->SetOptions(array('load_inventory' => true)); $characters->BuildCharacter($name, $realmId); } $isCharacter = $characters->CheckPlayer(); @@ -80,6 +82,8 @@ if(isset($primaryCharacter['name'])) { if($primaryCharacter['name'] != $characters->GetName() || ($primaryCharacter['name'] == $characters->GetName() && $primaryCharacter['realm_id'] != $characters->GetRealmID())) { $newChar = new Characters(); + $newChar->SetOptions(LOAD_NOTHING); + $newChar->SetOptions(array('load_inventory' => true)); $newChar->BuildCharacter($primaryCharacter['name'], $primaryCharacter['realm_id']); if($newChar->CheckPlayer()) { $itemSlot = $items->GetItemSlotId($itemID); diff --git a/search.php b/search.php index 35f8100bc..807f8fa6d 100644 --- a/search.php +++ b/search.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release 4.50 - * @revision 450 + * @revision 456 * @copyright (c) 2009-2011 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -58,6 +58,7 @@ if(isset($_GET['pi']) && is_numeric($_GET['pi']) && $_GET['pi'] > 0) { $findGearUpgrade = true; $itemID = (int) $_GET['pi']; + $characters->SetOptions(LOAD_NOTHING); $characters->BuildCharacter($_GET['pn'], $utils->GetRealmIdByName($_GET['pr']), false); if(!$characters->CheckPlayer()) { $plLevel = 80; diff --git a/sql/updates/armory_r456_armory_realm_data.sql b/sql/updates/armory_r456_armory_realm_data.sql new file mode 100644 index 000000000..1c32e132e --- /dev/null +++ b/sql/updates/armory_r456_armory_realm_data.sql @@ -0,0 +1,2 @@ +UPDATE `armory_db_version` SET `version` = 'armory_r456'; +DROP TABLE `armory_realm_data`; \ No newline at end of file