国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

139 行
5.6KB

  1. <?php
  2. /**
  3. * 标签管理
  4. *
  5. * @version $id:tag_test_action.php 23:07 2010年7月20日 tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__).'/config.php');
  12. CheckPurview('sys_Keyword');
  13. require_once(DEDEINC.'/datalistcp.class.php');
  14. $timestamp = time();
  15. if (empty($tag)) $tag = '';
  16. if (empty($action)) {
  17. $orderby = empty($orderby) ? 'id' : preg_replace("#[^a-z]#i", '', $orderby);
  18. $orderway = isset($orderway) && $orderway == 'asc' ? 'asc' : 'desc';
  19. if (!empty($tag)) $where = " where tag like '%$tag%'";
  20. else $where = '';
  21. $neworderway = ($orderway == 'desc' ? 'asc' : 'desc');
  22. $query = "SELECT * FROM `#@__tagindex` $where ORDER BY $orderby $orderway";
  23. $dlist = new DataListCP();
  24. $tag = stripslashes($tag);
  25. $dlist->SetParameter("tag", $tag);
  26. $dlist->SetParameter("orderway", $orderway);
  27. $dlist->SetParameter("orderby", $orderby);
  28. $dlist->pagesize = 30;
  29. $dlist->SetTemplet(DEDEADMIN."/templets/tags_main.htm");
  30. $dlist->SetSource($query);
  31. $dlist->Display();
  32. exit();
  33. } else if ($action == 'update') {
  34. $tid = (empty($tid) ? 0 : intval($tid));
  35. $count = (empty($count) ? 0 : intval($count));
  36. if (empty($tid)) {
  37. ShowMsg('请选择需要删除的标签', '-1');
  38. exit();
  39. }
  40. $query = "UPDATE `#@__tagindex` SET `count`='$count' WHERE id='$tid' ";
  41. $dsql->ExecuteNoneQuery($query);
  42. ShowMsg("成功保存标签点击信息", 'tags_main.php');
  43. exit();
  44. } else if ($action == 'delete') {
  45. if (@is_array($ids)) {
  46. $stringids = implode(',', $ids);
  47. } else if (!empty($ids)) {
  48. $stringids = $ids;
  49. } else {
  50. ShowMsg('请选择需要删除的标签', '-1');
  51. exit();
  52. }
  53. $query = "DELETE FROM `#@__tagindex` WHERE id IN ($stringids)";
  54. if ($dsql->ExecuteNoneQuery($query)) {
  55. $query = "DELETE FROM `#@__taglist` WHERE tid IN ($stringids)";
  56. $dsql->ExecuteNoneQuery($query);
  57. ShowMsg("删除[$stringids]标签成功", 'tags_main.php');
  58. } else {
  59. ShowMsg("删除[$stringids]标签失败", 'tags_main.php');
  60. }
  61. exit();
  62. } else if ($action == 'get_one') {
  63. $tid = (empty($tid) ? 0 : intval($tid));
  64. $row = $dsql->GetOne("SELECT * FROM `#@__tagindex` WHERE id = $tid");
  65. echo json_encode($row);
  66. exit;
  67. } else if ($action == 'set_one') {
  68. $tid = (empty($tid) ? 0 : intval($tid));
  69. $title = empty($title) ? "" : HtmlReplace($title, 0);
  70. $kw = empty($kw) ? "" : HtmlReplace($kw, 0);
  71. $des = empty($des) ? "" : HtmlReplace($des, 0);
  72. $now = time();
  73. $dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET title='{$title}',keywords='{$kw}',`description`='{$des}',`uptime`='{$now}' WHERE id = {$tid}");
  74. echo json_encode(array('code' => 200, 'result' => true));
  75. } else if ($action == 'fetch') {
  76. $wheresql = '';
  77. $start = isset($start) && is_numeric($start) ? $start : 0;
  78. $where = array();
  79. if (isset($startaid) && is_numeric($startaid) && $startaid > 0) {
  80. $where[] = " id>=$startaid ";
  81. } else {
  82. $startaid = 0;
  83. }
  84. if (isset($endaid) && is_numeric($endaid) && $endaid > 0) {
  85. $where[] = " id<=$endaid ";
  86. } else {
  87. $endaid = 0;
  88. }
  89. if (!empty($where)) {
  90. $wheresql = " WHERE arcrank>-1 AND ".implode(' AND ', $where);
  91. }
  92. $query = "SELECT id as aid,arcrank,typeid,keywords FROM `#@__archives` $wheresql LIMIT $start, 100";
  93. $dsql->SetQuery($query);
  94. $dsql->Execute();
  95. $complete = true;
  96. $now = time();
  97. while ($row = $dsql->GetArray()) {
  98. $aid = $row['aid'];
  99. $typeid = $row['typeid'];
  100. $arcrank = $row['arcrank'];
  101. $row['keywords'] = trim($row['keywords']);
  102. if ($row['keywords'] != '' && !preg_match("#,#", $row['keywords'])) {
  103. $keyarr = explode(' ', $row['keywords']);
  104. } else {
  105. $keyarr = explode(',', $row['keywords']);
  106. }
  107. foreach ($keyarr as $keyword) {
  108. $keyword = trim($keyword);
  109. if ($keyword != '' && strlen($keyword) < 24) {
  110. $keyword = addslashes($keyword);
  111. $row = $dsql->GetOne("SELECT id,total FROM `#@__tagindex` WHERE tag LIKE '$keyword'");
  112. if (is_array($row)) {
  113. $tid = $row['id'];
  114. $trow = $dsql->GetOne("SELECT COUNT(*) as dd FROM `#@__taglist` WHERE tag LIKE '$keyword'");
  115. if (intval($trow['dd']) != $row['total']) {
  116. $query = "UPDATE `#@__tagindex` SET `total`=".$trow['dd'].",uptime=$now WHERE id='$tid' ";
  117. $dsql->ExecuteNoneQuery($query);
  118. }
  119. } else {
  120. $query = "INSERT INTO `#@__tagindex` (`tag`,`count`,`total`,`weekcc`,`monthcc`,`weekup`,`monthup`,`addtime`,`uptime`) VALUES ('$keyword','0','1','0','0','$timestamp','$timestamp','$timestamp','$now');";
  121. $dsql->ExecuteNoneQuery($query);
  122. $tid = $dsql->GetLastID();
  123. }
  124. $query = "REPLACE INTO `#@__taglist` (`tid`,`aid`,`typeid`,`arcrank`,`tag`) VALUES ('$tid','$aid','$typeid','$arcrank','$keyword'); ";
  125. $dsql->ExecuteNoneQuery($query);
  126. }
  127. }
  128. $complete = FALSE;
  129. }
  130. if ($complete) {
  131. ShowMsg('完成标签获取', 'tags_main.php');
  132. exit();
  133. }
  134. $start = $start + 100;
  135. $goto = "tags_main.php?action=fetch&startaid=$startaid&endaid=$endaid&start=$start";
  136. ShowMsg('正在获取标签', $goto);
  137. exit();
  138. }
  139. ?>