PHP Serverstatusbox [message #323408] |
Sat, 22 March 2008 19:21 |
|
SODPaddy
Messages: 233 Registered: August 2005 Location: Germany
Karma: 0
|
Recruit |
|
|
Hello,
has someone the php code for the server status like on n00bstories website:
Renegade
Map: Volcano
Time Left: 0.20.43
Nod: 21/50 15268 points
GDI: 19/50 9293 points
SFPS: 59
- Players -
Website: www.Area54.eu
Once 54, Always 54.
(\__/)
(O.o )
(___)
Visit us at www.Area54.eu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: PHP Serverstatusbox [message #323524 is a reply to message #323408] |
Sun, 23 March 2008 14:25 |
|
SODPaddy
Messages: 233 Registered: August 2005 Location: Germany
Karma: 0
|
Recruit |
|
|
<?php
$handle = fopen("serverstatus/fdsstatus.txt","r");
while (!feof($handle)) {
$line = fgets($handle, 1024);
$write = explode(",", $line);
$color = array("green", "green", "yellow", "yellow", "red", "red", "green", "green", "green" );
$i = 0;
echo "<span style=\"color: $color[$i++]\">". $write['0'] ."</span><br>";
echo "<span style=\"color: $color[$i++]\">". $write['1'] ."</span>";
echo "<span style=\"color: $color[$i++]\">". $write['2'] ."</span>";
echo "<span style=\"color: $color[$i++]\">". $write['3'] ."</span>";
echo "<span style=\"color: $color[$i++]\">". $write['4'] ."</span>";
echo "<span style=\"color: $color[$i++]\">". $write['5'] ."</span>";
echo "<span style=\"color: $color[$i++]\">". $write['6'] ."</span>";
echo "<span style=\"color: $color[$i++]\">". $write['7'] ."</span>";
echo "<span style=\"color: $color[$i++]\">". $write['8'] ."</span>";
}
fclose ($handle);
?>
http://www.eh-server.com/list.php does not runing ... some idea
Website: www.Area54.eu
Once 54, Always 54.
(\__/)
(O.o )
(___)
Visit us at www.Area54.eu
[Updated on: Sun, 23 March 2008 15:04] Report message to a moderator
|
|
|
Re: PHP Serverstatusbox [message #323527 is a reply to message #323408] |
Sun, 23 March 2008 15:20 |
|
danpaul88
Messages: 5795 Registered: June 2004 Location: England
Karma: 0
|
General (5 Stars) |
|
|
Use this instead;
<?php
$fileContent = file_get_contents ( "serverstatus/fdsstatus.txt" );
$write = explode ( "\n", $fileContent );
$color = array("green", "green", "yellow", "yellow", "red", "red", "green", "green", "green" );
for ( $i = 0; $i < 9; $i++ )
echo "<span style=\"color: $color[$i]\">". $write[$i] ."</span><br>";
?>
The problem with your original code is your trying to write the entire thing for every line you read from the file, which ends up with the entire thing being written in green.
[Updated on: Sun, 23 March 2008 15:23] Report message to a moderator
|
|
|
|