function stats($action) { global $output, $realm_id, $logon_db, $server, $theme, $sql, $core; $race = array(1 => array(1, "human", "", ""), 2 => array(2, "orc", "", ""), 3 => array(3, "dwarf", "", ""), 4 => array(4, "nightelf", "", ""), 5 => array(5, "undead", "", ""), 6 => array(6, "tauren", "", ""), 7 => array(7, "gnome", "", ""), 8 => array(8, "troll", "", ""), 10 => array(10, "bloodelf", "", ""), 11 => array(11, "draenei", "", "")); $class = array(1 => array(1, "warrior", "", ""), 2 => array(2, "paladin", "", ""), 3 => array(3, "hunter", "", ""), 4 => array(4, "rogue", "", ""), 5 => array(5, "priest", "", ""), 6 => array(6, "death_knight", "", ""), 7 => array(7, "shaman", "", ""), 8 => array(8, "mage", "", ""), 9 => array(9, "warlock", "", ""), 11 => array(11, "druid", "", "")); $level = array(1 => array(1, 1, 9, "", ""), 2 => array(2, 10, 19, "", ""), 3 => array(3, 20, 29, "", ""), 4 => array(4, 30, 39, "", ""), 5 => array(5, 40, 49, "", ""), 6 => array(6, 50, 59, "", ""), 7 => array(7, 60, 69, "", ""), 8 => array(8, 70, 79, "", ""), 9 => array(9, 80, 80, "", "")); 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 .= $days === 1 ? " day" : " days"; } if ($hours) { $uptimeString .= ($days > 0 ? ", " : "") . $hours; $uptimeString .= $hours === 1 ? " hour" : " hours"; } if ($mins) { $uptimeString .= ($days > 0 || $hours > 0 ? ", " : "") . $mins; $uptimeString .= $mins === 1 ? " minute" : " minutes"; } if ($secs) { $uptimeString .= ($days > 0 || $hours > 0 || $mins > 0 ? ", " : "") . $secs; $uptimeString .= $secs === 1 ? " second" : " seconds"; } return $uptimeString; } $total_chars = $sql["char"]->result($sql["char"]->query("SELECT COUNT(*) FROM characters" . ($action ? " WHERE online=1" : "")), 0); if ($core == 1) { $stats = get_uptime($server[$realm_id]["stats.xml"]); $stat_uptime = explode(' ', $stats["uptime"]); } else { $up_query = "SELECT * FROM uptime WHERE realmid='" . $realm_id . "' ORDER BY starttime DESC LIMIT 1"; $up_results = $sql["logon"]->query($up_query); $uptime = $sql["logon"]->fetch_assoc($up_results); $stats["uptime"] = time() - $uptime["starttime"]; $stats["uptime"] = " " . format_uptime($stats["uptime"]); $stat_uptime = explode(" ", $stats["uptime"]); $stats["peak"] = $uptime["maxplayers"]; } $output .= ' <div class="tab"> <ul> <li' . ($action ? '' : ' class="selected"') . '> <a href="stat.php">' . lang("stat", "srv_statistics") . '</a> </li> <li' . ($action ? ' class="selected"' : '') . '> <a href="stat.php?action=true">' . lang("stat", "on_statistics") . '</a> </li> </ul> </div> <div class="tab_content center"> <div class="top"><h1>' . ($action ? lang("stat", "on_statistics") : lang("stat", "srv_statistics")) . '</h1></div> <table class="hidden"> <tr> <td align="left"> <h1>' . lang("stat", "general_info") . '</h1> </td> </tr> <tr align="left"> <td class="large">'; if ($action) { $output .= ' <font class="bold">' . lang("index", "tot_users_online") . ' : ' . $total_chars . '</font><br /><br />'; } else { if ($core == 1) { $query = $sql["logon"]->query("SELECT COUNT(*) FROM accounts UNION SELECT COUNT(*) FROM accounts WHERE gm<>'0'"); } elseif ($core == 2) { $query = $sql["logon"]->query("SELECT COUNT(*) FROM account UNION SELECT COUNT(*) FROM account WHERE gmlevel<>'0'"); } else { $query = $sql["logon"]->query("SELECT COUNT(*) FROM account UNION SELECT COUNT(*) FROM account_access WHERE gmlevel<>'0'"); } $total_acc = $sql["logon"]->result($query, 0); $total_gms = $sql["logon"]->result($query, 1); unset($query); $data = date("Y-m-d H:i:s"); $data_1 = mktime(date("H"), date("i"), date("s"), date("m"), date("d") - 1, date("Y")); $data_1 = date("Y-m-d H:i:s", $data_1); if ($core == 1) { $uni_query = "SELECT DISTINCT COUNT(lastip) FROM accounts WHERE lastlogin>'" . $data_1 . "' AND lastlogin<'" . $data . "'"; } else { $uni_query = "SELECT DISTINCT COUNT(last_ip) FROM account WHERE last_login>'" . $data_1 . "' AND last_login<'" . $data . "'"; } $uniqueIPs = $sql["logon"]->result($sql["logon"]->query($uni_query), 0); unset($data_1); unset($data); //$max_ever = $sql["mgr"]->result($sql["mgr"]->query('SELECT peakcount FROM uptime WHERE realmid = '.$realm_id.' ORDER BY peakcount DESC LIMIT 1'), 0); $max_restart = $stats["peak"]; // Mangos uptime table doesn't have an uptime field. O_o //$uptime = $sqlr->fetch_row($sqlr->query('SELECT AVG(uptime)/60, MAX(uptime)/60, ( 100*SUM(uptime)/( UNIX_TIMESTAMP()-MIN(starttime) ) ) FROM uptime WHERE realmid = '.$realm_id.'')); $output .= ' <table> <tr valign="top"> <td align="left"> <span>' . lang("stat", "max_uptime") . ':</span> <br /> <br /> <span>' . lang("stat", "tot_accounts") . ':</span> <br /> <span>' . lang("stat", "tot_chars_on_realm") . ':</span> <br /> </td> <td align="right"> <span>' . $stat_uptime[4] . 'd ' . $stat_uptime[6] . 'h ' . $stat_uptime[8] . 'm</span> <br /> <br /> <span>' . $total_acc . '</span> <br /> <span>' . $total_chars . '</span> <br /> </td> <td> </td> <td align="left"> <span>' . lang("stat", "unique_ip") . ':</span> <br /> <br /> <span>' . lang("stat", "max_players") . ' </span> <br /> <span>' . lang("stat", "max_restart") . ' :</span> <br /> </td> <td align="right"> <span>' . $uniqueIPs . '</span> <br /> <br /> <br /> <span>' . $max_restart . '</span> <br /> </td> </tr> <tr align="left"> <td colspan="2"> <span>' . lang("stat", "average_of") . ' ' . round($total_chars / $total_acc, 1) . ' ' . lang("stat", "chars_per_acc") . '</span> <br /> <span>' . lang("stat", "total_of") . ' ' . $total_gms . ' ' . lang("stat", "gms_one_for") . ' ' . round($total_acc / $total_gms, 1) . ' ' . lang("stat", "players") . '</span> </td> <td colspan="2"></td> </tr> </table> <br />'; unset($uptime); unset($uniqueIPs); unset($max_restart); unset($max_ever); unset($total_gms); unset($total_acc); } // get counts and percentages for alliance and horde characters $horde_chars = $sql["char"]->result($sql["char"]->query("SELECT COUNT(guid) FROM characters WHERE race IN(2, 5, 6, 8, 10)" . ($action ? " AND online=1" : "")), 0); $horde_pros = round($horde_chars * 100 / $total_chars, 1); $allies_chars = $total_chars - $horde_chars; $allies_pros = 100 - $horde_pros; // if we have zero of both, we'll show half red, half blue if ($horde_chars == 0 && $allies_chars == 0) { $horde_pros = 50; $allies_pros = 50; } $output .= ' <table class="tot_bar"> <tr> <td class="tot_bar_horde" style="width: ' . $horde_pros . '%; height: 40px;"><a href="stat.php?action=' . $action . '&side=h">' . lang("stat", "horde") . ': ' . $horde_chars . ' (' . $horde_pros . '%)</a></td> <td class="tot_bar_alliance" style="width: ' . $allies_pros . '%; height: 40px;"><a href="stat.php?action=' . $action . '&side=a">' . lang("stat", "alliance") . ': ' . $allies_chars . ' (' . $allies_pros . '%)</a></td> </tr> </table> <hr/> </td> </tr>'; unset($horde_chars); unset($horde_pros); unset($allies_chars); unset($allies_pros); $order_race = isset($_GET["race"]) ? "AND race=" . $sql["char"]->quote_smart($_GET["race"]) : ""; $order_class = isset($_GET["class"]) ? "AND class=" . $sql["char"]->quote_smart($_GET["class"]) : ""; if (isset($_GET["level"])) { $lvl_min = $sql["char"]->quote_smart($_GET["level"]); $lvl_max = $lvl_min + 4; $order_level = "AND level>=" . $lvl_min . " AND level<=" . $lvl_max . ""; } else { $order_level = ""; } if (isset($_GET["side"])) { if ($sql["char"]->quote_smart($_GET["side"]) == "h") { $order_side = "AND race IN(2, 5, 6, 8, 10)"; } elseif ($sql["char"]->quote_smart($_GET["side"]) == "a") { $order_side = "AND race IN (1, 3, 4, 7, 11)"; } } else { $order_side = ""; } // RACE foreach ($race as $id) { $race[$id[0]][2] = $sql["char"]->result($sql["char"]->query("SELECT COUNT(guid) FROM characters\n WHERE race=" . $id[0] . " " . $order_class . " " . $order_level . " " . $order_side . ($action ? " AND online=1" : "")), 0); $race[$id[0]][3] = round($race[$id[0]][2] * 100 / $total_chars, 1); } $output .= ' <tr align="left"> <td> <h1>' . lang("stat", "chars_by_race") . '</h1> </td> </tr> <tr> <td> <table class="bargraph"> <tr>'; foreach ($race as $id) { $height = $race[$id[0]][3] * 4; $output .= ' <td> <a href="stat.php?action=' . $action . '&race=' . $id[0] . '" class="graph_link">' . $race[$id[0]][3] . '%<img src="themes/' . $theme . '/column.gif" width="69" height="' . $height . '" alt="' . $race[$id[0]][2] . '" /></a> </td>'; } $output .= ' </tr> <tr>'; foreach ($race as $id) { $output .= ' <th>' . lang("id_tab", $race[$id[0]][1]) . '<br />' . $race[$id[0]][2] . '</th>'; } unset($race); $output .= ' </tr> </table> <br /> </td> </tr>'; // RACE END // CLASS foreach ($class as $id) { $class[$id[0]][2] = $sql["char"]->result($sql["char"]->query("SELECT COUNT(guid) FROM characters\n WHERE class=" . $id[0] . " " . $order_race . " " . $order_level . " " . $order_side . ($action ? " AND online=1" : "")), 0); $class[$id[0]][3] = round($class[$id[0]][2] * 100 / $total_chars, 1); } unset($order_level); $output .= ' <tr align="left"> <td> <h1>' . lang("stat", "chars_by_class") . '</h1> </td> </tr> <tr> <td> <table class="bargraph"> <tr>'; foreach ($class as $id) { $height = $class[$id[0]][3] * 4; $output .= ' <td> <a href="stat.php?action=' . $action . '&class=' . $id[0] . '" class="graph_link">' . $class[$id[0]][3] . '%<img src="themes/' . $theme . '/column.gif" width="69" height="' . $height . '" alt="' . $class[$id[0]][2] . '" /></a> </td>'; } $output .= ' </tr> <tr>'; foreach ($class as $id) { $output .= ' <th>' . lang("id_tab", $class[$id[0]][1]) . '<br />' . $class[$id[0]][2] . '</th>'; } unset($class); $output .= ' </tr> </table> <br /> </td> </tr>'; // CLASS END // LEVEL foreach ($level as $id) { $level[$id[0]][3] = $sql["char"]->result($sql["char"]->query("SELECT COUNT(guid) FROM characters\n WHERE level>=" . $id[1] . " AND level<=" . $id[2] . "\n " . $order_race . " " . $order_class . " " . $order_side . ($action ? " AND online=1" : "")), 0); $level[$id[0]][4] = round($level[$id[0]][3] * 100 / $total_chars, 1); } unset($order_level); unset($order_class); unset($order_race); unset($total_chars); unset($order_side); $output .= ' <tr align="left"> <td> <h1>' . lang("stat", "chars_by_level") . '</h1> </td> </tr> <tr> <td> <table class="bargraph"> <tr>'; foreach ($level as $id) { $height = $level[$id[0]][4] * 4; $output .= ' <td><a href="stat.php?action=' . $action . '&level=' . $id[1] . '" class="graph_link">' . $level[$id[0]][4] . '%<img src="themes/' . $theme . '/column.gif" width="77" height="' . $height . '" alt="' . $level[$id[0]][3] . '" /></a></td>'; } unset($height); $output .= ' </tr> <tr>'; foreach ($level as $id) { $output .= ' <th>' . $level[$id[0]][1] . '-' . $level[$id[0]][2] . '<br />' . $level[$id[0]][3] . '</th>'; } unset($id); unset($level); $output .= ' </tr> </table> <br /> <hr/> </td> </tr> <tr> <td>'; // LEVEL END makebutton(lang("stat", "reset"), 'stat.php', 720); $output .= ' </td> </tr> </table> </div> <br />'; }
$days = floor($uptime / 60 / 60 / 24); $hours = str_pad(floor($uptime / 60 / 60) % 24, 2, "0", STR_PAD_LEFT); $mins = str_pad(floor($uptime / 60) % 60, 2, "0", STR_PAD_LEFT); $secs = str_pad(floor($uptime % 60), 2, "0", STR_PAD_LEFT); return array("days" => $days, "hours" => $hours, "mins" => $mins, "secs" => $secs); } if (stristr(PHP_OS, 'win') != false) { $fileModTime = filemtime("./uptime.cache"); $uptime = 0; $cache = @file_get_contents("./uptime.cache"); if (file_exists("./uptime.cache") && !empty($cache) && $fileModTime && time() - $fileModTime < 60) { $uptime = (int) $cache; } else { if (function_exists("shell_exec")) { $started = shell_exec('systeminfo | find "Time:"'); $matches = array(); preg_match("/(([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})|([0-9]{1,2})\\/([0-9]{1,2})\\/([0-9]{4})).?[^0-9]([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})[\\s]?(AM|PM|[\\s]?)/", $started, $matches); $uptime = time() - strtotime($matches[1]); file_put_contents("./uptime.cache", $uptime); } } $uptime_array = format_uptime($uptime); } else { $uptime_txt = @file_get_contents('/proc/uptime'); $uptime = trim(substr($uptime_txt, 0, strpos($uptime_txt, " "))); if (!$uptime && function_exists('shell_exec')) { $uptime = shell_exec("cut -d. -f1 /proc/uptime"); } $uptime_array = format_uptime($uptime); } echo "<uptime>{$uptime_array["days"]} Days {$uptime_array["hours"]}:{$uptime_array["mins"]}:{$uptime_array["secs"]}</uptime>\n";
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 . '&order_by=' . $order_by . '&dir=' . ($dir ? 0 : 1), $total_online, $itemperpage, $start); $output .= ' </td> </tr> <tr> <th width="15%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=name&dir=' . $dir . '"' . ($order_by === 'name' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['name'] . '</a></th> <th width="1%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=race&dir=' . $dir . '"' . ($order_by === 'race' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['race'] . '</a></th> <th width="1%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=class&dir=' . $dir . '"' . ($order_by === 'class' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['class'] . '</a></th> <th width="5%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=level&dir=' . $dir . '"' . ($order_by === 'level' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['level'] . '</a></th> <th width="1%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=totalHonorPoints&dir=' . $dir . '"' . ($order_by === 'totalHonorPoints' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['rank'] . '</a></th> <th width="15%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=guildid&dir=' . $dir . '"' . ($order_by === 'gname' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['guild'] . '</a></th> <th width="20%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=map&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 . '&start_m=' . $start_m . '&order_by=zone&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&error=3&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 . '&order_by=' . $order_by . '&dir=' . ($dir ? 0 : 1), $total_online, $itemperpage, $start); unset($total_online); $output .= ' </td> </tr> </table> </fieldset> <br /> </center>'; } }
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&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'] . ': <font color=white>' . $post['id'] . '</font><br />' . $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&error=3&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 . '&order_by=' . $order_by . '&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 . '&order_by=' . $order_by . '&dir=' . ($dir ? 0 : 1), $total_online, $itemperpage, $start); $output .= ' </td> </tr> <tr> <th width="15%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=name&dir=' . $dir . '"' . ($order_by === 'name' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['name'] . '</a></th> <th width="1%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=race&dir=' . $dir . '"' . ($order_by === 'race' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['race'] . '</a></th> <th width="1%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=class&dir=' . $dir . '"' . ($order_by === 'class' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['class'] . '</a></th> <th width="5%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=level&dir=' . $dir . '"' . ($order_by === 'level' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['level'] . '</a></th> <th width="1%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=totalHonorPoints&dir=' . $dir . '"' . ($order_by === 'totalHonorPoints' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['rank'] . '</a></th> <th width="15%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=guildid&dir=' . $dir . '"' . ($order_by === 'guildid' ? ' class="' . $order_dir . '"' : '') . '>' . $lang_index['guild'] . '</a></th> <th width="20%"><a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=map&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 . '&start_m=' . $start_m . '&order_by=zone&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&error=3&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 . '&order_by=' . $order_by . '&dir=' . ($dir ? 0 : 1), $total_online, $itemperpage, $start); unset($total_online); $output .= ' </td> </tr> </table> <br /> </center>'; } }
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&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&error=11&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&error=11&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") . ': <font color=white>' . $temp["ID"] . '</font><br />' . lang("global", "are_you_sure") . '\', del_motd + ' . $temp["ID"] . ');" alt="" />'; } if ($user_lvl >= $action_permission["update"]) { $output .= ' <a href="motd.php?action=edit_motd&error=3&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&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&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&coupon_id=' . $coupon["entry"] . '"> <img src="img/star.png" width="16" height="16" alt="" /> <span> ' . 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&error=4&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&guid=' . $change["guid"] . '"> <img src="img/cross.png" width="12" height="12" alt="" /> </a>'; if (!$change_char["online"]) { $output .= ' <a href="' . $file . '?action=approve&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 . "&order_by=" . $order_hold . "&dir=" . ($dir ? 0 : 1), $total_online, $itemperpage, $start); $output .= ' </td> </tr> <tr> <th style="width: 15%;"> <a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=name&dir=' . $dir . '"' . ($order_by === "name" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "name") . '</a> </th> <th style="width: 1%;"> <a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=race&dir=' . $dir . '"' . ($order_by === "race" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "race") . '</a> </th> <th style="width: 1%;"> <a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=class&dir=' . $dir . '"' . ($order_by === "class" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "class") . '</a> </th> <th style="width: 5%;"> <a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=level&dir=' . $dir . '"' . ($order_by === "level" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "level") . '</a> </th> <th style="width: 1%;"> <a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=highest_rank&dir=' . $dir . '"' . ($order_by === "highest_rank" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "rank") . '</a> </th> <th style="width: 15%;"> <a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=gname&dir=' . $dir . '"' . ($order_by === "gname" ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "guild") . '</a> </th> <th style="width: 20%;"> <a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=mapid&dir=' . $dir . '"' . ($order_by === "mapid, zoneid " ? ' class="' . $order_dir . '"' : '') . '>' . lang("index", "map") . '</a> </th> <th style="width: 25%;"> <a href="index.php?start=' . $start . '&start_m=' . $start_m . '&order_by=zoneid&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 . '&start_m=' . $start_m . '&order_by=latency&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 . '&start_m=' . $start_m . '&order_by=lastip&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&error=3&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 . "&order_by=" . $order_by . "&dir=" . ($dir ? 0 : 1), $total_online, $itemperpage, $start); $output .= ' </td> </tr> </table>'; } $output .= ' <br />'; unset($total_online); } }
if ($mins > 0) { @($uptimeString .= ($days > 0 || $hours > 0 ? " " : "") . $mins); $uptimeString .= $mins == 1 ? " Minute" : " Minutes"; } if ($secs > 0) { $uptimeString .= ($days > 0 || $hours > 0 || $mins > 0 ? " " : "") . $secs; $uptimeString .= $secs == 1 ? " Second" : " Seconds"; } return $uptimeString; } if (isset($_GET['remote_server_id'])) { require_once 'includes/lib_remote.php'; global $db; $rhost_id = $_GET['remote_server_id']; $remote_server = $db->getRemoteServer($rhost_id); $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']); $uptime = $remote->exec('cat /proc/uptime'); $uptime = explode(" ", $uptime); $uptimeSecs = $uptime[0]; $staticUptime = format_uptime($uptimeSecs); $indexuptime = $staticUptime; $indexuptimesince = $remote->exec('date -d "`cut -f1 -d. /proc/uptime` seconds ago"'); } else { $uptime = exec("cat /proc/uptime"); $uptime = explode(" ", $uptime); $uptimeSecs = $uptime[0]; $staticUptime = format_uptime($uptimeSecs); $indexuptime = $staticUptime; $indexuptimesince = exec('date -d "`cut -f1 -d. /proc/uptime` seconds ago"'); } }