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

164 line
5.0KB

  1. <?php
  2. /**
  3. * 获取TAGS管理
  4. *
  5. * @version $Id: tag_test_action.php 1 23:07 2010年7月20日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.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. {
  18. $orderby = empty($orderby) ? 'id' : preg_replace("#[^a-z]#i", '', $orderby);
  19. $orderway = isset($orderway) && $orderway == 'asc' ? 'asc' : 'desc';
  20. if(!empty($tag)) $where = " where tag like '%$tag%'";
  21. else $where = '';
  22. $neworderway = ($orderway == 'desc' ? 'asc' : 'desc');
  23. $query = "SELECT * FROM `#@__tagindex` $where ORDER BY $orderby $orderway";
  24. $dlist = new DataListCP();
  25. $tag = stripslashes($tag);
  26. $dlist->SetParameter("tag", $tag);
  27. $dlist->SetParameter("orderway", $orderway);
  28. $dlist->SetParameter("orderby", $orderby);
  29. $dlist->pageSize = 20;
  30. $dlist->SetTemplet(DEDEADMIN."/templets/tags_main.htm");
  31. $dlist->SetSource($query);
  32. $dlist->Display();
  33. exit();
  34. }
  35. /*
  36. function update()
  37. */
  38. else if($action == 'update')
  39. {
  40. $tid = (empty($tid) ? 0 : intval($tid) );
  41. if(empty($tid))
  42. {
  43. ShowMsg('没有选择要删除的tag!','-1');
  44. exit();
  45. }
  46. $query = "UPDATE `#@__tagindex` SET `count`='$count' WHERE id='$tid' ";
  47. $dsql->ExecuteNoneQuery($query);
  48. ShowMsg("成功保存标签的点击信息!", 'tags_main.php');
  49. exit();
  50. }
  51. /*
  52. function delete()
  53. */
  54. else if($action == 'delete')
  55. {
  56. if(@is_array($ids))
  57. {
  58. $stringids = implode(',', $ids);
  59. }
  60. else if(!empty($ids))
  61. {
  62. $stringids = $ids;
  63. }
  64. else
  65. {
  66. ShowMsg('没有选择要删除的tag','-1');
  67. exit();
  68. }
  69. $query = "DELETE FROM `#@__tagindex` WHERE id IN ($stringids)";
  70. if($dsql->ExecuteNoneQuery($query))
  71. {
  72. $query = "DELETE FROM `#@__taglist` WHERE tid IN ($stringids)";
  73. $dsql->ExecuteNoneQuery($query);
  74. ShowMsg("删除tags[ $stringids ]成功", 'tags_main.php');
  75. }
  76. else
  77. {
  78. ShowMsg("删除tags[ $stringids ]失败", 'tags_main.php');
  79. }
  80. exit();
  81. }
  82. /*
  83. function fetch()
  84. */
  85. else if($action == 'fetch')
  86. {
  87. $wheresql = '';
  88. $start = isset($start) && is_numeric($start) ? $start : 0;
  89. $where = array();
  90. if(isset($startaid) && is_numeric($startaid) && $startaid > 0)
  91. {
  92. $where[] = " id>$startaid ";
  93. }
  94. else
  95. {
  96. $startaid = 0;
  97. }
  98. if(isset($endaid) && is_numeric($endaid) && $endaid > 0)
  99. {
  100. $where[] = " id<$endaid ";
  101. }
  102. else
  103. {
  104. $endaid = 0;
  105. }
  106. if(!empty($where))
  107. {
  108. $wheresql = " WHERE arcrank>-1 AND ".implode(' AND ', $where);
  109. }
  110. $query = "SELECT id as aid,arcrank,typeid,keywords FROM `#@__archives` $wheresql LIMIT $start, 100";
  111. $dsql->SetQuery($query);
  112. $dsql->Execute();
  113. $complete = true;
  114. while($row = $dsql->GetArray())
  115. {
  116. $aid = $row['aid'];
  117. $typeid = $row['typeid'];
  118. $arcrank = $row['arcrank'];
  119. $row['keywords'] = trim($row['keywords']);
  120. if($row['keywords']!='' && !preg_match("#,#", $row['keywords']))
  121. {
  122. $keyarr = explode(' ', $row['keywords']);
  123. }
  124. else
  125. {
  126. $keyarr = explode(',', $row['keywords']);
  127. }
  128. foreach($keyarr as $keyword)
  129. {
  130. $keyword = trim($keyword);
  131. if($keyword != '' && strlen($keyword)<13 )
  132. {
  133. $keyword = addslashes($keyword);
  134. $row = $dsql->GetOne("SELECT id FROM `#@__tagindex` WHERE tag LIKE '$keyword'");
  135. if(is_array($row))
  136. {
  137. $tid = $row['id'];
  138. $query = "UPDATE `#@__tagindex` SET `total`=`total`+1 WHERE id='$tid' ";
  139. $dsql->ExecuteNoneQuery($query);
  140. }
  141. else
  142. {
  143. $query = " INSERT INTO `#@__tagindex`(`tag`,`count`,`total`,`weekcc`,`monthcc`,`weekup`,`monthup`,`addtime`) VALUES('$keyword','0','1','0','0','$timestamp','$timestamp','$timestamp');";
  144. $dsql->ExecuteNoneQuery($query);
  145. $tid = $dsql->GetLastID();
  146. }
  147. $query = "REPLACE INTO `#@__taglist`(`tid`,`aid`,`typeid`,`arcrank`,`tag`) VALUES ('$tid', '$aid', '$typeid','$arcrank','$keyword'); ";
  148. $dsql->ExecuteNoneQuery($query);
  149. }
  150. }
  151. $complete = FALSE;
  152. }
  153. if($complete)
  154. {
  155. ShowMsg("tags获取完成", 'tags_main.php');
  156. exit();
  157. }
  158. $start = $start + 100;
  159. $goto = "tags_main.php?action=fetch&startaid=$startaid&endaid=$endaid&start=$start";
  160. ShowMsg('继续获取tags ...', $goto, 0, 500);
  161. exit();
  162. }