Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Tools

Development::Tools 3rd Party Tools for EQEMu (DB management tools, front ends, etc...)

Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2008, 04:01 PM
spoon
Sarnak
 
Join Date: Aug 2007
Posts: 34
Default

updated:

added check on line 121-3
added check on line 189
added class and level to player table

PHP Code:
<?php

class telnet {

    
// Variables
    
var $message = array();
    var 
$connection;

    
// Connects to the World Telnet Server
    
function connect(){
        
        
// Open Socket Connection
        
$this->connection fsockopen('127.0.0.1'9000);

        if(!
$this->connection){
            
$this->message[] = "Error connecting to World Telnet Server";
            return 
false;
        }else{
            
fputs($this->connectionsprintf("%s\r"'USER_NAME'));
            
usleep(125000);   
              
fputs($this->connectionsprintf("%s\r"'PASSWORD'));
            
usleep(125000);
            return 
true;
        }
    }
    
    
    
// Close the Telnet Connection
    
function close(){
        
fclose($this->connection);
    }
    
    
    
// Server Uptime
    
function uptime(){
        
fputs ($this->connection"uptime\r"); 
        
usleep(125000);
            
        while (!
feof($this->connection)){
            
$ret fgets($this->connection);
            if (
ereg("Uptime"$ret)) {
                
$ret str_replace("$user"""$ret);
                return 
str_replace(">"""$ret);
                break;
            }
        }
    }
    
    
    
// Zone Status
    
function zonestatus($zone=''){
        
fputs ($this->connectionsprintf("zonestatus %s\r"$zone)); 
        
usleep(125000);
        
        while(!
feof($this->connection)){
            
$ret fgets($this->connection);
            
            if (
ereg("$Server:"$ret)){
                echo 
"$ret \n <br>";
            }
            
            if(
ereg("avail"$ret)){
                echo 
"$ret \n <br>";
                break;
            }                
        }
    }
    
    
// Kick Character from World Server
    
function kick($character$message='YOU ARE BEING KICKED FROM THE SERVER IN 4 SECONDS'){
        
fputs($this->connectionsprintf("tell %s %s\r"$character$message));
        
sleep(4); 
        
fputs($this->connectionsprintf("kick %s\r"$character));
        
$this->message[] = "Character has been kicked from server";
        
sleep(1);
    }
    
    
    
// Send Character a Tell
    
function tell($character$message){
        
fputs($this->connectionsprintf("tell %s %s\r"$character$message));
        
sleep(1);
        
$this->message[] = sprintf("Message Sent to Character: %s"$character);
    }
    
    
    
// Send Server a OOC Message
    
function ooc($message){
        
fputs($this->connectionsprintf("ooc %s\r"$message));
        
sleep(1);
        
$this->message[] = "Message sent to OOC";
    }
    
    
    
// Broadcast Message Server Wide
    
function broadcast($message){
        
fputs($this->connectionsprintf("broadcast %s\r"$message));
        
sleep(1);
        
$this->message[] = "Broadcast Message Sent to World Server";
    }
    
    
    
// Who/Who All
    
function whoall($who=''){
    
        
fputs ($this->connectionsprintf("who%s\r"$who)); 
        
usleep(125000);

        while (!
feof($this->connection)) {
            
$ret_tmp fgets($this->connection);

            if(
ereg("zone"$ret_tmp)){ 
                
$ret[++$x] = $ret_tmp;
            }
            
            if(
ereg("online"$ret_tmp)){
                break;
            }
        }
        
        if( !
is_array($ret) ) {
            return;
        }

        
// Process each line of the returned results
        
foreach ($ret as $key => $value) {
        
            
// Original Return
            
$players[$key]['original'] = $value;

            
// GM Status
            
if (preg_match("/\*.*\*/"$value$matches)) {
                
$players[$key]['GM'] = trim($matches[0], "* ");
            }
        
            
// Role/Anon, Level & Class
            
if (preg_match("/\[.*\]/"$value$matches)) {
                
$tmp explode(" "trim($matches[0], "[] "));
                if (!
is_numeric($tmp[0])) {
                    
$players[$key]['Visible'] = $tmp[0];
                    
$players[$key]['Level'] = $tmp[1];
                    
$players[$key]['Class'] = rtrim($tmp[2] . " " $tmp[3], " ");
                } else {
                    
$players[$key]['Level'] = $tmp[0];
                    
$players[$key]['Class'] = rtrim($tmp[1] . " " $tmp[2], " ");
                }
            }
        
            
// Character's Name
            
if(preg_match("/\].*\(/"$value$matches)){
                
$players[$key]['Name'] = trim($matches[0], "] (");
            }
        
            
// Race
            
if(preg_match("/\(.*\)/"$value$matches)){
                
$players[$key]['Race'] = trim($matches[0], "( )");
            }
        
            
// Zone
            
if(preg_match("/zone:.*AccID:/"$value$matches)){
                
$players[$key]['ZoneLong'] = substr($matches[0], 6, -7);
            }
        
            
// Account ID
            
if(preg_match("/AccID:.*AccName:/"$value$matches)){
                
$players[$key]['AcctID'] = substr($matches[0], 7, -9);
            }
        
            
// Account Name
            
if(preg_match("/AccName:.*LSID:/"$value$matches)){
                
$players[$key]['AcctName'] = substr($matches[0], 9, -6);
            }
        
            
// Login Server ID
            
if(preg_match("/LSID:.*Status:/"$value$matches)){
                
$players[$key]['LSID'] = substr($matches[0], 6, -8);
            }
        
            
// Status
            
if(preg_match("/Status:.*/"$value$matches)){
                
$players[$key]['Status'] = substr($matches[0], 83);
            }
        }
        
        
// Return Player Array
        
return $players;
    }

}
Class

$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>";
    
$players $telnet->whoall();
    if( 
is_array($players) ) {
        echo 
"<table><tr><td>Name</td><td>Class</td><td>Level</td><td>Zone</td></tr>";
        foreach( 
array_keys($players) as $key) {
            echo 
"<tr><td>" $players[$key]['Name'] . "</td>";
            echo 
"<td>" $players[$key]['Class']. "</td>";
            echo 
"<td>" $players[$key]['Level']. "</td>";
            echo 
"<td>" $players[$key]['ZoneLong']. "</td><tr>";
        }
        echo 
"</table>";
    } else {
        echo 
"<p>Nobody is on</p>";
    }
    
} else {
    
// OH NOS!
    
echo "<h1>Server is <span style='background-color:red;'>DOWN</span></h1><p>" $telnet->message[0] ."</p>";

?>
Reply With Quote
  #2  
Old 09-18-2008, 04:09 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

nope just a big:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING in /var/www/localhost/htdocs/game-servers/eq/status/eqstatus.php on line 192

On the page. Not getting any of the uptime stuff now either. When I put it in gedit the colors of some of the text is not right. Something may not be closed right? I dunno, like I said I am just finishing up learning html and starting to move into php.
Reply With Quote
  #3  
Old 09-18-2008, 04:12 PM
spoon
Sarnak
 
Join Date: Aug 2007
Posts: 34
Default

Quote:
Originally Posted by cubber View Post
nope just a big:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING in /var/www/localhost/htdocs/game-servers/eq/status/eqstatus.php on line 192

On the page. Not getting any of the uptime stuff now either.
Oups! somehow "Class" made its way onto line 192. Removed:

PHP Code:
<?php

class telnet {

    
// Variables
    
var $message = array();
    var 
$connection;

    
// Connects to the World Telnet Server
    
function connect(){
        
        
// Open Socket Connection
        
$this->connection fsockopen('127.0.0.1'9000);

        if(!
$this->connection){
            
$this->message[] = "Error connecting to World Telnet Server";
            return 
false;
        }else{
            
fputs($this->connectionsprintf("%s\r"'USER_NAME'));
            
usleep(125000);   
              
fputs($this->connectionsprintf("%s\r"'PASSWORD'));
            
usleep(125000);
            return 
true;
        }
    }
    
    
    
// Close the Telnet Connection
    
function close(){
        
fclose($this->connection);
    }
    
    
    
// Server Uptime
    
function uptime(){
        
fputs ($this->connection"uptime\r"); 
        
usleep(125000);
            
        while (!
feof($this->connection)){
            
$ret fgets($this->connection);
            if (
ereg("Uptime"$ret)) {
                
$ret str_replace("$user"""$ret);
                return 
str_replace(">"""$ret);
                break;
            }
        }
    }
    
    
    
// Zone Status
    
function zonestatus($zone=''){
        
fputs ($this->connectionsprintf("zonestatus %s\r"$zone)); 
        
usleep(125000);
        
        while(!
feof($this->connection)){
            
$ret fgets($this->connection);
            
            if (
ereg("$Server:"$ret)){
                echo 
"$ret \n <br>";
            }
            
            if(
ereg("avail"$ret)){
                echo 
"$ret \n <br>";
                break;
            }                
        }
    }
    
    
// Kick Character from World Server
    
function kick($character$message='YOU ARE BEING KICKED FROM THE SERVER IN 4 SECONDS'){
        
fputs($this->connectionsprintf("tell %s %s\r"$character$message));
        
sleep(4); 
        
fputs($this->connectionsprintf("kick %s\r"$character));
        
$this->message[] = "Character has been kicked from server";
        
sleep(1);
    }
    
    
    
// Send Character a Tell
    
function tell($character$message){
        
fputs($this->connectionsprintf("tell %s %s\r"$character$message));
        
sleep(1);
        
$this->message[] = sprintf("Message Sent to Character: %s"$character);
    }
    
    
    
// Send Server a OOC Message
    
function ooc($message){
        
fputs($this->connectionsprintf("ooc %s\r"$message));
        
sleep(1);
        
$this->message[] = "Message sent to OOC";
    }
    
    
    
// Broadcast Message Server Wide
    
function broadcast($message){
        
fputs($this->connectionsprintf("broadcast %s\r"$message));
        
sleep(1);
        
$this->message[] = "Broadcast Message Sent to World Server";
    }
    
    
    
// Who/Who All
    
function whoall($who=''){
    
        
fputs ($this->connectionsprintf("who%s\r"$who)); 
        
usleep(125000);

        while (!
feof($this->connection)) {
            
$ret_tmp fgets($this->connection);

            if(
ereg("zone"$ret_tmp)){ 
                
$ret[++$x] = $ret_tmp;
            }
            
            if(
ereg("online"$ret_tmp)){
                break;
            }
        }
        
        if( !
is_array($ret) ) {
            return;
        }

        
// Process each line of the returned results
        
foreach ($ret as $key => $value) {
        
            
// Original Return
            
$players[$key]['original'] = $value;

            
// GM Status
            
if (preg_match("/\*.*\*/"$value$matches)) {
                
$players[$key]['GM'] = trim($matches[0], "* ");
            }
        
            
// Role/Anon, Level & Class
            
if (preg_match("/\[.*\]/"$value$matches)) {
                
$tmp explode(" "trim($matches[0], "[] "));
                if (!
is_numeric($tmp[0])) {
                    
$players[$key]['Visible'] = $tmp[0];
                    
$players[$key]['Level'] = $tmp[1];
                    
$players[$key]['Class'] = rtrim($tmp[2] . " " $tmp[3], " ");
                } else {
                    
$players[$key]['Level'] = $tmp[0];
                    
$players[$key]['Class'] = rtrim($tmp[1] . " " $tmp[2], " ");
                }
            }
        
            
// Character's Name
            
if(preg_match("/\].*\(/"$value$matches)){
                
$players[$key]['Name'] = trim($matches[0], "] (");
            }
        
            
// Race
            
if(preg_match("/\(.*\)/"$value$matches)){
                
$players[$key]['Race'] = trim($matches[0], "( )");
            }
        
            
// Zone
            
if(preg_match("/zone:.*AccID:/"$value$matches)){
                
$players[$key]['ZoneLong'] = substr($matches[0], 6, -7);
            }
        
            
// Account ID
            
if(preg_match("/AccID:.*AccName:/"$value$matches)){
                
$players[$key]['AcctID'] = substr($matches[0], 7, -9);
            }
        
            
// Account Name
            
if(preg_match("/AccName:.*LSID:/"$value$matches)){
                
$players[$key]['AcctName'] = substr($matches[0], 9, -6);
            }
        
            
// Login Server ID
            
if(preg_match("/LSID:.*Status:/"$value$matches)){
                
$players[$key]['LSID'] = substr($matches[0], 6, -8);
            }
        
            
// Status
            
if(preg_match("/Status:.*/"$value$matches)){
                
$players[$key]['Status'] = substr($matches[0], 83);
            }
        }
        
        
// Return Player Array
        
return $players;
    }

}

$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>";
    
$players $telnet->whoall();
    if( 
is_array($players) ) {
        echo 
"<table><tr><td>Name</td><td>Class</td><td>Level</td><td>Zone</td></tr>";
        foreach( 
array_keys($players) as $key) {
            echo 
"<tr><td>" $players[$key]['Name'] . "</td>";
            echo 
"<td>" $players[$key]['Class']. "</td>";
            echo 
"<td>" $players[$key]['Level']. "</td>";
            echo 
"<td>" $players[$key]['ZoneLong']. "</td><tr>";
        }
        echo 
"</table>";
    } else {
        echo 
"<p>Nobody is on</p>";
    }
    
} else {
    
// OH NOS!
    
echo "<h1>Server is <span style='background-color:red;'>DOWN</span></h1><p>" $telnet->message[0] ."</p>";

?>
Reply With Quote
  #4  
Old 09-18-2008, 04:17 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

Very nice! Cant wait to go home and log on to test! Only one thing I see that could be a security risk though is that the username used to establish the telnet connection is displayed before the uptime report:

Code:
Server is ONLINE

TELNET-USERNAME uptime Worldserver Uptime: 01d 06h 39m 52s

Nobody is online
How can it be hidden?
Reply With Quote
  #5  
Old 09-18-2008, 04:33 PM
spoon
Sarnak
 
Join Date: Aug 2007
Posts: 34
Default

Quote:
Originally Posted by cubber View Post
Very nice! Cant wait to go home and log on to test! Only one thing I see that could be a security risk though is that the username used to establish the telnet connection is displayed before the uptime report:

Code:
Server is ONLINE

TELNET-USERNAME uptime Worldserver Uptime: 01d 06h 39m 52s

Nobody is online
How can it be hidden?
Haven't properly tested the regex, but try this:

PHP Code:
<?php

class telnet {

    
// Variables
    
var $message = array();
    var 
$connection;

    
// Connects to the World Telnet Server
    
function connect(){
        
        
// Open Socket Connection
        
$this->connection fsockopen('127.0.0.1'9000);

        if(!
$this->connection){
            
$this->message[] = "Error connecting to World Telnet Server";
            return 
false;
        }else{
            
fputs($this->connectionsprintf("%s\r"'USER_NAME'));
            
usleep(125000);   
              
fputs($this->connectionsprintf("%s\r"'PASSWORD'));
            
usleep(125000);
            return 
true;
        }
    }
    
    
    
// Close the Telnet Connection
    
function close(){
        
fclose($this->connection);
    }
    
    
    
// Server Uptime
    
function uptime(){
        
fputs ($this->connection"uptime\r"); 
        
usleep(125000);
            
        while (!
feof($this->connection)){
            
$ret fgets($this->connection);
            if (
ereg("Uptime"$ret)) {
                
$ret str_replace("$user"""$ret);
                return 
str_replace(">"""$ret);
                break;
            }
        }
    }
    
    
    
// Zone Status
    
function zonestatus($zone=''){
        
fputs ($this->connectionsprintf("zonestatus %s\r"$zone)); 
        
usleep(125000);
        
        while(!
feof($this->connection)){
            
$ret fgets($this->connection);
            
            if (
ereg("$Server:"$ret)){
                echo 
"$ret \n <br>";
            }
            
            if(
ereg("avail"$ret)){
                echo 
"$ret \n <br>";
                break;
            }                
        }
    }
    
    
// Kick Character from World Server
    
function kick($character$message='YOU ARE BEING KICKED FROM THE SERVER IN 4 SECONDS'){
        
fputs($this->connectionsprintf("tell %s %s\r"$character$message));
        
sleep(4); 
        
fputs($this->connectionsprintf("kick %s\r"$character));
        
$this->message[] = "Character has been kicked from server";
        
sleep(1);
    }
    
    
    
// Send Character a Tell
    
function tell($character$message){
        
fputs($this->connectionsprintf("tell %s %s\r"$character$message));
        
sleep(1);
        
$this->message[] = sprintf("Message Sent to Character: %s"$character);
    }
    
    
    
// Send Server a OOC Message
    
function ooc($message){
        
fputs($this->connectionsprintf("ooc %s\r"$message));
        
sleep(1);
        
$this->message[] = "Message sent to OOC";
    }
    
    
    
// Broadcast Message Server Wide
    
function broadcast($message){
        
fputs($this->connectionsprintf("broadcast %s\r"$message));
        
sleep(1);
        
$this->message[] = "Broadcast Message Sent to World Server";
    }
    
    
    
// Who/Who All
    
function whoall($who=''){
    
        
fputs ($this->connectionsprintf("who%s\r"$who)); 
        
usleep(125000);

        while (!
feof($this->connection)) {
            
$ret_tmp fgets($this->connection);

            if(
ereg("zone"$ret_tmp)){ 
                
$ret[++$x] = $ret_tmp;
            }
            
            if(
ereg("online"$ret_tmp)){
                break;
            }
        }
        
        if( !
is_array($ret) ) {
            return;
        }

        
// Process each line of the returned results
        
foreach ($ret as $key => $value) {
        
            
// Original Return
            
$players[$key]['original'] = $value;

            
// GM Status
            
if (preg_match("/\*.*\*/"$value$matches)) {
                
$players[$key]['GM'] = trim($matches[0], "* ");
            }
        
            
// Role/Anon, Level & Class
            
if (preg_match("/\[.*\]/"$value$matches)) {
                
$tmp explode(" "trim($matches[0], "[] "));
                if (!
is_numeric($tmp[0])) {
                    
$players[$key]['Visible'] = $tmp[0];
                    
$players[$key]['Level'] = $tmp[1];
                    
$players[$key]['Class'] = rtrim($tmp[2] . " " $tmp[3], " ");
                } else {
                    
$players[$key]['Level'] = $tmp[0];
                    
$players[$key]['Class'] = rtrim($tmp[1] . " " $tmp[2], " ");
                }
            }
        
            
// Character's Name
            
if(preg_match("/\].*\(/"$value$matches)){
                
$players[$key]['Name'] = trim($matches[0], "] (");
            }
        
            
// Race
            
if(preg_match("/\(.*\)/"$value$matches)){
                
$players[$key]['Race'] = trim($matches[0], "( )");
            }
        
            
// Zone
            
if(preg_match("/zone:.*AccID:/"$value$matches)){
                
$players[$key]['ZoneLong'] = substr($matches[0], 6, -7);
            }
        
            
// Account ID
            
if(preg_match("/AccID:.*AccName:/"$value$matches)){
                
$players[$key]['AcctID'] = substr($matches[0], 7, -9);
            }
        
            
// Account Name
            
if(preg_match("/AccName:.*LSID:/"$value$matches)){
                
$players[$key]['AcctName'] = substr($matches[0], 9, -6);
            }
        
            
// Login Server ID
            
if(preg_match("/LSID:.*Status:/"$value$matches)){
                
$players[$key]['LSID'] = substr($matches[0], 6, -8);
            }
        
            
// Status
            
if(preg_match("/Status:.*/"$value$matches)){
                
$players[$key]['Status'] = substr($matches[0], 83);
            }
        }
        
        
// Return Player Array
        
return $players;
    }

}

$telnet = new telnet;
if(
$telnet->connect() ) {
    
// We are connected... yay!
    
echo "<h1>Server is <span style='background-color:green;'>UP</span></h1>";
    
$uptime $telnet->uptime();
    
$uptime preg_replace'/^.*:/','' $uptime );
    echo 
"<p> Uptime: " $uptime "</p>";
    
$players $telnet->whoall();
    if( 
is_array($players) ) {
        echo 
"<table><tr><td>Name</td><td>Class</td><td>Level</td><td>Zone</td></tr>";
        foreach( 
array_keys($players) as $key) {
            echo 
"<tr><td>" $players[$key]['Name'] . "</td>";
            echo 
"<td>" $players[$key]['Class']. "</td>";
            echo 
"<td>" $players[$key]['Level']. "</td>";
            echo 
"<td>" $players[$key]['ZoneLong']. "</td><tr>";
        }
        echo 
"</table>";
    } else {
        echo 
"<p>Nobody is on</p>";
    }
    
} else {
    
// OH NOS!
    
echo "<h1>Server is <span style='background-color:red;'>DOWN</span></h1><p>" $telnet->message[0] ."</p>";

?>
Reply With Quote
  #6  
Old 09-18-2008, 04:45 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

Perfect! Now I get :

Code:
The EverQuest Server is ONLINE

Uptime: 01d 07h 07m 53s

Nobody is online
after a bit of text modification of course. I also linked the page to my site's css stylesheet and it blends in nicely! Final test report will be in a couple hours after I get home and log in. Thanks a bunch!
Reply With Quote
  #7  
Old 09-18-2008, 04:55 PM
spoon
Sarnak
 
Join Date: Aug 2007
Posts: 34
Default

Quote:
Originally Posted by cubber View Post
Perfect! Now I get :

Code:
The EverQuest Server is ONLINE

Uptime: 01d 07h 07m 53s

Nobody is online
after a bit of text modification of course. I also linked the page to my site's css stylesheet and it blends in nicely! Final test report will be in a couple hours after I get home and log in. Thanks a bunch!
Good to hear. The true test will be to see if the player info gets displayed properly. I don't have a server to test it on, so please let me know how it goes.

Thanks,
spoon
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:31 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3