 <?php
require_once(dirname(__FILE__)."/admin_inc.php");
/*******************************************************************************************
' Software name: DJCMS Content Management System
' Version:3.0
' Web: http://www.djcms.net
' Author: 心情(qq:1130731)
' Copyright (C) 2009-2010 DJCMS官方 版权所有
' 法律申明：DJCMS程序所有代码100%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任
'*******************************************************************************************/
checkPower();
@error_reporting(0);
@set_time_limit(0);
@session_start();
$action = getForm("action", "get");
switch ($action) {
	case "wizard2save":wizard2save();break;
	case "ghost":ghost();break;
	case "remove":removeesfile();break;
	case "delall" : delAll();break;
	case "exec":Heades();execesfile();Footer();break;
	case "proxy" : proxy();break;
	case "importtxt":Heades();importtxt();Footer();break;
	case "exporttxt":Heades();exporttxt();Footer();break;
	case "savenews":savenews();break;
	case "import":Heades();import();Footer();break;
	case "editVideo":Heades();editVideo();Footer();break;
	case "tempdatabase" : Heades();tempdatabase();Footer();break;
	case "delallTempData":delallTempData();break;
	case "delTempData":delTempData();break;
	case "customerdelcls":customerdelcls();break;
	case "customerdelallcls":customerdelallcls();break;
	case "customersavecls":customersavecls();break;
	case "customercls":Heades();customercls();Footer();break;
	case "customernewcls":customernewcls();break;
	case "saveeditoradd":saveeditoradd();break;
	case "filtersban":filtersban();break;
	case "filtersdel":filtersdel();break;
	case "filtersdelall":filtersdelall();break;
	case "filters":Heades();filtersDictionary();Footer();break;
	case "filtersadd":
	case "filtersedit":Heades();EditOrAdd();Footer();break;
	case "wizard":
	case "edit":Heades();wizard();Footer();break;
	default : Heades();itemlist();Footer();break;
}

function proxy() {
	$txt = GetHttpTextFile(getForm("url", "get"),getForm("charset", "get"));
	echo ifthen(getForm("result", "get") == "false", "OK", $txt);
}

function importtxt(){
	$base64=getForm("base64","both");$referer=getForm("referer","both");
	if (getForm("do","both") == "save") {
		$importrules = explode(':',$base64);
		$importrule = $importrules[1];
		$arr = unserialize(base64_decode($importrule));
		if (!is_array($arr)) { die("没找到记录");}
		$feedarr = array(
		    'itemname' => $arr[itemname],
			'siteurl' => $arr[siteurl],
			'charset' => $arr[charset],
			'playfrom' => $arr[playfrom],
			'enable' => $arr[enable],
			'intoa' => $arr[intoa],
			'autocls' => $arr[autocls],
			'classid' => $arr[classid],
			'isupdate' => $arr[isupdate],
			'getherday' => $arr[getherday],
			'inithit' => $arr[inithit],
			'pageset' => $arr[pageset],
			'pageurl0' => $arr[pageurl0],
			'pageurl1' => $arr[pageurl1],
			'pageurl2' => $arr[pageurl2],
			'istart' => $arr[istart],
			'iend' => $arr[iend],
			'reverse' => $arr[reverse],
			'removecode' => $arr[removecode],
			'des' => new_addslashes($arr[des]),
			'publi' => 1,
			'CollectTime' => $arr[CollectTime],
	    );
		if(DB::insert('collect',$feedarr)){
		    selectMsg("保存成功，是否自动跳转到预览界面?", $referer, "admin_collectnews.php");
		} else {
			die("请选择需要设置专题的数据");
		}
	}
?>
<form name="wizardform" id="wizardform" method="post" action="?action=importtxt&do=save" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="referer" value="<?=getRefer()?>" />
<table class="tb">
	<thead>
		<tr class="thead"><th>&nbsp;导入采集脚本： <a href="admin_collectnews.php">管理采集规则</a> | <a href="?action=wizard">添加采集规则</a> | <a href="?action=importtxt">导入采集规则</a></span></th></tr>
	</thead>
	<tbody>
		<tr>
			<td><textarea name="base64" cols="100" rows="20" style="height:400px;font-family:Fixedsys"><?=$base64?></textarea></td>
		</tr>
		<tr>
			<td><input type="submit" class="btn" value="保  存"/>&nbsp;&nbsp;<input type="button" class="btn" name="back" value="管理采集规则" onClick="location.href='?childdir=';" /></td>
		</tr>
	</tbody>
</table>
</form>
<?php
}

function exporttxt(){
	$id = intval(getForm("id","get"));
	$vrow = DB::fetch_first("SELECT itemname,siteurl,charset,playfrom,enable,intoa,autocls,classid,isupdate,getherday,inithit,pageset,pageurl0,pageurl1,pageurl2,istart,iend,reverse,removecode,des,CollectTime FROM ".DB::table('collect')." WHERE publi=1 AND id='$id'");
	if (!is_array($vrow)) { die("没找到记录");}
	$export = serialize($vrow);
	$txt = "BASE64:".base64_encode($export).":END";
	unset($rule);
?>
<table class="tb">
	<thead>
		<tr class="thead"><th>&nbsp;导出采集脚本： <a href="admin_collectnews.php">管理采集规则</a> | <a href="?action=wizard">添加采集规则</a> | <a href="?action=importtxt">导入采集规则</a></th></tr>
	</thead>
	<tbody>
		<tr>
			<td><textarea cols="100" rows="20" style="height:400px;font-family:Fixedsys" readonly><?=$txt?></textarea></td>
		</tr>
	</tbody>
</table>
<?php
}

function Heades() {
	global $menuList;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>DjCMS智能采集工具</title>
<link href="imgs/admin.css" rel="stylesheet" type="text/css" />
<script src="../js/common.js" type="text/javascript"></script>
<script src="imgs/main.js" type="text/javascript"></script>
<script>if(parent.$('admincpnav')) parent.$('admincpnav').innerHTML='后台首页&nbsp;&raquo;&nbsp;<?=$menuList[6][0]?>&nbsp;&raquo;&nbsp;智能采集工具';</script>
<style type="text/css">
input{height:12px;}
.txt{width:250px;}
.tb2 td{padding:2px 5px 2px 5px;height:25px}
.tb2 .thc{text-align:center;line-height:30px; background-color: #F5F7F8;font-size:18px;font-weight:bold;color:#000}
.tb2 .thr{text-align:center;height:20px}
.label{padding:0;width:150px;text-align:right;border-right:1px solid #DEEFFA;}
.btn{height:22px}
.red{color:red}
.blue{color:blue}
</style>
<script type="text/javascript">
function show(){
	var arg=arguments;
	for(var i=0;i<arg.length;i++){
		$(arg[i]).style.display="";
	}
}

function hide(){
	var arg=arguments;
	for(var i=0;i<arg.length;i++){
		$(arg[i]).style.display="none";
	}
}
</script>
</head>
<body bgcolor="#F7FBFF">
<div class="container" id="cpcontainer">
<?php
}

function Footer(){
	global $t1;
?></div>
<div align=center><?php echo getRunTime($t1);?></div>
<div align=center>Copyright 2005-2010 All rights reserved. <a target="_blank" href="http://www.djcms.net/">djCms3.0</a></div>
</body>
<iframe frameborder="0" scrolling="no" height="0" width="0" name="hiddensubmit" id="hiddensubmit" src="about:blank"></iframe>
</html>
<?php
}

function wizard2save() {
	$id = getForm("id","post");
	$removecode=getForm("removecode","post");
	$removecode=implode('|', is_array($removecode) ? $removecode : array($removecode));
	$darr = array(
	'listA' => getForm("listA","post"),
	'listB' => getForm("listB","post"),
	'mlinkA' => getForm("mlinkA","post"),
	'mlinkB' => getForm("mlinkB","post"),
	'isspecialmlink' => getForm("isspecialmlink","post"),
	'mlinkRF' => getForm("mlinkRF","post"),
	'mlinkRR' => getForm("mlinkRR","post"),
	'nameA' => getForm("nameA","post"),
	'nameB' => getForm("nameB","post"),
	'picvar' => getForm("picvar","post"),
	'splay' => getForm("splay","post"),
	'plistA' => getForm("plistA","post"),
	'plistB' => getForm("plistB","post"),
	'plinkA' => getForm("plinkA","post"),
	'plinkB' => getForm("plinkB","post"),
	'isspecial' => getForm("isspecial","post"),
	'linkRF' => getForm("linkRF","post"),
	'linkRR' => getForm("linkRR","post"),
	);
	if (isExistStr($fields,"pic")){ 
	    $darr['picA'] = getForm("picA","post");
		$darr['picB'] = getForm("picB","post");
	} else {
		$darr['picA'] = '';
		$darr['picB'] = '';
	}
	if (isExistStr($fields,"cls")){ 
	    $darr['clsA'] = getForm("clsA","post");
		$darr['clsB'] = getForm("clsB","post");
	} else {
		$darr['clsA'] = '';
		$darr['clsB'] = '';
	}
	if (isExistStr($fields,"author")){ 
	    $darr['authorA'] = getForm("authorA","post");
		$darr['authorB'] = getForm("authorB","post");
	} else {
		$darr['authorA'] = '';
		$darr['authorB'] = '';
	}
	if (isExistStr($fields,"from")){ 
	    $darr['fromrA'] = getForm("fromA","post");
		$darr['fromB'] = getForm("fromB","post");
	} else {
		$darr['fromA'] = '';
		$darr['fromB'] = '';
	}
	if (isExistStr($fields,"outline")){ 
	    $darr['outlineA'] = getForm("outlineA","post");
		$darr['outlineB'] = getForm("outlineB","post");
	} else {
		$darr['outlineA'] = '';
		$darr['outlineB'] = '';
	}
	if (isExistStr($fields,"keys")){ 
	    $darr['keysA'] = getForm("keysA","post");
		$darr['keysB'] = getForm("keysB","post");
	} else {
		$darr['keysA'] = '';
		$darr['keysB'] = '';
	}
	if (isExistStr($fields,"des")){ 
	    $darr['desA'] = getForm("desA","post");
		$darr['desB'] = getForm("desB","post");
	} else {
		$darr['desA'] = '';
		$darr['desB'] = '';
	}
	if (isExistStr($fields,"date")){ 
	    $darr['dateA'] = getForm("dateA","post");
		$darr['dateB'] = getForm("dateB","post");
	} else {
		$darr['dateA'] = '';
		$darr['dateB'] = '';
	}
	$darr = base64_encode(serialize($darr));
	$feedarr = array(
	'itemname' => getForm("itemname","post"),
	'siteurl' => getForm("siteurl","post"),
	'charset' => getForm("charset","post"),
	'playfrom' => getForm("playfrom","post"),
	'enable' => getForm("enable","post"),
	'intoa' => getForm("intoa","post"),
	'autocls' => getForm("autocls","post"),
	'classid' => getForm("classid","post"),
	'isupdate' => getForm("isupdate","post"),
	'getherday' => getForm("getherday","post"),
	'inithit' => getForm("inithit","post"),
	'pageset' => getForm("pageset","post"),
	'pageurl0' => getForm("pageurl0","post"),
	'pageurl1' => getForm("pageurl1","post"),
	'pageurl2' => getForm("pageurl2","post"),
	'istart' => getForm("istart","post"),
	'iend' => getForm("iend","post"),
	'reverse' => getForm("reverse","post"),
	'removecode' => $removecode,
	'des' => $darr,
	'publi' => 1,
	'CollectTime' => time(),
	);
	if ($id) {
	    DB::update('collect', $feedarr, array('publi' => 1,'id' => $id));
	    alertMsg("修改成功","admin_collectnews.php?action=main");
	} else {
		DB::insert('collect', $feedarr);
	    alertMsg("保存成功","admin_collectnews.php?action=main");
	}
}

function wizard() {
	global $action,$menuList;
	$id = intval(getForm("id","get"));
	if ($action == "edit") {
	    $row = DB::fetch_first("select * from ".DB::table('collect')." where publi=1 AND id=$id");
		foreach ($row as $k => $v) {
		    if (!isset($$k)) {
			    $$k = stripslashes($v);
		    }
	    }
		$arr = unserialize(base64_decode($des));
		foreach ($arr as $l => $j) {
		    if (!isset($$l)) {
			    $$l = stripslashes($j);
		    }
	    }
	} else {
	    global $itemname,$siteurl,$charset,$playfrom,$enable,$intoa,$autocls,$classid,$isupdate,$getherday,$inithit,$pageset,$pageurl0,$pageurl1,$pageurl2,$istart,$iend,$reverse,$removecode,$listA,$listB,$mlinkA,$mlinkB,$picmode,$mdataA,$mdataB,$nameA,$nameB,$actorA,$actorB,$clsA,$clsB,$dateA,$dateB,$yearA,$yearB,$directorA,$directorB,$langA,$langB,$keysA,$keysB,$areaA,$areaB,$stateA,$stateB,$noteA,$noteB,$picA,$picB,$picvar,$desA,$desB,$splay,$plistA,$plistB,$playgetsrc,$playlinkA,$playlinkB,$isspecial,$linkRF,$linkRR,$msrcA,$msrcB,$getpart,$partA,$partB,$savefiles;
	}
?>
<table class="tb">
	<thead>
		<tr class="thead"><th>&nbsp;操作选项：<a href="?">管理采集规则</a> | <a href="?action=wizard">添加采集规则</a> | <a href="?action=importtxt">导入采集规则</a></th></tr>
	</thead>
	<tbody>
		<tr>
			<td><?=ifthen($id=="","1. 通过本向导将传统的采集规则转换成采集规则文件","1.修改采集规则文件：<span class=\"red\">".$id."</span>")?></td>
		</tr>
	</tbody>
</table>

<table class="tb2">
	<thead>
		<tr>
			<th colspan="2" height="20"><span id="showurl"></span></th>
		</tr>
		<tr id="htmltable" style="display:none">
			<th colspan="2"><textarea id="htmlcode" style="width:99%;height:200px;font-family:Fixedsys" wrap="off" readonly></textarea></th>
		</tr>
		<tr>
			<th colspan="2" class="thc">使用采集规则向导生成采集规则文件</th>
		</tr>
		<tr>
			<th colspan="2" class="thr"><font id="stephit1" color="red">１. 设置基本参数</font>&nbsp;&nbsp;<font id="stephit2">２. 采集列表连接设置</font>&nbsp;&nbsp;<font id="stephit3">３. 采集内容与数据地址设置</font>&nbsp;&nbsp;<font id="stephit4">４. 在线模拟预览结果</font>&nbsp;&nbsp;<font id="stephit5">５. 完成向导并真实演示</font></th>
		</tr>
	</thead>
</table>
<form name="wizardform" id="wizardform" method="post" action="?action=wizard2save" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="referer" value="<?=getRefer()?>" />
 <?php
if ($action == "edit") {
	echo "<input type='hidden' name='id' value=".$id." />"; 
}
?>
<table class="tb2" id="step1" style="display:.none">
	<tbody>
		<tr>
			<td class="label">站点名称：</td>
			<td><input type="text" class="txt" name="itemname" value="<?=$itemname?>" /></td>
		</tr>
		<tr>
			<td class="label">目标站点网址：</td>
			<td><input type="text" class="txt" name="siteurl" value="<?=$siteurl?>" /></td>
		</tr>
		<tr>
			<td class="label">网页编码：</td>
			<td><input type="text" name="charset" value="<?=$charset?>" style="width: 85px" />&nbsp;&nbsp;<font color="#0000FF">请选择编码→</font><select onChange="this.form.charset.value=this.value"><option value="">请选择编码</option><option value="GB2312">GB2312</option><option value="GBK">GBK</option><option value="BIG5">BIG5</option><option value="UTF-8">UTF-8</option></select></td>
		</tr>
<?php $t=$playfrom;?>
		<tr>
			<td class="label">预设文章来源：</td>
			<td><input type="text" name="playfrom" class="txt" value="<?=ifthen($t=="",siteName,$t)?>" maxlength="255"/></td>
		</tr>
		<tr>
			<td class="label red">数据分类设置：</td>
			<td><input type="radio" class="radio" name="autocls" value="0" onClick="hide('autoclsbody');show('selcls');" <?=ifthen($autocls==true,"","checked")?>/>固定分类<input type="radio" class="radio" name="autocls" value="1" onClick="hide('selcls');show('autoclsbody');"<?=ifthen($autocls==true,"checked","")?>/>智能归类</td>
		</tr>
		<tr id="selcls" style="<?=ifthen($autocls==true,"display:none","")?>">
			<td class="label">所属分类：</td>
			<td><select name="classid"><option value="">请选择数据分类</option><?php makenewsTypeOptionselected(0,"&nbsp;|&nbsp;&nbsp;","",$classid)?></select></td>
		</tr>
		<tr>
			<td class="label">分页设置：</td>
			<td>
			<input type="radio" class="radio" name="pageset" value="0" onClick="hide('page_0','page_1','page_2');show('page_0');"<?=ifthen($pageset==0,"checked","");?>/>不分页
			<input type="radio" class="radio" name="pageset" value="1" onClick="hide('page_0','page_1','page_2');show('page_1');"<?=ifthen($pageset==1,"checked","");?>/>批量分页
			<input type="radio" class="radio" name="pageset" value="2" onClick="hide('page_0','page_1','page_2');show('page_2');"<?=ifthen($pageset==2,"checked","");?>/>手动分页
			<input type="radio" class="radio" name="pageset" value="3" onClick="hide('page_0','page_1','page_2');show('page_0');"<?=ifthen($pageset==3,"checked","");?>/>直接采集内容页
			</td>
		</tr>
		<tr id="page_0" style="<?=ifthen($pageset==0,"","display:none")?>">
			<td class="label">采集网址：</td>
			<td><input type="text" class="txt" name="pageurl0" value="<?=$pageurl0?>" /></td>
		</tr>
		</tbody>
		<tbody id="page_1" style="<?=ifthen($pageset==1 || $pageset==3,"","display:none")?>">
		<tr>
			<td class="label">批量生成采集网址：</td>
			<td><input type="text" class="txt" name="pageurl1" value="<?=$pageurl1?>" />&nbsp;ID变量<font color="red">{id}</font></td>
		</tr>
		<tr>
			<td class="label">起始ID：</td>
			<td>标准格式：Http://www.damin.com/list/list_{id}.html<br />开始：<input type="text" name="istart" value="<?php $t = $istart;echo ifthen($t<1,1,$t);?>" style="width: 60px"/> - 结束：<input type="text" name="iend" value="<?php $t=$iend;echo ifthen($t<1,1,$t);?>" style="width: 60px" />&nbsp;例如：1 - 10 或者 10 - 1</td>
		</tr>
		</tbody>
		<tbody id="page_2" style="<?=ifthen($pageset==2,"","display:none")?>">
		<tr>
			<td class="label">手动分页：</td>
			<td><textarea name="pageurl2" rows="6" cols="80"><?=$pageurl2?></textarea></td>
		</tr>
		</tbody>
		<tbody>
		<tr>
			<td class="label">采集方式：</td>
			<td><input type="checkbox" class="checkbox" name="reverse" value="1"<?=ifthen($reverse==1,"checked","");?>/>倒序采集</td>
		</tr>
		<tr>
			<td class="label">内容过滤设置：</td>
			<td>
			<?php
				$a=explode("|","IFRAME|OBJECT|BUTTON|CLASS|HTML|SPAN|DIV|P|SCRIPT|APPLET|STRONG|STYLE|TABLE|FONT|IMG|A");
				$t="|".ifthen($action == "edit",$removecode,"IFRAME|OBJECT|BUTTON|CLASS|DIV|SCRIPT|APPLET|STRONG|STYLE|TABLE|A")."|";
				$count = count($a);
	            for ($i = 0;$i < $count;$i++){
					echo "<input type=\"checkbox\" class=\"checkbox\" name=\"removecode[]\" value=\"".$a[$i]."\"".ifthen(jsIndexOf($t,"|".$a[$i]."|")<>'-1',"checked","")."/>".$a[$i];
					if ($a[$i]=="P") echo "<br>";
                }
			?>
			</td>
		</tr>
		</tbody>
	</tbody>
</table>
<table class="tb2" id="step2" style="display:none">
	<tbody>
		<tr>
			<td class="label">列表开始：</td>
			<td><textarea name="listA" rows="6" cols="80"><?=new_htmlspecialchars($listA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">列表结束：</td>
			<td><textarea name="listB" rows="6" cols="80"><?=new_htmlspecialchars($listB)?></textarea></td>
		</tr>
		<tbody>
		<tr>
			<td class="label red">获取数据图片方式：</td>
			<td><input type="radio" class="radio" name="picmode" value="1" onClick="show('picbody');$('step2').insertBefore($('picbody'),parentNode.parentNode.parentNode.nextSibling);$('piccheckbox').checked=true;"<?php if  ($picmode == 1) echo "checked";?>/>在列表页<input type="radio" class="radio" name="picmode" value="0" onClick="$('step3').insertBefore($('picbody'),$('desbody'));"<?php if ($picmode==0) echo "checked";?>/>在内容页</td>
		</tr>
		</tbody>
<?php if ($picmode==1){?>
		<tbody id="picbody">
			<tr>
				<td class="label">图片开始：</td>
				<td><textarea name="picA" rows="4" cols="80"><?=new_htmlspecialchars($picA)?></textarea></td>
			</tr>
			<tr>
				<td class="label">图片结束：</td>
				<td><textarea name="picB" rows="4" cols="80"><?=new_htmlspecialchars($picB)?></textarea></td>
			</tr>
			<tr>
				<td class="label">图片替换变量：</td>
				<td><input type="radio" class="radio" name="0" value="0" onClick="hide('picvardc');"<?=ifthen($t==true,"","checked")?>/>不作设置<input type="radio" class="radio" name="0" value="1" onClick="show('picvardc')"<?=ifthen($t==true,"checked","")?>/>替换变量</td>
			</tr>
			<tr id="picvardc" style="<?=ifthen($picvar=="","display:none","")?>">
				<td class="label">替换变量：<p class="red">图片开始加 [变量]<br />图片结束 [变量]</p></td>
				<td><textarea name="picvar" rows="4" cols="80"><?=new_htmlspecialchars($picvar)?></textarea></td>
			</tr>
		</tbody>
<?php }?>
		<tbody>
		<tr>
			<td class="label">链接开始：</td>
			<td><textarea name="mlinkA" rows="6" cols="80"><?=new_htmlspecialchars($mlinkA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">链接结束：</td>
			<td><textarea name="mlinkB" rows="6" cols="80"><?=new_htmlspecialchars($mlinkB)?></textarea></td>
		</tr>
<?php $t = $isspecialmlink;?>
		<tr>
			<td class="label red">特殊链接处理：</td>
			<td><input type="radio" class="radio" name="isspecialmlink" value="0" onClick="hide('specialmlinkbody');"<?=ifthen($t==true,"","checked")?>/>不作设置<input type="radio" class="radio" name="isspecialmlink" value="1" onClick="show('specialmlinkbody')"<?=ifthen($t==true,"checked","")?>/>替换地址<br>对于使用了JavaScript跳转形式的连接请使用此功能</td>
		</tr>
	</tbody>
	<tbody id="specialmlinkbody" style="<?=ifthen($t==true,"","display:none")?>">
		<tr>
			<td class="label">要替换的地址：</td>
			<td><p class="red">要替换的连接:/channel/[变量]/[变量].html</p><textarea name="mlinkRF" rows="4" cols="80"><?=new_htmlspecialchars($linkRF)?></textarea></td>
		</tr>
		<tr>
			<td class="label">替换为的地址：</td>
			<td><p class="red">实际连接:/list/?$1-$2.html ($1至$99对应[变量]的出现位置)<br>/list/?[变量]-[变量].html中的[变量]等同$1</p><textarea name="mlinkRR" rows="4" cols="80"><?=new_htmlspecialchars($linkRR)?></textarea></td>
		</tr>
	</tbody>
</table>
<table class="tb2" id="step3" style="display:none">
	<tbody>
		<tr>
			<td class="label">可选采集字段</td>
			<td>
				<input type="checkbox" class="checkbox" name="fields" id="piccheckbox" value="pic" onClick="if(this.checked){show('picbody')}else{hide('picbody')}"<?=ifthen($picA.$picB<>""," checked","")?>/><label for="piccheckbox">图片</label>
				<input type="checkbox" class="checkbox" name="fields" id="cls" value="cls" onClick="if(this.checked){show('autoclsbody')}else{hide('autoclsbody')}"<?=ifthen($autocls==true || $clsA.$clsB<>""," checked","")?>/><label for="cls">分类</label>
				<input type="checkbox" class="checkbox" name="fields" id="author" value="author" onClick="if(this.checked){show('authorbody')}else{hide('authorbody')}"<?=ifthen($authorA.$authorB<>""," checked","")?>/><label for="author">作者</label>
				<input type="checkbox" class="checkbox" name="fields" id="from" value="from" onClick="if(this.checked){show('frombody')}else{hide('frombody')}"<?=ifthen($fromA.$fromB<>""," checked","")?>/><label for="from">来源</label>
				<input type="checkbox" class="checkbox" name="fields" id="outline" value="outline" onClick="if(this.checked){show('outlinebody')}else{hide('notebody')}"<?=ifthen($outlineA.$outlineB<>""," checked","")?>/><label for="outline">简述</label>
				<input type="checkbox" class="checkbox" name="fields" id="keys" value="keys" onClick="if(this.checked){show('keysbody')}else{hide('keysbody')}"<?=ifthen($keysA.$keysB<>""," checked","")?>/><label for="keys">关键词</label>
				<input type="checkbox" class="checkbox" name="fields" id="des" value="des" onClick="if(this.checked){show('desbody')}else{hide('desbody')}"<?=ifthen($desA.$desB<>""," checked","")?>/><label for="des">正文</label>
				<input type="checkbox" class="checkbox" name="fields" id="date" value="date" onClick="if(this.checked){show('datebody')}else{hide('datebody')}"<?=ifthen($getherday>0 || $dateA.$dateB<>""," checked","")?>/><label for="date">采集日期</label>
			</td>
		</tr>
	</tbody>
	<tbody id="namebody">
		<tr>
			<td class="label red">名称开始：</td>
			<td><textarea name="nameA" rows="4" cols="80"><?=new_htmlspecialchars($nameA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">名称结束：</td>
			<td><textarea name="nameB" rows="4" cols="80"><?=new_htmlspecialchars($nameB)?></textarea></td>
		</tr>
	</tbody>
<?php if ($picmode<>1){?>
	<tbody id="picbody" style="<?=ifthen($picA.$picB=="","display:none","")?>">
		<tr>
			<td class="label">图片开始：</td>
			<td><textarea name="picA" rows="4" cols="80"><?=new_htmlspecialchars($picA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">图片结束：</td>
			<td><textarea name="picB" rows="4" cols="80"><?=new_htmlspecialchars($picB)?></textarea></td>
		</tr>
		<tr>
			<td class="label">图片替换变量：</td>
			<td><input type="radio" class="radio" name="0" value="0" onClick="hide('picvardc');"<?=ifthen($t==true,"","checked")?>/>不作设置<input type="radio" class="radio" name="0" value="1" onClick="show('picvardc')"<?=ifthen($t==true,"checked","")?>/>替换变量</td>
		</tr>
		<tr id="picvardc" style="<?=ifthen($picvar=="","display:none","")?>">
			<td class="label">替换变量：<p class="red">图片开始加 [变量]<br />图片结束 [变量]</p></td>
			<td><textarea name="picvar" rows="4" cols="80"><?=new_htmlspecialchars($picvar)?></textarea></td>
		</tr>
	</tbody>
<?php }?>
	<tbody id="autoclsbody" style="<?=ifthen($autocls==true || $clsA.$clsB<>"","","display:none")?>">
		<tr>
			<td class="label">分类开始：</td>
			<td><textarea name="clsA" rows="4" cols="80"><?=new_htmlspecialchars($clsA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">分类结束：</td>
			<td><textarea name="clsB" rows="4" cols="80"><?=new_htmlspecialchars($clsB)?></textarea></td>
		</tr>
	</tbody>
    <tbody id="actorbody" style="<?=ifthen($actorA.$actorB=="","display:none","")?>">
		<tr>
			<td class="label">作者开始：</td>
			<td><textarea name="authorA" rows="4" cols="80"><?=new_htmlspecialchars($authorA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">作者结束：</td>
			<td><textarea name="authorB" rows="4" cols="80"><?=new_htmlspecialchars($authorB)?></textarea></td>
		</tr>
	</tbody>
	<tbody id="frombody" style="<?=ifthen($fromA.$fromB=="","display:none","")?>">
		<tr>
			<td class="label">来源开始：</td>
			<td><textarea name="fromA" rows="4" cols="80"><?=new_htmlspecialchars($fromA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">来源结束：</td>
			<td><textarea name="fromB" rows="4" cols="80"><?=new_htmlspecialchars($fromA)?></textarea></td>
		</tr>
	</tbody>
	<tbody id="outlinebody" style="<?=ifthen($outlineA.$outlineB=="","display:none","")?>">
		<tr>
			<td class="label">备注开始：</td>
			<td><textarea name="outlineA" rows="4" cols="80"><?=new_htmlspecialchars($outlineA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">备注结束：</td>
			<td><textarea name="outlineB" rows="4" cols="80"><?=new_htmlspecialchars($outlineB)?></textarea></td>
		</tr>
	</tbody>
	<tbody id="keysbody" style="<?=ifthen($keysA.$keysB=="","display:none","")?>">
		<tr>
			<td class="label">关键词开始：</td>
			<td><textarea name="keysA" rows="4" cols="80"><?=new_htmlspecialchars($keysA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">关键词结束：</td>
			<td><textarea name="keysB" rows="4" cols="80"><?=new_htmlspecialchars($keysB)?></textarea></td>
		</tr>
	</tbody>
	<tbody id="datebody" style="<?=ifthen($getherday>0 || $dateA.$dateB<>"","","display:none")?>">
		<tr>
			<td class="label">日期开始：</td>
			<td><textarea name="dateA" rows="4" cols="80"><?=new_htmlspecialchars($dateA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">日期结束：</td>
			<td><textarea name="dateB" rows="4" cols="80"><?=new_htmlspecialchars($dateB)?></textarea></td>
		</tr>
	</tbody>
    <tbody id="desbody" style="<?=ifthen($desA.$desB=="","display:none","");?>">
		<tr>
			<td class="label">正文开始：</td>
			<td><textarea name="desA" rows="4" cols="80"><?=new_htmlspecialchars($desA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">正文结束：</td>
			<td><textarea name="desB" rows="4" cols="80"><?=new_htmlspecialchars($desB)?></textarea></td>
		</tr>
	</tbody>
<?php $t = $splay;?>
	<tbody>
		<tr>
			<td class="label red">分页列表范围：</td>
			<td><input type="radio" class="radio" name="splay" value="0" onClick="hide('plistbody');"<?=ifthen($t==true,"","checked")?>/>关闭<input type="radio" class="radio" name="splay" value="1" onClick="show('plistbody')"<?=ifthen($t==true,"checked","")?>/>开启</td>
		</tr>
	</tbody>
	<tbody id="plistbody" style="<?=ifthen($t==true,"","display:none")?>">
		<tr>
			<td class="label">分页列表开始：</td>
			<td><textarea name="plistA" rows="4" cols="80"><?=new_htmlspecialchars($plistA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">分页列表结束：</td>
			<td><textarea name="plistB" rows="4" cols="80"><?=new_htmlspecialchars($plistB)?></textarea></td>
		</tr>
		<tr>
			<td class="label">分页链接开始：</td>
			<td><textarea name="plinkA" rows="4" cols="80"><?=new_htmlspecialchars($plinkA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">分页链接结束：</td>
			<td><textarea name="plinkB" rows="4" cols="80"><?=new_htmlspecialchars($plinkB)?></textarea></td>
		</tr>
<?php $t = $isspecial;?>
		<tr>
			<td class="label red">特殊链接处理：</td>
			<td><input type="radio" class="radio" name="isspecial" value="0" onClick="hide('specialbody');"<?=ifthen($t==true,"","checked")?>/>不作设置<input type="radio" class="radio" name="isspecial" value="1" onClick="show('specialbody')"<?=ifthen($t==true,"checked","")?>/>替换地址<br>对于使用了JavaScript:openwindow形式的连接请使用此功能</td>
		</tr>
	</tbody>
	<tbody id="specialbody" style="<?=ifthen($t==true,"","display:none")?>">
		<tr>
			<td class="label">要替换的地址：</td>
			<td><p class="red">要替换的连接:javaScript:OpenWnd([变量])</p><textarea name="linkRF" rows="4" cols="80"><?=new_htmlspecialchars($linkRF)?></textarea></td>
		</tr>
		<tr>
			<td class="label">替换为的地址：</td>
			<td><p class="red">实际连接:content.asp?id=1&amp;page=$1</p><textarea name="linkRR" rows="4" cols="80"><?=new_htmlspecialchars($linkRR)?></textarea></td>
		</tr>
	</tbody>
</table>
<div id="step4" style="display:none">
</div>
<div id="step5" style="display:none">
</div>
<table class="tb2">
	<tbody>
		<tr>
			<td class="label"></td>
			<td><?php if ($action=="edit") echo "<input type='submit' class='btn' value='快速保存'/>&nbsp;&nbsp;";?><input type="button" class="btn" name="back" value="返回上一步" onClick="prestep()" />&nbsp;&nbsp;<input type="button" class="btn" name="next" value="下一步" onClick="nextstep()" />&nbsp;&nbsp;<input type="checkbox" class="checkbox" name="showcode" id="showcode" value="1"/>下一步显示源码</td>
		</tr>
	</tbody>
</table>
</form>
<script type="text/javascript">
function setHtmlCode(str){
	$('htmlcode').value=(""+str).replace(/([^\r])\n([^\r])/ig,"$1\\n$2");
}

function trim(s){
	return (""+s).replace(/(^\s*)|(\s*$)/g,"");
}

function trimall(s){
	return (""+s).replace(/(\s*)/g,"");
}

function addcslashes(str){
	return (""+str).replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/([\(\)\[\]\""\'\.\?\+\*\/\\\^\$])/ig,"\\$1").replace(/\n/g,"\\n").replace(/\r/g,"\\r");
}

function StrSlice(Str,sStr,eStr){
	if(eStr=='') return false;
	var tStr=Str.toLowerCase(),iPos=tStr.indexOf(sStr.toLowerCase()),sLen=sStr.length;
	if(iPos==-1) return false;
	iPos=sLen>0 ? iPos+sLen : 0;
	return Str.substr(iPos,tStr.slice(iPos).indexOf(eStr.toLowerCase()));
}

function StrSliceB(Str,sStr,eStr){
	if(sStr+eStr=="") return Str;
	var tStr=Str.toLowerCase(),iPos=tStr.indexOf(sStr.toLowerCase()),sLen=sStr.length;
	if(iPos==-1) return false;
	iPos=sLen>0 ? iPos+sLen : 0;
	if(eStr==""){
		return Str.slice(iPos);
	}else{
		return Str.substr(iPos,tStr.slice(iPos).lastIndexOf(eStr.toLowerCase()));
	}
}
function ReCrlf(Str){
	return Str.replace(/\\t/g,'\u0009').replace(/\\n/g,'\u000a').replace(/\\r/g,'\u000d');
}
//分割文件段
function StrSplits(Str,sStr,eStr){
	if(eStr=="" || Str=="") return [];
	var ret=[],tStr=Str.toLowerCase(),str=Str;
	sStr=sStr.toLowerCase(),eStr=eStr.toLowerCase();
	var sLen=sStr.length,eLen=eStr.length,iPos,ePos;
	while(true){
		iPos=tStr.indexOf(sStr);
		if(iPos==-1) break;
		iPos=sLen>0 ? iPos+sLen : 0,tStr=tStr.slice(iPos),ePos=tStr.indexOf(eStr);
		if(ePos==-1) break;
		ret[ret.length]=str.substr(iPos,ePos),tStr=tStr.slice(ePos+eLen),str=str.slice(iPos+ePos+eLen)
	}
	return ret;
}

function paseAbsURI(aLink,currUrl){
	var b,t,H,i,j,k,siteUrl,rg=/^\s*[\/\\]/i,ab=/^http:\/\//i,qt=/\\([\\\/])/ig;
	currUrl=trim(currUrl).replace(qt,"/"),siteUrl=currUrl.replace(/(https?\:\/\/)((\w+)(\.\w+)*(:\d+)?)\/.*/i,"$1$2"),currUrl=currUrl.replace(siteUrl,"")
	for(var i=0;i<aLink.length;i++){
		H=""+aLink[i];
		if(ab.test(H)){
		}else if(rg.test(H)){
			aLink[i]=siteUrl+H
		}else{
			j=H.split("../").length,t=currUrl.split("/"),k=t.length
			t.length=j<k ? k-j : 0
			aLink[i]=siteUrl+t.join("/")+"/"+H.replace(/([\.]{2}\/)/g,"")
		}
	}
	return aLink;
}

function speciallink(sLink,fLink,rLink){
	var a=fLink.split('[变量]');
	rLink=rLink.split('[变量]').join("$1");
	for(var i=0;i<a.length;i++){
		a[i]=addcslashes(a[i]);
	};
	var rg=new RegExp(a.join("([\\w\\W]+)"),"ig");
	return a.length>1 ? sLink.replace(rg,rLink) : sLink;
}

function removeHTMLCode(Str,cHas){
	if(cHas=="" || Str===false) return Str;
	cHas=cHas.toUpperCase().split("|"),Str=""+Str;
	for(var i=0;i<cHas.length;i++){
		switch(cHas[i]){
			case "TABLE":
				Str=Str.replace(/<\/?(table|thead|tbody|tr|th|td).*>/ig,"");
			break;
			case "OBJECT":
				Str=Str.replace(/<\/?(object|param|embed).*>/ig,"");
			break;
			case "SCRIPT":
				Str=Str.replace(new RegExp("<scr"+"ipt.*>[\\w\\W]+?<\\/scr"+"ipt>","ig"),"").replace(new RegExp("\\son[\\w]+=[\\'\\\"].+?[\\'\\\"](\\s|>)(\\s|\\>)","ig"),"$1");
			break;
			case "STYLE":
				Str=Str.replace(/<style.*>[\w\W]+?<\/style>/ig,"");
				Str=Str.replace(/\sstyle=.+(\s|\>)/ig,"$1");
			break;
			case "CLASS":
				Str=Str.replace(/\sclass=.+(\s|\>)/ig,"$1");
			break;
			default:
				Str=removeHTMLCode(removeHTMLCode(Str,"SCRIPT"),"STYLE").replace(new RegExp("<.*?>","ig"),"");
			break;
		}
	}
	return Str
}

var f=$('wizardform'),hurl={1:"",2:"",3:"",4:""},url,cache={},step=[],stephit=[],istep=1;
for(var i=1;i<6;i++){
	step.push($("step"+i));
	stephit.push($("stephit"+i));
}

function clearvalue(){
	var arg=arguments;
	for(var i=0;i<arg.length;i++){
		try{f.elements[arg[i]].value='';}catch(ignore){}
	}
};

function showBody(n){
	n--;
	for(var i=0;i<step.length;i++){
		step[i].style.display= n!=i ? "none" : "";
		stephit[i].color= n==i ? "red" : "";
	};
}

function prestep(){
	if(istep>1){
		showurl(url=hurl[--istep]);
		showBody(istep);
		if(url!="") request(url,function (Q){setHtmlCode(Q.responseText)});
	}else{
		if(confirm("确实要离开该页面吗？\n\n这将会导致规则页面上未保存的数据丢失，确定？\n\n按确定继续，或按取消留在当前页面。")){
			history.go(-1);
		}
	}
}

function request(url,fun){
	url="admin_collectnews.php?action=proxy&result=true&charset="+f.elements['charset'].value+"&url="+escape(url);
	if(cache[url]==undefined || cache[url]!=''){
		ajax.get(url,function (Q){
			var txt=Q.responseText;
			if(txt!="err" && txt!="ok") cache[url]=txt;
			fun(Q);
		});
	}else{
		fun({responseText:cache[url]})
	}
};

function _nextstep(Q){
	var txt=Q.responseText;
	if(txt!="err"){
		showBody(++istep);
		$('htmltable').style.display=$('showcode').checked ? '' : 'none'
		if(txt!="OK") setHtmlCode(txt);
	}else{
		alert("err")
	}
}
function showurl(s){
	$('showurl').innerHTML="&nbsp;&nbsp;当前采集地址：<font color=red>"+s+"</font>";
}
var hPic="",rg=/\[\u53d8\u91cf\]/g;
function nextstep(){
	var es=f.elements,showcode=es['showcode'].checked;
	if(trim(es["charset"].value)==""){alert("请选择网页编码");return;}
	if(istep==1){
		for(var i=0,ps;i<es['pageset'].length;i++){
			if(es['pageset'][i].checked){
				ps=i;
				break;
			}
		};
		if(ps==0){
			url = es['pageurl0'].value
		}else if(ps==1 || ps==3){
			var _s=parseInt(es['istart'].value),_e=parseInt(es['iend'].value);
			if(_s>_e){
				es['istart'].value=_e,es['iend'].value=_s,es['reverse'].checked=true;
			}
			url = es['pageurl1'].value.replace("{id}",trim(es['istart'].value));
		}else if(ps==2){
			url = trim(es['pageurl2'].value).split("\r\n")[0]
		}else{
			alert("请选择分类设置")
		};
		if(es['playfrom'].value==""){
			alert("请选择播放来源");
			return;
		};
		if(es['autocls'][0].checked && es['classid'].value==""){
			alert("请选择所属分类");
			return;
		};
		if(trim(url) == ""){
			alert("请输入采集列表网址");
			return;
		};
		showurl(hurl[2]=url);
		request(url,function (Q){
				if(ps==3) istep=2;
				_nextstep(Q);
		});
	}else if(istep == 2){
		request(url,function (Q){
			var txt=Q.responseText,ls=StrSliceB(txt,ReCrlf(es["listA"].value),ReCrlf(es["listB"].value));
			if(ls===false){if(!confirm("截取 列表开始~数据列表结束 失败\n\n点[确定]忽略这错误提示，[取消]返回修改")){return;}}
			var mlink=StrSlice(ls,ReCrlf(es["mlinkA"].value),ReCrlf(es["mlinkB"].value));
			if(mlink===false){if(!confirm("截取 链接开始~数据链接结束 失败\n\n点[确定]忽略这错误提示，[取消]返回修改")){return;}}
			if(es['isspecialmlink'][1].checked) mlink=speciallink(mlink,es["mlinkRF"].value,es["mlinkRR"].value);
			if(es['picmode'][0].checked){
				var sa=ReCrlf(es["picA"].value),sb=ReCrlf(es["picB"].value),t=ReCrlf(es['picvar'].value);
				if(t!=""){
					hPic = sa+sb!='' ? (rg.test(sa) ? t : '')+StrSlice(ls,sa.replace(rg,""),sb.replace(rg,""))+((rg.test(sb) ? t : '')) : '-';
				}else{
					hPic = sa+sb!='' ? StrSlice(ls,sa,sb) : '-';
				};
				if(hPic===false){
						if(!confirm("截取 图片开始 ~ 数据结束 失败\n\n点[确定]忽略这错误提示，[取消]返回修改")){
							return;
						}
				};
			}
			mlink=paseAbsURI([mlink],url);
			setHtmlCode(mlink);
			showurl(hurl[3]=url=mlink);
			request(url,function (W){
				_nextstep(W);
			});
		});
	}else if(istep == 3){

		request(url,function (Q){
			var t,sa,sb,ttxt,txt=Q.responseText,val={},has={'name':"标题",'author': "作者",'from': '来源','outline': '简述','cls': '分类','date': '日期'};
			ttxt = txt;
			for(var k in has){
				try{
					t=document.getElementById(k);
					if(k=='name' || t && t.checked){
						sa=ReCrlf(es[k+"A"].value),sb=ReCrlf(es[k+"B"].value);
						val[k] = sa+sb!='' ? removeHTMLCode(StrSlice(ttxt,sa,sb),"SCRIPT|STYLE|*") : '-';
					}
				}catch(ignore){}
			};
			if(!es['picmode'][0].checked){
				sa=ReCrlf(es["picA"].value),sb=ReCrlf(es["picB"].value),t=ReCrlf(es['picvar'].value);
				if(t!=""){
					val['pic'] = sa+sb!='' ? (rg.test(sa) ? t : '')+StrSlice(ttxt,sa.replace(rg,""),sb.replace(rg,""))+((rg.test(sb) ? t : '')) : '-';
				}else{
					val['pic'] = sa+sb!='' ? StrSlice(ttxt,sa,sb) : '-';
				};
			}else{
				val['pic']=hPic;
			}
			if(es["autocls"][1].checked && val['cls']=="-"){
				if(!confirm("截取 "+has['cls']+"开始 ~ "+has['cls']+"结束 失败\n\n点[确定]忽略这错误提示，[取消]返回修改")){
					return;
				}
			}
			sa=ReCrlf(es["desA"].value),sb=ReCrlf(es["desB"].value);
			val['des'] = sa+sb!='' ? StrSlice(txt,sa,sb) : "-";
			has['des']='正文',has['pic']='图片',has['plist']='分页列表',has['plink']='分页链接',has['linkR']='特殊链接处理';
			var ch=function (R){
			var txt=R.responseText;
				for(var k in has){
					if(val[k]===false){
						if(!confirm("截取 "+has[k]+"开始 ~ "+has[k]+"结束 失败\n\n点[确定]忽略这错误提示，[取消]返回修改")){
							return;
						}
					};
				};
				if(val['pic']!='-') val['pic']=paseAbsURI([val['pic']],url).join();
				var te=es["removecode[]"],removecode=[];
				for(var i=0;i<te.length;i++){
					if(te[i].checked) removecode.push(te[i].value);
				};
				removecode=removecode.join("|");
				if(removecode!="") for(k in val){val[k]=removeHTMLCode(val[k],removecode);}
				var dc=$('step4');
var s="\
标题："+trim(val['name'] || '')+"\r\n\
图片："+trim(val['pic'] || '')+"\r\n\
分类："+trim(val['cls'] || '')+"\r\n\
作者："+trimall(val['author'] || '')+"\r\n\
来源："+trimall(val['from'] || '')+"\r\n\
时间："+trim(val['date'] || '')+"\r\n\
简述："+trim(val['outline'] || '')+"\r\n\
正文："+trim(val['des'] || '')+"\r\n\
";
				dc.innerHTML="<pre>"+s.replace(/\</g,"&lt;").replace(/\>/g,"&gt;")+"</pre>";
				_nextstep(R);
			};
			if(es['splay'][1].checked){
				k='plist',sa=ReCrlf(es[k+"A"].value),sb=ReCrlf(es[k+"B"].value);
				val[k] = sa+sb!='' ? StrSlice(txt,sa,sb) : '-';
				txt= val[k];
				k='plink',sa=ReCrlf(es[k+"A"].value),sb=ReCrlf(es[k+"B"].value);
				val[k] = sa+sb!='' ? StrSlice(txt,sa,sb) : '-';
				if(val[k]===false){
					if(!confirm("截取 "+has[k]+"开始 ~ "+has[k]+"结束 失败\n\n点[确定]忽略这错误提示，[取消]返回修改")){
						return;
					}
				};
				if(es['isspecial'][1].checked) val[k]=speciallink(val[k],ReCrlf(es["linkRF"].value),ReCrlf(es["linkRR"].value));
				showurl(hurl[4]=paseAbsURI([val[k]],url).join());
				request(hurl[4],function (R){
					setHtmlCode(R.responseText);
					ch(R);
				});
			}else{
				ch({'responseText':txt});
			}
		});
	}else if(istep == 4){
		f.submit()
	}
}
</script>
<?php
}

function itemlist() {
	global $menuList;
	$page = getForm("page", "get");$page=ifthen($page<1,1,$page);
	$number = 10;
    $sqlStr = "select * from ".DB::table('collect')." WHERE publi=1 order by `id` desc";
	$allRecordset = DB::getCount($sqlStr);
	$tpagecount = ceil($allRecordset / $number);
	if ($page > $tpagecount) $page = $tpagecount;
	switch (gatherSet) {
		case 0:$iMode="智能覆盖";break;
		case 1:$iMode="地址头部追加";break;
		case 2:$iMode="地址尾部追加";break;
		case 3:$iMode="覆盖地址";break;
		case 4:$iMode="新增数据";break;
		case 5:$iMode="仅更新地址以外的信息";break;
	}
?>
<table class="tb">
	<tr class="thead"><th colspan="7"><div style="float:left">采集规则列表 <a href="?">管理采集规则</a> | <a href="?action=wizard">添加采集规则</a> | <a href="?action=importtxt">导入采集规则</a> |</span></div><div style="float:right">入库方式：<span class=red><?=$iMode;?></span> <a href="admin_config.php#rule">更改设置</a></div></th></tr>
    <tr>
 <td colspan="7">小提示：第一次采集在批量分页里填写完整的页码，以后采集时更改为前几页可以大大提高采集效率！</td>
 <form action="" method="post" name="linkform">
 </tr>
    <TR align="center">
	  <TD>&nbsp;</TD>
      <TD width="6%">ID</TD>
      <TD>采集名称</TD>
      <TD>来源/分类</TD>
      <TD>目标站点</TD>
      <TD>最后采集时间</TD>
      <TD>操作</TD>
    </TR>

	<?php
$page = max(intval($page), 1);
$offset = $number*($page-1);
$query = DB::query("$sqlStr LIMIT $offset, $number");
while($row = DB::fetch($query)) {
 ?>
	<TR align="center">
        <TD>&nbsp;</TD>
        <TD align="left"><input type="checkbox" value="<?=$row['id']?>" name="m_id[]"  class="checkbox" /><?=$row['id']?></TD>
		<td><img width="16" height="16" src="imgs/icon01.GIF" align="absmiddle"/> <?=$row['itemname']?></td>
		<td align="center"><?=$row['playfrom']?>/
		<?php if($row['autocls']){echo "<font color=\"red\">自动转换分类</font>";}else{if($row['classid']) echo viewDataType($row['classid']); else echo "<font color=\"red\">没有分类，请修改</font>";}?></td>
		<td><a href="javascript:void(0);" onClick="window.open('<?=$row['siteurl']?>','_blank');" title="<?=$row['siteurl']?>"><?php echo msubstr($row['siteurl'],20);?></a></td>
        <?php if($row['CollectTime']==0){echo " <td>从未采集过"; }else {?><td title="<?=date('Y-m-d H:i:s',$row['CollectTime'])?>"><a href="?action=exporttxt&id=<?=$row['id']?>" title="导出此脚本">导出此脚本</a><br><span style='font-size:9px'><?=date('Y-m-d',$row['CollectTime'])?></span><?php }?></td>
		<td align="center" colspan="2"><a href="?action=exec&id=<?=$row['id']?>">采集</a> <a href="?action=ghost&id=<?=$row['id']?>">克隆</a> <a href="?action=edit&id=<?=$row['id']?>">编辑</a> <a href="#" onClick="if(confirm('确定要永久删除<?=$row['itemname']?>采集规则吗？')) $('hiddensubmit').src='?action=remove&id=<?=$row['id']?>'">删除</a></td>
	</tr>
	<?php
}
?>
<tr><td  colspan="7"><label>全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onClick="checkAll(this.checked,'input','m_id[]')" /></label><label>反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onClick="checkOthers('input','m_id[]')" /></label><input type="submit" value="批量删除" onClick="if(confirm('确定要删除吗')){linkform.action='?action=delall';}else{return false}" class="btn"  />&nbsp;&nbsp; <?=fPageCount($allRecordset, $number, $page)?></td></tr>
</table>
<?php
}

function tempdatabase() {
	$inbase=getForm("inbase","get");$keyword=getForm("keyword","both");$m_type=getForm("type","both");$m_typename=getForm("typename","both");$from=getForm("from","both");$page=getForm("page","get");$page=ifthen($page<1,1,$page);
	$whereStr = " where 1=1";
	if ($inbase == 'true') {
       $whereStr .= " and `m_inbase`=1";
	} else if ($inbase == 'false') {
       $whereStr.=" and `m_inbase`=0";
    }
	if (is_numeric($m_type)) {
	   if ($m_type == '0') {
		   $whereStr .= " and `m_type` in (0)";
	   } else {
		   $whereStr .= " and `m_type` in (".getTypeIdOnCache($m_type).")";
	   }
	}
    $number = 30;
	if (!empty($typename)) $whereStr .= " and m_typename='".$m_typename."";
	if (!empty($keyword)) $whereStr .= " and `m_title` like '%".$keyword."%'";
    if (!empty($from)) $whereStr .= " and m_from like '%".$from."%' ";
    $whereorder = str_replace("where and", "where", $whereStr);
    $sqlStr = "SELECT m_id,m_title,m_inbase,m_from,m_type,m_typename,m_addtime FROM ".DB::table('tempnews')." ".$whereorder." ORDER BY m_addtime DESC";
	$allRecordset = db::getCount($sqlStr);
	$tpagecount = ceil($allRecordset / $number);
	if ($page > $tpagecount) $page = $tpagecount;
?>
<table class="tb">
	<tr class="thead"><th colspan="5">&nbsp;<font color="#000000">管理临时库： </font><a href="?action=tempdatabase&inbase=true">显示已入库的</a> | <a href="?action=tempdatabase&inbase=false">显示未入库的</a> | <a href="?action=tempdatabase&type=0">显示未分类的</a> | <a href="?action=tempdatabase">显示所有</a> | <a href="?action=delallTempData&do=all" onClick="if(confirm('确定要删除所有吗')){return true;}else{return false;}"><u>清空临时库</u></a></th><th colspan="4"></th></tr>
	<form action="?action=tempdatabase" method="post">
	<tr>
		<td align="left" colspan="9">
		关键字<input name="keyword" type="text" id="keyword" size="20">
		<select name="type" id="type"><option value="">请选择数据分类</option><?php makeTypeOption(0,"&nbsp;|&nbsp;")?></select>
		<input type="submit" name="selectBtn"  value="查 询..." class="btn" />&nbsp;
		<select onChange="self.location.href='?action=tempdatabase&type='+this.options[this.selectedIndex].value"><option value="">按数据分类查看</option><?php makeTypeOption(0,"&nbsp;|&nbsp;")?></select>
		<select id='m_playfrom' name='m_playfrom' style="width:120px" onChange="self.location.href='?action=tempdatabase&playfrom='+this.options[this.selectedIndex].value"><option value=''>按视频来源查看</option><?php echo makePlayerSelect("");?></select>
		</td>
	</tr>
</form>
<?php
    if($allRecordset == 0) {
	    if (!empty($keyword))  echo "<tr align='center'><td>关键字  <font color=red>\"".$keyword."\"</font>   没有记录</td></tr>"; 
    } else {
	    if (!empty($keyword)) {
?>
  <tr ><td colspan="10">关键字  <font color=red> <?=$keyword?> </font>   的记录如下</td></tr>
<?php
    }
?>
	<tr>
		<td width="50">编号</td>
		<td>标题</td>
		<td width="50">状态</td>
		<td width="80">来源</td>
		<td width="80">绑定分类</td>
		<td width="80">旧分类名</td>
		<td width="60">采集时间</td>
		<td width="100" colspan="2" align="center">操作</td>
	</tr>
	<form method="post" name="tempdataform" action="?action=delallTempData">
<?php
    $page = max(intval($page), 1);
    $offset = $number*($page-1);
	$query = DB::query("$sqlStr LIMIT $offset, $number");
    while($row = DB::fetch($query)) {
        $m_id=$row['m_id'];
?>
     <tr>
		<td><input type="checkbox" value="<?=$m_id?>" name="m_id[]" class="checkbox" /><?=$m_id?></td>
		<td><?=$row['m_title']?></td>
		<td><?php if ($row['m_inbase']) echo "已入库"; else echo "未入库";?></td>
        <td><?=ifthen($row['m_from']<>"","<a href=\"?action=tempdatabase&inbase=".$inbase."&from=".urlencode($row['m_from'])."\">".$row['m_from']."</a>","")?></td>
		<td><?php if ($row['m_type'] != 0) echo viewDataType($row['m_type']); else echo "<font color=red>没找到相关分类</font>";?></td>
        <td><?=ifthen($row['m_typename']<>"","<a href=\"?action=tempdatabase&inbase=".$inbase."&typename=".urlencode($row['m_typename'])."\">".$row['m_typename']."</a>","")?></td>
		<td><span title="<?=date('Y-m-d H:i:s',$row['m_addtime'])?>"><?=isCurrentDay($row['m_addtime'])?></span></td>
		<td colspan="2" align="center"><a href="?action=editVideo&id=<?=$m_id?>">编辑</a> <a href="?action=delTempData&id=<?=$m_id?>" onClick="return confirm('确定要删除吗')">删除</a></td>
	</tr>
<?php }?>
<tr>
		<td colspan="9">同名更新：
			<input type="checkbox" class="checkbox" name="fields[]" value="title">标题
			<input type="checkbox" class="checkbox" name="fields[]" value="author" checked>作者
			<input type="checkbox" class="checkbox" name="fields[]" value="pic" checked>图片
			<input type="checkbox" class="checkbox" name="fields[]" value="from" checked>来源
			<input type="checkbox" class="checkbox" name="fields[]" value="outline">简述
			<input type="checkbox" class="checkbox" name="fields[]" value="content">正文
			<input type="checkbox" class="checkbox" name="fields[]" value="keyword">关键词
			<input type="checkbox" class="checkbox" name="fields[]" value="commend">星级
			<input type="checkbox" class="checkbox" name="fields[]" value="note">属性
			<input type="checkbox" class="checkbox" name="fields[]" id="now" value="now" onClick="$('addtime').checked=false;">使用现在时间
			<input type="checkbox" class="checkbox" name="fields[]" id="addtime" value="addtime" onClick="$('now').checked=false;">使用采集时间
		</td>
	</tr>
    <tr>
		<td colspan="9">全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onClick="checkAll(this.checked,'input','m_id[]')" />反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onClick="checkOthers('input','m_id[]')" />&nbsp;&nbsp;<input type="submit" value="批量删除" onClick="if(confirm('确定要批量删除吗')){return true}else{return false}" class="btn" />&nbsp;<select name="type" id="type"><option value="">智能识别分类</option><?php makeNewsTypeOption(0,"&nbsp;|&nbsp;")?></select>&nbsp;<input type="submit" value="导入选中数据" onClick="this.form.action='?action=import';" class="btn" style="width:85px"/>&nbsp;<input type="submit" value="导入全部数据" onClick="this.form.action='?action=import&smode=all';" class="btn" style="width:85px"/>&nbsp;<input type="submit" value="导入未入库" onClick="this.form.action='?action=import&smode=noinbase';" class="btn" style="width:85px"/></td>
	</tr>
	<tr>
	<td colspan="9"><?=fPageCount($allRecordset, $number, $page)?></td></tr>
</form>
<?php }?>
</table>
<?php
}

function editVideo() {
	global $menuList;
	$id = intval(getForm("id","get"));
	$row = DB::fetch_first("SELECT * FROM ".DB::table('tempnews')." WHERE m_id='$id'");
	if (!is_array($row)) { die("没找到记录");}
	$m_color = $row['m_color'];
	$m_type = $row['m_type'];
?>
<div class="container" id="cpcontainer">
<form action="?action=savenews&acttype=edit" method="post" name="editform" id="editform">
<input type="hidden" id="m_commend" name="m_commend" value="0">
<input type="hidden" id="m_vid" name="m_vid" value="<?=$row['m_vid']?>">
<table class="tb">
<tr class="thead"><th colspan="2">修改文章(<font color='red'>＊</font>为必填,其它选填)</th></tr>
	<tr> 
		<td height="22" align="right">来源：</td>
		<td><a href="javascript:void(0);" onClick="window.open('<?=$row['m_fromurl']?>','_blank');"><?=$row['m_fromurl']?></a></td>
	</tr>
	<tr>
	  <td align="right" height="22">标 题：</td>
		<td><input type="text" size="23" id="m_title" name="m_title" autocomplete="off" value="<?=$row['m_title']?>"/>&nbsp;<font color='red'>＊</font>颜色：
		<select name="m_color" >
		<?php if ($m_color==""){?>
		 <option style="" value="">无色</option> 
		<?php }else{?> 
		<option style="background-color:<?=$m_color?>;color: <?=$m_color?>" value="<?=$m_color?>"><?=$m_color?></option>
		<?php }?>
		<option style="background-color:#FF0000;color: #FF0000" value="#FF0000">红色</option> 
		<option style="background-color:#FF33CC;color: #FF33CC" value="#FF33CC">粉红</option>  
		<option style="background-color:#00FF00;color: #00FF00" value="#00FF00">绿色</option>
		<option style="background-color:#0000CC;color: #0000CC" value="#0000CC">深蓝</option>
		<option style="background-color:#FFFF00;color: #FFFF00" value="#FFFF00">黄色</option>
		<option style="background-color:#660099;color: #660099" value="#660099">紫色</option>
		<option style="" value="">无色</option> 
		</select>
类 型：<select name="m_type" id="m_type"><option value="">请选择数据分类</option>
    <?php makenewsTypeOptionselected(0,"&nbsp;|&nbsp;&nbsp;","",$m_type)?>
	</select>&nbsp;&nbsp;<font color='red'>＊</font>&nbsp;<input type="checkbox" name="isupdatetime" value="1" checked class="checkbox" />更新时间</td>
	</tr>
	<tr> 
		<td height="22" align="right">图片地址：</td>
		<td><input type="text" size="30" name="m_pic" id="m_pic" value="<?=$row['m_pic']?>">&nbsp;←<input type="button" size="10" value="清除" onClick="javascript:document.editform.m_pic.value=''" class="btn">&nbsp;<iframe src="fckeditor/upload.htm?isnews=1" scrolling="no" topmargin="0" width="300" height="24" marginwidth="0" marginheight="0" frameborder="0" align="center"></iframe></td>
  </tr>

	<tr>
	 <td align="right" height="22">作&nbsp;&nbsp;者：</td>
	 <td><input type="text" size="30" name="m_author" value="<?=$row['m_author']?>">&nbsp;&nbsp;来&nbsp;&nbsp;&nbsp;源：<input type="text" size="10" name="m_from" value="<?=$row['m_from']?>">&nbsp;星级：<span id="star0" style="width:85px;display:inline-block"><script>starView(<?=$row['m_commend']?>,0)</script></span></td>
	</tr>
	<tr>
		<td align="right" height="22">关键词：</td>
	  <td><input type="text" name="keyword" size="30" value="<?=$row['m_keyword']?>">&nbsp;&nbsp;点击率：<input type="text" size="10" name="m_hit" id="m_hit" maxlength="9" value="<?=$row['m_hit']?>">&nbsp;属性：<input type="checkbox" class="checkbox" name="m_note" value="64"<?=ifthen($row['m_note']==64," checked","")?>>[荐]&nbsp;<input type="checkbox" name="m_note" class="checkbox" value="128"<?=ifthen($row['m_note']==128," checked","")?>>[图]&nbsp;<input type="checkbox" class="checkbox" name="m_note" value="32"<?=ifthen($row['m_note']==32," checked","")?>>[视]</td>
	</tr>
	<tr>
		<td align="right" height="22">简&nbsp;&nbsp;述：</td>
		<td><textarea name="m_outline" rows="3" cols="70" maxlength="100"><?=$row['m_outline']?></textarea></td>
	</tr>
	<tr>
		<td align="right" height="22">内&nbsp;&nbsp;容：</td>
		<td>
        <?php
        GetEditor('m_content', $row['m_content']);
	?>
  		</td>
	</tr>
	<tr><input type="hidden" name="m_id" value="<?=$id?>"><input type="hidden" name="m_back" value="<?=getRefer()?>" />
	<td></td><td class="forumRow"><input type="submit" name="submit" class="btn" value="确认保存" onClick="if($('m_title').value.length==0){alert('请填写标题');return false;};if($('m_type').value.length==0){alert('请选择分类');return false;}">&nbsp;<input type="reset" class="btn" value="清 除">&nbsp;<input type="button" class="btn" value="返　回" onClick="javascript:history.go(-1);"></td>
  </tr>
</table>
</form>
<script type="text/javascript">
window.commendVideo=function (id,n){
	$('m_commend').value=n;
	starView(n,id);
}
$('editform').m_title.focus();</script>
</div>
<?php
}

function customercls() {
	global $menuList;
?>
<table class="tb">
	<tr class="thead"><th colspan="4">自定义分类</th></tr>
	<tr>
		<td>ID</td>
		<td>要转换的分类名</td>
		<td>影射到系统分类</td>
		<td>操作</td>
	</tr>

<form action="?action=customersavecls" method="post" name="form1">
<?php
$number=20;
$page=getForm("page","get");$page=ifthen($page<1,1,$page);
$page = max(intval($page), 1);
$offset = $number*($page-1);
$sqlStr="select `id`,`clsname`,`sysclsid` from ".DB::table('cls')." WHERE publi=1";
$allRecordset = DB::getCount($sqlStr);
if ($allRecordset == 0) {
?>
	<tr>
		<td colspan="4" align="center">没找到自定义分类</td>
	</tr>
<?php
} else {
	$query = DB::query("$sqlStr limit $offset, $number");
    while($row = DB::fetch($query)) {
        $id=$row['id'];
?>
	<tr>
		<td><input type="checkbox" name="id[]" value="<?=$id?>"  class="checkbox" /></td>
		<td><input type="text" name="clsname<?=$id?>" value="<?=$row['clsname']?>" /></td>
		<td><select name="m_type<?php echo $id;?>"><option value="">请选择数据分类</option><?php makeTypeOptionSelected(0,"&nbsp;|&nbsp;","",$row['sysclsid']); ?></select></td>
		<td><a href="?action=customerdelcls&id=<?=$id?>">删除</a></td>
	</tr>
<?php 
    }
}
?>
	<tr>
		<td colspan="4"><label>全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onClick="checkAll(this.checked,'input','id[]')" /></label><label>反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onClick="checkOthers('input','id[]')" /></label><input type="submit" value="批量删除" onClick="if(confirm('确定要删除吗')){this.form.action='?action=customerdelallcls';}else{return false}" class="btn"/>&nbsp;&nbsp;<input type="submit" value="批量修改选中分类" name="Submit" class="btn" onClick="this.form.action='?action=customersavecls';"/>&nbsp;&nbsp;<?=fPageCount($allRecordset,$number,$page)?></td>
	</tr>
</form>
	<tr class="thead"><th colspan="4"></th></tr>
<form action="?action=customernewcls" method="post" name="form2">
	<tr>
		<td>添加</td>
		<td><input type="text" name="clsname" value="" /></td>
		<td><select name="m_type" id="m_type"><option value="">请选择数据分类</option><?php makeTypeOption(0,"&nbsp;|&nbsp;"); ?></select></td>
		<td><input type="submit" value="确定" name="Submit" class="btn"/></td>
	</tr>
</form>
</table>
<?php
}

function filtersDictionary() {
	global $menuList;
	$page=getForm("page","get");$page = ifthen($page<1,1,$page);
    $number = 30;
    $sqlStr = "select * from ".DB::table('fword')." WHERE m_ison=1";
	$allRecordset = db::getCount($sqlStr);
	$tpagecount = ceil($allRecordset / $number);
	if ($page > $tpagecount) $page = $tpagecount;
?>
<table class="tb">
	<tr class="thead"><th colspan="6">过滤字典: <a href="?action=filters">字典列表</a> | <a href="?action=filtersadd">添加过滤</a></th></tr>
	<tr>
		<td>ID</td>
		<td>过滤名称</td>
		<td>过滤字段</td>
		<td>过滤模式</td>
		<td>状态</td>
		<td>操作</td>
	</tr>
<?php if($allRecordset==0){?>
	<tr>
		<td colspan="6" align="center">没找到内容</td>
	</tr>
<?php
}else{
?>
<form action="" method="post" name="form1">
<?php
$page = max(intval($page), 1);
$offset = $number*($page-1);
$query = DB::query("$sqlStr limit $offset, $number");
while($row = DB::fetch($query)) {
$id=$row['m_id'];
?>
	<tr>
		<td><input type="checkbox" value="<?=$id?>" name="m_id[]" class="checkbox"/><?=$id?></td>
		<td><?=$row['m_name']?></td>
		<td><?=ifthen($row['m_rcolumn']==0,"标题替换","剧情替换")?></td>
		<td><?=ifthen($row['m_uesmode']==0,"简单替换","高级替换")?></td>
		<td><?=ifthen($row['m_flag']==1,"√","<font color=red>×</font>")?></td>
		<td><a href="?action=filtersban&id=<?=$id?>"><?=ifthen($row['m_flag']==1,"禁用","启用")?></a> <a href="?action=filtersedit&id=<?=$id?>">编缉</a> <a href="?action=filtersdel&id=<?=$id?>">删除</a></td>
	</tr>
<?php 
}
?>
	<tr>
		<td colspan="6"><label>全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onClick="checkAll(this.checked,'input','m_id[]')" /></label><label>反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onClick="checkOthers('input','m_id[]')" /></label><input type="submit" value="批量删除" onClick="if(confirm('确定要删除吗')){this.form.action='?action=filtersdelall';}else{return false}" class="btn"/><?=fPageCount($allRecordset, $number, $page)?></td>
	</tr>
</form>
<?php
}
?>
</table>
<?php
}

function EditOrAdd() {
	global $id,$Name,$sFind,$sStart,$sEnd,$sReplace;
	$id = getForm("id","get");
    $rColumn = 0;$uesMode = 0;$Flag = 1;
	if (!empty($id)) { 
	    $row = DB::fetch_first("SELECT * FROM ".DB::table('fword')."  WHERE m_ison=1 AND m_id=$id");
	    if (is_array($row)) {
		    $id = $row['m_id'];$Name = $row['m_name'];$rColumn = $row['m_rcolumn'];$uesMode = $row['m_uesmode'];
		    $sFind = $row['m_sfind'];$sStart = $row['m_sstart'];$sEnd = $row['m_send'];$sReplace = $row['m_sreplace'];$Flag = $row['m_flag'];
	    }
	}
?>
<table class="tb">
	<tr class="thead"><th colspan="2">过滤字典: <a href="?action=filters">字典列表</a> | <a href="?action=filtersadd">添加过滤</a></th></tr>
	<form action="?action=saveeditoradd" method="post" name="form1">
	<input type="hidden" name="m_id" value="<?=$id?>" />
	<tr>
		<td class="label">过滤器名称</td>
		<td><input type="text" class="txt" name="m_name" value="<?=$Name?>" /></td>
	</tr>
	<tr>
		<td class="label">过滤字段</td>
		<td><select name="m_rcolumn"><option value="0"<?=ifthen($rColumn==1,""," selected")?>>数据名称</option><option value="1"<?=ifthen($rColumn==1," selected","")?>>数据简介</option></select></td>
	</tr>
	<tr>
		<td class="label">过滤模式</td>
		<td><input type="radio" class="radio" name="m_uesmode" value="0" onClick="hide('sStartBody','sEndBody');show('sFindBody');"<?=ifthen($uesMode==1,"","checked")?>/>简单替换 <input type="radio" class="radio" name="m_uesmode" value="1" onClick="hide('sFindBody');show('sStartBody','sEndBody');"<?=ifthen($uesMode==1,"checked","")?>/>高级替换</td>
	</tr>
	<tr id="sFindBody" style="<?=ifthen($uesMode==1,"display:none","")?>">
		<td class="label">查找</td>
		<td><textarea name="m_sfind" rows="4" cols="80" wrap="off"><?=new_htmlspecialchars($sFind)?></textarea></td>
	</tr>
	<tr id="sStartBody" style="<?=ifthen($uesMode==1,"","display:none")?>">
		<td class="label">开始标记</td>
		<td><textarea name="m_sstart" rows="4" cols="80" wrap="off"><?=new_htmlspecialchars($sStart)?></textarea></td>
	</tr>
	<tr id="sEndBody" style="<?=ifthen($uesMode==1,"","display:none")?>">
		<td class="label">结束标记</td>
		<td><textarea name="m_send" rows="4" cols="80" wrap="off"><?=new_htmlspecialchars($sEnd)?></textarea></td>
	</tr>
	<tr>
		<td class="label">替换</td>
		<td><textarea name="m_sreplace" rows="4" cols="80" wrap="off"><?=new_htmlspecialchars($sReplace)?></textarea></td>
	</tr>
	<tr>
		<td class="label">启用</td>
		<td><input type="radio" class="radio" name="m_flag" value="1"<?=ifthen($Flag==1," checked","")?>/>启用 <input type="radio" class="radio" name="m_flag" value="0"<?=ifthen($Flag==1,""," checked")?>/>禁用</td>
	</tr>
	<tr>
		<td colspan=2><input  type="submit" class="btn" name="Submit" value="确&nbsp;&nbsp;定" >&nbsp;&nbsp;&nbsp;&nbsp;<input name="Cancel" class="btn" type="button" id="Cancel" value="取&nbsp;&nbsp;消" onClick="window.location.href='?action=filters'"></td>
	</tr>
	</form>
</table>
<?php
}

function filtersban() {
	$back = getRefer();$id = getForm("id","get");
	if ($id > 0) DB::query("UPDATE ".DB::table('fword')." SET m_flag=(!m_flag) WHERE m_ison=1 AND m_id=$id");
	alertMsg("", $back);
}

function filtersdel() {
	$back = getRefer();$id = getForm("id","get");
	DB::delete('fword', array('m_ison' => 1,'m_id' => $id));
	alertMsg("", $back);
}

function filtersdelall() {
	$ids = getForm("m_id","post");
	if (!empty($ids)) DB::delete('fword', 'm_ison=1 AND m_id IN ('.dimplode($ids).')');
	alertMsg("", "?action=filters");
}

function saveeditoradd(){
	$m_id = getForm("m_id","post");
	$m_name=getForm("m_name","post");$m_rcolumn=getForm("m_rcolumn","post");$m_uesmode=getForm("m_uesmode","post");
	$m_sfind=getForm("m_sfind","post");$m_sstart=getForm("m_sstart","post");$m_send=getForm("m_send","post");$m_sreplace=getForm("m_sreplace","post");
	$m_flag=getForm("m_flag","post")==1;
	if (trim($m_name) == "") { alertMsg("请填写过滤器名称","javascript:history.go(-1)");exit;}
	if ($m_uesmode == 0 && strlen($m_sfind) == 0) { alertMsg("请填写查找的字符","javascript:history.go(-1)");exit;}
	if ($m_uesmode == 1 && strlen($m_sstart) == 0) { alertMsg("请填写开始标记","javascript:history.go(-1)");exit;}
	if ($m_uesmode == 1 && strlen($m_send) == 0) { alertMsg("请填写结束标记","javascript:history.go(-1)");exit;}
	if (!empty($m_id)) {
		$fwordarr = array(
		'm_name' => $m_name,
		'm_rcolumn' => $m_rcolumn,
		'm_uesmode' => $m_uesmode,
		'm_sfind' => $m_sfind,
		'm_sstart' => $m_sstart,
		'm_send' => $m_send,
		'm_sreplace' => $m_sreplace,
		'm_flag' => $m_flag,
		);
		DB::update('fword', $fwordarr, array('m_ison' => 1,'m_id' => $m_id));
	} else {
		$fwordarr = array(
		'm_name' => $m_name,
		'm_rcolumn' => $m_rcolumn,
		'm_uesmode' => $m_uesmode,
		'm_sfind' => $m_sfind,
		'm_sstart' => $m_sstart,
		'm_send' => $m_send,
		'm_sreplace' => $m_sreplace,
		'm_flag' => $m_flag,
		'm_ison' => 1,
		);
	    DB::insert('fword', $fwordarr);
	}
	alertMsg("", "?action=filters");
}

function customernewcls() {
	$clsname = getForm("clsname","post");$m_type=getForm("m_type","post");
	if (empty($clsname)) { alertMsg("要转换有分类名还没填写","javascript:history.go(-1)");exit;}
	if (!is_numeric($m_type)) { alertMsg("未选择影射到系统分类","javascript:history.go(-1)");exit;}
	$clsarr = array(
	'clsname' => $clsname,
	'sysclsid' => $m_type,
	'publi' => 1,
	);
	DB::insert('cls', $clsarr);
	alertMsg("", "?action=customercls");
}

function customersavecls() {
	$ids = getForm("id","post");
	$back = getRefer();
	if (empty($ids)) { alertMsg("",$back);exit;}
	foreach ($ids as $id) {
		$clsname = getForm("clsname".$id,"post");
		if (empty($clsname)){ alertMsg("ID为".$id." 要转换有分类名还没填写","javascript:history.go(-1)");exit;}
		$m_type = getForm("m_type".$id,"post");
		if (!is_numeric($m_type)){ alertMsg("ID为".$id." 未选择影射到系统分类","javascript:history.go(-1)");exit;}
		DB::update('cls', array('clsname' => $clsname,'sysclsid' => $m_type),array('publi' => 1,'id' => $id));
	}
	alertMsg("", "?action=customercls");
}

function customerdelallcls() {
	$ids = getForm("id","post");$back = getRefer();
	if (!empty($ids)) DB::delete('cls', 'publi=1 AND id IN ('.dimplode($ids).')');
	alertMsg("", "?action=customercls");
}

function customerdelcls(){
	$id = getForm("id","get");
	$back = getRefer();
	DB::delete('cls', array('publi' => 1,'id' => $id));
	alertMsg("", $back);
}

function replaceSpecial($str){
	return replaceStr($str, "'", "".chr(34).chr(34)."");
}

function saveNews(){
	$actType = getForm("acttype","get");
	$x = 0;
	$m_id = getForm("m_id","post");if (!is_numeric($m_id)) $m_id=0;
	$m_vid = getForm("m_vid","post");if (!is_numeric($m_vid)) $m_vid=0;
	$m_title = getForm("m_title","post");
	$m_keyword = replaceStr(replaceStr(getForm("keyword","post"),chr(13),""),chr(10),"");
	$isuppingyin = getForm("isuppingyin","post")=="1";
	$m_entitle = getForm("m_entitle","post");if (empty($m_entitle)) $m_entitle = MoviePinYin($m_title);
	$m_hit = getForm("m_hit","post");if (!is_numeric($m_hit)) $m_hit=0;
	$m_back = getForm("m_back","post");
	$m_color = getForm("m_color","post");
	$m_type = getForm("m_type","post");if (empty($m_type)){ echoMsgAndGo("请选择分类",3,false);die("");}
	$m_pic = getForm("m_pic","post");
	$m_author = getForm("m_author","post");
	$m_outline = getForm("m_outline","post");
	$m_content = replaceSpecial(getForm("m_content","post"));
	$m_addtime = getForm("m_addtime","post");
	$m_note = getForm("m_note","post");
	$m_from = getForm("m_from","post");
	$m_commend = getForm("m_commend","post");if (is_numeric($m_commend)) $m_commend=intval($m_commend);else $m_commend=0;
	$isupdatetime = getForm("isupdatetime","post");
	$feedarr = array(
	    'm_keyword' => $m_keyword,
		'm_hit' => $m_hit,
		'm_letter' => msubstr($m_enname,1),
		'm_title' => $m_title,
		'm_color' => $m_color,
		'm_type' => $m_type,
		'm_pic' => $m_pic,
		'm_author' => $m_author,
		'm_outline' => $m_outline,
		'm_content' => $m_content,
		'm_from' => $m_from,
		'm_entitle' => $m_entitle,
		'm_commend' => $m_commend,
		'm_note' => $m_note,
	);
	switch (trim($actType)) {
		case "edit":
			if (!empty($isupdatetime)){ $feedarr['m_addtime'] = time();}
			DB::update('tempnews', $feedarr, array('m_id' => $m_id));
		    alertMsg("", $m_back);
		break;
	}
}

function delallTempData(){
	$ids = getForm("m_id","post");
	if (getForm("do","get") == "all") {
		DB::delete('tempnews');
	} else {
		DB::delete('tempnews', 'm_id IN ('.dimplode($ids).')');
	}
	alertMsg("", "?action=tempdatabase");
}

function delTempData(){
	$back = getRefer();$id = getForm("id","get");
	DB::delete('tempnews', array('m_id' => $id));
	alertMsg("", $back);
}

function import(){
	global $action;
	$result=trim(getForm("result","both"));$result=ifthen($result<>"",$result,getRefer());$smode=getForm("smode","both");$vtype=getForm("type","post");$rcount=getForm("rcount","both");$pcount=getForm("pcount","both");$m_typename=getForm("typename","both");$fields=getForm("fields","both");
	if (!empty($smode)) {
		$number = 250;
		$page=getForm("page","both");$page = ifthen($page < 1,1,$page);
		$idsArray = array();
		$whereStr=" WHERE 1";
		if ($smode<>"all") $whereStr .= " and m_inbase=0";
		if (!empty($m_typename)) $whereStr .= " and m_typename='".$m_typename."'";
		
		$sqlStr = "select m_id from ".DB::table('tempnews')." ".$whereStr."";
		$allRecordset = db::getCount($sqlStr);
		$tpagecount = ceil($allRecordset / $number);
		$page = max(intval($page), 1);
        $offset = $number * ($page - 1);
		$rcount = ifthen($rcount > 0, $rcount, $allRecordset);$pcount = ifthen($pcount > 0, $pcount, $tpagecount);
		$query = DB::query("$sqlStr limit $offset, $number");
        while($row = DB::fetch($query)) {
		      $idsArray[] = $row['m_id'];
		}
		if (count($idsArray) > 0) {
			echo "正在导入数据,当前是第<font color='red'>".$page."</font>页,共<font color='red'>".$pcount."</font>页,共<font color='red'>".$rcount."</font>部数据<hr />";
			import2Base($idsArray, $vtype,$fields);
			unset($idsArray);
			echo "<br>暂停3秒后继续导入<script language='javascript'>setTimeout(function (){location.href='?action=".$action."&smode=".$smode."&type=".$vtype."&typename=".urlencode($m_typename)."&page=".($page+1)."&pcount=".$pcount."&rcount=".$rcount."&result=".urlencode($result)."';},3000);</script>";
		} else {
			alertMsg("导入完成", $result);
        }
    } else {
		$ids = getForm("m_id","post");
		if (empty($ids)) {alertMsg("请选择数据",$result);exit();}
		import2Base($ids, $vtype,$fields);
		alertMsg("", $result);
   }
}

function getTypeAllId(){
	$tlist=getNewsTypeLists();$r="";
	foreach ($tlist as $row) {
		if ($r==""){
			$r=$row['m_id'];
	    }else{
			$r=$r.",".$row['m_id'];
	    }
	}
	return $r;
}

function import2Base($idsArray, $vtype,$fields) {
	if (count($idsArray)>0) {
		$darr = array();
		$ids = dimplode($idsArray);$fields = dimplode($fields);$allid=",".getTypeAllId().",";
		$query = DB::query("SELECT m_id,m_keyword,m_hit,m_letter,m_title,m_color,m_type,m_pic,m_author,m_outline,m_content,m_addtime,m_from,m_entitle,m_datetime,m_recycle,m_commend,m_vid,m_note,m_score FROM ".DB::table('tempnews')." WHERE m_id IN (".$ids.") ORDER BY m_addtime ASC");
        while($row = DB::fetch($query)) {
			$m_where = "";$sql = "";$title = $row['m_title'];$titleArray = explode("/",$title);
			$m_type = ifthen($row['m_type']>0, $row['m_type'], $vtype);
			if (!empty($m_type)) {
				foreach ($titleArray as $m_title) {
					if (!empty($m_title)) $m_where .= " or concat('/',m_title,'/') like '%/".$m_title."/%' ";
				}
				$m_where = ltrim($m_where," or");$m_entitle=MoviePinYin($title);
				$rs = DB::fetch_first("select m_id,m_type,m_pic from ".DB::table('news')." where ".$m_where."");
				if (is_array($rs)) $m_type=ifthen($m_type>0,$m_type,$rs["m_type"]);
				if (strpos($allid,",".$m_type.",")==0){
				    $m_type=0;
				}elseif (is_null($m_type)){
				     $m_type=0;
				}
				if ($m_type>0){
				    $row["m_title"]=getStrByLen($row["m_title"],255);
				    $row["m_author"]=getStrByLen($row["m_author"],80);
					if (!is_array($rs)) {
						$feedarr = array(
						    'm_keyword' => new_addslashes($row["m_keyword"]),
							'm_hit' => $row["m_hit"],
							'm_letter' => $row["m_letter"],
							'm_title' => new_addslashes($row["m_title"]),
							'm_type' => $m_type,
							'm_color' => $row['m_color'],
							'm_pic' => $row['m_pic'],
							'm_author' => $row['m_author'],
							'm_outline' => $row['m_outline'],
							'm_content' => new_addslashes($row['m_content']),
							'm_addtime' => $row['m_addtime'],
							'm_from' => $row['m_from'],
							'm_entitle' => $row['m_entitle'],
							'm_datetime' => time(),
							'm_recycle' => $row['m_recycle'],
							'm_commend' => $row['m_commend'],
							'm_addtime' => time(),
							'm_vid' =>$row['m_vid'],
							'm_note' =>$row['m_note'],
							'm_score' =>$row['m_score'],
						);
			            DB::insert('news', $feedarr);
					}else{
						$row["m_pic"]=ifthen(trim("".$rs["m_pic"])=="",$row["m_pic"],$rs["m_pic"]);
						if (isExistStr($fields,"title")){
								$darr['m_title'] = new_addslashes($row["m_title"]);
								$darr['m_letter'] = msubstr($m_entitle,1);
								$darr['m_entitle'] = $m_entitle;
					    }
					    if (isExistStr($fields,"author")) $darr['m_author'] = $row["m_author"];
						if (isExistStr($fields,"outline")) $darr['m_outline'] = $row["m_outline"];
						if (isExistStr($fields,"note")) $darr['m_note'] = $row["m_note"];
						if (isExistStr($fields,"pic")) $darr['m_pic'] = $row["m_pic"];
						if (isExistStr($fields,"content")) $darr['m_content'] = new_addslashes($row["m_content"]);
						if (isExistStr($fields,"commend")) $darr['m_commend'] = $row["m_commend"];
						if (isExistStr($fields,"keyword")) $darr['m_keyword'] = new_addslashes($row["m_keyword"]);
						if (isExistStr($fields,"now")) $darr['m_addtime'] = time();
						if (isExistStr($fields,"addtime")) $darr['m_addtime'] = $row["m_addtime"];
						if (isExistStr($fields,"from")) $darr['m_from'] = $row["m_from"];
						$darr['m_type'] = $m_type;
						DB::update('news', $darr, array('m_id' => $rs["m_id"]));
					}
					DB::update('tempnews', array('m_inbase' => 1,'m_type' => $m_type), array('m_id' => $row['m_id']));
				    echo "<font color=blue>导入成功 ID:".$row['m_id']."	".$row['m_title']."</font><br>";
				}
			} else {
				echo "<font color=red>没选择分类</font> 导入失败 ID:".$row['m_id']."	".$row['m_title']."<br>";
			}
		}
	}
}

function ghost() {
	$id = getForm("id","get");
	$row = DB::fetch_first("select * from ".DB::table('collect')." where publi=0 AND id=".$id);
	$feedarr = array(
	'itemname' => $row["itemname"]."[复制]",
	'siteurl' => $row["siteurl"],
	'charset' => $row["charset"],
	'playfrom' => $row["playfrom"],
	'enable' => $row["enable"],
	'intoa' => $row["intoa"],
	'autocls' => $row["autocls"],
	'classid' => $row["classid"],
	'isupdate' => $row["isupdate"],
	'getherday' => $row["getherday"],
	'inithit' => $row["inithit"],
	'pageset' => $row["pageset"],
	'pageurl0' => $row["pageurl0"],
	'pageurl1' => $row["pageurl1"],
	'pageurl2' => $row["pageurl2"],
	'istart' => $row["istart"],
	'iend' => $row["iend"],
	'reverse' => $row["reverse"],
	'removecode' => $row["removecode"],
	'des' => new_addslashes($row["des"]),
	'publi' => $row["publi"],
	'CollectTime' => time(),
	);
	DB::insert('collect', $feedarr);
	alertMsg("克隆成功","admin_collectnews.php?action=main");
}

function removeesfile() {
	$id = getForm("id","get");
	DB::delete('collect', array('publi' => 1,'id' => $id));
	die("<script>parent.location.reload();</script>");
}

function delAll() {
	$ids = getForm("m_id","post");
	DB::delete('collect', 'publi=1 AND id IN ('.dimplode($ids).')');
	alertMsg("","admin_collectnews.php?action=main");
}

function execesfile() {
	$id = getForm("id","get");$listnum = getForm("listnum");$movienum = getForm("movienum");$sb = getForm("sb");$cg = getForm("cg");$listurl = getForm("listurl");
	$txt = "";$listend = 0;
	if (!$listnum)
	    $listnum = 0;
    if (!$movienum)
	    $movienum = 0;
	if (!$sb && !$cg) {
		DB::update('collect', array('CollectTime' => time()),array('publi' => 1,'id' => $id));
	    $sb = 0;$cg = 0;
	    session_unset();
	    session_destroy();
    }
    $row = DB::fetch_first("select * from ".DB::table('collect')." where publi=1 AND id=$id");
	foreach ($row as $k => $v) {
		if (!isset($$k)) {
			$$k = stripslashes($v);
		}
	}
	$arr = unserialize(base64_decode($des));
	foreach ($arr as $l => $j) {
		if (!isset($$l)) {
			$$l = stripslashes($j);
		}
	}
	switch ($pageset){
	    case "0":if($listnum < 1) $listurl=  $pageurl0;else $listend = 1;break;
	    case "1":
	    case "3":
		    if ($reverse == 1){
				if ($istart > $iend){
					if (($iend + $listnum) > $istart || (($iend - $listnum) < 0)) {
				        $listend = 1;
			        } else {
				        $listurl = replaceStr($pageurl1, "{id}", ($iend+$listnum));
	                }
				} else {
			        if (($iend - $listnum) < $istart || (($iend - $listnum) < 0)) {
				        $listend = 1;
			        } else {
				        $listurl = replaceStr($pageurl1, "{id}", ($iend-$listnum));
	                }
				}
			} else {
				if ($istart > $iend){
					if (($istart - $listnum) < $iend) {
				        $listend = 1;
			        } else {
				        $listurl = replaceStr($pageurl1, "{id}", ($istart - $listnum));
			        }
				} else {
			        if (($istart + $listnum) > $iend) {
				        $listend = 1;
			        } else {
				        $listurl = replaceStr($pageurl1, "{id}", ($istart + $listnum));
			        }
				}
			}
		break; 
		case 2:
		    $listarray = explode(chr(13),$pageurl2);
            if (($listnum) >= count($listarray)) {
                $listend = 1;
			}else{
               $listurl = str_replace("\n","",$listarray[$listnum]);
			}
	    break; 
    }
    if ($listend == 1) {
        unset($_SESSION[$id.$listnum]);
        session_unset();
        session_destroy();
        $txt.="采集完成";
    } else {
	    $movienumid = $movienum;
	    $listcode = GetHttpTextFile($listurl, $charset);
	    if ($listcode == false) {
		     showerr("在获取:".$listurl."网页源码时发生错误","admin_collectnews.php");
	    }
	    if ($pageset == 3) {
		    $listnum = $listnum + 1;
		    $newscode = $listcode;
		    $urltest = $listurl;
	    } else {
		    $acad = isset($_SESSION[$id.$listnum]) ? $_SESSION[$id.$listnum] : '';
		    if (!$acad) {
			    $x = StrSliceB($listcode, $listA, $listB);
	            $z = StrSplits($x, $mlinkA, $mlinkB);
			    if ($isspecial == 1) {
				    $z= SpecialLinks($z, $mlinkRF, $mlinkRR);
		        }
			    $z = paseAbsURI($z, $listurl);
			    $z = array_unique($z);$zl=count($z);
			    if ($picmode == 1) {
			        if (!empty($picA) && !empty($picB)) {
			            $mcls['m_pic'] = StrSlice($x, $picA, $picB);
			        }
		        }
			    $y	= $zl + 1;
		        if ($zl == 0) {
				    $txt.="<font color=red><b>在获取链接列表时出错</b></font>";
				    $sb++;
			    }
			    $_SESSION[$id.$listnum] = $z;
			    unset($_SESSION[$id.$listnum-1]);
		    }
		    $newsarray = $_SESSION[$id.$listnum];
		    if (count($newsarray)-$movienum <= 1) {
			    $listnum=  $listnum + 1;
			    $movienum = 0;
		    } else {
			    $movienum++;
		    }
        $urltest = $newsarray[$movienumid];
	    $newscode = GetHttpTextFile($urltest, $charset);
	    }
	if ($newscode == false) {
	    $txt.="<font color=red><b>在获取内容页时出错。</b></font>";
	    $sb++;
	} else {
		$t=StrSlice($newscode, $nameA, $nameB);$t=fword($t, 0);$t=RemoveHTMLCode($t,"*");
	    $mcls['m_name'] = trim($t);
		if ($picmode == 0) {
			if (!empty($picA) && !empty($picB)) {
			    $m_pic = paseAbsURI(StrSlice($newscode, $picA, $picB), $urltest);
		        $mcls['m_pic'] = $m_pic[0];
			}
		}
		//判断数据介绍开始代码
		$y=$desA;$z=$desB;
		if (!empty($y) && !empty($z)) {
			$txt3 = RemoveHTMLCode(fword(StrSlice($newscode, $y, $z), 1), $removecode);
		}else{
			$txt3 = '';
	    }
		//die($txt3);
		if ($splay == 1) {
		    $txt2 = StrSlice($newscode, $plistA, $plistB);
		    $tt = StrSplits($txt2, $plinkA, $plinkB);
			if ($isspecial == 1) {
			    $tt = SpecialLinks($tt, $linkRF, $linkRR);
			}
		    $tt = array_unique(paseAbsURI($tt, $url));$t=count($tt);
		    if ($t>'-1'){
			    echo("正在截取<font color=red>".($t+1)."</font>页面上的文章内容，可能要花上1分钟。请稍候...<br />");
			    for ($i = 0;$i < $t;$i++) {
				    $txt3 .= "#p#第".($i+2)."页#e#".RemoveHTMLCode(fword(StrSlice(GetHttpTextFile($tt[$i],$charset), $y, $z), 1), $removecode);
				}
			}
		}
		$mcls["m_des"]=$txt3;
		$txt2	= "<pre>来源地址: " .$urltest."\n";
		if ($mcls['m_name']<>"" && $txt3!=""){
			if ($autocls==false){
			    $mcls['m_type'] = $classid;
			    $mcls["m_typename"] = viewDataType($classid);
			}else{
			    if (!empty($clsA) && !empty($clsB)) {
				    $t	= RemoveHTMLCode(StrSlice($newscode, $clsA, $clsB),"*");
				    $mcls["m_typename"] = $t;
				}
			    $mcls['m_type'] = newssmartGeneralize($t,$mcls["m_name"]);
			}
			//判断数据日期开始代码
			if (!empty($dateA) && !empty($dateB)) {
			    $t=RemoveHTMLCode(StrSlice($newscode, $dateA, $dateB),"*");
			    if (strtotime($t)){
				    $mcls["m_addtime"] = strtotime($t);
		        }else{
				    $mcls["m_addtime"] = time();
		        }
		    }else{
			    $mcls["m_addtime"] = time();
		    }
			//判断数据作者开始代码
			if (!empty($authorA) && !empty($authorB)) {
			    $mcls["m_author"] = RegReplace(RemoveHTMLCode(StrSlice($newscode, $authorA, $authorB),"*"),"/(\s+)|[\|\/]/i"," ");
		    }
			//判断数据关键字开始代码
			if (!empty($keysA) && !empty($keysB)) {
			    $mcls["m_keyword"] = RegReplace(RemoveHTMLCode(StrSlice($newscode, $keysA, $keysB),"*"),"/(\s+)|[\|\/]/i"," ");
		    }
			//判断数据简述开始代码
			if (!empty($outlineA) && !empty($outlineB)) {
			    $mcls["m_outline"] = RegReplace(RemoveHTMLCode(StrSlice($newscode, $outlineA, $outlineB),"*"),"/(\s+)|[\|\/]/i"," ");
		    }
			//判断数据来源开始代码
			if (!empty($fromA) && !empty($fromB)) {
			    $mcls["m_from"] = RegReplace(RemoveHTMLCode(StrSlice($newscode, $fromA, $fromB),"*"),"/(\s+)|[\|\/]/i"," ");
		    }
			//判断入库方式
			if ($intoa == 1 && $tid != 0) {
				$sburl = 0;$cg++;
                $tablename = "news";
			    $whereStr = " where m_title like '%$m_name%'";
			} else {
                $intoa = 0;
                $tablename = "tempnews";
			    $whereStr = " where m_fromurl='$urltest' or m_title like '%{$mcls['m_name']}%'";
			}
			$r = DB::fetch_first("select m_id,m_type from ".DB::table($tablename)."$whereStr");
			if (!is_array($r)) {
				$feedarr = array(
				    'm_title' => $mcls['m_name'],
					'm_type' => $mcls['m_type'],
					'm_letter' => $mcls['m_letter'],
					'm_datetime' => time(),
				);
                if (!empty($mcls["m_pic"])) $feedarr['m_pic'] = $mcls['m_pic'];
                if (!empty($mcls["m_from"])) $feedarr['m_from'] = $mcls['m_from'];
                if (!empty($mcls["m_author"])) $feedarr['m_author'] = $mcls['m_author'];
                if (!empty($mcls["m_keyword"])) $feedarr['m_keyword'] = $mcls['m_keyword'];
                if (!empty($mcls["m_outline"])) $feedarr['m_outline'] = $mcls['m_outline'];
                if (!empty($mcls["m_addtime"])){ $feedarr['m_addtime'] = $mcls['m_addtime'];} else { $feedarr['m_addtime'] = time();}
                if (!empty($mcls["m_des"])) $feedarr['m_content'] = new_addslashes($mcls['m_des']);
				if ($intoa==0){ $feedarr['m_typename'] = $mcls['m_typename'];$feedarr['m_fromurl'] = $urltest;}
				DB::insert($tablename, $feedarr);
				$cg++;
			} else {
				$feedarr = array(
				    'm_title' => $mcls['m_name'],
					'm_type' => $mcls['m_type'],
					'm_letter' => $mcls['m_letter'],
					'm_datetime' => time(),
				);
                if (!empty($mcls["m_pic"])) $feedarr['m_pic'] = $mcls['m_pic'];
                if (!empty($mcls["m_from"])) $feedarr['m_from'] = $mcls['m_from'];
                if (!empty($mcls["m_author"])) $feedarr['m_author'] = $mcls['m_author'];
                if (!empty($mcls["m_keyword"])) $feedarr['m_keyword'] = $mcls['m_keyword'];
                if (!empty($mcls["m_outline"])) $feedarr['m_outline'] = $mcls['m_outline'];
                if (!empty($mcls["m_addtime"])){ $feedarr['m_addtime'] = $mcls['m_addtime'];} else { $feedarr['m_addtime'] = time();}
                if (!empty($mcls["m_des"])) $feedarr['m_content'] = new_addslashes($mcls['m_des']);
				if ($intoa==0){ $feedarr['m_typename'] = $mcls['m_typename'];$feedarr['m_fromurl'] = $urltest;}
				DB::update($tablename, $feedarr, array('m_id' => $r['m_id']));
				$sb++;
			}
		    $txt2 .= "标  题: ".$mcls['m_name']."<br>";
		    $txt2 .= "分  类: ".$mcls["m_typename"]."<br>";
		    $txt2 .= "来  源: ".$mcls["m_from"]."<br>";
		    $txt2 .= "作  者: ".$mcls["m_author"]."<br>";
		    $txt2 .= "日  期: ".date('Y-m-d H:i:s',$mcls["m_addtime"])."<br>";
		    $txt2 .= "图  片: ".$mcls['m_pic']."<br>";
		    $txt2 .= "关键词: ".$mcls["m_keyword"]."<br>";
		    $txt2 .= "简  述: ".$mcls["m_outline"]."<br>";
		    $txt2 .= "正  文: ".htmlspecialchars($mcls["m_des"])."<br>";
		}else{;
		    $txt2 .= "忽略无效文章: ".$mcls['m_name']." 原因: ".ifthen(trimall($mcls['m_name'])=="","没有标题","没有文章正文");
		}
	}
	echo "<meta http-equiv=\"refresh\" content=\"0;url=admin_collectnews.php?action=exec&id=".$id."&listnum=".$listnum."&movienum=".$movienum."&sb=".$sb."&cg=".$cg."\">";
}
?>
	<table class="tb">
	<thead>
		<tr class="thead"><th>正在执行:<?=$itemname?>&nbsp;</span>重新修改请点这 <a href="?action=edit&id=<?=$id?>">编辑</a> <a href="?action=main">返回项目列表</a></th></tr>
	</thead>
</table>
</table>
<hr style="border:1px solid #DEEFFA" />
<table>
<tr>
<td width=224>项目: <font color='red'><?=$itemname?></font></td>
<td>地址: <a href="javascript:void(0);" onClick="window.open('<?=$listurl?>','_blank');"><font color='red'><?=$listurl?></font></a></td>
</tr>
</table>
<table>
<td width=120>采集统计：</td>
<td width=100>成功采集 <font color=red><?=$cg;?></font></td>
<td width=120><?php switch (gatherSet) {
	                    case "0":echo "智能覆盖";break;
	                    case "1":echo "地址头部追加";break;
	                    case "2":echo "地址尾部追加";break;
	                    case "3":echo "覆盖地址";break;
	                    case "4":echo "新增数据";break;
	                    case "5":echo "仅更新地址以外的信息";break;
                    };?> <font color=red><?=$sb?></font></td>
</tr>
</table>
<hr style="border:1px solid #DEEFFA" /><pre><?=$txt2?>
</pre></div>
<?php
}

function GetHttpTextFile($httpurl, $cset) {
	if (strlen($httpurl) < 18 || !$httpurl)
		return false;
	$httpcontent=getRemoteContent($httpurl);
	if ($httpcontent)
		if ($cset=="UTF-8"){
			return utf82gb($httpcontent);
		} else if ($cset=="BIG5"){
			return big5_to_gbk($httpcontent);
		} else { 
		    return $httpcontent;
		}
	else
		return false;
}

function paseAbsURI($Links, $currUrl) {
	$Links=ifthen(is_array($Links),$Links,array($Links));
	for ($i = 0;$i < count($Links);$i++) {
		$Links[$i]=FixPath($Links[$i], $currUrl);
	}
	return $Links;
}

function FixPath($aim, $baseUrl) { 
    $strSource = $baseUrl; 
    if (preg_match_all('/([^:\\/]+)\//', $strSource, $aryResult1, PREG_PATTERN_ORDER)) { 
        $intUrlLevel= count($aryResult1[0]); 
    } else { 
        $intUrlLevel = 0; 
        preg_match_all('/http:\/\/(.+?)$/', $strSource, $aryResult1, PREG_PATTERN_ORDER); 
        $aryResult1[0][0] = $aryResult1[1][0] . "/"; 
    }
    $strSource = $aim; 
    if (substr($strSource,0,7) == 'http://') { 
        return $aim; 
    } else {
	    if (preg_match_all("/^\//",$strSource, $aryResult2, PREG_PATTERN_ORDER)){ 
		    $strAimUrl = "http://" . $aryResult1[1][0] . str_replace("../","",$aim); 
		} else { 
			preg_match_all('/(\\.\\.\/)/', $strSource, $aryResult2, PREG_PATTERN_ORDER); 
			$intAimUrlLevel= count($aryResult2[0]); 
			if ($intUrlLevel<=$intAimUrlLevel){ 
		        $strAimUrl = "http://" . $aryResult1[0][0] . str_replace("../","",$aim); 
			} else { 
				$strAimUrl = "http://" . implode("",array_slice ($aryResult1[0], 0, $intUrlLevel - $intAimUrlLevel)) . str_replace("../","",$aim); 
			} 
		} 
	    return $strAimUrl; 
	}
}

function getTidFromCls($name){
	$trow = DB::fetch_first("SELECT sysclsid FROM ".DB::table('cls')." WHERE publi=1 AND clsname='$name'");
	if (is_array($trow)) return $trow['sysclsid'];
	else return 0;
}

function SpecialLinks($sLink,$fLink,$rLink){
	$t=explode("[变量]",$fLink);
	$rLink=explode("[变量]",$rLink);
	$rLink=implode("$"."1",$rLink);
	if (count($a)<1){
		return $sLink;
	}else{
	    for ($i = 0;$i < count($a);$i++) {
		    $t[$i]=addcslashes($a[$i]);
	    }
	    $fLink=implode("([\w\W]+)",$t);
		for ($i = 0;$i < count($sLink);$i++) {
			$sLink[$i]=preg_replace("/".$fLink."/i",$rLink,$sLink[$i]);
		}
	}
	return $sLink;
}

function fword($Str, $rCol) {
	if (empty($Str)) return $Str;
	$sqlStr = "select `m_rcolumn`,`m_uesmode`,`m_sfind`,`m_sreplace`,`m_sstart`,`m_send` from ".DB::table('fword')." where m_ison=1 AND m_flag=1";
	$query = DB::query($sqlStr);
    while($row = DB::fetch($query)) {
		if ($row["m_rcolumn"] == $rCol) {
            if ($row["m_uesmode"] == 1){
	            if ($row["m_sstart"].$row["m_send"] != "") {
					$labelRule = $row["m_sstart"]."(.*?)".$row["m_send"];
					preg_match_all(buildregx($labelRule, "is"), $Str, $ar);
					$Str=replaceStr($Str,$ar[1],$row["m_sreplace"]);
	            }
	        } else {
	            if ($row["m_sfind"] != "") {
	                $Str=replaceStr($Str,$row["m_sfind"],$row["m_sreplace"]);
	            }
	        }
	    }
	}
	return $Str;
}

function RegReplace($Str,$rule,$value)
{
	if (!empty($Str)){
		$result_text = preg_replace($rule,$value,$Str);
	}
	return $result_text;
}

function trimall($Str){
	return RegReplace($Str,"/(\s*)/is","");
}

function removeHTMLCode($Str="",$cHas=""){
	if($cHas=="" || $Str=="") return $Str;
	$cHas = trimall(strtoupper($cHas));
	$cHas = explode("|",$cHas);
	for($i=0;$i<count($cHas);$i++)
	{
		switch($cHas[$i])
		{
			case "TABLE":
				$Str=preg_replace("/<\/?(table|thead|tbody|tr|th|td).*>/i","",$Str);
			break;
			case "OBJECT":
				$Str=preg_replace("/<\/?(object|param|embed).*>/i","",$Str);
			break;
			case "SCRIPT":
				$Str=preg_replace("/<script.*>[\w\W]+?<\/script>/i","",$Str);
				$Str=preg_replace("/\\on[\w]+=[\\'\\\"].+?[\\'\\\"](\s|>)/i","$1",$Str);
			break;
			case "STYLE":
				$Str=preg_replace("/<style.*>[\w\W]+?<\/style>/i","",$Str);
			break;
			case "CLASS":
				$Str=preg_replace("/\sclass=.+?(\s|>)/i","$1",$Str);
			break;
			case "*":
				$Str = removeHTMLCode($Str,"SCRIPT|STYLE");
				$Str = preg_replace("/<.*?>/i","",$Str);
				$Str= replaceStr(replaceStr($Str,"<","&lt;"),">","&gt;");
			break;
			default:
				$Str = preg_replace("/<\/?".$cHas[$i].".*?>/i","",$Str);
			break;
		}
		
	}
	return replaceStr($Str,"&nbsp;"," ");

}

function filterQuote($Str) {
   return replaceStr("".$Str,"'","");
}

//智能归类(sClsName 类名)
function newssmartGeneralize($sClsName){
	$sClsName=filterQuote(trim($sClsName));$newssmartGeneralize=0;
	if ($sClsName=="")  return '';
	if ($sClsName<>""){
		$trow = DB::fetch_first("SELECT sysclsid FROM ".DB::table('cls')." WHERE publi=1 AND clsname='$sClsName'");
	    if (is_array($trow)) $newssmartGeneralize=$trow['sysclsid'];
	}
	if ($newssmartGeneralize>0) return $newssmartGeneralize;
	if ($newssmartGeneralize==0 && $sClsName<>""){
		$trow = DB::fetch_first("SELECT m_id FROM ".DB::table('type')." WHERE m_type=1 AND m_name='$sClsName'");
	    if (is_array($trow)) $newssmartGeneralize=$trow['m_id'];
		if ($newssmartGeneralize==0){
		    $trow = DB::fetch_first("SELECT m_id FROM ".DB::table('type')." WHERE m_type=1 AND m_name LIKE '%$sClsName%'");
	        if (is_array($trow)) $newssmartGeneralize=$trow['m_id'];
		}
	}
	return $newssmartGeneralize;
}

function viewDataType($str) {
	$viewDataType = explode(",", getNewsTypeNameTemplateArrayOnCache(intval($str)));
	if(empty($viewDataType[0])) $viewDataType[0]="<font color=red >数据分类错误</font>";
	return $viewDataType[0];
}
?>
