src/AppBundle/Component/Track/UserOnlineTrack.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace AppBundle\Component\Track;
use AppBundle\Component\DeviceDetector\DeviceDetectorAdapter;
use Codeages\Biz\Framework\Context\Biz;
use Symfony\Component\DependencyInjection\ContainerInterface;
class UserOnlineTrack
{
/**
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
private $container;
/**
* @var \Codeages\Biz\Framework\Context\Biz
*/
private $biz;
/**
* @var \AppBundle\Component\DeviceDetector\DeviceDetectorAdapter
*/
private $deviceDetector;
public function __construct(ContainerInterface $container, Biz $biz)
{
$this->container = $container;
$this->biz = $biz;
$this->deviceDetector = new DeviceDetectorAdapter($this->getUserAgent());
}
/**
* @todo api 和 web 的sessionId 应该统一
*
* @param $sessionId
*/
public function track($sessionId)
{
// 过滤掉爬虫
if ($this->deviceDetector->isBot()) {
return;
}
$user = $this->biz['user'];
$online = array(
'sess_id' => $sessionId,
'user_id' => $user['id'],
'ip' => $this->getClientIp(),
'user_agent' => $this->getUserAgent(),
'source' => $this->isFromApp() ? 'App' : 'Web',
);
$this->getUserActiveService()->saveOnline($online);
}
private function isFromApp()
{
$pathInfo = $this->getRequest()->getPathInfo();
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。