You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 57 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Server Status Block [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
Noxwizard
Nuke Cadet
Nuke Cadet


Joined: Jan 22, 2006
Posts: 2


PostPosted: Sun Jan 22, 2006 4:41 pm Reply with quoteBack to top

Hi, I have a script that will display the status of a game server and list the players on it. I tried to put it in a block, but none of the data is showing. Here's the block's code:
Code:
<?php

$server = "69.112.33.45";
$port = "28001";

function CantConn()
{
$content = "<table border=\"1\" align=\"left\" style=\"border-collapse: collapse\" width=\"100%\" id=\"table1\"><tr><td><B>Connection Error: Server Link Down</B></td></tr></table>";
}

function getData($server, $port, $retrying='1')
{
$input = Chr(98).Chr(0).Chr(0);
@$fp = fsockopen('udp://'.$server, $port);
stream_set_timeout($fp, (0.5*$retrying));
if(!$fp)
CantConn();

fputs($fp, $input);
$out = fopen('./serverDump.txt', 'a+');
$output;
for($problem = stream_get_meta_data($fp);!$problem[timed_out];$problem = stream_get_meta_data($fp))
$output .= fread($fp, 2048);
fclose($fp);

if(!displayData($output))
{
if($retrying == 2)
CantConn();
else
getData($server, $port, ($retrying+1));
}

return true;
}

function displayData($data)
{
$header = substr($data, 0, 4);
if($header != chr(99).chr(0).chr(0).chr(98))
return false;

$game = substr($data, 5, 6);
$rest = substr($data, 11);

$verC = ord(substr($rest, 0, 1));
$version = substr($rest, 1, $verC);
$rest = substr($rest, $verC+1);

$nameC = ord(substr($rest, 0, 1));
$name = substr($rest, 1, $nameC);
$numPL = ord(substr($rest, $nameC+3, 1));
$maxPL = ord(substr($rest, $nameC+4, 1));
$rest = substr($rest, $nameC+7);

$modCount = ord(substr($rest, 0, 1));
$mod = substr($rest, 1, $modCount);
$rest = substr($rest, $modCount+1);

$mapTC = ord(substr($rest, 0, 1));
$mapType = substr($rest, 1, $mapTC);
$rest = substr($rest, $mapTC+1);

$mapNC = ord(substr($rest, 0, 1));
$mapName = substr($rest, 1, $mapNC);
$rest = substr($rest, $mapNC+1);

$servDC = ord(substr($rest, 0, 1));
$servDetail = substr($rest, 1, $servDC);
$teams = ord(substr($rest, $servDC+1, 1));
$rest = substr($rest, $servDC+2);

//== Time to chop off all other stuff, starting from teams...
$b1c = ord(substr($rest, 0, 1));
$rest = substr($rest, $b1c+1);
$b2c = ord(substr($rest, 0, 1));
$rest = substr($rest, $b2c+1);

//== Getting team names
$teamName[255] = "Observer"; //== ALWAYS
for($i = 0; $i < $teams; $i++)
{
$teamNC = ord(substr($rest, 0, 1));
$teamName[$i] = substr($rest, 1, $teamNC);
$rest = substr($rest, $teamNC+1);
$chopC = ord(substr($rest, 0, 1));
$rest = substr($rest, $chopC+1);
# echo("$i: $chopC : ".substr($rest, 0, 1)).' ';
}

$playerName;
$playerTeam;
$playerPing;
$playerPL;
for($i = 0; $i < $numPL; $i++)
{
$playerPing[$i] = ord(substr($rest, 0, 1))*4;
$playerPL[$i] = ord(substr($rest, 1, 1));
$playerTeam[$i] = ord(substr($rest, 2, 1));
$playerNC = ord(substr($rest, 3, 1));
$playerName[$i] = substr($rest, 4, $playerNC);
$rest = substr($rest, (4+$playerNC));
$chopC = ord(substr($rest, 0, 1));
$rest = substr($rest, $chopC+1);
}

$content = "<table border=\"1\" align=\"left\" style=\"border-collapse: collapse\" width=\"100%\" id=\"table1\"><tr><td><B>$name</B><br /><B>$numPL</B> / <B>$maxPL</B> players</td></tr>";

$content = "<tr><td><U><B>Player:</B></U></td></tr>";


for($i = 0; $i < $numPL; $i++)
$content = "<tr><td>$playerName[$i]</td></tr>";
$content = "</table>";

return true;
}

function a($in)
{
$out = $in;
return $out;
}

$server = $_GET['server'];
$port = $_GET['port'];

// Generate Page
//makeForm($server,$port);
if($server && $port)
{
?>
<br>
<?php
getData($server, $port);
}
?>

I know I'm missing the protection part, I'll add it in when I get this working.

Thanks.
Find all posts by NoxwizardView user's profileSend private message
Evaders99
Site Admin
Site Admin


Joined: Aug 17, 2003
Posts: 12403


PostPosted: Sun Jan 22, 2006 5:50 pm Reply with quoteBack to top

Only the first $content needs to be equal
The subsequent ones need to add a period - this tells it to append
Quote:

$content .=

_________________
Helping those that help themselves
Read FIRST or DIE!

"Fighting is terrible, but not as terrible as losing the will to fight."
Star Wars Rebellion Network - Need Help? Evaders Squadron Coding
Find all posts by Evaders99View user's profileSend private messageVisit poster's websiteAIM Address
Noxwizard
Nuke Cadet
Nuke Cadet


Joined: Jan 22, 2006
Posts: 2


PostPosted: Sun Jan 22, 2006 6:20 pm Reply with quoteBack to top

Ok, did that. It's still showing as if there's no content.
Find all posts by NoxwizardView user's profileSend private message
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by · TOGETHER TEAM srl ITALY http://www.togetherteam.it · DONDELEO E-COMMERCE http://www.DonDeLeo.com
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.309 Seconds - 258 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::