PHP教程

php屏蔽非正常访问和检测用户登录检测

本文主要是介绍php屏蔽非正常访问和检测用户登录检测,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

<?php
namespace Manage\Controller;
use Common\Controller\DefaultController;
class BaseController extends DefaultController {

public function __construct(){
parent::__construct();
$this->initial();
}

private function initial(){
//屏蔽非正常访问
$back_path=$_COOKIE["SYSTEM_PATH"];
if(empty($back_path)) $back_path=SYSTEM_PATH;
if($back_path!='system'){
throw_exception('404');
}

global $publicData;
$peizhi=$publicData['peizhi'];

//检测用户登录
$checklogin=SL('Admin')->checklogin();
$nowAction = MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME;
if($checklogin[0]==0 && !strstr($nowAction,'Manage/Index/')){
header('Location:'.U('/Manage'));
}

$this->assign('config',$peizhi);
$this->assign('siteName','https://www.bz80.vip');
$this->assign('admin',$checklogin[1]);
}
public function index(){
$buffer = SL(CONTROLLER_NAME.'/index', $_REQUEST);
$this->reback($buffer, 1);
}
public function add(){
$buffer = SL(CONTROLLER_NAME.'/add', $_REQUEST);
$this->reback($buffer,1);
}
public function edit(){
$buffer = SL(CONTROLLER_NAME.'/edit', $_REQUEST);
$this->reback($buffer, 1);
}
public function save(){
$buffer = SL(CONTROLLER_NAME.'/save', $_REQUEST);
$this->reback($buffer);
}
public function delete(){
$buffer = SL(CONTROLLER_NAME.'/delete', $_REQUEST);
$this->reback($buffer);
}
}

这篇关于php屏蔽非正常访问和检测用户登录检测的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!