<?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";

include "fun.php";

@set_time_limit(0);

$S_ID=CollectGet("S_ID","auto");

$sql="select * from s_acustom where S_ID=$S_ID";

$row=$db->getrow($sql);

if($row){

  $S_Name=$row['S_Name'];

  $S_Url=$row['S_Url'];

  $S_Code=$row['S_Code'];

  $S_AutoPageMode=$row['S_AutoPageMode'];

  $S_Page=$row['S_Page'];

  $S_UrlStr=$row['S_UrlStr'];

  $S_PageGo=$row['S_PageGo'];

  $S_PageEnd=$row['S_PageEnd'];

  $S_Order=$row['S_Order'];

  $S_AutoSave=$row['S_AutoSave'];

  $S_SavePic=$row['S_SavePic'];

  $S_Safe=$row['S_Safe'];

  $S_ListGo=$row['S_ListGo'];

  $S_ListEnd=$row['S_ListEnd'];

  $S_LinkGo=$row['S_LinkGo'];

  $S_LinkEnd=$row['S_LinkEnd'];

  $S_ArtNameGo=$row['S_ArtNameGo'];

  $S_ArtNameEnd=$row['S_ArtNameEnd']; 

  $S_RemarkGo=$row['S_RemarkGo'];

  $S_RemarkEnd=$row['S_RemarkEnd'];

  

  $S_SourceName=$row['S_SourceName'];

  $S_SourceGo=$row['S_SourceGo'];

  $S_SourceEnd=$row['S_SourceEnd'];

  $S_SourceMode=$row['S_SourceMode'];

  

  $S_AuthorName=$row['S_AuthorName'];

  $S_AuthorMode=$row['S_AuthorMode'];

  $S_AuthorGo=$row['S_AuthorGo'];

  $S_AuthorEnd=$row['S_AuthorEnd'];

;

  $S_PicGo=$row['S_PicGo'];

  $S_PicEnd=$row['S_PicEnd'];



  $S_ClassMode=$row['S_ClassMode'];

  $S_ClassID=$row['S_ClassID'];

  $S_ClassGo=$row['S_ClassGo'];

  $S_ClassEnd=$row['S_ClassEnd'];

  $S_ContentGo=$row['S_ContentGo'];

  $S_ContentEnd=$row['S_ContentEnd'];

  

  $S_PageMode=$row['S_PageMode'];

  $S_PageUrlGo=$row['S_PageUrlGo'];

  $S_PageUrlEnd=$row['S_PageUrlEnd'];



  $S_AddTime=$row['S_AddTime'];

  $S_Replace=$row['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">

<script type="text/javascript" language="javascript">var tentpath='<?php echo S_SitePath?>';</script>

<script language="javascript" src="../../js/jquery.js"></script>

<script language="javascript" src="../../js/alerts.js"></script>

<title>自定义采集</title>



</head>



<body>

<div class="r_main">

	<div class="r_content">

		<div class="r_content_1">       

<?php

SystemPer(5);

	if($S_Page=='1'){//指定分类页面

		$Url=$S_UrlStr;

		$Content=geturlcontent($Url,$S_Code);//读取列表文件

		if(!IsNul($Content)) die("在获取<font color=red>$Url</font>时出错,原因获取不到内容!");

		$returnStr = getContent($Content,$S_ListGo,$S_ListEnd,1);//截取列表开始--结束

		$returnStr=formaturl($returnStr,$S_Url);

        $vLinkArr=getArr($S_LinkGo,$S_LinkEnd,$returnStr);//获取到文章连接地址 返回数组

		if(empty($vLinkArr)) die("获取文章连接地址时出错,请确认");

		$LinkCount=count($vLinkArr);//连接总数

		$NowArtCount=CollectGet("nvc","auto");

		if(!IsNul($NowArtCount)){

			$NowArtCount=0;

			}

		else{

			if($NowArtCount>$LinkCount){

				$LinkCount=$LinkCount-1;

				}

			}

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

        	<tr>

               <td height=\"30\" align=\"left\" class=\"td_title\">

           		&nbsp;&nbsp;正在采集指定分类列表,共<font color=red>".$S_PageEnd."</font>页,当前页共<font color=red>".$LinkCount."</font>条数据,已经采集<font color=red>".($NowArtCount+1)."</font>条</td>

            </tr>

      </table> ";

	  	

		$ArtContent=geturlcontent($vLinkArr[$NowArtCount],$S_Code);//文章内容页面

		if(!IsNul($ArtContent)) die("在获取<font color=red>$vLinkArr[$NowArtCount]</font>文章内容页出错,获取不到数据，暂停3秒继续采集下一文章!<script>setTimeout('ReadGo();',3000);function ReadGo(){window.location='?S_ID=".$S_ID."&nvc=".($NowArtCount+1)."'}</script>");

		$ArtContent=formaturl($ArtContent,$vLinkArr[$NowArtCount]);

		$V_Name=getContent($ArtContent,$S_ArtNameGo,$S_ArtNameEnd,1);//文章名

		

		$V_Remark=getContent($ArtContent,$S_RemarkGo,$S_RemarkEnd,1);

		if($S_ClassMode=='0'){//分类

			$V_ClassID=$S_ClassID;

			}

		else{

			$V_ClassName=getContent($ArtContent,$S_ClassGo,$S_ClassEnd,1);

			$sql="select S_ID from s_class where S_Name like '%$V_ClassName%' Order by S_ID desc";

			$row=$db->getRow($sql);

			if($row['S_ID']){

				$V_ClassID=$row['S_ID'];

				}

			else{

				$V_ClassID=0;

				}	

			}

	

		if($S_SourceMode=='1'){

			$V_Source=getContent($ArtContent,$S_SourceGo,$S_SourceEnd,1);

			}

		else{

			$V_Source=$S_SourceName;

			}

			

		if($S_AuthorMode=='1'){

			$V_Author=getContent($ArtContent,$S_AuthorGo,$S_AuthorEnd,1);

			}

		else{

			$V_Author=$S_AuthorName;

			}	



		$V_Pic=getContent($ArtContent,$S_PicGo,$S_PicEnd,1);

		

		//分页内容采集

		if($S_PageMode=='1'){

			

			$S_PageUrlGo=ReplaceStr($S_PageUrlGo,"'","\"");

			$S_PageUrlEnd=ReplaceStr($S_PageUrlEnd,"'","\"");

			$V_NextPage=trim(getContent($ArtContent,$S_PageUrlGo,$S_PageUrlEnd,1));

			$V_Content=getContent($ArtContent,$S_ContentGo,$S_ContentEnd,1);

			while(IsNul($V_NextPage) && substr(strtolower($V_NextPage),0,7)=="http://"){

					

					$Next_Content=geturlcontent($V_NextPage,$S_Code);

					

					$Next_Content=formaturl($Next_Content,$V_NextPage);

					if(!IsNul($Next_Content)) break;

					$VT_Content=getContent($Next_Content,$S_ContentGo,$S_ContentEnd,1);

					$V_NextPage=trim(getContent($Next_Content,$S_PageUrlGo,$S_PageUrlEnd,1));

					

					$V_Content.=$VT_Content;

					if(!IsNul($V_NextPage) or substr(strtolower($V_NextPage),0,7)!="http://") break;

				}

			}

		elseif($S_PageMode=='2'){

			$S_PageUrlGo=ReplaceStr($S_PageUrlGo,"'","\"");

			$S_PageUrlEnd=ReplaceStr($S_PageUrlEnd,"'","\"");

			$V_NextPage=trim(getContent($ArtContent,$S_PageUrlGo,$S_PageUrlEnd,1));

			$V_Content=getContent($ArtContent,$S_ContentGo,$S_ContentEnd,1);

			while(IsNul($V_NextPage) && substr(strtolower($V_NextPage),0,7)=="http://"){

					$Next_Content=geturlcontent($V_NextPage,$S_Code);

					$Next_Content=formaturl($Next_Content,$V_NextPage);

					if(!IsNul($Next_Content)) break;

					$VT_Content=getContent($Next_Content,$S_ContentGo,$S_ContentEnd,1);

					$V_NextPage=trim(getContent($Next_Content,$S_PageUrlGo,$S_PageUrlEnd,1));

					$V_Content.=$VT_Content;

					if(!IsNul($V_NextPage) or substr(strtolower($V_NextPage),0,7)!="http://") break;

				}			

			}

		else{	

			$V_Content=getContent($ArtContent,$S_ContentGo,$S_ContentEnd,1);

			}

			

		$V_Content=collectRep($V_Content,$S_Replace);

		$V_Content=ReplaceStr($V_Content,"'","");

		$V_Pic=dealPic($V_Pic,$S_Url,$V_Content);

		$V_AddTime=date('Y-m-d H:i:s');    

		$NowArtCount=$NowArtCount+1;

		showcollectinfo($V_Name,$V_Remark,$V_Author,$V_Source,$V_Pic,$V_ClassID,$V_Content);

		

		$sql="Insert tempart (S_Name,S_Remark,S_ClassID,S_Pic,S_Author,S_Content,S_Source,S_AddTime,S_Url) values ('".$V_Name."','".$V_Remark."',".$V_ClassID.",'".$V_Pic."','".$V_Author."','".$V_Content."','".$V_Source."','".$V_AddTime."','".$S_Url."')";

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

			echo "<div style=\"height:45px;line-height:45px;\">&nbsp;&nbsp;<font color=green>文章保存成功</font>";

			}

		else{

			echo "<div style=\"height:45px;line-height:45px;\">&nbsp;&nbsp;<font color=red>文章保存失败</font>";

			}	

		if($NowArtCount>=$LinkCount){

			if($S_AutoSave=='1'){

				die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停1秒继续采集....恭喜全部采集完毕！！&nbsp;暂停1秒后开始自动入库文章!</div><script>setTimeout('ReadGo();',1000);function ReadGo(){window.location='admin_inflow.php?action=save&sel=4&url=".$S_Url."&ispic=".$S_SavePic."'}</script>");

				}

			else{	

				die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停3秒继续采集....恭喜全部采集完毕！！</div>");

				}

			}			

		else{

			die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停1秒继续采集....</div><script>setTimeout('ReadGo();',1000);function ReadGo(){window.location='?S_ID=".$S_ID."&nvc=".($NowArtCount)."'}</script>");

			

			}			

		}

	elseif($S_Page=='2'){//自动分页类

		$StartPage=$S_PageGo;

		$Spage=CollectGet("spage","auto");

		if($S_Order=="desc"){

			if(!IsNul($Spage)){

				$Spage=$S_PageEnd;}

			else{

				if($Spage>=$S_PageEnd) $Spage=$S_PageEnd;

				}	

			}

		else{	

			if(!IsNul($Spage)){

				$Spage=$S_PageGo;

			}else{

				if($Spage>$S_PageEnd) $Spage=$S_PageEnd;

				}

		}

		$Url=ReplaceStr($S_UrlStr,'{$ID}',$Spage);

		$Content=geturlcontent($Url,$S_Code);//读取列表文件

		

		if(!IsNul($Content)) {

			if($S_Order=="desc"){

				die("在获取<font color=red>$Url</font>时出错,原因获取不到内容!<br/>暂停三秒采集下一列表<script>setTimeout('ReadGo();',3000);function ReadGo(){window.location='?S_ID=".$S_ID."&spage=".($Spage-1)."'}</script>");

				}

			else{

				die("在获取<font color=red>$Url</font>时出错,原因获取不到内容!<br/>暂停三秒采集下一列表<script>setTimeout('ReadGo();',3000);function ReadGo(){window.location='?S_ID=".$S_ID."&spage=".($Spage+1)."'}</script>");

				}	

			}

		$returnStr = getContent($Content,$S_ListGo,$S_ListEnd,1);//截取列表开始--结束

		$returnStr=formaturl($returnStr,$S_Url);

        $vLinkArr=getArr($S_LinkGo,$S_LinkEnd,$returnStr);//获取到文章连接地址 返回数组

		if(empty($vLinkArr)) die("获取文章连接地址时出错,请确认");

		$LinkCount=count($vLinkArr);//连接总数

		$NowArtCount=CollectGet("nvc","auto");

		if(!IsNul($NowArtCount)){

			$NowArtCount=0;

			}

		else{

			if($NowArtCount>$LinkCount){

				$LinkCount=$LinkCount-1;

				}

			}

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

        	<tr>

               <td height=\"30\" align=\"left\" class=\"td_title\">

           		&nbsp;&nbsp;正在采集第<font color=red>".$Spage."</font>页列表,共<font color=red>".($S_PageEnd-$S_PageGo+1)."</font>页,当前页共<font color=red>".$LinkCount."</font>条数据,已经采集<font color=red>".($NowArtCount)."</font>条</td>

            </tr>

      </table> ";			

		$ArtContent=geturlcontent($vLinkArr[$NowArtCount],$S_Code);//文章内容页面		

		$ArtContent=formaturl($ArtContent,$vLinkArr[$NowArtCount]);

		if(!IsNul($ArtContent)) die("在获取<font color=red>$vLinkArr[$NowArtCount]</font>文章内容页出错,获取不到数据，暂停3秒继续采集下一文章!<script>setTimeout('ReadGo();',3000);function ReadGo(){window.location='?S_ID=".$S_ID."&spage=".$Spage."&nvc=".($NowArtCount+1)."'}</script>");

		$V_Name=getContent($ArtContent,$S_ArtNameGo,$S_ArtNameEnd,1);//文章名

		$V_Remark=getContent($ArtContent,$S_RemarkGo,$S_RemarkEnd,1);

		

		if($S_SourceMode=='1'){

			$V_Source=getContent($ArtContent,$S_SourceGo,$S_SourceEnd,1);

			}

		else{

			$V_Source=$S_SourceName;

			}	

		

		if($S_ClassMode=='0'){//分类

			$V_ClassID=$S_ClassID;

			}

		else{

			$V_ClassName=getContent($ArtContent,$S_ClassGo,$S_ClassEnd,1);

			$sql="select S_ID from s_class where S_Name like '%$V_ClassName%' Order by S_ID desc";

			$row=$db->getRow($sql);

			if($row['S_ID']){

				$V_ClassID=$row['S_ID'];

				}

			else{

				$V_ClassID=0;

				}	

			}

		if($S_AuthorMode=='1'){

			$V_Author=getContent($ArtContent,$S_AuthorGo,$S_AuthorEnd,1);

			}

		else{

			$V_Author=$S_AuthorName;

			}	

		$V_Pic=getContent($ArtContent,$S_PicGo,$S_PicEnd,1);

		

		//分页内容采集

		if($S_PageMode=='1'){

			$S_PageUrlGo=ReplaceStr($S_PageUrlGo,"'","\"");

			$S_PageUrlEnd=ReplaceStr($S_PageUrlEnd,"'","\"");

			$V_NextPage=trim(getContent($ArtContent,$S_PageUrlGo,$S_PageUrlEnd,1));

			$V_Content=getContent($ArtContent,$S_ContentGo,$S_ContentEnd,1);

			while(IsNul($V_NextPage) && substr(strtolower($V_NextPage),0,7)=="http://"){

					$Next_Content=geturlcontent($V_NextPage,$S_Code);

					$Next_Content=formaturl($Next_Content,$V_NextPage);

					if(!IsNul($Next_Content)) break;

					$VT_Content=getContent($Next_Content,$S_ContentGo,$S_ContentEnd,1);

					$V_NextPage=trim(getContent($Next_Content,$S_PageUrlGo,$S_PageUrlEnd,1));

					$V_Content.=$VT_Content;

					if(!IsNul($V_NextPage) or substr(strtolower($V_NextPage),0,7)!="http://") break;

				}

			}

		elseif($S_PageMode=='2'){

			$S_PageUrlGo=ReplaceStr($S_PageUrlGo,"'","\"");

			$S_PageUrlEnd=ReplaceStr($S_PageUrlEnd,"'","\"");

			$V_NextPage=trim(getContent($ArtContent,$S_PageUrlGo,$S_PageUrlEnd,1));

			$V_Content=getContent($ArtContent,$S_ContentGo,$S_ContentEnd,1);

			while(IsNul($V_NextPage) && substr(strtolower($V_NextPage),0,7)=="http://"){

					$Next_Content=geturlcontent($V_NextPage,$S_Code);

					$Next_Content=formaturl($Next_Content,$V_NextPage);

					if(!IsNul($Next_Content)) break;

					$VT_Content=getContent($Next_Content,$S_ContentGo,$S_ContentEnd,1);

					$V_NextPage=trim(getContent($Next_Content,$S_PageUrlGo,$S_PageUrlEnd,1));

					$V_Content.=$VT_Content;

					if(!IsNul($V_NextPage) or substr(strtolower($V_NextPage),0,7)!="http://") break;

				}			

			}

		else{	

			$V_Content=getContent($ArtContent,$S_ContentGo,$S_ContentEnd,1);

			}

		$V_Content=collectRep($V_Content,$S_Replace);

		$V_Content=ReplaceStr($V_Content,"'","");

		$V_Pic=dealPic($V_Pic,$S_Url,$V_Content);

	   if($NowArtCount>=($LinkCount-1)){

		   if($S_Order=="desc"){

			   $Spage=$Spage-1;

			   }

			else{

				$Spage=$Spage+1;

				} 

		   $NowArtCount=0;

	   	}

		else{			

			$NowArtCount=$NowArtCount+1;

			}

		$V_AddTime=date('Y-m-d H:i:s');

		

		showcollectinfo($V_Name,$V_Remark,$V_Author,$V_Source,$V_Pic,$V_ClassID,$V_Content);



		$sql="Insert tempart (S_Name,S_Remark,S_ClassID,S_Pic,S_Author,S_Content,S_Source,S_AddTime,S_Url) values ('".$V_Name."','".$V_Remark."',".$V_ClassID.",'".$V_Pic."','".$V_Author."','".$V_Content."','".$V_Source."','".$V_AddTime."','".$S_Url."')";

		

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

			echo "<div style=\"height:45px;line-height:45px;\">&nbsp;&nbsp;<font color=green>文章保存成功</font>";

			}

		else{

			echo "<div style=\"height:45px;line-height:45px;\">&nbsp;&nbsp;<font color=red>文章保存失败</font>";

			}	

		if($S_Order=="desc" ){

			if($Spage<$S_PageGo){

				die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停3秒继续采集....恭喜全部采集完毕！！</div>");}

			else{

				die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停1秒继续采集....</div><script>setTimeout('ReadGo();',1000);function ReadGo(){window.location='?S_ID=".$S_ID."&spage=".$Spage."&nvc=".($NowArtCount)."'}</script>");

				}

			}

		else{

			if($Spage>$S_PageEnd){

				die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停3秒继续采集....恭喜全部采集完毕！！</div>");

				}

			else{				

				die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停1秒继续采集....</div><script>setTimeout('ReadGo();',1000);function ReadGo(){window.location='?S_ID=".$S_ID."&spage=".$Spage."&nvc=".($NowArtCount)."'}</script>");

				}			

			}	



		}

	elseif($S_Page=='3'){//批量分类页面

		$Url=$S_UrlStr;

		$UrlArr=explode('#',$Url);

		$UrlCount=count($UrlArr);

		

		$Spage=CollectGet("spage","auto");

		if(!IsNul($Spage)){

			$Spage=0;

			}

		else{

			if($Spage>($UrlCount-1)){

				$Spage=($UrlCount-1);

				}

			}	

		$Content=geturlcontent($UrlArr[$Spage],$S_Code);//读取列表文件

		if(!IsNul($Content)) die("在获取<font color=red>$UrlArr[$Spage]</font>时出错,原因获取不到内容!<br/>暂停三秒采集下一列表<script>setTimeout('ReadGo();',3000);function ReadGo(){window.location='?S_ID=".$S_ID."&spage=".($Spage+1)."'}</script>");

		$returnStr = getContent($Content,$S_ListGo,$S_ListEnd,1);//截取列表开始--结束

		$returnStr=formaturl($returnStr,$S_Url);

		

        $vLinkArr=getArr($S_LinkGo,$S_LinkEnd,$returnStr);//获取到文章连接地址 返回数组

		if(empty($vLinkArr)) die("获取文章连接地址时出错,请确认");

		$LinkCount=count($vLinkArr);//连接总数

		$NowArtCount=CollectGet("nvc","auto");

		

		if(!IsNul($NowArtCount)){

			$NowArtCount=0;

			}

		else{

			if($NowArtCount>$LinkCount){

				$LinkCount=$LinkCount-1;

				}

			}

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

        	<tr>

               <td height=\"30\" align=\"left\" class=\"td_title\">

           		&nbsp;&nbsp;正在采集第<font color=red>".($Spage+1)."</font>页列表,共<font color=red>".($UrlCount)."</font>页,当前页共<font color=red>".$LinkCount."</font>条数据,已经采集<font color=red>".($NowArtCount)."</font>条</td>

            </tr>

      </table> ";

	  	

		$ArtContent=geturlcontent($vLinkArr[$NowArtCount],$S_Code);//文章内容页面

		$ArtContent=formaturl($ArtContent,$S_Url);

		if(!IsNul($ArtContent)) die("在获取<font color=red>$vLinkArr[$NowArtCount]</font>文章内容页出错,获取不到数据，暂停3秒继续采集下一文章!<script>setTimeout('ReadGo();',3000);function ReadGo(){window.location='?S_ID=".$S_ID."&spage=".$Spage."&nvc=".($NowArtCount+1)."'}</script>");

		$V_Name=getContent($ArtContent,$S_ArtNameGo,$S_ArtNameEnd,1);//文章名

		$V_Remark=getContent($ArtContent,$S_RemarkGo,$S_RemarkEnd,1);

		if($S_ClassMode=='0'){//分类

			$V_ClassID=$S_ClassID;

			}

		else{

			$V_ClassName=getContent($ArtContent,$S_ClassGo,$S_ClassEnd,1);

			$sql="select S_ID from s_class where S_Name like '%$V_ClassName%' Order by S_ID desc";

			$row=$db->getRow($sql);

			if($row['S_ID']){

				$V_ClassID=$row['S_ID'];

				}

			else{

				$V_ClassID=0;

				}	

			}

	

		if($S_AuthorMode=='1'){

			$V_Author=getContent($ArtContent,$S_AuthorGo,$S_AuthorEnd,1);

			}

		else{

			$V_Author=$S_AuthorName;

			}

			

		if($S_SourceMode=='1'){

			$V_Source=getContent($ArtContent,$S_SourceGo,$S_SourceEnd,1);

			}

		else{

			$V_Source=$S_SourceName;

			}			

		$V_Pic=getContent($ArtContent,$S_PicGo,$S_PicEnd,1);

		

		//分页内容采集

		if($S_PageMode=='1'){

			$S_PageUrlGo=ReplaceStr($S_PageUrlGo,"'","\"");

			$S_PageUrlEnd=ReplaceStr($S_PageUrlEnd,"'","\"");

			$V_NextPage=trim(getContent($ArtContent,$S_PageUrlGo,$S_PageUrlEnd,1));

			$V_Content=getContent($ArtContent,$S_ContentGo,$S_ContentEnd,1);

			while(IsNul($V_NextPage) && substr(strtolower($V_NextPage),0,7)=="http://"){

					$Next_Content=geturlcontent($V_NextPage,$S_Code);

					$Next_Content=formaturl($Next_Content,$V_NextPage);

					if(!IsNul($Next_Content)) break;

					$VT_Content=getContent($Next_Content,$S_ContentGo,$S_ContentEnd,1);

					$V_NextPage=trim(getContent($Next_Content,$S_PageUrlGo,$S_PageUrlEnd,1));

					$V_Content.=$VT_Content;

					if(!IsNul($V_NextPage) or substr(strtolower($V_NextPage),0,7)!="http://") break;

				}

			}

		elseif($S_PageMode=='2'){

			$S_PageUrlGo=ReplaceStr($S_PageUrlGo,"'","\"");

			$S_PageUrlEnd=ReplaceStr($S_PageUrlEnd,"'","\"");

			$V_NextPage=trim(getContent($ArtContent,$S_PageUrlGo,$S_PageUrlEnd,1));

			$V_Content=getContent($ArtContent,$S_ContentGo,$S_ContentEnd,1);

			while(IsNul($V_NextPage) && substr(strtolower($V_NextPage),0,7)=="http://"){

					$Next_Content=geturlcontent($V_NextPage,$S_Code);

					$Next_Content=formaturl($Next_Content,$V_NextPage);

					if(!IsNul($Next_Content)) break;

					$VT_Content=getContent($Next_Content,$S_ContentGo,$S_ContentEnd,1);

					$V_NextPage=trim(getContent($Next_Content,$S_PageUrlGo,$S_PageUrlEnd,1));

					$V_Content.=$VT_Content;

					if(!IsNul($V_NextPage) or substr(strtolower($V_NextPage),0,7)!="http://") break;

				}			

			}

		else{	

			$V_Content=getContent($ArtContent,$S_ContentGo,$S_ContentEnd,1);

			}



		$V_Content=collectRep($V_Content,$S_Replace);

		$V_Content=ReplaceStr($V_Content,"'","");

		$V_Pic=dealPic($V_Pic,$S_Url,$V_Content);

		$V_AddTime=date('Y-m-d H:i:s');   

		showcollectinfo($V_Name,$V_Remark,$V_Author,$V_Source,$V_Pic,$V_ClassID,$V_Content);

		//die();

	$sql="Insert tempart (S_Name,S_Remark,S_ClassID,S_Pic,S_Author,S_Content,S_Source,S_AddTime,S_Url) values ('".$V_Name."','".$V_Remark."',".$V_ClassID.",'".$V_Pic."','".$V_Author."','".$V_Content."','".$V_Source."','".$V_AddTime."','".$S_Url."')";

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

			echo "<div style=\"height:45px;line-height:45px;\">&nbsp;&nbsp;<font color=green>文章保存成功</font>";

			}

		else{

			echo "<div style=\"height:45px;line-height:45px;\">&nbsp;&nbsp;<font color=red>文章保存失败</font>";

			}

		

	   if($NowArtCount>=($LinkCount-1)){

		   $Spage=$Spage+1;

		   $NowArtCount=0;

	   	}

		else{			

			$NowArtCount=$NowArtCount+1;

			}	

		if($Spage>($UrlCount-1)) die("恭喜全部采集完毕！！");	

		if($NowArtCount>=$LinkCount){

			die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停1秒继续采集....恭喜全部采集完毕！！</div>");

			}			

		else{

			die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停1秒继续采集....</div><script>setTimeout('ReadGo();',1000);function ReadGo(){window.location='?S_ID=".$S_ID."&spage=".$Spage."&nvc=".($NowArtCount)."'}</script>");

			

			}		

		

		}

	elseif($S_Page=='4'){//采集内容页

		$StartPage=$S_PageGo;

		$Spage=CollectGet("spage","auto");

		if($S_Order=="desc"){

			if(!IsNul($Spage)){

				$Spage=$S_PageEnd;}

			else{

				if($Spage>=$S_PageEnd) $Spage=$S_PageEnd;

				}	

			}

		else{	

			if(!IsNul($Spage)){

				$Spage=$S_PageGo;

			}else{

				if($Spage>$S_PageEnd) $Spage=$S_PageEnd;

				}

		}

		$Url=ReplaceStr($S_UrlStr,'{$ID}',$Spage);

		$ArtContent=geturlcontent($Url,$S_Code);//读取列表文件

		$ArtContent=formaturl($ArtContent,$Url);

		if(!IsNul($ArtContent)){

			if($S_Order=="desc"){

				die("在获取<font color=red>$Url</font>时出错,原因获取不到内容!<br/>暂停三秒采集下一列表<script>setTimeout('ReadGo();',3000);function ReadGo(){window.location='?S_ID=".$S_ID."&spage=".($Spage-1)."'}</script>");

				}

			else{

				die("在获取<font color=red>$Url</font>时出错,原因获取不到内容!<br/>暂停三秒采集下一列表<script>setTimeout('ReadGo();',3000);function ReadGo(){window.location='?S_ID=".$S_ID."&spage=".($Spage+1)."'}</script>");

				}	

			

		}

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

        	<tr>

               <td height=\"30\" align=\"left\" class=\"td_title\">

           		&nbsp;&nbsp;正在采集第<font color=red>".$Spage."</font>页文章内容,共<font color=red>".$S_PageEnd."</font>条数据,已经采集<font color=red>".($Spage)."</font>条</td>

            </tr>

      </table> ";			

		$V_Name=getContent($ArtContent,$S_ArtNameGo,$S_ArtNameEnd,1);//文章名

		$V_Remark=getContent($ArtContent,$S_RemarkGo,$S_RemarkEnd,1);

		if($S_ClassMode=='0'){//分类

			$V_ClassID=$S_ClassID;

			}

		else{

			$V_ClassName=getContent($ArtContent,$S_ClassGo,$S_ClassEnd,1);

			$sql="select S_ID from s_class where S_Name like '%$V_ClassName%' Order by S_ID desc";

			$row=$db->getRow($sql);

			if($row['S_ID']){

				$V_ClassID=$row['S_ID'];

				}

			else{

				$V_ClassID=0;

				}	

			}

		

		//分页内容采集

		if($S_PageMode=='1'){

			$S_PageUrlGo=ReplaceStr($S_PageUrlGo,"'","\"");

			$S_PageUrlEnd=ReplaceStr($S_PageUrlEnd,"'","\"");

			$V_NextPage=trim(getContent($ArtContent,$S_PageUrlGo,$S_PageUrlEnd,1));

			$V_Content=getContent($ArtContent,$S_ContentGo,$S_ContentEnd,1);

			while(IsNul($V_NextPage) && substr(strtolower($V_NextPage),0,7)=="http://"){

					$Next_Content=geturlcontent($V_NextPage,$S_Code);

					$Next_Content=formaturl($Next_Content,$V_NextPage);

					if(!IsNul($Next_Content)) break;

					$VT_Content=getContent($Next_Content,$S_ContentGo,$S_ContentEnd,1);

					$V_NextPage=trim(getContent($Next_Content,$S_PageUrlGo,$S_PageUrlEnd,1));

					$V_Content.=$VT_Content;

					if(!IsNul($V_NextPage) or substr(strtolower($V_NextPage),0,7)!="http://") break;

				}

			}

		elseif($S_PageMode=='2'){

			$S_PageUrlGo=ReplaceStr($S_PageUrlGo,"'","\"");

			$S_PageUrlEnd=ReplaceStr($S_PageUrlEnd,"'","\"");

			$V_NextPage=trim(getContent($ArtContent,$S_PageUrlGo,$S_PageUrlEnd,1));

			$V_Content=getContent($ArtContent,$S_ContentGo,$S_ContentEnd,1);

			while(IsNul($V_NextPage) && substr(strtolower($V_NextPage),0,7)=="http://"){

					$Next_Content=geturlcontent($V_NextPage,$S_Code);

					$Next_Content=formaturl($Next_Content,$V_NextPage);

					if(!IsNul($Next_Content)) break;

					$VT_Content=getContent($Next_Content,$S_ContentGo,$S_ContentEnd,1);

					$V_NextPage=trim(getContent($Next_Content,$S_PageUrlGo,$S_PageUrlEnd,1));

					$V_Content.=$VT_Content;

					if(!IsNul($V_NextPage) or substr(strtolower($V_NextPage),0,7)!="http://") break;

				}			

			}

		else{	

			$V_Content=getContent($ArtContent,$S_ContentGo,$S_ContentEnd,1);

			}	

		$V_Content=collectRep($V_Content,$S_Replace);

		$V_Content=ReplaceStr($V_Content,"'","");

		if($S_AuthorMode=='1'){

			$V_Author=getContent($ArtContent,$S_AuthorGo,$S_AuthorEnd,1);

			}

		else{

			$V_Author=$S_AuthorName;

			}

			

		if($S_SourceMode=='1'){

			$V_Source=getContent($ArtContent,$S_SourceGo,$S_SourceEnd,1);

			}

		else{

			$V_Source=$S_SourceName;

			}	

		

		$V_Pic=getContent($ArtContent,$S_PicGo,$S_PicEnd,1);

		$V_Pic=dealPic($V_Pic,$S_Url,$V_Content);

		$V_AddTime=date('Y-m-d H:i:s');

		if($S_Order=="desc"){

			 $Spage=$Spage-1;

			}

		else{	

		 	$Spage=$Spage+1;

			}

		showcollectinfo($V_Name,$V_Remark,$V_Author,$V_Source,$V_Pic,$V_ClassID,$V_Content);

	$sql="Insert tempart (S_Name,S_Remark,S_ClassID,S_Pic,S_Author,S_Content,S_Source,S_AddTime,S_Url) values ('".$V_Name."','".$V_Remark."',".$V_ClassID.",'".$V_Pic."','".$V_Author."','".$V_Content."','".$V_Source."','".$V_AddTime."','".$S_Url."')";

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

			echo "<div style=\"height:45px;line-height:45px;\">&nbsp;&nbsp;<font color=green>文章保存成功</font>";

			}

		else{

			echo "<div style=\"height:45px;line-height:45px;\">&nbsp;&nbsp;<font color=red>文章保存失败</font>";

			}

		if($S_Order=="desc" ){

			if($Spage<$S_PageGo){

				die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停3秒继续采集....恭喜全部采集完毕！！</div>");}

			else{

				die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停1秒继续采集....</div><script>setTimeout('ReadGo();',1000);function ReadGo(){window.location='?S_ID=".$S_ID."&spage=".$Spage."&nvc=".($NowArtCount)."'}</script>");

				}

			}

		else{

			if($Spage>=$S_PageEnd){

				die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停3秒继续采集....恭喜全部采集完毕！！</div>");

				}

			else{				

				die("&nbsp;&nbsp;<font color=red>$V_Name</font>采集完毕,暂停1秒继续采集....</div><script>setTimeout('ReadGo();',1000);function ReadGo(){window.location='?S_ID=".$S_ID."&spage=".$Spage."&nvc=".($NowArtCount)."'}</script>");

				}			

			}	

	

	

		}	







function showcollectinfo($V_Name,$V_Remark,$V_Author,$V_Source,$V_Pic,$V_ClassID,$V_Content){

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

    <tr>

       <td width=\"10%\" height=\"30\" align=\"right\" class=\"td_border\">文章名称：</td>

       <td width=\"90%\" height=\"30\" align=\"left\" class=\"td_border\" style=\"padding-left:10px;\">$V_Name</td>

    </tr>

    <tr>

       <td width=\"10%\" height=\"30\" align=\"right\" class=\"td_border\">文章状态：</td>

       <td width=\"90%\" height=\"30\" align=\"left\" class=\"td_border\" style=\"padding-left:10px;\">$V_Remark

	   </td>

    </tr>

    <tr>

       <td width=\"10%\" height=\"30\" align=\"right\" class=\"td_border\">文章作者：</td>

       <td width=\"90%\" height=\"30\" align=\"left\" class=\"td_border\" style=\"padding-left:10px;\">$V_Author</td>

    </tr>

    <tr>

       <td width=\"10%\" height=\"30\" align=\"right\" class=\"td_border\">文章来源：</td>

       <td width=\"90%\" height=\"30\" align=\"left\" class=\"td_border\" style=\"padding-left:10px;\">$V_Source</td>

    </tr>

    <tr>

       <td width=\"10%\" height=\"30\" align=\"right\" class=\"td_border\">文章图片：</td>

       <td width=\"90%\" height=\"30\" align=\"left\" class=\"td_border\" style=\"padding-left:10px;\">$V_Pic

	   </td>

    </tr>

    <tr>

       <td width=\"10%\" height=\"30\" align=\"right\" class=\"td_border\">文章分类：</td>

       <td width=\"90%\" height=\"30\" align=\"left\" class=\"td_border\" style=\"padding-left:10px;\">$V_ClassID</td>

    </tr>

     <tr>

       <td width=\"10%\" height=\"30\" align=\"right\" class=\"td_border\">文章内容：</td>

       <td width=\"90%\" height=\"30\" align=\"left\" class=\"td_border\" style=\"padding-left:10px;\"><div style=\"height:300px;overflow-y:scroll; \">$V_Content</div></td>

    </tr>



</table>";

	}





?>        

        </div>

    </div>

</div>        

</body>

</html>