31
talunceford
Re: BF2 Server Status Module...

Actually, I am using a heavily modified version of the code found on this guys site. www.greycube.com.
Tim
www.tswn.com | www.bf2online.com | aquaria.tswn.com | www.bf2142online.org

32
birdie
Re: BF2 Server Status Module...
  • 2006/1/1 15:49

  • birdie

  • Just popping in

  • Posts: 10

  • Since: 2005/12/5


well i'm amazed of how much you have done with that. If you need any storage, ive got an empty server

33
talunceford
Re: BF2 Server Status Module...

It seems to work very very well.
Tim
www.tswn.com | www.bf2online.com | aquaria.tswn.com | www.bf2142online.org

34
birdie
Re: BF2 Server Status Module...
  • 2006/1/3 18:06

  • birdie

  • Just popping in

  • Posts: 10

  • Since: 2005/12/5


would u mind publishing a bit of source code please? i'm just really interested into how u did this

35
talunceford
Re: BF2 Server Status Module...

<?php
//////////////////////////////////////////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<br>";
$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 <br /><br />";
  
    
unset($lines[$last_line]);

    foreach (
$lines as $line_number=>$line)
    {
      
$data_cache[$line_number] = unserialize($line);
    }
  }
  else
  {

//-----------------------------------------------------------------------------------------------------------+

    // echo "DEBUG: This information was LIVE <br /><br />";

    
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($fhtime());

    
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 "<div style='text-align:center'>No Players or Server Not Responding</div></body></html>"; }
 
//-----------------------------------------------------------------------------------------------------------+

  
if (isset($player_list[1][score]) )  { $lgsl_showscore  1; }
  if (isset(
$player_list[1][deaths]))  { $lgsl_showdeaths 1; }
  if (isset(
$player_list[1][skill]))   { $lgsl_showskill  1; }
  if (isset(
$player_list[1][goal]))    { $lgsl_showgoal   1; }
  if (isset(
$player_list[1][honor]))   { $lgsl_showhonor  1; }
  if (isset(
$player_list[1][leader]))  { $lgsl_showleader 1; }
  if (isset(
$player_list[1][ping])  )  { $lgsl_showping   1; }
  if (isset(
$player_list[1][team])  )  { $lgsl_showteam   1; }
  if (isset(
$player_list[1][stats]) )  { $lgsl_showstats  1; }
  if (isset(
$player_list[1][time])  )  { $lgsl_showtime   1; }
  if (isset(
$player_list[1][skin]))    { $lgsl_showskin   1; }
//if (isset($player_list[1][keyhash])) { $lgsl_showhash   = 1; }
//if (isset($player_list[1][pid]))     { $lgsl_showpid    = 1; }


// --------------------------------------------------------+

// --------------------------------------------------------+
  
foreach ($player_list as $key=>$player)
  {  
    
$player[name] = htmlentities($player[name], ENT_QUOTES); // CONVERT SYMBOLS
    
                
$time=time();
                
$time $time+1;
                
$playername $player[name]; //<== VARIABLE FROM SERVER QUERY, LISTS EACH PLAYER IN AN ARRAY. 
                
$hostname $data[hostname];
                
$playerscore $player[score];
                
$playerdeaths $player[deaths];
                
$playerskill $player[skill];
                
$playergoal $player[goal];
                
$playerhonor $player[honor];
                
$playerleader $player[leader];
                
$playerping $player[ping];
                
$playerteam $player[team];
                
$playerstats $player[stats];
                
$playertime $player[time];
                
$playerskin $player[skin];
                
$playerhash $player[hash];
                
$playerpid $player[pid];
                
$gameserver_ip $data[ip];
                
$gameserver_mapname $data[mapname];
                
$q "SELECT * FROM ".$xoopsDB->prefix("bf2query_s_name")." WHERE s_ip='$gameserver_ip'";
                
$query_servers $xoopsDB->query($q) or die("I cannot connect to the database!");
                
$server $xoopsDB->fetchArray($query_servers);
                
$s_port $server['s_port'];
                
                
$gameserver_port $s_port;
                
/*
                $qps = "SELECT * FROM ".$xoopsDB->prefix("bf2query_g_pstats")." WHERE s_p_name='$playername'";
                $query_playerstats = $xoopsDB->query($qps) or die("I cannot connect to the database to find the playername!");
                $playerstats = $xoopsDB->fetchArray($query_playerstats);
                $s_p_id = $playerstats['s_p_id'];
                $s_p_pid = $playerstats['s_p_pid'];
                $s_p_name = $playerstats['s_p_name'];
                $s_p_score = (($playerstats['s_p_score'])+($playerscore));
                $s_p_kill = (($playerstats['s_p_kill'])+($playerskill));
                $s_p_deaths = (($playerstats['s_p_deaths'])+($playerdeaths));
                $s_p_ping = ((($playerstats['s_p_ping'])+($playerping))/2);
                $s_p_sname = $playerstats['s_p_sname'];
                $s_s_ip = $playerstats['s_s_ip'];
                $s_s_port = $playerstats['s_s_port'];
                $s_p_map = $playerstats['s_p_map'];
                
                if (mysql_num_rows($query_playerstats)==0) {
                @mysql_query("INSERT INTO ".$xoopsDB->prefix("bf2query_g_pstats")." SET s_p_id='$s_p_id', s_p_pid='$playerpid', s_p_name='$playername', s_p_score='$s_p_score', s_p_deaths='$s_p_deaths', s_p_ping='$s_p_ping', s_p_map='$gameserver_mapname', s_p_kill='$playerskill'") or die("Help I cant INSERT the player information");
                }else{
                @mysql_query("UPDATE ".$xoopsDB->prefix("bf2query_g_pstats")." SET s_p_id='$s_p_id', s_p_pid='$playerpid', s_p_name='$playername', s_p_score='$s_p_score', s_p_deaths='$s_p_deaths', s_p_ping='$s_p_ping', s_p_map='$s_p_map', s_p_kill='$s_p_kill' WHERE s_p_name='$playername'") or die("Help I cant UPDATE the player information");
                }
                */
                //$result = $xoopsDB->query($r) or die("");
                
$qp "SELECT * FROM ".$xoopsDB->prefix("bf2query_info")." WHERE pname='$playername'";
                
$query_players $xoopsDB->query($qp) or die("I cannot connect to the database to find the playername!");
                
$p_score = (($query_players['p_score'])+($playerscore));
                
$p_kill = (($query_players['p_skill'])+($playerskill));
                
$p_deaths = (($query_players['p_deaths'])+($playerdeaths));
                
$p_ping = ((($query_players['p_ping'])+($playerping))/2);
                
                if (
mysql_num_rows($query_players)==0) {
                
//@mysql_query("INSERT INTO ".$xoopsDB->prefix("bf2query_player_info")." SET s_time='$time', p_s_ip='$gameserver_ip', pname='$playername', p_s_name='$hostname', p_s_port='$gameserver_port', p_score='$playerscore', p_deaths='$playerdeaths', p_skill='$playerskill', p_goal='$playergoal', p_honor='$playerhonor', p_leader='$playerleader', p_ping='$playerping', p_team='$playerteam', p_stats='$playerstats', p_skin='$playerskin', p_hash='$playerhash', p_pid='$playerpid', p_s_time='$time'") or die("Help Im broke");
                //$xoopsDB->query($insert_players) or die("I cannot insert this data!");
                
@mysql_query("INSERT INTO ".$xoopsDB->prefix("bf2query_info")." SET s_time='$time', p_s_ip='$gameserver_ip', pname='$playername', p_s_name='$hostname', p_s_port='$gameserver_port', p_score='$playerscore', p_deaths='$playerdeaths', p_ping='$playerping', p_team='$playerteam', p_skill='$playerskill', p_pid='$playerpid', p_s_map='$gameserver_mapname'") or die("Help I cant insert the player information");
                
//echo "$player[name]<br> inserted";//USE THIS TO TEST FOR ERRORS
                /*
                //MAIL FUNCTION ++-----------------------------------USE THIS WISELY, BECAUSE IT SENDS AN EMAIL OUT FOR EVERY PLAYER INSERTED.
                $msg = "BF2QUERY PLAYER INSERTED n";
                $sender_name = "BF2QUERY";
                $sender_email = "noreply@bf2online.com";
                $msg .= "Sender's Name:t$sender_namen";
                $msg .= "Senders' Email:t$sender_emailn";
                $message = "The Player $playername has been inserted into the database.  They are currently playing on $hostname.";
                $msg .= "Message:t$messagenn";
                $to = "widowmaker@bf2online.com";
                $subject = "BF2QUERY PLAYER INSERTED";
                $mailheaders = "From: BF2Online BF2QUERY <> n";
                $mailheaders .= "Reply-To: $sender_emailnn";
                mail($to, $subject, $msg, $mailheaders);
                //END MAIL FUNCTION
                */
                
}else{
                @
mysql_query("UPDATE ".$xoopsDB->prefix("bf2query_info")." SET s_time='$time', p_s_ip='$gameserver_ip', pname='$playername', p_s_name='$hostname', p_s_port='$gameserver_port', p_score='$p_score', p_deaths='$p_deaths', p_ping='$p_ping', p_team='$playerteam', p_skill='$p_kill', p_pid='$playerpid', p_s_map='$gameserver_mapname' WHERE pname='$playername'") or die("Help I cant update the player info, something is very wrong!!");
                
//echo "$player[name]<br> updated";//USE THIS TO TEST FOR ERRORS
                /*
                //MAIL FUNCTION ++-----------------------------------USE THIS WISELY, BECAUSE IT SENDS AN EMAIL OUT FOR EVERY PLAYER UPDATED.
                $msg = "BF2QUERY PLAYER UPDATE n";
                $sender_name = "BF2QUERY";
                $sender_email = "noreply@bf2online.com";
                $msg .= "Sender's Name:t$sender_namen";
                $msg .= "Senders' Email:t$sender_emailn";
                $message = "The Player $playername has been updated.  They are currently playing on $hostname.";
                $msg .= "Message:t$messagenn";
                $to = "widowmaker@bf2online.com";
                $subject = "BF2QUERY PLAYER UPDATE";
                $mailheaders = "From: BF2Online BF2QUERY <> n";
                $mailheaders .= "Reply-To: $sender_emailnn";
                mail($to, $subject, $msg, $mailheaders);
                //END MAIL FUNCTION
                */
                
                
}
    
  }



  }
                
//MAIL FUNCTION ++-----------------------------------.
                
$msg "BF2QUERY PARSE SCRIPT STATUS n";
                
$sender_name "BF2QUERY";
                
$sender_email "noreply@bf2online.com";
                
$msg .= "Sender's Name:t$sender_namen";
                
$msg .= "Senders' Email:t$sender_emailn";
                
$message "The first 500 servers have been successfully parsed.  Please check the module for updated or inserted players.";
                
$msg .= "Message:t$messagenn";
                
$to "widowmaker@bf2online.com";
                
$subject "BF2QUERY SCRIPT STATUS";
                
$mailheaders "From: BF2Online BF2QUERY <> n";
                
$mailheaders .= "Reply-To: $sender_emailnn";
                
mail($to$subject$msg$mailheaders);
                
//END MAIL FUNCTION
echo "Script finished";//
?>



This is the script that parses the servers and inserts the players, if there are any, into the database.
Tim
www.tswn.com | www.bf2online.com | aquaria.tswn.com | www.bf2142online.org

36
probatus
Re: BF2 Server Status Module...
  • 2006/1/4 4:33

  • probatus

  • Just popping in

  • Posts: 32

  • Since: 2005/5/14


Man that is looking great, you are very skilled. I am really looking forward to this! I still cant get the teamspeak module to work but its no big deal.

37
talunceford
Re: BF2 Server Status Module...

Well, I am working on the Teamspeak module as we speak. I am having trouble with 2.2.x and the Teamspeak module. I might start from scratch on a few of the pages, just to make them compatable. We'll see what happens.
Tim
www.tswn.com | www.bf2online.com | aquaria.tswn.com | www.bf2142online.org

38
birdie
Re: BF2 Server Status Module...
  • 2006/1/4 16:55

  • birdie

  • Just popping in

  • Posts: 10

  • Since: 2005/12/5


wow i need 2 post on these forums more often, its amazin what people are doing to xoops. good luck on the module guys.

ty for the source code

39
talunceford
Re: BF2 Server Status Module...

Not a problem man!
Tim
www.tswn.com | www.bf2online.com | aquaria.tswn.com | www.bf2142online.org

40
birdie
Re: BF2 Server Status Module...
  • 2006/1/16 19:52

  • birdie

  • Just popping in

  • Posts: 10

  • Since: 2005/12/5


hows it goin guys? i thought i heard gamespy and ea have tightened up the security and some scripts wont work anymore. affected u lot?

Login

Who's Online

221 user(s) are online (137 user(s) are browsing Support Forums)


Members: 0


Guests: 221


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits