AAO25.com
America's Army => General Chat => Topic started by: Spanky 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:
{"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();]
-
Thanks Spank! :style:
-
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?
-
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 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.
-
nice work spank :?
-
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.
-
Updated original post with some ghetto documentation and more stats for the JSON output.
-
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
-
Good job, I hope it's will reach the old players. :up:
-
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:
<?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 :)
-
All good just wanted to make sure , I use twig with autoescape on, very helpful.
-
return values in php:
<?php
function assist_stats(){
$fd = fsockopen( "aao25.com", 80, $errno, $errstr, 30);
if($fd){
fwrite($fd, "GET /stats/json.php HTTP/1.1\r\nHost: aao25.com\r\nConnection: Close\r\n\r\n");
$res=@fread($fd, 1024);
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";
}
?>
-
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
-
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.
-
Also, no crons are running and they haven't been running for some time. All the information is many weeks old.
-
Also, no crons are running and they haven't been running for some time. All the information is many weeks old.
And why dont you enable them again?