/**
  * @return array
  **/
 public function GetSocketInfo($num, $enchant_id_only = false)
 {
     if ($num <= 0 || $num > 4) {
         return 0;
     }
     if (isset($this->m_socketInfo[$num])) {
         return $enchant_id_only ? $this->m_socketInfo[$num]['enchant_id'] : $this->m_socketInfo[$num];
     }
     $data = array();
     switch ($this->m_server) {
         case SERVER_MANGOS:
             $socketfield = array(1 => ITEM_FIELD_ENCHANTMENT_3_2, 2 => ITEM_FIELD_ENCHANTMENT_4_2, 3 => ITEM_FIELD_ENCHANTMENT_5_2);
             $socketInfo = $this->GetUInt32Value($socketfield[$num] - 1);
             break;
         case SERVER_TRINITY:
             $socketfield = array(1 => 6, 2 => 9, 3 => 12);
             $socketInfo = $this->tc_ench[$socketfield[$num]];
             break;
         default:
             WoW_Log::WriteError('%s : unknown server type (%d)', __METHOD__, $this->m_server);
             return false;
             break;
     }
     if ($socketInfo > 0) {
         if ($enchant_id_only) {
             return $socketInfo;
         }
         $gemData = DB::Wow()->selectRow("SELECT `text_%s` AS `text`, `gem` FROM `DBPREFIX_enchantment` WHERE `id`=%d", WoW_Locale::GetLocale(), $socketInfo);
         $data['enchant_id'] = $socketInfo;
         $data['item'] = $gemData['gem'];
         $data['icon'] = WoW_Items::GetItemIcon($data['item']);
         $data['enchant'] = $gemData['text'];
         $data['quality'] = DB::World()->selectCell("SELECT `Quality` FROM `item_template` WHERE `entry` = %d", $data['item']);
         $data['name'] = WoW_Items::GetItemName($data['item']);
         $data['color'] = DB::Wow()->selectCell("SELECT `color` FROM `DBPREFIX_gemproperties` WHERE `spellitemenchantement`=%d", $socketInfo);
         $this->m_socketInfo[$num] = $data;
         // Is it neccessary?
         return $data;
     }
     return false;
 }
 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;
 }
 /**
  * @param array $item_info
  * @param int   $item_entry = 0
  **/
 public function GetBreadCrumbsForItem($item_info, $item_entry = 0)
 {
     if ($item_entry > 0 || !is_array($item_info)) {
         $item_info = DB::World()->selectRow("SELECT `class` AS `classId`, `subclass` AS `subClassId`, `InventoryType` AS `invType` FROM `item_template` WHERE `entry` = %d LIMIT 1", $item_entry);
     }
     if (!$item_info || !is_array($item_info)) {
         return false;
     }
     $itemsubclass = null;
     if (isset($item_info['classId']) && isset($item_info['subClassId'])) {
         $itemsubclass = 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(), $item_info['subClassId'], $item_info['classId']);
     } elseif (isset($item_info['classId'])) {
         $itemsubclass = DB::Wow()->selectRow("SELECT `class_name_%s` AS `class` FROM `DBPREFIX_item_subclass` WHERE `class` = %d LIMIT 1", WoW_Locale::GetLocale(), $item_info['classId']);
     } elseif (isset($item_info['subClassId'])) {
         $itemsubclass = DB::Wow()->selectRow("SELECT `subclass_name_%s` AS `subclass` FROM `DBPREFIX_item_subclass` WHERE `subclass` = %d LIMIT 1", WoW_Locale::GetLocale(), $item_info['subClassId']);
     }
     if (!$itemsubclass || !is_array($itemsubclass)) {
         return false;
     }
     $breadcrumbs = array();
     $global_url = sprintf('%s/wow/%s/item/', WoW::GetWoWPath(), WoW_Locale::GetLocale());
     $index = 0;
     if (isset($item_info['classId'])) {
         $global_url .= '?classId=' . $item_info['classId'];
         $breadcrumbs[$index] = array('caption' => $itemsubclass['class'], 'link' => $global_url, 'last' => true);
         ++$index;
     }
     if (isset($item_info['subClassId'])) {
         if (strpos($global_url, '?classId=') > 0) {
             $global_url .= '&amp;subClassId=' . $item_info['subClassId'];
         } else {
             $global_url .= '?subClassId=' . $item_info['subClassId'];
         }
         $breadcrumbs[$index] = array('caption' => $itemsubclass['subclass'], 'link' => $global_url, 'last' => true);
         if ($index > 0) {
             $breadcrumbs[$index - 1]['last'] = false;
         }
         ++$index;
     }
     if (isset($item_info['invType'])) {
         if (strpos($global_url, '?') > 0) {
             $global_url .= '&amp;invType=' . $item_info['invType'];
         } else {
             $global_url .= '?invType=' . $item_info['invType'];
         }
         $breadcrumbs[$index] = array('caption' => WoW_Locale::GetString('template_item_invtype_' . $item_info['invType']), 'link' => $global_url, 'last' => true);
         if ($index > 0) {
             $breadcrumbs[$index - 1]['last'] = false;
         }
         ++$index;
     }
     return $breadcrumbs;
 }
Example #4
0
}
// Get DB version
$current_db_version = (int) DB_VERSION;
$new_db_version = $current_db_version + 1;
set_time_limit(0);
$allowed_tables = array(array('name' => 'achievement', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'achievement_category', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'achievement_criteria', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'areas', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'blog_comments', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'bookmarks', 'internalFile' => false, 'skipData' => true, 'drop' => false, 'onlyIfNotExists' => true), array('name' => 'carousel', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'class_abilities', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'classes', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'db_version', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'enchantment', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'extended_cost', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'faction', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'gemproperties', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'glyphproperties', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'icons', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'instance_data', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'instances', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'instances_groups', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'item_equivalents', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'item_sources', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'item_subclass', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'itemdisplayinfo', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'itemsetdata', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'itemsetinfo', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'itemsubclass', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'login_characters', 'internalFile' => false, 'skipData' => true, 'drop' => false, 'onlyIfNotExists' => true), array('name' => 'main_menu', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'maps', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'mounts', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'news', 'internalFile' => false, 'skipData' => true, 'drop' => false, 'onlyIfNotExists' => true), array('name' => 'petcalc', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'professions', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'race_abilities', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'races', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'randomproperties', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'randompropertypoints', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'randomsuffix', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'rating', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'skills', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'source', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'spell', 'internalFile' => 'wowcs_spell_r' . (WOW_REVISION + 1) . '.sql', 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'spell_duration', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'spellenchantment', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'ssd', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'ssv', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'talent_icons', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'talents', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'titles', 'internalFile' => false, 'skipData' => false, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'user_characters', 'internalFile' => false, 'skipData' => true, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'users', 'internalFile' => false, 'skipData' => true, 'drop' => true, 'onlyIfNotExists' => false), array('name' => 'zones', 'internalFile' => false, 'skipData' => true, 'drop' => true, 'onlyIfNotExists' => false));
if ($_GET['do'] == 'show') {
    header('Content-type: text/plain');
}
$sql_dump_text = sprintf("/*\n    World of Warcraft Community Site Database\n    https://github.com/Shadez/wowcs/\n    Revision [%d]\n    Dump date: %s\n*/\n\n/*!40101 SET NAMES utf8 */;\n/*!40101 SET SQL_MODE=''*/;\n/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;", WOW_REVISION + 1, date('M-d-Y, H:i:s'));
foreach ($allowed_tables as $table) {
    $data = array();
    if ($table['skipData'] == false && $table['internalFile'] == false) {
        $data = DB::Wow()->select("SELECT * FROM `DBPREFIX_%s`", $table['name']);
    }
    $create_table = DB::Wow()->selectRow("SHOW CREATE TABLE `DBPREFIX_%s`", $table['name']);
    $create_table_query = $create_table['Create Table'];
    $sql_dump_text .= "\n\n-- `" . DatabaseConfig::$wow['db_prefix'] . '_' . $table['name'] . '`';
    if ($table['internalFile'] != false) {
        $sql_dump_text .= "\n-- execute from " . $table['internalFile'];
        continue;
    }
    if ($table['drop'] == true) {
        $sql_dump_text .= "\nDROP TABLE IF EXISTS `" . DatabaseConfig::$wow['db_prefix'] . '_' . $table['name'] . "`;\n" . $create_table_query . ';';
    } elseif ($table['onlyIfNotExists'] == true) {
        $sql_dump_text .= "\n" . str_replace('CREATE TABLE', 'CREATE TABLE IF NOT EXISTS', $create_table_query) . ';';
    }
    if ($table['skipData'] == false && $table['internalFile'] == false) {
        $sql_dump_text .= "\n";
        foreach ($data as $tbl_data) {
            $sql_dump_text .= sprintf("\nINSERT INTO `%s_%s` VALUES (", DatabaseConfig::$wow['db_prefix'], $table['name']);