1 (edited by Niki49 2014-01-22 23:35:23)

Topic: [MISC] PHP Functions (Server Stats)

Hello,

I would like to present some PHP-Functions of a friend. He just gave me the following text, so here are the functions:

- Get information from 0.6 Servers
FunctionExample

- Get information from 0.5.x Servers
FunctionExample

- Get information from Master Server (New Packet)
FunctionExample

- Get information from Master Server (Old Packet)
FunctionExample


Changelog:
02.08.2011

- Updated countryflags for 0.6.1

2

Re: [MISC] PHP Functions (Server Stats)

Good work smile

Getting servers from 0.6 masters isn't much different:
Request with: 10*"\x00" + "req2"
Response: 10*"\x00" + "lis2" followed by Server entries of 18 bytes consisting of:
a 16 Byte/128 Bit IPv6 address (IPv4 addresses are mapped like this ::ffff:127.0.0.1) and the Port. Please keep in mind the port is in network byte order (MSByte first; was little endian prior to 0.6 by mistake).

You can also request the server count from the master: cou2 is the keyword, gives you a unsigned short.
Example: http://teeworlds.mnus.de/

Edit:
instead of

if ($response{$i} == "\00") // IPv4

do

if(substr($response, $i, 12) == str_repeat("\x00", 10)."\xff\xff")

And for IP address unpacking you can use inet_ntop

3

Re: [MISC] PHP Functions (Server Stats)

Updated.

4

Re: [MISC] PHP Functions (Server Stats)

#Updated with "inet_ntop"

And thank you m!nus smile

5

Re: [MISC] PHP Functions (Server Stats)

For what these commands php are necessary?

6

Re: [MISC] PHP Functions (Server Stats)

Skorpion wrote:

For what these commands php are necessary?

Can be used on http://kottnet.net/teeworlds_servers, for instance.

7

Re: [MISC] PHP Functions (Server Stats)

wow, very nice statistics for tw server 0.6v, but how install this?

8

Re: [MISC] PHP Functions (Server Stats)

Just download the example and replace "localhost:8303" or "starlex.de:8303" with your server.
Then upload it to a webhoster which allows "socks" to use.

9

Re: [MISC] PHP Functions (Server Stats)

sl, sry, but i don't understand you =\ where i need write this code to my site? CSS? or no?

10 (edited by Kottizen 2011-04-26 13:05:14)

Re: [MISC] PHP Functions (Server Stats)

Skorpion wrote:

wow, very nice statistics for tw server 0.6v, but how install this?

When the tool is stable enough I'll add a button for requesting statistics on other servers too.

Skorpion wrote:

sl, sry, but i don't understand you =\ where i need write this code to my site? CSS? or no?

In a .php file.

11

Re: [MISC] PHP Functions (Server Stats)

In a .php file.

aa, ok. but i have two codes, Function and Example, what?

12

Re: [MISC] PHP Functions (Server Stats)

Put them in the same .php file. The function should be above the example.

13

Re: [MISC] PHP Functions (Server Stats)

Kottizen wrote:

Put them in the same .php file. The function should be above the example.

Actually just leave it be if you have no idea of PHP.

14

Re: [MISC] PHP Functions (Server Stats)

Niki49, why the Example don't have Team function Blue team and Red team, but have Spectators and Game?

15

Re: [MISC] PHP Functions (Server Stats)

Skorpion wrote:

Niki49, why the Example don't have Team function Blue team and Red team, but have Spectators and Game?

Because it's not sent by the server.

16 (edited by UnoSkorpion 2013-04-24 13:31:19)

Re: [MISC] PHP Functions (Server Stats)

Updated.
Guys, this function require special opened UDP protocols? Or it get info from server without connecting?

uop.

17

Re: [MISC] PHP Functions (Server Stats)

UnoSkorpion wrote:

Updated.
Guys, this function require special opened UDP protocols? Or it get info from server without connecting?

uop.

Need open UPD sockets.

18

Re: [MISC] PHP Functions (Server Stats)

Hokay, what are sockets needed?