From 653d0c0b4c2f0db02fb467eda626c4ab11ea8d08 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Sun, 20 Jul 2025 10:15:05 +0200 Subject: [PATCH] [QRZ callbook] Add logging if http code not 200 --- application/libraries/Qrz.php | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) 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;