45 lines
1.2 KiB
PHP
Executable File
45 lines
1.2 KiB
PHP
Executable File
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | 宏驰云科技开发团队 版权所有 拥有最终解释权
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | Author: HcyShop-kiki
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\api\behavior;
|
|
|
|
use think\Db;
|
|
use think\Request;
|
|
|
|
class AppEnd
|
|
{
|
|
/**
|
|
* 记录统计信息(用户访问量)
|
|
* @param Request $request
|
|
*/
|
|
public function run(Request $request)
|
|
{
|
|
try {
|
|
$ip = $request->ip();
|
|
$record = Db::name('stat')
|
|
->where('ip', '=', $ip)
|
|
->whereTime('create_time', 'today')
|
|
->find();
|
|
|
|
if ($record) {
|
|
Db::name('stat')
|
|
->where('id', $record['id'])
|
|
->setInc('count', 1);
|
|
} else {
|
|
$data = [
|
|
'ip' => $ip,
|
|
'count' => 1,
|
|
'create_time' => time()
|
|
];
|
|
Db::name('stat')->insert($data);
|
|
}
|
|
} catch (\Exception $e) {
|
|
|
|
}
|
|
}
|
|
} |