From ba33f69c6ac9269b88780bd10cf83f586bed1fb6 Mon Sep 17 00:00:00 2001 From: Matt Melling Date: Tue, 1 Sep 2020 20:16:21 +0100 Subject: [PATCH 1/2] configurable updates folder --- application/config/config.sample.php | 2 ++ application/controllers/Update.php | 27 ++++++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/application/config/config.sample.php b/application/config/config.sample.php index 1f596a03..0a168739 100644 --- a/application/config/config.sample.php +++ b/application/config/config.sample.php @@ -19,6 +19,8 @@ $config['directory'] = "logbook"; $config['callbook'] = "hamqth"; // Options are hamqth or qrz +$config['datadir'] = null; // default to install directory + /* |-------------------------------------------------------------------------- | Logbook Options diff --git a/application/controllers/Update.php b/application/controllers/Update.php index 57b78338..62fd454c 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -17,6 +17,19 @@ class Update extends CI_Controller { } + /* + * Create a path to a file in the updates folder, respecting the datadir + * configuration option. + */ + private function make_update_path($path) { + $path = "updates/" . $path; + $datadir = $this->config->item('datadir'); + if(!$datadir) { + return $path; + } + return $datadir . "/" . $path; + } + /* * Load the dxcc entities */ @@ -25,7 +38,7 @@ class Update extends CI_Controller { $this->load->model('dxcc_entities'); // Load the cty file - $xml_data = simplexml_load_file("updates/cty.xml"); + $xml_data = simplexml_load_file($this->make_update_path("cty.xml")); //$xml_data->entities->entity->count(); @@ -74,7 +87,7 @@ class Update extends CI_Controller { // Load Database connectors $this->load->model('dxcc_exceptions'); // Load the cty file - $xml_data = simplexml_load_file("updates/cty.xml"); + $xml_data = simplexml_load_file($this->make_update_path("cty.xml")); $count = 0; foreach ($xml_data->exceptions->exception as $record) { @@ -114,7 +127,7 @@ class Update extends CI_Controller { // Load Database connectors $this->load->model('dxcc_prefixes'); // Load the cty file - $xml_data = simplexml_load_file("updates/cty.xml"); + $xml_data = simplexml_load_file($this->make_update_path("cty.xml")); $count = 0; foreach ($xml_data->prefixes->prefix as $record) { @@ -169,8 +182,8 @@ class Update extends CI_Controller { $data .= gzgetc($gz); } gzclose($gz); - - file_put_contents('./updates/cty.xml', $data); + + file_put_contents($this->make_update_path("cty.xml"), $data); // Clear the tables, ready for new data $this->db->empty_table("dxcc_entities"); @@ -203,7 +216,7 @@ class Update extends CI_Controller { $html = $done."....
"; } - file_put_contents('./updates/status.html', $html); + file_put_contents($this->make_update_path("status.html"), $html); } @@ -226,7 +239,7 @@ class Update extends CI_Controller { } public function update_clublog_scp() { - $strFile = "./updates/clublog_scp.txt"; + $strFile = $this->make_update_path("clublog_scp.txt"); $url = "https://cdn.clublog.org/clublog.scp.gz"; set_time_limit(300); $this->update_status("Downloading Club Log SCP file"); From a7960735858c4b56245d83fc2e1634108a20efac Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 22 Sep 2021 14:19:48 +0200 Subject: [PATCH 2/2] Configurable updates folder. Changed install\config\config.php also. --- install/config/config.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install/config/config.php b/install/config/config.php index 9be40323..44ff528f 100644 --- a/install/config/config.php +++ b/install/config/config.php @@ -18,6 +18,8 @@ $config['app_version'] = "1.7"; $config['directory'] = "%directory%"; $config['callbook'] = "hamqth"; // Options are hamqth or qrz +$config['datadir'] = null; // default to install directory + /* |-------------------------------------------------------------------------- | Logbook Options