You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
8.6 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?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>
// +----------------------------------------------------------------------
/**
* 前台公共库文件
* 主要定义前台公共函数库
*/
/*
* 获取礼包设备类别
* lwx
*/
function get_site_gift_version($id,$gift,$server,$game,$pid) {
if (!is_numeric($id) || $id <=0 || !is_numeric($pid) || $pid <=0) {return 0;}
$map['tab_site_gift.gift_name']=$gift;
$map['tab_site_gift.server_name']=$server;
$map['tab_site_game.game_name']=$game;
$map['tab_site_gift.promote_id']=$pid;
$map['tab_site_gift.id']=array('neq',$id);
$data = M('site_gift','tab_')->field('tab_site_gift.giftbag_version')->join('tab_site_game on(tab_site_game.id=tab_site_gift.site_game_id)','inner')->where($map)->find();
return $data['giftbag_version'];
}
/*
* 获取礼包条数
* lwx
*/
function get_site_gift_count($serverid,$gameid,$pid) {
if (!is_numeric($serverid) || !is_numeric($gameid) || $serverid <=0 || $gameid<=0 || !is_numeric($pid) || $pid <=0) {return 0;}
$map['server_id']=$serverid;
$map['site_game_id']=$gameid;
$map['promote_id']=$pid;
$map['status'] = 1;
$map['novice'] = array("neq","");
$map['end_time'] = array("gt",time());
$gift = M('site_gift','tab_')->where($map)->field("id")->order("create_time desc")->find();
return $gift['id'];
}
/* 截取指定两个字符之间字符串 */
function get_between($input,$start,$end) {
$substr = substr($input,strlen($start)+strpos($input,$start),(strlen($input)-strpos($input,$end))*(-1));
return $substr;
}
/**
* 检测用户是否登录
* @return integer 0-未登录大于0-当前登录用户ID
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
function is_login_promote(){
$user = session('promote_auth');
if (empty($user)) {
return 0;
} else {
return session('promote_auth_sign') == data_auth_sign($user) ? $user['pid'] : 0;
}
}
function get_pay_sett($id){
switch ($id) {
case 0:
return "未提现";
break;
case 1:
return "已提现";
break;
}
}
/**
* 检测验证码
* @param integer $id 验证码ID
* @return boolean 检测结果
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
function check_verify($code, $id = 1){
$verify = new \Think\Verify();
return $verify->check($code, $id);
}
/**
* 获取列表总行数
* @param string $category 分类ID
* @param integer $status 数据状态
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
function get_list_count($category, $status = 1){
static $count;
if(!isset($count[$category])){
$count[$category] = D('Document')->listCount($category, $status);
}
return $count[$category];
}
/**
* 获取段落总数
* @param string $id 文档ID
* @return integer 段落总数
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
function get_part_count($id){
static $count;
if(!isset($count[$id])){
$count[$id] = D('Document')->partCount($id);
}
return $count[$id];
}
/**
* 获取导航URL
* @param string $url 导航URL
* @return string 解析或的url
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
function get_nav_url($url){
switch ($url) {
case 'http://' === substr($url, 0, 7):
case '#' === substr($url, 0, 1):
break;
default:
$url = U($url);
break;
}
return $url;
}
function get_apply_dow_url($game_id=0,$promote_id=0)
{
$model = M('Apply','tab_');
$map['game_id'] = $game_id;
$map['promote_id'] = $promote_id;
$data = $model->where($map)->find();
if(empty($data['dow_url'])){
$game_address = M('game','tab_')->where('id='.$game_id)->find();
if($game_address['sdk_version']==1){
if($game_address['add_game_address']!=''){
$game_address_url=$game_address['add_game_address'];
return $game_address_url;
}else{
$game_address_url=$game_address['and_dow_address'];
return 'http://'.$_SERVER['HTTP_HOST'].substr($game_address_url,1);
}
}else{
if($game_address['ios_game_address']!=''){
$game_address_url=$game_address['ios_game_address'];
return $game_address_url;
}else{
$game_address_url=$game_address['ios_dow_address'];
return 'http://'.$_SERVER['HTTP_HOST'].substr($game_address_url,1);
}
}
}
return 'http://'.$_SERVER['HTTP_HOST'].$data['dow_url'];
}
function get_promote_list_by_id(){
$map['parent_id']=get_pid();
$pro=M("promote","tab_")->where($map)->select();
return $pro;
}
function index_show($param=array()){
$paramcount=count($param);
if($paramcount>0){
$paramm[0][]=$param[0];
$paramm[0][]=$param[1];
$paramm[0][]=$param[2];
}
if($paramcount-3>0){
$paramm[1][]=$param[3];
$paramm[1][]=$param[4];
$paramm[1][]=$param[5];
}
foreach ($paramm as $key => $value) {
foreach ($value as $k => $v) {
if($v==''){
unset($paramm[$key][$k]);
}
}
}
return $paramm;
}
//获取礼包激活码数量
function get_site_gift_num($id){
$data = M('site_gift','tab_')->find($id);
$novice = explode(',',$data['novice']);
$count = count($novice);
if(empty(array_pop($novice)) && $count > 0){
$count--;
}
if(empty($novice[0])){
$count--;
}
return $count;
}
//获取游戏类型
function get_game_type($id){
$game_type = D('SiteGame')->field('game_type')->find($id);
return $game_type['game_type'];
}
//获取游戏名称
function get_site_game_name($id){
$game_type = D('SiteGame')->field('game_name')->find($id);
return $game_type['game_name'];
}
//获取游戏图标
function get_site_game_icon($id){
$data = D('SiteGame')->field('game_icon')->find($id);
$icon_url = get_cover($data['game_icon'],'path');
return $icon_url;
}
//获取游戏ID
function get_game_id($game_name){
$map['game_name'] = $game_name;
$map['promote_id'] = PID;
$game_type = M('Game')->field('id')->where($map)->find();
return $game_type['id'];
}
function get_game_icon(){
$data = $game_type = M('Game')->field('icon')->find($id);
return $data['icon'];
}
function get_site_game_id($game_name){
$map['game_name'] = $game_name;
$map['promote_id'] = PID;
$game_type = D('SiteGame')->field('id')->where($map)->find();
return $game_type['id'];
}
/**
* 判断手机访问型号
* @return string
*/
function get_device_type()
{
//全部变成小写字母
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
$type = 'other';
//分别进行判断
if (strpos($agent, 'iphone') || strpos($agent, 'ipad')) {
$type = 'ios';
}
if (strpos($agent, 'android')) {
$type = 'android';
}
return $type;
}
//获取支付方式
function get_pay_way($id=null)
{
if(!isset($id)){
return false;
}
switch ($id) {
case -1:
return "绑币";
break;
case 0:
return "平台币";
break;
case 1:
return "支付宝";
break;
case 2:
case 3:
case 4:
return "微信";
break;
case 5:
return "聚宝云";
break;
case 6:
return "竣付通";
break;
case 7:
return "苹果支付";
break;
}
}
/**
* [获取游戏版本]
* @param [type] $id [description]
* @return [type] [description]
*/
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];
}
/**
* 获取游戏信息
* @return [type] [description]
*/
function get_game_info($id=0){
$map["id"] =$id;
$data = M('Game','tab_')->where($map)->find();
return $data;
}