function print_player_list_gameq($player_list, $players, $playersmax, $gamename)
{
    return print_player_list($player_list, $players, $playersmax, $gamename);
}
                $data['status'] = "ONLINE WITH PASSWORD";
            }
        }
        $db->saveServerStatusCache($ip_id, $port, $data);
    }
    if ($data['status'] == 'ONLINE' or $data['status'] == 'ONLINE WITH PASSWORD') {
        $status = "online";
        $stats_players += $data['s']['players'];
        // COUNT VISIBLE NUMBER OF PLAYERS
        $stats_maxplayers += $data['s']['playersmax'];
        // COUNT VISIBLE NUMBER OF SLOTS
        $players = $data['s']['players'];
        $playersmax = $data['s']['playersmax'];
        $name = $data['s']['name'];
        $map = preg_replace("/[^a-z0-9_]/", "_", strtolower($data['s']['map']));
        $mod = preg_replace("/[^a-z0-9_]/", "_", strtolower($data['s']['game']));
        $xml_mod = xml_get_mod($server_xml, $data['s']['game']);
        $qport = get_query_port($server_xml, $server_home['port']);
        $address = "<a href='" . lgsl_software_link($server_xml->lgsl_query_name, $ip, $c_port, $q_port, $s_port) . "'>" . $ip . ":" . $port . "</a>";
        if ($data['s']['players'] > 0) {
            $player_list = print_player_list($data['p'], $players, $playersmax);
        }
        $playersList = $data['p'];
        $maplocation = get_map_path($query_name, $mod, $map);
    } else {
        $status = "half";
    }
} else {
    $status = "half";
    $notifications = get_lang_f('queries_disabled_by_setting_disable_queries_after', $numberservers_to_skip_query, $num_of_servers);
}
function exec_ogp_module()
{
    global $db, $OnlineServers;
    $isAdmin = $db->isAdmin($_SESSION['user_id']);
    $panel_settings = $db->getSettings();
    $settings = $db->getSettings();
    $OnlineServers = "";
    $OnlineServersTitle = "";
    require_once 'includes/lib_remote.php';
    if ($isAdmin) {
        $server_homes = $db->getIpPorts();
    } else {
        $server_homes = $db->getIpPortsForUser($_SESSION['user_id']);
    }
    $player_list = "";
    if (!$server_homes) {
        $OnlineServers .= "";
    } else {
        $stats_servers = 0;
        $stats_servers_online = 0;
        $stats_players = 0;
        $stats_maxplayers = 0;
        $onlinePlayers = "";
        $OnlineServers .= "<table style='width:100%;' class='online_servers'>";
        foreach ($server_homes as $server_home) {
            $remote_server_id = $server_home['remote_server_id'];
            $rserver = $db->getRemoteServerById($remote_server_id);
            // Count the number of servers.
            $stats_servers++;
            // Remember to clear the old value here.
            $message = "";
            $remote = new OGPRemoteLibrary($server_home['agent_ip'], $server_home['agent_port'], $server_home['encryption_key']);
            $host_stat = $remote->status_chk();
            if ($host_stat === 1) {
                // Check if the screen running the server is running.
                $screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME, $server_home['home_id']) === 1;
                $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $server_home['home_cfg_file']);
                $id = strlen($server_home['home_name']) > 15 ? "id='scrolldown'" : "";
                if ($screen_running) {
                    // Check if the screen running the server is running.
                    if ($server_xml->protocol == "gameq") {
                        require 'protocol/GameQ/GameQMonitor.php';
                    } else {
                        if ($server_xml->protocol == "lgsl") {
                            require 'protocol/lgsl/LGSLMonitor.php';
                        } else {
                            if ($server_xml->protocol == "teamspeak3") {
                                require 'protocol/TeamSpeak3/TS3Monitor.php';
                            } else {
                                // This is here because some servers are not supported by LGSL/GameQ or
                                // because we do not have proper support for them yet.
                                // With properly supported games this should not needed.
                                // (In a perfect world no one would need an insurance.)
                                $status = "half";
                                if ($server_home['use_nat'] == 1) {
                                    $ip = $server_home['agent_ip'];
                                } else {
                                    $ip = $server_home['ip'];
                                }
                                $port = $server_home['port'];
                                $player_list = "";
                            }
                        }
                    }
                    if ($status == "online") {
                        $OnlineServers .= "<tr><td><div {$id} class='name' ><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=" . $server_home['home_id'] . "-" . $server_home['mod_id'] . "-" . $server_home['ip'] . "-" . $server_home['port'] . "' ><img style='border:0;height:12px;' src='images/magnifglass.png'/>" . $server_home['home_name'] . "</a></div>";
                        $OnlineServers .= "<div><div style='font-size:8pt;' >[" . $players . '/' . $playersmax . "]</div> " . $map . '</div>';
                        $OnlineServers .= "<div id='gamelink' >{$address}</div>";
                        $OnlineServers .= "</td></tr>";
                        if ($players >= 1) {
                            $onlinePlayers .= print_player_list($playersList, $players, $playersmax, $server_home['game_name']);
                        }
                        $stats_servers_online++;
                    } elseif ($status == "half") {
                        $OnlineServers .= "<tr><td><div {$id} class='name' ><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=" . $server_home['home_id'] . "-" . $server_home['mod_id'] . "-" . $server_home['ip'] . "-" . $server_home['port'] . "' ><img style='border:0;height:12px;' src='images/magnifglass.png'/>" . $server_home['home_name'] . "</a></div>";
                        $OnlineServers .= "<div><div style='font-size:8pt;' ></div> </div>";
                        $OnlineServers .= "<div id='gamelink' >{$ip}:{$port}</div>";
                        $OnlineServers .= "</td></tr>";
                        $stats_servers_online++;
                    }
                }
            }
            unset($map, $player_list, $status, $ip, $port, $players, $playersmax, $name, $map, $mod, $xml_mod, $qport, $address, $maplocation);
        }
        $OnlineServers .= "</table>";
        $OnlineServers .= "<center>" . get_lang('statistics') . ":<br>{$stats_servers_online}/{$stats_servers} \n\t\t" . get_lang('servers') . "<br>{$stats_players}/{$stats_maxplayers} " . get_lang('players') . "</center>";
    }
    if ($_GET['show'] == "servers") {
        echo $OnlineServers;
    }
    if ($_GET['show'] == "players") {
        echo $onlinePlayers;
    }
}