 <?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 "saveVideo":saveVideo();break;
	case "import":Heades();import();Footer();break;
	case "editVideo":Heades();editVideo();popDiv();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 "cregion":Heades();cregion();Footer();break;
	case "cregionsave":cregionsave();break;
	case "cregionnew":cregionnew();break;
	case "cregiondel":cregiondel();break;
	case "cregiondelall":cregiondelall();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' => $arr[publi],
			'CollectTime' => $arr[CollectTime],
	    );
		if(DB::insert('collect',$feedarr)){
		    selectMsg("保存成功，是否自动跳转到预览界面?", $referer, "admin_collect.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_collect.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=0 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_collect.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>智能采集工具</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. yhcms</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");
	$fields=dimplode(getForm("fields","both"));
	$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"),
	'picmode' => getForm("picmode","post"),
	'mdataA' => getForm("mdataA","post"),
	'mdataB' => getForm("mdataB","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"),
	'playgetsrc' => getForm("playgetsrc","post"),
	'playlinkA' => getForm("playlinkA","post"),
	'playlinkB' => getForm("playlinkB","post"),
	'isspecial' => getForm("isspecial","post"),
	'linkRF' => getForm("linkRF","post"),
	'linkRR' => getForm("linkRR","post"),
	'msrcA' => getForm("msrcA","post"),
	'msrcB' => getForm("msrcB","post"),
	'getpart' => getForm("getpart","post"),
	'partA' => getForm("partA","post"),
	'partB' => getForm("partB","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,"actor")){ 
	    $darr['actorA'] = getForm("actorA","post");
		$darr['actorB'] = getForm("actorB","post");
	} else {
		$darr['actorA'] = '';
		$darr['actorB'] = '';
	}
	if (isExistStr($fields,"director")){ 
	    $darr['directorA'] = getForm("directorA","post");
		$darr['directorB'] = getForm("directorB","post");
	} else {
		$darr['directorA'] = '';
		$darr['directorB'] = '';
	}
	if (isExistStr($fields,"state")){ 
	    $darr['stateA'] = getForm("stateA","post");
		$darr['stateB'] = getForm("stateB","post");
	} else {
		$darr['stateA'] = '';
		$darr['stateB'] = '';
	}
	if (isExistStr($fields,"note")){ 
	    $darr['noteA'] = getForm("noteA","post");
		$darr['noteB'] = getForm("noteB","post");
	} else {
		$darr['noteA'] = '';
		$darr['noteB'] = '';
	}
	if (isExistStr($fields,"keys")){ 
	    $darr['keysA'] = getForm("keysA","post");
		$darr['keysB'] = getForm("keysB","post");
	} else {
		$darr['keysA'] = '';
		$darr['keysB'] = '';
	}
	if (isExistStr($fields,"year")){ 
	    $darr['yearA'] = getForm("yearA","post");
		$darr['yearB'] = getForm("yearB","post");
	} else {
		$darr['yearA'] = '';
		$darr['yearB'] = '';
	}
	if (isExistStr($fields,"lang")){ 
	    $darr['langA'] = getForm("langA","post");
		$darr['langB'] = getForm("langB","post");
	} else {
		$darr['langA'] = '';
		$darr['langB'] = '';
	}
	if (isExistStr($fields,"area")){ 
	    $darr['areaA'] = getForm("areaA","post");
		$darr['areaB'] = getForm("areaB","post");
	} else {
		$darr['areaA'] = '';
		$darr['areaB'] = '';
	}
	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,
	'CollectTime' => time(),
	);
	if ($id) {
	    DB::update('collect', $feedarr, array('publi' => 0,'id' => $id));
	    alertMsg("修改成功","admin_collect.php?action=main");
	} else {
		DB::insert('collect', $feedarr);
	    alertMsg("保存成功","admin_collect.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=0 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,$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;
		$pageset=0;
	}
?>
<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($itemname=="","1. 通过本向导将传统的采集规则转换成采集规则文件","1.修改采集规则文件：<span class=\"red\">".$itemname."</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>
<?php $t = $intoa?>
		<tr style="display:none">
			<td class="label">入库方式：</td>
			<td><input type="radio" class="radio" name="into" value="0" <?=ifthen($t==0,"checked","")?> /><span class="red">临时库</span> <input type="radio" class="radio" name="into" value="1" <?=ifthen($t==0,"","checked")?>/>直接入库(不建议使用，会损成数据库很大 或 损坏)</td>
		</tr>
		<tr style="display:none">
			<td class="label">只采集最近：</td>
			<td><select name="getherday" onChange="if(this.value=='0'){hide('datebody')}else{show('datebody')}"><option value="0">不限</option><?php for($i=1;$i<=31;$i++){echo "<option value='".$i."'".ifthen($getherday==$i," selected","").">".$i."</option>";}?></select> 天 * 选择天数还要填写第3步的 <span class="red">数据日期 开始 和 结束</span>才有效</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>
		<tr>
			<td class="label">播放来源：</td>
			<td><select name='playfrom'><option value=''>暂没有数据</option><?=makePlayerSelect($playfrom)?></select></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><?=makeTypeOptionSelected(0,"&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_1');"<?=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($mlinkRF)?></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($mlinkRR)?></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="actor" value="actor" onClick="if(this.checked){show('actorbody')}else{hide('actorbody')}"<?=ifthen($actorA.$actorB<>""," checked","")?>/><label for="actor">演员</label>
				<input type="checkbox" class="checkbox" name="fields[]" id="director" value="director" onClick="if(this.checked){show('directorbody')}else{hide('directorbody')}"<?=ifthen($directorA.$directorB<>""," checked","")?>/><label for="director">导演</label>
				<input type="checkbox" class="checkbox" name="fields[]" id="state" value="state" onClick="if(this.checked){show('statebody')}else{hide('statebody')}"<?=ifthen($stateA.$stateB<>""," checked","")?>/><label for="state">连载</label>
				<input type="checkbox" class="checkbox" name="fields[]" id="note" value="note" onClick="if(this.checked){show('notebody')}else{hide('notebody')}"<?=ifthen($noteA.$noteB<>""," checked","")?>/><label for="note">备注</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="year" value="year" onClick="if(this.checked){show('yearbody')}else{hide('yearbody')}"<?=ifthen($yearA.$yearB<>""," checked","")?>/><label for="year">年份</label>
				<input type="checkbox" class="checkbox" name="fields" id="lang" value="lang" onclick="if(this.checked){show('langbody')}else{hide('langbody')}"<?=ifthen($langA.$langB<>""," checked","")?><label for="lang">语言</label>
				<input type="checkbox" class="checkbox" name="fields[]" id="area" value="area" onClick="if(this.checked){show('areabody')}else{hide('areabody')}"<?=ifthen($areaA.$areaB<>""," checked","")?>/><label for="area">地区</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="actorA" rows="4" cols="80"><?=new_htmlspecialchars($actorA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">演员结束：</td>
			<td><textarea name="actorB" rows="4" cols="80"><?=new_htmlspecialchars($actorB)?></textarea></td>
		</tr>
	</tbody>
	<tbody id="directorbody" style="<?=ifthen($directorA.$directorB=="","display:none","")?>">
		<tr>
			<td class="label">导演开始：</td>
			<td><textarea name="directorA" rows="4" cols="80"><?=new_htmlspecialchars($directorA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">导演结束：</td>
			<td><textarea name="directorB" rows="4" cols="80"><?=new_htmlspecialchars($directorB)?></textarea></td>
		</tr>
	</tbody>
	<tbody id="statebody" style="<?=ifthen($stateA.$stateB=="","display:none","")?>">
		<tr>
			<td class="label">连载开始：</td>
			<td><textarea name="stateA" rows="4" cols="80"><?=new_htmlspecialchars($stateA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">连载结束：</td>
			<td><textarea name="stateB" rows="4" cols="80"><?=new_htmlspecialchars($stateB)?></textarea></td>
		</tr>
	</tbody>
	<tbody id="notebody" style="<?=ifthen($noteA.$noteB=="","display:none","")?>">
		<tr>
			<td class="label">备注开始：</td>
			<td><textarea name="noteA" rows="4" cols="80"><?=new_htmlspecialchars($noteA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">备注结束：</td>
			<td><textarea name="noteB" rows="4" cols="80"><?=new_htmlspecialchars($noteB)?></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="yearbody" style="<?=ifthen($yearA.$yearB=="","display:none","");?>">
		<tr>
			<td class="label">年份开始：</td>
			<td><textarea name="yearA" rows="4" cols="80"><?=new_htmlspecialchars($yearA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">年份结束：</td>
			<td><textarea name="yearB" rows="4" cols="80"><?=new_htmlspecialchars($yearB)?></textarea></td>
		</tr>
	</tbody>
	<tbody id="langbody" style="<?=ifthen($langA.$langB=="","display:none","")?>">
		<tr>
			<td class="label">语言开始：</td>
			<td><textarea name="langA" rows="4" cols="80"><?=new_htmlspecialchars($langA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">语言结束：</td>
			<td><textarea name="langB" rows="4" cols="80"><?=new_htmlspecialchars($langB)?></textarea></td>
		</tr>
	</tbody>
	<tbody id="areabody" style="<?=ifthen($areaA.$areaB=="","display:none","")?>">
		<tr>
			<td class="label">地区开始：</td>
			<td><textarea name="areaA" rows="4" cols="80"><?=new_htmlspecialchars($areaA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">地区结束：</td>
			<td><textarea name="areaB" rows="4" cols="80"><?=new_htmlspecialchars($areaB)?></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>
	</tbody>
<?php $t = $playgetsrc;?>
	<tbody>
		<tr>
			<td class="label red">获取数据地址方式：</td>
			<td><input type="radio" class="radio" name="playgetsrc" value="1" onClick="show('playlinkbody')"<?=ifthen($t==1,"checked","")?>/>播放页获取单个数据地址<input type="radio" class="radio" name="playgetsrc" value="2" onClick="show('playlinkbody')"<?=ifthen($t==2,"checked","")?>/>播放页获取所有数据地址<input type="radio" class="radio" name="playgetsrc" value="0" onClick="hide('playlinkbody');clearvalue('playlinkA','playlinkB');"<?=ifthen($t==0,"checked","")?>/>内容页直接获取数据地址</td>
		</tr>
	</tbody>
	<tbody id="playlinkbody" style="<?=ifthen($t==1 || $t==2,"","display:none")?>">
		<tr>
			<td class="label">播放链接开始：</td>
			<td><textarea name="playlinkA" rows="4" cols="80"><?=new_htmlspecialchars($playlinkA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">播放链接结束：</td>
			<td><textarea name="playlinkB" rows="4" cols="80"><?=new_htmlspecialchars($playlinkB)?></textarea></td>
		</tr>
	</tbody>
	<tbody>
<?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">实际连接:play.php?id=$1</p><textarea name="linkRR" rows="4" cols="80"><?=new_htmlspecialchars($linkRR)?></textarea></td>
		</tr>
	</tbody>
	<tbody>
		<tr>
			<td class="label">数据地址开始：</td>
			<td><textarea name="msrcA" rows="4" cols="80"><?=new_htmlspecialchars($msrcA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">数据地址结束：</td>
			<td><textarea name="msrcB" rows="4" cols="80"><?=new_htmlspecialchars($msrcB)?></textarea></td>
		</tr>
<?php $t=$getpart;?> 
		<tr>
			<td class="label red">采集数据分集名称：</td>
			<td><input type="radio" class="radio" name="getpart" value="0" onClick="hide('getpartbody');"<?=ifthen($t==true,"","checked")?>/>系统预设<input type="radio" class="radio" name="getpart" value="1" onClick="show('getpartbody')"<?=ifthen($t==true,"checked","")?>/>截取分集名称</td>
		</tr>
	</tbody>
	<tbody id="getpartbody" style="<?=ifthen($t==true,"","display:none")?>">
		<tr>
			<td class="label">分集名称开始：</td>
			<td><textarea name="partA" rows="4" cols="80"><?=new_htmlspecialchars($partA)?></textarea></td>
		</tr>
		<tr>
			<td class="label">分集名称结束：</td>
			<td><textarea name="partB" rows="4" cols="80"><?=new_htmlspecialchars($partB)?></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_collect.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':"名称",'actor': "演员",'director':'导演','cls': '分类','date': '日期','year': '年份','lang': '语言','area': '地区','note': '备注','state': '连载','keys': '关键词'};
			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['msrc']='数据地址',has['plist']='播放列表',has['playlink']='播放链接',has['linkR']='特殊链接处理';
			var ch=function (R){
			var txt=R.responseText;
				sa=ReCrlf(es["msrcA"].value),sb=ReCrlf(es["msrcB"].value);
				val['msrc']=StrSplits(txt,sa,sb).join("\r\n");
				if(val['msrc']=='') val['msrc']=false;
				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['actor'] || '')+"\r\n\
导  演："+trimall(val['director'] || '')+"\r\n\
连  载："+trim(val['state'] || '')+"\r\n\
备  注："+trim(val['note'] || '')+"\r\n\
关键词："+trimall(val['keys'] || '')+"\r\n\
年  份："+trim(val['year'] || '')+"\r\n\
语  言："+trim(val['lang'] || '')+"\r\n\
地  区："+trim(val['area'] || '')+"\r\n\
时  间："+trim(val['date'] || '')+"\r\n\
地  址：\r\n"+trim(val['msrc'] || '')+"\r\n\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];
			}
			if(es['playgetsrc'][0].checked || es['playgetsrc'][1].checked){
				k='playlink',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=0 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"><?php if(empty($row['playfrom'])) echo "没有指定播放器"; else echo $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");$playfrom=getForm("playfrom","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($m_typename)) $whereStr .= " and m_typename='".$m_typename."";
	if (!empty($keyword)) $whereStr .= " and `m_name` like '%".$keyword."%' or `m_actor` like '%".$keyword."%' ";
    if (!empty($playfrom)) $whereStr .= " and m_playdata like '%".$playfrom."$$%' ";
    $whereorder = str_replace("where and", "where", $whereStr);
    $sqlStr = "SELECT * FROM ".DB::table('tempdata')." ".$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></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="200">采集时间</td>
		<td width="50" 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_name']?></td>
		<td><?php if ($row['m_inbase']) echo "已入库"; else echo "未入库";?></td>
		<td>&nbsp;<?php echo getFromStr($row['m_playdata']);?></td>
		<td><?php if ($row['m_type'] != 0) echo viewDataType($row['m_type']); else echo "<font color=red>没找到相关分类</font>";?></td>
		<td>&nbsp;<?=$row['m_typename']?></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="playdata" checked>播放地址
			<input type="checkbox" class="checkbox" name="fields[]" value="name">名称
			<input type="checkbox" class="checkbox" name="fields[]" value="actor" checked>演员
			<input type="checkbox" class="checkbox" name="fields[]" value="area" checked>地区
			<input type="checkbox" class="checkbox" name="fields[]" value="state" checked>连载
			<input type="checkbox" class="checkbox" name="fields[]" value="note" checked>备注
			<input type="checkbox" class="checkbox" name="fields[]" value="pic" checked>图片
			<input type="checkbox" class="checkbox" name="fields[]" value="year" checked>年份
			<input type="checkbox" class="checkbox" name="fields[]" value="des" checked>介绍
			<input type="checkbox" class="checkbox" name="fields[]" value="director">导演
			<input type="checkbox" class="checkbox" name="fields[]" value="leng">语言
			<input type="checkbox" class="checkbox" name="fields[]" value="keyword">关键词
			<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="radio" class="radio" name="gatherset" value="0" checked/>智能覆盖
			<input type="radio" class="radio" name="gatherset" value="1" />地址头部追加
			<input type="radio" class="radio" name="gatherset" value="2" />地址尾部追加
			<input type="radio" class="radio" name="gatherset" value="3" />覆盖地址
			<input type="radio" class="radio" name="gatherset" value="4" />新增数据
			<input type="radio" class="radio" name="gatherset" value="5" />仅更新地址以外的信息
		</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 makeTypeOption(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)?>入库方式：<span class=red><?=$iMode?></span> &nbsp;&nbsp;<a href="?action=delallTempData&do=all" onClick="if(confirm('确定要删除所有吗')){return true;}else{return false;}"><u>清空临时库</u></a></td></tr>
</form>
<?php }?>
</table>
<?php
}

function popDiv() {
?>
<div id="gathervideo" style="top:100px; display:none;" class="popdiv">
<div class="poptitie"><img src="../pic/btn_close.gif" alt="关闭" onClick="$('gathervideo').style.display='none';selectTogg()" />WEB采集助手</div>
	<div class="popbody"><div>
	<table ><tr><td><input name='areaid' id='areaid' type='hidden' value=""><input type="text" name="gatherurl" id="gatherurl" size="60" /> <input type="button" onClick="gather()"   class="btn" value="分   析"/><span id="loading" style="display:none"><img src="imgs/loading2.gif" width="16" height="16"><font color="#FF0000">分析数据中</font></span></td></tr>
	<tr><td><textarea id="gathercontent" cols="72" rows="9"></textarea></td></tr>
	<tr><td><input type="button" onClick="insertResult(1);selectTogg()"   class="btn" value="添  加"/> <input type="button" value="倒 序" style="margin-left:30px;margin-right:10px" onClick="reverseOrder()" class="btn"   />将<input type="text" size="10" id='replace1' />替换成<input type="text" id='replace2' size="10" />&nbsp;
	<input type="button" value="替 换"  onclick="replaceStr()" class="btn" /></td></tr>
	</table>	
	 </div></div>
</div>
<script type="text/javascript" src="imgs/drag.js"></script>
<?php
}

function editVideo() {
	global $menuList;
	$id = intval(getForm("id","get"));
	$makePlayerSelectStr = str_replace("'","\'",makePlayerSelect(""));
	$makeDownSelectStr = str_replace("'","\'",makeDownSelect(""));
	$vrow = DB::fetch_first("SELECT * FROM ".DB::table('tempdata')." WHERE m_id='$id'");
	if (!is_array($vrow)) { die("没找到记录");}
	$m_color = $vrow['m_color'];
	$m_type = $vrow['m_type'];
?>
<div class="container" id="cpcontainer">
<script type="text/JavaScript">if(parent.$('admincpnav')) parent.$('admincpnav').innerHTML='后台首页&nbsp;&raquo;&nbsp;<?=$menuList[1][0]?>&nbsp;&raquo;&nbsp;修改数据';</script>
<form action="?action=saveVideo&acttype=edit" method="post" name="editform" id="editform" >
<input type="hidden" id="m_commend" name="m_commend" value="<?=$vrow['m_commend']?>">
<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('<?=$vrow['m_fromurl']?>','_blank');"><?=$vrow['m_fromurl']?></a></td>
	</tr>
	<tr>
		<td align="right" height="22" width="73">名称：</td>
		<td><input id="m_name" name="m_name" size="23" autocomplete="off" value="<?=$vrow['m_name']?>"/>&nbsp;<font color='red'>＊</font><label>连载？<input type="checkbox" onClick="isViewState()" class="checkbox"  id="m_statebox"  <?=$vrow['m_state'] != 0 ? 'checked' : ''?>/></label><span id="m_statespan" <?=$vrow['m_state'] == 0 ? "style=\"display:none\"" : ''?>>到第<input name="m_state" id="m_state" value="<?php echo $vrow['m_state'];?>" type="text" size="5" />集</span>
		<span id="m_name_ok"></span>颜色：
		<select name="m_color" >
		<?php 
		if($m_color)
		{
		?>
         <option style="background-color:<?=$m_color;?>;color: <?=$m_color;?>" value="<?=$m_color;?>"><?=$m_color;?></option>
		<?php 
		}
		else
		{
		?>
		<option style="" value="">无色</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 makeTypeOptionSelected(0,"&nbsp;|&nbsp;&nbsp;","",$vrow['m_type'])?>
	</select>&nbsp;&nbsp;<font color='red'>＊</font></td>
	</tr>
	<tr> 
		<td height="22" align="right">图片地址：</td>
		<td><input name="m_pic" id="m_pic" type="text" size="40" value="<?=$vrow['m_pic']?>">&nbsp;←<input size="10" value="清除" type="button" onClick="javascript:document.editform.m_pic.value=''" class="btn" />&nbsp;<iframe src="fckeditor/upload.htm" 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">主 演：</td>
	 <td><input type="text" size="30" name="m_actor" value="<?=$vrow['m_actor']?>">&nbsp;&nbsp;导&nbsp;&nbsp;&nbsp;演：<input type="text" size="10" name="m_director" value="<?=$vrow['m_director']?>">&nbsp;星级：<span id="star0" style="width:85px;display:inline-block"><script>starView(<?=$vrow['m_commend']?>,0)</script></span>&nbsp;&nbsp;&nbsp;&nbsp;主演、导演用逗号或空格隔开</td>
	</tr>
    
    <tr>
		<td align="right" height="22">备 注：</td>
		<td><input type="text" size="30" name="m_note" value="<?php if (!empty($vrow['m_note'])) echo decodeHtml($vrow['m_note']);?>">&nbsp;&nbsp;关键词：<input type="text" size="30" name="keyword" value="<?=$vrow['m_keyword']?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;备注如：高清,无水印 (配合标题一起显示)</td>
	</tr>
	<tr>
		<td align="right" height="22">发行年份：</td>
		<td><input size="5" name="m_publishyear" id="m_publishyear" value="<?=$vrow['m_publishyear']?>"  />年&nbsp;&nbsp;语言：<input type="text" size="10" name="m_lang" value="<?=$vrow['m_lang']?>">&nbsp;&nbsp;地&nbsp;&nbsp;&nbsp;区：<?php echo getAreaSelect("m_publisharea","选择地区",$vrow["m_publisharea"]);?>&nbsp;&nbsp;专题：<?=makeTopicSelect("m_topic", "选择专题", $vrow["m_topic"])?>  &nbsp;&nbsp;点击率：<input type="text" name="m_hit" id="m_hit" maxlength="9"  value="<?=$vrow['m_hit']?>"/>&nbsp;<input type="checkbox" name="isupdatetime" value="1" checked class="checkbox" />更新时间</td>
	</tr>
	<tr><td colspan="2" style="padding:0" class="noborder"><div style="" id="m_playarea"><?php
	$playArray=getPlayurlArray($vrow['m_playdata']);
	$playTypeCount=count($playArray);$m=0;
	if($vrow['m_playdata'] != "") {
		for ($i = 0;$i < $playTypeCount;$i++) {
			$m=$i+1;
			$playStr=$playArray[$i];
			$playArray2=explode("$$",$playStr) ; $playfrom=$playArray2[0];
			$playUrl=replaceStr($playArray2[1],chr(10),"");
			$playUrl=replaceStr($playUrl,"#",chr(13));
		?>
        <table width='100%' id='playfb<?=$m?>'><tr><td align='right' height='22'  width='70'>播放来源<?=$m?>：</td><td>
		<select id='m_playfrom<?=$m?>' name='m_playfrom[<?=$m?>]'>
		<option value=''>暂没有数据<?=$m?></option>
	   <?=makePlayerSelect($playfrom)?>
		</select>
		<input type='button' class='btn' value='WEB采集' onclick='viewGatherWin(<?=$m?>);selectTogg();'/>&nbsp;&nbsp;<img onClick="var tb=$('playfb<?=$m?>');tb.parentNode.removeChild(tb);" src='imgs/btn_dec.gif' class='pointer' alt="删除播放来源<?=$m?>" align="absmiddle"/>&nbsp;&nbsp;<font color='red'>＊</font>&nbsp;&nbsp;<a href="javascript:moveTableUp($('playfb<?=$m?>'))">上移</a>&nbsp;&nbsp;<a href="javascript:moveTableDown($('playfb<?=$m?>'))">下移</a></td></tr><tr><td align='right' height='22'>数据地址<?=$m?>：<br/><input type='button' value='校正' title='校正右侧文本框中的数据格式' class='btn' onclick='repairUrl(<?=$m?>)' /></td><td><textarea id='m_playurl<?=$m?>' name='m_playurl[<?=$m?>]' rows='8' cols='100'><?=$playUrl;?></textarea>&nbsp;&nbsp;<font color='red'>＊</font></td></tr>
		</table>
		<?php
    }
}
?>
	</div></td></tr>
	<tr><td colspan='2'>&nbsp;<img onClick="expendPlayArea(<?=$m+1?>,escape('<?=$makePlayerSelectStr?>'),0)" src='imgs/btn_add.gif' class='pointer' align="absmiddle"/>&nbsp;&nbsp;<font color="red">您可以单击前面的按钮添加一组播放来源</font></td></tr>
    <tr><td colspan="2" style="padding:0" class="noborder"><div style="" id="m_downarea">
    <?php
	$downArray=getPlayurlArray($vrow['m_downdata']);
	$downTypeCount=count($downArray);$n=0;
	if($vrow['m_downdata'] != "") {
	    for($j = 0;$j < $downTypeCount;$j++){
			$n=$j+1;
			$downStr=$downArray[$j];
			$downArray2=explode("$$", $downStr) ; $downfrom=$downArray2[0];
			$downUrl=replaceStr($downArray2[1],chr(10),"") ; $downUrl=replaceStr($downUrl,"#",chr(13));
		?>
		<table width="100%" id='downfb<?=$n?>'><tr><td align='right' height='22'  width='70'>下载来源<?=$n?>：</td><td>
		<select id='m_downfrom<?=$n?>' name='m_downfrom[<?=$n?>]'>
		<option value=''>暂无数据<?=$n?></option>
        <?=makeDownSelect($downfrom)?>
		</select>
		&nbsp;&nbsp;<img onClick="var tb=$('downfb<?=$n?>');tb.parentNode.removeChild(tb);" src='imgs/btn_dec.gif' class='pointer' alt="删除下载来源<?=$n?>" align="absmiddle"/>&nbsp;&nbsp;
		</td></tr><tr><td align='right' height='22'>下载地址<?=$n?>：</td><td><textarea id='m_downurl<?=$n?>' name='m_downurl[<?=$n;?>]' rows='8' cols='100'><?=$downUrl;?></textarea></td></tr>
		</table>
		<?php
         }
	}
	?>
	</div></td></tr> 
	<tr><td colspan='2'>&nbsp;<img onClick="expendDownArea(<?=$n+1?>,escape('<?=$makeDownSelectStr?>'),0)" src='imgs/btn_add.gif' class='pointer' align="absmiddle"/>&nbsp;&nbsp;<font color="red">您可以单击前面的按钮添加一组下载来源</font></td></tr>
    <tr>
		<td align="right" height="22"></td>
		<td>说明:程序默认每行为一个播放地址，多集请分行，不能有空行</td>
	</tr>
	<tr>
		<td align="right" height="22">相关介绍：</td>
		<td>
  <?php
        GetEditor('m_des', $vrow['m_des']);
	?>
  		</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="return chform();">&nbsp;<input type=reset name=Submit2 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);
}
function chform(){
	if($('m_name').value.length==0){
		alert('请填写名称');
		return false;
	};
	if($('m_type').value.length==0){
		alert('请选择分类');
		return false;
	};
	if($('m_publishyear').value.length>0){
		if(isNaN($('m_publishyear').value)){
			alert('年份请填写数字');
			return false;
		}
	}
	var c=document.getElementsByName("m_playfrom"),
	ct=document.getElementsByName("m_playurl"),
	d=document.getElementsByName("m_downfrom"),
	dt=document.getElementsByName("m_downurl");
	for(var i=0;i<c.length;i++){
		if(c[i].selectedIndex==0 && ct[i].value!=''){
			alert('请选择每个播放来源');c[i].focus();
			return false;
		}
	}
	for(var i=0;i<d.length;i++){
		if(d[i].selectedIndex==0 && dt[i].value!=''){
			alert('请选择每个下载来源');d[i].focus();
			return false;
		}
	}
	return true;
}
$('editform').m_name.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=0";
$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 cregion() {
	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=cregionsave" 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`,`syscls` from ".DB::table('cregion')."";
$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><?=getAreaSelect("m_type".$id,"选择地区",$row['syscls']);?></td>
		<td><a href="?action=cregiondel&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=cregiondelall';}else{return false}" class="btn"/>&nbsp;&nbsp;<input type="submit" value="批量修改选中地区" name="Submit" class="btn" onClick="this.form.action='?action=cregionsave';"/>&nbsp;&nbsp;<?=fPageCount($allRecordset,$number,$page)?></td>
	</tr>
</form>
	<tr class="thead"><th colspan="4"></th></tr>
<form action="?action=cregionnew" method="post" name="form2">
	<tr>
		<td>添加</td>
		<td><input type="text" name="clsname" value="" /></td>
		<td><?=getAreaSelect("m_type","选择地区","")?></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=0";
	$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=0 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=0 AND m_id=$id");
	alertMsg("", $back);
}

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

function filtersdelall() {
	$ids = getForm("m_id","post");
	if (!empty($ids)) DB::delete('fword', 'm_ison=0 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' => 0,'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,
		);
	    DB::insert('fword', $fwordarr);
	}
	alertMsg("", "?action=filters");
}

function cregionnew() {
	$clsname = getForm("clsname","post");$m_type=getForm("m_type","post");
	if (empty($clsname)) { alertMsg("要转换有地区名还没填写","javascript:history.go(-1)");exit;}
	if (empty($m_type)) { alertMsg("未选择影射到系统地区","javascript:history.go(-1)");exit;}
	$clsarr = array(
	    'clsname' => $clsname,
	    'syscls' => $m_type,
	);
	DB::insert('cregion', $clsarr);
	alertMsg("", "?action=cregion");
}

function cregionsave() {
	$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 (empty($m_type)){ alertMsg("ID为".$id." 未选择影射到系统地区","javascript:history.go(-1)");exit;}
		DB::update('cregion', array('clsname' => $clsname,'syscls' => $m_type),array('id' => $id));
	}
	alertMsg("", "?action=cregion");
}

function cregiondelall() {
	$ids = getForm("id","post");$back = getRefer();
	if (!empty($ids)) DB::delete('cregion', 'id IN ('.dimplode($ids).')');
	alertMsg("", "?action=cregion");
}

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

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,
	);
	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' => 0,'id' => $id));
	}
	alertMsg("", "?action=customercls");
}

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

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

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

function saveVideo() {
	$actType = getForm("acttype","get");
	$m_id = getForm("m_id","post");if (!is_numeric($m_id)) $m_id = 0;
	$m_name = getForm("m_name","post");
	$m_keyword = replaceStr(replaceStr(getForm("keyword","post"),chr(13),""),chr(10),"");
	$isuppingyin = getForm("isuppingyin","post")=="1";
	$m_enname = getForm("m_enname","post");if (empty($m_enname)) $m_enname = MoviePinYin($m_name);
	$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_state = getForm("m_state","post");if (empty($m_state)) $m_state=0;
	$m_type = getForm("m_type","post");if (empty($m_type)){ alertMsg("请选择分类","javascript:history.go(-1);");die("");}
	$m_pic = getForm("m_pic","post");
	$m_actor = getForm("m_actor","post");
	$m_note = replaceSpecial(getForm("m_note","post"));
	$m_des = replaceSpecial(getForm("m_des","post"));
	$m_addtime = getForm("m_addtime","post");
	$m_publishyear = getForm("m_publishyear","post");if (empty($m_publishyear)) $m_publishyear = 0;
	$m_publisharea = getForm("m_publisharea","post");if (empty($m_publisharea)) $m_publisharea = "";
	$m_topic = getForm("m_topic","post");if (empty($m_topic)) $m_topic = 0;
	$m_director = getForm("m_director","post");
	$m_lang = getForm("m_lang","post");
	$m_commend = getForm("m_commend","post");if (is_numeric($m_commend)){ $m_commend = intval($m_commend);}else{;$m_commend = 0;}
	$m_playfrom = getForm("m_playfrom","post");
	$m_playurl = getForm("m_playurl","post");
	if (!empty($m_playurl)){
		$m_playurl = repairUrlForm($m_playurl,$m_playfrom);
    }
	$m_playdata=transferUrl($m_playfrom,$m_playurl);
	$m_downfrom=getForm("m_downfrom","post");
	$m_downurl=getForm("m_downurl","post");
	if (!empty($m_downurl)){
		$m_downurl = repairDownUrl($m_downurl,$m_downfrom);
	}
	$m_downdata=transferUrl($m_downfrom,$m_downurl);
	$isupdatetime=getForm("isupdatetime","post");
	switch (trim($actType)) {
		case "edit":
		    $m_id=getForm("m_id","post");
		    $feedarr = array(
			'm_keyword' => $m_keyword,
			'm_hit' => $m_hit,
			'm_letter' => msubstr($m_enname,1),
			'm_name' => $m_name,
			'm_color' => $m_color,
			'm_state' => $m_state,
			'm_type' => $m_type,
			'm_pic' => $m_pic,
			'm_actor' => $m_actor,
			'm_note' => $m_note,
			'm_des' => $m_des,
			'm_publishyear' => $m_publishyear,
			'm_publisharea' => $m_publisharea,
			'm_topic' => $m_topic,
			'm_playdata' => $m_playdata,
			'm_downdata' => $m_downdata,
			'm_director' => $m_director,
			'm_lang' => $m_lang,
			'm_enname' => $m_enname,
			'm_commend' => $m_commend,
			);
			if (!empty($isupdatetime)){ DB::update('tempdata', array('m_addtime' => time()), array('m_id' => $m_id));}
			DB::update('tempdata', $feedarr, array('m_id' => $m_id));
			alertMsg("", $m_back);
	   break;
   }
}

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

function delTempData(){
	$back = getRefer();$id = getForm("id","get");
	DB::delete('tempdata', 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=Str2Num(getForm("type","both"));
	$rcount=Str2Num(getForm("rcount","both"));
	$pcount=Str2Num(getForm("pcount","both"));
	$m_typename=getForm("typename","both");
	$gatherSet=Str2Num(getForm("gatherset","both"));
	$fields=dimplode(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('tempdata')." ".$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,$gatherSet);
			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."&gatherset=".$gatherSet."&fields=".$fields."&result=".urlencode($result)."';},3000);</script>";
		} else {
			alertMsg("导入完成", $result);
        }
    } else {
		$ids = getForm("m_id","post");
		if (empty($ids)) {alertMsg("请选择数据",$result);exit();}
		import2Base($ids, $vtype,$fields,$gatherSet);
		alertMsg("", $result);
   }
}

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

function import2Base($idsArray, $vtype,$fields,$gatherSet) {
	if (count($idsArray)>0) {
		$darr = array();
		$ids = dimplode($idsArray);$allid=",".getTypeAllId().",";
		$query = DB::query("SELECT m_id,m_name,m_type,m_state,m_pic,m_actor,m_des,m_playdata,m_publishyear,m_publisharea,m_hit,m_note,m_keyword,m_lang,m_director,m_datetime,m_addtime FROM ".DB::table('tempdata')." WHERE m_id IN (".$ids.") ORDER BY m_addtime ASC");
        while($row = DB::fetch($query)) {
			$m_where = "";$sql = "";$title = $row['m_name'];$titleArray = explode("/",$title);
			$m_type = ifthen($vtype>0, $vtype, $row['m_type']);
			if ($m_type>0) {
				foreach ($titleArray as $m_title) {
					if (!empty($m_title)) $m_where .= " or concat('/',m_name,'/') like '%/".$m_title."/%' ";
				}
				$m_where = ltrim($m_where," or");$m_enname=MoviePinYin($title);
				$rs = DB::fetch_first("select m_id,m_playdata,m_state,m_type,m_pic from ".DB::table('data')." where ".$m_where."");
				if (is_array($rs)) $m_type=ifthen($m_type>0,$m_type,$rs["m_type"]);
				if (!isExistStr($allid,",".$m_type.",")){
				    $m_type=0;
				}elseif (is_null($m_type)){
				     $m_type=0;
				}
				if ($m_type>0) {
				    $row["m_actor"]=getStrByLen($row["m_actor"],255);
				    $row["m_director"]=getStrByLen($row["m_director"],50);
				    $row["m_lang"]=getStrByLen($row["m_lang"],30);
					if (!is_array($rs)) {
						$feedarr = array(
							'm_name' => new_addslashes($row['m_name']),
							'm_type' => $m_type,
							'm_state' => $row['m_state'],
							'm_pic' => $row['m_pic'],
							'm_actor' => new_addslashes($row['m_actor']),
							'm_des' => new_addslashes($row['m_des']),
							'm_playdata' => new_addslashes($row['m_playdata']),
							'm_isunion' => 1,
							'm_publishyear' => $row['m_publishyear'],
							'm_publisharea' => new_addslashes($row['m_publisharea']),
							'm_letter' => msubstr($m_enname,1),
							'm_hit' => $row['m_hit'],
							'm_note' => new_addslashes($row['m_note']),
							'm_addtime' => time(),
							'm_keyword' =>new_addslashes($row["m_keyword"]),
							'm_lang' =>new_addslashes($row['m_lang']),
							'm_director' =>$row['m_director'],
							'm_datetime' => time(),
							'm_enname' => $m_enname,
						);
			            DB::insert('data', $feedarr);
					}else{
					    if ($gatherSet!=4){
						    $row["m_state"]=ifthen($rs["m_state"]>$row["m_state"],$rs["m_state"],$row["m_state"]);
						    $row["m_pic"]=ifthen(empty($rs["m_pic"]),$row["m_pic"],$rs["m_pic"]);
						    if (isExistStr($fields,"name")){
								$darr['m_name'] = new_addslashes($row['m_name']);
								$darr['m_letter'] = msubstr($m_enname,1);
								$darr['m_enname'] = $m_enname;
							}
						    if (isExistStr($fields,"actor")) $darr['m_actor'] = new_addslashes($row["m_actor"]);
							if (isExistStr($fields,"area")) $darr['m_publisharea'] = new_addslashes($row["m_publisharea"]);
							if (isExistStr($fields,"state")) $darr['m_state'] = $row["m_state"];
							if (isExistStr($fields,"note")) $darr['m_note'] = new_addslashes($row["m_note"]);
							//if (isExistStr($fields,"pic")) $darr['m_pic'] = $row["m_pic"];
							if (isExistStr($fields,"pic")){ 
							   if (isExistStr($rs['m_pic'], '://')) {
								   $darr['m_pic'] = $row["m_pic"];
							   } else if (!file_exists(DJ_ROOT.$rs['m_pic'])) {
								   if (filesize(DJ_ROOT.$rs['m_pic'])<1) {
							           $darr['m_pic'] = $row["m_pic"];
								   }
							   }
							}
							if (isExistStr($fields,"year")) $darr['m_publishyear'] = $row["m_publishyear"];
							if (isExistStr($fields,"des")) $darr['m_des'] = new_addslashes($row['m_des']);
							if (isExistStr($fields,"director")) $darr['m_director'] = $row["m_director"];
							if (isExistStr($fields,"leng")) $darr['m_lang'] = new_addslashes($row["m_lang"]);
							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,"playdata") && $gatherSet!=5){
							    $darr['m_playdata'] = gatherIntoLibTransfer($rs["m_playdata"],new_addslashes($row['m_playdata']),$gatherSet);
							}
							//die(print_r($darr));
							DB::update('data', $darr, array('m_id' => $rs["m_id"]));
					    }
					    switch ($gatherSet) {
						    case 0 :case 1 :case 2 :case 3 :case 5 :
								$darr['m_type'] = $m_type;
								$darr['m_isunion'] = 1;
								DB::update('data', $darr, array('m_id' => $rs["m_id"]));
						    break;
				            case 4 :
								$feedarr = array(
								    'm_name' => new_addslashes($row['m_name']),
									'm_type' => $m_type,
									'm_state' => $row['m_state'],
									'm_pic' => $row['m_pic'],
									'm_actor' => new_addslashes($row['m_actor']),
									'm_des' => new_addslashes($row['m_des']),
									'm_playdata' => new_addslashes($row['m_playdata']),
									'm_isunion' => 1,
									'm_publishyear' => $row['m_publishyear'],
									'm_publisharea' => new_addslashes($row['m_publisharea']),
									'm_letter' => msubstr($m_enname,1),
									'm_hit' => $row['m_hit'],
									'm_note' => new_addslashes($row['m_note']),
									'm_keyword' => new_addslashes($row["m_keyword"]),
									'm_lang' => new_addslashes($row['m_lang']),
									'm_addtime' => time(),
									'm_director' =>$row['m_director'],
									'm_enname' => $m_enname,
								);
						        DB::insert('data', $feedarr);
							break;
						}
					}
					DB::update('tempdata', array('m_inbase' => 1,'m_type' => $m_type), array('m_id' => $row['m_id']));
				    echo "<font color=blue>导入成功 ID:".$row['m_id']."	".$row['m_name']."</font><br>";
				}
			} else {
				die(print_r($m_type));
				echo "<font color=red>没选择分类</font> 导入失败 ID:".$row['m_id']."	".$row['m_name']."<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"]),
	'CollectTime' => time(),
	);
	DB::insert('collect', $feedarr);
	alertMsg("克隆成功","admin_collect.php?action=main");
}

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

function delAll() {
	$ids = getForm("m_id","post");
	DB::delete('collect', 'publi=0 AND id IN ('.dimplode($ids).')');
	alertMsg("","admin_collect.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' => 0,'id' => $id));
	    $sb = 0;$cg = 0;
	    session_unset();
	    session_destroy();
    }
    $row = DB::fetch_first("select * from ".DB::table('collect')." where publi=0 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) {
			alertMsg("在获取:".$listurl."网页源码时发生错误","admin_collect.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)) {
			        $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 {
		//判断资料范围开始代码
		if (!empty($mdataA) && !empty($mdataB)) {
			$newscodel = StrSlice($newscode, $mdataA, $mdataB);
		} else {
			$newscodel = $newscode;
		}
		//判断数据名称开始代码
		if (!empty($nameA) && !empty($nameB)) {
			$t=StrSlice($newscodel, $nameA, $nameB);$t=fword($t, 0);$t=RemoveHTMLCode($t,"*");
	        $m_name = trim($t);
		}
		if ($splay == 1) {
		    $txt2 = StrSlice($newscode, $plistA, $plistB);
	    }else{
		    $txt2 = $newscode;
		}
	    if ($playgetsrc == 0) {
		    $txt3=$txt2;
		}else{
		    $tt = StrSplits($txt2, $playlinkA, $playlinkB);
			if ($isspecial == 1) {
			    $tt= SpecialLinks($tt, $linkRF, $linkRR);
			}
			$tt = array_unique(paseAbsURI($tt, $urltest));$t=count($tt);
		    $txt3 = "";
		    if ($playgetsrc == 2) {
				if ($t>-1){
				    echo("正在截取<font color=red>".($t)."</font>页面上的影片地址，可能要花上几分钟。请稍候...<br />");
					foreach ($tt as $webArray) {
					    $txt3 = $txt3.GetHttpTextFile($webArray,$charset);
					}
				}
			}else{
			    $txt3 = GetHttpTextFile($tt[$t-1],$charset);
			}
		}
		if ($getpart == 1) {
		    $tt= StrSplits($txt3, $partA, $partB);
		    $x["m_jie"]= $tt;
		}
	    $tt = StrSplits($txt3, $msrcA, $msrcB);
		$t=count($tt);
		for ($i = 0;$i < $t;$i++) {
		    $tt[$i]	= trim(RemoveHTMLCode($tt[$i],"*"));
		}
	    $movieurl = $tt;
		$txt3	= "<pre>来源地址: " .$urltest."\n";
	    if ($m_name<>"" && $t<>'-1'){
			if ($autocls=='0'){
			    $t	= $classid;
			    $m_type = $t;
			    $m_typename = viewDataType($classid);
			}else{
			    if (!empty($clsA) && !empty($clsB)) {
				    $t	= RemoveHTMLCode(StrSlice($newscodel, $clsA, $clsB),"*");
				    $m_typename = $t;
				}
			    $m_type = smartGeneralize($t,$m_name);
			}
			//判断数据日期开始代码
			if (!empty($dateA) && !empty($dateB)) {
			    $t=RemoveHTMLCode(StrSlice($newscodel, $dateA, $dateB),"*");
			    if (strtotime($t)){
				    $m_addtime = strtotime($t);
		        }else{
				    $m_addtime = time();
		        }
		    }else{
			    $m_addtime = time();
		    }
			//判断数据演员开始代码
			if (!empty($actorA) && !empty($actorB)) {
			    $m_actor = RegReplace(RemoveHTMLCode(StrSlice($newscodel, $actorA, $actorB),"*"),"/(\s+)|[\|\/]/i"," ");
		    }
			//判断数据导演开始代码
		    if (!empty($directorA) && !empty($directorB)) {
			    $m_director = RegReplace(RemoveHTMLCode(StrSlice($newscodel, $directorA, $directorB),"*"),"/(\s+)|[\|\/]/i"," ");
		    }
			//判断数据语言开始代码
		    if (!empty($langA) && !empty($langB)) {
			    $m_lang = RegReplace(RemoveHTMLCode(StrSlice($newscodel, $langA, $langB),"*"),"/(\s+)|[\|\/]/i"," ");
		    }
			//判断数据地区开始代码
		    if (!empty($areaA) && !empty($areaB)) {
				$m_publisharea = trim(RemoveHTMLCode(StrSlice($newscodel, $areaA, $areaB),"*"));
			    $m_publisharea = getTidcregion($m_publisharea);
		    }
			//判断数据关键字开始代码
		    if (!empty($keysA) && !empty($keysB)) {
			    $m_keyword = RegReplace(RemoveHTMLCode(StrSlice($newscodel, $keysA, $keysB),"*"),"/(\s+)|[\|\/]/i"," ");
		    }
			//判断数据年份开始代码
		    if (!empty($yearA) && !empty($yearB)) {
			    $y	= trim(RemoveHTMLCode(StrSlice($newscodel, $yearA, $yearB),"*"));
			    if (strtotime($y)){
				    $m_publishyear= date('Y');
			    }else{
				    $y	= Str2Num(RegReplace($y,"/[^\d]*(\d+).*/i","$1"));
				    if ($y<=date('Y')){
					    $m_publishyear = $y;
				    }
			    }
		    }
			//判断数据连载开始代码
		    if (!empty($stateA) && !empty($stateB)) {
			    $t = replaceStr(RemoveHTMLCode(StrSlice($newscodel, $stateA, $stateB),"*"),$mcls["m_name"],"");
			    $t = replaceStr(replaceStr(replaceStr(replaceStr(replaceStr(replaceStr(replaceStr($t,"连载",""),"集",""),"全",""),"至",""),"话",""),"季",""),"级","");
			    $t = Str2Num(replaceStr(replaceStr(replaceStr(replaceStr(replaceStr(replaceStr(replaceStr($t,"[",""),"]",""),"第",""),"更新",""),"结局",""),"完",""),"_",""));
			    if ($t>0){
				    $m_state = $t;
		        }
		    }
			//判断数据备注开始代码
		    if (!empty($noteA) && !empty($noteB)) {
			    $m_note = trim(RemoveHTMLCode(StrSlice($newscodel, $noteA, $noteB),"*"));
		    }
		    if ($picmode == 0) {
			    if (!empty($picA) && !empty($picB)) {
			        $m_pic = paseAbsURI(StrSlice($newscodel, $picA, $picB), $urltest);
					$m_pic = $m_pic[0];
			    }
		    }
		    //判断数据介绍开始代码
		    if (!empty($desA) && !empty($desB)) {
			    $m_des = RemoveHTMLCode(fword(StrSlice($newscode, $desA, $desB), 1), $removecode);
		    }
			$moviesrcs=$movieurl;
	        $partnames=$x["m_jie"];
	        if (is_array($moviesrcs)){
		        $l=count($moviesrcs);
		        if ($l<>'-1'){
			        if (is_array($partnames)){
				        if (count($partnames)==$l){
						    for ($i = 0;$i < $l;$i++){
				                $moviesrcs[$i]=ifthen(jsIndexOf($moviesrcs[$i],"$")=='-1',replaceStr("".$partnames[$i].",","")."$".$moviesrcs[$i],$moviesrcs[$i]);
						    }
					    }
					}
					foreach ($moviesrcs as $row) {
						$m_msrc .= $row."\r";
						
					}
					$m_playfrom[1] = replaceStr(replaceStr($playfrom,"#",""),"$","");
					$m_playurl[1] = new_addslashes(rtrim($m_msrc,"\r"));
			        $moviesrcs = repairUrlForm($m_playurl,$m_playfrom);
				}else{
			        $moviesrcs = "";
				}
			}else{
		       $moviesrcs=ifthen(!empty($moviesrcs),$moviesrcs,"");
			}
			if (!empty($moviesrcs)) $m_playdata = transferUrl($m_playfrom, $moviesrcs);
			//判断入库方式
			if ($intoa == 1 && $m_type != 0) {
				$sburl = 0;$cg++;
                $tablename = "data";
			    $whereStr = " where m_name like '%{$m_name}%'";
			} else {
                $intoa = 0;
                $tablename = "tempdata";
			    $whereStr = " where m_fromurl='$urltest' or m_name like '%{$m_name}%'";
			}
			$r = DB::fetch_first("select m_id,m_playdata,m_state,m_type,m_pic from ".DB::table($tablename)."$whereStr");
			if (!is_array($r)) {
				$feedarr = array(
				    'm_name' => new_addslashes($m_name),
					'm_type' => $m_type,
					'm_letter' => $m_letter,
					'm_enname' => $m_enname,
					'm_datetime' => time(),
				);
                if (!empty($m_pic)) $feedarr['m_pic'] = $m_pic;
                if (!empty($m_actor)) $feedarr['m_actor'] = $m_actor;
                if (!empty($m_director)) $feedarr['m_director'] = $m_director;
                if (!empty($m_state)) $feedarr['m_state'] = $m_state;
                if (!empty($m_note)) $feedarr['m_note'] = $m_note;
                if (!empty($m_keyword)) $feedarr['m_keyword'] = new_addslashes($m_keyword);
                if (!empty($m_publishyear)) $feedarr['m_publishyear'] = $m_publishyear;
                if (!empty($m_lang)) $feedarr['m_lang'] = $m_lang;
                if (!empty($m_publisharea)) $feedarr['m_publisharea'] = $m_publisharea;
                if (!empty($m_addtime)){ $feedarr['m_addtime'] = $m_addtime;} else { $feedarr['m_addtime'] = time();}
                if (!empty($m_playdata)) $feedarr['m_playdata'] = $m_playdata;
                if (!empty($m_des)) $feedarr['m_des'] = new_addslashes($m_des);
				if ($intoa==0){ $feedarr['m_typename'] = $m_typename;$feedarr['m_fromurl'] = $urltest;}
				DB::insert($tablename, $feedarr);
				$cg++;
			} else {
				$sb++;
				switch (gatherSet) {
				    case 0 :case 1 :case 2 :case 3 :
					    $m_playdata = gatherIntoLibTransfer($r['m_playdata'],$m_playdata,gatherSet);
						$feedarr = array(
						    'm_name' => $m_name,
							'm_type' => $m_type,
							'm_playdata' => $m_playdata,
						);
						if (!empty($m_addtime)){ $feedarr['m_addtime'] = $m_addtime;} else { $feedarr['m_addtime'] = time();}
						DB::update($tablename, $feedarr, array('m_id' => $r['m_id']));
						break;
                    case 4 :
					    $feedarr = array(
						    'm_name' => new_addslashes($m_name),
							'm_type' => $m_type,
							'm_letter' => $m_letter,
							'm_enname' => $m_enname,
							'm_datetime' => time(),
						);
                        if (!empty($m_pic)) $feedarr['m_pic'] = $m_pic;
                        if (!empty($m_actor)) $feedarr['m_actor'] = $m_actor;
                        if (!empty($m_director)) $feedarr['m_director'] = $m_director;
                        if (!empty($m_state)) $feedarr['m_state'] = $m_state;
                        if (!empty($m_note)) $feedarr['m_note'] = $m_note;
                        if (!empty($m_keyword)) $feedarr['m_keyword'] = new_addslashes($m_keyword);
                        if (!empty($m_publishyear)) $feedarr['m_publishyear'] = $m_publishyear;
                        if (!empty($m_lang)) $feedarr['m_lang'] = $m_lang;
                        if (!empty($m_publisharea)) $feedarr['m_publisharea'] = $m_publisharea;
                        if (!empty($m_addtime)){ $feedarr['m_addtime'] = $m_addtime;} else { $feedarr['m_addtime'] = time();}
                        if (!empty($m_playdata)) $feedarr['m_playdata'] = $m_playdata;
                        if (!empty($m_des)) $feedarr['m_des'] = new_addslashes($m_des);
				        if ($intoa==0){ $feedarr['m_typename'] = $m_typename;$feedarr['m_fromurl'] = $urltest;}
				        DB::insert($tablename, $feedarr);
						break;
                    case 5 :
					    $feedarr = array(
						    'm_name' => new_addslashes($m_name),
							'm_type' => $m_type,
							'm_letter' => $m_letter,
							'm_enname' => $m_enname,
							'm_datetime' => time(),
						);
                        if (!empty($m_pic)) $feedarr['m_pic'] = $m_pic;
                        if (!empty($m_actor)) $feedarr['m_actor'] = $m_actor;
                        if (!empty($m_director)) $feedarr['m_director'] = $m_director;
                        if (!empty($m_state)) $feedarr['m_state'] = $m_state;
                        if (!empty($m_note)) $feedarr['m_note'] = $m_note;
                        if (!empty($m_keyword)) $feedarr['m_keyword'] = new_addslashes($m_keyword);
                        if (!empty($m_publishyear)) $feedarr['m_publishyear'] = $m_publishyear;
                        if (!empty($m_lang)) $feedarr['m_lang'] = $m_lang;
                        if (!empty($m_publisharea)) $feedarr['m_publisharea'] = $m_publisharea;
                        if (!empty($m_addtime)){ $feedarr['m_addtime'] = $m_addtime;} else { $feedarr['m_addtime'] = time();}
                        if (!empty($m_des)) $feedarr['m_des'] = new_addslashes($m_des);
				        if ($intoa==0){ $feedarr['m_typename'] = $m_typename;$feedarr['m_fromurl'] = $urltest;}
				        DB::update($tablename, $feedarr, array('m_id' => $r['m_id']));
						break;
			    }
			    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;
                }
			    $txt .= "<font color=red><b>采集过该数据,进行'".$iMode."'！。</b></font>";
			}
			$txt3 .= "视频名称: ".$m_name."<br>";
		    $txt3 .= "视频分类: ".$m_typename."<br>";
		    $txt3 .= "演员列表: ".$m_actor."<br>";
		    $txt3 .= "导演列表: ".$m_director."<br>";
		    $txt3 .= "视频连载: ".$m_state."<br>";
		    $txt3 .= "视频备注: ".$m_note."<br>";
		    $txt3 .= "关 键 词: ".$m_keyword."<br>";
		    $txt3 .= "视频年份: ".$m_publishyear."<br>";
		    $txt3 .= "视频语言: ".$m_lang."<br>";
		    $txt3 .= "视频地区: ".$m_publisharea."<br>";
		    $txt3 .= "视频日期: ".date('Y-m-d H:i:s',$m_addtime)."<br>";
		    $txt3 .= "视频图片: ".$m_pic."<br>";
		    $txt3 .= "视频地址: ".join("\n",$movieurl)."\n\n";
		    $y=$x["m_jie"];
		    if (is_array($y)){
			    $txt3 .= "视频集名: ".join("\n",$y)."\n";
			}
		    $txt3 .= "影片介绍: ".new_htmlspecialchars($m_des)."\n";
		}else{
		    $txt3 .= "忽略无效电影: ".$m_name." 原因: ".ifthen(trimall($m_name)=="","没有影片名称","没有影片地址");
		}
	}
	echo "<meta http-equiv=\"refresh\" content=\"0;url=admin_collect.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><?=$txt3.$txt?>
</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));
	//$siteUrl=RegReplace($currUrl,"/(https?\:\/\/)((\w+)(\.\w+)*(:\d+)?)\/.*/i","$1$2");$currUrl=replaceStr($currUrl,$siteUrl,"");
	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 getTidcregion($name){
	$trow = DB::fetch_first("SELECT syscls FROM ".DB::table('cregion')." WHERE clsname='$name'");
	if (is_array($trow)) return $trow['syscls'];
	else return $name;
}

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

function SpecialLinks($sLink,$fLink,$rLink){
	$t=explode("[变量]",$fLink);
	if (count($t)<1){
		return $sLink;
	}else{
	    $rLink=implode("$"."1",explode("[变量]",$rLink));
	    for ($i = 0;$i < count($t);$i++) {
		    $t[$i]=addcslashes($t[$i]);
	    }
	    $fLink=implode("([\w\W]+)",$t);
		for ($i = 0;$i < count($sLink);$i++) {
			$sLink[$i]=RegReplace($sLink[$i],"/".$fLink."/is",$rLink);
		}
	}
	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=0 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"] != "") {
					$Str=RegReplace($Str,"/".$row["m_sstart"]."([\w\W]+?)".$row["m_send"]."/is",$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("/<\/?".addslashes($cHas[$i]).".*?>/i","",$Str);
			break;
		}
		
	}
	return replaceStr($Str,"&nbsp;"," ");

}

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

//智能归类(sClsName 类名,mName 视频名)
function smartGeneralize($sClsName,$mName){
	$sClsName=filterQuote(trim($sClsName));$mName=filterQuote(fword(trim($mName),0));$smartGeneralize=0;
	if ($sClsName=="" && $mName=="") return '';
	if ($sClsName<>""){
		$trow = DB::fetch_first("SELECT sysclsid FROM ".DB::table('cls')." WHERE publi=0 AND clsname='$sClsName'");
	    if (is_array($trow)) $smartGeneralize=$trow['sysclsid'];
	}
	if ($smartGeneralize>0) return $smartGeneralize;
	if ($smartGeneralize==0 && $sClsName<>""){
		$trow = DB::fetch_first("SELECT m_id FROM ".DB::table('type')." WHERE m_type=0 AND m_name='$sClsName'");
	    if (is_array($trow)) $smartGeneralize=$trow['m_id'];
		if ($smartGeneralize==0){
		    $trow = DB::fetch_first("SELECT m_id FROM ".DB::table('type')." WHERE m_type=0 AND m_name LIKE '%$sClsName%'");
	        if (is_array($trow)) $smartGeneralize=$trow['m_id'];
		}
	}
	if ($smartGeneralize==0 && $mName<>""){
	    $titleArray = explode("/", $mName);
	    foreach ($titleArray as $v_title) {
		    if (!empty($v_title)) $m_where .= " or concat('/',m_name,'/') like '%/".$v_title."/%' ";
	    }
	    if (!empty($m_where)){
		    $m_where = ltrim($m_where," or");
		    $trow = DB::fetch_first("SELECT m_type FROM ".DB::table('tempdata')." WHERE ".$m_where);
	        if (is_array($trow)) $smartGeneralize=$trow['m_type'];
		    if ($smartGeneralize==0){
		        $trow = DB::fetch_first("SELECT m_type FROM ".DB::table('data')." WHERE ".$m_where);
	            if (is_array($trow)) $smartGeneralize=$trow['m_type'];
		    }
	    }
	}
	return $smartGeneralize;
}


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