diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index 43a05855f..cfe24f285 100644 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -1,4 +1,4 @@ -optionslib->get_option('version')); $xml = curl_exec($ch); curl_close($ch); - + // Create XML object $xml = simplexml_load_string($xml); - + // Return Session Key return (string) $xml->Session->Key; } - + // Set Session Key session. public function set_session($username, $password) { - + $ci = & get_instance(); - + // URL to the XML Source $xml_feed_url = 'https://xmldata.qrz.com/xml/current/?username='.$username.';password='.urlencode($password).';agent=wavelog'; - + // CURL Functions $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $xml_feed_url); @@ -49,14 +49,14 @@ class Qrz { curl_setopt($ch, CURLOPT_USERAGENT, 'Wavelog/'.$ci->optionslib->get_option('version')); $xml = curl_exec($ch); curl_close($ch); - + // Create XML object $xml = simplexml_load_string($xml); - + $key = (string) $xml->Session->Key; - + $ci->session->set_userdata('qrz_session_key', $key); - + return true; } @@ -78,15 +78,19 @@ class Qrz { curl_setopt($ch, CURLOPT_USERAGENT, 'Wavelog/'.$ci->optionslib->get_option('version')); $xml = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + if ($httpcode != 200) { + $message = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); + log_message('debug', 'QRZ.com search for callsign: ' . $callsign . ' returned message: ' . $message . ' HTTP code: ' . $httpcode); + curl_close($ch); + return $data['error'] = 'Problems with qrz.com communication'; // Exit function if no 200. If request fails, 0 is returned + } curl_close($ch); - if ($httpcode != 200) return $data['error'] = 'Problems with qrz.com communication'; // Exit function if no 200. If request fails, 0 is returned - // Create XML object $xml = simplexml_load_string($xml); if (!empty($xml->Session->Error)) { return $data['error'] = $xml->Session->Error; } - + // Return Required Fields $data['callsign'] = (string)$xml->Callsign->call;