Home > Backend Development > PHP Tutorial > How to prevent users from directly entering method instances in the php background_PHP tutorial

How to prevent users from directly entering method instances in the php background_PHP tutorial

WBOY
Release: 2016-07-13 10:25:59
Original
880 people have browsed it

1) Create a BaseController controller and inherit the Controller (all background operations must inherit the BaseController):

Add in BaseController:

Copy code The code is as follows:

public function checkLogin() {

if (Yii::app ()->authority->isLogin() == Yii::app()->authority->getStatus('NOTLOGIN')) {
                              $url = $this->createUrl('user /login');
                    if (Yii::app()->request->isPostRequest && Yii::app()->request->isAjaxRequest) { code' => -101, 'message' => 'The user is not logged in ', 'callback' => 'window.location="' . $url . '";'));
          } else if (Yii::app()->request->isAjaxRequest) {
          echo '
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template