function char_pets()
{
    global $output, $realm_id, $characters_db, $arcm_db, $action_permission, $user_lvl, $user_name, $site_encoding, $base_datasite, $spell_datasite, $pet_ability, $sql, $core;
    //wowhead_tt();
    if (empty($_GET["id"])) {
        error(lang("global", "empty_fields"));
    }
    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;
        }
    }
    $id = $sql["char"]->quote_smart($_GET["id"]);
    if (!is_numeric($id)) {
        $id = 0;
    }
    if ($core == 1) {
        $result = $sql["char"]->query("SELECT acct, name, race, class, level, gender\n      FROM characters\n      WHERE guid='" . $id . "' LIMIT 1");
    } else {
        $result = $sql["char"]->query("SELECT account AS acct, name, race, class, level, gender\n      FROM characters\n      WHERE guid='" . $id . "' LIMIT 1");
    }
    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) {
            $result = $sql["logon"]->query("SELECT login FROM accounts WHERE acct='" . $char["acct"] . "'");
        } else {
            $result = $sql["logon"]->query("SELECT username AS login FROM account WHERE id='" . $char["acct"] . "'");
        }
        $owner_name = $sql["logon"]->result($result, 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_Pets"];
        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_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_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;
            }
        }
        if ($view_override || $user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
            $output .= '
          <center>
            <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>
            <div class="tab_content">
              <div class="tab">
                <ul>
                  <li><a href="char.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "char_sheet") . '</a></li>';
            $output .= '
                  <li class="selected"><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>
              <div class="tab_content2">
              <font 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"]) . '
              </font>
              <br />
              <br />';
            if ($core == 1) {
                $result = $sql["char"]->query("SELECT petnumber, level, fields,\n          SUBSTRING_INDEX(SUBSTRING_INDEX(`fields`, ' ', 77), ' ', -1) AS cur_xp,\n          SUBSTRING_INDEX(SUBSTRING_INDEX(`fields`, ' ', 78), ' ', -1) AS next_level_xp,\n          name, happinessupdate\n          FROM playerpets\n          WHERE ownerguid='" . $id . "'");
            } else {
                $result = $sql["char"]->query("SELECT id AS petnumber, level, abdata AS fields,\n          exp AS cur_xp,\n          SUBSTRING_INDEX(SUBSTRING_INDEX(`abdata`, ' ', 78), ' ', -1) AS next_level_xp,\n          name, curhappiness AS happinessupdate\n          FROM character_pet \n          WHERE owner='" . $id . "'");
            }
            if ($sql["char"]->num_rows($result)) {
                while ($pet = $sql["char"]->fetch_assoc($result)) {
                    $pet_data = explode(' ', $pet["fields"]);
                    $happiness = floor($pet_data[UNIT_FIELD_MAXPOWER3] / 333000);
                    if ($happiness == 1) {
                        $hap_text = 'Content';
                        $hap_val = 1;
                    } elseif ($happiness == 2) {
                        $hap_text = 'Happy';
                        $hap_val = 2;
                    } else {
                        $hap_text = 'Unhappy';
                        $hap_val = 0;
                    }
                    if ($core == 1) {
                        $pet_next_lvl_xp = $pet["next_level_xp"];
                    } else {
                        $pet_next_lvl_xp = floor(char_get_xp_to_level($pet["level"]) / 4);
                    }
                    // this_is_junk: style left hardcoded because it's calculated.
                    $output .= '
                <font class="bold">' . $pet["name"] . ' - lvl ' . char_get_level_color($pet["level"]) . '
                  <a class="ch_pet_padding" onmouseover="oldtoolTip(\'' . $hap_text . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()"><img src="img/pet/happiness_' . $hap_val . '.jpg" alt="" /></a>
                  <br /><br />
                </font>
                <table class="lined" id="ch_pet_xp">
                  <tr>
                    <td align="right">Exp:</td>
                    <td valign="top" class="bar skill_bar" style="background-position: ' . (round(385 * $pet["cur_xp"] / $pet_next_lvl_xp) - 385) . 'px;">
                      <span>' . $pet["cur_xp"] . '/' . $pet_next_lvl_xp . '</span>
                    </td>
                  </tr>
                  <tr>
                    <td align="right">Pet Abilities:</td>
                    <td align="left">';
                    if ($core == 1) {
                        $ability_results = $sql["char"]->query("SELECT spellid FROM playerpetspells WHERE petnumber='" . $pet["petnumber"] . "' AND flags > 1");
                    } else {
                        $ability_results = $sql["char"]->query("SELECT spell AS spellid FROM pet_spell WHERE guid='" . $pet["petnumber"] . "' AND active > 1");
                    }
                    // active = 0 is unused and active = 1 probably some passive auras, i dont know diference between values 129 and 193, need to check mangos source
                    if ($sql["char"]->num_rows($ability_results)) {
                        while ($ability = $sql["char"]->fetch_assoc($ability_results)) {
                            $output .= '
                      <a class="ch_pet_padding" href="' . $base_datasite . $spell_datasite . $ability["spellid"] . '" target="_blank">
                        <img src="' . spell_get_icon($ability["spellid"]) . '" alt="' . $ability["spellid"] . '" class="icon_border_0" />
                      </a>';
                        }
                    }
                    $output .= '
                    </td>
                  </tr>
                </table>
                <br /><br />';
                }
                unset($ability_results);
                unset($pet_next_lvl_xp);
                unset($happiness);
                unset($pet);
            }
            $output .= '
              </div>
            </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>';
            // 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>';
            }
            // 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 />
          </center>
          <!-- end of char_pets.php -->';
        } else {
            error(lang("char", "no_permission"));
        }
    } else {
        error(lang("char", "no_char_found"));
    }
}
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"));
    }
}
Exemplo n.º 3
0
function char_rep()
{
    global $output, $realm_id, $characters_db, $logon_db, $corem_db, $action_permission, $site_encoding, $user_lvl, $user_name, $sql, $core;
    require_once 'libs/fact_lib.php';
    $reputation_rank = fact_get_reputation_rank_arr();
    $reputation_rank_length = fact_get_reputation_rank_length();
    if (empty($_GET["id"])) {
        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;
        }
    }
    $id = $sql["char"]->quote_smart($_GET["id"]);
    if (!is_numeric($id)) {
        $id = 0;
    }
    if ($core == 1) {
        $result = $sql["char"]->query("SELECT acct, name, race, class, level, gender FROM characters WHERE guid='" . $id . "' LIMIT 1");
    } else {
        $result = $sql["char"]->query("SELECT account AS acct, name, race, class, level, gender FROM characters WHERE guid='" . $id . "' LIMIT 1");
    }
    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) {
            $result = $sql["logon"]->query("SELECT login FROM accounts WHERE acct='" . $char["acct"] . "'");
        } else {
            $result = $sql["logon"]->query("SELECT username AS login FROM account WHERE id='" . $char["acct"] . "'");
        }
        $owner_name = $sql["logon"]->result($result, 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_Rep"];
        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_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_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;
            }
        }
        if ($view_override || $user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
            if ($core == 1) {
                $result = $sql["char"]->query("SELECT faction, standing FROM playerreputations WHERE guid='" . $id . "'");
                $factions = array();
                $faction_ranks = array();
                while ($fact = $sql["char"]->fetch_assoc($result)) {
                    array_push($factions, $fact["faction"]);
                    array_push($faction_ranks, $fact["standing"]);
                }
                /*$result = $result["reputation"];
                  $result = substr($result, 0, strlen($result) - 1);
                  $result = explode(",", $result);
                  $factions = array();
                  $faction_ranks = array();
                  $pick = 0;
                  foreach ( $result as $t )
                  {
                    switch ( $pick )
                    {
                      case 0:
                      {
                        array_push($factions, $t);
                        $pick = 1;
                        break;
                      }
                      case 1:
                      {
                        // we skip this one
                        $pick = 2;
                        break;
                      }
                      case 2:
                      {
                        // we skip this one
                        $pick = 3;
                        break;
                      }
                      case 3:
                      {
                        array_push($faction_ranks, $t);
                        $pick = 0;
                        break;
                      }
                    }
                  }*/
            } else {
                $result = $sql["char"]->query("SELECT faction, standing FROM character_reputation WHERE guid='" . $id . "' AND (flags & 1 = 1)");
                $factions = array();
                $faction_ranks = array();
                while ($fact = $sql["char"]->fetch_assoc($result)) {
                    array_push($factions, $fact["faction"]);
                    array_push($faction_ranks, $fact["standing"]);
                }
            }
            $output .= '
            <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>
            <div class="tab_content center">
              <div class="tab">
                <ul>
                  <li><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>';
            }
            $output .= '
                  <li class="selected"><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>
              <div class="tab_content2 center center_text">
                <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 />';
            $temp_out = array(1 => array('
                <table class="lined" id="ch_rep_rep_alliance">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi1" onclick="expand(\'i1\', this, \'Alliance\')">[-] ' . lang("char", "rep_alliance") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i1" class="lined" style="width: 535px; display: table;">', 0), 2 => array('
                <table class="lined" id="ch_rep_rep_horde">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi2" onclick="expand(\'i2\', this, \'Horde\')">[-] ' . lang("char", "rep_horde") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i2" class="lined" style="width: 535px; display: table;">', 0), 3 => array('
                <table class="lined" id="ch_rep_rep_alliance_forces">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi3" onclick="expand(\'i3\', this, \'Alliance Forces\')">[-] ' . lang("char", "rep_alliance_forces") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i3" class="lined" style="width: 535px; display: table;">', 0), 4 => array('
                <table class="lined" id="ch_rep_rep_horde_forces">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi4" onclick="expand(\'i4\', this, \'Horde Forces\')">[-] ' . lang("char", "rep_horde_forces") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i4" class="lined" style="width: 535px; display: table;">', 0), 5 => array('
                <table class="lined" id="ch_rep_rep_steamwheedle_cartel">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi5" onclick="expand(\'i5\', this, \'Steamwheedle Cartels\')">[-] ' . lang("char", "rep_steamwheedle_cartel") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i5" class="lined" style="width: 535px; display: table;">', 0), 6 => array('
                <table class="lined" id="ch_rep_rep_the_burning_crusade">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi6" onclick="expand(\'i6\', this, \'The Burning Crusade\')">[-] ' . lang("char", "rep_the_burning_crusade") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i6" class="lined" style="width: 535px; display: table;">', 0), 7 => array('
                <table class="lined" id="ch_rep_rep_shattrath_city">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi7" onclick="expand(\'i7\', this, \'Shattrath City\')">[-] ' . lang("char", "rep_shattrath_city") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i7" class="lined" style="width: 535px; display: table;">', 0), 8 => array('
                <table class="lined" id="ch_rep_rep_alliance_vanguard">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi8" onclick="expand(\'i8\', this, \'Alliance Vanguard\')">[-] ' . lang("char", "rep_alliance_vanguard") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i8" class="lined" style="width: 535px; display: table;">', 0), 9 => array('
                <table class="lined" id="ch_rep_rep_horde_expedition">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi9" onclick="expand(\'i9\', this, \'Horde Expedition \')">[-] ' . lang("char", "rep_horde_expedition") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i9" class="lined" style="width: 535px; display: table;">', 0), 10 => array('
                <table class="lined" id="ch_rep_rep_sholazar_basin">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi10" onclick="expand(\'i10\', this, \'Sholazar Basin\')">[-] ' . lang("char", "rep_sholazar_basin") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i10" class="lined" style="width: 535px; display: table;">', 0), 11 => array('
                <table class="lined" id="ch_rep_rep_wrath_of_the_lich_king">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi11" onclick="expand(\'i11\', this, \'Wrath of the Lich King\')">[-] ' . lang("char", "rep_wrath_of_the_lich_king") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i11" class="lined" style="width: 535px; display: table;">', 0), 12 => array('
                <table class="lined" id="ch_rep_rep_other">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi12" onclick="expand(\'i12\', this, \'Other\')">[-] ' . lang("char", "rep_other") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i12" class="lined" style="width: 535px; display: table;">', 0), 0 => array('
                <table class="lined" id="ch_rep_rep_unknown">
                  <tr>
                    <th colspan="3" align="left">
                      <div id="divi13" onclick="expand(\'i13\', this, \'Unknown\')">[-] ' . lang("char", "rep_unknown") . '</div>
                    </th>
                  </tr>
                  <tr>
                    <td>
                      <table id="i13" class="lined" style="width: 535px; display: table;">', 0));
            if (count($factions) > 1) {
                for ($i = 0; $i < count($factions); $i++) {
                    $faction = $factions[$i];
                    $standing = $faction_ranks[$i];
                    $rep_rank = fact_get_reputation_rank($faction, $standing, $char["race"]);
                    $rep_rank_name = $reputation_rank[$rep_rank];
                    $rep_cap = $reputation_rank_length[$rep_rank];
                    $rep = fact_get_reputation_at_rank($faction, $standing, $char["race"]);
                    $faction_name = fact_get_faction_name($faction);
                    $ft = fact_get_faction_tree($faction);
                    // not show alliance rep for horde and vice versa:
                    if (1 << $char["race"] - 1 & 690 && ($ft == 1 || $ft == 3) || 1 << $char["race"] - 1 & 1101 && ($ft == 2 || $ft == 4)) {
                    } else {
                        // this_is_junk: style left hardcoded because it's calculated.
                        $temp_out[$ft][0] .= '
                        <tr>
                          <td style="width: 30%;" align="left">' . $faction_name . '</td>
                          <td style="width: 55%;" valign="top">
                            <div class="faction-bar">
                              <div class="rep' . $rep_rank . '">
                                <span class="rep-data">' . $rep . '/' . $rep_cap . '</span>
                                <div class="bar-color" style="width:' . 100 * $rep / $rep_cap . '%"></div>
                              </div>
                            </div>
                          </td>
                          <td style="width: 15%;" align="left" class="rep' . $rep_rank . '">' . $rep_rank_name . '</td>
                        </tr>';
                        $temp_out[$ft][1] = 1;
                    }
                }
            } else {
                $output .= '
                        <tr>
                          <td colspan="2"><br /><br />' . lang("global", "err_no_records_found") . '<br /><br /></td>
                        </tr>';
            }
            foreach ($temp_out as $out) {
                if ($out[1]) {
                    $output .= $out[0] . '
                      </table>
                    </td>
                  </tr>
                </table>';
                }
            }
            $output .= '
                <br />
              </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;id=' . $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>';
            }
            // 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_achieve.php -->';
        } else {
            error(lang("char", "no_permission"));
        }
    } else {
        error(lang("char", "no_char_found"));
    }
}
Exemplo n.º 4
0
$result = mysqli_query($connection, $query);
$rows = mysqli_num_rows($result);
if ($rows != 0) {
    if (isset($_GET['page'])) {
        $id = intval($_GET['page']);
        $pgname = urldecode($_GET['page']);
        $query = "SELECT * FROM `pages` WHERE name='{$pgname}'";
        $result = mysqli_query($connection, $query);
        $page = mysqli_fetch_array($result);
        if (mysqli_num_rows($result) == 0) {
            $error = "No page by this name found. Maybe it was deleted or renamed?";
            $pgsettings = array("title" => "No page by this name found!", "pageselection" => "true", "nav" => true, "banner" => 1, "use_google_analytics" => 1);
            require_once "includes/begin_html.php";
        } else {
            if ($page['published'] == 1) {
                if (get_page_permission(unserialize($page['visible']))) {
                    print_page($page);
                } else {
                    $pgsettings = array("title" => "You Do Not Have Permission", "pageselection" => false, "nav" => true, "banner" => 1, "use_google_analytics" => 1);
                    require_once "includes/begin_html.php";
                    ?>
<p>(You don't have permission to view this page.)</p><?php 
                }
            } else {
                $pgsettings = array("title" => "Unpublished", "pageselection" => false, "nav" => true, "banner" => 1, "use_google_analytics" => 1);
                require_once "includes/begin_html.php";
                ?>
<p>(You cannot view this page, it isn't published.)</p><?php 
            }
        }
    } else {
Exemplo n.º 5
0
function char_skill()
{
    global $output, $realm_id, $characters_db, $corem_db, $action_permission, $user_lvl, $site_encoding, $user_name, $base_datasite, $skill_datasite, $sql, $core;
    //wowhead_tt();
    if (empty($_GET["id"])) {
        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;
        }
    }
    $id = $sql["char"]->quote_smart($_GET["id"]);
    if (!is_numeric($id)) {
        $id = 0;
    }
    $order_by = isset($_GET["order_by"]) ? $sql["char"]->quote_smart($_GET["order_by"]) : 1;
    $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;
    if ($core == 1) {
        $result = $sql["char"]->query('SELECT acct, name, race, class, level, gender FROM characters WHERE guid = ' . $id . ' LIMIT 1');
    } else {
        $result = $sql["char"]->query('SELECT account AS acct, name, race, class, level, gender FROM characters WHERE guid = ' . $id . ' LIMIT 1');
    }
    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) {
            $result = $sql["logon"]->query("SELECT login FROM accounts WHERE acct='" . $char["acct"] . "'");
        } else {
            $result = $sql["logon"]->query("SELECT username AS login FROM account WHERE id='" . $char["acct"] . "'");
        }
        $owner_name = $sql["logon"]->result($result, 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_Skill"];
        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_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_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;
            }
        }
        if ($view_override || $user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
            if ($core == 1) {
                $result = $sql["char"]->query("SELECT data, name, race, class, level, gender FROM characters WHERE guid = '" . $id . "'");
                $char = $sql["char"]->fetch_assoc($result);
                $char_data = explode(';', $char["data"]);
            } else {
                $result = $sql["char"]->query("SELECT name, race, class, level, gender FROM characters WHERE guid='" . $id . "'");
                $char = $sql["char"]->fetch_assoc($result);
                $result = $sql["char"]->query("SELECT * FROM character_skills WHERE guid='" . $id . "'");
                // make TC's skill data work like our treatment of Arc's
                $char_data = array();
                $i = 0;
                while ($skill_row = $sql["char"]->fetch_assoc($result)) {
                    $char_data[PLAYER_SKILL_INFO_1_1 + $i] = $skill_row["skill"];
                    $char_data[PLAYER_SKILL_INFO_1_1 + $i + 1] = $skill_row["value"];
                    $char_data[PLAYER_SKILL_INFO_1_1 + $i + 2] = $skill_row["max"];
                    $i += 3;
                }
            }
            $output .= '
            <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>
            <div class="tab_content center">
              <div class="tab">
                <ul>
                  <li><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>';
            }
            $output .= '
                  <li class="selected"><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>
              <div class="tab_content2 center center_text">
                <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_ski_main">
                  <tr>
                    <th class="title" colspan="' . ($user_lvl ? '3' : '2') . '" align="left">' . lang("char", "skills") . '</th>
                  </tr>
                  <tr>
                    ' . ($user_lvl ? '<th><a href="char_skill.php?id=' . $id . '&amp;realm=' . $realmid . '&amp;order_by=0&amp;dir=' . $dir . '"' . ($order_by == 0 ? ' class="' . $order_dir . '"' : '') . '>' . lang("char", "skill_id") . '</a></th>' : '') . '
                    <th align="right"><a href="char_skill.php?id=' . $id . '&amp;realm=' . $realmid . '&amp;order_by=1&amp;dir=' . $dir . '"' . ($order_by == 1 ? ' class="' . $order_dir . '"' : '') . '>' . lang("char", "skill_name") . '</a></th>
                    <th><a href="char_skill.php?id=' . $id . '&amp;realm=' . $realmid . '&amp;order_by=2&amp;dir=' . $dir . '"' . ($order_by == 2 ? ' class="' . $order_dir . '"' : '') . '>' . lang("char", "skill_value") . '</a></th>
                  </tr>';
            $skill_array = array();
            $class_array = array();
            $prof_1_array = array();
            $prof_2_array = array();
            $weapon_array = array();
            $armor_array = array();
            $language_array = array();
            $skill_rank_array = array(75 => lang("char", "apprentice"), 150 => lang("char", "journeyman"), 225 => lang("char", "expert"), 300 => lang("char", "artisan"), 375 => lang("char", "master"), 450 => lang("char", "inherent"), 385 => lang("char", "wise"));
            for ($i = PLAYER_SKILL_INFO_1_1; $i <= PLAYER_SKILL_INFO_1_1 + 384; $i += 3) {
                if ($char_data[$i] && skill_get_name($char_data[$i] & 0xffff)) {
                    $temp = unpack("S", pack("L", $char_data[$i + 1]));
                    $skill = $char_data[$i] & 0xffff;
                    if (skill_get_type($skill) == 6) {
                        array_push($weapon_array, array($user_lvl ? $skill : '', skill_get_name($skill), $temp[1]));
                    } elseif (skill_get_type($skill) == 7) {
                        array_push($class_array, array($user_lvl ? $skill : '', skill_get_name($skill), $temp[1]));
                    } elseif (skill_get_type($skill) == 8) {
                        array_push($armor_array, array($user_lvl ? $skill : '', skill_get_name($skill), $temp[1]));
                    } elseif (skill_get_type($skill) == 9) {
                        array_push($prof_2_array, array($user_lvl ? $skill : '', skill_get_name($skill), $temp[1]));
                    } elseif (skill_get_type($skill) == 10) {
                        array_push($language_array, array($user_lvl ? $skill : '', skill_get_name($skill), $temp[1]));
                    } elseif (skill_get_type($skill) == 11) {
                        array_push($prof_1_array, array($user_lvl ? $skill : '', skill_get_name($skill), $temp[1]));
                    } else {
                        array_push($skill_array, array($user_lvl ? $skill : '', skill_get_name($skill), $temp[1]));
                    }
                }
            }
            unset($char_data);
            aasort($skill_array, $order_by, $dir);
            aasort($class_array, $order_by, $dir);
            aasort($prof_1_array, $order_by, $dir);
            aasort($prof_2_array, $order_by, $dir);
            aasort($weapon_array, $order_by, $dir);
            aasort($armor_array, $order_by, $dir);
            aasort($language_array, $order_by, $dir);
            foreach ($skill_array as $data) {
                // this_is_junk: style left hardcoded because it's calculated.
                $max = $data[2] < $char["level"] * 5 ? $char["level"] * 5 : $data[2];
                $output .= '
                  <tr>
                    ' . ($user_lvl ? '<td>' . $data[0] . '</td>' : '') . '
                    <td align="right">' . $data[1] . '</td>
                    <td class="bar skill_bar" style="background-position: ' . (round(385 * $data[2] / $max) - 385) . 'px;">
                      <span style="position: relative; top: -2px;">' . $data[2] . '/' . $max . '</span>
                    </td>
                  </tr>';
            }
            if (count($class_array)) {
                $output .= '
                  <tr><th class="title" colspan="' . ($user_lvl ? '3' : '2') . '" align="left">' . lang("char", "classskills") . '</th></tr>';
            }
            foreach ($class_array as $data) {
                $max = $data[2] < $char["level"] * 5 ? $char["level"] * 5 : $data[2];
                $output .= '
                  <tr>
                    ' . ($user_lvl ? '<td>' . $data[0] . '</td>' : '') . '
                    <td align="right"><a href="' . $base_datasite . $skill_datasite . '7.' . $char["class"] . '.' . $data[0] . '" rel="external">' . $data[1] . '</a></td>
                    <td class="bar skill_bar" style="background-position: 0px;">
                    </td>
                  </tr>';
            }
            if (count($prof_1_array)) {
                $output .= '
                  <tr><th class="title" colspan="' . ($user_lvl ? '3' : '2') . '" align="left">' . lang("char", "professions") . '</th></tr>';
            }
            foreach ($prof_1_array as $data) {
                // this_is_junk: style left hardcoded because it's calculated.
                $max = $data[2] < 76 ? 75 : ($data[2] < 151 ? 150 : ($data[2] < 226 ? 225 : ($data[2] < 301 ? 300 : ($data[2] < 376 ? 375 : ($data[2] < 376 ? 375 : 450)))));
                $output .= '
                  <tr>
                    ' . ($user_lvl ? '<td>' . $data[0] . '</td>' : '') . '
                    <td align="right"><a href="' . $base_datasite . $skill_datasite . '11.' . $data[0] . '" rel="external">' . $data[1] . '</a></td>
                    <td class="bar skill_bar" style="background-position: ' . (round(385 * $data[2] / $max) - 385) . 'px;">
                      <span style="position: relative; top: -2px;">' . $data[2] . '/' . $max . ' (' . $skill_rank_array[$max] . ')</span>
                    </td>
                  </tr>';
            }
            if (count($prof_2_array)) {
                $output .= '
                  <tr><th class="title" colspan="' . ($user_lvl ? '3' : '2') . '" align="left">' . lang("char", "secondaryskills") . '</th></tr>';
            }
            foreach ($prof_2_array as $data) {
                // this_is_junk: style left hardcoded because it's calculated.
                $max = $data[2] < 76 ? 75 : ($data[2] < 151 ? 150 : ($data[2] < 226 ? 225 : ($data[2] < 301 ? 300 : ($data[2] < 376 ? 375 : ($data[2] < 376 ? 375 : 450)))));
                $output .= '
                  <tr>
                    ' . ($user_lvl ? '<td>' . $data[0] . '</td>' : '') . '
                    <td align="right"><a href="' . $base_datasite . $skill_datasite . '9.' . $data[0] . '" rel="external">' . $data[1] . '</a></td>
                    <td class="bar skill_bar" style="background-position: ' . (round(385 * $data[2] / $max) - 385) . 'px;">
                      <span style="position: relative; top: -2px;">' . $data[2] . '/' . $max . ' (' . $skill_rank_array[$max] . ')</span>
                    </td>
                  </tr>';
            }
            if (count($weapon_array)) {
                $output .= '
                  <tr><th class="title" colspan="' . ($user_lvl ? '3' : '2') . '" align="left">' . lang("char", "weaponskills") . '</th></tr>';
            }
            foreach ($weapon_array as $data) {
                // this_is_junk: style left hardcoded because it's calculated.
                $max = $data[2] < $char["level"] * 5 ? $char["level"] * 5 : $data[2];
                $output .= '
                  <tr>
                    ' . ($user_lvl ? '<td>' . $data[0] . '</td>' : '') . '
                    <td align="right">' . $data[1] . '</td>
                    <td class="bar skill_bar" style="background-position: ' . (round(385 * $data[2] / $max) - 385) . 'px;">
                      <span style="position: relative; top: -2px;">' . $data[2] . '/' . $max . '</span>
                    </td>
                  </tr>';
            }
            if (count($armor_array)) {
                $output .= '
                  <tr><th class="title" colspan="' . ($user_lvl ? '3' : '2') . '" align="left">' . lang("char", "armorproficiencies") . '</th></tr>';
            }
            foreach ($armor_array as $data) {
                $max = $data[2] < $char["level"] * 5 ? $char["level"] * 5 : $data[2];
                $output .= '
                  <tr>
                    ' . ($user_lvl ? '<td>' . $data[0] . '</td>' : '') . '
                    <td align="right">' . $data[1] . '</td>
                    <td class="bar skill_bar" style="background-position: 0px;">
                    </td>
                  </tr>';
            }
            if (count($language_array)) {
                $output .= '
                  <tr><th class="title" colspan="' . ($user_lvl ? '3' : '2') . '" align="left">' . lang("char", "languages") . '</th></tr>';
            }
            foreach ($language_array as $data) {
                // this_is_junk: style left hardcoded because it's calculated.
                $max = $data[2] < $char["level"] * 5 ? $char["level"] * 5 : $data[2];
                $output .= '
                  <tr>
                    ' . ($user_lvl ? '<td>' . $data[0] . '</td>' : '') . '
                    <td align="right">' . $data[1] . '</td>
                    <td class="bar skill_bar" style="background-position: ' . (round(385 * $data[2] / $max) - 385) . 'px;">
                      <span style="position: relative; top: -2px;">' . $data[2] . '/' . $max . '</span>
                    </td>
                  </tr>';
            }
            $output .= '
                </table>
                <br />
              </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;id=' . $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>';
            }
            // 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_achieve.php -->';
        } else {
            error(lang("char", "no_permission"));
        }
    } else {
        error(lang("char", "no_char_found"));
    }
}
Exemplo n.º 6
0
function nav($position, $pgselection)
{
    global $connection;
    $logo = scandir("images/logo/");
    if (isset($logo[2])) {
        $logo = $logo[2];
    } else {
        $logo = false;
    }
    if ($position == "mobile") {
        ?>
        <ul id="slide-out" class="side-nav">
            <div style="height:71px; width:100%;" class="mobile-logo">
            <?php 
        if ($logo != false) {
            ?>
                <?php 
            if ($GLOBALS['site_info']['logo_url'] != '') {
                ?>
                <a href="<?php 
                echo $GLOBALS['site_info']['logo_url'];
                ?>
"><img src="<?php 
                echo $GLOBALS['HOST'];
                ?>
/images/logo/<?php 
                echo $logo;
                ?>
" alt="<?php 
                echo $GLOBALS['site_info']['name'];
                ?>
 Logo" width="240" /></a>
                <?php 
            } else {
                ?>
                <img src="<?php 
                echo $GLOBALS['HOST'];
                ?>
/images/logo/<?php 
                echo $logo;
                ?>
" width="240" />
            <?php 
            }
        }
        ?>
        </div>
    <?php 
        $query = "SELECT * FROM `pages` WHERE `horiz_menu` = 1 OR `vert_menu` = 1 AND `issubpage` = 0 AND `published` = 1 ORDER BY `position` ASC";
        $result = mysqli_query($connection, $query);
        $numpages = mysqli_num_rows($result);
        if ($numpages != 0) {
            $query = "SELECT * FROM `pages` WHERE `horiz_menu` = 1 AND `issubpage` = 0 AND `published` = 1 ORDER BY `position` ASC";
            $result = mysqli_query($connection, $query);
            $numhorizpages = mysqli_num_rows($result);
            if ($numhorizpages != 0) {
                ?>
            <ul>
			<?php 
                while ($page = mysqli_fetch_array($result)) {
                    ?>
				<li<?php 
                    if ($pgselection == "true") {
                        if (isset($_GET['page']) && urlencode($page['name']) == $_GET['page']) {
                            echo " class=\"selected\"";
                        }
                    }
                    ?>
><?php 
                    $query = "SELECT * FROM `pages` WHERE `horiz_menu` = 1 AND `issubpage` = 1 AND `published` = 1 AND `parent`={$page['id']} ORDER BY `position` ASC";
                    $subpgresult = mysqli_query($connection, $query);
                    confirm_query($subpgresult);
                    if (mysqli_num_rows($subpgresult) == 0) {
                        nav_button($page);
                    } else {
                        ?>
						<ul class="collapsible collapsible-accordion">
							<li>
								<span class="collapsible-header" style="padding-left:0px; margin-left:0px;">
                                	<?php 
                        nav_button($page);
                        ?>
                                	<i class="mdi-navigation-arrow-drop-down"></i>
                                </span>
                                
                                  <div class="collapsible-body">
                                    <ul>
									<?php 
                        while ($subpage = mysqli_fetch_array($subpgresult)) {
                            ?>
                                        <li style="width:100%;"<?php 
                            if ($pgselection == "true") {
                                if (isset($_GET['page']) && urlencode($subpage['name']) == $_GET['page']) {
                                    echo " class=\"selected\"";
                                }
                            }
                            ?>
><?php 
                            nav_button($subpage);
                            ?>
                                        </li>
                                    <?php 
                        }
                        ?>
								</ul>
							  </div>
							</li>
						  </ul>
					<?php 
                    }
                    ?>
					</li>
				<?php 
                }
                ?>
				</ul>
				<hr/>
			<?php 
            }
            ?>
			<?php 
            $query = "SELECT * FROM `pages` WHERE `vert_menu` = 1 AND `issubpage` = 0 AND `published` = 1 ORDER BY `position` ASC";
            $result = mysqli_query($connection, $query);
            $numvertpages = mysqli_num_rows($result);
            if ($numvertpages != 0) {
                ?>
            <ul>
            <?php 
                while ($page = mysqli_fetch_array($result)) {
                    if ($page['issubpage'] == 0) {
                        $lastmainpage = $page['id'];
                        ?>
				<li<?php 
                        if ($pgselection == "true") {
                            if (isset($_GET['page']) && urlencode($page['name']) == $_GET['page']) {
                                echo " class=\"selected\"";
                            }
                        }
                        ?>
><?php 
                        $query = "SELECT * FROM `pages` WHERE `vert_menu` = 1 AND `issubpage` = 1 AND `published` = 1 AND `parent`={$page['id']} ORDER BY `position` ASC";
                        $subpgresult = mysqli_query($connection, $query);
                        confirm_query($subpgresult);
                        if (mysqli_num_rows($subpgresult) == 0) {
                            nav_button($page);
                        } else {
                            ?>
					
						<ul class="collapsible collapsible-accordion">
							<li>
								<span class="collapsible-header" style="padding-left:0px; margin-left:0px;">
                                	<?php 
                            nav_button($page);
                            ?>
                                	<i class="mdi-navigation-arrow-drop-down"></i>
                                </span>
                                  <div class="collapsible-body">
                                    <ul>
									<?php 
                            while ($subpage = mysqli_fetch_array($subpgresult)) {
                                ?>
                                        <li style="width:100%;"<?php 
                                if ($pgselection == "true") {
                                    if (isset($_GET['page']) && urlencode($subpage['name']) == $_GET['page']) {
                                        echo " class=\"selected\"";
                                    }
                                }
                                ?>
><?php 
                                nav_button($subpage);
                                ?>
                                        </li>
                                    <?php 
                            }
                            ?>
								</ul>
							  </div>
							</li>
						  </ul>
						  </li>
					<?php 
                        }
                        ?>
					</li>
				<?php 
                    }
                    ?>
				
			<?php 
                }
                ?>
        </ul>
        <hr/>
        <?php 
            }
        }
        ?>
        <div class="mobile-login">
        	<?php 
        if (logged_in()) {
            ?>
        	<ul>
            	<li><span class="mobile-login-username"><?php 
            echo $_SESSION['username'];
            ?>
</span></li>
	            <li><span class="icon-cog"></span><a href="<?php 
            echo $GLOBALS['HOST'];
            ?>
/account-settings">Settings</a></li>
	            <?php 
            if (check_permission("Website", "cpanel_access")) {
                ?>
<li><span class="icon-dashboard"></span><a href="<?php 
                echo $GLOBALS['HOST'];
                ?>
/administrator/" target="_blank">CPanel</a></li><?php 
            }
            ?>
	            <li><span class="icon-exit"></span>                                       <a href="<?php 
            echo $GLOBALS['HOST'];
            ?>
/logout.php">Logout</a></li>
            </ul>
        <?php 
        } else {
            ?>
                <a href="<?php 
            echo $GLOBALS['HOST'];
            ?>
/index">Register</a> | <a href="<?php 
            echo $GLOBALS['HOST'];
            ?>
/login.php">Login</a>
        <?php 
        }
        ?>
            </div>
        </ul>
	<?php 
    }
    if ($position == "horiz" || $position == "vert") {
        if ($position == "horiz") {
            $query = "SELECT * FROM `pages` WHERE `horiz_menu` = 1 AND `issubpage` = 0 AND `published` = 1 ORDER BY `position` ASC";
        } elseif ($position == "vert") {
            $query = "SELECT * FROM `pages` WHERE `vert_menu` = 1 AND `issubpage` = 0 AND `published` = 1 ORDER BY `position` ASC";
        }
        $result = mysqli_query($connection, $query);
        $numpages = mysqli_num_rows($result);
        if ($position == "horiz" && $numpages != 0) {
            ?>
				<div class="nav">
					<ul id="horiz-menu" class="right">
			<?php 
        } elseif ($position == "vert" && $numpages != 0) {
            ?>
				<div class=" col l3 card" style="padding:0 !important;" id="vert-td"><div style="width:100%;">
					<ul  id="vert-menu">
			<?php 
        }
        //$buttonwidth = $numpages;
        //$buttonwidth = 900 - $buttonwidth;
        //$buttonwidth = $buttonwidth / $numpages + 1;
        if ($position == "horiz") {
            if ($numpages != 0) {
                $buttonwidth = round(100 / $numpages, 4);
            } else {
                $buttonwidth = 100;
            }
        } elseif ($position == "vert") {
            $buttonwidth = 100;
        }
        $pageorder = 0;
        if ($numpages != 0) {
            while ($page = mysqli_fetch_array($result)) {
                if ($page['issubpage'] == 0) {
                    $lastmainpage = $page['id'];
                    if (get_page_permission(unserialize($page['visible']))) {
                        ?>
	                        <li style="min-width:<?php 
                        echo $buttonwidth;
                        ?>
%;"<?php 
                        if ($pgselection == "true") {
                            if (isset($_GET['page']) && urlencode($page['name']) == $_GET['page']) {
                                echo " class=\"selected\"";
                            }
                        }
                        ?>
><a style="min-width:<?php 
                        echo $buttonwidth;
                        ?>
%;" href="<?php 
                        echo $GLOBALS['HOST'];
                        ?>
/page/<?php 
                        echo urlencode($page['name']);
                        /*	                                if($page['type']=='Custom' || $page['type']=='Staff'){
                        	                                    echo $GLOBALS['HOST'];?>/page/<?php echo urlencode($page['name']);
                        	                                }elseif($page['type']=='Blog'){
                        	                                    echo $GLOBALS['HOST'];?>/blog<?php
                        	                                }elseif($page['type']=='Forum'){
                        	                                    echo $GLOBALS['HOST'];?>/forums<?php
                        	                                }elseif($page['type']=='Link'){
                        	                                    echo $page['url'];
                        	                                }*/
                        ?>
" <?php 
                        if ($page['target'] != "_self") {
                            echo "target=\"" . $page['target'] . "\"";
                        }
                        ?>
><?php 
                        echo $page['name'];
                        ?>
</a><?php 
                        if ($position == "horiz") {
                            $query = "SELECT * FROM `pages` WHERE `horiz_menu` = 1 AND `issubpage` = 1 AND `published` = 1 AND `parent`={$page['id']} ORDER BY `position` ASC";
                        } elseif ($position == "vert") {
                            $query = "SELECT * FROM `pages` WHERE `vert_menu` = 1 AND `issubpage` = 1 AND `published` = 1 AND `parent`={$page['id']} ORDER BY `position` ASC";
                        }
                        $subpgresult = mysqli_query($connection, $query);
                        confirm_query($subpgresult);
                        if (mysqli_num_rows($subpgresult) != 0) {
                            ?>
	                                <ul style="min-width:100%;">
	                                <?php 
                            while ($subpage = mysqli_fetch_array($subpgresult)) {
                                if (get_page_permission(unserialize($subpage['visible']))) {
                                    ?>
		                                    <li style="width:100%;"<?php 
                                    if ($pgselection == "true") {
                                        if (isset($_GET['page']) && urlencode($subpage['name']) == $_GET['page']) {
                                            echo " class=\"selected\"";
                                        }
                                    }
                                    ?>
>
		                                        <a href="<?php 
                                    echo $GLOBALS['HOST'];
                                    ?>
/page/<?php 
                                    echo urlencode($subpage['name']);
                                    /*		                                            if($subpage['type']=='Custom' || $page['type']=='Staff'){
                                    		                                                echo $GLOBALS['HOST'];?>/page/<?php echo urlencode($subpage['name']);
                                    		                                            }elseif($subpage['type']=='Blog'){
                                    		                                                echo $GLOBALS['HOST'];?>/blog<?php
                                    		                                            }elseif($subpage['type']=='Forum'){
                                    		                                                echo $GLOBALS['HOST'];?>/forums<?php
                                    		                                            }elseif($subpage['type']=='Link'){
                                    		                                                echo $subpage['url'];
                                    		                                            }*/
                                    ?>
"
		                                            <?php 
                                    if ($subpage['target'] != "_self") {
                                        echo "target=\"" . $subpage['target'] . "\"";
                                    }
                                    ?>
><?php 
                                    echo $subpage['name'];
                                    ?>
</a>
		                                    </li>
		                                <?php 
                                }
                            }
                            ?>
	                                </ul>
		                            <?php 
                        }
                        ?>
	                            </li>
	                        <?php 
                    }
                }
            }
        }
        ?>
			</ul>
			<?php 
        if ($position == "horiz" && $numpages != 0) {
            ?>
				</div>
			<?php 
        } elseif ($position == "vert" && $numpages != 0) {
            ?>
            	</div></div>
			<?php 
        }
        ?>
		<?php 
    }
    return $numpages;
}
Exemplo n.º 7
0
function read_mail()
{
    global $output, $realm_id, $characters_db, $action_permission, $user_lvl, $user_name, $user_id, $site_encoding, $sql, $core;
    if (empty($_GET["id"])) {
        error(lang("global", "empty_fields"));
    }
    if (empty($_GET["message"])) {
        error(lang("global", "empty_fields"));
    }
    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;
        }
    }
    $id = $sql["char"]->quote_smart($_GET["id"]);
    if (!is_numeric($id)) {
        $id = 0;
    }
    $message = $sql["char"]->quote_smart($_GET["message"]);
    if (!is_numeric($message)) {
        $message = 0;
    }
    if ($core == 1) {
        $result = $sql["char"]->query("SELECT acct, name, race, class, level, gender\r\n      FROM characters WHERE guid='" . $id . "' LIMIT 1");
    } else {
        $result = $sql["char"]->query("SELECT account AS acct, name, race, class, level, gender\r\n      FROM characters WHERE guid='" . $id . "' LIMIT 1");
    }
    if ($sql["char"]->num_rows($result)) {
        $char = $sql["char"]->fetch_assoc($result);
        if ($user_id != $char["acct"] && $user_lvl < $action_permission["insert"]) {
            error(lang("char", "no_permission"));
        }
        $owner_acc_id = $sql["char"]->result($result, 0, 'acct');
        if ($core == 1) {
            $result = $sql["logon"]->query("SELECT login FROM accounts WHERE acct='" . $char["acct"] . "'");
        } else {
            $result = $sql["logon"]->query("SELECT username AS login FROM account WHERE id='" . $char["acct"] . "'");
        }
        $owner_name = $sql["logon"]->result($result, 0, 'login');
        $result = $sql["mgr"]->query("SELECT SecurityLevel AS gm FROM config_accounts WHERE Login='******'");
        $owner_gmlvl = $sql["mgr"]->result($result, 0, 'gm');
        if ($user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
            $output .= '
            <div class="tab">
              <ul>
                <li class="selected"><a href="char.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "char_sheet") . '</a></li>
                <li><a href="char_inv.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "inventory") . '</a></li>
                ' . ($char["level"] < 10 ? '' : '<li><a href="char_talent.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "talents") . '</a></li>') . '
                <li><a href="char_achieve.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "achievements") . '</a></li>
                <li><a href="char_quest.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "quests") . '</a></li>
                <li><a href="char_friends.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "friends") . '</a></li>
               </ul>
            </div>
            <div class="tab_content center">
              <div class="tab">
                <ul>
                  <li><a href="char.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "char_sheet") . '</a></li>';
            if (char_get_class_name($char["class"]) === 'Hunter') {
                $output .= '
                  <li><a href="char_pets.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "pets") . '</a></li>';
            }
            $output .= '
                  <li><a href="char_rep.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "reputation") . '</a></li>
                  <li><a href="char_skill.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "skills") . '</a></li>';
            if ($owner_name == $user_name || $user_lvl >= get_page_permission("insert", "char_mail.php")) {
                $output .= '
                  <li class="selected"><a href="char_mail.php?id=' . $id . '&amp;realm=' . $realmid . '">' . lang("char", "mail") . '</a></li>';
            }
            $output .= '
                </ul>
              </div>
              <div class="tab_content2 center center_text">
                <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="" /> - lvl ' . char_get_level_color($char["level"]) . '
                </span>
                <br />';
            if ($core == 1) {
                $result = $sql["char"]->query("SELECT * FROM mailbox WHERE message_id='" . $message . "'");
            } else {
                $result = $sql["char"]->query("SELECT *, sender AS sender_guid FROM mail WHERE id='" . $message . "'");
            }
            $mail = $sql["char"]->fetch_assoc($result);
            if ($sql["char"]->num_rows($result)) {
                $c_query = "SELECT name FROM characters WHERE guid='" . $mail["sender_guid"] . "'";
                $c_result = $sql["char"]->query($c_query);
                $c_name = $sql["char"]->fetch_assoc($c_result);
                $output .= '
                <div id="ch_read_mail_field" class="fieldset_border">
                  <table class="hidden" id="ch_read_mail">
                    <tr>
                      <td align="left"><b>' . lang("char", "sender") . ':</b></td>
                      <td align="left"><a href="char.php?id=' . $mail["sender_guid"] . '">' . $c_name["name"] . '</a></td>
                      <td width="40%"></td>
                    </tr>
                    <tr>
                      <td align="left"><b>' . lang("char", "subject") . ':</b></td>
                      <td align="left">' . $mail["subject"] . '</td>
                      <td width="40%"></td>
                    </tr>
                    <tr>
                      <td align="left"><b>' . lang("char", "body") . ':</b></td>
                      <td></td>
                      <td width="40%"></td>
                    </tr>
                    <tr>
                      <td colspan="3" align="left">' . $mail["body"] . '</td>
                    </tr>
                    <tr>
                      <td></td>
                    </tr>';
                if ($mail["money"] != 0) {
                    $attgold = str_pad($mail["money"], 4, "0", STR_PAD_LEFT);
                    $pg = substr($attgold, 0, -4);
                    if ($pg == '') {
                        $pg = 0;
                    }
                    $pg = $pg * 1;
                    $ps = substr($attgold, -4, 2);
                    if ($ps == '' || $ps == '00') {
                        $ps = 0;
                    }
                    $ps = $ps * 1;
                    $pc = substr($attgold, -2);
                    if ($pc == '' || $pc == '00') {
                        $pc = 0;
                    }
                    $pc = $pc * 1;
                    $output .= '
                    <tr>
                      <td colspan="3">' . lang("char", "messagehas") . ' ' . ($pg ? $pg . '<img src="img/gold.gif" alt="" align="middle" />' : '') . ($ps ? $ps . '<img src="img/silver.gif" alt="" align="middle" />' : '') . ($pc ? $pc . '<img src="img/copper.gif" alt="" align="middle" />' : '') . ' ' . lang("char", "attached") . '.</td>';
                }
                if ($mail["cod"] != 0) {
                    $codgold = str_pad($mail["cod"], 4, "0", STR_PAD_LEFT);
                    $pg = substr($codgold, 0, -4);
                    if ($pg == '') {
                        $pg = 0;
                    }
                    $pg = $pg * 1;
                    $ps = substr($codgold, -4, 2);
                    if ($ps == '' || $ps == '00') {
                        $ps = 0;
                    }
                    $ps = $ps * 1;
                    $pc = substr($codgold, -2);
                    if ($pc == '' || $pc == '00') {
                        $pc = 0;
                    }
                    $pc = $pc * 1;
                    $output .= '
                      <td colspan="3">' . lang("char", "cod") . '; ' . ($pg ? $pg . '<img src="img/gold.gif" alt="" align="middle" />' : '') . ($ps ? $ps . '<img src="img/silver.gif" alt="" align="middle" />' : '') . ($pc ? $pc . '<img src="img/copper.gif" alt="" align="middle" />' : '') . ' ' . lang("char", "isdue") . '.</td>';
                }
                if ($mail["attached_item_guids"] != 0) {
                    $items = $mail["attached_item_guids"];
                    $items = explode(',', $items);
                    $i_count = count($items);
                    $output .= '
                      <td colspan="3">' . lang("char", "messagehas") . ' ' . $i_count . ' ' . lang("char", "itemsattached") . '.</td>';
                }
                if ($mail["money"] != 0 || $mail["cod"] != 0 || $mail["attached_item_guids"] != 0) {
                    $output .= '
                    </tr>';
                }
                $output .= '
                  </table>
                </div>
                <br />';
            }
            $output .= '
              </div>
            </div>
            <br />
            <br />
          <!-- end of char_mail.php -->';
        } else {
            error(lang("char", "no_permission"));
        }
    } else {
        error(lang("char", "no_char_found"));
    }
}
Exemplo n.º 8
0
function char_pvp()
{
    global $output, $realm_id, $characters_db, $logon_db, $corem_db, $action_permission, $site_encoding, $user_lvl, $user_name, $sql, $core;
    if (empty($_GET["id"])) {
        error(lang("global", "empty_fields"));
    }
    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;
        }
    }
    $id = $sql["char"]->quote_smart($_GET["id"]);
    if (!is_numeric($id)) {
        $id = 0;
    }
    if ($core == 1) {
        $result = $sql["char"]->query("SELECT acct, name, race, class, level, gender, arenaPoints,\r\n      killsToday,\r\n      killsYesterday,\r\n      killsLifetime,\r\n      honorToday,\r\n      honorYesterday,\r\n      honorPoints\r\n      FROM characters WHERE guid='" . $id . "' LIMIT 1");
    } else {
        $result = $sql["char"]->query("SELECT account AS acct, name, race, class, level, gender, arenaPoints,\r\n      todayKills AS killsToday,\r\n      yesterdayKills AS killsYesterday,\r\n      totalKills AS killsLifetime,\r\n      todayHonorPoints AS honorToday,\r\n      yesterdayHonorPoints AS honorYesterday,\r\n      totalHonorPoints AS honorPoints\r\n      FROM characters WHERE guid='" . $id . "' LIMIT 1");
    }
    if ($core == 1) {
        // arenateams.data format: [week games] [week wins] [season games] [season wins]
        // arena team player structure [player_id] [week_played] [week_win] [season_played] [season_win] [rating]
        $query = "SELECT id, rating, type,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(data, ' ', 2), ' ', 1) AS games, \r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(data, ' ', 2), ' ', -1) AS wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(data, ' ', -2), ' ', 1) AS played, \r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(data, ' ', -2), ' ', -1) AS wins2,\r\n      ranking,\r\n      player_data1, player_data2, player_data3, player_data4, player_data5,\r\n      player_data6, player_data7, player_data8, player_data9, player_data10,\r\n      SUBSTRING_INDEX(player_data1, ' ', 1) AS player1_id,\r\n      SUBSTRING_INDEX(player_data2, ' ', 1) AS player2_id,\r\n      SUBSTRING_INDEX(player_data3, ' ', 1) AS player3_id,\r\n      SUBSTRING_INDEX(player_data4, ' ', 1) AS player4_id,\r\n      SUBSTRING_INDEX(player_data5, ' ', 1) AS player5_id,\r\n      SUBSTRING_INDEX(player_data6, ' ', 1) AS player6_id,\r\n      SUBSTRING_INDEX(player_data7, ' ', 1) AS player7_id,\r\n      SUBSTRING_INDEX(player_data8, ' ', 1) AS player8_id,\r\n      SUBSTRING_INDEX(player_data9, ' ', 1) AS player9_id,\r\n      SUBSTRING_INDEX(player_data10, ' ', 1) AS player10_id,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data1, ' ', 2), ' ', -1) AS player1_week_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data1, ' ', 3), ' ', -1) AS player1_week_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data1, ' ', 4), ' ', -1) AS player1_season_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data1, ' ', 5), ' ', -1) AS player1_season_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data1, ' ', 6), ' ', -1) AS player1_rating,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data2, ' ', 2), ' ', -1) AS player2_week_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data2, ' ', 3), ' ', -1) AS player2_week_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data2, ' ', 4), ' ', -1) AS player2_season_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data2, ' ', 5), ' ', -1) AS player2_season_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data2, ' ', 6), ' ', -1) AS player2_rating,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data3, ' ', 2), ' ', -1) AS player3_week_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data3, ' ', 3), ' ', -1) AS player3_week_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data3, ' ', 4), ' ', -1) AS player3_season_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data3, ' ', 5), ' ', -1) AS player3_season_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data3, ' ', 6), ' ', -1) AS player3_rating,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data4, ' ', 2), ' ', -1) AS player4_week_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data4, ' ', 3), ' ', -1) AS player4_week_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data4, ' ', 4), ' ', -1) AS player4_season_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data4, ' ', 5), ' ', -1) AS player4_season_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data4, ' ', 6), ' ', -1) AS player4_rating,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data5, ' ', 2), ' ', -1) AS player5_week_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data5, ' ', 3), ' ', -1) AS player5_week_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data5, ' ', 4), ' ', -1) AS player5_season_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data5, ' ', 5), ' ', -1) AS player5_season_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data5, ' ', 6), ' ', -1) AS player5_rating,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data6, ' ', 2), ' ', -1) AS player6_week_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data6, ' ', 3), ' ', -1) AS player6_week_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data6, ' ', 4), ' ', -1) AS player6_season_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data6, ' ', 5), ' ', -1) AS player6_season_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data6, ' ', 6), ' ', -1) AS player6_rating,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data7, ' ', 2), ' ', -1) AS player7_week_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data7, ' ', 3), ' ', -1) AS player7_week_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data7, ' ', 4), ' ', -1) AS player7_season_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data7, ' ', 5), ' ', -1) AS player7_season_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data7, ' ', 6), ' ', -1) AS player7_rating,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data8, ' ', 2), ' ', -1) AS player8_week_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data8, ' ', 3), ' ', -1) AS player8_week_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data8, ' ', 4), ' ', -1) AS player8_season_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data8, ' ', 5), ' ', -1) AS player8_season_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data8, ' ', 6), ' ', -1) AS player8_rating,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data9, ' ', 2), ' ', -1) AS player9_week_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data9, ' ', 3), ' ', -1) AS player9_week_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data9, ' ', 4), ' ', -1) AS player9_season_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data9, ' ', 5), ' ', -1) AS player9_season_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data9, ' ', 6), ' ', -1) AS player9_rating,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data10, ' ', 2), ' ', -1) AS player10_week_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data10, ' ', 3), ' ', -1) AS player10_week_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data10, ' ', 4), ' ', -1) AS player10_season_played,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data10, ' ', 5), ' ', -1) AS player10_season_wins,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(player_data10, ' ', 6), ' ', -1) AS player10_rating\r\n      FROM arenateams HAVING player1_id='" . $id . "' OR player2_id='" . $id . "' OR player3_id='" . $id . "' OR\r\n         player4_id='" . $id . "' OR player5_id='" . $id . "' OR player6_id='" . $id . "' OR player7_id='" . $id . "' OR\r\n          player8_id='" . $id . "' OR player9_id='" . $id . "' OR player10_id='" . $id . "'";
        $arena_team_query = $sql["char"]->query($query);
    } elseif ($core == 2) {
        $query = "SELECT *,arena_team.arenateamid AS id, rating, type,\r\n      games_week AS games, wins_week AS wins, games_season AS played, wins_season AS wins2, rank AS ranking,\r\n      (SELECT COUNT(*) FROM arena_team_member WHERE arenateamid=id) AS tot_chars\r\n      FROM arena_team\r\n        LEFT JOIN arena_team_stats ON arena_team_stats.arenateamid=arena_team.arenateamid\r\n        LEFT JOIN arena_team_member ON arena_team_member.arenateamid=arena_team.arenateamid\r\n      WHERE arena_team_member.guid='" . $id . "'";
        $arena_team_query = $sql["char"]->query($query);
    } else {
        $query = "SELECT *, arena_team.arenaTeamId AS id, rating, type,\r\n      arena_team.weekGames AS games, arena_team.weekWins AS wins,\r\n      arena_team.seasonGames AS played, arena_team.seasonWins AS wins2,\r\n      rank AS ranking, arena_team_member.personalRating AS personalRating,\r\n      arena_team_member.weekGames as played_week, arena_team_member.weekWins as wons_week,\r\n      arena_team_member.seasonGames as played_season, arena_team_member.seasonWins as wons_season,\r\n      (SELECT COUNT(*) FROM arena_team_member WHERE arenaTeamId=id) AS tot_chars\r\n      FROM arena_team\r\n        LEFT JOIN arena_team_member ON arena_team_member.arenaTeamId=arena_team.arenaTeamId\r\n      WHERE arena_team_member.guid='" . $id . "'";
        $arena_team_query = $sql["char"]->query($query);
    }
    while ($arena_row = $sql["char"]->fetch_assoc($arena_team_query)) {
        // Trinity stores Team type as 2, 3, 5; ArcEmu & MaNGOS use 0, 1, 2
        if ($core != 3) {
            if ($arena_row["type"] == 0) {
                $type = 2;
            } elseif ($arena_row["type"] == 1) {
                $type = 3;
            } elseif ($arena_row["type"] == 2) {
                $type = 5;
            }
        } else {
            $type = $arena_row["type"];
        }
        if ($type == 2) {
            $arena_team2 = $arena_row;
        } elseif ($type == 3) {
            $arena_team3 = $arena_row;
        } elseif ($type == 5) {
            $arena_team5 = $arena_row;
        }
    }
    $arenateam_data2 = arenateam_data($arena_team2["id"]);
    $arenateam_data3 = arenateam_data($arena_team3["id"]);
    $arenateam_data5 = arenateam_data($arena_team5["id"]);
    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) {
            $result = $sql["logon"]->query("SELECT login FROM accounts WHERE acct='" . $char["acct"] . "'");
        } else {
            $result = $sql["logon"]->query("SELECT username AS login FROM account WHERE id='" . $char["acct"] . "'");
        }
        $owner_name = $sql["logon"]->result($result, 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_PvP"];
        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_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;
            }
        }
        if ($view_override || $user_lvl > $owner_gmlvl || $owner_name === $user_name || $user_lvl == $action_permission["delete"]) {
            $output .= '
            <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>
            <div class="tab_content center">
              <div class="tab">
                <ul>
                  <li><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>';
            }
            $output .= '
                  <li class="selected"><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>
              <div class="tab_content2 center center_text">
                <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_pvp_top">
                  <tr>
                    <td colspan="4">' . lang("char", "honor") . ': <span id="ch_pvp_highlight">' . $char["honorPoints"] . '</span> <img src="img/money_' . (char_get_side_id($char["race"]) ? 'horde' : 'alliance') . '.gif" alt="" /></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>' . lang("char", "today") . '</td>
                    <td>' . lang("char", "yesterday") . '</td>
                    <td>' . lang("char", "lifetime") . '</td>
                  </tr>
                  <tr>
                    <td>' . lang("char", "kills") . '</td>
                    <td>' . $char["killsToday"] . '</td>
                    <td>' . $char["killsYesterday"] . '</td>
                    <td>' . $char["killsLifetime"] . '</td>
                  </tr>
                  <tr>
                    <td>' . lang("char", "honor") . '</td>
                    <td>' . $char["honorToday"] . '</td>
                    <td>' . $char["honorYesterday"] . '</td>
                    <td>-</td>
                  </tr>
                </table>
                <br />
                <table class="lined" id="ch_pvp_main">
                  <tr>
                    <td colspan="5">' . lang("char", "arena") . ': <span class="ch_pvp_highlight">' . $char["arenaPoints"] . '</span> <img src="img/money_arena.gif" alt="" /></td>
                  </tr>';
            if ($arena_team2 != NULL) {
                // ArcEmu: find the data set that is ours
                if ($core == 1) {
                    if ($arena_team2["player1_id"] == $id) {
                        $arena_team2["played_week"] = $arena_team2["player1_week_played"];
                        $arena_team2["wons_week"] = $arena_team2["player1_week_wins"];
                        $arena_team2["played_season"] = $arena_team2["player1_season_played"];
                        $arena_team2["wons_season"] = $arena_team2["player1_season_wins"];
                        $arena_team2["personal_rating"] = $arena_team2["player1_rating"];
                    }
                    if ($arena_team2["player2_id"] == $id) {
                        $arena_team2["played_week"] = $arena_team2["player2_week_played"];
                        $arena_team2["wons_week"] = $arena_team2["player2_week_wins"];
                        $arena_team2["played_season"] = $arena_team2["player2_season_played"];
                        $arena_team2["wons_season"] = $arena_team2["player2_season_wins"];
                        $arena_team2["personal_rating"] = $arena_team2["player2_rating"];
                    }
                    if ($arena_team2["player3_id"] == $id) {
                        $arena_team2["played_week"] = $arena_team2["player3_week_played"];
                        $arena_team2["wons_week"] = $arena_team2["player3_week_wins"];
                        $arena_team2["played_season"] = $arena_team2["player3_season_played"];
                        $arena_team2["wons_season"] = $arena_team2["player3_season_wins"];
                        $arena_team2["personal_rating"] = $arena_team2["player3_rating"];
                    }
                    if ($arena_team2["player4_id"] == $id) {
                        $arena_team2["played_week"] = $arena_team2["player4_week_played"];
                        $arena_team2["wons_week"] = $arena_team2["player4_week_wins"];
                        $arena_team2["played_season"] = $arena_team2["player4_season_played"];
                        $arena_team2["wons_season"] = $arena_team2["player4_season_wins"];
                        $arena_team2["personal_rating"] = $arena_team2["player4_rating"];
                    }
                    if ($arena_team2["player5_id"] == $id) {
                        $arena_team2["played_week"] = $arena_team2["player5_week_played"];
                        $arena_team2["wons_week"] = $arena_team2["player5_week_wins"];
                        $arena_team2["played_season"] = $arena_team2["player5_season_played"];
                        $arena_team2["wons_season"] = $arena_team2["player5_season_wins"];
                        $arena_team2["personal_rating"] = $arena_team2["player5_rating"];
                    }
                    if ($arena_team2["player6_id"] == $id) {
                        $arena_team2["played_week"] = $arena_team2["player6_week_played"];
                        $arena_team2["wons_week"] = $arena_team2["player6_week_wins"];
                        $arena_team2["played_season"] = $arena_team2["player6_season_played"];
                        $arena_team2["wons_season"] = $arena_team2["player6_season_wins"];
                        $arena_team2["personal_rating"] = $arena_team2["player6_rating"];
                    }
                    if ($arena_team2["player7_id"] == $id) {
                        $arena_team2["played_week"] = $arena_team2["player7_week_played"];
                        $arena_team2["wons_week"] = $arena_team2["player7_week_wins"];
                        $arena_team2["played_season"] = $arena_team2["player7_season_played"];
                        $arena_team2["wons_season"] = $arena_team2["player7_season_wins"];
                        $arena_team2["personal_rating"] = $arena_team2["player7_rating"];
                    }
                    if ($arena_team2["player8_id"] == $id) {
                        $arena_team2["played_week"] = $arena_team2["player8_week_played"];
                        $arena_team2["wons_week"] = $arena_team2["player8_week_wins"];
                        $arena_team2["played_season"] = $arena_team2["player8_season_played"];
                        $arena_team2["wons_season"] = $arena_team2["player8_season_wins"];
                        $arena_team2["personal_rating"] = $arena_team2["player8_rating"];
                    }
                    if ($arena_team2["player9_id"] == $id) {
                        $arena_team2["played_week"] = $arena_team2["player9_week_played"];
                        $arena_team2["wons_week"] = $arena_team2["player9_week_wins"];
                        $arena_team2["played_season"] = $arena_team2["player9_season_played"];
                        $arena_team2["wons_season"] = $arena_team2["player9_season_wins"];
                        $arena_team2["personal_rating"] = $arena_team2["player9_rating"];
                    }
                    if ($arena_team2["player10_id"] == $id) {
                        $arena_team2["played_week"] = $arena_team2["player10_week_played"];
                        $arena_team2["wons_week"] = $arena_team2["player10_week_wins"];
                        $arena_team2["played_season"] = $arena_team2["player10_season_played"];
                        $arena_team2["wons_season"] = $arena_team2["player10_season_wins"];
                        $arena_team2["personal_rating"] = $arena_team2["player10_rating"];
                    }
                }
                $output .= '
                    <tr>
                      <td rowspan="9" class="ch_pvp_banner_space">
                        <div class="arena_banner">
                          <img src="libs/banner_lib.php?action=banner&amp;f=' . $arenateam_data2["banner_style"] . '&amp;r=' . $arenateam_data2["BackgroundColor"][1] . '&amp;g=' . $arenateam_data2["BackgroundColor"][2] . '&amp;b=' . $arenateam_data2["BackgroundColor"][3] . '" class="banner_img" alt="" />
                          <img src="libs/banner_lib.php?action=border&amp;f=' . $arenateam_data2["BorderStyle"] . '&amp;f2=' . $arenateam_data2["banner_style"] . '&amp;r=' . $arenateam_data2["BorderColor"][1] . '&amp;g=' . $arenateam_data2["BorderColor"][2] . '&amp;b=' . $arenateam_data2["BorderColor"][3] . '" class="border_img" alt="" />
                          <img src="libs/banner_lib.php?action=emblem&amp;f=' . $arenateam_data2["EmblemStyle"] . '&amp;r=' . $arenateam_data2["EmblemColor"][1] . '&amp;g=' . $arenateam_data2["EmblemColor"][2] . '&amp;b=' . $arenateam_data2["EmblemColor"][3] . '&amp;s=0.55" class="emblem_img" alt="" />
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td colspan="2"><a href="arenateam.php?action=view_team&amp;error=3&amp;id=' . $arenateam_data2["id"] . '">' . $arenateam_data2["name"] . '</a></td>
                      <td colspan="2">' . lang("char", "team") . ' ' . lang("char", "rating") . ': <span class="ch_pvp_highlight">' . $arena_team2["rating"] . '</span></td>
                    </tr>
                    <tr>
                      <td><span class="ch_pvp_dim">' . lang("char", "team") . '</span></td>
                      <td>' . lang("char", "games") . '</td>
                      <td>' . lang("char", "winloss") . '</td>
                      <td>' . lang("char", "ratio") . '</td>
                    </tr>
                    <tr>
                      <td>' . lang("char", "thisweek") . '</td>
                      <td>' . $arena_team2["games"] . '</td>
                      <td>' . $arena_team2["wins"] . '-' . ($arena_team2["games"] - $arena_team2["wins"]) . '</td>
                      <td>' . $arena_team2["wins"] / $arena_team2["games"] * 100 . '%</td>
                    </tr>
                    <tr>
                      <td>' . lang("char", "thisseason") . '</td>
                      <td>' . $arena_team2["played"] . '</td>
                      <td>' . $arena_team2["wins2"] . '-' . ($arena_team2["played"] - $arena_team2["wins2"]) . '</td>
                      <td>' . $arena_team2["wins2"] / $arena_team2["played"] * 100 . '%</td>
                    </tr>
                    <tr>
                      <td colspan="2">
                        <span class="ch_pvp_dim">' . $char["name"] . '</span>
                      </td>
                      <td colspan="2">
                        <span>' . lang("char", "rating") . '</span>: <span class="ch_pvp_highlight">' . $arena_team2["personal_rating"] . '</span>
                      </td>
                    </tr>
                    <tr>
                      <td colspan="2"></td>
                      <td>' . lang("char", "played") . '</td>
                      <td>' . lang("char", "winloss") . '</td>
                    </tr>
                    <tr>
                      <td colspan="2">' . lang("char", "thisweek") . '</td>
                      <td>' . $arena_team2["played_week"] . '</td>
                      <td>' . $arena_team2["wons_week"] . '-' . ($arena_team2["played_week"] - $arena_team2["wons_week"]) . '</td>
                    </tr>
                    <tr>
                      <td colspan="2">' . lang("char", "thisseason") . '</td>
                      <td>' . $arena_team2["played_season"] . '</td>
                      <td>' . $arena_team2["wons_season"] . '-' . ($arena_team2["played_season"] - $arena_team2["wons_season"]) . '</td>
                    </tr>';
            } else {
                $output .= '
                    <tr>
                      <td rowspan="9" class="ch_pvp_banner_space">
                        <div class="arena_banner">
                          <img src="img/blank.gif" class="banner_img" alt="" />
                          <img src="img/blank.gif" class="border_img" alt="" />
                          <img src="img/blank.gif" class="emblem_img" alt="" />
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4"><span class="ch_pvp_dim">(' . lang("arenateam", "2MT") . ')</span></td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>';
            }
            if ($arena_team3 != NULL) {
                // ArcEmu: find the data set that is ours
                if ($core == 1) {
                    if ($arena_team3["player1_id"] == $id) {
                        $arena_team3["played_week"] = $arena_team3["player1_week_played"];
                        $arena_team3["wons_week"] = $arena_team3["player1_week_wins"];
                        $arena_team3["played_season"] = $arena_team3["player1_season_played"];
                        $arena_team3["wons_season"] = $arena_team3["player1_season_wins"];
                        $arena_team3["personal_rating"] = $arena_team3["player1_rating"];
                    }
                    if ($arena_team3["player2_id"] == $id) {
                        $arena_team3["played_week"] = $arena_team3["player2_week_played"];
                        $arena_team3["wons_week"] = $arena_team3["player2_week_wins"];
                        $arena_team3["played_season"] = $arena_team3["player2_season_played"];
                        $arena_team3["wons_season"] = $arena_team3["player2_season_wins"];
                        $arena_team3["personal_rating"] = $arena_team3["player2_rating"];
                    }
                    if ($arena_team3["player3_id"] == $id) {
                        $arena_team3["played_week"] = $arena_team3["player3_week_played"];
                        $arena_team3["wons_week"] = $arena_team3["player3_week_wins"];
                        $arena_team3["played_season"] = $arena_team3["player3_season_played"];
                        $arena_team3["wons_season"] = $arena_team3["player3_season_wins"];
                        $arena_team3["personal_rating"] = $arena_team3["player3_rating"];
                    }
                    if ($arena_team3["player4_id"] == $id) {
                        $arena_team3["played_week"] = $arena_team3["player4_week_played"];
                        $arena_team3["wons_week"] = $arena_team3["player4_week_wins"];
                        $arena_team3["played_season"] = $arena_team3["player4_season_played"];
                        $arena_team3["wons_season"] = $arena_team3["player4_season_wins"];
                        $arena_team3["personal_rating"] = $arena_team3["player4_rating"];
                    }
                    if ($arena_team3["player5_id"] == $id) {
                        $arena_team3["played_week"] = $arena_team3["player5_week_played"];
                        $arena_team3["wons_week"] = $arena_team3["player5_week_wins"];
                        $arena_team3["played_season"] = $arena_team3["player5_season_played"];
                        $arena_team3["wons_season"] = $arena_team3["player5_season_wins"];
                        $arena_team3["personal_rating"] = $arena_team3["player5_rating"];
                    }
                    if ($arena_team3["player6_id"] == $id) {
                        $arena_team3["played_week"] = $arena_team3["player6_week_played"];
                        $arena_team3["wons_week"] = $arena_team3["player6_week_wins"];
                        $arena_team3["played_season"] = $arena_team3["player6_season_played"];
                        $arena_team3["wons_season"] = $arena_team3["player6_season_wins"];
                        $arena_team3["personal_rating"] = $arena_team3["player6_rating"];
                    }
                    if ($arena_team3["player7_id"] == $id) {
                        $arena_team3["played_week"] = $arena_team3["player7_week_played"];
                        $arena_team3["wons_week"] = $arena_team3["player7_week_wins"];
                        $arena_team3["played_season"] = $arena_team3["player7_season_played"];
                        $arena_team3["wons_season"] = $arena_team3["player7_season_wins"];
                        $arena_team3["personal_rating"] = $arena_team3["player7_rating"];
                    }
                    if ($arena_team3["player8_id"] == $id) {
                        $arena_team3["played_week"] = $arena_team3["player8_week_played"];
                        $arena_team3["wons_week"] = $arena_team3["player8_week_wins"];
                        $arena_team3["played_season"] = $arena_team3["player8_season_played"];
                        $arena_team3["wons_season"] = $arena_team3["player8_season_wins"];
                        $arena_team3["personal_rating"] = $arena_team3["player8_rating"];
                    }
                    if ($arena_team3["player9_id"] == $id) {
                        $arena_team3["played_week"] = $arena_team3["player9_week_played"];
                        $arena_team3["wons_week"] = $arena_team3["player9_week_wins"];
                        $arena_team3["played_season"] = $arena_team3["player9_season_played"];
                        $arena_team3["wons_season"] = $arena_team3["player9_season_wins"];
                        $arena_team3["personal_rating"] = $arena_team3["player9_rating"];
                    }
                    if ($arena_team3["player10_id"] == $id) {
                        $arena_team3["played_week"] = $arena_team3["player10_week_played"];
                        $arena_team3["wons_week"] = $arena_team3["player10_week_wins"];
                        $arena_team3["played_season"] = $arena_team3["player10_season_played"];
                        $arena_team3["wons_season"] = $arena_team3["player10_season_wins"];
                        $arena_team3["personal_rating"] = $arena_team3["player10_rating"];
                    }
                }
                $output .= '
                    <tr>
                      <td rowspan="9" class="ch_pvp_banner_space">
                        <div class="arena_banner">
                          <img src="libs/banner_lib.php?action=banner&amp;f=' . $arenateam_data3["banner_style"] . '&amp;r=' . $arenateam_data3["BackgroundColor"][1] . '&amp;g=' . $arenateam_data3["BackgroundColor"][2] . '&amp;b=' . $arenateam_data3["BackgroundColor"][3] . '" class="banner_img" alt="" />
                          <img src="libs/banner_lib.php?action=border&amp;f=' . $arenateam_data3["BorderStyle"] . '&amp;f2=' . $arenateam_data3["banner_style"] . '&amp;r=' . $arenateam_data3["BorderColor"][1] . '&amp;g=' . $arenateam_data3["BorderColor"][2] . '&amp;b=' . $arenateam_data3["BorderColor"][3] . '" class="border_img" alt="" />
                          <img src="libs/banner_lib.php?action=emblem&amp;f=' . $arenateam_data3["EmblemStyle"] . '&amp;r=' . $arenateam_data3["EmblemColor"][1] . '&amp;g=' . $arenateam_data3["EmblemColor"][2] . '&amp;b=' . $arenateam_data3["EmblemColor"][3] . '&amp;s=0.55" class="emblem_img" alt="" />
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td colspan="2"><a href="arenateam.php?action=view_team&amp;error=3&amp;id=' . $arenateam_data3["id"] . '">' . $arenateam_data3["name"] . '</a></td>
                      <td colspan="2">' . lang("char", "team") . ' ' . lang("char", "rating") . ': <span class="ch_pvp_highlight">' . $arena_team3["rating"] . '</span></td>
                    </tr>
                    <tr>
                      <td><span class="ch_pvp_dim">' . lang("char", "team") . '</span></td>
                      <td>' . lang("char", "games") . '</td>
                      <td>' . lang("char", "winloss") . '</td>
                      <td>' . lang("char", "ratio") . '</td>
                    </tr>
                    <tr>
                      <td>' . lang("char", "thisweek") . '</td>
                      <td>' . $arena_team3["games"] . '</td>
                      <td>' . $arena_team3["wins"] . '-' . ($arena_team3["games"] - $arena_team3["wins"]) . '</td>
                      <td>' . $arena_team3["wins"] / $arena_team3["games"] * 100 . '%</td>
                    </tr>
                    <tr>
                      <td>' . lang("char", "thisseason") . '</td>
                      <td>' . $arena_team3["played"] . '</td>
                      <td>' . $arena_team3["wins2"] . '-' . ($arena_team3["played"] - $arena_team3["wins2"]) . '</td>
                      <td>' . $arena_team3["wins2"] / $arena_team3["played"] * 100 . '%</td>
                    </tr>
                    <tr>
                      <td colspan="2">
                        <span class="ch_pvp_dim">' . $char["name"] . '</span>
                      </td>
                      <td colspan="2">
                        <span>' . lang("char", "rating") . '</span>: <span class="ch_pvp_highlight">' . $arena_team3["personal_rating"] . '</span>
                      </td>
                    </tr>
                    <tr>
                      <td colspan="2"></td>
                      <td>' . lang("char", "played") . '</td>
                      <td>' . lang("char", "winloss") . '</td>
                    </tr>
                    <tr>
                      <td colspan="2">' . lang("char", "thisweek") . '</td>
                      <td>' . $arena_team3["played_week"] . '</td>
                      <td>' . $arena_team3["wons_week"] . '-' . ($arena_team3["played_week"] - $arena_team3["wons_week"]) . '</td>
                    </tr>
                    <tr>
                      <td colspan="2">' . lang("char", "thisseason") . '</td>
                      <td>' . $arena_team3["played_season"] . '</td>
                      <td>' . $arena_team3["wons_season"] . '-' . ($arena_team3["played_season"] - $arena_team3["wons_season"]) . '</td>
                    </tr>';
            } else {
                $output .= '
                    <tr>
                      <td rowspan="9" class="ch_pvp_banner_space">
                        <div class="arena_banner">
                          <img src="img/blank.gif" class="banner_img" alt="" />
                          <img src="img/blank.gif" class="border_img" alt="" />
                          <img src="img/blank.gif" class="emblem_img" alt="" />
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4"><span class="ch_pvp_dim">(' . lang("arenateam", "3MT") . ')</span></td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>';
            }
            if ($arena_team5 != NULL) {
                // ArcEmu: find the data set that is ours
                if ($core == 1) {
                    if ($arena_team5["player1_id"] == $id) {
                        $arena_team5["played_week"] = $arena_team5["player1_week_played"];
                        $arena_team5["wons_week"] = $arena_team5["player1_week_wins"];
                        $arena_team5["played_season"] = $arena_team5["player1_season_played"];
                        $arena_team5["wons_season"] = $arena_team5["player1_season_wins"];
                        $arena_team5["personal_rating"] = $arena_team5["player1_rating"];
                    }
                    if ($arena_team5["player2_id"] == $id) {
                        $arena_team5["played_week"] = $arena_team5["player2_week_played"];
                        $arena_team5["wons_week"] = $arena_team5["player2_week_wins"];
                        $arena_team5["played_season"] = $arena_team5["player2_season_played"];
                        $arena_team5["wons_season"] = $arena_team5["player2_season_wins"];
                        $arena_team5["personal_rating"] = $arena_team5["player2_rating"];
                    }
                    if ($arena_team5["player3_id"] == $id) {
                        $arena_team5["played_week"] = $arena_team5["player3_week_played"];
                        $arena_team5["wons_week"] = $arena_team5["player3_week_wins"];
                        $arena_team5["played_season"] = $arena_team5["player3_season_played"];
                        $arena_team5["wons_season"] = $arena_team5["player3_season_wins"];
                        $arena_team5["personal_rating"] = $arena_team5["player3_rating"];
                    }
                    if ($arena_team5["player4_id"] == $id) {
                        $arena_team5["played_week"] = $arena_team5["player4_week_played"];
                        $arena_team5["wons_week"] = $arena_team5["player4_week_wins"];
                        $arena_team5["played_season"] = $arena_team5["player4_season_played"];
                        $arena_team5["wons_season"] = $arena_team5["player4_season_wins"];
                        $arena_team5["personal_rating"] = $arena_team5["player4_rating"];
                    }
                    if ($arena_team5["player5_id"] == $id) {
                        $arena_team5["played_week"] = $arena_team5["player5_week_played"];
                        $arena_team5["wons_week"] = $arena_team5["player5_week_wins"];
                        $arena_team5["played_season"] = $arena_team5["player5_season_played"];
                        $arena_team5["wons_season"] = $arena_team5["player5_season_wins"];
                        $arena_team5["personal_rating"] = $arena_team5["player5_rating"];
                    }
                    if ($arena_team5["player6_id"] == $id) {
                        $arena_team5["played_week"] = $arena_team5["player6_week_played"];
                        $arena_team5["wons_week"] = $arena_team5["player6_week_wins"];
                        $arena_team5["played_season"] = $arena_team5["player6_season_played"];
                        $arena_team5["wons_season"] = $arena_team5["player6_season_wins"];
                        $arena_team5["personal_rating"] = $arena_team5["player6_rating"];
                    }
                    if ($arena_team5["player7_id"] == $id) {
                        $arena_team5["played_week"] = $arena_team5["player7_week_played"];
                        $arena_team5["wons_week"] = $arena_team5["player7_week_wins"];
                        $arena_team5["played_season"] = $arena_team5["player7_season_played"];
                        $arena_team5["wons_season"] = $arena_team5["player7_season_wins"];
                        $arena_team5["personal_rating"] = $arena_team5["player7_rating"];
                    }
                    if ($arena_team5["player8_id"] == $id) {
                        $arena_team5["played_week"] = $arena_team5["player8_week_played"];
                        $arena_team5["wons_week"] = $arena_team5["player8_week_wins"];
                        $arena_team5["played_season"] = $arena_team5["player8_season_played"];
                        $arena_team5["wons_season"] = $arena_team5["player8_season_wins"];
                        $arena_team5["personal_rating"] = $arena_team5["player8_rating"];
                    }
                    if ($arena_team5["player9_id"] == $id) {
                        $arena_team5["played_week"] = $arena_team5["player9_week_played"];
                        $arena_team5["wons_week"] = $arena_team5["player9_week_wins"];
                        $arena_team5["played_season"] = $arena_team5["player9_season_played"];
                        $arena_team5["wons_season"] = $arena_team5["player9_season_wins"];
                        $arena_team5["personal_rating"] = $arena_team5["player9_rating"];
                    }
                    if ($arena_team5["player10_id"] == $id) {
                        $arena_team5["played_week"] = $arena_team5["player10_week_played"];
                        $arena_team5["wons_week"] = $arena_team5["player10_week_wins"];
                        $arena_team5["played_season"] = $arena_team5["player10_season_played"];
                        $arena_team5["wons_season"] = $arena_team5["player10_season_wins"];
                        $arena_team5["personal_rating"] = $arena_team5["player10_rating"];
                    }
                }
                $output .= '
                    <tr>
                      <td rowspan="9" class="ch_pvp_banner_space">
                        <div class="arena_banner">
                          <img src="libs/banner_lib.php?action=banner&amp;f=' . $arenateam_data5["banner_style"] . '&amp;r=' . $arenateam_data5["BackgroundColor"][1] . '&amp;g=' . $arenateam_data5["BackgroundColor"][2] . '&amp;b=' . $arenateam_data5["BackgroundColor"][3] . '" class="banner_img" alt="" />
                          <img src="libs/banner_lib.php?action=border&amp;f=' . $arenateam_data5["BorderStyle"] . '&amp;f2=' . $arenateam_data5["banner_style"] . '&amp;r=' . $arenateam_data5["BorderColor"][1] . '&amp;g=' . $arenateam_data5["BorderColor"][2] . '&amp;b=' . $arenateam_data5["BorderColor"][3] . '" class="border_img" alt="" />
                          <img src="libs/banner_lib.php?action=emblem&amp;f=' . $arenateam_data5["EmblemStyle"] . '&amp;r=' . $arenateam_data5["EmblemColor"][1] . '&amp;g=' . $arenateam_data5["EmblemColor"][2] . '&amp;b=' . $arenateam_data5["EmblemColor"][3] . '&amp;s=0.55" class="emblem_img" alt="" />
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td colspan="2"><a href="arenateam.php?action=view_team&amp;error=3&amp;id=' . $arenateam_data5["id"] . '">' . $arenateam_data5["name"] . '</a></td>
                      <td colspan="2">' . lang("char", "team") . ' ' . lang("char", "rating") . ': <span class="ch_pvp_highlight">' . $arena_team5["rating"] . '</span></td>
                    </tr>
                    <tr>
                      <td><span class="ch_pvp_dim">' . lang("char", "team") . '</span></td>
                      <td>' . lang("char", "games") . '</td>
                      <td>' . lang("char", "winloss") . '</td>
                      <td>' . lang("char", "ratio") . '</td>
                    </tr>
                    <tr>
                      <td>' . lang("char", "thisweek") . '</td>
                      <td>' . $arena_team5["games"] . '</td>
                      <td>' . $arena_team5["wins"] . '-' . ($arena_team5["games"] - $arena_team5["wins"]) . '</td>
                      <td>' . $arena_team5["wins"] / $arena_team5["games"] * 100 . '%</td>
                    </tr>
                    <tr>
                      <td>' . lang("char", "thisseason") . '</td>
                      <td>' . $arena_team5["played"] . '</td>
                      <td>' . $arena_team5["wins2"] . '-' . ($arena_team5["played"] - $arena_team5["wins2"]) . '</td>
                      <td>' . $arena_team5["wins2"] / $arena_team5["played"] * 100 . '%</td>
                    </tr>
                    <tr>
                      <td colspan="2">
                        <span class="ch_pvp_dim">' . $char["name"] . '</span>
                      </td>
                      <td colspan="2">
                        <span>' . lang("char", "rating") . '</span>: <span class="ch_pvp_highlight">' . $arena_team2["personal_rating"] . '</span>
                      </td>
                    </tr>
                    <tr>
                      <td colspan="2"></td>
                      <td>' . lang("char", "played") . '</td>
                      <td>' . lang("char", "winloss") . '</td>
                    </tr>
                    <tr>
                      <td colspan="2">' . lang("char", "thisweek") . '</td>
                      <td>' . $arena_team5["played_week"] . '</td>
                      <td>' . $arena_team5["wons_week"] . '-' . ($arena_team5["played_week"] - $arena_team5["wons_week"]) . '</td>
                    </tr>
                    <tr>
                      <td colspan="2">' . lang("char", "thisseason") . '</td>
                      <td>' . $arena_team5["played_season"] . '</td>
                      <td>' . $arena_team5["wons_season"] . '-' . ($arena_team5["played_season"] - $arena_team5["wons_season"]) . '</td>
                    </tr>';
            } else {
                $output .= '
                    <tr>
                      <td rowspan="9" class="ch_pvp_banner_space">
                        <div class="arena_banner">
                          <img src="img/blank.gif" class="banner_img" alt="" />
                          <img src="img/blank.gif" class="border_img" alt="" />
                          <img src="img/blank.gif" class="emblem_img" alt="" />
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4"><span class="ch_pvp_dim">(' . lang("arenateam", "5MT") . ')</span></td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>';
            }
            $output .= '
                </table>
                <br />
              </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;id=' . $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>';
            }
            // 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_achieve.php -->';
        } else {
            error(lang("char", "no_permission"));
        }
    } else {
        error(lang("char", "no_char_found"));
    }
}