Spoon,
Thank you for that it looks perfect, but I am having issues integrating it. I tried to use the top part of the above script for the connection and authentication but it errored out at the beginning of your script. Here is what it looks like, I am sure I am doing something wrong.
PHP Code:
<?php
class telnet {
// Variables
var $message = array();
var $connection;
// Connects to the World Telnet Server
function connect(){
global $cfg;
// Open Socket Connection
$this->connection = fsockopen('192.168.0.4', 9000);
if(!$this->connection){
$this->message[] = "Error connecting to World Telnet Server";
return false;
}else{
fputs($this->connection, sprintf("%s\r", 'username'));
usleep(125000);
fputs($this->connection, sprintf("%s\r", 'password'));
usleep(125000);
return true;
}
}
$telnet = new telnet;
if($telnet->connect() ) {
// We are connected... yay!
echo "<h1>Server is <span style='background-color:green;'>UP</span></h1>";
echo "<p>" . $telnet->uptime() . "</p>";
echo "<table><tr><td>Name</td><td>Zone</td></tr>";
$players = $telnet->whoall();
foreach( array_keys($players) as $key) {
echo "<tr><td>" . $players[$key]['Name'] . "</td><td>" . $players[$key]['ZoneLong'] . "</td><tr>";
}
echo "</table>";
} else {
// OH NOS!
echo "<h1>Server is <span style='background-color:red;'>DOWN</span></h1><p>" . $telnet->message[0] ."</p>";
}
?>
And the error i get if I run php eqstatus.php from a command line on the server.
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /var/www/localhost/htdocs/game-servers/eq/status/eqstatus.php on line 27