BF3 online stats block

Post Reply

Topic author
DND
Active Member
Posts: 3
Joined: 21. May 2013 14:00

BF3 online stats block

Post by DND »

Your Portal Version: 2.0.1
Your phpBB Type: Standard phpBB3
MODs installed: Yes
Your knowledge: Beginner

What have you done before the problem was there?


What have you already tryed to solve the problem?


Description and Message
what I am trying to do is add a Battlefield 3 Online Stats block like the one on this vBulletin forum http://www.global-gamers.net/
I have the same PHP file as they have used on that site, the code from that file is below

Code: Select all

<?php
// Run POST Request via CURL
$c=curl_init('http://api.bf3stats.com/global/onlinestats/');
curl_setopt($c,CURLOPT_HEADER,false);
curl_setopt($c,CURLOPT_POST,true);
curl_setopt($c,CURLOPT_USERAGENT,'BF3StatsAPI/0.1');
curl_setopt($c,CURLOPT_HTTPHEADER,array('Expect:'));
curl_setopt($c,CURLOPT_RETURNTRANSFER,true);
curl_setopt($c,CURLOPT_POSTFIELDS,$postdata);
$data=curl_exec($c);
$statuscode=curl_getinfo($c,CURLINFO_HTTP_CODE);
curl_close($c);
if($statuscode==200){
// Decode JSON Data
$data=json_decode($data,true);
$html_out = '<table>';
if (isset($data['pc'])){ $html_out .= '<tr><td align="right" style="color:#EFEFEF;font-weight:bold;">PC Players: </td> <td style="color:#FF9900;font-weight:bold;">'.number_format($data['pc']).'</td></tr>'; }
if (isset($data['ps3'])){ $html_out .= '<tr><td align="right" style="color:#EFEFEF;font-weight:bold;">PS3 Players: </td> <td style="color:#FF9900;font-weight:bold;">'.number_format($data['ps3']).'</td></tr>'; }
if (isset($data['360'])){ $html_out .= '<tr><td align="right" style="color:#EFEFEF;font-weight:bold;">XBox360 Players: </td> <td style="color:#FF9900;font-weight:bold;">'.number_format($data['360']).'</td></tr>'; }
$html_out .= '</table>';
echo $html_out;
}else{
echo "BF3 Stats API error status: ".$statuscode;
}
?>
Is there a way to get this to work in a Board3 Portal block ?[/i]
User avatar

Kirk
Dev
Posts: 1956
Joined: 27. July 2010 18:02
phpBB.de User: Kirk
Contact:

Re: BF3 online stats block

Post by Kirk »

You must create a new module.
Look at this guide: How to edit a module file
Gruß Udo

Topic author
DND
Active Member
Posts: 3
Joined: 21. May 2013 14:00

Re: BF3 online stats block

Post by DND »

Thanx mate but that link just opens a reply page to this topic
User avatar

Kirk
Dev
Posts: 1956
Joined: 27. July 2010 18:02
phpBB.de User: Kirk
Contact:

Re: BF3 online stats block

Post by Kirk »

Sorry, I've corrected the link, Thanks for the note. :)
Gruß Udo

Topic author
DND
Active Member
Posts: 3
Joined: 21. May 2013 14:00

Re: BF3 online stats block

Post by DND »

thanks again,,

I'm following the "How to edit a module file" but I'm not sure where I need to add the code from my first post into it,
User avatar

Kirk
Dev
Posts: 1956
Joined: 27. July 2010 18:02
phpBB.de User: Kirk
Contact:

Re: BF3 online stats block

Post by Kirk »

As an example portal_custom.php
Paste your code after global $ config, $ template, $ portal_config, $ user, without a <?php at the beginning and without ?> At the end, this is already predetermined.
Note, this guidance: How to create a module zip for Board3 Portal
Gruß Udo
Post Reply

Return to “Modification Requests”