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

154 lines
6.4KB

  1. <?php
  2. /**
  3. * 文档描述管理
  4. *
  5. * @version $id:article_description_main.php 14:12 2010年7月12日 tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. @ob_start();
  12. @set_time_limit(3600);
  13. require_once(dirname(__FILE__)."/config.php");
  14. CheckPurview('sys_Keyword');
  15. if (empty($dojob)) $dojob = '';
  16. if ($dojob == '') {
  17. include DedeInclude("templets/article_description_main.htm");
  18. exit();
  19. } else {
  20. if (empty($startdd)) $startdd = 0;
  21. if (empty($pagesize)) $pagesize = 30;
  22. if (empty($totalnum)) $totalnum = 0;
  23. if (empty($sid)) $sid = 0;
  24. if (empty($eid)) $eid = 0;
  25. if (empty($dojob)) $dojob = 'des';
  26. $table = preg_replace("#[^0-9a-zA-Z_\#@]#", "", $table);
  27. $field = preg_replace("#[^0-9a-zA-Z_\[\]]#", "", $field);
  28. $channel = intval($channel);
  29. if ($dsize > 250) $dsize = 250;
  30. $tjnum = 0;
  31. //获取自动摘要
  32. if ($dojob == 'des') {
  33. if (empty($totalnum)) {
  34. $addquery = "";
  35. if ($sid != 0) {
  36. $addquery .= " AND id>='$sid' ";
  37. }
  38. if ($eid != 0) {
  39. $addquery .= " AND id<='$eid' ";
  40. }
  41. $tjQuery = "SELECT COUNT(*) AS dd FROM `#@__archives` WHERE channel='{$channel}' $addquery";
  42. $row = $dsql->GetOne($tjQuery);
  43. $totalnum = $row['dd'];
  44. }
  45. if ($totalnum > 0) {
  46. $addquery = "";
  47. if ($sid != 0) {
  48. $addquery .= " AND `#@__archives`.id>='$sid' ";
  49. }
  50. if ($eid != 0) {
  51. $addquery .= " AND `#@__archives`.id<='$eid' ";
  52. }
  53. $fquery = "SELECT `#@__archives`.id,`#@__archives`.title,`#@__archives`.description,{$table}.{$field} FROM `#@__archives` LEFT JOIN {$table} ON {$table}.aid=`#@__archives`.id WHERE `#@__archives`.channel='{$channel}' $addquery LIMIT $startdd,$pagesize ; ";
  54. $dsql->SetQuery($fquery);
  55. $dsql->Execute();
  56. while ($row = $dsql->GetArray()) {
  57. $body = $row[$field];
  58. $description = $row['description'];
  59. if (strlen($description) > 10 || $description == '-') {
  60. continue;
  61. }
  62. $bodytext = preg_replace("/#p#|#e#|副标题|分页标题/isU", "", Html2Text($body));
  63. if (strlen($bodytext) < $msize) {
  64. continue;
  65. }
  66. $des = trim(addslashes(cn_substr($bodytext, $dsize)));
  67. if (strlen($des) < 3) {
  68. $des = "-";
  69. }
  70. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET description='{$des}' WHERE id='{$row['id']}';");
  71. }
  72. //返回进度信息
  73. $startdd = $startdd + $pagesize;
  74. if ($totalnum > $startdd) {
  75. $tjlen = ceil(($startdd / $totalnum) * 100);
  76. } else {
  77. $tjlen = 100;
  78. ShowMsg('完成所有任务', 'javascript:;');
  79. exit();
  80. }
  81. $dvlen = $tjlen * 1;
  82. $tjsta = "<div style='margin-bottom:18px;width:260px;height:18px;text-align:left;border:1px solid #1eb867;border-radius:.2rem'><div style='max-width:260px;width:$dvlen%;height:18px;background:#1eb867'></div></div>";
  83. $tjsta .= "完成更新文档总数<span class='text-primary'>$tjlen</span>%";
  84. $nurl = "article_description_main.php?totalnum=$totalnum&startdd={$startdd}&pagesize=$pagesize&table={$table}&field={$field}&dsize={$dsize}&msize={$msize}&channel={$channel}&dojob={$dojob}";
  85. ShowMsg($tjsta, $nurl, 0, 500);
  86. exit();
  87. } else {
  88. ShowMsg('完成所有任务', 'javascript:;');
  89. exit();
  90. }
  91. }//获取自动摘要代码结束
  92. //更新自动分页
  93. if ($dojob == 'page') {
  94. require_once(DEDEADMIN."/inc/inc_archives_functions.php");
  95. $addquery = "";
  96. if ($sid != 0) {
  97. $addquery .= " and aid>='$sid' ";
  98. }
  99. if ($eid != 0) {
  100. $addquery .= " and aid<='$eid' ";
  101. }
  102. //统计记录总数
  103. if ($totalnum == 0) {
  104. $sql = "SELECT COUNT(*) AS dd FROM $table WHERE 1 $addquery";
  105. $row = $dsql->GetOne($sql);
  106. $totalnum = $row['dd'];
  107. }
  108. //获取记录,并分析
  109. if ($totalnum > $startdd + $pagesize) {
  110. $limitSql = " LIMIT $startdd,$pagesize";
  111. } else if (($totalnum - $startdd) > 0) {
  112. $limitSql = " LIMIT $startdd,".($totalnum - $startdd);
  113. } else {
  114. $limitSql = "";
  115. }
  116. $tjnum = $startdd;
  117. if ($limitSql != "") {
  118. $fquery = "SELECT aid,$field FROM $table WHERE 1 $addquery $limitSql ;";
  119. $dsql->SetQuery($fquery);
  120. $dsql->Execute();
  121. while ($row = $dsql->GetArray()) {
  122. $tjnum++;
  123. $body = $row[$field];
  124. $aid = $row['aid'];
  125. if (strlen($body) < $msize) {
  126. continue;
  127. }
  128. if (!preg_match("/#p#/iU", $body)) {
  129. $body = SpLongBody($body, $cfg_arcautosp_size * 1024, "#p#分页标题#e#");
  130. $body = addslashes($body);
  131. $dsql->ExecuteNoneQuery("UPDATE $table SET $field='$body' WHERE aid='$aid' ;");
  132. }
  133. }
  134. }//end if limit
  135. //返回进度提示
  136. if ($totalnum > 0) {
  137. $tjlen = ceil(($tjnum / $totalnum) * 100);
  138. } else {
  139. $tjlen = 100;
  140. }
  141. $dvlen = $tjlen * 1;
  142. $tjsta = "<div style='margin-bottom:18px;width:260px;height:18px;text-align:left;border:1px solid #1eb867;border-radius:.2rem'><div style='max-width:260px;width:$dvlen%;height:18px;background:#1eb867'></div></div>";
  143. $tjsta .= "完成更新文档总数<span class='text-primary'>$tjlen</span>%";
  144. if ($tjnum < $totalnum) {
  145. $nurl = "article_description_main.php?totalnum=$totalnum&startdd=".($startdd + $pagesize)."&pagesize=$pagesize&table={$table}&field={$field}&dsize={$dsize}&msize={$msize}&channel={$channel}&dojob={$dojob}";
  146. ShowMsg($tjsta, $nurl, 0, 500);
  147. exit();
  148. } else {
  149. ShowMsg('完成所有任务', 'javascript:;');
  150. exit();
  151. }
  152. }//更新自动分页处理代码结束
  153. }
  154. ?>