kopia lustrzana https://github.com/magicbug/Cloudlog
Merge pull request #1 from tmcarthur/lotw_web_import
Extract loading logic to private method from Travis KD0HCEpull/129/head
commit
bed4dccb88
|
@ -11,6 +11,72 @@ class Lotw extends CI_Controller {
|
|||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
}
|
||||
|
||||
private function loadFromFile($filepath)
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
set_time_limit(0);
|
||||
|
||||
$this->load->library('adif_parser');
|
||||
|
||||
$this->adif_parser->load_from_file($filepath);
|
||||
|
||||
$this->adif_parser->initialize();
|
||||
|
||||
$table = "<table>";
|
||||
|
||||
while($record = $this->adif_parser->get_record())
|
||||
{
|
||||
if(count($record) == 0)
|
||||
{
|
||||
break;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//echo date('Y-m-d', strtotime($record['qso_date']))."<br>";
|
||||
//echo date('H:m', strtotime($record['time_on']))."<br>";
|
||||
|
||||
//$this->logbook_model->import($record);
|
||||
|
||||
//echo $record["call"]."<br>";
|
||||
//print_r($record->);
|
||||
|
||||
$time_on = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on']));
|
||||
|
||||
$qsl_date = date('Y-m-d', strtotime($record['qslrdate'])) ." ".date('H:i', strtotime($record['qslrdate']));
|
||||
|
||||
if (isset($record['time_off'])) {
|
||||
$time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_off']));
|
||||
} else {
|
||||
$time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on']));
|
||||
}
|
||||
|
||||
$status = $this->logbook_model->import_check($time_on, $record['call'], $record['band']);
|
||||
$lotw_status = $this->logbook_model->lotw_update($time_on, $record['call'], $record['band'], $qsl_date, $record['qsl_rcvd']);
|
||||
|
||||
$table .= "<tr>";
|
||||
$table .= "<td>".$time_on."</td>";
|
||||
$table .= "<td>".$record['call']."</td>";
|
||||
$table .= "<td>".$record['mode']."</td>";
|
||||
$table .= "<td>".$record['qsl_rcvd']."</td>";
|
||||
$table .= "<td>".$qsl_date."</td>";
|
||||
$table .= "<td>QSO Record: ".$status."</td>";
|
||||
$table .= "<td>LoTW Record: ".$lotw_status."</td>";
|
||||
$table .= "<tr>";
|
||||
};
|
||||
|
||||
$table .= "</table>";
|
||||
|
||||
unlink('./uploads/'.$data['upload_data']['file_name']);
|
||||
|
||||
$data['lotw_table'] = $table;
|
||||
|
||||
$data['page_title'] = "LoTW ADIF Information";
|
||||
$this->load->view('layout/header', $data);
|
||||
$this->load->view('lotw/analysis');
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function import() {
|
||||
$data['page_title'] = "LoTW ADIF Import";
|
||||
|
@ -64,67 +130,7 @@ class Lotw extends CI_Controller {
|
|||
file_put_contents($file, file_get_contents($lotw_url));
|
||||
|
||||
ini_set('memory_limit', '-1');
|
||||
set_time_limit(0);
|
||||
|
||||
$this->load->library('adif_parser');
|
||||
|
||||
$this->adif_parser->load_from_file($file);
|
||||
|
||||
$this->adif_parser->initialize();
|
||||
|
||||
$table = "<table>";
|
||||
|
||||
while($record = $this->adif_parser->get_record())
|
||||
{
|
||||
if(count($record) == 0)
|
||||
{
|
||||
break;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//echo date('Y-m-d', strtotime($record['qso_date']))."<br>";
|
||||
//echo date('H:m', strtotime($record['time_on']))."<br>";
|
||||
|
||||
//$this->logbook_model->import($record);
|
||||
|
||||
//echo $record["call"]."<br>";
|
||||
//print_r($record->);
|
||||
|
||||
$time_on = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on']));
|
||||
|
||||
$qsl_date = date('Y-m-d', strtotime($record['qslrdate'])) ." ".date('H:i', strtotime($record['qslrdate']));
|
||||
|
||||
if (isset($record['time_off'])) {
|
||||
$time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_off']));
|
||||
} else {
|
||||
$time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on']));
|
||||
}
|
||||
|
||||
$status = $this->logbook_model->import_check($time_on, $record['call'], $record['band']);
|
||||
$lotw_status = $this->logbook_model->lotw_update($time_on, $record['call'], $record['band'], $qsl_date, $record['qsl_rcvd']);
|
||||
|
||||
$table .= "<tr>";
|
||||
$table .= "<td>".$time_on."</td>";
|
||||
$table .= "<td>".$record['call']."</td>";
|
||||
$table .= "<td>".$record['mode']."</td>";
|
||||
$table .= "<td>".$record['qsl_rcvd']."</td>";
|
||||
$table .= "<td>".$qsl_date."</td>";
|
||||
$table .= "<td>QSO Record: ".$status."</td>";
|
||||
$table .= "<td>LoTW Record: ".$lotw_status."</td>";
|
||||
$table .= "<tr>";
|
||||
};
|
||||
|
||||
$table .= "</table>";
|
||||
|
||||
unlink($file);
|
||||
|
||||
$data['lotw_table'] = $table;
|
||||
|
||||
$data['page_title'] = "LoTW ADIF Information";
|
||||
$this->load->view('layout/header', $data);
|
||||
$this->load->view('lotw/analysis');
|
||||
$this->load->view('layout/footer');
|
||||
loadFromFile($file);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -141,68 +147,7 @@ class Lotw extends CI_Controller {
|
|||
{
|
||||
$data = array('upload_data' => $this->upload->data());
|
||||
|
||||
ini_set('memory_limit', '-1');
|
||||
set_time_limit(0);
|
||||
|
||||
$this->load->library('adif_parser');
|
||||
|
||||
$this->adif_parser->load_from_file('./uploads/'.$data['upload_data']['file_name']);
|
||||
|
||||
$this->adif_parser->initialize();
|
||||
|
||||
$table = "<table>";
|
||||
|
||||
while($record = $this->adif_parser->get_record())
|
||||
{
|
||||
if(count($record) == 0)
|
||||
{
|
||||
break;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//echo date('Y-m-d', strtotime($record['qso_date']))."<br>";
|
||||
//echo date('H:m', strtotime($record['time_on']))."<br>";
|
||||
|
||||
//$this->logbook_model->import($record);
|
||||
|
||||
//echo $record["call"]."<br>";
|
||||
//print_r($record->);
|
||||
|
||||
$time_on = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on']));
|
||||
|
||||
$qsl_date = date('Y-m-d', strtotime($record['qslrdate'])) ." ".date('H:i', strtotime($record['qslrdate']));
|
||||
|
||||
if (isset($record['time_off'])) {
|
||||
$time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_off']));
|
||||
} else {
|
||||
$time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on']));
|
||||
}
|
||||
|
||||
$status = $this->logbook_model->import_check($time_on, $record['call'], $record['band']);
|
||||
$lotw_status = $this->logbook_model->lotw_update($time_on, $record['call'], $record['band'], $qsl_date, $record['qsl_rcvd']);
|
||||
|
||||
$table .= "<tr>";
|
||||
$table .= "<td>".$time_on."</td>";
|
||||
$table .= "<td>".$record['call']."</td>";
|
||||
$table .= "<td>".$record['mode']."</td>";
|
||||
$table .= "<td>".$record['qsl_rcvd']."</td>";
|
||||
$table .= "<td>".$qsl_date."</td>";
|
||||
$table .= "<td>QSO Record: ".$status."</td>";
|
||||
$table .= "<td>LoTW Record: ".$lotw_status."</td>";
|
||||
$table .= "<tr>";
|
||||
};
|
||||
|
||||
$table .= "</table>";
|
||||
|
||||
unlink('./uploads/'.$data['upload_data']['file_name']);
|
||||
|
||||
$data['lotw_table'] = $table;
|
||||
|
||||
$data['page_title'] = "LoTW ADIF Information";
|
||||
$this->load->view('layout/header', $data);
|
||||
$this->load->view('lotw/analysis');
|
||||
$this->load->view('layout/footer');
|
||||
loadFromFile('./uploads/'.$data['upload_data']['file_name']);
|
||||
}
|
||||
}
|
||||
} // end function
|
||||
|
|
Ładowanie…
Reference in New Issue