|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Support::Windows Servers Support forum for Windows EQEMu users. |
|
|
|
10-13-2014, 11:28 AM
|
|
Sarnak
|
|
Join Date: Apr 2014
Location: Florida
Posts: 44
|
|
PHP help plz.
So i have found a few threads and put together this script through a bunch of posts i found searching the forums here. it is OUTPUTTING Server UP or Down correctly but NOTHING else, and i cannot seem to catch the reason why. here is the code.
Code:
<?php
class telnet {
// Variables
var $message = array();
var $connection;
// Connects to the World Telnet Server
function connect(){
// Open Socket Connection
$this->connection = fsockopen('184.33.56.151', 9000);
if(!$this->connection){
$this->message[] = "Error connecting to World Telnet Server";
return false;
}else{
fputs($this->connection, sprintf("%s\r", 'usernamehidden'));
usleep(125000);
fputs($this->connection, sprintf("%s\r", 'passwordhidden'));
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;
}
}
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], 8, 3);
}
}
// 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>";
}
?>
it says Server UP but nobody online and i have like 6 people online and its doing nothing else.. what did i miss? thanks in advance.
|
|
|
|
|
|
|
10-13-2014, 10:17 PM
|
Opcode Ninja
|
|
Join Date: Mar 2009
Location: San francisco
Posts: 426
|
|
I tired to do a trace route on the ip posted with no returns is your server setup as a public server or private?
If you have a website for your users to login install Apache and php use this below i dug this up from May 2007 was posted on cavedude site
Code:
<?php
/*******************************************
* Aerewen's Uber Fake Pub Server *
* Why? Because we can :oD *
********************************************
I will be providing no support for this utility as it
was originally created for use on my server only, but I
wanted everyone else to be able to share their PEQ servers
with friends in an easy-to-use manner. This tool will
prevent you from having to manually update the database
account table.
Put this page on your site after setting the variables below to
the information of the MySQL database with the PEQ info in it.
*/
$DB_ADDY = "localhost"; //address:port for the MySQL server
$DB_USER = "root"; //username to login to MySQL with
$DB_PASS = "mypassword"; //password to login to MySQL with
$DB_DB = "peq"; //database name to use "peq" for default installation
$server_name "Name of Your Server"; //set the name of your server here
$admin_level = 250; //default level of admin to give to people who sign up
//This WILL NOT modify admin of people logging in to the server.
/*
Have your friends access this page on the webserver, enter a
username/password to create an account, and click Login/Create.
This will create their account with the level of access specified
in $admin_level. It will then detect the IP address they accessed
the page from, and update the account table with that IP.
Before connecting to your PEQ server, you should always have people
login from this page to update their IP if needed.
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $server_name; ?> PEQ Server Authentication</title>
<style type="text/css">
<!--
body,td,th {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 14px;
color: #CCCCCC;
}
body {
background-color: #000000;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style1 {font-size: 9px}
.formelements {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
color: #FFFFFF;
background-color: #333333;
border: thin solid #666666;
}
a {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 14px;
color: #CCCCCC;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #CCCCCC;
}
a:hover {
text-decoration: underline;
color: #CCCCCC;
}
a:active {
text-decoration: none;
color: #CCCCCC;
}
.style4 {font-size: 10px}
-->
</style>
</head>
<body>
<div align="center"><?php
if(!isset($_POST['Submit'])){
?>
<form id="form1" name="form1" method="post" action="index.php">
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="174" align="right" valign="top"><div align="right">Username: </div></td>
<td width="326" align="left" valign="top"><input name="username" type="text" class="formelements" id="username" size="40" maxlength="9" />
<br />
<span class="style1">*must be 9 characters or less</span> </td>
</tr>
<tr>
<td align="right" valign="top"><div align="right">Password: </div></td>
<td align="left" valign="top"><input name="password" type="password" class="formelements" id="password" size="40" maxlength="9" />
<br />
<span class="style1">*must be 9 characters or less</span></td>
</tr>
<tr>
<td colspan="2" align="center" valign="top"><input name="Submit" type="submit" class="formelements" value="Login/Create" /> <input name="Reset" type="reset" class="formelements" value="Clear" /></td>
</tr>
</table>
</form>
<?php
} else {
//set font color
$link = mysql_connect($DB_ADDY,$DB_USER,$DB_PASS);
mysql_select_db($DB_DB,$link);
$sql = "SELECT * FROM `account` WHERE `name` = '". $_POST['username']. "'";
$res = mysql_query($sql,$link);
if(mysql_num_rows($res) != 0){
//username was found
$info = mysql_fetch_assoc($res);
if($info['password'] == $_POST['password']){
//password matches
if($_SERVER['REMOTE_ADDR'] != $info['minilogin_ip']){
//ip address has changed
$sql = "UPDATE `account` SET `minilogin_ip` = '". $_SERVER['REMOTE_ADDR']. "' WHERE `name` = '". $_POST['username']. "' AND `password` = '". $_POST['password']. "'";
$sql2 = "UPDATE `account` SET `minilogin_ip` = '0.0.0.0' WHERE `minilogin_ip` = '". $_SERVER['REMOTE_ADDR']. "'";
if(($res = mysql_query($sql2,$link)) && mysql_query($sql,$link)){
echo '<font color="#00FF00">';
echo 'Your IP address was successfully updated. You may now start EverQuest Titanium Edition and log in to the server.';
echo '</font>';
} else {
echo '<font color="#FF0000">';
echo 'There was an error updating your IP address. Please try again later or contact an admin for assistance.';
echo '</font>';
}
} else {
//ip didnt change
echo '<font color="#00FF00">';
echo 'Your IP address has not changed. You may now start EverQuest Titanium Edition and log in to the server.';
echo '</font>';
}
} else {
//password was wrong
echo '<font color="#FF0000">';
echo 'The username: '. $_POST['username']. '<br />Already exists in our database, and the password<br />you entered for it was incorrect.<br />';
echo 'If this is your account, please <a href="index.php">go back</a>, re-enter your password, and try again.<br />';
echo 'If you were attempting to create a new account, please try a different user name.';
echo '</font>';
}
} else {
//username was not found create it now
$newno = "SELECT `id` FROM `account` ORDER BY `id` DESC LIMIT 1";
$res = mysql_query($newno,$link);
$newno = mysql_fetch_assoc($res);
$newno = ($newno['id'] + 1);
$sql = "INSERT INTO `account` VALUES (". $newno. ",'". $_POST['username']. "','',0,'". $_POST['password']. "',". $admin_level. ",". $newno. ",0,0,'". $_SERVER['REMOTE_ADDR']. "',0,0)";
$sql2 = "UPDATE `account` SET `minilogin_ip` = '0.0.0.0' WHERE `minilogin_ip` = '". $_SERVER['REMOTE_ADDR']. "'";
if(($res = mysql_query($sql2,$link)) && mysql_query($sql,$link)){
echo '<font color="#00FF00">';
echo 'New account created successfully. You may now start EverQuest Titanium Edition and log in to the server using:<br />';
echo 'Username: '. $_POST['username']. '<br />Password: '. $_POST['password']. '<br />*username and password are case sensitive!';
echo '</font>';
} else {
echo '<font color="#FF0000">';
echo 'There was an error while trying to create your account. Please try again later.';
echo '</font>';
}
}
}
?><br /><br />
<span class="style4">Before logging in to our server, please make sure you have downloaded the eqhost.txt and copied it into your EverQuest directory.<br />
For a new copy of eqhost.txt, right click <a href="eqhost.txt" class="style4">This Link</a> and
choose "Save Target As".<br />
This file will replace the existing one in your EverQuest directory, which defaults to: C:\Program Files\Sony\EverQuest\<br />
If you need any assistance, please contact an admin.<br />All content is protected under the GPL. Scripts are ©2007 Icesnake Web Solutions, LLC</span></div>
</body>
</html>
|
|
|
|
10-13-2014, 10:33 PM
|
|
Discordant
|
|
Join Date: Sep 2009
Posts: 270
|
|
I don't suggest using the script noport posted as it has no bearing on what you're trying to do and if it did work it would be creating accounts with GM status.
The script you posted works fine for me on one of two servers I tested it on.
The difference was password length. I could get the UP indication but then there was a buffer overflow.
You can see exactly what's happening by running it from the command line or setting more sensitive error reporting in your php.ini.
|
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 08:14 PM.
|
|
|
|
|
|
|
|
|
|
|
|
|