From f03ad1d0b0f48e4e8a034a7293871c3bac406cc0 Mon Sep 17 00:00:00 2001 From: DJ3CE Date: Thu, 4 Apr 2024 19:49:18 +0200 Subject: [PATCH] Switch dxped-url config to options-table --- application/config/config.sample.php | 1 - application/controllers/Workabledxcc.php | 2 +- .../migrations/175_add_dxped_url_option.php | 25 +++++++++++++++++++ application/models/Workabledxcc_model.php | 2 +- 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 application/migrations/175_add_dxped_url_option.php diff --git a/application/config/config.sample.php b/application/config/config.sample.php index 904851a8..4f1c9371 100644 --- a/application/config/config.sample.php +++ b/application/config/config.sample.php @@ -32,7 +32,6 @@ $config['datadir'] = null; // default to install directory $config['table_name'] = "TABLE_HRD_CONTACTS_V01"; $config['locator'] = ""; $config['display_freq'] = true; -$config['dxped_list'] = "https://cdn.cloudlog.org/read_ng3k_dxped_list.php"; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Workabledxcc.php b/application/controllers/Workabledxcc.php index d4373b84..e28ed67b 100644 --- a/application/controllers/Workabledxcc.php +++ b/application/controllers/Workabledxcc.php @@ -30,7 +30,7 @@ class Workabledxcc extends CI_Controller public function dxcclist() { - $json = file_get_contents($this->config->item('dxped_list') ?? 'https://cdn.cloudlog.org/read_ng3k_dxped_list.php'); + $json = file_get_contents($this->optionslib->get_option('dxped_url')); // Decode the JSON data into a PHP array $dataResult = json_decode($json, true); diff --git a/application/migrations/175_add_dxped_url_option.php b/application/migrations/175_add_dxped_url_option.php new file mode 100644 index 00000000..9fa04fe4 --- /dev/null +++ b/application/migrations/175_add_dxped_url_option.php @@ -0,0 +1,25 @@ + "dxped_url", 'option_value' => "https://cdn.cloudlog.org/read_ng3k_dxped_list.php", 'autoload' => "yes"), + ); + + $this->db->insert_batch('options', $data); + } + + public function down() + { + // No option to down + } +} diff --git a/application/models/Workabledxcc_model.php b/application/models/Workabledxcc_model.php index 799a30ab..d7a1860d 100644 --- a/application/models/Workabledxcc_model.php +++ b/application/models/Workabledxcc_model.php @@ -5,7 +5,7 @@ class Workabledxcc_model extends CI_Model public function GetThisWeek() { - $json = file_get_contents($this->config->item('dxped_list') ?? 'https://cdn.cloudlog.org/read_ng3k_dxped_list.php'); + $json = file_get_contents($this->optionslib->get_option('dxped_url')); // Step 2: Convert the JSON data to an array. $data = json_decode($json, true);