Obtaining IP addresses and other non-web related data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TheOracle
Forum Commoner
Posts: 64
Joined: Mon Nov 22, 2004 4:56 am
Location: Bedford, UK

Obtaining IP addresses and other non-web related data

Post by TheOracle »

Hi All,

I have recently set-up a games hosting comapny as an extension to my web-design/hosting one.

Although there are some 'ok' control panels out there for starting/stopping services, I would like to build my own custom one to fit in with the rest of my site.

However, I am at a loss as to how to obtain things like Microsoft Services, or player IP addresses through PHP. Can anyone point me in the right direction?

Also, how could I create or use those IP addresses in order to then stop those people connecting to the server, depending on certain criteria.

I am happy doing the coding but am just not sure what existing variables would come in handy.

Any help would be much appreciated.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

$HTTP_SERVER_VARS["REMOTE_ADDR"];

that gets the users ip address.
im not sure what you mean when stop the users from doing somthing depending on somthing else but you can save a log of the users ip when the login (if they are using a username and password) in a db so you have their most recently used ip on file then you can match the one you get when they connect to the most recently used one but i dont know what you are really trying to do so thats the most start i can offer.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I know most game servers keep logs of all their stats such as

1) player name
2) time online
3) kills/deaths/etc.
4) IP address

and many more.

Your existing control panels probably use SSH to issue commands to the server to tell it to restart or whatever, but your logs are most likely what you are after.

to get the logs, you are probably going to need ftp access to the server

http://www.php.net/ftp - connect to the server
http://www.php.net/file_get_contents - get files as a string
http://www.php.net/preg_match - grab data from string (probably need some help using this one though)

should be usefull


to get you started
TheOracle
Forum Commoner
Posts: 64
Joined: Mon Nov 22, 2004 4:56 am
Location: Bedford, UK

Post by TheOracle »

thx for your input guys.

On another note, how would I go about starting or stopping a windows service through a web panel. Would I need to get it to execute a batch file? If so, how can this be acheived?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

issue a networking command to them: 'net start <servicename>' or 'net stop <servicename>'

Those must be issued on the machine in question. ...Although most game servers are unix based in my experience..
Post Reply