Jump to content

IVAO Flightplan File


Chris

Recommended Posts

Hello guys,

is it posible to make a phpscript, where other pilots can download an ivao flightplan (.fpl) file of their flights?

I made an example:

[FLIGHTPLAN]
ID=<?php echo $schedule->code.$schedule->flightnum; ?>
RULES=I
DEPICAO=<?php echo "{$schedule->depicao}"; ?>
DEPTIME=<?php echo "{$schedule->deptime}"; ?>
LEVELTYPE=F
LEVEL=<?php echo "{$schedule->flightlevel}"; ?>
ROUTE=<?php echo "{$schedule->route}"; ?>
DESTICAO=<?php echo "{$schedule->arricao}"; ?>
EET=<?php echo "{$schedule->flighttime}"; ?>

Does somebody knows, if it works?

Kind regards

Chris

Link to comment
Share on other sites

  • Administrators

Ok, 3 steps:

1. create a new module called IVAOFlightPlan (so create a module in core/modules called that), then inside that create IVAOFlightPlan.php, then inside that, paste this:

<?php
class IVAOFlightPlan extends CodonModule
{
   public function download_ivao($schedule_id='')
   {
      // Make sure they specified a schedule
      if($schedule_id == '')
      {
         $this->set('message', 'No Schedule specified');
         $this->render('core_error.tpl');
         return;
      }
      
      $schedule = SchedulesData::findSchedules(array('s.id'=>$schedule_id), 1);
      
      // Make sure the schedule was valid/exists
      if(!$schedule)
      {
         $this->set('message', 'The schedule doesn't exist!');
         $this->render('core_error.tpl');
         return;
      }
      
      // Now write out our template file
      $this->set('schedule', $schedule[0]);
      $file = $this->get('ivao_flightplan.tpl');
      
      // And send it to the browser to download
      Util::downloadFile($file, 'ivao_flightplan.fpl');
   }
}

The Util::downloadFile() function will be available after tonight's commit. If you don't want ot wait, replace that line with:

# Set the headers so the browser things a file is being sent
$filename = 'ivao_flightplan.fpl';
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Length: ' . strlen($file));

echo $file;

You can change the filename to what you want it to be, I'll let you figure that out :)

2. Create in core/templates a file called 'ivao_flightplan.tpl', and paste your  flightplan code into it

[FLIGHTPLAN]
ID=<?php echo $schedule->code.$schedule->flightnum; ?>
RULES=I
DEPICAO=<?php echo "{$schedule->depicao}"; ?>
DEPTIME=<?php echo "{$schedule->deptime}"; ?>
LEVELTYPE=F
LEVEL=<?php echo "{$schedule->flightlevel}"; ?>
ROUTE=<?php echo "{$schedule->route}"; ?>
DESTICAO=<?php echo "{$schedule->arricao}"; ?>
EET=<?php echo "{$schedule->flighttime}"; ?>

3. Add a link to your briefing page:

<a href="<?php echo actionurl('/IVAOFlightPlan/download_ivao/'.$schedule->id);?>">Download IVAO Flight Plan</a>

Then you should be all set. You can add different flight plan types the same way (adding a public function download_XXXX($schedule_id) and then you can have different flight plan types within the same module.

Hope that helps, it might not work exactly, but should be the general gist of it

  • Like 1
Link to comment
Share on other sites

i installed the latest beta and the download works, but now i got the first lines of the header.tpl  ;D

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...