diff --git a/.gitignore b/.gitignore index 01d66723d..14d972ee3 100644 --- a/.gitignore +++ b/.gitignore @@ -8,8 +8,7 @@ /uploads/*.tq8 /uploads/*.TQ8 /install/* -/updates/*.xml -/updates/*.html +/updates/* /images/eqsl_card_images/*.jpg /updates/clublog_scp.txt /assets/qslcard/* diff --git a/application/controllers/Lookup.php b/application/controllers/Lookup.php index 98b85f48e..85ee7ce48 100644 --- a/application/controllers/Lookup.php +++ b/application/controllers/Lookup.php @@ -97,6 +97,13 @@ class Lookup extends CI_Controller { $arCalls[] = str_replace('0', 'Ø', $value); } } + } else { + $src = 'assets/ressources/clublog_scp.txt'; + if (copy($src, $file)) { + $this->scp(); + } else { + log_message('error', 'Failed to copy source file ('.$src.') to new location. Check if this path has the right permission: '.$file); + } } sort($arCalls); diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 9181001fe..66cec848f 100644 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -455,7 +455,7 @@ class QSO extends CI_Controller { $query = isset($_GET['query']) ? $_GET['query'] : FALSE; $wwff = strtoupper($query); - $file = 'assets/json/wwff.txt'; + $file = 'updates/wwff.txt'; if (is_readable($file)) { $lines = file($file, FILE_IGNORE_NEW_LINES); @@ -470,6 +470,13 @@ class QSO extends CI_Controller { $json[] = ["name"=>$value]; } } + } else { + $src = 'assets/ressources/wwff.txt'; + if (copy($src, $file)) { + $this->get_wwff(); + } else { + log_message('error', 'Failed to copy source file ('.$src.') to new location. Check if this path has the right permission: '.$file); + } } } @@ -484,7 +491,7 @@ class QSO extends CI_Controller { $query = isset($_GET['query']) ? $_GET['query'] : FALSE; $pota = strtoupper($query); - $file = 'assets/json/pota.txt'; + $file = 'updates/pota.txt'; if (is_readable($file)) { $lines = file($file, FILE_IGNORE_NEW_LINES); @@ -499,6 +506,13 @@ class QSO extends CI_Controller { $json[] = ["name"=>$value]; } } + } else { + $src = 'assets/ressources/pota.txt'; + if (copy($src, $file)) { + $this->get_pota(); + } else { + log_message('error', 'Failed to copy source file ('.$src.') to new location. Check if this path has the right permission: '.$file); + } } } @@ -516,7 +530,7 @@ class QSO extends CI_Controller { $query = isset($_GET['query']) ? $_GET['query'] : FALSE; $dok = strtoupper($query); - $file = 'assets/json/dok.txt'; + $file = 'updates/dok.txt'; if (is_readable($file)) { $lines = file($file, FILE_IGNORE_NEW_LINES); @@ -531,6 +545,13 @@ class QSO extends CI_Controller { $json[] = ["name"=>$value]; } } + } else { + $src = 'assets/ressources/dok.txt'; + if (copy($src, $file)) { + $this->get_dok(); + } else { + log_message('error', 'Failed to copy source file ('.$src.') to new location. Check if this path has the right permission: '.$file); + } } } diff --git a/application/libraries/Pota.php b/application/libraries/Pota.php index 7e4048851..34e720509 100644 --- a/application/libraries/Pota.php +++ b/application/libraries/Pota.php @@ -15,7 +15,7 @@ class Pota $json = []; $ref = strtoupper($query); - $file = 'assets/json/pota.txt'; + $file = 'updates/pota.txt'; if (is_readable($file)) { $lines = file($file, FILE_IGNORE_NEW_LINES); @@ -29,6 +29,13 @@ class Pota $json[] = ["name" => $value]; } } + } else { + $src = 'assets/ressources/pota.txt'; + if (copy($src, $file)) { + $this->get($query); + } else { + log_message('error', 'Failed to copy source file ('.$src.') to new location. Check if this path has the right permission: '.$file); + } } return $json; diff --git a/application/libraries/Sota.php b/application/libraries/Sota.php index 61bdb858b..7d6304ff8 100644 --- a/application/libraries/Sota.php +++ b/application/libraries/Sota.php @@ -15,7 +15,7 @@ class Sota $json = []; $ref = strtoupper($query); - $file = 'assets/json/sota.txt'; + $file = 'updates/sota.txt'; if (is_readable($file)) { $lines = file($file, FILE_IGNORE_NEW_LINES); @@ -29,6 +29,13 @@ class Sota $json[] = ["name" => $value]; } } + } else { + $src = 'assets/ressources/sota.txt'; + if (copy($src, $file)) { + $this->get($query); + } else { + log_message('error', 'Failed to copy source file ('.$src.') to new location. Check if this path has the right permission: '.$file); + } } return $json; diff --git a/application/libraries/Wwff.php b/application/libraries/Wwff.php index f6d036eab..54ac60166 100644 --- a/application/libraries/Wwff.php +++ b/application/libraries/Wwff.php @@ -15,7 +15,7 @@ class Wwff $json = []; $ref = strtoupper($query); - $file = 'assets/json/wwff.txt'; + $file = 'updates/wwff.txt'; if (is_readable($file)) { $lines = file($file, FILE_IGNORE_NEW_LINES); @@ -29,6 +29,13 @@ class Wwff $json[] = ["name" => $value]; } } + } else { + $src = 'assets/ressources/wwff.txt'; + if (copy($src, $file)) { + $this->get($query); + } else { + log_message('error', 'Failed to copy source file ('.$src.') to new location. Check if this path has the right permission: '.$file); + } } return $json; diff --git a/application/models/Update_model.php b/application/models/Update_model.php index 6e54a3a19..83c02ecc6 100644 --- a/application/models/Update_model.php +++ b/application/models/Update_model.php @@ -47,7 +47,7 @@ class Update_model extends CI_Model { if ($contents === FALSE) { return "Something went wrong with fetching the DOK file."; } else { - $file = './assets/json/dok.txt'; + $file = './updates/dok.txt'; if (file_put_contents($file, $contents) !== FALSE) { // Save our content to the file. $nCount = count(file($file)); @@ -69,7 +69,7 @@ class Update_model extends CI_Model { $csvfile = 'https://www.sotadata.org.uk/summitslist.csv'; - $sotafile = './assets/json/sota.txt'; + $sotafile = './updates/sota.txt'; $csvhandle = fopen($csvfile, "r"); if ($csvhandle === FALSE) { @@ -110,7 +110,7 @@ class Update_model extends CI_Model { $csvfile = 'https://wwff.co/wwff-data/wwff_directory.csv'; - $wwfffile = './assets/json/wwff.txt'; + $wwfffile = './updates/wwff.txt'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $csvfile); @@ -155,7 +155,7 @@ class Update_model extends CI_Model { $csvfile = 'https://pota.app/all_parks.csv'; - $potafile = './assets/json/pota.txt'; + $potafile = './updates/pota.txt'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $csvfile);