From e1d3e344968cb8cbe593a8475a57efa2b92042ff Mon Sep 17 00:00:00 2001 From: phl0 Date: Mon, 20 May 2024 09:08:59 +0200 Subject: [PATCH] Use cURL for LoTW ADIF import as well --- application/controllers/Lotw.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 00444ac92..680fd18d1 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -758,10 +758,19 @@ class Lotw extends CI_Controller { } if (is_writable(dirname($file)) && (!file_exists($file) || is_writable($file))) { - file_put_contents($file, file_get_contents($lotw_url)); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $lotw_url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); + $content = curl_exec($ch); + if(!curl_errno($ch)){ + file_put_contents($file, $content); - ini_set('memory_limit', '-1'); - $this->loadFromFile($file); + ini_set('memory_limit', '-1'); + $this->loadFromFile($file); + } else { + print "LoTW download failed for user ".$data['user_lotw_name'].": ".curl_strerror(curl_errno($ch))."."; + } } else { if (!is_writable(dirname($file))) { $data['errormsg'] = 'Directory '.dirname($file).' is not writable!';