kopia lustrzana https://github.com/magicbug/Cloudlog
Building function for automatic lotw downloads
rodzic
5b18c3ec38
commit
1e3b085886
|
@ -513,6 +513,50 @@ class Lotw extends CI_Controller {
|
|||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
||||
public function lotw_download() {
|
||||
$this->load->model('user_model');
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$file = $config['upload_path'] . 'lotwreport_download.adi';
|
||||
|
||||
// Get credentials for LoTW
|
||||
$query = $this->user_model->get_by_id($user_id);
|
||||
$q = $query->row();
|
||||
$data['user_lotw_name'] = $q->user_lotw_name;
|
||||
$data['user_lotw_password'] = $q->user_lotw_password;
|
||||
|
||||
// Get URL for downloading LoTW
|
||||
$query = $query = $this->db->query('SELECT lotw_download_url FROM config');
|
||||
$q = $query->row();
|
||||
$lotw_url = $q->lotw_download_url;
|
||||
|
||||
// Validate that LoTW credentials are not empty
|
||||
// TODO: We don't actually see the error message
|
||||
if ($data['user_lotw_name'] == '' || $data['user_lotw_password'] == '')
|
||||
{
|
||||
$this->session->set_flashdata('warning', 'You have not defined your ARRL LoTW credentials!'); redirect('lotw/import');
|
||||
}
|
||||
|
||||
$lotw_last_qsl_date = date('Y-m-d', strtotime($this->logbook_model->lotw_last_qsl_date()));
|
||||
|
||||
// Build URL for LoTW report file
|
||||
$lotw_url .= "?";
|
||||
$lotw_url .= "login=" . $data['user_lotw_name'];
|
||||
$lotw_url .= "&password=" . $data['user_lotw_password'];
|
||||
$lotw_url .= "&qso_query=1&qso_qsl='yes'&qso_qsldetail='yes'&qso_mydetail='yes'";
|
||||
|
||||
//TODO: Option to specifiy whether we download location data from LoTW or not
|
||||
//$lotw_url .= "&qso_qsldetail=\"yes\";
|
||||
|
||||
$lotw_url .= "&qso_qslsince=";
|
||||
$lotw_url .= "$lotw_last_qsl_date";
|
||||
|
||||
file_put_contents($file, file_get_contents($lotw_url));
|
||||
|
||||
ini_set('memory_limit', '-1');
|
||||
$this->loadFromFile($file);
|
||||
}
|
||||
|
||||
public function import() {
|
||||
$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'); }
|
||||
|
|
Ładowanie…
Reference in New Issue