From 0015d4a1cf85c81047044f559bd92e3ecd2d53c7 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Thu, 29 Jul 2021 12:05:52 +0200 Subject: [PATCH 01/40] [DX Atlas Gridsquare Export] Initial work begun for export --- application/controllers/Dxatlas.php | 104 +++++++++++++++ application/views/dxatlas/index.php | 119 ++++++++++++++++++ application/views/interface_assets/header.php | 2 + 3 files changed, 225 insertions(+) create mode 100644 application/controllers/Dxatlas.php create mode 100644 application/views/dxatlas/index.php diff --git a/application/controllers/Dxatlas.php b/application/controllers/Dxatlas.php new file mode 100644 index 00000000..ac8c46ff --- /dev/null +++ b/application/controllers/Dxatlas.php @@ -0,0 +1,104 @@ +load->model('user_model'); + $this->load->model('modes'); + $this->load->model('dxcc'); + $this->load->model('logbook_model'); + + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + + $data['worked_bands'] = $this->dxcc->get_worked_bands(); // Used in the view for band select + $data['modes'] = $this->modes->active(); // Used in the view for mode select + $data['dxcc'] = $this->logbook_model->fetchDxcc(); // Used in the view for dxcc select + + $data['page_title'] = "DX Atlas Gridsquare Export"; + + $this->load->view('interface_assets/header', $data); + $this->load->view('dxatlas/index'); + $this->load->view('interface_assets/footer'); + + } + + public function export() + { + // Load Librarys + $this->load->library('qra'); + $this->load->helper('file'); + + // Load Database connections + $this->load->model('logbook_model'); + + // Parameters + $band = $this->input->post('band'); + $mode = $this->input->post('mode'); + $dxcc = $this->input->post('dxcc_id'); + $cqz = $this->input->post('cqz'); + $propagation = $this->input->post('prop_mode'); + $fromdate = $this->input->post('fromdate'); + $todate = $this->input->post('todate'); + + // Get QSOs with Valid QRAs + $qsos = $this->logbook_model->kml_get_all_qsos($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate); + + $output = ""; + $output .= ""; + + $output .= ""; + + foreach ($qsos->result() as $row) + { + $output .= ""; + + if($row->COL_GRIDSQUARE != null) { + $stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE); + + $lat = $stn_loc[0]; + $lng = $stn_loc[1]; + } else { + $query = $this->db->query(' + SELECT * + FROM dxcc_entities + WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) ) + ORDER BY LENGTH( prefix ) DESC + LIMIT 1 + '); + + foreach ($query->result() as $dxcc) { + $lat = $dxcc->lat; + $lng = $dxcc->long; + } + } + + $timestamp = strtotime($row->COL_TIME_ON); + + $output .= "".$row->COL_CALL.""; + $output .= "Date/Time: ".date('Y-m-d H:i:s', ($timestamp))."
Band: ".$row->COL_BAND."

]]>
"; + $output .= ""; + $output .= "".$lng.",".$lat.",0"; + $output .= ""; + $output .= "
"; + } + + $output .= "
"; + $output .= "
"; + + if (!file_exists('kml')) { + mkdir('kml', 0755, true); + } + + if ( ! write_file('kml/qsos.kml', $output)) + { + echo 'Unable to write the file. Make sure the folder KML has write permissions.'; + } + else + { + header("Content-Disposition: attachment; filename=\"qsos.kml\""); + echo $output; + } + + } +} diff --git a/application/views/dxatlas/index.php b/application/views/dxatlas/index.php new file mode 100644 index 00000000..7e7f3521 --- /dev/null +++ b/application/views/dxatlas/index.php @@ -0,0 +1,119 @@ +
+
+

+ +
+
+ Export your logbook for use in DX Atlas to display worked / confirmed gridsquares. +
+ + + +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +

From date:

+
+
+ +
+
+
+
+
+ +

To date:

+
+
+ +
+
+
+
+
+
+ +
+
+
+
diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index 088d02da..aa264458 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -195,6 +195,8 @@ KML Export + DX Atlas Gridsquare Export + Logbook of the World From e384a631e0685d9a6a5418ca133d9d84cfdd5be2 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Sat, 31 Jul 2021 10:25:38 +0100 Subject: [PATCH 02/40] Created a SECURITY.md --- SECURITY.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..8c420770 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,7 @@ +# Security Policy + +## Reporting a Vulnerability + +If you discover a security vulnerability within Cloudlog, please send an e-mail to Peter Goodhall, 2M0SQL via [peter@magicbug.co.uk](mailto:peter@magicbug.co.uk). + +All security vulnerabilities will be promptly addressed. From ea916d88c9725b03b3be2b5bfcb5bca75335483e Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 31 Jul 2021 12:01:14 +0200 Subject: [PATCH 03/40] [QRA Library] Fixes #1117. This fixes bearing calculation. Distance was not calculcated if the locator was directly to the north or south of your own locator. --- application/libraries/Qra.php | 37 ++++++++++++++--------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/application/libraries/Qra.php b/application/libraries/Qra.php index 8d38ed7f..7398151d 100644 --- a/application/libraries/Qra.php +++ b/application/libraries/Qra.php @@ -1,4 +1,4 @@ - Date: Fri, 6 Aug 2021 17:52:04 +0100 Subject: [PATCH 04/40] [Migration] Creates station_logbook table in database. --- application/config/migration.php | 2 +- .../071_create_station_logbook_table.php | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 application/migrations/071_create_station_logbook_table.php diff --git a/application/config/migration.php b/application/config/migration.php index 5b216f92..227bc690 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 70; +$config['migration_version'] = 71; /* |-------------------------------------------------------------------------- diff --git a/application/migrations/071_create_station_logbook_table.php b/application/migrations/071_create_station_logbook_table.php new file mode 100644 index 00000000..762ef81b --- /dev/null +++ b/application/migrations/071_create_station_logbook_table.php @@ -0,0 +1,52 @@ +dbforge->add_field(array( + 'logbook_id' => array( + 'type' => 'BIGINT', + 'constraint' => 20, + 'unsigned' => TRUE, + 'auto_increment' => TRUE, + 'unique' => TRUE + ), + + 'user_id' => array( + 'type' => 'BIGINT', + 'constraint' => 20, + 'unsigned' => TRUE, + 'auto_increment' => FALSE + ), + + 'logbook_name' => array( + 'type' => 'VARCHAR', + 'constraint' => '191', + 'null' => TRUE + ), + + 'modified' => array( + 'type' => 'timestamp', + 'null' => TRUE, + ) + )); + + $this->dbforge->add_key('logbook_id', TRUE); + $this->dbforge->add_key('user_id', TRUE); + + $this->dbforge->create_table('station_logbooks'); + } + + public function down() + { + $this->dbforge->drop_table('station_logbooks'); + } +} \ No newline at end of file From e254753bec7365269837fc768bce17de710f08b0 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Fri, 6 Aug 2021 17:57:40 +0100 Subject: [PATCH 05/40] [Migration] Creates table station_logbook_relationship table for many to many setup --- application/config/migration.php | 2 +- ...ate_station_logbook_relationship_table.php | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 application/migrations/072_create_station_logbook_relationship_table.php diff --git a/application/config/migration.php b/application/config/migration.php index 227bc690..e0cf1bd4 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 71; +$config['migration_version'] = 72; /* |-------------------------------------------------------------------------- diff --git a/application/migrations/072_create_station_logbook_relationship_table.php b/application/migrations/072_create_station_logbook_relationship_table.php new file mode 100644 index 00000000..02ed7a4b --- /dev/null +++ b/application/migrations/072_create_station_logbook_relationship_table.php @@ -0,0 +1,54 @@ +dbforge->add_field(array( + 'logbook_relation_id' => array( + 'type' => 'BIGINT', + 'constraint' => 20, + 'unsigned' => TRUE, + 'auto_increment' => TRUE, + 'unique' => TRUE + ), + + 'station_logbook_id' => array( + 'type' => 'BIGINT', + 'constraint' => 20, + 'unsigned' => TRUE, + 'auto_increment' => FALSE + ), + + 'station_location_id' => array( + 'type' => 'BIGINT', + 'constraint' => 20, + 'unsigned' => TRUE, + 'auto_increment' => FALSE + ), + + 'modified' => array( + 'type' => 'timestamp', + 'null' => TRUE, + ) + )); + + $this->dbforge->add_key('logbook_relation_id', TRUE); + $this->dbforge->add_key('station_logbook_id', TRUE); + $this->dbforge->add_key('station_location_id', TRUE); + + $this->dbforge->create_table('station_logbooks_relationship'); + } + + public function down() + { + $this->dbforge->drop_table('station_logbooks_relationship'); + } +} \ No newline at end of file From ef65494eb6d63e29af5bb628b1ef7760321de948 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Thu, 12 Aug 2021 20:17:18 +0100 Subject: [PATCH 06/40] [Station Logbooks] Added the basics for the index page --- application/controllers/Logbook.php | 1 - application/controllers/Logbooks.php | 31 ++++++++++ application/models/Logbooks_model.php | 17 ++++++ application/views/interface_assets/header.php | 2 + application/views/logbooks/index.php | 57 +++++++++++++++++++ 5 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 application/controllers/Logbooks.php create mode 100644 application/models/Logbooks_model.php create mode 100644 application/views/logbooks/index.php diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index c764ce09..196780da 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -728,5 +728,4 @@ class Logbook extends CI_Controller { return $this->db->get(); } - } diff --git a/application/controllers/Logbooks.php b/application/controllers/Logbooks.php new file mode 100644 index 00000000..eee2abba --- /dev/null +++ b/application/controllers/Logbooks.php @@ -0,0 +1,31 @@ +load->helper(array('form', 'url')); + + $this->load->model('user_model'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + } + + function index() { + $this->load->model('logbooks_model'); + + $data['my_logbooks'] = $this->logbooks_model->show_all(); + + // Render Page + $data['page_title'] = "Station Logbooks"; + $this->load->view('interface_assets/header', $data); + $this->load->view('logbooks/index'); + $this->load->view('interface_assets/footer'); + } + + +} \ No newline at end of file diff --git a/application/models/Logbooks_model.php b/application/models/Logbooks_model.php new file mode 100644 index 00000000..b1b7e37c --- /dev/null +++ b/application/models/Logbooks_model.php @@ -0,0 +1,17 @@ +db->where('user_id', $this->session->userdata('user_id')); + return $this->db->get('station_logbooks'); + } +} +?> \ No newline at end of file diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index 088d02da..20071666 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -185,6 +185,8 @@