diff --git a/application/controllers/Visitor.php b/application/controllers/Visitor.php
index 031af7ce..170364d3 100644
--- a/application/controllers/Visitor.php
+++ b/application/controllers/Visitor.php
@@ -14,6 +14,9 @@ class Visitor extends CI_Controller {
elseif($method == "map") {
$this->map($method);
}
+ elseif($method == "satellites") {
+ $this->satellites($method);
+ }
else {
$this->index($method);
}
@@ -177,4 +180,197 @@ class Visitor extends CI_Controller {
echo "}";
}
+
+ public function satellites()
+ {
+
+ $slug = $this->security->xss_clean($this->uri->segment(3));
+
+ $this->load->model('logbooks_model');
+ if($this->logbooks_model->public_slug_exists($slug)) {
+ // Load the public view
+ if($logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($slug) != false)
+ {
+ // Get associated station locations for mysql queries
+ $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
+ } else {
+ log_message('error', $slug.' has no associated station locations');
+ show_404('Unknown Public Page.');
+ }
+ }
+
+ $this->load->model('gridsquares_model');
+
+ $data['page_title'] = "Satellite Gridsquare Map";
+
+
+ $array_grid_2char = array();
+ $array_grid_4char = array();
+ $array_grid_6char = array();
+
+
+ $array_confirmed_grid_2char = array();
+ $array_confirmed_grid_4char = array();
+ $array_confirmed_grid_6char = array();
+
+ $grid_2char = "";
+ $grid_4char = "";
+ $grid_6char = "";
+
+ $grid_2char_confirmed = "";
+ $grid_4char_confirmed = "";
+ $grid_6char_confirmed = "";
+
+
+ // Get Confirmed LOTW & Paper Squares (non VUCC)
+ $query = $this->gridsquares_model->get_confirmed_sat_squares($logbooks_locations_array);
+
+
+ if ($query && $query->num_rows() > 0)
+ {
+ foreach ($query->result() as $row)
+ {
+
+ $grid_2char_confirmed = strtoupper(substr($row->SAT_SQUARE,0,2));
+ $grid_4char_confirmed = strtoupper(substr($row->SAT_SQUARE,0,4));
+ if ($this->config->item('map_6digit_grids')) {
+ $grid_6char_confirmed = strtoupper(substr($row->SAT_SQUARE,0,6));
+ }
+
+ // Check if 2 Char is in array
+ if(!in_array($grid_2char_confirmed, $array_confirmed_grid_2char)){
+ array_push($array_confirmed_grid_2char, $grid_2char_confirmed);
+ }
+
+
+ if(!in_array($grid_4char_confirmed, $array_confirmed_grid_4char)){
+ array_push($array_confirmed_grid_4char, $grid_4char_confirmed);
+ }
+
+
+ if ($this->config->item('map_6digit_grids')) {
+ if(!in_array($grid_6char_confirmed, $array_confirmed_grid_6char)){
+ array_push($array_confirmed_grid_6char, $grid_6char_confirmed);
+ }
+ }
+
+
+ }
+ }
+
+ // Get worked squares
+ $query = $this->gridsquares_model->get_worked_sat_squares($logbooks_locations_array);
+
+ if ($query && $query->num_rows() > 0)
+ {
+ foreach ($query->result() as $row)
+ {
+
+ $grid_two = strtoupper(substr($row->SAT_SQUARE,0,2));
+ $grid_four = strtoupper(substr($row->SAT_SQUARE,0,4));
+ if ($this->config->item('map_6digit_grids')) {
+ $grid_six = strtoupper(substr($row->SAT_SQUARE,0,6));
+ }
+
+ // Check if 2 Char is in array
+ if(!in_array($grid_two, $array_grid_2char)){
+ array_push($array_grid_2char, $grid_two);
+ }
+
+
+ if(!in_array($grid_four, $array_grid_4char)){
+ array_push($array_grid_4char, $grid_four);
+ }
+
+
+ if ($this->config->item('map_6digit_grids')) {
+ if(!in_array($grid_six, $array_grid_6char)){
+ array_push($array_grid_6char, $grid_six);
+ }
+ }
+
+
+ }
+ }
+
+ $query_vucc = $this->gridsquares_model->get_worked_sat_vucc_squares($logbooks_locations_array);
+
+ if ($query && $query_vucc->num_rows() > 0)
+ {
+ foreach ($query_vucc->result() as $row)
+ {
+
+ $grids = explode(",", $row->COL_VUCC_GRIDS);
+
+ foreach($grids as $key) {
+ $grid_two = strtoupper(substr($key,0,2));
+ $grid_four = strtoupper(substr($key,0,4));
+
+ // Check if 2 Char is in array
+ if(!in_array($grid_two, $array_grid_2char)){
+ array_push($array_grid_2char, $grid_two);
+ }
+
+
+ if(!in_array($grid_four, $array_grid_4char)){
+ array_push($array_grid_4char, $grid_four);
+ }
+ }
+ }
+ }
+
+ // Confirmed Squares
+ $query_vucc = $this->gridsquares_model->get_confirmed_sat_vucc_squares($logbooks_locations_array);
+
+ if ($query && $query_vucc->num_rows() > 0)
+ {
+ foreach ($query_vucc->result() as $row)
+ {
+
+ $grids = explode(",", $row->COL_VUCC_GRIDS);
+
+ foreach($grids as $key) {
+ $grid_2char_confirmed = strtoupper(substr($key,0,2));
+ $grid_4char_confirmed = strtoupper(substr($key,0,4));
+
+ // Check if 2 Char is in array
+ if(!in_array($grid_2char_confirmed, $array_confirmed_grid_2char)){
+ array_push($array_confirmed_grid_2char, $grid_2char_confirmed);
+ }
+
+
+ if(!in_array($grid_4char_confirmed, $array_confirmed_grid_4char)){
+ array_push($array_confirmed_grid_4char, $grid_4char_confirmed);
+ }
+ }
+ }
+ }
+
+
+ function js_str($s)
+ {
+ return '"' . addcslashes($s, "\0..\37\"\\") . '"';
+ }
+
+ function js_array($array)
+ {
+ $temp = array_map('js_str', $array);
+ return '[' . implode(',', $temp) . ']';
+ }
+
+
+ $data['grid_2char_confirmed'] = js_array($array_confirmed_grid_2char);
+ $data['grid_4char_confirmed'] = js_array($array_confirmed_grid_4char);
+ $data['grid_6char_confirmed'] = js_array($array_confirmed_grid_6char);
+
+ $data['grid_2char'] = js_array($array_grid_2char);
+ $data['grid_4char'] = js_array($array_grid_4char);
+ $data['grid_6char'] = js_array($array_grid_6char);
+
+
+ $this->load->view('visitor/layout/header', $data);
+ $this->load->view('gridsquares/index');
+ $this->load->view('visitor/layout/footer');
+ }
+
}
\ No newline at end of file
diff --git a/application/models/Gridsquares_model.php b/application/models/Gridsquares_model.php
index 537df547..6bd36304 100644
--- a/application/models/Gridsquares_model.php
+++ b/application/models/Gridsquares_model.php
@@ -2,13 +2,13 @@
class Gridsquares_model extends CI_Model {
- function get_worked_sat_squares() {
- $CI =& get_instance();
- $CI->load->model('logbooks_model');
- $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
-
- if (!$logbooks_locations_array) {
- return null;
+ function get_worked_sat_squares($StationLocationsArray = null) {
+ if($StationLocationsArray == null) {
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ } else {
+ $logbooks_locations_array = $StationLocationsArray;
}
$this->db->select('distinct substring(COL_GRIDSQUARE,1,6) as SAT_SQUARE, COL_SAT_NAME', FALSE);
@@ -19,10 +19,14 @@ class Gridsquares_model extends CI_Model {
return $this->db->get($this->config->item('table_name'));
}
- function get_confirmed_sat_squares() {
- $CI =& get_instance();
- $CI->load->model('logbooks_model');
- $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ function get_confirmed_sat_squares($StationLocationsArray = null) {
+ if($StationLocationsArray == null) {
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ } else {
+ $logbooks_locations_array = $StationLocationsArray;
+ }
if (!$logbooks_locations_array) {
return null;
@@ -38,10 +42,14 @@ class Gridsquares_model extends CI_Model {
}
- function get_confirmed_sat_vucc_squares() {
- $CI =& get_instance();
- $CI->load->model('logbooks_model');
- $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ function get_confirmed_sat_vucc_squares($StationLocationsArray = null) {
+ if($StationLocationsArray == null) {
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ } else {
+ $logbooks_locations_array = $StationLocationsArray;
+ }
if (!$logbooks_locations_array) {
return null;
@@ -56,10 +64,14 @@ class Gridsquares_model extends CI_Model {
return $this->db->query($sql);
}
- function get_worked_sat_vucc_squares() {
- $CI =& get_instance();
- $CI->load->model('logbooks_model');
- $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ function get_worked_sat_vucc_squares($StationLocationsArray = null) {
+ if($StationLocationsArray == null) {
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ } else {
+ $logbooks_locations_array = $StationLocationsArray;
+ }
if (!$logbooks_locations_array) {
return null;
@@ -72,10 +84,14 @@ class Gridsquares_model extends CI_Model {
return $this->db->get($this->config->item('table_name'));
}
- function get_band($band) {
- $CI =& get_instance();
- $CI->load->model('logbooks_model');
- $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ function get_band($band, $StationLocationsArray = null) {
+ if($StationLocationsArray == null) {
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ } else {
+ $logbooks_locations_array = $StationLocationsArray;
+ }
if (!$logbooks_locations_array) {
return null;
@@ -97,11 +113,15 @@ class Gridsquares_model extends CI_Model {
return $this->db->get($this->config->item('table_name'));
}
- function get_band_confirmed($band) {
- $CI =& get_instance();
- $CI->load->model('logbooks_model');
- $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
-
+ function get_band_confirmed($band, $StationLocationsArray = null) {
+ if($StationLocationsArray == null) {
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ } else {
+ $logbooks_locations_array = $StationLocationsArray;
+ }
+
if (!$logbooks_locations_array) {
return null;
}
@@ -127,11 +147,14 @@ class Gridsquares_model extends CI_Model {
return $this->db->query($sql);
}
- function search_band($band, $gridsquare) {
- $CI =& get_instance();
- $CI->load->model('logbooks_model');
- $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
-
+ function search_band($band, $gridsquare, $StationLocationsArray = null) {
+ if($StationLocationsArray == null) {
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ } else {
+ $logbooks_locations_array = $StationLocationsArray;
+ }
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = 'SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_GRIDSQUARE, COL_VUCC_GRIDS FROM '
@@ -155,11 +178,14 @@ class Gridsquares_model extends CI_Model {
return json_encode($result->result());
}
- function search_sat($gridsquare) {
- $CI =& get_instance();
- $CI->load->model('logbooks_model');
- $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
-
+ function search_sat($gridsquare, $StationLocationsArray = null) {
+ if($StationLocationsArray == null) {
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ } else {
+ $logbooks_locations_array = $StationLocationsArray;
+ }
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = 'SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_SAT_NAME, COL_GRIDSQUARE, COL_VUCC_GRIDS FROM ' .
diff --git a/application/views/visitor/layout/footer.php b/application/views/visitor/layout/footer.php
index 48d232b9..7805bf19 100644
--- a/application/views/visitor/layout/footer.php
+++ b/application/views/visitor/layout/footer.php
@@ -1,3 +1,5 @@
+uri->segment(2); ?>
+
@@ -29,15 +31,17 @@
$('[data-toggle="tooltip"]').tooltip()
});
-
+
var q_lat = ;
var q_lng = ;
var q_lat = 40.313043;
var q_lng = -32.695312;
-
+
+
var qso_loc = '';
+
var q_zoom = 3;
$(document).ready(function(){
@@ -50,6 +54,129 @@
initmap(grid);
});
+
+
+
+uri->segment(2) == "satellites") { ?>
+
+
+
+