国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

159 líneas
5.1KB

  1. <?php
  2. /**
  3. * 生成文档操作
  4. *
  5. * @version $Id: makehtml_archives_action.php 1 9:11 2010年7月19日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_MakeHtml');
  13. require_once(DEDEINC."/arc.archives.class.php");
  14. $est1 = ExecTime();
  15. $startid = (empty($startid) ? -1 : $startid);
  16. $endid = (empty($endid) ? 0 : $endid);
  17. $startdd = (empty($startdd) ? 0 : $startdd);
  18. $pagesize = (empty($pagesize) ? 20 : $pagesize);
  19. $totalnum = (empty($totalnum) ? 0 : $totalnum);
  20. $typeid = (empty($typeid) ? 0 : $typeid);
  21. $seltime = (empty($seltime) ? 0 : $seltime);
  22. $stime = (empty($stime) ? '' : $stime );
  23. $etime = (empty($etime) ? '' : $etime);
  24. $sstime = (empty($sstime) ? 0 : $sstime);
  25. $mkvalue = (empty($mkvalue) ? 0 : $mkvalue);
  26. $isremote = (empty($isremote)? 0 : $isremote);
  27. $serviterm = empty($serviterm)? "" : $serviterm;
  28. //一键更新传递的参数
  29. if(!empty($uptype))
  30. {
  31. if($uptype!='time') $startid = $mkvalue;
  32. else $t1 = $mkvalue;
  33. }
  34. else
  35. {
  36. $uptype = '';
  37. }
  38. //获取条件
  39. $idsql = '';
  40. $gwhere = ($startid==-1 ? " WHERE arcrank=0 " : " WHERE id>=$startid AND arcrank=0 ");
  41. if($endid > $startid && $startid > 0) $gwhere .= " AND id <= $endid ";
  42. if($typeid!=0) {
  43. $ids = GetSonIds($typeid);
  44. $gwhere .= " AND typeid in($ids) ";
  45. }
  46. if($idsql=='') $idsql = $gwhere;
  47. if($seltime==1)
  48. {
  49. $t1 = GetMkTime($stime);
  50. $t2 = GetMkTime($etime);
  51. $idsql .= " And (senddate >= $t1 And senddate <= $t2) ";
  52. }
  53. else if(isset($t1) && is_numeric($t1))
  54. {
  55. $idsql .= " And senddate >= $t1 ";
  56. }
  57. //统计记录总数
  58. if($totalnum==0)
  59. {
  60. $row = $dsql->GetOne("SELECT COUNT(*) AS dd FROM `#@__arctiny` $idsql");
  61. $totalnum = $row['dd'];
  62. //清空缓存
  63. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arccache` ");
  64. }
  65. //获取记录,并生成HTML
  66. if($totalnum > $startdd+$pagesize)
  67. {
  68. $limitSql = " LIMIT $startdd,$pagesize";
  69. }
  70. else {
  71. $limitSql = " LIMIT $startdd,".($totalnum - $startdd);
  72. }
  73. $tjnum = $startdd;
  74. if(empty($sstime)) $sstime = time();
  75. //如果生成数量大于500,并且没选栏目,按栏目排序生成
  76. if($totalnum > 500 && empty($typeid))
  77. {
  78. $dsql->Execute('out',"SELECT id FROM `#@__arctiny` $idsql ORDER BY typeid ASC $limitSql");
  79. } else {
  80. $dsql->Execute('out',"SELECT id FROM `#@__arctiny` $idsql $limitSql");
  81. }
  82. if($cfg_remote_site=='Y' && $isremote=="1")
  83. {
  84. if($serviterm!="")
  85. {
  86. list($servurl, $servuser, $servpwd) = explode(',', $serviterm);
  87. $config = array( 'hostname' => $servurl, 'username' => $servuser,
  88. 'password' => $servpwd,'debug' => 'TRUE');
  89. } else {
  90. $config=array();
  91. }
  92. if(!$ftp->connect($config)) exit('Error:None FTP Connection!');
  93. }
  94. while($row=$dsql->GetObject('out'))
  95. {
  96. $tjnum++;
  97. $id = $row->id;
  98. $ac = new Archives($id);
  99. $rurl = $ac->MakeHtml($isremote);
  100. }
  101. $t2 = ExecTime();
  102. $t2 = ($t2 - $est1);
  103. $ttime = time() - $sstime;
  104. $ttime = number_format(($ttime / 60),2);
  105. //返回提示信息
  106. $tjlen = $totalnum>0 ? ceil( ($tjnum/$totalnum) * 100 ) : 100;
  107. $dvlen = $tjlen * 2;
  108. $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>";
  109. if($cfg_remote_site=='Y' && $isremote=="1") $tjsta .= "<br/><font color='red'>您已开启远程发布功能,生成速度会比较慢,请您耐心等待..</font>";
  110. $tjsta .= "<br/>本次用时:".number_format($t2,2).",总用时:$ttime 分钟,到达位置:".($startdd+$pagesize)."<br/>完成创建文件总数的:$tjlen %,继续执行任务...";
  111. //速度测试
  112. /*
  113. if($startdd > 1000)
  114. {
  115. ShowMsg("生成文件:1000 总用时:{$ttime} 分钟", "javascript:;");
  116. exit();
  117. }
  118. */
  119. if($tjnum < $totalnum)
  120. {
  121. $nurl = "makehtml_archives_action.php?endid=$endid&startid=$startid&typeid=$typeid";
  122. $nurl .= "&totalnum=$totalnum&startdd=".($startdd+$pagesize)."&pagesize=$pagesize";
  123. $nurl .= "&seltime=$seltime&sstime=$sstime&stime=".urlencode($stime)."&etime=".urlencode($etime)."&uptype=$uptype&mkvalue=$mkvalue&isremote={$isremote}&serviterm={$serviterm}";
  124. ShowMsg($tjsta,$nurl,0,100);
  125. exit();
  126. }
  127. else
  128. {
  129. if($typeid!='')
  130. {
  131. ShowMsg("生成文件:$totalnum 总用时:{$ttime} 分钟,现转向当前栏目更新&gt;&gt;","makehtml_list_action.php?typeid=$typeid&uptype=all&maxpagesize=50&upnext=1&isremote={$isremote}&serviterm={$serviterm}");
  132. }
  133. else
  134. {
  135. if($uptype=='')
  136. {
  137. ShowMsg("完成所有创建任务!,生成文件:$totalnum 总用时:{$ttime} 分钟。","javascript:;");
  138. } else {
  139. ShowMsg("完成文档HTML更新任务,现在开始进行主页更新...","makehtml_all.php?action=make&step=3&uptype=$uptype&mkvalue=$mkvalue");
  140. }
  141. }
  142. }