- 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
This commit is contained in:
Paolo
2019-11-25 16:25:10 +01:00
parent ceb3f212c9
commit 0f9b29c52e
+19
View File
@@ -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');
}
}
}