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

243 lines
9.7KB

  1. <?php
  2. /**
  3. * 采集操作
  4. *
  5. * @version $Id: co_do.php 1 14:31 2010年7月12日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 . "/oxwindow.class.php");
  13. if (!isset($nid)) $nid = 0;
  14. $ENV_GOBACK_URL = empty($_COOKIE["ENV_GOBACK_URL"]) ? "co_url.php" : $_COOKIE["ENV_GOBACK_URL"];
  15. //删除节点
  16. //删除节点将删除所有旧的网址索引
  17. /*
  18. function co_delete()
  19. */
  20. if ($dopost == "delete") {
  21. CheckPurview('co_Del');
  22. $nid = intval($nid);
  23. $dsql->ExecuteNoneQuery("DELETE FROM `#@__co_htmls` WHERE nid='$nid'");
  24. $dsql->ExecuteNoneQuery("DELETE FROM `#@__co_note` WHERE nid='$nid'");
  25. $dsql->ExecuteNoneQuery("DELETE FROM `#@__co_urls` WHERE nid='$nid'");
  26. ShowMsg("成功删除一个节点!", "co_main.php");
  27. exit();
  28. }
  29. //清空采集内容
  30. //清空采集内容时仍会保留旧的网址索引,在监控模式下始终采集新的内容
  31. /*
  32. function url_clear()
  33. */ else if ($dopost == "clear") {
  34. CheckPurview('co_Del');
  35. if (!isset($ids)) $ids = '';
  36. if (empty($ids)) {
  37. if (!empty($nid)) {
  38. $nid = intval($nid);
  39. $dsql->ExecuteNoneQuery("DELETE FROM `#@__co_htmls` WHERE nid='$nid'");
  40. }
  41. ShowMsg("成功清空一个节点采集的内容!", "co_main.php");
  42. exit();
  43. } else {
  44. if (!empty($clshash)) {
  45. $dsql->SetQuery("SELECT nid,url FROM `#@__co_htmls` WHERE aid IN($ids) ");
  46. $dsql->Execute();
  47. while ($arr = $dsql->GetArray()) {
  48. $nhash = md5($arr['url']);
  49. $nid = $row['nid'];
  50. $dsql->ExecuteNoneQuery("DELETE FROM `#@__co_urls ` WHERE nid='$nid' AND hash='$nhash' ");
  51. }
  52. }
  53. $dsql->ExecuteNoneQuery("DELETE FROM `#@__co_htmls` WHERE aid IN($ids) ");
  54. ShowMsg("成功删除指定的网址内容!", $ENV_GOBACK_URL);
  55. exit();
  56. }
  57. } else if ($dopost == "clearct") {
  58. CheckPurview('co_Del');
  59. if (!empty($ids)) {
  60. $dsql->ExecuteNoneQuery("UPDATE `#@__co_htmls` SET isdown=0,result='' WHERE aid IN($ids) ");
  61. }
  62. ShowMsg("成功清除所有内容!", $ENV_GOBACK_URL);
  63. exit();
  64. }
  65. /*
  66. function url_clearall()
  67. */ else if ($dopost == "clearall") {
  68. CheckPurview('co_Del');
  69. $dsql->ExecuteNoneQuery("DELETE FROM `#@__co_htmls` ");
  70. ShowMsg("成功清空所有采集的临时内容!", "co_main.php");
  71. exit();
  72. }
  73. //内容替换
  74. /*
  75. function co_replace() { }
  76. */ else if ($dopost == "replace") {
  77. //if()
  78. //$nid $aid $regtype $fdstring $rpstring
  79. $rpstring = trim($rpstring);
  80. if ($regtype == 'string') {
  81. $dsql->ExecuteNoneQuery("UPDATE `#@__co_htmls` SET `result`=REPLACE(`result`,'$fdstring','$rpstring') WHERE nid='$nid' ");
  82. } else {
  83. //返回一条测试结果,并要求用户确认操作
  84. if (empty($rpok)) {
  85. $fdstring = stripslashes($fdstring);
  86. $rpstring = stripslashes($rpstring);
  87. $hiddenrpvalue = "<textarea name='fdstring' style='display:none'>{$fdstring}</textarea>\r\n<textarea name='rpstring' style='display:none'>{$rpstring}</textarea>\r\n";
  88. $fdstring = str_replace("\\/", "#ASZZ#", $fdstring);
  89. $fdstring = str_replace('/', "\\/", $fdstring);
  90. $fdstring = str_replace('#ASZZ#', "\\/", $fdstring);
  91. $result = $rs = stripslashes($rs);
  92. if ($fdstring != '') {
  93. $result = trim(preg_replace("/$fdstring/isU", $rpstring, $rs));
  94. }
  95. $wintitle = "采集管理-内容替换";
  96. $wecome_info = "<a href='co_main.php'>采集管理</a>::内容替换";
  97. $win = new OxWindow();
  98. $win->Init("co_do.php", "js/blank.js", "POST");
  99. $win->AddHidden('dopost', $dopost);
  100. $win->AddHidden('nid', $nid);
  101. $win->AddHidden('regtype', 'regex');
  102. $win->AddHidden('aid', $aid);
  103. $win->AddHidden('rpok', 'ok');
  104. $win->AddTitle("内容替换操作确认:如果下面结果正确,点击确认,系统将替换当前节点所有内容!{$hiddenrpvalue}");
  105. $win->AddItem("原来的内容:", "<textarea name='rs' style='width:90%;height:250px'>{$rs}</textarea>\r\n");
  106. $win->AddItem("按规则替换后的内容:", "<textarea name='okrs' style='width:90%;height:250px'>{$result}</textarea>\r\n");
  107. $winform = $win->GetWindow("ok");
  108. $win->Display();
  109. exit();
  110. } else {
  111. if ($fdstring != '') {
  112. $dsql->SetQuery("SELECT `aid`,`result` FROM `#@__co_htmls` WHERE nid='$nid' ");
  113. $dsql->Execute();
  114. while ($row = $dsql->GetArray()) {
  115. $fdstring = stripslashes($fdstring);
  116. $rpstring = stripslashes($rpstring);
  117. $fdstring = str_replace("\\/", "#ASZZ#", $fdstring);
  118. $fdstring = str_replace('/', "\\/", $fdstring);
  119. $fdstring = str_replace('#ASZZ#', "\\/", $fdstring);
  120. $result = trim(preg_replace("/$fdstring/isU", $rpstring, $row['result']));
  121. $result = addslashes($result);
  122. $dsql->ExecuteNoneQuery("UPDATE `#@__co_htmls` SET `result`='$result' WHERE aid='{$row['aid']}' ");
  123. }
  124. }
  125. }
  126. }
  127. ShowMsg("成功替换当前节点所有数据!", "co_view.php?aid=$aid");
  128. exit();
  129. }
  130. //复制节点
  131. /*
  132. function co_copy()
  133. */ else if ($dopost == "copy") {
  134. CheckPurview('co_AddNote');
  135. if (empty($mynotename)) {
  136. $wintitle = "采集管理-复制节点";
  137. $wecome_info = "<a href='co_main.php'>采集管理</a>::复制节点";
  138. $win = new OxWindow();
  139. $win->Init("co_do.php", "js/blank.js", "POST");
  140. $win->AddHidden("dopost", $dopost);
  141. $win->AddHidden("nid", $nid);
  142. $win->AddTitle("请输入新节点名称:");
  143. $win->AddItem("新节点名称:", "<input type='text' name='mynotename' value='' size='30' />");
  144. $winform = $win->GetWindow("ok");
  145. $win->Display();
  146. exit();
  147. }
  148. $row = $dsql->GetOne("SELECT * FROM `#@__co_note` WHERE nid='$nid'");
  149. foreach ($row as $k => $v) {
  150. if (!isset($$k)) {
  151. $$k = addslashes($v);
  152. }
  153. }
  154. $usemore = (empty($usemore) ? '0' : $usemore);
  155. $inQuery = " INSERT INTO `#@__co_note`(`channelid`,`notename`,`sourcelang`,`uptime`,`cotime`,`pnum`,`isok`,`listconfig`,`itemconfig`,`usemore`)
  156. VALUES ('$channelid','$mynotename','$sourcelang','" . time() . "','0','0','0','$listconfig','$itemconfig','$usemore'); ";
  157. $dsql->ExecuteNoneQuery($inQuery);
  158. ShowMsg("成功复制一个节点!", $ENV_GOBACK_URL);
  159. exit();
  160. }
  161. //测试Rss源是否正确
  162. /*-----------------------
  163. function co_testrss()
  164. -------------------------*/ else if ($dopost == "testrss") {
  165. CheckPurview('co_AddNote');
  166. $msg = '';
  167. if ($rssurl == '') {
  168. $msg = '你没有指定RSS地址!';
  169. } else {
  170. include(DEDEINC . "/dedecollection.func.php");
  171. $arr = GetRssLinks($rssurl);
  172. $msg = "从 {$rssurl} 发现的网址:<br />";
  173. $i = 1;
  174. if (is_array($arr)) {
  175. foreach ($arr as $ar) {
  176. $msg .= "<hr size='1' />\r\n";
  177. $msg .= "link: {$ar['link']}<br />title: {$ar['title']}<br />image: {$ar['image']}\r\n";
  178. $i++;
  179. }
  180. }
  181. }
  182. $wintitle = "采集管理-测试";
  183. $wecome_info = "<a href='co_main.php'>采集管理</a>::RSS地址测试";
  184. $win = new OxWindow();
  185. $win->AddMsgItem($msg);
  186. $winform = $win->GetWindow("hand");
  187. $win->Display();
  188. exit();
  189. }
  190. //测试批量网址是否正确
  191. /*-----------------------
  192. function co_testregx()
  193. -------------------------*/ else if ($dopost == "testregx") {
  194. CheckPurview('co_AddNote');
  195. $msg = '';
  196. if ($regxurl == '') {
  197. $msg = '你没有指定匹配的网址!';
  198. } else {
  199. include(DEDEINC . "/dedecollection.func.php");
  200. $msg = "匹配的网址:<br />";
  201. $lists = GetUrlFromListRule($regxurl, '', $startid, $endid, $addv);
  202. foreach ($lists as $surl) {
  203. $msg .= $surl[0] . "<br />\r\n";
  204. }
  205. }
  206. $wintitle = "采集管理-测试匹配规则";
  207. $wecome_info = "<a href='co_main.php'>采集管理</a>::测试匹配列表网址规则";
  208. $win = new OxWindow();
  209. $win->AddMsgItem($msg);
  210. $winform = $win->GetWindow("hand");
  211. $win->Display();
  212. exit();
  213. }
  214. //采集未下载内容
  215. /*--------------------
  216. function co_all()
  217. ---------------------*/ else if ($dopost == "coall") {
  218. CheckPurview('co_PlayNote');
  219. $mrow = $dsql->GetOne("SELECT COUNT(*) AS dd FROM `#@__co_htmls` ");
  220. $totalnum = $mrow['dd'];
  221. if ($totalnum == 0) {
  222. ShowMsg("没发现可下载的内容!", "-1");
  223. exit();
  224. }
  225. $wintitle = "采集管理-采集未下载内容";
  226. $wecome_info = "<a href='co_main.php'>采集管理</a>::采集未下载内容";
  227. $win = new OxWindow();
  228. $win->Init("co_gather_start_action.php", "js/blank.js", "GET");
  229. $win->AddHidden('startdd', '0');
  230. $win->AddHidden('pagesize', '5');
  231. $win->AddHidden('sptime', '0');
  232. $win->AddHidden('nid', '0');
  233. $win->AddHidden('totalnum', $totalnum);
  234. $win->AddMsgItem("本操作会检测并下载‘<a href='co_url.php'><u>临时内容</u></a>’中所有未下载的内容,是否继续?");
  235. $winform = $win->GetWindow("ok");
  236. $win->Display();
  237. exit();
  238. }