kopia lustrzana https://github.com/magicbug/Cloudlog
SCP check now includes database from Club Log
You can automatically download the SCP from Club Log via index.php/update/update_clublog_scppull/372/head
rodzic
576442a5cb
commit
ab35f34467
|
@ -24,31 +24,61 @@ class Lookup extends CI_Controller {
|
||||||
|
|
||||||
public function scp($call) {
|
public function scp($call) {
|
||||||
|
|
||||||
|
if($call) {
|
||||||
|
$uppercase_callsign = strtoupper($call);
|
||||||
|
}
|
||||||
|
|
||||||
// SCP results from logbook
|
// SCP results from logbook
|
||||||
$this->load->model('logbook_model');
|
$this->load->model('logbook_model');
|
||||||
|
|
||||||
$log_calls = $this->logbook_model->get_callsigns($call);
|
$arCalls = array();
|
||||||
|
|
||||||
if($log_calls != "") {
|
$query = $this->logbook_model->get_callsigns($uppercase_callsign);
|
||||||
echo $log_calls ." ";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
foreach ($query->result() as $row)
|
||||||
|
{
|
||||||
|
if (in_array($row->COL_CALL, $arCalls) == false)
|
||||||
|
{
|
||||||
|
$arCalls[] = $row->COL_CALL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// SCP results from master scp db
|
// 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';
|
$file = 'updates/masterscp.txt';
|
||||||
|
|
||||||
if (is_readable($file)) {
|
if (is_readable($file)) {
|
||||||
|
|
||||||
$lines = file($file, FILE_IGNORE_NEW_LINES);
|
$lines = file($file, FILE_IGNORE_NEW_LINES);
|
||||||
$input = preg_quote($call, '~');
|
$input = preg_quote($uppercase_callsign, '~');
|
||||||
|
|
||||||
$result = preg_grep('~' . $input . '~', $lines, 0);
|
$result = preg_grep('~' . $input . '~', $lines, 0);
|
||||||
|
|
||||||
foreach ($result as &$value) {
|
foreach ($result as &$value) {
|
||||||
echo " ".$value. " ";
|
if (in_array($value, $arCalls) == false)
|
||||||
|
{
|
||||||
|
$arCalls[] = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort($arCalls);
|
||||||
|
|
||||||
|
foreach ($arCalls as $strCall)
|
||||||
|
{
|
||||||
|
echo " " . $strCall . " ";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -180,18 +180,7 @@ class Logbook_model extends CI_Model {
|
||||||
$this->db->distinct();
|
$this->db->distinct();
|
||||||
$this->db->like('COL_CALL', $callsign);
|
$this->db->like('COL_CALL', $callsign);
|
||||||
|
|
||||||
$query = $this->db->get($this->config->item('table_name'));
|
return $this->db->get($this->config->item('table_name'));
|
||||||
|
|
||||||
$result = "";
|
|
||||||
|
|
||||||
foreach ($query->result() as $row)
|
|
||||||
{
|
|
||||||
|
|
||||||
$result = $result." ".$row->COL_CALL;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Plik diff jest za duży
Load Diff
Ładowanie…
Reference in New Issue