mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Enable at least the manual uploading of a file
This commit is contained in:
@@ -99,8 +99,7 @@ class Lotw extends CI_Controller {
|
||||
| and processing of p12 files and storing the data into mysql
|
||||
|
|
||||
*/
|
||||
public function do_cert_upload()
|
||||
{
|
||||
public function do_cert_upload() {
|
||||
$this->load->model('user_model');
|
||||
$this->load->model('dxcc');
|
||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); }
|
||||
@@ -115,8 +114,7 @@ class Lotw extends CI_Controller {
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
if ( ! $this->upload->do_upload('userfile'))
|
||||
{
|
||||
if ( ! $this->upload->do_upload('userfile')) {
|
||||
// Upload of P12 Failed
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
|
||||
@@ -130,9 +128,7 @@ class Lotw extends CI_Controller {
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('lotw_views/upload_cert', $error);
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Load database queries
|
||||
$this->load->model('Lotw_model');
|
||||
|
||||
@@ -675,7 +671,7 @@ class Lotw extends CI_Controller {
|
||||
}
|
||||
|
||||
// Get credentials for LoTW
|
||||
$data['user_lotw_name'] = urlencode($user->user_lotw_name);
|
||||
$data['user_lotw_name'] = urlencode($user->user_lotw_name);
|
||||
$data['user_lotw_password'] = urlencode($user->user_lotw_password);
|
||||
|
||||
$lotw_last_qsl_date = date('Y-m-d', strtotime($this->logbook_model->lotw_last_qsl_date($user->user_id)));
|
||||
@@ -730,107 +726,99 @@ class Lotw extends CI_Controller {
|
||||
}
|
||||
|
||||
$station_ids=$this->Stations->all_station_ids_of_user($this->session->userdata['user_id']);
|
||||
if (!($this->config->item('disable_manual_lotw'))) {
|
||||
$data['page_title'] = __("LoTW ADIF Import");
|
||||
$data['page_title'] = __("LoTW ADIF Import");
|
||||
|
||||
$config['upload_path'] = './uploads/';
|
||||
$config['allowed_types'] = 'adi|ADI';
|
||||
$config['upload_path'] = './uploads/';
|
||||
$config['allowed_types'] = 'adi|ADI';
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
if ($this->input->post('lotwimport') == 'fetch') {
|
||||
$file = $config['upload_path'] . 'lotwreport_download.adi';
|
||||
if (($this->input->post('lotwimport') == 'fetch') && (!($this->config->item('disable_manual_lotw')))) {
|
||||
$file = $config['upload_path'] . 'lotwreport_download.adi';
|
||||
|
||||
// Get credentials for LoTW
|
||||
$query = $this->user_model->get_by_id($this->session->userdata('user_id'));
|
||||
$q = $query->row();
|
||||
$data['user_lotw_name'] = urlencode($q->user_lotw_name ?? '');
|
||||
$data['user_lotw_password'] = urlencode($q->user_lotw_password ?? '');
|
||||
// Get credentials for LoTW
|
||||
$query = $this->user_model->get_by_id($this->session->userdata('user_id'));
|
||||
$q = $query->row();
|
||||
$data['user_lotw_name'] = urlencode($q->user_lotw_name ?? '');
|
||||
$data['user_lotw_password'] = urlencode($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;
|
||||
// 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');
|
||||
}
|
||||
// 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');
|
||||
}
|
||||
|
||||
$customDate = $this->input->post('from');
|
||||
$customDate = $this->input->post('from');
|
||||
|
||||
if ($customDate != NULL) {
|
||||
$lotw_last_qsl_date = date($customDate);
|
||||
if ($customDate != NULL) {
|
||||
$lotw_last_qsl_date = date($customDate);
|
||||
} else {
|
||||
// Query the logbook to determine when the last LoTW confirmation was
|
||||
$lotw_last_qsl_date = date('Y-m-d', strtotime($this->logbook_model->lotw_last_qsl_date($this->session->userdata['user_id'])));
|
||||
}
|
||||
|
||||
// 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'";
|
||||
|
||||
$lotw_url .= "&qso_qslsince=";
|
||||
$lotw_url .= "$lotw_last_qsl_date";
|
||||
|
||||
if ($this->input->post('callsign') != '0') {
|
||||
$lotw_url .= "&qso_owncall=".$this->input->post('callsign');
|
||||
}
|
||||
|
||||
if (is_writable(dirname($file)) && (!file_exists($file) || is_writable($file))) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $lotw_url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
$content = curl_exec($ch);
|
||||
if(!curl_errno($ch)){
|
||||
file_put_contents($file, $content);
|
||||
|
||||
ini_set('memory_limit', '-1');
|
||||
$this->loadFromFile($file, $station_ids);
|
||||
} else {
|
||||
// Query the logbook to determine when the last LoTW confirmation was
|
||||
$lotw_last_qsl_date = date('Y-m-d', strtotime($this->logbook_model->lotw_last_qsl_date($this->session->userdata['user_id'])));
|
||||
}
|
||||
|
||||
// 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'";
|
||||
|
||||
$lotw_url .= "&qso_qslsince=";
|
||||
$lotw_url .= "$lotw_last_qsl_date";
|
||||
|
||||
if ($this->input->post('callsign') != '0') {
|
||||
$lotw_url .= "&qso_owncall=".$this->input->post('callsign');
|
||||
}
|
||||
|
||||
if (is_writable(dirname($file)) && (!file_exists($file) || is_writable($file))) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $lotw_url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
$content = curl_exec($ch);
|
||||
if(!curl_errno($ch)){
|
||||
file_put_contents($file, $content);
|
||||
|
||||
ini_set('memory_limit', '-1');
|
||||
$this->loadFromFile($file, $station_ids);
|
||||
} else {
|
||||
print "LoTW download failed for user ".$data['user_lotw_name'].": ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).").";
|
||||
}
|
||||
} else {
|
||||
if (!is_writable(dirname($file))) {
|
||||
$data['errormsg'] = 'Directory '.dirname($file).' is not writable!';
|
||||
} else if (!is_writable($file)) {
|
||||
$data['errormsg'] = 'File '.$file.' is not writable!';
|
||||
}
|
||||
$this->load->model('Stations');
|
||||
$data['callsigns'] = $this->Stations->callsigns_of_user($this->session->userdata('user_id'));
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('lotw/import', $data);
|
||||
$this->load->view('interface_assets/footer');
|
||||
print "LoTW download failed for user ".$data['user_lotw_name'].": ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).").";
|
||||
}
|
||||
} else {
|
||||
if ( ! $this->upload->do_upload())
|
||||
{
|
||||
|
||||
$data['error'] = $this->upload->display_errors();
|
||||
$this->load->model('Stations');
|
||||
$data['callsigns'] = $this->Stations->callsigns_of_user($this->session->userdata('user_id'));
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('lotw/import', $data);
|
||||
$this->load->view('interface_assets/footer');
|
||||
} else {
|
||||
$data = array('upload_data' => $this->upload->data());
|
||||
|
||||
$this->loadFromFile('./uploads/'.$data['upload_data']['file_name'], $station_ids);
|
||||
if (!is_writable(dirname($file))) {
|
||||
$data['errormsg'] = 'Directory '.dirname($file).' is not writable!';
|
||||
} else if (!is_writable($file)) {
|
||||
$data['errormsg'] = 'File '.$file.' is not writable!';
|
||||
}
|
||||
$this->load->model('Stations');
|
||||
$data['callsigns'] = $this->Stations->callsigns_of_user($this->session->userdata('user_id'));
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('lotw/import', $data);
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
} else {
|
||||
$this->session->set_flashdata('error', __("You're not allowed to do that!"));
|
||||
redirect('dashboard');
|
||||
exit();
|
||||
if (!$this->upload->do_upload()) {
|
||||
|
||||
$data['error'] = $this->upload->display_errors();
|
||||
$this->load->model('Stations');
|
||||
$data['callsigns'] = $this->Stations->callsigns_of_user($this->session->userdata('user_id'));
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('lotw/import', $data);
|
||||
$this->load->view('interface_assets/footer');
|
||||
} else {
|
||||
$data = array('upload_data' => $this->upload->data());
|
||||
|
||||
$this->loadFromFile('./uploads/'.$data['upload_data']['file_name'], $station_ids);
|
||||
}
|
||||
}
|
||||
} // end function
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<?php echo form_open_multipart('lotw/import'); ?>
|
||||
|
||||
<div class="form-check">
|
||||
<input type="radio" id="lotwimport" name="lotwimport" class="form-check-input">
|
||||
<input type="radio" id="lotwimport" name="lotwimport" class="form-check-input"<?php if ($this->config->item('disable_manual_lotw')) { echo ' checked="checked"'; } ?>>
|
||||
<label class="form-check-label" for="lotwimport"><?= __("Upload a File"); ?></label>
|
||||
<br><br>
|
||||
<p><?= sprintf(__("Upload the Exported ADIF file from LoTW from the %s Area, to mark QSOs as confirmed on LoTW."), "<a href='https://p1k.arrl.org/lotwuser/qsos?qsoscmd=adif' target='_blank'>".__("Download Report")."</a>"); ?></p>
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
<br><br>
|
||||
|
||||
<?php if (!$this->config->item('disable_manual_lotw')) { ?>
|
||||
<div>
|
||||
<div class="form-check">
|
||||
<input type="radio" name="lotwimport" id="fetch" class="form-check-input" value="fetch" checked="checked" />
|
||||
@@ -60,6 +61,7 @@
|
||||
|
||||
<p class="form-text text-muted"><?= __("Wavelog will use the LoTW username and password stored in your user profile to download a report from LoTW for you. The report Wavelog downloads will have all confirmations since chosen date, or since your last LoTW confirmation (fetched from your log), up until now."); ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<input class="btn btn-primary" type="submit" value="<?= __("Import LoTW Matches"); ?>" />
|
||||
|
||||
|
||||
@@ -5,10 +5,7 @@
|
||||
</div>
|
||||
<?php } ?>
|
||||
<br>
|
||||
<?php
|
||||
if (!($this->config->item('disable_manual_lotw'))) { ?>
|
||||
<a class="btn btn-outline-primary btn-sm float-end" href="<?php echo site_url('/lotw/import'); ?>" role="button"><i class="fas fa-cloud-download-alt"></i> <?= __("LoTW Import"); ?></a>
|
||||
<?php } ?>
|
||||
<h2><?= __("Logbook of the World"); ?></h2>
|
||||
|
||||
<!-- Card Starts -->
|
||||
|
||||
Reference in New Issue
Block a user