コード例 #1
0
ファイル: index.php プロジェクト: BACKUPLIB/minimanager-1
function index(&$sqlr, &$sqlc, &$sqlm)
{
    global $output, $lang_global, $lang_index, $realm_id, $mmfpm_db, $server, $action_permission, $user_lvl, $user_id, $showcountryflag, $motd_display_poster, $gm_online_count, $gm_online, $itemperpage;
    $output .= '
<div class="top">';
    if (test_port($server[$realm_id]['addr'], $server[$realm_id]['game_port'])) {
        $stats = $sqlr->fetch_assoc($sqlr->query('
			SELECT starttime, maxplayers 
			FROM uptime 
			WHERE realmid = ' . $realm_id . ' 
			ORDER BY starttime DESC 
			LIMIT 1'), 0);
        $uptimetime = time() - $stats['starttime'];
        $max_ever = $sqlr->fetch_assoc($sqlr->query('
			SELECT maxplayers
			FROM uptime
			WHERE realmid = ' . $realm_id . '
			ORDER BY maxplayers DESC
			LIMIT 1'), 0);
        function format_uptime($seconds)
        {
            $secs = intval($seconds % 60);
            $mins = intval($seconds / 60 % 60);
            $hours = intval($seconds / 3600 % 24);
            $days = intval($seconds / 86400);
            $uptimeString = '';
            if ($days) {
                $uptimeString .= $days;
                $uptimeString .= 1 === $days ? ' day' : ' days';
            }
            if ($hours) {
                $uptimeString .= (0 < $days ? ', ' : '') . $hours;
                $uptimeString .= 1 === $hours ? ' hour' : ' hours';
            }
            if ($mins) {
                $uptimeString .= (0 < $days || 0 < $hours ? ', ' : '') . $mins;
                $uptimeString .= 1 === $mins ? ' minute' : ' minutes';
            }
            if ($secs) {
                $uptimeString .= (0 < $days || 0 < $hours || 0 < $mins ? ', ' : '') . $secs;
                $uptimeString .= 1 === $secs ? ' second' : ' seconds';
            }
            return $uptimeString;
        }
        $staticUptime = $lang_index['realm'] . ' <em>' . htmlentities(get_realm_name($realm_id)) . '</em> ' . $lang_index['online'] . ' for ' . format_uptime($uptimetime);
        unset($uptimetime);
        $output .= '
	<div id="uptime">
		<h1><font color="#55aa55">' . $staticUptime . '</font><br /></h1>
	</div>
</div>';
        unset($staticUptime);
        $online = true;
    } else {
        $output .= '
	<h1><font class="error">' . $lang_index['realm'] . ' <em>' . htmlentities(get_realm_name($realm_id)) . '</em> ' . $lang_index['offline_or_let_high'] . '</font></h1>
</div>';
        $online = false;
    }
    $output .= '
<center>
<fieldset>
	<legend>Info</legend>
	<table class="lined" style="width: 100%; display: table">
		<tr>
			<th>
				' . $lang_index['maxplayers'] . ': ' . $stats['maxplayers'] . '<br />
				' . $lang_index['maxplayersever'] . ': ' . $max_ever['maxplayers'] . '
			</th>
		</tr>
	</table>
</fieldset>';
    unset($max_ever);
    unset($stats);
    $start_m = isset($_GET['start_m']) ? $sqlc->quote_smart($_GET['start_m']) : 0;
    if (is_numeric($start_m)) {
    } else {
        $start_m = 0;
    }
    //print online chars
    if ($online) {
        //==========================$_GET and SECURE=================================
        $start = isset($_GET['start']) ? $sqlc->quote_smart($_GET['start']) : 0;
        if (is_numeric($start)) {
        } else {
            $start = 0;
        }
        $order_by = isset($_GET['order_by']) ? $sqlc->quote_smart($_GET['order_by']) : 'level';
        if (preg_match('/^[_[:lower:]]{1,12}$/', $order_by)) {
        } else {
            $order_by = 'level';
        }
        $dir = isset($_GET['dir']) ? $sqlc->quote_smart($_GET['dir']) : 1;
        if (preg_match('/^[01]{1}$/', $dir)) {
        } else {
            $dir = 1;
        }
        $order_dir = $dir ? 'DESC' : 'ASC';
        $dir = $dir ? 0 : 1;
        //==========================$_GET and SECURE end=============================
        if ($order_by === 'map') {
            $order_by = 'map ' . $order_dir . ', zone';
        } elseif ($order_by === 'zone') {
            $order_by = 'zone ' . $order_dir . ', map';
        }
        $order_side = '';
        if ($user_lvl || $server[$realm_id]['both_factions']) {
        } else {
            $result = $sqlc->query('
				SELECT race 
				FROM characters 
				WHERE account = ' . $user_id . '	AND totaltime = 
					(SELECT MAX(totaltime) 
					FROM characters 
					WHERE account = ' . $user_id . ') 
				LIMIT 1');
            if ($sqlc->num_rows($result)) {
                $order_side = in_array($sqlc->result($result, 0), array(2, 5, 6, 8, 10)) ? ' AND race IN (2,5,6,8,10) ' : ' AND race IN (1,3,4,7,11) ';
            }
        }
        if ($order_by == 'ip') {
            $result = $sqlr->query('
				SELECT id, last_ip 
				FROM account 
				WHERE active_realm_id  != 1 
				ORDER BY last_ip ' . $order_dir . ' 
				LIMIT ' . $start . ', ' . $itemperpage . '');
        } else {
            $result = $sqlc->query('
				SELECT c.guid, c.name, c.race, c.class, c.zone, c.map, c.level, c.account, c.gender, c.totalHonorPoints,
					COALESCE(guild_member.guildid,0) AS guildid 
				FROM characters c
					LEFT JOIN guild_member ON guild_member.guid = c.guid 
				WHERE c.online = 1 ' . ($gm_online == '0' ? 'AND c.extra_flags &1 = 0 ' : '') . $order_side . ' 
				ORDER BY ' . $order_by . ' ' . $order_dir . ' LIMIT ' . $start . ', ' . $itemperpage);
        }
        $total_online = $sqlc->result($sqlc->query('
				SELECT count(*)
				FROM characters
				WHERE online= 1' . ($gm_online_count == '0' ? ' AND extra_flags &1 = 0' : '')), 0);
        $output .= '
<center>
<fieldset>
	<legend>' . $lang_index['tot_users_online'] . ': ' . $total_online . '</legend>
	<table class="lined" style="width: 100%; display: table">

	<tr>
		<td colspan="' . (10 - $showcountryflag) . '" align="right" class="hidden" width="25%">';
        $output .= generate_pagination('index.php?start_m=' . $start_m . '&amp;order_by=' . $order_by . '&amp;dir=' . ($dir ? 0 : 1), $total_online, $itemperpage, $start);
        $output .= '
		</td>
	</tr>
	<tr>
		<th width="15%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=name&amp;dir=' . $dir . '"' . ($order_by === 'name' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['name'] . '</a></th>
		<th width="1%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=race&amp;dir=' . $dir . '"' . ($order_by === 'race' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['race'] . '</a></th>
		<th width="1%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=class&amp;dir=' . $dir . '"' . ($order_by === 'class' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['class'] . '</a></th>
		<th width="5%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=level&amp;dir=' . $dir . '"' . ($order_by === 'level' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['level'] . '</a></th>
		<th width="1%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=totalHonorPoints&amp;dir=' . $dir . '"' . ($order_by === 'totalHonorPoints' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['rank'] . '</a></th>
		<th width="15%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=guildid&amp;dir=' . $dir . '"' . ($order_by === 'gname' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['guild'] . '</a></th>
		<th width="20%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=map&amp;dir=' . $dir . '"' . ($order_by === 'map ' . $order_dir . ', zone' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['map'] . '</a></th>
		<th width="25%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=zone&amp;dir=' . $dir . '"' . ($order_by === 'zone ' . $order_dir . ', map' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['zone'] . '</a></th>';
        if ($showcountryflag) {
            require_once 'libs/misc_lib.php';
            $output .= '
		<th width="1%">' . $lang_global['country'] . '</th>';
        }
        $output .= '
	</tr>';
        $sqlm = new SQL();
        $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
        while ($char = $sqlc->fetch_assoc($result)) {
            if ($order_by == 'ip') {
                $temp = $sqlc->fetch_assoc($sqlc->query('
					SELECT characters.guid, characters.name, characters.race, characters.class, characters.zone, characters.map, characters.level, characters.account, characters.gender, characters.totalHonorPoints,
						COALESCE(guild_member.guildid,0) AS guildid 
					FROM characters LEFT JOIN guild_member ON guild_member.guid = characters.guid 
					WHERE characters.online= 1 ' . ($gm_online == '0' ? 'AND characters.extra_flags &1 = 0 ' : '') . $order_side . ' and account = ' . $char['id']));
                if (isset($temp['guid'])) {
                    $char = $temp;
                } else {
                    continue;
                }
            }
            $gm = $sqlr->result($sqlr->query('
			SELECT gmlevel 
			FROM account 
			WHERE id=' . $char['account'] . ''), 0);
            $guild_name = $sqlc->result($sqlc->query('
			SELECT name 
			FROM guild 
			WHERE guildid=' . $char['guildid'] . ''));
            $output .= '
	<tr>
		<td>';
            if ($user_lvl >= $gm) {
                $output .= '
			<a href="char.php?id=' . $char['guid'] . '">
				<span onmousemove="toolTip(\'' . id_get_gm_level($gm) . '\', \'item_tooltip\')" onmouseout="toolTip()">' . htmlentities($char['name']) . '</span>
			</a>';
            } else {
                $output .= '
			' . htmlentities($char['name']) . '</span>';
            }
            $output .= '
		</td>
		<td>
			<img src="img/c_icons/' . $char['race'] . '-' . $char['gender'] . '.gif" onmousemove="toolTip(\'' . char_get_race_name($char['race']) . '\', \'item_tooltip\')" onmouseout="toolTip()" alt="" />
		</td>
		<td>
			<img src="img/c_icons/' . $char['class'] . '.gif" onmousemove="toolTip(\'' . char_get_class_name($char['class']) . '\', \'item_tooltip\')" onmouseout="toolTip()" alt="" />
		</td>
		<td>' . char_get_level_color($char['level']) . '</td>
		<td>
			<span onmouseover="toolTip(\'' . char_get_pvp_rank_name($char['totalHonorPoints'], char_get_side_id($char['race'])) . '\', \'item_tooltip\')" onmouseout="toolTip()" style="color: white;"><img src="img/ranks/rank' . char_get_pvp_rank_id($char['totalHonorPoints'], char_get_side_id($char['race'])) . '.gif" alt="" /></span>
		</td>
		<td>
			<a href="guild.php?action=view_guild&amp;error=3&amp;id=' . $char['guildid'] . '">' . htmlentities($guild_name) . '</a>
		</td>
		<td>
			<span onmousemove="toolTip(\'MapID:' . $char['map'] . '\', \'item_tooltip\')" onmouseout="toolTip()">' . get_map_name($char['map'], $sqlm) . '</span>
		</td>
		<td>
			<span onmousemove="toolTip(\'ZoneID:' . $char['zone'] . '\', \'item_tooltip\')" onmouseout="toolTip()">' . get_zone_name($char['zone'], $sqlm) . '</span>
		</td>';
            if ($showcountryflag) {
                $country = misc_get_country_by_account($char['account'], $sqlr, $sqlm);
                $output .= '
		<td>
			' . ($country['code'] ? '<img src="img/flags/' . $country['code'] . '.png" onmousemove="toolTip(\'' . $country['country'] . '\',\'item_tooltip\')" onmouseout="toolTip()" alt="" />' : '-') . '
		</td>';
            }
            $output .= '
	</tr>';
        }
        $output .= '
	<tr>';
        $output .= '
		<td colspan="' . (10 - $showcountryflag) . '" align="right" class="hidden" width="25%">';
        $output .= generate_pagination('index.php?start_m=' . $start_m . '&amp;order_by=' . $order_by . '&amp;dir=' . ($dir ? 0 : 1), $total_online, $itemperpage, $start);
        unset($total_online);
        $output .= '
		</td>
	</tr>
	</table>
</fieldset>
<br />
</center>';
    }
}
コード例 #2
0
ファイル: honor.php プロジェクト: xhaher/CoreManager
        $guild_name = $guild_name["name"];
    }
    $output .= '
            <tr>
              <td>
                <a href="char.php?id=' . $char["guid"] . '">' . htmlentities($char["name"], ENT_COMPAT, $site_encoding) . '</a>
              </td>
              <td>
                <img src="img/c_icons/' . $char["race"] . '-' . $char["gender"] . '.gif" onmousemove="oldtoolTip(\'' . char_get_race_name($char["race"]) . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />
              </td>
              <td>
                <img src="img/c_icons/' . $char["class"] . '.gif" onmousemove="oldtoolTip(\'' . char_get_class_name($char["class"]) . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />
              </td>
              <td>' . char_get_level_color($char["level"]) . '</td>
              <td>
                <span onmouseover="oldtoolTip(\'' . char_get_pvp_rank_name($char["honor"], char_get_side_id($char["race"])) . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()" class="honor_tooltip">
                  <img src="img/ranks/rank' . char_get_pvp_rank_id($char["honor"], char_get_side_id($char["race"])) . '.gif" alt="" />
                </span>
              </td>
              <td>' . $char["honor"] . '</td>
              <td>' . $char["kills"] . '</td>
              <td>' . $char["arena"] . '</td>
              <td>
                <a href="guild.php?action=view_guild&amp;error=3&amp;id=' . $char["GNAME"] . '">' . htmlentities($guild_name, ENT_COMPAT, $site_encoding) . '</a>
              </td>
            </tr>';
}
$output .= '
          </table>
        </div>';
require_once "footer.php";
コード例 #3
0
ファイル: index.php プロジェクト: GlassFace/CoreManager2
function main()
{
    global $output, $realm_id, $world_db, $logon_db, $characters_db, $corem_db, $server, $action_permission, $user_lvl, $user_id, $site_encoding, $hide_coupons, $locales_search_option, $base_datasite, $item_datasite, $showcountryflag, $gm_online_count, $gm_online, $itemperpage, $hide_uptime, $player_online, $hide_max_players, $hide_avg_latency, $hide_plr_latency, $hide_server_mem, $sql, $core;
    // do any raffle drawings that are necessary
    do_raffles();
    // check achievement contests
    do_contests();
    $output .= '
          <div class="top">';
    //---------------------Information for Explorer Users--------------------------
    if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) {
        $msie = '
            <br />
              <span id="index_explorer_warning">' . lang("index", "explorer_warn") . '</span>
            <br />';
    } else {
        $msie = '';
    }
    //-----------------------------------------------------------------------------
    if (test_port($server[$realm_id]["addr"], $server[$realm_id]["game_port"])) {
        if ($core == 1) {
            $stats = get_uptime($server[$realm_id]["stats.xml"]);
            $staticUptime = ' <em>' . htmlentities(get_realm_name($realm_id), ENT_COMPAT, $site_encoding) . '</em> <br />' . $stats["platform"][4] . ' ' . $stats["platform"][5] . ' ' . $stats["platform"][6];
            if (!$hide_uptime) {
                $staticUptime .= '<br />' . lang("index", "online") . ' for ' . $stats["uptime"];
            }
            $output .= '
            <div id="uptime">' . $msie . '
              <h1>
                <span id="index_realm_info">
                  <span>' . $staticUptime . '</span>';
            if (!$hide_max_players) {
                $output .= '
                  <br />
                  <span>' . lang("index", "maxplayers") . ': </span>
                  <span class="index_realm_info_value">' . $stats["peak"] . '</span>';
            }
            if (!$hide_avg_latency) {
                $output .= '
                  <br />
                  <span>' . lang("index", "avglat") . ': </span>
                  <span class="index_realm_info_value">' . $stats["avglat"] . '</span>';
            }
            $output .= '
                  <br />';
            if ($hide_server_mem != 0) {
                if ($hide_server_mem == 2 || $user_lvl == $action_permission["delete"]) {
                    $output .= '
                  <span>' . lang("index", "cpu") . ': </span>
                  <span class="index_realm_info_value">' . $stats["cpu"] . '%, </span>
                  <span>' . lang("index", "ram") . ': </span>
                  <span class="index_realm_info_value">' . $stats["ram"] . ' MB, </span>
                  <span>' . lang("index", "threads") . ': </span>
                  <span class="index_realm_info_value">' . $stats["threads"] . '</span>';
                }
            }
            $output .= '
               </span>
              </h1>
            </div>';
        } else {
            $stats = $sql["logon"]->fetch_assoc($sql["logon"]->query("SELECT starttime, maxplayers FROM uptime WHERE realmid='" . $realm_id . "' ORDER BY starttime DESC LIMIT 1"), 0);
            $uptimetime = time() - $stats["starttime"];
            // a more reliable method of counting how many characters have been online since server start
            //$maxplayers_query = "SELECT COUNT(*) FROM `".$characters_db[$realm_id]["name"]."`.characters WHERE logout_time>='".$stats["starttime"]."' AND logout_time>=(SELECT UNIX_TIMESTAMP(last_login) FROM `".$logon_db["name"]."`.account WHERE id=`".$characters_db[$realm_id]["name"]."`.characters.account)";
            //$maxplayers_result = $sql["char"]->query($maxplayers_query);
            //$maxplayers_result = $sql["char"]->fetch_assoc($maxplayers_result);
            //$stats["maxplayers"] = $maxplayers_result["COUNT(*)"];
            function format_uptime($seconds)
            {
                $secs = intval($seconds % 60);
                $mins = intval($seconds / 60 % 60);
                $hours = intval($seconds / 3600 % 24);
                $days = intval($seconds / 86400);
                if ($days > 365) {
                    $days = intval($seconds / 86400 % 365.24);
                    $years = intval($seconds / 31556926);
                }
                $uptimeString = '';
                if ($years) {
                    // we have a server that has been up for over a year? O_o
                    // actually, it's probably because the server didn't write a useful
                    // value to the uptime table's starttime field.
                    $uptimeString .= $years;
                    $uptimeString .= $years == 1 ? ' ' . lang("index", "uptime_year") : ' ' . lang("index", "uptime_years");
                    if ($days) {
                        $uptimeString .= ($years > 0 ? ', ' : '') . $days;
                        $uptimeString .= $days == 1 ? ' ' . lang("index", "uptime_day") : ' ' . lang("index", "uptime_days");
                    }
                } else {
                    if ($days) {
                        $uptimeString .= $days;
                        $uptimeString .= $days == 1 ? ' ' . lang("index", "uptime_day") : ' ' . lang("index", "uptime_days");
                    }
                }
                if ($hours) {
                    $uptimeString .= ($days > 0 ? ', ' : '') . $hours;
                    $uptimeString .= $hours == 1 ? ' ' . lang("index", "uptime_hour") : ' ' . lang("index", "uptime_hours");
                }
                if ($mins) {
                    $uptimeString .= ($days > 0 || $hours > 0 ? ', ' : '') . $mins;
                    $uptimeString .= $mins == 1 ? ' ' . lang("index", "uptime_minute") : ' ' . lang("index", "uptime_minutes");
                }
                if ($secs) {
                    $uptimeString .= ($days > 0 || $hours > 0 || $mins > 0 ? ', ' : '') . $secs;
                    $uptimeString .= $secs == 1 ? ' ' . lang("index", "uptime_second") : ' ' . lang("index", "uptime_seconds");
                }
                return $uptimeString;
            }
            $staticUptime = ' <em>' . htmlentities(get_realm_name($realm_id), ENT_COMPAT, $site_encoding) . '</em> ';
            if (!$hide_uptime) {
                if ($stats["starttime"] != 0) {
                    $staticUptime .= '<br /><span>' . lang("index", "online") . format_uptime($uptimetime) . '</span>';
                } else {
                    $staticUptime .= '<br /><span style="color:orange">' . lang("index", "time_error1") . ': <br>' . format_uptime($uptimetime) . '</span><br><span style="color:red">' . lang("index", "time_error2") . '</span>';
                }
            }
            unset($uptimetime);
            $output .= '
            <div id="uptime">' . $msie . '
              <h1>
                <span id="index_realm_info">' . $staticUptime;
            if (!$hide_max_players) {
                $output .= '
                  <br />
                  <span>' . lang("index", "maxplayers") . ': </span>
                  <span class="index_realm_info_value">' . $stats["maxplayers"] . '</span>';
            }
            // this_is_junk: MaNGOS doesn't store player latency. :/
            if ($core == 3) {
                if (!$hide_avg_latency) {
                    $lat_query = "SELECT SUM(latency), COUNT(*) FROM characters WHERE online=1";
                    $lat_result = $sql["char"]->query($lat_query);
                    $lat_fields = $sql["char"]->fetch_assoc($lat_result);
                    $avglat = sprintf("%.3f", $lat_fields["SUM(latency)"] / $lat_fields["COUNT(*)"]);
                    $output .= '
                    <br />
                    <span>' . lang("index", "avglat") . ': </span>
                    <span class="index_realm_info_value">' . $avglat . '</span>';
                }
            }
            $output .= '
                </span>
              </h1>
            </div>';
            unset($stats);
            $online = true;
        }
        unset($staticUptime);
        //unset($stats);
        $online = true;
    } else {
        $output .= $msie . '<h1><span class="error">' . lang("index", "realm") . ' <em>' . htmlentities(get_realm_name($realm_id), ENT_COMPAT, $site_encoding) . '</em> ' . lang("index", "offline_or_let_high") . '</span></h1>';
        $online = false;
    }
    //close the div
    $output .= '
          </div>';
    // MOTDs
    // get our MotDs...
    $motd = "";
    $motd_result = $sql["mgr"]->query("SELECT *, UNIX_TIMESTAMP(Created) AS Created, UNIX_TIMESTAMP(Last_Edited) AS Last_Edited FROM motd WHERE Enabled<>0 AND (Target='" . $user_id . "' OR Target=0) ORDER BY Priority ASC");
    // if we don't get any MotDs, it'll stay empty
    if ($user_lvl >= $action_permission["update"]) {
        $output .= '
          <script type="text/javascript">
            // <![CDATA[
              answerbox.btn_ok = "' . lang("global", "yes_low") . '";
              answerbox.btn_cancel = "' . lang("global", "no") . '";
              var del_motd = "motd.php?action=delete_motd&amp;id=";
            // ]]>
          </script>';
    }
    if ($sql["mgr"]->num_rows($motd_result) > 0) {
        $output .= '
            <div class="div_lined">
              <div class="div_lined_head">
                <span>' . lang("index", "motd") . '</span>
              </div>';
    }
    while ($temp = $sql["mgr"]->fetch_assoc($motd_result)) {
        if ($user_lvl >= $temp["Min_Sec_Level"]) {
            $motd = bb2html($temp["Message"]) . "<br /><br />";
            if ($motd) {
                if ($temp["Target"] != 0) {
                    $output .= '
                <div class="div_lined_line left_text">' . lang("motd", "private") . '</div>';
                }
                $output .= '
                <div class="div_lined_line left_text">';
                $output .= $motd;
                $output .= '
                  <br />';
                // Get User Name for poster
                if ($core == 1) {
                    $posted_name_query = "SELECT login FROM accounts WHERE acct='" . $temp["Created_By"] . "'";
                } else {
                    $posted_name_query = "SELECT username AS login FROM account WHERE id='" . $temp["Created_By"] . "'";
                }
                $posted_name_result = $sql["logon"]->query($posted_name_query);
                $posted_name = $sql["logon"]->fetch_assoc($posted_name_result);
                $posted_name = $posted_name["login"];
                // Get Screen Name for poster, if available
                $posted_screenname_query = "SELECT ScreenName FROM config_accounts WHERE Login='******'";
                $posted_screenname_result = $sql["mgr"]->query($posted_screenname_query);
                $posted_screenname = $sql["mgr"]->fetch_assoc($posted_screenname_result);
                if ($posted_screenname["ScreenName"] != NULL) {
                    $posted_name = htmlspecialchars($posted_screenname["ScreenName"]);
                }
                // if the Server Message is posted by the system, Created_By will be zero
                if ($temp["Created_By"] != 0) {
                    $output .= '
                  <span>' . lang("motd", "posted_by") . ':</span>';
                    if ($user_lvl > -1) {
                        $output .= '
                  <a href="user.php?action=edit_user&amp;error=11&amp;acct=' . $temp["Created_By"] . '">';
                    }
                    $output .= '
                    <span>' . $posted_name . '</span>';
                    if ($user_lvl > -1) {
                        $output .= '
                  </a>';
                    }
                    $output .= '
                  <span>(' . date("M d, Y @ H:i:s", $temp["Created"]) . ')</span>';
                } else {
                    $output .= '
                  <span>' . lang("motd", "posted") . ': ' . date("M d, Y @ H:i:s", $temp["Created"]) . '</span>';
                }
                // Get User Name for last editor
                if ($core == 1) {
                    $edited_name_query = "SELECT login FROM accounts WHERE acct='" . $temp["Last_Edited_By"] . "'";
                } else {
                    $edited_name_query = "SELECT username AS login FROM account WHERE id='" . $temp["Last_Edited_By"] . "'";
                }
                $edited_name_result = $sql["logon"]->query($edited_name_query);
                $edited_name = $sql["logon"]->fetch_assoc($edited_name_result);
                $edited_name = $edited_name["login"];
                // Get Screen Name for last editor, if available
                $edited_screenname_query = "SELECT ScreenName FROM config_accounts WHERE Login='******'";
                $edited_screenname_result = $sql["mgr"]->query($edited_screenname_query);
                $edited_screenname = $sql["mgr"]->fetch_assoc($edited_screenname_result);
                if ($edited_screenname["ScreenName"] != NULL) {
                    $edited_name = htmlspecialchars($edited_screenname["ScreenName"]);
                }
                if ($temp["Last_Edited_By"] != 0) {
                    $output .= '
                  <br />
                  <div>
                    <span>' . lang("motd", "edited_by") . ':</span>';
                    if ($user_lvl > -1) {
                        $output .= '
                    <a href="user.php?action=edit_user&amp;error=11&amp;acct=' . $temp["Last_Edited_By"] . '">';
                    }
                    $output .= '
                      <span>' . $edited_name . '</span>';
                    if ($user_lvl > -1) {
                        $output .= '
                    </a>';
                    }
                    $output .= '
                    <span>(' . date("M d, Y @ H:i:s", $temp["Last_Edited"]) . ')</span>
                  </div>';
                }
                $output .= '
                </div>';
                if ($user_lvl >= $action_permission["update"]) {
                    $output .= '
                <div class="div_lined_line right_text">
                  <img src="img/aff_cross.png" width="16" height="16" onclick="answerBox(\'' . lang("global", "delete") . ': &lt;font color=white&gt;' . $temp["ID"] . '&lt;/font&gt;&lt;br /&gt;' . lang("global", "are_you_sure") . '\', del_motd + ' . $temp["ID"] . ');" alt="" />';
                }
                if ($user_lvl >= $action_permission["update"]) {
                    $output .= '
                  <a href="motd.php?action=edit_motd&amp;error=3&amp;id=' . $temp["ID"] . '">
                    <img src="img/edit.png" width="16" height="16" alt="" />
                  </a>
                </div>';
                }
                $output .= '
                <br />';
            }
        }
    }
    if ($sql["mgr"]->num_rows($motd_result)) {
        $output = substr($output, 0, strlen($output) - 24);
    }
    if ($sql["mgr"]->num_rows($motd_result) > 0) {
        $output .= '
            </div>';
    }
    if ($user_lvl >= $action_permission["insert"]) {
        $output .= '
            <div class="div_lined">
              <div class="div_lined_head right_text">
                <a href="motd.php?action=add_motd&amp;error=4">' . lang("index", "add_motd") . '</a>
              </div>
            </div>';
    }
    // Coupons
    if (!$hide_coupons) {
        $coupon_query = "SELECT * FROM point_system_coupons WHERE ((target='0' AND contest='0') OR target='" . $user_id . "') AND enabled='1'";
        $coupon_result = $sql["mgr"]->query($coupon_query);
        if ($sql["mgr"]->num_rows($coupon_result) > 0) {
            $output .= '
            <br />
            <div class="div_lined">
              <div class="div_lined_head">
                <span>' . lang("index", "avail_coupons") . '</span>
              </div>';
            while ($coupon = $sql["mgr"]->fetch_assoc($coupon_result)) {
                $usage_query = "SELECT * FROM point_system_coupon_usage WHERE coupon='" . $coupon["entry"] . "' AND user='******'";
                $usage_result = $sql["mgr"]->query($usage_query);
                if ($sql["mgr"]->num_rows($usage_result) < $coupon["usage_limit"] || $coupon["usage_limit"] == -1) {
                    $output .= '
              <div class="div_lined_line left_text">
                <span>' . $coupon["title"] . '</span>
              </div>';
                    if ($coupon["text"] != "") {
                        $output .= '
              <div class="div_lined_line left_text">
                <span>' . $coupon["text"] . '</span>
              </div>';
                    }
                    if ($coupon["credits"] != 0 || $coupon["money"] != 0 || $coupon["item_id"] != 0 || $coupon["raffle_id"] != 0) {
                        $output .= '
              <div class="div_lined_line left_text">
                <span>' . lang("index", "coupon_value") . ':</span>';
                        if ($coupon["credits"] > 0) {
                            if ($coupon["credits"] > 1) {
                                $tip = lang("index", "coupon_credits");
                            } else {
                                $tip = lang("index", "coupon_credit");
                            }
                            $output .= '
                <br />
                <br />
                <span>' . $coupon["credits"] . '</span>
                <span>' . $tip . '</span>';
                        }
                        if ($coupon["money"] > 0) {
                            // extract gold/silver/copper from single gold number
                            $coupon["money"] = str_pad($coupon["money"], 4, "0", STR_PAD_LEFT);
                            $coupon_g = substr($coupon["money"], 0, -4);
                            if ($coupon_g == "") {
                                $coupon_g = 0;
                            }
                            $coupon_s = substr($coupon["money"], -4, 2);
                            if ($coupon_s == "" || $coupon_s == "00") {
                                $coupon_s = 0;
                            }
                            $coupon_c = substr($coupon["money"], -2);
                            if ($coupon_c == "" || $coupon_c == "00") {
                                $coupon_c = 0;
                            }
                            $output .= '
                <br />
                <br />
                <span>' . $coupon_g . '</span>
                <img src="img/gold.gif" alt="gold" />
                <span>' . $coupon_s . '</span>
                <img src="img/silver.gif" alt="gold" />
                <span>' . $coupon_c . '</span>
                <img src="img/copper.gif" alt="gold" />';
                        }
                        if ($coupon["item_id"] != 0) {
                            if ($coupon["item_id"] > 0) {
                                // get item data
                                if ($core == 1) {
                                    $i_query = "SELECT \r\n                    *, description AS description1, name1 AS name, quality AS Quality, inventorytype AS InventoryType, \r\n                    socket_color_1 AS socketColor_1, socket_color_2 AS socketColor_2, socket_color_3 AS socketColor_3,\r\n                    requiredlevel AS RequiredLevel, allowableclass AS AllowableClass,\r\n                    sellprice AS SellPrice, itemlevel AS ItemLevel\r\n                    FROM items " . ($locales_search_option != 0 ? "LEFT JOIN items_localized ON (items_localized.entry=items.entry AND language_code='" . $locales_search_option . "') " : " ") . "WHERE items.entry='" . $coupon["item_id"] . "'";
                                } else {
                                    $i_query = "SELECT *, description AS description1 FROM item_template " . ($locales_search_option != 0 ? "LEFT JOIN locales_item ON locales_item.entry=item_template.entry " : " ") . "WHERE item_template.entry='" . $coupon["item_id"] . "'";
                                }
                                $i_result = $sql["world"]->query($i_query);
                                $i = $sql["world"]->fetch_assoc($i_result);
                                $output .= '
                <br />
                <br />
                <div class="coupon_item">
                  <div>
                    <a href="' . $base_datasite . $item_datasite . $coupon["item_id"] . '" rel="external" onmouseover="ShowTooltip(this,\'_b' . $coupon["entry"] . '\');" onmouseout="HideTooltip(\'_b' . $coupon["entry"] . '\');">
                      <img src="' . get_item_icon($coupon["item_id"]) . '" alt="" />
                    </a>';
                                if ($coupon["item_count"] > 1) {
                                    $output .= '
                    <div class="ch_inv_quantity_shadow">' . $coupon["item_count"] . '</div>
                    <div class="ch_inv_quantity">' . $coupon["item_count"] . '</div>';
                                }
                                $output .= '
                  </div>';
                                // build a tooltip object for this item
                                $output .= '
                  <div class="item_tooltip_div" id="tooltip_b' . $coupon["entry"] . '" style="left: -129px; top: 42px;">
                    <div>' . get_item_tooltip($i, 0, 0, 0, 0, 0) . '</div>
                  </div>';
                                $output .= '
                </div>';
                            } else {
                                $output .= '
                <br />
                <br />
                <div class="coupon_item">
                  <div>
                    <a href="point_system.php?action=view_bag&amp;bag_id=' . $coupon["item_id"] * -1 . '" onmousemove="oldtoolTip(\'' . lang("points", "prize_bag") . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()">
                      <img src="' . get_item_icon(1725) . '" alt="" />
                    </a>
                  </div>
                </div>';
                            }
                        }
                        if ($coupon["raffle_id"] != 0) {
                            // find out how many entries per user the raffle allows and whether the raffle is enabled
                            if ($coupon["raffle_id"] != -1) {
                                $query = "SELECT tickets_per_user, enabled FROM point_system_raffles WHERE entry='" . $coupon["raffle_id"] . "'";
                                $result = $sql["mgr"]->query($query);
                                $result = $sql["mgr"]->fetch_assoc($result);
                                $per_user = $result["tickets_per_user"];
                                $raffle_enabled = $result["enabled"];
                                // if tickets_per_user is -1 then its unlimited, fake it with a reasonably high number
                                $per_user = 999999999;
                            } else {
                                // if it allows any raffle, then fake it
                                $per_user = 999999999;
                                $raffle_enabled = 1;
                            }
                            if ($raffle_enabled) {
                                // find out how many time we've entered
                                $query = "SELECT COUNT(*) FROM point_system_raffle_tickets WHERE raffle='" . $coupon["raffle_id"] . "' AND user='******'";
                                $result = $sql["mgr"]->query($query);
                                $result = $sql["mgr"]->fetch_assoc($result);
                                $tickets = $result["COUNT(*)"];
                                // if we haven't already purchased the maximum number of tickets
                                // or the raffle allows purchase of tickets from any raffle
                                if ($tickets < $per_user || $coupon["raffle_id"] == -1) {
                                    if ($coupon["redemption_option"] == 0) {
                                        $output .= '
                <br />
                <br />
                <span>' . lang("index", "and_raffle") . '</span>';
                                    } else {
                                        $output .= '
                <br />
                <br />
                <span>' . lang("index", "or_raffle") . '</span>';
                                    }
                                }
                            }
                        }
                        $output .= '
              </div>';
                    }
                    if ($coupon["credits"] < 0) {
                        $message = lang("points", "coupon_cost_credits");
                        $message = str_replace("%1", $coupon["credits"] * -1, $message);
                        $output .= '
              <div class="div_lined_line right_text">
                <span>' . $message . '</span>
              </div>';
                    }
                    if ($coupon["money"] < 0) {
                        $coupon["money"] = $coupon["money"] * -1;
                        $coupon_money = $coupon["money"];
                        $coupon_money = str_pad($coupon_money, 4, "0", STR_PAD_LEFT);
                        $cg = substr($coupon_money, 0, -4);
                        if ($cg == "") {
                            $cg = 0;
                        }
                        $cs = substr($coupon_money, -4, 2);
                        if ($cs == "" || $cs == "00") {
                            $cs = 0;
                        }
                        $cc = substr($coupon_money, -2);
                        if ($cc == "" || $cc == "00") {
                            $cc = 0;
                        }
                        $coupon_money_display = '
              <span>' . $cg . '</span>
              <img src="img/gold.gif" alt="" align="middle" />
              <span>' . $cs . '</span>
              <img src="img/silver.gif" alt="" align="middle" />
              <span>' . $cc . '</span>
              <img src="img/copper.gif" alt="" align="middle" />';
                        $message = lang("points", "coupon_cost_money");
                        $message = str_replace("%1", $coupon_money_display, $message);
                        $output .= '
              <div class="div_lined_line right_text">
                <span>' . $message . '</span>
              </div>';
                    }
                    $output .= '
              <div class="div_lined_line right_text">
                <a href="point_system.php?action=redeem_coupon&amp;coupon_id=' . $coupon["entry"] . '">
                  <img src="img/star.png" width="16" height="16" alt="" />
                  <span>&nbsp;' . lang("index", "use_coupon") . '</span>
                </a>
              </div>';
                    $output .= '
              <br />';
                }
            }
            if ($sql["mgr"]->num_rows($coupon_result)) {
                $output = substr($output, 0, strlen($output) - 20);
            }
            $output .= '
            </div>';
        }
    }
    // GM Tickets
    $start_m = isset($_GET["start_m"]) ? $sql["char"]->quote_smart($_GET["start_m"]) : 0;
    if (!is_numeric($start_m)) {
        $start_m = 0;
    }
    if ($core == 1) {
        $all_record_m = $sql["char"]->result($sql["char"]->query("SELECT COUNT(*) FROM gm_tickets WHERE deleted=0"), 0);
    } elseif ($core == 2) {
        $all_record_m = $sql["char"]->result($sql["char"]->query("SELECT COUNT(*) FROM character_ticket"), 0);
    } else {
        $all_record_m = $sql["char"]->result($sql["char"]->query("SELECT COUNT(*) FROM gm_tickets WHERE closedBy=0"), 0);
    }
    // show gm tickets
    $output .= '
            <br />';
    if ($user_lvl >= $action_permission["insert"]) {
        if ($all_record_m) {
            $output .= '
            <div class="div_lined">
              <div class="div_lined_head">
                <span>' . lang("index", "tickets") . '</span>
              </div>';
            if ($core == 1) {
                $result = $sql["char"]->query("SELECT ticketid, level, message, name, deleted,\r\n          timestamp, gm_tickets.playerGuid, acct\r\n          FROM gm_tickets\r\n            LEFT JOIN characters ON characters.guid=gm_tickets.playerGuid\r\n          ORDER BY ticketid DESC LIMIT " . $start_m . ", 3");
            } elseif ($core == 2) {
                $result = $sql["char"]->query("SELECT character_ticket.ticket_id AS ticketid, characters.level,\r\n          ticket_text AS message, characters.name, UNIX_TIMESTAMP(ticket_lastchange) AS timestamp,\r\n          character_ticket.guid AS playerGuid, account AS acct\r\n          FROM character_ticket\r\n            LEFT JOIN characters ON characters.guid=character_ticket.guid\r\n          ORDER BY ticketid DESC LIMIT " . $start_m . ", 3");
            } else {
                $result = $sql["char"]->query("SELECT gm_tickets.guid AS ticketid, characters.level, message,\r\n          gm_tickets.name, closedBy AS deleted, lastModifiedTime AS timestamp, gm_tickets.guid AS playerGuid, account AS acct\r\n          FROM gm_tickets\r\n            LEFT JOIN characters ON characters.guid=gm_tickets.guid\r\n          ORDER BY ticketid DESC LIMIT " . $start_m . ", 3");
            }
            while ($post = $sql["char"]->fetch_assoc($result)) {
                if (!$post["deleted"]) {
                    if ($core == 1) {
                        $login_result = $sql["logon"]->query("SELECT * FROM accounts WHERE acct='" . $post["acct"] . "'");
                    } else {
                        $login_result = $sql["logon"]->query("SELECT *, username AS login FROM account WHERE id='" . $post["acct"] . "'");
                    }
                    $login = $sql["logon"]->fetch_assoc($login_result);
                    $gm_result = $sql["mgr"]->query("SELECT SecurityLevel FROM config_accounts WHERE Login='******'");
                    $gm = $sql["mgr"]->fetch_assoc($gm_result);
                    $gm = $gm["SecurityLevel"];
                    if ($user_lvl > 0 && ($user_lvl >= gmlevel($gm) || $user_lvl == $action_permission["delete"])) {
                        $output .= '
              <div class="div_lined_line left_text">
                <a href="char.php?id=' . $post["playerGuid"] . '">
                  <span onmousemove="oldtoolTip(\'' . htmlspecialchars($login["username"]) . ' (' . id_get_gm_level($gm) . ')' . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()">' . htmlentities($post["name"], ENT_COMPAT, $site_encoding) . '</span>
                </a>
              </div>
              <div class="div_lined_line left_text">
                <span>' . htmlspecialchars($post["message"]) . '</span>
              </div>
              <div class="div_lined_line right_text">';
                    }
                    $output .= '
                <span>' . lang("index", "submitted") . ": " . date('G:i:s m-d-Y', $post["timestamp"]) . '</span>';
                    $output .= '
              </div>
              <div class="div_lined_line right_text">';
                    if ($user_lvl >= $action_permission["update"]) {
                        $output .= '
                <a href="ticket.php?action=edit_ticket&amp;error=4&amp;id=' . $post["ticketid"] . '">
                  <img src="img/edit.png" width="16" height="16" alt="" />
                </a>';
                    }
                    $output .= '
              </div>
              <br />';
                }
            }
            $output .= '
            </div>';
        }
    }
    // Character Changes
    // count pending character changes
    $char_change_count = $sql["mgr"]->result($sql["mgr"]->query("SELECT COUNT(*) FROM char_changes"), 0);
    // show pending character changes
    $output .= '
            <br />';
    if ($user_lvl >= $action_permission["update"]) {
        if ($char_change_count) {
            $output .= '
            <div class="div_lined">
              <div class="div_lined_head">
                <span>' . lang("index", "pendingchanges") . '</span>
              </div>';
            $result = $sql["mgr"]->query("SELECT * FROM char_changes");
            while ($change = $sql["mgr"]->fetch_assoc($result)) {
                if ($core == 1) {
                    $change_char_query = "SELECT * FROM characters WHERE guid='" . $change["guid"] . "'";
                } else {
                    $change_char_query = "SELECT *, account AS acct FROM characters WHERE guid='" . $change["guid"] . "'";
                }
                $change_char = $sql["char"]->fetch_assoc($sql["char"]->query($change_char_query));
                if ($core == 1) {
                    $change_acct_query = "SELECT * FROM accounts WHERE acct='" . $change_char["acct"] . "'";
                } else {
                    $change_acct_query = "SELECT *, username AS login FROM account WHERE id='" . $change_char["acct"] . "'";
                }
                $change_acct = $sql["logon"]->fetch_assoc($sql["logon"]->query($change_acct_query));
                if (isset($change["new_name"])) {
                    // Localization
                    $namechange = lang("xname", "playerhasreq");
                    $namechange = str_replace("%1", htmlspecialchars($change_acct["login"]), $namechange);
                    $namechange = str_replace("%2", htmlspecialchars($change_char["name"]), $namechange);
                    $namechange = str_replace("%3", htmlspecialchars($change["new_name"]), $namechange);
                    $output .= '
              <div class="div_lined_line left_text large">
                <span>' . $namechange . '</span>';
                }
                if (isset($change["new_race"])) {
                    // Localization
                    $racechange = lang("xrace", "playerhasreq");
                    $racechange = str_replace("%1", htmlspecialchars($change_acct["login"]), $racechange);
                    $racechange = str_replace("%2", htmlspecialchars($change_char["name"]), $racechange);
                    $racechange = str_replace("%3", char_get_race_name($change["new_race"]), $racechange);
                    $output .= '
              <div class="div_lined_line left_text large">
                <span>' . $racechange . '</span>';
                }
                if (isset($change["new_acct"])) {
                    if ($core == 1) {
                        $new_acct_query = "SELECT login FROM accounts WHERE acct='" . $change["new_acct"] . "'";
                    } else {
                        $new_acct_query = "SELECT username AS login FROM account WHERE id='" . $change["new_acct"] . "'";
                    }
                    $new_acct_result = $sql["logon"]->query($new_acct_query);
                    $new_acct_result = $sql["logon"]->fetch_assoc($new_acct_result);
                    $new_acct_name = $new_acct_result["login"];
                    // Localization
                    $acctchange = lang("xacct", "playerhasreq");
                    $acctchange = str_replace("%1", htmlspecialchars($change_acct["login"]), $acctchange);
                    $acctchange = str_replace("%2", htmlspecialchars($change_char["name"]), $acctchange);
                    $acctchange = str_replace("%3", $new_acct_name, $acctchange);
                    $output .= '
              <div class="div_lined_line left_text large">
                <span>' . $acctchange . '</span>';
                }
                if ($change_char["online"]) {
                    $output .= '
                <br />
                <br />
                <img src="img/aff_warn.gif" alt="warn" />
                <span class="error">' . lang("xname", "online") . '</span>';
                }
                $output .= '
              </div>';
                if (isset($change["new_name"])) {
                    $file = "change_char_name.php";
                } elseif (isset($change["new_race"])) {
                    $file = "change_char_race.php";
                } else {
                    $file = "change_char_account.php";
                }
                $output .= '
              <div class="div_lined_line right_text">
                <a href="' . $file . '?action=denied&amp;guid=' . $change["guid"] . '">
                  <img src="img/cross.png" width="12" height="12" alt="" />
                </a>';
                if (!$change_char["online"]) {
                    $output .= '
                <a href="' . $file . '?action=approve&amp;guid=' . $change["guid"] . '">
                  <img src="img/aff_tick.png" width="14" height="14" alt="" />
                </a>';
                }
                $output .= '
              </div>
              <br />';
            }
            $output .= '
            </div>';
        }
    }
    //print online chars
    if ($online && $user_lvl >= $player_online) {
        //==========================$_GET and SECURE=================================
        $start = isset($_GET["start"]) ? $sql["char"]->quote_smart($_GET["start"]) : 0;
        if (!is_numeric($start)) {
            $start = 0;
        }
        $order_by = isset($_GET["order_by"]) ? $sql["char"]->quote_smart($_GET["order_by"]) : "name";
        if (!preg_match("/^[_[:lower:]]{1,12}\$/", $order_by)) {
            $order_by = "name";
        }
        $dir = isset($_GET["dir"]) ? $sql["char"]->quote_smart($_GET["dir"]) : 1;
        if (!preg_match("/^[01]{1}\$/", $dir)) {
            $dir = 1;
        }
        $order_dir = $dir ? "ASC" : "DESC";
        $dir = $dir ? 0 : 1;
        //==========================$_GET and SECURE end=============================
        if ($order_by === "mapid") {
            $order_by = "mapid, zoneid ";
            $order_hold = "mapid";
        } elseif ($order_by === "zoneid") {
            $order_by = "zoneid, mapid ";
            $order_hold = "zoneid";
        } else {
            $order_hold = $order_by;
        }
        $order_side = "";
        if (!($user_lvl || $server[$realm_id]["both_factions"])) {
            if ($core == 1) {
                $result = $sql["char"]->query("SELECT race FROM characters WHERE acct=" . $user_id . "\r\n          AND SUBSTRING_INDEX(SUBSTRING_INDEX(playedtime, ' ', 2), ' ', -1)=(SELECT MAX(SUBSTRING_INDEX(SUBSTRING_INDEX(playedtime, ' ', 2), ' ', -1)) FROM characters WHERE acct=" . $user_id . ") LIMIT 1");
            } else {
                $result = $sql["char"]->query("SELECT race FROM characters WHERE account=" . $user_id . "\r\n          AND totaltime=(SELECT MAX(totaltime) FROM characters WHERE account=" . $user_id . ") LIMIT 1");
            }
            if ($sql["char"]->num_rows($result)) {
                $order_side = in_array($sql["char"]->result($result, 0), array(2, 5, 6, 8, 10)) ? " AND race IN (2, 5, 6, 8, 10) " : " AND race IN (1, 3, 4, 7, 11) ";
            }
        }
        if ($core == 1) {
            $result = $sql["char"]->query("SELECT guid, name, race, class, zoneid, mapid, level, characters.acct, gender,\r\n                            CAST( SUBSTRING_INDEX( SUBSTRING_INDEX( data, ';', " . (PLAYER_FIELD_HONOR_CURRENCY + 1) . " ), ';', -1 ) AS UNSIGNED ) AS highest_rank, lastip\r\n                            FROM characters\r\n                              LEFT JOIN `" . $logon_db["name"] . "`.accounts ON characters.acct=`" . $logon_db["name"] . "`.accounts.acct\r\n                            WHERE characters.online=1 " . $order_side . " ORDER BY " . $order_by . " " . $order_dir . " LIMIT " . $start . ", " . $itemperpage);
        } elseif ($core == 2) {
            $result = $sql["char"]->query("SELECT guid, name, race, class, zone AS zoneid, map AS mapid, level, account AS acct, gender,\r\n                            totalHonorPoints AS highest_rank, last_ip AS lastip\r\n                            FROM characters\r\n                              LEFT JOIN `" . $logon_db["name"] . "`.account ON characters.account=`" . $logon_db["name"] . "`.account.id\r\n                            WHERE characters.online=1 " . $order_side . " ORDER BY " . $order_by . " " . $order_dir . " LIMIT " . $start . ", " . $itemperpage);
        } else {
            $result = $sql["char"]->query("SELECT characters.guid, characters.name, race, class, zone AS zoneid, map AS mapid, level, account AS acct, gender,\r\n                            totalHonorPoints AS highest_rank, latency, last_ip AS lastip, guild.name AS gname\r\n                            FROM characters\r\n                              LEFT JOIN `" . $logon_db["name"] . "`.account ON characters.account=`" . $logon_db["name"] . "`.account.id\r\n                              LEFT JOIN guild_member ON characters.guid=guild_member.guid\r\n                              LEFT JOIN guild ON guild_member.guildid=guild.guildid\r\n                            WHERE characters.online=1 " . $order_side . " ORDER BY " . $order_by . " " . $order_dir . " LIMIT " . $start . ", " . $itemperpage);
        }
        $total_online = $sql["char"]->result($sql["char"]->query("SELECT count(*) FROM characters WHERE online= 1"), 0);
        $output .= '
            <div class="div_lined center_text">
              <span class="bold">' . lang("index", "tot_users_online") . ': ' . $total_online . '</span>
            </div>';
        if ($total_online) {
            $output .= '
            <table class="lined">
              <tr>
                <td colspan="' . (9 - $showcountryflag) . '" align="right" class="hidden" style="width: 25%;">';
            $output .= generate_pagination("index.php?start_m=" . $start_m . "&amp;order_by=" . $order_hold . "&amp;dir=" . ($dir ? 0 : 1), $total_online, $itemperpage, $start);
            $output .= '
                </td>
              </tr>
              <tr>
                <th style="width: 15%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=name&amp;dir=' . $dir . '"' . ($order_by === "name" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "name") . '</a>
                </th>
                <th style="width: 1%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=race&amp;dir=' . $dir . '"' . ($order_by === "race" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "race") . '</a>
                </th>
                <th style="width: 1%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=class&amp;dir=' . $dir . '"' . ($order_by === "class" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "class") . '</a>
                </th>
                <th style="width: 5%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=level&amp;dir=' . $dir . '"' . ($order_by === "level" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "level") . '</a>
                </th>
                <th style="width: 1%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=highest_rank&amp;dir=' . $dir . '"' . ($order_by === "highest_rank" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "rank") . '</a>
                </th>
                <th style="width: 15%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=gname&amp;dir=' . $dir . '"' . ($order_by === "gname" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "guild") . '</a>
                </th>
                <th style="width: 20%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=mapid&amp;dir=' . $dir . '"' . ($order_by === "mapid, zoneid " ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "map") . '</a>
                </th>
                <th style="width: 25%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=zoneid&amp;dir=' . $dir . '"' . ($order_by === "zoneid, mapid " ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "zone") . '</a>
                </th>';
            if ($core == 1) {
                $output .= '
                <th style="width: 25%;">
                  <span>' . lang("index", "area") . '</span>
                </th>';
            }
            // this_is_junk: MaNGOS doesn't store player latency
            if ($core != 2) {
                if (!$hide_plr_latency) {
                    // this_is_junk: Trinity is the only core which can sort by Player Latency
                    if ($core == 3) {
                        $output .= '
                <th style="width: 1%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=latency&amp;dir=' . $dir . '"' . ($order_by === "latency" ? ' class="' . $order_dir . '"' : '') . '>
                    <img src="img/time.png" onmousemove="oldtoolTip(\'' . lang("index", "latency") . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()" alt=""' . ($order_by === "latency" ? '' : ' style="position: relative; top: 7px;"') . ' />
                  </a>
                </th>';
                    } else {
                        $output .= '
                <th style="width: 1%;">
                  <img src="img/time.png" onmousemove="oldtoolTip(\'' . lang("index", "latency") . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" style="position: relative; top: 7px;" />
                </th>';
                    }
                }
            }
            if ($showcountryflag) {
                require_once "libs/misc_lib.php";
                $output .= '
                <th style="width: 1%;">
                  <a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=lastip&amp;dir=' . $dir . '"' . ($order_by === "lastip" ? ' class="' . $order_dir . '"' : '') . '>
                    <img src="img/world.png" onmousemove="oldtoolTip(\'' . lang("global", "country") . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()" alt=""' . ($order_by === "lastip" ? '' : ' style="position: relative; top: 7px;"') . ' />
                  </a>
                </th>';
            }
            $output .= '
              </tr>';
        }
        while ($char = $sql["char"]->fetch_assoc($result)) {
            if ($core == 1) {
                $ca_query = "SELECT accounts.login AS name FROM `" . $logon_db["name"] . "`.accounts LEFT JOIN `" . $corem_db["name"] . "`.config_accounts ON accounts.login=`" . $corem_db["name"] . "`.config_accounts.Login COLLATE utf8_unicode_ci WHERE acct='" . $char["acct"] . "'";
            } else {
                $ca_query = "SELECT *, username AS name FROM `" . $logon_db["name"] . "`.account LEFT JOIN `" . $corem_db["name"] . "`.config_accounts ON account.username=`" . $corem_db["name"] . "`.config_accounts.Login WHERE id='" . $char["acct"] . "'";
            }
            $ca_result = $sql["mgr"]->query($ca_query);
            $char_acct = $sql["mgr"]->fetch_assoc($ca_result);
            $gm = $char_acct["SecurityLevel"];
            if (!isset($gm)) {
                $gm = 0;
            }
            if ($core == 1) {
                $guild_id = $sql["char"]->result($sql["char"]->query("SELECT guildid FROM guild_data WHERE playerid='" . $char["guid"] . "'"), 0);
            } else {
                $guild_id = $sql["char"]->result($sql["char"]->query("SELECT guildid FROM guild_member WHERE guid='" . $char["guid"] . "'"), 0);
            }
            if ($core == 1) {
                $guild_name_query = "SELECT guildName FROM guilds WHERE guildid='" . $guild_id . "'";
            } else {
                $guild_name_query = "SELECT name AS guildName FROM guild WHERE guildid='" . $guild_id . "'";
            }
            $guild_name_result = $sql["char"]->query($guild_name_query);
            $guild_name = $sql["char"]->fetch_assoc($guild_name_result);
            $guild_name = $guild_name["guildName"];
            $output .= '
              <tr>
                <td>';
            if ($user_lvl > 0 && ($user_lvl >= gmlevel($gm) || $user_lvl == $action_permission["delete"])) {
                $output .= '
                  <a href="char.php?id=' . $char["guid"] . '">
                    <span onmousemove="oldtoolTip(\'' . htmlspecialchars($char_acct["name"]) . ' (' . id_get_gm_level($gm) . ')' . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()">' . htmlentities($char["name"], ENT_COMPAT, $site_encoding) . '</span>
                  </a>';
            } else {
                $output .= '
                  <span>' . htmlentities($char["name"], ENT_COMPAT, $site_encoding) . '</span>';
            }
            $output .= '
                </td>
                <td>
                  <img src="img/c_icons/' . $char["race"] . '-' . $char["gender"] . '.gif" onmousemove="oldtoolTip(\'' . char_get_race_name($char["race"]) . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />
                </td>
                <td>
                  <img src="img/c_icons/' . $char["class"] . '.gif" onmousemove="oldtoolTip(\'' . char_get_class_name($char["class"]) . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />
                </td>
                <td>' . char_get_level_color($char["level"]) . '</td>
                <td>
                  <span onmouseover="oldtoolTip(\'' . char_get_pvp_rank_name($char["highest_rank"], char_get_side_id($char["race"])) . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" id="index_delete_cursor"><img src="img/ranks/rank' . char_get_pvp_rank_id($char["highest_rank"], char_get_side_id($char["race"])) . '.gif" alt="" /></span>
                </td>
                <td>
                  <a href="guild.php?action=view_guild&amp;error=3&amp;id=' . $guild_id . '">' . htmlentities($guild_name, ENT_COMPAT, $site_encoding) . '</a>
                </td>
                <td>
                  <span onmousemove="oldtoolTip(\'MapID:' . $char["mapid"] . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()">' . get_map_name($char["mapid"]) . '</span>
                </td>
                <td>
                  <span onmousemove="oldtoolTip(\'ZoneID:' . $char["zoneid"] . '\', \'old_item_tooltip\')" onmouseout="oldtoolTip()">' . get_zone_name($char["zoneid"]) . '</span>
                </td>';
            // display player area, if available
            if ($core == 1) {
                for ($i = 0; $i < count($stats["plrs_area"]); $i++) {
                    if ($stats["plrs_area"][$i][0] == $char["name"]) {
                        $output .= '
                <td>
                  <span onmousemove="toolTip(\'AreaID:' . $stats["plrs_area"][$i][1] . '\', \'item_tooltip\')" onmouseout="toolTip()">' . get_zone_name($stats["plrs_area"][$i][1]) . '</span>
                </td>';
                    }
                    if (!isset($stats["plrs_lat"][$i][1])) {
                        $output .= '
                <td>-</td>';
                    }
                }
            }
            // display player latency, if enabled, and if available
            if (!$hide_plr_latency) {
                if ($core == 1) {
                    for ($i = 0; $i < count($stats["plrs_lat"]); $i++) {
                        if ($stats["plrs_lat"][$i][0] == $char["name"]) {
                            $output .= '
                <td>' . $stats["plrs_lat"][$i][1] . '</td>';
                        }
                        if (!isset($stats["plrs_lat"][$i][1])) {
                            $output .= '
                <td>-</td>';
                        }
                    }
                } else {
                    // this_is_junk: MaNGOS doesn't store player latency
                    if ($core == 3) {
                        $output .= '
                <td>' . $char["latency"] . '</td>';
                    }
                }
            }
            if ($showcountryflag) {
                $country = misc_get_country_by_ip($char["lastip"]);
                $output .= '
                <td>' . ($country["code"] ? '<img src="img/flags/' . $country["code"] . '.png" onmousemove="oldtoolTip(\'' . $country["country"] . ($user_lvl >= $action_permission["update"] ? '<br />' . $country["actualip"] : '') . '\',\'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />' : '-') . '</td>';
            }
            $output .= '
              </tr>';
        }
        if ($total_online) {
            $output .= '
              <tr>';
            $output .= '
                <td colspan="' . (9 - $showcountryflag) . '" align="right" class="hidden" style="width: 25%;">';
            $output .= generate_pagination("index.php?start_m=" . $start_m . "&amp;order_by=" . $order_by . "&amp;dir=" . ($dir ? 0 : 1), $total_online, $itemperpage, $start);
            $output .= '
                </td>
              </tr>
            </table>';
        }
        $output .= '
            <br />';
        unset($total_online);
    }
}
コード例 #4
0
ファイル: index.php プロジェクト: BACKUPLIB/minimanager
function front(&$sqlr, &$sqlc, &$sqlm)
{
    global $output, $lang_global, $lang_index, $realm_id, $world_db, $mmfpm_db, $server, $action_permission, $user_lvl, $user_id, $showcountryflag, $motd_display_poster, $gm_online_count, $gm_online, $itemperpage;
    $output .= '
                <div class="top">';
    if (test_port($server[$realm_id]['addr'], $server[$realm_id]['game_port'])) {
        $stats = $sqlr->fetch_assoc($sqlr->query('SELECT starttime, maxplayers FROM uptime WHERE realmid = ' . $realm_id . ' ORDER BY starttime DESC LIMIT 1'), 0);
        $uptimetime = time() - $stats['starttime'];
        function format_uptime($seconds)
        {
            $secs = intval($seconds % 60);
            $mins = intval($seconds / 60 % 60);
            $hours = intval($seconds / 3600 % 24);
            $days = intval($seconds / 86400);
            $uptimeString = '';
            if ($days) {
                $uptimeString .= $days;
                $uptimeString .= 1 === $days ? ' day' : ' days';
            }
            if ($hours) {
                $uptimeString .= (0 < $days ? ', ' : '') . $hours;
                $uptimeString .= 1 === $hours ? ' hour' : ' hours';
            }
            if ($mins) {
                $uptimeString .= (0 < $days || 0 < $hours ? ', ' : '') . $mins;
                $uptimeString .= 1 === $mins ? ' minute' : ' minutes';
            }
            if ($secs) {
                $uptimeString .= (0 < $days || 0 < $hours || 0 < $mins ? ', ' : '') . $secs;
                $uptimeString .= 1 === $secs ? ' second' : ' seconds';
            }
            return $uptimeString;
        }
        $staticUptime = $lang_index['realm'] . ' <em>' . htmlentities(get_realm_name($realm_id)) . '</em> ' . $lang_index['online'] . ' for ' . format_uptime($uptimetime);
        unset($uptimetime);
        $output .= '
                    <div id="uptime">
                        <h1>
                            <font color="#55aa55">' . $staticUptime . '<br />' . $lang_index['maxplayers'] . ': ' . $stats['maxplayers'] . '</font>
                        </h1>
                    </div>';
        unset($staticUptime);
        unset($stats);
        $online = true;
    } else {
        $output .= '
                    <h1>
                        <font class="error">' . $lang_index['realm'] . ' <em>' . htmlentities(get_realm_name($realm_id)) . '</em> ' . $lang_index['offline_or_let_high'] . '</font>
                    </h1>';
        $online = false;
    }
    $sqlw = new SQL();
    $sqlw->connect($world_db[$realm_id]['addr'], $world_db[$realm_id]['user'], $world_db[$realm_id]['pass'], $world_db[$realm_id]['name']);
    //  This retrieves the actual database version from the database itself, instead of hardcoding it into a string
    $version = $sqlw->fetch_assoc($sqlw->query('SELECT core_revision, db_version FROM version'), 0);
    $output .= '
                    ' . $lang_index['trinity_rev'] . ' ' . $version['core_revision'] . ' ' . $lang_index['using_db'] . ' ' . $version['db_version'] . '
                </div>';
    unset($version);
    //MOTD part
    $start_m = isset($_GET['start_m']) ? $sqlc->quote_smart($_GET['start_m']) : 0;
    if (is_numeric($start_m)) {
    } else {
        $start_m = 0;
    }
    $sqlm = new SQL();
    $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
    $all_record_m = $sqlm->result($sqlm->query('SELECT count(*) FROM mm_motd'), 0);
    if ($user_lvl >= $action_permission['delete']) {
        $output .= '
                <script type="text/javascript">
                    // <![CDATA[
                        answerbox.btn_ok="' . $lang_global['yes_low'] . '";
                        answerbox.btn_cancel="' . $lang_global['no'] . '";
                        var del_motd = "motd.php?action=delete_motd&amp;id=";
                    // ]]>
                </script>';
    }
    $output .= '
                <center>
                    <table class="lined">
                        <tr>
                            <th align="right">';
    if ($user_lvl >= $action_permission['insert']) {
        $output .= '
                                <a href="motd.php?action=add_motd">' . $lang_index['add_motd'] . '</a>';
    }
    $output .= '
                            </th>
                        </tr>';
    if ($all_record_m) {
        $result = $sqlm->query('SELECT id, realmid, type, content FROM mm_motd WHERE realmid = ' . $realm_id . ' ORDER BY id DESC LIMIT ' . $start_m . ', 3');
        while ($post = $sqlm->fetch_assoc($result)) {
            $output .= '
                        <tr>
                            <td align="left" class="large">
                                <blockquote>' . bbcode_bbc2html($post['content']) . '</blockquote>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">';
            $motd_display_poster ? $output .= $post['type'] : '';
            if ($user_lvl >= $action_permission['delete']) {
                $output .= '
                                <img src="img/cross.png" width="12" height="12" onclick="answerBox(\'' . $lang_global['delete'] . ': &lt;font color=white&gt;' . $post['id'] . '&lt;/font&gt;&lt;br /&gt;' . $lang_global['are_you_sure'] . '\', del_motd + ' . $post['id'] . ');" style="cursor:pointer;" alt="" />';
            }
            if ($user_lvl >= $action_permission['update']) {
                $output .= '
                                <a href="motd.php?action=edit_motd&amp;error=3&amp;id=' . $post['id'] . '">
                                    <img src="img/edit.png" width="14" height="14" alt="" />
                                </a>';
            }
            $output .= '
                            </td>
                        </tr>
                        <tr>
                            <td class="hidden"></td>
                        </tr>';
        }
        if ($online) {
            $output .= '%%REPLACE_TAG%%';
        } else {
            $output .= '
                        <tr>
                            <td align="right" class="hidden">' . generate_pagination('index.php?start=0', $all_record_m, 3, $start_m, 'start_m') . '</td>
                        </tr>';
        }
    }
    $output .= '
                    </table>';
    //print online chars
    if ($online) {
        //==========================$_GET and SECURE=================================
        $start = isset($_GET['start']) ? $sqlc->quote_smart($_GET['start']) : 0;
        if (is_numeric($start)) {
        } else {
            $start = 0;
        }
        $order_by = isset($_GET['order_by']) ? $sqlc->quote_smart($_GET['order_by']) : 'level';
        if (preg_match('/^[_[:lower:]]{1,12}$/', $order_by)) {
        } else {
            $order_by = 'level';
        }
        $dir = isset($_GET['dir']) ? $sqlc->quote_smart($_GET['dir']) : 1;
        if (preg_match('/^[01]{1}$/', $dir)) {
        } else {
            $dir = 1;
        }
        $order_dir = $dir ? 'DESC' : 'ASC';
        $dir = $dir ? 0 : 1;
        //==========================$_GET and SECURE end=============================
        if ($order_by === 'map') {
            $order_by = 'map ' . $order_dir . ', zone';
        } elseif ($order_by === 'zone') {
            $order_by = 'zone ' . $order_dir . ', map';
        }
        $order_side = '';
        if ($user_lvl || $server[$realm_id]['both_factions']) {
        } else {
            $result = $sqlc->query('SELECT race FROM characters WHERE account = ' . $user_id . '
                                    AND totaltime = (SELECT MAX(totaltime) FROM characters WHERE account = ' . $user_id . ') LIMIT 1');
            if ($sqlc->num_rows($result)) {
                $order_side = in_array($sqlc->result($result, 0), array(2, 5, 6, 8, 10)) ? ' AND race IN (2,5,6,8,10) ' : ' AND race IN (1,3,4,7,11) ';
            }
        }
        if ($order_by == 'ip') {
            $result = $sqlr->query('SELECT id, last_ip FROM account WHERE online = 1 ORDER BY last_ip ' . $order_dir . ' LIMIT ' . $start . ', ' . $itemperpage . '');
        } else {
            $result = $sqlc->query('SELECT characters.guid,  characters.name,  characters.race,  characters.class,  characters.zone,  characters.map,  characters.level,  characters.account,  characters.gender,  characters.totalHonorPoints, COALESCE(guild_member.guildid,0) AS guildid FROM characters LEFT JOIN guild_member ON guild_member.guid = characters.guid WHERE characters.online = 1 ' . ($gm_online == '0' ? 'AND characters.extra_flags &1 = 0 ' : '') . $order_side . ' ORDER BY ' . $order_by . ' ' . $order_dir . ' LIMIT ' . $start . ', ' . $itemperpage);
        }
        $total_online = $sqlc->result($sqlc->query('SELECT count(*) FROM characters WHERE online= 1' . ($gm_online_count == '0' ? ' AND extra_flags &1 = 0' : '')), 0);
        $replace = '
              <tr>
                <td align="right" class="hidden">' . generate_pagination('index.php?start=' . $start . '&amp;order_by=' . $order_by . '&amp;dir=' . ($dir ? 0 : 1) . '', $all_record_m, 3, $start_m, 'start_m') . '</td>
              </tr>';
        unset($all_record_m);
        $output = str_replace('%%REPLACE_TAG%%', $replace, $output);
        unset($replace);
        $output .= '
                    <font class="bold">' . $lang_index['tot_users_online'] . ': ' . $total_online . '</font>
                    <table class="lined">
                        <tr>
                            <td colspan="' . (10 - $showcountryflag) . '" align="right" class="hidden" width="25%">';
        $output .= generate_pagination('index.php?start_m=' . $start_m . '&amp;order_by=' . $order_by . '&amp;dir=' . ($dir ? 0 : 1), $total_online, $itemperpage, $start);
        $output .= '
                            </td>
                        </tr>
                        <tr>
                            <th width="15%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=name&amp;dir=' . $dir . '"' . ($order_by === 'name' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['name'] . '</a></th>
                            <th width="1%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=race&amp;dir=' . $dir . '"' . ($order_by === 'race' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['race'] . '</a></th>
                            <th width="1%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=class&amp;dir=' . $dir . '"' . ($order_by === 'class' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['class'] . '</a></th>
                            <th width="5%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=level&amp;dir=' . $dir . '"' . ($order_by === 'level' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['level'] . '</a></th>
                            <th width="1%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=totalHonorPoints&amp;dir=' . $dir . '"' . ($order_by === 'totalHonorPoints' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['rank'] . '</a></th>
                            <th width="15%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=guildid&amp;dir=' . $dir . '"' . ($order_by === 'guildid' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['guild'] . '</a></th>
                            <th width="20%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=map&amp;dir=' . $dir . '"' . ($order_by === 'map ' . $order_dir . ', zone' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['map'] . '</a></th>
                            <th width="25%"><a href="index.php?start=' . $start . '&amp;start_m=' . $start_m . '&amp;order_by=zone&amp;dir=' . $dir . '"' . ($order_by === 'zone ' . $order_dir . ', map' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['zone'] . '</a></th>';
        if ($showcountryflag) {
            require_once 'libs/misc_lib.php';
            $output .= '
                            <th width="1%">' . $lang_global['country'] . '</th>';
        }
        $output .= '
                        </tr>';
        $sqlm = new SQL();
        $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
        while ($char = $sqlc->fetch_assoc($result)) {
            if ($order_by == 'ip') {
                $temp = $sqlc->fetch_assoc($sqlc->query('SELECT characters.guid,  characters.name,  characters.race,  characters.class,  characters.zone,  characters.map,  characters.level,  characters.account,  characters.gender,  characters.totalHonorPoints, COALESCE(guild_member.guildid,0) AS guildid FROM characters LEFT JOIN guild_member ON guild_member.guid = characters.guid WHERE characters.online= 1 ' . ($gm_online == '0' ? 'AND characters.extra_flags &1 = 0 ' : '') . $order_side . ' and account = ' . $char['id']));
                if (isset($temp['guid'])) {
                    $char = $temp;
                } else {
                    continue;
                }
            }
            $gm = $sqlr->result($sqlr->query('SELECT gmlevel FROM account_access WHERE id=' . $char['account'] . ''), 0);
            $guild_name = $sqlc->result($sqlc->query('SELECT name FROM guild WHERE guildid=' . $char['guildid'] . ''));
            $output .= '
                        <tr>
                            <td>';
            if ($user_lvl >= $gm) {
                $output .= '
                                <a href="char.php?id=' . $char['guid'] . '">
                                    <span onmousemove="toolTip(\'' . id_get_gm_level($gm) . '\', \'item_tooltip\')" onmouseout="toolTip()">' . htmlentities($char['name']) . '</span>
                                </a>';
            } else {
                $output .= '
                                <span onmousemove="toolTip(\'' . id_get_gm_level($gm) . '\', \'item_tooltip\')" onmouseout="toolTip()">' . htmlentities($char['name']) . '</span>';
            }
            $output .= '
                            </td>
                            <td>
                                <img src="img/c_icons/' . $char['race'] . '-' . $char['gender'] . '.gif" onmousemove="toolTip(\'' . char_get_race_name($char['race']) . '\', \'item_tooltip\')" onmouseout="toolTip()" alt="" />
                            </td>
                            <td>
                                <img src="img/c_icons/' . $char['class'] . '.gif" onmousemove="toolTip(\'' . char_get_class_name($char['class']) . '\', \'item_tooltip\')" onmouseout="toolTip()" alt="" />
                            </td>
                            <td>' . char_get_level_color($char['level']) . '</td>
                            <td>
                                <span onmouseover="toolTip(\'' . char_get_pvp_rank_name($char['totalHonorPoints'], char_get_side_id($char['race'])) . '\', \'item_tooltip\')" onmouseout="toolTip()" style="color: white;"><img src="img/ranks/rank' . char_get_pvp_rank_id($char['totalHonorPoints'], char_get_side_id($char['race'])) . '.gif" alt="" /></span>
                            </td>
                            <td>
                                <a href="guild.php?action=view_guild&amp;error=3&amp;id=' . $char['guildid'] . '">' . htmlentities($guild_name) . '</a>
                            </td>
                            <td><span onmousemove="toolTip(\'MapID:' . $char['map'] . '\', \'item_tooltip\')" onmouseout="toolTip()">' . get_map_name($char['map'], $sqlm) . '</span></td>
                            <td><span onmousemove="toolTip(\'ZoneID:' . $char['zone'] . '\', \'item_tooltip\')" onmouseout="toolTip()">' . get_zone_name($char['zone'], $sqlm) . '</span></td>';
            if ($showcountryflag) {
                $country = misc_get_country_by_account($char['account'], $sqlr, $sqlm);
                $output .= '
                            <td>' . ($country['code'] ? '<img src="img/flags/' . $country['code'] . '.png" onmousemove="toolTip(\'' . $country['country'] . '\',\'item_tooltip\')" onmouseout="toolTip()" alt="" />' : '-') . '</td>';
            }
            $output .= '
                        </tr>';
        }
        $output .= '
                        <tr>';
        $output .= '
                            <td colspan="' . (10 - $showcountryflag) . '" align="right" class="hidden" width="25%">';
        $output .= generate_pagination('index.php?start_m=' . $start_m . '&amp;order_by=' . $order_by . '&amp;dir=' . ($dir ? 0 : 1), $total_online, $itemperpage, $start);
        unset($total_online);
        $output .= '
                            </td>
                        </tr>
                    </table>
                    <br />
                </center>';
    }
}
コード例 #5
0
ファイル: honor.php プロジェクト: BACKUPLIB/minimanager
<?php

require_once "header.php";
require_once "libs/char_lib.php";
valid_login($action_permission['read']);
//global $lang_honor, $lang_global, $output, $characters_db, $realm_id, $itemperpage, $realm_db;
$sql = new SQL();
$sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
$start = isset($_GET['start']) ? $sql->quote_smart($_GET['start']) : 0;
$order_by = isset($_GET['order_by']) ? $sql->quote_smart($_GET['order_by']) : "honor";
$query = $sql->query("SELECT C.guid, C.name, C.race, C.class, C.totalHonorPoints AS honor , C.totalKills AS kills, C.level, C.arenaPoints AS arena, COALESCE(guild_member.guildid,0) as GNAME, C.gender FROM characters C LEFT JOIN guild_member ON C.guid = guild_member.guid WHERE race in (1,3,4,7,11) ORDER BY {$order_by} DESC LIMIT 25;");
$this_page = $sql->num_rows($query);
$output .= "\r\n                <script type=\"text/javascript\">\r\n                    answerbox.btn_ok='{$lang_global['yes_low']}';\r\n                    answerbox.btn_cancel='{$lang_global['no']}';\r\n                </script>\r\n                <center>\r\n                    <fieldset style=\"width: 776px;\">\r\n                        <legend><img src='img/alliance.gif' /></legend>\r\n                        <table class=\"lined\" style=\"width: 705px;\">\r\n                            <tr class=\"bold\">\r\n                                <td colspan=\"11\">{$lang_honor['allied']} {$lang_honor['browse_honor']}</td>\r\n                            </tr>\r\n                            <tr>\r\n                                <th width=\"30%\">{$lang_honor['guid']}</th>\r\n                                <th width=\"7%\">{$lang_honor['race']}</th>\r\n                                <th width=\"7%\">{$lang_honor['class']}</th>\r\n                                <th width=\"7%\">{$lang_honor['level']}</th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=honor\"" . ($order_by == 'honor' ? " class=DESC" : "") . ">{$lang_honor['honor']}</a></th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=honor\"" . ($order_by == 'honor' ? " class=DESC" : "") . ">{$lang_honor['honor points']}</a></th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=kills\"" . ($order_by == 'kills' ? " class=DESC" : "") . ">Kills</a></th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=arena\"" . ($order_by == 'arena' ? " class=DESC" : "") . ">AP</a></th>\r\n                                <th width=\"30%\">{$lang_honor['guild']}</th>\r\n                            </tr>";
while ($char = $sql->fetch_row($query)) {
    $guild_name = $sql->fetch_row($sql->query("SELECT `name` FROM `guild` WHERE `guildid`=" . $char[8] . ";"));
    $output .= "\r\n                            <tr>\r\n                                <td><a href=\"char.php?id={$char['0']}\">" . htmlentities($char[1]) . "</a></td>\r\n                                <td><img src='img/c_icons/{$char[2]}-{$char[9]}.gif' onmousemove='toolTip(\"" . char_get_race_name($char[2]) . "\",\"item_tooltip\")' onmouseout='toolTip()'></td>\r\n                                <td><img src='img/c_icons/{$char[3]}.gif' onmousemove='toolTip(\"" . char_get_class_name($char[3]) . "\",\"item_tooltip\")' onmouseout='toolTip()'></td>\r\n                                <td>" . char_get_level_color($char[6]) . "</td>\r\n                                <td><span onmouseover='toolTip(\"" . char_get_pvp_rank_name($char[4], char_get_side_id($char[2])) . "\",\"item_tooltip\")' onmouseout='toolTip()' style='color: white;'><img src='img/ranks/rank" . char_get_pvp_rank_id($char[4], char_get_side_id($char[2])) . ".gif'></span></td>\r\n                                <td>{$char['4']}</td>\r\n                                <td>{$char['5']}</td>\r\n                                <td>{$char['7']}</td>\r\n                                <td><a href=\"guild.php?action=view_guild&amp;error=3&amp;id={$char['8']}\">" . htmlentities($guild_name[0]) . "</a></td>\r\n                            </tr>";
}
$output .= "\r\n                        </table>\r\n                        <br />\r\n                    </fieldset>";
$query = $sql->query("SELECT C.guid, C.name, C.race, C.class, C.todayHonorPoints AS honor , C.totalKills AS kills, C.level, C.arenaPoints AS arena, COALESCE(guild_member.guildid,0) as GNAME, C.gender FROM characters C LEFT JOIN guild_member ON C.guid = guild_member.guid WHERE race not in (1,3,4,7,11) ORDER BY {$order_by} DESC LIMIT 25;");
$this_page = $sql->num_rows($query);
$output .= "\r\n                <script type=\"text/javascript\">\r\n                    answerbox.btn_ok='{$lang_global['yes_low']}';\r\n                    answerbox.btn_cancel='{$lang_global['no']}';\r\n                </script>\r\n                <center>\r\n                    <fieldset style=\"width: 776px;\">\r\n                        <legend><img src='img/horde.gif' /></legend>\r\n                        <table class=\"lined\" style=\"width: 705px;\">\r\n                            <tr class=\"bold\">\r\n                                <td colspan=\"11\">{$lang_honor['horde']} {$lang_honor['browse_honor']}</td>\r\n                            </tr>\r\n                            <tr>\r\n                                <th width=\"30%\">{$lang_honor['guid']}</th>\r\n                                <th width=\"7%\">{$lang_honor['race']}</th>\r\n                                <th width=\"7%\">{$lang_honor['class']}</th>\r\n                                <th width=\"7%\">{$lang_honor['level']}</th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=honor\"" . ($order_by == 'honor' ? " class=DESC" : "") . ">{$lang_honor['honor']}</a></th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=honor\"" . ($order_by == 'honor' ? " class=DESC" : "") . ">{$lang_honor['honor points']}</a></th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=kills\"" . ($order_by == 'kills' ? " class=DESC" : "") . ">Kills</a></th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=arena\"" . ($order_by == 'arena' ? " class=DESC" : "") . ">AP</a></th>\r\n                                <th width=\"30%\">{$lang_honor['guild']}</th>\r\n                            </tr>";
while ($char = $sql->fetch_row($query)) {
    $guild_name = $sql->fetch_row($sql->query("SELECT `name` FROM `guild` WHERE `guildid`=" . $char[8] . ";"));
    $output .= "\r\n                            <tr>\r\n                                <td><a href=\"char.php?id={$char['0']}\">" . htmlentities($char[1]) . "</a></td>\r\n                                <td><img src='img/c_icons/{$char[2]}-{$char[9]}.gif' onmousemove='toolTip(\"" . char_get_race_name($char[2]) . "\",\"item_tooltip\")' onmouseout='toolTip()'></td>\r\n                                <td><img src='img/c_icons/{$char[3]}.gif' onmousemove='toolTip(\"" . char_get_class_name($char[3]) . "\",\"item_tooltip\")' onmouseout='toolTip()'></td>\r\n                                <td>" . char_get_level_color($char[6]) . "</td>\r\n                                <td><span onmouseover='toolTip(\"" . char_get_pvp_rank_name($char[4], char_get_side_id($char[2])) . "\",\"item_tooltip\")' onmouseout='toolTip()' style='color: white;'><img src='img/ranks/rank" . char_get_pvp_rank_id($char[4], char_get_side_id($char[2])) . ".gif'></span></td>\r\n                                <td>{$char['4']}</td>\r\n                                <td>{$char['5']}</td>\r\n                                <td>{$char['7']}</td>\r\n                                <td><a href=\"guild.php?action=view_guild&amp;error=3&amp;id={$char['8']}\">" . htmlentities($guild_name[0]) . "</a></td>\r\n                            </tr>";
}
$output .= "\r\n                        </table>\r\n                        <br />\r\n                    </fieldset>";
require_once "footer.php";
コード例 #6
0
ファイル: top100.php プロジェクト: xhaher/CoreManager
function top100($realm_id)
{
    global $output, $logon_db, $characters_db, $dbc_db, $server, $itemperpage, $developer_test_mode, $multi_realm_mode, $sql, $core, $site_encoding, $n_realms;
    $sql["char"]->connect($characters_db[$realm_id]["addr"], $characters_db[$realm_id]["user"], $characters_db[$realm_id]["pass"], $characters_db[$realm_id]["name"], $characters_db[$realm_id]["encoding"]);
    //==========================$_GET and SECURE========================
    $type = isset($_GET["type"]) ? $sql["char"]->quote_smart($_GET["type"]) : "level";
    if (!preg_match("/^[_[:lower:]]{1,10}\$/", $type)) {
        $type = "level";
    }
    $start = isset($_GET["start"]) ? $sql["char"]->quote_smart($_GET["start"]) : 0;
    if (!is_numeric($start)) {
        $start = 0;
    }
    $order_by = isset($_GET["order_by"]) ? $sql["char"]->quote_smart($_GET["order_by"]) : "level";
    if (!preg_match("/^[_[:lower:]]{1,14}\$/", $order_by)) {
        $order_by = "level";
    }
    // Top 100 should sort DESC by default...
    $dir = isset($_GET["dir"]) ? $sql["char"]->quote_smart($_GET["dir"]) : 0;
    if (!preg_match("/^[01]{1}\$/", $dir)) {
        $dir = 1;
    }
    $order_dir = $dir ? "ASC" : "DESC";
    $dir = $dir ? 0 : 1;
    //==========================$_GET and SECURE end========================
    $type_list = array("level", "stat", "defense", "attack", "resist", "crit_hit", "pvp");
    if (!in_array($type, $type_list)) {
        $type = "level";
    }
    $result = $sql["char"]->query("SELECT count(*) FROM characters");
    $all_record = $sql["char"]->result($result, 0);
    $all_record = $all_record < 100 ? $all_record : 100;
    if ($core == 1) {
        // this_is_junk: rage and runic are both stored *10
        $result = $sql["char"]->query("SELECT guid, name, race, class, gender, level, online, gold,\r\n      SUBSTRING_INDEX(SUBSTRING_INDEX(playedtime, ' ', 2), ' ', -1) AS totaltime,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_GUILDID + 1) . "), ';', -1) AS UNSIGNED) AS gname,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_MAXHEALTH + 1) . "), ';', -1) AS UNSIGNED) AS health,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_MAXPOWER1 + 1) . "), ';', -1) AS UNSIGNED) AS mana,\r\n     (CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_MAXPOWER2 + 1) . "), ';', -1) AS UNSIGNED) DIV 10) AS rage,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_MAXPOWER4 + 1) . "), ';', -1) AS UNSIGNED) AS energy,\r\n     (CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_MAXPOWER7 + 1) . "), ';', -1) AS UNSIGNED) DIV 10) AS runic,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_STAT0 + 1) . "), ';', -1) AS UNSIGNED) AS str,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_STAT1 + 1) . "), ';', -1) AS UNSIGNED) AS agi,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_STAT2 + 1) . "), ';', -1) AS UNSIGNED) AS sta,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_STAT3 + 1) . "), ';', -1) AS UNSIGNED) AS intel,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_STAT4 + 1) . "), ';', -1) AS UNSIGNED) AS spi,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_RESISTANCES + 1) . "), ';', -1) AS UNSIGNED) AS armor,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_BLOCK_PERCENTAGE + 1) . "), ';', -1) AS UNSIGNED) AS block,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_DODGE_PERCENTAGE + 1) . "), ';', -1) AS UNSIGNED) AS dodge,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_PARRY_PERCENTAGE + 1) . "), ';', -1) AS UNSIGNED) AS parry,\r\n     (CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_ATTACK_POWER + 1) . "), ';', -1) AS UNSIGNED)\r\n    + CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_ATTACK_POWER_MODS + 1) . "), ';', -1) AS UNSIGNED)) AS ap,\r\n     (CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_RANGED_ATTACK_POWER + 1) . "), ';', -1) AS UNSIGNED)\r\n    + CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_RANGED_ATTACK_POWER_MODS + 1) . "), ';', -1) AS UNSIGNED)) AS ranged_ap,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_MINDAMAGE + 1) . "), ';', -1) AS UNSIGNED) AS min_dmg,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_MAXDAMAGE + 1) . "), ';', -1) AS UNSIGNED) AS max_dmg,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_MINRANGEDDAMAGE + 1) . "), ';', -1) AS UNSIGNED) AS min_ranged_dmg,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_MAXRANGEDDAMAGE + 1) . "), ';', -1) AS UNSIGNED) AS max_ranged_dmg,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_EXPERTISE + 1) . "), ';', -1) AS UNSIGNED) AS expertise,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_OFFHAND_EXPERTISE + 1) . "), ';', -1) AS UNSIGNED) AS off_expertise,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_RESISTANCES + 1 + 1) . "), ';', -1) AS UNSIGNED) AS holy,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_RESISTANCES + 2 + 1) . "), ';', -1) AS UNSIGNED) AS fire,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_RESISTANCES + 3 + 1) . "), ';', -1) AS UNSIGNED) AS nature,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_RESISTANCES + 4 + 1) . "), ';', -1) AS UNSIGNED) AS frost,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_RESISTANCES + 5 + 1) . "), ';', -1) AS UNSIGNED) AS shadow,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (UNIT_FIELD_RESISTANCES + 6 + 1) . "), ';', -1) AS UNSIGNED) AS arcane,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_CRIT_PERCENTAGE + 1) . "), ';', -1) AS UNSIGNED) AS melee_crit,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_RANGED_CRIT_PERCENTAGE + 1) . "), ';', -1) AS UNSIGNED) AS range_crit,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_FIELD_COMBAT_RATING_1 + 7) . "), ';', -1) AS UNSIGNED) AS melee_hit,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_FIELD_COMBAT_RATING_1 + 6) . "), ';', -1) AS UNSIGNED) AS range_hit,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_FIELD_COMBAT_RATING_1 + 5) . "), ';', -1) AS UNSIGNED) AS spell_hit,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_FIELD_HONOR_CURRENCY + 1) . "), ';', -1) AS UNSIGNED) AS honor,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_FIELD_LIFETIME_HONORBALE_KILLS + 1) . "), ';', -1) AS UNSIGNED) AS kills,\r\n      CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', " . (PLAYER_FIELD_ARENA_CURRENCY + 1) . "), ';', -1) AS UNSIGNED) AS arena,\r\n      IFNULL((SELECT SUM(points) FROM character_achievement LEFT JOIN `" . $dbc_db["name"] . "`.achievement ON `" . $dbc_db["name"] . "`.achievement.id=character_achievement.achievement WHERE character_achievement.guid=characters.guid),0) AS ach_points\r\n      FROM characters \r\n      ORDER BY " . $order_by . " " . $order_dir . " LIMIT " . $start . ", " . $itemperpage);
    } elseif ($core == 2) {
        $query = "SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.level, \r\n              characters.totaltime, characters.online, characters.money AS gold, health,\r\n              power1 AS mana,\r\n              power2 AS rage,\r\n              power4 AS energy,\r\n              power7 AS runic,\r\n\t\t\t\t\t\t\tcharacters.arenaPoints AS arena, characters.totalHonorPoints AS honor, characters.totalKills AS kills,\r\n              strength AS str,\r\n              agility AS agi,\r\n              stamina AS sta,\r\n              intellect AS intel,\r\n              spirit AS spi,\r\n              armor AS armor,\r\n              blockPct AS block,\r\n              dodgePct AS dodge,\r\n              parryPct AS parry,\r\n              attackPower AS ap,\r\n              rangedAttackPower AS ranged_ap,\r\n              power2 AS min_dmg,\r\n              power3 AS max_dmg,\r\n              power4 AS min_ranged_dmg,\r\n              power5 AS max_ranged_dmg,\r\n              power6 AS expertise,\r\n              power7 AS off_expertise,\r\n              resHoly AS holy,\r\n              resFire AS fire,\r\n              resNature AS nature,\r\n              resFrost AS frost,\r\n              resShadow AS shadow,\r\n              resArcane AS arcane,\r\n              critPct AS melee_crit,\r\n              rangedCritPct AS range_crit,\r\n              power1 AS melee_hit,\r\n              power2 AS range_hit,\r\n              power3 AS spell_hit,\r\n              IFNULL((SELECT SUM(points) FROM character_achievement LEFT JOIN `" . $dbc_db["name"] . "`.achievement ON `" . $dbc_db["name"] . "`.achievement.id=character_achievement.achievement WHERE character_achievement.guid=characters.guid),0) AS ach_points\r\n              FROM characters\r\n              LEFT JOIN character_stats ON character_stats.guid=characters.guid\r\n              ORDER BY " . $order_by . " " . $order_dir . " LIMIT " . $start . ", " . $itemperpage;
        $result = $sql["char"]->query($query);
    } else {
        $query = "SELECT characters.guid, characters.name, race, class, gender, level, \r\n              totaltime, online, money AS gold, health,\r\n              power1 AS mana,\r\n              power2 AS rage,\r\n              power4 AS energy,\r\n              power7 AS runic,\r\n\t\t\t\t\t\t\tarenaPoints AS arena, totalHonorPoints AS honor, totalKills AS kills,\r\n              strength AS str,\r\n              agility AS agi,\r\n              stamina AS sta,\r\n              intellect AS intel,\r\n              spirit AS spi,\r\n              armor AS armor,\r\n              blockPct AS block,\r\n              dodgePct AS dodge,\r\n              parryPct AS parry,\r\n              attackPower AS ap,\r\n              rangedAttackPower AS ranged_ap,\r\n              power2 AS min_dmg,\r\n              power3 AS max_dmg,\r\n              power4 AS min_ranged_dmg,\r\n              power5 AS max_ranged_dmg,\r\n              power6 AS expertise,\r\n              power7 AS off_expertise,\r\n              resHoly AS holy,\r\n              resFire AS fire,\r\n              resNature AS nature,\r\n              resFrost AS frost,\r\n              resShadow AS shadow,\r\n              resArcane AS arcane,\r\n              critPct AS melee_crit,\r\n              rangedCritPct AS range_crit,\r\n              power1 AS melee_hit,\r\n              power2 AS range_hit,\r\n              power3 AS spell_hit,\r\n              IFNULL((SELECT SUM(points) FROM character_achievement LEFT JOIN `" . $dbc_db["name"] . "`.achievement ON `" . $dbc_db["name"] . "`.achievement.id=character_achievement.achievement WHERE character_achievement.guid=characters.guid),0) AS ach_points\r\n              FROM characters\r\n              LEFT JOIN character_stats ON character_stats.guid=characters.guid\r\n              ORDER BY " . $order_by . " " . $order_dir . " LIMIT " . $start . ", " . $itemperpage;
        $result = $sql["char"]->query($query);
    }
    //==========================top tage navigaion starts here========================
    $output .= '
          <div class="tab">
            <ul>
              <li' . ($type == "level" ? ' class="selected"' : '') . '>
                <a href="top100.php?n_realms=' . $n_realms . '&amp;start=' . $start . '">
                  ' . lang("top", "general") . '
                </a>
              </li>
              <li' . ($type == "stat" ? ' class="selected"' : '') . '>
                <a href="top100.php?n_realms=' . $n_realms . '&amp;start=' . $start . '&amp;type=stat&amp;order_by=health">
                  ' . lang("top", "stats") . '
                </a>
              </li>
              <li' . ($type == "defense" ? ' class="selected"' : '') . '>
                <a href="top100.php?n_realms=' . $n_realms . '&amp;start=' . $start . '&amp;type=defense&amp;order_by=armor">
                  ' . lang("top", "defense") . '
                </a>
              </li>
              <li' . ($type == "resist" ? ' class="selected"' : '') . '>
                <a href="top100.php?n_realms=' . $n_realms . '&amp;start=' . $start . '&amp;type=resist&amp;order_by=holy">
                  ' . lang("top", "resist") . '
                </a>
              </li>
              <li' . ($type == "attack" ? ' class="selected"' : '') . '>
                <a href="top100.php?n_realms=' . $n_realms . '&amp;start=' . $start . '&amp;type=attack&amp;order_by=ap">
                  ' . lang("top", "melee") . '
                </a>
              </li>
              <li' . ($type == "crit_hit" ? ' class="selected"' : '') . '>
                <a href="top100.php?n_realms=' . $n_realms . '&amp;start=' . $start . '&amp;type=crit_hit&amp;order_by=ranged_ap">
                  ' . lang("top", "ranged") . '
                </a>
              </li>
              <li' . ($type == "pvp" ? ' class="selected"' : '') . '>
                <a href="top100.php?n_realms=' . $n_realms . '&amp;start=' . $start . '&amp;type=pvp&amp;order_by=honor">
                  ' . lang("top", "pvp") . '
                </a>
              </li>
            </ul>
          </div>
          <div class="tab_content center">
            <table class="top_hidden" id="top100_realms">';
    $output .= '
              <tr>
                <td align="right">Total: ' . $all_record . '</td>
                <td align="right" style="width: 25%;">';
    $output .= generate_pagination('top100.php?type=' . $type . '&amp;order_by=' . $order_by . '&amp;dir=' . ($dir ? 0 : 1) . '', $all_record, $itemperpage, $start);
    $output .= '
                </td>
              </tr>
            </table>';
    //==========================top tage navigaion ENDS here ========================
    $output .= '
            <table class="lined" id="' . ($type == "level" ? 'top100_mainlist_wide' : 'top100_mainlist') . '">
              <tr>
                <th style="width: 5%;">#</th>
                <th style="width: 14%;">' . lang("top", "name") . '</th>
                <th style="width: 5%;">' . lang("top", "race") . '</th>
                <th style="width: 5%;">' . lang("top", "class") . '</th>
                <th style="width: 8%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=level&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "level" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "level") . '</a></th>';
    if ($type == "level") {
        $output .= '
                <th style="width: 5%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=ach_points&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "ach_points" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "ach_points") . '</a></th>
                <th style="width: 22%;">' . lang("top", "guild") . '</th>
                <th style="width: 20%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=gold&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "gold" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "money") . '</a></th>
                <th style="width: 20%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=totaltime&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "totaltime" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "time_played") . '</a></th>';
    } elseif ($type == "stat") {
        $output .= '
                <th style="width: 11%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=health&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "health" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "health") . '</a></th>
                <th style="width: 10%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=mana&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "mana" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "mana") . '</a></th>
                <th style="width: 9%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=str&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "str" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "str") . '</a></th>
                <th style="width: 8%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=agi&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "agi" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "agi") . '</a></th>
                <th style="width: 8%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=sta&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "sta" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "sta") . '</a></th>
                <th style="width: 8%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=intel&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "intel" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "intel") . '</a></th>
                <th style="width: 8%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=spi&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "spi" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "spi") . '</a></th>';
    } elseif ($type == "defense") {
        $output .= '
                <th style="width: 16%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=armor&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "armor" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "armor") . '</a></th>
                <th style="width: 16%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=block&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "block" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "block") . '</a></th>
                <th style="width: 15%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=dodge&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "dodge" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "dodge") . '</a></th>
                <th style="width: 15%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=parry&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "parry" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "parry") . '</a></th>';
    } elseif ($type == "resist") {
        $output .= '
                <th style="width: 10%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=holy&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "holy" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "holy") . '</a></th>
                <th style="width: 10%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=fire&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "fire" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "fire") . '</a></th>
                <th style="width: 10%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=nature&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "nature" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "nature") . '</a></th>
                <th style="width: 10%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=frost&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "frost" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "frost") . '</a></th>
                <th style="width: 11%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=shadow&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "shadow" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "shadow") . '</a></th>
                <th style="width: 11%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=arcane&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "arcane" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "arcane") . '</a></th>';
    } elseif ($type == "attack") {
        $output .= '
                <th style="width: 20%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=ap&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "ap" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "ap") . '</a></th>
                <th style="width: 6%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=min_dmg&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "min_dmg" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "min_dmg") . '</a></th>
                <th style="width: 6%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=max_dmg&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "max_dmg" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "max_dmg") . '</a></th>
                <th style="width: 10%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=melee_crit&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "melee_crit" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "crit") . '</a></th>
                <th style="width: 5%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=melee_hit&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "melee_hit" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "hit") . '</a></th>
                <th style="width: 5%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=expertise&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "expertise" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "expertise") . '</a></th>
                <th style="width: 9%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=off_expertise&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "off_expertise" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "off_expertise") . '</a></th>';
    } elseif ($type == "crit_hit") {
        $output .= '
                <th style="width: 18%"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=ranged_ap&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "ranged_ap" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "ap") . '</a></th>
                <th style="width: 12%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=min_ranged_dmg&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "min_ranged_dmg" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "min_dmg") . '</a></th>
                <th style="width: 12%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=max_ranged_dmg&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "max_ranged_dmg" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "max_dmg") . '</a></th>
                <th style="width: 10%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=range_crit&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "range_crit" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "crit") . '</a></th>
                <th style="width: 10%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=range_hit&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "range_hit" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "hit") . '</a></th>';
    } elseif ($type == "pvp") {
        $output .= '
                <th style="width: 20%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=honor&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "honor" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "rank") . '</a></th>
                <th style="width: 14%;">' . lang("top", "honor_points") . '</th>
                <th style="width: 14%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=kills&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "kills" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "kills") . '</a></th>
                <th style="width: 14%;"><a href="top100.php?n_realms=' . $n_realms . '&amp;type=' . $type . '&amp;order_by=arena&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by == "arena" ? ' class="' . $order_dir . '"' : '') . '>' . lang("top", "arena_points") . '</a></th>';
    }
    $output .= '
              </tr>';
    $i = 0;
    while ($char = $sql["char"]->fetch_assoc($result)) {
        // MaNGOS & Trinity don't save guild info on the character
        if ($core != 1) {
            $g_query = "SELECT * FROM guild_member WHERE guid='" . $char["guid"] . "'";
            $g_result = $sql["char"]->query($g_query);
            $guildinfo = $sql["char"]->fetch_assoc($g_result);
            $char["gname"] = $guildinfo["guildid"];
        }
        $output .= '
              <tr valign="top">
                <td>' . (++$i + $start) . '</td>
                <td><a href="char.php?id=' . $char["guid"] . '&amp;realm=' . $realm_id . '">' . htmlentities($char["name"], ENT_COMPAT, $site_encoding) . '</a></td>
                <td>
                  <img src="img/c_icons/' . $char["race"] . '-' . $char["gender"] . '.gif" alt="' . char_get_race_name($char["race"]) . '" onmousemove="toolTip(\'' . char_get_race_name($char["race"]) . '\', \'item_tooltip\')" onmouseout="toolTip()" />
                </td>
                <td>
                  <img src="img/c_icons/' . $char["class"] . '.gif" alt="' . char_get_class_name($char["class"]) . '" onmousemove="toolTip(\'' . char_get_class_name($char["class"]) . '\', \'item_tooltip\')" onmouseout="toolTip()" />
                </td>
                <td>' . char_get_level_color($char["level"]) . '</td>';
        if ($type == "level") {
            if ($core == 1) {
                $guild_id = $sql["char"]->result($sql["char"]->query("SELECT guildid FROM guild_data WHERE playerid = '" . $char["guid"] . "'"), 0);
                $guild_name = $sql["char"]->result($sql["char"]->query("SELECT guildname FROM guilds WHERE guildid = '" . $guild_id . "'"), 0);
            } else {
                $guild_id = $sql["char"]->result($sql["char"]->query("SELECT guildid 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 . "'"), 0);
            }
            $days = floor(round($char["totaltime"] / 3600) / 24);
            $hours = round($char["totaltime"] / 3600) - $days * 24;
            $time = '';
            if ($days) {
                $time .= $days . ' days ';
            }
            if ($hours) {
                $time .= $hours . ' hours';
            }
            $output .= '
                <td>' . $char["ach_points"] . '</td>
                <td><a href="guild.php?action=view_guild&amp;realm=' . $realm_id . '&amp;error=3&amp;id=' . $guild_name . '">' . htmlentities($guild_name, ENT_COMPAT, $site_encoding) . '</a></td>
                <td align="right">
                  ' . substr($char["gold"], 0, -4) . '<img src="img/gold.gif" alt="" style="position: relative; bottom: -6px;" />
                  ' . substr($char["gold"], -4, 2) . '<img src="img/silver.gif" alt="" style="position: relative; bottom: -6px;" />
                  ' . substr($char["gold"], -2) . '<img src="img/copper.gif" alt="" style="position: relative; bottom: -6px;" />
                </td>
                <td align="right">' . $time . '</td>';
        } elseif ($type == "stat") {
            switch ($char["class"]) {
                case 1:
                    // Warrior
                    $output .= '
                <td>' . $char["health"] . '</td>
                <td>' . $char["rage"] . '</td>
                <td>' . $char["str"] . '</td>
                <td>' . $char["agi"] . '</td>
                <td>' . $char["sta"] . '</td>
                <td>' . $char["intel"] . '</td>
                <td>' . $char["spi"] . '</td>';
                    break;
                case 2:
                    //Paladin
                    $output .= '
                <td>' . $char["health"] . '</td>
                <td>' . $char["mana"] . '</td>
                <td>' . $char["str"] . '</td>
                <td>' . $char["agi"] . '</td>
                <td>' . $char["sta"] . '</td>
                <td>' . $char["intel"] . '</td>
                <td>' . $char["spi"] . '</td>';
                    break;
                case 3:
                    //Hunter
                    $output .= '
                <td>' . $char["health"] . '</td>
                <td>' . $char["mana"] . '</td>
                <td>' . $char["str"] . '</td>
                <td>' . $char["agi"] . '</td>
                <td>' . $char["sta"] . '</td>
                <td>' . $char["intel"] . '</td>
                <td>' . $char["spi"] . '</td>';
                    break;
                case 4:
                    //Rogue
                    $output .= '
                <td>' . $char["health"] . '</td>
                <td>' . $char["energy"] . '</td>
                <td>' . $char["str"] . '</td>
                <td>' . $char["agi"] . '</td>
                <td>' . $char["sta"] . '</td>
                <td>' . $char["intel"] . '</td>
                <td>' . $char["spi"] . '</td>';
                    break;
                case 5:
                    //Priest
                    $output .= '
                <td>' . $char["health"] . '</td>
                <td>' . $char["mana"] . '</td>
                <td>' . $char["str"] . '</td>
                <td>' . $char["agi"] . '</td>
                <td>' . $char["sta"] . '</td>
                <td>' . $char["intel"] . '</td>
                <td>' . $char["spi"] . '</td>';
                    break;
                case 6:
                    //Death Knight
                    $output .= '
                <td>' . $char["health"] . '</td>
                <td>' . $char["runic"] . '</td>
                <td>' . $char["str"] . '</td>
                <td>' . $char["agi"] . '</td>
                <td>' . $char["sta"] . '</td>
                <td>' . $char["intel"] . '</td>
                <td>' . $char["spi"] . '</td>';
                    break;
                case 7:
                    //Shaman
                    $output .= '
                <td>' . $char["health"] . '</td>
                <td>' . $char["mana"] . '</td>
                <td>' . $char["str"] . '</td>
                <td>' . $char["agi"] . '</td>
                <td>' . $char["sta"] . '</td>
                <td>' . $char["intel"] . '</td>
                <td>' . $char["spi"] . '</td>';
                    break;
                case 8:
                    //Mage
                    $output .= '
                <td>' . $char["health"] . '</td>
                <td>' . $char["mana"] . '</td>
                <td>' . $char["str"] . '</td>
                <td>' . $char["agi"] . '</td>
                <td>' . $char["sta"] . '</td>
                <td>' . $char["intel"] . '</td>
                <td>' . $char["spi"] . '</td>';
                    break;
                case 9:
                    //Warlock
                    $output .= '
                <td>' . $char["health"] . '</td>
                <td>' . $char["mana"] . '</td>
                <td>' . $char["str"] . '</td>
                <td>' . $char["agi"] . '</td>
                <td>' . $char["sta"] . '</td>
                <td>' . $char["intel"] . '</td>
                <td>' . $char["spi"] . '</td>';
                    break;
                case 7:
                    //Druid
                    $output .= '
                <td>' . $char["health"] . '</td>
                <td>' . $char["mana"] . '</td>
                <td>' . $char["str"] . '</td>
                <td>' . $char["agi"] . '</td>
                <td>' . $char["sta"] . '</td>
                <td>' . $char["intel"] . '</td>
                <td>' . $char["spi"] . '</td>';
                    break;
            }
        } elseif ($type == "defense") {
            $block = unpack("f", pack("L", $char["block"]));
            $block = round($block[1], 2);
            $dodge = unpack("f", pack("L", $char["dodge"]));
            $dodge = round($dodge[1], 2);
            $parry = unpack("f", pack("L", $char["parry"]));
            $parry = round($parry[1], 2);
            $output .= '
                <td>' . $char["armor"] . '</td>
                <td>' . $block . '%</td>
                <td>' . $dodge . '%</td>
                <td>' . $parry . '%</td>';
        } elseif ($type == "resist") {
            $output .= '
                <td>' . $char["holy"] . '</td>
                <td>' . $char["fire"] . '</td>
                <td>' . $char["nature"] . '</td>
                <td>' . $char["frost"] . '</td>
                <td>' . $char["shadow"] . '</td>
                <td>' . $char["arcane"] . '</td>';
        } elseif ($type == "attack") {
            $melee = unpack("f", pack("L", $char["melee_crit"]));
            $melee = round($melee[1], 2);
            $mindamage = unpack("f", pack("L", $char["min_dmg"]));
            $mindamage = round($mindamage[1], 0);
            $maxdamage = unpack("f", pack("L", $char["max_dmg"]));
            $maxdamage = round($maxdamage[1], 0);
            $output .= '
                <td>' . $char["ap"] . '</td>
                <td>' . $mindamage . '</td>
                <td>' . $maxdamage . '</td>
                <td>' . $melee . '%</td>
                <td>' . $char["melee_hit"] . '</td>
                <td>' . $char["expertise"] . '</td>
                <td>' . $char["off_expertise"] . '</td>';
        } elseif ($type == "crit_hit") {
            $range = unpack("f", pack("L", $char["range_crit"]));
            $range = round($range[1], 2);
            $minrangeddamage = unpack("f", pack("L", $char["min_ranged_dmg"]));
            $minrangeddamage = round($minrangeddamage[1], 0);
            $maxrangeddamage = unpack("f", pack("L", $char["max_ranged_dmg"]));
            $maxrangeddamage = round($maxrangeddamage[1], 0);
            $output .= '
                <td>' . $char["ranged_ap"] . '</td>
                <td>' . $minrangeddamage . '</td>
                <td>' . $maxrangeddamage . '</td>
                <td>' . $range . '%</td>
                <td>' . $char["range_hit"] . '</td>';
        } elseif ($type == "pvp") {
            $output .= '
                <td align="left"><img src="img/ranks/rank' . char_get_pvp_rank_id($char["honor"], char_get_side_id($char["race"])) . '.gif" alt=""></img> ' . char_get_pvp_rank_name($char["honor"], char_get_side_id($char["race"])) . '</td>
                <td>' . $char["honor"] . '</td>
                <td>' . $char["kills"] . '</td>
                <td>' . $char["arena"] . '</td>';
        }
        $output .= '
              </tr>';
    }
    $output .= '
            </table>
            <table class="top_hidden" id="top100_total_etc">
              <tr>
                <td align="right">Total: ' . $all_record . '</td>
                <td align="right" style="width: 25%;">';
    $output .= generate_pagination('top100.php?type=' . $type . '&amp;order_by=' . $order_by . '&amp;dir=' . ($dir ? 0 : 1) . '', $all_record, $itemperpage, $start);
    unset($all_record);
    $output .= '
                </td>
              </tr>
            </table>
          </div>
          <br />';
}
コード例 #7
0
ファイル: top100.php プロジェクト: BACKUPLIB/minimanager-1
function top100($realmid, &$sqlr, &$sqlc)
{
    global $output, $lang_top, $realm_db, $characters_db, $server, $itemperpage, $developer_test_mode, $multi_realm_mode;
    $realm_id = $realmid;
    $sqlc->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
    //==========================$_GET and SECURE========================
    $type = isset($_GET['type']) ? $sqlc->quote_smart($_GET['type']) : 'level';
    if (preg_match('/^[_[:lower:]]{1,10}$/', $type)) {
    } else {
        $type = 'level';
    }
    $start = isset($_GET['start']) ? $sqlc->quote_smart($_GET['start']) : 0;
    if (is_numeric($start)) {
    } else {
        $start = 0;
    }
    $order_by = isset($_GET['order_by']) ? $sqlc->quote_smart($_GET['order_by']) : 'level';
    if (preg_match('/^[_[:lower:]]{1,14}$/', $order_by)) {
    } else {
        $order_by = 'level';
    }
    $dir = isset($_GET['dir']) ? $sqlc->quote_smart($_GET['dir']) : 1;
    if (preg_match('/^[01]{1}$/', $dir)) {
    } else {
        $dir = 1;
    }
    $order_dir = $dir ? 'DESC' : 'DESC';
    $dir = $dir ? 0 : 1;
    //==========================$_GET and SECURE end========================
    $type_list = array('level', 'stat', 'defense', 'attack', 'resist', 'crit_hit', 'pvp');
    if (in_array($type, $type_list)) {
    } else {
        $type = 'level';
    }
    $result = $sqlc->query('SELECT count(*) FROM characters');
    $all_record = $sqlc->result($result, 0);
    $all_record = $all_record < 100 ? $all_record : 100;
    $result = $sqlc->query('SELECT characters.guid, characters.name, race, class, gender, level, totaltime, online, money, health,
							power1,
							arenaPoints as arena, totalHonorPoints as honor, totalKills as kills, 
    guildid as gname,
    strength AS str,
    agility AS agi,
    stamina AS sta,
    intellect AS intel,
    spirit AS spi,
    armor AS armor,
    blockPct AS block,
    dodgePct AS dodge,
    parryPct AS parry,
    attackPower AS ap,
    rangedAttackPower AS ranged_ap,
    power2 AS min_dmg,
    power3 AS max_dmg,
    power4 AS min_ranged_dmg,
    power5 AS max_ranged_dmg,
    power6 AS expertise,
    power7 AS off_expertise,
    resHoly AS holy,
    resFire AS fire,
    resNature AS nature,
    resFrost AS frost,
    resShadow AS shadow,
    resArcane AS arcane,
    critPct AS melee_crit,
    rangedCritPct AS range_crit,
    power1 AS melee_hit,
    power2 AS range_hit,
    power3 AS spell_hit

FROM characters, character_stats, guild_member WHERE guild_member.guid = characters.guid ORDER BY ' . $order_by . ' ' . $order_dir . ' LIMIT ' . $start . ', ' . $itemperpage . '');
    //==========================top tage navigaion starts here========================
    $output .= '
          <center>
            <div id="tab">
              <ul>
                <li' . ($type === 'level' ? ' id="selected"' : '') . '>
                  <a href="top100.php?start=' . $start . '">
                    ' . $lang_top['general'] . '
                  </a>
                </li>
                <li' . ($type === 'stat' ? ' id="selected"' : '') . '>
                  <a href="top100.php?start=' . $start . '&amp;type=stat&amp;order_by=health">
                    ' . $lang_top['stats'] . '
                  </a>
                </li>
                <li' . ($type === 'defense' ? ' id="selected"' : '') . '>
                  <a href="top100.php?start=' . $start . '&amp;type=defense&amp;order_by=armor">
                    ' . $lang_top['defense'] . '
                  </a>
                </li>
                <li' . ($type === 'resist' ? ' id="selected"' : '') . '>
                  <a href="top100.php?start=' . $start . '&amp;type=resist&amp;order_by=holy">
                    ' . $lang_top['resist'] . '
                  </a>
                </li>
                <li' . ($type === 'attack' ? ' id="selected"' : '') . '>
                  <a href="top100.php?start=' . $start . '&amp;type=attack&amp;order_by=ap">
                    ' . $lang_top['melee'] . '
                  </a>
                </li>
                <li' . ($type === 'crit_hit' ? ' id="selected"' : '') . '>
                  <a href="top100.php?start=' . $start . '&amp;type=crit_hit&amp;order_by=ranged_ap">
                    ' . $lang_top['ranged'] . '
                  </a>
                </li>
                <li' . ($type === 'pvp' ? ' id="selected"' : '') . '>
                  <a href="top100.php?start=' . $start . '&amp;type=pvp&amp;order_by=honor">
                    ' . $lang_top['pvp'] . '
                  </a>
                </li>
              </ul>
            </div>
            <div id="tab_content">
            <table class="top_hidden" style="width: 720px">';
    if ($developer_test_mode && $multi_realm_mode) {
        $realms = $sqlr->query('SELECT count(*) FROM realmlist');
        $tot_realms = $sqlr->result($realms, 0);
        if (1 < $tot_realms && 1 < count($server)) {
            $output .= '
              <tr>
                <td colspan="2" align="left">';
            makebutton('View', 'javascript:do_submit(\'form' . $realm_id . '\',0)', 130);
            $output .= '
                  <form action="top100.php?type=' . $type . '" method="post" name="form' . $realm_id . '">
                    Number of Realms :
                    <input type="hidden" name="action" value="realms" />
                    <select name="n_realms">';
            for ($i = 1; $i <= $tot_realms; ++$i) {
                $output .= '
                      <option value="' . $i . '">' . htmlentities($i) . '</option>';
            }
            $output .= '
                    </select>
                  </form>
                </td>
              </tr>';
        }
    }
    $output .= '
              <tr>
                <td align="right">Total: ' . $all_record . '</td>
                <td align="right" width="25%">';
    $output .= generate_pagination('top100.php?type=' . $type . '&amp;order_by=' . $order_by . '&amp;dir=' . ($dir ? 0 : 1) . '', $all_record, $itemperpage, $start);
    $output .= '
                </td>
              </tr>
            </table>';
    //==========================top tage navigaion ENDS here ========================
    $output .= '
            <table class="lined" style="width: 720px">
              <tr>
                <th width="5%">#</th>
                <th width="14%">' . $lang_top['name'] . '</th>
                <th width="11%">' . $lang_top['race'] . ' ' . $lang_top['class'] . '</th>
                <th width="8%"><a href="top100.php?type=' . $type . '&amp;order_by=level&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'level' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['level'] . '</a></th>';
    if ($type === 'level') {
        $output .= '
                <th width="22%">' . $lang_top['guild'] . '</th>
                <th width="20%"><a href="top100.php?type=' . $type . '&amp;order_by=money&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'money' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['money'] . '</a></th>
                <th width="20%"><a href="top100.php?type=' . $type . '&amp;order_by=totaltime&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'totaltime' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['time_played'] . '</a></th>';
    } elseif ($type === 'stat') {
        $output .= '
                <th width="11%"><a href="top100.php?type=' . $type . '&amp;order_by=health&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'health' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['health'] . '</a></th>
                <th width="10%"><a href="top100.php?type=' . $type . '&amp;order_by=power1&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'power1' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['mana'] . '</a></th>
                <th width="9%"><a href="top100.php?type=' . $type . '&amp;order_by=str&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'str' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['str'] . '</a></th>
                <th width="8%"><a href="top100.php?type=' . $type . '&amp;order_by=agi&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'agi' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['agi'] . '</a></th>
                <th width="8%"><a href="top100.php?type=' . $type . '&amp;order_by=sta&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'sta' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['sta'] . '</a></th>
                <th width="8%"><a href="top100.php?type=' . $type . '&amp;order_by=intel&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'intel' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['intel'] . '</a></th>
                <th width="8%"><a href="top100.php?type=' . $type . '&amp;order_by=spi&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'spi' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['spi'] . '</a></th>';
    } elseif ($type === 'defense') {
        $output .= '
                <th width="16%"><a href="top100.php?type=' . $type . '&amp;order_by=armor&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'armor' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['armor'] . '</a></th>
                <th width="16%"><a href="top100.php?type=' . $type . '&amp;order_by=block&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'block' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['block'] . '</a></th>
                <th width="15%"><a href="top100.php?type=' . $type . '&amp;order_by=dodge&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'dodge' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['dodge'] . '</a></th>
                <th width="15%"><a href="top100.php?type=' . $type . '&amp;order_by=parry&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'parry' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['parry'] . '</a></th>';
    } elseif ($type === 'resist') {
        $output .= '
                <th width="10%"><a href="top100.php?type=' . $type . '&amp;order_by=holy&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'holy' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['holy'] . '</a></th>
                <th width="10%"><a href="top100.php?type=' . $type . '&amp;order_by=fire&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'fire' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['fire'] . '</a></th>
                <th width="10%"><a href="top100.php?type=' . $type . '&amp;order_by=nature&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'nature' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['nature'] . '</a></th>
                <th width="10%"><a href="top100.php?type=' . $type . '&amp;order_by=frost&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'frost' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['frost'] . '</a></th>
                <th width="11%"><a href="top100.php?type=' . $type . '&amp;order_by=shadow&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'shadow' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['shadow'] . '</a></th>
                <th width="11%"><a href="top100.php?type=' . $type . '&amp;order_by=arcane&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'arcane' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['arcane'] . '</a></th>';
    } elseif ($type === 'attack') {
        $output .= '
                <th width="20%"><a href="top100.php?type=' . $type . '&amp;order_by=ap&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'ap' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['ap'] . '</a></th>
                <th width="6%"><a href="top100.php?type=' . $type . '&amp;order_by=min_dmg&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'min_dmg' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['min_dmg'] . '</a></th>
                <th width="6%"><a href="top100.php?type=' . $type . '&amp;order_by=max_dmg&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'max_dmg' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['max_dmg'] . '</a></th>
                <th width="10%"><a href="top100.php?type=' . $type . '&amp;order_by=melee_crit&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'melee_crit' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['crit'] . '</a></th>
                <th width="5%"><a href="top100.php?type=' . $type . '&amp;order_by=melee_hit&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'melee_hit' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['hit'] . '</a></th>
                <th width="5%"><a href="top100.php?type=' . $type . '&amp;order_by=expertise&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'expertise' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['expertise'] . '</a></th>
                <th width="9%"><a href="top100.php?type=' . $type . '&amp;order_by=off_expertise&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'off_expertise' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['off_expertise'] . '</a></th>
              </tr>';
    } elseif ($type === 'crit_hit') {
        $output .= '
                <th width="18%"><a href="top100.php?type=' . $type . '&amp;order_by=ranged_ap&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'ranged_ap' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['ap'] . '</a></th>
                <th width="12%"><a href="top100.php?type=' . $type . '&amp;order_by=min_ranged_dmg&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'min_ranged_dmg' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['min_dmg'] . '</a></th>
                <th width="12%"><a href="top100.php?type=' . $type . '&amp;order_by=max_ranged_dmg&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'max_ranged_dmg' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['max_dmg'] . '</a></th>
                <th width="10%"><a href="top100.php?type=' . $type . '&amp;order_by=range_crit&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'range_crit' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['crit'] . '</a></th>
                <th width="10%"><a href="top100.php?type=' . $type . '&amp;order_by=range_hit&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'range_hit' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['hit'] . '</a></th>';
    } elseif ($type === 'pvp') {
        $output .= '
                <th width="20%"><a href="top100.php?type=' . $type . '&amp;order_by=honor&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'honor' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['rank'] . '</a></th>
                <th width="14%">' . $lang_top['honor_points'] . '</th>
                <th width="14%"><a href="top100.php?type=' . $type . '&amp;order_by=kills&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'kills' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['kills'] . '</a></th>
                <th width="14%"><a href="top100.php?type=' . $type . '&amp;order_by=arena&amp;start=' . $start . '&amp;dir=' . $dir . '"' . ($order_by === 'arena' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_top['arena_points'] . '</a></th>';
    }
    $output .= '
              </tr>';
    $i = 0;
    while ($char = $sqlc->fetch_assoc($result)) {
        $output .= '
              <tr valign="top">
                <td>' . (++$i + $start) . '</td>
                <td><a href="char.php?id=' . $char['guid'] . '&amp;realm=' . $realm_id . '">' . htmlentities($char['name']) . '</a></td>
                <td>
                  <img src="img/c_icons/' . $char['race'] . '-' . $char['gender'] . '.gif" alt="' . char_get_race_name($char['race']) . '" onmousemove="toolTip(\'' . char_get_race_name($char['race']) . '\', \'item_tooltip\')" onmouseout="toolTip()" />
                  <img src="img/c_icons/' . $char['class'] . '.gif" alt="' . char_get_class_name($char['class']) . '" onmousemove="toolTip(\'' . char_get_class_name($char['class']) . '\', \'item_tooltip\')" onmouseout="toolTip()" />
                </td>
                <td>' . char_get_level_color($char['level']) . '</td>';
        if ($type === 'level') {
            $guild_name = $sqlc->result($sqlc->query('SELECT name FROM guild WHERE guildid = ' . $char['gname'] . ''), 0);
            $days = floor(round($char['totaltime'] / 3600) / 24);
            $hours = round($char['totaltime'] / 3600) - $days * 24;
            $time = '';
            if ($days) {
                $time .= $days . ' days ';
            }
            if ($hours) {
                $time .= $hours . ' hours';
            }
            $output .= '
                <td><a href="guild.php?action=view_guild&amp;realm=' . $realm_id . '&amp;error=3&amp;id=' . $char['gname'] . '">' . htmlentities($guild_name) . '</a></td>
                <td align="right">
                  ' . substr($char['money'], 0, -4) . '<img src="img/gold.gif" alt="" align="middle" />
                  ' . substr($char['money'], -4, 2) . '<img src="img/silver.gif" alt="" align="middle" />
                  ' . substr($char['money'], -2) . '<img src="img/copper.gif" alt="" align="middle" />
                </td>
                <td align="right">' . $time . '</td>';
        } elseif ($type === 'stat') {
            $output .= '
                <td>' . $char['health'] . '</td>
                <td>' . $char['power1'] . '</td>
                <td>' . $char['str'] . '</td>
                <td>' . $char['agi'] . '</td>
                <td>' . $char['sta'] . '</td>
                <td>' . $char['intel'] . '</td>
                <td>' . $char['spi'] . '</td>';
        } elseif ($type === 'defense') {
            $block = unpack('f', pack('L', $char['block']));
            $block = round($block[1], 2);
            $dodge = unpack('f', pack('L', $char['dodge']));
            $dodge = round($dodge[1], 2);
            $parry = unpack('f', pack('L', $char['parry']));
            $parry = round($parry[1], 2);
            $output .= '
                <td>' . $char['armor'] . '</td>
                <td>' . $block . '%</td>
                <td>' . $dodge . '%</td>
                <td>' . $parry . '%</td>';
        } elseif ($type === 'resist') {
            $output .= '
                <td>' . $char['holy'] . '</td>
                <td>' . $char['fire'] . '</td>
                <td>' . $char['nature'] . '</td>
                <td>' . $char['frost'] . '</td>
                <td>' . $char['shadow'] . '</td>
                <td>' . $char['arcane'] . '</td>';
        } elseif ($type === 'attack') {
            $melee = unpack('f', pack('L', $char['melee_crit']));
            $melee = round($melee[1], 2);
            $mindamage = unpack('f', pack('L', $char['min_dmg']));
            $mindamage = round($mindamage[1], 0);
            $maxdamage = unpack('f', pack('L', $char['max_dmg']));
            $maxdamage = round($maxdamage[1], 0);
            $output .= '
                <td>' . $char['ap'] . '</td>
                <td>' . $mindamage . '</td>
                <td>' . $maxdamage . '</td>
                <td>' . $melee . '%</td>
                <td>' . $char['melee_hit'] . '</td>
                <td>' . $char['expertise'] . '</td>
                <td>' . $char['off_expertise'] . '</td>';
        } elseif ($type === 'crit_hit') {
            $range = unpack('f', pack('L', $char['range_crit']));
            $range = round($range[1], 2);
            $minrangeddamage = unpack('f', pack('L', $char['min_ranged_dmg']));
            $minrangeddamage = round($minrangeddamage[1], 0);
            $maxrangeddamage = unpack('f', pack('L', $char['max_ranged_dmg']));
            $maxrangeddamage = round($maxrangeddamage[1], 0);
            $output .= '
                <td>' . $char['ranged_ap'] . '</td>
                <td>' . $minrangeddamage . '</td>
                <td>' . $maxrangeddamage . '</td>
                <td>' . $range . '%</td>
                <td>' . $char['range_hit'] . '</td>';
        } elseif ($type === 'pvp') {
            $output .= '
                <td align="left"><img src="img/ranks/rank' . char_get_pvp_rank_id($char['honor'], char_get_side_id($char['race'])) . '.gif" alt=""></img> ' . char_get_pvp_rank_name($char['honor'], char_get_side_id($char['race'])) . '</td>
                <td>' . $char['honor'] . '</td>
                <td>' . $char['kills'] . '</td>
                <td>' . $char['arena'] . '</td>';
        }
        $output .= '
              </tr>';
    }
    $output .= '
            </table>
            <table class="top_hidden" style="width: 720px">
              <tr>
                <td align="right">Total: ' . $all_record . '</td>
                <td align="right" width="25%">';
    $output .= generate_pagination('top100.php?type=' . $type . '&amp;order_by=' . $order_by . '&amp;dir=' . ($dir ? 0 : 1) . '', $all_record, $itemperpage, $start);
    unset($all_record);
    $output .= '
                </td>
              </tr>
            </table>
            </div>
            <br />
          </center>';
}
コード例 #8
0
ファイル: object.php プロジェクト: GlassFace/CoreManager2
function view_go()
{
    global $output, $corem_db, $dbc_db, $locales_search_option, $user_id, $sql, $core;
    // SQL injection prevention
    $entry = isset($_GET["entry"]) ? $sql["world"]->quote_smart($_GET["entry"]) : NULL;
    // retain the other filter values
    $filter_name = $_GET["name"];
    $filter_type = $_GET["type"];
    $filter_displayid = $_GET["displayid"];
    $filter_flags = $_GET["flags"];
    $filter_faction = $_GET["faction"];
    if (!is_numeric($entry)) {
        error(lang("game_object", "NAN"));
    }
    $show = isset($_GET["show"]) ? $sql["world"]->quote_smart($_GET["show"]) : NULL;
    $floor = isset($_GET["floor"]) ? $sql["world"]->quote_smart($_GET["floor"]) : NULL;
    if (!is_numeric($show) && isset($show)) {
        error(lang("game_object", "NAN"));
    }
    // Make sure we have correct values if we're showing Dalaran & The Underbelly
    if ($show == 4395) {
        if ($floor == 505) {
            $display_floor = " AND worldmaparea_fine.ID=505";
        } else {
            // we default to Dalaran
            $display_floor = " AND worldmaparea_fine.ID=504";
        }
    } else {
        // we aren't showing Dalaran or The Underbelly
        $display_floor = "";
    }
    // object info
    if ($core == 1) {
        $go_info_query = "SELECT *, Type AS type, DisplayID AS displayId, gameobject_names.Name AS name1" . ($locales_search_option != 0 ? ", gameobject_names_localized.name AS name" : "") . "\r\n                      FROM gameobject_names " . ($locales_search_option != 0 ? "LEFT JOIN gameobject_names_localized ON gameobject_names.entry=gameobject_names_localized.entry AND language_code='" . $locales_search_option . "') " : " ") . "WHERE gameobject_names.entry='" . $entry . "'";
    } else {
        $go_info_query = "SELECT * FROM gameobject_template " . ($locales_search_option != 0 ? "LEFT JOIN locales_gameobject ON gameobject_template.entry=locales_gameobject.entry " : "") . "WHERE gameobject_template.entry='" . $entry . "'";
    }
    $go_info_result = $sql["world"]->query($go_info_query);
    $go_info = $sql["world"]->fetch_assoc($go_info_result);
    // localization
    if ($core == 1) {
        $go_info["name"] = $locales_search_option ? $go_info["name"] : $go_info["name1"];
    } else {
        $go_info["name"] = $locales_search_option ? $go_info["name_loc" . $locales_search_option] : $go_info["name"];
    }
    // counts & areas
    if ($core == 1) {
        $query_count = "SELECT COUNT(*) FROM gameobject_spawns\r\n                      LEFT JOIN `" . $corem_db["name"] . "`.worldmaparea_fine ON ((position_x<=X1 AND position_x>=X2) AND (position_y<=Y1 AND position_y>=Y2) AND (position_z<=Z1 AND position_z>=Z2) AND gameobject_spawns.map=worldmaparea_fine.Map)\r\n                    WHERE gameobject_spawns.entry='" . $entry . "' AND (gameobject_spawns.map=0 OR gameobject_spawns.map=1 OR gameobject_spawns.map=530 OR gameobject_spawns.map=571) ORDER BY worldmaparea_fine.AreaTable ASC";
        $query_areas = "SELECT DISTINCT(worldmaparea_fine.AreaTable), worldmaparea_fine.ID, RefCon, Name FROM gameobject_spawns\r\n                      LEFT JOIN `" . $corem_db["name"] . "`.worldmaparea_fine ON ((position_x<=X1 AND position_x>=X2) AND (position_y<=Y1 AND position_y>=Y2) AND (position_z<=Z1 AND position_z>=Z2) AND gameobject_spawns.map=worldmaparea_fine.Map)\r\n                    WHERE gameobject_spawns.entry='" . $entry . "' AND (gameobject_spawns.map=0 OR gameobject_spawns.map=1 OR gameobject_spawns.map=530 OR gameobject_spawns.map=571) ORDER BY worldmaparea_fine.AreaTable ASC";
    } else {
        $query_count = "SELECT COUNT(*) FROM gameobject\r\n                      LEFT JOIN `" . $corem_db["name"] . "`.worldmaparea_fine ON ((position_x<=X1 AND position_x>=X2) AND (position_y<=Y1 AND position_y>=Y2) AND (position_z<=Z1 AND position_z>=Z2) AND gameobject.map=worldmaparea_fine.Map)\r\n                    WHERE gameobject.id='" . $entry . "' AND (gameobject.map=0 OR gameobject.map=1 OR gameobject.map=530 OR gameobject.map=571) ORDER BY worldmaparea_fine.AreaTable ASC";
        $query_areas = "SELECT DISTINCT(worldmaparea_fine.AreaTable), worldmaparea_fine.ID, RefCon, Name FROM gameobject\r\n                      LEFT JOIN `" . $corem_db["name"] . "`.worldmaparea_fine ON ((position_x<=X1 AND position_x>=X2) AND (position_y<=Y1 AND position_y>=Y2) AND (position_z<=Z1 AND position_z>=Z2) AND gameobject.map=worldmaparea_fine.Map)\r\n                    WHERE gameobject.id='" . $entry . "' AND (gameobject.map=0 OR gameobject.map=1 OR gameobject.map=530 OR gameobject.map=571) ORDER BY worldmaparea_fine.AreaTable ASC";
    }
    $result = $sql["world"]->query($query_count);
    $result = $sql["world"]->fetch_assoc($result);
    $total = $result["COUNT(*)"];
    $result = $sql["world"]->query($query_areas);
    $output .= '
        <div class="gob_header center">
          <span class="gob_name">' . $go_info["name"] . '</span>
          <hr />
        </div>
        <div class="center_text">
          <span>' . lang("game_object", "foundin") . '</span>';
    while ($row = $sql["world"]->fetch_assoc($result)) {
        if (!isset($show)) {
            // no map selected, we'll show the first
            $show = $row["AreaTable"];
            $show_map = $row;
        } else {
            // map selected, we'll show it
            if (!isset($show_map) && $show == $row["AreaTable"]) {
                $show_map = $row;
            }
        }
        if ($core == 1) {
            $query_count_by_area = "SELECT COUNT(*) FROM gameobject_spawns\r\n                                LEFT JOIN `" . $corem_db["name"] . "`.worldmaparea_fine ON ((position_x<=X1 AND position_x>=X2) AND (position_y<=Y1 AND position_y>=Y2) AND (position_z<=Z1 AND position_z>=Z2) AND gameobject_spawns.map=worldmaparea_fine.Map)\r\n                              WHERE gameobject_spawns.entry='" . $entry . "' AND (gameobject_spawns.map=0 OR gameobject_spawns.map=1 OR gameobject_spawns.map=530 OR gameobject_spawns.map=571) AND worldmaparea_fine.AreaTable='" . $row["AreaTable"] . "'";
        } else {
            $query_count_by_area = "SELECT COUNT(*) FROM gameobject\r\n                                LEFT JOIN `" . $corem_db["name"] . "`.worldmaparea_fine ON ((position_x<=X1 AND position_x>=X2) AND (position_y<=Y1 AND position_y>=Y2) AND (position_z<=Z1 AND position_z>=Z2) AND gameobject.map=worldmaparea_fine.Map)\r\n                              WHERE gameobject.id='" . $entry . "' AND (gameobject.map=0 OR gameobject.map=1 OR gameobject.map=530 OR gameobject.map=571) AND worldmaparea_fine.AreaTable='" . $row["AreaTable"] . "'";
        }
        $result_count_by_area = $sql["world"]->query($query_count_by_area);
        $result_count_by_area = $sql["world"]->fetch_assoc($result_count_by_area);
        $total_by_area = $result_count_by_area["COUNT(*)"];
        // prevent Zone names from breaking across lines
        $row["Name"] = str_replace(" ", "&nbsp;", $row["Name"]);
        // show zones with spawns and counts
        if ($row["AreaTable"] != $show) {
            $output .= '
          <a href="object.php?action=view&amp;entry=' . $entry . '&amp;show=' . $row["AreaTable"] . ($row["AreaTable"] == 4395 ? '&amp;floor=' . $row["ID"] : '') . '&amp;error=3">' . $row["Name"] . "</a>&nbsp;(" . $total_by_area . ') ';
        } else {
            $output .= '
          <span class="zone_active">' . $row["Name"] . "</span>&nbsp;(" . $total_by_area . ') ';
        }
    }
    $output .= '
        </div>';
    if ($core == 1) {
        $query = "SELECT gameobject_spawns.id AS guid, Yw, Xw, position_y, position_x, position_z, worldmaparea.X1 AS XBase, worldmaparea.Y1 AS YBase, Z1, Z2 FROM gameobject_spawns\r\n                LEFT JOIN `" . $corem_db["name"] . "`.worldmaparea_fine ON ((position_x<=X1 AND position_x>=X2) AND (position_y<=Y1 AND position_y>=Y2) AND (position_z<=Z1 AND position_z>=Z2) AND gameobject_spawns.map=worldmaparea_fine.Map)\r\n                LEFT JOIN `" . $dbc_db["name"] . "`.worldmaparea ON worldmaparea_fine.AreaTable=worldmaparea.AreaTable\r\n              WHERE gameobject_spawns.entry='" . $entry . "' AND (gameobject_spawns.map=0 OR gameobject_spawns.map=1 OR gameobject_spawns.map=530 OR gameobject_spawns.map=571) AND worldmaparea_fine.AreaTable='" . $show . "'" . $display_floor;
    } else {
        $query = "SELECT guid, Yw, Xw, position_y, position_x, position_z, worldmaparea.X1 AS XBase, worldmaparea.Y1 AS YBase, Z1, Z2 FROM gameobject\r\n                LEFT JOIN `" . $corem_db["name"] . "`.worldmaparea_fine ON ((position_x<=X1 AND position_x>=X2) AND (position_y<=Y1 AND position_y>=Y2) AND (position_z<=Z1 AND position_z>=Z2) AND gameobject.map=worldmaparea_fine.Map)\r\n                LEFT JOIN `" . $dbc_db["name"] . "`.worldmaparea ON worldmaparea_fine.AreaTable=worldmaparea.AreaTable\r\n              WHERE gameobject.id='" . $entry . "' AND (gameobject.map=0 OR gameobject.map=1 OR gameobject.map=530 OR gameobject.map=571) AND worldmaparea_fine.AreaTable='" . $show . "'" . $display_floor;
    }
    $result = $sql["world"]->query($query);
    // Dalaran or The Underbelly
    if (isset($floor)) {
        if ($floor == 505) {
            $show_map["RefCon"] = "Underbelly";
        } else {
            $show_map["RefCon"] = "Dalaran";
        }
    }
    // show selected map
    $output .= '
        <div class="mini_map">
          <img src="img/map/area_small/' . $show_map["RefCon"] . '.png" alt="' . $show_map["Name"] . '" />';
    // temp storage for Area Z's
    $area_Z1 = 0;
    $area_Z2 = 0;
    // draw object pins
    while ($row = $sql["world"]->fetch_assoc($result)) {
        $x_scale = 488 / $row["Yw"];
        $y_scale = 326 / $row["Xw"];
        // Dalaran & The Underbelly don't have proper entries
        if ($show == 4395) {
            $row["YBase"] = 1051;
            $row["XBase"] = 6073;
        }
        $x_loc_scaled = floor(abs($row["position_y"] - $row["YBase"]) * $y_scale);
        $y_loc_scaled = floor(abs($row["position_x"] - $row["XBase"]) * $x_scale);
        $gps_x = round($x_loc_scaled / 488 * 100, 2);
        $gps_y = round($y_loc_scaled / 326 * 100, 2);
        $x_relative = $x_loc_scaled;
        // + 152;
        $y_relative = $y_loc_scaled;
        $area_Z1 = $row["Z1"];
        $area_Z2 = $row["Z2"];
        $output .= '
          <div class="gps_tooltip" id="tooltip' . $row["guid"] . '" style="left: ' . ($x_relative + 10) . 'px; top:' . ($y_relative + 10) . 'px;">
            <table>
              <tr>
                <td>' . $gps_x . ', ' . $gps_y . '</td>
              </tr>
            </table>
          </div>
          <img src="img/map/pin.gif" alt="' . $gps_x . " " . $gps_y . '" style="position: absolute; left: ' . $x_relative . 'px; top: ' . $y_relative . 'px;" onmouseover="ShowTooltip(this,' . $row["guid"] . ');" onmouseout="HideTooltip(' . $row["guid"] . ');" />';
    }
    // get our characters
    if ($core == 1) {
        $query_chars = "SELECT guid, race, class, level, gender, characters.name AS cname, Yw, Xw, positionY AS position_y, positionX AS position_x, positionZ AS position_z, worldmaparea.X1 AS XBase, worldmaparea.Y1 AS YBase FROM characters\r\n                      LEFT JOIN `" . $corem_db["name"] . "`.worldmaparea_fine ON ((positionX<=X1 AND positionX>=X2) AND (positionY<=Y1 AND positionY>=Y2) AND (positionZ<=Z1 AND positionZ>=Z2) AND characters.mapId=worldmaparea_fine.Map)\r\n                      LEFT JOIN `" . $dbc_db["name"] . "`.worldmaparea ON worldmaparea_fine.AreaTable=worldmaparea.AreaTable\r\n                    WHERE acct='" . $user_id . "' AND (positionZ<='" . $area_Z1 . "' AND positionZ>='" . $area_Z2 . "') AND (characters.mapId=0 OR characters.mapId=1 OR characters.mapId=530 OR characters.mapId=571) AND worldmaparea_fine.AreaTable='" . $show . "'";
    } else {
        $query_chars = "SELECT guid, race, class, level, gender, characters.name AS cname, Yw, Xw, position_y, position_x, position_z, worldmaparea.X1 AS XBase, worldmaparea.Y1 AS YBase FROM characters\r\n                      LEFT JOIN `" . $corem_db["name"] . "`.worldmaparea_fine ON ((position_x<=X1 AND position_x>=X2) AND (position_y<=Y1 AND position_y>=Y2) AND (position_z<=Z1 AND position_z>=Z2) AND characters.map=worldmaparea_fine.Map)\r\n                      LEFT JOIN `" . $dbc_db["name"] . "`.worldmaparea ON worldmaparea_fine.AreaTable=worldmaparea.AreaTable\r\n                    WHERE account='" . $user_id . "' AND (position_z<='" . $area_Z1 . "' AND position_z>='" . $area_Z2 . "') AND (characters.map=0 OR characters.map=1 OR characters.map=530 OR characters.map=571) AND worldmaparea_fine.AreaTable='" . $show . "'";
    }
    $result_chars = $sql["char"]->query($query_chars);
    // draw character pins
    while ($row = $sql["char"]->fetch_assoc($result_chars)) {
        $x_scale = 488 / $row["Yw"];
        $y_scale = 326 / $row["Xw"];
        // Dalaran & The Underbelly don't have proper entries
        if ($show == 4395) {
            $row["YBase"] = 1051;
            $row["XBase"] = 6073;
        }
        $x_loc_scaled = floor(abs($row["position_y"] - $row["YBase"]) * $y_scale);
        $y_loc_scaled = floor(abs($row["position_x"] - $row["XBase"]) * $x_scale);
        $gps_x = round($x_loc_scaled / 488 * 100, 2);
        $gps_y = round($y_loc_scaled / 326 * 100, 2);
        $x_relative = $x_loc_scaled;
        // + 152;
        $y_relative = $y_loc_scaled;
        $output .= '
          <div class="map_tooltip" id="tooltip' . $row["guid"] . '" style="left: ' . ($x_relative + 10) . 'px; top:' . ($y_relative + 10) . 'px;">
            <table>
              <tr>
                <td class="name_level" colspan="2">
                  ' . $row["cname"] . ' (' . char_get_level_color($row["level"]) . ')
                </td>
              </tr>
              <tr>
                <td class="race">
                  <img src="img/c_icons/' . $row["race"] . '-' . $row["gender"] . '.gif" />
                </td>
                <td>
                  ' . char_get_race_name($row["race"]) . '
                </td>
              </tr>
              <tr>
                <td class="race">
                  <img src="img/c_icons/' . $row["class"] . '.gif" />
                </td>
                <td>
                  ' . char_get_class_name($row["class"]) . '
                </td>
              </tr>
              <tr>
                <td class="zone" colspan="2">' . $gps_x . ', ' . $gps_y . '</td>
              </tr>
            </table>
          </div>
          <img src="img/map/' . (char_get_side_id($row["race"]) ? 'horde' : 'allia') . '.gif" alt="' . $gps_x . " " . $gps_y . '" style="position: absolute; left: ' . $x_relative . 'px; top: ' . $y_relative . 'px;" onmouseover="ShowTooltip(this,' . $row["guid"] . ');" onmouseout="HideTooltip(' . $row["guid"] . ');" />';
    }
    $output .= '
        </div>
        <table>
          <tr>
            <td>';
    makebutton(lang("global", "back"), "object.php?error=2&amp;entry=" . $entry . "&amp;name=" . $filter_name . "&amp;type=" . $filter_type . "&amp;displayid=" . $filter_displayid . "&amp;flags=" . $filter_flags . "&amp;faction=" . $filter_faction, 130);
    $output .= '
            </td>
          </tr>
        </table>
        <br />';
}
コード例 #9
0
ファイル: map.php プロジェクト: GlassFace/CoreManager2
function show_map()
{
    global $output, $map_status_gm_include_all, $map_gm_add_suffix, $user_id, $realm_id, $logon_db, $sql, $core;
    // if the user selected a specific map, we'll show it, otherwise we show Azeroth
    $showmap = isset($_GET["map"]) ? $_GET["map"] : -1;
    // get the user's selection for whether to view only characters that are online, offline, or both
    // (the default is online only)
    $online = isset($_GET["online"]) ? $_GET["online"] : 1;
    // get both factions for this realm
    $bf_query = "SELECT Both_Factions FROM config_servers WHERE `Index`='" . $realm_id . "'";
    $bf_result = $sql["mgr"]->query($bf_query);
    $bf_result = $sql["mgr"]->fetch_assoc($bf_result);
    $both_factions = $bf_result["Both_Factions"];
    // if both factions is disabled then we need to know what faction the player is
    // we'll count the number of characters of each faction the player has and base
    // the players faction on the higher of the two
    if (!$both_factions) {
        if ($core == 1) {
            $q_horde = "SELECT COUNT(*) FROM characters WHERE race NOT IN (1, 3, 4, 7, 11) AND acct='" . $user_id . "'";
            $q_alliance = "SELECT COUNT(*) FROM characters WHERE race IN (1, 3, 4, 7, 11) AND acct='" . $user_id . "'";
        } else {
            $q_horde = "SELECT COUNT(*) FROM characters WHERE race NOT IN (1, 3, 4, 7, 11) AND account='" . $user_id . "'";
            $q_alliance = "SELECT COUNT(*) FROM characters WHERE race IN (1, 3, 4, 7, 11) AND account='" . $user_id . "'";
        }
        $r_horde = $sql["char"]->query($q_horde);
        $r_alliance = $sql["char"]->query($q_alliance);
        $c_horde = $sql["char"]->fetch_assoc($r_horde);
        $c_alliance = $sql["char"]->fetch_assoc($r_alliance);
        $c_horde = $c_horde["COUNT(*)"];
        $c_alliance = $c_alliance["COUNT(*)"];
        if ($c_horde != $c_alliance) {
            if ($c_horde < $c_alliance) {
                $faction = 0;
            } else {
                $faction = 1;
            }
        } else {
            // if the player has an equal number of horde and alliance characters then the first character returned in this
            // query will be the players faction
            if ($core == 1) {
                $f_query = "SELECT race FROM characters WHERE acct='" . $user_id . "' LIMIT 1";
            } else {
                $f_query = "SELECT race FROM characters WHERE account='" . $user_id . "' LIMIT 1";
            }
            $f_result = $sql["char"]->query($f_query);
            $f_result = $sql["char"]->fetch_assoc($f_result);
            $race = $f_result["race"];
            $alliance = array(1, 3, 4, 7, 11);
            if (in_array($race, $alliance)) {
                $faction = 0;
            } else {
                $faction = 1;
            }
        }
    }
    // if we created the faction variable then we need to insert a further limit on where clauses of the character queries below
    if (isset($faction)) {
        // horde = 1, alliance = 0
        $faction_append = " AND race " . ($faction ? "NOT " : "") . "IN (1, 3, 4, 7, 11)";
    } else {
        $faction_append = "";
    }
    // otherwise, we'll just insert nothing
    $output .= '
          <table class="hidden">
            <tr>';
    // we don't want to show the button for the map we're currently viewing
    $output .= '
              <td>';
    if ($showmap != -1) {
        makebutton(lang("map", "azeroth"), 'map.php?map=-1&amp;online=' . $online, 150);
    } else {
        $output .= '
              <div class="dis_button" style="width: 150px;">' . lang("map", "azeroth") . '</div>';
    }
    $output .= '
              </td>
              <td>';
    if ($showmap != 530) {
        makebutton(lang("map", "outland"), 'map.php?map=530&amp;online=' . $online, 150);
    } else {
        $output .= '
              <div class="dis_button" style="width: 150px;">' . lang("map", "outland") . '</div>';
    }
    $output .= '
              </td>
            </tr>
            <tr>
              <td>';
    if ($showmap != 0) {
        makebutton(lang("map", "ek"), 'map.php?map=0&amp;online=' . $online, 150);
    } else {
        $output .= '
              <div class="dis_button" style="width: 150px;">' . lang("map", "ek") . '</div>';
    }
    $output .= '
              </td>
              <td>';
    if ($showmap != 1) {
        makebutton(lang("map", "k"), 'map.php?map=1&amp;online=' . $online, 150);
    } else {
        $output .= '
              <div class="dis_button" style="width: 150px;">' . lang("map", "k") . '</div>';
    }
    $output .= '
              </td>
              <td>';
    if ($showmap != 571) {
        makebutton(lang("map", "nr"), 'map.php?map=571&amp;online=' . $online, 150);
    } else {
        $output .= '
              <div class="dis_button" style="width: 150px;">' . lang("map", "nr") . '</div>';
    }
    $output .= '
              </td>
            </tr>
            <tr>
              <td colspan="3">' . lang("map", "display") . '</td>
            </tr>
            <tr>';
    // make the buttons for online/offline/both viewing
    $output .= '
              <td>';
    if ($online != 1) {
        makebutton(lang("map", "online"), 'map.php?map=' . $showmap . '&amp;online=1', 150);
    } else {
        $output .= '
              <div class="dis_button" style="width: 150px;">' . lang("map", "online") . '</div>';
    }
    $output .= '
              </td>
              <td>';
    if ($online != 0) {
        makebutton(lang("map", "offline"), 'map.php?map=' . $showmap . '&amp;online=0', 150);
    } else {
        $output .= '
              <div class="dis_button" style="width: 150px;">' . lang("map", "offline") . '</div>';
    }
    $output .= '
              </td>
              <td>';
    if ($online != -1) {
        makebutton(lang("map", "both"), 'map.php?map=' . $showmap . '&amp;online=-1', 150);
    } else {
        $output .= '
              <div class="dis_button" style="width: 150px;">' . lang("map", "both") . '</div>';
    }
    $output .= '
              </td>
            </tr>
          </table>';
    // show the appropriate map
    switch ($showmap) {
        case -1:
            $mapfilename = "world";
            break;
        case 0:
            $mapfilename = "easternkingdoms";
            break;
        case 1:
            $mapfilename = "kalimdor";
            break;
        case 530:
            $mapfilename = "outland";
            break;
        case 571:
            $mapfilename = "northrend";
            break;
    }
    // if we're only showing one faction, we should make the viewer aware of that fact
    if (isset($faction)) {
        $fact_color = $faction ? "map_horde" : "map_alliance";
        $limited = str_replace("%1", '<span class="' . $fact_color . '">' . char_get_side_name($faction) . '</span>', lang("map", "only"));
        $output .= '
          <br />';
        $output .= '<b>(' . $limited . ')</b>';
        $output .= '
          <br />';
    }
    $output .= '
          <div class="map_map">
            <br />
            <img src="img/map/' . $mapfilename . '1.png" class="map_image" alt="" />
            <img src="img/map/' . $mapfilename . '2.png" class="map_image" alt="" style="top: -2px;" />
            <img src="img/map/' . $mapfilename . '3.png" class="map_image" alt="" style="top: -4px;" />';
    // generate the queries based on which map we're viewing
    // GM status here is based on the core's opinion of who is a GM, NOT on CoreManager's Security Level
    // we filter out anyone on GM island also
    // if we're viewing map 530 we don't want to get characters in:
    //   Eversong Woods, Ghostlands, Azuremyst Isle, or Bloodmyst Isle
    if ($core == 1) {
        if ($showmap == -1) {
            $query = "SELECT *, gm\n        FROM characters\n          LEFT JOIN `" . $logon_db["name"] . "`.accounts ON characters.acct=accounts.acct\n        WHERE " . ($online != -1 ? "online='" . $online . "' AND " : "") . "mapid IN (0,1,571) AND zoneid<>876" . $faction_append;
        } else {
            $query = "SELECT *, gm\n        FROM characters\n          LEFT JOIN `" . $logon_db["name"] . "`.accounts ON characters.acct=accounts.acct\n        WHERE " . ($online != -1 ? "online='" . $online . "' AND " : "") . "mapid='" . $showmap . "'" . ($showmap == 1 ? " AND zoneid<>876" : "") . ($showmap == 530 ? "  AND positionY>0" : "") . $faction_append;
        }
        // don't want this query at all if we're viewing Outland or Northrend
        if ($showmap != 530 && $showmap != 571) {
            $out_query = "SELECT *, gm\n        FROM characters\n          LEFT JOIN `" . $logon_db["name"] . "`.accounts ON characters.acct=accounts.acct\n        WHERE " . ($online != -1 ? "online='" . $online . "' AND " : "") . "mapid='530' AND positionY<-5000" . ($showmap == 0 ? " AND positionX>0" : "") . ($showmap == 1 ? " AND positionX<0" : "") . $faction_append;
        }
    } elseif ($core == 2) {
        if ($showmap == -1) {
            $query = "SELECT *, position_x AS positionX, position_y AS positionY, gmlevel AS gm\n      FROM characters\n        LEFT JOIN `" . $logon_db["name"] . "`.account ON characters.account=account.id\n      WHERE " . ($online != -1 ? "online='" . $online . "' AND " : "") . "map IN (0,1,571) AND zone<>876" . $faction_append;
        } else {
            $query = "SELECT *, position_x AS positionX, position_y AS positionY, gmlevel AS gm\n      FROM characters\n        LEFT JOIN `" . $logon_db["name"] . "`.account ON characters.account=account.id\n      WHERE " . ($online != -1 ? "online='" . $online . "' AND " : "") . "map='" . $showmap . "'" . ($showmap == 1 ? " AND zone<>876" : "") . ($showmap == 530 ? "  AND position_y>0" : "") . $faction_append;
        }
        // don't want this query at all if we're viewing Outland or Northrend
        if ($showmap != 530 && $showmap != 571) {
            $out_query = "SELECT *, position_x AS positionX, position_y AS positionY, gmlevel AS gm\n      FROM characters\n        LEFT JOIN `" . $logon_db["name"] . "`.account ON characters.account=account.id\n      WHERE " . ($online != -1 ? "online='" . $online . "' AND " : "") . "map='530' AND position_y<-5000" . ($showmap == 0 ? " AND position_x>0" : "") . ($showmap == 1 ? " AND position_x<0" : "") . $faction_append;
        }
    } else {
        if ($showmap == -1) {
            $query = "SELECT *, position_x AS positionX, position_y AS positionY, gmlevel AS gm\n      FROM characters\n        LEFT JOIN `" . $logon_db["name"] . "`.account_access ON characters.account=account_access.id\n      WHERE " . ($online != -1 ? "online='" . $online . "' AND " : "") . "map IN (0,1,571) AND zone<>876" . $faction_append;
        } else {
            $query = "SELECT *, position_x AS positionX, position_y AS positionY, gmlevel AS gm\n      FROM characters\n        LEFT JOIN `" . $logon_db["name"] . "`.account_access ON characters.account=account_access.id\n      WHERE " . ($online != -1 ? "online='" . $online . "' AND " : "") . "map='" . $showmap . "'" . ($showmap == 1 ? " AND zone<>876" : "") . ($showmap == 530 ? "  AND position_y>0" : "") . $faction_append;
        }
        // don't want this query at all if we're viewing Outland or Northrend
        if ($showmap != 530 && $showmap != 571) {
            $out_query = "SELECT *, position_x AS positionX, position_y AS positionY, gmlevel AS gm\n      FROM characters\n        LEFT JOIN `" . $logon_db["name"] . "`.account_access ON characters.account=account_access.id\n      WHERE " . ($online != -1 ? "online='" . $online . "' AND " : "") . "map='530' AND position_y<-5000" . ($showmap == 0 ? " AND position_x>0" : "") . ($showmap == 1 ? " AND position_x<0" : "") . $faction_append;
        }
    }
    // normal map characters
    $result = $sql["char"]->query($query);
    // map 530 characters (if we even need it)
    if ($showmap != 530 && $showmap != 571) {
        $out_result = $sql["char"]->query($out_query);
    }
    while ($row = $sql["char"]->fetch_assoc($result)) {
        $hide = 0;
        if (!isset($row["gm"])) {
            $row["gm"] = 0;
        }
        if ($map_status_gm_include_all == 0) {
            if ($row["gm"] != 0) {
                $hide = 1;
            }
        }
        if (!$hide) {
            // wow's X & Y axes are weird
            $x = -1 * $row["positionY"];
            $y = -1 * $row["positionX"];
            $map = $row["map"];
            // each major map has a different scale & origin
            if ($showmap == -1) {
                if ($map == 0) {
                    $x_scaled = floor($x * 0.023);
                    $y_scaled = floor($y * 0.021);
                    // 0,0 = 771,311
                    $x_relative = $x_scaled + 771;
                    $y_relative = $y_scaled + 311;
                } elseif ($map == 1) {
                    $x_scaled = floor($x * 0.02);
                    $y_scaled = floor($y * 0.022);
                    // 0,0 = 177,387
                    $x_relative = $x_scaled + 177;
                    $y_relative = $y_scaled + 387;
                } else {
                    $x_scaled = floor($x * 0.021);
                    $y_scaled = floor($y * 0.022);
                    // 0,0 = 530,232
                    $x_relative = $x_scaled + 530;
                    $y_relative = $y_scaled + 232;
                }
            } elseif ($showmap == 0) {
                $x_scaled = floor($x * 0.025);
                $y_scaled = floor($y * 0.0245);
                // 0,0 = 447,274
                $x_relative = $x_scaled + 447;
                $y_relative = $y_scaled + 279;
            } elseif ($showmap == 1) {
                $x_scaled = floor($x * 0.027);
                $y_scaled = floor($y * 0.027);
                // 0,0 = 464,347
                $x_relative = $x_scaled + 464;
                $y_relative = $y_scaled + 350;
            } elseif ($showmap == 530) {
                $x_scaled = floor($x * 0.0575);
                $y_scaled = floor($y * 0.0585);
                // 0,0 = 744,334
                $x_relative = $x_scaled + 744;
                $y_relative = $y_scaled + 334;
            } elseif ($showmap == 571) {
                $x_scaled = floor($x * 0.057);
                $y_scaled = floor($y * 0.057);
                // 0,0 = 520,597
                $x_relative = $x_scaled + 520;
                $y_relative = $y_scaled + 597;
            }
            // build the tooltip for this character
            $output .= '
            <div class="map_tooltip" id="tooltip' . $row["guid"] . '" style="left: ' . ($x_relative + 10) . 'px; top:' . ($y_relative + 10) . 'px;">
              <table>
                <tr>
                  <td class="name_level" colspan="2">
                    ' . ($map_gm_add_suffix && $row["gm"] ? '<img src="img/star.png" alt="" /> ' : '') . $row["name"] . ' (' . char_get_level_color($row["level"]) . ')
                  </td>
                </tr>
                <tr>
                  <td class="race">
                    <img src="img/c_icons/' . $row["race"] . '-' . $row["gender"] . '.gif" alt="" />
                  </td>
                  <td>
                    ' . char_get_race_name($row["race"]) . '
                  </td>
                </tr>
                <tr>
                  <td class="race">
                    <img src="img/c_icons/' . $row["class"] . '.gif" alt="" />
                  </td>
                  <td>
                    ' . char_get_class_name($row["class"]) . '
                  </td>
                </tr>
                <tr>
                  <td class="zone" colspan="2">
                    ' . get_zone_name($row["zone"]) . '
                  </td>
                </tr>
              </table>
            </div>';
            // draw a dot for the character
            $output .= '
            <a href="char.php?id=' . $row["guid"] . '" onmouseover="ShowTooltip(this,' . $row["guid"] . ');" onmouseout="HideTooltip(' . $row["guid"] . ');"><!-- X' . $x . ' Y' . $y . ' Map' . $map . ' -->
              <img src="img/map/' . (char_get_side_id($row["race"]) ? 'horde' : 'allia') . '.gif" style="position: absolute; left: ' . $x_relative . 'px; top: ' . ($y_relative + 10) . 'px;" alt="" />
            </a>';
        }
    }
    // process our Azeroth characters who's map is 530
    // first, make sure we need to do this section at all
    if ($showmap != 530 && $showmap != 571) {
        while ($row = $sql["char"]->fetch_assoc($out_result)) {
            $hide = 0;
            if (!isset($row["gm"])) {
                $row["gm"] = 0;
            }
            if ($map_status_gm_include_all == 0) {
                if ($row["gm"] != 0) {
                    $hide = 1;
                }
            }
            if (!$hide) {
                // wow's X & Y axes are weird
                $x = -1 * $row["positionY"];
                $y = -1 * $row["positionX"];
                $map = $row["map"];
                // should always be 530
                if ($showmap == -1) {
                    if ($y < 0) {
                        // Eversong Woods & Ghostlands
                        // Eastern Kingdoms
                        $x_scaled = floor($x * 0.023);
                        $y_scaled = floor($y * 0.021);
                        // 0,0 = 771,311
                        $x_relative = $x_scaled + 705;
                        $y_relative = $y_scaled + 360;
                    } else {
                        // Azuremyst Isle & Bloodmyst Isle
                        // Kalimdor
                        $x_scaled = floor($x * 0.02);
                        $y_scaled = floor($y * 0.022);
                        // 0,0 = 177,387
                        $x_relative = $x_scaled - 183;
                        $y_relative = $y_scaled + 178;
                    }
                } elseif ($showmap == 0) {
                    // Eversong Woods & Ghostlands
                    // Eastern Kingdoms
                    $x_scaled = floor($x * 0.025);
                    $y_scaled = floor($y * 0.0245);
                    // 0,0 = 447,274
                    $x_relative = $x_scaled + 380;
                    $y_relative = $y_scaled + 335;
                } elseif ($showmap == 1) {
                    $x_scaled = floor($x * 0.027);
                    $y_scaled = floor($y * 0.027);
                    // 0,0 = 464,347
                    $x_relative = $x_scaled - 20;
                    $y_relative = $y_scaled + 70;
                }
            }
            // build the tooltip for this character
            $output .= '
            <div class="map_tooltip" id="tooltip' . $row["guid"] . '" style="left: ' . ($x_relative + 10) . 'px; top:' . ($y_relative + 10) . 'px;">
              <table>
                <tr>
                  <td class="name_level" colspan="2">
                    ' . ($map_gm_add_suffix && $row["gm"] ? '<img src="img/star.png" alt="" /> ' : '') . $row["name"] . ' (' . char_get_level_color($row["level"]) . ')
                  </td>
                </tr>
                <tr>
                  <td class="race">
                    <img src="img/c_icons/' . $row["race"] . '-' . $row["gender"] . '.gif" alt="" />
                  </td>
                  <td>
                    ' . char_get_race_name($row["race"]) . '
                  </td>
                </tr>
                <tr>
                  <td class="race">
                    <img src="img/c_icons/' . $row["class"] . '.gif" alt="" />
                  </td>
                  <td>
                    ' . char_get_class_name($row["class"]) . '
                  </td>
                </tr>
                <tr>
                  <td class="zone" colspan="2">
                    ' . get_zone_name($row["zone"]) . '
                  </td>
                </tr>
              </table>
            </div>';
            // draw a dot for the character
            $output .= '
            <a href="char.php?id=' . $row["guid"] . '" onmouseover="ShowTooltip(this,' . $row["guid"] . ');" onmouseout="HideTooltip(' . $row["guid"] . ');"><!-- X' . $x . ' Y' . $y . ' Map' . $map . ' -->
              <img src="img/map/' . (char_get_side_id($row["race"]) ? 'horde' : 'allia') . '.gif" style="position: absolute; left: ' . $x_relative . 'px; top: ' . ($y_relative + 10) . 'px;" alt="" />
            </a>';
        }
    }
    $output .= '
          </div>';
}
コード例 #10
0
ファイル: char_pvp.php プロジェクト: GlassFace/CoreManager2
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"));
    }
}
function chooserace()
{
    global $output, $action_permission, $characters_db, $realm_id, $user_id, $Class_Races, $user_name, $race_credits, $sql, $core;
    valid_login($action_permission["view"]);
    $guid = $sql["char"]->quote_smart($_GET["char"]);
    $new1 = '';
    if (isset($_GET["new1"])) {
        $new1 = $sql["char"]->quote_smart($_GET["new1"]);
    }
    $new2 = '';
    if (isset($_GET["new2"])) {
        $new2 = $sql["char"]->quote_smart($_GET["new2"]);
    }
    $char = $sql["char"]->fetch_assoc($sql["char"]->query("SELECT * FROM characters WHERE guid='" . $guid . "'"));
    // credits
    if ($race_credits >= 0) {
        // get our credit balance
        $cr_query = "SELECT Credits FROM config_accounts WHERE Login='******'";
        $cr_result = $sql["mgr"]->query($cr_query);
        $cr_result = $sql["mgr"]->fetch_assoc($cr_result);
        $credits = $cr_result["Credits"];
    }
    $output .= '
          <div id="xname_fieldset" class="fieldset_border center">
            <span class="legend">' . lang("xrace", "chooserace") . '</span>
            <form method="get" action="change_char_race.php" id="form">
              <div>
                <input type="hidden" name="action" value="getapproval" />
                <input type="hidden" name="guid" value="' . $char["guid"] . '" />
              </div>
              <table id="xname_char_table" class="center">
                <tr>
                  <td rowspan="4" style="width: 170px;">
                    <div style="width: 64px; margin-left: auto; margin-right: auto;">
                      <img src="' . char_get_avatar_img($char["level"], $char["gender"], $char["race"], $char["class"]) . '" alt="" />
                    </div>
                  </td>
                  <td>
                    <span class="xname_char_name">' . $char["name"] . '</span>
                  </td>
                </tr>
                <tr>
                  <td>' . lang("xrace", "level") . ': ' . $char["level"] . '</td>
                </tr>
                <tr>
                  <td>' . lang("xrace", "race") . ': ' . char_get_race_name($char["race"]) . '</td>
                </tr>
                <tr>
                  <td>' . lang("xrace", "class") . ': ' . char_get_class_name($char["class"]) . '</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                </tr>';
    if ($race_credits > 0) {
        $cost_line = lang("xrace", "credit_cost");
        $cost_line = str_replace("%1", '<b>' . $race_credits . '</b>', $cost_line);
        $output .= '
                <tr>
                  <td colspan="2">' . $cost_line . '</td>
                </tr>';
        if ($credits >= 0) {
            $credit_balance = lang("xrace", "credit_balance");
            $credit_balance = str_replace("%1", '<b>' . (double) $credits . '</b>', $credit_balance);
            $output .= '
                <tr>
                  <td colspan="2">' . $credit_balance . '</td>
                </tr>';
            if ($credits < $race_credits) {
                $output .= '
                <tr>
                  <td colspan="2">' . lang("xrace", "insufficient_credits") . '</td>
                </tr>';
            } else {
                $output .= '
                <tr>
                  <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                  <td colspan="2">' . lang("xrace", "delay_warning") . '</td>
                </tr>';
            }
        } else {
            $output .= '
                <tr>
                  <td colspan="2">' . lang("global", "credits_unlimited") . '</td>
                </tr>';
        }
        $output .= '
                <tr>
                  <td colspan="2">&nbsp;</td>
                </tr>';
    }
    $output .= '
                <tr>
                  <td colspan="2"><b>' . lang("xrace", "enterrace") . ':</b></td>
                </tr>
                <tr>
                  <td>' . lang("xrace", "newrace") . ':</td>
                  <td>';
    $races = $Class_Races[$char["class"]];
    $available_races = array();
    for ($i = 0; $i < count($races); $i++) {
        if (!($races[$i] == $char["race"])) {
            if (char_get_side_id($races[$i]) == char_get_side_id($char["race"])) {
                $available_races[] = $races[$i];
            }
        }
    }
    if (count($available_races) > 0) {
        $output .= '
                    <select name="newrace">';
        foreach ($available_races as $race) {
            $output .= '
                      <option value="' . $race . '">' . char_get_race_name($race) . '</option>';
        }
        $output .= '
                    </select>';
    } else {
        $output .= '
                  <span>' . lang("xrace", "no_races") . '</span>';
    }
    $output .= '
                  </td>
                </tr>';
    // if we have unlimited credits, then we fake our credit balance here
    $credits = $credits < 0 ? $race_credits : $credits;
    if ($race_credits <= 0 || $credits >= $race_credits) {
        $output .= '
                <tr>
                  <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                  <td colspan="2">';
        makebutton(lang("xrace", "save"), "javascript:do_submit()", 180);
        $output .= '
                  </td>
                </tr>';
    }
    $output .= '
              </table>
            </form>
          </div>
          <br />';
}