From 0fd289419313e564b7d2df31a7c69d0ad8ecf4eb Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Sun, 10 Jul 2022 11:27:08 +0100 Subject: [PATCH] [Visitor] Hopefully fixes incorrect logs loading Maybe Fixes #1530 --- application/controllers/Visitor.php | 32 +++++++++++++++++------------ 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/application/controllers/Visitor.php b/application/controllers/Visitor.php index f57b8dc1..8a5b8045 100644 --- a/application/controllers/Visitor.php +++ b/application/controllers/Visitor.php @@ -56,13 +56,9 @@ class Visitor extends CI_Controller { $logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($public_slug); if($logbook_id != false) { - - print_r($logbook_id); // Get associated station locations for mysql queries $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id); - print_r($logbooks_locations_array); - if (!$logbooks_locations_array) { show_404('Empty Logbook'); } @@ -138,10 +134,15 @@ class Visitor extends CI_Controller { $slug = $this->security->xss_clean($this->uri->segment(3)); $this->load->model('logbooks_model'); - if($logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($slug) != false) + $logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($slug); + if($logbook_id != false) { // Get associated station locations for mysql queries $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id); + + if (!$logbooks_locations_array) { + show_404('Empty Logbook'); + } } else { log_message('error', $slug.' has no associated station locations'); show_404('Unknown Public Page.'); @@ -236,14 +237,19 @@ class Visitor extends CI_Controller { $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.'); - } + $logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($slug); + if($logbook_id != false) + { + // Get associated station locations for mysql queries + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id); + + if (!$logbooks_locations_array) { + show_404('Empty Logbook'); + } + } else { + log_message('error', $slug.' has no associated station locations'); + show_404('Unknown Public Page.'); + } } $this->load->model('gridsquares_model');