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

202 line
6.7KB

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