Beispiel #1
0
 public static function Initialize($is_enabled, $log_level)
 {
     self::$is_enabled = $is_enabled;
     self::$log_level = $log_level;
     self::$file = WOW_DIRECTORY . '/_debug/tmp.dbg';
     return true;
 }
Beispiel #2
0
 public static function InitPage($page_type, $category)
 {
     if (!in_array($page_type, array('items', 'item'))) {
         WoW_Log::WriteError('%s : wrong page type (%s)!', __METHOD__, $page_type);
         return false;
     }
     WoW_Template::SetPageData('breadcrumb', '0,0');
     switch ($page_type) {
         case 'items':
             self::ExtractCategory($page_type, $category, self::$m_items_class, self::$m_items_subclass);
             if (isset($_GET['filter'])) {
                 self::SetFilter($_GET['filter']);
             }
             self::LoadItems();
             self::HandleItems();
             break;
         case 'item':
             self::$m_id = (int) $category;
             self::$m_pageType = 'item';
             if (self::IsPower()) {
                 self::GetPower();
                 // Do not load item here
             }
             self::LoadItem();
             self::HandleItem();
             break;
     }
     return true;
 }
 public static function Initialize($is_enabled, $log_level)
 {
     self::$is_enabled = $is_enabled;
     self::$log_level = $log_level;
     self::$file = ESTATICO_DIR . '_debug' . DS . 'tmp.dbg';
     return true;
 }
 public function GetTopTeams($format, $bg_id, $limit = 3, $offset = 0, $count = false)
 {
     if (!isset(WoWConfig::$BattleGroups[$bg_id])) {
         WoW_Log::WriteError('%s : battleGroupd #%d was not found!', __METHOD__, $bg_id);
         return false;
     }
     $realms = WoWConfig::$BattleGroups[$bg_id]['realms'];
     if (!$realms) {
         WoW_Log::WriteError('%s : no realms found for battleGroup #%d, using first available bg instead.', __METHOD__, $bg_id);
         $realms = WoWConfig::$BattleGroups[1]['realms'];
         if (!$realms) {
             WoW_Log::WriteError('%s : default BG has no realms, unable to continue.', __METHOD__);
             return false;
         }
     }
     $top_teams_data = array();
     $counter = 0;
     foreach ($realms as $realmId) {
         DB::ConnectToDB(DB_CHARACTERS, $realmId);
         if (!DB::Characters()->TestLink()) {
             continue;
         }
         if (WoW::GetServerType($realmId) == SERVER_MANGOS) {
             if ($count) {
                 $counter += DB::Characters()->selectCell("\n                    SELECT COUNT(*)\n                    FROM `arena_team` AS `a`\n                    LEFT JOIN `arena_team_stats` AS `b` ON `b`.`arenateamid` = `a`.`arenateamid`\n                    WHERE `a`.`type` = %d\n                    AND `b`.`rank` > 0 AND `b`.`rank` < 4", $format);
                 continue;
             }
             $teams = DB::Characters()->select("SELECT\n                `a`.`arenateamid` AS `id`,\n                `a`.`rank`,\n                `a`.`rating`,\n                '%d' AS `realmId`,\n                `b`.`type`\n                FROM `arena_team_stats` AS `a`\n                LEFT JOIN `arena_team` AS `b` ON `b`.`arenateamid` = `a`.`arenateamid`\n                WHERE `a`.`rank` > 0 AND `a`.`rank` < 4 AND `b`.`type` = %d ORDER BY `rank`, `rating` LIMIT %d, %d", $realmId, $format, $offset, $limit);
         } else {
             $teams = DB::Characters()->select("SELECT `arenaTeamId` AS `id`, `rank`, `rating`, '%d' AS `realmId`, `type` FROM `arena_team` WHERE `rank` > 0 AND `rank` < 4 AND `type` = %d ORDER BY `rank`, `rating` LIMIT %d, %d", $realmId, $format, $offset, $limit);
         }
         if (!$teams) {
             continue;
         }
         $top_teams_data[] = array('realmId' => $realmId, 'teamsId' => $teams);
     }
     if ($count) {
         return $counter;
     }
     // Find top 3 teams
     $top_teams = array();
     foreach ($top_teams_data as &$teams) {
         foreach ($teams['teamsId'] as &$team) {
             if (!isset($top_teams[$team['rank']])) {
                 $top_teams[$team['rank']] = $team;
             }
             if ($top_teams[$team['rank']]['rating'] < $team['rating']) {
                 $top_teams[$team['rank']] = $team;
             }
         }
     }
     // Create objects
     $top_teams_objects = array();
     foreach ($top_teams as &$team) {
         $top_teams_objects[] = new WoW_ArenaTeam($team['realmId'], '', $team['id']);
     }
     unset($top_teams, $top_teams_data, $team, $teams);
     return $top_teams_objects;
 }
Beispiel #5
0
 private static function GetDB($database_type)
 {
     if (!self::IsConnected($database_type)) {
         self::ConnectToDB($database_type);
     }
     if (!isset(self::$database_objects[$database_type])) {
         WoW_Log::WriteError('%s : attempt to access non-existed %d database type!', __METHOD__, $database_type);
         return null;
     }
     return self::$database_objects[$database_type];
 }
Beispiel #6
0
 public static function LoadTemplate($template_name, $overall = false)
 {
     if (self::$isErrorPage) {
         //return true;
     }
     if ($overall) {
         $template = WOW_DIRECTORY . '/includes/templates/overall/overall_' . $template_name . '.php';
     } else {
         $template = WOW_DIRECTORY . '/includes/templates/' . self::GetTemplateTheme() . '/' . self::GetTemplateTheme() . '_' . $template_name . '.php';
     }
     if (file_exists($template)) {
         include $template;
     } else {
         WoW_Log::WriteError('%s : unable to find template "%s" (template theme: %s, overall: %d, path: %s)!', __METHOD__, $template_name, self::GetTemplateTheme(), (int) $overall, str_replace('/', '\\', $template));
     }
 }
 public static function LoadTemplate($template_name, $overall = false)
 {
     if (self::$is_error_page || self::$is_redirect) {
         return false;
         // Do not load any templates if error page was triggered or page is redirecting.
     }
     if ($overall) {
         $template = VISTA_DIR . 'overall' . DS . 'overall_' . $template_name . '.php';
     } else {
         $template = VISTA_DIR . self::GetTemplateTheme() . DS . self::GetTemplateTheme() . '_' . $template_name . '.php';
     }
     if (file_exists($template)) {
         include $template;
     } else {
         WoW_Log::WriteError('%s : unable to find template "%s" (template theme: %s, overall: %d, path: %s)!', __METHOD__, $template_name, self::GetTemplateTheme(), (int) $overall, $template);
     }
 }
Beispiel #8
0
 public static function InitPage($page_type, $category)
 {
     if (!in_array($page_type, array('quests', 'quest'))) {
         WoW_Log::WriteError('%s : wrong page type (%s)!', __METHOD__, $page_type);
         return false;
     }
     WoW_Template::SetPageData('breadcrumb', '0,3');
     switch ($page_type) {
         case 'quests':
             self::ExtractCategory($page_type, $category, self::$m_quest_type, self::$m_quest_category);
             self::LoadQuests();
             self::HandleQuests();
             break;
         case 'quest':
             self::$m_id = (int) $category;
             self::LoadQuest();
             self::HandleQuest();
             break;
     }
 }
 public function GetTopTeams($format, $bg_id)
 {
     if (!isset(WoWConfig::$BattleGroups[$bg_id])) {
         WoW_Log::WriteError('%s : battleGroupd #%d was not found!', __METHOD__, $bg_id);
         return false;
     }
     $realms = WoWConfig::$BattleGroups[$bg_id]['realms'];
     if (!$realms) {
         WoW_Log::WriteError('%s : no realms found for battleGroup #%d, using first available bg instead.', __METHOD__, $bg_id);
         $realms = WoWConfig::$BattleGroups[1]['realms'];
         if (!$realms) {
             WoW_Log::WriteError('%s : default BG has no realms, unable to continue.', __METHOD__);
             return false;
         }
     }
     $top_teams_data = array();
     foreach ($realms as $realmId) {
         DB::ConnectToDB(DB_CHARACTERS, $realmId);
         if (!DB::Characters()->TestLink()) {
             continue;
         }
         $teams = DB::Characters()->select("SELECT `%s`, `rank`, `rating` FROM `arena_team` ORDER BY `rank` LIMIT 3", WoW::GetServerType($realmId) == SERVER_MANGOS ? 'arenateamid' : 'arenaTeamId');
         if (!$teams) {
             continue;
         }
         $top_teams_data[] = array('realmId' => $realmId, 'teamsId' => $teams);
     }
     // Find top 3 teams
     foreach ($top_teams_data as &$teams) {
         foreach ($teams['teamsId'] as &$team) {
             if (!isset($top_teams[$team['rank']])) {
                 $top_teams[$team['rank']] = $team;
             }
             if ($top_teams[$team['rank']]['rating'] < $team['rating']) {
                 $top_teams[$team['rank']] = $team;
             }
         }
     }
     print_r($top_teams);
 }
Beispiel #10
0
 public static function InitPage($page_type, $category)
 {
     if ($page_type != 'search') {
         WoW_Log::WriteError('%s : wrong page type (%s)!', __METHOD__, $page_type);
         return false;
     }
     if (!isset($_GET['q'])) {
         WoW::RedirectTo();
     }
     if ($_GET['q'] == null) {
         WoW::RedirectTo();
     }
     WoW_Template::SetPageData('search_query', $_GET['q']);
     self::$m_query = $_GET['q'];
     if (isset($_GET['opensearch'])) {
         echo '["ragnaros", ["Lil\' Ragnaros (Item)", "Ragnaros Core (Item)", "Spark of Ragnaros (Item)", "Sulfuras, Hand of Ragnaros (Item)", "Symbol of Ragnaros (Item)", "Ragnaros kills (Molten Core) (Achievement)", "Sulfuras, Hand of Ragnaros (Achievement)", "Sulfuras, Hand of Ragnaros - Guild Edition (Achievement)", "Dream of Ragnaros (Spell)", "Wrath of Ragnaros (Spell)"], [], [], [], [], [], [[3, 68385, "achievement_boss_ragnaros", 3], [3, 17982, "INV_Jewelry_Ring_25", 3], [3, 52332, "INV_Elemental_Primal_Fire", 1], [3, 17182, "INV_Hammer_Unique_Sulfuras", 5], [3, 10552, "INV_Jewelry_Talisman_04", 1], [10, 1099, "spell_fire_elemental_totem"], [10, 429, "inv_hammer_unique_sulfuras"], [10, 4997, "inv_hammer_unique_sulfuras"], [6, 75145, "INV_Chest_Cloth_57"], [6, 84402, "spell_fire_soulburn"]]]';
         die;
     }
     WoW_Template::SetPageData('disable_breadcrumb', true);
     WoW_Template::SetPageData('activeTab', 0);
     // Do search
     self::PerformSearch();
 }
Beispiel #11
0
 public static function InitPage($page_type, $category)
 {
     if (!in_array($page_type, array('achievements', 'achievement'))) {
         WoW_Log::WriteError('%s : wrong page type (%s)!', __METHOD__, $page_type);
         return false;
     }
     WoW_Template::SetPageData('breadcrumb', '0,9');
     switch ($page_type) {
         case 'achievements':
             self::ExtractCategory($page_type, $category, self::$m_achievement_type, self::$m_achievement_category);
             self::LoadAchievements();
             self::HandleAchievements();
             break;
         case 'achievement':
             self::$m_id = (int) $category;
             if (self::IsPower()) {
                 self::GetPower();
             }
             self::LoadAchievement();
             self::HandleAchievement();
             break;
     }
     return true;
 }
Beispiel #12
0
 public static function InitPage($page_type, $category)
 {
     if (!in_array($page_type, array('npcs', 'npc'))) {
         WoW_Log::WriteError('%s : wrong page type (%s)!', __METHOD__, $page_type);
         return false;
     }
     WoW_Template::SetPageData('breadcrumb', '0,4');
     switch ($page_type) {
         case 'npcs':
             self::ExtractCategory($page_type, $category, self::$m_npc_classification, self::$m_npc_family);
             if (isset($_GET['filter'])) {
                 self::SetFilter($_GET['filter']);
             }
             self::LoadNPCs();
             self::HandleNPCs();
             break;
         case 'npc':
             self::$m_id = (int) $category;
             self::LoadNPC();
             self::HandleNPC();
             break;
     }
     return true;
 }
Beispiel #13
0
 public static function LoadRace($race_id)
 {
     if ($race_id <= 0 || $race_id >= MAX_RACES) {
         WoW_Log::WriteError('%s : raceID %d was not found!', __METHOD__, $race_id);
         return false;
     }
     self::$m_race = DB::WoW()->selectRow("\n        SELECT\n        `id`, `story_%s` AS `story`, `info_%s` AS `info`, `location_%s` AS `location`, `location_info_%s` AS `location_info`, `homecity_%s` AS `homecity`,\n        `homecity_info_%s` AS `homecity_info`, `mount_%s` AS `mount`, `mount_info_%s` AS `mount_info`, `leader_%s` AS `leader`, `leader_info_%s` AS `leader_info`,\n        `classes_flag`, `expansion`\n        FROM `DBPREFIX_races`\n        WHERE `id` = '%d'", WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), $race_id);
     if (!self::$m_race) {
         WoW_Log::WriteError('%s : race %d was not found in DB!', __METHOD__, $race_id);
         return false;
     }
     self::$m_race['abilities'] = DB::WoW()->select("SELECT `title_%s` AS `title`, `text_%s` AS `text`, `icon` FROM `DBPREFIX_race_abilities` WHERE `race` = %d", WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), $race_id);
     if (!self::$m_race['abilities']) {
         WoW_Log::WriteError('%s : unable to load abilities for race %d!', __METHOD__, $race_id);
         // Do not return false
     }
     return true;
 }
Beispiel #14
0
 /**
  * Returns character by GUID and RealmID
  * 
  * @access   public
  * @static   WoW_Account::GetCharacter($guid, $realm_id)
  * @param    int $guid
  * @param    int $realm_id
  * @category Account Manager Class
  * @return   array
  **/
 public static function GetCharacter($guid, $realm_id)
 {
     $db = DB::ConnectToDB(DB_CHARACTERS, $realm_id);
     if (!$db) {
         return false;
     }
     $char_data = DB::Characters()->selectRow("SELECT `guid`, `name`, `class`, `race`, `level`, `gender` FROM `characters` WHERE `guid` = %d LIMIT 1", $guid);
     if (!$char_data) {
         WoW_Log::WriteError('%s : character %d was not found in `characters` table!', __METHOD__, $guid);
         return false;
     }
     $char_data['realmName'] = WoWConfig::$Realms[$realm_id]['name'];
     return $char_data;
 }
 private static function AddProfession($profession)
 {
     if (!self::IsCorrect()) {
         WoW_Log::WriteError('%s : guild was not found.', __METHOD__);
         return false;
     }
     $skills_professions = array(SKILL_BLACKSMITHING, SKILL_LEATHERWORKING, SKILL_ALCHEMY, SKILL_HERBALISM, SKILL_MINING, SKILL_TAILORING, SKILL_ENGINERING, SKILL_ENCHANTING, SKILL_SKINNING, SKILL_JEWELCRAFTING, SKILL_INSCRIPTION);
     if (!in_array($profession['skill'], $skills_professions)) {
         WoW_Log::WriteError('%s : wrong skill ID (%d) for player %d (Realm: %s), ignore.', __METHOD__, $profession['skill'], $profession['guid'], self::GetGuildRealmName());
         return false;
     }
     if (!isset(self::$guild_professions[$profession['skill']])) {
         self::$guild_professions[$profession['skill']] = array();
     }
     self::$guild_professions[$profession['skill']][] = $profession;
     return true;
 }
 private function LoadController()
 {
     if (!$this->m_controller) {
         WoW_Log::WriteError('%s : unable to detect controller name (type: %s)!', __METHOD__, $this->m_type);
         WoW_Template::ErrorPage(404);
         return false;
     }
     $this->m_allowErrorPage = true;
     switch (strtolower($this->m_controller)) {
         case 'marketing':
         case 'ta':
         case 'login_frag':
         case 'data':
         case 'discussion':
         case 'pref':
             $this->m_allowErrorPage = false;
             break;
         case 'item':
             if (isset($this->m_actions['action4']) && strtolower($this->m_actions['action4']) == 'tooltip') {
                 $this->m_allowErrorPage = false;
             }
             break;
     }
     $controller_file = CONTROLLERS_DIR . $this->m_type . DS . $this->m_controller . '.php';
     if (!file_exists($controller_file)) {
         if ($this->m_allowErrorPage) {
             WoW_Template::ErrorPage(404, null, $this->m_type == 'wow' ? false : true);
         }
         exit;
     }
     include $controller_file;
     if (!class_exists($this->m_controller, false)) {
         if ($this->m_allowErrorPage) {
             WoW_Template::ErrorPage(404);
         }
         exit;
     }
     $this->m_controller = new $this->m_controller($this->m_actions, $this->m_type);
     if (!is_object($this->m_controller) || !method_exists($this->m_controller, 'main')) {
         if ($this->m_allowErrorPage) {
             WoW_Template::ErrorPage(404, null, $this->m_type == 'wow' ? false : true);
         }
         exit;
     }
     // Run page
     $this->m_controller->main();
 }
Beispiel #17
0
 public function CalculateDurabilityCost()
 {
     if (!$this->IsCorrect()) {
         return 0;
     }
     if ($this->durability_cost >= 0) {
         return $this->durability_cost;
     }
     // Ported from MaNGOS:
     // uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank);
     $totalCost = 0;
     $discountMod = 1;
     // No faction
     $maxDurability = $this->MaxDurability;
     if ($maxDurability == 0) {
         return 0;
     }
     $curDurability = 1;
     $lostDurability = $maxDurability - $curDurability;
     $dcost = DB::World()->selectRow("SELECT * FROM `DBPREFIX_durability_costs` WHERE `ItemLevel` = %d", $this->ItemLevel);
     if (!$dcost) {
         WoW_Log::WriteError('%s : wrong item level %d', __METHOD__, $this->ItemLevel);
         return 0;
     }
     $dQualitymodEntryId = ($this->Quality + 1) * 2;
     $dQualitymodEntry = DB::World()->selectRow("SELECT * FROM `DBPREFIX_durability_quality` WHERE `id` = %d", $dQualitymodEntryId);
     if (!$dQualitymodEntry) {
         WoW_Log::WriteError('%s : wrong dQualityModEntry %d', __METHOD__, $dQualitymodEntryId);
         return 0;
     }
     $dmultiplier = $dcost['multiplier_' . ($this->ItemSubClassToDurabilityMultiplierId() + 1)];
     $costs = (int) ($lostDurability * $dmultiplier * (double) $dQualitymodEntry['qualityMod']);
     $costs = (int) $costs * $discountMod;
     if ($costs == 0) {
         $costs = 1;
     }
     $this->durability_cost = abs($costs);
     return $this->durability_cost;
 }
 public function GetItemTabContents($entry, $tab_type, &$item_tabs)
 {
     if ($entry <= 0) {
         WoW_Log::WriteError('%s : wrong item entry (%d)!', __METHOD__, $entry);
         return false;
     }
     if (!in_array($tab_type, $item_tabs)) {
         WoW_Log::WriteError('%s : empty tab for item #%d (%s), ignore.', __METHOD__, $entry, $tab_type);
         return false;
     }
     $allowed_types = array('dropCreatures', 'dropGameObjects', 'vendors', 'currencyForItems', 'rewardFromQuests', 'skinnedFromCreatures', 'pickPocketCreatures', 'minedFromCreatures', 'createdBySpells', 'reagentForSpells', 'disenchantItems');
     if (!in_array($tab_type, $allowed_types)) {
         WoW_Log::WriteError('%s : wrong tab type for item #%d: %s, ignore.', __METHOD__, $entry, $tab_type);
         return false;
     }
     $item_tabs = array();
     $item_tabs['table_headers'] = array();
     // Table headers
     $item_tabs['table_contents'] = array();
     // Table contents
     // Generate headers
     // Generate contents
     switch ($tab_type) {
         case 'dropCreatures':
             /*$item_tabs['table_headers'] = array(
                   array(
                       'class' => '-link',
                       'type' => 'name'
                   ),
                   array(
                       'class' => '-link',
                       'type' => 'type',
                   ),
                   array(
                       'class' => 'link numeric',
                       'type' => 'level',
                   ),
                   array(
                       'class' => '-link',
                       'type' => 'zone'
                   ),
                   array(
                       'class' => '-link numeric',
                       'type' => 'droprate'
                   )
               );
               $creature_loot = DB::World()->select("
               SELECT
               `a`.`entry` AS `id`,
               `a`.`name`,
               `a`.`minlevel` AS `minLevel`, 
               `a`.`maxlevel` AS `maxLevel`, 
               `a`.`rank` AS `classification`, 
               `a`.`KillCredit1`, 
               `a`.`KillCredit2`, 
               `a`.`type`,
               `b`.`ChanceOrQuestChance`, 
               `b`.`groupid`,
               `b`.`mincountOrRef`,
               `b`.`item`
               FROM `creature_template` AS `a`
               JOIN `creature_loot_template` AS `b` ON `b`.`entry` = `a`.`entry`
               WHERE `b`.`item` = %d", $entry);
               if(!$creature_loot) {
                   return false;
               }
               foreach($creature_loot as $creature) {
                   if(WoW_Utils::IsBossCreature($creature)) {
                       $drop_percent = WoW_Utils::GenerateLootPercent($creature['id'], 'creature_loot_template', $creature['item']);
                       $drop_rate = WoW_Utils::GetDropRate($drop_percent);
                       $item_tabs['table_contents'][] = array(
                           array(
                               'td' => '',
                               'text' => $creature['name']
                           ),
                           array(
                               'td' => '',
                               'text' => WoW_Locale::GetString('creature_type_' . $creature['type'])
                           ),
                           array(
                               'td' => '',
                               'text' => $creature['maxLevel']
                           ),
                           array(
                               'td' => ' data-raw=""',
                               'text' => '',
                           ),
                           array(
                               'td' => ' data-raw="' . $drop_rate . '"',
                               'text' => WoW_Locale::GetString('template_item_drop_rate_' . $drop_rate)
                           )
                       );
                   }
               }*/
             break;
     }
     return $item_tabs;
 }
 public static function LoadBlog($blog_id)
 {
     $blog_data = DB::WoW()->selectRow("SELECT `id`, `image`, `header_image`, `title_%s` AS `title`, `text_%s` AS `text`, `author`, `postdate` FROM `DBPREFIX_news` WHERE `id` = %d LIMIT 1", WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), $blog_id);
     if (!$blog_data) {
         WoW_Log::WriteError('%s : blog entry #%d was not found in DB.', __METHOD__, $blog_id);
         return false;
     }
     self::$blog_contents['blog'] = $blog_data;
     unset($blog_data);
     self::$blog_contents['comments'] = DB::WoW()->select("SELECT * FROM `DBPREFIX_blog_comments` WHERE `blog_id` = %d", $blog_id);
     self::$blog_contents['blog']['comments_count'] = count(self::$blog_contents['comments']);
     return true;
 }
Beispiel #20
0
{
    //prevent error when mailer classes are loaded
    if (!preg_match('/swift_(.*)/i', $className)) {
        if (preg_match('/[^DB][Ss]torage/i', $className)) {
            $classFileName = INCLUDES_DIR . 'storages' . DS . ucfirst(str_replace('Storage', null, $className)) . '.php';
        } else {
            $classFileName = CLASSES_DIR . 'class.' . strtolower(str_replace('WoW_', null, $className)) . '.php';
        }
        if (!file_exists($classFileName)) {
            die('<strong>Autoload Fatal Error:</strong> unable to autoload class ' . $className . ' (path: ' . $classFileName . ')!');
        }
        include $classFileName;
    }
}
// Initialize debug log
WoW_Log::Initialize(WoWConfig::$UseLog, WoWConfig::$LogLevel);
// Load databases configs
// Do not create DB connections here - it will be created automatically at first query request!
DB::LoadConfigs();
// Core self testing
WoW::SelfTests();
// Try to catch some operations (login, logout, etc.)
$locale_loaded = false;
WoW::CatchOperations($locale_loaded);
// locale from page controller
$wow_locale_cms = isset($_COOKIE['wow_locale']) ? $_COOKIE['wow_locale'] : WoWConfig::$DefaultLocale;
if (!isset($_COOKIE['wow_locale'])) {
    setcookie('wow_locale', $wow_locale_cms, strtotime('NEXT YEAR'), '/');
    $_COOKIE['wow_locale'] = $wow_locale_cms;
}
$pController = new PageController();
 private static function HandleBaseModValue($modGroup, $modType, $amount, $apply)
 {
     if ($modGroup >= BASEMOD_END || $modType >= MOD_END) {
         WoW_Log::WriteError('%s : ERROR in HandleBaseModValue(): nonexistent BaseModGroup (%d) of wrong BaseModType (%d)!', __METHOD__, $modGroup, $modType);
         return false;
     }
     $val = 1.0;
     switch ($modType) {
         case FLAT_MOD:
             self::$m_auraBaseMod[$modGroup][$modType] += $apply ? $amount : -$amount;
             break;
         case PCT_MOD:
             if ($amount <= -100.0) {
                 $amount = 200.0;
             }
             $val = (100.0 + $amount) / 100.0;
             self::$m_auraBaseMod[$modGroup][$modType] *= $apply ? $val : 1.0 / $val;
     }
     if (!self::CanModifyStats()) {
         return;
     }
     switch ($modGroup) {
         case CRIT_PERCENTAGE:
             self::UpdateCritPercentage(BASE_ATTACK);
             break;
         case RANGED_CRIT_PERCENTAGE:
             self::UpdateCritPercentage(RANGED_ATTACK);
             break;
         case OFFHAND_CRIT_PERCENTAGE:
             self::UpdateCritPercentage(OFF_ATTACK);
             break;
         case SHIELD_BLOCK_VALUE:
             self::UpdateShieldBlockValue();
             break;
         default:
             break;
     }
 }
/**
 * Copyright (C) 2011 - 2014 Apocalypsecore <https://Apocalypsecore.tk>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 **/
WoW_Log::WriteLog('RunOnce : execute commands.');
/**
 * Execute necessary code (once)
 * @param void
 * @return bool
 **/
function ExecuteRunOnce()
{
    ////////////////////////////////////////
    DB::WoW()->query("TRUNCATE TABLE `DBPREFIX_user_characters`");
    return true;
    ////////////////////////////////////////
}
Beispiel #23
0
 private function LoadTrinity(&$team)
 {
     $team = DB::Characters()->selectRow("\n        SELECT\n        `a`.*,\n        `b`.`race`\n        FROM `arena_team` AS `a`\n        LEFT JOIN `characters` AS `b` ON `b`.`guid` = `a`.`captainguid`\n        WHERE `a`.`arenaTeamId` = %d", $this->m_teamId);
     if (!$team) {
         WoW_Log::WriteError('%s : team "%s" (%d) was not found in DB!', __METHOD__, $this->m_teamName, $this->m_teamId);
         return false;
     }
     // Fill class field
     $this->m_teamName = $team['name'];
     $this->m_teamId = $team['arenaTeamId'];
     $this->m_teamCaptain = $team['captainGuid'];
     $this->m_teamEmblem = array('bgColor' => $team['backgroundColor'], 'eStyle' => $team['emblemStyle'], 'eColor' => $team['emblemColor'], 'bStyle' => $team['borderStyle'], 'bColor' => $team['borderColor']);
     $this->m_teamFaction = WoW_Utils::GetFactionId($team['race']);
     $this->m_teamStats = array('rating' => $team['rating'], 'games_week' => $team['weekGames'], 'games_season' => $team['seasonGames'], 'wins_week' => $team['weekWins'], 'wins_season' => $team['seasonWins'], 'loses_week' => $team['weekGames'] - $team['weekWins'], 'loses_season' => $team['seasonGames'] - $team['seasonWins'], 'rank' => $team['rank']);
     $this->m_teamType = $team['type'];
     // Load member list
     $members = DB::Characters()->select("\n        SELECT\n        `a`.`weekGames`,\n        `a`.`weekWins`,\n        `a`.`seasonGames`,\n        `a`.`seasonWins`,\n        (`a`.`weekGames` - `a`.`weekWins`) AS `loses_week`,\n        (`a`.`seasonGames` - `a`.`seasonWins`) AS `loses_season`,\n        `a`.`personalRating`,\n        `b`.`guid`,\n        `b`.`name`,\n        `b`.`class`,\n        `b`.`race`,\n        `b`.`gender`,\n        `b`.`level`\n        FROM `arena_team_member` AS `a`\n        LEFT JOIN `characters` AS `b` ON `b`.`guid` = `a`.`guid`\n        WHERE `a`.`arenateamid` = %d", $this->m_teamId);
     if (!$members) {
         WoW_Log::WriteError('%s : team "%s" (%d) has empty member list', __METHOD__, $this->m_teamName, $this->m_teamId);
         return false;
     }
     foreach ($members as $member) {
         $this->m_teamMembers[] = array('guid' => $member['guid'], 'name' => $member['name'], 'classId' => $member['class'], 'class_text' => WoW_Locale::GetString('character_class_' . $member['class'], $member['gender']), 'raceId' => $member['race'], 'race_text' => WoW_Locale::GetString('character_race_' . $member['race'], $member['gender']), 'factionId' => WoW_Utils::GetFactionId($member['race']), 'faction_text' => WoW_Utils::GetFactionId($member['race']) == FACTION_ALLIANCE ? 'alliance' : 'horde', 'genderId' => $member['gender'], 'level' => $member['level'], 'url' => sprintf('%s/wow/%s/character/%s/%s/', WoW::GetWoWPath(), WoW_Locale::GetLocale(), $this->GetTeamRealmName(), $member['name']), 'gamesWeek' => $member['weekGames'], 'winsWeek' => $member['weekWins'], 'losesWeek' => $member['loses_week'], 'gamesSeason' => $member['seasonGames'], 'winsSeason' => $member['seasonWins'], 'losesSeason' => $member['loses_season'], 'personalRating' => $member['personalRating'], 'teamId' => $this->m_teamId, 'matchMakerRating' => DB::Characters()->selectCell("SELECT `matchMakerRating` FROM `character_arena_stats` WHERE `guid` = %d AND `slot` = %d", $member['guid'], $this->m_teamType));
     }
     unset($members, $member, $team);
     // Loaded successfully
     return true;
 }
Beispiel #24
0
 /**
  * Converts array values to string format (for IN(%s) cases)
  * @category WoW Database Handler
  * @access   private
  * @param    array $source
  * @return   string
  **/
 private function ConvertArray($source)
 {
     if (!is_array($source)) {
         WoW_Log::WriteError('%s : source must have an array type!', __METHOD__);
         return null;
     }
     $returnString = null;
     $count = count($source);
     for ($i = 0; $i < $count; $i++) {
         if (!isset($source[$i])) {
             continue;
         }
         if ($i) {
             $returnString .= ", '" . addslashes($source[$i]) . "'";
         } else {
             $returnString .= "'" . addslashes($source[$i]) . "'";
         }
     }
     return $returnString;
 }
 /**
  * @return array
  **/
 public function GetRandomSuffixData()
 {
     if ($this->m_server != SERVER_MANGOS) {
         WoW_Log::WriteError('%s : this method is usable with MaNGOS servers only.', __METHOD__);
         return false;
     }
     return array($this->GetUInt32Value(ITEM_FIELD_ENCHANTMENT_8_1), $this->GetUInt32Value(ITEM_FIELD_ENCHANTMENT_9_1), $this->GetUInt32Value(ITEM_FIELD_ENCHANTMENT_10_1));
 }
 private static function SetSearchResults($type, $results)
 {
     if (!isset(self::$searchResults[$type])) {
         WoW_Log::WriteError('%s : unknown search type: "%s"!', __METHOD__, $type);
         return false;
     }
     self::$searchResults[$type] = $results;
     return true;
 }
 public static function GetStatisticSummary()
 {
     $summary = array();
     $achievements = DB::WoW()->select("SELECT `id`, `name_%s` AS `name`, `description_%s` AS `desc`, `categoryId` FROM `DBPREFIX_achievement` WHERE `id` IN (377, 1198, 338, 529, 931, 588, 378, 339)", WoW_Locale::GetLocale(), WoW_Locale::GetLocale());
     if (!$achievements) {
         WoW_Log::WriteError('%s : unable to find any achievement for statistics!', __METHOD__, $category);
         return false;
     }
     foreach ($achievements as $ach) {
         $summary[$ach['id']] = $ach;
         $summary[$ach['id']]['quantity'] = self::GetCriteriaValue($ach['id']);
     }
     return $summary;
 }
 private static function LoadFactions()
 {
     $factions = DB::WoW()->select("SELECT `id`, `category`, `name_%s` AS `name` FROM `DBPREFIX_faction` WHERE `id` IN (%s) ORDER BY `id` DESC", WoW_Locale::GetLocale(), self::GetFactionsIDs());
     if (!$factions) {
         WoW_Log::WriteError('%s : unable to load factions info for character %d!', __METHOD__, self::$guid);
         return false;
     }
     // Default categories
     $categories = array(1118 => array(67 => array('order' => 1, 'side' => FACTION_HORDE), 892 => array('order' => 2, 'side' => FACTION_HORDE), 469 => array('order' => 1, 'side' => FACTION_ALLIANCE), 891 => array('order' => 2, 'side' => FACTION_ALLIANCE), 169 => array('order' => 3, 'side' => -1)), 980 => array(936 => array('order' => 1, 'side' => -1)), 1097 => array(1117 => array('order' => 1, 'side' => -1), 1052 => array('order' => 2, 'side' => FACTION_HORDE), 1037 => array('order' => 2, 'side' => FACTION_ALLIANCE)), 0 => array(589 => array('order' => 1, 'side' => FACTION_ALLIANCE), 70 => array('order' => 2, 'side' => -1)));
     $storage = array();
     foreach ($factions as $faction) {
         // Standing & adjusted values
         $standing = min(42999, self::$reputation[$faction['id']]['standing']);
         $type = REP_EXALTED;
         $rep_cap = 999;
         $rep_adjusted = $standing - 42000;
         if ($standing < REPUTATION_VALUE_HATED) {
             $type = REP_HATED;
             $rep_cap = 36000;
             $rep_adjusted = $standing + 42000;
         } elseif ($standing < REPUTATION_VALUE_HOSTILE) {
             $type = REP_HOSTILE;
             $rep_cap = 3000;
             $rep_adjusted = $standing + 6000;
         } elseif ($standing < REPUTATION_VALUE_UNFRIENDLY) {
             $type = REP_UNFRIENDLY;
             $rep_cap = 3000;
             $rep_adjusted = $standing + 3000;
         } elseif ($standing < REPUTATION_VALUE_NEUTRAL) {
             $type = REP_NEUTRAL;
             $rep_cap = 3000;
             $rep_adjusted = $standing;
         } elseif ($standing < REPUTATION_VALUE_FRIENDLY) {
             $type = REP_FRIENDLY;
             $rep_cap = 6000;
             $rep_adjusted = $standing - 3000;
         } elseif ($standing < REPUTATION_VALUE_HONORED) {
             $type = REP_HONORED;
             $rep_cap = 12000;
             $rep_adjusted = $standing - 9000;
         } elseif ($standing < REPUTATION_VALUE_REVERED) {
             $type = REP_REVERED;
             $rep_cap = 21000;
             $rep_adjusted = $standing - 21000;
         }
         $faction['standing'] = self::$reputation[$faction['id']]['standing'];
         $faction['type'] = $type;
         $faction['cap'] = $rep_cap;
         $faction['adjusted'] = $rep_adjusted;
         $faction['percent'] = WoW_Utils::GetPercent($rep_cap, $rep_adjusted);
         if (isset($categories[$faction['category']])) {
             if (!isset($storage[$faction['category']])) {
                 $storage[$faction['category']] = array();
             }
             $storage[$faction['category']][] = $faction;
         } else {
             foreach ($categories as $catId => $subcat) {
                 if (isset($categories[$catId][$faction['category']])) {
                     if (!isset($categories[$catId][$faction['category']])) {
                         $categories[$catId][$faction['category']] = array();
                     }
                     $storage[$catId][$faction['category']][] = $faction;
                 }
             }
         }
     }
     self::$factions = $storage;
     unset($storage);
     return true;
 }
 public static function GetNpcAreaInfo($entry)
 {
     $npc_coordinates = DB::World()->selectRow("SELECT `guid`, `map`, `position_x`, `position_y` FROM `creature` WHERE `id` = %d LIMIT 1", $entry);
     if (!is_array($npc_coordinates)) {
         WoW_Log::WriteLog('%s : creature #%d was not found in `creature` table!', __METHOD__, $entry);
         return false;
     }
     $area_data = DB::WoW()->selectRow("\n        SELECT\n        `a`.`id`,\n        `a`.`area`,\n        `b`.`name_en` AS `areaName_original`,\n        `b`.`name_%s` AS `areaName_locale`\n        FROM `DBPREFIX_zones` AS `a`\n        JOIN `DBPREFIX_areas` AS `b` ON `b`.`id` = `a`.`area`\n        WHERE `a`.`map` = %d AND `a`.`y_min` >= %d AND `a`.`y_max` <= %d AND `a`.`x_min` >= %d AND `a`.`x_max` <= %d\n        LIMIT 1", WoW_Locale::GetLocale(), $npc_coordinates['map'], $npc_coordinates['position_y'], $npc_coordinates['position_y'], $npc_coordinates['position_x'], $npc_coordinates['position_x']);
     if (!is_array($area_data)) {
         WoW_Log::WriteLog('%s : area data for creature #%d (GUID: %d) was not found!', __METHOD__, $entry, $npc_coordinates['guid']);
         return false;
     }
     return array('entry' => $entry, 'guid' => $npc_coordinates['guid'], 'mapID' => $npc_coordinates['map'], 'zoneID' => $area_data['id'], 'areaID' => $area_data['area'], 'zoneName' => $area_data['areaName_original'], 'zoneName_loc' => $area_data['areaName_locale'], 'pos_x' => $npc_coordinates['position_x'], 'pos_y' => $npc_coordinates['position_y']);
 }
 public function LoadItem($item_entry, $itemGuid = 0, $ownerGuid = 0)
 {
     $item_row = DB::World()->selectRow("SELECT * FROM `item_template` WHERE `entry` = '%d' LIMIT 1", $item_entry);
     if (!$item_row) {
         WoW_Log::WriteError('%s : item #%d (GUID: %d) was not found in `item_template` table.', __METHOD__, $item_entry, $itemGuid);
         return false;
     }
     // FlagsExtra check
     if (isset($item_row['FlagsExtra'])) {
         $item_row['Flags2'] = $item_row['FlagsExtra'];
         unset($item_row['FlagsExtra']);
         // For compatibility
     }
     // Assign variables
     foreach ($item_row as $field => $value) {
         $this->{$field} = $value;
     }
     // Create arrays
     // Item mods
     for ($i = 0; $i < MAX_ITEM_PROTO_STATS + 1; $i++) {
         $key = $i + 1;
         if (isset($this->{'stat_type' . $key})) {
             $this->ItemStat[$i] = array('type' => $this->{'stat_type' . $key}, 'value' => $this->{'stat_value' . $key});
         }
     }
     // Item damages
     for ($i = 0; $i < MAX_ITEM_PROTO_DAMAGES + 1; $i++) {
         $key = $i + 1;
         if (isset($this->{'dmg_type' . $key})) {
             $this->Damage[$i] = array('type' => $this->{'dmg_type' . $key}, 'min' => $this->{'dmg_min' . $key}, 'max' => $this->{'dmg_max' . $key});
         }
     }
     // Item spells
     for ($i = 0; $i < MAX_ITEM_PROTO_SPELLS + 1; $i++) {
         $key = $i + 1;
         if (isset($this->{'spellid_' . $key})) {
             $this->Spells[$i] = array('spellid' => $this->{'spellid_' . $key}, 'trigger' => $this->{'spelltrigger_' . $key}, 'charges' => $this->{'spellcharges_' . $key}, 'ppmRate' => $this->{'spellppmRate_' . $key}, 'cooldown' => $this->{'spellcooldown_' . $key}, 'category' => $this->{'spellcategory_' . $key}, 'categorycooldown' => $this->{'spellcategorycooldown_' . $key});
         }
     }
     // Item sockets
     for ($i = 0; $i < MAX_ITEM_PROTO_SOCKETS + 1; $i++) {
         $key = $i + 1;
         if (isset($this->{'socketColor_' . $key})) {
             $this->Socket[$i] = array('color' => $this->{'socketColor_' . $key}, 'content' => $this->{'socketContent_' . $key});
         }
     }
     $this->icon = DB::Wow()->selectCell("SELECT `icon` FROM `DBPREFIX_icons` WHERE `displayid` = %d LIMIT 1", $this->displayid);
     if (WoW_Locale::GetLocale() != 'en') {
         $newname = DB::World()->selectRow("SELECT `name_loc%d` AS `name`, `description_loc%d` AS `desc` FROM `locales_item` WHERE `entry` = %d", WoW_Locale::GetLocaleID(), WoW_Locale::GetLocaleID(), $this->entry);
         if ($newname) {
             $this->name = $newname['name'];
             $this->description = $newname['desc'];
         }
     }
     $itemsublcass = DB::Wow()->selectRow("SELECT `subclass_name_%s` AS `subclass`, `class_name_%s` AS `class` FROM `DBPREFIX_item_subclass` WHERE `subclass` = %d AND `class` = %d LIMIT 1", WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), $this->subclass, $this->class);
     $this->subclass_name = $itemsublcass['subclass'];
     $this->class_name = $itemsublcass['class'];
     $this->m_guid = $itemGuid;
     // Can be NULL.
     $this->m_owner = $ownerGuid;
     // Can be NULL.
     $this->loaded = true;
     return true;
 }