diff --git a/application/libraries/hamqth.php b/application/libraries/hamqth.php new file mode 100644 index 00000000..3035280e --- /dev/null +++ b/application/libraries/hamqth.php @@ -0,0 +1,85 @@ +session->session_id; + } + + // Set Session Key session. + public function set_session($username, $password) { + + $ci = & get_instance(); + + // URL to the XML Source + $xml_feed_url = 'https://www.hamqth.com/xml.php?u='.$username.';p='.$password; + + // 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->session_id; + + $ci->session->set_userdata('hamqth_session_key', $key); + + return true; + } + + + public function search($callsign, $key) + { + + // URL to the XML Source + $xml_feed_url = 'https://www.hamqth.com/xml.php?id='.$key.'&callsign='.$callsign.'&prg=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); + + // Return Required Fields + $data['callsign'] = (string) $xml->search->callsign; + $data['name'] = (string) $xml->search->nick; + $data['gridsquare'] = (string) $xml->search->grid; + $data['city'] = (string) $xml->search->adr_city; + $data['lat'] = (string) $xml->search->latitude; + $data['long'] = (string) $xml->search->longitude; + $data['iota'] = (string) $xml->search->iota; + + return $data; + } +}