Skip to content

Commit c52859f

Browse files
authored
Merge branch 'dev' into dev-log-fallback
2 parents 18813c2 + 21c8e94 commit c52859f

File tree

58 files changed

+11444
-10449
lines changed

Some content is hidden

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

58 files changed

+11444
-10449
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Wavelog-support can be reached by creating an issue here at github. If you've an
6868

6969
Special thanks to our contributors, who are part of Wavelog by improving code!
7070

71-
[F4ANS](https://github.com/abarrau), [DG0TM](https://github.com/dg0tm), [DG9VH](https://github.com/dg9vh), [DJ3CE](https://github.com/dj3ce), [R1BLH](https://github.com/r1blh), [BG2ELG](https://github.com/violarulan), [DF1ASH](https://github.com/derFogel), [DB4SCW](https://github.com/DB4SCW), [VE2HEW](https://github.com/anthonydiiorio), [OK1GOD](https://github.com/filipmelik), [DJ1PW](https://github.com/winnieXY), [toseppo](https://github.com/toseppo), [N7DSB](https://github.com/desertblade), [BA7LAC](https://github.com/imlonghao), [AE4CE](https://github.com/ethancedwards8), [K1AF](https://github.com/patrickrb), [OE4BAM](https://github.com/MatykoBr), [HB9HJQ](https://github.com/zone11), [R3DHX](https://github.com/AleksdemSA), [uiolee](https://github.com/uiolee), [VK3ARR](https://github.com/VK3ARR), [BI7BST](https://github.com/Cryolitia), [ludoux](https://github.com/ludoux), [BG5ATV](https://github.com/tallcode), [BH6SKD](https://github.com/xiaosuan2b), [VK7TO](https://github.com/RhinoLance), [IU2FRL](https://github.com/iu2frl), [szporwolik](https://github.com/szporwolik), [agrif](https://github.com/agrif), [goodspeed34](https://github.com/goodspeed34), [kmanwar89](https://github.com/kmanwar89)
71+
[F4ANS](https://github.com/abarrau), [DG0TM](https://github.com/dg0tm), [DG9VH](https://github.com/dg9vh), [DJ3CE](https://github.com/dj3ce), [R1BLH](https://github.com/r1blh), [BG2ELG](https://github.com/violarulan), [DF1ASH](https://github.com/derFogel), [DB4SCW](https://github.com/DB4SCW), [VE2HEW](https://github.com/anthonydiiorio), [OK1GOD](https://github.com/filipmelik), [DJ1PW](https://github.com/winnieXY), [toseppo](https://github.com/toseppo), [N7DSB](https://github.com/desertblade), [BA7LAC](https://github.com/imlonghao), [AE4CE](https://github.com/ethancedwards8), [K1AF](https://github.com/patrickrb), [OE4BAM](https://github.com/MatykoBr), [HB9HJQ](https://github.com/zone11), [R3DHX](https://github.com/AleksdemSA), [uiolee](https://github.com/uiolee), [VK3ARR](https://github.com/VK3ARR), [BI7BST](https://github.com/Cryolitia), [ludoux](https://github.com/ludoux), [BG5ATV](https://github.com/tallcode), [BH6SKD](https://github.com/xiaosuan2b), [VK7TO](https://github.com/RhinoLance), [IU2FRL](https://github.com/iu2frl), [szporwolik](https://github.com/szporwolik), [agrif](https://github.com/agrif), [goodspeed34](https://github.com/goodspeed34), [kmanwar89](https://github.com/kmanwar89),[imorourke](https://github.com/imorourke)
7272

7373
Translators:
7474

application/config/config.sample.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
|
1010
| 'app_name' Name of the App 'Wavelog'
1111
| 'directory' directory where wavelog is installed eg "logger"
12-
| 'callbook' Selects which Callbook lookup to use defaults "hamqth" but supports "qrz"
12+
| 'callbook' Selects which Callbook lookup to use defaults "hamqth" but also supports: "qrz", "qrzcq" and "qrzru"
1313
*/
1414

1515
$config['app_name'] = 'Wavelog';
1616
$config['directory'] = 'logbook';
17-
$config['callbook'] = 'hamqth'; // Options are hamqth, qrz or qrzcq
17+
$config['callbook'] = 'hamqth'; // Options are hamqth, qrz, qrzcq or qrzru
1818

1919
$config['datadir'] = null; // default to install directory
2020

application/controllers/Eqsl.php

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,15 @@ function image($id) {
306306
$this->load->model('logbook_model');
307307
$this->load->model('user_model');
308308
$qso_query = $this->logbook_model->get_qso($id);
309+
310+
// Check if QSO exists and is accessible
311+
if (!$qso_query || $qso_query->num_rows() == 0) {
312+
show_error(__('QSO not found or not accessible'), 404);
313+
return;
314+
}
315+
309316
$qso = $qso_query->row();
317+
310318
$qso_timestamp = strtotime($qso->COL_TIME_ON);
311319
$callsign = $qso->COL_CALL;
312320
$band = $qso->COL_BAND;
@@ -318,40 +326,90 @@ function image($id) {
318326
$minute = date('i', $qso_timestamp);
319327

320328
$query = $this->user_model->get_by_id($this->session->userdata('user_id'));
329+
if ($query->num_rows() == 0) {
330+
show_error(__('User not found'), 404);
331+
return;
332+
}
321333
$q = $query->row();
322334
$username = $qso->COL_STATION_CALLSIGN;
323335
$password = $q->user_eqsl_password;
324336

337+
// Check if eQSL password is set
338+
if (empty($password)) {
339+
show_error(__('eQSL password not configured for this user'), 400);
340+
return;
341+
}
342+
325343
$image_url = $this->electronicqsl->card_image($username, urlencode($password), $callsign, $band, $mode, $year, $month, $day, $hour, $minute);
326-
$file = file_get_contents($image_url, true); // TODO use curl instead
344+
345+
// Use curl for better error handling instead of file_get_contents
346+
$ch = curl_init();
347+
curl_setopt($ch, CURLOPT_URL, $image_url);
348+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
349+
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
350+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
351+
curl_setopt($ch, CURLOPT_USERAGENT, 'Wavelog-eQSL/1.0');
352+
$file = curl_exec($ch);
353+
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
354+
curl_close($ch);
355+
356+
if ($file === false || $http_code != 200) {
357+
show_error(__('Failed to fetch eQSL image data'), 503);
358+
return;
359+
}
327360

328361
$dom = new domDocument;
362+
// Suppress warnings for malformed HTML
363+
libxml_use_internal_errors(true);
329364
$dom->loadHTML($file);
365+
libxml_clear_errors();
330366
$dom->preserveWhiteSpace = false;
331367
$images = $dom->getElementsByTagName('img');
332368

333369
if (!isset($images) || count($images) == 0) {
334370
$h3 = $dom->getElementsByTagName('h3');
335371
if (isset($h3) && ($h3->item(0) !== null)) {
336-
echo $h3->item(0)->nodeValue;
372+
$error_message = $h3->item(0)->nodeValue;
337373
} else {
338-
echo "Rate Limited";
374+
$error_message = "Rate Limited";
339375
}
340-
exit;
376+
show_error(__('eQSL image not available') . ': ' . $error_message, 503);
377+
return;
341378
}
342379

343380
foreach ($images as $image) {
344-
header('Content-Type: image/jpg');
345-
$content = file_get_contents("https://www.eqsl.cc" . $image->getAttribute('src'));
346-
if ($content === false) {
347-
echo "No response";
348-
exit;
381+
$image_src = "https://www.eqsl.cc" . $image->getAttribute('src');
382+
383+
// Use curl for downloading the actual image
384+
$ch = curl_init();
385+
curl_setopt($ch, CURLOPT_URL, $image_src);
386+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
387+
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
388+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
389+
curl_setopt($ch, CURLOPT_USERAGENT, 'Wavelog-eQSL/1.0');
390+
$content = curl_exec($ch);
391+
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
392+
curl_close($ch);
393+
394+
if ($content === false || $http_code != 200) {
395+
show_error(__('Failed to download eQSL image'), 503);
396+
return;
349397
}
398+
399+
header('Content-Type: image/jpg');
350400
echo $content;
401+
351402
$filename = uniqid() . '.jpg';
352-
if (file_put_contents($this->Eqsl_images->get_imagePath('p') . '/' . $filename, $content) !== false) {
403+
$image_path = $this->Eqsl_images->get_imagePath('p') . '/' . $filename;
404+
$save_result = file_put_contents($image_path, $content);
405+
406+
if ($save_result !== false) {
353407
$this->Eqsl_images->save_image($id, $filename);
408+
} else {
409+
log_message('error', 'Failed to save eQSL image to: ' . $image_path);
354410
}
411+
412+
return; // Only process the first image found
355413
}
356414
} else {
357415
header('Content-Type: image/jpg');

application/controllers/Options.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ function appearance_save() {
6767
$this->session->set_flashdata('success', __("Options saved"));
6868
}
6969

70-
// Update theme choice within the options system
71-
$search_update_status = $this->optionslib->update('global_search', $this->input->post('globalSearch'));
72-
73-
// If theme update is complete set a flashsession with a success note
74-
if($search_update_status == TRUE) {
75-
$this->session->set_flashdata('success', __("Options saved"));
76-
}
77-
7870
// Update logbook map within the options system
7971
$logbook_map_update_status = $this->optionslib->update('logbook_map', $this->input->post('logbookMap'), 'yes');
8072

application/controllers/Qso.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ public function index() {
3131
show_404();
3232
}
3333

34-
$data['active_station_profile'] = $this->stations->find_active();
34+
if ($this->stations->check_station_is_accessible($this->session->userdata('station_profile_id') ?? 0)) { // Last Station from session accessible? Take it!
35+
$data['active_station_profile'] = $this->session->userdata('station_profile_id');
36+
} else {
37+
$data['active_station_profile'] =$this->stations->find_active();
38+
}
3539

3640
$data['notice'] = false;
3741
$data['stations'] = $this->stations->all_of_user();
@@ -88,6 +92,13 @@ public function index() {
8892
$data['user_dok_to_qso_tab'] = 0;
8993
}
9094

95+
$qkey_opt=$this->user_options_model->get_options('qso_tab',array('option_name'=>'station','option_key'=>'show'))->result();
96+
if (count($qkey_opt)>0) {
97+
$data['user_station_to_qso_tab'] = $qkey_opt[0]->option_value;
98+
} else {
99+
$data['user_station_to_qso_tab'] = 0;
100+
}
101+
91102
// Get status of DX Waterfall enable option
92103
$qkey_opt=$this->user_options_model->get_options('dxwaterfall',array('option_name'=>'enable','option_key'=>'boolean'))->result();
93104
if (count($qkey_opt)>0) {

application/controllers/Search.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ function __construct() {
77
parent::__construct();
88

99
$this->load->helper(array('form', 'url'));
10-
if($this->optionslib->get_option('global_search') != "true") {
11-
$this->load->model('user_model');
12-
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); }
13-
}
10+
$this->load->model('user_model');
11+
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); }
1412
}
1513

1614
public function index() {

application/controllers/User.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ function add() {
238238
$data['user_pota_to_qso_tab'] = $this->input->post('user_pota_to_qso_tab');
239239
$data['user_sig_to_qso_tab'] = $this->input->post('user_sig_to_qso_tab');
240240
$data['user_dok_to_qso_tab'] = $this->input->post('user_dok_to_qso_tab');
241+
$data['user_station_to_qso_tab'] = $this->input->post('user_station_to_qso_tab');
241242
$data['user_language'] = $this->input->post('user_language');
242243
$data['global_oqrs_text'] = $this->input->post('global_oqrs_text') ?? '';
243244
$data['oqrs_grouped_search'] = $this->input->post('oqrs_grouped_search') ?? 'off';
@@ -292,6 +293,7 @@ function add() {
292293
$this->input->post('user_pota_to_qso_tab'),
293294
$this->input->post('user_sig_to_qso_tab'),
294295
$this->input->post('user_dok_to_qso_tab'),
296+
$this->input->post('user_station_to_qso_tab'),
295297
$this->input->post('user_lotw_name'),
296298
$this->input->post('user_lotw_password'),
297299
$this->input->post('user_eqsl_name'),
@@ -811,6 +813,14 @@ function edit() {
811813
$data['user_dok_to_qso_tab'] = $qkey_opt[0]->option_value;
812814
}
813815
}
816+
if($this->input->post('user_station_to_qso_tab')) {
817+
$data['user_station_to_qso_tab'] = $this->input->post('user_station_to_qso_tab', false);
818+
} else {
819+
$qkey_opt=$this->user_options_model->get_options('qso_tab',array('option_name'=>'station','option_key'=>'show'), $this->uri->segment(3))->result();
820+
if (count($qkey_opt)>0) {
821+
$data['user_station_to_qso_tab'] = $qkey_opt[0]->option_value;
822+
}
823+
}
814824

815825
if($this->input->post('global_oqrs_text')) {
816826
$data['global_oqrs_text'] = $this->input->post('global_oqrs_text', false);

application/libraries/Callbook.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ function hamqth($username, $password, $callsign) {
151151

152152
if (!$this->ci->session->userdata('hamqth_session_key')) {
153153
$hamqth_session_key = $this->ci->hamqth->session($username, $password);
154-
$this->ci->session->set_userdata('hamqth_session_key', $hamqth_session_key);
154+
if ($hamqth_session_key == false) {
155+
$callbook['error'] = __("Error obtaining a session key for HamQTH query");
156+
return $callbook;
157+
} else {
158+
$this->ci->session->set_userdata('hamqth_session_key', $hamqth_session_key);
159+
}
155160
}
156161

157162
$callbook = $this->ci->hamqth->search($callsign, $this->ci->session->userdata('hamqth_session_key'));

application/libraries/Hamqth.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public function session($username, $password) {
2121
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
2222
$xml = curl_exec($ch);
2323
curl_close($ch);
24+
if(curl_errno($ch)) {
25+
log_message('error', 'Hamqth query failed: '.curl_strerror(curl_errno($ch))." (".curl_errno($ch).")");
26+
return false;
27+
}
2428

2529
// Create XML object
2630
$xml = simplexml_load_string($xml);

0 commit comments

Comments
 (0)