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.
140 lines
6.2 KiB
PHP
140 lines
6.2 KiB
PHP
<?php
|
|
namespace Mobile\Controller;
|
|
use Think\Controller;
|
|
|
|
/**
|
|
* 首页
|
|
*/
|
|
class OpenController extends BaseController {
|
|
|
|
/**
|
|
* 开服
|
|
*/
|
|
public function index() {
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
$row = C('LIST_ROWS');
|
|
$devices = get_devices_type();
|
|
|
|
$open = I('get.open') ? I('get.open') : 1;
|
|
|
|
$time = time();
|
|
if($open==1){
|
|
$where['start_time'] = ['egt',$time];
|
|
$order = 'start_time';
|
|
}else{
|
|
$where['start_time'] = ['lt',$time];
|
|
$order = 'start_time desc';
|
|
}
|
|
|
|
$where['show_status'] = 1;
|
|
$where['g.sdk_version'] = array('like','%'.$devices.'%');
|
|
$lists = D("Server")
|
|
->alias('ser')
|
|
->field('server_name,start_time,ser.game_name,sor.pack_name,ser.game_id,sor.file_url,g.sdk_version,g.down_port,g.and_dow_address,g.dow_status,g.ios_dow_address,g.add_game_address,g.ios_game_address,g.relation_game_name')
|
|
->join('tab_game g on g.id = ser.game_id and g.game_status = 1 and g.display_site like "%'.DISPLAY_SITE.'%" ')
|
|
->join("left join tab_game_source as sor on sor.game_id = ser.game_id")
|
|
->where($where)
|
|
->order($order)
|
|
->page($page, $row)
|
|
->select();
|
|
foreach ($lists as $key => $value) {
|
|
if($value['dow_status']!=1){
|
|
$lists[$key]['status'] = 0;
|
|
}elseif($value["down_port"] == 1 && $value["sdk_version"] == 1 && empty($value["and_dow_address"]) || $value["down_port"] == 1 && $value["sdk_version"] == 2 && empty($value["ios_dow_address"]) || $value["down_port"] == 2 && $value["sdk_version"] == 1 && empty($value["add_game_address"]) || $value["down_port"] == 2 && $value["sdk_version"] == 2 && empty($value["ios_game_address"])){
|
|
$lists[$key]['status'] = 0;
|
|
}else{
|
|
if($value["down_port"] == 1){
|
|
if($value["sdk_version"] == 2){
|
|
$lists[$key]['down_url'] = $value["ios_dow_address"];
|
|
}else{
|
|
$lists[$key]['down_url'] = U('AjaxDown/down_file',['game_id'=>$value['game_id'],'sdk_version'=>$value['sdk_version']]);
|
|
}
|
|
}else{
|
|
if($value["sdk_version"] == 2){
|
|
$lists[$key]['down_url'] = $value["ios_game_address"];
|
|
}else{
|
|
$lists[$key]['down_url'] = U('AjaxDown/down_file',['game_id'=>$value['game_id'],'sdk_version'=>$value['sdk_version']]);
|
|
}
|
|
}
|
|
|
|
$lists[$key]['status'] = 1;
|
|
}
|
|
$lists[$key]['time'] = date('H:i',$value['start_time']);
|
|
$lists[$key]['date'] = date('Y-m-d',$value['start_time']);
|
|
if(!is_mobile_request()){
|
|
$lists[$key]['relation_game_name'] = $value['game_name'];
|
|
}
|
|
}
|
|
$this->assign('lists',$lists);
|
|
$this->assign('page',$page);
|
|
$this->assign('open',$open);
|
|
$this->assign('devices',$devices);
|
|
$this->assign('mate_title','开服列表');
|
|
$this->display();
|
|
}
|
|
|
|
public function ajaxopen() {
|
|
$p = I('post.p');
|
|
$devices = get_devices_type();
|
|
$open = I('get.open') ? I('get.open') : 1;
|
|
$status = 0;
|
|
$row = C('LIST_ROWS'); // C('LIST_ROWS')
|
|
$time = time();
|
|
if($open==1){
|
|
$where['start_time'] = ['egt',$time];
|
|
}else{
|
|
$where['start_time'] = ['lt',$time];
|
|
}
|
|
|
|
$where['show_status'] = 1;
|
|
$where['g.sdk_version'] = array('like','%'.$devices.'%');
|
|
$lists = D("Server")
|
|
->alias('ser')
|
|
->field('server_name,start_time,ser.game_name,sor.pack_name,ser.game_id,sor.file_url,g.sdk_version,g.down_port,g.and_dow_address,g.dow_status,g.ios_dow_address,g.add_game_address,g.ios_game_address')
|
|
->join('tab_game g on g.id = ser.game_id and g.game_status = 1 and g.display_site "%'.DISPLAY_SITE.'%" ')
|
|
->join("left join tab_game_source as sor on sor.game_id = ser.game_id")
|
|
->where($where)
|
|
->order("start_time")
|
|
->page($p, $row)
|
|
->select();
|
|
foreach ($lists as $key => $value) {
|
|
if($value['dow_status']!=1){
|
|
$lists[$key]['status'] = 0;
|
|
}elseif($value["down_port"] == 1 && $value["sdk_version"] == 1 && empty($value["and_dow_address"]) || $value["down_port"] == 1 && $value["sdk_version"] == 2 && empty($value["ios_dow_address"]) || $value["down_port"] == 2 && $value["sdk_version"] == 1 && empty($value["add_game_address"]) || $value["down_port"] == 2 && $value["sdk_version"] == 2 && empty($value["ios_game_address"])){
|
|
$lists[$key]['status'] = 0;
|
|
}else{
|
|
$lists[$key]['status'] = 1;
|
|
if($value["down_port"] == 1){
|
|
if($value["sdk_version"] == 2){
|
|
$lists[$key]['down_url'] = $value["ios_dow_address"];
|
|
}else{
|
|
$lists[$key]['down_url'] = U('AjaxDown/down_file',['game_id'=>$value['game_id'],'sdk_version'=>$value['sdk_version']]);
|
|
}
|
|
}else{
|
|
if($value["sdk_version"] == 2){
|
|
$lists[$key]['down_url'] = $value["ios_game_address"];
|
|
}else{
|
|
$lists[$key]['down_url'] = U('AjaxDown/down_file',['game_id'=>$value['game_id'],'sdk_version'=>$value['sdk_version']]);
|
|
}
|
|
}
|
|
}
|
|
if(!is_mobile_request()) {
|
|
$lists[$key]['game_name'] = substr_game_name($value['game_name']);
|
|
} else {
|
|
$lists[$key]['game_name'] = str_replace(array('(安卓版)','(苹果版)'),'',$value['game_name']);
|
|
}
|
|
$lists[$key]['time'] = date('H:i',$value['start_time']);
|
|
$lists[$key]['date'] = date('Y-m-d',$value['start_time']);
|
|
if(!is_mobile_request()){
|
|
$lists[$key]['relation_game_name'] = $value['game_name'];
|
|
}
|
|
}
|
|
|
|
if (!empty($lists) && is_array($lists)) { $status=1;}
|
|
|
|
echo json_encode(array('status'=>$status,'page'=>$p,'lists'=>$lists));
|
|
|
|
}
|
|
|
|
|
|
} |