<?php

/*

'**************************************************************************************************

' 软件名称: 黑色幻想舞曲管理系统CMS2.0

' 版本编号: hshxsdj 2.0

' 官方网站: http://www.hshxs.com

' 官方论坛：http://bbs.hshxs.com

' 版权所有: 黑色幻想开发团队    噬己翼(QQ:532917920)

' 郑重声明:

'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；

'    2、黑色幻想网络事业部保留此软件的法律追究权利

'**************************************************************************************************

*/

include "../../../include/conn.php";

include "../../../include/function.php";

include "../../admin_version.php";

include "../../admin_loginstate.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

SystemPer(5);

class ui_collect{



	function main(){

		global $db;

		$sql="select S_ID,S_Name,S_Url,S_AddTime from s_acustom";

		$Arr=getpagerow($sql,20);//sql,每页显示条数

		$result=$db->query($Arr[2]);

		$adminnum=$db->num_rows($result);

?>

<div class="r_main">

	<div class="r_content">

		<div class="r_content_1">

				<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"  class="tb_style" >

				<form method="post" name="formb" action="../action=add" >

					<tr>

					  <td height="30" colspan="9" bgcolor="#FFFFFF" class="td_title">&nbsp;采集规则列表</td>

				  </tr>

					<tr>

					  <td height="30" bgcolor="#FFFFFF" class="td_border">&nbsp; 编号</td>

						<td width="105" bgcolor="#FFFFFF" class="td_border">&nbsp;采集规则名</td>

						<td width="191"  bgcolor="#FFFFFF" class="td_border">&nbsp;采集站点链接</td>

						<td width="175" align="center" bgcolor="#FFFFFF" class="td_border">最后采集时间</td>

						<td colspan="4" align="center" bgcolor="#FFFFFF" class="td_border">操 作</td>

					</tr>

                       <?php

					   if($adminnum==0) echo "

							<tr>

                            	<td colspan=\"8\" class=\"td_border\" height=\"30\" align=center><b>暂无规则列表,请添加<b/>！</td>

                            </tr>";						   

                       if($result){

						   while ($row = $db ->fetch_array($result)){



					   ?>   

						<tr>

							<td height="30" class="td_border" width="52">&nbsp; <?php echo $row['S_ID'];?></td>

							<td width="105" align="centent" class="td_border">&nbsp;<a href="?action=add&amp;S_ID=<?php echo $row['S_ID'];?>"><?php echo $row['S_Name'];?></a></td>

							<td width="191" class="td_border">&nbsp;<a href="<?php echo $row['S_Url'];?>" target="_blank"><?php echo $row['S_Url'];?></a></td>

							

							<td width="175" align="center" class="td_border"><?php echo $row['S_AddTime'];?></td>

							<td width="36" align="center"  class="td_border"><A href="admin_collecting.php?S_ID=<?php echo $row['S_ID'];?>">采集</a></td>

							<td width="31" align="center"  class="td_border"><A href="admin_export.php?s_id=<?php echo $row['S_ID'];?>" >导出</a></td>

							<td width="28" align="center"  class="td_border"><A href="admin_collect_edit.php?action=step1&amp;S_ID=<?php echo $row['S_ID'];?>">编辑</a></td>

							<td width="32" align="center"  class="td_border"><a href="?action=del&amp;S_ID=<?php echo $row['S_ID'];?>" onClick="" >删除</a></td>

						</tr>

                         <?php

                         							   

							   }

					   }

?> 

				  </form>

			  	  <tr>

                  	<td height="30"  colspan="2" class="td_border"> &nbsp;

                  	  &nbsp; <input name="export" type="button" class="rb1" id="export" onClick="window.location='admin_export.php?action=imp'" value="导入采集规则"/></td>

				    <td height="30" colspan="12" align="right" class="td_border"><?php echo $Arr[0];?>&nbsp;</td>

			      </tr>

			  </table>

				</div>

		</div>

</div>

<?php		

		

		}

		





	function step1(){

		global $db;

?>

<div class="r_main">

	<div class="r_content">

		<div class="r_content_1">

<form action="?action=step2" 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 "{chshdjcms: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(){

	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" 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']!='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_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']!=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_SourceGo" cols="70" rows="5"><?php echo $_SESSION['S_SourceGo']; ?></textarea></td>

					</tr>

                    <tr id="source2" <?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;

					  <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 'ruleadd':

			session_destroy(); 

			$ui->step1();

			break;

		case 'step1':

			$ui->step1();

			break;

		case 'del':

			del();

			break;

		case 'main':

			$ui->main();

			break;

		case 'step2':

			$_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();

			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->main();

			break;

		}



function del(){

		global $db;

		$S_ID=SafeRequest("S_ID","get");

		$sql="delete from s_acustom where S_ID='".$S_ID."'";

		if($db->query($sql)){

			echo "<script>window.location='admin_collect.php';</script>";

			}

		}



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_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'];

  $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="INSERT INTO `s_acustom` (

`S_Name` ,`S_Url` ,`S_Code` ,`S_SourceGo`,`S_SourceEnd` ,`S_SourceMode` ,`S_SourceName` ,`S_Page` ,`S_AutoPageMode` ,`S_UrlStr` ,`S_PageGo` ,`S_PageEnd` ,`S_Order` ,`S_AutoSave` ,`S_SavePic` ,`S_Safe` ,`S_ListGo` ,`S_ListEnd` ,`S_LinkGo` ,`S_LinkEnd` ,`S_ArtNameGo` ,`S_ArtNameEnd` ,`S_RemarkGo` ,`S_RemarkEnd` ,`S_AuthorMode` ,`S_AuthorName` ,`S_AuthorGo` ,`S_AuthorEnd` ,`S_PicGo` ,`S_PageMode` ,`S_PageUrlGo` ,`S_PageUrlEnd` ,`S_PageListGo` ,`S_PageListEnd` ,`S_PicEnd` ,`S_ClassMode` ,`S_ClassID` ,`S_ClassGo` ,`S_ClassEnd` ,`S_ContentGo` ,`S_ContentEnd` ,`S_AddTime` ,`S_Replace` )VALUES ('$S_Name', '$S_Url', '$S_Code', '$S_SourceGo','$S_SourceEnd', '$S_SourceMode', '$S_SourceName', '$S_Page', '$S_AutoPageMode', '$S_UrlStr', '$S_PageGo', '$S_PageEnd', '$S_Order' , '$S_AutoSave', '$S_SavePic', '$S_Safe', '$S_ListGo', '$S_ListEnd', '$S_LinkGo', '$S_LinkEnd', '$S_ArtNameGo', '$S_ArtNameEnd', '$S_RemarkGo', '$S_RemarkEnd', '$S_AuthorMode', '$S_AuthorName', '$S_AuthorGo', '$S_AuthorEnd', '$S_PicGo', '$S_PageMode', '$S_PageUrlGo', '$S_PageUrlEnd', '$S_PageListGo', '$S_PageListEnd', '$S_PicEnd', '$S_ClassMode', '$S_ClassID', '$S_ClassGo', '$S_ClassEnd', '$S_ContentGo', '$S_ContentEnd', '$S_AddTime', '$S_Replace'

);";

 // die($sql);

  if($db->query($sql)){

	  die("规则添加成功!&nbsp;");

	  }

 else{

	 die("未知错误规则添加失败!");

	 }		  

	}

?> 

<?php require_once("../../admin_bottom.php");?>   

</body>

</html>