From 2c1b3b65fb7096f5b071f3ea5d8648989be44076 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Sun, 21 Jul 2024 17:47:09 +0200 Subject: [PATCH] fix feedback for dxcc update --- application/controllers/Update.php | 34 ++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/application/controllers/Update.php b/application/controllers/Update.php index dd9674e72..f334fc73c 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -36,7 +36,9 @@ class Update extends CI_Controller { public function dxcc_entities() { // Load the cty file - $this->load->library('Paths'); + if(!$this->load->is_loaded('Paths')) { + $this->load->library('Paths'); + } $xml_data = simplexml_load_file($this->paths->make_update_path("cty.xml")); //$xml_data->entities->entity->count(); @@ -87,7 +89,9 @@ class Update extends CI_Controller { public function dxcc_exceptions() { // Load the cty file - $this->load->library('Paths'); + if(!$this->load->is_loaded('Paths')) { + $this->load->library('Paths'); + } $xml_data = simplexml_load_file($this->paths->make_update_path("cty.xml")); $count = 0; @@ -129,7 +133,9 @@ class Update extends CI_Controller { public function dxcc_prefixes() { // Load the cty file - $this->load->library('Paths'); + if(!$this->load->is_loaded('Paths')) { + $this->load->library('Paths'); + } $xml_data = simplexml_load_file($this->paths->make_update_path("cty.xml")); $count = 0; @@ -169,7 +175,9 @@ class Update extends CI_Controller { // Updates the DXCC & Exceptions from the Club Log Cty.xml file. public function dxcc() { - $this->load->library('Paths'); + if(!$this->load->is_loaded('Paths')) { + $this->load->library('Paths'); + } // set the last run in cron table for the correct cron id $this->load->model('cron_model'); @@ -192,7 +200,7 @@ class Update extends CI_Controller { if ($gz === FALSE) { $this->update_status("FAILED: Could not download from clublog.org"); log_message('error', 'FAILED: Could not download exceptions from clublog.org'); - return; + exit(); } $data = ""; @@ -203,7 +211,7 @@ class Update extends CI_Controller { if (file_put_contents($this->paths->make_update_path("cty.xml"), $data) === FALSE) { $this->update_status("FAILED: Could not write to cty.xml file"); - return; + exit(); } // Clear the tables, ready for new data @@ -220,21 +228,25 @@ class Update extends CI_Controller { $this->db->trans_complete(); $this->update_status(__("DONE")); + + echo 'success'; } public function update_status($done=""){ - $this->load->library('Paths'); + if(!$this->load->is_loaded('Paths')) { + $this->load->library('Paths'); + } if ($done != "Downloading file"){ // Check that everything is done? if ($done == ""){ - $done = "Updating..."; + $done = __("Updating..."); } $html = $done."
"; - $html .= "Dxcc Entities: ".$this->db->count_all('dxcc_entities')."
"; - $html .= "Dxcc Exceptions: ".$this->db->count_all('dxcc_exceptions')."
"; - $html .= "Dxcc Prefixes: ".$this->db->count_all('dxcc_prefixes')."
"; + $html .= __("Dxcc Entities:")." ".$this->db->count_all('dxcc_entities')."
"; + $html .= __("Dxcc Exceptions:")." ".$this->db->count_all('dxcc_exceptions')."
"; + $html .= __("Dxcc Prefixes:")." ".$this->db->count_all('dxcc_prefixes')."
"; } else { $html = $done."....
"; }