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

66 lines
2.1KB

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