diff --git a/application/controllers/Eqsl.php b/application/controllers/Eqsl.php
index 18f6f7aa..64869ea2 100644
--- a/application/controllers/Eqsl.php
+++ b/application/controllers/Eqsl.php
@@ -3,8 +3,7 @@
class eqsl extends CI_Controller {
/* Controls who can access the controller and its functions */
- function __construct()
- {
+ function __construct() {
parent::__construct();
$this->load->helper(array('form', 'url'));
@@ -29,7 +28,7 @@ class eqsl extends CI_Controller {
$this->load->library('upload', $config);
- $this->load->model('logbook_model');
+ $this->load->model('eqslmethods_model');
$eqsl_results = array();
if ($this->input->post('eqslimport') == 'fetch')
@@ -100,17 +99,16 @@ class eqsl extends CI_Controller {
ini_set('memory_limit', '-1');
set_time_limit(0);
- $this->load->model('logbook_model');
+ $this->load->model('eqslmethods_model');
$data['page_title'] = "eQSL QSO Upload";
$custom_date_format = $this->session->userdata('user_date_format');
- if ($this->input->post('eqslexport') == "export")
- {
+ if ($this->input->post('eqslexport') == "export") {
// Get credentials for eQSL
$query = $this->user_model->get_by_id($this->session->userdata('user_id'));
- $q = $query->row();
- $data['user_eqsl_name'] = $q->user_eqsl_name;
+ $q = $query->row();
+ $data['user_eqsl_name'] = $q->user_eqsl_name;
$data['user_eqsl_password'] = $q->user_eqsl_password;
// Validate that eQSL credentials are not empty
@@ -121,347 +119,39 @@ class eqsl extends CI_Controller {
// Grab the list of QSOs to send information about
// perform an HTTP get on each one, and grab the status back
- $qslsnotsent = $this->logbook_model->eqsl_not_yet_sent();
-
- $table = "
";
- $table .= "";
- $table .= "| Date | ";
- $table .= "Time | ";
- $table .= "Call | ";
- $table .= "Mode | ";
- $table .= "Submode | ";
- $table .= "Band | ";
- $table .= "Result | ";
- $table .= "
";
- // Build out the ADIF info string according to specs http://eqsl.cc/qslcard/ADIFContentSpecs.cfm
- foreach ($qslsnotsent->result_array() as $qsl)
- {
+ $qslsnotsent = $this->eqslmethods_model->eqsl_not_yet_sent();
+
+ $rows = "
";
+ foreach ($qslsnotsent->result_array() as $qsl) {
+
// eQSL username changes for linked account.
// i.e. when operating /P it must be callsign/p
// the password, however, is always the same as the main account
$data['user_eqsl_name'] = $qsl['station_callsign'];
+ $adif = $this->generateAdif($qsl, $data);
+
+ $status = $this->uploadQso($adif, $qsl);
- $COL_QSO_DATE = date('Ymd',strtotime($qsl['COL_TIME_ON']));
- $COL_TIME_ON = date('Hi',strtotime($qsl['COL_TIME_ON']));
-
- # Set up the single record file
- $adif = "http://www.eqsl.cc/qslcard/importADIF.cfm?";
- $adif .= "ADIFData=CloudlogUpload%20";
-
- /* Handy reference of escaping chars
- "<" = 3C
- ">" = 3E
- ":" = 3A
- " " = 20
- "_" = 5F
- "-" = 2D
- "." = 2E
- */
-
- $adif .= "%3C";
- $adif .= "ADIF%5FVER";
- $adif .= "%3A";
- $adif .= "4";
- $adif .= "%3E";
- $adif .= "1%2E00 ";
- $adif .= "%20";
-
- $adif .= "%3C";
- $adif .= "EQSL%5FUSER";
- $adif .= "%3A";
- $adif .= strlen($data['user_eqsl_name']);
- $adif .= "%3E";
- $adif .= $data['user_eqsl_name'];
- $adif .= "%20";
-
- $adif .= "%3C";
- $adif .= "EQSL%5FPSWD";
- $adif .= "%3A";
- $adif .= strlen($data['user_eqsl_password']);
- $adif .= "%3E";
- $adif .= urlencode($data['user_eqsl_password']);
- $adif .= "%20";
-
- $adif .= "%3C";
- $adif .= "EOH";
- $adif .= "%3E";
-
- # Lay out the required fields
- $adif .= "%3C";
- $adif .= "QSO%5FDATE";
- $adif .= "%3A";
- $adif .= "8";
- $adif .= "%3E";
- $adif .= $COL_QSO_DATE;
- $adif .= "%20";
-
- $adif .= "%3C";
- $adif .= "TIME%5FON";
- $adif .= "%3A";
- $adif .= "4";
- $adif .= "%3E";
- $adif .= $COL_TIME_ON;
- $adif .= "%20";
-
- $adif .= "%3C";
- $adif .= "CALL";
- $adif .= "%3A";
- $adif .= strlen($qsl['COL_CALL']);
- $adif .= "%3E";
- $adif .= $qsl['COL_CALL'];
- $adif .= "%20";
-
- $adif .= "%3C";
- $adif .= "MODE";
- $adif .= "%3A";
- $adif .= strlen($qsl['COL_MODE']);
- $adif .= "%3E";
- $adif .= $qsl['COL_MODE'];
- $adif .= "%20";
+ $timestamp = strtotime($qsl['COL_TIME_ON']);
+ $rows .= "| ".date($custom_date_format, $timestamp)." | ";
+ $rows .= "".date('H:i', $timestamp)." | ";
+ $rows .= "".str_replace("0","Ø",$qsl['COL_CALL'])." | ";
+ $rows .= "".$qsl['COL_MODE']." | ";
if(isset($qsl['COL_SUBMODE'])) {
- $adif .= "%3C";
- $adif .= "SUBMODE";
- $adif .= "%3A";
- $adif .= strlen($qsl['COL_SUBMODE']);
- $adif .= "%3E";
- $adif .= $qsl['COL_SUBMODE'];
- $adif .= "%20";
+ $rows .= "".$qsl['COL_SUBMODE']." | ";
+ } else {
+ $rows .= " | ";
}
-
- $adif .= "%3C";
- $adif .= "BAND";
- $adif .= "%3A";
- $adif .= strlen($qsl['COL_BAND']);
- $adif .= "%3E";
- $adif .= $qsl['COL_BAND'];
- $adif .= "%20";
-
- # End all the required fields
-
-
- // adding RST_Sent
- $adif .= "%3C";
- $adif .= "RST%5FSENT";
- $adif .= "%3A";
- $adif .= strlen($qsl['COL_RST_SENT']);
- $adif .= "%3E";
- $adif .= $qsl['COL_RST_SENT'];
- $adif .= "%20";
-
- // adding prop mode if it isn't blank
- if ($qsl['COL_PROP_MODE']){
- $adif .= "%3C";
- $adif .= "PROP%5FMODE";
- $adif .= "%3A";
- $adif .= strlen($qsl['COL_PROP_MODE']);
- $adif .= "%3E";
- $adif .= $qsl['COL_PROP_MODE'];
- $adif .= "%20";
- }
-
- // adding sat name if it isn't blank
- if ($qsl['COL_SAT_NAME'] != ''){
- $adif .= "%3C";
- $adif .= "SAT%5FNAME";
- $adif .= "%3A";
- $adif .= strlen($qsl['COL_SAT_NAME']);
- $adif .= "%3E";
- $adif .= str_replace('-', '%2D', $qsl['COL_SAT_NAME']);
- $adif .= "%20";
- }
-
- // adding sat mode if it isn't blank
- if ($qsl['COL_SAT_MODE'] != ''){
- $adif .= "%3C";
- $adif .= "SAT%5FMODE";
- $adif .= "%3A";
- $adif .= strlen($qsl['COL_SAT_MODE']);
- $adif .= "%3E";
- $adif .= $qsl['COL_SAT_MODE'];
- $adif .= "%20";
- }
-
- // adding qslmsg if it isn't blank
- if ($qsl['COL_QSLMSG'] != ''){
- $adif .= "%3C";
- $adif .= "QSLMSG";
- $adif .= "%3A";
- $adif .= strlen($qsl['COL_QSLMSG']);
- $adif .= "%3E";
- $adif .= $qsl['COL_QSLMSG'];
- $adif .= "%20";
- }
-
- if ($qsl['eqslqthnickname'] != ''){
- $adif .= "%3C";
- $adif .= "APP%5FEQSL%5FQTH%5FNICKNAME";
- $adif .= "%3A";
- $adif .= strlen($qsl['eqslqthnickname']);
- $adif .= "%3E";
- $adif .= $qsl['eqslqthnickname'];
- $adif .= "%20";
- }
-
- // adding sat mode if it isn't blank
- if ($qsl['station_gridsquare'] != ''){
- $adif .= "%3C";
- $adif .= "MY%5FGRIDSQUARE";
- $adif .= "%3A";
- $adif .= strlen($qsl['station_gridsquare']);
- $adif .= "%3E";
- $adif .= $qsl['station_gridsquare'];
- $adif .= "%20";
- }
-
-
- # Tie a bow on it!
- $adif .= "%3C";
- $adif .= "EOR";
- $adif .= "%3E";
-
- # Make sure we don't have any spaces
- $adif = str_replace(" ", '%20', $adif);
-
- $status = "";
-
- // begin script
- $ch = curl_init();
-
- // basic curl options for all requests
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_HEADER, 1);
-
- // use the URL we built
- curl_setopt($ch, CURLOPT_URL, $adif);
-
- $result = curl_exec($ch);
- $chi = curl_getinfo($ch);
- curl_close($ch);
-
-
- /* Time for some error handling
- Things we might get back
- Result: 0 out of 0 records added -> eQSL didn't understand the format
- Result: 1 out of 1 records added -> Fantastic
- Error: No match on eQSL_User/eQSL_Pswd -> eQSL credentials probably wrong
- Warning: Y=2013 M=08 D=11 F6ARS 15M JT65 Bad record: Duplicate
- Result: 0 out of 1 records added -> Dupe, OM!
- */
-
- if ($chi['http_code'] == "200")
- {
- if (stristr($result, "Result: 1 out of 1 records added"))
- {
- $status = "Sent";
- $this->logbook_model->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']);
- }
- else
- {
- if (stristr($result, "Error: No match on eQSL_User/eQSL_Pswd"))
- {
- $this->session->set_flashdata('warning', 'Your eQSL username and/or password is incorrect.'); redirect('eqsl/export');
- }
- else
- {
- if (stristr($result, "Result: 0 out of 0 records added"))
- {
- $this->session->set_flashdata('warning', 'Something went wrong with eQSL.cc!'); redirect('eqsl/export');
- }
- else
- {
- if (stristr($result, "Bad record: Duplicate"))
- {
- $status = "Duplicate";
-
- # Mark the QSL as sent if this is a dupe.
- $this->logbook_model->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']);
- }
- }
- }
- }
- }
- else
- {
- if ($chi['http_code'] == "500")
- {
- $this->session->set_flashdata('warning', 'eQSL.cc is experiencing issues. Please try exporting QSOs later.'); redirect('eqsl/export');
- }
- else
- {
- if ($chi['http_code'] == "400")
- {
- $this->session->set_flashdata('warning', 'There was an error in one of the QSOs. You might want to manually upload them.'); redirect('eqsl/export');
- $status = "Error";
- }
- else
- {
- if ($chi['http_code'] == "404")
- {
- $this->session->set_flashdata('warning', 'It seems that the eQSL site has changed. Please open up an issue on GitHub.'); redirect('eqsl/export');
- }
- }
- }
- }
- $table .= "
";
- $timestamp = strtotime($qsl['COL_TIME_ON']);
- $table .= "| ".date($custom_date_format, $timestamp)." | ";
- $table .= "".date('H:i', $timestamp)." | ";
- $table .= "".str_replace("0","Ø",$qsl['COL_CALL'])." | ";
- $table .= "".$qsl['COL_MODE']." | ";
- if(isset($qsl['COL_SUBMODE'])) {
- $table .= "".$qsl['COL_SUBMODE']." | ";
- } else {
- $table .= " | ";
- }
- $table .= "".$qsl['COL_BAND']." | ";
- $table .= "".$status." | ";
- $table .= "
";
+ $rows .= "| ".$qsl['COL_BAND']." | ";
+ $rows .= "".$status." | ";
}
- $table .= "
";
-
- // Dump out a table with the results
- $data['eqsl_results_table'] = $table;
- log_message('debug', $result);
- }
- else
- {
- $qslsnotsent = $this->logbook_model->eqsl_not_yet_sent();
-
- if ($qslsnotsent->num_rows() > 0)
- {
- $table = "";
- $table .= "";
- $table .= "| Date | ";
- $table .= "Time | ";
- $table .= "Call | ";
- $table .= "Mode | ";
- $table .= "Submode | ";
- $table .= "Band | ";
- $table .= "eQSL QTH Nickname | ";
- $table .= "
";
-
- foreach ($qslsnotsent->result_array() as $qsl)
- {
- $table .= "
";
- $timestamp = strtotime($qsl['COL_TIME_ON']);
- $table .= "| ".date($custom_date_format, $timestamp)." | ";
- $table .= "".date('H:i', $timestamp)." | ";
- $table .= "" . str_replace("0","Ø",strtoupper($qsl['COL_CALL'])) . " | ";
- $table .= "".$qsl['COL_MODE']." | ";
-
- if(isset($qsl['COL_SUBMODE'])) {
- $table .= "".$qsl['COL_SUBMODE']." | ";
- } else {
- $table .= " | ";
- }
- $table .= "".$qsl['COL_BAND']." | ";
- $table .= "".$qsl['eqslqthnickname']." | ";
- $table .= "
";
- }
- $table .= "
";
-
- $data['eqsl_table'] = $table;
+ $rows .= "";
+ $data['eqsl_table'] = $this->generateResultTable($custom_date_format, $rows);
+ } else {
+ $qslsnotsent = $this->eqslmethods_model->eqsl_not_yet_sent();
+ if ($qslsnotsent->num_rows() > 0) {
+ $data['eqsl_table'] = $this->writeEqslNotSent($qslsnotsent->result_array(), $custom_date_format);
}
}
@@ -470,6 +160,309 @@ class eqsl extends CI_Controller {
$this->load->view('interface_assets/footer');
}
+ function uploadQso($adif, $qsl) {
+ $this->load->model('eqslmethods_model');
+ $status = "";
+
+ // begin script
+ $ch = curl_init();
+
+ // basic curl options for all requests
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+
+ // use the URL we built
+ curl_setopt($ch, CURLOPT_URL, $adif);
+
+ $result = curl_exec($ch);
+ $chi = curl_getinfo($ch);
+ curl_close($ch);
+
+ /* Time for some error handling
+ Things we might get back
+ Result: 0 out of 0 records added -> eQSL didn't understand the format
+ Result: 1 out of 1 records added -> Fantastic
+ Error: No match on eQSL_User/eQSL_Pswd -> eQSL credentials probably wrong
+ Warning: Y=2013 M=08 D=11 F6ARS 15M JT65 Bad record: Duplicate
+ Result: 0 out of 1 records added -> Dupe, OM!
+ */
+
+ if ($chi['http_code'] == "200") {
+ if (stristr($result, "Result: 1 out of 1 records added")) {
+ $status = "Sent";
+ $this->eqslmethods_model->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']);
+ } else {
+ if (stristr($result, "Error: No match on eQSL_User/eQSL_Pswd")) {
+ $this->session->set_flashdata('warning', 'Your eQSL username and/or password is incorrect.'); redirect('eqsl/export');
+ } else {
+ if (stristr($result, "Result: 0 out of 0 records added")) {
+ $this->session->set_flashdata('warning', 'Something went wrong with eQSL.cc!'); redirect('eqsl/export');
+ } else {
+ if (stristr($result, "Bad record: Duplicate")) {
+ $status = "Duplicate";
+
+ # Mark the QSL as sent if this is a dupe.
+ $this->eqslmethods_model->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']);
+ }
+ }
+ }
+ }
+ } else {
+ if ($chi['http_code'] == "500") {
+ $this->session->set_flashdata('warning', 'eQSL.cc is experiencing issues. Please try exporting QSOs later.'); redirect('eqsl/export');
+ } else {
+ if ($chi['http_code'] == "400") {
+ $this->session->set_flashdata('warning', 'There was an error in one of the QSOs. You might want to manually upload them.'); redirect('eqsl/export');
+ $status = "Error";
+ } else {
+ if ($chi['http_code'] == "404") {
+ $this->session->set_flashdata('warning', 'It seems that the eQSL site has changed. Please open up an issue on GitHub.'); redirect('eqsl/export');
+ }
+ }
+ }
+ }
+ log_message('debug', $result);
+ return $status;
+ }
+
+ function generateResultTable($custom_date_format, $rows) {
+ $table = '';
+ $table .= "";
+ $table .= "| Date | ";
+ $table .= "Time | ";
+ $table .= "Call | ";
+ $table .= "Mode | ";
+ $table .= "Submode | ";
+ $table .= "Band | ";
+ $table .= "Status | ";
+ $table .= "
";
+
+ $table .= $rows;
+ $table .= "
";
+
+ return $table;
+ }
+
+ // Build out the ADIF info string according to specs http://eqsl.cc/qslcard/ADIFContentSpecs.cfm
+ function generateAdif($qsl, $data) {
+ $COL_QSO_DATE = date('Ymd',strtotime($qsl['COL_TIME_ON']));
+ $COL_TIME_ON = date('Hi',strtotime($qsl['COL_TIME_ON']));
+
+ # Set up the single record file
+ $adif = "http://www.eqsl.cc/qslcard/importADIF.cfm?";
+ $adif .= "ADIFData=CloudlogUpload%20";
+
+ /* Handy reference of escaping chars
+ "<" = 3C
+ ">" = 3E
+ ":" = 3A
+ " " = 20
+ "_" = 5F
+ "-" = 2D
+ "." = 2E
+ */
+
+ $adif .= "%3C";
+ $adif .= "ADIF%5FVER";
+ $adif .= "%3A";
+ $adif .= "4";
+ $adif .= "%3E";
+ $adif .= "1%2E00 ";
+ $adif .= "%20";
+
+ $adif .= "%3C";
+ $adif .= "EQSL%5FUSER";
+ $adif .= "%3A";
+ $adif .= strlen($data['user_eqsl_name']);
+ $adif .= "%3E";
+ $adif .= $data['user_eqsl_name'];
+ $adif .= "%20";
+
+ $adif .= "%3C";
+ $adif .= "EQSL%5FPSWD";
+ $adif .= "%3A";
+ $adif .= strlen($data['user_eqsl_password']);
+ $adif .= "%3E";
+ $adif .= urlencode($data['user_eqsl_password']);
+ $adif .= "%20";
+
+ $adif .= "%3C";
+ $adif .= "EOH";
+ $adif .= "%3E";
+
+ # Lay out the required fields
+ $adif .= "%3C";
+ $adif .= "QSO%5FDATE";
+ $adif .= "%3A";
+ $adif .= "8";
+ $adif .= "%3E";
+ $adif .= $COL_QSO_DATE;
+ $adif .= "%20";
+
+ $adif .= "%3C";
+ $adif .= "TIME%5FON";
+ $adif .= "%3A";
+ $adif .= "4";
+ $adif .= "%3E";
+ $adif .= $COL_TIME_ON;
+ $adif .= "%20";
+
+ $adif .= "%3C";
+ $adif .= "CALL";
+ $adif .= "%3A";
+ $adif .= strlen($qsl['COL_CALL']);
+ $adif .= "%3E";
+ $adif .= $qsl['COL_CALL'];
+ $adif .= "%20";
+
+ $adif .= "%3C";
+ $adif .= "MODE";
+ $adif .= "%3A";
+ $adif .= strlen($qsl['COL_MODE']);
+ $adif .= "%3E";
+ $adif .= $qsl['COL_MODE'];
+ $adif .= "%20";
+
+ if(isset($qsl['COL_SUBMODE'])) {
+ $adif .= "%3C";
+ $adif .= "SUBMODE";
+ $adif .= "%3A";
+ $adif .= strlen($qsl['COL_SUBMODE']);
+ $adif .= "%3E";
+ $adif .= $qsl['COL_SUBMODE'];
+ $adif .= "%20";
+ }
+
+ $adif .= "%3C";
+ $adif .= "BAND";
+ $adif .= "%3A";
+ $adif .= strlen($qsl['COL_BAND']);
+ $adif .= "%3E";
+ $adif .= $qsl['COL_BAND'];
+ $adif .= "%20";
+
+ # End all the required fields
+
+ // adding RST_Sent
+ $adif .= "%3C";
+ $adif .= "RST%5FSENT";
+ $adif .= "%3A";
+ $adif .= strlen($qsl['COL_RST_SENT']);
+ $adif .= "%3E";
+ $adif .= $qsl['COL_RST_SENT'];
+ $adif .= "%20";
+
+ // adding prop mode if it isn't blank
+ if ($qsl['COL_PROP_MODE']){
+ $adif .= "%3C";
+ $adif .= "PROP%5FMODE";
+ $adif .= "%3A";
+ $adif .= strlen($qsl['COL_PROP_MODE']);
+ $adif .= "%3E";
+ $adif .= $qsl['COL_PROP_MODE'];
+ $adif .= "%20";
+ }
+
+ // adding sat name if it isn't blank
+ if ($qsl['COL_SAT_NAME'] != ''){
+ $adif .= "%3C";
+ $adif .= "SAT%5FNAME";
+ $adif .= "%3A";
+ $adif .= strlen($qsl['COL_SAT_NAME']);
+ $adif .= "%3E";
+ $adif .= str_replace('-', '%2D', $qsl['COL_SAT_NAME']);
+ $adif .= "%20";
+ }
+
+ // adding sat mode if it isn't blank
+ if ($qsl['COL_SAT_MODE'] != ''){
+ $adif .= "%3C";
+ $adif .= "SAT%5FMODE";
+ $adif .= "%3A";
+ $adif .= strlen($qsl['COL_SAT_MODE']);
+ $adif .= "%3E";
+ $adif .= $qsl['COL_SAT_MODE'];
+ $adif .= "%20";
+ }
+
+ // adding qslmsg if it isn't blank
+ if ($qsl['COL_QSLMSG'] != ''){
+ $adif .= "%3C";
+ $adif .= "QSLMSG";
+ $adif .= "%3A";
+ $adif .= strlen($qsl['COL_QSLMSG']);
+ $adif .= "%3E";
+ $adif .= $qsl['COL_QSLMSG'];
+ $adif .= "%20";
+ }
+
+ if ($qsl['eqslqthnickname'] != ''){
+ $adif .= "%3C";
+ $adif .= "APP%5FEQSL%5FQTH%5FNICKNAME";
+ $adif .= "%3A";
+ $adif .= strlen($qsl['eqslqthnickname']);
+ $adif .= "%3E";
+ $adif .= $qsl['eqslqthnickname'];
+ $adif .= "%20";
+ }
+
+ // adding sat mode if it isn't blank
+ if ($qsl['station_gridsquare'] != ''){
+ $adif .= "%3C";
+ $adif .= "MY%5FGRIDSQUARE";
+ $adif .= "%3A";
+ $adif .= strlen($qsl['station_gridsquare']);
+ $adif .= "%3E";
+ $adif .= $qsl['station_gridsquare'];
+ $adif .= "%20";
+ }
+
+ # Tie a bow on it!
+ $adif .= "%3C";
+ $adif .= "EOR";
+ $adif .= "%3E";
+
+ # Make sure we don't have any spaces
+ $adif = str_replace(" ", '%20', $adif);
+
+ return $adif;
+ }
+
+ function writeEqslNotSent($qslsnotsent, $custom_date_format) {
+ $table = '';
+ $table .= "";
+ $table .= "| Date | ";
+ $table .= "Time | ";
+ $table .= "Call | ";
+ $table .= "Mode | ";
+ $table .= "Submode | ";
+ $table .= "Band | ";
+ $table .= "eQSL QTH Nickname | ";
+ $table .= "
";
+
+ foreach ($qslsnotsent as $qsl)
+ {
+ $table .= "";
+ $timestamp = strtotime($qsl['COL_TIME_ON']);
+ $table .= "| ".date($custom_date_format, $timestamp)." | ";
+ $table .= "".date('H:i', $timestamp)." | ";
+ $table .= "" . str_replace("0","Ø",strtoupper($qsl['COL_CALL'])) . " | ";
+ $table .= "".$qsl['COL_MODE']." | ";
+
+ if(isset($qsl['COL_SUBMODE'])) {
+ $table .= "".$qsl['COL_SUBMODE']." | ";
+ } else {
+ $table .= " | ";
+ }
+ $table .= "".$qsl['COL_BAND']." | ";
+ $table .= "".$qsl['eqslqthnickname']." | ";
+ $table .= "
";
+ }
+ $table .= "
";
+
+ return $table;
+ }
+
function image($id) {
$this->load->library('electronicqsl');
$this->load->model('Eqsl_images');
@@ -529,7 +522,6 @@ class eqsl extends CI_Controller {
}
public function tools() {
-
// Check logged in
$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'); }
@@ -543,7 +535,6 @@ class eqsl extends CI_Controller {
}
public function mark_all_sent() {
-
// Check logged in
$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'); }
@@ -556,5 +547,35 @@ class eqsl extends CI_Controller {
redirect('eqsl/tools');
}
+
+ /*
+ * Used for CRON job
+ */
+ public function upload() {
+ $this->load->model('eqslmethods_model');
+
+ $users = $this->eqslmethods_model->get_eqsl_users();
+
+ foreach ($users as $user) {
+ $this->uploadUser($user->user_id, $user->user_eqsl_name, $user->user_eqsl_password);
+ }
+ }
+
+ function uploadUser($userid, $username, $password) {
+ ini_set('memory_limit', '-1');
+ set_time_limit(0);
+ $data['user_eqsl_name'] = $this->security->xss_clean($username);
+ $data['user_eqsl_password'] = $this->security->xss_clean($password);
+ $clean_userid = $this->security->xss_clean($userid);
+
+ $qslsnotsent = $this->eqslmethods_model->eqsl_not_yet_sent($clean_userid);
+
+ foreach ($qslsnotsent->result_array() as $qsl) {
+ $data['user_eqsl_name'] = $qsl['station_callsign'];
+ $adif = $this->generateAdif($qsl, $data);
+
+ $status = $this->uploadQso($adif, $qsl);
+ }
+ }
} // end class
diff --git a/application/models/Eqslmethods_model.php b/application/models/Eqslmethods_model.php
index c60c97c4..e112d2e8 100644
--- a/application/models/Eqslmethods_model.php
+++ b/application/models/Eqslmethods_model.php
@@ -18,6 +18,61 @@ class Eqslmethods_model extends CI_Model {
$this->db->update($this->config->item('table_name'), $data);
}
+ function get_eqsl_users() {
+ $this->db->select('user_eqsl_name, user_eqsl_password, user_id');
+ $this->db->where('coalesce(user_eqsl_name, "") != ""');
+ $this->db->where('coalesce(user_eqsl_password, "") != ""');
+ $query = $this->db->get($this->config->item('auth_table'));
+ return $query->result();
+ }
+
+
+ // Show all QSOs we need to send to eQSL
+ function eqsl_not_yet_sent($userid = null) {
+ $CI =& get_instance();
+ if ($userid == null) {
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ } else {
+ $CI->load->model('Stations');
+ $stations = $CI->Stations->all_of_user();
+ $logbooks_locations_array = array();
+ foreach ($stations->result() as $row) {
+ array_push($logbooks_locations_array, $row->station_id);
+ }
+ }
+
+ $this->db->select('station_profile.*, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_COMMENT, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_PROP_MODE, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_SAT_MODE, '.$this->config->item('table_name').'.COL_QSLMSG');
+ $this->db->from('station_profile');
+ $this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
+ $this->db->where("coalesce(station_profile.eqslqthnickname, '') <> ''");
+ $this->db->where($this->config->item('table_name').'.COL_CALL !=', '');
+ $this->db->group_start();
+ $this->db->where($this->config->item('table_name').'.COL_EQSL_QSL_SENT is null');
+ $this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', '');
+ $this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'R');
+ $this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'Q');
+ $this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'N');
+ $this->db->group_end();
+ $this->db->where_in('station_profile.station_id', $logbooks_locations_array);
+
+ return $this->db->get();
+ }
+
+ // Mark the QSO as sent to eQSL
+ function eqsl_mark_sent($primarykey) {
+ $data = array(
+ 'COL_EQSL_QSLSDATE' => date('Y-m-d H:i:s'), // eQSL doesn't give us a date, so let's use current
+ 'COL_EQSL_QSL_SENT' => 'Y',
+ );
+
+ $this->db->where('COL_PRIMARY_KEY', $primarykey);
+
+ $this->db->update($this->config->item('table_name'), $data);
+
+ return "eQSL Sent";
+ }
+
}
?>
\ No newline at end of file
diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php
index 80cb64b6..b301148f 100755
--- a/application/models/Logbook_model.php
+++ b/application/models/Logbook_model.php
@@ -2573,20 +2573,6 @@ class Logbook_model extends CI_Model {
return "Updated";
}
- // Mark the QSO as sent to eQSL
- function eqsl_mark_sent($primarykey) {
- $data = array(
- 'COL_EQSL_QSLSDATE' => date('Y-m-d H:i:s'), // eQSL doesn't give us a date, so let's use current
- 'COL_EQSL_QSL_SENT' => 'Y',
- );
-
- $this->db->where('COL_PRIMARY_KEY', $primarykey);
-
- $this->db->update($this->config->item('table_name'), $data);
-
- return "eQSL Sent";
- }
-
// Get the last date we received an eQSL
function eqsl_last_qsl_rcvd_date($callsign, $nickname) {
$qso_table_name = $this->config->item('table_name');
@@ -2637,29 +2623,6 @@ class Logbook_model extends CI_Model {
}
}
- // Show all QSOs we need to send to eQSL
- function eqsl_not_yet_sent() {
- $CI =& get_instance();
- $CI->load->model('logbooks_model');
- $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
-
- $this->db->select('station_profile.*, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_COMMENT, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_PROP_MODE, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_SAT_MODE, '.$this->config->item('table_name').'.COL_QSLMSG');
- $this->db->from('station_profile');
- $this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
- $this->db->where("coalesce(station_profile.eqslqthnickname, '') <> ''");
- $this->db->where($this->config->item('table_name').'.COL_CALL !=', '');
- $this->db->group_start();
- $this->db->where($this->config->item('table_name').'.COL_EQSL_QSL_SENT is null');
- $this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', '');
- $this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'R');
- $this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'Q');
- $this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'N');
- $this->db->group_end();
- $this->db->where_in('station_profile.station_id', $logbooks_locations_array);
-
- return $this->db->get();
- }
-
/*
* $skipDuplicate - used in ADIF import to skip duplicate checking when importing QSOs
* $markLoTW - used in ADIF import to mark QSOs as exported to LoTW when importing QSOs
@@ -3901,6 +3864,4 @@ function validateADIFDate($date, $format = 'Ymd')
$d = DateTime::createFromFormat($format, $date);
return $d && $d->format($format) == $date;
}
-
-
-?>
+?>
\ No newline at end of file
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php
index 89384901..9e00854a 100644
--- a/application/views/interface_assets/footer.php
+++ b/application/views/interface_assets/footer.php
@@ -2672,6 +2672,21 @@ function deleteQsl(id) {
+
+uri->segment(1) == "eqsl") { ?>
+
+
+
uri->segment(1) == "qslprint") { ?>