// +---------------------------------------------------------------------- namespace Home\Controller; use Think\Controller; /** * 前台公共控制器 * 为防止多分组Controller名称冲突,公共Controller名称统一使用分组名称 */ class HomeController extends Controller { /* 空操作,用于输出404页面 */ public function _empty() { $this->redirect('Index/index'); } protected function _initialize() { /* 读取站点配置 */ $config = api('Config/lists'); C($config); //添加配置 //var_dump($config); if (!C('WEB_SITE_CLOSE')) { $this->error('站点已经关闭,请稍后访问~'); } } public function rule() { $this->display(); } public function generateWechatSign() { $url = I('url', ''); $appid = 'wx0ba5be5c8bb9f1b7'; $secret = '0adcf03d6fd637c578db343c74ee931e'; $tokenUrl = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $appid . '&secret=' . $secret; $result = file_get_contents($tokenUrl); $result = json_decode($result, true); if (!$result || isset($result['errcode'])) { $this->ajaxReturn([ 'status' => false, 'msg' => '获取失败', ]); } $accessToken = $result['access_token']; $ticketUrl = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=' . $accessToken . '&type=jsapi'; $result = file_get_contents($ticketUrl); $result = json_decode($result, true); if (!$result || $result['errcode'] != 0) { $this->ajaxReturn([ 'status' => false, 'msg' => '获取失败', ]); } $ticket = $result['ticket']; $randStr = rand(100000, 999999); $time = time(); $signStr = 'jsapi_ticket=' . $ticket . '&noncestr=' . $randStr . '×tamp=' . $time . '&url=' . $url; $sign = sha1($signStr); $this->ajaxReturn([ 'status' => true, 'msg' => '获取成功', 'data' => [ 'sign' => $sign, 'randStr' => $randStr, 'time' => $time, 'appid' => $appid, ] ]); } public function promitionofregestion() { $map['tab_game.relation_game_id'] = $_GET['gid']; $map['ta.promote_id'] = $_GET['pid']; $data = M('game', 'tab_')->field('tab_game.id,tab_game.sdk_version,tab_game.icon,tab_game.screenshot,tab_game.relation_game_id,tab_game.relation_game_name,ta.enable_status,tab_game.dow_status,tab_game.features,tab_game.flooring_page_imgs')->where($map)->join('tab_apply ta ON ta.game_id = tab_game.id and ta.promote_id=' . $_GET['pid'])->select(); foreach ($data as $key => $value) { if (!empty($value['flooring_page_imgs'])) { $data[$key]['flooring_page_imgs'] = explode(',', $value['flooring_page_imgs']); } } $this->assign('data', $data); $this->display(); } public function iosDown() { $gameId = I('get.gid'); $promoteId = I('get.pid'); if (empty($gameId) || empty($promoteId)) { $this->error('链接丢失'); } $downLink = get_apply_dow_url($gameId, $promoteId); $this->assign('downLink', $downLink); $this->display(); } /* * 推广链接(含投放) * @author 鹿文学 */ public function promotionofregistration() { $map['relation_game_id'] = $_GET['gid']; $map['ta.promote_id'] = $_GET['pid']; $data = M('game', 'tab_') ->field('tab_game.id,tab_game.dow_icon,tab_game.back_map,tab_game.back_describe,tab_game.sdk_version,tab_game.dow_status,icon,screenshot,relation_game_id,relation_game_name,enable_status,ta.promote_id,ta.id as applyid,if(tab_game.sdk_version=1,ta.pack_url,ta.plist_url) as channel_url') ->where($map)->join('tab_apply ta ON ta.game_id=tab_game.id')->select(); if (empty($data)) { $res = M('game', 'tab_')->find($_GET['gid']); if ($res) { $data = M('game', 'tab_') ->field('tab_game.id,tab_game.sdk_version,tab_game.dow_status,icon,screenshot,relation_game_id,relation_game_name,enable_status,ta.promote_id,ta.id as applyid,if(tab_game.sdk_version=1,ta.pack_url,ta.plist_url) as channel_url') ->where(['relation_game_id' => $res['relation_game_id']])->join('tab_apply ta ON ta.game_id=tab_game.id')->select(); } } $platform_id = $_GET['lid']; $position = $_GET['p'] ? $_GET['p'] : 1; if ($platform_id && $platform_id > 0) { $launchmodel = M('apply_launch', 'tab_'); foreach ($data as $k => $v) { if ($v['applyid'] > 0) { $launch = $launchmodel->field('launch_down_url,launch_plist_url')->where(['apply_id' => $v['applyid'], 'platform_id' => $platform_id, 'position' => $position])->find(); if ($v['sdk_version'] == 1) { $data[$k]['launch'] = $launch['launch_down_url']; } else { $data[$k]['launch'] = $launch['launch_plist_url']; } } } $this->assign('platform_id', $platform_id); $this->assign('position', $position); $this->assign('is_launch', 1); } $this->assign('data', $data); $this->display(); } }