|
|
<?php
|
|
|
// +----------------------------------------------------------------------
|
|
|
// | 徐州梦创信息科技有限公司—专业的游戏运营,推广解决方案.
|
|
|
// +----------------------------------------------------------------------
|
|
|
// | Copyright (c) 2013 http://www.vlcms.com All rights reserved.
|
|
|
// +----------------------------------------------------------------------
|
|
|
// | Author: kefu@vlcms.com QQ:97471547
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
/**
|
|
|
* [获取游戏版本]
|
|
|
* @param [type] $id [description]
|
|
|
* @return [type] [description]
|
|
|
*/
|
|
|
|
|
|
function is_weixin_brower() {
|
|
|
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
function is_in_qq_brower() {
|
|
|
if (strpos($_SERVER['HTTP_USER_AGENT'], 'QQ/') !== false) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
function game_version($id){
|
|
|
$game=M('game','tab_');
|
|
|
$map['id']=$id;
|
|
|
$data=$game->field('sdk_version')->where($map)->find();
|
|
|
if($data['id']==null){
|
|
|
return false;
|
|
|
}
|
|
|
return $data['version'];
|
|
|
}
|
|
|
// 获取IOS游戏名称
|
|
|
function get_ios_game_name($game_id=null,$field='id'){
|
|
|
$map[$field]=$game_id;
|
|
|
$map['game_version']=0;
|
|
|
$data=M('Game','tab_')->where($map)->find();
|
|
|
if(empty($data)){return false;}
|
|
|
$game_name=explode("(", $data['game_name']);
|
|
|
return $game_name[0];
|
|
|
}
|
|
|
|
|
|
function think_md5($str, $key = 'ThinkUCenter'){
|
|
|
return '' === $str ? '' : md5($str.$key);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*获取游戏设置信息
|
|
|
*/
|
|
|
function get_game_set_info($game_id = 0){
|
|
|
$game = M('GameSet','tab_');
|
|
|
$map['game_id'] = $game_id;
|
|
|
$data = $game->where($map)->find();
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* [通过游戏appid获取游戏信息]
|
|
|
* @param $game_appid
|
|
|
* @return mixed
|
|
|
*/
|
|
|
function get_game_entity($game_appid){
|
|
|
$model = M('game','tab_');
|
|
|
$map['game_appid'] = $game_appid;
|
|
|
$data = $model->where($map)->find();
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* [通过游戏appid获取游戏ID]
|
|
|
* @param $game_appid
|
|
|
* @return mixed
|
|
|
*/
|
|
|
function sdk_game_entity($game_appid){
|
|
|
$model = M('game','tab_');
|
|
|
$map['game_appid'] = $game_appid;
|
|
|
$data = $model->where($map)->find();
|
|
|
return $data['id'];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*根据推广员id获取推广员名称
|
|
|
*/
|
|
|
function get_promote_ParentID($promote_id){
|
|
|
$model = M("Promote",'tab_');
|
|
|
$map["id"] = $promote_id;
|
|
|
$reg = $model->where($map)->find();
|
|
|
return $reg["parent_id"];
|
|
|
}
|
|
|
|
|
|
|
|
|
//通过手机号获取用户id
|
|
|
function get_user_id_phone($phone)
|
|
|
{
|
|
|
$map['phone']=$phone;
|
|
|
$user=M("user","tab_")->where($map)->find();
|
|
|
if($user){
|
|
|
return $user['id'];
|
|
|
}else{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//根据id获取游戏原包路径
|
|
|
function get_source_path($game_id){
|
|
|
$model = M('gamesource');
|
|
|
$map['game_id'] = $game_id;
|
|
|
$res = $model->where($map)->find();
|
|
|
return $res['path'];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* [获取开放类型名称]
|
|
|
* @param $id
|
|
|
* @return mixed
|
|
|
*/
|
|
|
function get_cname($id)
|
|
|
{
|
|
|
$model = M('opentype','tab_');
|
|
|
$map['id'] = $id;
|
|
|
$res = $model->where($map)->find();
|
|
|
return $res['open_name'];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* [检查订单是否存在]
|
|
|
* @param $order_number
|
|
|
* @param $pay_order_number
|
|
|
* @return bool
|
|
|
*/
|
|
|
function check_order($order_number,$pay_order_number){
|
|
|
if(empty($order_number)||empty($pay_order_number)){
|
|
|
return false;
|
|
|
}
|
|
|
$map['order_number']=$order_number;
|
|
|
$map['pay_order_number']=$pay_order_number;
|
|
|
$pri=M("deposit","tab_")->where($map)->find();
|
|
|
if($pri){
|
|
|
return false;
|
|
|
}else{
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
function get_img_url($cover_id){
|
|
|
if(empty($cover_id)){
|
|
|
return "";
|
|
|
}
|
|
|
$picture = M('Picture')->where(array('status'=>1))->getById($cover_id);
|
|
|
if (get_tool_status("oss_storage") == 1) {
|
|
|
if(!empty($picture['oss_url'])){
|
|
|
return $picture['oss_url'];
|
|
|
}else{
|
|
|
return 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__.$picture['path'];
|
|
|
}
|
|
|
}elseif(get_tool_status("qiniu_storage") == 1){
|
|
|
if(!empty($picture['url'])){
|
|
|
return $picture['url'];
|
|
|
}else{
|
|
|
return 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__.$picture['path'];
|
|
|
}
|
|
|
}elseif(get_tool_status("cos_storage") == 1){
|
|
|
if(!empty($picture['url'])){
|
|
|
return $picture['url'];
|
|
|
}else{
|
|
|
return 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__.$picture['path'];
|
|
|
}
|
|
|
|
|
|
}elseif(get_tool_status("bos_storage") == 1){
|
|
|
if(!empty($picture['bos_url'])){
|
|
|
return $picture['bos_url'];
|
|
|
}else{
|
|
|
return 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__.$picture['path'];
|
|
|
}
|
|
|
}else{
|
|
|
return 'http://' . $_SERVER['HTTP_HOST'] .__ROOT__.$picture['path'];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询该用户是否领取该礼包
|
|
|
* @param [type] $account [description]
|
|
|
* @param [type] $game_id [description]
|
|
|
* @param [type] $gift_id [description]
|
|
|
* @return [type] [description]
|
|
|
*/
|
|
|
function check_user_gift($account,$game_id,$gift_id){
|
|
|
$map['user_account']=$account;
|
|
|
$map['gift_id']=$gift_id;
|
|
|
$map['game_id']=$game_id;
|
|
|
$find=M('gift_record','tab_')->field('id')->where($map)->find();
|
|
|
if(null==$find){
|
|
|
return 1;
|
|
|
}else{
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 判断游戏原包/第三方链接是否可用
|
|
|
* @param [type] $game_id [description]
|
|
|
* @return [type] [description]
|
|
|
*/
|
|
|
function check_game_sorue($game_id){
|
|
|
$xia_status = 1;
|
|
|
$map['id']=$game_id;
|
|
|
$game=M('game','tab_')->field('down_port,sdk_version,and_dow_address,ios_dow_address,add_game_address,ios_game_address,dow_status')->where(['id'=>$game_id])->find();
|
|
|
if($game['dow_status'] == 0){
|
|
|
return 0;
|
|
|
}
|
|
|
if($game['down_port']==1){
|
|
|
if($game['sdk_version']==1){
|
|
|
if(empty($game['and_dow_address'])){
|
|
|
$xia_status=0;
|
|
|
}
|
|
|
}elseif($game['sdk_version']==2){
|
|
|
if(empty($game['ios_dow_address'])){
|
|
|
$xia_status=0;
|
|
|
}
|
|
|
}else{
|
|
|
if(empty($game['and_dow_address'])&& empty($game['ios_dow_address'])){
|
|
|
$xia_status=0;
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
if($game['sdk_version']==1){
|
|
|
if(empty($game['add_game_address'])){
|
|
|
$xia_status=0;
|
|
|
}
|
|
|
}elseif($game['sdk_version']==2){
|
|
|
if(empty($game['ios_game_address'])){
|
|
|
$xia_status=0;
|
|
|
}
|
|
|
}else{
|
|
|
if(empty($game['ios_game_address'])&&empty($game['add_game_address'])){
|
|
|
$xia_status=0;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return $xia_status;
|
|
|
|
|
|
} |