<?php
/*
'**************************************************************************************************
' 软件名称: 搜一次 Content Management System
' 版本编号: Version 1.X
' 官方网站: http://www.syccms.com
' 官方论坛：http://bbs.syccms.com
' 版权所有: 搜一次运营团队
' 法律顾问: 杭州市元茂律师事务所 严飞律师
' 郑重声明:
'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；
'    2、搜一次网络事业部保留此软件的法律追究权利
'**************************************************************************************************
*/
include "../../../include/conn.php";
include "../../../include/function.php";
include "../../admin_version.php";
include "../../admin_loginstate.php";
include "fun.php";
set_time_limit(0);
session_register("S_Name");
session_register("S_Url");
session_register("S_SourceMode");
session_register("S_SourceName");
session_register("S_Source");
session_register("S_Code");
session_register("S_Page");
session_register("S_AutoPageMode");
session_register("S_UrlStr");
session_register("S_PageGo");
session_register("S_PageEnd");
session_register("S_Order");
session_register("S_AutoSave");
session_register("S_SavePic");
session_register("S_Safe");
session_register("S_ListGo");
session_register("S_ListEnd");
session_register("S_LinkGo");
session_register("S_LinkEnd");					
session_register("S_ArtNameGo");	
session_register("S_ArtNameEnd");	
session_register("S_RemarkGo");	
session_register("S_RemarkEnd");
session_register("S_ClassMode");
session_register("S_ClassID");
session_register("S_ClassGo");
session_register("S_ClassEnd");
session_register("S_AuthorMode");
session_register("S_AuthorName");
session_register("S_AuthorGo");
session_register("S_AuthorEnd");
session_register("S_PicGo");
session_register("S_PicEnd");			
session_register("S_ContentGo");
session_register("S_ContentEnd");
session_register("S_PageMode");
session_register("S_PageUrlGo");
session_register("S_PageUrlEnd");
session_register("S_PageListGo");
session_register("S_PageListEnd");
session_register("S_Replace");
?>
<!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" />
<link  href="../../images/style.css" rel="stylesheet" type="text/css" />
<link type="text/css" href="../../images/alerts.css" rel="stylesheet" media="screen">
<title>自定义采集</title>
<script type="text/javascript" language="javascript">var tentpath='<?php echo S_SitePath?>';</script>
<script src="../../js/jquery.js"></script>
<script language="javascript" src="../../js/alerts.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#step1").click(function(){
		 var listgo = $("#S_ListGo").attr("value");
		 var listend = $("#S_ListGo").attr("value");
		 var linkgo = $("#s_linkgo").attr("value");
		 var linkend = $("#s_linkgo").attr("value");				   
		if($("#S_Name").val()==""){
			jAlert("请输入采集规则名称!","操作提示");
			return false;
			}
		else if($("#S_Url").val()==""){
			jAlert("请输入采集站点网址!","操作提示");
			return false;				
			}
		else if(listgo==''){
			jAlert("出错了，列表开始代码不能为空!","错误提示");
			return false;
		 }else if (listend==''){
			jAlert("出错了，列表结束代码不能为空!","错误提示");
			return false;
		 }else if(linkgo==''){
			jAlert("出错了，链接开始代码不能为空!","错误提示");
			return false;
		 }else if(linkend==''){
			jAlert("出错了，链接开始代码不能为空!","错误提示");
			return false;
		 }
		 else{
			document.form1.submit();
			 }
		
		})
})

function showpage(id){
		$.get("ajax.php?id="+id+"&str=<?php echo $_SESSION['S_UrlStr'];?>&ps=<?php echo $_SESSION['S_PageGo'];?>&pe=<?php echo $_SESSION['S_PageEnd'];?>",function(R){
				$("#pagevalue").html(R);						 
				})
		
		}
function getcheck(){
	url=$("#S_UrlStr").val();
		$("#getinfo").html("测试中...");
		$.get("ajax.php?action=getcheck&url="+url,function(R){
			$("#getinfo").html(R);			
			   })
	}	
function trshow(trname,id){
	if(id==0){
		$("#"+trname+"0").css("display","");
		$("#"+trname+"1").css("display","none");
		$("#"+trname+"2").css("display","none");
	}else{
		$("#"+trname+"0").css("display","none");
		$("#"+trname+"1").css("display","");
		$("#"+trname+"2").css("display","");
	}
}	
function playurlshow(id){
	if (id==0){
		$("#s_playurlgo").html("地址列表开始代码：&nbsp;")
		$("#s_playurlend").html("地址列表结束代码：&nbsp;")
	}else if(id==1){
		$("#s_playurlgo").html("播放链接开始代码：&nbsp;")
		$("#s_playurlend").html("播放链接结束代码：&nbsp;")
	}
}
</script>
</head>

<body>
<?php
class ui_collect{

	function step1($S_ID){
		global $db;
?>
<div class="r_main">
	<div class="r_content">
		<div class="r_content_1">
<form action="?action=step2&amp;S_ID=<?php echo $S_ID;?>" name="form1" method="post">        
				<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"  class="tb_style" >
					<tr>
					  	<td height="30" colspan="2" bgcolor="#FFFFFF" class="td_title">&nbsp;添加采集规则&nbsp;<font color="red">１. 设置基本参数及列表连接设置</font>  2. 采集内容与影片地址设置  3. 完成并采集测试</td>
					</tr>
					<tr>
					  	<td width="146" height="35" align="right" bgcolor="#FFFFFF" class="td_border">采集规则名称：&nbsp;</td>
						<td width="793"  align="left" bgcolor="#FFFFFF" class="td_border"><input name="S_Name" type="text"  size="50" value="<?php echo $_SESSION['S_Name']?>" id="S_Name"/>
						<font color="#FF0000">＊</font></td>
					</tr> 
					<tr>
					  	<td width="146" height="35" align="right" bgcolor="#FFFFFF" class="td_border">采集站点网址：&nbsp;</td>
						<td width="793"  align="left" bgcolor="#FFFFFF" class="td_border"><input name="S_Url" type="text"   value="<?php echo $_SESSION['S_Url']?>" size="50" id="S_Url"/>
						<font color="#FF0000"> ＊</font></td>
					</tr> 
					<tr>
					  	<td width="146" height="35" align="right" bgcolor="#FFFFFF" class="td_border">目标网页编码：&nbsp;</td>
						<td width="793"  align="left" bgcolor="#FFFFFF" class="td_border"><select name="S_Code" id="S_Code">
										<option value="GB2312" <?php if($_SESSION['S_Code']=='GB2312'){echo "selected";}?>>GB2312</option>
										<option value="UTF-8"  <?php if($_SESSION['S_Code']=='UTF-8'){echo "selected";}?>>UTF-8</option>
										<option value="BIG-5"  <?php if($_SESSION['S_Code']=='BIG-5'){echo "selected";}?>>BIG-5</option>
								   </select> <font color=#FF0000>＊</font>						</td>
					</tr>
                   <tr>
					  	<td width="146" height="35" align="right" bgcolor="#FFFFFF" class="td_border">采集分页设置：&nbsp;</td>
						<td width="793"  align="left" bgcolor="#FFFFFF" class="td_border"><input type="radio" name="S_Page"  checked class="radio" value="1" onclick="showpage(1);" <?php if($_SESSION['S_Page']=='1'){echo "checked";}?>/>
						  指定分类页
						  &nbsp;
						  <input type="radio" name="S_Page"  class="radio"  value="2" onclick="showpage(2);"  <?php if($_SESSION['S_Page']=='2'){echo "checked";}?>/>
						  自动分类页
						  &nbsp;
						  <input type="radio" name="S_Page"  class="radio"  value="3" onclick="showpage(3);"  <?php if($_SESSION['S_Page']=='3'){echo "checked";}?>/>
						  批量分类页&nbsp;
						  <input type="radio" name="S_Page"   class="radio"  value="4" onclick="showpage(4);"  <?php if($_SESSION['S_Page']=='4'){echo "checked";}?>/>						  
					    采集内容页</td>                   
                   </tr> 
					<tr>
					  	<td width="146" height="35" align="right" bgcolor="#FFFFFF" class="td_border" id="pagetitle">采集页面网址：&nbsp;</td>
					  <td width="793"  align="left" bgcolor="#FFFFFF" class="td_border" id="pagevalue">
                      &nbsp;载入中......
					  <script type="text/javascript">
					  $.get("ajax.php?id=<?php echo $_SESSION['S_Page'];?>&str=<?php echo $_SESSION['S_UrlStr'];?>&ps=<?php echo $_SESSION['S_PageGo'];?>&pe=<?php echo $_SESSION['S_PageEnd'];?>",function(R){
						$("#pagevalue").html(R);						 
							})
                	</script>
                      </td>
					</tr>  
 					<tr>
					  	<td width="146" height="35" align="right" bgcolor="#FFFFFF" class="td_border">采集功能选项：&nbsp;</td>
						<td width="793"  align="left" bgcolor="#FFFFFF" class="td_border"><input type="checkbox" name="S_Order" value="desc"  class="checkbox" <?php if($_SESSION['S_Order']=='desc'){echo "checked";}?>/>
						是否倒序采集&nbsp;&nbsp;&nbsp;
						<input type="checkbox" value="1" name="S_AutoSave" class="checkbox"  <?php if($_SESSION['S_AutoSave']=='1'){echo "checked";}?>/>
						  采集完毕自动入库&nbsp;&nbsp;
						  <input type="checkbox" name="S_SavePic" value="1"   class="checkbox" <?php if($_SESSION['S_SavePic']=='1'){echo "checked";}?>/>
						  入库完毕自动下载图片
				      </td>
					</tr> 
  <tr>
					  	<td width="104" height="40" align="right" bgcolor="#FFFFFF" class="td_border">文章分页参数：&nbsp;</td>
						<td width="639"  align="left" bgcolor="#FFFFFF" class="td_border"><input type="radio" name="S_AutoPageMode"  checked class="radio" value="0"/>不分页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="S_AutoPageMode"  class="radio" value="1" <?php if($_SESSION['S_AutoPageMode']=='1'){echo "checked";}?> />
根据目标站分页&nbsp;&nbsp;<span style="color:red">
<?php echo "{syccms:nextpage}"; ?></span></td>
					</tr>                   
					<tr>
					  	<td width="146" height="35" align="right" bgcolor="#FFFFFF" class="td_border">采集过滤选项：&nbsp;</td>
					  <td width="793"  align="left" valign="middle" bgcolor="#FFFFFF" class="td_border"  style="padding-top:10px;">		                      <input type="checkbox" name="S_Safe[]" value="iframe"  class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"iframe")=='1'){echo "checked";}?>/>Iframe&nbsp;
                      <input type="checkbox" name="S_Safe[]" value="object"  class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"object")=='1'){echo "checked";}?>/>Object&nbsp;
                      <input type="checkbox" name="S_Safe[]" value="script"  class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"script")=='1'){echo "checked";}?>/>Script&nbsp;
                      <input type="checkbox" name="S_Safe[]" value="div"     class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"div")=='1'){echo "checked";}?>/>Div&nbsp;
                      <input type="checkbox" name="S_Safe[]" value="class"   class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"class")=='1'){echo "checked";}?>/>Class&nbsp;
                      <input type="checkbox" name="S_Safe[]" value="table"   class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"table")=='1'){echo "checked";}?>/>Table<br /><br />
					  <input type="checkbox" name="S_Safe[]" value="span"    class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"span")=='1'){echo "checked";}?>/>Span&nbsp;&nbsp;&nbsp;
                      <input type="checkbox" name="S_Safe[]" value="img"     class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"img")=='1'){echo "checked";}?>/>Img&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <input type="checkbox" name="S_Safe[]" value="font"  class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"font")=='1'){echo "checked";}?>/>Font&nbsp;&nbsp;&nbsp;
                      <input type="checkbox" name="S_Safe[]" value="a"     class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"a")=='1'){echo "checked";}?>/>A &nbsp;&nbsp;
                      <input type="checkbox" name="S_Safe[]" value="html"  class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"html")=='1'){echo "checked";}?>/>Html&nbsp;&nbsp;
                      <input type="checkbox" name="S_Safe[]" value="td"  class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"td")=='1'){echo "checked";}?>/>Td&nbsp;&nbsp; 
                      <input type="checkbox" name="S_Safe[]" value="tr"  class="checkbox" <?php if(safesplit($_SESSION['S_Safe'],"tr")=='1'){echo "checked";}?>/>Tr<br />
						  <br /></td>
					</tr>
					<tr>
					  	<td width="155" height="30" align="right" bgcolor="#FFFFFF" class="td_border">&nbsp;文章列表开始代码：&nbsp;</td>
						<td width="728"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;<textarea name="S_ListGo" id="S_ListGo" cols="70" rows="5"><?php echo $_SESSION['S_ListGo']?></textarea></td>
					</tr>
					<tr>
					  	<td width="155" height="30" align="right" bgcolor="#FFFFFF" class="td_border">&nbsp;文章列表结束代码：&nbsp;</td>
						<td width="728"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;<textarea name="S_ListEnd" id="s_listend" cols="70" rows="5"><?php echo   $_SESSION['S_ListEnd'] ?></textarea></td>
					</tr>
                    <tr>
					  	<td width="155" height="30" align="right" bgcolor="#FFFFFF" class="td_border">&nbsp;文章链接开始代码：&nbsp;</td>
						<td width="728"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;<textarea name="S_LinkGo" id="s_linkgo" cols="70" rows="5"><?php echo   $_SESSION['S_LinkGo'] ?></textarea></td>
					</tr>
                    <tr>
					  	<td width="155" height="30" align="right" bgcolor="#FFFFFF" class="td_border">&nbsp;文章链接开始代码：&nbsp;</td>
						<td width="728"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;<textarea name="S_LinkEnd" id="s_linkend" cols="70" rows="5"><?php echo   $_SESSION['S_LinkEnd'] ?></textarea></td>
					</tr>                    
					<tr>
				  	  <td height="40" bgcolor="#FFFFFF" class="td_border">&nbsp;</td>
					  <td height="30" bgcolor="#FFFFFF" class="td_border"><input name="step1" type="button" class="rb1" id="step1"   value="继续下一步"/></td>
					</tr>                                                                                                                     
				</table>    
                </form>    
        </div>
    </div>
</div> 
<?php 
	}
function step2($S_ID){
	global $db;
		$clsstr='';
		$sql="select S_ID,S_Name from s_class where S_SystemID=2";
		$result=$db->query($sql);
		if($result){
			while($row=$db->fetch_array($result)){
				if($_SESSION['S_ClassID']==$row['S_ID']){
					$clsstr.="<option value=\"".$row['S_ID']."\" selected>".$row['S_Name']."</option>\r\n";
					}
				else{
					$clsstr.="<option value=\"".$row['S_ID']."\">".$row['S_Name']."</option>\r\n";
					}	
				}
			}	
			
?>
<div class="r_main">
	<div class="r_content">
		<div class="r_content_1">
        <form name="form2" action="?action=step3&amp;S_ID=<?php echo $S_ID;?>" method="post">
            	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"  class="tb_style" >
					<tr>
					  	<td height="30" colspan="2" bgcolor="#FFFFFF" class="td_title">&nbsp;添加采集规则&nbsp;１. 设置基本参数及列表连接设置  <font color="red">2. 采集内容与影片地址设置</font>  3. 完成并采集测试</td>
					</tr>
					<tr>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章标题开始代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_VideoNameGo" cols="70" rows="5"><?php echo $_SESSION['S_ArtNameGo']; ?></textarea></td>
					</tr>
					<tr>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章标题结束代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_VideoNameEnd" cols="70" rows="5"><?php echo $_SESSION['S_ArtNameEnd']; ?></textarea></td>
					</tr>
					<tr>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章分类采集设置：&nbsp;</td>
					    <td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
				      <input type="radio" name="S_ClassMode" id="S_ClassMode" value="0"  class="radio" checked onClick="trshow('s_classid',0)"/>固定分类&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="S_ClassMode" id="S_ClassMode" value="1"  class="radio" <?php if($_SESSION['S_ClassMode']=='1'){echo "checked"; }?> onClick="trshow('s_classid',1)"/>					    自动转换</td>
					</tr>
                    <tr id="s_classid0" <?php if($_SESSION['S_ClassMode']!='0'){ echo "style=\"display:none;\"";} ?>>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">固定文章分类选择：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
                        	<select name="S_ClassID">
 							<?php echo $clsstr; ?>
                      </select></td>
					</tr>
					<tr id="s_classid1" <?php if($_SESSION['S_ClassMode']!=1){ echo "style=\"display:none;\"";} ?>>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章分类开始代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_ClassGo" cols="70" rows="5"><?php echo $_SESSION['S_ClassGo']; ?></textarea></td>
					</tr>
                    <tr id="s_classid2" <?php if($_SESSION['S_ClassMode']!=1){ echo "style=\"display:none;\"";} ?> >
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章分类结束代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_ClassEnd" cols="70" rows="5"><?php echo $_SESSION['S_ClassEnd']; ?></textarea></td>
					</tr>
                    
                    <tr>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章概述开始代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_RemarkGo" cols="70" rows="5"><?php echo $_SESSION['S_RemarkGo']; ?></textarea></td>
					</tr>
					<tr>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章概述结束代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_RemarkEnd" cols="70" rows="5"><?php echo $_SESSION['S_RemarkEnd']; ?></textarea></td>
					</tr>
					
 					<tr>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章作者采集设置：&nbsp;</td>
					    <td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
				      <input type="radio" name="S_AuthorMode" id="S_AuthorMode" value="0"  class="radio" checked onClick="trshow('sauthor',0)"/>固定作者&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="S_AuthorMode" id="S_AuthorMode" value="1"  class="radio" <?php if($_SESSION['S_AuthorMode']=='1'){echo "checked"; }?> onClick="trshow('sauthor',1)"/>					    自动采集</td>
					</tr>
                    <tr id="sauthor0" <?php if($_SESSION['S_AuthorMode']!='0'){ echo "style=\"display:none;\"";} ?>>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">固定文章作者：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
                        	<?php $S_AuthorName=$_SESSION["S_AuthorName"];if(!IsNul($S_AuthorName)){$S_AuthorName=$_COOKIE['S_AdminUserName'];} ?><input name="S_AuthorName" type="text" value="<?php echo $S_AuthorName;?>" /></td>
					</tr>
					<tr id="sauthor1" <?php if($_SESSION['S_AuthorMode']!=1){ echo "style=\"display:none;\"";} ?>>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章作者开始代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_AuthorGo" cols="70" rows="5"><?php echo $_SESSION['S_AuthorGo']; ?></textarea></td>
					</tr>
                    <tr id="sauthor2" <?php if($_SESSION['S_AuthorMode']!=1){ echo "style=\"display:none;\"";} ?> >
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章作者结束代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_AuthorEnd" cols="70" rows="5"><?php echo $_SESSION['S_AuthorEnd']; ?></textarea></td>
					</tr>
					
 
                    <tr>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章图片开始代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_PicGo" cols="70" rows="5"><?php echo $_SESSION['S_PicGo']; ?></textarea></td>
					</tr>
					<tr>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章图片结束代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_PicEnd" cols="70" rows="5"><?php echo $_SESSION['S_PicEnd']; ?></textarea></td>
					</tr>
 					<tr>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章来源采集设置：&nbsp;</td>
					    <td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
				      <input type="radio" name="S_SourceMode" id="S_SourceMode" value="0"  class="radio" checked onClick="trshow('source',0)"/>固定来源&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="S_SourceMode" id="S_SourceMode" value="1"  class="radio" <?php if($_SESSION['S_SourceMode']=='1'){echo "checked"; }?> onClick="trshow('source',1)"/>					    自动采集</td>
					</tr>
                    <tr id="source0" <?php if($_SESSION['S_SourceMode']=='1'){ echo "style=\"display:none;\"";} ?>>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">固定文章来源：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
                        	<?php $S_SourceName=$_SESSION["S_SourceName"];if(!IsNul($S_SourceName)){$S_SourceName=S_SiteName;} ?><input name="S_SourceName" type="text" value="<?php echo $S_SourceName;?>" /></td>
					</tr>
					<tr id="source1" <?php if($_SESSION['S_SourceMode']==0){ echo "style=\"display:none;\"";} ?>>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章来源开始代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_SourceGo" cols="70" rows="5"><?php echo $_SESSION['S_SourceGo']; ?></textarea></td>
					</tr>
                    <tr id="source2" <?php if($_SESSION['S_SourceMode']==0){ echo "style=\"display:none;\"";} ?> >
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章来源结束代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_SourceEnd" cols="70" rows="5"><?php echo $_SESSION['S_SourceEnd']; ?></textarea></td>
					</tr>
					<tr>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章介绍开始代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_ContentGo" cols="70" rows="5"><?php echo $_SESSION['S_ContentGo']; ?></textarea></td>
					</tr>
                    <tr>
					  	<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">文章介绍结束代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_ContentEnd" cols="70" rows="5"><?php echo $_SESSION['S_ContentEnd']; ?></textarea></td>
					</tr>

                     <tr>
					  	<td width="205" height="30" align="right" bgcolor="#FFFFFF" class="td_border">分页采集模式选项：&nbsp;</td>
					  <td width="980"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;<input type="radio" name="S_PageMode" id="S_PageMode0" value="0"  class="radio" checked /> 
					    不采分页
&nbsp;&nbsp;&nbsp;
<input type="radio" name="S_PageMode" id="S_PageMode1" value="1"  class="radio" <?php if($_SESSION['S_PageMode']=='1'){echo "checked"; }?>/>
					  根据下一页引导模式&nbsp;&nbsp;&nbsp;&nbsp;
					  <input type="radio" name="S_PageMode" id="S_PageMode2" value="2"  class="radio" <?php if($_SESSION['S_PageMode']=='2'){echo "checked"; }?>/>	
		  根据分页列表模式				    </td>
				  </tr>
                    <tr id="pageurl1"   >
					  	<td width="205" height="30" align="right" bgcolor="#FFFFFF" class="td_border">分页列表开始代码：&nbsp;</td>
						<td width="980"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_PageUrlGo" cols="70" rows="5"><?php echo $_SESSION['S_PageUrlGo'];?></textarea></td>
					</tr>
                    <tr id="pageurl2" >
					  	<td width="205" height="30" align="right" bgcolor="#FFFFFF" class="td_border">分页列表结束代码：&nbsp;</td>
						<td width="980"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
					  <textarea name="S_PageUrlEnd" cols="70" rows="5"><?php echo $_SESSION['S_PageUrlEnd']; ?></textarea></td>
					</tr>
                    


                    <tr>
					  	<td width="126" height="35" align="right" bgcolor="#FFFFFF" class="td_border">&nbsp;文章采集内容替换：&nbsp;</td>
				      <td width="617"  align="left" bgcolor="#FFFFFF" class="td_border"> &nbsp;
					      <textarea name="S_Replace" id="S_Replace" cols="70" rows="5"><?php echo $_SESSION['S_Replace']; ?></textarea><br />
					  <span style="color:red">&nbsp; 格式：被替换的内容@@替换为的内容，每行为一个多个替换请以回车键换行，可使用&nbsp;&nbsp;[变量]&nbsp;&nbsp;标签&nbsp;<br>
					  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
					</tr>
					<tr>
					  	<td height="30" bgcolor="#FFFFFF" class="td_border" align="center">&nbsp;</td>
					    <td height="30" bgcolor="#FFFFFF" class="td_border" ><input name="botton4" type="button" class="rb1"  onclick="history.go(-1);" value="返回上一步"/>
					  	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="submit1" type="submit" class="rb1" value="保存采集规则"  /></td>
					</tr>
					<tr>
					  	<td height="30" bgcolor="#FFFFFF" class="td_border" colspan="2">&nbsp;</td>
					</tr>
			  </table>
              </form>
        </div>
    </div>
</div> 
<?php	
	}
function step3(){
?>
<div class="r_main">
	<div class="r_content">
		<div class="r_content_1">
        <input name="botton2" type="button" class="rb1"  onclick="history.go(-1);" value="返回上一步"/>
        </div>
    </div>
</div> 
<?php 
	}
}//end class
	$ui=new ui_collect;
	$action=SafeRequest("action","get");
	switch($action){
		case 'step1':
			$S_ID=CollectGet("S_ID","get");
			$sql="select * from s_acustom where S_ID=$S_ID";
			$row=$db->getrow($sql);
			if($row){
				  $_SESSION['S_Name']=$row['S_Name'];
				  $_SESSION['S_Url']=$row['S_Url'];
				  $_SESSION['S_Code']=$row['S_Code'];
				  $_SESSION['S_AutoPageMode']=$row['S_AutoPageMode'];
				  $_SESSION['S_Page']=$row['S_Page'];
				  $_SESSION['S_UrlStr']=$row['S_UrlStr'];
				  $_SESSION['S_PageGo']=$row['S_PageGo'];
				  $_SESSION['S_PageEnd']=$row['S_PageEnd'];
				  $_SESSION['S_Order']=$row['S_Order'];
				  $_SESSION['S_AutoSave']=$row['S_AutoSave'];
				  $_SESSION['S_SavePic']=$row['S_SavePic'];
				  $_SESSION['S_Safe']=$row['S_Safe'];
				  $_SESSION['S_ListGo']=$row['S_ListGo'];
				  $_SESSION['S_ListEnd']=$row['S_ListEnd'];
				  $_SESSION['S_LinkGo']=$row['S_LinkGo'];
				  $_SESSION['S_LinkEnd']=$row['S_LinkEnd'];
				  $_SESSION['S_ArtNameGo']=$row['S_ArtNameGo'];
				  $_SESSION['S_ArtNameEnd']=$row['S_ArtNameEnd']; 
				  $_SESSION['S_RemarkGo']=$row['S_RemarkGo'];
				  $_SESSION['S_RemarkEnd']=$row['S_RemarkEnd'];
				  $_SESSION['S_AuthorMode']=$row['S_AuthorMode'];	
				  $_SESSION['S_AuthorGo']=$row['S_AuthorGo'];
				  $_SESSION['S_AuthorEnd']=$row['S_AuthorEnd'];
				  $_SESSION['S_AuthorName']=$row['S_AuthorName'];
				  $_SESSION['S_SourceMode']=$row['S_SourceMode'];	
				  $_SESSION['S_SourceName']=$row['S_SourceName'];	
				  $_SESSION['S_SourceGo']=$row['S_SourceGo'];	
				  $_SESSION['S_SourceEnd']=$row['S_SourceEnd'];	
				  $_SESSION['S_PicGo']=$row['S_PicGo'];
				  $_SESSION['S_PicEnd']=$row['S_PicEnd'];
				  $_SESSION['S_ClassMode']=$row['S_ClassMode'];
				  $_SESSION['S_ClassID']=$row['S_ClassID'];
				  $_SESSION['S_ClassGo']=$row['S_ClassGo'];
				  $_SESSION['S_ClassEnd']=$row['S_ClassEnd'];
				  $_SESSION['S_ContentGo']=$row['S_ContentGo'];
				  $_SESSION['S_ContentEnd']=$row['S_ContentEnd'];
				  $_SESSION['S_PageMode']=$row['S_PageMode'];
				  $_SESSION['S_PageUrlGo']=$row['S_PageUrlGo'];
				  $_SESSION['S_PageUrlEnd']=$row['S_PageUrlEnd'];
				  $_SESSION['S_Replace']=$row['S_Replace'];				
				}		
			$ui->step1($S_ID);
			break;
		case 'step2':
			$S_ID=CollectGet("S_ID","get");
			$_SESSION['S_Name']=SafeRequest("S_Name","post");
			$_SESSION['S_Url']=SafeRequest("S_Url","post");
			$_SESSION['S_Code']=SafeRequest("S_Code","post");
			$_SESSION['S_Page']=SafeRequest("S_Page","post");
			$_SESSION['S_AutoPageMode']=SafeRequest("S_AutoPageMode","post");			
			$_SESSION['S_UrlStr']=SafeRequest("S_UrlStr","post");
			$_SESSION['S_PageGo']=SafeRequest("S_PageGo","post");
			$_SESSION['S_PageEnd']=SafeRequest("S_PageEnd","post");
			$_SESSION['S_Order']=SafeRequest("S_Order","post");
			$_SESSION['S_AutoSave']=SafeRequest("S_AutoSave","post");
			$_SESSION['S_SavePic']=SafeRequest("S_SavePic","post");
			$_SESSION['S_Safe']=RequestBox("S_Safe");
			$_SESSION['S_ListGo']=SafeRequest("S_ListGo","post");
			$_SESSION['S_ListEnd']=SafeRequest("S_ListEnd","post");
			$_SESSION['S_LinkGo']=SafeRequest("S_LinkGo","post");
			$_SESSION['S_LinkEnd']=SafeRequest("S_LinkEnd","post");			
			$ui->step2($S_ID);
			break;
		case 'step3':
			$_SESSION['S_ArtNameGo']=SafeRequest("S_VideoNameGo","post");	
			$_SESSION['S_ArtNameEnd']=SafeRequest("S_VideoNameEnd","post");	
			$_SESSION['S_RemarkGo']=SafeRequest("S_RemarkGo","post");	
			$_SESSION['S_RemarkEnd']=SafeRequest("S_RemarkEnd","post");
			$_SESSION['S_ClassMode']=SafeRequest("S_ClassMode","post");
			$_SESSION['S_ClassID']=SafeRequest("S_ClassID","post");
			$_SESSION['S_ClassGo']=SafeRequest("S_ClassGo","post");
			$_SESSION['S_ClassEnd']=SafeRequest("S_ClassEnd","post");
			
			$_SESSION['S_AuthorMode']=SafeRequest("S_AuthorMode","post");
			$_SESSION['S_AuthorName']=SafeRequest("S_AuthorName","post");
			$_SESSION['S_AuthorGo']=SafeRequest("S_AuthorGo","post");
			$_SESSION['S_AuthorEnd']=SafeRequest("S_AuthorEnd","post");
			
			$_SESSION['S_SourceMode']=SafeRequest("S_SourceMode","post");
			$_SESSION['S_SourceName']=SafeRequest("S_SourceName","post");
			$_SESSION['S_SourceGo']=SafeRequest("S_SourceGo","post");
			$_SESSION['S_SourceEnd']=SafeRequest("S_SourceEnd","post");
			
			$_SESSION['S_PageMode']=SafeRequest("S_PageMode","post");
			$_SESSION['S_PageUrlGo']=SafeRequest("S_PageUrlGo","post");
			$_SESSION['S_PageUrlEnd']=SafeRequest("S_PageUrlEnd","post");
			

			$_SESSION['S_PicGo']=SafeRequest("S_PicGo","post");
			$_SESSION['S_PicEnd']=SafeRequest("S_PicEnd","post");			
			$_SESSION['S_ContentGo']=SafeRequest("S_ContentGo","post");
			$_SESSION['S_ContentEnd']=SafeRequest("S_ContentEnd","post");


			$_SESSION['S_Replace']=SafeRequest("S_Replace","post");
			saveRules();
			break;
		default:
			$ui->step1();
			break;
		}



function safesplit($str,$value){
		$strArr=explode(',',$str);
		for($i=0;$i<count($strArr);$i++){
			if($strArr[$i]==$value){
				return "1";
				break;
				}
			}		
	}

function saveRules(){
 global $db;
  $S_ID=CollectGet("S_ID","get");
  $S_Name=$_SESSION['S_Name'];
  $S_Url=$_SESSION['S_Url'];
  $S_Code=$_SESSION['S_Code'];
  $S_AutoPageMode=$_SESSION['S_AutoPageMode'];
  $S_Page=$_SESSION['S_Page'];
  $S_UrlStr=$_SESSION['S_UrlStr'];
   if($S_Page=='3' or $S_Page=='4'){
	  $TempArr=explode(chr(13).chr(10),$S_UrlStr);
	  $S_UrlStr=implode('#',$TempArr);	 
	  }
  $S_PageGo=$_SESSION['S_PageGo'];
  $S_PageEnd=$_SESSION['S_PageEnd'];
  $S_Order=$_SESSION['S_Order'];
  $S_AutoSave=$_SESSION['S_AutoSave'];
  $S_SavePic=$_SESSION['S_SavePic'];
  $S_Safe=$_SESSION['S_Safe'];
  $S_ListGo=$_SESSION['S_ListGo'];
  $S_ListEnd=$_SESSION['S_ListEnd'];
  $S_LinkGo=$_SESSION['S_LinkGo'];
  $S_LinkEnd=$_SESSION['S_LinkEnd'];
  $S_ArtNameGo=$_SESSION['S_ArtNameGo'];
  $S_ArtNameEnd=$_SESSION['S_ArtNameEnd']; 
  $S_RemarkGo=$_SESSION['S_RemarkGo'];
  $S_RemarkEnd=$_SESSION['S_RemarkEnd'];
  
  $S_AuthorName=$_SESSION['S_AuthorName'];
  $S_AuthorMode=$_SESSION['S_AuthorMode'];	
  $S_AuthorGo=$_SESSION['S_AuthorGo'];
  $S_AuthorEnd=$_SESSION['S_AuthorEnd'];

  $S_SourceMode=$_SESSION['S_SourceMode'];	
  $S_SourceName=$_SESSION['S_SourceName'];	
  $S_SourceGo=$_SESSION['S_SourceGo'];	
  $S_SourceEnd=$_SESSION['S_SourceEnd'];	

  $S_PicGo=$_SESSION['S_PicGo'];
  $S_PicEnd=$_SESSION['S_PicEnd'];

  $S_ClassMode=$_SESSION['S_ClassMode'];
  $S_ClassID=$_SESSION['S_ClassID'];
  $S_ClassGo=$_SESSION['S_ClassGo'];
  $S_ClassEnd=$_SESSION['S_ClassEnd'];
  $S_ContentGo=$_SESSION['S_ContentGo'];
  $S_ContentEnd=$_SESSION['S_ContentEnd'];

  $S_PageMode=$_SESSION['S_PageMode'];
  $S_PageUrlGo=$_SESSION['S_PageUrlGo'];
  $S_PageUrlEnd=$_SESSION['S_PageUrlEnd'];

			
  $S_Replace=$_SESSION['S_Replace'];


  $S_AddTime=date("Y-m-d H:i:s");
  if(!IsNum($S_PageGo)) $S_PageGo=1;
  if(!IsNum($S_PageEnd)) $S_PageEnd=1;
  if(!IsNum($S_AutoSave)) $S_AutoSave=0;
  if(!IsNum($S_SavePic)) $S_SavePic=0;
  $sql="update  s_acustom set 
`S_Name`='$S_Name' ,`S_Url`='$S_Url' ,`S_Code`='$S_Code',`S_SourceGo`='$S_SourceGo',`S_SourceEnd`='$S_SourceEnd',`S_SourceMode`='$S_SourceMode' ,`S_SourceName`= '$S_SourceName',`S_Page`= '$S_Page',`S_AutoPageMode`= '$S_AutoPageMode',`S_UrlStr`= '$S_UrlStr',`S_PageGo`= '$S_PageGo',`S_PageEnd`= '$S_PageEnd',`S_Order`='$S_Order'  ,`S_AutoSave`= '$S_AutoSave',`S_SavePic`= '$S_SavePic',`S_Safe`= '$S_Safe',`S_ListGo`='$S_ListGo' ,`S_ListEnd`='$S_ListEnd' ,`S_LinkGo`= '$S_LinkGo',`S_LinkEnd`='$S_LinkEnd' ,`S_ArtNameGo`='$S_ArtNameGo' ,`S_ArtNameEnd`='$S_ArtNameEnd' ,`S_RemarkGo`=  '$S_RemarkGo',`S_RemarkEnd`='$S_RemarkEnd' ,`S_AuthorMode`= '$S_AuthorMode',`S_AuthorName`= '$S_AuthorName',`S_AuthorGo`='$S_AuthorGo' ,`S_AuthorEnd`= '$S_AuthorEnd',`S_PicGo`='$S_PicGo' ,`S_PageMode`='$S_PageMode' ,`S_PageUrlGo`= '$S_PageUrlGo',`S_PageUrlEnd`= '$S_PageUrlEnd',`S_PageListGo`='$S_PageListGo' ,`S_PageListEnd`= '$S_PageListEnd',`S_PicEnd`='$S_PicEnd' ,`S_ClassMode`= '$S_ClassMode' ,`S_ClassID`='$S_ClassID' ,`S_ClassGo`= '$S_ClassGo' ,`S_ClassEnd`='$S_ClassEnd' ,`S_ContentGo`= '$S_ContentGo',`S_ContentEnd`= '$S_ContentEnd',`S_AddTime`= '$S_AddTime',`S_Replace`='$S_Replace' where S_ID=$S_ID;";
  //die($sql);
  if($db->query($sql)){
	  die("规则编辑成功!&nbsp;");
	  }
 else{
	 die("未知错误规则添加失败!");
	 }		  
	}
?> 
<?php require_once("../../admin_bottom.php");?>   
</body>
</html>