Files
juipphp/app/api/controller/Index.php
“wanyongkang” e81e23e0f1 添加ip查询接口
2025-05-16 18:29:01 +08:00

52 lines
1.1 KiB
PHP

<?php
namespace app\api\controller;
use fastphp\base\Controller;
use app\api\model\Logs;
class Index extends Controller
{
public function index()
{
$logs = new Logs();
$list = $logs->getUserListPage('50');
$count = $logs->getCount();
$data = [
'Code'=>10000,
'count'=>$count['count'],
'data'=>$list
];
echo json_encode($data);
}
//获取指定页码数据
public function pageList()
{
if(!$_GET){
die;
}
$page = ($_GET['page'] - 1) * 50;
$logs = new Logs();
$list = $logs->getUserListPage("$page,50");
$data = [
'Code'=>10000,
'data'=>$list
];
echo json_encode($data);
}
public function getIpAddress()
{
if(!$_GET){
die;
}
$ip = $_GET['ip'];
$cip_content = json_decode(file_get_contents('https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?co=&resource_id=6006&oe=utf8&query='.$ip),true);
\result($cip_content['data'][0]['location']);
}
}