From 81a968947b8a3579c482ba4a4d29bd1f5fd3c354 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 2 Dec 2019 12:36:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Base/Service/PromoteService.class.php | 50 +++++++++++++++++++ .../Home/Controller/HomeController.class.php | 7 ++- .../Controller/PackageController.class.php | 5 +- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index a8d5e1e7c..79fa51a05 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -958,4 +958,54 @@ class PromoteService { return M('promote', 'tab_')->add($data); } + + public function getLandingPageIdentifier($url) + { + $code = $this->getUrlParam($url, 'code'); + if ($code === null) { + $pid = $this->getUrlParam($url, 'gid'); + $gid = $this->getUrlParam($url, 'pid'); + if ($gid === null || $gid === null) { + return null; + } else { + return $gid . '-' . $pid; + } + } + return $code; + } + + public function getDownloadIdentifier($url) + { + $code = $this->getUrlParam($url, 'code'); + if ($code === null) { + $pid = $this->getUrlParam($url, 'game_id'); + $gid = $this->getUrlParam($url, 'promote_id'); + if ($gid === null || $gid === null) { + return null; + } else { + return $gid . '-' . $pid; + } + } + return $code; + } + + private function getUrlParam($url, $name) + { + $items = parse_url($url); + $queryString = ltrim($items['query'], 's='); + $queryString = ltrim($queryString, '/'); + $queryString = rtrim($queryString, '.html'); + $rows = explode('/', $queryString); + $codeIndex = null; + foreach ($rows as $key => $value) { + if ($key >= 3 && $value == $name) { + $codeIndex = $key; + break; + } + } + if ($codeIndex !== null) { + return $rows[$codeIndex + 1] ?? null; + } + return null; + } } \ No newline at end of file diff --git a/Application/Home/Controller/HomeController.class.php b/Application/Home/Controller/HomeController.class.php index 9254e4332..5a0a198ad 100644 --- a/Application/Home/Controller/HomeController.class.php +++ b/Application/Home/Controller/HomeController.class.php @@ -142,8 +142,9 @@ class HomeController extends Controller $this->error('访问错误'); } - $blackList = M('device_bans', 'tab_')->where(['type' => 3])->getField('tag', true); - if (in_array($code, $blackList) || in_array('gid/' . $gameId . '/pid/' . $promoteId, $blackList)) { + $identifier = $code != '' ? $code : 'gid/' . $gameId . '/pid/' . $promoteId; + $isBlack = M('device_bans', 'tab_')->where(['type' => 3, 'tag' => ['like', '%' . $identifier . '%']])->limit(1)->getField('id'); + if ($isBlack) { $this->error('该链接已被禁'); } @@ -228,6 +229,8 @@ class HomeController extends Controller $this->assign('apply', $apply); $this->assign('game', $game); $this->assign('promoteId', $promoteId); + $cur_url = base64_encode(base64_encode("http://" . $_SERVER['HTTP_HOST'] . __SELF__)); + $this->assign('cur_url', $cur_url); $this->display('landingPage'); } diff --git a/Application/Home/Controller/PackageController.class.php b/Application/Home/Controller/PackageController.class.php index 580cc849d..830606409 100644 --- a/Application/Home/Controller/PackageController.class.php +++ b/Application/Home/Controller/PackageController.class.php @@ -35,8 +35,9 @@ class PackageController extends Controller $this->redirect("package/downloadError", ['message' => '访问错误']); } - $blackList = M('device_bans', 'tab_')->where(['type' => 4])->getField('tag', true); - if (in_array($code, $blackList) || in_array('game_id/' . $gameId . '/promote_id/' . $promoteId, $blackList)) { + $identifier = $code != '' ? $code : 'game_id/' . $gameId . '/promote_id/' . $promoteId; + $isBlack = M('device_bans', 'tab_')->where(['type' => 4, 'tag' => ['like', '%' . $identifier . '%']])->limit(1)->getField('id'); + if ($isBlack) { $this->redirect("package/downloadError", ['message' => '该链接已被禁']); } if ($code != '') {