A nice touch for us pilots who use forums

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

Previous topic - Next topic

Helgesen

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:
http://www.myserver.com/mulitplayerserver/pilotreq.php?id=MyLogOnName

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.

Russell

CowBoyGuy

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 http://68.55.129.14/FSHost/FSHostIcon.txt, 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...
http://mywebpages.comcast.net/alandtracysmith/CutRate/

Helgesen

#3
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":

http://68.55.129.14/FSHost/FSHostIcon.txt

  • 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 66.105.121.185.

  • 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:

http://www.yourwebserver.com/playercheck.php?Pilot=Pegasus&FSHost=http://66.105.121.185/xml

  • 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,

Russell

Helgesen

#5
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
http://www.virtualnorwegian.com/vispilot.php

Then I tried to use my very own FSHOST
http://vnas.hopto.org:8080

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

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:

http://nl2.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen

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

Russell

Helgesen

#7
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:

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

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.

Russell

insanecessna

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.

<?php


//
// 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;
       }
     }
     return 
$CleanLine;
}

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

//
// 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
//
$pic=ImageCreate($picWidth,$picHeight); 

//
// 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
//
ImageFilledRectangle($pic,0,0,$picWidth+1,$picHeight+1,$Colors['Black']);

//
// 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 "65.50.41.138:86"// Put in your FSHost's Web IP:Port here.

if (($pilotname == "") &#124;&#124; ( $fshostaddress == "" ))
{
  
imagestring($pic3315"BadRef"$Colors['Red']);
} else {
  if (!(
$fp fopen("http://".$fshostaddress."/xml","r")))
  {
    
imagestring($pic3315"Cannot Read FSHost Data"$Colors['Red']);
  }
  while (
$data fgets($fp,4096))
  {
    if (
stristr($data,"<Player>"))
    {
      
$Player=True;
    }
    if (
stristr($data,"</Player>"))
    {
      
$Player=False;
      
$PlayerActive=False;
    }
    if ((
$Player == True) && (stristr($data,$pilotname)))
    {
      
$PlayerActive=True;
      
$PlayerFound=True;
    }
    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;
  
imagestring($pic23$Space$pilotname$Colors['Green']);
  if (
$PlayerFound == True)
  {
    
$Space $Space $Spacer;
    
imagestring($pic23$Space" Near ".$PlayerNear$Colors['Blue']);
    if (
stristr($PlayerStatus,"On ground"))
    {
      
$Space $Space $Spacer;
      
imagestring($pic23$Space"_".$PlayerStatus."_"$Colors['Green']);
    } else {
      
      
$string1$PlayerStatus;
      
$string2"Altitude: $PlayerAltitude ";
      
$string3"Speed: $PlayerSpeed ";
      
$string4"Near: $PlayerNear ";
      
$string5$pilotname;

      
      
$px = (imagesx($pic)-6*strlen($string1))/2;
      
imagettftext($pic100$px12$text_color1"./visitor2.ttf""$string1");
      
$px = (imagesx($pic)-6*strlen($string2))/2;
      
imagettftext($pic100$px24$text_color2"./visitor2.ttf""$string2");
      
$px = (imagesx($pic)-6*strlen($string3))/2;
      
imagettftext($pic100$px36$text_color3"./visitor2.ttf""$string3");
      
$px = (imagesx($pic)-6*strlen($string4))/2;
      
imagettftext($pic100$px48$text_color4"./visitor2.ttf""$string4");
      
$px = (imagesx($pic)-6*strlen($string5))/2;
      
imagettftext($pic100$px60$text_color5"./visitor2.ttf""$string5");
      
//        imagecolortransparent($pic, $background_color); // Make the image transparent (comment this out for now).
    
}
  }
  else
  {
      
$Space $Space $Spacer;
    
imagestring($pic23$Space"Not on server"$Colors['White']);
  } 
}

//
// Write the image and get rid of the scraps
//
ImagePNG($pic);
ImageDestroy($pic);

?>

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?
Webserver:

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

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.

Russell

insanecessna

 :-[

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

insanecessna

#13
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:
http://richgannon.net/fshosticon.php

Demo Source:
http://richgannon.net/fshosticon.txt

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:
http://richgannon.net/visitor2.ttf
Webserver:

N704FN

#14
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,

Mark