GNET php coding / Alt-Tab

Blitz3D Forums/Blitz3D Programming/GNET php coding / Alt-Tab

I have modified my GNET to incude a string holding the number of players on the server and it works very well, but i'd also like to include the total servers/players on my web page, infact I already am but it does not quite work right.

http://sailing.bansheestudios.com/

Current the information isn't cleared and it's showing 1 server and 4 players from my last test, this is ok I am sure I can figure that bit out. However the count seems to break when I have more than 1 server, although this is hard to test as I need more than one IP to do it!

Also I would like to make the check detect what the game is, as currently I am working on two games with GNET and the servers/players reported shows both games total.

This is my current script (I have removed database login details)

	$_server = "";
	$_dbname = "";
	$_usname = "";
	$_paswrd = "";
	$_conect = mysql_connect($_server, $_usname, $_paswrd) or die( mysql_error() );
	mysql_select_db($_dbname, $_conect);

	//return a list of all servers
	function list_servers(){
		$res=mysql_query( "select players from gnet_servers order by t_time desc" );

		//Debug content of row
		while( $row=mysql_fetch_row($res) ){
			$totalPlayers=$totalPlayers+$row[0];
			//$totalPlayers=$totalPlayers+sum($row[0]);
			//$totalPlayers=$totalPlayers+$_GET["players"]
		}

		$totalServers=count($row);
		echo( "Servers: " );
		echo( $totalServers );
		echo( "<br>" );
		echo( "Players: ");
		echo( $totalPlayers );

		exit();
	}



	//setup some useful globals
	if ($_SERVER["HTTP_X_FORWARDED_FOR"]) {
		$ip   = $_SERVER["HTTP_X_FORWARDED_FOR"];
	} else {
		$ip   = $_SERVER["REMOTE_ADDR"];
	}

	$opt=array_key_exists("opt",$_GET) ? $_GET["opt"] : "";
	$game=array_key_exists("game",$_GET) ? $_GET["game"] : "";
	$server=array_key_exists("server",$_GET) ? $_GET["server"] : "";

	//$players=array_key_exists("players",$_GET) ? $_GET["players"] : "";

	//delete 'old' servers
	mysql_query( "delete from gnet_servers where time_to_sec(now())-time_to_sec(t_time)>300" );

	//begin header...
	header( "content-type: text/html; cache-control: no-cache" );

	switch( $opt ){
		case "list": 
			list_servers() ;
			break ;
		default:
			list_servers();
			break;
	}

	exit();


Also whilst i'm at it i've searched through the forums and found lots of stuff on disabling alt-tab, but I would like to make alt-tab work with one of my programs, it's a mod for the sim LiveForSpeed which runs full screen and can flip into windowed mode (and back again), my mod stays in a window in the background but on some systems when you flip LFS into windowed mode my app just shows a black screen.

How can I detect if i've lost my spot on the graphics card RAM and what do I have to do to reinitialise everything please?