Core.php 738 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Source\Lib;
  3. use Dever;
  4. class Core
  5. {
  6. /**
  7. * 日志记录
  8. *
  9. * @return mixed
  10. */
  11. public function save($uid, $id)
  12. {
  13. $input = Dever::json_encode(Dever::input());
  14. $url = Dever::url();
  15. $log = array
  16. (
  17. 'uid' => $uid,
  18. 'source_id' => $id,
  19. 'input' => $input,
  20. 'url' => $url,
  21. );
  22. Dever::log($log, 'source');
  23. $data = array();
  24. $data['info_id'] = $id;
  25. $data['day'] = Dever::maketime(date('Y-m-d', time()));
  26. $info = Dever::db('source/stat')->one($data);
  27. if ($info) {
  28. $data['pv'] = $info['pv'] + 1;
  29. Dever::db('source/stat')->update($data);
  30. } else {
  31. $data['pv'] = 1;
  32. Dever::db('source/stat')->insert($data);
  33. }
  34. return true;
  35. }
  36. }