EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Feature Requests (https://www.eqemulator.org/forums/forumdisplay.php?f=612)
-   -   Users online php script . (https://www.eqemulator.org/forums/showthread.php?t=17806)

sdabbs65 02-01-2005 06:25 PM

Users online php script .
 
Dunno nothing about how this.
Just an Idea, I would like to see a php script that could tell me how many users are online and the locations,kinda like the runuo emulator has.
it is even possable ?

--------------------------------------------------------

edit...ah nevermind i think I found it in a old thread...


<?php
$server = "localhost";
$username = "root";
$password = "xxxxxxx";
$dbname = "eq";

$link = mysql_pconnect($server,$username,$password);
mysql_select_db($dbname, $link);

$sql = "SELECT zonename, profile FROM character_";
$result = mysql_query($sql);

echo "<table border=\"0\" width=\"100%\">\n";
echo "<th>Name</th>\n";
echo "<th>Zone Name</th>\n";
echo "<th>Gender</th>\n";
echo "<th>Race</th>\n";
echo "<th>Level</th>\n";
echo "<th>Bind</th>\n";
while ($row = mysql_fetch_array($result)) {
$zonename = $row["zonename"];
$profile = $row["profile"];
$alt_adv = $row["alt_adv"];
$profileinfo = unpack("Lchecksum/a64firstname/a32lastname/Lgender/Lrace/Lclass/Lunknown/Llevel/Lzoneid/fbindx/fbindy/fbindz", $profile);

$firstname = $profileinfo["firstname"];
$lastname = $profileinfo["lastname"];
$gender = $profileinfo["gender"];
$race = $profileinfo["race"];
$class = $profileinfo["class"];
$level = $profileinfo["level"];
$zoneid = $profileinfo["zoneid"];
$bindx = $profileinfo["bindx"];
$bindy = $profileinfo["bindy"];
$bindz = $profileinfo["bindz"];
$bind = "$bindx, $bindy, $bindz";
$id++;


if ($gender == 0) {
$gender = "male";
} elseif ($gender == 1) {
$gender = "female";
}

echo "<tr>\n";
echo " <td align=center>$firstname $lastname</td>\n";
echo " <td align=center>$zonename ($zoneid)</td>\n";
echo " <td align=center>$gender</td>\n";
echo " <td align=center>$race</td>\n";
echo " <td align=center>$level</td>\n";
echo " <td align=center>$bind</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
?>

fathernitwit 02-02-2005 06:01 AM

that actually just gives you stats, wether they are logged in or not.
To detect active connections, you would prolly have to telnet to the world console and ask it for a who.

sdabbs65 02-02-2005 04:50 PM

Quote:

Originally Posted by fathernitwit
that actually just gives you stats, wether they are logged in or not.
To detect active connections, you would prolly have to telnet to the world console and ask it for a who.

.

hmmm i was hoping perl could do something like that , I will have to research that this weekend.

Acolyte 02-05-2005 04:22 PM

Damn, it's been a long time since I've posted or done anything with EQEmu... probably close to 3 years now.

I wrote a php script that did what you were asking for. I don't have a copy of it anymore, but I will tell you what it did.

Basically, using PHP, you CAN telnet into the world server and parse the output of players to display it on a webpage. No PERL needed.

KingMortenson 02-18-2005 01:25 PM

I remember that Acolyte , didn't you write that for my server ? hehe

farce 03-14-2005 10:45 PM

Use PHP to open a socket to the telnet port on your world server. Send in the commands to get the list, read out the data into an array then format and display.

pseudo code:

Code:

<?php

$fp = fsockopen('localhost',21, $errno, $errstr,30); // PHP server and world are on the same machine
if(!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    fgets($fp, 128); // then keep getting data until an input prompt
    fwrite($fp, "who\n"); // input command
    while(!feof($fp)) {
        echo fgets($fp, 128);
    }
    fclose($fp);
}

something to that effect =)

sdabbs65 03-15-2005 02:11 AM

PHP script.
 
I don't think the server supports telnet as I can not even telnet into it
localy.
when I do telnet to the server it echos and just says invalid username and password.

I was thinking a perl script might work but I dont know enuff to get it going properly.

Im getting this error.
500 'WHO': command not understood.

knightz 03-15-2005 06:18 AM

http://heightenedreality.com/cgi-bin/whoson.pl

Code is sort of ugly, I'll post it later when I get time.

sdabbs65 03-16-2005 04:31 AM

[QUOTE=knightz
Code is sort of ugly, I'll post it later when I get time.[/QUOTE]


ok
with some modification it could be usefull but without the
code it's useless.

knightz 04-05-2005 08:43 AM

Sorry it took so long....

Code:

#!/usr/bin/perl

use Net::Telnet;
use strict;

my $server = "Website title : Who's online";
my $titleimg = "http://kmra.fliphost.net/themes/Illusion/images/head/banner.jpg";
my $host = "localhost";
my $user = "johndoe";
my $pass = "password";

my %players;

my $telnet = new Net::Telnet( Port=>9000, Timeout=>200, Errmode=>'die', Prompt=>'/knightz> $/i');
# print "Connecting...\n";
$telnet->open($host);

sleep 1;

$telnet->print($user);
$telnet->waitfor("/:/");
$telnet->print($pass);

$telnet->waitfor("/>/");

my @wholist = $telnet->cmd('who');

$telnet->close();

print "Content-type: text/html\n\n";
print "<title>$server online user list</title>";
print "<meta http-equiv='REFRESH' content='60;url=whoson.pl'>";
print "<body topmargin='0'>";
print "<center><img src='$titleimg'>";
print "<h3>$server</h3>";

foreach my $line (@wholist) {

    if($line =~/^ +\[.*/) { # regular players
        my ($v_userinfo, $v_zone, $v_account_id, $v_account_name, $v_lsid, $v_status) = split(/[a-zA-Z]+:/, $line);
        # clean up the spaces and other garbage
        $v_userinfo =~s/^ +//;
        $v_userinfo =~s/ +$//;
        $v_userinfo =~s/RolePlay |ANON //;
        $v_zone =~s/^ +([a-z]+) +$/$1/;

        # if no guild
        if($v_userinfo =~/^\[([0-9]+) ([A-Za-z ]+)\] ([A-Za-z_]+) \(([A-Za-z ]+)\)$/) {
            if($1>0) {
                $players{$3}{"level"} = $1;
                $players{$3}{"class"} = $2;
                $players{$3}{"race"} = $4;
                $players{$3}{"guild"} = "\&nbsp;";
                $players{$3}{"zone"} = $v_zone;
            } else {
                $players{$3}{"level"} = "\&nbsp;";
                $players{$3}{"class"} = "\&nbsp;";
                $players{$3}{"race"} = "\&nbsp;";
                $players{$3}{"guild"} = "\&nbsp;";
                $players{$3}{"zone"} = "zoning";
            }
        # if in a guild
        } elsif($v_userinfo =~/^\[([0-9]+) ([A-Za-z ]+)\] ([A-Za-z_]+) \(([A-Za-z ]+)\) \<(.*)\>$/) {
            if($1>0) {
                $players{$3}{"level"} = $1;
                $players{$3}{"class"} = $2;
                $players{$3}{"race"} = $4;
                $players{$3}{"guild"} = $5;
                $players{$3}{"zone"} = $v_zone;
            } else {
                $players{$3}{"level"} = "\&nbsp;";
                $players{$3}{"class"} = "\&nbsp;";
                $players{$3}{"race"} = "\&nbsp;";
                $players{$3}{"guild"} = "\&nbsp;";
                $players{$3}{"zone"} = "zoning";
            }
        }
    } elsif($line =~/\* GM-.*/) { # GMs
        $line =~s/\* GM-[A-Za-z]+ \*//;
        my ($v_userinfo, $v_zone, $v_account_id, $v_account_name, $v_lsid, $v_status) = split(/[a-zA-Z]+:/, $line);
        # clean up the spaces and other garbage
        $v_userinfo =~s/^ +//;
        $v_userinfo =~s/ +$//;
        $v_userinfo =~s/RolePlay |ANON //;
        $v_zone =~s/^ +([a-z]+) +$/$1/;

        # if no guild
        if($v_userinfo =~/^\[([0-9]+) ([A-Za-z ]+)\] ([A-Za-z_]+) \(([A-Za-z ]+)\)$/) {
            if($1>0) {
                $players{$3}{"level"} = $1;
                $players{$3}{"class"} = $2;
                $players{$3}{"race"} = $4;
                $players{$3}{"guild"} = "\&nbsp;";
                $players{$3}{"zone"} = $v_zone;
                $players{$3}{"gm"} = "yes";
            } else {
                $players{$3}{"level"} = "\&nbsp;";
                $players{$3}{"class"} = "\&nbsp;";
                $players{$3}{"race"} = "\&nbsp;";
                $players{$3}{"guild"} = "\&nbsp;";
                $players{$3}{"zone"} = "zoning";
                $players{$3}{"gm"} = "yes";
            }
        # if in a guild
        } elsif($v_userinfo =~/^\[([0-9]+) ([A-Za-z ]+)\] ([A-Za-z_]+) \(([A-Za-z ]+)\) \<(.*)\>$/) {
            if($1>0) {
                $players{$3}{"level"} = $1;
                $players{$3}{"class"} = $2;
                $players{$3}{"race"} = $4;
                $players{$3}{"guild"} = $5;
                $players{$3}{"zone"} = $v_zone;
                $players{$3}{"gm"} = "yes";
            } else {
                $players{$3}{"level"} = "\&nbsp;";
                $players{$3}{"class"} = "\&nbsp;";
                $players{$3}{"race"} = "\&nbsp;";
                $players{$3}{"guild"} = "\&nbsp;";
                $players{$3}{"zone"} = "zoning";
                $players{$3}{"gm"} = "yes";
            }
        }
    }
}

print "<html><body><table border='1' cellpadding='3' cellspacing='0'>\n";
print "<tr><td align='center'>Player</td><td align='center'>Class</td><td align='center'>Zone</td><td align='center'>Guild</td></tr>\n";
my $count = 0;

if(scalar(%players) > 0) {
    foreach my $player (sort keys %players) {
        my $fontcolor;
        if(defined $players{$player}{"gm"}) {
            $fontcolor = '#008f1e';
        } else {
            $fontcolor = '#000000';
        }
        print "<tr><td align='center'><font color='$fontcolor'>$player</font></td><td>$players{$player}{'level'} $players{$player}{'race'} $players{$player}{'class'}</td><td align='center'>$players{$player}{'zone'}</td><td align='center'>$players{$player}{'guild'}</td></tr>\n";
        $count++;
    }
} else {
    print "<tr><td colspan='4'>No players online</tr>";
}
print "</table><br>";
print "$count players online.";
print "</center>";
print "</body></html>\n";


KhaN 04-05-2005 07:15 PM

Thanks Buri, its nice PHP script :)

btw, i seen on KMRA you fixed govtcheese magelo profile for latest EQEmu version, is there any plan to make it public ? :p

Belfedia 04-05-2005 10:05 PM

Don't know perl,
But i have a error :
Global symbol "$li" requires explicit package name at D:/Apache2/cgi-bin/whoson.pl line 41.

Ps: perl is'nt install with telnet features
you need to open Mcpan and install module :) no more error 500 :)

knightz 04-06-2005 02:39 AM

Quote:

Originally Posted by KhaN
btw, i seen on KMRA you fixed govtcheese magelo profile for latest EQEmu version, is there any plan to make it public ? :p

Actually atm, I only stripped out the parts it reads the item information from a custom items table (dont have the import script). I do plan on fixing this (eventually) and will release it at that time.

sdabbs65 04-06-2005 11:50 PM

non computer GURU's INSTALL telnet under Perl.
 
Go to DOS and type .
perl -MCPAN -e shell;

then at the command lilne type
install Net::Telnet::Cisco
you will see about 500 lines then ask you to do some things just keep hitting enter for default.

then you will have telnet installed under perl.

SuedeWorthey 08-08-2005 06:56 AM

No PERL... PHP is the way to go.
 
I don't use PERL, so can someone port this to PHP? I will if I have to but if someone has already done it, please share. :)

mwmdragon 08-08-2005 06:31 PM

php
 
Yeah PHP would be nice ;)

SuedeWorthey 08-09-2005 06:51 AM

Quote:

Originally Posted by mwmdragon
Yeah PHP would be nice ;)

I am working on a port now... Just gotta figure out all the authentication stuff...

sdabbs65 08-11-2005 05:52 AM

telnet
 
Quote:

Originally Posted by SuedeWorthey
I am working on a port now... Just gotta figure out all the authentication stuff...

I heard the telnet feature was disabled years ago...
it may still be in the source somewhere tho <shrug>..

SuedeWorthey 08-11-2005 09:48 AM

Quote:

Originally Posted by sdabbs65
I heard the telnet feature was disabled years ago...
it may still be in the source somewhere tho <shrug>..

Are you talking about in the World.exe or in PHP? I know telnet doesn't exist in PHP, and the wanna-be telnet class I downloaded sucks ass... Yeah, I always have to re-write everything... But it's still enabled in world.

sdabbs65 08-11-2005 03:49 PM

World.exe
 
Quote:

Originally Posted by SuedeWorthey
Are you talking about in the World.exe or in PHP? I know telnet doesn't exist in PHP, and the wanna-be telnet class I downloaded sucks ass... Yeah, I always have to re-write everything... But it's still enabled in world.

Well when I tryed it in World.exe it's in duplex and never works...
password never is acepted...
there is a ppm to download,it seems to work ok for other things.
but never got it to work for this item.

wize_one 08-11-2005 05:25 PM

you have to set a md5 password in your database per user you want to allow telnet to world.. we use it for some of our stuff.. thats what the password field is for in the accounts_ table(if i recall right)

sdabbs65 08-15-2005 07:51 AM

yup
 
Quote:

Originally Posted by wize_one
you have to set a md5 password in your database per user you want to allow telnet to world.. we use it for some of our stuff.. thats what the password field is for in the accounts_ table(if i recall right)

I got the password in and it connects but still refuses to allow log in hmmm.
.. im thinking maybe it's not enabled in command line functions in world.exe
or maybe a value in vars im missing,checking the source now.

back to the lab.

wize_one 08-15-2005 08:02 AM

telnet serverip:9000 login name: LoginserverName password: MD5Password
then,
echo off
acceptmessages on
and you should be at the world shell.. might have to open port 9000

Cisyouc 08-16-2005 12:41 PM

telnet in world does work, for sure.
I have had some trouble in the past with puTTY, don't know why.

sdabbs65 08-18-2005 12:21 AM

y
 
Quote:

Originally Posted by Cisyouc
telnet in world does work, for sure.
I have had some trouble in the past with puTTY, don't know why.

yeah im useing putty...thats probbly the problem.

Magoth78 08-21-2005 01:55 AM

Number of users online, their names and the number, using php.

It's my first Php code so don't be rude if it's extremly ugly, basic.
It will show the name and the amount of the connected characters char.

Code:

<?php


$Server = 'Host.com';
$Port    = 9000;
$user  = "your_user\r";
$pass  = "your_pass\r";           

$fp = fsockopen($Server, $Port);
       
                      fputs ($fp, $user);
                usleep(125000); 
                      fputs ($fp, $pass);
                usleep(125000);
                      fputs ($fp, "who\r");
                usleep(125000);

                          do
                        {
                          $output = fgets($fp);
                          $output = str_replace("Username: Password: Login accepted.", "", $output);
                          $output = str_replace($user">", "", $output);
                          $output = str_replace("who", "", $output);
                          $output = str_replace("Players", "", $output);
                          $output = str_replace("on", "", $output);
                          $output = str_replace("server:", "", $output);
                          $output = str_replace("line", "", $output);
                          $who = preg_replace('#^.*]\s+(.*?)\(.*$#','\1',$output);
                         
                                echo $who;
                                if (preg_match("/Players/i", $who)) {
                                Break;
                                }
                          }
                while(!feof($fp));
                fclose($fp);
?>

Mag

sdabbs65 08-23-2005 01:06 PM

hmmm
 
Quote:

Originally Posted by Magoth78
Number of users online, their names and the number, using php.

It's my first Php code so don't be rude if it's extremly ugly, basic.
It will show the name and the amount of the connected characters char.

Code:

<?php
 
 
$Server = 'Host.com';
$Port = 9000;
$user = "your_user\r";
$pass = "your_pass\r";
 
$fp = fsockopen($Server, $Port);
 
                fputs ($fp, $user);
                usleep(125000);
                fputs ($fp, $pass);
                usleep(125000);
                fputs ($fp, "who\r");
                usleep(125000);
 
                do
                        {
                        $output = fgets($fp);
                        $output = str_replace("Username: Password: Login accepted.", "", $output);
                        $output = str_replace($user">", "", $output);
                        $output = str_replace("who", "", $output);
                        $output = str_replace("Players", "", $output);
                        $output = str_replace("on", "", $output);
$output = str_replace("server:", "", $output);
                        $output = str_replace("line", "", $output);
$who = preg_replace('#^.*]\s+(.*?)\(.*$#','\1',$output);
 
echo $who;
                                if (preg_match("/Players/i", $who)) {
                                Break;
                                }
                        }
                while(!feof($fp));
                fclose($fp);
?>

Mag

All I get is a blank...
error msg says ..
xx.xx.xx.xxx - - [23/Aug/2005:20:32:47 -0400] "GET /who.php HTTP/1.1" 200 -

Magoth78 08-24-2005 03:49 AM

Change this line :

Code:

$output = str_replace($user">", "", $output);
to
Code:

$output = str_replace("your_user>", "", $output);
You just have to edit "your_user".


Mag

sdabbs65 08-25-2005 06:43 AM

hmm
 
Quote:

Originally Posted by Magoth78
Change this line :

Code:

$output = str_replace($user">", "", $output);
to
Code:

$output = str_replace("your_user>", "", $output);
You just have to edit "your_user".


Mag

$output = str_replace("your_user>", "", $output);

when I take out this line I get a return...

sdabbs65> Tailwind Kash Godenex Ydradi 4 players



when it's placed back in I get a empty screen...

Magoth78 08-25-2005 11:08 AM

Ah yeah, if you don't want to have the characters name in the ouput, and just the number of connected players, you should use my simple script:

Code:

<?php

$Server = 'Host.com';
$Port = 9000;
$user = "your_user\r";
$pass = "your_pass\r";

$fp = fsockopen($Server, $Port);
               
                      fputs ($fp, $user);
                //echo("Login Accepted\r\n");
                usleep(125000); 
                      fputs ($fp, $pass);
                usleep(125000);
                //echo("Password Accepted\r\n");
                      fputs ($fp, "who\r");
                usleep(125000);
                //echo("Who launched\r\n");

                       
                              while (!feof($fp))
                        {
                              $ret = fgets($fp, 128);
                                      if  (ereg("players", $ret)){
                                $ret = ereg_replace("players online","",$ret);
                                          echo "$ret \n";
                                        break;
                                        fclose($fp);
                                      }
                               
                        }
?>


Damilis 09-19-2005 07:14 AM

.net equivilent
 
I have ben searching high and low to develop a .net equivlent to the .php scripts floating around the boards... has anyone had any luck getting a vb.net or c#.net app telneting to world.exe?

bleh 09-19-2005 09:55 AM

It's not VB or C#, but for what it's worth, I have a minimal world Java client if you want to look at that.

executable jar: http://home.comcast.net/~moofn/eqadmin.jar
source: http://home.comcast.net/~moofn/eqadminsrc.zip

sdabbs65 09-22-2005 05:04 AM

?
 
Quote:

Originally Posted by bleh
It's not VB or C#, but for what it's worth, I have a minimal world Java client if you want to look at that.

executable jar: http://home.comcast.net/~moofn/eqadmin.jar
source: http://home.comcast.net/~moofn/eqadminsrc.zip

Nice..what did you use to make that ?


All times are GMT -4. The time now is 07:13 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.