From 6e354fe3b3b6727e5615e8aada869e9bdf386104 Mon Sep 17 00:00:00 2001 From: "elf@home" <360197197@qq.com> Date: Sun, 29 Dec 2019 23:36:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=93=BE=E6=8E=A5=E5=BD=92?= =?UTF-8?q?=E5=B1=9E=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PromoteController.class.php | 66 +++++++++++-------- Application/Admin/View/Promote/linkInfo.html | 23 ++----- .../Base/Service/ApplyService.class.php | 55 ++++++++++++++++ 3 files changed, 98 insertions(+), 46 deletions(-) diff --git a/Application/Admin/Controller/PromoteController.class.php b/Application/Admin/Controller/PromoteController.class.php index b53e4ffc9..46954063b 100644 --- a/Application/Admin/Controller/PromoteController.class.php +++ b/Application/Admin/Controller/PromoteController.class.php @@ -1102,42 +1102,52 @@ class PromoteController extends ThinkController public function linkInfo() { $link = $_REQUEST['link']; - $strCode = "code/"; - $link_type = $_REQUEST['link_type']; - $linkArr = strstr ( $link , $strCode ); - $length = strlen($strCode); - $code = substr($linkArr, $length); - //$this->display(); + $applyServe = new ApplyService(); - $codeRes = $applyServe->decodeApplyCode($code); - $promote_id = $codeRes['promote_id']; - $game_id = $codeRes["game_id"]; - $promoteInfo = M('promote','tab_')->field('account')->where(['id'=>$promote_id])->find(); + $identifier = $applyServe->getPageIdentifier($link); + if (!$identifier) { + $this->assign('error', '链接异常'); + return $this->display(); + } + $promoteId = 0; + $gameId = 0; + $createdAt = '无法获知'; + $expiresIn = 0; + $realType = 0; + if (isset($identifier['code'])) { + $result = $applyServe->decodeApplyCode($identifier['code']); + if (!$result) { + $this->assign('error', '解码异常'); + return $this->display(); + } + $promoteId = $result['promote_id']; + $gameId = $result["game_id"]; + $expiresIn = $result['expires_in']; + $createdAt = $result['created_at']; + $realType = $result['type']; + } else if(isset($identifier['promote_id']) && isset($identifier['game_id'])) { + $promoteId = $identifier['promote_id']; + $gameId = $identifier["game_id"]; + $realType = $identifier['type']; + } + + $promoteInfo = M('promote','tab_')->field('account')->where(['id'=>$promoteId])->find(); $params['account'] = $promoteInfo['account']; - $game_id = $codeRes['game_id']; - $gameInfo = M('game','tab_')->field('game_name')->where(['id'=>$game_id])->find(); + $gameInfo = M('game','tab_')->field('game_name')->where(['id'=>$gameId])->find(); $params['game_name'] = $gameInfo['game_name']; - if(!empty($codeRes)) { - $expires_in = $codeRes['expires_in']; - }else { - $expires_in = -100; - } - if($expires_in == 0) { + if($expiresIn == 0) { $params['expires_in'] = "永久性"; - }else if($expires_in > 0) { - $params['expires_in'] = $expires_in; + }else if($expiresIn > 0) { + $params['expires_in'] = $expiresIn; } - $params['created_at'] = $codeRes['created_at']; - if($codeRes['type'] == 1) { - $params['type'] = '复制下载链接'; - }else if($codeRes['type'] == 2) { + $params['created_at'] = $createdAt; + if($realType == 1) { + $params['type'] = '下载链接'; + } else if($realType == 2) { $params['type'] = '落地页链接'; } - if($codeRes['type'] == $link_type || $link_type == 0) { - $this->assign('params',$params); - } + $this->assign('params',$params); $this->display(); - } } diff --git a/Application/Admin/View/Promote/linkInfo.html b/Application/Admin/View/Promote/linkInfo.html index 11a562686..35e84734b 100644 --- a/Application/Admin/View/Promote/linkInfo.html +++ b/Application/Admin/View/Promote/linkInfo.html @@ -52,25 +52,12 @@
-
- -
-
- -
- - - +
+ +
- - +
- -
搜索
@@ -95,7 +82,7 @@ - aOh! 暂时还没有内容! + aOh! 暂时还没有内容! diff --git a/Application/Base/Service/ApplyService.class.php b/Application/Base/Service/ApplyService.class.php index b6b1f416f..5590f5924 100644 --- a/Application/Base/Service/ApplyService.class.php +++ b/Application/Base/Service/ApplyService.class.php @@ -142,4 +142,59 @@ class ApplyService { 'message' => '验证成功', ]; } + + public function getPageIdentifier($url) + { + $params = $this->getUrlParams($url); + $sValue = isset($params['s']) ? $params['s'] : ''; + $code = $this->getSParam($sValue, 'code'); + if ($code === null) { + $gid = $this->getSParam($sValue, 'game_id'); + $pid = $this->getSParam($sValue, 'promote_id'); + $type = 0; + if ($gid && $pid) { + $type = 1; + } else { + $gid = $this->getSParam($sValue, 'gid'); + $pid = $this->getSParam($sValue, 'pid'); + $type = 2; + } + if ($gid === null || $gid === null) { + return null; + } else { + return [ + 'game_id' => $gid, + 'promote_id' => $pid, + 'type' => $type, + ]; + } + } + return ['code' => $code]; + } + + public function getSParam($sValue, $name) + { + $sValue = ltrim($sValue, '/'); + $sValue = rtrim($sValue, '.html'); + $rows = explode('/', $sValue); + $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; + } + + public function getUrlParams($url) + { + $items = parse_url($url); + $queryParts = explode('&', $items['query']); + parse_str($items['query'], $params); + return $params; + } } \ No newline at end of file