public function jumpseat()
 {
     $icao = DB::escape($_GET['depicao']);
     $this->set('airport', OperationsData::getAirportInfo($icao));
     $this->set('cost', DB::escape($_GET['cost']));
     $this->show('RSL/realschedulelite_jumpseatconfirm.tpl');
 }
Ejemplo n.º 2
0
 public function jumpseat()
 {
     $icao = DB::escape($_GET['depicao']);
     $this->set('airport', OperationsData::getAirportInfo($icao));
     $this->set('cost', DB::escape($_GET['cost']));
     $this->show('fbsv/jumpseatconfirm.php');
 }
Ejemplo n.º 3
0
 public function overview()
 {
     $this->set('acstats', StatsData::AircraftUsage());
     $this->set('toproutes', StatsData::TopRoutes());
     $this->set('allairlines', OperationsData::GetAllAirlines());
     $this->render('reports_main.php');
 }
Ejemplo n.º 4
0
 /**
  * Pilots::index()
  * 
  * @return
  */
 public function index()
 {
     // Get all of our hubs, and list pilots by hub
     $allhubs = OperationsData::GetAllHubs();
     if (!$allhubs) {
         $allhubs = array();
     }
     foreach ($allhubs as $hub) {
         $this->set('title', $hub->name);
         $this->set('icao', $hub->icao);
         $pilot_list = PilotData::findPilots(array('p.hub' => $hub->icao));
         $this->set('allpilots', $pilot_list);
         # deprecated
         $this->set('pilot_list', $pilot_list);
         $this->render('pilots_list.tpl');
     }
     $nohub = PilotData::findPilots(array('p.hub' => ''));
     if (!$nohub) {
         return;
     }
     $this->set('title', 'No Hub');
     $this->set('icao', '');
     $this->set('allpilots', $nohub);
     # deprecated
     $this->set('pilot_list', $nohub);
     $this->render('pilots_list.tpl');
 }
Ejemplo n.º 5
0
 protected function ShowForm()
 {
     $this->set('extrafields', RegistrationData::GetCustomFields());
     $this->set('allairlines', OperationsData::GetAllAirlines(true));
     $this->set('allhubs', OperationsData::GetAllHubs());
     $this->set('countries', Countries::getAllCountries());
     $this->render('registration_mainform.tpl');
 }
Ejemplo n.º 6
0
 public function jumpseat()
 {
     if (!Auth::LoggedIn()) {
         $this->set('message', 'You must be logged in to access this feature!');
         $this->render('core_error.tpl');
         return;
     } else {
         $icao = DB::escape($this->post->depicao);
         $this->set('airport', OperationsData::getAirportInfo($icao));
         $this->set('cost', DB::escape($this->post->cost));
         $this->show('Fltbook/jumpseatticket');
     }
 }
 public function index()
 {
     if (isset($this->post->action)) {
         if ($this->post->action == 'findflight') {
             $this->findflight();
         }
     } else {
         $this->set('airports', OperationsData::GetAllAirports());
         $this->set('airlines', OperationsData::getAllAirlines());
         $this->set('aircrafts', FrontSchedulesData::findaircrafttypes());
         $this->set('countries', FrontSchedulesData::findcountries());
         $this->show('RSL/airport_search.tpl');
     }
 }
Ejemplo n.º 8
0
 public function testRetrieveAirport()
 {
     echo '<h3>Core API Tests</h3>';
     echo "<strong>Checking geonames server</strong><br />";
     Config::Set('AIRPORT_LOOKUP_SERVER', 'geonames');
     OperationsData::RemoveAirport('PANC');
     $return = OperationsData::RetrieveAirportInfo('PANC');
     $this->assertNotEqual($return, false);
     echo "<strong>Checking phpVMS API server</strong><br />";
     Config::Set('AIRPORT_LOOKUP_SERVER', 'phpvms');
     Config::Set('PHPVMS_API_SERVER', 'http://apidev.phpvms.net');
     OperationsData::RemoveAirport('PANC');
     $return = OperationsData::RetrieveAirportInfo('PANC');
     $this->assertNotEqual($return, false);
 }
Ejemplo n.º 9
0
 protected function ShowForm()
 {
     $field_list = RegistrationData::GetCustomFields();
     $this->set('extrafields', $field_list);
     $this->set('field_list', $field_list);
     $airline_list = OperationsData::getAllAirlines(true);
     $this->set('allairlines', $airline_list);
     $this->set('airline_list', $airline_list);
     $hub_list = OperationsData::getAllHubs();
     $this->set('allhubs', $hub_list);
     $this->set('hub_list', $hub_list);
     $country_list = Countries::getAllCountries();
     $this->set('countries', $country_list);
     $this->set('country_list', $country_list);
     $this->render('registration_mainform.tpl');
 }
Ejemplo n.º 10
0
 /**
  * StatsTest::testPaxCount()
  * 
  * @return void
  */
 public function testPaxCount()
 {
     $total = DB::get_row('SELECT SUM(`load`) AS `total` 
             FROM phpvms_pireps WHERE `flighttype`=\'P\' AND `accepted`=' . PIREP_ACCEPTED);
     $this->assertEquals($total->total, StatsData::TotalPaxCarried(), 'StatsData::TotalPaxCarried(NO CODE)');
     $airlines = OperationsData::getAllAirlines(true);
     foreach ($airlines as $airline) {
         $pilotCount = StatsData::TotalPaxCarried($airline->code);
         $total = DB::get_row('SELECT SUM(`load`) AS `total` 
              FROM phpvms_pireps
              WHERE accepted =' . PIREP_ACCEPTED . ' 
                 AND flighttype = \'P\' 
                 AND code = \'' . $airline->code . '\'');
         $this->assertEquals($total->total, $pilotCount, 'StatsData::TotalPaxCarried(' . $airline->code . ')');
     }
 }
Ejemplo n.º 11
0
 protected function ShowForm()
 {
     //Google reCaptcha
     //updated to Google noCaptcha 1/15
     $this->set('sitekey', RECAPTCHA_PUBLIC_KEY);
     $this->set('lang', 'en');
     $field_list = RegistrationData::GetCustomFields();
     $this->set('extrafields', $field_list);
     $this->set('field_list', $field_list);
     $airline_list = OperationsData::getAllAirlines(true);
     $this->set('allairlines', $airline_list);
     $this->set('airline_list', $airline_list);
     $hub_list = OperationsData::getAllHubs();
     $this->set('allhubs', $hub_list);
     $this->set('hub_list', $hub_list);
     $country_list = Countries::getAllCountries();
     $this->set('countries', $country_list);
     $this->set('country_list', $country_list);
     $this->render('registration_mainform.tpl');
 }
Ejemplo n.º 12
0
 public function index()
 {
     if ($this->get->maptype == 'hubmap') {
         // Show hubmap
         $params = array('s.depicao' => $this->get->hub, 's.enabled' => 1);
         // Show only 20 routes
         $allschedules = SchedulesData::findSchedules($params, Config::Get('ROUTE_MAP_SHOW_NUMBER'));
         if (count($allschedules) == 0) {
             echo 'There are no departures from this airport!';
             return;
         }
         $airportinfo = OperationsData::GetAirportInfo($this->get->hub);
         echo '<h3>Departures from ' . $airportinfo->name . '</h3>';
     } else {
         # Get all of the schedule
         $allschedules = SchedulesData::findSchedules(array('s.enabled' => 1), Config::Get('ROUTE_MAP_SHOW_NUMBER'));
     }
     $this->set('allschedules', $allschedules);
     $this->render('flown_routes_map.tpl');
 }
Ejemplo n.º 13
0
 /**
  * Get the current fuel price for an airport, returns it in the
  * unit specified in the config file
  *
  * @param string $apt_icao ICAO of the airport
  * @return float Fuel price
  *
  * @version 709 rewritten
  */
 public static function getFuelPrice($apt_icao)
 {
     $price = false;
     $aptinfo = OperationsData::GetAirportInfo($apt_icao);
     // Live pricing enabled, and the airport is set to '0' for a live price
     if (Config::Get('FUEL_GET_LIVE_PRICE') == true && ($aptinfo->fuelprice == '0' || $aptinfo->fuelprice == '')) {
         $price = self::get_cached_price($apt_icao);
         if (!$price) {
             $price = self::get_from_server($apt_icao);
             if (!is_bool($price)) {
                 return $price;
                 // Returns the JetA price
             }
         } else {
             return $price->jeta;
         }
     }
     /* Live price stuff above failed or was "off" */
     if ($aptinfo->fuelprice == '' || $aptinfo->fuelprice == 0) {
         return Config::Get('FUEL_DEFAULT_PRICE');
     } else {
         return $aptinfo->fuelprice;
     }
 }
Ejemplo n.º 14
0
    /**
     * This updates the ACARS live data for a pilot
     *
     * @param mixed $data This is the data structure with flight properties
     * @return mixed Nothing
     *
     */
    public static function updateFlightData($pilotid, $data)
    {
        if (!is_array($data)) {
            self::$lasterror = 'Data not array';
            return false;
        }
        if (isset($data['code']) && isset($data['flightnum'])) {
            $data['flightnum'] = $data['code'] . $data['flightnum'];
        }
        // Add pilot info
        $pilotinfo = PilotData::getPilotData($pilotid);
        $data['pilotid'] = $pilotid;
        $data['pilotname'] = $pilotinfo->firstname . ' ' . $pilotinfo->lastname;
        // Store for later
        if (isset($data['registration'])) {
            $ac_registration = $data['registration'];
            unset($data['registration']);
        }
        if (isset($data['depicao'])) {
            $dep_apt = OperationsData::GetAirportInfo($data['depicao']);
            $data['depapt'] = DB::escape($dep_apt->name);
        }
        if (isset($data['arricao'])) {
            $arr_apt = OperationsData::GetAirportInfo($data['arricao']);
            $data['arrapt'] = DB::escape($arr_apt->name);
        }
        if (isset($data['route']) && empty($data['route'])) {
            $flight_info = SchedulesData::getProperFlightNum($data['flightnum']);
            $params = array('s.code' => $flight_info['code'], 's.flightnum' => $flight_info['flightnum']);
            $schedule = SchedulesData::findSchedules($params);
            $schedule = $schedule[0];
            $data['route'] = $schedule->route;
            //$data['route_details'] = serialize(SchedulesData::getRouteDetails($schedule->id));
        } elseif (isset($data['route']) && !empty($data['route'])) {
            /*$tmp = new stdClass();
            		$tmp->deplat = $dep_apt->lat;
            		$tmp->deplng = $dep_apt->lng;
            		$tmp->route = $data['route'];
            		
            		$data['route_details'] = NavData::parseRoute($tmp);
            		$data['route_details'] = serialize($data['route_details']);
            		unset($tmp);*/
        }
        if (!empty($data['route_details'])) {
            $data['route_details'] = DB::escape($data['route_details']);
        }
        if (isset($dep_apt)) {
            unset($dep_apt);
        }
        if (isset($arr_apt)) {
            unset($arr_apt);
        }
        // Clean up times
        if (isset($data['deptime']) && !is_numeric($data['deptime'])) {
            $data['deptime'] = strtotime($data['deptime']);
        }
        if (isset($data['arrtime']) && !is_numeric($data['arrtime'])) {
            $data['arrtime'] = strtotime($data['arrtime']);
        }
        /* Check the heading for the flight
        			If none is specified, then point it straight to the arrival airport */
        if ($data['heading'] == '' || !isset($data['heading']) && isset($data['lat']) && isset($data['lng'])) {
            /* Calculate an angle based on current coords and the
            			destination coordinates */
            $data['heading'] = intval(atan2($data['lat'] - $arr_apt->lat, $data['lng'] - $arr_apt->lng) * 180 / 3.14);
            if ($data['lat'] - $data['lng'] < 0) {
                $data['heading'] += 180;
            }
            if ($data['heading'] < 0) {
                $data['heading'] += 360;
            }
        }
        // Manually add the last set
        $data['lastupdate'] = 'NOW()';
        // first see if we exist:
        $sql = 'SELECT `id`
				FROM ' . TABLE_PREFIX . "acarsdata \n\t\t\t\tWHERE `pilotid`={$pilotid}";
        $exist = DB::get_row($sql);
        $flight_id = '';
        if ($exist) {
            // update
            $upd = array();
            $flight_id = $exist->id;
            foreach ($data as $field => $value) {
                $value = DB::escape(trim($value));
                // Append the message log
                if ($field === 'messagelog') {
                    $upd[] = "`messagelog`=CONCAT(`messagelog`, '{$value}')";
                } elseif ($field === 'lastupdate') {
                    $upd[] = "`lastupdate`=NOW()";
                } elseif ($field === 'deptime' || $field === 'arrtime') {
                    /*	If undefined, set a default time to now (penalty for malformed data?)
                    			Won't be quite accurate.... */
                    if ($value == '') {
                        $value = time();
                    }
                    $upd[] = "`{$field}`=FROM_UNIXTIME({$value})";
                } else {
                    $upd[] = "`{$field}`='{$value}'";
                }
            }
            $upd = implode(',', $upd);
            $query = 'UPDATE ' . TABLE_PREFIX . "acarsdata \n\t\t\t\t\tSET {$upd} \n\t\t\t\t\tWHERE `id`='{$flight_id}'";
            DB::query($query);
        } else {
            // form array with $ins[column]=value and then
            //	give it to quick_insert to finish
            $ins = array();
            $vals = array();
            foreach ($data as $field => $value) {
                $ins[] = "`{$field}`";
                if ($field === 'deptime' || $field === 'arrtime') {
                    if (empty($value)) {
                        $value = time();
                    }
                    $vals[] = "FROM_UNIXTIME({$value})";
                } elseif ($field === 'lastupdate') {
                    $vals[] = 'NOW()';
                } else {
                    $value = DB::escape($value);
                    $vals[] = "'{$value}'";
                }
            }
            $ins = implode(',', $ins);
            $vals = implode(',', $vals);
            $query = 'INSERT INTO ' . TABLE_PREFIX . "acarsdata ({$ins}) \n\t\t\t\t\t\tVALUES ({$vals})";
            DB::query($query);
            $data['deptime'] = time();
            $flight_id = DB::$insert_id;
        }
        $flight_info = self::get_flight_by_id($flight_id);
        // Add this cuz we need it
        $data['code'] = $pilotinfo->code;
        $data['pilotid'] = $pilotid;
        $data['unique_id'] = $flight_id;
        $data['aircraft'] = $flight_info->aircraftname;
        $data['registration'] = $flight_info->registration;
        $res = CentralData::send_acars_data($data);
        return true;
    }
Ejemplo n.º 15
0
 /**
  * Parse a pilot ID from a passed ID
  *
  * @param int $pilotid Pass the ID string
  * @return int Returns the integer database ID
  *
  */
 public static function parsePilotID($pilotid)
 {
     if (!is_numeric($pilotid)) {
         $airlines = OperationsData::getAllAirlines();
         foreach ($airlines as $a) {
             $a->code = strtoupper($a->code);
             if (strpos($pilotid, $a->code) === false) {
                 continue;
             }
             $pilotid = intval(str_ireplace($a->code, '', $pilotid));
             $pilotid = $pilotid - Config::Get('PILOTID_OFFSET');
         }
     }
     return $pilotid;
 }
Ejemplo n.º 16
0
 public function editpirep()
 {
     $this->set('pirep', PIREPData::GetReportDetails($this->get->pirepid));
     $this->set('allairlines', OperationsData::GetAllAirlines());
     $this->set('allairports', OperationsData::GetAllAirports());
     $this->set('allaircraft', OperationsData::GetAllAircraft());
     $this->set('fielddata', PIREPData::GetFieldData($this->get->pirepid));
     $this->set('pirepfields', PIREPData::GetAllFields());
     $this->set('comments', PIREPData::GetComments($this->get->pirepid));
     $this->render('pirep_edit.tpl');
 }
Ejemplo n.º 17
0
 /**
  * Process ACARS messages here
  * 
  */
 public function acars()
 {
     if (!isset($_REQUEST['DATA1'])) {
         die("0|Invalid Data");
     }
     if (!isset($_REQUEST['DATA1'])) {
         die("0|Invalid Data");
     }
     // TEST, BEGINFLIGHT, PAUSEFLIGHT, ENDFLIGHT and MESSAGE
     $method = strtoupper($_REQUEST['DATA2']);
     if (!isset($_REQUEST['DATA3'])) {
         $value = '';
     } else {
         $value = $_REQUEST['DATA3'];
     }
     if (!isset($_REQUEST['DATA4'])) {
         $message = '';
     } 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) {
             echo '0|Invalid login data';
             return;
         }
         /*preg_match('/^([A-Za-z]*)(\d*)/', $flight_data[0], $matches);
         		$code = $matches[1];
         		$pilotid = intval($matches[2]) - Config::Get('PILOTID_OFFSET');*/
         $pilotid = PilotData::parsePilotID($flight_data[0]);
         $coords = $this->get_coordinates($flight_data[6]);
         $route = explode('~', $flight_data[5]);
         $depicao = $route[0];
         $arricao = $route[count($route) - 1];
         unset($route[0]);
         unset($route[count($route) - 1]);
         $route = implode(' ', $route);
         $flightinfo = SchedulesData::getProperFlightNum($flight_data[2]);
         $code = $flightinfo['code'];
         $flightnum = $flightinfo['flightnum'];
         $aircraft = $flight_data[3];
         $heading = $flight_data[12];
         $alt = $flight_data[7];
         $gs = 0;
         $dist_remain = $flight_data[16];
         $time_remain = 0;
         $deptime = time();
         $online = 0;
         $fields = array('pilotid' => $pilotid, 'flightnum' => $code . $flightnum, 'aircraft' => $aircraft, 'lat' => $coords['lat'], 'lng' => $coords['lng'], 'heading' => $heading, 'route' => $route, 'alt' => $alt, 'gs' => $gs, 'depicao' => $depicao, 'arricao' => $arricao, 'distremain' => $dist_remain, 'timeremaining' => $time_remain, 'phasedetail' => 'On the ground', 'online' => $online, 'client' => 'fsfk');
     } elseif ($method == 'MESSAGE') {
         $pilotid = $value;
         $flight_data = ACARSData::get_flight_by_pilot($pilotid);
         // Get the flight
         preg_match("/Flight ID: (.*)\n/", $message, $matches);
         $flightinfo = SchedulesData::getProperFlightNum($matches[1]);
         $code = $flightinfo['code'];
         $flightnum = $flightinfo['flightnum'];
         // Get the aircraft
         preg_match("/.*Aircraft Reg: \\.\\.(.*)\n/", $message, $matches);
         $aircraft_data = OperationsData::GetAircraftByReg(trim($matches[1]));
         $aircraft = $aircraft_data->id;
         $depicao = $flight_data->depicao;
         $arricao = $flight_data->arricao;
         // Get coordinates from ACARS message
         $count = preg_match("/POS(.*)\n/", $message, $matches);
         if ($count > 0) {
             $coords = $this->get_coordinates(trim($matches[1]));
         } else {
             $coords = array('lat' => $flight_data->lat, 'lng' => $flight_data->lng);
         }
         // Get our heading
         preg_match("/\\/HDG.(.*)\n/", $message, $matches);
         $heading = $matches[1];
         // Get our altitude
         preg_match("/\\/ALT.(.*)\n/", $message, $matches);
         $alt = $matches[1];
         // Get our speed
         preg_match("/\\/IAS.(.*)\\//", $message, $matches);
         $gs = $matches[1];
         $fields = array('pilotid' => $pilotid, 'aircraft' => $aircraft, 'lat' => $coords['lat'], 'lng' => $coords['lng'], 'heading' => $heading, 'alt' => $alt, 'gs' => $gs, 'phasedetail' => 'Enroute');
     } elseif ($method == 'UPDATEFLIGHTPLAN') {
         $flight_id = $value;
         $flight_data = explode("|", $message);
         echo '1|';
         return;
     }
     $depapt = OperationsData::GetAirportInfo($depicao);
     $dist_remain = SchedulesData::distanceBetweenPoints($coords->lat, $coords->lng, $depapt->lat, $depapt->lng);
     # Estimate the time remaining
     if ($gs != 0) {
         $time_remain = $dist_remain / $gs;
     } else {
         $time_remain = '0';
     }
     $fields['distremain'] = $dist_remain;
     $fields['timeremaining'] = $time_remain;
     if ($deptime != '') {
         $fields['deptime'] = $deptime;
     }
     if ($arrtime != '') {
         $fields['arrtime'] = $arrtime;
     }
     Debug::log(print_r($fields, true), 'fsfk');
     ACARSData::updateFlightData($pilotid, $fields);
     $id = DB::$insert_id;
     if ($method == 'BEGINFLIGHT') {
         echo '1|' . $pilotid;
         return;
     }
     echo '1|';
 }
Ejemplo n.º 18
0
 public function routeinfo($depicao = '', $arricao = '')
 {
     header('Content-type: text/xml');
     if ($depicao == '') {
         $depicao = $_GET['depicao'];
     }
     if ($arricao == '') {
         $arricao = $_GET['arricao'];
     }
     if ($depicao == '' || $arricao == '') {
         return;
     }
     $depinfo = OperationsData::GetAirportInfo($depicao);
     if (!$depinfo) {
         $depinfo = OperationsData::RetrieveAirportInfo($depicao);
     }
     $arrinfo = OperationsData::GetAirportInfo($arricao);
     if (!$arrinfo) {
         $arrinfo = OperationsData::RetrieveAirportInfo($arricao);
     }
     $xml = new SimpleXMLElement('<flightinfo/>');
     $dep = $xml->addChild('departure');
     $dep->addAttribute('icao', $depinfo->icao);
     $dep->addAttribute('name', $depinfo->name);
     $dep->addAttribute('country', $depinfo->country);
     $dep->addAttribute('lat', $depinfo->lat);
     $dep->addAttribute('lng', $depinfo->lng);
     $arr = $xml->addChild('arrival');
     $arr->addAttribute('icao', $arrinfo->icao);
     $arr->addAttribute('name', $arrinfo->name);
     $arr->addAttribute('country', $arrinfo->country);
     $arr->addAttribute('lat', $arrinfo->lat);
     $arr->addAttribute('lng', $arrinfo->lng);
     header('Content-type: text/xml');
     echo $xml->asXML();
 }
Ejemplo n.º 19
0
 /**
  * Get the active load count based on the load factor
  *  based on the flight type: P(assenger), C(argo), H(Charter)
  */
 public static function getLoadCount($aircraft_id, $flighttype = 'P')
 {
     $flighttype = strtoupper($flighttype);
     # Calculate our load factor for this flight
     #	Charter flights always will have a 100% capacity
     if ($flighttype == 'H') {
         $load = 100;
     } else {
         # Not a charter
         $loadfactor = intval(Config::Get('LOAD_FACTOR'));
         $load = rand($loadfactor - LOAD_VARIATION, $loadfactor + LOAD_VARIATION);
         # Don't allow a load of more than 95%
         if ($load > 95) {
             $load = 95;
         } elseif ($load <= 0) {
             $load = 92;
         }
         # Use ATA standard of 72%
     }
     /*
      * Get the maximum allowed based on the aircraft flown
      */
     $aircraft = OperationsData::GetAircraftInfo($aircraft_id);
     if (!$aircraft) {
         if ($flighttype == 'C') {
             # Check cargo if cargo flight
             $count = Config::Get('DEFAULT_MAX_CARGO_LOAD');
         } else {
             $count = Config::Get('DEFAULT_MAX_PAX_LOAD');
         }
     } else {
         if ($flighttype == 'C') {
             # Check cargo if cargo flight
             $count = $aircraft->maxcargo;
         } else {
             $count = $aircraft->maxpax;
         }
     }
     $load = $load / 100;
     $currload = ceil($count * $load);
     return $currload;
 }
Ejemplo n.º 20
0
        $_GET['dest'] = DB::escape($_GET['dest']);
        # Get schedule info, using minimal information
        #	Check if they forgot the flight code
        if ($code == '') {
            # Find a flight using just the flight code
            $sched = SchedulesData::FindFlight($flightnum);
            # Can't do it. They completely f****d this up
            if (!$sched) {
                return;
            }
            $code = $sched->code;
            $flightnum = $sched->flightnum;
            if ($_GET['origin'] != $sched->depicao || $_GET['dest'] != $sched->arricao) {
                $comment = 'phpVMS Message: Arrival or Departure does not match schedule';
            }
        }
        # Make sure airports exist:
        #  If not, add them.
        if (!OperationsData::GetAirportInfo($_GET['origin'])) {
            OperationsData::RetrieveAirportInfo($_GET['origin']);
        }
        if (!OperationsData::GetAirportInfo($_GET['dest'])) {
            OperationsData::RetrieveAirportInfo($_GET['dest']);
        }
        # Convert the time to xx.xx
        $flighttime = number_format(floatval(str_replace(':', '.', $_GET['duration'])), 2);
        $data = array('pilotid' => $pilotid, 'code' => $code, 'flightnum' => $flightnum, 'depicao' => $_GET['origin'], 'arricao' => $_GET['dest'], 'aircraft' => $ac->id, 'flighttime' => $flighttime, 'landingrate' => $landingrate, 'submitdate' => 'NOW()', 'comment' => $comment, 'fuelused' => $_GET['fuel'], 'source' => 'fsacars', 'route' => $route, 'load' => $load, 'rawdata' => $log, 'log' => $_GET['log']);
        $ret = ACARSData::FilePIREP($pilotid, $data);
        echo 'OK';
        break;
}
Ejemplo n.º 21
0
 protected static function process_airport_list()
 {
     self::set_xml('process_airport_list');
     foreach (self::$response->airport as $apt) {
         // Get from API
         $apt = OperationsData::GetAirportInfo($apt->icao);
         if ($apt) {
             $airport = self::$xml->addChild('airport');
             $airport->addChild('icao', $apt->icao);
             $airport->addChild('name', $apt->name);
             $airport->addChild('location', $apt->country);
             $airport->addChild('lat', $apt->lat);
             $airport->addChild('lng', $apt->lng);
         }
     }
 }
Ejemplo n.º 22
0
 			$pilotid = $data[0];
 		}*/
 $pilotid = PilotData::parsePilotID($data[0]);
 # Make sure airports exist:
 #  If not, add them.
 $depicao = $data[6];
 $arricao = $data[7];
 if (!OperationsData::GetAirportInfo($depicao)) {
     OperationsData::RetrieveAirportInfo($depicao);
 }
 if (!OperationsData::GetAirportInfo($arricao)) {
     OperationsData::RetrieveAirportInfo($arricao);
 }
 # Get aircraft information
 $reg = trim($data[3]);
 $ac = OperationsData::GetAircraftByReg($reg);
 # Load info
 /* If no passengers set, then set it to the cargo */
 $load = $data[14];
 if (empty($load)) {
     $load = $data[15];
 }
 # Convert the time to xx.xx
 $flighttime = floatval(str_replace(':', '.', $data[11])) * 1.0;
 /* Fuel conversion - XAcars only reports in lbs */
 $fuelused = $data[12];
 if (Config::Get('LiquidUnit') == '0') {
     # Convert to KGs, divide by density since d = mass * volume
     $fuelused = $fuelused * 0.45359237 / 0.8075;
 } elseif (Config::Get('LiquidUnit') == '1') {
     $fuelused = $fuelused * 6.84;
Ejemplo n.º 23
0
 public static function SiteSetup()
 {
     /*$_POST['SITE_NAME'] == '' || $_POST['firstname'] == '' || $_POST['lastname'] == ''
     		|| $_POST['email'] == '' ||  $_POST['password'] == '' || $_POST['vaname'] == ''
     		|| $_POST['vacode'] == ''*/
     // first add the airline
     $_POST['vacode'] = strtoupper($_POST['vacode']);
     if (!OperationsData::AddAirline($_POST['vacode'], $_POST['vaname'])) {
         self::$error = DB::$error;
         return false;
     }
     // Add an initial airport/hub, because I love KJFK so much
     $data = array('icao' => 'KJFK', 'name' => 'Kennedy International', 'country' => 'USA', 'lat' => '40.6398', 'lng' => '-73.7787', 'hub' => false, 'fuelprice' => 0);
     $ret = OperationsData::AddAirport($data);
     // Add the user
     $data = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'email' => $_POST['email'], l, 'password' => $_POST['password'], 'code' => $_POST['vacode'], 'location' => 'US', 'hub' => 'KJFK', 'confirm' => true);
     if (!RegistrationData::AddUser($data)) {
         self::$error = DB::$error;
         return false;
     }
     // Add a rank
     RanksData::updateRank(1, 'New Hire', 0, fileurl('/lib/images/ranks/newhire.jpg'), 18.0);
     # Add to admin group
     $pilotdata = PilotData::GetPilotByEmail($_POST['email']);
     if (!PilotGroups::AddUsertoGroup($pilotdata->pilotid, 'Administrators')) {
         self::$error = DB::$error;
         return false;
     }
     # Add the final settings in
     SettingsData::SaveSetting('SITE_NAME', $_POST['SITE_NAME']);
     SettingsData::SaveSetting('ADMIN_EMAIL', $_POST['email']);
     SettingsData::SaveSetting('GOOGLE_KEY', $_POST['googlekey']);
     return true;
 }
Ejemplo n.º 24
0
 /**
  * Extract the code and flight number portions from the flight number
  * Ensures that the code and number are properly split
  */
 public static function getProperFlightNum($flightnum)
 {
     if ($flightnum == '') {
         return false;
     }
     $ret = array();
     $flightnum = strtoupper($flightnum);
     $airlines = OperationsData::getAllAirlines(false);
     foreach ($airlines as $a) {
         $a->code = strtoupper($a->code);
         if (strpos($flightnum, $a->code) === false) {
             continue;
         }
         $ret['code'] = $a->code;
         $ret['flightnum'] = str_ireplace($a->code, '', $flightnum);
         return $ret;
     }
     # Invalid flight number
     $ret['code'] = '';
     $ret['flightnum'] = $flightnum;
     return $ret;
 }
Ejemplo n.º 25
0
 public function routeinfo()
 {
     if ($this->get->depicao == '' || $this->get->arricao == '') {
         return;
     }
     $depinfo = OperationsData::GetAirportInfo($this->get->depicao);
     if (!$depinfo) {
         $depinfo = OperationsData::RetrieveAirportInfo($this->get->depicao);
     }
     $arrinfo = OperationsData::GetAirportInfo($this->get->arricao);
     if (!$arrinfo) {
         $arrinfo = OperationsData::RetrieveAirportInfo($this->get->arricao);
     }
     // Convert to json format
     $c = array();
     $c['depapt'] = (array) $depinfo;
     $c['arrapt'] = (array) $arrinfo;
     echo json_encode($c);
 }
Ejemplo n.º 26
0
 public function showSchedules()
 {
     $depapts = OperationsData::GetAllAirports();
     $equip = OperationsData::GetAllAircraftSearchList(true);
     $airlines = OperationsData::GetAllAirlines();
     $this->set('airlines', $airlines);
     $this->set('depairports', $depapts);
     $this->set('equipment', $equip);
     $this->render('schedule_searchform.tpl');
     # Show the routes. Remote this to not show them.
     $schedules = SchedulesData::GetSchedules();
     # Do some filtering and whatnots, take it out of the template...
     $today = getdate();
     $week_number = intval(($today['mday'] - 1) / 7) + 1;
     $current_day == date('w');
     $var_name = 'week' . $week_number;
     # query once, save for later
     if (Config::get('SCHEDULES_ONLY_LAST_PIREP') === true && Auth::LoggedIn() == true) {
         $reports = PIREPData::findPIREPS(array('p.pilotid' => Auth::$userinfo->pilotid, 'p.accepted' => PIREP_ACCEPTED), 1);
         // return only one
     }
     foreach ($schedules as $key => $s) {
         # should we skip schedules based on day of week?
         if (Config::get('CHECK_SCHEDULE_DAY_OF_WEEK') === true) {
             if (isset($s->{$var_name}) && !empty($s->{$var_name})) {
                 # check if today is in the active list for this week
                 if (@substr_count($s->{$var_name}, $current_day) == 0) {
                     unset($schedules[$key]);
                     continue;
                 }
             } else {
                 if (substr_count($s->daysofweek, date('w')) == 0) {
                     unset($schedules[$key]);
                     continue;
                 }
             }
         }
         # remove this schedule from the list if there's a bid on it
         if (Config::get('DISABLE_SCHED_ON_BID') === true && $route->bidid != 0) {
             unset($schedules[$key]);
             continue;
         }
         /*	This means the aircraft rank level is higher than
          		what the pilot's ranklevel, so just do "continue"
         			and move onto the next route in the list  */
         if (Config::get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn()) {
             if ($route->aircraftlevel > Auth::$userinfo->ranklevel) {
                 unset($schedules[$key]);
                 continue;
             }
         }
         if (Config::get('SCHEDULES_ONLY_LAST_PIREP') === true && Auth::LoggedIn() == true) {
             if (count($reports) > 0) {
                 # IF the arrival airport doesn't match the departure airport
                 if ($reports[0]->arricao != $s->depicao) {
                     unset($schedules[$key]);
                     continue;
                 }
             }
         }
     }
     // end foreach schedules
     $this->set('allroutes', $schedules);
     $this->render('schedule_list.tpl');
 }
Ejemplo n.º 27
0
 public static function getAllAircraft()
 {
     $results = OperationsData::getAllAircraft(true);
     $xml = new SimpleXMLElement("<aircraftdata />");
     $info_xml = $xml->addChild('info');
     foreach ($results as $row) {
         $info_xml->addChild('aircraftICAO', $row->icao);
         $info_xml->addChild('aircraftReg', $row->registration);
     }
     # For debug
     #$this->log("Sending: \n".print_r($xml_string, true), 'kacars');
     header('Content-type: text/xml');
     echo $xml->asXML();
 }
Ejemplo n.º 28
0
 protected function add_schedule_post()
 {
     if ($this->post->code == '' || $this->post->flightnum == '' || $this->post->deptime == '' || $this->post->arrtime == '' || $this->post->depicao == '' || $this->post->arricao == '') {
         $this->set('message', 'All of the fields must be filled out');
         $this->render('core_error.tpl');
         return;
     }
     # Check if the schedule exists
     $sched = SchedulesData::getScheduleByFlight($this->post->code, $this->post->flightnum);
     if (is_object($sched)) {
         $this->set('message', 'This schedule already exists!');
         $this->render('core_error.tpl');
         return;
     }
     $enabled = $this->post->enabled == 'on' ? true : false;
     # Check the distance
     if ($this->post->distance == '' || $this->post->distance == 0) {
         $this->post->distance = OperationsData::getAirportDistance($this->post->depicao, $this->post->arricao);
     }
     # Format the flight level
     $this->post->flightlevel = str_replace(',', '', $this->post->flightlevel);
     $this->post->flightlevel = str_replace(' ', '', $this->post->flightlevel);
     $this->post->route = strtoupper($this->post->route);
     $this->post->route = str_replace($this->post->depicao, '', $this->post->route);
     $this->post->route = str_replace($this->post->arricao, '', $this->post->route);
     $this->post->route = str_replace('SID', '', $this->post->route);
     $this->post->route = str_replace('STAR', '', $this->post->route);
     $data = array('code' => $this->post->code, 'flightnum' => $this->post->flightnum, 'depicao' => $this->post->depicao, 'arricao' => $this->post->arricao, 'route' => $this->post->route, 'aircraft' => $this->post->aircraft, 'flightlevel' => $this->post->flightlevel, 'distance' => $this->post->distance, 'deptime' => $this->post->deptime, 'arrtime' => $this->post->arrtime, 'flighttime' => $this->post->flighttime, 'daysofweek' => implode('', $_POST['daysofweek']), 'price' => $this->post->price, 'flighttype' => $this->post->flighttype, 'notes' => $this->post->notes, 'enabled' => $enabled);
     # Add it in
     $ret = SchedulesData::AddSchedule($data);
     if (DB::errno() != 0 && $ret == false) {
         $this->set('message', 'There was an error adding the schedule, already exists DB error: ' . DB::error());
         $this->render('core_error.tpl');
         return;
     }
     $this->set('message', 'The schedule "' . $this->post->code . $this->post->flightnum . '" has been added');
     $this->render('core_success.tpl');
     LogData::addLog(Auth::$userinfo->pilotid, 'Added schedule "' . $this->post->code . $this->post->flightnum . '"');
 }
Ejemplo n.º 29
0
 /**
  * Installer::SiteSetup()
  * 
  * @return
  */
 public static function SiteSetup()
 {
     /*$_POST['SITE_NAME'] == '' || $_POST['firstname'] == '' || $_POST['lastname'] == ''
     		|| $_POST['email'] == '' ||  $_POST['password'] == '' || $_POST['vaname'] == ''
     		|| $_POST['vacode'] == ''*/
     // first add the airline
     $_POST['vacode'] = strtoupper($_POST['vacode']);
     if (!OperationsData::addAirline($_POST['vacode'], $_POST['vaname'])) {
         self::$error = __FILE__ . ' ' . __LINE__ . ' ' . DB::$error;
         return false;
     }
     // Add the user
     $data = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'email' => $_POST['email'], l, 'password' => $_POST['password'], 'code' => $_POST['vacode'], 'location' => 'US', 'hub' => 'KJFK', 'confirm' => true);
     if (!RegistrationData::addUser($data)) {
         self::$error = __FILE__ . ' ' . __LINE__ . ' ' . DB::$error;
         return false;
     }
     RanksData::calculatePilotRanks();
     # Add to admin group
     $pilotdata = PilotData::getPilotByEmail($_POST['email']);
     if (!PilotGroups::addUsertoGroup($pilotdata->pilotid, 'Administrators')) {
         self::$error = __FILE__ . ' ' . __LINE__ . ' ' . DB::$error;
         return false;
     }
     # Add the final settings in
     SettingsData::SaveSetting('SITE_NAME', $_POST['SITE_NAME']);
     SettingsData::SaveSetting('ADMIN_EMAIL', $_POST['email']);
     SettingsData::SaveSetting('GOOGLE_KEY', $_POST['googlekey']);
     return true;
 }
Ejemplo n.º 30
0
 /**
  * Retrieve Airport Information
  */
 public static function RetrieveAirportInfo($icao)
 {
     $icao = strtoupper($icao);
     if (Config::Get('AIRPORT_LOOKUP_SERVER') == 'geonames') {
         $url = Config::Get('GEONAME_API_SERVER') . '/searchJSON?maxRows=1&style=medium&featureCode=AIRP&type=json&q=' . $icao;
     } elseif (Config::Get('AIRPORT_LOOKUP_SERVER') == 'phpvms') {
         $url = Config::Get('PHPVMS_API_SERVER') . '/index.php/airport/get/' . $icao;
     }
     # Updated to use CodonWebServer instead of simplexml_load_url() straight
     #	Could cause errors
     $file = new CodonWebService();
     $contents = @$file->get($url);
     $reader = json_decode($contents);
     if ($reader->totalResultsCount == 0 || !$reader) {
         return false;
     } else {
         if (isset($reader->geonames)) {
             $apt = $reader->geonames[0];
         } elseif (isset($reader->airports)) {
             $apt = $reader->airports[0];
         }
         if (!isset($apt->jeta)) {
             $apt->jeta = '';
         }
         // Add the AP
         $data = array('icao' => $icao, 'name' => $apt->name, 'country' => $apt->countryName, 'lat' => $apt->lat, 'lng' => $apt->lng, 'hub' => false, 'fuelprice' => $apt->jeta);
         OperationsData::addAirport($data);
     }
     return self::GetAirportInfo($icao);
 }