Example #1
0
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>';
    }
}
Example #2
0
function motd(&$sqlm)
{
    global $output, $lang_motd, $lang_global, $lang_index, $action_permission, $user_lvl, $user_id, $motd_display_poster, $realm_id, $mmfpm_db;
    // minimum permission to view page
    valid_login($action_permission['read']);
    //MOTD part
    $sqlm = new SQL();
    $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
    $start_m = isset($_GET['start_m']) ? $sqlm->quote_smart($_GET['start_m']) : 0;
    if (is_numeric($start_m)) {
    } else {
        $start_m = 0;
    }
    // get all entries, need to add total to page
    $all_record_m = $sqlm->result($sqlm->query('
		SELECT count(*) 
		FROM mm_motd'), 0);
    // to delete MOTD
    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="center">';
    // to add new MOTD
    if ($user_lvl >= $action_permission['insert']) {
        $output .= '
			<font size="2"><a href="motd.php?action=add_motd&amp;error=4">' . $lang_index['add_motd'] . '</a></font>';
    } else {
        $output .= '
			<font size="2">' . $lang_index['motd'] . '</a></font>
		</th>
	</tr>';
    }
    // if is there any record
    if ($all_record_m) {
        // here we get MOTD content
        $result = $sqlm->query('
			SELECT id, realmid, type, content 
			FROM mm_motd 
			WHERE realmid = ' . $realm_id . ' 
			ORDER BY id DESC 
			LIMIT ' . $start_m . ', 10');
        while ($post = $sqlm->fetch_assoc($result)) {
            $output .= '
	<tr>
		<td align="left" class="large">
			<blockquote>' . bbcode_bbc2html($post['content']) . '</blockquote>
		</td>
	</tr>
	<tr>
		<td align="left">';
            $motd_display_poster ? $output .= $post['type'] : '';
            // to delete MOTD
            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="" />';
            }
            // to edit MOTD
            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>';
        }
        $output .= '
	<tr>
		<td align="right" class="hidden">' . generate_pagination('motd.php?start=0', $all_record_m, 10, $start_m, 'start_m') . '</td>
	</tr>';
    }
    $output .= '
</table>';
}
Example #3
0
function main(&$sqlr, &$sqlc)
{
    global $output, $lang_login, $characters_db, $server, $remember_me_checked, $motd_display_poster;
    $output .= '
          <center>
            <script type="text/javascript" src="libs/js/sha1.js"></script>
            <script type="text/javascript">
              // <![CDATA[
                function dologin ()
                {
                  document.form.pass.value = hex_sha1(document.form.user.value.toUpperCase()+":"+document.form.login_pass.value.toUpperCase());
                  document.form.login_pass.value = "0";
                  do_submit();
                }
              // ]]>
            </script>
            <table class="hidden" style="width: 100%">
              <tr>
                <td valign="top" width="25%">
                  <table  class="lined" style="width: 100%">
                      <th align="left" width="40%">
                          <div id="divlogin" onclick="expand(\'login\', this);">[-]</div>
                      </th>
                      <th align="left">
                        Login
                      </th>
                    </tr>
                    <tr>
                      <td colspan="2"valign="top">
                          <form method="post" action="login.php?action=dologin" name="form" onsubmit="return dologin()">
                            <input type="hidden" name="pass" value="" maxlength="256" />
                            <table id="login" style="width: 100%; display: table">
                              <tr align="right">
                                <td>' . $lang_login['username'] . ' : <input type="text" name="user" size="12" maxlength="16" /></td>
                              </tr>
                              <tr align="right">
                                <td>' . $lang_login['password'] . ' : <input type="password" name="login_pass" size="12" maxlength="40" /></td>
                              </tr>';
    $result = $sqlr->query('SELECT id, name FROM realmlist LIMIT 10');
    if ($sqlr->num_rows($result) > 1 && count($server) > 1 && count($characters_db) > 1) {
        $output .= '
                              <tr align="right">
                                <td>' . $lang_login['select_realm'] . ' :
                                  <select name="realm">';
        while ($realm = $sqlr->fetch_assoc($result)) {
            if (isset($server[$realm['id']])) {
                $output .= '
                                    <option value="' . $realm['id'] . '">' . htmlentities($realm['name']) . '</option>';
            }
        }
        $output .= '
                                  </select>
                                </td>
                              </tr>';
    } else {
        $output .= '
                              <input type="hidden" name="realm" value="' . $sqlr->result($result, 0, 'id') . '" />';
    }
    $output .= '
                              <tr align="right">
                                <td>' . $lang_login['remember_me'] . ' : <input type="checkbox" name="remember" value="1"';
    if ($remember_me_checked) {
        $output .= ' checked="checked"';
    }
    $output .= ' /></td>
                              </tr>
                              <input type="submit" value="" style="display: none" />
                              <tr align="right">
                                <td>';
    makebutton($lang_login['not_registrated'], 'register.php" type="wrn', 80);
    makebutton($lang_login['login'], 'javascript:dologin()" type="def', 80);
    $output .= '
                                </td>
                              </tr>
                              <tr align="right">
                                <td>
                                  <a href="register.php?action=pass_recovery">' . $lang_login['pass_recovery'] . '</a>
                                </td>
                              </tr>
                            </table>
                            <script type="text/javascript">
                              // <![CDATA[
                                document.form.user.focus();
                              // ]]>
                            </script>
                          </form>
                      </td>
                    <tr>
                  </table>
                </td>
                <td>
                </td>
                <td valign="top" width="50%">
                  <table class="lined" style="width: 100%">
                      <th align="left" width="40%">
                          <div id="divMOTD" onclick="expand(\'MOTD\', this);">[-]</div>
                      </th>
                      <th align="left">
                        MOTD
                      </th>
                    </tr>
                    <tr>
                      <td colspan="2"valign="top">';
    $all_record_m = $sqlc->result($sqlc->query('SELECT count(*) FROM bugreport'), 0);
    $output .= '
                        <table id="MOTD" class="lined" style="width: 100%; display: table">';
    if ($all_record_m) {
        $result = $sqlc->query('SELECT id, type, content FROM bugreport ORDER BY id DESC LIMIT 0, 3');
        while ($post = $sqlc->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'] : '';
            $output .= '
                            </td>
                          </tr>
                          <tr>
                            <td class="hidden"></td>
                          </tr>';
        }
    }
    $output .= '
                        </table>
                      </td>
                    <tr>
                  </table>
                </td>
                <td>
                </td>
                <td valign="top" width="25%">
                  <table class="lined" style="width: 100%">
                    <tr>
                      <th align="left" width="40%">
                          <div id="divstats" onclick="expand(\'stats\', this);">[-]</div>
                      </th>
                      <th align="left">
                        Stats
                      </th>
                    </tr>
                    <tr>
                      <td colspan="2"valign="top">
                        <table id="stats" class="lined" style="width: 100%; display: table">
                          <tr>
                            <td align="right">
                              Total Accounts:
                            </td>
                            <td align="left">
                              ' . $sqlr->result($sqlr->query('SELECT count(*) FROM account'), 0) . '
                            </td>
                          </tr>
                          <tr>
                            <td align="right">
                              Total GMs:
                            </td>
                            <td align="left">
                              ' . $sqlr->result($sqlr->query('SELECT count(*) FROM account WHERE gmlevel > 0'), 0) . '
                            </td>
                          </tr>';
    $realms = $sqlr->query('SELECT id, name FROM realmlist');
    if (1 < $sqlr->num_rows($realms) && 1 < count($server) && 1 < count($characters_db)) {
        while ($realm = $sqlr->fetch_assoc($realms)) {
            $sqlc->connect($characters_db[$realm['id']]['addr'], $characters_db[$realm['id']]['user'], $characters_db[$realm['id']]['pass'], $characters_db[$realm['id']]['name']);
            $output .= '
                          <tr>
                            <th colspan="2" align="left">
                              Realm ' . $realm['name'] . '
                            </th>
                          </tr>
                          <tr>
                            <td align="right">
                              Total Chars:
                            </td>
                            <td align="left">' . $sqlc->result($sqlc->query('SELECT count(*) FROM characters'), 0) . '</td>
                          </tr>
                          <tr>
                            <td align="right">
                              Total Online:
                            </td>
                            <td align="left">' . $sqlc->result($sqlc->query('SELECT count(*) FROM characters where online = \'1\''), 0) . '</td>
                          </tr>';
        }
        unset($realm);
    } else {
        $realm = $sqlr->fetch_assoc($realms);
        $output .= '
                          <tr>
                            <th colspan="2" align="left">
                              Realm ' . $realm['name'] . '
                            </th>
                          </tr>
                          <tr>
                            <td align="right">
                              Total Chars:
                            </td>
                            <td align="left">' . $sqlc->result($sqlc->query('SELECT count(*) FROM characters'), 0) . '</td>
                          </tr>
                          <tr>
                            <td align="right">
                              Total Online:
                            </td>
                            <td align="left">' . $sqlc->result($sqlc->query('SELECT count(*) FROM characters where online = \'1\''), 0) . '</td>
                          </tr>';
    }
    $output .= '
                        </table>
                      </td>
                    <tr>
                  </table>
                </td>
              <tr>
            </table>
          </center>';
}