mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Merge pull request #2791 from phl0/remoteLotwStuff
Remove unneeded LoTW stuff from the code
This commit is contained in:
@@ -988,134 +988,8 @@ class Lotw extends CI_Controller {
|
|||||||
}
|
}
|
||||||
} // end function
|
} // end function
|
||||||
|
|
||||||
public function export() {
|
|
||||||
$this->load->model('user_model');
|
|
||||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); }
|
|
||||||
|
|
||||||
$data['page_title'] = __("LoTW .TQ8 Upload");
|
|
||||||
|
|
||||||
$config['upload_path'] = './uploads/';
|
|
||||||
$config['allowed_types'] = 'tq8|TQ8';
|
|
||||||
|
|
||||||
$this->load->library('upload', $config);
|
|
||||||
|
|
||||||
if ( ! $this->upload->do_upload())
|
|
||||||
{
|
|
||||||
$data['error'] = $this->upload->display_errors();
|
|
||||||
|
|
||||||
$this->load->view('interface_assets/header', $data);
|
|
||||||
$this->load->view('lotw/export');
|
|
||||||
$this->load->view('interface_assets/footer');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$data = array('upload_data' => $this->upload->data());
|
|
||||||
|
|
||||||
// Figure out how we should be marking QSLs confirmed via LoTW
|
|
||||||
$query = $query = $this->db->query('SELECT lotw_login_url FROM config');
|
|
||||||
$q = $query->row();
|
|
||||||
$config['lotw_login_url'] = $q->lotw_login_url;
|
|
||||||
|
|
||||||
// Set some fields that we're going to need for ARRL login
|
|
||||||
$query = $this->user_model->get_by_id($this->session->userdata('user_id'));
|
|
||||||
$q = $query->row();
|
|
||||||
$fields['login'] = $q->user_lotw_name;
|
|
||||||
$fields['password'] = $q->user_lotw_password;
|
|
||||||
$fields['acct_sel'] = "";
|
|
||||||
|
|
||||||
if ($fields['login'] == '' || $fields['password'] == '')
|
|
||||||
{
|
|
||||||
$this->session->set_flashdata('warning', __("You have not defined your ARRL LoTW credentials!")); redirect('lotw/status');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Curl stuff goes here
|
|
||||||
|
|
||||||
// First we need to get a cookie
|
|
||||||
|
|
||||||
// options
|
|
||||||
$cookie_file_path = "./uploads/cookies.txt";
|
|
||||||
$agent = "Mozilla/4.0 (compatible;)";
|
|
||||||
|
|
||||||
// begin script
|
|
||||||
$ch = curl_init();
|
|
||||||
|
|
||||||
// extra headers
|
|
||||||
$headers[] = "Accept: */*";
|
|
||||||
$headers[] = "Connection: Keep-Alive";
|
|
||||||
|
|
||||||
// basic curl options for all requests
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
||||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
||||||
|
|
||||||
// TODO: These SSL things should probably be set to true :)
|
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
|
|
||||||
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
|
|
||||||
|
|
||||||
// Set login URL
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $config['lotw_login_url']);
|
|
||||||
|
|
||||||
// set postfields using what we extracted from the form
|
|
||||||
$POSTFIELDS = http_build_query($fields);
|
|
||||||
|
|
||||||
// set post options
|
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $POSTFIELDS);
|
|
||||||
|
|
||||||
// perform login
|
|
||||||
$result = curl_exec($ch);
|
|
||||||
if (stristr($result, "Username/password incorrect"))
|
|
||||||
{
|
|
||||||
$this->session->set_flashdata('warning', __("Your ARRL username and/or password is incorrect.")); redirect('lotw/status');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Now we need to use that cookie and upload the file
|
|
||||||
// change URL to upload destination URL
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $config['lotw_login_url']);
|
|
||||||
|
|
||||||
// Grab the file
|
|
||||||
$postfile = array(
|
|
||||||
"upfile"=>"@./uploads/".$data['upload_data']['file_name'],
|
|
||||||
);
|
|
||||||
|
|
||||||
//Upload it
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfile);
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
if (stristr($response, "accepted"))
|
|
||||||
{
|
|
||||||
$this->session->set_flashdata('lotw_status', 'accepted');
|
|
||||||
$data['page_title'] = __("LoTW .TQ8 Sent");
|
|
||||||
}
|
|
||||||
elseif (stristr($response, "rejected"))
|
|
||||||
{
|
|
||||||
$this->session->set_flashdata('lotw_status', 'rejected');
|
|
||||||
$data['page_title'] = __("LoTW .TQ8 Sent");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If we're here, we didn't find what we're looking for in the ARRL response
|
|
||||||
// and LoTW is probably down or broken.
|
|
||||||
$this->session->set_flashdata('warning', 'Did not receive proper response from LoTW. Try again later.');
|
|
||||||
$data['page_title'] = __("LoTW .TQ8 Not Sent");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now we need to clean up
|
|
||||||
unlink($cookie_file_path);
|
|
||||||
unlink('./uploads/'.$data['upload_data']['file_name']);
|
|
||||||
|
|
||||||
$this->load->view('interface_assets/header', $data);
|
|
||||||
$this->load->view('lotw/status');
|
|
||||||
$this->load->view('interface_assets/footer');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Deprecated. To be back compatible we do the same as update/lotw_users
|
Deprecated. To be back compatible we do the same as update/lotw_users
|
||||||
HB9HIL, July 2024
|
HB9HIL, July 2024
|
||||||
*/
|
*/
|
||||||
public function load_users() {
|
public function load_users() {
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
<div class="container">
|
|
||||||
|
|
||||||
<h2><?php echo $page_title; ?></h2>
|
|
||||||
<?php $this->load->view('layout/messages'); ?>
|
|
||||||
|
|
||||||
<h4>Step 1</h4>
|
|
||||||
<a href="<?php echo site_url('adif/export_lotw'); ?>" title="Export LoTW" target="_blank">Export an ADIF</a> file of QSOs that have not been uploaded to LoTW.
|
|
||||||
|
|
||||||
<h4>Step 2</h4>
|
|
||||||
<p>Use Trusted QSL to sign the exported file.</p>
|
|
||||||
|
|
||||||
<h4>Step 3</h4>
|
|
||||||
<p>Select the signed file and click "Upload". It will be sent to LoTW for processing.</p>
|
|
||||||
|
|
||||||
<?php echo form_open_multipart('lotw/export');?>
|
|
||||||
<p><span class="label important">Important</span> Log files must have the file type .tq8</p>
|
|
||||||
<input type="file" name="userfile" size="20" />
|
|
||||||
|
|
||||||
<p>Wavelog will use the LoTW username an password stored in your user profile to download a report from LoTW for you. The report Wavelog downloads will have all confirmations since your last LoTW confirmation, up until now.</p>
|
|
||||||
|
|
||||||
<input class="btn primary" type="submit" value="Upload" />
|
|
||||||
</form>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<div class="container">
|
|
||||||
<h2><?php echo $page_title; ?></h2>
|
|
||||||
|
|
||||||
<?php if($this->session->flashdata('warning')) { ?>
|
|
||||||
<div id="message" >
|
|
||||||
<?php echo $this->session->flashdata('warning'); ?>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
<?php if($this->session->flashdata('lotw_status')) { ?>
|
|
||||||
<div id="message" >
|
|
||||||
<?php echo $this->session->flashdata('lotw_status'); ?>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
Reference in New Issue
Block a user