Merge branch 'hotfix/link_info' into release

master
ELF 5 years ago
commit a31e42b7c4

@ -1140,43 +1140,53 @@ 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();
}
/**

@ -52,25 +52,12 @@
<!-- 高级搜索 -->
<div class="jssearch fl cf search_list">
<div class="input-list search-title-box">
<label>链接归属:</label>
</div>
<div class="input-list">
<input type="text" name="link" placeholder="链接归属" value="">
</div>
<div class="input-list search-title-box">
<label>链接归属:</label>
</div>
<div class="input-list">
<label>链接类型:</label>
<select name="link_type">
<option value="0">全部</option>
<option value="1">下载链接</option>
<option value="2">落地页下载链接</option>
</select>
<input type="text" name="link" placeholder="链接归属" value="">
</div>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('linkInfo')}">搜索</a>
</div>
@ -95,7 +82,7 @@
<!-- 列表 -->
<tbody>
<empty name ="params">
<td colspan="14" class="text-center"> aOh! 暂时还没有内容! </td>
<td colspan="14" class="text-center"> <?php if($error != ''):?> <span style="color: red;"><?= $error ?></span><?php else:?>aOh! 暂时还没有内容! <?php endif;?></td>
<else />
<tr>

@ -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;
}
}
Loading…
Cancel
Save