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

08-29-2008, 06:58 PM
|
Sarnak
|
|
Join Date: Feb 2008
Posts: 87
|
|
Yea, LOTS....
This is a php class that you must call and then call each function you want performed, also you need to input your username/password.
Replace
$this->connection = fsockopen($cfg['telnet']['address'], $cfg['telnet']['port']);
with
$this->connection = fsockopen('your server ip address', 9000);
9000 is the default port, change it to match what your server's is.
Also change
fputs($this->connection, sprintf("%s\r", unserialize($_SESSION['EQ_EDT_USR'])));
and
fputs($this->connection, sprintf("%s\r", unserialize($_SESSION['EQ_EDT_PWD'])));
and replace the
unserialize($_SESSION'EQ_EDT_USR']) and unserialize($_SESSION['EQ_EDT_PWD'])
with your EQ EMU Username and Password.. This checks the account table in the database. Make sure your username and password is like this:
fputs($this->connection, sprintf("%s\r", 'username'));
fputs($this->connection, sprintf("%s\r", 'password'));
After that you need to call the class and then the functions below the script.
Example:
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('127.0.0.1', 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;
}
}
// 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->connection, sprintf("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->connection, sprintf("tell %s %s\r", $character, $message));
sleep(4);
fputs($this->connection, sprintf("kick %s\r", $character));
$this->message[] = "Character has been kicked from server";
sleep(1);
}
// Send Character a Tell
function tell($character, $message){
fputs($this->connection, sprintf("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->connection, sprintf("ooc %s\r", $message));
sleep(1);
$this->message[] = "Message sent to OOC";
}
// Broadcast Message Server Wide
function broadcast($message){
fputs($this->connection, sprintf("broadcast %s\r", $message));
sleep(1);
$this->message[] = "Broadcast Message Sent to World Server";
}
// Who/Who All
function whoall($who=''){
fputs ($this->connection, sprintf("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;
}
}
// 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], 8, 3);
}
}
// Return Player Array
return $players;
}
}
$telnet = new telnet;
$telnet->connect();
$telnet->broadcast('This is a test message from your GM Please sign out NOW!');
$telnet->close();
?>
or you can call more than 1 function before the session is closed.
PHP Code:
$telnet = new telnet;
$telnet->connect();
$telnet->broadcast('This is a test message from your GM Please sign out NOW!');
$telnet->kick('icantplayeq', 'I DONT LIKE YOU SO IM KICKING YOU');
$telnet->close();
|
 |
|
 |
 |
|
 |

09-04-2008, 12:02 PM
|
Discordant
|
|
Join Date: Apr 2006
Posts: 374
|
|
I made all the edits that you suggested and still end up with a blank page.
Here is my page called index.php
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.2.6', 9000);
if(!$this->connection){ $this->message[] = "Error connecting to World Telnet Server"; return false; }else{ fputs($this->connection, sprintf("%s\r", 'my-user-name')); usleep(125000); fputs($this->connection, sprintf("%s\r", 'my-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->connection, sprintf("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->connection, sprintf("tell %s %s\r", $character, $message)); sleep(4); fputs($this->connection, sprintf("kick %s\r", $character)); $this->message[] = "Character has been kicked from server"; sleep(1); } // Send Character a Tell function tell($character, $message){ fputs($this->connection, sprintf("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->connection, sprintf("ooc %s\r", $message)); sleep(1); $this->message[] = "Message sent to OOC"; } // Broadcast Message Server Wide function broadcast($message){ fputs($this->connection, sprintf("broadcast %s\r", $message)); sleep(1); $this->message[] = "Broadcast Message Sent to World Server"; } // Who/Who All function whoall($who=''){ fputs ($this->connection, sprintf("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; } }
// 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], 8, 3); } } // Return Player Array return $players; }
}
$telnet = new telnet; $telnet->connect(); $telnet->broadcast('This is a test message from the GM Please sign out NOW!'); $telnet->close(); ?>
|
 |
|
 |

09-04-2008, 06:01 PM
|
Sarnak
|
|
Join Date: Feb 2008
Posts: 87
|
|
You are supposed to end up with a blank page.... There is nothing that is supposed to print out on the screen. All that I gave you is basically the "back end" of a program/script.
The real question is did it work for you? It should have, next time log in to the server and then run this script once more and see if it shows up in EQ...
Also you might be missing something in PHP or apache or something..
Look in your error logs to see if this script had an error.
|

09-11-2008, 11:54 AM
|
Discordant
|
|
Join Date: Apr 2004
Location: 127.0.0.1
Posts: 402
|
|
Thanks for the contribution cybernine186.
|

09-18-2008, 01:37 PM
|
Discordant
|
|
Join Date: Apr 2006
Posts: 374
|
|
I have been trying to figure out how I go about using this "back end" script to display the server status on a web page but keep coming up blank. Do you mind shedding some insight on how this would be accomplished. I would guess that I would need to call this script within the webpage somehow to have it display the data.
I am still new to PHP. Like I said before I would only like to display server status, uptime, and a list of currently logged in characters with lvl/class info.
Thanks again.
|

09-18-2008, 02:27 PM
|
Sarnak
|
|
Join Date: Aug 2007
Posts: 34
|
|
Quote:
Originally Posted by cubber
I have been trying to figure out how I go about using this "back end" script to display the server status on a web page but keep coming up blank. Do you mind shedding some insight on how this would be accomplished. I would guess that I would need to call this script within the webpage somehow to have it display the data.
I am still new to PHP. Like I said before I would only like to display server status, uptime, and a list of currently logged in characters with lvl/class info.
Thanks again.
|
You might try something like:
PHP Code:
$telnet = new telnet;
if($telnet->connect() ) {
// We are connected... yay!
echo "<h1>Server is <span style='background-color:green;'>UP</h1><p>" . $telnet->uptime() . "</p>";
} else {
// OH NOS!
echo "<h1>Server is <span style='background-color:red;'>DOWN</h1><p>" . $telnet->message[0] ."</p>";
}
|

09-18-2008, 02:58 PM
|
Sarnak
|
|
Join Date: Aug 2007
Posts: 34
|
|
saw you wanted the players on as well:
PHP Code:
<?php $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>"; } ?>
|
Thread Tools |
|
Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 11:38 PM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |