Codeigniter 2 restrict controller to command line

。_饼干妹妹 提交于 2019-12-12 07:55:18

问题


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?


回答1:


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();
     }
   }

}


来源:https://stackoverflow.com/questions/8092945/codeigniter-2-restrict-controller-to-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!