2005/12/7 2:22
talunceford
Just can't stay away
Posts: 532
Since: 2002/8/14
2006/1/1 15:49
birdie
Just popping in
Posts: 10
Since: 2005/12/5
2006/1/3 11:16
2006/1/3 18:06
2006/1/4 2:24
//////////////////////////////////////////XOOOPS ADMIN HEADER INFORMATION//////////////////////////////////////// include_once '../../../mainfile.php'; global $xoopsDB; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //-----------------------------------LIST CREATION-----------------------------+ global $xoopsDB; $filename = XOOPS_ROOT_PATH."/modules/bf2query/lgsl/cachedips/lgsl_servers.txt"; $iplist = @fopen($filename, "w+"); @fclose($iplist); $server_sql = "SELECT * FROM ".$xoopsDB->prefix("bf2query_s_name")." LIMIT 0, 500";// These are pre-defined server IPS that were gathered by KQUERY. $query_servers = $xoopsDB->query($server_sql) or die("I cannot connect to the database to find the playername!"); while ($row_servers = $xoopsDB->fetchArray($query_servers)){ $server = $row_servers['s_ip']; $port = $row_servers['s_port']; $sid = $row_servers['s_name_id']; //echo "$sid - $server:$port"; $filename = XOOPS_ROOT_PATH."/modules/bf2query/lgsl/cachedips/lgsl_servers.txt"; $iplist = @fopen($filename, "a+"); $ipaddress = $row_servers['s_ip']; $ipstring = "$ipaddress:16567:bf2 n"; @fwrite($iplist, "$ipstring"); @fclose($iplist); ///////////////////////////////////////////////////////////////END SERVER LIST CREATION ////////////////////////////////// } //------------------------------------------------------------SERVER PARSE FUNCTION--------------------------------------------------++ /*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ _| |_/ _| LIVE GAME SERVER LIST [ STAND ALONE ] |_/ _| |_/ _| © Richard Perry from http://www.greycube.com |_/ _| |_/ _| Released under the terms and conditions of the |_/ _| GNU General Public License (http://gnu.org). |_/ _| |_/ _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/ //-----------------------------------------------------------------------------------------------------------+ $lgsl_cachetime = 10; // REFRESH DELAY IN MINS - AS GUIDE ADD 1 AFTER EVERY 30 SERVERS ON THE LIST $lgsl_hostnamelength = 50; // FULL SERVER LIST - NUMBER OF CHARACTERS BEFORE SERVER NAME GETS CHOPPED $lgsl_hostname_to_ip = 0; // CONVERT HOSTNAMES TO IP ADDRESS TO SAVE SPACE AND FOR ASE LINK TO WORK //-----------------------------------------------------------------------------------------------------------+ include_once XOOPS_ROOT_PATH.'/modules/bf2query/lgsl/lgsl_protocol.php'; if (!is_writable(XOOPS_ROOT_PATH.'/modules/bf2query/lgsl/cachedips/lgsl_cache.dat')) { echo "THE FILE LGSL_CACHE.DAT IS NOT WRITABLE"; exit; } //-----------------------------------------------------------------------------------------------------------+ $lines = file(XOOPS_ROOT_PATH.'/modules/bf2query/lgsl/cachedips/lgsl_cache.dat'); $last_line = count($lines) - 1; $last_update = intval($lines[$last_line]); $time_check = time() - ($lgsl_cachetime * 60); if ($time_check < $last_update) { // echo "DEBUG: This information was CACHED "; unset($lines[$last_line]); foreach ($lines as $line_number=>$line) { $data_cache[$line_number] = unserialize($line); } } else { //-----------------------------------------------------------------------------------------------------------+ // echo "DEBUG: This information was LIVE "; ignore_user_abort(true); // FINISH WRITING CACHE EVEN IF THE BROWSER IS CLOSED $lines = file(XOOPS_ROOT_PATH.'/modules/bf2query/lgsl/cachedips/lgsl_servers.txt'); foreach ($lines as $line) { if (!trim($line)) { continue; } // SKIP BLANK LINES $part = explode(":", $line); $server_ip = trim($part[0]); // TRIM REMOVES $server_port = trim($part[1]); // ACCIDENTAL SPACES $server_type = trim($part[2]); // AND NEWLINE CHARACTERS $data = lgsl_query($server_ip, $server_port, $server_type, "info"); $data[mapname] = preg_replace("/[^A-Za-z0-9 _-]/", "_", strtolower($data[mapname])); // CONVERT FOR FILE $data[gamemod] = preg_replace("/[^A-Za-z0-9 _-]/", "_", strtolower($data[gamemod])); // AND FOLDER USAGE $data_counter += 1; $data_cache[$data_counter] = $data; } $fh = fopen(XOOPS_ROOT_PATH.'/modules/bf2query/lgsl/cachedips/lgsl_cache.dat',"w"); foreach($data_cache as $line) { $line = serialize($line)."rn"; fwrite($fh,$line); } fwrite($fh, time()); fclose($fh); ignore_user_abort(false); } //-----------------------------------------------------------------------------------------------------------+ ?> foreach($data_cache as $data) { if (!$data[status]) { $lgsl_image_status = "images/status/server_offline.gif"; $data[status] = "OFFLINE"; $data[hostname] = "Unknown"; $data[mapname] = "unknown"; $data[players] = "0"; $data[maxplayers] = "0"; } else if (!$data[password]) { $lgsl_image_status = "images/status/server_online.gif"; $data[status] = "ONLINE"; } else { $lgsl_image_status = "images/status/server_online_password.gif"; $data[status] = "ONLINE WITH PASSWORD"; } //-----------------------------------------------------------------------------------------------------------+ $lgsl_image_icon = "images/icons/$data[gametype]/$data[gamemod].gif"; // USE MOD ICON if (!file_exists($lgsl_image_icon)) { $lgsl_image_icon = "images/icons/$data[gametype]/$data[gametype].gif"; // USE GAME ICON if (!file_exists($lgsl_image_icon)) { $lgsl_image_icon = "images/status/unknown.gif"; // USE UKNOWN ICON } } //-----------------------------------------------------------------------------------------------------------+ if (strlen($data[hostname]) > $lgsl_hostnamelength) { $data[hostname] = substr($data[hostname], 0, $lgsl_hostnamelength - 3) . "..."; // SHORTEN HOSTNAME } $data[hostname] = htmlentities($data[hostname], ENT_QUOTES); // CHANGE SYMBOLS INTO ENTITIES //-----------------------------------------------------------------------------------------------------------+ if ($lgsl_hostname_to_ip) { $data[ip] = gethostbyname($data[ip]); } // CONVERT HOSTNAME TO IP $lgsl_launch = lgsl_get("launch", $data[ip], $data[port], $data[gametype]); // GET SOFTWARE LAUNCH LINK //-----------------------------------------------------------------------------------------------------------+ $lgsl_stats_servers++; // COUNT VISIBLE NUMBER OF SERVERS $lgsl_stats_players += $data[players]; // COUNT VISIBLE NUMBER OF PLAYERS $lgsl_stats_maxplayers += $data[maxplayers]; // COUNT VISIBLE NUMBER OF SLOTS //-----------------------------------------------------------------------------------------------------------+ //-----------------------------------------------------------------------------------------------------------+ //-----------------------------------------INSERT PLAYER INFORMATION INTO THE DATABASE-----------------------+ //require_once("lgsl_protocol.php"); //$data = lgsl_query($server_ip, $server_port, $server_type, "players"); $_GET[ip] = $data[ip]; $_GET[port] = $data[port]; $get_ip = $_GET[ip]; $get_port = $_GET[port]; //-----------------------------------------------------------------------------------------------------------+ unset($get_type); $lines = file(XOOPS_ROOT_PATH.'/modules/bf2query/lgsl/cachedips/lgsl_servers.txt'); foreach ($lines as $line) { if (!trim($line)) { continue; } // SKIP BLANK LINES $part = explode(":", $line); $server_ip = trim($part[0]); // TRIM REMOVES $server_port = trim($part[1]); // ACCIDENTAL SPACES $server_type = trim($part[2]); // AND NEWLINE CHARACTERS if ($server_ip == $get_ip && $server_port == $get_port) { $get_type = $server_type; // GETS THE SERVER TYPE FROM THE LGSL_SERVERS.TXT } } if (!$get_type) { exit; } // PROTECT AGAINST THE LINK BEING ALTERED //-----------------------------------------------------------------------------------------------------------+ $player_list = lgsl_query($get_ip, $get_port, $get_type, "players"); //if (!$player_list) { echo "No Players or Server Not Responding