Forum

ASSIST, AMERICA'S ARMY COMMUNITY - RELIVE THE GLORY DAYS OF AMERICA'S ARMY 2.5

Author Topic: JSON Statistics for Assist  (Read 50129 times)

0 Members and 1 Guest are viewing this topic.

Offline Spanky

  • <?php echo $opinion .' is better.'; ?>
  • Administrator
  • Posts like a Spanky!
  • *
  • Posts: 10,893
    • View Profile
    • NatesComp.com
  • AA: tigobitties
JSON Statistics for Assist
« on: Monday, September 16, 2013, 18:44:54 PM »
Rapture came to me earlier asking for a way to have the number of players and number of servers passed on to other websites. So, I decided to export the stats from AAO25 into JSON format with some PHP code. Here it is for anyone to use:

http://aao25.com/stats/json.php

Example output:
Code: [Select]
{"players":"73","servers":"83","top server":"{ATAS} - TR - EU - SERVER","auth":"online","auth_time":"1379373722","downloads":"62,488","assist_ver":"7.48","assist_news":"Visit http:\/\/aao25.com for updates.","most_players":"132","most_players_time":"1379270942"}
Per the example above, stats are ordered as follows:
Players In-Game: 73 - [Will not be updated if auth is offline]
Servers Online: 83 - [Will not be updated if auth is offline]
Top Server: {ATAS} - TR - EU - SERVER - [Shows server with the most players, ill not be updated if auth is offline]
Authorization Status: online - [will show 'offline' when auth is down]
Authorization Last Online: 1379373722 - [unix timestamp, CST, -6 UTC, can be converted with PHP date();]
Assist Downloads: 62,488 - [Taken directly from SourceForge]
Assist Version: 7.48
Assist News: Visit http:\/\/aao25.com for updates - [News shown in the Assist client]
Most Players Online Ever: 132
Most Players Online Time: 1379270942 - [The unix timestamp that the 132 players were on, , CST, -6 UTC, can be converted with PHP date();]
« Last Edit: Monday, September 16, 2013, 19:31:31 PM by Spanky »
It's like shaving your pubes to make your junk look bigger.
Might look bigger, but it aint.....

Offline M_TopSecret

  • Jr. Member
  • **
  • Posts: 48
  • Never fly the 'A' model of anything. — Ed Thompson
    • View Profile
    • |M|@fioso Clan
  • AA: |M|TopSecret
Re: JSON Statistics for Assist
« Reply #1 on: Monday, September 16, 2013, 18:49:09 PM »
Thanks Spank!  :style:
Never fly the 'A' model of anything. — Ed Thompson

Offline Spanky

  • <?php echo $opinion .' is better.'; ?>
  • Administrator
  • Posts like a Spanky!
  • *
  • Posts: 10,893
    • View Profile
    • NatesComp.com
  • AA: tigobitties
Re: JSON Statistics for Assist
« Reply #2 on: Monday, September 16, 2013, 18:50:50 PM »
Thanks Spank!  :style:

Would you like the Auth online/offline status as well? No sense displaying # of players if auth is down. The way I have the code here, if auth is down, # of players doesn't get updated so you could return the # of players that was online just before auth was down and that might confuse people. Anything else you could think of?
It's like shaving your pubes to make your junk look bigger.
Might look bigger, but it aint.....

Offline alechko1

  • Full Member
  • ***
  • Posts: 272
    • View Profile
Re: JSON Statistics for Assist
« Reply #3 on: Monday, September 16, 2013, 18:58:01 PM »
I can do interactive charts like that when you can hover with your mouth or press on them to change visualizatopn if you think you can find it a use for it (or if I wont be too lazy working on that)

http://ramnathv.github.io/rCharts/

Offline Spanky

  • <?php echo $opinion .' is better.'; ?>
  • Administrator
  • Posts like a Spanky!
  • *
  • Posts: 10,893
    • View Profile
    • NatesComp.com
  • AA: tigobitties
Re: JSON Statistics for Assist
« Reply #4 on: Monday, September 16, 2013, 19:10:46 PM »
I can do interactive charts like that when you can hover with your mouth or press on them to change visualizatopn if you think you can find it a use for it (or if I wont be too lazy working on that)

http://ramnathv.github.io/rCharts/

I started work on some, got most of my ideas implemented:
http://aao25.com/info#Player_Stats

Since Assist was shut down, I wiped all the stats so there wasn't a gap in the timeline so it may take another week for the other charts to populate.
It's like shaving your pubes to make your junk look bigger.
Might look bigger, but it aint.....

Jared

  • Guest
Re: JSON Statistics for Assist
« Reply #5 on: Monday, September 16, 2013, 19:14:21 PM »
nice work spank  :?

Offline Spanky

  • <?php echo $opinion .' is better.'; ?>
  • Administrator
  • Posts like a Spanky!
  • *
  • Posts: 10,893
    • View Profile
    • NatesComp.com
  • AA: tigobitties
Re: JSON Statistics for Assist
« Reply #6 on: Monday, September 16, 2013, 19:15:47 PM »
nice work spank  :?

Thanks. Auth is added. Values are either online or offline. I know it should probably be true/false but I don't feel like going through all the code and editing it for pretty much no gain.
It's like shaving your pubes to make your junk look bigger.
Might look bigger, but it aint.....

Offline Spanky

  • <?php echo $opinion .' is better.'; ?>
  • Administrator
  • Posts like a Spanky!
  • *
  • Posts: 10,893
    • View Profile
    • NatesComp.com
  • AA: tigobitties
Re: JSON Statistics for Assist
« Reply #7 on: Monday, September 16, 2013, 19:31:50 PM »
Updated original post with some ghetto documentation and more stats for the JSON output.
It's like shaving your pubes to make your junk look bigger.
Might look bigger, but it aint.....

Offline ibad

  • Jr. Member
  • **
  • Posts: 46
    • View Profile
Re: JSON Statistics for Assist
« Reply #8 on: Monday, September 16, 2013, 20:13:17 PM »
you should also note that if youre going to be displaying this information, use htmlentities() to prevent xss /csrf attacks. Unless of course its already filtered from when spanky extracts it. Either way it can't hurt =D
ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็

Offline HANG_JEBAT

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: JSON Statistics for Assist
« Reply #9 on: Monday, September 16, 2013, 21:09:14 PM »
Good job, I hope it's will reach the old players.  :up:

Offline Spanky

  • <?php echo $opinion .' is better.'; ?>
  • Administrator
  • Posts like a Spanky!
  • *
  • Posts: 10,893
    • View Profile
    • NatesComp.com
  • AA: tigobitties
Re: JSON Statistics for Assist
« Reply #10 on: Monday, September 16, 2013, 21:28:46 PM »
you should also note that if youre going to be displaying this information, use htmlentities() to prevent xss /csrf attacks. Unless of course its already filtered from when spanky extracts it. Either way it can't hurt =D

Most of these stats couldn't be altered by outside people unless they hacked into the master server. Players & Servers are calculated by parsing the server list so if that got hijacked, the code would screw up in trying to add the non-numeric text to the tally. Pretty much the only one that could be 'hacked' is the 'top server' and could easily be done by reporting a server to Assist with 40 players, making it the 'top server'. So, the top server text is passed through this:
Code: [Select]
<?php $name htmlspecialchars(preg_replace('/[^(\x20-\x7F)]*/',''urldecode($pieces[4]))); ?>That strips weird characters that gamers come up with, replaces the %20 that Assist uses for spaces and replaces <, >, /, and &. So the output shouldn't harm a website. After running it through that, I also do a mysqli real_escape_string before entering it into the database for this site.

Still, it wouldn't hurt to re-process it on your end just to make 100% sure. I'll be the first to admit, I didn't go to school for this so I'm sure everything I make could be done better and probably isn't 100% secure/safe/efficient :)
It's like shaving your pubes to make your junk look bigger.
Might look bigger, but it aint.....

Offline ibad

  • Jr. Member
  • **
  • Posts: 46
    • View Profile
Re: JSON Statistics for Assist
« Reply #11 on: Monday, September 16, 2013, 21:39:07 PM »
All good just wanted to make sure , I use twig with autoescape on, very helpful.
ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็ส็็็็็็็็็็็็็็ส็็็็็็็็็

Offline 82nd_DXO_COL=Shad

Re: JSON Statistics for Assist
« Reply #12 on: Tuesday, January 14, 2014, 15:04:25 PM »
return values in php:

Code: [Select]
<?php
function assist_stats(){
 
$fd fsockopen"aao25.com"80$errno$errstr30);
 if(
$fd){
  
fwrite($fd"GET /stats/json.php HTTP/1.1\r\nHost: aao25.com\r\nConnection: Close\r\n\r\n");
  
$res=@fread($fd1024);
  
fclose($fd);
 }
 else return 
false;
 if(!empty(
$res)){
  
$startpos=strpos($res,'{');
  
$endpos=strpos($res,'}')+1;
  if(
$startpos && $endpos) {
   
$str=substr($res,$startpos,($endpos-$startpos));
   
$varArr=json_decode($str,true);
   return 
$varArr;
  }
 else return 
false;
 }
 else return 
false;
}

$varArr=assist_stats();
if(
count($varArr)){
 echo 
"players: {$varArr['players']}\n";
 echo 
"servers: {$varArr['servers']}\n";
 echo 
"top server: {$varArr['top server']}\n";
 echo 
"auth: {$varArr['auth']}\n";
 echo 
"auth_time: ".date('r',$varArr['auth_time'])."\n";
 echo 
"downloads: {$varArr['downloads']}\n";
 echo 
"assist_ver: {$varArr['assist_ver']}\n";
 echo 
"assist_news: {$varArr['assist_news']}\n";
 echo 
"most_players: {$varArr['most_players']}\n";
 echo 
"most_players_time: ".date('r',$varArr['most_players_time'])."\n";
}
?>

Offline 82nd_DXO_COL=Shad

Re: JSON Statistics for Assist
« Reply #13 on: Wednesday, January 22, 2014, 08:38:49 AM »
Auth: online Sun, 05 Jan 2014 13:08:01 -0600
Ver: 8.02
Most Players: 199 Sat, 04 Jan 2014 14:57:01 -0600
Assist News:
Happy Hollidays Enjoy your surprise. Visit us at aao25.com

These stats correct?  I thought we were at 8.0.3

Offline ELiZ

Re: JSON Statistics for Assist
« Reply #14 on: Wednesday, January 22, 2014, 08:44:20 AM »
Auth: online Sun, 05 Jan 2014 13:08:01 -0600
Ver: 8.02
Most Players: 199 Sat, 04 Jan 2014 14:57:01 -0600
Assist News:
Happy Hollidays Enjoy your surprise. Visit us at aao25.com

These stats correct?  I thought we were at 8.0.3

I've changed the location of the file so the crons don't updated that information anymore.

 

Download Assist

×

Download Game Client

Important: Battletracker no longer exists. However, old Battletracker accounts may still work. You can create a new 25Assist account here

Download Server Manager