Jump to content

MainController::Run


Tato123

Recommended Posts

Hi to all,

i have a little question.

From my site i call this:

http://www.virtualir...eflights?cs=VAR

and i see the page with my map

Now i need start the function with MainController::Run but don't work

I use this code

<?php MainController::Run('liveflightsivao', 'index', '?cs=VAR'); ?></center>

Any suggestion for the correct string ?

Thanks

Link to comment
Share on other sites

  • Administrators

Servetas makes a valid point as the url shows no sign of the "ivao" part of the string. I would also look over the documentation here -> http://forum.phpvms....and-add-ons-r25 - specifically the section about passing variables.

I would guess you are not processing the GET data correctly within the controller if the "ivao" string is not the issue.

--------------------------------------------------------------------------------------

Passing Variables

Variables can be passed in several different ways. We'll use two different URLs and functions to demonstrate

 index.php/moduletest/pageone/apple/red

index.php/moduletest/pagetwo?fruit=apple&color=red

The code:

class ModuleTest extends CodonModule
{
public function pageone($fruit='', $orange='')
{
echo "The fruit is an {$fruit} and the color is {$orange}";
}

public function pagetwo()
{
echo "The fruit is an {$this->get->fruit} and the color is {$this->get->orange}";
}
}

As you can see, the "pageone" method is cleaner - the function parameters will be the variables after the function name in the URL, in the order they appear in the URL.

The "pagetwo" method is the more "traditional" way of doing things, but they are essentially the same thing. To access the variables in the query string you use:

$this->get->[variable name]
Link to comment
Share on other sites

Ok but how i must try to try?

I must run this

http://www.virtualiroma.it/newvar/index.php/liveflights?cs=VAR

in my TPL.

Is possible or not?

the code of module is:

<?php
class liveflightsonline extends CodonModule {
public function index() { ?>
 <script src="http://maps.google.com/maps/api/js?sensor=true"
	  type="text/javascript"></script>
<?php 
//randomize servers
//$serv[] = "http://nl1.www.ivao.aero/whazzup.txt";
//$serv[] = "http://am1.www.ivao.aero/whazzup.txt";
$serv[] = "http://api.ivao.aero/getdata/whazzup/whazzup.txt";
$serv[] = "http://api.ivao.aero/getdata/whazzup/whazzup.txt";
srand ((double) microtime() * 1000000);
$randomserv = rand(0,count($serv)-1);
$servers = $serv[$randomserv];
//readin whazzup.txt
$file = file($servers);
$explode = explode(":", $line);
?>
<table width="93%" border="1" align="center" >
 <tr>
   <td  colspan="11" align="center" >
<center><img src="http://maps.google.com/maps/api/staticmap?center=48.41, 9.8&size=480x300
<?php
foreach($file as $line) {
   if(strpos($line,$_GET['cs']) === 0){
 list($callsign,$vid,$realname,$clienttype,$frequency,$latitude,$longitude,$altitude,$groundspeed,
$planned_aircraft,$planned_tascruise,$planned_depairport,$planned_altitude,$planned_destairport,
$server,$protrevision,$rating,$transponder,$facilitytype,$visualrange,$planned_revision,
$planned_flighttype,$planned_deptime,$planned_actdeptime,$planned_hrsenroute,$planned_minenroute,
$planned_hrsfuel,$planned_minfuel,$planned_altairport,$planned_remarks,$planned_route,
$planned_depairport_lat,$planned_depairport_lon,$planned_destairport_lat,$planned_destairport_lon,
$atis_message,$time_last_atis_received,$time_connected,$client_software_name,$client_software_version,
$adminrating,$atc_or_pilotrating,$planned_altairport2,$planned_typeofflight,$planned_pob,$true_heading,$onground)=explode(":",$line)
?>
&markers=color:blue%7Clabel:P%7C<?php echo $latitude ?>, <?php echo $longitude ?>&sensor=true<?php }} ?>" alt="Map Not Available!" /></center>
</td>
 </tr>
 </table>
 <table>
<table border="0">
<?php
foreach($file as $line) {
   if(strpos($line,$_GET['cs']) === 0){
 list($callsign,$vid,$realname,$clienttype,$frequency,$latitude,$longitude,$altitude,$groundspeed,
$planned_aircraft,$planned_tascruise,$planned_depairport,$planned_altitude,$planned_destairport,
$server,$protrevision,$rating,$transponder,$facilitytype,$visualrange,$planned_revision,
$planned_flighttype,$planned_deptime,$planned_actdeptime,$planned_hrsenroute,$planned_minenroute,
$planned_hrsfuel,$planned_minfuel,$planned_altairport,$planned_remarks,$planned_route,
$planned_depairport_lat,$planned_depairport_lon,$planned_destairport_lat,$planned_destairport_lon,
$atis_message,$time_last_atis_received,$time_connected,$client_software_name,$client_software_version,
$adminrating,$atc_or_pilotrating,$planned_altairport2,$planned_typeofflight,$planned_pob,$true_heading,$onground)=explode(":",$line)
?>
 <tr>
   <td width="63"><div align="center"><a href="<?php echo SITE_URL; ?>/index.php/liveflights/track?cs=<?php echo $callsign; ?>" target="_blank"><?php echo $callsign ?></a></div></td>
   <td width="165">
  <div align="center">
 <?php
if (strlen($realname)>=30)
 echo (substr($realname, 0, 30))."...";
 else
 echo $realname
 ?>
   </div></td>
   <td width="33"><div align="center"><?php echo $planned_depairport  ?></div></td>
   <td width="78"><div align="center"><?php echo $planned_destairport  ?></div></td>
   <td width="101"><div align="center"><?php echo (substr($planned_aircraft, 2, 6)) ?></div></td>
   <td width="91"><div align="center"><?php echo $groundspeed ?></div></td>
   <td width="88"><div align="center"><?php echo $altitude ?></div></td>
   <td><div align="center">
  <?php if ($groundspeed=="0") echo 'Gate Open'; elseif  ($altitude>="12000") echo 'En Route'; else echo 'Departing/Arriving'; ?>
   </div></td>
 </tr>
 <?php 
}
}
?>
</table>
<?php
// server in use
//echo $serv[$randomserv]?>
<?php
}
public function track() { ?>
<?php   
//randomize servers
//$serv[] = "http://nl1.www.ivao.aero/whazzup.txt";
//$serv[] = "http://am1.www.ivao.aero/whazzup.txt";
$serv[] = "http://api.ivao.aero/getdata/whazzup/whazzup.txt";
$serv[] = "http://api.ivao.aero/getdata/whazzup/whazzup.txt";
srand ((double) microtime() * 1000000);
$randomserv = rand(0,count($serv)-1);
?>
<?php
$file = file($serv[$randomserv]);
$explode = explode(":", $line);
foreach($file as $line)
   if(strpos($line,$_GET['cs']) === 0)
list($callsign,$vid,$realname,$clienttype,$frequency,$latitude,$longitude,$altitude,$groundspeed,
$planned_aircraft,$planned_tascruise,$planned_depairport,$planned_altitude,$planned_destairport,
$server,$protrevision,$rating,$transponder,$facilitytype,$visualrange,$planned_revision,
$planned_flighttype,$planned_deptime,$planned_actdeptime,$planned_hrsenroute,$planned_minenroute,
$planned_hrsfuel,$planned_minfuel,$planned_altairport,$planned_remarks,$planned_route,
$planned_depairport_lat,$planned_depairport_lon,$planned_destairport_lat,$planned_destairport_lon,
$atis_message,$time_last_atis_received,$time_connected,$client_software_name,$client_software_version,
$adminrating,$atc_or_pilotrating,$planned_altairport2,$planned_typeofflight,$planned_pob,$true_heading,$onground)=explode(":",$line)
?>
<table width="100%" border="1" align="center" class="tablevar" >
 <tr>
   <td width="239" >Callsign:</td>
   <td width="564" ><?php echo $callsign ?></td>
 </tr>
 <tr>
   <td >Partenza:</td>
   <td ><?php echo $planned_depairport  ?></td>
 </tr>
<tr>
   <td >Meteo alla Partenza:</td>
   <td ><?php

$lines = file("http://wx.ivao.aero/metar.php?id=$planned_depairport");
   $top200 = array_slice(array_reverse($lines),0,1000);
foreach($top200 as $line)
{
   echo $line;
}
?>
</td>
 </tr>
 <tr>
   <td >Destinazione:</td>
   <td ><?php echo $planned_destairport  ?></td>
 </tr>
 <tr>
   <td >Meteo Destinazione:</td>
   <td ><?php

$lines = file("http://wx.ivao.aero/metar.php?id=$planned_destairport");
   $top200 = array_slice(array_reverse($lines),0,1000);
foreach($top200 as $line)
{
   echo $line;
}
?></td>
 </tr>
 <tr>
   <td >Aereo:</td>
   <td ><?php echo (substr($planned_aircraft, 2, 6)) ?></td>
 </tr>
 <tr>
   <td >Carburante a bordo per:</td>
   <td ><?php echo $planned_hrsfuel ?> Ore e <?php echo $planned_minfuel ?> minuti</td>
 </tr>
 <tr>
   <td >Passeggeri:</td>
   <td ><?php echo $planned_pob ?></td>
 </tr>
 <tr>
   <td >Ground Speed/Altitude:</td>
   <td ><?php echo $groundspeed ?> / <?php echo $altitude ?>
 </tr>
 <tr>
   <td >Rotta:</td>
   <td ><?php echo $planned_route ?></td>
 </tr>
 <tr>
   <td >Stato:</td>
   <td ><?php if ($groundspeed=="0") echo 'Gate Open'; elseif  ($altitude>="12000") echo 'En Route'; else echo 'Departing/Arriving'; ?>
</td>
 </tr>
 <tr>
   <td >Pilota al Comando:</td>
   <td ><?php
 if (strlen($realname)>=20)
 echo (substr($realname, 0, 20))."...";
 else
 echo $realname
 ?>
 </td>
 </tr>
   <td >Grado:</td>
   <td ><p style="color:white;font-size:11px; vertical-align:top;">
   <img src="http://www.ivao.aero/data/images/ratings/pilot/<? echo $rating ?>.gif" width="105" height="30" />
 - <?php
if ($rating == 1 )
echo  "OBS - Observer";
elseif ($rating == 2 )
echo  "Basic Flight Student (FS1)";
elseif ($rating == 3 )
echo "Flight Student (FS2)";
elseif ($rating == 4 )
echo "Advanced Flight Student (FS3)";
elseif ($rating == 5 )
echo "Private Pilot (PP)";
elseif ($rating == 6 )
echo "Senior Private Pilot (SPP)";
elseif ($rating == 7 )
echo "Commercial Pilot (CP)";
elseif ($rating == 8 )
echo "Airline Transport Pilot (ATP)";
elseif ($rating == 9 )
echo "Senior Flight Instructor (SFI)";
elseif ($rating == 10 )
echo "Chief Flight Instructor (CFI)";
elseif ($rating == 11 )
echo "Supervisor (SUP)";
elseif ($rating == 12 )
echo "Administrator (ADM)";
?>
 </td>
 </tr>
   <tr>
   <td colspan="4" align="center">
<center><img src="http://maps.google.com/maps/api/staticmap?path=color:0xff0000ff%7Cweight:5%7C&markers=color:blue%7Clabel:Position%7C<?php echo $latitude ?>,<?php echo $longitude ?>&zoom=2&size=600x300&sensor=true" /></center>
 </td>
 </tr>
</table>
   <?php

}

}

Link to comment
Share on other sites

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