|
|
|
@ -3423,14 +3423,23 @@ if ($key == 'model'){
|
|
|
|
|
|
|
|
|
|
$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',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -3463,7 +3472,7 @@ if ($key == 'model'){
|
|
|
|
|
$map['user_account'] = array('like', '%' . trim($_REQUEST['account']) . '%');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$map['login_time'] = array('neq', 0);
|
|
|
|
|
// $map['login_time'] = array('neq', 0);
|
|
|
|
|
|
|
|
|
|
$page = intval($_REQUEST['p']);
|
|
|
|
|
|
|
|
|
@ -3471,26 +3480,64 @@ if ($key == 'model'){
|
|
|
|
|
|
|
|
|
|
$row = $_REQUEST['row']?$_REQUEST['row']:10;
|
|
|
|
|
|
|
|
|
|
$data = M('UserLoginRecord','tab_')
|
|
|
|
|
->where($map)->order('id desc')->select();
|
|
|
|
|
|
|
|
|
|
$xlsData = [];
|
|
|
|
|
//查询数量
|
|
|
|
|
$accessNum = M('UserLoginRecord','tab_')
|
|
|
|
|
->where($map)->order('id desc')->count();
|
|
|
|
|
|
|
|
|
|
foreach($data as $k => $v) {
|
|
|
|
|
if ($accessNum > 1000000) {
|
|
|
|
|
echo "数据量过大,大于100万";die();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$v['login_time'] = date('Y-m-d H:i:s',$v['login_time']);
|
|
|
|
|
$v['server_name'] = empty($v['server_name'])?'空':$v['server_name'];
|
|
|
|
|
$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流中
|
|
|
|
|
|
|
|
|
|
$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();
|
|
|
|
|
|
|
|
|
|
$gamename=trim(get_game_name($v['game_id'],'id'));
|
|
|
|
|
foreach($data as $k => $v) {
|
|
|
|
|
|
|
|
|
|
$v['game_name'] = empty($gamename)?($v['type']==2?'APP登录':'平台登录'):$gamename;
|
|
|
|
|
$v['login_time'] = date('Y-m-d H:i:s',$v['login_time']);
|
|
|
|
|
$v['server_name'] = empty($v['server_name'])?'空':$v['server_name'];
|
|
|
|
|
|
|
|
|
|
$xlsData[] = $v;
|
|
|
|
|
// $gamename=trim(get_game_name($v['game_id'],'id'));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// $v['game_name'] = empty($gamename)?($v['type']==2?'APP登录':'平台登录'):$gamename;
|
|
|
|
|
|
|
|
|
|
$xlsData[] = $v;
|
|
|
|
|
|
|
|
|
|
$this->exportExcel($xlsName, $xlsCell, $xlsData);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|