修改落地页/下载页

master
elf@home 5 years ago
parent 55d9c36ccf
commit fc1cef9ec1

@ -3,6 +3,7 @@ namespace Base\Service;
use Base\Model\PromoteModel;
use Base\Model\ApplyModel;
use Base\Tool\Request;
class ApplyService {
@ -22,4 +23,29 @@ class ApplyService {
M('apply', 'tab_')->where(['game_id' => $gameId, 'promote_id' => ['in', $ids]])->save($save);
}
public function getDownloadUrl($apply, $game = null)
{
$host = Request::getHost();
if(empty($apply['dow_url'])) {
if ($game == null) {
$columns = ['sdk_version', 'add_game_address', 'and_dow_address', 'ios_game_address', 'ios_dow_address'];
$game = M('game','tab_')->field($columns)->where(['id' => $apply['game_id']])->find();
}
if($game['sdk_version'] == 1){
if($game['add_game_address'] != '') {
return $game['add_game_address'];
}else{
return $host . substr($game['and_dow_address'], 1);
}
} else {
if($game['ios_game_address'] != ''){
return $game['ios_game_address'];
}else{
return $host . substr($game['ios_dow_address'], 1);
}
}
}
return $host . $apply['dow_url'];
}
}

@ -0,0 +1,138 @@
<?php
namespace Base\Tool;
/**
* @author elf<360197197@qq.com>
*/
class Request {
private static $instance;
private $serverInfo;
private $scheme;
private function __construct()
{
$this->serverInfo = $_SERVER;
}
public static function getInstance()
{
if (self::$instance == null) {
self::$instance = new static();
}
return self::$instance;
}
public function isWechat()
{
$userAgent = $this->getUserAgent();
if (strpos($userAgent, 'MicroMessenger') == false && strpos($userAgent, 'Windows Phone') == false) {
return false;
} else {
return true;
}
}
public function getUserAgent()
{
return $this->serverInfo['HTTP_USER_AGENT'] ?? '';
}
public function isMobile()
{
$isMobile = false;
$userAgent = $this->getUserAgent();
$mobileAgents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad','iPod'];
foreach ($mobileAgents as $mobileAgent) {
if (stripos($userAgent, $mobileAgent) !== false) {
$isMobile = true;
}
}
return $isMobile;
}
public function isIOS()
{
$userAgent = $this->getUserAgent();
if(stripos($userAgent, 'iphone') !== false || strpos($userAgent, 'ipad') !== false) {
return true;
}
return false;
}
public function isAndroid()
{
$userAgent = $this->getUserAgent();
if(strpos($userAgent, 'android')) {
return true;
}
return false;
}
public function isIOS13()
{
if (preg_match('/OS [1][3-9]_[1-9][_\d]* like Mac OS X/i')) {
return true;
}
return false;
}
/**
* 获取客户端IP
*/
public function getClientIP()
{
$serverInfo = $this->serverInfo;
$ip = '0.0.0.0';
if (isset($serverInfo['HTTP_X_FORWARDED_FOR'])) {
$items = explode(',', $serverInfo['HTTP_X_FORWARDED_FOR']);
$position = array_search('unknown', $items);
if (false !== $position) {
unset($items[$position]);
}
$ip = trim($items[0]);
} elseif (isset($serverInfo['HTTP_CLIENT_IP'])) {
$ip = $serverInfo['HTTP_CLIENT_IP'];
} elseif (isset($this->serverInfo['REMOTE_ADDR'])) {
$ip = $serverInfo['REMOTE_ADDR'];
}
return $ip;
}
public function getHost()
{
$host = $this->getScheme() . '://' . $this->serverInfo['SERVER_NAME'];
if (in_array($this->serverInfo['SERVER_PORT'], [80, 443])) {
return $host;
}
return $host . ':' . $this->serverInfo['SERVER_PORT'];
}
public function getScheme()
{
if ($this->scheme) {
return $this->scheme;
}
$serverInfo = $this->serverInfo;
if (isset($serverInfo['REQUEST_SCHEME'])) {
$this->scheme = $serverInfo['REQUEST_SCHEME'];
return $this->scheme;
}
if ((isset($serverInfo['HTTPS']) && $serverInfo['HTTPS'] == 'on')
|| (isset($serverInfo['HTTP_X_FORWARDED_PROTO']) && $serverInfo['HTTP_X_FORWARDED_PROTO'] == 'https'
|| (isset($serverInfo['SERVER_PORT']) && $serverInfo['SERVER_PORT'] == 443))
) {
$this->scheme = 'https';
} else {
$this->scheme = 'http';
}
return $this->scheme;
}
public static function __callStatic($name, $arguments)
{
$instance = self::getInstance();
return call_user_func_array([$instance, $name], $arguments);
}
}

@ -0,0 +1,329 @@
<?php
namespace Home\Controller;
use Think\Controller;
use App\Model\GameModel;
/**
* @author elf<360197197@qq.com>
*/
class DownloadController extends Controller {
public function down_error($message='')
{
$this->assign("message",$message);
$this->display();
}
public function index($game_id=0,$promote_id=0){
$applyModel = M('Apply','tab_');
$map['status'] = 1;
$map['enable_status'] = 1;
$data = $applyModel
->field('game_id,tab_apply.game_name,promote_id,promote_account,relation_game_id,pack_url,plist_url,`status`,enable_status,tab_apply.sdk_version')
->join("tab_game ON tab_apply.game_id = tab_game.id AND promote_id = $promote_id AND game_id = $game_id ")
->where($map)
->find();
$system_type = 1;
if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
$system_type = 2;
}
$gamemodel = new GameModel();
$source = $gamemodel->getGameDownInfo($game_id);
$pack_url = $this->package($source['packet'],$promote_id);
M('Game','tab_')->where('id='.$data['game_id'])->setInc('dow_num');
if(is_mobile_request()){
if($data['sdk_version'] == 1 && get_devices_type()==2)$this->redirect("Down/down_error",array('message'=>"请使用安卓浏览器下载"));
// if($data['sdk_version'] == 1 && is_weixin()) $this->redirect("Down/down_error",array('message'=>"请使用安卓浏览器下载"));
if($data['sdk_version'] == 2 && get_devices_type()==1)$this->redirect("Down/down_error",array('message'=>"请使用ios浏览器下载"));
}
switch ($data['sdk_version']) {
case 1:
if(!empty($pack_url)){
if(preg_match("/oss/", $pack_url)){
$url=str_replace('-internal', '', $pack_url);
echo "<script>window.location.href='$url';</script>";
}elseif(preg_match("/clouddn/", $pack_url)){
$url = "http://".$pack_url;
redirect($url);
}elseif(preg_match("/myqcloud/", $pack_url)){
redirect($pack_url);
}elseif(preg_match("/bcebos/", $pack_url)){
redirect($pack_url);
}else{
if (!file_exists($pack_url)){
$this->error('文件不存在哦 亲!');
}else{
redirect("http://".$_SERVER['HTTP_HOST'].ltrim($pack_url,'.'));
}
}
}else{
$this->error('原包地址不存在');
}
break;
default:
switch ($system_type) {
case 1:
if(!empty($pack_url)){
if(preg_match("/oss/", $pack_url)){
$url=str_replace('-internal', '', $pack_url);
echo "<script>window.location.href='$url';</script>";
}elseif(preg_match("/clouddn/", $pack_url)){
$url = "http://".$pack_url;
redirect($url);
}elseif(preg_match("/myqcloud/", $pack_url)){
redirect($pack_url);
}elseif(preg_match("/bcebos/", $pack_url)){
redirect($pack_url);
}else{
$this->down($pack_url);
}
}else{
$this->error('原包地址不存在');
}
break;
default:
$plist_url = substr($data['plist_url'],'1',strlen($data['plist_url']));
Header("HTTP/1.1 303 See Other");
Header("Location: "."itms-services://?action=download-manifest&url="."https://".$_SERVER["HTTP_HOST"]."/".$plist_url);
break;
}
break;
}
}
/**
* 投放包下载
* @param
* @author 鹿文学
*/
public function launch_down_file($game_id=0,$promote_id=0,$platform_id=0,$position=1) {
/* 检查游戏是否存在 */
//$game = M('game','tab_')->field('id,game_name')->where(['id'=>$game_id])->find();
//if(!is_array($game)) {$this->error('游戏不存在');}
/* 检查渠道包是否存在或更改 */
$applymodel = M('apply','tab_');
$apply = $applymodel->field('id,sdk_version,pack_url,plist_url')
->where(['game_id'=>$game_id,'promote_id'=>$promote_id])->find();
//if(!is_array($apply)) {$this->error('渠道不存在');}
$launchmodel = M('apply_launch','tab_');
$map = array(
'platform_id'=>$platform_id,
'apply_id'=>$apply['id'],
'position'=>$position,
);
$launch = $launchmodel->where($map)->find();
//if(!is_array($launch)) {$this->error('游戏包不存在');}
/* 检查原包是否存在或更改 */
$gamesource = M('game_source','tab_')->field('id,file_name,source_version')->where(['game_id'=>$game_id])->find();
if(!is_array($gamesource)) {$this->error('文件不存在哦');}
if($gamesource['file_name'] == $launch['game_source_filename']) {
$system_type = 1;
if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
$system_type = 2;
}
$pack_url = $launch['launch_down_url'];
M('Game','tab_')->where(['id'=>$game_id])->setInc('dow_num');
if(is_mobile_request()){
if($apply['sdk_version'] == 1 && get_devices_type()==2)$this->redirect("Down/down_error",array('message'=>"请使用安卓浏览器下载"));
if($apply['sdk_version'] == 1 && is_weixin())$this->redirect("Home/promotionofregistration",array('pid'=>$promote_id,'gid'=>$game_id,'lid'=>$platform_id,'p'=>$position,'message'=>"请使用安卓浏览器下载"));
if($apply['sdk_version'] == 2 && get_devices_type()==1)$this->redirect("Down/down_error",array('message'=>"请使用ios浏览器下载"));
}
switch ($apply['sdk_version']) {
case 1:
if(!empty($pack_url)){
if(preg_match("/oss/", $pack_url)){
$url=str_replace('-internal', '', $pack_url);
echo "<script>window.location.href='$url';</script>";
}elseif(preg_match("/clouddn/", $pack_url)){
$url = "http://".$pack_url;
redirect($url);
}elseif(preg_match("/myqcloud/", $pack_url)){
redirect($pack_url);
}elseif(preg_match("/bcebos/", $pack_url)){
redirect($pack_url);
}else{
$url = ROOTTT . substr($pack_url,stripos($pack_url,'uploads'));
if (!file_exists($url)){
$this->error('文件不存在哦 亲!');
}else{
redirect($pack_url);
}
}
}else{
$this->error('原包地址不存在');
}
break;
default:
switch ($system_type) {
case 1:
if(!empty($pack_url)){
if(preg_match("/oss/", $pack_url)){
$url=str_replace('-internal', '', $pack_url);
echo "<script>window.location.href='$url';</script>";
}elseif(preg_match("/clouddn/", $pack_url)){
$url = "http://".$pack_url;
redirect($url);
}elseif(preg_match("/myqcloud/", $pack_url)){
redirect($pack_url);
}elseif(preg_match("/bcebos/", $pack_url)){
redirect($pack_url);
}else{
$this->down($pack_url);
}
}else{
$this->error('原包地址不存在');
}
break;
default:
$plist_url = $launch['launch_plist_url'];
if(stripos($plist_url,'https://') === false) {
$plist_url = 'https://'.$_SERVER['HTTP_HOST'].str_replace('./','/',$plist_url);
}
Header("HTTP/1.1 303 See Other");
Header("Location: "."itms-services://?action=download-manifest&url=".$plist_url);
break;
}
break;
}
} else {
$applymodel->where(['id'=>$apply['id']])->setField('enable_status',2);
$this->error('游戏正在打包,请稍候');
}
}
public function media_down_file($game_id=0,$type=1){
$model = M('Game','tab_');
$map['tab_game.id'] = $game_id;
$map['file_type'] = $type;
$data = $model
->field('tab_game_source.*,tab_game.game_name,tab_game.add_game_address,tab_game.ios_game_address')
->join("left join tab_game_source on tab_game.id = tab_game_source.game_id")->where($map)->find();
if($type==1){
if($data['file_url']!=''||!varify_url($data['add_game_address'])){
$this->down($data['file_url']);
}
else{
Header("HTTP/1.1 303 See Other");
Header("Location: ".$data['add_game_address']);
}
}else{
if($data['file_url']!=''||!varify_url($data['ios_game_address'])){
$this->down($data['file_url']);
}
else{
Header("HTTP/1.1 303 See Other");
Header("Location: ".$data['ios_game_address']);
}
}
}
public function down($file, $isLarge = false, $rename = NULL)
{
if(headers_sent())return false;
if(!$file) {
$this->error('文件不存在哦 亲!');
}
if($rename==NULL){
if(strpos($file, '/')===false && strpos($file, '\\')===false)
$filename = $file;
else{
$filename = basename($file);
}
}else{
$filename = $rename;
}
header('Content-Description: File Transfer');
header("Content-Type: application/force-download;");
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=\"$filename\"");
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.filesize($file));//$_SERVER['DOCUMENT_ROOT'].
header("Pragma: no-cache"); //不缓存页面
ob_clean();
flush();
if($isLarge)
self::readfileChunked($file);
else
readfile($file);
}
public function down_material($game_id){
$map['status'] = 1;
$game = M("game",'tab_')->where($map)->find($game_id);
$material = $game['material_url'];
if(file_exists($material) && is_file($material)){
clearstatcache();
$this->down($material);
}else{
clearstatcache();
$this->error('下载地址错误');
}
}
/**
* 安卓打包渠道信息
* @param $source_info 原包信息
* @param $promote_id
* @return string
* author: xmy 280564871@qq.com
*/
public function package($source_info, $promote_id)
{
$file_path = $source_info['file_url'];
//验证原包是否存在
if (!varify_url($file_path)) {
$this->error("未上传原包");
} else {
$result = M('apply', 'tab_')
->alias('a')
->field('id, pack_url, plist_url')
->where(['a.game_id'=>$source_info['game_id'],'a.promote_id'=>$promote_id])
->find();
if(empty($result)) {
$this->error('此游戏不存在');
}
if(GameModel::ANDROID == $source_info['sdk_version']){
if(varify_url($result['pack_url'])) {
return $result['pack_url'];
}
}elseif(GameModel::IOS == $source_info['sdk_version']){
if(varify_url($result['plist_url'])) {
return $result['plist_url'];
}
}else{
$this->error('游戏版本错误');
}
}
}
}

@ -1,24 +1,9 @@
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace Home\Controller;
use Think\Controller;
use User\Api\MemberApi;
use Base\Tool\Request;
/**
* 前台公共控制器
@ -142,6 +127,66 @@ class HomeController extends Controller
$this->display();
}
public function landingPage()
{
$code = I('code', '');
$data = [];
$isWechat = Request::isWechat();
$isIOS = Request::isIOS();
$isAndroid = Request::isAndroid();
$isIOS13 = Request::isIOS13();
$columns = [
'id',
'sdk_version',
'icon',
'screenshot',
'relation_game_id',
'relation_game_name',
'dow_status',
'features',
'flooring_page_imgs',
];
$map = ['id' => intval($data['game_id'])];
$game = M('game', 'tab_')->field($columns)->where($map)->find();
if ($game['sdk_version'] == 1 && $isIOS) {
$map['relation_game_id'] = $game['relation_game_id'];
$map['sdk_version'] = 2;
$game = M('game', 'tab_')->field($columns)->where($map)->find();
} elseif ($game['sdk_version'] == 2 && $isAndroid) {
$map['relation_game_id'] = $game['relation_game_id'];
$map['sdk_version'] = 1;
$game = M('game', 'tab_')->field($columns)->where($map)->find();
}
$apply = M('apply', 'tab_')->field(['game_id', 'enable_status'])
->where(['promote_id' => $data['promote_id'], 'game_id' => $game['id']])
->find();
$game['flooring_page_imgs'] = explode(',', $game['flooring_page_imgs']);
$game['icon'] = get_cover($game['icon'], 'path');
$downloadUrl = '';
if ($isIOS13) {
$gameSource = M('GameSource', 'tab_')->where(array('game_id' => $gameId))->getField('org_plist_url');
$downloadUrl = 'itms-services://?action=download-manifest&url=' . Request::getHost() . ltrim($gameSource['org_plist_url'], '.');
} else {
$applyService = new ApplyService();
$downloadUrl = $applyService->getDownloadUrl($apply, $game);
}
$this->assign('downloadUrl', $downloadUrl);
$this->assign('isIOS13', $isIOS13);
$this->assign('isWechat', $isWechat);
$this->assign('isIOS', $isIOS);
$this->assign('isAndroid', $isAndroid);
$this->assign('apply', $apply);
$this->assign('game', $game);
$this->display();
}
public function iosDown()
{
$gameId = I('get.gid');

@ -0,0 +1,133 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta itemprop="name" content="{$game['relation_game_name']}"/>
<meta itemprop="image" content="{$game['icon']}"/>
<meta name="description" itemprop="description" content="{$game['features']}"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
<script type="text/javascript" src="__JS__/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="https://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<link href="{:get_cover(C('CH_SET_ICO'),'path')}" type="image/x-icon" rel="shortcut icon">
<title>{$game['relation_game_name']}</title>
<link rel="stylesheet" href="__CSS__/20180207/promition.css">
<link rel="stylesheet" href="__CSS__/20180207/game.css">
<link href="__STATIC__/ios9/css/common.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="__CSS__/landing_page.css">
</head>
<body class="main_bg" style="background-color: #0a0a0a;height: auto;">
<input type="hidden" name="title" value="{$game['relation_game_name']}">
<input type="hidden" name="icon" value="{$game['icon']}">
<input type="hidden" name="desc" value="{$game['features']}">
<input type="hidden" name="isIOS13" value="<?php if($isIOS13):?>1<?php else:?>0<?php endif;?>">
<?php if ($isWechat):?>
<?php if ($isAndroid):?>
<div class="bn-rule" style="display: none;"><img id="rule-img" src="__STATIC__/ios9/images/android-rule.png"></div>
<?php elseif ($isIOS):?>
<div class="bn-rule" style="display: none;"><img id="rule-img" src="__STATIC__/ios9/images/ios-rule.png"></div>
<?php endif;?>
<?php endif;?>
<div class="h_wrap">
<div id="data-2">
<volist name="game['flooring_page_imgs']" id="item">
<?php if ($downloadUrl == 'https://'.$_SERVER['HTTP_HOST']) :?>
<a href="#" class="no-package"><img src="{$item|get_cover='path'}" style="width: 100%;"/></a>
<?php else :?>
<a href="javascript:;" class="down-link" down-link="{$dowUrl}"><img src="{$vo|get_cover='path'}" style="width: 100%;"/></a>
<?php endif ;?>
</volist>
</div>
</div>
<script src="__STATIC__/layer/layer.js"></script>
<script src="__STATIC__/ios9/js/layer/layer.js?VerNo=20190923" type="text/javascript"></script>
<script type="text/javascript">
$('.down-link').on('click', function () {
if ($('.bn-rule').length > 0) {
$('.bn-rule').css('display','block')
$('.bn-rule').css('z-index','12')
return
}
if ($('input[name=isIOS13]').val() == 1) {
if (parseInt("{:I('get.status')}") > 0) {
location.href = "{:U('iosDown',array('gid'=>$gameId,'pid'=>I('get.pid'),'status'=>1))}"
return
} else {
layer.confirm('请先到官网注册', {title: '提示'}, function () {
location.href = "/mobile.php?s=/User/login/pid/" + "{:I('get.pid')}" + "/gid/" + "{:I('get.gid')}" + ".html"
})
return
}
}
var downLink = $(this).attr('down-link')
location.href = downLink
});
$('.no-package').click(function() {
layer.msg('暂无下载', {
icon: 7,
time: 2000
})
})
$.ajax({
url: "{:U('Home/generateWechatSign')}",
dataType: 'json',
type: 'post',
data: {url: window.location.href},
success: function(response) {
if (response.status) {
wx.config({
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来若要查看传入的参数可以在pc端打开参数信息会通过log打出仅在pc端时才会打印。
appId: response.data.appid,
timestamp: response.data.time,
nonceStr: response.data.randStr,
signature: response.data.sign,
jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone']
})
var title = $('[name=title]').val();
var description = $('[name=desc]').val();
var icon = $('[name=icon]').val();
wxReady(title, description, icon)
}
}
});
function wxReady(title, description, img) {
wx.ready(function () {
wx.onMenuShareAppMessage({
title: title,
desc: description,
link: window.location.href,
imgUrl: img,
type: '',
dataUrl: ''
});
wx.onMenuShareTimeline({
title: title,
link: window.location.href,
imgUrl: img
});
wx.onMenuShareQQ({
title: title,
desc: description,
link: window.location.href,
imgUrl: img
});
wx.onMenuShareWeibo({
title: title,
desc: description,
link: window.location.href,
imgUrl: img
});
wx.onMenuShareQZone({
title: title,
desc: description,
link: window.location.href,
imgUrl: img
});
});
}
</script>
</body>
</html>

@ -0,0 +1,102 @@
.weixin {
position: absolute;
top: -80px;
right: 0;
width: 17rem;
height: 30rem;
margin-top: 2px;
background: url(../images/img_sign.png) left top no-repeat;
background-size: 100% 100%;
z-index: 99;
}
html {
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
body, div {
margin: 0;
padding: 0;
}
.bn-rule {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #333;
}
.bn-rule img {
margin-top: 21px;
width: 100%;
}
.register-box-max {
width: 80%;
height: 280px;
top: calc(50% - 140px);
left: 10%;
position: fixed;
z-index: 10;
background-color: #fff;
border-radius: 10px;
}
@media screen and (min-width: 768px) {
.register-box-max {
width: 50%;
left: 25%;
}
}
.register-bg {
width: 100%;
height: inherit;
position: fixed;
background-color: #0a0a0a;
opacity: 0.5;
}
.register-title-box {
padding: 10px 10px;
margin-top: 10px;
text-align: center;
font-size: 1.2rem;
}
.register-title-box span {
font-weight: 600;
}
.register-input-box {
text-align: center;
font-size: 1rem;
}
.register-input-box input {
width: calc(80% - 5px);
height: 2rem;
padding-left: 5px;
margin-top: 10px;
margin-bottom: 10px;
border: 1px solid #6f6f6f;
border-radius: 3px;
}
.register-btn-box {
margin-top: 40px;
text-align: center;
}
.register-btn-box button {
width: 80%;
height: 2.5rem;
border: 0;
border-radius: 18px;
background-color: #1993ff;
color: #fff;
font-size: 1.1rem;
}
Loading…
Cancel
Save