mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-24 11:11:10 +00:00
Merge pull request #536 from HB9HIL/lotw_c2m
This commit is contained in:
@@ -5,20 +5,23 @@ class Dashboard extends CI_Controller
|
||||
|
||||
public function index()
|
||||
{
|
||||
// Database connections
|
||||
$this->load->model('logbook_model');
|
||||
$this->load->model('user_model');
|
||||
|
||||
// LoTW infos
|
||||
$this->load->model('LotwCert');
|
||||
|
||||
// Check if users logged in
|
||||
|
||||
$this->load->model('user_model');
|
||||
if ($this->user_model->validate_session() == 0) {
|
||||
// user is not logged in
|
||||
redirect('user/login');
|
||||
}
|
||||
|
||||
// Database connections
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
// LoTW infos
|
||||
$this->load->model('Lotw_model');
|
||||
$current_date = date('Y-m-d H:i:s');
|
||||
$data['lotw_cert_expired'] = $this->Lotw_model->lotw_cert_expired($this->session->userdata('user_id'), $current_date);
|
||||
$data['lotw_cert_expiring'] = $this->Lotw_model->lotw_cert_expiring($this->session->userdata('user_id'), $current_date);
|
||||
|
||||
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
|
||||
@@ -44,16 +44,11 @@ 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'); }
|
||||
|
||||
// Fire OpenSSL missing error if not found
|
||||
if (!extension_loaded('openssl')) {
|
||||
echo "You must install php OpenSSL for LoTW functions to work";
|
||||
}
|
||||
|
||||
// Load required models for page generation
|
||||
$this->load->model('LotwCert');
|
||||
$this->load->model('Lotw_model');
|
||||
|
||||
// Get Array of the logged in users LoTW certs.
|
||||
$data['lotw_cert_results'] = $this->LotwCert->lotw_certs($this->session->userdata('user_id'));
|
||||
$data['lotw_cert_results'] = $this->Lotw_model->lotw_certs($this->session->userdata('user_id'));
|
||||
|
||||
// Set Page Title
|
||||
$data['page_title'] = __("Logbook of the World");
|
||||
@@ -108,12 +103,7 @@ class Lotw extends CI_Controller {
|
||||
$this->load->model('dxcc');
|
||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
|
||||
// Fire OpenSSL missing error if not found
|
||||
if (!extension_loaded('openssl')) {
|
||||
echo "You must install php OpenSSL for LoTW functions to work";
|
||||
}
|
||||
|
||||
// create folder to store certs while processing
|
||||
// create folder to store certs while processing
|
||||
if (!file_exists('./uploads/lotw/certs')) {
|
||||
mkdir('./uploads/lotw/certs', 0755, true);
|
||||
}
|
||||
@@ -142,7 +132,7 @@ class Lotw extends CI_Controller {
|
||||
else
|
||||
{
|
||||
// Load database queries
|
||||
$this->load->model('LotwCert');
|
||||
$this->load->model('Lotw_model');
|
||||
|
||||
//Upload of P12 successful
|
||||
$data = array('upload_data' => $this->upload->data());
|
||||
@@ -150,20 +140,20 @@ class Lotw extends CI_Controller {
|
||||
$info = $this->decrypt_key($data['upload_data']['full_path']);
|
||||
|
||||
// Check to see if certificate is already in the system
|
||||
$new_certificate = $this->LotwCert->find_cert($info['issued_callsign'], $info['dxcc-id'], $this->session->userdata('user_id'));
|
||||
$new_certificate = $this->Lotw_model->find_cert($info['issued_callsign'], $info['dxcc-id'], $this->session->userdata('user_id'));
|
||||
|
||||
if($new_certificate == 0) {
|
||||
// New Certificate Store in Database
|
||||
|
||||
// Store Certificate Data into MySQL
|
||||
$this->LotwCert->store_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $info['dxcc-id'], $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']);
|
||||
$this->Lotw_model->store_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $info['dxcc-id'], $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']);
|
||||
|
||||
// Cert success flash message
|
||||
$this->session->set_flashdata('Success', $info['issued_callsign'].' Certificate Imported.');
|
||||
} else {
|
||||
// Certificate is in the system time to update
|
||||
|
||||
$this->LotwCert->update_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $info['dxcc-id'], $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']);
|
||||
$this->Lotw_model->update_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $info['dxcc-id'], $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']);
|
||||
|
||||
// Cert success flash message
|
||||
$this->session->set_flashdata('Success', $info['issued_callsign'].' Certificate Updated.');
|
||||
@@ -190,11 +180,6 @@ class Lotw extends CI_Controller {
|
||||
$this->load->model('user_model');
|
||||
$this->user_model->authorize(2);
|
||||
|
||||
// Fire OpenSSL missing error if not found
|
||||
if (!extension_loaded('openssl')) {
|
||||
echo "You must install php OpenSSL for LoTW functions to work";
|
||||
}
|
||||
|
||||
// set the last run in cron table for the correct cron id
|
||||
$this->load->model('cron_model');
|
||||
$this->cron_model->set_last_run($this->router->class.'_'.$this->router->method);
|
||||
@@ -226,9 +211,9 @@ class Lotw extends CI_Controller {
|
||||
foreach ($station_profiles->result() as $station_profile) {
|
||||
|
||||
// Get Certificate Data
|
||||
$this->load->model('LotwCert');
|
||||
$this->load->model('Lotw_model');
|
||||
$data['station_profile'] = $station_profile;
|
||||
$data['lotw_cert_info'] = $this->LotwCert->lotw_cert_details($station_profile->station_callsign, $station_profile->station_dxcc);
|
||||
$data['lotw_cert_info'] = $this->Lotw_model->lotw_cert_details($station_profile->station_callsign, $station_profile->station_dxcc);
|
||||
|
||||
// If Station Profile has no LoTW Cert continue on.
|
||||
if(!isset($data['lotw_cert_info']->cert_dxcc_id)) {
|
||||
@@ -324,7 +309,7 @@ class Lotw extends CI_Controller {
|
||||
|
||||
if(curl_errno($ch)){
|
||||
echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Failed - ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).")<br>";
|
||||
$this->LotwCert->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed");
|
||||
$this->Lotw_model->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed");
|
||||
if (curl_errno($ch) == 28) { // break on timeout
|
||||
echo "Timeout reached. Stopping subsequent uploads.<br>";
|
||||
break;
|
||||
@@ -338,7 +323,7 @@ class Lotw extends CI_Controller {
|
||||
if ($pos === false) {
|
||||
// Upload of TQ8 Failed for unknown reason
|
||||
echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Failed - ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).")<br>";
|
||||
$this->LotwCert->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed");
|
||||
$this->Lotw_model->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed");
|
||||
if (curl_errno($ch) == 28) { // break on timeout
|
||||
echo "Timeout reached. Stopping subsequent uploads.<br>";
|
||||
break;
|
||||
@@ -350,7 +335,7 @@ class Lotw extends CI_Controller {
|
||||
|
||||
echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Successful - ".$filename_for_saving."<br>";
|
||||
|
||||
$this->LotwCert->last_upload($data['lotw_cert_info']->lotw_cert_id, "Success");
|
||||
$this->Lotw_model->last_upload($data['lotw_cert_info']->lotw_cert_id, "Success");
|
||||
|
||||
// Mark QSOs as Sent
|
||||
foreach ($qso_id_array as $qso_number) {
|
||||
@@ -389,9 +374,9 @@ 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'); }
|
||||
|
||||
$this->load->model('LotwCert');
|
||||
$this->load->model('Lotw_model');
|
||||
|
||||
$this->LotwCert->delete_certificate($this->session->userdata('user_id'), $cert_id);
|
||||
$this->Lotw_model->delete_certificate($this->session->userdata('user_id'), $cert_id);
|
||||
|
||||
$this->session->set_flashdata('Success', 'Certificate Deleted.');
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class LotwCert extends CI_Model {
|
||||
class Lotw_model extends CI_Model {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -113,14 +113,13 @@ function echo_table_col($row, $name) {
|
||||
|
||||
<?php if ($this->session->userdata('user_id')) { ?>
|
||||
<?php
|
||||
$current_date = date('Y-m-d H:i:s');
|
||||
if($this->LotwCert->lotw_cert_expired($this->session->userdata('user_id'), $current_date) == true) { ?>
|
||||
if($lotw_cert_expired == true) { ?>
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<span class="badge text-bg-info"><?= __("Important"); ?></span> <i class="fas fa-hourglass-end"></i> <?= __("At least one of your LoTW certificates is expired!"); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if($this->LotwCert->lotw_cert_expiring($this->session->userdata('user_id'), $current_date) == true) { ?>
|
||||
<?php if($lotw_cert_expiring == true) { ?>
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<span class="badge text-bg-info"><?= __("Important"); ?></span> <i class="fas fa-hourglass-half"></i> <?= __("At least one of your LoTW certificates is about to expire!"); ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user