Visit.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Db;
  4. class Visit extends Base
  5. {
  6. public function __construct()
  7. {
  8. parent::__construct();
  9. }
  10. public function index()
  11. {
  12. $param = input();
  13. $param['page'] = intval($param['page']) <1 ? 1 : $param['page'];
  14. $param['limit'] = intval($param['limit']) <1 ? $this->_pagesize : $param['limit'];
  15. $where=[];
  16. if(!empty($param['uid'])){
  17. $where['user_id'] = ['eq',$param['uid'] ];
  18. }
  19. if(isset($param['time'])){
  20. $t = strtotime(date('Y-m-d',strtotime('-'.$param['time'] .' day')));
  21. $where['visit_time'] = ['egt', intval($t) ];
  22. }
  23. if(!empty($param['wd'])){
  24. $a = $param['wd'];
  25. if(substr($a,5)==='http:'){
  26. $b = str_replace('http:','https:',$a);
  27. }
  28. elseif(substr($a,5)==='https'){
  29. $b = str_replace('https:','http:',$a);
  30. }
  31. else{
  32. $a = 'http://'.$param['wd'];
  33. $b = 'https://'.$param['wd'];
  34. }
  35. $where['visit_ly'] = ['like', [$a.'%',$b.'%'],'OR'];
  36. }
  37. $order='visit_id desc';
  38. $res = model('Visit')->listData($where,$order,$param['page'],$param['limit']);
  39. $this->assign('list',$res['list']);
  40. $this->assign('total',$res['total']);
  41. $this->assign('page',$res['page']);
  42. $this->assign('limit',$res['limit']);
  43. $param['page'] = '{page}';
  44. $param['limit'] = '{limit}';
  45. $this->assign('param',$param);
  46. $this->assign('title',lang('admin/visit/title'));
  47. return $this->fetch('admin@visit/index');
  48. }
  49. public function del()
  50. {
  51. $param = input();
  52. $ids = $param['ids'];
  53. $all = $param['all'];
  54. if(!empty($ids)){
  55. $where=[];
  56. $where['visit_id'] = ['in',$ids];
  57. if($all==1){
  58. $where['visit_id'] = ['gt',0];
  59. }
  60. $res = model('Visit')->delData($where);
  61. if($res['code']>1){
  62. return $this->error($res['msg']);
  63. }
  64. return $this->success($res['msg']);
  65. }
  66. return $this->error(lang('param_err'));
  67. }
  68. }