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

193 lines
6.5KB

  1. <?php
  2. /**
  3. * 任务操作
  4. *
  5. * @version $Id: task_do.php 1 23:07 2010年7月20日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2020, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require(dirname(__FILE__).'/config.php');
  12. $dopost = (!isset($dopost) ? '' : $dopost);
  13. /******************************
  14. 返回到下一任务的URL
  15. 特殊变量,除非知道作用,否则不能在任务传递中占用
  16. f 临时,仅为了方便网址结构
  17. dopost 当前任务(指向下一个任务), 由用户自行处理或在 nextdo 中自动获得
  18. del 上一次任务删除的变量
  19. morejob ,设定后,表示当前任务需请求多次,会把 dopost 和 nextdo 处理后转为 doposttmp, nextdotmp,然后由用户自行处理
  20. ******************************/
  21. function GetNextUrl($notallowArr = array('dopost', 'f', 'del'))
  22. {
  23. $reurl = "task_do.php?f=0";
  24. foreach($_GET as $k=>$v)
  25. {
  26. if($k=='nextdo')
  27. {
  28. $nextdo = '';
  29. $nextdos = explode(',', $GLOBALS[$k]);
  30. if(isset($nextdos[1]))
  31. {
  32. for($i=1; $i < count($nextdos); $i++)
  33. {
  34. if( trim($nextdos[$i]) == '' ) continue;
  35. $nextdo .= ($nextdo=='' ? $nextdos[$i] : ','.$nextdos[$i]);
  36. }
  37. }
  38. //如果系统有多重任务, 把下一任务和任务列表参数提交给程序处理
  39. if( in_array('morejob', $notallowArr) )
  40. {
  41. $reurl .= "&doposttmp=".$nextdos[0];
  42. if($nextdo != '') $reurl .= "&nextdotmp=$nextdo";
  43. }
  44. else
  45. {
  46. $reurl .= "&dopost=".$nextdos[0];
  47. if($nextdo != '') $reurl .= "&nextdo=$nextdo";
  48. }
  49. }
  50. else if( in_array($k, $notallowArr) )
  51. {
  52. continue;
  53. }
  54. else
  55. {
  56. $reurl .= "&{$k}=".urlencode($GLOBALS[$k]);
  57. }
  58. }
  59. return $reurl;
  60. }
  61. /******************************
  62. //更新上一篇和下一篇
  63. function makeprenext() { }
  64. ******************************/
  65. if($dopost=='makeprenext')
  66. {
  67. require_once(DEDEINC.'/arc.archives.class.php');
  68. $aid = intval($aid);
  69. $preRow = $dsql->GetOne("SELECT id FROM `#@__arctiny` WHERE id<$aid AND arcrank>-1 AND typeid='$typeid' ORDER BY id DESC");
  70. $nextRow = $dsql->GetOne("SELECT id FROM `#@__arctiny` WHERE id>$aid AND arcrank>-1 AND typeid='$typeid' ORDER BY id ASC");
  71. if(is_array($preRow))
  72. {
  73. $envs['aid'] = $preRow['id'];
  74. $arc = new Archives($preRow['id']);
  75. $arc->MakeHtml();
  76. }
  77. if(is_array($nextRow))
  78. {
  79. $envs['aid'] = $nextRow['id'];
  80. $arc = new Archives($nextRow['id']);
  81. $arc->MakeHtml();
  82. }
  83. if( empty($nextdo) )
  84. {
  85. ShowMsg("<b>完成上下篇文档更新任务!完成所有更新任务!</b>", "close::tgtable");
  86. exit();
  87. }
  88. else
  89. {
  90. $jumpurl = GetNextUrl();
  91. ShowMsg("完成下篇文档更新任务! 继续执行其它任务...", $jumpurl,0,500);
  92. exit();
  93. }
  94. }
  95. /******************************
  96. //更新主页的任务
  97. function makeindex() { }
  98. ******************************/
  99. if($dopost=='makeindex')
  100. {
  101. require_once(DEDEINC.'/arc.partview.class.php');
  102. $envs = $_sys_globals = array();
  103. $envs['aid'] = 0;
  104. $pv = new PartView();
  105. $row = $pv->dsql->GetOne('SELECT * FROM `#@__homepageset`');
  106. $templet = str_replace("{style}", $cfg_df_style, $row['templet']);
  107. $homeFile = dirname(__FILE__).'/'.$row['position'];
  108. $homeFile = str_replace("//", "/", str_replace("\\", "/", $homeFile));
  109. $fp = fopen($homeFile, 'w') or die("无法更新网站主页到:$homeFile 位置");
  110. fclose($fp);
  111. $tpl = $cfg_basedir.$cfg_templets_dir.'/'.$templet;
  112. if(!file_exists($tpl))
  113. {
  114. $tpl = $cfg_basedir.$cfg_templets_dir.'/default/index.htm';
  115. if(!file_exists($tpl)) exit("无法找到主页模板:$tpl ");
  116. }
  117. $GLOBALS['_arclistEnv'] = 'index';
  118. $pv->SetTemplet($tpl);
  119. $pv->SaveToHtml($homeFile);
  120. $pv->Close();
  121. if( empty($nextdo) )
  122. {
  123. ShowMsg("<b>完成主页更新任务!完成所有更新任务!</b>", "close::tgtable");
  124. exit();
  125. }
  126. else
  127. {
  128. $jumpurl = GetNextUrl();
  129. ShowMsg("完成主页更新! 现在跳转到其它更新任务...", $jumpurl,0,500);
  130. exit();
  131. }
  132. }
  133. /******************************
  134. //更新所有关连的栏目
  135. function makeparenttype() { }
  136. ******************************/
  137. else if($dopost=='makeparenttype')
  138. {
  139. require_once(DEDEDATA."/cache/inc_catalog_base.inc");
  140. require_once(DEDEINC.'/arc.listview.class.php');
  141. $notallowArr = array('dopost', 'f', 'del', 'curpage', 'morejob');
  142. $jumpurl = GetNextUrl($notallowArr);
  143. if( empty($typeid) )
  144. {
  145. ShowMsg("<b>完成栏目更新任务!完成所有更新任务!</b>", "close::tgtable");
  146. exit();
  147. }
  148. $topids = explode(',', GetTopids($typeid));
  149. if(empty($curpage)) $curpage = 0;
  150. $tid = $topids[$curpage];
  151. if(isset($cfg_Cs[$tid]) && $cfg_Cs[$tid][1]>0)
  152. {
  153. require_once(DEDEINC."/arc.listview.class.php");
  154. $lv = new ListView($tid);
  155. $lv->CountRecord();
  156. $lv->MakeHtml();
  157. $lv->Close();
  158. }
  159. else
  160. {
  161. require_once(DEDEINC."/arc.sglistview.class.php");
  162. $lv = new SgListView($tid);
  163. $lv->CountRecord();
  164. $lv->MakeHtml();
  165. $lv->Close();
  166. }
  167. if($curpage >= count($topids)-1)
  168. {
  169. if( !empty($doposttmp) )
  170. {
  171. $jumpurl = preg_replace("#doposttmp|nextdotmp#", 'del', $jumpurl);
  172. $jumpurl .= "&dopost={$doposttmp}&nextdo={$nextdotmp}";
  173. ShowMsg("完成栏目:{$tid} 更新!<br /><b>完成栏目更新任务,继续执行后续任务...</b>", $jumpurl,0,500);
  174. exit();
  175. }
  176. else
  177. {
  178. ShowMsg("完成栏目:{$tid} 更新!<br /><b>完成栏目更新任务,完成所有更新任务!</b>", "close::tgtable");
  179. exit();
  180. }
  181. }
  182. else
  183. {
  184. $curpage++;
  185. $jumpurl .= "&curpage={$curpage}&dopost=makeparenttype";
  186. ShowMsg("完成栏目:{$tid} 更新,继续更新其它栏目...", $jumpurl,0,500);
  187. exit();
  188. }
  189. }