A nice touch for us pilots who use forums

Started by Helgesen, April 02, 2004, 05:47:58 AM

Previous topic - Next topic


Is it possible to create som kind of "picture" like vatsim uses for their pilots. That i can use as a sig. in different forums that tells people that i am online and flying at 2500ft and HDG 124 degrees for my server?

the only thing people put into the signature is something like this:

And then a small picture comes up with warious values from the flight.
I do not explain very well, but hope you understand....

Russell Gilbert

Hi Helgesen,

Yes, I understand what you mean, I think I've seen something like that before, but not with FSHost.

I think what's needed is for someone to write a CGI script sort of like FSHostMap.  The idea is to query the particular FSHost server for the current pilot list, pull out the info for the requested pilot name, and then send back an image displaying the pilot's current status.  If it turns out to be too difficult to create an image on the fly, an alternative might be to just use text, with an iframe to hold it in the signature.

Maybe one of the clever programmers around this forum would like to tackle that project.



If I understand,
    you want a URL that will call a server that will in turn call the proper FSHostServer\xml file and read teh single player data, and return a 'picture' with pilot stats (Location, alt., speed) or a simple message 'On Ground'.
I threw together a php script to do just that. here are 3 examples:
The problem is with fitting all the desired text into an image that fits. Most Avitars are limited to sizes pretty small. These are 90w by 60h.

You can grab a copy of the script from, and drop it on your own php server. Look into php image functions... you'll find you can even start with a fixed background image and write on top of that... see www.php.net for more.
Using free stuff to better the world...


Hmmm !

Does not work for me at all....
Can you please help me out?

MP server adress:  vnas.hopto.org (instead of ip adress)
PHP scriptserver: virtualnorwegian.com/vispilot.php

Russell Gilbert

Here's more help on how to use the script that CowBoyGuy posted...

  • First, you'll need a web server that supports PHP.

  • Click the link below to view CowBoyGuy's PHP script.  Save the script to your web server's hard drive, in a directory that supports html files.  Name the file you're saving something like "playercheck.php":

  • Find an FSHost server you want to test with -- if you have FSHostSpy, you can find a server that has several players on it.  Or you can just run your own FSHost, if there are players connected to it.  Get the IP address of the FSHost server.  For this example, I'll use the Akroma Flight Sim Server, which (currently) has the IP

  • Find a player name on that server.  For this example, I'll use the player named "Pegasus".

  • Test the script by opening a browser and going to a URL that points to your PHP script on your web server.  At the end of the URL, add "?Pilot=<player-name>&FSHost=http://<ip-address>/xml".  For example:


  • You should see a white page with a white icon in the upper left corner, that looks something like the examples CowBoyGuy included in his post above.  It should show the player name "Pegasus", and his nearest airport, status, alitude, speed, etc.

  • Try it again, but use a pilot name that doesn't exist on the server, such as "Pegasus123".  You should get an icon back showing that the player is not on the server.

  • If all that works ok, then you can use the PHP script somewhere in a normal HTML page.  In your HTML page, you'll have an image tag somewhere, and that image will be loaded from the PHP script.  So if your html page is "mypage.html", you might have an image tag somewhere in it that looks like this:

Then when you go to that html page in a browser, the image should load the icon you saw before, from the PHP script.  You can put the image anywhere on the page.

  • You can modify the PHP script to do things like change the size of the icon (look for $picWidth and $picHeight) and the colors of the text on the icon (look for $Colors).

Hope this helps,



Seems to me that you guys can do things i can't
I've tried (very hard) to make this work for me.

First of all:
I did paste the code from the txt file you gave me into a file that I called vispilot.php and saved it on my php able server

Then I tried to use my very own FSHOST

with this URL:

pleas feel free to try.  ;D
The php "script" is CHMOD 777 but still......

Russell Gilbert

Hi Helgesen,

When I try this link in IE:

http://virtualnorwegian.com/vispilot.php?Pilot=vnas001&FSHost=http:/ /vnas.hopto.org:8080/xml

I get these error messages:

Warning:  fopen(): URL file-access is disabled in the server configuration in /customers/virtualnorwegian.com/virtualnorwegian.com/httpd.www/vispilot.php on line 49

Warning:  fopen(http://vnas.hopto.org:8080/xml): failed to open stream: no suitable wrapper could be found in /customers/virtualnorwegian.com/virtualnorwegian.com/httpd.www/vispilot.php on line 49

Warning:  fgets(): supplied argument is not a valid stream resource in /customers/virtualnorwegian.com/virtualnorwegian.com/httpd.www/vispilot.php on line 53

What it's saying is that on your web server, PHP is setup to not allow PHP scripts to open remote URLs, such as the URL to retrieve the XML data from FSHost.  To fix this, you need to make a change to the php.ini file on your web server.  Here's a page that talks more about the line you need to add:


On my Apache server, the file is /etc/php.ini, and the line that needs to be changed is line 509:

allow_url_fopen = On



Ok, thanks Russell!

But i have a last option as long as i wait for my isp to change the php.ini (if they want to then) and that is to use my very own server:


But still errors  ngh!

Russell Gilbert

After searching for the error message on Google, it looks like your ISP hasn't installed "GD", which apparently is some type of image library for PHP.



GD is what actually draws images from PHP.  without GD, you're going nowhere with PHP images.

Do you maybe know what is wrong with this one?

http://richgannon.net/fshosticon.php ?

It does not need the variables in URL as I set them statically in the php file.


// this is a goofy character funtion to get rid
// of unprintables
function CleanDirtyLine($DirtyLine)
$arr1 preg_split('//'$DirtyLine);
     foreach (
$arr1 as $Char)
       if (
$Char chr(126) ) 
        && (
$Char chr(31)  )
$CleanLine .= $Char;

// Specific sizes of images can be altered here
$picWidth 300;
$picHeight 65;

// Header for png picture content, 
// and expiration past due to force reload
Header("Content-type: image/png");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

// Create the working image

// You can alter the colors of the picture as you want
// to keep it simple, add/update this array 
$Colors= array(

'Blue' => ImageColorAllocate($pic,0,0,255),
'Black' => ImageColorAllocate($pic,0,0,0),
'Red' => ImageColorAllocate($pic,255,0,0),
'Green' => ImageColorAllocate($pic,0,255,0),
'White' => ImageColorAllocate($pic,255,255,255),
$text_color1 ImageColorAllocate($im,75,75,75);  
$text_color2 ImageColorAllocate($im,75,75,75);
$text_color3 ImageColorAllocate($im,75,75,75);
$text_color4 ImageColorAllocate($im,75,75,75);
$text_color5 ImageColorAllocate($im,75,75,75);
// Create a complete single color back ground

// First get the host address and pilot name from values passed in

//$pilotname = $_REQUEST['pilot']; 
//$fshostaddress = $_REQUEST['ip'];

$pilotname "_DMN59"// Put in your pilot name here.
$fshostaddress ""// Put in your FSHost's Web IP:Port here.

if (($pilotname == "") &#124;&#124; ( $fshostaddress == "" ))
} else {
  if (!(
$fp fopen("http://".$fshostaddress."/xml","r")))
imagestring($pic3315"Cannot Read FSHost Data"$Colors['Red']);
  while (
$data fgets($fp,4096))
    if (
    if (
    if ((
$Player == True) && (stristr($data,$pilotname)))
    if ((
$PlayerActive == True) && (stristr($data,"<NearAirport>")))
$PlayerNear CleanDirtyLine(strip_tags($data));
    if ((
$PlayerActive == True) && (stristr($data,"<Speed>")))
$PlayerSpeed CleanDirtyLine(strip_tags($data));
    if ((
$PlayerActive == True) && (stristr($data,"<Status>")))
$PlayerStatus CleanDirtyLine(strip_tags($data));
    if ((
$PlayerActive == True) && (stristr($data,"<Altitude>")))
$PlayerAltitude CleanDirtyLine(strip_tags($data));

  // Add text to the image to report the data
$Space 0;
$Spacer 10;
  if (
$PlayerFound == True)
$Space $Space $Spacer;
imagestring($pic23$Space" Near ".$PlayerNear$Colors['Blue']);
    if (
stristr($PlayerStatus,"On ground"))
$Space $Space $Spacer;
    } else {
$string2"Altitude: $PlayerAltitude ";
$string3"Speed: $PlayerSpeed ";
$string4"Near: $PlayerNear ";

$px = (imagesx($pic)-6*strlen($string1))/2;
$px = (imagesx($pic)-6*strlen($string2))/2;
$px = (imagesx($pic)-6*strlen($string3))/2;
$px = (imagesx($pic)-6*strlen($string4))/2;
$px = (imagesx($pic)-6*strlen($string5))/2;
//        imagecolortransparent($pic, $background_color); // Make the image transparent (comment this out for now).
$Space $Space $Spacer;
imagestring($pic23$Space"Not on server"$Colors['White']);

// Write the image and get rid of the scraps


Normally I can troubleshoot problems pretty fast but I'm like sleeping now.  I also have alot more work to do, but do you see any fixes needing to be done?

Russell Gilbert

Are you seeing the errors when you try that link in IE?

Warning:  imagecolorallocate(): supplied argument is not a valid Image resource in /home/rgannon/public_html/fshosticon.php on line 56

When I look at line 56 in your source above, I see these lines:

 $text_color1 = ImageColorAllocate($im,75,75,75);  
 $text_color2 = ImageColorAllocate($im,75,75,75);
 $text_color3 = ImageColorAllocate($im,75,75,75);
 $text_color4 = ImageColorAllocate($im,75,75,75);
 $text_color5 = ImageColorAllocate($im,75,75,75);

The problem seems to be that $im does not exist.  You probably want to use $pic, since it contains an object created by calling ImageCreate, a few lines above.


Russell Gilbert

BTW, if you can't get GD installed, you can probably modify the PHP code to output text lines instead, and then just load the PHP script in an iframe tag, instead of using an image tag.




I thought I changed all those lol...back to work.


Alright.  I just got home from school (I was in computer class in my above post ;D) and made som changes.

It is now working pretty well however I will be doing more work on it later.

Working demo:

Demo Source:

I will be updating it as I get around to it.  Currently the PHP I added is still choppy and mixed up and the stuff that I am not using is still in there and I'll clean up the mess later.

Also, to use the fonts, you will need to recompile PHP and GD with the FreeType Library.

The font I am using above can be downloaded here:


Thanks for the script Cowboy.  Think I finally got it working.

Hey Cessna,

Like the look you came up with, but am not able to get the demo code.  If possible, could you mail it me?  Thanks,



What can't you get?

BTW...when a user is online, it looks alot better...when the pilot is noit online, then (at this time) it looks like nothing really useful.


Ok, my ISP won't adjust their server, so I must try at my very own.
Here's the php script:

Seems to me that some extentions on the php is missing...
Anyone up for a link?
I'we tried the php.net but does not find anything with GD...

I'm running
Apache 2
PHP Version 5.0.2
windows 2000 pro.

There's something with imagecreate() whats that?


Google GD.  That is what creates the image.


QuoteGoogle GD.  That is what creates the image.

Thank you, I have been reading here: "http://www.boutell.com/gd/faq.html"
But compile a new dll file?
No thanks, i give up.
Thanks for all help and you're time.



Don't give up that easily.

I'll host it for you.

Once I get home, we'll talk  ;)


PM me where I can download the PHP file (if edited) of yours in TXT format and I'll put it on one of my boxes.


Could someone create the code so it does not require GD? Just puts the text.

Tanner S.

TS Aviation