From 676b3176675831ca07b2bd3caf5b6c9d502200af Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 14 Mar 2025 20:52:42 +0000 Subject: [PATCH] Handle the unhandled... --- application/models/Eqslmethods_model.php | 74 ++++++++++++++---------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/application/models/Eqslmethods_model.php b/application/models/Eqslmethods_model.php index a39460eab..52c87048c 100644 --- a/application/models/Eqslmethods_model.php +++ b/application/models/Eqslmethods_model.php @@ -56,7 +56,7 @@ class Eqslmethods_model extends CI_Model { log_message('error', 'eQSL Error for '.$data['user_eqsl_name']); break; } elseif ($status == 'Login Error') { - log_message('error', 'eQSL Credentials-Error for '.$data['user_eqsl_name'].' Login will be disabled!'); + log_message('error', 'eQSL Credentials-Error (User, Pass or Nickname) for '.$data['user_eqsl_name'].' Login will be disabled!'); $this->disable_eqsl_uid($userid); break; } @@ -289,21 +289,23 @@ class Eqslmethods_model extends CI_Model { log_message('error', 'eQSL: '.$msg); $this->session->set_flashdata('warning', $msg); $status = "Login Error"; + } elseif (stristr($result, "Result: 0 out of 0 records added")) { + $msg = __("Something went wrong with eQSL.cc!"); + log_message('error', 'eQSL at QSO-ID: '.$qsl['COL_PRIMARY_KEY']); // No leftover-Debug, but Find the faulty QSO for not known errors! + $this->session->set_flashdata('warning', $msg); + $status = "Error"; + } elseif (stristr($result, "Result: 0 out of 1 records added")) { + $this->eqsl_mark_invalid($qsl['COL_PRIMARY_KEY']); + $status = "Invalid"; + } elseif (stristr($result, "No match on APP_EQSL_QTH_NICKNAME")) { + $msg = __("eQSL-Nickname doesn't exist at eQSL"); + $this->session->set_flashdata('warning', $msg); + $status = "Login Error"; + } elseif (stristr($result, "Bad record: Duplicate")) { + $status = "Duplicate"; + $this->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']); } else { - if (stristr($result, "Result: 0 out of 0 records added")) { - $msg = __("Something went wrong with eQSL.cc!"); - log_message('error', 'eQSL at QSO: '.$qsl['COL_PRIMARY_KEY']); // No leftover-Debug, but Find the faulty QSO for not known errors! - log_message('error', 'eQSL: '.$msg); - $this->session->set_flashdata('warning', $msg); - $status = "Error"; - } else { - if (stristr($result, "Bad record: Duplicate")) { - $status = "Duplicate"; - - # Mark the QSL as sent if this is a dupe. - $this->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']); - } - } + log_message("Error","eQSL: Uncaught exception at QSO-ID: ".$qsl['COL_PRIMARY_KEY']); } } } else { @@ -312,20 +314,21 @@ class Eqslmethods_model extends CI_Model { log_message('error', 'eQSL: '.$msg); $this->session->set_flashdata('warning', $msg); $status = "Error"; + } elseif ($chi['http_code'] == "400") { + $msg = __("There was an error in one of the QSOs. You might want to manually upload them."); + log_message('error', 'eQSL: '.$msg); + $this->session->set_flashdata('warning', $msg); + $status = "Error"; + } elseif ($chi['http_code'] == "404") { + $msg = __("It seems that the eQSL site has changed. Please open up an issue on GitHub."); + log_message('error', 'eQSL: '.$msg); + $this->session->set_flashdata('warning', $msg); + $status = "Error"; } else { - if ($chi['http_code'] == "400") { - $msg = __("There was an error in one of the QSOs. You might want to manually upload them."); - log_message('error', 'eQSL: '.$msg); - $this->session->set_flashdata('warning', $msg); - $status = "Error"; - } else { - if ($chi['http_code'] == "404") { - $msg = __("It seems that the eQSL site has changed. Please open up an issue on GitHub."); - log_message('error', 'eQSL: '.$msg); - $this->session->set_flashdata('warning', $msg); - $status = "Error"; - } - } + log_message("Error","eQSL: Uncaught HTTP-exception at QSO-ID: ".$qsl['COL_PRIMARY_KEY']); + $msg = __("An uncaught Error occured while uploading QSOs. Perhaps eQSL has hiccups"); + $this->session->set_flashdata('warning', $msg); + $status= "Error"; } } return $status; @@ -398,7 +401,7 @@ class Eqslmethods_model extends CI_Model { array_push($logbooks_locations_array, -9999); } - $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->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->config->item('table_name') . '.station_id as eqsl_station_id'); $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, '') <> ''"); @@ -458,6 +461,19 @@ class Eqslmethods_model extends CI_Model { return "eQSL Sent"; } + function eqsl_mark_invalid($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' => 'I', + ); + + $this->db->where('COL_PRIMARY_KEY', $primarykey); + + $this->db->update($this->config->item('table_name'), $data); + + return "eQSL Invalid"; + } + // Returns all the distinct callsign, eqsl nick pair for the current user/supplied user function all_of_user_with_eqsl_nick_defined($userid = null) { if ($userid == null) {