visit.mod.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. function visit_update_today($type, $module_name = '') {
  8. global $_W;
  9. $module_name = trim($module_name);
  10. $type = trim($type);
  11. if (empty($type) || !in_array($type, array('app', 'web', 'api'))) {
  12. return false;
  13. }
  14. if ($type == 'app' && empty($module_name)) {
  15. return false;
  16. }
  17. $today = date('Ymd');
  18. $today_exist = pdo_get('stat_visit', array('date' => $today, 'uniacid' => $_W['uniacid'], 'module' => $module_name, 'type' => $type));
  19. if (empty($today_exist)) {
  20. $insert_data = array(
  21. 'uniacid' => $_W['uniacid'],
  22. 'module' => $module_name,
  23. 'type' => $type,
  24. 'date' => $today,
  25. 'count' => 1
  26. );
  27. pdo_insert('stat_visit', $insert_data);
  28. } else {
  29. $data = array('count' => $today_exist['count'] + 1);
  30. pdo_update('stat_visit' , $data, array('id' => $today_exist['id']));
  31. }
  32. return true;
  33. }