Chris Posted December 20, 2009 Report Share Posted December 20, 2009 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 Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted December 20, 2009 Administrators Report Share Posted December 20, 2009 Hey, So where do you want this downloadble from? How do you know which schedule? Quote Link to comment Share on other sites More sharing options...
Chris Posted December 20, 2009 Author Report Share Posted December 20, 2009 I think the best should be if pilots can download it from the briefing page. Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted December 20, 2009 Administrators Report Share Posted December 20, 2009 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 1 Quote Link to comment Share on other sites More sharing options...
Chris Posted December 20, 2009 Author Report Share Posted December 20, 2009 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 Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted December 20, 2009 Administrators Report Share Posted December 20, 2009 Ah, this code will only work on the latest betas/next release Quote Link to comment Share on other sites More sharing options...
Chris Posted December 20, 2009 Author Report Share Posted December 20, 2009 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"> Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted December 20, 2009 Administrators Report Share Posted December 20, 2009 Sorry, the link should be actionurl, not just url Then it should be all good. I fixed it in my original post Quote Link to comment Share on other sites More sharing options...
Chris Posted December 20, 2009 Author Report Share Posted December 20, 2009 It works, thanks a lot Quote Link to comment Share on other sites More sharing options...
elferen1 Posted March 9, 2012 Report Share Posted March 9, 2012 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.