|
|
|
@ -3419,80 +3419,127 @@ if ($key == 'model'){
|
|
|
|
|
* 登录记录
|
|
|
|
|
* @author 鹿文学
|
|
|
|
|
*/
|
|
|
|
|
public function login_record() {
|
|
|
|
|
public function login_record() {
|
|
|
|
|
|
|
|
|
|
$xlsName = $_REQUEST['xlsname'];
|
|
|
|
|
$xlsName = $_REQUEST['xlsname'];
|
|
|
|
|
|
|
|
|
|
$xlsCell = array(
|
|
|
|
|
array('user_account','玩家账号'),
|
|
|
|
|
array('game_name','游戏名称'),
|
|
|
|
|
array('server_name','游戏区服'),
|
|
|
|
|
array('user_nickname','角色名'),
|
|
|
|
|
array('login_time','登录时间'),
|
|
|
|
|
array('login_ip','最后登录ip'),
|
|
|
|
|
);
|
|
|
|
|
// $xlsCell = array(
|
|
|
|
|
// array('user_account','玩家账号'),
|
|
|
|
|
// array('game_name','游戏名称'),
|
|
|
|
|
// array('server_name','游戏区服'),
|
|
|
|
|
// array('user_nickname','角色名'),
|
|
|
|
|
// array('login_time','登录时间'),
|
|
|
|
|
// array('login_ip','最后登录ip'),
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
$xlsCell = array(
|
|
|
|
|
'玩家账号',
|
|
|
|
|
'游戏名称',
|
|
|
|
|
'游戏区服',
|
|
|
|
|
'角色名',
|
|
|
|
|
'登录时间',
|
|
|
|
|
'最后登录ip',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($_REQUEST['login_ip'])) {
|
|
|
|
|
$map['login_ip'] = $_REQUEST['login_ip'];
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['game_id'])) {
|
|
|
|
|
$map['game_id'] = $_REQUEST['game_id'];
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['game_name'])) {
|
|
|
|
|
$map['game_name'] = ['like', $_REQUEST['game_name']."%"];
|
|
|
|
|
unset($_REQUEST['game_name']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['game_type'])) {
|
|
|
|
|
$map['sdk_version'] = $_REQUEST['game_type'];
|
|
|
|
|
unset($_REQUEST['game_type']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['server_name'])) {
|
|
|
|
|
$map['server_name'] = $_REQUEST['server_name'];
|
|
|
|
|
unset($_REQUEST['server_name']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) {
|
|
|
|
|
$map['login_time'] = array('BETWEEN', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1));
|
|
|
|
|
}elseif(isset($_REQUEST['timestart'])){
|
|
|
|
|
$map['login_time'] = array('GT',strtotime($_REQUEST['timestart']));
|
|
|
|
|
}elseif(isset($_REQUEST['timeend'])){
|
|
|
|
|
$map['login_time'] = array('lt',(strtotime($_REQUEST['timeend'])+ 24 * 60 * 60 - 1));
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['account'])) {
|
|
|
|
|
$map['user_account'] = array('like', '%' . trim($_REQUEST['account']) . '%');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$map['login_time'] = array('neq', 0);
|
|
|
|
|
|
|
|
|
|
$page = intval($_REQUEST['p']);
|
|
|
|
|
if (isset($_REQUEST['login_ip'])) {
|
|
|
|
|
$map['login_ip'] = $_REQUEST['login_ip'];
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['game_id'])) {
|
|
|
|
|
$map['game_id'] = $_REQUEST['game_id'];
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['game_name'])) {
|
|
|
|
|
$map['game_name'] = ['like', $_REQUEST['game_name']."%"];
|
|
|
|
|
unset($_REQUEST['game_name']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['game_type'])) {
|
|
|
|
|
$map['sdk_version'] = $_REQUEST['game_type'];
|
|
|
|
|
unset($_REQUEST['game_type']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['server_name'])) {
|
|
|
|
|
$map['server_name'] = $_REQUEST['server_name'];
|
|
|
|
|
unset($_REQUEST['server_name']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) {
|
|
|
|
|
$map['login_time'] = array('BETWEEN', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1));
|
|
|
|
|
}elseif(isset($_REQUEST['timestart'])){
|
|
|
|
|
$map['login_time'] = array('GT',strtotime($_REQUEST['timestart']));
|
|
|
|
|
}elseif(isset($_REQUEST['timeend'])){
|
|
|
|
|
$map['login_time'] = array('lt',(strtotime($_REQUEST['timeend'])+ 24 * 60 * 60 - 1));
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['account'])) {
|
|
|
|
|
$map['user_account'] = array('like', '%' . trim($_REQUEST['account']) . '%');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$page = $page?$page:1;
|
|
|
|
|
// $map['login_time'] = array('neq', 0);
|
|
|
|
|
|
|
|
|
|
$row = $_REQUEST['row']?$_REQUEST['row']:10;
|
|
|
|
|
$page = intval($_REQUEST['p']);
|
|
|
|
|
|
|
|
|
|
$data = M('UserLoginRecord','tab_')
|
|
|
|
|
->where($map)->order('id desc')->select();
|
|
|
|
|
$page = $page?$page:1;
|
|
|
|
|
|
|
|
|
|
$xlsData = [];
|
|
|
|
|
$row = $_REQUEST['row']?$_REQUEST['row']:10;
|
|
|
|
|
|
|
|
|
|
foreach($data as $k => $v) {
|
|
|
|
|
|
|
|
|
|
$v['login_time'] = date('Y-m-d H:i:s',$v['login_time']);
|
|
|
|
|
$v['server_name'] = empty($v['server_name'])?'空':$v['server_name'];
|
|
|
|
|
//查询数量
|
|
|
|
|
$accessNum = M('UserLoginRecord','tab_')
|
|
|
|
|
->where($map)->order('id desc')->count();
|
|
|
|
|
|
|
|
|
|
$gamename=trim(get_game_name($v['game_id'],'id'));
|
|
|
|
|
if ($accessNum > 1000000) {
|
|
|
|
|
echo "数据量过大,大于100万";die();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$v['game_name'] = empty($gamename)?($v['type']==2?'APP登录':'平台登录'):$gamename;
|
|
|
|
|
$csvFileName = $xlsName.'.csv';
|
|
|
|
|
//设置好告诉浏览器要下载excel文件的headers
|
|
|
|
|
header('Content-Description: File Transfer');
|
|
|
|
|
header('Content-Type: application/vnd.ms-excel');
|
|
|
|
|
header('Content-Disposition: attachment; filename="'. $csvFileName .'"');
|
|
|
|
|
header('Expires: 0');
|
|
|
|
|
header('Cache-Control: must-revalidate');
|
|
|
|
|
header('Pragma: public');
|
|
|
|
|
$fp = fopen('php://output', 'a');//打开output流
|
|
|
|
|
mb_convert_variables('GBK', 'UTF-8', $xlsCell);
|
|
|
|
|
fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中
|
|
|
|
|
|
|
|
|
|
$xlsData[] = $v;
|
|
|
|
|
$perSize = 50000;//每次查询的条数
|
|
|
|
|
$pages = ceil($accessNum / $perSize);
|
|
|
|
|
for($i = 1; $i <= $pages; $i++) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$data = M('UserLoginRecord','tab_')
|
|
|
|
|
->field("user_account,game_name,server_name,user_nickname,login_time,login_ip")
|
|
|
|
|
->where($map)
|
|
|
|
|
->limit(($i-1)*$perSize ,$perSize)
|
|
|
|
|
->order('id desc')
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
foreach($data as $k => $v) {
|
|
|
|
|
|
|
|
|
|
$this->exportExcel($xlsName, $xlsCell, $xlsData);
|
|
|
|
|
$v['login_time'] = date('Y-m-d H:i:s',$v['login_time']);
|
|
|
|
|
$v['server_name'] = empty($v['server_name'])?'空':$v['server_name'];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// $gamename=trim(get_game_name($v['game_id'],'id'));
|
|
|
|
|
|
|
|
|
|
// $v['game_name'] = empty($gamename)?($v['type']==2?'APP登录':'平台登录'):$gamename;
|
|
|
|
|
|
|
|
|
|
$xlsData[] = $v;
|
|
|
|
|
|
|
|
|
|
mb_convert_variables('GBK', 'UTF-8', $v);
|
|
|
|
|
fputcsv($fp, $v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unset($xlsData);//释放变量的内存
|
|
|
|
|
//刷新输出缓冲到浏览器
|
|
|
|
|
ob_flush();
|
|
|
|
|
flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。
|
|
|
|
|
}
|
|
|
|
|
// $xlsData = [];
|
|
|
|
|
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $this->exportExcel($xlsName, $xlsCell, $xlsData);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|