国内流行的内容管理系统(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.

51 lines
1.9KB

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