TinyPortal

Development => Block Codes => Topic started by: knight111 on August 20, 2006, 06:26:53 PM

Title: Americas army server block help
Post by: knight111 on August 20, 2006, 06:26:53 PM
I have just switch from PHPnuke to the SMF 1.1 RC2 and really like it ... the only things i miss on the nuke are the Donations block and the server scroller ... here is my old site that has both for and Example:   http://acesarmy.com/main/modules.php?name=Forums

they are both setup on the left side now because the site is closed and if u hit HOME it takes u to the new site.

now mainly i am looking to get the Server scroller block goin on the new one and need help .... not sure if anyone has coded it or not ... i have searched and found a few things but i really like this block ... you can download the block at Forward observer found here

http://www.forwardobserver.us/modules.php?name=Downloads&d_op=getit&lid=25

if there is anything anyone knows about this i would really apreciate it ... love The TP block setup by the way ... very clean ... great job all

[Hairy Working America Army Server block code can be found here, Also check links in that post for updates
http://www.tinyportal.net/index.php/topic,7628.msg220631.html#msg220631    ]
Title: Re: Americas army server block help
Post by: G6Cad on August 20, 2006, 06:34:37 PM
Im pretty sure that some of the coders here will give you a hand with the army block code snippet.

Also i have seen some diffrent block code snippets for diffrent donation blocks for TP.

I will move this thread to block code and snippets board.
Title: Re: Americas army server block help
Post by: knight111 on August 20, 2006, 07:16:22 PM
thx a ton wasnt sure on where to post :) will be awaiting help

thx again
Title: Re: Americas army server block help
Post by: IchBin on August 20, 2006, 09:46:37 PM
If you can give me your IP and Port I can test this to see if I can get it to work.
Title: Re: Americas army server block help
Post by: Thurnok on August 21, 2006, 01:11:16 AM
Here you go!

Place the attached files somewhere on your server.  Next, put the following code into a phpblock:

//////////////////////////////////////////////
// America's Army Server Info Block
// based on the PHP Nuke block designed by DivideByZero
//
// Redesigned and converted by Ken McNicholas for TinyPortal block
// Complete Computer Services
// August 20, 2006
//
// TinyPortal 0.86 with SMF 1.1 RC2
//
// The America's Army Server Info Block displays current players
// on a particular America's Army server.
// Set up the configuration info for the server you wish to query
//
//////////////////////////////////////////////

/*
****************************************
****************************************
*** !! User Configuration Section !! ***
****************************************
****************************************
*/

// Server IP you want to query
$aa_ip = '8.6.76.34';
// Server Name
$aa_server_name = 'aces server';
$aa_server_url = 'http://www.forwardobserver.us/browser/foserverlist.php?ServerIP=';
$aa_lookup_server = 'http://www.aa-mbs.com/serverlookup.php?ip=' . $aa_ip . ':1716';

// Server Port - 1717 = default
$aa_port = '1717';

// URL to where you put the folder containing the map pics (include a trailing slash!)
$aa_image_path = 'http://www.yourdomain.com/pathtoimages/';

// You should only need to change the map array if maps
// are added/deleted/changed, otherwise leave as is
$map = array("Bridge Crossing" => "Bridge.jpg",
"Bridge SE" => "Bridge SE.jpg",
"Collapsed Tunnel" => "Tunnel-d.jpg",
"FLS Assault" => "FLS-b.jpg",
"Headquarters Raid" => "HQ_Raid.jpg",
"Insurgent Camp" => "Insurgent_Camp-c.jpg",
"JRTC Farm Raid" => "JRTC_Farm.jpg",
"Mountain Ambush" => "Mountain_Ambush-b.jpg",
"Mountain Pass" => "Mountain_Pass.jpg",
"Mountain Pass SE" => "Mountain Pass SE.jpg",
"Mout McKenna" => "MOUT_McKenna.jpg",
"Pipeline" => "Pipeline-b.jpg",
"Pipeline SF" => "Pipeline.jpg",
"Radio Tower" => "Radio_Tower.jpg",
"River Basin" => "River_Basin-c.jpg",
"SF Oasis" => "sf_oasis.jpg",
"SF Taiga" => "sf_taiga.jpg",
"SF Blizzard" => "sf_blizzard.jpg",
"SF Courtyard" => "sf_courtyard.jpg",
"SF PCR" => "sf_pcr.jpg",
"SF Water Treatment" => "sf_water_treatment.jpg",
"SF Arctic" => "sfarctic.jpg",
"SF Village" => "sfvillage.jpg",
"SF CSAR" => "sf_csar.jpg",
"SF Hospital" => "sf_hospital.jpg",
"SF Recon" => "sf_recon.jpg",
"SF SandStorm" => "sf_sandstorm.jpg",
"Swamp Raid" => "Swamp_Raid-a.jpg",
"Weapons Cache" => "Weapons_Cache-d.jpg",
"Weapons Cache SE" => "Weapons_Cache-a.jpg",
"Woodland Outpost" => "woodland_outpost.jpg",
"Urban Assault" => "urban_assault.jpg");

/*
****************************************
****************************************
*/

//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////

// query server for game info
$aa_sock = fsockopen( "udp://" . $aa_ip, $aa_port);
if($aa_sock != false){
socket_set_timeout($aa_sock, 0, 500000);
fwrite($aa_sock, "\\info\\");
$aa_info = @fread($aa_sock, 8192);
fclose($aa_sock);
}

// create array to hold game info
$aa_infoarr = explode("\\", $aa_info);
$aa_info = array();
$aa_infosize = count($aa_infoarr);
// since first element is unused (element 0) start at element 1
// and populate an associative array (nicer, and easier!)
for ($i = 1; $i < $aa_infosize; $i += 2){
$aa_info[$aa_infoarr[$i]] = $aa_infoarr[$i+1];
}

// get player list
$players = "";
$p = 1;
for ($i = 0; $i < $aa_info['numplayers']; $i++){
$players .= $p . ' - ' . $aa_info['player_' . $i] . '<br />';
$p++;
}

// display info
// Host name and link to detail from FO Online Server Browser
echo '<a href="' . $aa_server_url . $aa_ip . '">' . $aa_info['hostname'] . "</a><br />";
//IP:Port address
echo 'IP: ' . $aa_ip . ':' . $aa_port . '<br />';
// Map Name
echo 'Map: ' . $aa_info['mapname'] . '<br />';
// Players / Max Players
echo 'Players: ' . $aa_info['numplayers'] . '/' . $aa_info['maxplayers'] . '<br />';
// Round
echo 'Round: ' . $aa_info['current_round'] . '<br />';
//Mission Time
echo 'Time: ' . $aa_info['mission_time'] . '<br />';

$mappic = "";
if (array_key_exists($aa_info['mapname'], $map)){
echo '<img src="' . $aa_image_path . $map[$aa_info['mapname']] . '"><br />';
} else {
echo 'Map Unavailable!<br />';
}
echo '<a href="' . $aa_lookup_server . '">* Server Intel *</a><br />';
echo '<a href="aao://' . $aa_ip . '"><img src="' . $aa_image_path . 'joinserver.gif" border="0" alt="Join Server!!"></a><br />';
echo 'Current Players:<br />';
echo '<a name="scrollingCode"></a>';
// display scrolling player list
echo '<marquee behavior="scroll" align="left" direction="up" height="80" width="90%" scrollamount="2" scrolldelay="100" bgcolor="232323"
loop="infinite" onmouseover="this.stop()" onmouseout="this.start()">';
echo '<a href="' . $aa_lookup_server . '">' . $players . '</a></marquee>';


Next, configure the code above for your information.  I don't know if there are other servers you can grab the info from, but you will definately need to set the $aa_image_path variable to the URL you can get to the images you place on your server.

NOTE: Your Host provider must allow the fsockopen() php function on your server otherwise you will get no data.  Not all Host providers allow this function.  Talk to your Host provider about allowing it if they do not already.
Title: Re: Americas army server block help
Post by: knight111 on August 21, 2006, 02:45:48 AM
Awsome mate ... works great .... thx very very much .... if by chance u happen to get the DONATIONS block for paypal like my old site ... would bow down before you even more :) lol thx again
Title: Re: Americas army server block help
Post by: G6Cad on August 21, 2006, 08:21:50 AM
Thank you for this Turnok :)
I knew you could pull it off :)
Title: Re: Americas army server block help
Post by: rbh on August 21, 2006, 04:17:16 PM
here is an smf donation mod. it is in beta yet, but a lot of people are using it with success

http://mods.simplemachines.org/index.php?mod=413
Title: Re: Americas army server block help
Post by: knight111 on August 21, 2006, 04:25:03 PM
yeah i have that one installed ... the only thing is it doesnt show like the donations does in my old Nuke forum ... was just wondering if anyone had coded it like Thurnok  so graciously did with the server scroller block

thx
Title: Re: Americas army server block help
Post by: IchBin on August 21, 2006, 04:28:40 PM
You have a link to that mod Knight111? I couldn't seem to find a download for it that worked.
Title: Re: Americas army server block help
Post by: knight111 on August 21, 2006, 06:13:48 PM
for the donations block ... yeah sure give me a few to find it ... and ill upload and link it
Title: Re: Americas army server block help
Post by: knight111 on August 21, 2006, 06:17:30 PM
ok here it is ... it called Nuke treasury

http://acesarmy.com/main/downloads/NukeTreasury.zip

hope this helps ... need anything else ... just shout
Title: Re: Americas army server block help
Post by: Thurnok on August 21, 2006, 08:04:03 PM
Quote from: Mrs G6 on August 21, 2006, 08:21:50 AM
Thank you for this Turnok :)
I knew you could pull it off :)

No problem G6.  Not sure what prompted you to send that one to me, but you can anytime.  :)

I see Ich is already looking into the other one so I'll leave that one to him.  Instead I think I'll enhance the AA server block.  Since all the info is transfered as part of the socket functions, I think I'll make a link that pops up the info in a table for the rest of the information it passes.
Title: Re: Americas army server block help
Post by: G6Cad on August 21, 2006, 09:35:05 PM
I have seen what you have done so far in here, and you seem to like being at service with those kind of things, so thats the reason i thought you might pull it off for him and others that want to use it in SMF and TP :)

Again thanks for helping us here :)
Title: Re: Americas army server block help
Post by: knight111 on August 21, 2006, 11:54:25 PM
ok the Server scroller i link for ya was the right one but didnt have the 4 newest maps ... so i added the code and maps into it so here is the code with the added 4 .... and ill zip the map pack for ya ... just incase u want to pass it around or if anyone asks that way they have all maps working ... thx again .. its working great

4 maps added were



Border
Dusk
SF Dockside
SF Extraction


//////////////////////////////////////////////
// America's Army Server Info Block
// based on the PHP Nuke block designed by DivideByZero
//
// Redesigned and converted by Ken McNicholas for TinyPortal block
// Complete Computer Services
// August 20, 2006
//
// TinyPortal 0.86 with SMF 1.1 RC2
//
// The America's Army Server Info Block displays current players
// on a particular America's Army server.
// Set up the configuration info for the server you wish to query
//
//////////////////////////////////////////////

/*
****************************************
****************************************
*** !! User Configuration Section !! ***
****************************************
****************************************
*/

// Server IP you want to query
$aa_ip = '8.6.76.34';
// Server Name
$aa_server_name = 'aces server';
$aa_server_url = 'http://www.forwardobserver.us/browser/foserverlist.php?ServerIP=';
$aa_lookup_server = 'http://www.aa-mbs.com/serverlookup.php?ip=' . $aa_ip . ':1716';

// Server Port - 1717 = default
$aa_port = '1717';

// URL to where you put the folder containing the map pics (include a trailing slash!)
$aa_image_path = 'http://www.acesarmy.com/forum/server/armygame/';

// You should only need to change the map array if maps
// are added/deleted/changed, otherwise leave as is
$map = array("Bridge Crossing" => "Bridge.jpg",
"Bridge SE" => "Bridge SE.jpg",
"Border" => "Border.jpg",
"Collapsed Tunnel" => "Tunnel-d.jpg",
"Dusk" => "Dusk.jpg",
"FLS Assault" => "FLS-b.jpg",
"Headquarters Raid" => "HQ_Raid.jpg",
"Insurgent Camp" => "Insurgent_Camp-c.jpg",
"JRTC Farm Raid" => "JRTC_Farm.jpg",
"Mountain Ambush" => "Mountain_Ambush-b.jpg",
"Mountain Pass" => "Mountain_Pass.jpg",
"Mountain Pass SE" => "Mountain Pass SE.jpg",
"Mout McKenna" => "MOUT_McKenna.jpg",
"Pipeline" => "Pipeline-b.jpg",
"Pipeline SF" => "Pipeline.jpg",
"Radio Tower" => "Radio_Tower.jpg",
"River Basin" => "River_Basin-c.jpg",
"SF Oasis" => "sf_oasis.jpg",
"SF Taiga" => "sf_taiga.jpg",
"SF Blizzard" => "sf_blizzard.jpg",
"SF Courtyard" => "sf_courtyard.jpg",
"SF Dockside" => "SFdockside.jpg",
"SF Extraction" => "SFextraction.jpg",
"SF PCR" => "sf_pcr.jpg",
"SF Water Treatment" => "sf_water_treatment.jpg",
"SF Arctic" => "sfarctic.jpg",
"SF Village" => "sfvillage.jpg",
"SF CSAR" => "sf_csar.jpg",
"SF Hospital" => "sf_hospital.jpg",
"SF Recon" => "sf_recon.jpg",
"SF SandStorm" => "sf_sandstorm.jpg",
"Swamp Raid" => "Swamp_Raid-a.jpg",
"Weapons Cache" => "Weapons_Cache-d.jpg",
"Weapons Cache SE" => "Weapons_Cache-a.jpg",
"Woodland Outpost" => "woodland_outpost.jpg",
"Urban Assault" => "urban_assault.jpg");
                                   
/*
****************************************
****************************************
*/

//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////

// query server for game info
$aa_sock = fsockopen( "udp://" . $aa_ip, $aa_port);
if($aa_sock != false){
socket_set_timeout($aa_sock, 0, 500000);
fwrite($aa_sock, "\\info\\");
$aa_info = @fread($aa_sock, 8192);
fclose($aa_sock);
}

// create array to hold game info
$aa_infoarr = explode("\\", $aa_info);
$aa_info = array();
$aa_infosize = count($aa_infoarr);
// since first element is unused (element 0) start at element 1
// and populate an associative array (nicer, and easier!)
for ($i = 1; $i < $aa_infosize; $i += 2){
$aa_info[$aa_infoarr[$i]] = $aa_infoarr[$i+1];
}

// get player list
$players = "";
$p = 1;
for ($i = 0; $i < $aa_info['numplayers']; $i++){
$players .= $p . ' - ' . $aa_info['player_' . $i] . '<br />';
$p++;
}

// display info
// Host name and link to detail from FO Online Server Browser
echo '<a href="' . $aa_server_url . $aa_ip . '">' . $aa_info['hostname'] . "</a><br />";
//IP:Port address
echo 'IP: ' . $aa_ip . ':' . $aa_port . '<br />';
// Map Name
echo 'Map: ' . $aa_info['mapname'] . '<br />';
// Players / Max Players
echo 'Players: ' . $aa_info['numplayers'] . '/' . $aa_info['maxplayers'] . '<br />';
// Round
echo 'Round: ' . $aa_info['current_round'] . '<br />';
//Mission Time
echo 'Time: ' . $aa_info['mission_time'] . '<br />';

$mappic = "";
if (array_key_exists($aa_info['mapname'], $map)){
echo '<img src="' . $aa_image_path . $map[$aa_info['mapname']] . '"><br />';
} else {
echo 'Map Unavailable!<br />';
}
echo '<a href="' . $aa_lookup_server . '">* Server Intel *</a><br />';
echo '<a href="aao://' . $aa_ip . '"><img src="' . $aa_image_path . 'joinserver.gif" border="0" alt="Join Server!!"></a><br />';
echo 'Current Players:<br />';
echo '<a name="scrollingCode"></a>';
// display scrolling player list
echo '<marquee behavior="scroll" align="left" direction="up" height="80" width="90%" scrollamount="2" scrolldelay="100" bgcolor="232323"
loop="infinite" onmouseover="this.stop()" onmouseout="this.start()">';
echo '<a href="' . $aa_lookup_server . '">' . $players . '</a></marquee>';
Title: Re: Americas army server block help
Post by: Thurnok on August 22, 2006, 12:41:21 AM
Thanks.  Yes, I try to keep all the necessary files with any project, so definately a good thing to have!  Thanks Knight!
Title: Re: Americas army server block help
Post by: mebymyself on October 19, 2006, 11:01:13 PM
Hi Thurnok,

I installed this on my site - worked like charm!
Thank you a lot for great code.

I have one little issue
when server name contains color codes those codes are not shown correctly (which make perfect sence)
The color code is 4byte code with first byte - is escape code chr(27) or chr(&H1B)   and other 3 is hex RGB values
ex. 1BFFFF66

I tried to remve this code but due to lack of PHP knoladge end up with this code (which is not working)


$in_str=chr(27) . 'ÃÆ'Ã,¿ÃÆ'Ã,¿fSAMPLE Server name';

$out_str='';

echo $in_str;

for ($i = 1; $i <= strlen($in_str); $i++) {

if $in_str{$i}==chr(27)
{

$i = $i + 4;
}

else
{
$out_str .= $in_str{$i};

}

};

echo $out_str;



can you fix it and maybe update your code so it shows server name "colorless"?
Title: Re: Americas army server block help
Post by: insanemustang on October 20, 2006, 06:42:28 AM
Quote from: Thurnok on August 21, 2006, 01:11:16 AM
Here you go!

Place the attached files somewhere on your server.  Next, put the following code into a phpblock:

//////////////////////////////////////////////
// America's Army Server Info Block
// based on the PHP Nuke block designed by DivideByZero
//
// Redesigned and converted by Ken McNicholas for TinyPortal block
// Complete Computer Services
// August 20, 2006
//
// TinyPortal 0.86 with SMF 1.1 RC2
//
// The America's Army Server Info Block displays current players
// on a particular America's Army server.
// Set up the configuration info for the server you wish to query
//
//////////////////////////////////////////////

/*
****************************************
****************************************
*** !! User Configuration Section !! ***
****************************************
****************************************
*/

// Server IP you want to query
$aa_ip = '8.6.76.34';
// Server Name
$aa_server_name = 'aces server';
$aa_server_url = 'http://www.forwardobserver.us/browser/foserverlist.php?ServerIP=';
$aa_lookup_server = 'http://www.aa-mbs.com/serverlookup.php?ip=' . $aa_ip . ':1716';

// Server Port - 1717 = default
$aa_port = '1717';

// URL to where you put the folder containing the map pics (include a trailing slash!)
$aa_image_path = 'http://www.yourdomain.com/pathtoimages/';

// You should only need to change the map array if maps
// are added/deleted/changed, otherwise leave as is
$map = array("Bridge Crossing" => "Bridge.jpg",
"Bridge SE" => "Bridge SE.jpg",
"Collapsed Tunnel" => "Tunnel-d.jpg",
"FLS Assault" => "FLS-b.jpg",
"Headquarters Raid" => "HQ_Raid.jpg",
"Insurgent Camp" => "Insurgent_Camp-c.jpg",
"JRTC Farm Raid" => "JRTC_Farm.jpg",
"Mountain Ambush" => "Mountain_Ambush-b.jpg",
"Mountain Pass" => "Mountain_Pass.jpg",
"Mountain Pass SE" => "Mountain Pass SE.jpg",
"Mout McKenna" => "MOUT_McKenna.jpg",
"Pipeline" => "Pipeline-b.jpg",
"Pipeline SF" => "Pipeline.jpg",
"Radio Tower" => "Radio_Tower.jpg",
"River Basin" => "River_Basin-c.jpg",
"SF Oasis" => "sf_oasis.jpg",
"SF Taiga" => "sf_taiga.jpg",
"SF Blizzard" => "sf_blizzard.jpg",
"SF Courtyard" => "sf_courtyard.jpg",
"SF PCR" => "sf_pcr.jpg",
"SF Water Treatment" => "sf_water_treatment.jpg",
"SF Arctic" => "sfarctic.jpg",
"SF Village" => "sfvillage.jpg",
"SF CSAR" => "sf_csar.jpg",
"SF Hospital" => "sf_hospital.jpg",
"SF Recon" => "sf_recon.jpg",
"SF SandStorm" => "sf_sandstorm.jpg",
"Swamp Raid" => "Swamp_Raid-a.jpg",
"Weapons Cache" => "Weapons_Cache-d.jpg",
"Weapons Cache SE" => "Weapons_Cache-a.jpg",
"Woodland Outpost" => "woodland_outpost.jpg",
"Urban Assault" => "urban_assault.jpg");

/*
****************************************
****************************************
*/

//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////

// query server for game info
$aa_sock = fsockopen( "udp://" . $aa_ip, $aa_port);
if($aa_sock != false){
socket_set_timeout($aa_sock, 0, 500000);
fwrite($aa_sock, "\\info\\");
$aa_info = @fread($aa_sock, 8192);
fclose($aa_sock);
}

// create array to hold game info
$aa_infoarr = explode("\\", $aa_info);
$aa_info = array();
$aa_infosize = count($aa_infoarr);
// since first element is unused (element 0) start at element 1
// and populate an associative array (nicer, and easier!)
for ($i = 1; $i < $aa_infosize; $i += 2){
$aa_info[$aa_infoarr[$i]] = $aa_infoarr[$i+1];
}

// get player list
$players = "";
$p = 1;
for ($i = 0; $i < $aa_info['numplayers']; $i++){
$players .= $p . ' - ' . $aa_info['player_' . $i] . '<br />';
$p++;
}

// display info
// Host name and link to detail from FO Online Server Browser
echo '<a href="' . $aa_server_url . $aa_ip . '">' . $aa_info['hostname'] . "</a><br />";
//IP:Port address
echo 'IP: ' . $aa_ip . ':' . $aa_port . '<br />';
// Map Name
echo 'Map: ' . $aa_info['mapname'] . '<br />';
// Players / Max Players
echo 'Players: ' . $aa_info['numplayers'] . '/' . $aa_info['maxplayers'] . '<br />';
// Round
echo 'Round: ' . $aa_info['current_round'] . '<br />';
//Mission Time
echo 'Time: ' . $aa_info['mission_time'] . '<br />';

$mappic = "";
if (array_key_exists($aa_info['mapname'], $map)){
echo '<img src="' . $aa_image_path . $map[$aa_info['mapname']] . '"><br />';
} else {
echo 'Map Unavailable!<br />';
}
echo '<a href="' . $aa_lookup_server . '">* Server Intel *</a><br />';
echo '<a href="aao://' . $aa_ip . '"><img src="' . $aa_image_path . 'joinserver.gif" border="0" alt="Join Server!!"></a><br />';
echo 'Current Players:<br />';
echo '<a name="scrollingCode"></a>';
// display scrolling player list
echo '<marquee behavior="scroll" align="left" direction="up" height="80" width="90%" scrollamount="2" scrolldelay="100" bgcolor="232323"
loop="infinite" onmouseover="this.stop()" onmouseout="this.start()">';
echo '<a href="' . $aa_lookup_server . '">' . $players . '</a></marquee>';


Next, configure the code above for your information.  I don't know if there are other servers you can grab the info from, but you will definately need to set the $aa_image_path variable to the URL you can get to the images you place on your server.

NOTE: Your Host provider must allow the fsockopen() php function on your server otherwise you will get no data.  Not all Host providers allow this function.  Talk to your Host provider about allowing it if they do not already.


Will doing those things allow me to display info for any gaming servers, like cod2 or bf2?
Title: Re: Americas army server block help
Post by: mebymyself on October 20, 2006, 01:42:03 PM
Not it shows only America's Army Server info
Title: Re: Americas army server block help
Post by: mebymyself on October 20, 2006, 05:18:29 PM
Here is it! I made it by myself


//////////////////////////////////////////////
// America's Army Server Info Block
// based on the PHP Nuke block designed by DivideByZero
//
// Redesigned and converted by Ken McNicholas for TinyPortal block
// Complete Computer Services
// August 20, 2006
//
// TinyPortal 0.9.5 with SMF 1.1 RC3
//
// The America's Army Server Info Block displays current players
// on a particular America's Army server.
// Set up the configuration info for the server you wish to query
//
//////////////////////////////////////////////

function cleanup($string){
     $done = false;
     $count=0;
     while($done == false){
          $out = unpack("H*", $string);
          $pos = strpos($out[1], "1b");
          $len = "4";
         
          if ($pos === false){
               $done = true;
               break;
          }
          $count++;

          /* Calc true position */
          if($pos == 0){
               $loc = $pos;
          }else{
               $loc = $pos / 2;
          }

         $color=join(unpack("H*", substr($string, $loc+1, $len-1)))   ;
                 
             
         $substr='<' . 'font color="#' . $color . '">' ;
         $string = substr_replace($string, $substr, $loc, $len);


     }
     
while ( $count>0 ){
    $string = $string  . '<'  .'/font'.  '>' ;
    $count-- ;
  }
     return $string;
}


/*
****************************************
****************************************
*** !! User Configuration Section !! ***
****************************************
****************************************
*/

// Server IP you want to query
$aa_ip = '127.0.0.1';
// Server Name
$aa_server_name = 'YourServerNameGoesHere;
$aa_server_url = 'http://www.forwardobserver.us/browser/foserverlist.php?ServerIP=';
$aa_lookup_server = 'http://www.aa-mbs.com/serverlookup.php?ip=' . $aa_ip . ':1716';

// Server Port - 1717 = default
$aa_port = '1717';

// URL to where you put the folder containing the map pics (include a trailing slash!)
$aa_image_path = 'aaomaps/';

// You should only need to change the map array if maps
// are added/deleted/changed, otherwise leave as is

// New maps added Steamroller, SF SnakePlain, Interdiction
$map = array("Bridge Crossing" => "Bridge.jpg",
"Bridge SE" => "Bridge SE.jpg",
"Border" => "Border.jpg",
"Collapsed Tunnel" => "Tunnel-d.jpg",
"Dusk" => "Dusk.jpg",
"FLS Assault" => "FLS-b.jpg",
"Headquarters Raid" => "HQ_Raid.jpg",
"Insurgent Camp" => "Insurgent_Camp-c.jpg",
             
             "Interdiction" =>"interdiction.jpg",
"JRTC Farm Raid" => "JRTC_Farm.jpg",
"Mountain Ambush" => "Mountain_Ambush-b.jpg",
"Mountain Pass" => "Mountain_Pass.jpg",
"Mountain Pass SE" => "Mountain Pass SE.jpg",
"Mout McKenna" => "MOUT_McKenna.jpg",
"Pipeline" => "Pipeline-b.jpg",
"Pipeline SF" => "Pipeline.jpg",
"Radio Tower" => "Radio_Tower.jpg",
"River Basin" => "River_Basin-c.jpg",
"SF Oasis" => "sf_oasis.jpg",
"SF Taiga" => "sf_taiga.jpg",
"SF Blizzard" => "sf_blizzard.jpg",
"SF Courtyard" => "sf_courtyard.jpg",
"SF Dockside" => "SFdockside.jpg",
"SF Extraction" => "SFextraction.jpg",
"SF PCR" => "sf_pcr.jpg",
"SF Water Treatment" => "sf_water_treatment.jpg",
"SF Arctic" => "sfarctic.jpg",
"SF Village" => "sfvillage.jpg",
"SF CSAR" => "sf_csar.jpg",
"SF Hospital" => "sf_hospital.jpg",
"SF Recon" => "sf_recon.jpg",
"SF SandStorm" => "sf_sandstorm.jpg",

             "SF SnakePlain" => "sf_snakeplain.jpg",
             
             "Steamroller" => "steamroller.jpg",
"Swamp Raid" => "Swamp_Raid-a.jpg",
"Weapons Cache" => "Weapons_Cache-d.jpg",
"Weapons Cache SE" => "Weapons_Cache-a.jpg",
"Woodland Outpost" => "woodland_outpost.jpg",
"Urban Assault" => "urban_assault.jpg");
                                   
/*
****************************************
****************************************
*/

//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////

// query server for game info
$aa_sock = fsockopen( "udp://" . $aa_ip, $aa_port);
if($aa_sock != false){
socket_set_timeout($aa_sock, 0, 500000);
fwrite($aa_sock, "\\info\\");
$aa_info = @fread($aa_sock, 8192);
fclose($aa_sock);
}

// create array to hold game info
$aa_infoarr = explode("\\", $aa_info);
$aa_info = array();
$aa_infosize = count($aa_infoarr);
// since first element is unused (element 0) start at element 1
// and populate an associative array (nicer, and easier!)
for ($i = 1; $i < $aa_infosize; $i += 2){
$aa_info[$aa_infoarr[$i]] = $aa_infoarr[$i+1];
}

// get player list
$players = "<br /><br />";
$p = 1;
for ($i = 0; $i < $aa_info['numplayers']; $i++){
$players .= $p . ' ' . $aa_info['player_' . $i] . '<br />';
$p++;
}
$players .='<br /><br />';

// display info

// Host name and link to detail from FO Online Server Browser
echo '<center><a href="' . $aa_server_url . $aa_ip . '">' . cleanup($aa_info['hostname']) . "</a><br />";
//IP:Port address
echo 'IP: ' . $aa_ip . ':' . $aa_port . '<br />';
// Map Name
echo 'Map: ' . $aa_info['mapname'] . '<br />';
// Players / Max Players
echo 'Players: ' . $aa_info['numplayers'] . '/' . $aa_info['maxplayers'] . '<br />';
// Round
echo 'Round: ' . $aa_info['current_round'] . '<br />';
//Mission Time
echo 'Time: ' . $aa_info['mission_time'] . '<br />';

$mappic = "";
if (array_key_exists($aa_info['mapname'], $map)){
echo '<img src="' . $aa_image_path . $map[$aa_info['mapname']] . '"><br />';
} else {
echo 'Map Unavailable!<br />';
}
echo '<a href="' . $aa_lookup_server . '">* Server Intel *</a><br />';
echo '<a href="aao://' . $aa_ip . '"><img src="' . $aa_image_path . 'joinserver.gif" border="0" alt="Join Server!!"></a><br />';
echo 'Current Players:<br />';
echo '<a name="scrollingCode"></a>';
// display scrolling player list
echo '<marquee behavior="scroll" align="left" direction="up" height="80" width="90%" scrollamount="2" scrolldelay="100" bgcolor="232323"
loop="infinite" onmouseover="this.stop()" onmouseout="this.start()">';
echo '<a href="' . $aa_lookup_server . '">' . $players . '</a></marquee></center>';


Title: Re: Americas army server block help
Post by: Thurnok on October 21, 2006, 04:21:11 AM
Just read your msg, but appears you have already solved it.
Title: Re: Americas army server block help
Post by: mebymyself on October 21, 2006, 04:26:17 AM
yes , i did - but i will appriciate if you can look my code - I am totally new to php.
maybe some issues will pop up for your eyes

I also added 3 mew maps that was introduced in AA v2.7
Title: Re: Americas army server block help
Post by: RBakker on July 14, 2007, 02:23:05 PM
Is this still working?
Because I cant find anything to download.

nvm ::)Found it at Turnoks

Now trying to get it to work


Broken links?
Title: Re: Americas army server block help
Post by: Thurnok on July 18, 2007, 07:19:08 AM
The links in the block code?  Those are from a server that was running at one time that may or may not still be up.  You will need to provide a valid server and port for use of the block itself.
Title: Re: Americas army server block help
Post by: RBakker on July 18, 2007, 07:14:54 PM
Somehow it will not display 66.55.155.38

I do think it has something to do with SCI (in this line:$aa_server_url   = 'http://www.forwardobserver.us/browser/foserverlist.php?ServerIP=';)
Because this part ($aa_lookup_server = 'http://www.aa-mbs.com/serverlookup.php?ip=' . $aa_ip . ':1716';)does work