Example #1
0
function achievement(array $ids = [])
{
    if ($ids) {
        DB::Aowow()->query('DELETE FROM ?_achievement WHERE id IN (?a)', $ids);
    } else {
        DB::Aowow()->query('REPLACE INTO ?_achievement SELECT a.id, 2 - a.faction, a.map, 0, 0, a.category, ac.parentCategory, a.points, a.orderInGroup, a.iconId, a.flags, a.reqCriteriaCount, a.refAchievement, 0, 0, a.name_loc0, a.name_loc2, a.name_loc3, a.name_loc4, a.name_loc6, a.name_loc8, a.description_loc0, a.description_loc2, a.description_loc3, a.description_loc4, a.description_loc6, a.description_loc8, a.reward_loc0, a.reward_loc2, a.reward_loc3, a.reward_loc4, a.reward_loc6, a.reward_loc8 FROM dbc_achievement a LEFT JOIN dbc_achievement_category ac ON ac.id = a.category');
    }
    // serverside achievements
    $serverAchievements = DB::World()->select('SELECT ID, IF(requiredFaction = -1, 3, IF(requiredFaction = 0, 2, 1)) AS "faction", mapID, points, flags, count, refAchievement FROM achievement_dbc{ WHERE id IN (?a)}', $ids ?: DBSIMPLE_SKIP);
    foreach ($serverAchievements as $sa) {
        DB::Aowow()->query('REPLACE INTO ?_achievement (id, faction, map, points, flags, reqCriteriaCount, refAchievement, cuFlags, name_loc0, name_loc2, name_loc3, name_loc4, name_loc6, name_loc8) VALUES (?d, ?d, ?d, ?d, ?d, ?d, ?d, ?d, ?, ?, ?, ?, ?, ?)', $sa['ID'], $sa['faction'], $sa['mapID'], $sa['points'], $sa['flags'], $sa['count'], $sa['refAchievement'], CUSTOM_SERVERSIDE, 'Serverside - #' . $sa['ID'], 'Serverside - #' . $sa['ID'], 'Serverside - #' . $sa['ID'], 'Serverside - #' . $sa['ID'], 'Serverside - #' . $sa['ID'], 'Serverside - #' . $sa['ID']);
    }
    if ($ids) {
        return true;
    }
    // create chain of achievements
    $chainIdx = 0;
    $parents = DB::Aowow()->selectCol('SELECT a.id FROM dbc_achievement a JOIN dbc_achievement b ON b.previous = a.id WHERE a.previous = 0');
    foreach ($parents as $chainId => $next) {
        $tree = [null, $next];
        while ($next = DB::Aowow()->selectCell('SELECT id FROM dbc_achievement WHERE previous = ?d', $next)) {
            $tree[] = $next;
        }
        foreach ($tree as $idx => $aId) {
            if (!$aId) {
                continue;
            }
            DB::Aowow()->query('UPDATE ?_achievement SET cuFlags = cuFlags | ?d, chainId = ?d, chainPos = ?d WHERE id = ?d', $idx == 1 ? ACHIEVEMENT_CU_FIRST_SERIES : (count($tree) == $idx + 1 ? ACHIEVEMENT_CU_LAST_SERIES : 0), $chainId + 1, $idx, $aId);
        }
    }
    return true;
}
Example #2
0
 protected function handleWeightscales()
 {
     if ($this->_post['save']) {
         if (!$this->_post['scale']) {
             return 0;
         }
         if (!$this->_post['id']) {
             $res = DB::Aowow()->selectRow('SELECT MAX(id) AS max, count(id) AS num FROM ?_account_weightscales WHERE userId = ?d', User::$id);
             if ($res['num'] < 5) {
                 // more or less hard-defined in LANG.message_weightscalesaveerror
                 $this->_post['id'] = ++$res['max'];
             } else {
                 return 0;
             }
         }
         if (DB::Aowow()->query('REPLACE INTO ?_account_weightscales VALUES (?d, ?d, ?, ?)', $this->_post['id'], User::$id, $this->_post['name'], $this->_post['scale'])) {
             return $this->_post['id'];
         } else {
             return 0;
         }
     } else {
         if ($this->_post['delete'] && $this->_post['id']) {
             DB::Aowow()->query('DELETE FROM ?_account_weightscales WHERE id = ?d AND userId = ?d', $this->_post['id'], User::$id);
         } else {
             return 0;
         }
     }
 }
Example #3
0
function events(array $ids = [])
{
    $eventQuery = '
        SELECT
            ge.eventEntry,
            holiday,
            0,                                              -- cuFlags
            UNIX_TIMESTAMP(start_time),
            UNIX_TIMESTAMP(end_time),
            occurence * 60,
            length * 60,
            IF (gep.eventEntry IS NOT NULL, GROUP_CONCAT(prerequisite_event SEPARATOR " "), NULL),
            description
        FROM
            game_event ge
        LEFT JOIN
            game_event_prerequisite gep ON gep.eventEntry = ge.eventEntry
        {
        WHERE
            ge.eventEntry IN (?a)
        }
        GROUP BY
            ge.eventEntry';
    $events = DB::World()->select($eventQuery, $ids ?: DBSIMPLE_SKIP);
    foreach ($events as $e) {
        DB::Aowow()->query('REPLACE INTO ?_events VALUES (?a)', array_values($e));
    }
    return true;
}
Example #4
0
 protected function generateContent()
 {
     $conditions = [];
     if (!User::isInGroup(U_GROUP_EMPLOYEE)) {
         // unlisted factions
         $conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
     }
     if (isset($this->category[1])) {
         $conditions[] = ['parentFactionId', $this->category[1]];
     } else {
         if (isset($this->category[0])) {
             if ($this->category[0]) {
                 $subs = DB::Aowow()->selectCol('SELECT id FROM ?_factions WHERE parentFactionId = ?d', $this->category[0]);
             } else {
                 $subs = [0];
             }
             $conditions[] = ['OR', ['parentFactionId', $subs], ['id', $subs]];
         }
     }
     $data = [];
     $factions = new FactionList($conditions);
     if (!$factions->error) {
         $data = $factions->getListviewData();
     }
     $this->lvTabs[] = array('file' => 'faction', 'data' => $data, 'params' => []);
 }
Example #5
0
function titles()
{
    $questQuery = '
        SELECT
             qt.RewardTitleId AS ARRAY_KEY,
             qt.RequiredRaces,
             ge.holiday
        FROM
            quest_template qt
        LEFT JOIN
            game_event_seasonal_questrelation sq ON sq.questId = qt.id
        LEFT JOIN
            game_event ge ON ge.eventEntry = sq.eventEntry
        WHERE
             qt.RewardTitleId <> 0';
    DB::Aowow()->query('REPLACE INTO ?_titles SELECT Id, 0, 0, 0, 0, 0, 0, 0, male_loc0, male_loc2, male_loc3, male_loc6, male_loc8, female_loc0, female_loc2, female_loc3, female_loc6, female_loc8 FROM dbc_chartitles');
    // hide unused titles
    DB::Aowow()->query('UPDATE ?_titles SET cuFlags = ?d WHERE id BETWEEN 85 AND 123 AND id NOT IN (113, 120, 121, 122)', CUSTOM_EXCLUDE_FOR_LISTVIEW);
    // set expansion
    DB::Aowow()->query('UPDATE ?_titles SET expansion = 2 WHERE id >= 72 AND id <> 80');
    DB::Aowow()->query('UPDATE ?_titles SET expansion = 1 WHERE id >= 42 AND id <> 46 AND expansion = 0');
    // set category
    DB::Aowow()->query('UPDATE ?_titles SET category = 1 WHERE id <= 28 OR id IN (42, 43, 44, 45, 47, 48, 62, 71, 72, 80, 82, 126, 127, 128, 157, 163, 167, 169, 177)');
    DB::Aowow()->query('UPDATE ?_titles SET category = 5 WHERE id BETWEEN 96 AND 109 OR id IN (83, 84)');
    DB::Aowow()->query('UPDATE ?_titles SET category = 2 WHERE id BETWEEN 144 AND 156 OR id IN (63, 77, 79, 113, 123, 130, 131, 132, 176)');
    DB::Aowow()->query('UPDATE ?_titles SET category = 6 WHERE id IN (46, 74, 75, 76, 124, 133, 134, 135, 137, 138, 155, 168)');
    DB::Aowow()->query('UPDATE ?_titles SET category = 4 WHERE id IN (81, 125)');
    DB::Aowow()->query('UPDATE ?_titles SET category = 3 WHERE id IN (53, 64, 120, 121, 122, 129, 139, 140, 141, 142) OR (id >= 158 AND category = 0)');
    // update side
    $questInfo = DB::World()->select($questQuery);
    $sideUpd = DB::World()->selectCol('SELECT IF (title_A, title_A, title_H) AS ARRAY_KEY, BIT_OR(IF(title_A, 1, 2)) AS side FROM achievement_reward WHERE (title_A <> 0 AND title_H = 0) OR (title_H <> 0 AND title_A = 0) GROUP BY ARRAY_KEY HAVING side <> 3');
    foreach ($questInfo as $tId => $data) {
        if ($data['holiday']) {
            DB::Aowow()->query('UPDATE ?_titles SET holidayId = ?d WHERE id = ?d', $data['holiday'], $tId);
        }
        $side = Util::sideByRaceMask($data['RequiredRaces']);
        if ($side == 3) {
            continue;
        }
        if (!isset($sideUpd[$tId])) {
            $sideUpd[$tId] = $side;
        } else {
            $sideUpd[$tId] |= $side;
        }
    }
    foreach ($sideUpd as $tId => $side) {
        if ($side != 3) {
            DB::Aowow()->query("UPDATE ?_titles SET side = ?d WHERE id = ?d", $side, $tId);
        }
    }
    // update side - sourceless titles (maintain query order)
    DB::Aowow()->query('UPDATE ?_titles SET side = 2 WHERE id <= 28 OR id IN (118, 119, 116, 117, 110, 127)');
    DB::Aowow()->query('UPDATE ?_titles SET side = 1 WHERE id <= 14 OR id IN (111, 115, 112, 114, 126)');
    // ! src12Ext pendant in source-script !
    $doubles = DB::World()->selectCol('SELECT IF(title_A, title_A, title_H) AS ARRAY_KEY, GROUP_CONCAT(entry SEPARATOR " "), count(1) FROM achievement_reward WHERE title_A <> 0 OR title_H <> 0 GROUP BY ARRAY_KEY HAVING count(1) > 1');
    foreach ($doubles as $tId => $acvIds) {
        DB::Aowow()->query('UPDATE ?_titles SET src12Ext = ?d WHERE id = ?d', explode(' ', $acvIds)[1], $tId);
    }
    return true;
}
Example #6
0
function talents()
{
    // class: 0 => hunter pets
    for ($i = 1; $i < 6; $i++) {
        DB::Aowow()->query('REPLACE INTO ?_talents SELECT t.Id, IF(tt.classMask <> 0, LOG(2, tt.classMask) + 1, 0), IF(tt.creaturefamilyMask <> 0, LOG(2, tt.creaturefamilyMask), tt.tabNumber), t.row, t.column, t.rank?d, ?d FROM dbc_talenttab tt JOIN dbc_talent t ON tt.Id = t.tabId WHERE t.rank?d <> 0', $i, $i, $i);
    }
    return true;
}
Example #7
0
function itemScalingSD()
{
    $data = DB::Aowow()->select('SELECT *, Id AS ARRAY_KEY FROM dbc_scalingstatdistribution');
    foreach ($data as &$row) {
        $row = array_values($row);
        array_splice($row, 0, 1);
    }
    return CFG_DEBUG ? debugify($data) : Util::toJSON($data);
}
Example #8
0
 public static function getName($id)
 {
     if ($id > 0) {
         $row = DB::Aowow()->SelectRow('SELECT * FROM ?_holidays WHERE Id = ?d', intVal($id));
     } else {
         $row = DB::Aowow()->SelectRow('SELECT description as name FROM ?_events WHERE Id = ?d', intVal(-$id));
     }
     return Util::localizedString($row, 'name');
 }
Example #9
0
function itemrandomenchant()
{
    $query = '
        REPLACE INTO ?_itemrandomenchant
            SELECT -id, name_loc0, name_loc2, name_loc3, name_loc4, name_loc6, name_loc8, nameINT, enchantId1, enchantId2, enchantId3, enchantId4, enchantId5, allocationPct1, allocationPct2, allocationPct3, allocationPct4, allocationPct5 FROM dbc_itemrandomsuffix
        UNION
            SELECT  id, name_loc0, name_loc2, name_loc3, name_loc4, name_loc6, name_loc8, nameINT, enchantId1, enchantId2, enchantId3, enchantId4, enchantId5, 0, 0, 0, 0, 0 FROM dbc_itemrandomproperties';
    DB::Aowow()->query($query);
    return true;
}
Example #10
0
function icons()
{
    $baseQuery = '
        REPLACE INTO
            ?_icons
                SELECT Id, LOWER(SUBSTRING_INDEX(iconPath, "\\\\", -1)) FROM dbc_spellicon
            UNION
                SELECT -Id, LOWER(inventoryIcon1) FROM dbc_itemdisplayinfo';
    DB::Aowow()->query($baseQuery);
    return true;
}
Example #11
0
function spelldifficulty(array $ids = [])
{
    // has no unique keys..
    DB::Aowow()->query('TRUNCATE TABLE ?_spelldifficulty');
    DB::Aowow()->query('INSERT INTO ?_spelldifficulty SELECT * FROM dbc_spelldifficulty');
    $rows = DB::World()->select('SELECT spellid0, spellid1, spellid2, spellid3 FROM spelldifficulty_dbc');
    foreach ($rows as $r) {
        DB::Aowow()->query('INSERT INTO ?_spelldifficulty VALUES (?a)', array_values($r));
    }
    return true;
}
Example #12
0
 protected function handleGoToComment()
 {
     if (!$this->_get['id']) {
         exit;
     }
     // just be blank
     if ($_ = DB::Aowow()->selectRow('SELECT IFNULL(c2.id, c1.id) AS id, IFNULL(c2.type, c1.type) AS type, IFNULL(c2.typeId, c1.typeId) AS typeId FROM ?_comments c1 LEFT JOIN ?_comments c2 ON c1.replyTo = c2.id WHERE c1.id = ?d', $this->_get['id'])) {
         return '?' . Util::$typeStrings[$_['type']] . '=' . $_['typeId'] . '#comments:id=' . $_['id'] . ($_['id'] != $this->_get['id'] ? ':reply=' . $this->_get['id'] : null);
     } else {
         exit;
     }
 }
Example #13
0
 private function getTalentDistribution($tString)
 {
     $classMask = 1 << $this->character['classs'] - 1;
     $distrib = DB::Aowow()->selectCol('SELECT COUNT(t.id) FROM dbc_talent t JOIN dbc_talenttab tt ON t.tabId = tt.id WHERE tt.classMask & ?d GROUP BY tt.id ORDER BY tt.tabNumber ASC', $classMask);
     $result = [0, 0, 0];
     $start = 0;
     foreach ($distrib as $idx => $len) {
         $result[$idx] = array_sum(str_split(substr($tString, $start, $len)));
         $start += $len;
     }
     return $result;
 }
Example #14
0
function gems()
{
    // sketchy, but should work
    // Id < 36'000 || ilevel < 70 ? BC : WOTLK
    $gems = DB::Aowow()->Select('SELECT    i.id AS itemId,
                      i.name_loc0, i.name_loc2, i.name_loc3, i.name_loc4, i.name_loc6, i.name_loc8,
                      IF (i.id < 36000 OR i.itemLevel < 70, 1 , 2) AS expansion,
                      i.quality,
                      ic.iconString AS icon,
                      i.gemEnchantmentId AS enchId,
                      i.gemColorMask AS colors
            FROM      ?_items i
            JOIN      ?_icons ic ON ic.id = -i.displayId
            WHERE     i.gemEnchantmentId <> 0
            ORDER BY  i.id DESC');
    $success = true;
    // check directory-structure
    foreach (Util::$localeStrings as $dir) {
        if (!CLISetup::writeDir('datasets/' . $dir)) {
            $success = false;
        }
    }
    $enchIds = [];
    foreach ($gems as $pop) {
        $enchIds[] = $pop['enchId'];
    }
    $enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
    if ($enchantments->error) {
        CLISetup::log('Required table ?_itemenchantment seems to be empty! Leaving gems()...', CLISetup::LOG_ERROR);
        CLISetup::log();
        return false;
    }
    foreach (CLISetup::$localeIds as $lId) {
        set_time_limit(5);
        User::useLocale($lId);
        Lang::load(Util::$localeStrings[$lId]);
        $gemsOut = [];
        foreach ($gems as $pop) {
            if (!$enchantments->getEntry($pop['enchId'])) {
                CLISetup::log(' * could not find enchantment #' . $pop['enchId'] . ' referenced by item #' . $gem['itemId'], CLISetup::LOG_WARN);
                continue;
            }
            $gemsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'quality' => $pop['quality'], 'icon' => strToLower($pop['icon']), 'enchantment' => $enchantments->getField('name', true), 'jsonequip' => $enchantments->getStatGain(), 'colors' => $pop['colors'], 'expansion' => $pop['expansion']);
        }
        $toFile = "var g_gems = " . Util::toJSON($gemsOut) . ";";
        $file = 'datasets/' . User::$localeString . '/gems';
        if (!CLISetup::writeFile($file, $toFile)) {
            $success = false;
        }
    }
    return $success;
}
Example #15
0
 private function getTalentDistribution()
 {
     if (!empty($this->tDistribution)) {
         $this->tDistribution[$this->curTpl['classId']] = DB::Aowow()->selectCol('SELECT COUNT(t.id) FROM dbc_talent t JOIN dbc_talenttab tt ON t.tabId = tt.id WHERE tt.classMask & ?d GROUP BY tt.id ORDER BY tt.tabNumber ASC', 1 << $this->curTpl['classId'] - 1);
     }
     $result = [];
     $start = 0;
     foreach ($this->tDistribution[$this->curTpl['classId']] as $len) {
         $result[] = array_sum(str_split(substr($this->curTpl['talentString'], $start, $len)));
         $start += $len;
     }
     return $result;
 }
Example #16
0
function glyphs()
{
    $success = true;
    $glyphList = DB::Aowow()->Select('SELECT i.id AS itemId,
                   i.*,
                   IF (g.typeFlags & 0x1, 2, 1) AS type,
                   i.subclass AS classs,
                   i.requiredLevel AS level,
                   s1.Id AS glyphSpell,
                   ic.iconString AS icon,
                   s1.skillLine1 AS skillId,
                   s2.Id AS glyphEffect,
                   s2.Id AS ARRAY_KEY
            FROM   ?_items i
            JOIN   ?_spell s1 ON s1.Id = i.spellid1
            JOIN   ?_glyphproperties g ON g.Id = s1.effect1MiscValue
            JOIN   ?_spell s2 ON s2.Id = g.spellId
            JOIN   ?_icons ic ON ic.Id = s1.iconIdAlt
            WHERE  i.classBak = 16');
    // check directory-structure
    foreach (Util::$localeStrings as $dir) {
        if (!CLISetup::writeDir('datasets/' . $dir)) {
            $success = false;
        }
    }
    $glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)], CFG_SQL_LIMIT_NONE));
    foreach (CLISetup::$localeIds as $lId) {
        set_time_limit(30);
        User::useLocale($lId);
        Lang::load(Util::$localeStrings[$lId]);
        $glyphsOut = [];
        foreach ($glyphSpells->iterate() as $__) {
            $pop = $glyphList[$glyphSpells->id];
            if (!$pop['glyphEffect']) {
                continue;
            }
            if ($glyphSpells->getField('effect1Id') != 6 && $glyphSpells->getField('effect2Id') != 6 && $glyphSpells->getField('effect3Id') != 6) {
                continue;
            }
            $glyphsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'description' => $glyphSpells->parseText()[0], 'icon' => $pop['icon'], 'type' => $pop['type'], 'classs' => $pop['classs'], 'skill' => $pop['skillId'], 'level' => $pop['level']);
        }
        $toFile = "var g_glyphs = " . Util::toJSON($glyphsOut) . ";";
        $file = 'datasets/' . User::$localeString . '/glyphs';
        if (!CLISetup::writeFile($file, $toFile)) {
            $success = false;
        }
    }
    return $success;
}
Example #17
0
function update()
{
    list($date, $part) = array_values(DB::Aowow()->selectRow('SELECT `date`, `part` FROM ?_dbversion'));
    CLISetup::log('checking sql updates');
    $nFiles = 0;
    foreach (glob('setup/updates/*.sql') as $file) {
        $pi = pathinfo($file);
        list($fDate, $fPart) = explode('_', $pi['filename']);
        if ($date && $fDate < $date) {
            continue;
        } else {
            if ($part && $date && $fDate == $date && $fPart <= $part) {
                continue;
            }
        }
        $nFiles++;
        $updQuery = '';
        $nQuerys = 0;
        foreach (file($file) as $line) {
            // skip comments
            if (substr($line, 0, 2) == '--' || $line == '') {
                continue;
            }
            $updQuery .= $line;
            // semicolon at the end -> end of query
            if (substr(trim($line), -1, 1) == ';') {
                if (DB::Aowow()->query($updQuery)) {
                    $nQuerys++;
                }
                $updQuery = '';
            }
        }
        DB::Aowow()->query('UPDATE ?_dbversion SET `date`= ?d, `part` = ?d', $fDate, $fPart);
        CLISetup::log(' -> ' . date('d.m.Y', $fDate) . ' #' . $fPart . ': ' . $nQuerys . ' queries applied', CLISetup::LOG_OK);
    }
    CLISetup::log($nFiles ? 'applied ' . $nFiles . ' update(s)' : 'db is already up to date', CLISetup::LOG_OK);
    // fetch sql/build after applying updates, as they may contain sync-prompts
    list($sql, $build) = array_values(DB::Aowow()->selectRow('SELECT `sql`, `build` FROM ?_dbversion'));
    sleep(1);
    $sql = trim($sql) ? array_unique(explode(' ', trim($sql))) : [];
    $build = trim($build) ? array_unique(explode(' ', trim($build))) : [];
    if ($sql) {
        CLISetup::log('The following table(s) require syncing: ' . implode(', ', $sql));
    }
    if ($build) {
        CLISetup::log('The following file(s) require syncing: ' . implode(', ', $build));
    }
    return [$sql, $build];
}
Example #18
0
 protected function generateContent()
 {
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // has Animation
     if ($this->subject->getField('isAnimated')) {
         $infobox[] = Lang::emote('isAnimated');
     }
     /****************/
     /* Main Content */
     /****************/
     $text = '';
     if ($aliasses = DB::Aowow()->selectCol('SELECT command FROM ?_emotes_aliasses WHERE id = ?d AND locales & ?d', $this->typeId, 1 << User::$localeId)) {
         $text .= '[h3]' . Lang::emote('aliases') . '[/h3][ul]';
         foreach ($aliasses as $a) {
             $text .= '[li]/' . $a . '[/li]';
         }
         $text .= '[/ul][br][br]';
     }
     $texts = [];
     if ($_ = $this->subject->getField('self', true)) {
         $texts[Lang::emote('self')] = $_;
     }
     if ($_ = $this->subject->getField('target', true)) {
         $texts[Lang::emote('target')] = $_;
     }
     if ($_ = $this->subject->getField('noTarget', true)) {
         $texts[Lang::emote('noTarget')] = $_;
     }
     if (!$texts) {
         $text .= '[div][i class=q0]' . Lang::emote('noText') . '[/i][/div]';
     } else {
         foreach ($texts as $h => $t) {
             $text .= '[pad][b]' . $h . '[/b][ul][li][span class=s4]' . preg_replace('/%\\d?\\$?s/', '<' . Util::ucFirst(Lang::main('name')) . '>', $t) . '[/span][/li][/ul]';
         }
     }
     $this->extraText = $text;
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     /**************/
     /* Extra Tabs */
     /**************/
     // tab: achievement
     $condition = array(['ac.type', ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE], ['ac.value1', $this->typeId]);
     $acv = new AchievementList($condition);
     $this->lvTabs[] = ['achievement', ['data' => array_values($acv->getListviewData())]];
     $this->extendGlobalData($acv->getJsGlobals());
 }
Example #19
0
function holidays()
{
    $query = '
        REPLACE INTO
            ?_holidays (id, name_loc0, name_loc2, name_loc3, name_loc6, name_loc8, description_loc0, description_loc2, description_loc3, description_loc6, description_loc8, looping, scheduleType, textureString)
        SELECT
            h.id, n.name_loc0, n.name_loc2, n.name_loc3, n.name_loc6, n.name_loc8, d.description_loc0, d.description_loc2, d.description_loc3, d.description_loc6, d.description_loc8, h.looping, h.scheduleType, h.textureString
        FROM
            dbc_holidays h
        LEFT JOIN
            dbc_holidaynames n ON n.id = h.nameId
        LEFT JOIN
            dbc_holidaydescriptions d ON d.id = h.descriptionId';
    DB::Aowow()->query($query);
    return true;
}
Example #20
0
function races()
{
    $baseQuery = '
        REPLACE INTO
            ?_races
        SELECT
            Id, 0, flags, 0, factionId, 0, 0, baseLanguage, IF(side = 2, 0, side + 1), fileString, name_loc0, name_loc2, name_loc3, name_loc4, name_loc6, name_loc8, expansion
        FROM
            dbc_chrraces';
    DB::Aowow()->query($baseQuery);
    // add classMask
    DB::Aowow()->query('UPDATE ?_races r JOIN (SELECT BIT_OR(1 << (classId - 1)) as classMask, raceId FROM dbc_charbaseinfo GROUP BY raceId) cbi ON cbi.raceId = r.id SET r.classMask = cbi.classMask');
    // add cuFlags
    DB::Aowow()->query('UPDATE ?_races SET cuFlags = ?d WHERE flags & ?d', CUSTOM_EXCLUDE_FOR_LISTVIEW, 0x1);
    return true;
}
Example #21
0
function pets()
{
    $success = true;
    $locations = [];
    $petList = DB::Aowow()->Select('SELECT    cr. id,
                      cr.name_loc0, cr.name_loc2, cr.name_loc3, cr.name_loc6, cr.name_loc8,
                      cr.minLevel,
                      cr.maxLevel,
                      ft.A,
                      ft.H,
                      cr.rank AS classification,
                      cr.family,
                      cr.displayId1 AS displayId,
                      cr.textureString AS skin,
                      LOWER(SUBSTRING_INDEX(cf.iconString, "\\\\", -1)) AS icon,
                      cf.petTalentType AS type
            FROM      ?_creature cr
            JOIN      ?_factiontemplate  ft ON ft.Id = cr.faction
            JOIN      dbc_creaturefamily cf ON cf.id = cr.family
            WHERE     cr.typeFlags & 0x1 AND (cr.cuFlags & 0x2) = 0
            ORDER BY  cr.id ASC');
    // check directory-structure
    foreach (Util::$localeStrings as $dir) {
        if (!CLISetup::writeDir('datasets/' . $dir)) {
            $success = false;
        }
    }
    foreach (CLISetup::$localeIds as $lId) {
        User::useLocale($lId);
        Lang::load(Util::$localeStrings[$lId]);
        $petsOut = [];
        foreach ($petList as $pet) {
            // get locations
            // again: caching will save you time and nerves
            if (!isset($locations[$pet['id']])) {
                $locations[$pet['id']] = DB::Aowow()->SelectCol('SELECT DISTINCT areaId FROM ?_spawns WHERE type = ?d AND typeId = ?d', TYPE_NPC, $pet['id']);
            }
            $petsOut[$pet['id']] = array('id' => $pet['id'], 'name' => Util::localizedString($pet, 'name'), 'minlevel' => $pet['minLevel'], 'maxlevel' => $pet['maxLevel'], 'location' => $locations[$pet['id']], 'react' => [$pet['A'], $pet['H']], 'classification' => $pet['classification'], 'family' => $pet['family'], 'displayId' => $pet['displayId'], 'skin' => $pet['skin'], 'icon' => $pet['icon'], 'type' => $pet['type']);
        }
        $toFile = "var g_pets = " . Util::toJSON($petsOut) . ";";
        $file = 'datasets/' . User::$localeString . '/pets';
        if (!CLISetup::writeFile($file, $toFile)) {
            $success = false;
        }
    }
    return $success;
}
Example #22
0
 public static function getName($id)
 {
     $row = DB::Aowow()->SelectRow('
         SELECT
             IFNULL(h.name_loc0, e.description) AS name_loc0,
             h.name_loc2,
             h.name_loc3,
             h.name_loc6,
             h.name_loc8
         FROM
             ?_events e
         LEFT JOIN
             ?_holidays h ON e.holidayId = h.id
         WHERE
             e.id = ?d', $id);
     return Util::localizedString($row, 'name');
 }
Example #23
0
 protected function handleContactUs()
 {
     $mode = $this->_post['mode'];
     $rsn = $this->_post['reason'];
     $ua = $this->_post['ua'];
     $app = $this->_post['appname'];
     $url = $this->_post['page'];
     $desc = $this->_post['desc'];
     $contexts = array([1, 2, 3, 4, 5, 6, 7, 8], [15, 16, 17, 18, 19, 20], [30, 31, 32, 33, 34, 35, 36, 37], [45, 46, 47, 48], [60, 61], [45, 46, 47, 48], [45, 46, 48]);
     if ($mode === null || $rsn === null || $ua === null || $app === null || $url === null) {
         return 'required field missing';
     }
     if (!isset($contexts[$mode]) || !in_array($rsn, $contexts[$mode])) {
         return 'mode invalid';
     }
     if (!$desc) {
         return 3;
     }
     if (mb_strlen($desc) > 500) {
         return 2;
     }
     if (!User::$id && !User::$ip) {
         return 'your ip could not be determined';
     }
     // check already reported
     $field = User::$id ? 'userId' : 'ip';
     if (DB::Aowow()->selectCell('SELECT 1 FROM ?_reports WHERE `mode` = ?d AND `reason`= ?d AND `subject` = ?d AND ?# = ?', $mode, $rsn, $this->_post['id'], $field, User::$id ?: User::$ip)) {
         return 7;
     }
     $update = array('userId' => User::$id, 'mode' => $mode, 'reason' => $rsn, 'ip' => User::$ip, 'description' => $desc, 'userAgent' => $ua, 'appName' => $app, 'url' => $url);
     if ($_ = $this->_post['id']) {
         $update['subject'] = $_;
     }
     if ($_ = $this->_post['relatedurl']) {
         $update['relatedurl'] = $_;
     }
     if ($_ = $this->_post['email']) {
         $update['email'] = $_;
     }
     if (DB::Aowow()->query('INSERT INTO ?_reports (?#) VALUES (?a)', array_keys($update), array_values($update))) {
         return 0;
     }
     return 'save to db unsuccessful';
 }
Example #24
0
function gems()
{
    // sketchy, but should work
    // Id < 36'000 || ilevel < 70 ? BC : WOTLK
    $gems = DB::Aowow()->Select('SELECT    i.id AS itemId,
                      i.name_loc0, i.name_loc2, i.name_loc3, i.name_loc6, i.name_loc8,
                      IF (i.id < 36000 OR i.itemLevel < 70, 1 , 2) AS expansion,
                      i.quality,
                      ic.iconString AS icon,
                      i.gemEnchantmentId AS enchId,
                      i.gemColorMask AS colors
            FROM      ?_items i
            JOIN      ?_icons ic ON ic.id = -i.displayId
            WHERE     i.gemEnchantmentId <> 0
            ORDER BY  i.id DESC');
    $success = true;
    // check directory-structure
    foreach (Util::$localeStrings as $dir) {
        if (!CLISetup::writeDir('datasets/' . $dir)) {
            $success = false;
        }
    }
    $enchIds = [];
    foreach ($gems as $pop) {
        $enchIds[] = $pop['enchId'];
    }
    $enchMisc = [];
    $enchJSON = Util::parseItemEnchantment($enchIds, false, $enchMisc);
    foreach (CLISetup::$localeIds as $lId) {
        set_time_limit(5);
        User::useLocale($lId);
        Lang::load(Util::$localeStrings[$lId]);
        $gemsOut = [];
        foreach ($gems as $pop) {
            $gemsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'quality' => $pop['quality'], 'icon' => strToLower($pop['icon']), 'enchantment' => Util::localizedString(@$enchMisc[$pop['enchId']]['text'] ?: [], 'text'), 'jsonequip' => @$enchJSON[$pop['enchId']] ?: [], 'colors' => $pop['colors'], 'expansion' => $pop['expansion']);
        }
        $toFile = "var g_gems = " . Util::toJSON($gemsOut) . ";";
        $file = 'datasets/' . User::$localeString . '/gems';
        if (!CLISetup::writeFile($file, $toFile)) {
            $success = false;
        }
    }
    return $success;
}
Example #25
0
function update()
{
    $createQuery = "\r\n        CREATE TABLE `aowow_dbversion` (\r\n            `date` INT(10) UNSIGNED NOT NULL DEFAULT '0',\r\n            `part` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0'\r\n        ) ENGINE=MyISAM";
    $date = $part = 0;
    if (!DB::Aowow()->selectCell('SHOW TABLES LIKE "%dbversion"')) {
        DB::Aowow()->query($createQuery);
        DB::Aowow()->query('INSERT INTO ?_dbversion VALUES (0, 0)');
    } else {
        list($date, $part) = array_values(DB::Aowow()->selectRow('SELECT `date`, `part` FROM ?_dbversion'));
    }
    CLISetup::log('checking sql updates');
    $nFiles = 0;
    foreach (glob('setup/updates/*.sql') as $file) {
        $pi = pathinfo($file);
        list($fDate, $fPart) = explode('_', $pi['filename']);
        if ($date && $fDate < $date) {
            continue;
        } else {
            if ($part && $date && $fDate == $date && $fPart <= $part) {
                continue;
            }
        }
        $nFiles++;
        $updQuery = '';
        $nQuerys = 0;
        foreach (file($file) as $line) {
            // skip comments
            if (substr($line, 0, 2) == '--' || $line == '') {
                continue;
            }
            $updQuery .= $line;
            // semicolon at the end -> end of query
            if (substr(trim($line), -1, 1) == ';') {
                if (DB::Aowow()->query($updQuery)) {
                    $nQuerys++;
                }
                $updQuery = '';
            }
        }
        DB::Aowow()->query('UPDATE ?_dbversion SET `date`= ?d, `part` = ?d', $fDate, $fPart);
        CLISetup::log(' -> ' . date('d.m.Y', $fDate) . ' #' . $fPart . ': ' . $nQuerys . ' queries applied', CLISetup::LOG_OK);
    }
    CLISetup::log($nFiles ? 'applied ' . $nFiles . ' update(s)' : 'db is already up to date', CLISetup::LOG_OK);
}
Example #26
0
function classes()
{
    $classes = DB::Aowow()->select('SELECT *, Id AS ARRAY_KEY FROM dbc_chrclasses');
    // add raceMask
    $races = DB::Aowow()->select('SELECT classId AS ARRAY_KEY, BIT_OR(1 << (raceId - 1)) AS raceMask FROM dbc_charbaseinfo GROUP BY classId');
    Util::arraySumByKey($classes, $races);
    // add skills
    $skills = DB::Aowow()->select('SELECT LOG(2, classMask) + 1 AS ARRAY_KEY, GROUP_CONCAT(skillLine SEPARATOR \' \') AS skills FROM dbc_skillraceclassinfo WHERE flags = 1040 GROUP BY classMask HAVING ARRAY_KEY = CAST(LOG(2, classMask) + 1 AS SIGNED)');
    Util::arraySumByKey($classes, $skills);
    // add weaponTypeMask & armorTypeMask
    foreach ($classes as $id => &$data) {
        $data['weaponTypeMask'] = DB::Aowow()->selectCell('SELECT BIT_OR(equippedItemSubClassMask) FROM dbc_spell s JOIN dbc_skilllineability sla ON sla.spellId = s.id JOIN dbc_skillraceclassinfo srci ON srci.skillLine = sla.skillLineId AND srci.classMask & ?d WHERE sla.skilllineid <> 183 AND (sla.reqClassMask & ?d OR sla.reqClassMask = 0) AND equippedItemClass = ?d AND (effect1Id = 60 OR effect2Id = 60)', 1 << $id - 1, 1 << $id - 1, ITEM_CLASS_WEAPON);
        $data['armorTypeMask'] = DB::Aowow()->selectCell('SELECT BIT_OR(equippedItemSubClassMask) FROM dbc_spell s JOIN dbc_skilllineability sla ON sla.spellId = s.id JOIN dbc_skillraceclassinfo srci ON srci.skillLine = sla.skillLineId AND srci.classMask & ?d WHERE                             sla.reqClassMask & ?d                          AND equippedItemClass = ?d AND (effect1Id = 60 OR effect2Id = 60)', 1 << $id - 1, 1 << $id - 1, ITEM_CLASS_ARMOR);
    }
    foreach ($classes as $cl) {
        DB::Aowow()->query('REPLACE INTO ?_classes (?#) VALUES (?a)', array_keys($cl), array_values($cl));
    }
    return true;
}
Example #27
0
function itemenchantment()
{
    $baseQuery = '
        REPLACE INTO
            ?_itemenchantment
        SELECT
            Id, charges, 0, 0, 0, type1, type2, type3, amount1, amount2, amount3, object1, object2, object3, name_loc0, name_loc2, name_loc3, name_loc6, name_loc8, conditionId, skillLine, skillLevel, requiredLevel
        FROM
            dbc_spellitemenchantment';
    DB::Aowow()->query($baseQuery);
    $cuProcs = DB::World()->select('SELECT entry AS ARRAY_KEY, customChance AS procChance, PPMChance AS ppmRate FROM spell_enchant_proc_data');
    foreach ($cuProcs as $id => $vals) {
        DB::Aowow()->query('UPDATE ?_itemenchantment SET ?a WHERE id = ?d', $vals, $id);
    }
    // hide strange stuff
    DB::Aowow()->query('UPDATE ?_itemenchantment SET cuFlags = ?d WHERE type1 = 0 AND type2 = 0 AND type3 = 0', CUSTOM_EXCLUDE_FOR_LISTVIEW);
    DB::Aowow()->query('UPDATE ?_itemenchantment SET cuFlags = ?d WHERE name_loc0 LIKE "%test%"', CUSTOM_EXCLUDE_FOR_LISTVIEW);
    return true;
}
Example #28
0
function factiontemplate()
{
    $query = '
        REPLACE INTO
            ?_factiontemplate
        SELECT
            id,
            factionId,
            IF(friendFactionId1 = 1 OR friendFactionId2 = 1 OR friendFactionId3 = 1 OR friendFactionId4 = 1 OR friendlyMask & 0x3,
                1,
                IF(enemyFactionId1 = 1 OR enemyFactionId2 = 1 OR enemyFactionId3 = 1 OR enemyFactionId4 = 1 OR hostileMask & 0x3, -1, 0)
            ),
            IF(friendFactionId1 = 2 OR friendFactionId2 = 2 OR friendFactionId3 = 2 OR friendFactionId4 = 2 OR friendlyMask & 0x5,
                1,
                IF(enemyFactionId1 = 2 OR enemyFactionId2 = 2 OR enemyFactionId3 = 2 OR enemyFactionId4 = 2 OR hostileMask & 0x5, -1, 0)
            )
        FROM
            dbc_factiontemplate';
    DB::Aowow()->query($query);
    return true;
}
Example #29
0
function quests_startend()
{
    $query['creature'] = '
        SELECT 1 AS type, id AS typeId, quest AS questId, 1 AS method, 0          AS eventId FROM creature_queststarter UNION
        SELECT 1 AS type, id AS typeId, quest AS questId, 2 AS method, 0          AS eventId FROM creature_questender   UNION
        SELECT 1 AS type, id AS typeId, quest AS questId, 1 AS method, eventEntry AS eventId FROM game_event_creature_quest';
    $query['object'] = '
        SELECT 2 AS type, id AS typeId, quest AS questId, 1 AS method, 0          AS eventId FROM gameobject_queststarter UNION
        SELECT 2 AS type, id AS typeId, quest AS questId, 2 AS method, 0          AS eventId FROM gameobject_questender   UNION
        SELECT 2 AS type, id AS typeId, quest AS questId, 1 AS method, eventEntry AS eventId FROM game_event_gameobject_quest';
    $query['item'] = 'SELECT 3 AS type, entry AS typeId, startquest AS questId, 1 AS method, 0 AS eventId FROM item_template WHERE startquest <> 0';
    // always rebuild this table from scratch
    // or how would i know what to fetch specifically
    DB::Aowow()->query('TRUNCATE TABLE ?_quests_startend');
    foreach ($query as $q) {
        $data = DB::World()->select($q);
        foreach ($data as $d) {
            DB::Aowow()->query('INSERT INTO ?_quests_startend (?#) VALUES (?a) ON DUPLICATE KEY UPDATE method = method | VALUES(method), eventId = IF(eventId = 0, VALUES(eventId), eventId)', array_keys($d), array_values($d));
        }
    }
    return true;
}
Example #30
0
function skillline()
{
    $baseQuery = '
        REPLACE INTO
            ?_skillline
        SELECT
            Id, categoryId, 0, categoryId, name_loc0, name_loc2, name_loc3, name_loc4, name_loc6, name_loc8, description_loc0, description_loc2, description_loc3, description_loc4, description_loc6, description_loc8, iconId, 0, 0, ""
        FROM
            dbc_skillline';
    DB::Aowow()->query($baseQuery);
    // categorization
    DB::Aowow()->query('UPDATE ?_skillline SET typeCat = -5 WHERE id = 777 OR (categoryId = 9 AND id NOT IN (356, 129, 185, 142, 155))');
    DB::Aowow()->query('UPDATE ?_skillline SET typeCat = -4 WHERE categoryId = 9 AND name_loc0 LIKE "%racial%"');
    DB::Aowow()->query('UPDATE ?_skillline SET typeCat = -6 WHERE id IN (778, 788, 758) OR (categoryId = 7 AND name_loc0 LIKE "%pet%")');
    // more complex fixups
    DB::Aowow()->query('UPDATE ?_skillline sl, dbc_spell s, dbc_skilllineability sla SET sl.iconId = s.iconId WHERE (s.effect1Id IN (25, 26, 40) OR s.effect2Id = 60) AND sla.spellId = s.id AND sl.id = sla.skillLineId');
    DB::Aowow()->query('UPDATE ?_skillline SET name_loc8 = REPLACE(name_loc8, " - ", ": ") WHERE categoryId = 7 OR id IN (758, 788)');
    DB::Aowow()->query('UPDATE ?_skillline SET iconId = ?d WHERE iconId = 0', 1776);
    // inv_misc_questionmark
    DB::Aowow()->query('UPDATE ?_skillline SET cuFlags = ?d WHERE id IN (?a)', CUSTOM_EXCLUDE_FOR_LISTVIEW, [142, 148, 149, 150, 152, 155, 183, 533, 553, 554, 713, 769]);
    return true;
}