From 93156261e2a930c8ec9281db472ca84757e21df0 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Tue, 13 Nov 2012 17:02:43 +0000 Subject: [PATCH] Includes QRZ XML Lookup functions if you have a subcription --- application/config/config.php | 15 ++++++ application/libraries/qrz.php | 83 +++++++++++++++++++++++++++++++++ application/views/qso/index.php | 6 +++ 3 files changed, 104 insertions(+) create mode 100644 application/libraries/qrz.php diff --git a/application/config/config.php b/application/config/config.php index 17c7a4c0..064ccfd0 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -9,12 +9,15 @@ | 'app_name' Name of the App 'Cloudlog' | 'app_version' Set by the dev team. | 'directory' directory where cloudlog is installed eg "logger" +| 'callbook' Selects which Callbook lookup to use defaults "callbytxt" but supports "qrz" */ $config['app_name'] = "Cloudlog"; $config['app_version'] = "0.1"; $config['directory'] = "logbook"; +$config['callbook'] = "callbytxt"; // Options are qrz or callbytxt + /* |-------------------------------------------------------------------------- | Logbook Options @@ -51,6 +54,18 @@ $config['auth_level'][2] = "Editor"; $config['auth_level'][3] = "API User"; $config['auth_level'][99] = "Administrator"; +/* +|-------------------------------------------------------------------------- +| QRZ Subscription Information +|-------------------------------------------------------------------------- +| +| 'username' QRZ.com Username +| 'password' Default locator used to calculate bearings/distance +*/ + +$config['qrz_username'] = ""; +$config['qrz_password'] = ""; + /* |-------------------------------------------------------------------------- | Base Site URL diff --git a/application/libraries/qrz.php b/application/libraries/qrz.php new file mode 100644 index 00000000..796ebda3 --- /dev/null +++ b/application/libraries/qrz.php @@ -0,0 +1,83 @@ +Session->Key; + } + + // Set Session Key session. + public function set_session($username, $password) { + + // URL to the XML Source + $xml_feed_url = 'http://xmldata.qrz.com/xml/current/?username='.$username.';password='.$password.';agent=cloudlog'; + + // CURL Functions + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $xml_feed_url); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $xml = curl_exec($ch); + curl_close($ch); + + // Create XML object + $xml = simplexml_load_string($xml); + + $key = (string) $xml->Session->Key; + + $this->session->set_userdata('qrz_session_key', $key); + + return true; + } + + + public function search($callsign, $key) + { + + // URL to the XML Source + $xml_feed_url = 'http://xmldata.qrz.com/xml/current/?s='.$key.';callsign='.$callsign.''; + + // CURL Functions + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $xml_feed_url); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $xml = curl_exec($ch); + curl_close($ch); + + // Create XML object + $xml = simplexml_load_string($xml); + + // Return Required Fields + $data['callsign'] = (string) $xml->Callsign->call; + $data['name'] = (string) $xml->Callsign->fname; + $data['gridsquare'] = (string) $xml->Callsign->grid; + $data['city'] = (string) $xml->Callsign->addr2; + $data['lat'] = (string) $xml->Callsign->lat; + $data['long'] = (string) $xml->Callsign->lon; + $data['iota'] = (string) $xml->Callsign->iota; + + return $data; + } +} diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 8a353977..6b620a35 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -515,6 +515,12 @@ $('#qth').val(result); }); } + + if($('#qth').val() == "") { + $.get('logbook/callsign_iota/' + $(this).val(), function(result) { + $('#iota_ref').val(result); + }); + } } });