116 lines
3.9 KiB
PHP
Executable File
116 lines
3.9 KiB
PHP
Executable File
<?php
|
|
//declare (strict_types = 1);
|
|
|
|
namespace app\api\controller;
|
|
use think\Loader;
|
|
use think\Cookie;
|
|
use think\Config;
|
|
use think\Session;
|
|
|
|
class TrackProducer extends BaseController
|
|
{
|
|
|
|
private $topic_name = 'log-const-total-data'; // kafka队列 topic
|
|
private $username = 'dolog'; // 队列账号
|
|
private $password = 'kafka_log_Aa-1221'; // 队列密码
|
|
private $brokerList = '127.0.0.1:9092';
|
|
|
|
|
|
public function etime()
|
|
{
|
|
$data = request()->get();
|
|
|
|
$useragent = $_SERVER['HTTP_USER_AGENT'];
|
|
$ip = get_ip();
|
|
$address = GetIpLookup($ip);
|
|
//echo $ip."<pre>=="; print_r($address);die;
|
|
$url = getpageurl();
|
|
$keywords =getKeywords($url);
|
|
|
|
$curUrl = parse_url($url);
|
|
$host = $curUrl['host'];
|
|
|
|
$feed = array(
|
|
"items" => 'ORICO Official',
|
|
"forum" => $controller,
|
|
"forum_code" => $controller,
|
|
"url" => $url,
|
|
"refer" => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $url,
|
|
"channel" => isset($keywords['channel']) ? $keywords['channel'] : $host,
|
|
"channel_type" => isset($keywords['channel']) ?$keywords['channel'] :'1',
|
|
"keyword" => isset($keywords['search']) ?$keywords['search'] :'',
|
|
"start_time" => date("y-m-d H:i:s"),
|
|
"ip" => $ip,
|
|
"country" => isset($address['country']) ? $address['country'] :'',
|
|
"province" => isset($address['province']) ? $address['province'] :'',
|
|
"city" => isset($address['city']) ? $address['city'] :'',
|
|
"drive" => isMobile() ? "H5": "PC",
|
|
"system" => getOs($useragent),
|
|
"brower" => getBroswer($useragent),
|
|
|
|
"uuid" => $data['uuid'],
|
|
"end_time" => date("y-m-d H:i:s"),
|
|
"elapsed_time" => $data['dt'],
|
|
|
|
);
|
|
|
|
|
|
$feed = http_build_query($feed);
|
|
$result = CurlRequest('https://producer.datamaster.cc/api/v1/browser_logs/send', $feed);
|
|
$res = json_decode($result, true);
|
|
return $this->json(200, 'ok');
|
|
|
|
}
|
|
|
|
public function records()
|
|
{
|
|
|
|
$data = $this->request->post();
|
|
if (empty($data) || !is_array($data))
|
|
return $this->json(-1, 'Data error ');
|
|
|
|
|
|
$useragent = $data['user_agent'];
|
|
$ip = get_ip();
|
|
$address = GetIpLookup($ip);
|
|
//echo $ip."<pre>=="; print_r($address);die;
|
|
$url = $data['url'];
|
|
$keywords =getKeywords($url);
|
|
|
|
$arr_url = parse_url($url);
|
|
$content = pregReplaceImg($data['content'],'https://'.$arr_url['host']);
|
|
|
|
$fds = array(
|
|
"items" => 'ORICO Official',
|
|
"forum" => $data['forum'],
|
|
"forum_code" => $data['forum'],
|
|
"url" => $data['url'],
|
|
"refer" =>isset($data['refer']) ? $data['refer'] : $arr_url['host'],
|
|
"channel" => isset($keywords['channel']) ? $keywords['channel'] : $arr_url['host'],
|
|
"channel_type" => isset($keywords['channel']) ?$keywords['channel'] :'1',
|
|
"keyword" => isset($keywords['search']) ?$keywords['search'] :'',
|
|
"start_time" => date("y-m-d H:i:s"),
|
|
"ip" => $ip,
|
|
"country" => isset($address['country']) ? $address['country'] :'',
|
|
"province" => isset($address['province']) ? $address['province'] :'',
|
|
"city" => isset($address['city']) ? $address['city'] :'',
|
|
"content" => $content,
|
|
"drive" => $data['drive'],
|
|
"event_type" => $data['event_type'],
|
|
"system" => getOs($useragent),
|
|
"brower" => getBroswer($useragent),
|
|
|
|
);
|
|
|
|
|
|
$feeds = http_build_query($fds);
|
|
$result = CurlRequest('https://producer.datamaster.cc/api/v1/action_logs/send', $feeds);
|
|
$res = json_decode($result, true);
|
|
return $this->json(200, 'ok');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} |