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

287 lines
9.8KB

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