[PHP] Stats:Extract [0.6] 
26 comments
Original Post





The main reason of this update is to make S:E faster as most of the code is refactored in a better way.
Features









Credits











edited 29×, last 20.08.16 08:26:32 am

Comments
26 commentsLog in!
You need to log in to be able to write comments!Log in
09.09.15 01:08:13 pm
ver. 0.2d
Another minor hotfix which fixes another fclose issue in the parse_live_server_info function.
ver. 0.2c
Thank you Lubs, Glix and Dizio. ;0
Just a quick update tho. This version is a stable release. No more bugs. (hopefully)
ver. 0.2b
-Fixed parse_serverstats user ranking bug with time on server and broken sorting.
Another minor hotfix which fixes another fclose issue in the parse_live_server_info function.
ver. 0.2c
Thank you Lubs, Glix and Dizio. ;0
Just a quick update tho. This version is a stable release. No more bugs. (hopefully)
ver. 0.2b
-Fixed parse_serverstats user ranking bug with time on server and broken sorting.
edited 2×, last 14.09.15 08:32:50 am
Thank you
Ajmin ;0
Update: [Quick Fix]. There was an error where file close wasnt called when extracting the serverstats.html. If you had a VPS this resulted in a "too many files open" error. It's patched now and here's a new live demo of S.E 0.2!
http://fwsstatistics.tk

Update: [Quick Fix]. There was an error where file close wasnt called when extracting the serverstats.html. If you had a VPS this resulted in a "too many files open" error. It's patched now and here's a new live demo of S.E 0.2!
http://fwsstatistics.tk

You can add a Lua script to write in stats more information about every player than it is in normal CS2D.
@
oxytamine; Goddit, thanks for the tip! I'll add it in the next update. :3

@
Nekomata:
Just keep them in memory and unload them automatically, wrap it in one function, something like this.
This'll make code much easier & cleaner to use.
About unsetting values - remember, PHP does it for you, all the variables inside function will be free when function finishes work.
If you deal with large arrays, prefer pre-increment since it's about 10% faster and performance matters in scripts like yours. Just keep in mind that $i++ will return new value while ++$i will return old.

Just keep them in memory and unload them automatically, wrap it in one function, something like this.
Code:
1
2
2
$se->parse_userdata();
$se->parse_html_stats();
$se->parse_html_stats();
This'll make code much easier & cleaner to use.
About unsetting values - remember, PHP does it for you, all the variables inside function will be free when function finishes work.
If you deal with large arrays, prefer pre-increment since it's about 10% faster and performance matters in scripts like yours. Just keep in mind that $i++ will return new value while ++$i will return old.
edited 1×, last 11.03.15 11:04:09 am
@
Rainoth, thanks for your opinion and for removing all the crap. Yeahp, I'm pretty well aware it wouldn't be much of a use since the number of VPS server hosters are not that many and most of them probably would not even consider the use of it. I primarily created this because I was already creating it for
_Yank and I thought It'd be a good idea to create a library for public use too, even if the use may not be that much, it would be useful for someone. As it's pretty much restricted.
Less people willing to use it
Requires PHP knowledge
And other minor factors
So it's just here incase someone decides to use it.
@
oxytamine, Thanks for the feedback!
The main process of S:E is made by the general rule of first loading the file at start and then extracting it. I followed the "fopen" procedures for this one. First opening the file, then read/writing to it. I kind of found it better that way imo.
These methods were required before as I loaded the files (userstats.dat and serverstats.html) both in the same variable
But then I realized that It'd be better to create seperate variables for each to play it safe otherwise it would become a muck up for someone somewhere.
Other than that
is used by both userdata & serverstats extraction, and I tend to destruct most variables by returning them to their default states (null).
And I believe I found another bug already. I recently started formatting it like that because It seemed "clean", but I'll stop the urges now.
Yes, I suck at documenting and It's a todo to create a proper documentation for S:E as I didn't have enough time right then.
I'm unsetting it again, just to play the safe side. .__.
As for the post-increment, I guess it's just habit. o.O I'll consider pre-increment from now since
Again, thanks!
I guess quite so.





So it's just here incase someone decides to use it.

@

The main process of S:E is made by the general rule of first loading the file at start and then extracting it. I followed the "fopen" procedures for this one. First opening the file, then read/writing to it. I kind of found it better that way imo.
Code:
1
2
2
$se->unload_html_stats();
$se->unload_userdata();
$se->unload_userdata();
These methods were required before as I loaded the files (userstats.dat and serverstats.html) both in the same variable
Code:
1
2
2
public $file = NULL;
public $file_path = NULL;
public $file_path = NULL;
But then I realized that It'd be better to create seperate variables for each to play it safe otherwise it would become a muck up for someone somewhere.
Other than that
Code:
1
$this->user = array();
is used by both userdata & serverstats extraction, and I tend to destruct most variables by returning them to their default states (null).
Code:
1
2
2
$this->userdata_file = NULL;
$this->userdata_file = NULL;
$this->userdata_file = NULL;
And I believe I found another bug already. I recently started formatting it like that because It seemed "clean", but I'll stop the urges now.

Yes, I suck at documenting and It's a todo to create a proper documentation for S:E as I didn't have enough time right then.
I'm unsetting it again, just to play the safe side. .__.
As for the post-increment, I guess it's just habit. o.O I'll consider pre-increment from now since
Code:
1
$this->entry = 0;
Again, thanks!
Quote:
PHP. PHP programmers never change.
I guess quite so.

edited 1×, last 11.03.15 05:31:11 am
Code:
1
2
2
$se->unload_html_stats();
$se->unload_userdata();
$se->unload_userdata();
Why these methods, why do you even need them? You use OOP but actually whole structure is almost functional.
Code:
1
2
3
4
2
3
4
$this->userdata_file = NULL;
$this->userdata_file = NULL;
$this->html_userdata_file = NULL;
$this->html_userdata_file_path = NULL;
$this->userdata_file = NULL;
$this->html_userdata_file = NULL;
$this->html_userdata_file_path = NULL;
Never ever format your code like this - it's really ugly.
Code:
1
2
3
4
2
3
4
/**
* Logs!
* Log crap & stuff.
*/
* Logs!
* Log crap & stuff.
*/
You do know what phpDocumentator is but you're doing it wrong.
Code:
1
unset($html);
Why? You do understand that it's being unset at the end of function anyway?
Code:
1
$this->entry++;
There is no reason not to use pre-increment.
PHP. PHP programmers never change.
edited 3×, last 10.03.15 11:15:09 pm
Alright, please no more. I've been clicking intensively for past 4 hours (heh
Infinite Rain) and now I got to do it again just because u guys can't act properly.
Allow me to explain how comment section works.
1) If you like the file and you think it's great and doesn't need anything to be better, you can thank the creator or say how useful his file is
2) If you don't like the file, you can also express it, however phrases such as "quite sucks", "sucks" or alike are meaningless and thus not needed. This scaled to the point that you had to call each other assholes and bitches so I've removed this whole mess.
Now, if you've got any PERSONAL GRUDGES you can say them via PRIVATE MESSAGE instead of whining/flaming/w/e here.
If I see you bros misbehaving again, I won't hesitate to punish you. Punish you heavily. Am I clear? Great! Now lets all make up and appreciate the efforts of
Nekomata
@
Nekomata: I think it's a great feature but most people on us.de won't notice this so it's kind of a waste. I personally don't host servers so I cannot say this will be useful for me but I guess it will be useful to some.

Allow me to explain how comment section works.
1) If you like the file and you think it's great and doesn't need anything to be better, you can thank the creator or say how useful his file is
2) If you don't like the file, you can also express it, however phrases such as "quite sucks", "sucks" or alike are meaningless and thus not needed. This scaled to the point that you had to call each other assholes and bitches so I've removed this whole mess.
Now, if you've got any PERSONAL GRUDGES you can say them via PRIVATE MESSAGE instead of whining/flaming/w/e here.
If I see you bros misbehaving again, I won't hesitate to punish you. Punish you heavily. Am I clear? Great! Now lets all make up and appreciate the efforts of

@
