Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter 2 restrict controller to command line

I need to restrict a controller in CI 2 to only run from command line. The other controllers in the application are accessible from the web.

What's the best way to do it?

like image 530
applechief Avatar asked Nov 11 '11 10:11

applechief


1 Answers

You might want to check if is a CLI request:

class Mycontroller extends CI_Controller {

   function __construct()
   {
     parent::__construct();

     if(!$this->input->is_cli_request())
     { 
       // echo 'Not allowed';
       // exit();
     }
   }

}
like image 124
Damien Pirsy Avatar answered Sep 22 '22 08:09

Damien Pirsy