You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
12
hyhproject/admin/behavior/InitConfig.php
Executable file
12
hyhproject/admin/behavior/InitConfig.php
Executable file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace wstmart\admin\behavior;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 初始化基础数据
|
||||
*/
|
||||
class InitConfig
|
||||
{
|
||||
public function run(&$params){
|
||||
WSTConf('listenUrl',WSTVisitPrivilege());
|
||||
}
|
||||
}
|
37
hyhproject/admin/behavior/ListenLoginStatus.php
Executable file
37
hyhproject/admin/behavior/ListenLoginStatus.php
Executable file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace wstmart\admin\behavior;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 检测用户有没有登录
|
||||
*/
|
||||
class ListenLoginStatus
|
||||
{
|
||||
public function run(&$params){
|
||||
$STAFF = session('WST_STAFF');
|
||||
$allowUrl = ['admin/index/login',
|
||||
'admin/index/checklogin',
|
||||
'admin/index/logout',
|
||||
'admin/index/logout',
|
||||
'admin/index/getverify',
|
||||
'admin/cronjobs/autocancelnopay',
|
||||
'admin/cronjobs/autoappraise',
|
||||
'admin/cronjobs/autoreceive',
|
||||
'admin/cronjobs/autosendmsg'
|
||||
];
|
||||
$request = request();
|
||||
$visit = strtolower($request->module()."/".$request->controller()."/".$request->action());
|
||||
if(empty($STAFF) && !in_array($visit,$allowUrl)){
|
||||
if($request->isAjax()){
|
||||
echo json_encode(['status'=>-999,'msg'=>'对不起,您还没有登录,请先登录']);
|
||||
}else{
|
||||
if('quanlianggongmall' == input('key')){
|
||||
header("Location:".url('admin/index/login?key=quanlianggongmall'));
|
||||
}else{
|
||||
echo 'hello';
|
||||
}
|
||||
|
||||
}
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
24
hyhproject/admin/behavior/ListenOperate.php
Executable file
24
hyhproject/admin/behavior/ListenOperate.php
Executable file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace wstmart\admin\behavior;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 记录用户的访问日志
|
||||
*/
|
||||
class ListenOperate
|
||||
{
|
||||
public function run(&$params){
|
||||
$urls = WSTConf('listenUrl');
|
||||
$request = request();
|
||||
$visit = strtolower($request->module()."/".$request->controller()."/".$request->action());
|
||||
if(array_key_exists($visit,$urls)&& $visit!='admin/logoperates/pagequery'){
|
||||
$privilege = current($urls[$visit]);
|
||||
$data = [];
|
||||
$data['menuId'] = $privilege['menuId'];
|
||||
$data['operateUrl'] = $_SERVER['REQUEST_URI'];
|
||||
$data['operateDesc'] = $privilege['name'];
|
||||
$data['content'] = !empty($_REQUEST)?json_encode($_REQUEST):'';
|
||||
$data['operateIP'] = $request->ip();
|
||||
model('admin/LogOperates')->add($data);
|
||||
}
|
||||
}
|
||||
}
|
33
hyhproject/admin/behavior/ListenPrivilege.php
Executable file
33
hyhproject/admin/behavior/ListenPrivilege.php
Executable file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace wstmart\admin\behavior;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 检测有没有访问权限
|
||||
*/
|
||||
class ListenPrivilege
|
||||
{
|
||||
public function run(&$params){
|
||||
$privileges = session('WST_STAFF.privileges');
|
||||
$staffId = (int)session('WST_STAFF.staffId');
|
||||
if($staffId!=1){
|
||||
$urls = WSTConf('listenUrl');
|
||||
$request = request();
|
||||
$visit = strtolower($request->module()."/".$request->controller()."/".$request->action());
|
||||
if(array_key_exists($visit,$urls) && !$this->checkUserCode($urls[$visit],$privileges)){
|
||||
if($request->isAjax()){
|
||||
echo json_encode(['status'=>-998,'msg'=>'对不起,您没有操作权限,请与管理员联系']);
|
||||
}else{
|
||||
header("Content-type: text/html; charset=utf-8");
|
||||
echo "对不起,您没有操作权限,请与管理员联系";
|
||||
}
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
private function checkUserCode($urlCodes,$userCodes){
|
||||
foreach ($urlCodes as $key => $value) {
|
||||
if(in_array($key,$userCodes))return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user