Failsafe (Disable Download for stations without grant)

This commit is contained in:
int2001
2024-05-09 17:38:22 +00:00
parent 290e6ecf9a
commit 8c2070295e
2 changed files with 15 additions and 5 deletions

View File

@@ -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);
}
}

View File

@@ -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)