Forum

> > CS2D > General > Stats::Extract [WE'RE THERE!]
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Stats::Extract [WE'RE THERE!]

21 replies
Page
To the start Previous 1 2 Next To the start

Poll Poll

Yay or Nay?

Only registered users are allowed to vote
Yay!
85.00% (17)
Nay!
15.00% (3)
20 votes cast

old Poll Stats::Extract [WE'RE THERE!]

Nekomata
User Off Offline

Quote
IMG:https://i.imgur.com/N0XW5Qz.png


NEWS
Update March 9th, 15
First version of S:E released!




_______________________________________________
"Stats::Extract (or S:E for short) is a data extractor for servers using their website's and want to display some statistics created with PHP." or relatively is what you'd see in a new post depending on the outcome of this poll.

Let's get to that introductory phase where I explain what this actually is. If you're a mass server hoster for CS2D, you might have a website at it which includes forums etc. You'd also want your server statistics displayed directly there, right? For example you'd want to list the top hundred players or perhaps you've got an admin panel built for yourself and you'd like your server statistics to be displayed there and so on. Sounds neat, right?

S:E would be a PHP based library to conclude for these needs. You'd be able to extract statistical information directly with a few calls. It's to be Object Orientated, which would leave the easy parts to you while managing the complex algorithms.

Note that this is just a library, it does not have user interface, no design, nothing. It's just a few functions that you're going to need to call. To make the use of it you're required to have programming knowledge, especially in PHP.

As of now I haven't even started it yet but I've got a successful algorithm made by extracting the top thirty from serverstats.html, however S:E will be directly extracting from sys/stats.

Currently, the only thing I've planned out is that it'll provide you with user data, server data & perhaps graphs as well. Note that I don't know if the graphs part is going to work, yet, but in case it does it'll be a responsive JS Graph I'll be using as an example (values will be provided from the library, you can use your own graphs if you'd like).

Obviously, you'd have to be hosting the website along side your server on the same host to get the stuff. Haven't tested out if links between multiple hosts would work; That is your website would be hosted on another server and your servers on an other, P:E (on your website) would extract the required files as reading them directly from the given valid hyperlink paths.

And as time passes it'll be updated and maintained as well. (Ideas are welcomed!)


Yay or Nay?


Tl;dr Stats::Extract is a PHP library that can be used to extract useful server information if you're hosting a website along with your servers to display there.







F.A.Qs

Why do you want to make this?
I'm bored & of course exp++.

Features?

• User data extraction
• Server data extraction
• Graph value extraction
• Logs! (You'd want to know what went wrong when and where)
• What you heed necessary


How long would this take to develop?
Depends, could take a month. Perhaps less, waaay less, more, waaay more. For all I know, it could take a few days. o.o

When will you start developing this?
When the "yay" is in my favor!

Why're you making a poll for it?
Because if I can make something useful, wouldn't it be better to share it with others that might find it useful? Plus. It'd be in a better format and all.
edited 4×, last 08.03.15 10:57:40 pm

old Re: Stats::Extract [WE'RE THERE!]

Nekomata
User Off Offline

Quote
@user GeoB99: Thank you!

@user MikuAuahDark: That's pretty much the main thing it's supposed to extract. Player rank, usgn, kills, deaths, ratios, etc (most of the information serverstats.html holds)

I may have not clearly elaborated but it the main thing it'll extract is the user ranking information in your server.

old Re: Stats::Extract [WE'RE THERE!]

MikuAuahDark
User Off Offline

Quote
@user Nekomata: No, i mean the userstats.dat file(which contains the whole player rank and not just the 100 top(as far as i remember) player with highest rank), does it extract the player rank from USGN input?

old Re: Stats::Extract [WE'RE THERE!]

Nekomata
User Off Offline

Quote
There will be two types of extraction methods, the top 30 from serverstats.html & from userstats.dat.
Following an algorithm it'll store the values in a multidimensional array. So to call it'd be something like this if you were to call a user's stats.
(an example)

1
2
3
4
echo $user[RANK_NUMBER_HERE]['name'];
echo $user[RANK_NUMBER_HERE]['usgn'];
echo $user[RANK_NUMBER_HERE]['rank'];
echo $user[RANK_NUMBER_HERE]['kpd'];

It'll be extracted the users and storing them and their datas using the array index as ranks (which means it starts from 1)

Here's a general idea of how it'd be. note again, I haven't started on this. It's just the sketch idea
1
2
3
4
5
6
7
8
<?php
$se = new StatExtract; //constructs the class
$se->load_userstats("PATH_TO_FILE"); //loads the file
$se->extract_userstats(); //extracts the data and puts it in an multidimensional array called '$user' by their rank numbers

echo $se->user[1]['name']; //echo ranked 1 player's name
echo $se->user[65]['score']; //echo ranked 65 player's score
?>


Lets say you'd want to go through the names of the top 100 players
1
2
3
for($i=1;$i<=100;$i++){
	echo $se->user[$i]['name'].'<br />';
}

Would be simple as that.

old Re: Stats::Extract [WE'RE THERE!]

Nekomata
User Off Offline

Quote
Playing with bytes is a pain in the ass, so it's a real hassle. I have no idea as of now how to extract the endian format. I'd greatly appreciate your help with it, thanks.

old Re: Stats::Extract [WE'RE THERE!]

MikuAuahDark
User Off Offline

Quote
Here's the PHP script of extracting the user stats.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
function GetUserStatsRank($usgn) {
	$Int=function($f) {
		return ord(fread($f,1))+ord(fread($f,1))*256+ord(fread($f,1))*65536+ord(fread($f,1))*16777216;
	};
	$f=fopen("sys/stats/userstats.dat","rb");
	fseek($f,0,SEEK_END);
	$size=ftell($f);
	fseek($f,17,SEEK_SET);
	$temp=[
		"isexists"=>FALSE,
		"score"=>0,
		"frags"=>0,
		"deaths"=>0,
		"time"=>0,
	];
	while(ftell($f)!=$size) {
		fgets($f);		// skip player name
		$temp_usgn=Int($f);
		if($usgn==$temp_usgn) {
			$temp["isexists"]=TRUE;
			$temp["score"]=$Int($f);
			$temp["frags"]=$Int($f);
			$temp["deaths"]=$Int($f);
			$temp["time"]=$Int($f);
			break;
		} else fseek($f,16,SEEK_CUR);
	}
	fclose($f);
	return $temp;
}

function AllUserStatsByJoinOrder() {
	$Int=function($f) {
		return ord(fread($f,1))+ord(fread($f,1))*256+ord(fread($f,1))*65536+ord(fread($f,1))*16777216;
	};
	$f=fopen("sys/stats/userstats.dat","rb");
	fseek($f,0,SEEK_END);
	$size=ftell($f);
	fseek($f,17,SEEK_SET);
	$temp=[];
	$counter=0;
	while(ftell($f)!=$size) {
		fgets($f);	// skip player name
		$counter++;
		$temp[$counter]=[
			"usgn"=>$Int($f),
			"score"=>$Int($f),
			"frags"=>$Int($f),
			"deaths"=>$Int($f),
			"time"=>$Int($f),
		];
	}
	return $temp;
}

function AllUserStatsByUSGN() {
	$Int=function($f) {
		return ord(fread($f,1))+ord(fread($f,1))*256+ord(fread($f,1))*65536+ord(fread($f,1))*16777216;
	};
	$f=fopen("sys/stats/userstats.dat","rb");
	fseek($f,0,SEEK_END);
	$size=ftell($f);
	fseek($f,17,SEEK_SET);
	$temp=[];
	while(ftell($f)!=$size) {
		fgets($f);	// skip player name
		$temp[$Int($f)]=[
			"score"=>$Int($f),
			"frags"=>$Int($f),
			"deaths"=>$Int($f),
			"time"=>$Int($f),
		];
	}
	return $temp;
}
?>

GetUserStatsRank is a function which get the player rank from USGN(PHP implementation of file cs2d [UNUSED] Get Player Rank v1.4 )
AllUserStatsByJoinOrder is a function which get the player rank in userstats.dat order(key index starts at 1, multi dimensional array)
AllUserStatsByUSGN is a function which same as AllUserStatsByJoinOrder with exception that USGN is the key index instead.

old Re: Stats::Extract [WE'RE THERE!]

Nekomata
User Off Offline

Quote
You saved me from a long struggle, genuinely thanks a lot; the code's very well written as well as efficient. O.O

Check your PM!

The Yay! is in my favour, development will start soon!

old Almost there!

Nekomata
User Off Offline

Quote
IMG:https://i.imgur.com/N0XW5Qz.png


@IchigoBankai, thank you!

@OT; It's almost done, here's the main things that have been completed.
• serverstats.html userdata extraction
• serverstats.html graph value extraction
• userstats.dat userdata extraction
• Logger
• Configuration Parser

Todo;
• Direct USGN server information extraction
• Useful addon Functions
• serverstats.html serverdata extraction
• cleaning da code



Alpha Screenshots! >



user DC, I've got a request! After the release of S.E, I was wondering if you could put it up on the website of cs2d as a must-have asset for server owners. Thanks.


What are the basic call methods?

-Userdata
1
2
3
4
5
6
7
8
9
10
11
require 'stats.extract.php'
$se = new StatsExtract;
$se->load_userdata('userstats.dat');
$se->extract_userdata();
$se->unload_userdata();

// Your values will be stored in an array;
// $se->user

// lets call the name of the player which is ranked 5th
echo $se->user[5]['name'];

-Serverstats!
1
2
3
4
5
6
7
8
9
10
require 'stats.extract.php'
$se->load_html_userdata('serverstats.html');
$se->extract_html_userdata();
$se->extract_html_graph_values();
$se->extract_html_server_data();
$se->unload_html_userdata();

// userdata will be stored in: $se->user
// serverdata in; $se->server
// graph values in; $se->graph

How will I call graph values?
There are 3 values stored in the graph array. Basically a multidimensional array consisting of the main array that's counted as hours (1-23) and 3 values inside it consisting of: "players", "upload", "download" which are floats/decimals.

1
2
3
4
5
// get the information of the first hour
[h1]Hour 1[/h1]
echo "Upload".$se->graph[1]["upload"]."<br/>";
echo "Download".$se->graph[1]["download"]."<br/>";
echo "Players".$se->graph[1]["players"]."<br/>";

Note: All values (userdata & graph) will be indexed in an array from 1, not the usual array 0 indexing.
edited 2×, last 27.02.15 02:54:15 am

old Re: Stats::Extract [WE'RE THERE!]

Nekomata
User Off Offline

Quote
It's bugged(serverstats.html) I'm using one from the fws servers and most of the users there in the top ranking have bugged values for some reason. Some flaw in cs2d or a lua bug, idk.
edited 1×, last 27.02.15 10:03:44 am

old Re: Stats::Extract [WE'RE THERE!]

Nekomata
User Off Offline

Quote
I don't know about that, never really played cs1.6; But if that was a(too lazy to search it) user data/graph data extractor for servers, PHP based as a library, then yes, probably.

old Re: Stats::Extract [WE'RE THERE!]

_Yank
User Off Offline

Quote
I'm not sure wether I should put it here but if you guys want to see a demo, here it is

PS: Don't get me wrong, this is not Stats::Extract only, it is just a page which uses its "engine". In case you don't know, Stats Extract is just a tool, not a web page, it just serves to help your web page getting the server ranking informations.

Also, this is a previous version (I would call it pre-alpha) and it doesn't have the Statistics and these new things yet (I might update it when user Nekomata release it).
edited 3×, last 27.02.15 08:03:36 pm
To the start Previous 1 2 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview