summaryrefslogtreecommitdiff
path: root/controllers/controllers.php
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2018-06-21 18:33:32 -0700
committerAaron Parecki <aaron@parecki.com>2018-06-21 18:33:32 -0700
commitc67f48eb28a8aa3fafa161104fc360babf3ed038 (patch)
treef3bfbd5680ccd359ef68a3d58ccca7650b920a4e /controllers/controllers.php
parent63655f119bf2f0c70d1b563ca69c88a4d0988fb7 (diff)
set timezone of itinerary legs based on airport location
Diffstat (limited to 'controllers/controllers.php')
-rw-r--r--controllers/controllers.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/controllers/controllers.php b/controllers/controllers.php
index bc13dd3..9a49305 100644
--- a/controllers/controllers.php
+++ b/controllers/controllers.php
@@ -1005,3 +1005,23 @@ $app->get('/edit', function() use($app) {
$app->redirect($url . '?edit=' . $params['url'], 302);
}
});
+
+$app->get('/airport-info', function() use($app){
+ if($user=require_login($app)) {
+ $params = $app->request()->params();
+ if(!isset($params['code'])) return;
+
+ $ch = curl_init('https://atlas.p3k.io/api/timezone?airport='.urlencode($params['code']));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ $data = json_decode(curl_exec($ch), true);
+
+ if(!$data)
+ $response = ['error' => 'unknown'];
+ else {
+ $response = $data;
+ }
+
+ $app->response()['Content-type'] = 'application/json';
+ $app->response()->body(json_encode($response));
+ }
+});