From 8c2070295efb4fe24751d7dc7f2acb8bfb5f8b97 Mon Sep 17 00:00:00 2001 From: int2001 Date: Thu, 9 May 2024 17:38:22 +0000 Subject: [PATCH] Failsafe (Disable Download for stations without grant) --- application/controllers/Clublog.php | 13 +++++++++---- application/models/Clublog_model.php | 7 ++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/application/controllers/Clublog.php b/application/controllers/Clublog.php index d31aa10e9..c68bd6f7d 100644 --- a/application/controllers/Clublog.php +++ b/application/controllers/Clublog.php @@ -79,13 +79,18 @@ class Clublog extends CI_Controller { $response = curl_exec($request); $info = curl_getinfo($request); curl_close ($request); - if(curl_errno($request)) { echo curl_error($request); + } elseif (preg_match_all('/Invalid callsign/',$response)) { // We're trying to download calls for a station we're not granted. Disable Clublog-Transfer for that station(s) + $this->clublog_model->disable_sync4call($station_row->station_callsign,$station_row->station_ids); } else { - $cl_qsls=json_decode($response); - foreach ($cl_qsls as $oneqsl) { - $this->logbook_model->clublog_update($oneqsl[2], $oneqsl[0], $oneqsl[3], 'Y', $station_row->station_callsign, $station_row->station_ids); + try { + $cl_qsls=json_decode($response); + foreach ($cl_qsls as $oneqsl) { + $this->logbook_model->clublog_update($oneqsl[2], $oneqsl[0], $oneqsl[3], 'Y', $station_row->station_callsign, $station_row->station_ids); + } + } catch (Exception $e) { + log_message("Error","Something gone wrong while trying to Download for station(s) ".$station_row->station_ids." / Call: ".$station_row->station_callsign); } } diff --git a/application/models/Clublog_model.php b/application/models/Clublog_model.php index 4668ebe54..dee198086 100644 --- a/application/models/Clublog_model.php +++ b/application/models/Clublog_model.php @@ -103,7 +103,12 @@ class Clublog_model extends CI_Model { return '19700101'; } } - + + function disable_sync4call($call, $stations) { + $sql="update station_profile set clublogignore=1 where station_callsign=? and station_id in (".$stations.")"; + $query = $this->db->query($sql,$call); + } + function all_enabled($userid) { $sql="select sp.station_callsign, group_concat(sp.station_id) as station_ids from station_profile sp inner join users u on (u.user_id=sp.user_id)