IVAO Flightplan File

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

Hey,

So where do you want this downloadble from? How do you know which schedule?

I think the best should be if pilots can download it from the briefing page.

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

  1. 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}"; ?>

  2. Add a link to your briefing page:

    Download IVAO Flight Plan

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

1 Like

Thanks a lot for the fast reply.

But i got an error  :-

Fatal error: Call to undefined method SchedulesData::findschedules() in core/modules/IVAOFlightPlan/IVAOFlightPlan.php on line 14

Ah, this code will only work on the latest betas/next release

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">

Sorry, the link should be actionurl, not just url

Then it should be all good. I fixed it in my original post

It works, thanks a lot 

Sorry for popping up an old topic but i receive this error:

Parse error: syntax error, unexpected T_STRING in /home/aireu/domains/aireuropa-virtual.com/public_html/core/modules/IVAOFlightPlan/IVAOFlightPlan.php on line 19