mischka Posted December 13, 2017 Report Share Posted December 13, 2017 (edited) Hello all, I know lots of you have been annoyed with the absence of the airport lookup function in PHPvms.. well at least I was! So, in a bid to save time not just for myself but also for you, I've recreated a service that provides the same functionality with minimal changes but some extra data All you have to do is this: 1) Go to your local.config.php / app.config.php to change your phpvms_api_server to https://virtualairlines.eu .. if you haven't already 2) Go to /admin/lib/phpvmsadmin.js and scroll to line 250 where it says: url = phpvms_api_server + "/airport/get/" + icao + "&callback=?"; replace it with: url = phpvms_api_server + "/airports.php?icao="+ icao+ "&callback=?"; save it all on your server and the airport lookup should work again! Note that this seems not to work with firefox or internet explorer! Chrome is your safest bet. Now, I have some extra goodies up my sleeve: for every airport I also have the IATA code, city name, timezone offset, dbtimezone and altitude. Don't worry, airport lookup will work without it, but if you want these extra data you have them available now. In the next couple of days I'm going to post on my blog how to implement these extra values and display them on a website. If you have any questions or comments let me know in the comments below. Oh, and I *guarantee* that I will provide this service for free as long as I run this website - although I may restrict it to members of virtualairlines.eu at some point in the future. Edited December 15, 2017 by mischka Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted December 14, 2017 Administrators Report Share Posted December 14, 2017 This looks good, I'm working on a new vacentral library, and it'll be able to be retrofitted. The airport lookup is working in it. You don't need an API key for the Airport lookup call https://github.com/nabeelio/vacentral-library Quote Link to comment Share on other sites More sharing options...
ncd200 Posted December 14, 2017 Report Share Posted December 14, 2017 Thanks, I have installed it but it wont work at my place. keeps saying that it is fetching. Quote Link to comment Share on other sites More sharing options...
CPC900 Posted December 14, 2017 Report Share Posted December 14, 2017 Yes, me as well Quote Link to comment Share on other sites More sharing options...
mischka Posted December 14, 2017 Author Report Share Posted December 14, 2017 (edited) have you changed the phpvms_api_server in the local.config.php or app.config.php? I just did the change on another website (a clean 5.5.2 install) and the lookup works flawlessly. on chrome you can hit F12 and look at the console. You should see some kind of error there. If you are 100% sure you are querying virtualairlines.eu and not the old api server, drop me a PM and attach the phpvmsadmin.js and specify your phpvms version Edited December 14, 2017 by mischka Quote Link to comment Share on other sites More sharing options...
CPC900 Posted December 14, 2017 Report Share Posted December 14, 2017 Ok, the airport lookup worked in Chrome, but NOT in Firefox.....I had been using Firefox Quote Link to comment Share on other sites More sharing options...
mischka Posted December 14, 2017 Author Report Share Posted December 14, 2017 2 minutes ago, CPC900 said: Ok, the airport lookup worked in Chrome, but NOT in Firefox.....I had been using Firefox Ooh, that's odd. It might be some security setting that was implemented after vacentral went down. The only thing you change is the address of the server name. Do you get any error messages in firefox? Quote Link to comment Share on other sites More sharing options...
CPC900 Posted December 14, 2017 Report Share Posted December 14, 2017 No, it just hangs there forever. Weird. Bruce Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted December 14, 2017 Administrators Report Share Posted December 14, 2017 You still need the " "&callback=?";" portion. It might not be working because it needs the JSONP callback Quote Link to comment Share on other sites More sharing options...
mischka Posted December 14, 2017 Author Report Share Posted December 14, 2017 1 hour ago, Nabeel said: You still need the " "&callback=?";" portion. It might not be working because it needs the JSONP callback what callback did you use in the jsonp though? as far as I researched, you had to add some kind of java bit to the json Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted December 14, 2017 Administrators Report Share Posted December 14, 2017 14 minutes ago, mischka said: what callback did you use in the jsonp though? as far as I researched, you had to add some kind of java bit to the json I'm trying to find my code for that... but I don't know where the code is. Hmm. What you basically do is: #instead of this: return jsonencode({"some" => "structure"}); # you do: return $_GET["callback"] . '(' . jsonencode({"some" => "structure"}) . ')'; So you're essentially wrapping the JSON that's returned. So if the request is: airports?icao=KJFK&callback=somefn (the browser populates "somefn" with some name, it gets returned as: somefn({JSON}); 1 Quote Link to comment Share on other sites More sharing options...
mischka Posted December 15, 2017 Author Report Share Posted December 15, 2017 Cheers Nabeel, I'm gonna look into this! Quote Link to comment Share on other sites More sharing options...
Longhaul444 Posted December 31, 2017 Report Share Posted December 31, 2017 (edited) mischka, I followed the instructions to add the extended values. For some reason the table on my admin side isn't showing the extra information, yet it populates when searching and in the db. Here is what I changed in ops.airportlist.php: colNames: ['ICAO', 'IATA', 'Airport Name', 'Hub', 'Country', 'City', 'Fuel Cost', 'Altitude', 'Lat', 'Lng', 'TZ Offset', 'Timezone', 'Edit'], colModel : [ {index: 'icao', name : 'icao', width: 30, sortable : true, align: 'center', search: 'true', searchoptions:{sopt:['eq','ne']}}, {index: 'iata', name : 'iata', width: 30, sortable : true, align: 'center', searchoptions:{sopt:['in']}}, {index: 'name', name : 'name', width: 65, sortable : true, align: 'center', searchoptions:{sopt:['in']}}, {index: 'hub', name : 'hub', width: 15, sortable : true, align: 'center', search: 'false'}, {index: 'country', name : 'country', width: 65, sortable : true, align: 'center', searchoptions:{sopt:['in']}}, {index: 'city', name : 'city', width: 65, sortable : true, align: 'center', search:false}, {index: 'fuelprice', name : 'fuelprice', width: 30, sortable : true, align: 'center', search:false}, {index: 'altitude', name : 'altitude', width: 25, sortable : true, align: 'center', search:false}, {index: 'lat', name : 'lat', width: 40, sortable : true, align: 'center', search:false}, {index: 'lng', name : 'lng', width: 40, sortable : true, align: 'center', search:false}, {index: 'timezone', name : 'timezone', width: 40, sortable : true, align: 'center', search:false}, {index: 'dbtimezone', name : 'dbtimezone', width: 65, sortable : true, align: 'center', search:false}, {index: '', name : '', width: 100, sortable : true, align: 'center', search: false} This is what was changed in the phpvmsadmin.js: $.each(data.airports, function(i, item) { $("#airporticao").val(icao); $("#airportiata").val(item.iata); $("#airportname").val(item.name); $("#airportcity").val(item.city); $("#airportcountry").val(item.countryName); $("#airportlat").val(item.lat); $("#airportlong").val(item.lng); $("#airportaltitude").val(item.altitude); $("#fuelprice").val(item.jeta); $("#airporttimezone").val(item.timezone); $("#airportdbtimezone").val(item.dbtimezone); $("#statusbox").html(""); $("#lookupicao").show(); The ops_airportform.php is changed at instructed: Changed in operations.php: $data = array('icao' => $this->post->icao, 'iata'=> $this->post->iata, 'name' => $this->post->name, 'hub' => $this->post->hub, 'country' => $this->post->country, 'city'=> $this->post->city, 'fuelprice' => $this->post->fuelprice, 'altitude'=> $this->post->altitude, 'lat' => $this->post->lat, 'lng' => $this->post->lng, 'timezone'=> $this->post->timezone, 'dbtimezone'=> $this->post->dbtimezone, 'chartlink' => $this->post->chartlink); operationsdata.php: Line 550: if ($data['icao'] == '') return false; $data['icao'] = strtoupper(DB::escape($data['icao'])); $data['name'] = DB::escape($data['name']); if ($data['hub'] === true) $data['hub'] = 1; else $data['hub'] = 0; if ($data['fuelprice'] == '') $data['fuelprice'] = 0; if (!isset($data['chartlink'])) { $data['chartlink'] = ''; } if($data['timezone'] == '') $data['timezone'] = 0; if($data['altitude'] == '') $data['altitude'] = 0; $sql = "INSERT INTO " . TABLE_PREFIX . "airports ( `icao`, `iata`, `name`, `hub`, `country`, `city`, `fuelprice`, `altitude`, `lat`, `lng`, `timezone`, `dbtimezone`, `chartlink`) VALUES ( '{$data['icao']}', '{$data['iata']}', '{$data['name']}', '{$data['hub']}', '{$data['country']}', '{$data['city']}', '{$data['fuelprice']}', '{$data['altitude']}', '{$data['lat']}', '{$data['lng']}', '{$data['timezone']}', '{$data['dbtimezone']}', '{$data['chartlink']}')"; $res = DB::query($sql); if (DB::errno() != 0) return false; CodonCache::delete('all_airports'); CodonCache::delete('all_airports_json'); CodonCache::delete('get_airport_' . $data['icao']); return true; } Line 596: public static function editAirport($data) { $data['icao'] = strtoupper(DB::escape($data['icao'])); $data['name'] = DB::escape($data['name']); if ($data['hub'] === true) $data['hub'] = 1; else $data['hub'] = 0; if ($data['fuelprice'] == '') $data['fuelprice'] = 0; if($data['timezone'] == '') $data['timezone'] = 0; if($data['altitude'] == '') $data['altitude'] = 0; $sql = "UPDATE " . TABLE_PREFIX . "airports SET `icao`='{$data['icao']}', `iata`='{$data['iata']}', `name`='{$data['name']}',`hub`={$data['hub']}', `country`='{$data['country']}', `city`='{$data['city']}', `fuelprice`={$data['fuelprice']}', `altitude`={$data['altitude']}', `lat`={$data['lat']}', `lng`={$data['lng']}', `timezone`={$data['timezone']}', `dbtimezone`='{$data['dbtimezone']}', `chartlink`='{$data['chartlink']}' WHERE `icao`='{$data['icao']}'"; $res = DB::query($sql); if (DB::errno() != 0) return false; CodonCache::delete('get_airport_' . $data['icao']); CodonCache::delete('all_airports_json'); CodonCache::delete('all_airports'); return true; } I'm scratching my head over this and can't figure out how to get the columns to give the correct information. Any suggestions? Edited January 1, 2018 by Longhaul444 Quote Link to comment Share on other sites More sharing options...
OzFlyer Posted January 2, 2018 Report Share Posted January 2, 2018 Hi there, So far I have done this from the first post: Quote All you have to do is this: 1) Go to your local.config.php / app.config.php to change your phpvms_api_server to https://virtualairlines.eu .. if you haven't already 2) Go to /admin/lib/phpvmsadmin.js and scroll to line 250 where it says: url = phpvms_api_server + "/airport/get/" + icao + "&callback=?"; replace it with: url = phpvms_api_server + "/airports.php?icao="+ icao+ "&callback=?"; save it all on your server and the airport lookup should work again! I am using Chrome and when using "Add new Airport" still only get: Quote Fetching airport data... Have not as yet tried "Import Schedules & Routes. Quote Link to comment Share on other sites More sharing options...
Longhaul444 Posted January 2, 2018 Report Share Posted January 2, 2018 (edited) I'd really love to get this working correctly, as it makes the airport listings more professional looking. Just can't get the columns in the admin section to populate correctly. Haven't tried the import/export yet either. Edited January 2, 2018 by Longhaul444 Quote Link to comment Share on other sites More sharing options...
mischka Posted January 2, 2018 Author Report Share Posted January 2, 2018 5 hours ago, david said: Hi there, So far I have done this from the first post: I am using Chrome and when using "Add new Airport" still only get: Have not as yet tried "Import Schedules & Routes. When you press F12 in chrome, do you get any error messages? 4 hours ago, Longhaul444 said: I'd really love to get this working correctly, as it makes the airport listings more professional looking. Just can't get the columns in the admin section to populate correctly. Haven't tried the import/export yet either. I just tried to add NTSU and it says added but it's not in db Ok, I'm confused.. the airport lookup itself works, but the extra fields don't show up in the columns in the grid? I never thought of extending the grid to be honest, I'd have to look into it. Quote Link to comment Share on other sites More sharing options...
OzFlyer Posted January 2, 2018 Report Share Posted January 2, 2018 1 hour ago, mischka said: When you press F12 in chrome, do you get any error messages? Yes Hope this helps. I did add the google maps API key to "core/templates/core_htmlhead.tpl the other night which fixed routes not being displayed on the public side of the website but has not fixed routes not being displayed in the admin panel ie:routes in PIREP's. I have posted about this in another post and on Discord #support. I have Discord if you want to catch up and talk (UTC+11) Quote Link to comment Share on other sites More sharing options...
mischka Posted January 2, 2018 Author Report Share Posted January 2, 2018 It's strange... the 2nd line below doesn't show the full url you are calling. What is the actual url of your website? Can you send me your phpvms.js by PM? Quote Link to comment Share on other sites More sharing options...
Longhaul444 Posted January 2, 2018 Report Share Posted January 2, 2018 3 hours ago, mischka said: Ok, I'm confused.. the airport lookup itself works, but the extra fields don't show up in the columns in the grid? I never thought of extending the grid to be honest, I'd have to look into it. Could you? That would be awesome if you could figure out where I went wrong. I've been racking my brain for days now trying to figure out what is wrong. Anything you need from me to help figure this out please let me know. Quote Link to comment Share on other sites More sharing options...
mischka Posted January 2, 2018 Author Report Share Posted January 2, 2018 In my operations.php, around line 338, I have this: $tmp = array( 'id' => $row->id, 'cell' => array( # Each column, in order $row->icao, $row->name, $row->country, $row->fuelprice, $row->lat, $row->lng, $edit, ), ); Have you added the new fields there? Quote Link to comment Share on other sites More sharing options...
Longhaul444 Posted January 2, 2018 Report Share Posted January 2, 2018 13 minutes ago, mischka said: In my operations.php, around line 338, I have this: $tmp = array( 'id' => $row->id, 'cell' => array( # Each column, in order $row->icao, $row->name, $row->country, $row->fuelprice, $row->lat, $row->lng, $edit, ), ); Have you added the new fields there? AH, that might be the piece that's missing. let me try and see what happens Quote Link to comment Share on other sites More sharing options...
Longhaul444 Posted January 2, 2018 Report Share Posted January 2, 2018 (edited) That worked! Now I just have to figure out why the IATA code isn't going in. Thanks for the missing piece to the puzzle. And I haven't tried the import function yet either, I'll get back to ya in a bit. Edited January 2, 2018 by Longhaul444 Quote Link to comment Share on other sites More sharing options...
mischka Posted January 2, 2018 Author Report Share Posted January 2, 2018 might be a case senstive problem (iata vs IATA) by import you mean the automatic add of airports when importing schedules? That *should* work, cause afaik it uses the same mechanism. I haven't tried it myself actually Quote Link to comment Share on other sites More sharing options...
Longhaul444 Posted January 2, 2018 Report Share Posted January 2, 2018 3 minutes ago, mischka said: might be a case senstive problem (iata vs IATA) by import you mean the automatic add of airports when importing schedules? That *should* work, cause afaik it uses the same mechanism. I haven't tried it myself actually Yup that was exactly the case. My db had IATA and it was looking for iata. Working beautifully now, thanks for the help. Hopefully the schedules still work. And I changed the template form for the airports admin/lib/airport_template.csv as well to show the extra colums: icao,iata,name,hub,country,city,fuelprice,altitude,lat,lng,timezoneoffset,timezone,chartlink Quote Link to comment Share on other sites More sharing options...
Longhaul444 Posted January 2, 2018 Report Share Posted January 2, 2018 Dunno if this will help David or not, but did you also change the VACENTRAL_API_SERVER to https://virtualairlines.eu as well? That might cause an issue if the vacentral url is still there. Quote Link to comment Share on other sites More sharing options...
OzFlyer Posted January 2, 2018 Report Share Posted January 2, 2018 (edited) 4 hours ago, mischka said: It's strange... the 2nd line below doesn't show the full url you are calling. What is the actual url of your website? Can you send me your phpvms.js by PM? Is this for me or Longhaul444? If for me URL is: http://msfairways.net Quote VACENTRAL_API_SERVER to https://virtualairlines.eu I have check this and it has not been changed. Should I copy this line over to the local.config.php file and edit it? David. Oz Flyer. Edited January 2, 2018 by david Quote Link to comment Share on other sites More sharing options...
mischka Posted January 3, 2018 Author Report Share Posted January 3, 2018 18 hours ago, david said: I have check this and it has not been changed. Should I copy this line over to the local.config.php file and edit it? David. Oz Flyer. Yes, you need to make the change or add it to your local.config.php otherwise you are just querying the old vacentral server Quote Link to comment Share on other sites More sharing options...
Longhaul444 Posted January 4, 2018 Report Share Posted January 4, 2018 (edited) Sorry for my lateness, we got hammered by a snow storm nobody was expecting. Almost a foot of snow. Power just came back on. Ah I see mischka beat me to it. Edited January 4, 2018 by Longhaul444 Quote Link to comment Share on other sites More sharing options...
OzFlyer Posted January 7, 2018 Report Share Posted January 7, 2018 Have added VACENTRAL_API_SERVER to https://virtualairlines.eu to local.config file and ask site owner to restart phpvms. Will report back when restart has been done. Thanks so far for all the help. Quote Link to comment Share on other sites More sharing options...
OzFlyer Posted January 8, 2018 Report Share Posted January 8, 2018 Still not working. Now today the add airport is no longer a popup window but a fresh page of is own and when you click look up you get a blank page with "Some fields were blank" 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.