SCP check now includes database from Club Log

You can automatically download the SCP from Club Log via index.php/update/update_clublog_scp
pull/372/head
Peter Goodhall 2019-10-11 16:42:18 +01:00
rodzic 576442a5cb
commit ab35f34467
4 zmienionych plików z 199872 dodań i 21 usunięć

Wyświetl plik

@ -24,31 +24,61 @@ class Lookup extends CI_Controller {
public function scp($call) {
if($call) {
$uppercase_callsign = strtoupper($call);
}
// SCP results from logbook
$this->load->model('logbook_model');
$log_calls = $this->logbook_model->get_callsigns($call);
$arCalls = array();
if($log_calls != "") {
echo $log_calls ." ";
}
$query = $this->logbook_model->get_callsigns($uppercase_callsign);
foreach ($query->result() as $row)
{
if (in_array($row->COL_CALL, $arCalls) == false)
{
$arCalls[] = $row->COL_CALL;
}
}
// SCP results from 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[] = $value;
}
}
}
$file = 'updates/masterscp.txt';
if (is_readable($file)) {
$lines = file($file, FILE_IGNORE_NEW_LINES);
$input = preg_quote($call, '~');
$input = preg_quote($uppercase_callsign, '~');
$result = preg_grep('~' . $input . '~', $lines, 0);
foreach ($result as &$value) {
echo " ".$value. " ";
if (in_array($value, $arCalls) == false)
{
$arCalls[] = $value;
}
}
}
sort($arCalls);
foreach ($arCalls as $strCall)
{
echo " " . $strCall . " ";
}
}

Wyświetl plik

@ -225,5 +225,36 @@ class Update extends CI_Controller {
}
public function update_clublog_scp() {
$strFile = "./updates/clublog_scp.txt";
$url = "https://cdn.clublog.org/clublog.scp.gz";
set_time_limit(300);
$this->update_status("Downloading Club Log SCP file");
$gz = gzopen($url, 'r');
if ($gz)
{
$data = "";
while (!gzeof($gz)) {
$data .= gzgetc($gz);
}
gzclose($gz);
file_put_contents($strFile, $data);
if (file_exists($strFile))
{
$nCount = count(file($strFile));
if ($nCount > 0)
{
$this->update_status("DONE: " . number_format($nCount) . " callsigns loaded" );
} else {
$this->update_status("FAILED: Empty file");
}
} else {
$this->update_status("FAILED: Could not create Club Log SCP file locally");
}
} else {
$this->update_status("FAILED: Could not connect to Club Log");
}
}
}
?>

Wyświetl plik

@ -180,18 +180,7 @@ class Logbook_model extends CI_Model {
$this->db->distinct();
$this->db->like('COL_CALL', $callsign);
$query = $this->db->get($this->config->item('table_name'));
$result = "";
foreach ($query->result() as $row)
{
$result = $result." ".$row->COL_CALL;
}
return $result;
return $this->db->get($this->config->item('table_name'));
}

199801
updates/clublog_scp.txt 100644

Plik diff jest za duży Load Diff