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; }
protected function add_airport_post() { if ($this->post->icao == '' || $this->post->name == '' || $this->post->country == '' || $this->post->lat == '' || $this->post->lng == '') { $this->set('message', 'Some fields were blank!'); $this->render('core_error.tpl'); return; } if ($this->post->hub == 'true') { $this->post->hub = true; } else { $this->post->hub = false; } $data = array('icao' => $this->post->icao, 'name' => $this->post->name, 'country' => $this->post->country, 'lat' => $this->post->lat, 'lng' => $this->post->lng, 'hub' => $this->post->hub, 'chartlink' => $this->post->chartlink, 'fuelprice' => $this->post->fuelprice); OperationsData::AddAirport($data); if (DB::errno() != 0) { if (DB::$errno == 1062) { // Duplicate entry $this->set('message', 'This airport has already been added'); } else { $this->set('message', 'There was an error adding the airport'); } $this->render('core_error.tpl'); return; } /*$this->set('message', 'The airport has been added'); $this->render('core_success.tpl');*/ LogData::addLog(Auth::$userinfo->pilotid, 'Added the airport "' . $this->post->icao . ' - ' . $this->post->name . '"'); }
/** * 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]; } // 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); }