Merge pull request #1127 from HB9HIL/qso_improve

[QSO] Improvement and Bugfixes
This commit is contained in:
HB9HIL
2024-10-25 13:24:47 +02:00
committed by GitHub
2 changed files with 72 additions and 69 deletions

View File

@@ -71,73 +71,67 @@ class Lookup extends CI_Controller {
public function scp() {
session_write_close();
$uppercase_callsign = strtoupper($this->input->post('callsign', TRUE) ?? '');
// SCP results from logbook
$this->load->model('logbook_model');
$arCalls = array();
$query = $this->logbook_model->get_callsigns($uppercase_callsign);
foreach ($query->result() as $row)
{
if (in_array($row->COL_CALL, $arCalls) == false)
{
$arCalls[] = str_replace('0', 'Ø', $row->COL_CALL);
}
}
foreach ($query->result() as $row) {
$normalized_call = str_replace('0', 'Ø', $row->COL_CALL);
$arCalls[$normalized_call] = true;
}
// SCP results from Club Log master scp db
$file = 'updates/clublog_scp.txt';
if (is_readable($file)) {
$lines = file($file, FILE_IGNORE_NEW_LINES);
$input = preg_quote($uppercase_callsign, '~');
$result = preg_grep('~' . $input . '~', $lines, 0);
foreach ($result as &$value) {
if (in_array($value, $arCalls) == false)
{
$arCalls[] = str_replace('0', 'Ø', $value);
}
foreach ($result as $value) {
$normalized_call = str_replace('0', 'Ø', $value);
$arCalls[$normalized_call] = true;
}
} else {
$src = 'assets/resources/clublog_scp.txt';
if (copy($src, $file)) {
$this->scp();
return;
} else {
log_message('error', 'Failed to copy source file ('.$src.') to new location. Check if this path has the right permission: '.$file);
}
}
// SCP results from master scp https://www.supercheckpartial.com
$file = 'updates/MASTER.SCP';
if (is_readable($file)) {
$lines = file($file, FILE_IGNORE_NEW_LINES);
$input = preg_quote($uppercase_callsign, '~');
$result = preg_grep('~' . $input . '~', $lines, 0);
foreach ($result as &$value) {
if (in_array($value, $arCalls) == false)
{
$arCalls[] = str_replace('0', 'Ø', $value);
}
foreach ($result as $value) {
$normalized_call = str_replace('0', 'Ø', $value);
$arCalls[$normalized_call] = true;
}
} else {
$src = 'assets/resources/MASTER.SCP';
if (copy($src, $file)) {
$this->scp();
return;
} else {
log_message('error', 'Failed to copy source file ('.$src.') to new location. Check if this path has the right permission: '.$file);
}
}
sort($arCalls);
foreach ($arCalls as $strCall)
{
// Sort and print unique calls
ksort($arCalls);
foreach (array_keys($arCalls) as $strCall) {
echo " " . $strCall . " ";
}
}
public function dok($call) {