Skip to content

Commit 8d013bd

Browse files
authored
2.6.1 Year Wrap up
2 parents 468c0e4 + 7be7231 commit 8d013bd

79 files changed

Lines changed: 2560 additions & 26447 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

application/config/migration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
|
2323
*/
2424

25-
$config['migration_version'] = 161;
25+
$config['migration_version'] = 165;
2626

2727
/*
2828
|--------------------------------------------------------------------------

application/controllers/Adif.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ public function index() {
158158
public function import() {
159159
$this->load->model('stations');
160160
$data['station_profile'] = $this->stations->all_of_user();
161+
log_message("debug","Started ADIF Import");
161162

162-
$active_station_id = $this->stations->find_active();
163-
$station_profile = $this->stations->profile($active_station_id);
163+
$active_station_id = $this->stations->find_active();
164+
$station_profile = $this->stations->profile($active_station_id);
164165

165166
$data['active_station_info'] = $station_profile->row();
166167

@@ -183,7 +184,6 @@ public function import() {
183184
} else {
184185
if ($this->stations->check_station_is_accessible($this->input->post('station_profile'))) {
185186
$data = array('upload_data' => $this->upload->data());
186-
187187
ini_set('memory_limit', '-1');
188188
set_time_limit(0);
189189

@@ -192,29 +192,29 @@ public function import() {
192192
$this->load->library('adif_parser');
193193

194194
$this->adif_parser->load_from_file('./uploads/'.$data['upload_data']['file_name']);
195+
unlink('./uploads/'.$data['upload_data']['file_name']);
196+
$data['upload_data']=''; // free memory
195197

196198
$this->adif_parser->initialize();
197199
$custom_errors = "";
200+
$alladif=[];
198201
while($record = $this->adif_parser->get_record())
199202
{
200203
if(count($record) == 0) {
201204
break;
202205
};
203-
204-
$one_error = $this->logbook_model->import($record, $this->input->post('station_profile'), $this->input->post('skipDuplicate'), $this->input->post('markClublog'),$this->input->post('markLotw'), $this->input->post('dxccAdif'), $this->input->post('markQrz'), $this->input->post('markHrd'), true, $this->input->post('operatorName'), false, $this->input->post('skipStationCheck'));
205-
if ($one_error != '') {
206-
$custom_errors.=$one_error."<br/>";
207-
}
206+
array_push($alladif,$record);
208207
};
209-
unlink('./uploads/'.$data['upload_data']['file_name']);
208+
$record=''; // free memory
209+
$custom_errors = $this->logbook_model->import_bulk($alladif, $this->input->post('station_profile'), $this->input->post('skipDuplicate'), $this->input->post('markClublog'),$this->input->post('markLotw'), $this->input->post('dxccAdif'), $this->input->post('markQrz'), $this->input->post('markHrd'), true, $this->input->post('operatorName'), false, $this->input->post('skipStationCheck'));
210210
} else {
211211
$custom_errors='Station Profile not valid for User';
212212
}
213213

214214
$data['adif_errors'] = $custom_errors;
215215
$data['skip_dupes'] = $this->input->post('skipDuplicate');
216216

217-
217+
log_message("debug","Finished ADIF Import");
218218
$data['page_title'] = "ADIF Imported";
219219
$this->load->view('interface_assets/header', $data);
220220
$this->load->view('adif/import_success');

application/controllers/Hrdlog.php

Lines changed: 70 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1+
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
22

33
/*
44
Controller to interact with the hrdlog.net API
@@ -20,11 +20,12 @@ public function upload() {
2020

2121
if ($station_ids) {
2222
foreach ($station_ids as $station) {
23+
$hrdlog_username = $station->hrdlog_username;
2324
$hrdlog_code = $station->hrdlog_code;
24-
if($this->mass_upload_qsos($station->station_id, $hrdlog_code)) {
25+
if ($this->mass_upload_qsos($station->station_id, $hrdlog_username, $hrdlog_code)) {
2526
echo "QSOs have been uploaded to hrdlog.net.";
2627
log_message('info', 'QSOs have been uploaded to hrdlog.net.');
27-
} else{
28+
} else {
2829
echo "No QSOs found for upload.";
2930
log_message('info', 'No QSOs found for upload.');
3031
}
@@ -48,49 +49,53 @@ function setOptions() {
4849
* Function gets all QSOs from given station_id, that are not previously uploaded to hrdlog.
4950
* Adif is build for each qso, and then uploaded, one at a time
5051
*/
51-
function mass_upload_qsos($station_id, $hrdlog_code) {
52-
$i = 0;
53-
$data['qsos'] = $this->logbook_model->get_hrdlog_qsos($station_id);
54-
$errormessages=array();
55-
56-
$CI =& get_instance();
57-
$CI->load->library('AdifHelper');
58-
59-
if ($data['qsos']) {
60-
foreach ($data['qsos']->result() as $qso) {
61-
$adif = $CI->adifhelper->getAdifLine($qso);
62-
63-
if ($qso->COL_HRDLOG_QSO_UPLOAD_STATUS == 'M') {
64-
$result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_code, $qso->COL_STATION_CALLSIGN,$adif, true);
65-
} else {
66-
$result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_code, $qso->COL_STATION_CALLSIGN,$adif);
67-
}
68-
69-
if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') || ($result['status'] == 'duplicate')) ){
70-
$this->markqso($qso->COL_PRIMARY_KEY);
71-
$i++;
72-
} elseif ((substr($result['status'],0,11) == 'auth_error')) {
73-
log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON);
74-
log_message('error', 'hrdlog upload failed with the following message: ' .$result['message']);
75-
log_message('error', 'hrdlog upload stopped for Station_ID: ' .$station_id);
76-
$errormessages[] = $result['message'] . 'Invalid HRDLog-Code, stopped at Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON;
77-
break; /* If key is invalid, immediate stop syncing for more QSOs of this station */
78-
} else {
79-
log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON);
80-
log_message('error', 'hrdlog upload failed with the following message: ' .$result['message']);
81-
$errormessages[] = $result['message'] . ' Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON;
82-
}
83-
}
84-
$result['status'] = 'OK';
85-
$result['count'] = $i;
86-
$result['errormessages'] = $errormessages;
87-
return $result;
88-
} else {
89-
$result['status'] = 'Error';
90-
$result['count'] = $i;
91-
$result['errormessages'] = $errormessages;
92-
return $result;
93-
}
52+
function mass_upload_qsos($station_id, $hrdlog_username, $hrdlog_code) {
53+
$i = 0;
54+
$data['qsos'] = $this->logbook_model->get_hrdlog_qsos($station_id);
55+
$errormessages = array();
56+
57+
$this->load->library('AdifHelper');
58+
59+
if ($data['qsos']) {
60+
foreach ($data['qsos']->result() as $qso) {
61+
$adif = $this->adifhelper->getAdifLine($qso);
62+
63+
if ($qso->COL_HRDLOG_QSO_UPLOAD_STATUS == 'M') {
64+
$result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_username, $hrdlog_code, $adif, true);
65+
} else {
66+
$result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_username, $hrdlog_code, $adif);
67+
}
68+
69+
if (($result['status'] == 'OK') || (($result['status'] == 'error') || ($result['status'] == 'duplicate'))) {
70+
$this->markqso($qso->COL_PRIMARY_KEY);
71+
$i++;
72+
$result['status'] = 'OK';
73+
} elseif ((substr($result['status'], 0, 11) == 'auth_error')) {
74+
log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON);
75+
log_message('error', 'hrdlog upload failed with the following message: ' . $result['message']);
76+
log_message('error', 'hrdlog upload stopped for Station_ID: ' . $station_id);
77+
$errormessages[] = $result['message'] . 'Invalid HRDLog-Code, stopped at Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON;
78+
$result['status'] = 'Error';
79+
break; /* If key is invalid, immediate stop syncing for more QSOs of this station */
80+
} else {
81+
log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON);
82+
log_message('error', 'hrdlog upload failed with the following message: ' . $result['message']);
83+
$result['status'] = 'Error';
84+
$errormessages[] = $result['message'] . ' Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON;
85+
}
86+
}
87+
if ($i == 0) {
88+
$result['status']='Error';
89+
}
90+
$result['count'] = $i;
91+
$result['errormessages'] = $errormessages;
92+
return $result;
93+
} else {
94+
$result['status'] = 'Error';
95+
$result['count'] = $i;
96+
$result['errormessages'] = $errormessages;
97+
return $result;
98+
}
9499
}
95100

96101
/*
@@ -108,7 +113,7 @@ public function export() {
108113

109114
$data['page_title'] = "HRDlog.net Logbook";
110115

111-
$data['station_profiles'] = $this->stations->all_of_user();
116+
$data['station_profiles'] = $this->stations->all_of_user();
112117
$data['station_profile'] = $this->stations->stations_with_hrdlog_code();
113118

114119
$this->load->view('interface_assets/header', $data);
@@ -126,10 +131,11 @@ public function upload_station() {
126131
$postData = $this->input->post();
127132

128133
$this->load->model('logbook_model');
129-
$result = $this->logbook_model->exists_hrdlog_code($postData['station_id']);
134+
$result = $this->logbook_model->exists_hrdlog_credentials($postData['station_id']);
135+
$hrdlog_username = $result->hrdlog_username;
130136
$hrdlog_code = $result->hrdlog_code;
131137
header('Content-type: application/json');
132-
$result = $this->mass_upload_qsos($postData['station_id'], $hrdlog_code);
138+
$result = $this->mass_upload_qsos($postData['station_id'], $hrdlog_username, $hrdlog_code);
133139
if ($result['status'] == 'OK') {
134140
$stationinfo = $this->stations->stations_with_hrdlog_code();
135141
$info = $stationinfo->result();
@@ -141,31 +147,31 @@ public function upload_station() {
141147
echo json_encode($data);
142148
} else {
143149
$data['status'] = 'Error';
144-
$data['info'] = 'Error: No QSOs found to upload.';
150+
$data['info'] = 'No QSOs found to upload.';
145151
$data['errormessages'] = $result['errormessages'];
146152
echo json_encode($data);
147153
}
148154
}
149155

150-
public function mark_hrdlog() {
151-
// Set memory limit to unlimited to allow heavy usage
152-
ini_set('memory_limit', '-1');
156+
public function mark_hrdlog() {
157+
// Set memory limit to unlimited to allow heavy usage
158+
ini_set('memory_limit', '-1');
153159

154-
$station_id = $this->security->xss_clean($this->input->post('station_profile'));
160+
$station_id = $this->security->xss_clean($this->input->post('station_profile'));
155161

156-
$this->load->model('adif_data');
162+
$this->load->model('adif_data');
157163

158-
$data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id);
164+
$data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id);
159165

160-
$this->load->model('logbook_model');
166+
$this->load->model('logbook_model');
161167

162-
foreach ($data['qsos']->result() as $qso)
168+
foreach ($data['qsos']->result() as $qso)
163169
{
164-
$this->logbook_model->mark_hrdlog_qsos_sent($qso->COL_PRIMARY_KEY);
165-
}
170+
$this->logbook_model->mark_hrdlog_qsos_sent($qso->COL_PRIMARY_KEY);
171+
}
166172

167-
$this->load->view('interface_assets/header', $data);
168-
$this->load->view('hrdlog/mark_hrdlog', $data);
169-
$this->load->view('interface_assets/footer');
170-
}
173+
$this->load->view('interface_assets/header', $data);
174+
$this->load->view('hrdlog/mark_hrdlog', $data);
175+
$this->load->view('interface_assets/footer');
176+
}
171177
}

0 commit comments

Comments
 (0)