From 0f9b29c52ed7086a14c458d23b289de5e8250b87 Mon Sep 17 00:00:00 2001 From: Paolo Date: Mon, 25 Nov 2019 16:25:10 +0100 Subject: [PATCH] - Added private method _checkHTTPS to core/FHC_Controller - Method _checkHTTPS is called in core/FHC_Controller constructor immediately after the parent constructor call - Method _checkHTTPS checks if the HTTPS protocol is enabled and used, if NOT then an error is raised and the execution is terminated --- application/core/FHC_Controller.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php index 234cf6a6f..93c324b21 100644 --- a/application/core/FHC_Controller.php +++ b/application/core/FHC_Controller.php @@ -21,6 +21,9 @@ abstract class FHC_Controller extends CI_Controller { parent::__construct(); + // NOTE: placed here before performing anything else!!! + $this->_checkHTTPS(); + $this->_controllerId = null; // set _controllerId as null by default // Loads helper message to manage returning messages @@ -129,4 +132,20 @@ abstract class FHC_Controller extends CI_Controller { $this->output->set_content_type('application/json')->set_output(json_encode($mixed)); } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Checks if the call is performed via web and if HTTPS is enabled and used + * If NOT then an error is raised and the execution is terminated + */ + private function _checkHTTPS() + { + // If NOT called from command line and if the HTTPS protocol is NOT enabled + if (!$this->input->is_cli_request() && !isset($_SERVER['HTTPS'])) + { + show_error('This web site cannot work correctly without the HTTPS protocol enabled'); + } + } }