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?

19 (edited by odgs 2020-07-09 10:27:50)

Re: [MISC] PHP Functions (Server Stats)

does this PHP code still works for newer version of teeworlds ? It seems to timeout for me for the latest version (0.7.5).

Update : I think it should not work since the protocol has changed for version 0.7, but does anyone can point me to a documentation as to how to query newer server ?

20

Re: [MISC] PHP Functions (Server Stats)

No, this is for the 0.6 (and 0.5) protocol, not for the 0.7 protocol. In 0.7, tokens were added. There is no proper documentation but you can have a look at heinrich5991's commit messages:

https://github.com/teeworlds/teeworlds/ … 19ac9d215f
https://github.com/teeworlds/teeworlds/ … 1dd9f61d94
https://github.com/teeworlds/teeworlds/ … 553a38e39e

Not Luck, Just Magic.

21

Re: [MISC] PHP Functions (Server Stats)

https://github.com/jxsl13/twapi

a small framework written in the Go programming language to for example fetch server infos.
I would be careful with fetching too much data from all servers.
the more people start fetching all server stats, the more hostess will start to blacklist those people in order to avoid getting flooded with such server info requests.

Teeworlds [ friends ] clan
Some YouTube Stuff about Teeworlds