From 3bd289a3c14f377c3c689f97cf20366571f6add9 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 13 Jul 2016 21:47:56 +0200 Subject: Throw public exception when accessing CLI only functions We actually don't need to hide this from the user. The error should be shown rather than a blank page being returned. Signed-off-by: Florian Pritz --- application/core/MY_Controller.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'application/core') diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php index 79d258c37..ede6577da 100644 --- a/application/core/MY_Controller.php +++ b/application/core/MY_Controller.php @@ -105,4 +105,11 @@ class MY_Controller extends CI_Controller { $this->data["user_logged_in"] = $this->muser->logged_in(); $this->data['redirect_uri'] = $this->uri->uri_string(); } + + protected function _require_cli_request() + { + if (!$this->input->is_cli_request()) { + throw new \exceptions\PublicApiException("api/cli-only", "This function can only be accessed via the CLI interface"); + } + } } -- cgit v1.2.3-24-g4f1b