You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.5 KiB

  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. require APPPATH . '/libraries/REST_Controller.php';
  4. class Statics extends REST_Controller
  5. {
  6. function visit_get()
  7. {
  8. // 모델 가져오기
  9. $start_date = $this->get('start_date', TRUE);
  10. $end_date = $this->get('end_date', TRUE);
  11. $is_mobile = $this->get('is_mobile', TRUE);
  12. $ip = $this->get('ip', TRUE);
  13. $page_rows = $this->input->get('take', TRUE, 15);
  14. $start = $this->input->get('skip', TRUE);
  15. if(! empty($start_date)) $this->db->where('sta_regtime >=', $start_date . ' 00:00:00');
  16. if(! empty($end_date)) $this->db->where('sta_regime <=', $end_date, ' 23:59:59');
  17. if(! empty($ip)) $this->db->like('INET_NTOA(sta_ip)', $ip);
  18. if(! empty($is_mobile)) $this->db->where('sta_is_mobile', $is_mobile);
  19. $this->db
  20. ->select('SQL_CALC_FOUND_ROWS *', FALSE)
  21. ->from('statics')
  22. ->order_by('sta_idx DESC')
  23. ->limit($page_rows, $start);
  24. $result = $this->db->get();
  25. $return['lists'] = $result->result_array();
  26. $return['totalCount'] = (int)$this->db->query("SELECT FOUND_ROWS() AS cnt")->row(0)->cnt;
  27. foreach($return['lists'] as $i=>&$row)
  28. {
  29. $row['nums'] = $return['totalCount'] - $i - $start;
  30. $row['sta_ip'] = long2ip((int)$row['sta_ip']);
  31. $row['sta_is_mobile'] = ($row['sta_is_mobile'] == 'Y');
  32. }
  33. $this->response($return, 200);
  34. }
  35. }