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

  1. <?php
  2. /**
  3. * 生成所有页面
  4. *
  5. * @version $Id: makehtml_all.php 1 8:48 2010年7月13日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2020, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__) . "/config.php");
  12. require_once(DEDEINC . "/channelunit.func.php");
  13. $action = (empty($action) ? '' : $action);
  14. if ($action == '') {
  15. require_once(DEDEADMIN . "/templets/makehtml_all.htm");
  16. exit();
  17. } else if ($action == 'make') {
  18. //step = 1 更新主页、step = 2 更新内容、step = 3 更新栏目
  19. if (empty($step)) $step = 1;
  20. //更新文档前优化数据
  21. /*-------------------
  22. function _1_OptimizeData1()
  23. ---------------------*/
  24. if ($step == 1) {
  25. $starttime = GetMkTime($starttime);
  26. $mkvalue = ($uptype == 'time' ? $starttime : $startid);
  27. OptimizeData($dsql);
  28. ShowMsg("完成数据优化,现在开始更新文档!", "makehtml_all.php?action=make&step=2&uptype=$uptype&mkvalue=$mkvalue");
  29. exit();
  30. }
  31. //更新文档
  32. /*-------------------
  33. function _2_MakeArchives()
  34. ---------------------*/ else if ($step == 2) {
  35. include_once(DEDEADMIN . "/makehtml_archives_action.php");
  36. exit();
  37. }
  38. //更新主页
  39. /*-------------------------
  40. function _3_MakeHomePage()
  41. -------------------*/
  42. if ($step == 3) {
  43. include_once(DEDEINC . "/arc.partview.class.php");
  44. $pv = new PartView();
  45. $row = $pv->dsql->GetOne("SELECT * FROM `#@__homepageset` ");
  46. $templet = str_replace("{style}", $cfg_df_style, $row['templet']);
  47. $homeFile = DEDEADMIN . '/' . $row['position'];
  48. $homeFile = str_replace("\\", '/', $homeFile);
  49. $homeFile = preg_replace("#\/{1,}#", '/', $homeFile);
  50. if ($row['showmod'] == 1) {
  51. $pv->SetTemplet($cfg_basedir . $cfg_templets_dir . '/' . $templet);
  52. $pv->SaveToHtml($homeFile);
  53. $pv->Close();
  54. } else {
  55. if (file_exists($homeFile)) @unlink($homeFile);
  56. }
  57. ShowMsg("完成更新所有文档,现在开始更新栏目页!", "makehtml_all.php?action=make&step=4&uptype=$uptype&mkvalue=$mkvalue");
  58. exit();
  59. }
  60. //更新栏目
  61. /*-------------------
  62. function _4_MakeCatalog()
  63. --------------------*/ else if ($step == 4) {
  64. $mkvalue = intval($mkvalue);
  65. $typeidsok = $typeids = array();
  66. $adminID = $cuserLogin->getUserID();
  67. $mkcachefile = DEDEDATA . "/mkall_cache_{$adminID}.php";
  68. if ($uptype == 'all' || empty($mkvalue)) {
  69. ShowMsg("不需要进行初处理,现更新所有栏目!", "makehtml_list_action.php?gotype=mkallct");
  70. exit();
  71. } else {
  72. if ($uptype == 'time') {
  73. $query = "SELECT DISTINCT typeid From `#@__arctiny` WHERE senddate >=" . GetMkTime($mkvalue) . " AND arcrank>-1";
  74. } else {
  75. $query = "SELECT DISTINCT typeid From `#@__arctiny` WHERE id>=$mkvalue AND arcrank>-1";
  76. }
  77. $dsql->SetQuery($query);
  78. $dsql->Execute();
  79. while ($row = $dsql->GetArray()) {
  80. $typeids[$row['typeid']] = 1;
  81. }
  82. foreach ($typeids as $k => $v) {
  83. $vs = array();
  84. $vs = GetParentIds($k);
  85. if (!isset($typeidsok[$k])) {
  86. $typeidsok[$k] = 1;
  87. }
  88. foreach ($vs as $k => $v) {
  89. if (!isset($typeidsok[$v])) {
  90. $typeidsok[$v] = 1;
  91. }
  92. }
  93. }
  94. }
  95. $fp = fopen($mkcachefile, 'w') or die("无法写入缓存文件:{$mkcachefile} 所以无法更新栏目!");
  96. if (count($typeidsok) > 0) {
  97. fwrite($fp, "<" . "?php\r\n");
  98. $i = -1;
  99. foreach ($typeidsok as $k => $t) {
  100. if ($k != '') {
  101. $i++;
  102. fwrite($fp, "\$idArray[$i]={$k};\r\n");
  103. }
  104. }
  105. fwrite($fp, "?" . ">");
  106. fclose($fp);
  107. ShowMsg("完成栏目缓存处理,现转向更新栏目!", "makehtml_list_action.php?gotype=mkall");
  108. exit();
  109. } else {
  110. fclose($fp);
  111. ShowMsg("没有可更新的栏目,现在作最后数据优化!", "makehtml_all.php?action=make&step=10");
  112. exit();
  113. }
  114. }
  115. //成功状态
  116. /*-------------------
  117. function _10_MakeAllOK()
  118. --------------------*/ else if ($step == 10) {
  119. $adminID = $cuserLogin->getUserID();
  120. $mkcachefile = DEDEDATA . "/mkall_cache_{$adminID}.php";
  121. @unlink($mkcachefile);
  122. OptimizeData($dsql);
  123. ShowMsg("完成所有文件的更新!", "javascript:;");
  124. exit();
  125. } //make step
  126. } //action=='make'
  127. /**
  128. * 优化数据
  129. *
  130. * @access public
  131. * @param object $dsql 数据库对象
  132. * @return void
  133. */
  134. function OptimizeData($dsql)
  135. {
  136. global $cfg_dbprefix;
  137. $tptables = array("{$cfg_dbprefix}archives", "{$cfg_dbprefix}arctiny");
  138. $dsql->SetQuery("SELECT maintable,addtable FROM `#@__channeltype` ");
  139. $dsql->Execute();
  140. while ($row = $dsql->GetObject()) {
  141. $addtable = str_replace('#@__', $cfg_dbprefix, $row->addtable);
  142. if ($addtable != '' && !in_array($addtable, $tptables)) $tptables[] = $addtable;
  143. }
  144. $tptable = '';
  145. foreach ($tptables as $t) $tptable .= ($tptable == '' ? "`{$t}`" : ",`{$t}`");
  146. $dsql->ExecuteNoneQuery(" OPTIMIZE TABLE $tptable; ");
  147. }