/** * Returns array with all characters. * @category Utils class * @access public * @return array **/ public function GetAllCharacters() { if (!isset($_SESSION['accountId'])) { return false; } $results = array(); foreach (Armory::$realmData as $realm_info) { $db = new Armory::$dbClass($realm_info['host_characters'], $realm_info['user_characters'], $realm_info['pass_characters'], $realm_info['port_characters'], $realm_info['name_characters'], $realm_info['charset_characters']); if (!$db) { continue; } $chars_data = $db->select("\n SELECT\n `characters`.`guid`,\n `characters`.`name`,\n `characters`.`class` AS `classId`,\n `characters`.`race` AS `raceId`,\n `characters`.`gender` AS `genderId`,\n `characters`.`level`,\n `guild_member`.`guildid` AS `guildId`,\n `guild`.`name` AS `guild`\n FROM `characters` AS `characters`\n LEFT JOIN `guild_member` AS `guild_member` ON `guild_member`.`guid`=`characters`.`guid`\n LEFT JOIN `guild` AS `guild` ON `guild`.`guildid`=`guild_member`.`guildId`\n WHERE `characters`.`account`=%d", $_SESSION['accountId']); if (!$chars_data) { Armory::Log()->writeLog('%s : no characters found for account %d in `%s` database', __METHOD__, $_SESSION['accountId'], $realm_info['name_characters']); continue; } foreach ($chars_data as $realm) { $realm['account'] = strtoupper($_SESSION['username']); $realm['factionId'] = self::GetFactionId($realm['raceId']); $realm['realm'] = $realm_info['name']; $realm['relevance'] = 100; if ($realm['level'] < Armory::$armoryconfig['minlevel']) { $realm['relevance'] = 0; } elseif ($realm['level'] >= Armory::$armoryconfig['minlevel'] && $realm['level'] <= 79) { $realm['relevance'] = $realm['level']; } elseif ($realm['level'] == MAX_PLAYER_LEVEL) { $realm['relevance'] = 100; } else { $realm['relevance'] = 0; // Unknown } $realm['url'] = sprintf('r=%s&cn=%s', urlencode($realm['realm']), urlencode($realm['name'])); $realm['selected'] = Armory::$aDB->selectCell("SELECT `selected` FROM `ARMORYDBPREFIX_login_characters` WHERE `account`=%d AND `guid`=%d AND `realm_id`=%d LIMIT 1", $_SESSION['accountId'], $realm['guid'], $realm_info['id']); if ($realm['selected'] > 2) { $realm['selected'] = 2; } elseif ($realm['selected'] == 0) { unset($realm['selected']); } $ach = new Achievements(); $ach->InitAchievements($realm['guid'], $db); $realm['achPoints'] = $ach->CalculateAchievementPoints(); unset($realm['guid'], $ach); // Do not show GUID in XML results $results[] = $realm; } } if (is_array($results)) { return $results; } Armory::Log()->writeLog('%s : unable to find any character for account %d', __METHOD__, $_SESSION['accountId']); return false; }
public function GetHeader(Achievements $achievements) { $header = array('battleGroup' => $this->armoryconfig['defaultBGName'], 'charUrl' => $this->GetUrlString(), 'class' => $this->classText, 'classId' => $this->class, 'classUrl' => sprintf("c=%s", urlencode($this->classText)), 'faction' => null, 'factionId' => $this->faction, 'gender' => null, 'genderId' => $this->gender, 'guildName' => $this->guild_id > 0 ? $this->guild_name : null, 'guildUrl' => $this->guild_id > 0 ? sprintf('r=%s&gn=%s', urlencode($this->currentRealmInfo['name']), urlencode($this->guild_name)) : null, 'lastModified' => null, 'level' => $this->level, 'name' => $this->name, 'points' => $achievements->CalculateAchievementPoints(), 'prefix' => $this->character_title['prefix'], 'race' => $this->raceText, 'raceId' => $this->race, 'realm' => $this->currentRealmInfo['name'], 'suffix' => $this->character_title['suffix'], 'titleId' => $this->character_title['titleId']); return $header; }