Remove unneeded LoTW stuff from the code

This commit is contained in:
phl0
2026-01-07 22:40:01 +01:00
parent 19d688a971
commit ed2a465f90
3 changed files with 1 additions and 167 deletions

View File

@@ -988,134 +988,8 @@ class Lotw extends CI_Controller {
}
} // 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
*/
public function load_users() {