| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- /**
- *------Create thems Model------
- *------SCWPHP Version 1.0.0------
- *------Dev Model Jions------
- *------Create Time 2017-10-30 13:48:09------
- */
- namespace App\Commons\Model;
- use \System\Model;
- class User_logs extends Model
- {
- public $timestamps = false;
- protected $table = 'user_logs';
- /**
- *初始化
- *
- * @return void
- */
- function initVisitor(){
- $mob=C()->get('header');
- $ip=$mob->getIP();
- $time=time()-180;
- $had=$this->where('ip',$ip)->where("create_time",'>',date('Y-m-d H:i:s',$time))->orderBy('create_time','desc')->first();
- // toLog($had);
- if($had){
- return;
- }
- $data=array(
- 'ip'=>$ip,
- 'header'=>$mob->getHttpHeader(),
- 'create_time'=>date('Y-m-d H:i:s'),
- );
- $this->insert($data);
- }
- //
- function updateUid($uid,$uname){
- // $uid=isset($_GET['uid'])?trim($_GET['uid']):null;
- // $uname=isset($_GET['uname'])?trim($_GET['uname']):null;
- if(empty($uid))
- {
- return -1;
- }
- $mob=C()->get('header');
- $ip=$mob->getIP();
- $this->where('ip',$ip)->orderBy('create_time','desc')->update(['user_id'=>$uid,'user_name'=>$uname]);
- }
- }
|