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.
66 lines
2.4 KiB
PHTML
66 lines
2.4 KiB
PHTML
|
2 months ago
|
<?php
|
||
|
|
|
||
|
|
namespace App\Controllers\Admin;
|
||
|
|
|
||
|
|
use App\Models\LoginIp;
|
||
|
|
use App\Models\User;
|
||
|
|
use App\Controllers\AdminController;
|
||
|
|
use App\Utils\QQWry;
|
||
|
|
use App\Utils\Tools;
|
||
|
|
use App\Services\AdminDataMasker;
|
||
|
|
|
||
|
|
use App\Utils\SafeDatatables as Datatables;
|
||
|
|
use App\Utils\DatatablesHelper;
|
||
|
|
|
||
|
|
class IpController extends AdminController
|
||
|
|
{
|
||
|
|
public function index($request, $response, $args)
|
||
|
|
{
|
||
|
|
$table_config['total_column'] = array("id" => "ID", "userid" => "用户ID",
|
||
|
|
"user_name" => "用户名", "ip" => "IP",
|
||
|
|
"location" => "归属地", "request_domain" => "访问域名", "datetime" => "时间", "type" => "类型");
|
||
|
|
$table_config['default_show_column'] = array();
|
||
|
|
foreach ($table_config['total_column'] as $column => $value) {
|
||
|
|
array_push($table_config['default_show_column'], $column);
|
||
|
|
}
|
||
|
|
$table_config['ajax_url'] = 'login/ajax';
|
||
|
|
return $this->view()->assign('table_config', $table_config)->display('admin/ip/login.tpl');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function ajax_login($request, $response, $args)
|
||
|
|
{
|
||
|
|
$datatables = new Datatables(new DatatablesHelper());
|
||
|
|
$datatables->query('Select login_ip.id,login_ip.userid,user.user_name,login_ip.ip,login_ip.ip as location,login_ip.request_domain,login_ip.datetime,login_ip.type from login_ip,user WHERE login_ip.userid = user.id');
|
||
|
|
|
||
|
|
$datatables->edit('datetime', function ($data) {
|
||
|
|
return date('Y-m-d H:i:s', $data['datetime']);
|
||
|
|
});
|
||
|
|
|
||
|
|
$datatables->edit('user_name', function ($data) {
|
||
|
|
return AdminDataMasker::account($data['user_name']);
|
||
|
|
});
|
||
|
|
|
||
|
|
$datatables->edit('ip', function ($data) {
|
||
|
|
return AdminDataMasker::ip($data['ip']);
|
||
|
|
});
|
||
|
|
|
||
|
|
$datatables->edit('request_domain', function ($data) {
|
||
|
|
return AdminDataMasker::sensitiveText($data['request_domain']);
|
||
|
|
});
|
||
|
|
|
||
|
|
$iplocation = new QQWry();
|
||
|
|
$datatables->edit('location', function ($data) use ($iplocation) {
|
||
|
|
$location=$iplocation->getlocation($data['location']);
|
||
|
|
return iconv('gbk', 'utf-8//IGNORE', $location['country'].$location['area']);
|
||
|
|
});
|
||
|
|
|
||
|
|
$datatables->edit('type', function ($data) {
|
||
|
|
return $data['type'] == 0 ? '成功' : '失败';
|
||
|
|
});
|
||
|
|
|
||
|
|
$body = $response->getBody();
|
||
|
|
$body->write($datatables->generate());
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|