国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
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.

54 lines
1.9KB

  1. <?php
  2. /**
  3. * 文档统计
  4. *
  5. * 如果想显示点击次数,请添加view参数,即把下面js调用放到文档模板适当位置
  6. * <script src="{dede:field name='phpurl'/}/count.php?view=yes&aid={dede:field name='id'/}&mid={dede:field name='mid'/}"></script>
  7. * 普通计数器为
  8. * <script src="{dede:field name='phpurl'/}/count.php?aid={dede:field name='id'/}&mid={dede:field name='mid'/}"></script>
  9. *
  10. * @version $id:count.php$
  11. * @package DedeBIZ.Site
  12. * @copyright Copyright (c) 2022 DedeBIZ.COM
  13. * @license https://www.dedebiz.com/license
  14. * @link https://www.dedebiz.com
  15. */
  16. require_once(dirname(__FILE__)."/../system/common.inc.php");
  17. if (isset($aid)) $arcID = $aid;
  18. $cid = empty($cid) ? 1 : intval($cid);
  19. $arcID = $aid = empty($arcID) ? 0 : intval($arcID);
  20. $format = isset($format) ? $format : "";
  21. $maintable = '#@__archives';
  22. $idtype = 'id';
  23. if ($aid == 0) exit();
  24. //获得栏目模型id
  25. if ($cid < 0) {
  26. $row = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$cid' AND issystem='-1';");
  27. $maintable = empty($row['addtable']) ? '' : $row['addtable'];
  28. $idtype = 'aid';
  29. }
  30. $mid = (isset($mid) && is_numeric($mid)) ? $mid : 0;
  31. if (!empty($maintable)) {
  32. $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET click=click+1 WHERE {$idtype}='$aid' ");
  33. }
  34. if (!empty($mid)) {
  35. $dsql->ExecuteNoneQuery("UPDATE `#@__member_tj` SET pagecount=pagecount+1 WHERE mid='$mid' ");
  36. }
  37. if (!empty($view)) {
  38. $row = $dsql->GetOne("SELECT click FROM `{$maintable}` WHERE {$idtype}='$aid' ");
  39. if (is_array($row)) {
  40. if (!empty($format)) {
  41. $result = array(
  42. "code" => 200,
  43. "data" => array(
  44. 'click' => $row['click'],
  45. ),
  46. );
  47. echo json_encode($result);
  48. } else {
  49. echo "document.write('".$row['click']."');\r\n";
  50. }
  51. }
  52. }
  53. exit();
  54. ?>