function QueryServer($block, $server_id) { global $sitename, $prefix, $db, $module_name, $admin, $GSdownloads, $GSdebug, $module_name, $GSremote, $GSremotepath, $GScode, $GSTags, $GSfailcount, $GSbcachetime; if ($_GET['do'] != "bquery") { include 'header.php'; } $sql = "SELECT ip, port, longname, engine, active, failstring, failcounts FROM " . $prefix . "_gameservers WHERE server_id='" . $_GET['server_id'] . "'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $GSip = $row[ip]; $GSport = $row[port]; $GSlongname = $row[longname]; $GSactive = $row[active]; $GSgame = $row[engine]; $GSfailstring = $row[failstring]; $GSfailcounts = $row[failcounts]; if ($_GET['do'] != "bquery") { title($sitename . " : " . _MODULENAME . " : " . $GSlongname); echo "<br />"; OpenTable(); echo "<center><a href=\"" . getlink("GameServers") . "\">.:: Display All Servers ::.</a><br />"; CloseTable(); echo "<br />"; OpenTable(); } if ($GSip) { if ($GSactive or is_admin($admin)) { $servers[$GSgame] = array($GSgame, $GSip, $GSport); if ($_GET['do'] == "bquery") { $sql2 = "SELECT server_id, sname, numplayers, maxplayers, map, stamp, ping FROM " . $prefix . "_gameservers_statcache WHERE server_id='" . $server_id . "' ORDER BY `stamp` ASC LIMIT 1"; $result2 = $db->sql_query($sql2); $stats[$server_id] = $db->sql_fetchrow($result2); $eng[$server_id] = $servers[$server_id][0]; $time = time(); $oldtime = $time - gmmktime(0, $GSbcachetime, 0, 1, 1, 1970, 0); if ($stats[$server_id][stamp] > 0 and $oldtime < $stats[$server_id][stamp]) { $skipq = 1; } } if ($skipq != 1) { if ($GSremote) { $fc = file_get_contents($GSremotepath . '/remote.php?game=' . $GSgame . '&ip=' . $GSip . '&port=' . $GSport . '&code=' . $GScode); $data = @unserialize($fc); } else { define('CFG_FILE', 'modules/' . $module_name . '/gameq/class.gameq.cfg.php'); define('INC_PATH', 'modules/' . $module_name . '/gameq/inc/'); require_once 'modules/' . $module_name . '/gameq/class.gameq.php'; $query = new GameQ(); $data = $query->GetInfo($servers); } } if (CheckQuery($data, $GSgame) or $skipq == 1) { if ($data[$GSgame][custom][ping] != 200) { $ping = $data[$GSgame][custom][ping]; } else { $ping = 0; } if ($_GET['do'] != "bquery") { if (file_exists('modules/' . $module_name . '/output_templates/' . $GSgame . '.php')) { if ($GSTags and $data[$GSgame][custom][type] == 'q3') { echo "<LINK REL=\"StyleSheet\" HREF=\"modules/{$module_name}/q3col.css\" TYPE=\"text/css\">"; } include 'modules/' . $module_name . '/output_templates/' . $GSgame . '.php'; } else { echo '<pre><strong>Raw Data:</strong>'; print_r($data); echo '</pre>'; } } else { if ($skipq != 1) { $SSplayers = PlayerCount($servers, $GSgame, $data); $SSmap = CurrentMap($servers, $GSgame, $data); $SSname = ServerName($servers, $GSgame, $data); } else { $SSplayers = $stats[$server_id][numplayers] . "/" . $stats[$server_id][maxplayers]; $SSmap = $stats[$server_id][map]; $SSname = $stats[$server_id][sname]; $ping = $stats[$server_id][ping]; } include 'modules/' . $module_name . '/output_templates/SSblock.php'; } SaveStats($servers, $server_id, $GSgame, $data); } elseif ($data == "BADCODE") { echo _BADCODE; } else { echo _BADQUERY; if ($GSfailcount and !$block) { AddFail($server_id); } } } else { echo _INACTIVE; } } else { echo _INVALID; } if ($_GET['do'] != "bquery") { CloseTable(); } // display downloads section if enabled if ($GSdownloads and !$bquery) { ListDLs($GSgame); } // display admin tools if admin if (is_admin($admin) and $_GET['do'] != "bquery") { echo "<br>"; OpenTable(); echo '<center>[ <a href="' . adminlink() . '">' . _GSADMIN . '</a> | <a href="' . adminlink("&mode=GSConfig") . '">' . _GSADMINC . '</a> | <a href="' . adminlink("&mode=GSEdit&server_id=" . $_GET['server_id'] . "") . '">' . _GSEDIT . '</a> | <a href="' . adminlink("&mode=GSStatus&server_id=" . $_GET['server_id'] . "&GSactive=" . $GSactive . "") . '">'; switch ($GSactive) { case 1: echo _GSDEACTIVE; break; case 2: echo _DEACTIVATED . "(" . count(explode("|", $GSfailstring)) . ")"; break; case 0: echo _GSACTIVE; break; } echo '</a> | '; if ($GSremote) { echo '<a href="' . $GSremotepath . '/remote.php?game=' . $GSgame . '&ip=' . $GSip . '&port=' . $GSport . '&code=' . $GScode . '" target="_blank">' . _REMLINK . '</a> | '; } echo '<a href="' . adminlink("&mode=GSDelete&server_id=" . $_GET['server_id'] . "&ok=0") . '">' . _GSDEL . '</a> ]</center>'; CloseTable(); } // display degug if admin and debug is enabled if (is_admin($admin) and $GSdebug and $_GET['do'] != "bquery") { echo '<br>'; OpenTable(); echo '<pre><strong>You\'re an admin for this module and debug is enabled - here is the Raw Data for this query:</strong><br>'; print_r($data); echo '</pre>'; echo '<pre><strong>Errors:</strong>'; print_r($query->ErrorMsg); echo '</pre>'; CloseTable(); } if ($_GET['do'] != "bquery") { include 'footer.php'; } else { die; } }