diff --git a/1 b/1 new file mode 100644 index 000000000..4fff486ce --- /dev/null +++ b/1 @@ -0,0 +1,81 @@ +111111101001100000110010111001110100011110010111101110111111100110101000001111111 +100000101101110101010010000011011000001010010110100011101011011000000111101000001 +101110101001101100000101011111100000101011111111110000000000000110001010101011101 +101110100011011110100101111010001110000000101111111111101000000001101010101011101 +101110100110010010000110111110101101000101101101111110100100000010010000001011101 +100000101010001101110100100010110100010011011110100010101110000001001001001000001 +111111101010101010101010101010101010101010101010101010101010101010101010101111111 +000000001010000100100001100011110100101001001010100010101001000110001111000000000 +001110101001010000010001111110001111111111110111111111101010101100000011011100111 +111101000000010101101110111000000001100010111011111010001100110110001110111001111 +100011100101100001101001100011001000001000101100000011000110100100000100000111010 +010001010010110101000011010011110101011111101110111110011010000110111100000100011 +110111100001111111000001101111011010111101100100100011000100111111101010110100111 +000101011000011000111111110101001110011101001000011100110101010100010000001001110 +101001101000011110011110101010110011000111001100100000001111011011010010111010000 +000011011101001000010001000000000111010110000101000100001011000001111110101001000 +101001100011101011011011000111000010010110000110101110001001111111010111000101000 +110001001110001100100101111100001001010100111000000000011110000100011110001111101 +000011101001100111111010011101111110111001100100000001000000001110000011111100010 +111011011100000110000101011110000011000100000010011100111110000010101100111101110 +100110110010000011111010101000000100000100100100110001100110111111100111000000110 +001110011011111100101011001001101001100001101000000100110111000100111100110010010 +100010110010000111000111111001111001111111101000111111001010001111001100100000110 +111111000101011011000011101011101100100101000010110000101000001001110101000001001 +011111111010111101010101111111101000011101100010111110100111110101001001111111100 +101110001011110010101001100010010010101000100100100010000111001100111100100010011 +001010101011110001010100101011001010101011011110101010010010011110000110101010110 +110010001001111100111101100010111001010111001000100010111110100011000010100011110 +000111111001010110010010111111010110001101111110111111000101111101000110111110111 +001101001101001110101000000100000110011011110110010110000111001011100100110100001 +000000111011101000000111101111000110010000010011010010001100111010000110000101110 +001100000100010010000011001011011100101000100101101110101111000001110011110111101 +100011111000110101000000010001110010001100111010111111100100011101000101000001110 +011101000011111110110111010110111010001110111001001000101111100000010100110000010 +000011111111110000100101111101110111100010000000010000001010111011111010000101110 +011000011100110111111000010100000111001010001110011110001100000110100011110111111 +101001101000001100000000011100001101110100011111011010101011101100101011111000110 +111011000101000101111111011111101010110001111010100000000001000010100101100111100 +011000110010111000011001111011011101100000000101100011011011101110000010111110010 +011000010111101110011010101011101111100111100011100110101101000110001011100101101 +010111110010110010110010100001011110001110101000100001101010001101101110011001010 +110011001100001110110001011011100101101100110111001110010101100111011101101010110 +101001110011011001111010010010111001100101011000001011111110111100001011001101110 +010011001010011111110011001000111000001101100000100111001110000110001110110100101 +000011101111000011101110111100000010001100011001000111100010000111101110010001001 +000110011111111110100101110011011011000111101011101000110010101111100100111100011 +100111110101101101010100110000111100000110111001001110000100101111010110001100000 +100111010001000000111101010011101100111100100101010101100101001000001101110001110 +100011111000010111101001111110011011100001111000111111010110000110001100111111001 +110110001101000000101100100010010000101111011110100011111100100000000111100010011 +100110101100111100000010101011011010010101110111101010001010011111010110101010100 +011110001100011000001010100010110101010001011110100011111010010101111011100011110 +100111111010111111001010111110100101010111001000111110010010100000001100111111010 +111000010110001000110101010101110000111011000001101000110100000010001100000000001 +001100110110001111100010010001010001110100011110001001101110111111111010101000110 +001000010101011010101100101001010001001011100111000011111111000010001100011001101 +101000111110011010110101111001000101000001100100100111110110110000001110100110001 +001001011101111100011110000001100001001100101011100101010101101000000100011000000 +001101100110101000101110000111011010101001000010001000000110001101010010000100011 +000111011100101110100111000110110110110000101110010011001001001110011011001000100 +101100110001001100101100010110000100111100111001100000100000000100000010100111000 +110111001110111100111010100001011101001011100010010100111100001100111001011001111 +011010111000101001110100101100011111001010001111011010000111100000000111110101011 +000100011101001011101000101111111101011110011000010111111001011010011100010100101 +111000111101110101110001000100101110000011011010110111000110011111001100110111010 +000010010110000010111011011001100111111000010100101000101100001010100100010000100 +011001101101110111111101001011001111110010001101101100110010111010011001100100110 +000110010101100111000001101011000011111100101001101011001110000101101111011001100 +100110110001011010001000010110110101001001111010001110110000010111101100100100010 +100010010110111111010101111110011000010001001000110100111100001100100110111010110 +011100101111111010000111110011101011010101111010000000111010000100001101111111010 +010001010011001111011111111111000101101111110000011011110111101010101101001011101 +011100100011110000101010111110101111000001001101111110000010011111000000111111010 +000000001001100101111100100011110101101011110001100011101100110110001010100010101 +111111100101011111011000101010100001111011101001101010001110111111001010101010010 +100000100011101011011100100010011111100011001111100010110011001001000110100011000 +101110101011111001001001111111110111011011000101111110000100011110010010111110001 +101110101000001010000011111011000011001001101111101000101111000110000100111001100 +101110101101010111111101000000011001110010001011000001001000001011100100100001000 +100000100110110011111111101011001101100110101010011011011110000111000111010111100 +111111100111010110110100111000000100011101111011110011001111101100101011100001010 \ No newline at end of file diff --git a/Application/Base/Facade/Request.class.php b/Application/Base/Facade/Request.class.php new file mode 100644 index 000000000..8ea6817dc --- /dev/null +++ b/Application/Base/Facade/Request.class.php @@ -0,0 +1,26 @@ + + */ +class Request { + + private static $instance; + + public static function getInstance() + { + if (self::$instance == null) { + self::$instance = new BaseRequest(); + } + return self::$instance; + } + + public static function __callStatic($name, $arguments) + { + $instance = self::getInstance(); + return call_user_func_array([$instance, $name], $arguments); + } +} \ No newline at end of file diff --git a/Application/Base/Service/ApplyService.class.php b/Application/Base/Service/ApplyService.class.php index e41bfda6f..a9ea455d5 100644 --- a/Application/Base/Service/ApplyService.class.php +++ b/Application/Base/Service/ApplyService.class.php @@ -3,15 +3,51 @@ namespace Base\Service; use Base\Model\PromoteModel; use Base\Model\ApplyModel; -use Base\Tool\Request; +use Base\Facade\Request; class ApplyService { - private $model; + const ENCRYPT_METHOD = 'AES-256-ECB'; + const ENCRYPT_KEY = 'WmtX1@#Landing&Download2048'; + const ENCRYPT_TYPE_DOWNLOAD = 1; + const ENCRYPT_TYPE_LANDING_PAGE = 2; + + public static $enableStatusList = [ + '-1' => '打包失败', + '0' => '打包失败', + '1' => '打包成功 ', + '2' => '准备打包 ', + '3' => '打包中', + ]; public function __construct() { - $this->model = new ApplyModel(); + } + + public function checkApplyStatus($apply) + { + if ($apply['status'] == 0) { + return [ + 'status' => false, + 'message' => '游戏未审核', + ]; + } + if ($apply['offline_status'] == 1) { + return [ + 'status' => false, + 'message' => '游戏已下架', + ]; + } + if ($apply['enable_status'] != 1) { + return [ + 'status' => false, + 'message' => self::$enableStatusList[$apply['enable_status']] ?? '未知错误', + ]; + } + return [ + 'status' => true, + 'message' => '游戏打包成功', + ]; } public function cancelGame($gameId, $promoteId) { @@ -24,28 +60,70 @@ class ApplyService { M('apply', 'tab_')->where(['game_id' => $gameId, 'promote_id' => ['in', $ids]])->save($save); } - public function getDownloadUrl($apply, $game = null) + public function getDownloadUrl($apply) + { + $host = Request::getHost(); + $code = $this->encodeApplyCode($apply, self::ENCRYPT_TYPE_DOWNLOAD); + return $host . '/index.php?s=/Home/Download/index/code/' . $code; + } + + public function getLandingPageUrl($apply) { $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); - } - } + $code = $this->encodeApplyCode($apply, self::ENCRYPT_TYPE_LANDING_PAGE); + return $host . '/index.php?s=/Home/Home/landingPage/code/' . $code; + } + + public function encodeApplyCode($apply, $type) + { + $expiresIn = 0; + $data = [ + 'promote_id' => $apply['promote_id'], + 'game_id' => $apply['game_id'], + 'expires_in' => $expiresIn, + 'created_at' => date('Y-m-d H:i:s'), + 'type' => $type + ]; + + $jsonStr = json_encode($data); + return base64_encode(openssl_encrypt($jsonStr, self::ENCRYPT_METHOD, self::ENCRYPT_KEY)); + } + + public function decodeApplyCode($code) + { + $decryptStr = openssl_decrypt(base64_decode($code), self::ENCRYPT_METHOD, self::ENCRYPT_KEY); + return json_decode($decryptStr, true); + } + + public function checkApplyCode($data, $type) + { + if ( + !isset($data['promote_id']) || + !isset($data['game_id']) || + !isset($data['expires_in']) || + !isset($data['created_at']) || + !isset($data['type']) + ) { + return [ + 'status' => false, + 'message' => '参数异常', + ]; + } + if ($data['type'] != $type) { + return [ + 'status' => false, + 'message' => '参数异常', + ]; + } + if ($data['expires_in'] > 0 && time() > (strtotime($data['created_at']) + $data['expires_in'])) { + return [ + 'status' => false, + 'message' => '链接已过期', + ]; } - return $host . $apply['dow_url']; + return [ + 'status' => true, + 'message' => '验证成功', + ]; } } \ No newline at end of file diff --git a/Application/Base/Tool/Request.class.php b/Application/Base/Tool/Request.class.php index 1176fe064..68b4f0ffe 100644 --- a/Application/Base/Tool/Request.class.php +++ b/Application/Base/Tool/Request.class.php @@ -5,25 +5,15 @@ namespace Base\Tool; * @author elf<360197197@qq.com> */ class Request { - - private static $instance; private $serverInfo; private $scheme; - private function __construct() + public 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(); @@ -129,10 +119,4 @@ class Request { } return $this->scheme; } - - public static function __callStatic($name, $arguments) - { - $instance = self::getInstance(); - return call_user_func_array([$instance, $name], $arguments); - } } \ No newline at end of file diff --git a/Application/Home/Controller/ApplyController.class.php b/Application/Home/Controller/ApplyController.class.php index 9a03ac1e0..9a597e5d7 100644 --- a/Application/Home/Controller/ApplyController.class.php +++ b/Application/Home/Controller/ApplyController.class.php @@ -5,6 +5,8 @@ namespace Home\Controller; use OT\DataDictionary; use Admin\Model\ApplyModel; use Think\Model; +use Base\Facade\Request; +use Base\Service\ApplyService; /** @@ -633,9 +635,7 @@ class ApplyController extends BaseController if ($_REQUEST['pattern'] != null) { $map['tab_apply.pattern'] = $_REQUEST['pattern']; } -// $map['tab_apply.status'] = 1; -// $map['tab_game.game_status'] = 1;//游戏状态 -// empty(I('sdk_version')) || $map['tab_game.sdk_version'] = I('sdk_version'); + $page = intval(I('get.p', 0)); $page = $page ? $page : 1; //默认显示第一页数据 @@ -1750,7 +1750,80 @@ class ApplyController extends BaseController $this->ajaxReturn($result); } + } + + public function getDownloadUrl() + { + $gameId = I('game_id', 0); + $promote = $this->getLoginPromote(); + $apply = M('apply', 'tab_')->where(['promote_id' => $promote['id'], 'game_id' => $gameId])->find(); + $game = M('game', 'tab_')->field(['icon'])->where(['game_id' => $gameId])->find(); + if ($apply == null) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => '游戏不存在', + 'data' => [ + ] + ]); + } + + $icon = Request::getHost() . '/' . get_cover($game['icon'], 'path'); + + $applyService = new ApplyService(); + $result = $applyService->checkApplyStatus($apply); + if (!$result['status']) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => $result['message'], + 'data' => [ + ] + ]); + } + $url = $applyService->getDownloadUrl($apply); + $this->ajaxReturn([ + 'status' => 1, + 'message' => '获取成功', + 'data' => [ + 'url' => $url, + ] + ]); + } + + public function getLandingPageUrl() + { + $gameId = I('game_id', 0); + $promote = $this->getLoginPromote(); + $apply = M('apply', 'tab_')->where(['promote_id' => $promote['id'], 'game_id' => $gameId])->find(); + $game = M('game', 'tab_')->field(['icon'])->where(['game_id' => $gameId])->find(); + if ($apply == null) { + $this->ajaxReturn([ + 'status' => 1, + 'message' => '游戏不存在', + 'data' => [ + ] + ]); + } + $icon = Request::getHost() . '/' . get_cover($game['icon'], 'path'); + + $applyService = new ApplyService(); + $result = $applyService->checkApplyStatus($apply); + if (!$result['status']) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => $result['message'], + 'data' => [ + ] + ]); + } + $url = $applyService->getLandingPageUrl($apply); + $this->ajaxReturn([ + 'status' => 1, + 'message' => '获取成功', + 'data' => [ + 'url' => $url, + ] + ]); } } diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index 30a46f3ea..74d178baa 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -2,327 +2,82 @@ namespace Home\Controller; use Think\Controller; -use App\Model\GameModel; +use Base\Facade\Request; +use Base\Service\ApplyService; /** * @author elf<360197197@qq.com> */ class DownloadController extends Controller { - public function down_error($message='') + public function downloadError($message) { - $this->assign("message",$message); - $this->display(); + $this->assign('message', $message); + $this->display('error'); } - 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 ""; - }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 ""; - }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浏览器下载")); + public function index() + { + $code = I('code', ''); + if ($code == '') { + $this->redirect("download/downloadError", ['message' => '访问错误']); } - switch ($apply['sdk_version']) { - case 1: - if(!empty($pack_url)){ - if(preg_match("/oss/", $pack_url)){ - $url=str_replace('-internal', '', $pack_url); - echo ""; - }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 ""; - }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; + $applyService = new ApplyService(); + $data = $applyService->decodeApplyCode($code); + $result = $applyService->checkApplyCode($data, ApplyService::ENCRYPT_TYPE_DOWNLOAD); + if (!$result['status']) { + $this->error($result['message']); } + + $gameId = $data['game_id']; + $promoteId = $data['promote_id']; + $map = []; + $map['status'] = 1; + $map['enable_status'] = 1; + $columns = ['game_id', 'promote_id', 'promote_account', 'pack_url', 'plist_url', 'status', 'enable_status']; + $apply = M('apply','tab_')->field($columns)->where($map)->find(); + $game = M('game','tab_')->field(['id', 'game_name', 'sdk_version'])->where(['id' => $apply['game_id']])->find(); - - - } 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']); + if (Request::isMobile()) { + if (!Request::isAndroid() && $game['sdk_version'] == 1) { + $this->redirect("download/downloadError", ['message' => '请使用安卓浏览器下载']); } - 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); + if (!Request::isIOS() && $game['sdk_version'] == 2) { + $this->redirect("download/downloadError", ['message' => '请使用ios浏览器下载']); } - }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('下载地址错误'); + $packageUrl = $game['sdk_version'] == 1 ? $apply['pack_url'] : $apply['plist_url']; + + M('game','tab_')->where(['id' => $game['id']])->setInc('dow_num'); + if (Request::isAndroid()) { + $this->gotoPkgUrl($packageUrl); + } else if (Request::isIOS()) { + $plistUrl = substr($packageUrl, 1, strlen($packageUrl)); + header("HTTP/1.1 303 See Other"); + header("Location: "."itms-services://?action=download-manifest&url=" . "https://" . Request::getHost() . "/" . $plistUrl); + } else { + $this->gotoPkgUrl($packageUrl); } - } - /** - * 安卓打包渠道信息 - * @param $source_info 原包信息 - * @param $promote_id - * @return string - * author: xmy 280564871@qq.com - */ - public function package($source_info, $promote_id) + private function gotoPkgUrl($packageUrl) { - $file_path = $source_info['file_url']; - //验证原包是否存在 - if (!varify_url($file_path)) { - $this->error("未上传原包"); + if (preg_match("/oss/", $packageUrl)) { + $url = str_replace('-internal', '', $packageUrl); + echo ""; + } elseif (preg_match("/clouddn/", $packageUrl)) { + $url = "http://".$packageUrl; + redirect($url); + } elseif (preg_match("/myqcloud/", $packageUrl)) { + redirect($packageUrl); + } elseif(preg_match("/bcebos/", $packageUrl)) { + redirect($packageUrl); } 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']; - } + if (!file_exists($packageUrl)) { + $this->error('文件不存在哦,亲!'); }else{ - $this->error('游戏版本错误'); + redirect(Request::getHost() . ltrim($packageUrl, '.')); } } } diff --git a/Application/Home/Controller/HomeController.class.php b/Application/Home/Controller/HomeController.class.php index 53696a362..4a5e0f735 100644 --- a/Application/Home/Controller/HomeController.class.php +++ b/Application/Home/Controller/HomeController.class.php @@ -3,7 +3,8 @@ namespace Home\Controller; use Think\Controller; use User\Api\MemberApi; -use Base\Tool\Request; +use Base\Facade\Request; +use Base\Service\ApplyService; /** * 前台公共控制器 @@ -130,7 +131,15 @@ class HomeController extends Controller public function landingPage() { $code = I('code', ''); - $data = []; + if ($code == '') { + $this->redirect("download/downloadError", ['message' => '访问错误']); + } + $applyService = new ApplyService(); + $data = $applyService->decodeApplyCode($code); + $result = $applyService->checkApplyCode($data, ApplyService::ENCRYPT_TYPE_LANDING_PAGE); + if (!$result['status']) { + $this->error($result['message']); + } $isWechat = Request::isWechat(); $isIOS = Request::isIOS(); @@ -160,12 +169,17 @@ class HomeController extends Controller $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']); + $apply = M('apply', 'tab_')->field(['game_id', 'enable_status', 'promote_id']) + ->where(['promote_id' => $data['promote_id'], 'game_id' => $game['id']]) + ->find(); $game['icon'] = get_cover($game['icon'], 'path'); + + $imageIds = explode(',', $game['flooring_page_imgs']) ?? []; + $imageUrls = []; + foreach ($imageIds as $imageId) { + $imageUrls[] = get_cover($imageId, 'path'); + } + $game['flooring_page_imgs'] = $imageUrls; $downloadUrl = ''; if ($isIOS13) { @@ -173,7 +187,7 @@ class HomeController extends Controller $downloadUrl = 'itms-services://?action=download-manifest&url=' . Request::getHost() . ltrim($gameSource['org_plist_url'], '.'); } else { $applyService = new ApplyService(); - $downloadUrl = $applyService->getDownloadUrl($apply, $game); + $downloadUrl = $applyService->getDownloadUrl($apply); } $this->assign('downloadUrl', $downloadUrl); diff --git a/Application/Home/View/default/Apply/my_game.html b/Application/Home/View/default/Apply/my_game.html index 599867866..30ffdf05b 100644 --- a/Application/Home/View/default/Apply/my_game.html +++ b/Application/Home/View/default/Apply/my_game.html @@ -3,89 +3,10 @@ + - - - @@ -104,15 +25,7 @@ IOS游戏 Android游戏 我的游戏 - -
@@ -151,13 +64,6 @@
- - - - - - -
@@ -236,20 +142,6 @@ 游戏类型:{$vo.game_type_name}  

- -
@@ -257,10 +149,8 @@ 添加推广员游戏 - - 复制下载链接 - $vo['id'],'pid'=>$vo['promote_id']));?> - 落地页链接 + 复制下载链接 + 落地页链接 下架
@@ -347,16 +237,11 @@
- + +
- - - - - -
复制成功,ctrl+v粘贴即可 @@ -364,8 +249,8 @@
-
- +
@@ -426,68 +311,16 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- + +