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

288 lines
9.9KB

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