Browse Source

防止sql注入

master
wanghongjun 3 years ago
parent
commit
bd94f83bfd
  1. 12
      source/application/api/controller/pass/Passcc.php
  2. 2
      source/application/common/logic/PassFlow.php

12
source/application/api/controller/pass/Passcc.php

@ -26,8 +26,8 @@ class Passcc extends Controller
public function allGroupTimeNum() public function allGroupTimeNum()
{ {
$granularity = $this->request->param('granularity'); $granularity = $this->request->param('granularity');
$groupsId = $this->request->param('groupsId'); $type = $this->request->param('type');
$res = PassFlow::allGroupTimeNum(['granularity' => $granularity, 'groupsId' => $groupsId]); $res = PassFlow::allGroupTimeNum(['granularity' => $granularity, 'type' => $type]);
if (empty($res['code'])) $this->renderError($res['msg']); if (empty($res['code'])) $this->renderError($res['msg']);
$data = $res['data']; $data = $res['data'];
return $this->renderSuccess(compact('data')); return $this->renderSuccess(compact('data'));
@ -42,8 +42,8 @@ class Passcc extends Controller
*/ */
public function allGroupNum() public function allGroupNum()
{ {
$groupsId = $this->request->param('groupsId') ?: ''; $type = $this->request->param('type') ?: '';
$returnData = PassFlow::allGroupNum(null,['groupsId' => $groupsId]); $returnData = PassFlow::allGroupNum(null,['type' => $type]);
return $this->renderSuccess(compact('returnData')); return $this->renderSuccess(compact('returnData'));
} }
@ -69,8 +69,8 @@ class Passcc extends Controller
*/ */
public function toDayGroupsEnterNum() public function toDayGroupsEnterNum()
{ {
$groupsId = $this->request->param('groupsId') ?: ''; $type = $this->request->param('type') ?: '';
$data = PassFlow::toDayGroupsEnterNum(null,['groupsId' => $groupsId]); $data = PassFlow::toDayGroupsEnterNum(null,['type' => $type]);
return $this->renderSuccess(compact('data')); return $this->renderSuccess(compact('data'));
} }

2
source/application/common/logic/PassFlow.php

@ -7,6 +7,7 @@ use app\common\dm\Dm;
class PassFlow class PassFlow
{ {
protected static $groupType = [1,2];# 1 = 体育 2 = 文化 protected static $groupType = [1,2];# 1 = 体育 2 = 文化
protected static $granularity = ['daily','monthly','yearly'];# 1 = 体育 2 = 文化
protected static function getGroupIds($dm,$type = 1) protected static function getGroupIds($dm,$type = 1)
{ {
@ -31,6 +32,7 @@ class PassFlow
$type = $param['type']; $type = $param['type'];
if (empty($granularity)) return ['code' => 0, 'msg' => '缺少参数:granularity']; if (empty($granularity)) return ['code' => 0, 'msg' => '缺少参数:granularity'];
if (!in_array($granularity,self::$granularity)) return ['code' => 0, 'msg' => '参数错误:granularity'];
$where = ''; $where = '';
$groupsId = ''; $groupsId = '';
if (!empty($type)) { if (!empty($type)) {

Loading…
Cancel
Save