Skip to content
This repository has been archived by the owner on Dec 6, 2019. It is now read-only.

Commit

Permalink
FSFK fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabeel Shahzad committed Feb 21, 2011
1 parent acb8be8 commit 7dd4ed3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
1 change: 1 addition & 0 deletions core/logs/errors.txt
@@ -0,0 +1 @@

40 changes: 22 additions & 18 deletions core/modules/FSFK/FSFK.php
Expand Up @@ -92,7 +92,6 @@ public function pirep() {
/* Add the map images in */
if ($key == 'FLIGHTMAPS') {


$img = (string )$xml->FLIGHTMAPS->FlightMapWeatherJPG;
if ($img)
$rawdata['FLIGHTMAPS']['FlightMapWeather'] = $img;
Expand Down Expand Up @@ -120,16 +119,12 @@ public function pirep() {

/* Fuel conversion - kAcars only reports in lbs */
$fuelused = (string )$xml->BlockFuel;
if (Config::Get('LiquidUnit') == '0') {
if (intval(Config::Get('LiquidUnit')) == 0) {
# Convert to KGs, divide by density since d = mass * volume
$fuelused = ($fuelused * .45359237) / .8075;
}
# Convert lbs to gallons
elseif (Config::Get('LiquidUnit') == '1') {
} elseif (intval(Config::Get('LiquidUnit')) == 1) { # Convert lbs to gallons
$fuelused = $fuelused * 6.84;
}
# Convert lbs to kgs
elseif (Config::Get('LiquidUnit') == '2') {
} elseif (intval(Config::Get('LiquidUnit')) == 2) { # Convert lbs to kgs
$fuelused = $fuelused * .45359237;
}

Expand All @@ -141,11 +136,11 @@ public function pirep() {
'depicao' => $depicao,
'arricao' => $arricao,
'aircraft' => $aircraft,
'registration' => (string )$xml->AircraftTailNumber,
'registration' => (string) $xml->AircraftTailNumber,
'flighttime' => $flighttime,
'landingrate' => (string )$xml->ONVS,
'landingrate' => (string) $xml->ONVS,
'submitdate' => 'NOW()',
'comment' => trim((string )$xml->COMMENT),
'comment' => trim((string) $xml->COMMENT),
'fuelused' => $fuelused,
'source' => 'fsfk',
'load' => $load,
Expand All @@ -154,10 +149,7 @@ public function pirep() {
);

$this->log(print_r($data, true), 'fsfk');
$ret = ACARSData::FilePIREP($pilotid, $data);

$sql1 = "UPDATE phpvms_pilots SET `status`='Active' WHERE pilotid='$pilotid'";
mysql_query($sql1);
$ret = ACARSData::filePIREP($pilotid, $data);

if (!$ret)
echo PIREPData::$lasterror;
Expand All @@ -170,6 +162,7 @@ public function pirep() {
*
*/
public function acars() {

if (!isset($_REQUEST['DATA1']))
die("0|Invalid Data");
if (!isset($_REQUEST['DATA1']))
Expand All @@ -188,18 +181,20 @@ public function acars() {
else
$message = $_REQUEST['DATA4'];


$this->log("Method: {$method}", 'fsfk');

$fields = array();

# Go through each method now
if ($method == 'TEST') {

$pilotid = $value;

echo '1|30';
return;

} elseif ($method == 'BEGINFLIGHT') {

$flight_data = explode('|', $value);

if (count($flight_data) < 10) {
Expand Down Expand Up @@ -254,7 +249,9 @@ public function acars() {
'online' => $online,
'client' => 'fsfk',
);

} elseif ($method == 'MESSAGE') {

$pilotid = $value;
$flight_data = ACARSData::get_flight_by_pilot($pilotid);

Expand Down Expand Up @@ -319,8 +316,8 @@ public function acars() {

# Estimate the time remaining
if ($gs != 0) {
$Minutes = round($dist_remain / $gs * 60);
$time_remain = self::ConvertMinutes2Hours($Minutes);
$minutes = round($dist_remain / $gs * 60);
$time_remain = self::ConvertMinutes2Hours($minutes);
} else {
$time_remain = '00:00';
}
Expand Down Expand Up @@ -400,7 +397,14 @@ protected function write_template($name, $save_as) {
echo $acars_config;
}

/**
* FSFK::ConvertMinutes2Hours()
*
* @param mixed $Minutes
* @return
*/
public function ConvertMinutes2Hours($Minutes) {

if ($Minutes < 0) {
$Min = Abs($Minutes);
} else {
Expand Down

0 comments on commit 7dd4ed3

Please sign in to comment.