Init Repo

This commit is contained in:
root
2019-09-06 23:53:10 +08:00
commit f0ef89dfbb
7905 changed files with 914138 additions and 0 deletions

View File

@ -0,0 +1,12 @@
<?php
namespace wstmart\admin\behavior;
/**
* ============================================================================
* 初始化基础数据
*/
class InitConfig
{
public function run(&$params){
WSTConf('listenUrl',WSTVisitPrivilege());
}
}

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

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

View 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;
}
}