Esempio n. 1
0
function bbcode_callbacks_wow($item)
{
    global $item_datasite;
    wowhead_tt();
    require_once "scripts/id_tab.php";
    require_once "scripts/get_lib.php";
    return "<a href=\"{$item_datasite}{$item[1]}\" target=\"_blank\"\r\nonmouseover=\"toolTip('" . addslashes(get_item_tooltip($item[1])) . "','item_tooltip')\" onmouseout=\"toolTip()\">\r\n<img src=\"" . get_item_icon($item[1]) . "\" class=\"icon_border\" alt=\"\" /></a>";
}
Esempio n. 2
0
function bbcode_callbacks_wow($item)
{
    global $base_datasite, $item_datasite;
    wowhead_tt();
    require_once "scripts/id_tab.php";
    require_once "scripts/get_lib.php";
    return '
    <a href="' . $base_datasite . $item_datasite . $item[1] . '" target="_blank" onmouseover="oldtoolTip(\'' . addslashes(get_item_tooltip($item[1])) . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()">
      <img src="' . get_item_icon($item[1]) . '" class="icon_border" alt="" />
    </a>';
}
function char_main()
{
    global $output, $realm_id, $logon_db, $characters_db, $world_db, $server, $corem_db, $site_encoding, $action_permission, $user_lvl, $user_name, $user_id, $locales_search_option, $base_datasite, $item_datasite, $spell_datasite, $showcountryflag, $timezone_offset, $sql, $core;
    // this page uses wowhead tooltops
    //wowhead_tt();
    // we need at either an id or a name or we would have nothing to show
    if (empty($_GET["id"])) {
        if (empty($_GET["name"])) {
            error(lang("global", "empty_fields"));
        }
    }
    // this is multi realm support, as of writing still under development
    // this page is already implementing it
    if (empty($_GET["realm"])) {
        $realmid = $realm_id;
    } else {
        $realmid = $sql["logon"]->quote_smart($_GET["realm"]);
        if (is_numeric($realmid)) {
            $sql["char"]->connect($characters_db[$realmid]["addr"], $characters_db[$realmid]["user"], $characters_db[$realmid]["pass"], $characters_db[$realmid]["name"], $characters_db[$realmid]["encoding"]);
        } else {
            $realmid = $realm_id;
        }
    }
    if (empty($_GET["id"])) {
        $name = $sql["char"]->quote_smart($_GET["name"]);
        if ($core == 1) {
            $result = $sql["char"]->query("SELECT guid, acct, race FROM characters WHERE name='" . $name . "' LIMIT 1");
        } else {
            $result = $sql["char"]->query("SELECT guid, id AS acct, race FROM characters WHERE name='" . $name . "' LIMIT 1");
        }
        $id_result = $sql["char"]->fetch_assoc($result);
        $id = $id_result["guid"];
    } else {
        $id = $sql["char"]->quote_smart($_GET["id"]);
    }
    if (!is_numeric($id)) {
        error(lang("global", "empty_fields"));
    }
    if ($core == 1) {
        $result = $sql["char"]->query("SELECT acct, race FROM characters WHERE guid='" . $id . "' LIMIT 1");
    } else {
        $result = $sql["char"]->query("SELECT account AS acct, race FROM characters WHERE guid='" . $id . "' LIMIT 1");
    }
    if ($sql["char"]->num_rows($result)) {
        //resrict by owner's gmlvl
        $owner_acc_id = $sql["char"]->result($result, 0, "acct");
        if ($core == 1) {
            $query = $sql["logon"]->query("SELECT login FROM accounts WHERE acct='" . $owner_acc_id . "'");
        } else {
            $query = $sql["logon"]->query("SELECT username as login FROM account WHERE id='" . $owner_acc_id . "'");
        }
        $owner_name = $sql["logon"]->result($query, 0, "login");
        $s_query = "SELECT *, SecurityLevel AS gm FROM config_accounts WHERE Login='******'";
        $s_result = $sql["mgr"]->query($s_query);
        $s_fields = $sql["mgr"]->fetch_assoc($s_result);
        $owner_gmlvl = $s_fields["gm"];
        $view_mod = $s_fields["View_Mod_Sheet"];
        if ($owner_gmlvl >= 1073741824) {
            $owner_gmlvl -= 1073741824;
        }
        // owner configured overrides
        $view_override = false;
        if ($view_mod > 0) {
            if ($view_mod == 1) {
            } elseif ($view_mod == 2) {
                // only registered users may view this page
                if ($user_lvl > -1) {
                    $view_override = true;
                }
            }
        }
        if ($user_lvl || $server[$realmid]["both_factions"]) {
            $side_v = 0;
            $side_p = 0;
        } else {
            $side_p = in_array($sql["char"]->result($result, 0, "race"), array(2, 5, 6, 8, 10)) ? 1 : 2;
            if ($core == 1) {
                $result_1 = $sql["char"]->query("SELECT race FROM characters WHERE acct='" . $user_id . "' LIMIT 1");
            } else {
                $result_1 = $sql["char"]->query("SELECT race FROM characters WHERE account='" . $user_id . "' LIMIT 1");
            }
            if ($sql["char"]->num_rows($result)) {
                $side_v = in_array($sql["char"]->result($result_1, 0, "race"), array(2, 5, 6, 8, 10)) ? 1 : 2;
            } else {
                $side_v = 0;
            }
            unset($result_1);
        }
        if ($view_override || $user_lvl >= gmlevel($owner_gmlvl) && ($side_v === $side_p || !$side_v)) {
            if ($core == 1) {
                $result = $sql["char"]->query("SELECT guid, name, race, class, level, zoneid, mapid, online, gender,\n          SUBSTRING_INDEX(SUBSTRING_INDEX(playedtime, ' ', 2), ' ', -1) AS totaltime,\n          acct, data, timestamp, xp \n          FROM characters WHERE guid='" . $id . "'");
            } elseif ($core == 2) {
                $result = $sql["char"]->query("SELECT guid, name, race, class, level, zone AS zoneid, map AS mapid, \n          online, gender, totaltime, account AS acct, logout_time AS timestamp, health, \n\t\t\t\t\tpower1, power2, power3, power4, power5, power6, power7, xp,\n          arenaPoints, totalHonorPoints, totalKills\n          FROM characters WHERE guid='" . $id . "'");
            } else {
                $result = $sql["char"]->query("SELECT guid, name, race, class, level, zone AS zoneid, map AS mapid, \n          online, gender, totaltime, account AS acct, logout_time AS timestamp, health, \n\t\t\t\t\tpower1, power2, power3, power4, power5, power6, power7, xp, arenaPoints, totalHonorPoints, totalKills\n          FROM characters WHERE guid='" . $id . "'");
            }
            $char = $sql["char"]->fetch_assoc($result);
            // find out what mode we're in View or Delete (0 = View, 1 = Delete)
            $mode = isset($_GET["mode"]) ? $_GET["mode"] : 0;
            // only the character's owner or a GM with Delete privs can enter Delete Mode
            if ($owner_name != $user_name) {
                if ($user_lvl < $action_permission["delete"]) {
                    $mode = 0;
                } else {
                    $mode = $mode;
                }
            }
            // View Mode is only availble on characters that are offline
            if ($char["online"] != 0) {
                $mode = 0;
            }
            if ($core == 1) {
                $char_data = $char["data"];
                if (empty($char_data)) {
                    $char_data = str_repeat("0;", PLAYER_END);
                }
                $char_data = explode(";", $char_data);
            } else {
                $query = "SELECT * FROM characters LEFT JOIN character_stats ON characters.guid=character_stats.guid WHERE characters.guid='" . $id . "'";
                $char_data_result = $sql["char"]->query($query);
                $char_data_fields = $sql["char"]->fetch_assoc($char_data_result);
                $char_data[PLAYER_BLOCK_PERCENTAGE] = isset($char_data_fields["blockPct"]) ? $char_data_fields["blockPct"] : '&nbsp;';
                $char_data[PLAYER_DODGE_PERCENTAGE] = isset($char_data_fields["dodgePct"]) ? $char_data_fields["dodgePct"] : '&nbsp;';
                $char_data[PLAYER_PARRY_PERCENTAGE] = isset($char_data_fields["parryPct"]) ? $char_data_fields["parryPct"] : '&nbsp;';
                $char_data[PLAYER_CRIT_PERCENTAGE] = isset($char_data_fields["critPct"]) ? $char_data_fields["critPct"] : '&nbsp;';
                $char_data[PLAYER_RANGED_CRIT_PERCENTAGE] = isset($char_data_fields["rangedCritPct"]) ? $char_data_fields["rangedCritPct"] : '&nbsp;';
                $char_data[UNIT_FIELD_MAXDAMAGE] = isset($char_data_fields["attackPower"]) ? $char_data_fields["attackPower"] : '&nbsp;';
                $char_data[UNIT_FIELD_MINDAMAGE] = isset($char_data_fields["attackPower"]) ? $char_data_fields["attackPower"] : '&nbsp;';
                $char_data[UNIT_FIELD_MAXRANGEDDAMAGE] = isset($char_data_fields["rangedAttackPower"]) ? $char_data_fields["rangedAttackPower"] : '&nbsp;';
                $char_data[UNIT_FIELD_MINRANGEDDAMAGE] = isset($char_data_fields["rangedAttackPower"]) ? $char_data_fields["rangedAttackPower"] : '&nbsp;';
                $char_data[PLAYER_SPELL_CRIT_PERCENTAGE1] = isset($char_data_fields["spellCritPct"]) ? $char_data_fields["spellCritPct"] : '&nbsp;';
                $char_data[PLAYER_FIELD_MOD_DAMAGE_DONE_POS] = isset($char_data_fields["spellPower"]) ? $char_data_fields["spellPower"] : '&nbsp;';
                $char_data[UNIT_FIELD_STAT0] = isset($char_data_fields["strength"]) ? $char_data_fields["strength"] : '&nbsp;';
                $char_data[UNIT_FIELD_STAT1] = isset($char_data_fields["agility"]) ? $char_data_fields["agility"] : '&nbsp;';
                $char_data[UNIT_FIELD_STAT2] = isset($char_data_fields["stamina"]) ? $char_data_fields["stamina"] : '&nbsp;';
                $char_data[UNIT_FIELD_STAT3] = isset($char_data_fields["intellect"]) ? $char_data_fields["intellect"] : '&nbsp;';
                $char_data[UNIT_FIELD_STAT4] = isset($char_data_fields["spirit"]) ? $char_data_fields["spirit"] : '&nbsp;';
                $char_data[UNIT_FIELD_RESISTANCES] = isset($char_data_fields["armor"]) ? $char_data_fields["armor"] : '&nbsp;';
                $char_data[UNIT_FIELD_RESISTANCES + 1] = isset($char_data_fields["resHoly"]) ? $char_data_fields["resHoly"] : '&nbsp;';
                $char_data[UNIT_FIELD_RESISTANCES + 2] = isset($char_data_fields["resArcane"]) ? $char_data_fields["resArcane"] : '&nbsp;';
                $char_data[UNIT_FIELD_RESISTANCES + 3] = isset($char_data_fields["resFire"]) ? $char_data_fields["resFire"] : '&nbsp;';
                $char_data[UNIT_FIELD_RESISTANCES + 4] = isset($char_data_fields["resNature"]) ? $char_data_fields["resNature"] : '&nbsp;';
                $char_data[UNIT_FIELD_RESISTANCES + 5] = isset($char_data_fields["resFrost"]) ? $char_data_fields["resFrost"] : '&nbsp;';
                $char_data[UNIT_FIELD_RESISTANCES + 6] = isset($char_data_fields["resShadow"]) ? $char_data_fields["resShadow"] : '&nbsp;';
                $char_data[UNIT_FIELD_HEALTH] = isset($char["health"]) ? $char["health"] : '&nbsp;';
                $char_data[UNIT_FIELD_MAXHEALTH] = isset($char_data_fields["maxhealth"]) ? $char_data_fields["maxhealth"] : '&nbsp;';
                $char_data[UNIT_FIELD_POWER1] = isset($char["power1"]) ? $char["power1"] : '&nbsp;';
                $char_data[UNIT_FIELD_POWER2] = isset($char["power2"]) ? $char["power2"] : '&nbsp;';
                $char_data[UNIT_FIELD_POWER3] = isset($char["power3"]) ? $char["power3"] : '&nbsp;';
                $char_data[UNIT_FIELD_POWER4] = isset($char["power4"]) ? $char["power4"] : '&nbsp;';
                $char_data[UNIT_FIELD_POWER5] = isset($char["power5"]) ? $char["power5"] : '&nbsp;';
                $char_data[UNIT_FIELD_POWER6] = isset($char["power6"]) ? $char["power6"] : '&nbsp;';
                $char_data[UNIT_FIELD_POWER7] = isset($char["power7"]) ? $char["power7"] : '&nbsp;';
                $char_data[UNIT_FIELD_MAXPOWER1] = isset($char_data_fields["maxpower1"]) ? $char_data_fields["maxpower1"] : '&nbsp;';
                $char_data[UNIT_FIELD_MAXPOWER2] = isset($char_data_fields["maxpower2"]) ? $char_data_fields["maxpower2"] : '&nbsp;';
                $char_data[UNIT_FIELD_MAXPOWER3] = isset($char_data_fields["maxpower3"]) ? $char_data_fields["maxpower3"] : '&nbsp;';
                $char_data[UNIT_FIELD_MAXPOWER4] = isset($char_data_fields["maxpower4"]) ? $char_data_fields["maxpower4"] : '&nbsp;';
                $char_data[UNIT_FIELD_MAXPOWER5] = isset($char_data_fields["maxpower5"]) ? $char_data_fields["maxpower5"] : '&nbsp;';
                $char_data[UNIT_FIELD_MAXPOWER6] = isset($char_data_fields["maxpower6"]) ? $char_data_fields["maxpower6"] : '&nbsp;';
                $char_data[UNIT_FIELD_MAXPOWER7] = isset($char_data_fields["maxpower7"]) ? $char_data_fields["maxpower7"] : '&nbsp;';
                $char_data[PLAYER_FIELD_MOD_HEALING_DONE_POS] = "ERR";
                $char_data[PLAYER_FIELD_COMBAT_RATING_1 + 5] = "ERR";
                $char_data[PLAYER_FIELD_COMBAT_RATING_1 + 17] = "ERR";
                $char_data[PLAYER_FIELD_COMBAT_RATING_1 + 6] = "ERR";
                $char_data[PLAYER_FIELD_COMBAT_RATING_1 + 7] = "ERR";
                $char_data[PLAYER_EXPERTISE] = "ERR";
                $char_data[PLAYER_OFFHAND_EXPERTISE] = "ERR";
                $char_data[PLAYER_FIELD_HONOR_CURRENCY] = isset($char["totalHonorPoints"]) ? $char["totalHonorPoints"] : '&nbsp;';
                $char_data[PLAYER_FIELD_ARENA_CURRENCY] = isset($char["arenaPoints"]) ? $char["arenaPoints"] : '&nbsp;';
                $char_data[PLAYER_FIELD_LIFETIME_HONORBALE_KILLS] = isset($char["totalKills"]) ? $char["totalKills"] : '&nbsp;';
            }
            if ($core == 1) {
                $guild_id = $sql["char"]->result($sql["char"]->query("SELECT guildid FROM guild_data WHERE playerid='" . $char["guid"] . "'"), 0);
                $guild_rank = $sql["char"]->result($sql["char"]->query("SELECT guildRank FROM guild_data WHERE playerid='" . $char["guid"] . "'"), 0);
                $guild_name = $sql["char"]->result($sql["char"]->query("SELECT guildName FROM guilds WHERE guildid='" . $guild_id . "'"));
            } else {
                $guild_id = $sql["char"]->result($sql["char"]->query("SELECT guildid FROM guild_member WHERE guid='" . $char["guid"] . "'"), 0);
                $guild_rank = $sql["char"]->result($sql["char"]->query("SELECT rank AS guildRank FROM guild_member WHERE guid='" . $char["guid"] . "'"), 0);
                $guild_name = $sql["char"]->result($sql["char"]->query("SELECT name AS guildName FROM guild WHERE guildid='" . $guild_id . "'"));
            }
            $online = $char["online"] ? lang("char", "online") : lang("char", "offline");
            if ($guild_id) {
                //$guild_name = $sql["char"]->result($sql["char"]->query('SELECT name FROM guild WHERE guildid ='.$char_data[CHAR_DATA_OFFSET_GUILD_ID].''), 0, 'name');
                $guild_name = '<a href="guild.php?action=view_guild&amp;realm=' . $realmid . '&amp;error=3&amp;id=' . $guild_id . '" >' . $guild_name . '</a>';
                $mrank = $guild_rank;
                if ($core == 1) {
                    $guild_rank = $sql["char"]->result($sql["char"]->query("SELECT rankname FROM guild_ranks WHERE guildid='" . $guild_id . "' AND rankId='" . $mrank . "'"), 0, "rankname");
                } else {
                    $guild_rank = $sql["char"]->result($sql["char"]->query("SELECT rname AS rankname FROM guild_rank WHERE guildid='" . $guild_id . "' AND rid='" . $mrank . "'"), 0, "rankname");
                }
            } else {
                $guild_name = lang("global", "none");
                $guild_rank = lang("global", "none");
            }
            if ($core == 1) {
                $block = unpack("f", pack("L", $char_data[PLAYER_BLOCK_PERCENTAGE]));
                $block = round($block[1], 2);
                $dodge = unpack("f", pack("L", $char_data[PLAYER_DODGE_PERCENTAGE]));
                $dodge = round($dodge[1], 2);
                $parry = unpack("f", pack("L", $char_data[PLAYER_PARRY_PERCENTAGE]));
                $parry = round($parry[1], 2);
                $crit = unpack("f", pack("L", $char_data[PLAYER_CRIT_PERCENTAGE]));
                $crit = round($crit[1], 2);
                $ranged_crit = unpack("f", pack("L", $char_data[PLAYER_RANGED_CRIT_PERCENTAGE]));
                $ranged_crit = round($ranged_crit[1], 2);
                $maxdamage = unpack("f", pack("L", $char_data[UNIT_FIELD_MAXDAMAGE]));
                $maxdamage = round($maxdamage[1], 0);
                $mindamage = unpack("f", pack("L", $char_data[UNIT_FIELD_MINDAMAGE]));
                $mindamage = round($mindamage[1], 0);
                $maxrangeddamage = unpack("f", pack("L", $char_data[UNIT_FIELD_MAXRANGEDDAMAGE]));
                $maxrangeddamage = round($maxrangeddamage[1], 0);
                $minrangeddamage = unpack("f", pack("L", $char_data[UNIT_FIELD_MINRANGEDDAMAGE]));
                $minrangeddamage = round($minrangeddamage[1], 0);
            } else {
                $block = $char_data[PLAYER_BLOCK_PERCENTAGE];
                $block = round($block, 2);
                $dodge = $char_data[PLAYER_DODGE_PERCENTAGE];
                $dodge = round($dodge, 2);
                $parry = $char_data[PLAYER_PARRY_PERCENTAGE];
                $parry = round($parry, 2);
                $crit = $char_data[PLAYER_CRIT_PERCENTAGE];
                $crit = round($crit, 2);
                $ranged_crit = $char_data[PLAYER_RANGED_CRIT_PERCENTAGE];
                $ranged_crit = round($ranged_crit, 2);
                $maxdamage = $char_data[UNIT_FIELD_MAXDAMAGE];
                $maxdamage = round($maxdamage, 0);
                $mindamage = $char_data[UNIT_FIELD_MINDAMAGE];
                $mindamage = round($mindamage, 0);
                $maxrangeddamage = $char_data[UNIT_FIELD_MAXRANGEDDAMAGE];
                $maxrangeddamage = round($maxrangeddamage, 0);
                $minrangeddamage = $char_data[UNIT_FIELD_MINRANGEDDAMAGE];
                $minrangeddamage = round($minrangeddamage, 0);
            }
            if ($core == 1) {
                $spell_crit = 100;
                for ($i = 0; $i < 6; ++$i) {
                    $temp = unpack("f", pack("L", $char_data[PLAYER_SPELL_CRIT_PERCENTAGE1 + 1 + $i]));
                    if ($temp[1] < $spell_crit) {
                        $spell_crit = $temp[1];
                    }
                }
                $spell_crit = round($spell_crit, 2);
            } else {
                $spell_crit = $char_data[PLAYER_SPELL_CRIT_PERCENTAGE1];
                $spell_crit = round($spell_crit, 2);
            }
            if ($core == 1) {
                $spell_damage = 9999;
                for ($i = 0; $i < 6; ++$i) {
                    if ($char_data[PLAYER_FIELD_MOD_DAMAGE_DONE_POS + 1 + $i] < $spell_damage) {
                        $spell_damage = $char_data[PLAYER_FIELD_MOD_DAMAGE_DONE_POS + 1 + $i];
                    }
                }
            } else {
                $spell_damage = $char_data[PLAYER_FIELD_MOD_DAMAGE_DONE_POS];
            }
            $spell_heal = $char_data[PLAYER_FIELD_MOD_HEALING_DONE_POS];
            // this_is_junk: PLAYER_FIELD_COMBAT_RATING_1 +5, +6, and +7 seem to have the same value as +5
            //               I'm not sure which of these fields is which hit rating. :/
            $spell_hit = $char_data[PLAYER_FIELD_COMBAT_RATING_1 + 5];
            // this_is_junk: PLAYER_FIELD_COMBAT_RATING_1 +18 and +19 seem to have the same value as +5
            //               I'm not sure which of these fields is really spell haste. :/
            $spell_haste = $char_data[PLAYER_FIELD_COMBAT_RATING_1 + 17];
            // this_is_junk: PLAYER_FIELD_COMBAT_RATING_1 +5, +6, and +7 seem to have the same value as +5
            //               I'm not sure which of these fields is which hit rating. :/
            $ranged_hit = $char_data[PLAYER_FIELD_COMBAT_RATING_1 + 6];
            // this_is_junk: PLAYER_FIELD_COMBAT_RATING_1 +5, +6, and +7 seem to have the same value as +5
            //               I'm not sure which of these fields is which hit rating. :/
            $melee_hit = $char_data[PLAYER_FIELD_COMBAT_RATING_1 + 7];
            $expertise = $char_data[PLAYER_EXPERTISE] . " / " . $char_data[PLAYER_OFFHAND_EXPERTISE];
            //if ( $core == 1 )
            //{
            /*$EQU_HEAD      = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 0];
              $EQU_NECK      = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 2];
              $EQU_SHOULDER  = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 4];
              $EQU_SHIRT     = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 6];
              $EQU_CHEST     = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 8];
              $EQU_BELT      = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 10];
              $EQU_LEGS      = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 12];
              $EQU_FEET      = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 14];
              $EQU_WRIST     = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 16];
              $EQU_GLOVES    = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 18];
              $EQU_FINGER1   = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 20];
              $EQU_FINGER2   = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 22];
              $EQU_TRINKET1  = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 24];
              $EQU_TRINKET2  = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 26];
              $EQU_BACK      = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 28];
              $EQU_MAIN_HAND = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 30];
              $EQU_OFF_HAND  = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 32];
              $EQU_RANGED    = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 34];
              $EQU_TABARD    = $char_data[PLAYER_FIELD_INV_SLOT_HEAD + 36];*/
            //}
            //else
            //{
            $world_db_name = $world_db[$realm_id]["name"];
            if ($core == 1) {
                $char_equip_query = "SELECT *, \n          playeritems.entry AS item_template, randomprop as property, enchantments AS enchantment, flags\n          FROM playeritems WHERE ownerguid='" . $id . "' AND containerslot=-1";
            } elseif ($core == 2) {
                $char_equip_query = "SELECT *,\n          SUBSTRING_INDEX(SUBSTRING_INDEX(item_instance.data, ' ', 11), ' ', -1) AS creator,\n          SUBSTRING_INDEX(SUBSTRING_INDEX(item_instance.data, ' ', 23), ' ', -1) AS enchantment,\n          SUBSTRING_INDEX(SUBSTRING_INDEX(item_instance.data, ' ', 60), ' ', -1) AS property,\n          SUBSTRING_INDEX(SUBSTRING_INDEX(item_instance.data, ' ', 62), ' ', -1) AS durability,\n          SUBSTRING_INDEX(SUBSTRING_INDEX(item_instance.data, ' ', 22), ' ', -1) AS flags\n          FROM character_inventory\n            LEFT JOIN item_instance ON character_inventory.item=item_instance.guid\n          WHERE character_inventory.guid='" . $id . "' AND character_inventory.bag=0";
            } else {
                $char_equip_query = "SELECT *,\n          creatorGuid AS creator, enchantments AS enchantment,\n          randomPropertyId AS property, durability, flags,\n          itemEntry AS item_template\n          FROM character_inventory\n            LEFT JOIN item_instance ON character_inventory.item=item_instance.guid\n          WHERE character_inventory.guid='" . $id . "' AND character_inventory.bag=0";
            }
            $char_equip_result = $sql["char"]->query($char_equip_query);
            while ($equip_row = $sql["char"]->fetch_assoc($char_equip_result)) {
                switch ($equip_row["slot"]) {
                    case 0:
                        $EQU_HEAD = $equip_row["item_template"];
                        $EQU_HEAD_ROW = $equip_row;
                        break;
                    case 1:
                        $EQU_NECK = $equip_row["item_template"];
                        $EQU_NECK_ROW = $equip_row;
                        break;
                    case 2:
                        $EQU_SHOULDER = $equip_row["item_template"];
                        $EQU_SHOULDER_ROW = $equip_row;
                        break;
                    case 3:
                        $EQU_SHIRT = $equip_row["item_template"];
                        $EQU_SHIRT_ROW = $equip_row;
                        break;
                    case 4:
                        $EQU_CHEST = $equip_row["item_template"];
                        $EQU_CHEST_ROW = $equip_row;
                        break;
                    case 5:
                        $EQU_BELT = $equip_row["item_template"];
                        $EQU_BELT_ROW = $equip_row;
                        break;
                    case 6:
                        $EQU_LEGS = $equip_row["item_template"];
                        $EQU_LEGS_ROW = $equip_row;
                        break;
                    case 7:
                        $EQU_FEET = $equip_row["item_template"];
                        $EQU_FEET_ROW = $equip_row;
                        break;
                    case 8:
                        $EQU_WRIST = $equip_row["item_template"];
                        $EQU_WRIST_ROW = $equip_row;
                        break;
                    case 9:
                        $EQU_GLOVES = $equip_row["item_template"];
                        $EQU_GLOVES_ROW = $equip_row;
                        break;
                    case 10:
                        $EQU_FINGER1 = $equip_row["item_template"];
                        $EQU_FINGER1_ROW = $equip_row;
                        break;
                    case 11:
                        $EQU_FINGER2 = $equip_row["item_template"];
                        $EQU_FINGER2_ROW = $equip_row;
                        break;
                    case 12:
                        $EQU_TRINKET1 = $equip_row["item_template"];
                        $EQU_TRINKET1_ROW = $equip_row;
                        break;
                    case 13:
                        $EQU_TRINKET2 = $equip_row["item_template"];
                        $EQU_TRINKET2_ROW = $equip_row;
                        break;
                    case 14:
                        $EQU_BACK = $equip_row["item_template"];
                        $EQU_BACK_ROW = $equip_row;
                        break;
                    case 15:
                        $EQU_MAIN_HAND = $equip_row["item_template"];
                        $EQU_MAIN_HAND_ROW = $equip_row;
                        break;
                    case 16:
                        $EQU_OFF_HAND = $equip_row["item_template"];
                        $EQU_OFF_HAND_ROW = $equip_row;
                        break;
                    case 17:
                        $EQU_RANGED = $equip_row["item_template"];
                        $EQU_RANGED_ROW = $equip_row;
                        break;
                    case 18:
                        $EQU_TABARD = $equip_row["item_template"];
                        $EQU_TABARD_ROW = $equip_row;
                        break;
                }
            }
            //}
            $equiped_items = array(1 => array("", $EQU_HEAD ? get_item_icon($EQU_HEAD) : 0, $EQU_HEAD ? get_item_border($EQU_HEAD) : 0, $EQU_HEAD_ROW), 2 => array("", $EQU_NECK ? get_item_icon($EQU_NECK) : 0, $EQU_NECK ? get_item_border($EQU_NECK) : 0, $EQU_NECK_ROW), 3 => array("", $EQU_SHOULDER ? get_item_icon($EQU_SHOULDER) : 0, $EQU_SHOULDER ? get_item_border($EQU_SHOULDER) : 0, $EQU_SHOULDER_ROW), 4 => array("", $EQU_SHIRT ? get_item_icon($EQU_SHIRT) : 0, $EQU_SHIRT ? get_item_border($EQU_SHIRT) : 0, $EQU_SHIRT_ROW), 5 => array("", $EQU_CHEST ? get_item_icon($EQU_CHEST) : 0, $EQU_CHEST ? get_item_border($EQU_CHEST) : 0, $EQU_CHEST_ROW), 6 => array("", $EQU_BELT ? get_item_icon($EQU_BELT) : 0, $EQU_BELT ? get_item_border($EQU_BELT) : 0, $EQU_BELT_ROW), 7 => array("", $EQU_LEGS ? get_item_icon($EQU_LEGS) : 0, $EQU_LEGS ? get_item_border($EQU_LEGS) : 0, $EQU_LEGS_ROW), 8 => array("", $EQU_FEET ? get_item_icon($EQU_FEET) : 0, $EQU_FEET ? get_item_border($EQU_FEET) : 0, $EQU_FEET_ROW), 9 => array("", $EQU_WRIST ? get_item_icon($EQU_WRIST) : 0, $EQU_WRIST ? get_item_border($EQU_WRIST) : 0, $EQU_WRIST_ROW), 10 => array("", $EQU_GLOVES ? get_item_icon($EQU_GLOVES) : 0, $EQU_GLOVES ? get_item_border($EQU_GLOVES) : 0, $EQU_GLOVES_ROW), 11 => array("", $EQU_FINGER1 ? get_item_icon($EQU_FINGER1) : 0, $EQU_FINGER1 ? get_item_border($EQU_FINGER1) : 0, $EQU_FINGER1_ROW), 12 => array("", $EQU_FINGER2 ? get_item_icon($EQU_FINGER2) : 0, $EQU_FINGER2 ? get_item_border($EQU_FINGER2) : 0, $EQU_FINGER2_ROW), 13 => array("", $EQU_TRINKET1 ? get_item_icon($EQU_TRINKET1) : 0, $EQU_TRINKET1 ? get_item_border($EQU_TRINKET1) : 0, $EQU_TRINKET1_ROW), 14 => array("", $EQU_TRINKET2 ? get_item_icon($EQU_TRINKET2) : 0, $EQU_TRINKET2 ? get_item_border($EQU_TRINKET2) : 0, $EQU_TRINKET2_ROW), 15 => array("", $EQU_BACK ? get_item_icon($EQU_BACK) : 0, $EQU_BACK ? get_item_border($EQU_BACK) : 0, $EQU_BACK_ROW), 16 => array("", $EQU_MAIN_HAND ? get_item_icon($EQU_MAIN_HAND) : 0, $EQU_MAIN_HAND ? get_item_border($EQU_MAIN_HAND) : 0, $EQU_MAIN_HAND_ROW), 17 => array("", $EQU_OFF_HAND ? get_item_icon($EQU_OFF_HAND) : 0, $EQU_OFF_HAND ? get_item_border($EQU_OFF_HAND) : 0, $EQU_OFF_HAND_ROW), 18 => array("", $EQU_RANGED ? get_item_icon($EQU_RANGED) : 0, $EQU_RANGED ? get_item_border($EQU_RANGED) : 0, $EQU_RANGED_ROW), 19 => array("", $EQU_TABARD ? get_item_icon($EQU_TABARD) : 0, $EQU_TABARD ? get_item_border($EQU_TABARD) : 0, $EQU_TABARD_ROW));
            // visibility overrides for specific tabs
            $view_inv_override = false;
            if ($s_fields["View_Mod_Inv"] > 0) {
                if ($s_fields["View_Mod_Inv"] == 1) {
                } elseif ($s_fields["View_Mod_Inv"] == 2) {
                    // only registered users may view this tab
                    if ($user_lvl > -1) {
                        $view_inv_override = true;
                    }
                }
            } else {
                if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                    $view_inv_override = true;
                }
            }
            $view_talent_override = false;
            if ($s_fields["View_Mod_Talent"] > 0) {
                if ($s_fields["View_Mod_Talent"] == 1) {
                } elseif ($s_fields["View_Mod_Talent"] == 2) {
                    // only registered users may view this tab
                    if ($user_lvl > -1) {
                        $view_talent_override = true;
                    }
                }
            } else {
                if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                    $view_talent_override = true;
                }
            }
            $view_achieve_override = false;
            if ($s_fields["View_Mod_Achieve"] > 0) {
                if ($s_fields["View_Mod_Achieve"] == 1) {
                } elseif ($s_fields["View_Mod_Achieve"] == 2) {
                    // only registered users may view this tab
                    if ($user_lvl > -1) {
                        $view_achieve_override = true;
                    }
                }
            } else {
                if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                    $view_achieve_override = true;
                }
            }
            $view_quest_override = false;
            if ($s_fields["View_Mod_Quest"] > 0) {
                if ($s_fields["View_Mod_Quest"] == 1) {
                } elseif ($s_fields["View_Mod_Quest"] == 2) {
                    // only registered users may view this tab
                    if ($user_lvl > -1) {
                        $view_quest_override = true;
                    }
                }
            } else {
                if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                    $view_quest_override = true;
                }
            }
            $view_friends_override = false;
            if ($s_fields["View_Mod_Friends"] > 0) {
                if ($s_fields["View_Mod_Friends"] == 1) {
                } elseif ($s_fields["View_Mod_Friends"] == 2) {
                    // only registered users may view this tab
                    if ($user_lvl > -1) {
                        $view_friends_override = true;
                    }
                }
            } else {
                if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                    $view_friends_override = true;
                }
            }
            $view_view_override = false;
            if ($s_fields["View_Mod_View"] > 0) {
                if ($s_fields["View_Mod_View"] == 1) {
                } elseif ($s_fields["View_Mod_View"] == 2) {
                    // only registered users may view this tab
                    if ($user_lvl > -1) {
                        $view_view_override = true;
                    }
                }
            } else {
                if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                    $view_view_override = true;
                }
            }
            $view_pets_override = false;
            if ($s_fields["View_Mod_Pets"] > 0) {
                if ($s_fields["View_Mod_Pets"] == 1) {
                } elseif ($s_fields["View_Mod_Pets"] == 2) {
                    // only registered users may view this tab
                    if ($user_lvl > -1) {
                        $view_pets_override = true;
                    }
                }
            } else {
                if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                    $view_pets_override = true;
                }
            }
            $view_rep_override = false;
            if ($s_fields["View_Mod_Rep"] > 0) {
                if ($s_fields["View_Mod_Rep"] == 1) {
                } elseif ($s_fields["View_Mod_Rep"] == 2) {
                    // only registered users may view this tab
                    if ($user_lvl > -1) {
                        $view_rep_override = true;
                    }
                }
            } else {
                if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                    $view_rep_override = true;
                }
            }
            $view_skill_override = false;
            if ($s_fields["View_Mod_Skill"] > 0) {
                if ($s_fields["View_Mod_Skill"] == 1) {
                } elseif ($s_fields["View_Mod_Skill"] == 2) {
                    // only registered users may view this tab
                    if ($user_lvl > -1) {
                        $view_skill_override = true;
                    }
                }
            } else {
                if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                    $view_skill_override = true;
                }
            }
            $view_pvp_override = false;
            if ($s_fields["View_Mod_PvP"] > 0) {
                if ($s_fields["View_Mod_PvP"] == 1) {
                } elseif ($s_fields["View_Mod_PvP"] == 2) {
                    // only registered users may view this tab
                    if ($user_lvl > -1) {
                        $view_pvp_override = true;
                    }
                }
            } else {
                if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                    $view_pvp_override = true;
                }
            }
            $output .= '
          <!-- start of char.php -->
          <div class="tab">
            <ul>
              <li class="selected"><a href="char.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "char_sheet") . '</a></li>';
            if ($view_inv_override) {
                $output .= '
              <li><a href="char_inv.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "inventory") . '</a></li>';
            }
            if ($view_talent_override) {
                $output .= '
              ' . ($char["level"] < 10 ? '' : '<li><a href="char_talent.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "talents") . '</a></li>') . '';
            }
            if ($view_achieve_override) {
                $output .= '
              <li><a href="char_achieve.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "achievements") . '</a></li>';
            }
            if ($view_quest_override) {
                $output .= '
              <li><a href="char_quest.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "quests") . '</a></li>';
            }
            if ($view_friends_override) {
                $output .= '
              <li><a href="char_friends.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "friends") . '</a></li>';
            }
            if ($view_view_override) {
                $output .= '
              <li><a href="char_view.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "view") . '</a></li>';
            }
            $output .= '
            </ul>
          </div>';
            if ($view_override || $user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                $output .= '
          <div class="tab_content center">
            <div class="tab">
              <ul>
                <li class="selected"><a href="char.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "char_sheet") . '</a></li>';
                if (char_get_class_name($char["class"]) === "Hunter" && $view_pets_override) {
                    $output .= '
                <li><a href="char_pets.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "pets") . '</a></li>';
                }
                if ($view_rep_override) {
                    $output .= '
                <li><a href="char_rep.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "reputation") . '</a></li>';
                }
                if ($view_skill_override) {
                    $output .= '
                <li><a href="char_skill.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "skills") . '</a></li>';
                }
                if ($view_pvp_override) {
                    $output .= '
                <li><a href="char_pvp.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "pvp") . '</a></li>';
                }
                if ($owner_name == $user_name || $user_lvl >= get_page_permission("insert", "char_mail.php")) {
                    $output .= '
                <li><a href="char_mail.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "mail") . '</a></li>';
                }
                $output .= '
              </ul>
            </div>';
            } else {
                $output .= '
            <div class="tab_content center">
              <div class="tab">
              </div>';
            }
            $output .= '
              <div class="tab_content2 center">
                <table class="lined" id="char_character_sheet">
                  <tr>
                    <td colspan="2">
                      <div>
                        <img src="' . char_get_avatar_img($char["level"], $char["gender"], $char["race"], $char["class"], 0) . '" alt="avatar" />
                      </div>
                      <div>';
            // this_is_junk: auras are stored in a string in the characters table.
            // not sure how to query a string as though it were a record
            if ($core == 1) {
            } else {
                $a_results = $sql["char"]->query("SELECT DISTINCT spell FROM character_aura WHERE guid='" . $id . "'");
            }
            if ($sql["char"]->num_rows($a_results)) {
                while ($aura = $sql["char"]->fetch_assoc($a_results)) {
                    $output .= '
                        <a class="char_icon_padding" href="' . $base_datasite . $spell_datasite . $aura["spell"] . '" rel="external">
                          <img src="' . spell_get_icon($aura["spell"]) . '" alt="' . $aura["spell"] . '" width="24" height="24" />
                        </a>';
                }
            }
            $output .= '
                      </div>
                    </td>
                    <td colspan="4">
                      <span class="bold">
                        ' . htmlentities($char["name"], ENT_COMPAT, $site_encoding) . ' -
                        <img src="img/c_icons/' . $char["race"] . '-' . $char["gender"] . '.gif" onmousemove="oldtoolTip(\'' . char_get_race_name($char["race"]) . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />
                        <img src="img/c_icons/' . $char["class"] . '.gif" onmousemove="oldtoolTip(\'' . char_get_class_name($char["class"]) . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />
                       - ' . lang("char", "level_short") . char_get_level_color($char["level"]) . '
                      </span>
                      <br />' . lang("char", "location") . ': ' . get_map_name($char["mapid"]) . ' - ' . get_zone_name($char["zoneid"]) . '
                      <br />' . lang("char", "honor_points") . ': ' . $char_data[PLAYER_FIELD_HONOR_CURRENCY] . ' | ' . lang("char", "arena_points") . ': ' . $char_data[PLAYER_FIELD_ARENA_CURRENCY] . ' | ' . lang("char", "honor_kills") . ': ' . $char_data[PLAYER_FIELD_LIFETIME_HONORBALE_KILLS] . '
                      <br />' . lang("char", "guild") . ': ' . $guild_name . ' | ' . lang("char", "rank") . ': ' . htmlentities($guild_rank, ENT_COMPAT, $site_encoding) . '
                      <br />' . lang("char", "online") . ': ' . ($char["online"] ? '<img src="img/up.gif" onmousemove="oldtoolTip(\'' . lang("char", "online") . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="online" />' : '<img src="img/down.gif" onmousemove="oldtoolTip(\'' . lang("char", "offline") . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="offline" />');
            if ($showcountryflag) {
                require_once 'libs/misc_lib.php';
                $country = misc_get_country_by_account($char["acct"]);
                $output .= ' | ' . lang("global", "country") . ': ' . ($country["code"] ? '<img src="img/flags/' . $country["code"] . '.png" onmousemove="oldtoolTip(\'' . $country["country"] . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />' : '-');
                unset($country);
            }
            $output .= '
                    </td>
                  </tr>
                  <tr>
                    <td style="width: 6%;">';
            if ($equiped_items[1][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_HEAD . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'HEAD' . '\');" onmouseout="HideTooltip(\'_b' . 'HEAD' . '\');">
                        <img src="' . $equiped_items[1][1] . '" class="' . $equiped_items[1][2] . '" alt="Head" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[1][3]["bag"] . '&slot=' . $equiped_items[1][3]["slot"] . '&item=' . $equiped_items[1][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[1][3]["item_template"]);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'HEAD' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[1][3]["enchantment"], $equiped_items[1][3]["property"], $equiped_items[1][3]["creator"], $equiped_items[1][3]["durability"], $equiped_items[1][3]["flags"]) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_head.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                    <td class="half_line" colspan="2" align="center" style="width: 50%;">
                      <div class="gradient_p" id="char_hp_name">' . lang("item", "health") . ':</div>
                      <div class="gradient_pp" id="char_hp_value">' . $char_data[UNIT_FIELD_HEALTH] . '/' . $char_data[UNIT_FIELD_MAXHEALTH] . '</div>';
            if ($char["class"] == 11) {
                //druid
                $output .= '
                      <br />
                      <div class="gradient_p" id="char_energy_name">' . lang("item", "mana") . ':</div>
                      <div class="gradient_pp" id="char_energy_value">' . $char_data[UNIT_FIELD_POWER1] . '/' . $char_data[UNIT_FIELD_MAXPOWER1] . '</div>';
            }
            $output .= '
                    </td>
                    <td class="half_line" colspan="2" align="center" style="width: 50%;">';
            if ($char["class"] == 1) {
                $output .= '
                      <div class="gradient_p" id="char_energy_name">' . lang("item", "rage") . ':</div>
                      <div class="gradient_pp" id="char_energy_value">' . $char_data[UNIT_FIELD_POWER2] / 10 . '/' . $char_data[UNIT_FIELD_MAXPOWER2] / 10 . '</div>';
            } elseif ($char["class"] == 4) {
                $output .= '
                      <div class="gradient_p" id="char_energy_name">' . lang("item", "energy") . ':</div>
                      <div class="gradient_pp" id="char_energy_value">' . $char_data[UNIT_FIELD_POWER4] . '/' . $char_data[UNIT_FIELD_MAXPOWER4] . '</div>';
            } elseif ($char["class"] == 6) {
                $output .= '
                      <div class="gradient_p" id="char_energy_name">' . lang("item", "runic") . ':</div>
                      <div class="gradient_pp" id="char_energy_value">' . $char_data[UNIT_FIELD_POWER7] / 10 . '/' . $char_data[UNIT_FIELD_MAXPOWER7] / 10 . '</div>';
            } elseif ($char["class"] == 11) {
                $output .= '
                      <div class="gradient_p" id="char_energy_name">' . lang("item", "mana") . ':</div>
                      <div class="gradient_pp" id="char_energy_value">' . $char_data[UNIT_FIELD_POWER1] . '/' . $char_data[UNIT_FIELD_MAXPOWER1] . '</div>
                      <br />
                      <div class="gradient_p" id="char_energy_name">' . lang("item", "rage") . ':</div>
                      <div class="gradient_pp" id="char_energy_value">' . $char_data[UNIT_FIELD_POWER2] / 10 . '/' . $char_data[UNIT_FIELD_MAXPOWER2] / 10 . '</div>';
            } elseif ($char["class"] == 2 || $char["class"] == 3 || $char["class"] == 5 || $char["class"] == 7 || $char["class"] == 8 || $char["class"] == 9) {
                $output .= '
                      <div class="gradient_p" id="char_energy_name">' . lang("item", "mana") . ':</div>
                      <div class="gradient_pp" id="char_energy_value">' . $char_data[UNIT_FIELD_POWER1] . '/' . $char_data[UNIT_FIELD_MAXPOWER1] . '</div>';
            }
            $output .= '
                    </td>
                    <td style="width: 6%;">';
            if ($equiped_items[10][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_GLOVES . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'GLOVES' . '\');" onmouseout="HideTooltip(\'_b' . 'GLOVES' . '\');">
                        <img src="' . $equiped_items[10][1] . '" class="' . $equiped_items[10][2] . '" alt="Gloves" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[10][3]["bag"] . '&slot=' . $equiped_items[10][3]["slot"] . '&item=' . $equiped_items[10][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[10][3]["item_template"]);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'GLOVES' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[10][3]["enchantment"], $equiped_items[10][3]["property"], $equiped_items[10][3]["creator"], $equiped_items[10][3]["durability"], $equiped_items[10][3]["flags"]) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_gloves.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                  </tr>
                  <tr>
                    <td style="width: 1%;">';
            if ($equiped_items[2][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_NECK . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'NECK' . '\');" onmouseout="HideTooltip(\'_b' . 'NECK' . '\');">
                        <img src="' . $equiped_items[2][1] . '" class="' . $equiped_items[2][2] . '" alt="Neck" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[2][3]["bag"] . '&slot=' . $equiped_items[2][3]["slot"] . '&item=' . $equiped_items[2][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[2][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'NECK' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[2][3]['enchantment'], $equiped_items[2][3]['property'], $equiped_items[2][3]['creator'], $equiped_items[2][3]['durability'], $equiped_items[2][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_neck.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                    <td class="half_line" colspan="2" rowspan="3" align="center" style="width: 50%;">
                      <div class="gradient_p">
                        ' . lang("item", "strength") . ':<br />
                        ' . lang("item", "agility") . ':<br />
                        ' . lang("item", "stamina") . ':<br />
                        ' . lang("item", "intellect") . ':<br />
                        ' . lang("item", "spirit") . ':<br />
                        ' . lang("item", "armor") . ':
                      </div>
                      <div class="gradient_pp">
                        ' . $char_data[UNIT_FIELD_STAT0] . '<br />
                        ' . $char_data[UNIT_FIELD_STAT1] . '<br />
                        ' . $char_data[UNIT_FIELD_STAT2] . '<br />
                        ' . $char_data[UNIT_FIELD_STAT3] . '<br />
                        ' . $char_data[UNIT_FIELD_STAT4] . '<br />
                        ' . $char_data[UNIT_FIELD_RESISTANCES] . '
                      </div>
                    </td>
                    <td class="half_line" colspan="2" rowspan="3" align="center" style="width: 50%;">
                      <div class="gradient_p">
                        ' . lang("item", "res_holy") . ':<br />
                        ' . lang("item", "res_arcane") . ':<br />
                        ' . lang("item", "res_fire") . ':<br />
                        ' . lang("item", "res_nature") . ':<br />
                        ' . lang("item", "res_frost") . ':<br />
                        ' . lang("item", "res_shadow") . ':
                      </div>
                      <div class="gradient_pp">
                        ' . $char_data[UNIT_FIELD_RESISTANCES + 1] . '<br />
                        ' . $char_data[UNIT_FIELD_RESISTANCES + 2] . '<br />
                        ' . $char_data[UNIT_FIELD_RESISTANCES + 3] . '<br />
                        ' . $char_data[UNIT_FIELD_RESISTANCES + 4] . '<br />
                        ' . $char_data[UNIT_FIELD_RESISTANCES + 5] . '<br />
                        ' . $char_data[UNIT_FIELD_RESISTANCES + 6] . '
                      </div>
                    </td>
                    <td style="width: 1%;">';
            if ($equiped_items[6][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_BELT . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'BELT' . '\');" onmouseout="HideTooltip(\'_b' . 'BELT' . '\');">
                        <img src="' . $equiped_items[6][1] . '" class="' . $equiped_items[6][2] . '" alt="Belt" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[6][3]["bag"] . '&slot=' . $equiped_items[6][3]["slot"] . '&item=' . $equiped_items[6][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[6][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'BELT' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[6][3]['enchantment'], $equiped_items[6][3]['property'], $equiped_items[6][3]['creator'], $equiped_items[6][3]['durability'], $equiped_items[6][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_waist.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                  </tr>
                  <tr>
                    <td style="width: 1%;">';
            if ($equiped_items[3][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_SHOULDER . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'SHOULDER' . '\');" onmouseout="HideTooltip(\'_b' . 'SHOULDER' . '\');">
                        <img src="' . $equiped_items[3][1] . '" class="' . $equiped_items[3][2] . '" alt="Shoulder" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[3][3]["bag"] . '&slot=' . $equiped_items[3][3]["slot"] . '&item=' . $equiped_items[3][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[3][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'SHOULDER' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[3][3]['enchantment'], $equiped_items[3][3]['property'], $equiped_items[3][3]['creator'], $equiped_items[3][3]['durability'], $equiped_items[3][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_shoulder.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                    <td style="width: 1%;">';
            if ($equiped_items[7][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_LEGS . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'LEGS' . '\');" onmouseout="HideTooltip(\'_b' . 'LEGS' . '\');">
                        <img src="' . $equiped_items[7][1] . '" class="' . $equiped_items[7][2] . '" alt="Legs" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[7][3]["bag"] . '&slot=' . $equiped_items[7][3]["slot"] . '&item=' . $equiped_items[7][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[7][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'LEGS' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[7][3]['enchantment'], $equiped_items[7][3]['property'], $equiped_items[7][3]['creator'], $equiped_items[7][3]['durability'], $equiped_items[7][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_legs.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                  </tr>
                  <tr>
                    <td style="width: 1%;">';
            if ($equiped_items[15][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_BACK . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'BACK' . '\');" onmouseout="HideTooltip(\'_b' . 'BACK' . '\');">
                        <img src="' . $equiped_items[15][1] . '" class="' . $equiped_items[15][2] . '" alt="Back" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[15][3]["bag"] . '&slot=' . $equiped_items[15][3]["slot"] . '&item=' . $equiped_items[15][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[15][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'BACK' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[15][3]['enchantment'], $equiped_items[15][3]['property'], $equiped_items[15][3]['creator'], $equiped_items[15][3]['durability'], $equiped_items[15][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_chest_back.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                    <td style="width: 1%;">';
            if ($equiped_items[8][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_FEET . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'FEET' . '\');" onmouseout="HideTooltip(\'_b' . 'FEET' . '\');">
                        <img src="' . $equiped_items[8][1] . '" class="' . $equiped_items[8][2] . '" alt="Feet" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[8][3]["bag"] . '&slot=' . $equiped_items[8][3]["slot"] . '&item=' . $equiped_items[8][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[8][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'FEET' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[8][3]['enchantment'], $equiped_items[8][3]['property'], $equiped_items[8][3]['creator'], $equiped_items[8][3]['durability'], $equiped_items[8][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_feet.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                  </tr>
                  <tr>
                    <td style="width: 1%;">';
            if ($equiped_items[5][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_CHEST . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'CHEST' . '\');" onmouseout="HideTooltip(\'_b' . 'CHEST' . '\');">
                        <img src="' . $equiped_items[5][1] . '" class="' . $equiped_items[5][2] . '" alt="Chest" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[5][3]["bag"] . '&slot=' . $equiped_items[5][3]["slot"] . '&item=' . $equiped_items[5][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[5][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'CHEST' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[5][3]['enchantment'], $equiped_items[5][3]['property'], $equiped_items[5][3]['creator'], $equiped_items[5][3]['durability'], $equiped_items[5][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_chest_back.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                    <td class="half_line" colspan="2" rowspan="2" align="center" style="width: 50%;">
                      <div class="gradient_p" id="char_melee_name">
                        ' . lang("char", "melee_d") . ':<br />
                        ' . lang("char", "melee_ap") . ':<br />
                        ' . lang("char", "melee_hit") . ':<br />
                        ' . lang("char", "melee_crit") . ':<br />
                        ' . lang("char", "expertise") . ':<br />
                      </div>
                      <div class="gradient_pp" id="char_melee_value">
                        ' . $mindamage . '-' . $maxdamage . '<br />
                        ' . ($char_data[UNIT_FIELD_ATTACK_POWER] + $char_data[UNIT_FIELD_ATTACK_POWER_MODS]) . '<br />
                        ' . $melee_hit . '<br />
                        ' . $crit . '%<br />
                        ' . $expertise . '<br />
                      </div>
                    </td>
                    <td class="half_line" colspan="2" rowspan="2" align="center" style="width: 50%;">
                      <div class="gradient_p">
                        ' . lang("char", "spell_d") . ':<br />
                        ' . lang("char", "spell_heal") . ':<br />
                        ' . lang("char", "spell_hit") . ':<br />
                        ' . lang("char", "spell_crit") . ':<br />
                        ' . lang("char", "spell_haste") . '
                      </div>
                      <div class="gradient_pp">
                        ' . $spell_damage . '<br />
                        ' . $spell_heal . '<br />
                        ' . $spell_hit . '<br />
                        ' . $spell_crit . '%<br />
                        ' . $spell_haste . '
                      </div>
                    </td>
                    <td style="width: 1%;">';
            if ($equiped_items[11][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_FINGER1 . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'FINGER1' . '\');" onmouseout="HideTooltip(\'_b' . 'FINGER1' . '\');">
                        <img src="' . $equiped_items[11][1] . '" class="' . $equiped_items[11][2] . '" alt="Finger1" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[11][3]["bag"] . '&slot=' . $equiped_items[11][3]["slot"] . '&item=' . $equiped_items[11][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[11][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'FINGER1' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[11][3]['enchantment'], $equiped_items[11][3]['property'], $equiped_items[11][3]['creator'], $equiped_items[11][3]['durability'], $equiped_items[11][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_finger.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                  </tr>
                  <tr>
                    <td style="width: 1%;">';
            if ($equiped_items[4][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_SHIRT . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'SHIRT' . '\');" onmouseout="HideTooltip(\'_b' . 'SHIRT' . '\');">
                        <img src="' . $equiped_items[4][1] . '" class="' . $equiped_items[4][2] . '" alt="Shirt" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[4][3]["bag"] . '&slot=' . $equiped_items[4][3]["slot"] . '&item=' . $equiped_items[4][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[4][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'SHIRT' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[4][3]['enchantment'], $equiped_items[4][3]['property'], $equiped_items[4][3]['creator'], $equiped_items[4][3]['durability'], $equiped_items[4][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_shirt.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                    <td style="width: 1%;">';
            if ($equiped_items[12][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_FINGER2 . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'FINGER2' . '\');" onmouseout="HideTooltip(\'_b' . 'FINGER2' . '\');">
                        <img src="' . $equiped_items[12][1] . '" class="' . $equiped_items[12][2] . '" alt="Finger2" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[12][3]["bag"] . '&slot=' . $equiped_items[12][3]["slot"] . '&item=' . $equiped_items[12][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[12][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'FINGER2' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[12][3]['enchantment'], $equiped_items[12][3]['property'], $equiped_items[12][3]['creator'], $equiped_items[12][3]['durability'], $equiped_items[12][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_finger.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                  </tr>
                  <tr>
                    <td style="width: 1%;">';
            if ($equiped_items[19][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_TABARD . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'TABARD' . '\');" onmouseout="HideTooltip(\'_b' . 'TABARD' . '\');">
                        <img src="' . $equiped_items[19][1] . '" class="' . $equiped_items[19][2] . '" alt="Tabard" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[19][3]["bag"] . '&slot=' . $equiped_items[19][3]["slot"] . '&item=' . $equiped_items[19][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[19][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'TABARD' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[19][3]['enchantment'], $equiped_items[19][3]['property'], $equiped_items[19][3]['creator'], $equiped_items[19][3]['durability'], $equiped_items[19][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_tabard.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                    <td class="half_line" colspan="2" rowspan="2" align="center" style="width: 50%;">
                      <div class="gradient_p">
                        ' . lang("char", "dodge") . ':<br />
                        ' . lang("char", "parry") . ':<br />
                        ' . lang("char", "block") . ':
                      </div>
                      <div class="gradient_pp">
                        ' . $dodge . '%<br />
                        ' . $parry . '%<br />
                        ' . $block . '%
                      </div>
                    </td>
                    <td class="half_line" colspan="2" rowspan="2" align="center" style="width: 50%;">
                      <div class="gradient_p" id="char_ranged_name">
                        ' . lang("char", "ranged_d") . ':<br />
                        ' . lang("char", "ranged_ap") . ':<br />
                        ' . lang("char", "ranged_hit") . ':<br />
                        ' . lang("char", "ranged_crit") . ':<br />
                      </div>
                      <div class="gradient_pp" id="char_ranged_value">
                        ' . $minrangeddamage . '-' . $maxrangeddamage . '<br />
                        ' . ($char_data[UNIT_FIELD_RANGED_ATTACK_POWER] + $char_data[UNIT_FIELD_RANGED_ATTACK_POWER_MODS]) . '<br />
                        ' . $ranged_hit . '<br />
                        ' . $ranged_crit . '%<br />
                      </div>
                    </td>
                    <td style="width: 1%;">';
            if ($equiped_items[13][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_TRINKET1 . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'TRINKET1' . '\');" onmouseout="HideTooltip(\'_b' . 'TRINKET1' . '\');">
                        <img src="' . $equiped_items[13][1] . '" class="' . $equiped_items[13][2] . '" alt="Trinket1" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[13][3]["bag"] . '&slot=' . $equiped_items[13][3]["slot"] . '&item=' . $equiped_items[13][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[13][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'TRINKET1' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[13][3]['enchantment'], $equiped_items[13][3]['property'], $equiped_items[13][3]['creator'], $equiped_items[13][3]['durability'], $equiped_items[13][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_trinket.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                  </tr>
                  <tr>
                    <td style="width: 1%;">';
            if ($equiped_items[9][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_WRIST . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'WRIST' . '\');" onmouseout="HideTooltip(\'_b' . 'WRIST' . '\');">
                        <img src="' . $equiped_items[9][1] . '" class="' . $equiped_items[9][2] . '" alt="Wrist" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[9][3]["bag"] . '&slot=' . $equiped_items[9][3]["slot"] . '&item=' . $equiped_items[9][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[9][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'WRIST' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[9][3]['enchantment'], $equiped_items[9][3]['property'], $equiped_items[9][3]['creator'], $equiped_items[9][3]['durability'], $equiped_items[9][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_wrist.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                    <td style="width: 1%;">';
            if ($equiped_items[14][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_TRINKET2 . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'TRINKET2' . '\');" onmouseout="HideTooltip(\'_b' . 'TRINKET2' . '\');">
                        <img src="' . $equiped_items[14][1] . '" class="' . $equiped_items[14][2] . '" alt="Trinket2" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[14][3]["bag"] . '&slot=' . $equiped_items[14][3]["slot"] . '&item=' . $equiped_items[14][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[14][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'TRINKET2' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[14][3]['enchantment'], $equiped_items[14][3]['property'], $equiped_items[14][3]['creator'], $equiped_items[14][3]['durability'], $equiped_items[14][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_trinket.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                  </tr>
                  <tr>
                    <td></td>
                    <td style="width: 15%;">';
            if ($equiped_items[16][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_MAIN_HAND . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'MAIN_HAND' . '\');" onmouseout="HideTooltip(\'_b' . 'MAIN_HAND' . '\');">
                        <img src="' . $equiped_items[16][1] . '" class="' . $equiped_items[16][2] . '" alt="MainHand" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[16][3]["bag"] . '&slot=' . $equiped_items[16][3]["slot"] . '&item=' . $equiped_items[16][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[16][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'MAIN_HAND' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[16][3]['enchantment'], $equiped_items[16][3]['property'], $equiped_items[16][3]['creator'], $equiped_items[16][3]['durability'], $equiped_items[16][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_main_hand.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                    <td style="width: 15%;">';
            if ($equiped_items[17][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_OFF_HAND . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'OFF_HAND' . '\');" onmouseout="HideTooltip(\'_b' . 'OFF_HAND' . '\');">
                        <img src="' . $equiped_items[17][1] . '" class="' . $equiped_items[17][2] . '" alt="OffHand" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[17][3]["bag"] . '&slot=' . $equiped_items[17][3]["slot"] . '&item=' . $equiped_items[17][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[17][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'OFF_HAND' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[17][3]['enchantment'], $equiped_items[17][3]['property'], $equiped_items[17][3]['creator'], $equiped_items[17][3]['durability'], $equiped_items[17][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_off_hand.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                    <td style="width: 15%;">';
            if ($equiped_items[18][1]) {
                $output .= '
                      <a class="char_icon_padding" href="' . $base_datasite . $item_datasite . $EQU_RANGED . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . 'RANGED' . '\');" onmouseout="HideTooltip(\'_b' . 'RANGED' . '\');">
                        <img src="' . $equiped_items[18][1] . '" class="' . $equiped_items[18][2] . '" alt="Ranged" />
                      </a>';
                if ($mode) {
                    $output .= '
                      <div style="position: relative;">
                        <a href="char.php?action=delete_item&id=' . $id . '&bag=' . $equiped_items[18][3]["bag"] . '&slot=' . $equiped_items[18][3]["slot"] . '&item=' . $equiped_items[18][3]["item_template"] . '&mode=' . $mode . '" id="ch_item_delete">
                          <img src="img/aff_cross.png" />
                        </a>
                      </div>';
                }
                // build a tooltip object for this item
                $i_fields = get_item_info($equiped_items[18][3]['item_template']);
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . 'RANGED' . '">
                        <table>
                          <tr>
                            <td>
                              ' . get_item_tooltip($i_fields, $equiped_items[18][3]['enchantment'], $equiped_items[18][3]['property'], $equiped_items[18][3]['creator'], $equiped_items[18][3]['durability'], $equiped_items[18][3]['flags']) . '
                            </td>
                          </tr>
                        </table>
                      </div>';
            } else {
                $output .= '
                      <img src="img/INV/INV_empty_ranged.png" class="icon_border_0" alt="empty" />';
            }
            $output .= '
                    </td>
                    <td style="width: 15%;"></td>
                    <td></td>
                  </tr>';
            if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                // if the character is still leveling, show an experience bar
                if ($char["level"] < 80) {
                    $xp_query = "SELECT * FROM xp_to_level WHERE level='" . $char["level"] . "'";
                    $xp_result = $sql["mgr"]->query($xp_query);
                    $xp_fields = $sql["mgr"]->fetch_assoc($xp_result);
                    $xp_to_level = $xp_fields["xp_for_next_level"];
                    $output .= '
                    <tr>
                      <td colspan="6" class="bar xp_bar" style="background-position: ' . (round(580 * $char["xp"] / $xp_to_level) - 580) . 'px;">
                        ' . lang("char", "exp") . ": " . $char["xp"] . " / " . $xp_to_level . '
                      </td>
                    </tr>';
                }
                //total time played
                $tot_time = $char["totaltime"];
                $tot_days = (int) ($tot_time / 86400);
                $tot_time = $tot_time - $tot_days * 86400;
                $total_hours = (int) ($tot_time / 3600);
                $tot_time = $tot_time - $total_hours * 3600;
                $total_min = (int) ($tot_time / 60);
                $time_offset = $timezone_offset * 3600;
                if ($char["timestamp"] != 0) {
                    $lastseen = date("F j, Y @ Hi", $char["timestamp"] + $time_offset);
                } else {
                    $lastseen = '-';
                }
                $output .= '
                  <tr>
                    <td colspan="6">
                      ' . lang("char", "tot_play_time") . ': ' . $tot_days . ' ' . lang("char", "days") . ' ' . $total_hours . ' ' . lang("char", "hours") . ' ' . $total_min . ' ' . lang("char", "min") . '
                    </td>
                  </tr>';
                $output .= '
                  <tr>
                    <td colspan="6">
                      ' . lang("char", "lastseen") . ': ' . $lastseen . '
                    </td>
                  </tr>';
            }
            $output .= '
                </table>
              </div>
              <br />
            </div>
            <br />
            <table class="hidden center">
              <tr>
                <td>';
            // button to user account page, user account page has own security
            makebutton(lang("char", "chars_acc"), 'user.php?action=edit_user&amp;acct=' . $owner_acc_id . '', 130);
            $output .= '
                </td>
                <td>';
            // only higher level GM with delete access can edit character
            //  character edit allows removal of character items, so delete permission is needed
            if ($user_lvl >= $owner_gmlvl && $user_lvl >= $action_permission["delete"]) {
                makebutton(lang("char", "edit_button"), 'char_edit.php?id=' . $id . '&amp;realm=' . $realmid, 130);
                $output .= '
                </td>
                <td>';
            }
            // only higher level GM with delete access, or character owner can delete character
            if ($user_lvl > $owner_gmlvl && $user_lvl >= $action_permission["delete"] || $owner_name === $user_name) {
                makebutton(lang("char", "del_char"), 'char_list.php?action=del_char_form&amp;check%5B%5D=' . $id . '" type="wrn', 130);
                $output .= '
                </td>
                <td>';
            }
            // show Delete Mode / View Mode button depending on current mode
            if ($mode) {
                makebutton(lang("char", "viewmode"), 'char.php?id=' . $id . '&amp;realm=' . $realmid . '&amp;mode=0" type="def', 130);
            } else {
                makebutton(lang("char", "deletemode"), 'char.php?id=' . $id . '&amp;realm=' . $realmid . '&amp;mode=1" type="def', 130);
            }
            $output .= '
                </td>
                <td>';
            // only GM with update permission can send mail, mail can send items, so update permission is needed
            if ($user_lvl >= $action_permission["update"]) {
                makebutton(lang("char", "send_mail"), 'mail.php?type=ingame_mail&amp;to=' . $char["name"], 130);
                $output .= '
                </td>';
            } else {
                $output .= '
                </td>';
            }
            $output .= '
              </tr>
              <tr>
                <td>';
            makebutton(lang("global", "back"), 'javascript:window.history.back()" type="def', 130);
            $output .= '
                </td>
              </tr>
            </table>
            <br />
          <!-- end of char.php -->';
        } else {
        }
        //error($lang_char["no_permission"]);
    } else {
        error(lang("char", "no_char_found"));
    }
}
Esempio n. 4
0
function char_inv()
{
    global $output, $realm_id, $characters_db, $world_db, $corem_db, $site_encoding, $action_permission, $user_lvl, $user_name, $locales_search_option, $base_datasite, $item_datasite, $sql, $core;
    // this page uses wowhead tooltops
    //wowhead_tt();
    $cid = $_GET["id"];
    // we need at least an id or we would have nothing to show
    // also, make sure id is numeric to prevent SQL injection
    if (empty($_GET["id"]) || !is_numeric($cid)) {
        error(lang("global", "empty_fields"));
    }
    // this is multi realm support, as of writing still under development
    //  this page is already implementing it
    if (empty($_GET["realm"])) {
        $realmid = $realm_id;
    } else {
        $realmid = $sql["logon"]->quote_smart($_GET["realm"]);
        if (is_numeric($realmid)) {
            $sql["char"]->connect($characters_db[$realmid]["addr"], $characters_db[$realmid]["user"], $characters_db[$realmid]["pass"], $characters_db[$realmid]["name"], $characters_db[$realmid]["encoding"]);
        } else {
            $realmid = $realm_id;
        }
    }
    //-------------------SQL Injection Prevention--------------------------------
    // no point going further if we don have a valid ID
    // this_is_junk: char.php doesn't post account.   Why is this even here?
    //$acct = $sql["char"]->quote_smart($_GET["acct"]);
    //if (is_numeric($acct));
    //else error($lang_global["empty_fields"]);
    // getting character data from database
    if ($core == 1) {
        $result = $sql["char"]->query("SELECT acct, name, race, class, level, gender, gold, online\r\n      FROM characters WHERE guid='" . $cid . "' LIMIT 1");
    } else {
        $result = $sql["char"]->query("SELECT account AS acct, name, race, class, level, gender, money AS gold, online\r\n      FROM characters WHERE guid='" . $cid . "' LIMIT 1");
    }
    // no point going further if character does not exist
    if ($sql["char"]->num_rows($result)) {
        $char = $sql["char"]->fetch_assoc($result);
        // we get user permissions first
        $owner_acc_id = $sql["char"]->result($result, 0, "acct");
        if ($core == 1) {
            $query = $sql["logon"]->query("SELECT login FROM accounts WHERE acct='" . $owner_acc_id . "'");
        } else {
            $query = $sql["logon"]->query("SELECT username as login FROM account WHERE id='" . $owner_acc_id . "'");
        }
        $owner_name = $sql["logon"]->result($query, 0, "login");
        $s_query = "SELECT *, SecurityLevel AS gm FROM config_accounts WHERE Login='******'";
        $s_result = $sql["mgr"]->query($s_query);
        $s_fields = $sql["mgr"]->fetch_assoc($s_result);
        $owner_gmlvl = $s_fields["gm"];
        $view_mod = $s_fields["View_Mod_Inv"];
        if ($owner_gmlvl >= 1073741824) {
            $owner_gmlvl -= 1073741824;
        }
        // owner configured overrides
        $view_override = false;
        if ($view_mod > 0) {
            if ($view_mod == 1) {
            } elseif ($view_mod == 2) {
                // only registered users may view this page
                if ($user_lvl > -1) {
                    $view_override = true;
                }
            }
        }
        // visibility overrides for specific tabs
        $view_talent_override = false;
        if ($s_fields["View_Mod_Talent"] > 0) {
            if ($s_fields["View_Mod_Talent"] == 1) {
            } elseif ($s_fields["View_Mod_Talent"] == 2) {
                // only registered users may view this tab
                if ($user_lvl > -1) {
                    $view_talent_override = true;
                }
            }
        } else {
            if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                $view_talent_override = true;
            }
        }
        $view_achieve_override = false;
        if ($s_fields["View_Mod_Achieve"] > 0) {
            if ($s_fields["View_Mod_Achieve"] == 1) {
            } elseif ($s_fields["View_Mod_Achieve"] == 2) {
                // only registered users may view this tab
                if ($user_lvl > -1) {
                    $view_achieve_override = true;
                }
            }
        } else {
            if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                $view_achieve_override = true;
            }
        }
        $view_quest_override = false;
        if ($s_fields["View_Mod_Quest"] > 0) {
            if ($s_fields["View_Mod_Quest"] == 1) {
            } elseif ($s_fields["View_Mod_Quest"] == 2) {
                // only registered users may view this tab
                if ($user_lvl > -1) {
                    $view_quest_override = true;
                }
            }
        } else {
            if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                $view_quest_override = true;
            }
        }
        $view_friends_override = false;
        if ($s_fields["View_Mod_Friends"] > 0) {
            if ($s_fields["View_Mod_Friends"] == 1) {
            } elseif ($s_fields["View_Mod_Friends"] == 2) {
                // only registered users may view this tab
                if ($user_lvl > -1) {
                    $view_friends_override = true;
                }
            }
        } else {
            if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                $view_friends_override = true;
            }
        }
        $view_view_override = false;
        if ($s_fields["View_Mod_View"] > 0) {
            if ($s_fields["View_Mod_View"] == 1) {
            } elseif ($s_fields["View_Mod_View"] == 2) {
                // only registered users may view this tab
                if ($user_lvl > -1) {
                    $view_view_override = true;
                }
            }
        } else {
            if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
                $view_view_override = true;
            }
        }
        // find out what mode we're in View or Delete (0 = View, 1 = Delete)
        $mode = isset($_GET["mode"]) ? $_GET["mode"] : 0;
        // only the character's owner or a GM with Delete privs can enter Delete Mode
        if ($owner_name != $user_name) {
            if ($user_lvl < $action_permission["delete"]) {
                $mode = 0;
            } else {
                $mode = $mode;
            }
        }
        // View Mode is only availble on characters that are offline
        if ($char["online"] != 0) {
            $mode = 0;
        }
        // check user permission
        if ($view_override || $user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
            // main data that we need for this page, character inventory
            if ($core == 1) {
                $result = $sql["char"]->query("SELECT \r\n          containerslot, slot, entry, enchantments AS enchantment, randomprop AS property, count, flags\r\n          FROM playeritems WHERE ownerguid='" . $cid . "' ORDER BY containerslot, slot");
            } elseif ($core == 2) {
                $result = $sql["char"]->query("SELECT \r\n          bag, slot, item_template AS entry, item, \r\n          SUBSTRING_INDEX(SUBSTRING_INDEX(item_instance.data, ' ', 11), ' ', -1) AS creator,\r\n          SUBSTRING_INDEX(SUBSTRING_INDEX(item_instance.data, ' ', 23), ' ', -1) AS enchantment, \r\n          SUBSTRING_INDEX(SUBSTRING_INDEX(item_instance.data, ' ', 60), ' ', -1) AS property, \r\n          SUBSTRING_INDEX(SUBSTRING_INDEX(item_instance.data, ' ', 15), ' ', -1) AS count,\r\n          SUBSTRING_INDEX(SUBSTRING_INDEX(item_instance.data, ' ', 62), ' ', -1) AS durability,\r\n          SUBSTRING_INDEX(SUBSTRING_INDEX(item_instance.data, ' ', 22), ' ', -1) AS flags\r\n          FROM character_inventory LEFT JOIN item_instance ON character_inventory.item=item_instance.guid\r\n          WHERE character_inventory.guid='" . $cid . "' ORDER BY bag, slot");
            } else {
                $result = $sql["char"]->query("SELECT \r\n          bag, slot, itemEntry AS entry, item, \r\n          creatorGuid AS creator,\r\n          enchantments AS enchantment, \r\n          randomPropertyId AS property, \r\n          count, durability, flags\r\n          FROM character_inventory \r\n            LEFT JOIN item_instance ON character_inventory.item=item_instance.guid\r\n          WHERE character_inventory.guid='" . $cid . "' ORDER BY bag, slot");
            }
            //---------------Page Specific Data Starts Here--------------------------
            // lets start processing first before we display anything
            //  we have lots to do for inventory
            // character bags, 1 main + 4 additional
            $bag = array(0 => array(), 1 => array(), 2 => array(), 3 => array(), 4 => array());
            // character bank, 1 main + 7 additional
            $bank = array(0 => array(), 1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array(), 6 => array(), 7 => array());
            // this is where we will put items that are in main bag
            $bag_id = array();
            // this is where we will put items that are in main bank
            $bank_bag_id = array();
            // this is where we will put items that are in character bags, 4 arrays, 1 for each
            $equiped_bag_id = array(0, 0, 0, 0, 0);
            // this is where we will put items that are in bank bangs, 7 arrays, 1 for each
            $equip_bnk_bag_id = array(0, 0, 0, 0, 0, 0, 0, 0);
            // we load the things in each bag slot
            while ($slot = $sql["char"]->fetch_assoc($result)) {
                if ($core == 1) {
                    if ($slot["containerslot"] == -1 && $slot["slot"] > 18) {
                        if ($slot["slot"] < 23) {
                            $bag_id[$slot["slot"]] = $slot["slot"] - 18;
                            $equiped_bag_id[$slot["slot"] - 18] = array($slot["entry"], $sql["world"]->result($sql["world"]->query("SELECT containerslots FROM items\r\n                  WHERE entry='" . $slot["entry"] . "'"), 0, "containerslots"), $slot["count"]);
                        } elseif ($slot["slot"] < 39) {
                            $i_query = "SELECT \r\n                *, description AS description1, name1 AS name, quality AS Quality, inventorytype AS InventoryType, \r\n                socket_color_1 AS socketColor_1, socket_color_2 AS socketColor_2, socket_color_3 AS socketColor_3,\r\n                requiredlevel AS RequiredLevel, allowableclass AS AllowableClass,\r\n                sellprice AS SellPrice, itemlevel AS ItemLevel\r\n                FROM items " . ($locales_search_option != 0 ? "LEFT JOIN items_localized ON (items_localized.entry=items.entry AND language_code='" . $locales_search_option . "') " : " ") . "WHERE items.entry='" . $slot["entry"] . "'";
                            $i_result = $sql["world"]->query($i_query);
                            $i = $sql["world"]->fetch_assoc($i_result);
                            if (isset($bag[0][$slot["slot"] - 23])) {
                                $bag[0][$slot["slot"] - 23][0]++;
                            } else {
                                $bag[0][$slot["slot"] - 23] = array($slot["entry"], 0, $slot["count"], $i, $slot["enchantment"], $slot["property"], $slot["creator"], $slot["durability"], $slot["flags"], $slot["bag"], $slot["slot"]);
                            }
                        } elseif ($slot["slot"] < 67) {
                            $i_query = "SELECT\r\n                *, description AS description1, name1 AS name, quality AS Quality, inventorytype AS InventoryType, \r\n                socket_color_1 AS socketColor_1, socket_color_2 AS socketColor_2, socket_color_3 AS socketColor_3,\r\n                requiredlevel AS RequiredLevel, allowableclass AS AllowableClass,\r\n                sellprice AS SellPrice, itemlevel AS ItemLevel\r\n                FROM items " . ($locales_search_option != 0 ? "LEFT JOIN items_localized ON (items_localized.entry=items.entry AND language_code='" . $locales_search_option . "') " : " ") . "WHERE items.entry='" . $slot["entry"] . "'";
                            $i_result = $sql["world"]->query($i_query);
                            $i = $sql["world"]->fetch_assoc($i_result);
                            $bank[0][$slot["slot"] - 39] = array($slot["entry"], 0, $slot["count"], $i, $slot["enchantment"], $slot["property"], $slot["creator"], $slot["durability"], $slot["flags"], $slot["bag"], $slot["slot"]);
                        } elseif ($slot["slot"] < 74) {
                            $bank_bag_id[$slot["slot"]] = $slot["slot"] - 66;
                            $equip_bnk_bag_id[$slot["slot"] - 66] = array($slot["entry"], $sql["world"]->result($sql["world"]->query("SELECT containerslots FROM items\r\n                  WHERE entry='" . $slot["entry"] . "'"), 0, "containerslots"), $slot["count"]);
                        }
                    } else {
                        // Bags
                        if (isset($bag_id[$slot["containerslot"]])) {
                            $i_query = "SELECT\r\n                *, description AS description1, name1 AS name, quality AS Quality, inventorytype AS InventoryType, \r\n                socket_color_1 AS socketColor_1, socket_color_2 AS socketColor_2, socket_color_3 AS socketColor_3,\r\n                requiredlevel AS RequiredLevel, allowableclass AS AllowableClass,\r\n                sellprice AS SellPrice, itemlevel AS ItemLevel\r\n                FROM items " . ($locales_search_option != 0 ? "LEFT JOIN items_localized ON (items_localized.entry=items.entry AND language_code='" . $locales_search_option . "') " : " ") . "WHERE items.entry='" . $slot["entry"] . "'";
                            $i_result = $sql["world"]->query($i_query);
                            $i = $sql["world"]->fetch_assoc($i_result);
                            if (isset($bag[$bag_id[$slot["containerslot"]]][$slot["slot"]])) {
                                $bag[$bag_id[$slot["containerslot"]]][$slot["slot"]][1]++;
                            } else {
                                $bag[$bag_id[$slot["containerslot"]]][$slot["slot"]] = array($slot["entry"], 0, $slot["count"], $i, $slot["enchantment"], $slot["property"], $slot["creator"], $slot["durability"], $slot["flags"], $slot["bag"], $slot["slot"]);
                            }
                        } elseif (isset($bank_bag_id[$slot["containerslot"]])) {
                            $i_query = "SELECT\r\n                *, description AS description1, name1 AS name, quality AS Quality, inventorytype AS InventoryType, \r\n                socket_color_1 AS socketColor_1, socket_color_2 AS socketColor_2, socket_color_3 AS socketColor_3,\r\n                requiredlevel AS RequiredLevel, allowableclass AS AllowableClass,\r\n                sellprice AS SellPrice, itemlevel AS ItemLevel\r\n                FROM items " . ($locales_search_option != 0 ? "LEFT JOIN items_localized ON (items_localized.entry=items.entry AND language_code='" . $locales_search_option . "') " : " ") . "WHERE items.entry='" . $slot["entry"] . "'";
                            $i_result = $sql["world"]->query($i_query);
                            $i = $sql["world"]->fetch_assoc($i_result);
                            $bank[$bank_bag_id[$slot["containerslot"]]][$slot["slot"]] = array($slot["entry"], 0, $slot["count"], $i, $slot["enchantment"], $slot["property"], $slot["creator"], $slot["durability"], $slot["flags"], $slot["bag"], $slot["slot"]);
                        }
                    }
                } else {
                    if ($slot["bag"] == 0 && $slot["slot"] > 18) {
                        if ($slot["slot"] < 23) {
                            $bag_id[$slot["item"]] = $slot["slot"] - 18;
                            $equiped_bag_id[$slot["slot"] - 18] = array($slot["entry"], $sql["world"]->result($sql["world"]->query("SELECT ContainerSlots FROM item_template\r\n                  WHERE entry='" . $slot["entry"] . "'"), 0, "containerslots"), $slot["count"]);
                        } elseif ($slot["slot"] < 39) {
                            $i_query = "SELECT *, description AS description1 FROM item_template " . ($locales_search_option != 0 ? "LEFT JOIN locales_item ON locales_item.entry=item_template.entry " : " ") . "WHERE item_template.entry='" . $slot["entry"] . "'";
                            $i_result = $sql["world"]->query($i_query);
                            $i = $sql["world"]->fetch_assoc($i_result);
                            if (isset($bag[0][$slot["slot"] - 23])) {
                                $bag[0][$slot["slot"] - 23][0]++;
                            } else {
                                $bag[0][$slot["slot"] - 23] = array($slot["entry"], 0, $slot["count"], $i, $slot["enchantment"], $slot["property"], $slot["creator"], $slot["durability"], $slot["flags"], $slot["bag"], $slot["slot"]);
                            }
                        } elseif ($slot["slot"] < 67) {
                            $i_query = "SELECT *, description AS description1 FROM item_template " . ($locales_search_option != 0 ? "LEFT JOIN locales_item ON locales_item.entry=item_template.entry " : " ") . "WHERE item_template.entry='" . $slot["entry"] . "'";
                            $i_result = $sql["world"]->query($i_query);
                            $i = $sql["world"]->fetch_assoc($i_result);
                            $bank[0][$slot["slot"] - 39] = array($slot["entry"], 0, $slot["count"], $i, $slot["enchantment"], $slot["property"], $slot["creator"], $slot["durability"], $slot["flags"], $slot["bag"], $slot["slot"]);
                        } elseif ($slot["slot"] < 74) {
                            $bank_bag_id[$slot["item"]] = $slot["slot"] - 66;
                            $equip_bnk_bag_id[$slot["slot"] - 66] = array($slot["entry"], $sql["world"]->result($sql["world"]->query('SELECT ContainerSlots FROM item_template
                  WHERE entry = ' . $slot["entry"] . ''), 0, "ContainerSlots"), $slot["count"]);
                        }
                    } else {
                        // Bags
                        if (isset($bag_id[$slot["bag"]])) {
                            $i_query = "SELECT *, description AS description1 FROM item_template " . ($locales_search_option != 0 ? "LEFT JOIN locales_item ON locales_item.entry=item_template.entry " : " ") . "WHERE item_template.entry='" . $slot["entry"] . "'";
                            $i_result = $sql["world"]->query($i_query);
                            $i = $sql["world"]->fetch_assoc($i_result);
                            if (isset($bag[$bag_id[$slot["bag"]]][$slot["slot"]])) {
                                $bag[$bag_id[$slot["bag"]]][$slot["slot"]][1]++;
                            } else {
                                $bag[$bag_id[$slot["bag"]]][$slot["slot"]] = array($slot["entry"], 0, $slot["count"], $i, $slot["enchantment"], $slot["property"], $slot["creator"], $slot["durability"], $slot["flags"], $slot["bag"], $slot["slot"]);
                            }
                        } elseif (isset($bank_bag_id[$slot["bag"]])) {
                            $i_query = "SELECT *, description AS description1 FROM item_template " . ($locales_search_option != 0 ? "LEFT JOIN locales_item ON locales_item.entry=item_template.entry " : " ") . "WHERE item_template.entry='" . $slot["entry"] . "'";
                            $i_result = $sql["world"]->query($i_query);
                            $i = $sql["world"]->fetch_assoc($i_result);
                            $bank[$bank_bag_id[$slot["bag"]]][$slot["slot"]] = array($slot["entry"], 0, $slot["count"], $i, $slot["enchantment"], $slot["property"], $slot["creator"], $slot["durability"], $slot["flags"], $slot["bag"], $slot["slot"]);
                        }
                    }
                }
            }
            unset($slot);
            unset($bag_id);
            unset($bank_bag_id);
            unset($result);
            //------------------------Character Tabs---------------------------------
            // we start with a lead of 10 spaces,
            //  because last line of header is an opening tag with 8 spaces
            //  keep html indent in sync, so debuging from browser source would be easy to read
            $output .= '
          <!-- start of char_inv.php -->
            <div class="tab">
              <ul>
                <li><a href="char.php?id=' . $cid . '&amp;realm=' . $realmid . '">' . lang("char", "char_sheet") . '</a></li>';
            $output .= '
                <li class="selected"><a href="char_inv.php?id=' . $cid . '&amp;realm=' . $realmid . '">' . lang("char", "inventory") . '</a></li>';
            if ($view_talent_override) {
                $output .= '
                ' . ($char["level"] < 10 ? '' : '<li><a href="char_talent.php?id=' . $cid . '&amp;realm=' . $realmid . '">' . lang("char", "talents") . '</a></li>') . '';
            }
            if ($view_achieve_override) {
                $output .= '
                <li><a href="char_achieve.php?id=' . $cid . '&amp;realm=' . $realmid . '">' . lang("char", "achievements") . '</a></li>';
            }
            if ($view_quest_override) {
                $output .= '
                <li><a href="char_quest.php?id=' . $cid . '&amp;realm=' . $realmid . '">' . lang("char", "quests") . '</a></li>';
            }
            if ($view_friends_override) {
                $output .= '
                <li><a href="char_friends.php?id=' . $cid . '&amp;realm=' . $realmid . '">' . lang("char", "friends") . '</a></li>';
            }
            if ($view_view_override) {
                $output .= '
                <li><a href="char_view.php?id=' . $cid . '&amp;realm=' . $realmid . '">' . lang("char", "view") . '</a></li>';
            }
            $output .= '
              </ul>
            </div>
            <div class="tab_content center" id="ch_inv_bags_wrap">
              <span class="bold">
                ' . htmlentities($char["name"], ENT_COMPAT, $site_encoding) . ' -
                <img src="img/c_icons/' . $char["race"] . '-' . $char["gender"] . '.gif"
                  onmousemove="oldtoolTip(\'' . char_get_race_name($char["race"]) . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />
                <img src="img/c_icons/' . $char["class"] . '.gif"
                  onmousemove="oldtoolTip(\'' . char_get_class_name($char["class"]) . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" /> - ' . lang("char", "level_short") . char_get_level_color($char["level"]) . '
              </span>
              <br />
              <br />
              <table class="lined" id="ch_inv_bags">
                <tr>';
            //---------------Page Specific Data Starts Here--------------------------
            // equipped bags
            for ($i = 4; $i > 0; --$i) {
                $output .= '
                  <th>';
                if ($equiped_bag_id[$i]) {
                    $output .= '
                    <a href="' . $base_datasite . $item_datasite . $equiped_bag_id[$i][0] . '" rel="external">
                      <img class="bag_icon" src="' . get_item_icon($equiped_bag_id[$i][0]) . '" alt="" />
                    </a>
                    ' . lang("item", "bag") . ' ' . $i . '<br />
                    <span class="small">' . $equiped_bag_id[$i][1] . ' ' . lang("item", "slots") . '</span>';
                }
                $output .= '
                  </th>';
            }
            $output .= '
                </tr>
                <tr>';
            // equipped bag slots
            for ($t = 4; $t > 0; --$t) {
                // this_is_junk: style left hardcoded because it's calculated.
                $output .= '
                  <td align="center">
                    <div class="bag" style="width: ' . 4 * 43 . 'px; height: ' . ceil($equiped_bag_id[$t][1] / 4) * 41 . 'px;">';
                $dsp = $equiped_bag_id[$t][1] % 4;
                if ($dsp) {
                    $output .= '
                      <div class="no_slot"></div>';
                }
                foreach ($bag[$t] as $pos => $item) {
                    // this_is_junk: style left hardcoded because it's calculated.
                    $item[2] = $item[2] == 1 ? '' : $item[2];
                    $output .= '
                      <div class="bag_slot" style="left: ' . (($pos + $dsp) % 4 * 43 + 4) . 'px; top: ' . (floor(($pos + $dsp) / 4) * 41 + 4) . 'px;">
                        <a href="' . $base_datasite . $item_datasite . $item[0] . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . $t . 'p' . $pos . ($pos + $dsp) % 4 * 42 . 'x' . floor(($pos + $dsp) / 4) * 41 . '\');" onmouseout="HideTooltip(\'_b' . $t . 'p' . $pos . ($pos + $dsp) % 4 * 42 . 'x' . floor(($pos + $dsp) / 4) * 41 . '\');">
                          <img src="' . get_item_icon($item[0]) . '" alt="" class="inv_icon" />
                        </a>';
                    if ($mode) {
                        $output .= '
                        <div>
                          <a href="char_inv.php?action=delete_item&amp;id=' . $cid . '&amp;bag=' . $item[9] . '&amp;slot=' . $item[10] . '&amp;item=' . $item[0] . '&amp;mode=' . $mode . '">
                            <img src="img/aff_cross.png" class="ch_inv_delete" alt="" />
                          </a>
                        </div>';
                    } else {
                        $output .= '
                        <div class="ch_inv_quantity_shadow">' . $item[2] . '</div>
                        <div class="ch_inv_quantity">' . $item[2] . '</div>';
                    }
                    $output .= '
                      </div>';
                    // build a tooltip object for this item
                    $output .= '
                      <div class="item_tooltip" id="tooltip_b' . $t . 'p' . $pos . ($pos + $dsp) % 4 * 42 . 'x' . floor(($pos + $dsp) / 4) * 41 . '" style="left: ' . (($pos + $dsp) % 4 * 42 - 129) . 'px; top: ' . (floor(($pos + $dsp) / 4) * 41 + 42) . 'px;">
                        <table>
                          <tr>
                            <td>' . get_item_tooltip($item[3], $item[4], $item[5], $item[6], $item[7], $item[8]) . '</td>
                          </tr>
                        </table>
                      </div>';
                }
                $output .= '
                    </div>
                  </td>';
            }
            unset($equiped_bag_id);
            // this_is_junk: style left hardcoded because it's calculated.
            $output .= '
                </tr>
                <tr>
                  <th colspan="2" align="left">
                    <img class="bag_icon" src="' . get_item_icon(3960) . '" alt="" id="ch_backpack_icon_margin" />
                    <span id="ch_backpack_name_margin">' . lang("char", "backpack") . '</span>
                  </th>
                  <th colspan="2">
                    ' . lang("char", "bank_items") . '
                  </th>
                </tr>
                <tr>
                  <td colspan="2" style="height: 220px; text-align: center;">
                    <div class="bag" id="ch_backpack" style="width: ' . 4 * 43 . 'px; height: ' . ceil(16 / 4) * 41 . 'px;">';
            // inventory items
            foreach ($bag[0] as $pos => $item) {
                // this_is_junk: style left hardcoded because it's calculated.
                $item[2] = $item[2] == 1 ? '' : $item[2];
                $output .= '
                      <div class="bag_slot" style="left: ' . ($pos % 4 * 43 + 4) . 'px; top: ' . (floor($pos / 4) * 41 + 4) . 'px;">
                        <a href="' . $base_datasite . $item_datasite . $item[0] . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . $t . 'p' . $pos . $pos % 4 * 42 . 'x' . floor($pos / 4) * 41 . '\');" onmouseout="HideTooltip(\'_b' . $t . 'p' . $pos . $pos % 4 * 42 . 'x' . floor($pos / 4) * 41 . '\');">
                          <img src="' . get_item_icon($item[0]) . '" class="inv_icon" alt="" />
                        </a>';
                if ($mode) {
                    $output .= '
                        <div>
                          <a href="char_inv.php?action=delete_item&amp;id=' . $cid . '&amp;bag=' . $item[9] . '&amp;slot=' . $item[10] . '&amp;item=' . $item[0] . '&amp;mode=' . $mode . '">
                            <img src="img/aff_cross.png" class="ch_inv_delete" alt="" />
                          </a>
                        </div>';
                } else {
                    $output .= '
                        <div class="ch_inv_quantity_shadow">' . $item[2] . '</div>
                        <div class="ch_inv_quantity">' . $item[2] . '</div>';
                }
                $output .= '
                      </div>';
                // build a tooltip object for this item
                $output .= '
                      <div class="item_tooltip" id="tooltip_b' . $t . 'p' . $pos . $pos % 4 * 42 . 'x' . floor($pos / 4) * 41 . '" style="left: ' . ($pos % 4 * 42 - 129) . 'px; top: ' . (floor($pos / 4) * 41 + 42) . 'px;">
                        <table>
                          <tr>
                            <td>' . get_item_tooltip($item[3], $item[4], $item[5], $item[6], $item[7], $item[8]) . '</td>
                          </tr>
                        </table>
                      </div>';
            }
            unset($bag);
            $output .= '
                    </div>
                    <div id="ch_money">
                      <b>
                        ' . substr($char["gold"], 0, -4) . '<img src="img/gold.gif" alt="gold" style="position: relative; bottom: -6px;" />
                        ' . substr($char["gold"], -4, 2) . '<img src="img/silver.gif" alt="silver" style="position: relative; bottom: -6px;" />
                        ' . substr($char["gold"], -2) . '<img src="img/copper.gif" alt="copper" style="position: relative; bottom: -6px;" />
                      </b>
                    </div>
                  </td>
                  <td colspan="2" align="center">
                    <div class="bag bank" style="width: ' . (7 * 43 + 2) . 'px; height: ' . ceil(24 / 7) * 41 . 'px;">';
            // bank items
            foreach ($bank[0] as $pos => $item) {
                // this_is_junk: style left hardcoded because it's calculated.
                $item[2] = $item[2] == 1 ? '' : $item[2];
                $output .= '
                      <div class="bag_slot" style="left: ' . ($pos % 7 * 43 + 4) . 'px; top: ' . (floor($pos / 7) * 41 + 4) . 'px;">
                        <a href="' . $base_datasite . $item_datasite . $item[0] . '" rel="external" onmouseover="ShowTooltip(this,\'_bbp' . $pos . $pos % 7 * 43 . 'x' . floor($pos / 7) * 41 . '\');" onmouseout="HideTooltip(\'_bbp' . $pos . $pos % 7 * 43 . 'x' . floor($pos / 7) * 41 . '\');">
                          <img src="' . get_item_icon($item[0]) . '" class="inv_icon" alt="" />
                        </a>';
                if ($mode) {
                    $output .= '
                        <div>
                          <a href="char_inv.php?action=delete_item&amp;id=' . $cid . '&amp;bag=' . $item[9] . '&amp;slot=' . $item[10] . '&amp;item=' . $item[0] . '&amp;mode=' . $mode . '">
                            <img src="img/aff_cross.png" class="ch_inv_delete" alt="" />
                          </a>
                        </div>';
                } else {
                    $output .= '
                        <div class="ch_inv_quantity_shadow">' . $item[2] . '</div>
                        <div class="ch_inv_quantity">' . $item[2] . '</div>';
                }
                $output .= '
                      </div>';
                // build a tooltip object for this item
                $output .= '
                      <div class="item_tooltip" id="tooltip_bbp' . $pos . $pos % 7 * 43 . 'x' . floor($pos / 7) * 41 . '" style="left: ' . ($pos % 7 * 43 - 129) . 'px; top: ' . (floor($pos / 7) * 41 + 42) . 'px;">
                        <table>
                          <tr>
                            <td>' . get_item_tooltip($item[3], $item[4], $item[5], $item[6], $item[7], $item[8]) . '</td>
                          </tr>
                        </table>
                      </div>';
            }
            $output .= '
                    </div>
                  </td>
                </tr>
                <tr>';
            // equipped bank bags, first 4
            for ($i = 1; $i < 5; ++$i) {
                $output .= '
                  <th>';
                if ($equip_bnk_bag_id[$i]) {
                    $output .= '
                    <a href="' . $base_datasite . $item_datasite . $equip_bnk_bag_id[$i][0] . '" rel="external">
                      <img class="bag_icon" src="' . get_item_icon($equip_bnk_bag_id[$i][0]) . '" alt="" />
                    </a>
                    ' . lang("item", "bag") . ' ' . $i . '<br />
                    <span class="small">' . $equip_bnk_bag_id[$i][1] . ' ' . lang("item", "slots") . '</span>';
                }
                $output .= '
                  </th>';
            }
            $output .= '
                </tr>
                <tr>';
            // equipped bank bag slots
            for ($t = 1; $t < 8; ++$t) {
                // equipped bank bags, last 3
                if ($t === 5) {
                    $output .= '
                </tr>
                <tr>';
                    for ($i = 5; $i < 8; ++$i) {
                        $output .= '
                  <th>';
                        if ($equip_bnk_bag_id[$i]) {
                            $output .= '
                    <a href="' . $base_datasite . $item_datasite . $equip_bnk_bag_id[$i][0] . '" rel="external">
                      <img class="bag_icon" src="' . get_item_icon($equip_bnk_bag_id[$i][0]) . '" alt="" />
                    </a>
                    ' . lang("item", "bag") . ' ' . $i . '<br />
                    <span class="small">' . $equip_bnk_bag_id[$i][1] . ' ' . lang("item", "slots") . '</span>';
                        }
                        $output .= '
                  </th>';
                    }
                    $output .= '
                  <th>
                  </th>
                </tr>
                <tr>';
                }
                // this_is_junk: style left hardcoded because it's calculated.
                $output .= '
                  <td align="center">
                    <div class="bag bank" style="width: ' . (4 * 43 + 2) . 'px; height: ' . ceil($equip_bnk_bag_id[$t][1] / 4) * 41 . 'px;">';
                $dsp = $equip_bnk_bag_id[$t][1] % 4;
                if ($dsp) {
                    $output .= '
                      <div class="no_slot"></div>';
                }
                foreach ($bank[$t] as $pos => $item) {
                    // this_is_junk: style left hardcoded because it's calculated.
                    $item[2] = $item[2] == 1 ? '' : $item[2];
                    $output .= '
                      <div class="bag_slot" style="left: ' . (($pos + $dsp) % 4 * 43 + 4) . 'px; top: ' . (floor(($pos + $dsp) / 4) * 41 + 4) . 'px;">
                        <a href="' . $base_datasite . $item_datasite . $item[0] . '" rel="external" onmouseover="ShowTooltip(this,\'_bb' . $t . 'p' . $pos . ($pos + $dsp) % 4 * 43 . 'x' . floor(($pos + $dsp) / 4) * 41 . '\');" onmouseout="HideTooltip(\'_bb' . $t . 'p' . $pos . ($pos + $dsp) % 4 * 43 . 'x' . floor(($pos + $dsp) / 4) * 41 . '\');">
                          <img src="' . get_item_icon($item[0]) . '" class="inv_icon" alt="" />
                        </a>';
                    if ($mode) {
                        $output .= '
                        <div>
                          <a href="char_inv.php?action=delete_item&amp;id=' . $cid . '&amp;bag=' . $item[9] . '&amp;slot=' . $item[10] . '&amp;item=' . $item[0] . '&amp;mode=' . $mode . '">
                            <img src="img/aff_cross.png" class="ch_inv_delete" alt="" />
                          </a>
                        </div>';
                    } else {
                        $output .= '
                        <div class="ch_inv_quantity_shadow">' . $item[2] . '</div>
                        <div class="ch_inv_quantity">' . $item[2] . '</div>';
                    }
                    $output .= '
                      </div>';
                    // build a tooltip object for this item
                    $output .= '
                      <div class="item_tooltip" id="tooltip_bb' . $t . 'p' . $pos . ($pos + $dsp) % 4 * 43 . 'x' . floor(($pos + $dsp) / 4) * 41 . '" style="left: ' . (($pos + $dsp) % 4 * 43 - 129) . 'px; top: ' . (floor(($pos + $dsp) / 4) * 41 + 42) . 'px;">
                        <table>
                          <tr>
                            <td>' . get_item_tooltip($item[3], $item[4], $item[5], $item[6], $item[7], $item[8]) . '</td>
                          </tr>
                        </table>
                      </div>';
                }
                $output .= '
                    </div>
                  </td>';
            }
            unset($equip_bnk_bag_id);
            unset($bank);
            $output .= '
                  <td><div class="bag bank"></div></td>';
            //---------------Page Specific Data Ends here----------------------------
            //---------------Character Tabs Footer-----------------------------------
            $output .= '
                </tr>
              </table>
            </div>
            <br />
            <table class="hidden">
              <tr>
                <td>';
            // button to user account page, user account page has own security
            makebutton(lang("char", "chars_acc"), 'user.php?action=edit_user&amp;id=' . $owner_acc_id . '', 130);
            $output .= '
                </td>
                <td>';
            // show Delete Mode / View Mode button depending on current mode
            if ($mode) {
                makebutton(lang("char", "viewmode"), 'char_inv.php?id=' . $cid . '&amp;realm=' . $realmid . '&amp;mode=0" type="def', 130);
            } else {
                makebutton(lang("char", "deletemode"), 'char_inv.php?id=' . $cid . '&amp;realm=' . $realmid . '&amp;mode=1" type="def', 130);
            }
            $output .= '
                </td>
                <td>';
            // only higher level GM with delete access can edit character
            //  character edit allows removal of character items, so delete permission is needed
            if ($user_lvl > $owner_gmlvl && $user_lvl >= $action_permission["delete"]) {
                //makebutton($lang_char["edit_button"], 'char_edit.php?id='.$cid.'&amp;realm='.$realmid.'', 130);
                $output .= '
                </td>
                <td>';
            }
            // only higher level GM with delete access, or character owner can delete character
            if ($user_lvl > $owner_gmlvl && $user_lvl >= $action_permission["delete"] || $owner_name === $user_name) {
                makebutton(lang("char", "del_char"), 'char_list.php?action=del_char_form&amp;check%5B%5D=' . $cid . '" type="wrn', 130);
                $output .= '
                </td>
                <td>';
            }
            // only GM with update permission can send mail, mail can send items, so update permission is needed
            if ($user_lvl >= $action_permission["update"]) {
                makebutton(lang("char", "send_mail"), 'mail.php?type=ingame_mail&amp;to=' . $char["name"] . '', 130);
                $output .= '
                </td>
                <td>';
            }
            makebutton(lang("global", "back"), 'javascript:window.history.back()" type="def', 130);
            $output .= '
                </td>
              </tr>
            </table>
            <br />
          <!-- end of char_inv.php -->';
        } else {
            error(lang("char", "no_permission"));
        }
    } else {
        error(lang("char", "no_char_found"));
    }
}
Esempio n. 5
0
function view_raffle()
{
    global $output, $coupon_id, $raffle_id, $bag_id, $characters_db, $user_id, $user_name, $base_datasite, $item_datasite, $sql, $core;
    points_tabs();
    if (!isset($_GET["purchased"])) {
        $query = "SELECT * FROM point_system_raffles WHERE entry='" . $raffle_id . "'";
        $result = $sql["mgr"]->query($query);
        $raffle = $sql["mgr"]->fetch_assoc($result);
        $my_usage_query = "SELECT * FROM point_system_raffle_tickets WHERE raffle='" . $raffle_id . "' AND user='******'";
        $my_usage_result = $sql["mgr"]->query($my_usage_query);
        $my_usage_count = $sql["mgr"]->num_rows($my_usage_result);
        $usage_query = "SELECT * FROM point_system_raffle_tickets WHERE raffle='" . $raffle_id . "'";
        $usage_result = $sql["mgr"]->query($usage_query);
        $usage_count = $sql["mgr"]->num_rows($usage_result);
        $output .= '
          <div class="tab_content center">';
        // make sure we're allowed to use this coupon
        if ($raffle["tickets_per_user"] <= $my_usage_count && $raffle["tickets_per_user"] != -1 || $usage_count >= $raffle["ticket_limit"] && $raffle["ticket_limit"] != -1) {
            $output .= '
            <span class="error">' . lang("points", "cannot_purchase_ticket") . '</span>';
        } else {
            $output .= '
            <form action="point_system.php" id="form1">
              <input type="hidden" name="action" value="do_purchase" />
              <input type="hidden" name="raffle_id" value="' . $raffle_id . '" />
              <table class="lined" id="coupon_table">
                <tr>
                  <td align="left">' . $raffle["title"] . '</td>
                </tr>';
            if ($raffle["text"] != "") {
                $output .= '
                <tr>
                  <td align="left">' . $raffle["text"] . '</td>
                </tr>';
            }
            $output .= '
              <tr>
                <td align="left"><span>' . lang("points", "drawing") . '</span>:&nbsp;' . $raffle["drawing"] . '</td>
              </tr>';
            if ($raffle["credits"] != 0 || $raffle["money"] != 0 || $raffle["item_id"] != 0) {
                $output .= '
                <tr>
                  <td>
                    <div class="coupon_parts">' . lang("points", "raffle_prizes") . ':</div>';
                if ($raffle["credits"] != 0) {
                    if ($raffle["credits"] > 1) {
                        $tip = lang("points", "raffle_credits");
                    } else {
                        $tip = lang("points", "raffle_credit");
                    }
                    $output .= '
                    <div class="coupon_parts">
                      <span>' . $raffle["credits"] . '</span>
                      <span>' . $tip . '</span>
                    </div>';
                }
                if ($raffle["money"] != 0) {
                    // extract gold/silver/copper from single gold number
                    $raffle["money"] = str_pad($raffle["money"], 4, "0", STR_PAD_LEFT);
                    $raffle_g = substr($raffle["money"], 0, -4);
                    if ($raffle_g == "") {
                        $raffle_g = 0;
                    }
                    $raffle_s = substr($raffle["money"], -4, 2);
                    if ($raffle_s == "" || $raffle_s == "00") {
                        $raffle_s = 0;
                    }
                    $raffle_c = substr($raffle["money"], -2);
                    if ($raffle_c == "" || $raffle_c == "00") {
                        $raffle_c = 0;
                    }
                    $output .= '
                    <div class="coupon_parts">
                      <span>' . $raffle_g . '</span>
                      <img src="img/gold.gif" alt="gold" style="position: relative; bottom: -6px;" />
                      <span>' . $raffle_s . '</span>
                      <img src="img/silver.gif" alt="silver" style="position: relative; bottom: -6px;" />
                      <span>' . $raffle_c . '</span>
                      <img src="img/copper.gif" alt="copper" style="position: relative; bottom: -6px;" />
                    </div>';
                }
                if ($raffle["item_id"] != 0) {
                    if ($raffle["item_id"] > 0) {
                        // get item data
                        if ($core == 1) {
                            $i_query = "SELECT \r\n                *, description AS description1, name1 AS name, quality AS Quality, inventorytype AS InventoryType, \r\n                socket_color_1 AS socketColor_1, socket_color_2 AS socketColor_2, socket_color_3 AS socketColor_3,\r\n                requiredlevel AS RequiredLevel, allowableclass AS AllowableClass,\r\n                sellprice AS SellPrice, itemlevel AS ItemLevel\r\n                FROM items " . ($locales_search_option != 0 ? "LEFT JOIN items_localized ON (items_localized.entry=items.entry AND language_code='" . $locales_search_option . "') " : " ") . "WHERE items.entry='" . $raffle["item_id"] . "'";
                        } else {
                            $i_query = "SELECT *, description AS description1 FROM item_template " . ($locales_search_option != 0 ? "LEFT JOIN locales_item ON locales_item.entry=item_template.entry " : " ") . "WHERE item_template.entry='" . $raffle["item_id"] . "'";
                        }
                        $i_result = $sql["world"]->query($i_query);
                        $i = $sql["world"]->fetch_assoc($i_result);
                        $output .= '
                    <div class="coupon_parts">
                      <div class="coupon_item">
                        <div>
                          <a id="ch_inv_padding" href="' . $base_datasite . $item_datasite . $raffle["item_id"] . '" rel="external" onmouseover="ShowTooltip(this,\'_b\');" onmouseout="HideTooltip(\'_b\');">
                            <img src="' . get_item_icon($raffle["item_id"]) . '" alt="" />
                          </a>';
                        if ($raffle["item_count"] > 1) {
                            $output .= '
                          <div id="coupon_item_quantity_shadow">' . $raffle["item_count"] . '</div>
                          <div id="coupon_item_quantity">' . $raffle["item_count"] . '</div>';
                        }
                        $output .= '
                        </div>';
                        // build a tooltip object for this item
                        $output .= '
                        <div class="item_tooltip" id="tooltip_b" style="left: -129px; top: 42px;">
                          <table>
                            <tr>
                              <td>' . get_item_tooltip($i, $item[4], $item[5], $item[6], $item[7], $item[8]) . '</td>
                            </tr>
                          </table>
                        </div>';
                        $output .= '
                      </div>
                    </div>';
                    } else {
                        $output .= '
                    <div class="coupon_parts">
                      <div>
                        <a href="point_system.php?action=view_bag&amp;bag_id=' . $coupon["item_id"] * -1 . '&amp;raffle_id=' . $raffle_id . '" onmousemove="oldtoolTip(\'' . lang("points", "prize_bag") . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()">
                          <img src="' . get_item_icon(1725) . '" alt="" />
                        </a>
                      </div>
                    </div>';
                    }
                }
                $output .= '
                  </td>
                </tr>
                <tr>
                  <td>
                    <div class="coupon_parts">' . lang("points", "ticket_cost") . ':</div>';
                if ($raffle["cost_credits"] != 0) {
                    // get our credit balance
                    $query = "SELECT credits FROM config_accounts WHERE Login='******'";
                    $result = $sql["mgr"]->query($query);
                    $result = $sql["mgr"]->fetch_assoc($result);
                    $credits = $result["credits"];
                    // check our funds vs Unlimited and the raffle's requirement
                    $insufficient = false;
                    if ($credits < $raffle["cost_credits"] && $credits > -1) {
                        $insufficient = true;
                    }
                    if ($raffle["cost_credits"] > 1) {
                        $tip = lang("points", "raffle_credits");
                    } else {
                        $tip = lang("points", "raffle_credit");
                    }
                    $output .= '
                    <div class="coupon_parts">
                      <span>' . $raffle["cost_credits"] . '</span>
                      <span>' . $tip . '</span>
                      <span class="points_credit_highlight">' . ($credits > -1 ? '&nbsp;' . lang("points", "balance") . ':&nbsp;' . rtrim($credits, "0.") : '') . '</span>
                      <span class="points_credit_highlight">' . ($insufficient ? '&nbsp;<b>(' . lang("points", "insufficient_funds") . ')</b>' : '') . '</span>
                      <span class="points_credit_highlight">' . ($credits <= -1 ? '&nbsp;<b>(' . lang("points", "unlimited") . ')</b>' : '') . '</span>
                    </div>';
                }
                if ($raffle["cost_money"] != 0) {
                    // extract gold/silver/copper from single gold number
                    $raffle["cost_money"] = str_pad($raffle["cost_money"], 4, "0", STR_PAD_LEFT);
                    $raffle_cost_g = substr($raffle["cost_money"], 0, -4);
                    if ($raffle_cost_g == "") {
                        $raffle_cost_g = 0;
                    }
                    $raffle_cost_s = substr($raffle["cost_money"], -4, 2);
                    if ($raffle_cost_s == "" || $raffle_cost_s == "00") {
                        $raffle_cost_s = 0;
                    }
                    $raffle_cost_c = substr($raffle["cost_money"], -2);
                    if ($raffle_cost_c == "" || $raffle_cost_c == "00") {
                        $raffle_cost_c = 0;
                    }
                    $output .= '
                    <div class="coupon_parts">
                      <span>' . $raffle_cost_g . '</span>
                      <img src="img/gold.gif" alt="gold" style="position: relative; bottom: -6px;" />
                      <span>' . $raffle_cost_s . '</span>
                      <img src="img/silver.gif" alt="silver" style="position: relative; bottom: -6px;" />
                      <span>' . $raffle_cost_c . '</span>
                      <img src="img/copper.gif" alt="copper" style="position: relative; bottom: -6px;" />
                    </div>';
                    $output .= '
                    <div class="coupon_part_title">
                      <span>' . lang("points", "choose_char_use_money") . ':</span>
                    </div>';
                    // get characters
                    $char_list = array();
                    $realm_list = array();
                    foreach ($characters_db as $db) {
                        $sqlt = new SQL();
                        $sqlt->connect($db["addr"], $db["user"], $db["pass"], $db["name"], $db["encoding"]);
                        $realm_char_list = array();
                        // store the realm id for later
                        $realm_list[] = $db["id"];
                        if ($core == 1) {
                            $char_query = "SELECT guid FROM characters WHERE acct='" . $user_id . "' ORDER BY guid ASC";
                        } else {
                            $char_query = "SELECT guid FROM characters WHERE account='" . $user_id . "' ORDER BY guid ASC";
                        }
                        $char_result = $sqlt->query($char_query);
                        while ($row = $sqlt->fetch_assoc($char_result)) {
                            $realm_char_list[] = $row["guid"];
                        }
                        $char_list[] = $realm_char_list;
                    }
                    for ($i = 0; $i < count($char_list); $i++) {
                        $realm_chars = $char_list[$i];
                        $cur_realm = $realm_list[$i];
                        $realm_name_query = "SELECT * FROM config_servers WHERE `Index`='" . $cur_realm . "'";
                        $realm_name_result = $sql["mgr"]->query($realm_name_query);
                        $realm_name_result = $sql["mgr"]->fetch_assoc($realm_name_result);
                        $cur_realm_name = $realm_name_result["Name"];
                        $sqlt = new SQL();
                        $sqlt->connect($characters_db[$cur_realm]["addr"], $characters_db[$cur_realm]["user"], $characters_db[$cur_realm]["pass"], $characters_db[$cur_realm]["name"], $characters_db[$cur_realm]["encoding"]);
                        if (count($realm_list) > 1) {
                            $output .= '
                    <div class="coupon_part_chars">
                      <span>' . $cur_realm_name . '</span>
                    </div>';
                        }
                        $output .= '
                    <div class="coupon_part_chars">
                      <div class="fake_table">';
                        $first = true;
                        // we want the first character to be selected
                        foreach ($realm_chars as $row) {
                            if ($core == 1) {
                                $char_query = "SELECT *, gold AS money FROM characters WHERE guid='" . $row . "'";
                            } else {
                                $char_query = "SELECT * FROM characters WHERE guid='" . $row . "'";
                            }
                            $char_result = $sqlt->query($char_query);
                            $char = $sqlt->fetch_assoc($char_result);
                            // extract gold/silver/copper from single gold number
                            $char["money"] = str_pad($char["money"], 4, "0", STR_PAD_LEFT);
                            $char_g = substr($char["money"], 0, -4);
                            if ($char_g == "") {
                                $char_g = 0;
                            }
                            $char_s = substr($char["money"], -4, 2);
                            if ($char_s == "" || $char_s == "00") {
                                $char_s = 0;
                            }
                            $char_c = substr($char["money"], -2);
                            if ($char_c == "" || $char_c == "00") {
                                $char_c = 0;
                            }
                            $output .= '
                        <div class="fake_table_cell">
                          <input type="radio" name="money_character" value="' . ($i + 1) . "-" . $row . '-' . $char["name"] . '"' . (isset($first) ? ' checked="checked"' : '') . ($char["online"] || $char["money"] < $raffle["cost_money"] ? ' disabled="disabled"' : '') . ' />
                          <a href="char.php?id=' . $row . '&amp;realm=' . $cur_realm . '">' . $char["name"] . '</a> - <img src="img/c_icons/' . $char["race"] . '-' . $char["gender"] . '.gif" onmousemove="oldtoolTip(\'' . char_get_race_name($char["race"]) . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />
                          <img src="img/c_icons/' . $char["class"] . '.gif" onmousemove="oldtoolTip(\'' . char_get_class_name($char["class"]) . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt=""/> - ' . lang("char", "level_short") . char_get_level_color($char["level"]) . '
                        </div>
                        <div class="fake_table_cell">
                          <span>' . $char_g . '</span>
                          <img src="img/gold.gif" alt="gold" style="position: relative; bottom: -6px;" />
                          <span>' . $char_s . '</span>
                          <img src="img/silver.gif" alt="silver" style="position: relative; bottom: -6px;" />
                          <span>' . $char_c . '</span>
                          <img src="img/copper.gif" alt="copper" style="position: relative; bottom: -6px;" />
                        </div>';
                            unset($first);
                        }
                    }
                }
                $output .= '
                      </div>
                    </div>
                  </td>
                </tr>';
            }
            if ($raffle["tickets_per_user"] > 1) {
                $output .= '
                <tr>
                  <td>
                    <div class="coupon_parts">' . lang("points", "tickets_purchased") . ':&nbsp;<b>' . $my_usage_count . '</b></div>
                  </td>
                </tr>';
            }
            $output .= '
                <tr>
                  <td align="right">
                    <a href="javascript:do_submit(\'form1\',0)">
                      <img src="img/aff_tick.png" width="16" height="16" alt="" />
                      <span>&nbsp;' . lang("points", "confirm_purchase") . '</span>
                    </a>
                  </td>
                </tr>
              </table>
            </form>';
        }
    } else {
        $output .= '
          <div class="tab_content center">';
        $output .= '
            <span>' . lang("points", "purchased") . '</span>';
    }
    $output .= '
          </div>
          <br />
          <!-- end of point_system.php -->';
}
Esempio n. 6
0
function main()
{
    global $output, $realm_id, $world_db, $logon_db, $characters_db, $corem_db, $server, $action_permission, $user_lvl, $user_id, $site_encoding, $hide_coupons, $locales_search_option, $base_datasite, $item_datasite, $showcountryflag, $gm_online_count, $gm_online, $itemperpage, $hide_uptime, $player_online, $hide_max_players, $hide_avg_latency, $hide_plr_latency, $hide_server_mem, $sql, $core;
    // do any raffle drawings that are necessary
    do_raffles();
    // check achievement contests
    do_contests();
    $output .= '
          <div class="top">';
    //---------------------Information for Explorer Users--------------------------
    if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) {
        $msie = '
            <br />
              <span id="index_explorer_warning">' . lang("index", "explorer_warn") . '</span>
            <br />';
    } else {
        $msie = '';
    }
    //-----------------------------------------------------------------------------
    if (test_port($server[$realm_id]["addr"], $server[$realm_id]["game_port"])) {
        if ($core == 1) {
            $stats = get_uptime($server[$realm_id]["stats.xml"]);
            $staticUptime = ' <em>' . htmlentities(get_realm_name($realm_id), ENT_COMPAT, $site_encoding) . '</em> <br />' . $stats["platform"][4] . ' ' . $stats["platform"][5] . ' ' . $stats["platform"][6];
            if (!$hide_uptime) {
                $staticUptime .= '<br />' . lang("index", "online") . ' for ' . $stats["uptime"];
            }
            $output .= '
            <div id="uptime">' . $msie . '
              <h1>
                <span id="index_realm_info">
                  <span>' . $staticUptime . '</span>';
            if (!$hide_max_players) {
                $output .= '
                  <br />
                  <span>' . lang("index", "maxplayers") . ': </span>
                  <span class="index_realm_info_value">' . $stats["peak"] . '</span>';
            }
            if (!$hide_avg_latency) {
                $output .= '
                  <br />
                  <span>' . lang("index", "avglat") . ': </span>
                  <span class="index_realm_info_value">' . $stats["avglat"] . '</span>';
            }
            $output .= '
                  <br />';
            if ($hide_server_mem != 0) {
                if ($hide_server_mem == 2 || $user_lvl == $action_permission["delete"]) {
                    $output .= '
                  <span>' . lang("index", "cpu") . ': </span>
                  <span class="index_realm_info_value">' . $stats["cpu"] . '%, </span>
                  <span>' . lang("index", "ram") . ': </span>
                  <span class="index_realm_info_value">' . $stats["ram"] . ' MB, </span>
                  <span>' . lang("index", "threads") . ': </span>
                  <span class="index_realm_info_value">' . $stats["threads"] . '</span>';
                }
            }
            $output .= '
               </span>
              </h1>
            </div>';
        } else {
            $stats = $sql["logon"]->fetch_assoc($sql["logon"]->query("SELECT starttime, maxplayers FROM uptime WHERE realmid='" . $realm_id . "' ORDER BY starttime DESC LIMIT 1"), 0);
            $uptimetime = time() - $stats["starttime"];
            // a more reliable method of counting how many characters have been online since server start
            //$maxplayers_query = "SELECT COUNT(*) FROM `".$characters_db[$realm_id]["name"]."`.characters WHERE logout_time>='".$stats["starttime"]."' AND logout_time>=(SELECT UNIX_TIMESTAMP(last_login) FROM `".$logon_db["name"]."`.account WHERE id=`".$characters_db[$realm_id]["name"]."`.characters.account)";
            //$maxplayers_result = $sql["char"]->query($maxplayers_query);
            //$maxplayers_result = $sql["char"]->fetch_assoc($maxplayers_result);
            //$stats["maxplayers"] = $maxplayers_result["COUNT(*)"];
            function format_uptime($seconds)
            {
                $secs = intval($seconds % 60);
                $mins = intval($seconds / 60 % 60);
                $hours = intval($seconds / 3600 % 24);
                $days = intval($seconds / 86400);
                if ($days > 365) {
                    $days = intval($seconds / 86400 % 365.24);
                    $years = intval($seconds / 31556926);
                }
                $uptimeString = '';
                if ($years) {
                    // we have a server that has been up for over a year? O_o
                    // actually, it's probably because the server didn't write a useful
                    // value to the uptime table's starttime field.
                    $uptimeString .= $years;
                    $uptimeString .= $years == 1 ? ' ' . lang("index", "uptime_year") : ' ' . lang("index", "uptime_years");
                    if ($days) {
                        $uptimeString .= ($years > 0 ? ', ' : '') . $days;
                        $uptimeString .= $days == 1 ? ' ' . lang("index", "uptime_day") : ' ' . lang("index", "uptime_days");
                    }
                } else {
                    if ($days) {
                        $uptimeString .= $days;
                        $uptimeString .= $days == 1 ? ' ' . lang("index", "uptime_day") : ' ' . lang("index", "uptime_days");
                    }
                }
                if ($hours) {
                    $uptimeString .= ($days > 0 ? ', ' : '') . $hours;
                    $uptimeString .= $hours == 1 ? ' ' . lang("index", "uptime_hour") : ' ' . lang("index", "uptime_hours");
                }
                if ($mins) {
                    $uptimeString .= ($days > 0 || $hours > 0 ? ', ' : '') . $mins;
                    $uptimeString .= $mins == 1 ? ' ' . lang("index", "uptime_minute") : ' ' . lang("index", "uptime_minutes");
                }
                if ($secs) {
                    $uptimeString .= ($days > 0 || $hours > 0 || $mins > 0 ? ', ' : '') . $secs;
                    $uptimeString .= $secs == 1 ? ' ' . lang("index", "uptime_second") : ' ' . lang("index", "uptime_seconds");
                }
                return $uptimeString;
            }
            $staticUptime = ' <em>' . htmlentities(get_realm_name($realm_id), ENT_COMPAT, $site_encoding) . '</em> ';
            if (!$hide_uptime) {
                if ($stats["starttime"] != 0) {
                    $staticUptime .= '<br /><span>' . lang("index", "online") . format_uptime($uptimetime) . '</span>';
                } else {
                    $staticUptime .= '<br /><span style="color:orange">' . lang("index", "time_error1") . ': <br>' . format_uptime($uptimetime) . '</span><br><span style="color:red">' . lang("index", "time_error2") . '</span>';
                }
            }
            unset($uptimetime);
            $output .= '
            <div id="uptime">' . $msie . '
              <h1>
                <span id="index_realm_info">' . $staticUptime;
            if (!$hide_max_players) {
                $output .= '
                  <br />
                  <span>' . lang("index", "maxplayers") . ': </span>
                  <span class="index_realm_info_value">' . $stats["maxplayers"] . '</span>';
            }
            // this_is_junk: MaNGOS doesn't store player latency. :/
            if ($core == 3) {
                if (!$hide_avg_latency) {
                    $lat_query = "SELECT SUM(latency), COUNT(*) FROM characters WHERE online=1";
                    $lat_result = $sql["char"]->query($lat_query);
                    $lat_fields = $sql["char"]->fetch_assoc($lat_result);
                    $avglat = sprintf("%.3f", $lat_fields["SUM(latency)"] / $lat_fields["COUNT(*)"]);
                    $output .= '
                    <br />
                    <span>' . lang("index", "avglat") . ': </span>
                    <span class="index_realm_info_value">' . $avglat . '</span>';
                }
            }
            $output .= '
                </span>
              </h1>
            </div>';
            unset($stats);
            $online = true;
        }
        unset($staticUptime);
        //unset($stats);
        $online = true;
    } else {
        $output .= $msie . '<h1><span class="error">' . lang("index", "realm") . ' <em>' . htmlentities(get_realm_name($realm_id), ENT_COMPAT, $site_encoding) . '</em> ' . lang("index", "offline_or_let_high") . '</span></h1>';
        $online = false;
    }
    //close the div
    $output .= '
          </div>';
    // MOTDs
    // get our MotDs...
    $motd = "";
    $motd_result = $sql["mgr"]->query("SELECT *, UNIX_TIMESTAMP(Created) AS Created, UNIX_TIMESTAMP(Last_Edited) AS Last_Edited FROM motd WHERE Enabled<>0 AND (Target='" . $user_id . "' OR Target=0) ORDER BY Priority ASC");
    // if we don't get any MotDs, it'll stay empty
    if ($user_lvl >= $action_permission["update"]) {
        $output .= '
          <script type="text/javascript">
            // <![CDATA[
              answerbox.btn_ok = "' . lang("global", "yes_low") . '";
              answerbox.btn_cancel = "' . lang("global", "no") . '";
              var del_motd = "motd.php?action=delete_motd&amp;id=";
            // ]]>
          </script>';
    }
    if ($sql["mgr"]->num_rows($motd_result) > 0) {
        $output .= '
            <div class="div_lined">
              <div class="div_lined_head">
                <span>' . lang("index", "motd") . '</span>
              </div>';
    }
    while ($temp = $sql["mgr"]->fetch_assoc($motd_result)) {
        if ($user_lvl >= $temp["Min_Sec_Level"]) {
            $motd = bb2html($temp["Message"]) . "<br /><br />";
            if ($motd) {
                if ($temp["Target"] != 0) {
                    $output .= '
                <div class="div_lined_line left_text">' . lang("motd", "private") . '</div>';
                }
                $output .= '
                <div class="div_lined_line left_text">';
                $output .= $motd;
                $output .= '
                  <br />';
                // Get User Name for poster
                if ($core == 1) {
                    $posted_name_query = "SELECT login FROM accounts WHERE acct='" . $temp["Created_By"] . "'";
                } else {
                    $posted_name_query = "SELECT username AS login FROM account WHERE id='" . $temp["Created_By"] . "'";
                }
                $posted_name_result = $sql["logon"]->query($posted_name_query);
                $posted_name = $sql["logon"]->fetch_assoc($posted_name_result);
                $posted_name = $posted_name["login"];
                // Get Screen Name for poster, if available
                $posted_screenname_query = "SELECT ScreenName FROM config_accounts WHERE Login='******'";
                $posted_screenname_result = $sql["mgr"]->query($posted_screenname_query);
                $posted_screenname = $sql["mgr"]->fetch_assoc($posted_screenname_result);
                if ($posted_screenname["ScreenName"] != NULL) {
                    $posted_name = htmlspecialchars($posted_screenname["ScreenName"]);
                }
                // if the Server Message is posted by the system, Created_By will be zero
                if ($temp["Created_By"] != 0) {
                    $output .= '
                  <span>' . lang("motd", "posted_by") . ':</span>';
                    if ($user_lvl > -1) {
                        $output .= '
                  <a href="user.php?action=edit_user&amp;error=11&amp;acct=' . $temp["Created_By"] . '">';
                    }
                    $output .= '
                    <span>' . $posted_name . '</span>';
                    if ($user_lvl > -1) {
                        $output .= '
                  </a>';
                    }
                    $output .= '
                  <span>(' . date("M d, Y @ H:i:s", $temp["Created"]) . ')</span>';
                } else {
                    $output .= '
                  <span>' . lang("motd", "posted") . ': ' . date("M d, Y @ H:i:s", $temp["Created"]) . '</span>';
                }
                // Get User Name for last editor
                if ($core == 1) {
                    $edited_name_query = "SELECT login FROM accounts WHERE acct='" . $temp["Last_Edited_By"] . "'";
                } else {
                    $edited_name_query = "SELECT username AS login FROM account WHERE id='" . $temp["Last_Edited_By"] . "'";
                }
                $edited_name_result = $sql["logon"]->query($edited_name_query);
                $edited_name = $sql["logon"]->fetch_assoc($edited_name_result);
                $edited_name = $edited_name["login"];
                // Get Screen Name for last editor, if available
                $edited_screenname_query = "SELECT ScreenName FROM config_accounts WHERE Login='******'";
                $edited_screenname_result = $sql["mgr"]->query($edited_screenname_query);
                $edited_screenname = $sql["mgr"]->fetch_assoc($edited_screenname_result);
                if ($edited_screenname["ScreenName"] != NULL) {
                    $edited_name = htmlspecialchars($edited_screenname["ScreenName"]);
                }
                if ($temp["Last_Edited_By"] != 0) {
                    $output .= '
                  <br />
                  <div>
                    <span>' . lang("motd", "edited_by") . ':</span>';
                    if ($user_lvl > -1) {
                        $output .= '
                    <a href="user.php?action=edit_user&amp;error=11&amp;acct=' . $temp["Last_Edited_By"] . '">';
                    }
                    $output .= '
                      <span>' . $edited_name . '</span>';
                    if ($user_lvl > -1) {
                        $output .= '
                    </a>';
                    }
                    $output .= '
                    <span>(' . date("M d, Y @ H:i:s", $temp["Last_Edited"]) . ')</span>
                  </div>';
                }
                $output .= '
                </div>';
                if ($user_lvl >= $action_permission["update"]) {
                    $output .= '
                <div class="div_lined_line right_text">
                  <img src="img/aff_cross.png" width="16" height="16" onclick="answerBox(\'' . lang("global", "delete") . ': &lt;font color=white&gt;' . $temp["ID"] . '&lt;/font&gt;&lt;br /&gt;' . lang("global", "are_you_sure") . '\', del_motd + ' . $temp["ID"] . ');" alt="" />';
                }
                if ($user_lvl >= $action_permission["update"]) {
                    $output .= '
                  <a href="motd.php?action=edit_motd&amp;error=3&amp;id=' . $temp["ID"] . '">
                    <img src="img/edit.png" width="16" height="16" alt="" />
                  </a>
                </div>';
                }
                $output .= '
                <br />';
            }
        }
    }
    if ($sql["mgr"]->num_rows($motd_result)) {
        $output = substr($output, 0, strlen($output) - 24);
    }
    if ($sql["mgr"]->num_rows($motd_result) > 0) {
        $output .= '
            </div>';
    }
    if ($user_lvl >= $action_permission["insert"]) {
        $output .= '
            <div class="div_lined">
              <div class="div_lined_head right_text">
                <a href="motd.php?action=add_motd&amp;error=4">' . lang("index", "add_motd") . '</a>
              </div>
            </div>';
    }
    // Coupons
    if (!$hide_coupons) {
        $coupon_query = "SELECT * FROM point_system_coupons WHERE ((target='0' AND contest='0') OR target='" . $user_id . "') AND enabled='1'";
        $coupon_result = $sql["mgr"]->query($coupon_query);
        if ($sql["mgr"]->num_rows($coupon_result) > 0) {
            $output .= '
            <br />
            <div class="div_lined">
              <div class="div_lined_head">
                <span>' . lang("index", "avail_coupons") . '</span>
              </div>';
            while ($coupon = $sql["mgr"]->fetch_assoc($coupon_result)) {
                $usage_query = "SELECT * FROM point_system_coupon_usage WHERE coupon='" . $coupon["entry"] . "' AND user='******'";
                $usage_result = $sql["mgr"]->query($usage_query);
                if ($sql["mgr"]->num_rows($usage_result) < $coupon["usage_limit"] || $coupon["usage_limit"] == -1) {
                    $output .= '
              <div class="div_lined_line left_text">
                <span>' . $coupon["title"] . '</span>
              </div>';
                    if ($coupon["text"] != "") {
                        $output .= '
              <div class="div_lined_line left_text">
                <span>' . $coupon["text"] . '</span>
              </div>';
                    }
                    if ($coupon["credits"] != 0 || $coupon["money"] != 0 || $coupon["item_id"] != 0 || $coupon["raffle_id"] != 0) {
                        $output .= '
              <div class="div_lined_line left_text">
                <span>' . lang("index", "coupon_value") . ':</span>';
                        if ($coupon["credits"] > 0) {
                            if ($coupon["credits"] > 1) {
                                $tip = lang("index", "coupon_credits");
                            } else {
                                $tip = lang("index", "coupon_credit");
                            }
                            $output .= '
                <br />
                <br />
                <span>' . $coupon["credits"] . '</span>
                <span>' . $tip . '</span>';
                        }
                        if ($coupon["money"] > 0) {
                            // extract gold/silver/copper from single gold number
                            $coupon["money"] = str_pad($coupon["money"], 4, "0", STR_PAD_LEFT);
                            $coupon_g = substr($coupon["money"], 0, -4);
                            if ($coupon_g == "") {
                                $coupon_g = 0;
                            }
                            $coupon_s = substr($coupon["money"], -4, 2);
                            if ($coupon_s == "" || $coupon_s == "00") {
                                $coupon_s = 0;
                            }
                            $coupon_c = substr($coupon["money"], -2);
                            if ($coupon_c == "" || $coupon_c == "00") {
                                $coupon_c = 0;
                            }
                            $output .= '
                <br />
                <br />
                <span>' . $coupon_g . '</span>
                <img src="img/gold.gif" alt="gold" />
                <span>' . $coupon_s . '</span>
                <img src="img/silver.gif" alt="gold" />
                <span>' . $coupon_c . '</span>
                <img src="img/copper.gif" alt="gold" />';
                        }
                        if ($coupon["item_id"] != 0) {
                            if ($coupon["item_id"] > 0) {
                                // get item data
                                if ($core == 1) {
                                    $i_query = "SELECT \r\n                    *, description AS description1, name1 AS name, quality AS Quality, inventorytype AS InventoryType, \r\n                    socket_color_1 AS socketColor_1, socket_color_2 AS socketColor_2, socket_color_3 AS socketColor_3,\r\n                    requiredlevel AS RequiredLevel, allowableclass AS AllowableClass,\r\n                    sellprice AS SellPrice, itemlevel AS ItemLevel\r\n                    FROM items " . ($locales_search_option != 0 ? "LEFT JOIN items_localized ON (items_localized.entry=items.entry AND language_code='" . $locales_search_option . "') " : " ") . "WHERE items.entry='" . $coupon["item_id"] . "'";
                                } else {
                                    $i_query = "SELECT *, description AS description1 FROM item_template " . ($locales_search_option != 0 ? "LEFT JOIN locales_item ON locales_item.entry=item_template.entry " : " ") . "WHERE item_template.entry='" . $coupon["item_id"] . "'";
                                }
                                $i_result = $sql["world"]->query($i_query);
                                $i = $sql["world"]->fetch_assoc($i_result);
                                $output .= '
                <br />
                <br />
                <div class="coupon_item">
                  <div>
                    <a href="' . $base_datasite . $item_datasite . $coupon["item_id"] . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . $coupon["entry"] . '\');" onmouseout="HideTooltip(\'_b' . $coupon["entry"] . '\');">
                      <img src="' . get_item_icon($coupon["item_id"]) . '" alt="" />
                    </a>';
                                if ($coupon["item_count"] > 1) {
                                    $output .= '
                    <div class="ch_inv_quantity_shadow">' . $coupon["item_count"] . '</div>
                    <div class="ch_inv_quantity">' . $coupon["item_count"] . '</div>';
                                }
                                $output .= '
                  </div>';
                                // build a tooltip object for this item
                                $output .= '
                  <div class="item_tooltip_div" id="tooltip_b' . $coupon["entry"] . '" style="left: -129px; top: 42px;">
                    <div>' . get_item_tooltip($i, 0, 0, 0, 0, 0) . '</div>
                  </div>';
                                $output .= '
                </div>';
                            } else {
                                $output .= '
                <br />
                <br />
                <div class="coupon_item">
                  <div>
                    <a href="point_system.php?action=view_bag&amp;bag_id=' . $coupon["item_id"] * -1 . '" onmousemove="oldtoolTip(\'' . lang("points", "prize_bag") . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()">
                      <img src="' . get_item_icon(1725) . '" alt="" />
                    </a>
                  </div>
                </div>';
                            }
                        }
                        if ($coupon["raffle_id"] != 0) {
                            // find out how many entries per user the raffle allows and whether the raffle is enabled
                            if ($coupon["raffle_id"] != -1) {
                                $query = "SELECT tickets_per_user, enabled FROM point_system_raffles WHERE entry='" . $coupon["raffle_id"] . "'";
                                $result = $sql["mgr"]->query($query);
                                $result = $sql["mgr"]->fetch_assoc($result);
                                $per_user = $result["tickets_per_user"];
                                $raffle_enabled = $result["enabled"];
                                // if tickets_per_user is -1 then its unlimited, fake it with a reasonably high number
                                $per_user = 999999999;
                            } else {
                                // if it allows any raffle, then fake it
                                $per_user = 999999999;
                                $raffle_enabled = 1;
                            }
                            if ($raffle_enabled) {
                                // find out how many time we've entered
                                $query = "SELECT COUNT(*) FROM point_system_raffle_tickets WHERE raffle='" . $coupon["raffle_id"] . "' AND user='******'";
                                $result = $sql["mgr"]->query($query);
                                $result = $sql["mgr"]->fetch_assoc($result);
                                $tickets = $result["COUNT(*)"];
                                // if we haven't already purchased the maximum number of tickets
                                // or the raffle allows purchase of tickets from any raffle
                                if ($tickets < $per_user || $coupon["raffle_id"] == -1) {
                                    if ($coupon["redemption_option"] == 0) {
                                        $output .= '
                <br />
                <br />
                <span>' . lang("index", "and_raffle") . '</span>';
                                    } else {
                                        $output .= '
                <br />
                <br />
                <span>' . lang("index", "or_raffle") . '</span>';
                                    }
                                }
                            }
                        }
                        $output .= '
              </div>';
                    }
                    if ($coupon["credits"] < 0) {
                        $message = lang("points", "coupon_cost_credits");
                        $message = str_replace("%1", $coupon["credits"] * -1, $message);
                        $output .= '
              <div class="div_lined_line right_text">
                <span>' . $message . '</span>
              </div>';
                    }
                    if ($coupon["money"] < 0) {
                        $coupon["money"] = $coupon["money"] * -1;
                        $coupon_money = $coupon["money"];
                        $coupon_money = str_pad($coupon_money, 4, "0", STR_PAD_LEFT);
                        $cg = substr($coupon_money, 0, -4);
                        if ($cg == "") {
                            $cg = 0;
                        }
                        $cs = substr($coupon_money, -4, 2);
                        if ($cs == "" || $cs == "00") {
                            $cs = 0;
                        }
                        $cc = substr($coupon_money, -2);
                        if ($cc == "" || $cc == "00") {
                            $cc = 0;
                        }
                        $coupon_money_display = '
              <span>' . $cg . '</span>
              <img src="img/gold.gif" alt="" align="middle" />
              <span>' . $cs . '</span>
              <img src="img/silver.gif" alt="" align="middle" />
              <span>' . $cc . '</span>
              <img src="img/copper.gif" alt="" align="middle" />';
                        $message = lang("points", "coupon_cost_money");
                        $message = str_replace("%1", $coupon_money_display, $message);
                        $output .= '
              <div class="div_lined_line right_text">
                <span>' . $message . '</span>
              </div>';
                    }
                    $output .= '
              <div class="div_lined_line right_text">
                <a href="point_system.php?action=redeem_coupon&amp;coupon_id=' . $coupon["entry"] . '">
                  <img src="img/star.png" width="16" height="16" alt="" />
                  <span>&nbsp;' . lang("index", "use_coupon") . '</span>
                </a>
              </div>';
                    $output .= '
              <br />';
                }
            }
            if ($sql["mgr"]->num_rows($coupon_result)) {
                $output = substr($output, 0, strlen($output) - 20);
            }
            $output .= '
            </div>';
        }
    }
    // GM Tickets
    $start_m = isset($_GET["start_m"]) ? $sql["char"]->quote_smart($_GET["start_m"]) : 0;
    if (!is_numeric($start_m)) {
        $start_m = 0;
    }
    if ($core == 1) {
        $all_record_m = $sql["char"]->result($sql["char"]->query("SELECT COUNT(*) FROM gm_tickets WHERE deleted=0"), 0);
    } elseif ($core == 2) {
        $all_record_m = $sql["char"]->result($sql["char"]->query("SELECT COUNT(*) FROM character_ticket"), 0);
    } else {
        $all_record_m = $sql["char"]->result($sql["char"]->query("SELECT COUNT(*) FROM gm_tickets WHERE closedBy=0"), 0);
    }
    // show gm tickets
    $output .= '
            <br />';
    if ($user_lvl >= $action_permission["insert"]) {
        if ($all_record_m) {
            $output .= '
            <div class="div_lined">
              <div class="div_lined_head">
                <span>' . lang("index", "tickets") . '</span>
              </div>';
            if ($core == 1) {
                $result = $sql["char"]->query("SELECT ticketid, level, message, name, deleted,\r\n          timestamp, gm_tickets.playerGuid, acct\r\n          FROM gm_tickets\r\n            LEFT JOIN characters ON characters.guid=gm_tickets.playerGuid\r\n          ORDER BY ticketid DESC LIMIT " . $start_m . ", 3");
            } elseif ($core == 2) {
                $result = $sql["char"]->query("SELECT character_ticket.ticket_id AS ticketid, characters.level,\r\n          ticket_text AS message, characters.name, UNIX_TIMESTAMP(ticket_lastchange) AS timestamp,\r\n          character_ticket.guid AS playerGuid, account AS acct\r\n          FROM character_ticket\r\n            LEFT JOIN characters ON characters.guid=character_ticket.guid\r\n          ORDER BY ticketid DESC LIMIT " . $start_m . ", 3");
            } else {
                $result = $sql["char"]->query("SELECT gm_tickets.guid AS ticketid, characters.level, message,\r\n          gm_tickets.name, closedBy AS deleted, lastModifiedTime AS timestamp, gm_tickets.guid AS playerGuid, account AS acct\r\n          FROM gm_tickets\r\n            LEFT JOIN characters ON characters.guid=gm_tickets.guid\r\n          ORDER BY ticketid DESC LIMIT " . $start_m . ", 3");
            }
            while ($post = $sql["char"]->fetch_assoc($result)) {
                if (!$post["deleted"]) {
                    if ($core == 1) {
                        $login_result = $sql["logon"]->query("SELECT * FROM accounts WHERE acct='" . $post["acct"] . "'");
                    } else {
                        $login_result = $sql["logon"]->query("SELECT *, username AS login FROM account WHERE id='" . $post["acct"] . "'");
                    }
                    $login = $sql["logon"]->fetch_assoc($login_result);
                    $gm_result = $sql["mgr"]->query("SELECT SecurityLevel FROM config_accounts WHERE Login='******'");
                    $gm = $sql["mgr"]->fetch_assoc($gm_result);
                    $gm = $gm["SecurityLevel"];
                    if ($user_lvl > 0 && ($user_lvl >= gmlevel($gm) || $user_lvl == $action_permission["delete"])) {
                        $output .= '
              <div class="div_lined_line left_text">
                <a href="char.php?id=' . $post["playerGuid"] . '">
                  <span onmousemove="oldtoolTip(\'' . htmlspecialchars($login["username"]) . ' (' . id_get_gm_level($gm) . ')' . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()">' . htmlentities($post["name"], ENT_COMPAT, $site_encoding) . '</span>
                </a>
              </div>
              <div class="div_lined_line left_text">
                <span>' . htmlspecialchars($post["message"]) . '</span>
              </div>
              <div class="div_lined_line right_text">';
                    }
                    $output .= '
                <span>' . lang("index", "submitted") . ": " . date('G:i:s m-d-Y', $post["timestamp"]) . '</span>';
                    $output .= '
              </div>
              <div class="div_lined_line right_text">';
                    if ($user_lvl >= $action_permission["update"]) {
                        $output .= '
                <a href="ticket.php?action=edit_ticket&amp;error=4&amp;id=' . $post["ticketid"] . '">
                  <img src="img/edit.png" width="16" height="16" alt="" />
                </a>';
                    }
                    $output .= '
              </div>
              <br />';
                }
            }
            $output .= '
            </div>';
        }
    }
    // Character Changes
    // count pending character changes
    $char_change_count = $sql["mgr"]->result($sql["mgr"]->query("SELECT COUNT(*) FROM char_changes"), 0);
    // show pending character changes
    $output .= '
            <br />';
    if ($user_lvl >= $action_permission["update"]) {
        if ($char_change_count) {
            $output .= '
            <div class="div_lined">
              <div class="div_lined_head">
                <span>' . lang("index", "pendingchanges") . '</span>
              </div>';
            $result = $sql["mgr"]->query("SELECT * FROM char_changes");
            while ($change = $sql["mgr"]->fetch_assoc($result)) {
                if ($core == 1) {
                    $change_char_query = "SELECT * FROM characters WHERE guid='" . $change["guid"] . "'";
                } else {
                    $change_char_query = "SELECT *, account AS acct FROM characters WHERE guid='" . $change["guid"] . "'";
                }
                $change_char = $sql["char"]->fetch_assoc($sql["char"]->query($change_char_query));
                if ($core == 1) {
                    $change_acct_query = "SELECT * FROM accounts WHERE acct='" . $change_char["acct"] . "'";
                } else {
                    $change_acct_query = "SELECT *, username AS login FROM account WHERE id='" . $change_char["acct"] . "'";
                }
                $change_acct = $sql["logon"]->fetch_assoc($sql["logon"]->query($change_acct_query));
                if (isset($change["new_name"])) {
                    // Localization
                    $namechange = lang("xname", "playerhasreq");
                    $namechange = str_replace("%1", htmlspecialchars($change_acct["login"]), $namechange);
                    $namechange = str_replace("%2", htmlspecialchars($change_char["name"]), $namechange);
                    $namechange = str_replace("%3", htmlspecialchars($change["new_name"]), $namechange);
                    $output .= '
              <div class="div_lined_line left_text large">
                <span>' . $namechange . '</span>';
                }
                if (isset($change["new_race"])) {
                    // Localization
                    $racechange = lang("xrace", "playerhasreq");
                    $racechange = str_replace("%1", htmlspecialchars($change_acct["login"]), $racechange);
                    $racechange = str_replace("%2", htmlspecialchars($change_char["name"]), $racechange);
                    $racechange = str_replace("%3", char_get_race_name($change["new_race"]), $racechange);
                    $output .= '
              <div class="div_lined_line left_text large">
                <span>' . $racechange . '</span>';
                }
                if (isset($change["new_acct"])) {
                    if ($core == 1) {
                        $new_acct_query = "SELECT login FROM accounts WHERE acct='" . $change["new_acct"] . "'";
                    } else {
                        $new_acct_query = "SELECT username AS login FROM account WHERE id='" . $change["new_acct"] . "'";
                    }
                    $new_acct_result = $sql["logon"]->query($new_acct_query);
                    $new_acct_result = $sql["logon"]->fetch_assoc($new_acct_result);
                    $new_acct_name = $new_acct_result["login"];
                    // Localization
                    $acctchange = lang("xacct", "playerhasreq");
                    $acctchange = str_replace("%1", htmlspecialchars($change_acct["login"]), $acctchange);
                    $acctchange = str_replace("%2", htmlspecialchars($change_char["name"]), $acctchange);
                    $acctchange = str_replace("%3", $new_acct_name, $acctchange);
                    $output .= '
              <div class="div_lined_line left_text large">
                <span>' . $acctchange . '</span>';
                }
                if ($change_char["online"]) {
                    $output .= '
                <br />
                <br />
                <img src="img/aff_warn.gif" alt="warn" />
                <span class="error">' . lang("xname", "online") . '</span>';
                }
                $output .= '
              </div>';
                if (isset($change["new_name"])) {
                    $file = "change_char_name.php";
                } elseif (isset($change["new_race"])) {
                    $file = "change_char_race.php";
                } else {
                    $file = "change_char_account.php";
                }
                $output .= '
              <div class="div_lined_line right_text">
                <a href="' . $file . '?action=denied&amp;guid=' . $change["guid"] . '">
                  <img src="img/cross.png" width="12" height="12" alt="" />
                </a>';
                if (!$change_char["online"]) {
                    $output .= '
                <a href="' . $file . '?action=approve&amp;guid=' . $change["guid"] . '">
                  <img src="img/aff_tick.png" width="14" height="14" alt="" />
                </a>';
                }
                $output .= '
              </div>
              <br />';
            }
            $output .= '
            </div>';
        }
    }
    //print online chars
    if ($online && $user_lvl >= $player_online) {
        //==========================$_GET and SECURE=================================
        $start = isset($_GET["start"]) ? $sql["char"]->quote_smart($_GET["start"]) : 0;
        if (!is_numeric($start)) {
            $start = 0;
        }
        $order_by = isset($_GET["order_by"]) ? $sql["char"]->quote_smart($_GET["order_by"]) : "name";
        if (!preg_match("/^[_[:lower:]]{1,12}\$/", $order_by)) {
            $order_by = "name";
        }
        $dir = isset($_GET["dir"]) ? $sql["char"]->quote_smart($_GET["dir"]) : 1;
        if (!preg_match("/^[01]{1}\$/", $dir)) {
            $dir = 1;
        }
        $order_dir = $dir ? "ASC" : "DESC";
        $dir = $dir ? 0 : 1;
        //==========================$_GET and SECURE end=============================
        if ($order_by === "mapid") {
            $order_by = "mapid, zoneid ";
            $order_hold = "mapid";
        } elseif ($order_by === "zoneid") {
            $order_by = "zoneid, mapid ";
            $order_hold = "zoneid";
        } else {
            $order_hold = $order_by;
        }
        $order_side = "";
        if (!($user_lvl || $server[$realm_id]["both_factions"])) {
            if ($core == 1) {
                $result = $sql["char"]->query("SELECT race FROM characters WHERE acct=" . $user_id . "\r\n          AND SUBSTRING_INDEX(SUBSTRING_INDEX(playedtime, ' ', 2), ' ', -1)=(SELECT MAX(SUBSTRING_INDEX(SUBSTRING_INDEX(playedtime, ' ', 2), ' ', -1)) FROM characters WHERE acct=" . $user_id . ") LIMIT 1");
            } else {
                $result = $sql["char"]->query("SELECT race FROM characters WHERE account=" . $user_id . "\r\n          AND totaltime=(SELECT MAX(totaltime) FROM characters WHERE account=" . $user_id . ") LIMIT 1");
            }
            if ($sql["char"]->num_rows($result)) {
                $order_side = in_array($sql["char"]->result($result, 0), array(2, 5, 6, 8, 10)) ? " AND race IN (2, 5, 6, 8, 10) " : " AND race IN (1, 3, 4, 7, 11) ";
            }
        }
        if ($core == 1) {
            $result = $sql["char"]->query("SELECT guid, name, race, class, zoneid, mapid, level, characters.acct, gender,\r\n                            CAST( SUBSTRING_INDEX( SUBSTRING_INDEX( data, ';', " . (PLAYER_FIELD_HONOR_CURRENCY + 1) . " ), ';', -1 ) AS UNSIGNED ) AS highest_rank, lastip\r\n                            FROM characters\r\n                              LEFT JOIN `" . $logon_db["name"] . "`.accounts ON characters.acct=`" . $logon_db["name"] . "`.accounts.acct\r\n                            WHERE characters.online=1 " . $order_side . " ORDER BY " . $order_by . " " . $order_dir . " LIMIT " . $start . ", " . $itemperpage);
        } elseif ($core == 2) {
            $result = $sql["char"]->query("SELECT guid, name, race, class, zone AS zoneid, map AS mapid, level, account AS acct, gender,\r\n                            totalHonorPoints AS highest_rank, last_ip AS lastip\r\n                            FROM characters\r\n                              LEFT JOIN `" . $logon_db["name"] . "`.account ON characters.account=`" . $logon_db["name"] . "`.account.id\r\n                            WHERE characters.online=1 " . $order_side . " ORDER BY " . $order_by . " " . $order_dir . " LIMIT " . $start . ", " . $itemperpage);
        } else {
            $result = $sql["char"]->query("SELECT characters.guid, characters.name, race, class, zone AS zoneid, map AS mapid, level, account AS acct, gender,\r\n                            totalHonorPoints AS highest_rank, latency, last_ip AS lastip, guild.name AS gname\r\n                            FROM characters\r\n                              LEFT JOIN `" . $logon_db["name"] . "`.account ON characters.account=`" . $logon_db["name"] . "`.account.id\r\n                              LEFT JOIN guild_member ON characters.guid=guild_member.guid\r\n                              LEFT JOIN guild ON guild_member.guildid=guild.guildid\r\n                            WHERE characters.online=1 " . $order_side . " ORDER BY " . $order_by . " " . $order_dir . " LIMIT " . $start . ", " . $itemperpage);
        }
        $total_online = $sql["char"]->result($sql["char"]->query("SELECT count(*) FROM characters WHERE online= 1"), 0);
        $output .= '
            <div class="div_lined center_text">
              <span class="bold">' . lang("index", "tot_users_online") . ': ' . $total_online . '</span>
            </div>';
        if ($total_online) {
            $output .= '
            <table class="lined">
              <tr>
                <td colspan="' . (9 - $showcountryflag) . '" align="right" class="hidden" style="width: 25%;">';
            $output .= generate_pagination("index.php?start_m=" . $start_m . "&amp;order_by=" . $order_hold . "&amp;dir=" . ($dir ? 0 : 1), $total_online, $itemperpage, $start);
            $output .= '
                </td>
              </tr>
              <tr>
                <th style="width: 15%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=name&amp;dir=' . $dir . '"' . ($order_by === "name" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "name") . '</a>
                </th>
                <th style="width: 1%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=race&amp;dir=' . $dir . '"' . ($order_by === "race" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "race") . '</a>
                </th>
                <th style="width: 1%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=class&amp;dir=' . $dir . '"' . ($order_by === "class" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "class") . '</a>
                </th>
                <th style="width: 5%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=level&amp;dir=' . $dir . '"' . ($order_by === "level" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "level") . '</a>
                </th>
                <th style="width: 1%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=highest_rank&amp;dir=' . $dir . '"' . ($order_by === "highest_rank" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "rank") . '</a>
                </th>
                <th style="width: 15%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=gname&amp;dir=' . $dir . '"' . ($order_by === "gname" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "guild") . '</a>
                </th>
                <th style="width: 20%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=mapid&amp;dir=' . $dir . '"' . ($order_by === "mapid, zoneid " ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "map") . '</a>
                </th>
                <th style="width: 25%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=zoneid&amp;dir=' . $dir . '"' . ($order_by === "zoneid, mapid " ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "zone") . '</a>
                </th>';
            if ($core == 1) {
                $output .= '
                <th style="width: 25%;">
                  <span>' . lang("index", "area") . '</span>
                </th>';
            }
            // this_is_junk: MaNGOS doesn't store player latency
            if ($core != 2) {
                if (!$hide_plr_latency) {
                    // this_is_junk: Trinity is the only core which can sort by Player Latency
                    if ($core == 3) {
                        $output .= '
                <th style="width: 1%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=latency&amp;dir=' . $dir . '"' . ($order_by === "latency" ? ' class="' . $order_dir . '"' : '') . '>
                    <img src="img/time.png" onmousemove="oldtoolTip(\'' . lang("index", "latency") . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()" alt=""' . ($order_by === "latency" ? '' : ' style="position: relative; top: 7px;"') . ' />
                  </a>
                </th>';
                    } else {
                        $output .= '
                <th style="width: 1%;">
                  <img src="img/time.png" onmousemove="oldtoolTip(\'' . lang("index", "latency") . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" style="position: relative; top: 7px;" />
                </th>';
                    }
                }
            }
            if ($showcountryflag) {
                require_once "libs/misc_lib.php";
                $output .= '
                <th style="width: 1%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=lastip&amp;dir=' . $dir . '"' . ($order_by === "lastip" ? ' class="' . $order_dir . '"' : '') . '>
                    <img src="img/world.png" onmousemove="oldtoolTip(\'' . lang("global", "country") . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()" alt=""' . ($order_by === "lastip" ? '' : ' style="position: relative; top: 7px;"') . ' />
                  </a>
                </th>';
            }
            $output .= '
              </tr>';
        }
        while ($char = $sql["char"]->fetch_assoc($result)) {
            if ($core == 1) {
                $ca_query = "SELECT accounts.login AS name FROM `" . $logon_db["name"] . "`.accounts LEFT JOIN `" . $corem_db["name"] . "`.config_accounts ON accounts.login=`" . $corem_db["name"] . "`.config_accounts.Login COLLATE utf8_unicode_ci WHERE acct='" . $char["acct"] . "'";
            } else {
                $ca_query = "SELECT *, username AS name FROM `" . $logon_db["name"] . "`.account LEFT JOIN `" . $corem_db["name"] . "`.config_accounts ON account.username=`" . $corem_db["name"] . "`.config_accounts.Login WHERE id='" . $char["acct"] . "'";
            }
            $ca_result = $sql["mgr"]->query($ca_query);
            $char_acct = $sql["mgr"]->fetch_assoc($ca_result);
            $gm = $char_acct["SecurityLevel"];
            if (!isset($gm)) {
                $gm = 0;
            }
            if ($core == 1) {
                $guild_id = $sql["char"]->result($sql["char"]->query("SELECT guildid FROM guild_data WHERE playerid='" . $char["guid"] . "'"), 0);
            } else {
                $guild_id = $sql["char"]->result($sql["char"]->query("SELECT guildid FROM guild_member WHERE guid='" . $char["guid"] . "'"), 0);
            }
            if ($core == 1) {
                $guild_name_query = "SELECT guildName FROM guilds WHERE guildid='" . $guild_id . "'";
            } else {
                $guild_name_query = "SELECT name AS guildName FROM guild WHERE guildid='" . $guild_id . "'";
            }
            $guild_name_result = $sql["char"]->query($guild_name_query);
            $guild_name = $sql["char"]->fetch_assoc($guild_name_result);
            $guild_name = $guild_name["guildName"];
            $output .= '
              <tr>
                <td>';
            if ($user_lvl > 0 && ($user_lvl >= gmlevel($gm) || $user_lvl == $action_permission["delete"])) {
                $output .= '
                  <a href="char.php?id=' . $char["guid"] . '">
                    <span onmousemove="oldtoolTip(\'' . htmlspecialchars($char_acct["name"]) . ' (' . id_get_gm_level($gm) . ')' . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()">' . htmlentities($char["name"], ENT_COMPAT, $site_encoding) . '</span>
                  </a>';
            } else {
                $output .= '
                  <span>' . htmlentities($char["name"], ENT_COMPAT, $site_encoding) . '</span>';
            }
            $output .= '
                </td>
                <td>
                  <img src="img/c_icons/' . $char["race"] . '-' . $char["gender"] . '.gif" onmousemove="oldtoolTip(\'' . char_get_race_name($char["race"]) . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />
                </td>
                <td>
                  <img src="img/c_icons/' . $char["class"] . '.gif" onmousemove="oldtoolTip(\'' . char_get_class_name($char["class"]) . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />
                </td>
                <td>' . char_get_level_color($char["level"]) . '</td>
                <td>
                  <span onmouseover="oldtoolTip(\'' . char_get_pvp_rank_name($char["highest_rank"], char_get_side_id($char["race"])) . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" id="index_delete_cursor"><img src="img/ranks/rank' . char_get_pvp_rank_id($char["highest_rank"], char_get_side_id($char["race"])) . '.gif" alt="" /></span>
                </td>
                <td>
                  <a href="guild.php?action=view_guild&amp;error=3&amp;id=' . $guild_id . '">' . htmlentities($guild_name, ENT_COMPAT, $site_encoding) . '</a>
                </td>
                <td>
                  <span onmousemove="oldtoolTip(\'MapID:' . $char["mapid"] . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()">' . get_map_name($char["mapid"]) . '</span>
                </td>
                <td>
                  <span onmousemove="oldtoolTip(\'ZoneID:' . $char["zoneid"] . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()">' . get_zone_name($char["zoneid"]) . '</span>
                </td>';
            // display player area, if available
            if ($core == 1) {
                for ($i = 0; $i < count($stats["plrs_area"]); $i++) {
                    if ($stats["plrs_area"][$i][0] == $char["name"]) {
                        $output .= '
                <td>
                  <span onmousemove="toolTip(\'AreaID:' . $stats["plrs_area"][$i][1] . '\', \'item_tooltip\')" onmouseout="toolTip()">' . get_zone_name($stats["plrs_area"][$i][1]) . '</span>
                </td>';
                    }
                    if (!isset($stats["plrs_lat"][$i][1])) {
                        $output .= '
                <td>-</td>';
                    }
                }
            }
            // display player latency, if enabled, and if available
            if (!$hide_plr_latency) {
                if ($core == 1) {
                    for ($i = 0; $i < count($stats["plrs_lat"]); $i++) {
                        if ($stats["plrs_lat"][$i][0] == $char["name"]) {
                            $output .= '
                <td>' . $stats["plrs_lat"][$i][1] . '</td>';
                        }
                        if (!isset($stats["plrs_lat"][$i][1])) {
                            $output .= '
                <td>-</td>';
                        }
                    }
                } else {
                    // this_is_junk: MaNGOS doesn't store player latency
                    if ($core == 3) {
                        $output .= '
                <td>' . $char["latency"] . '</td>';
                    }
                }
            }
            if ($showcountryflag) {
                $country = misc_get_country_by_ip($char["lastip"]);
                $output .= '
                <td>' . ($country["code"] ? '<img src="img/flags/' . $country["code"] . '.png" onmousemove="oldtoolTip(\'' . $country["country"] . ($user_lvl >= $action_permission["update"] ? '<br />' . $country["actualip"] : '') . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />' : '-') . '</td>';
            }
            $output .= '
              </tr>';
        }
        if ($total_online) {
            $output .= '
              <tr>';
            $output .= '
                <td colspan="' . (9 - $showcountryflag) . '" align="right" class="hidden" style="width: 25%;">';
            $output .= generate_pagination("index.php?start_m=" . $start_m . "&amp;order_by=" . $order_by . "&amp;dir=" . ($dir ? 0 : 1), $total_online, $itemperpage, $start);
            $output .= '
                </td>
              </tr>
            </table>';
        }
        $output .= '
            <br />';
        unset($total_online);
    }
}
Esempio n. 7
0
function browse_auctions()
{
    global $output, $characters_db, $world_db, $realm_id, $locales_search_option, $itemperpage, $base_datasite, $item_datasite, $server, $user_lvl, $user_id, $sql, $core;
    //wowhead_tt();
    $red = '"#DD5047"';
    $blue = '"#0097CD"';
    $sidecolor = array(1 => $blue, 2 => $red, 3 => $blue, 4 => $blue, 5 => $red, 6 => $red, 7 => $blue, 8 => $red, 10 => $red);
    $hiddencols = array(1, 8, 9, 10);
    //==========================$_GET and SECURE=================================
    $start = isset($_GET["start"]) ? $sql["char"]->quote_smart($_GET["start"]) : 0;
    if (!is_numeric($start)) {
        $start = 0;
    }
    $order_by = isset($_GET["order_by"]) ? $sql["char"]->quote_smart($_GET["order_by"]) : "time";
    if (!preg_match("/^[_[:lower:]]{1,15}\$/", $order_by)) {
        $order_by = "time";
    }
    $dir = isset($_GET["dir"]) ? $sql["char"]->quote_smart($_GET["dir"]) : 1;
    if (!preg_match("/^[01]{1}\$/", $dir)) {
        $dir = 1;
    }
    $order_dir = $dir ? "ASC" : "DESC";
    $dir = $dir ? 0 : 1;
    //==========================$_GET and SECURE end=============================
    if (!$user_lvl && !$server[$realm_id]["both_factions"]) {
        $result = $sql["char"]->query("SELECT race FROM characters\r\n      WHERE account=" . $user_id . " AND totaltime=(SELECT MAX(totaltime) FROM characters WHERE account=" . $user_id . ")\r\n      LIMIT 1");
        if ($sql["char"]->num_rows($result)) {
            $order_side = in_array($sql["char"]->result($result, 0, "race"), array(2, 5, 6, 8, 10)) ? " AND characters.race IN (2,5,6,8,10) " : " AND characters.race IN (1,3,4,7,11) ";
        } else {
            $order_side = "";
        }
    } else {
        $order_side = "";
    }
    //==========================Browse/Search CHECK==============================
    $search_by = '';
    $search_value = '';
    $search_filter = '';
    $search_class = -1;
    $search_quality = -1;
    if (isset($_GET["search_value"]) && isset($_GET["search_by"]) || isset($_GET["search_class"]) || isset($_GET["search_quality"])) {
        $search_value = $sql["char"]->quote_smart($_GET["search_value"]);
        $search_by = $sql["char"]->quote_smart($_GET["search_by"]);
        $search_class = $sql["char"]->quote_smart($_GET["search_class"]);
        $search_quality = $sql["char"]->quote_smart($_GET["search_quality"]);
        switch ($search_by) {
            case "item_name":
                if (($search_class >= 0 || $search_quality >= 0) && !isset($search_value)) {
                    if ($search_class >= 0) {
                        if ($core == 1) {
                            $search_filter = "AND items.class='" . $search_class . "'";
                        } else {
                            $search_filter = "AND item_template.class='" . $search_class . "'";
                        }
                    }
                    if ($search_quality >= 0) {
                        if ($core == 1) {
                            $search_filter = "AND items.quality='" . $search_quality . "'";
                        } else {
                            $search_filter = "AND item_template.Quality='" . $search_quality . "'";
                        }
                    }
                } else {
                    $item_prefix = "";
                    if ($search_class >= 0) {
                        if ($core == 1) {
                            $item_prefix .= "AND items.class='" . $search_class . "' ";
                        } else {
                            $item_prefix .= "AND item_template.class='" . $search_class . "' ";
                        }
                    }
                    if ($search_quality >= 0) {
                        if ($core == 1) {
                            $item_prefix .= "AND items.quality='" . $search_quality . "' ";
                        } else {
                            $item_prefix .= "AND item_template.Quality='" . $search_quality . "' ";
                        }
                    }
                    if ($core == 1) {
                        $result = $sql["char"]->query("SELECT entry FROM " . $world_db[$realm_id]['name'] . ".items WHERE name LIKE '%" . $search_value . "%' " . $item_prefix);
                    } else {
                        $result = $sql["char"]->query("SELECT entry FROM " . $world_db[$realm_id]['name'] . ".item_template WHERE name LIKE '%" . $search_value . "%' " . $item_prefix);
                    }
                    if ($core == 1) {
                        $search_filter = "AND auctions.item IN(0";
                    } elseif ($core == 2) {
                        $search_filter = "AND auction.item_template IN(0";
                    } else {
                        $search_filter = "AND item_instance.itemEntry IN(0";
                    }
                    while ($item = $sql["char"]->fetch_row($result)) {
                        $search_filter .= ", " . $item[0];
                    }
                    $search_filter .= ")";
                }
                break;
            case "item_id":
                if ($core == 1) {
                    $search_filter = "AND auctions.item='" . $search_value . "'";
                } elseif ($core == 2) {
                    $search_filter = "AND auction.item_template='" . $search_value . "'";
                } else {
                    $search_filter = "AND item_instance.itemEntry='" . $search_value . "'";
                }
                break;
            case "seller_name":
                if (($search_class >= 0 || $search_quality >= 0) && !isset($search_value)) {
                    if ($search_class >= 0) {
                        if ($core == 1) {
                            $search_filter = "AND items.class='" . $search_class . "'";
                        } else {
                            $search_filter = "AND item_template.class='" . $search_class . "'";
                        }
                    }
                    if ($search_quality >= 0) {
                        if ($core == 1) {
                            $search_filter = "AND items.quality='" . $search_quality . "'";
                        } else {
                            $search_filter = "AND item_template.Quality='" . $search_quality . "'";
                        }
                    }
                } else {
                    $item_prefix = "";
                    if ($search_class >= 0) {
                        if ($core == 1) {
                            $item_prefix .= "AND items.class='" . $search_class . "' ";
                        } else {
                            $item_prefix .= "AND item_template.class='" . $search_class . "' ";
                        }
                    }
                    if ($search_quality >= 0) {
                        if ($core == 1) {
                            $item_prefix .= "AND items.quality='" . $search_quality . "' ";
                        } else {
                            $item_prefix .= "AND item_template.Quality='" . $search_quality . "' ";
                        }
                    }
                    $result = $sql["char"]->query("SELECT guid FROM characters WHERE name LIKE '%" . $search_value . "%'");
                    $search_filter = $item_prefix;
                    if ($core == 1) {
                        $search_filter .= "AND auctions.owner IN(0";
                    } elseif ($core == 2) {
                        $search_filter .= "AND auction.itemowner IN(0";
                    } else {
                        $search_filter .= "AND auctionhouse.itemowner IN(0";
                    }
                    while ($char = $sql["char"]->fetch_row($result)) {
                        $search_filter .= ", " . $char[0];
                    }
                    $search_filter .= ")";
                    $search_filter .= $item_prefix;
                }
                break;
            case "buyer_name":
                if (($search_class >= 0 || $search_quality >= 0) && !isset($search_value)) {
                    if ($search_class >= 0) {
                        if ($core == 1) {
                            $search_filter = "AND items.class='" . $search_class . "'";
                        } else {
                            $search_filter = "AND item_template.class='" . $search_class . "'";
                        }
                    }
                    if ($search_quality >= 0) {
                        if ($core == 1) {
                            $search_filter = "AND items.quality='" . $search_quality . "'";
                        } else {
                            $search_filter = "AND item_template.Quality='" . $search_quality . "'";
                        }
                    }
                } else {
                    $item_prefix = "";
                    if ($search_class >= 0) {
                        if ($core == 1) {
                            $item_prefix .= "AND items.class='" . $search_class . "' ";
                        } else {
                            $item_prefix .= "AND item_template.class='" . $search_class . "' ";
                        }
                    }
                    if ($search_quality >= 0) {
                        if ($core == 1) {
                            $item_prefix .= "AND items.quality='" . $search_quality . "' ";
                        } else {
                            $item_prefix .= "AND item_template.Quality='" . $search_quality . "' ";
                        }
                    }
                    $result = $sql["char"]->query("SELECT guid FROM characters WHERE name LIKE '%" . $search_value . "%'");
                    $search_filter = $item_prefix;
                    if ($core == 1) {
                        $search_filter .= "AND auctions.bidder IN(-1";
                    } elseif ($core == 2) {
                        $search_filter .= "AND auction.buyguid IN(-1";
                    } else {
                        $search_filter .= "AND auctionhouse.buyguid IN(-1";
                    }
                    while ($char = $sql["char"]->fetch_row($result)) {
                        $search_filter .= ", " . $char[0];
                    }
                    $search_filter .= ")";
                }
                break;
            default:
                redirect("ahstats.php?error=1");
        }
        /*$query_1 = $sql["char"]->query("SELECT count(*)
          FROM `".$characters_db[$realm_id]['name']."`.`characters` , `".$characters_db[$realm_id]['name']."`.`item_instance` ,
          `".$world_db[$realm_id]['name']."`.`item_template` , `".$characters_db[$realm_id]['name']."`.`auctionhouse`
          LEFT JOIN `".$characters_db[$realm_id]['name']."`.`characters` c2 ON `c2`.`guid`=`auctionhouse`.`buyguid`
          WHERE `auctionhouse`.`itemowner`=`characters`.`guid` AND `auctionhouse`.`item_template`=`item_template`.`entry` AND `auctionhouse`.`itemguid`=`item_instance`.`guid`
          $search_filter $order_side");*/
        // this_is_junk: really?
        if ($core == 1) {
            $query_1 = $sql["char"]->query("SELECT COUNT(*) FROM auctions");
        } elseif ($core == 2) {
            $query_1 = $sql["char"]->query("SELECT COUNT(*) FROM auction");
        } else {
            $query_1 = $sql["char"]->query("SELECT COUNT(*) FROM auctionhouse");
        }
    } else {
        if ($core == 1) {
            $query_1 = $sql["char"]->query("SELECT COUNT(*) FROM auctions");
        } elseif ($core == 2) {
            $query_1 = $sql["char"]->query("SELECT COUNT(*) FROM auction");
        } else {
            $query_1 = $sql["char"]->query("SELECT COUNT(*) FROM auctionhouse");
        }
    }
    /*$result = $sql["char"]->query("SELECT `characters`.`name` AS `seller`, `auctionhouse`.`item_template` AS `itemid`,
      `item_template`.`name` AS `itemname`, `auctionhouse`.`buyoutprice` AS `buyout`, `auctionhouse`.`time`-unix_timestamp(),
      `c2`.`name` AS `encherisseur`, `auctionhouse`.`lastbid`, `auctionhouse`.`startbid`,
      SUBSTRING_INDEX(SUBSTRING_INDEX(`item_instance`.`data`, ' ',15), ' ',-1) AS qty, `characters`.`race` AS seller_race,
      `c2`.`race` AS buyer_race
      FROM `".$characters_db[$realm_id]['name']."`.`characters` , `".$characters_db[$realm_id]['name']."`.`item_instance` ,
      `".$world_db[$realm_id]['name']."`.`item_template` , `".$characters_db[$realm_id]['name']."`.`auctionhouse`
      LEFT JOIN `".$characters_db[$realm_id]['name']."`.`characters` c2 ON `c2`.`guid`=`auctionhouse`.`buyguid`
      WHERE `auctionhouse`.`itemowner`=`characters`.`guid` AND `auctionhouse`.`item_template`=`item_template`.`entry` AND `auctionhouse`.`itemguid`=`item_instance`.`guid`
      $search_filter
      $order_side ORDER BY `auctionhouse`.`$order_by` $order_dir LIMIT $start, $itemperpage");*/
    // Sorting special cases, everything else works as is...
    if ($core == 1) {
        switch ($order_by) {
            case "owner":
                $post_order_by = "characters.name";
                break;
            case "item":
                $post_order_by = "playeritems.entry";
                break;
            default:
                $post_order_by = $order_by;
        }
    } elseif ($core == 2) {
        switch ($order_by) {
            case "owner":
                $post_order_by = "characters.name";
                break;
            case "item":
                $post_order_by = "auction.item_template";
                break;
            case "buyout":
                $post_order_by = "auction.buyoutprice";
                break;
            case "bidder":
                $post_order_by = "auction.buyguid";
                break;
            case "bid":
                $post_order_by = "auction.lastbid";
                break;
            default:
                $post_order_by = $order_by;
        }
    } else {
        switch ($order_by) {
            case "owner":
                $post_order_by = "characters.name";
                break;
            case "item":
                $post_order_by = "item_instance.itemEntry";
                break;
            case "buyout":
                $post_order_by = "auctionhouse.buyoutprice";
                break;
            case "bidder":
                $post_order_by = "auctionhouse.buyguid";
                break;
            case "bid":
                $post_order_by = "auctionhouse.lastbid";
                break;
            default:
                $post_order_by = $order_by;
        }
    }
    if ($core == 1) {
        // this_is_junk: the guid in auction is stored raw, so we have to subtract 4611686018427387904 to get the matching guid stored in playeritems :/
        $query = "SELECT characters.name AS owner_name, owner, playeritems.entry AS item_entry,\r\n      item-4611686018427387904 AS item, buyout, time, UNIX_TIMESTAMP() AS now, bidder, bid\r\n      FROM auctions\r\n        LEFT JOIN characters ON auctions.owner=characters.guid\r\n        LEFT JOIN playeritems ON auctions.item-4611686018427387904=playeritems.guid\r\n        LEFT JOIN " . $world_db[$realm_id]['name'] . ".items ON " . $world_db[$realm_id]['name'] . ".items.entry=playeritems.entry\r\n      " . $seach_filter . " " . $order_side . " ORDER BY " . $post_order_by . " " . $order_dir . " LIMIT " . $start . ", " . $itemperpage;
    } elseif ($core == 2) {
        $query = "SELECT characters.name AS owner_name, auction.item_template AS item_entry,\r\n      auction.itemowner AS owner, item_template.name AS itemname, itemguid AS item,\r\n      auction.buyoutprice AS buyout, auction.time AS time, UNIX_TIMESTAMP() AS now,\r\n      c2.name AS bidder_name, auction.buyguid AS bidder, auction.lastbid AS bid, auction.startbid,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(item_instance.data, ' ',15), ' ',-1) AS qty,\r\n      characters.race AS seller_race, c2.race AS buyer_race\r\n      FROM characters, item_instance, " . $world_db[$realm_id]['name'] . ".item_template, auction\r\n        LEFT JOIN characters c2 ON c2.guid=auction.buyguid\r\n      WHERE auction.itemowner=characters.guid\r\n        AND auction.item_template=item_template.entry\r\n        AND auction.itemguid=item_instance.guid\r\n      " . $search_filter . " " . $order_side . " ORDER BY " . $post_order_by . " " . $order_dir . " LIMIT " . $start . ", " . $itemperpage;
    } else {
        $query = "SELECT characters.name AS owner_name, item_instance.itemEntry AS item_entry,\r\n      auctionhouse.itemowner AS owner, item_template.name AS itemname, itemguid AS item,\r\n      auctionhouse.buyoutprice AS buyout, auctionhouse.time AS time, UNIX_TIMESTAMP() AS now,\r\n      c2.name AS bidder_name, auctionhouse.buyguid AS bidder, auctionhouse.lastbid AS bid, auctionhouse.startbid,\r\n      item_instance.count AS qty,\r\n      characters.race AS seller_race, c2.race AS buyer_race\r\n      FROM characters, item_instance, " . $world_db[$realm_id]['name'] . ".item_template, auctionhouse\r\n        LEFT JOIN characters c2 ON c2.guid=auctionhouse.buyguid\r\n      WHERE auctionhouse.itemowner=characters.guid\r\n        AND item_instance.itemEntry=item_template.entry\r\n        AND auctionhouse.itemguid=item_instance.guid\r\n      " . $search_filter . " " . $order_side . " ORDER BY " . $post_order_by . " " . $order_dir . " LIMIT " . $start . ", " . $itemperpage;
    }
    $result = $sql["char"]->query($query);
    $all_record = $sql["char"]->result($query_1, 0);
    // give ourselves a little less XSS
    $search_value = htmlspecialchars($search_value);
    $search_by = htmlspecialchars($search_by);
    $search_class = htmlspecialchars($search_class);
    $search_quality = htmlspecialchars($search_quality);
    //=====================top tage navigaion starts here========================
    $output .= '
          <table class="top_hidden">
            <tr>
              <td style="width: 80%;">
                <form action="ahstats.php" method="get" id="form">
                  <div class="no_display">
                    <input type="hidden" name="error" value="2" />
                  </div>
                  <table class="hidden">
                    <tr>
                      <td>
                        <input type="text" size="24" name="search_value" value="' . $search_value . '" />
                      </td>
                      <td>
                        <select name="search_by">
                          <option' . ($search_by == "item_name" ? ' selected="selected"' : '') . ' value="item_name">' . lang("auctionhouse", "item_name") . '</option>
                          <option' . ($search_by == "item_id" ? ' selected="selected"' : '') . ' value="item_id">' . lang("auctionhouse", "item_id") . '</option>
                          <option' . ($search_by == "seller_name" ? ' selected="selected"' : '') . ' value="seller_name">' . lang("auctionhouse", "seller_name") . '</option>
                          <option' . ($search_by == "buyer_name" ? ' selected="selected"' : '') . ' value="buyer_name">' . lang("auctionhouse", "buyer_name") . '</option>
                        </select>
                      </td>
                      <td>
                        <select name="search_class">
                          <option' . ($search_class == -1 ? ' selected="selected"' : '') . ' value="-1">' . lang("auctionhouse", "all") . '</option>
                          <option' . ($search_class == 0 ? ' selected="selected"' : '') . ' value="0">' . lang("item", "consumable") . '</option>
                          <option' . ($search_class == 1 ? ' selected="selected"' : '') . ' value="1">' . lang("item", "bag") . '</option>
                          <option' . ($search_class == 2 ? ' selected="selected"' : '') . ' value="2">' . lang("item", "weapon") . '</option>
                          <option' . ($search_class == 4 ? ' selected="selected"' : '') . ' value="4">' . lang("item", "armor") . '</option>
                          <option' . ($search_class == 5 ? ' selected="selected"' : '') . ' value="5">' . lang("item", "reagent") . '</option>
                          <option' . ($search_class == 7 ? ' selected="selected"' : '') . ' value="7">' . lang("item", "trade_goods") . '</option>
                          <option' . ($search_class == 9 ? ' selected="selected"' : '') . ' value="9">' . lang("item", "recipe") . '</option>
                          <option' . ($search_class == 11 ? ' selected="selected"' : '') . ' value="11">' . lang("item", "quiver") . '</option>
                          <option' . ($search_class == 14 ? ' selected="selected"' : '') . ' value="14">' . lang("item", "permanent") . '</option>
                          <option' . ($search_class == 15 ? ' selected="selected"' : '') . ' value="15">' . lang("item", "misc_short") . '</option>
                        </select>
                      </td>
                      <td>
                        <select name="search_quality">
                          <option' . ($search_quality == -1 ? ' selected="selected"' : '') . ' value="-1">' . lang("auctionhouse", "all") . '</option>
                          <option' . ($search_quality == 0 ? ' selected="selected"' : '') . ' value="0">' . lang("item", "poor") . '</option>
                          <option' . ($search_quality == 1 ? ' selected="selected"' : '') . ' value="1">' . lang("item", "common") . '</option>
                          <option' . ($search_quality == 2 ? ' selected="selected"' : '') . ' value="2">' . lang("item", "uncommon") . '</option>
                          <option' . ($search_quality == 3 ? ' selected="selected"' : '') . ' value="3">' . lang("item", "rare") . '</option>
                          <option' . ($search_quality == 4 ? ' selected="selected"' : '') . ' value="4">' . lang("item", "epic") . '</option>
                          <option' . ($search_quality == 5 ? ' selected="selected"' : '') . ' value="5">' . lang("item", "legendary") . '</option>
                          <option' . ($search_quality == 6 ? ' selected="selected"' : '') . ' value="6">' . lang("item", "artifact") . '</option>
                        </select>
                      </td>
                      <td>';
    makebutton(lang("global", "search"), "javascript:do_submit()", 80);
    $output .= '
                      </td>
                      <td>';
    $search_by && $search_value || $search_class != -1 || $search_quality != -1 ? makebutton(lang("global", "back"), "javascript:window.history.back()", 80) : ($output .= "");
    $output .= '
                      </td>
                    </tr>
                  </table>
                </form>
              </td>
              <td style="width: 25%; text-align: right;">';
    $output .= generate_pagination("ahstats.php?order_by=" . $order_by . ($search_by && $search_value || $search_class != -1 || $search_quality != -1 ? "&amp;search_by=" . $search_by . "&amp;search_value=" . $search_value . "&amp;search_quality=" . $search_quality . "&amp;search_class=" . $search_class . "&amp;error=2" : "") . "&amp;dir=" . ($dir ? 0 : 1), $all_record, $itemperpage, $start);
    $output .= '
              </td>
            </tr>
          </table>
          <table class="lined">
            <tr>
              <th style="width: 10%;"><a href="ahstats.php?order_by=owner&amp;start=' . $start . ($search_by && $search_value || $search_class != -1 || $search_quality != -1 ? '&amp;search_by=' . $search_by . '&amp;search_value=' . $search_value . '&amp;search_quality=' . $search_quality . '&amp;search_class=' . $search_class . '&amp;error=2' : '') . '&amp;dir=' . $dir . '">' . ($order_by == 'owner' ? '<img src="img/arr_' . ($dir ? 'dw' : 'up') . '.gif" alt="" /> ' : '') . lang("auctionhouse", "seller") . '</a></th>
              <th style="width: 20%;" colspan="2"><a href="ahstats.php?order_by=item&amp;start=' . $start . ($search_by && $search_value || $search_class != -1 || $search_quality != -1 ? '&amp;search_by=' . $search_by . '&amp;search_value=' . $search_value . '&amp;search_quality=' . $search_quality . '&amp;search_class=' . $search_class . '&amp;error=2' : '') . '&amp;dir=' . $dir . '">' . ($order_by == 'item' ? '<img src="img/arr_' . ($dir ? 'dw' : 'up') . '.gif" alt="" /> ' : '') . lang("auctionhouse", "item") . '</a></th>
              <th style="width: 15%;"><a href="ahstats.php?order_by=buyout&amp;start=' . $start . ($search_by && $search_value || $search_class != -1 || $search_quality != -1 ? '&amp;search_by=' . $search_by . '&amp;search_value=' . $search_value . '&amp;search_quality=' . $search_quality . '&amp;search_class=' . $search_class . '&amp;error=2' : '') . '&amp;dir=' . $dir . '">' . ($order_by == 'buyout' ? '<img src="img/arr_' . ($dir ? 'dw' : 'up') . '.gif" alt="" /> ' : '') . lang("auctionhouse", "buyoutprice") . '</a></th>
              <th style="width: 15%;"><a href="ahstats.php?order_by=time-unix_timestamp()&amp;start=' . $start . ($search_by && $search_value || $search_class != -1 || $search_quality != -1 ? '&amp;search_by=' . $search_by . '&amp;search_value=' . $search_value . '&amp;search_quality=' . $search_quality . '&amp;search_class=' . $search_class . '&amp;error=2' : '') . '&amp;dir=' . $dir . '">' . ($order_by == 'time' ? '<img src="img/arr_' . ($dir ? 'dw' : 'up') . '.gif" alt="" /> ' : '') . lang("auctionhouse", "timeleft") . '</a></th>
              <th style="width: 10%;"><a href="ahstats.php?order_by=bidder&amp;start=' . $start . ($search_by && $search_value || $search_class != -1 || $search_quality != -1 ? '&amp;search_by=' . $search_by . '&amp;search_value=' . $search_value . '&amp;search_quality=' . $search_quality . '&amp;search_class=' . $search_class . '&amp;error=2' : '') . '&amp;dir=' . $dir . '">' . ($order_by == 'bidder' ? '<img src="img/arr_' . ($dir ? 'dw' : 'up') . '.gif" alt="" /> ' : '') . lang("auctionhouse", "buyer") . '</a></th>
              <th style="width: 15%;"><a href="ahstats.php?order_by=bid&amp;start=' . $start . ($search_by && $search_value || $search_class != -1 || $search_quality != -1 ? '&amp;search_by=' . $search_by . '&amp;search_value=' . $search_value . '&amp;search_quality=' . $search_quality . '&amp;search_class=' . $search_class . '&amp;error=2' : '') . '&amp;dir=' . $dir . '">' . ($order_by == 'bid' ? '<img src="img/arr_' . ($dir ? 'dw' : 'up') . '.gif" alt="" /> ' : '') . lang("auctionhouse", "lastbid") . '</a></th>
            </tr>';
    while ($rows = $sql["char"]->fetch_assoc($result)) {
        // get item info
        if ($core == 1) {
            $i_query = "SELECT name1 AS name, quality AS Quality, inventorytype AS InventoryType, \r\n            socket_color_1 AS socketColor_1, socket_color_2 AS socketColor_2, socket_color_3 AS socketColor_3,\r\n            requiredlevel AS RequiredLevel, allowableclass AS AllowableClass,\r\n            sellprice AS SellPrice, itemlevel AS ItemLevel,\r\n            creator, enchantments AS enchantment, randomprop AS property, count, durability, flags\r\n            FROM items\r\n              LEFT JOIN playeritems ON playeritems.guid=" . $rows["item"] . " " . ($locales_search_option != 0 ? "LEFT JOIN items_localized ON (items_localized.entry=items.entry AND language_code='" . $locales_search_option . "') " : " ") . "WHERE items.entry=" . $rows["item_entry"];
        } elseif ($core == 2) {
            $i_query = "SELECT *, \r\n            SUBSTRING_INDEX(SUBSTRING_INDEX(`" . $characters_db[$realm_id]["name"] . "`.item_instance.data, ' ', 11), ' ', -1) AS creator,\r\n            SUBSTRING_INDEX(SUBSTRING_INDEX(`" . $characters_db[$realm_id]["name"] . "`.item_instance.data, ' ', 23), ' ', -1) AS enchantment, \r\n            SUBSTRING_INDEX(SUBSTRING_INDEX(`" . $characters_db[$realm_id]["name"] . "`.item_instance.data, ' ', 60), ' ', -1) AS property, \r\n            SUBSTRING_INDEX(SUBSTRING_INDEX(`" . $characters_db[$realm_id]["name"] . "`.item_instance.data, ' ', 15), ' ', -1) AS count,\r\n            SUBSTRING_INDEX(SUBSTRING_INDEX(`" . $characters_db[$realm_id]["name"] . "`.item_instance.data, ' ', 62), ' ', -1) AS durability,\r\n            SUBSTRING_INDEX(SUBSTRING_INDEX(`" . $characters_db[$realm_id]["name"] . "`.item_instance.data, ' ', 22), ' ', -1) AS flags\r\n            FROM item_template\r\n              LEFT JOIN `" . $characters_db[$realm_id]["name"] . "`.character_inventory ON character_inventory.item=" . $rows["item"] . "\r\n              LEFT JOIN `" . $characters_db[$realm_id]["name"] . "`.item_instance ON item_instance.guid=" . $rows["item"] . " " . ($locales_search_option != 0 ? "LEFT JOIN locales_item ON locales_item.entry=item_template.entry " : " ") . "WHERE item_template.entry=" . $rows["item_entry"];
        } else {
            $i_query = "SELECT *, \r\n            creatorGuid AS creator,\r\n            enchantments AS enchantment, \r\n            randomPropertyId AS property, \r\n            count, durability, `" . $characters_db[$realm_id]["name"] . "`.item_instance.flags AS flags\r\n            FROM item_template\r\n              LEFT JOIN `" . $characters_db[$realm_id]["name"] . "`.character_inventory ON character_inventory.item=" . $rows["item"] . "\r\n              LEFT JOIN `" . $characters_db[$realm_id]["name"] . "`.item_instance ON item_instance.guid=" . $rows["item"] . " " . ($locales_search_option != 0 ? "LEFT JOIN locales_item ON locales_item.entry=item_template.entry " : " ") . "WHERE item_template.entry=" . $rows["item_entry"];
        }
        $i_result = $sql["world"]->query($i_query);
        $item_result = $sql["world"]->fetch_assoc($i_result);
        // Localization
        if ($locales_search_option != 0) {
            if ($core == 1) {
                $item_result["name"] = $item_result["name"];
            } else {
                $item_result["name"] = $item_result["name_loc" . $locales_search_option];
            }
        } else {
            $item_result["name"] = $item_result["name"];
        }
        // calculate the buyout value
        $value = $rows["buyout"];
        $g = floor($value / 10000);
        $value -= $g * 10000;
        $s = floor($value / 100);
        $value -= $s * 100;
        $c = $value;
        $buyout = $g . '<img src="./img/gold.gif" alt="" style="position: relative; bottom: -6px;" /> ' . $s . '<img src="./img/silver.gif" alt="" style="position: relative; bottom: -6px;" /> ' . $c . '<img src="./img/copper.gif" alt="" style="position: relative; bottom: -6px;" /> ';
        // calculate the remaining time
        $tot_time = $rows["time"] - $rows["now"];
        $total_days = (int) ($tot_time / 86400);
        $tot_time = $tot_time - $tot_days * 86400;
        $total_hours = (int) ($tot_time / 3600);
        $tot_time = $tot_time - $total_hours * 3600;
        $total_min = (int) ($tot_time / 60);
        // get bidder name
        $bidder_result = $sql["char"]->result($sql["char"]->query("SELECT name FROM characters WHERE guid = '" . $rows["bidder"] . "'"), 0);
        // calculate the last bid value
        $value = $rows["bid"];
        $g = floor($value / 10000);
        $value -= $g * 10000;
        $s = floor($value / 100);
        $value -= $s * 100;
        $c = $value;
        $bid = $g . '<img src="./img/gold.gif" alt="" /> ' . $s . '<img src="./img/silver.gif" alt="" /> ' . $c . '<img src="./img/copper.gif" alt="" /> ';
        $output .= '
            <tr>
              <td class="center-text">
                <a href="./char.php?id=' . $rows["owner"] . '">' . $rows["owner_name"] . '</a>
              </td>
              <td>';
        $item_icon = get_item_icon($rows["item_entry"]);
        $item_border = get_item_border($rows["item_entry"]);
        $output .= '
                <a href="' . $base_datasite . $item_datasite . $rows["item_entry"] . '" rel="external" onmouseover="ShowTooltip(this,\'_' . $rows["item"] . '\');" onmouseout="HideTooltip(\'_' . $rows["item"] . '\');">
                  <img src="' . $item_icon . '" class="' . $item_border . '" alt="" />
                </a>';
        $output .= '
                <div class="item_tooltip" id="tooltip_' . $rows["item"] . '">
                  <table>
                    <tr>
                      <td>
                        ' . get_item_tooltip($item_result, $item_result['enchantment'], $item_result['property'], $item_result['creator'], $item_result['durability'], $item_result['flags']) . '
                      </td>
                    </tr>
                  </table>
                </div>';
        $output .= '
              </td>
              <td class="center-text">
                <a href="' . $base_datasite . $item_datasite . $rows["item_entry"] . '" rel="external" onmouseover="ShowTooltip(this,\'_' . $rows["item"] . '\');" onmouseout="HideTooltip(\'_' . $rows["item"] . '\');" style="color:' . get_item_quality_color($item_result["Quality"]) . '">' . $item_result["name"] . '</a>
              </td>
              <td class="center-text">
                ' . $buyout . '
              </td>
              <td class="center-text">';
        if ($rows["time"] > $rows["now"]) {
            $output .= ($total_days != 0 ? $total_days . ' days, ' : '') . ($total_hours != 0 ? $total_hours . ' hours, ' : '') . ($total_min != 0 ? $total_min . ' minutes' : '');
        } else {
            $output .= lang("auctionhouse", "auction_over");
        }
        $output .= '
              </td>
              <td class="center-text">
                <a href="./char.php?id=' . $rows["bidder"] . '">' . $bidder_result . '</a>
              </td>
              <td class="center-text">
                ' . ($bidder_result != '' ? $bid : '') . '
              </td>
            </tr>';
    }
    $output .= '
            <tr>
              <td colspan="7" class="hidden" style="width: 25%; text-align: right;">';
    $output .= generate_pagination("ahstats.php?order_by=" . $order_by . ($search_by && $search_value || $search_class != -1 || $search_quality != -1 ? "&amp;search_by=" . $search_by . "&amp;search_value=" . $search_value . "&amp;search_quality=" . $search_quality . "&amp;search_class=" . $search_class . "&amp;error=2" : "") . "&amp;dir=" . ($dir ? 0 : 1), $all_record, $itemperpage, $start);
    $output .= '
              </td>
            </tr>
            <tr>
              <td colspan="7" class="hidden" style="text-align: right;">' . lang("auctionhouse", "total_auctions") . ' : ' . $all_record . '
              </td>
            </tr>
          </table>';
}
Esempio n. 8
0
 $EQU_BELT = $char_data[CHAR_DATA_OFFSET_EQU_BELT];
 $EQU_LEGS = $char_data[CHAR_DATA_OFFSET_EQU_LEGS];
 $EQU_FEET = $char_data[CHAR_DATA_OFFSET_EQU_FEET];
 $EQU_WRIST = $char_data[CHAR_DATA_OFFSET_EQU_WRIST];
 $EQU_GLOVES = $char_data[CHAR_DATA_OFFSET_EQU_GLOVES];
 $EQU_FINGER1 = $char_data[CHAR_DATA_OFFSET_EQU_FINGER1];
 $EQU_FINGER2 = $char_data[CHAR_DATA_OFFSET_EQU_FINGER2];
 $EQU_TRINKET1 = $char_data[CHAR_DATA_OFFSET_EQU_TRINKET1];
 $EQU_TRINKET2 = $char_data[CHAR_DATA_OFFSET_EQU_TRINKET2];
 $EQU_BACK = $char_data[CHAR_DATA_OFFSET_EQU_BACK];
 $EQU_MAIN_HAND = $char_data[CHAR_DATA_OFFSET_EQU_MAIN_HAND];
 $EQU_OFF_HAND = $char_data[CHAR_DATA_OFFSET_EQU_OFF_HAND];
 $EQU_RANGED = $char_data[CHAR_DATA_OFFSET_EQU_RANGED];
 $EQU_TABARD = $char_data[CHAR_DATA_OFFSET_EQU_TABARD];
 $EQU_PROJECT = $char_data[CHAR_DATA_OFFSET_EQU_PROJECT];
 $equiped_items = array(1 => array($EQU_HEAD ? get_item_tooltip($EQU_HEAD) : 0, $EQU_HEAD ? get_icon($EQU_HEAD) : 0, $EQU_HEAD ? get_item_border($EQU_HEAD) : 0), 2 => array($EQU_NECK ? get_item_tooltip($EQU_NECK) : 0, $EQU_NECK ? get_icon($EQU_NECK) : 0, $EQU_NECK ? get_item_border($EQU_NECK) : 0), 3 => array($EQU_SHOULDER ? get_item_tooltip($EQU_SHOULDER) : 0, $EQU_SHOULDER ? get_icon($EQU_SHOULDER) : 0, $EQU_SHOULDER ? get_item_border($EQU_SHOULDER) : 0), 4 => array($EQU_SHIRT ? get_item_tooltip($EQU_SHIRT) : 0, $EQU_SHIRT ? get_icon($EQU_SHIRT) : 0, $EQU_SHIRT ? get_item_border($EQU_SHIRT) : 0), 5 => array($EQU_CHEST ? get_item_tooltip($EQU_CHEST) : 0, $EQU_CHEST ? get_icon($EQU_CHEST) : 0, $EQU_CHEST ? get_item_border($EQU_CHEST) : 0), 6 => array($EQU_BELT ? get_item_tooltip($EQU_BELT) : 0, $EQU_BELT ? get_icon($EQU_BELT) : 0, $EQU_BELT ? get_item_border($EQU_BELT) : 0), 7 => array($EQU_LEGS ? get_item_tooltip($EQU_LEGS) : 0, $EQU_LEGS ? get_icon($EQU_LEGS) : 0, $EQU_LEGS ? get_item_border($EQU_LEGS) : 0), 8 => array($EQU_FEET ? get_item_tooltip($EQU_FEET) : 0, $EQU_FEET ? get_icon($EQU_FEET) : 0, $EQU_FEET ? get_item_border($EQU_FEET) : 0), 9 => array($EQU_WRIST ? get_item_tooltip($EQU_WRIST) : 0, $EQU_WRIST ? get_icon($EQU_WRIST) : 0, $EQU_WRIST ? get_item_border($EQU_WRIST) : 0), 10 => array($EQU_GLOVES ? get_item_tooltip($EQU_GLOVES) : 0, $EQU_GLOVES ? get_icon($EQU_GLOVES) : 0, $EQU_GLOVES ? get_item_border($EQU_GLOVES) : 0), 11 => array($EQU_FINGER1 ? get_item_tooltip($EQU_FINGER1) : 0, $EQU_FINGER1 ? get_icon($EQU_FINGER1) : 0, $EQU_FINGER1 ? get_item_border($EQU_FINGER1) : 0), 12 => array($EQU_FINGER2 ? get_item_tooltip($EQU_FINGER2) : 0, $EQU_FINGER2 ? get_icon($EQU_FINGER2) : 0, $EQU_FINGER2 ? get_item_border($EQU_FINGER2) : 0), 13 => array($EQU_TRINKET1 ? get_item_tooltip($EQU_TRINKET1) : 0, $EQU_TRINKET1 ? get_icon($EQU_TRINKET1) : 0, $EQU_TRINKET1 ? get_item_border($EQU_TRINKET1) : 0), 14 => array($EQU_TRINKET2 ? get_item_tooltip($EQU_TRINKET2) : 0, $EQU_TRINKET2 ? get_icon($EQU_TRINKET2) : 0, $EQU_TRINKET2 ? get_item_border($EQU_TRINKET2) : 0), 15 => array($EQU_BACK ? get_item_tooltip($EQU_BACK) : 0, $EQU_BACK ? get_icon($EQU_BACK) : 0, $EQU_BACK ? get_item_border($EQU_BACK) : 0), 16 => array($EQU_MAIN_HAND ? get_item_tooltip($EQU_MAIN_HAND) : 0, $EQU_MAIN_HAND ? get_icon($EQU_MAIN_HAND) : 0, $EQU_MAIN_HAND ? get_item_border($EQU_MAIN_HAND) : 0), 17 => array($EQU_OFF_HAND ? get_item_tooltip($EQU_OFF_HAND) : 0, $EQU_OFF_HAND ? get_icon($EQU_OFF_HAND) : 0, $EQU_OFF_HAND ? get_item_border($EQU_OFF_HAND) : 0), 18 => array($EQU_RANGED ? get_item_tooltip($EQU_RANGED) : 0, $EQU_RANGED ? get_icon($EQU_RANGED) : 0, $EQU_RANGED ? get_item_border($EQU_RANGED) : 0), 19 => array($EQU_TABARD ? get_item_tooltip($EQU_TABARD) : 0, $EQU_TABARD ? get_icon($EQU_TABARD) : 0, $EQU_TABARD ? get_item_border($EQU_TABARD) : 0), 20 => array($EQU_PROJECT ? get_item_tooltip($EQU_PROJECT) : 0, $EQU_PROJECT ? get_icon($EQU_PROJECT) : 0, $EQU_PROJECT ? get_item_border($EQU_PROJECT) : 0));
 // Talents
 mysql_connect($characters[$royaume]['host'], $characters[$royaume]['user'], $characters[$royaume]['password']) or die(mysql_error());
 mysql_select_db($characters[$royaume]['db']) or die(mysql_error());
 $arbreTalent = array(0, 0, 0);
 $ids = array(0, 0, 0);
 $spellQuery = mysql_query("SELECT * FROM `character_spell` WHERE `guid`='{$guid}'") or die(mysql_error());
 mysql_close();
 mysql_connect($coolwow['host'], $coolwow['user'], $coolwow['password']) or die(mysql_error());
 mysql_select_db($coolwow['db']) or die(mysql_error());
 while ($spellData = mysql_fetch_array($spellQuery)) {
     $spellId = $spellData['spell'];
     if ($talentInfo = getTalentInfo($spellId)) {
         $tree = $talentInfo['ref_tab'];
         $talentQuery = mysql_query("SELECT * FROM `talenttab` WHERE `id`='{$tree}'") or die(mysql_error());
         $talentData = mysql_fetch_array($talentQuery);