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