<?php 
error_reporting(0);
ini_set('html_errors',false);
ini_set('display_errors',false);
@ini_set('memory_limit', '-1');
@set_time_limit(0);
require_once "../includes/common.inc.php";
require_once MODEPATH.'./'.$adminpath.'/global.func.php';
require_once MODEPATH.'./includes/cache.func.php';
require_once MODEPATH.'./includes/image.func.php';
require_once MODEPATH.'./'.$adminpath.'/httpget.class.php';

function replacefc( $text )
{
    $text = str_replace( "\n", "", $text );
    $text = str_replace( "\r", "", $text );
    return $text;
}
function repinfozz( $text )
{
    $text = str_replace( "*", "(.*?)", $text );
    $text = str_replace( "/", "\\/", $text );
    $text = "/".$text."/is";
    return $text;
}
function reppagead( $repad, $text )
{
    if ( empty( $repad ) )
    {
        return $text;
    }
    $repad = stripslashes( $repad );
    $repad = replacefc( $repad );
    $r = explode( ",", $repad );
    $i = 0;
    for ( ; $i < count( $r ); ++$i )
    {
        $zztext = repinfozz( $r[$i]);
        $strtext = "";
        $text = stripslashes( preg_replace( $zztext, $strtext, $text ) );
    }
    return $text;
}

function repinfoword( $title, $oldword, $newword )
{
    if ( empty( $oldword ) )
    {
        return $title;
    }
    $oldword = stripslashes( $oldword );
    $newword = stripslashes( $newword );
    $oldword = replacefc( $oldword );
    $newword = replacefc( $newword );
    $repmore = 0;
    if ( strstr( $newword, "," ) )
    {
        $repmore = 1;
        $nr = explode( ",", $newword );
    }
    $r = explode( ",", $oldword );
    $i = 0;
    for ( ; $i < count( $r ); ++$i )
    {
        if ( $repmore )
        {
            $title = str_replace( $r[$i], $nr[$i], $title );
        }
        else
        {
            $title = str_replace( $r[$i], $newword, $title );
        }
    }
    return $title;
}

function get_encoding($data,$to)
{
$encode_arr = array('UTF-8','ASCII','GBK','GB2312','BIG5','JIS','eucjp-win','sjis-win','EUC-JP');
$encoded = mb_detect_encoding($data, $encode_arr);
$data = mb_convert_encoding($data,$to,$encoded);
return $data;
}

function repcjpagetextstr( $text, $h1, $h2, $h3 )
{
global $charset;
    $text = str_replace( "\\", "/", $text );
    $text = get_encoding( $text, $charset );
    $text = repinfoword( $text, $h1, $h2 );
    $text = reppagead( $h3, $text );
    return $text;
}


if(!$mm_mid){	
	clearcookies();
	header("Location:loggin.php?action=loggin");
	mexit();
}
if(!$adminid){	
	cpmsg('admin_login_failure','loggin.php?action=loggin');
	mexit();
}
function mainusertou($message,$url){
	$a="&nbsp;<a href=cj.php>采集首页</a> &raquo; <a href=#".$url."><samp>".$message."</samp></a>";
	return $a;
	}
	function Getstr($str){
	$str=str_replace("<","",$str);
	$str=str_replace(">","",$str);
	$str=str_replace("=","",$str);
	$str=str_replace("'","",$str);
	$str=trim($str);
	return $str;
	}
		function show($message,$url){
	$a="<div id=show><strong><samp>".$message."</samp></strong><hr /><a href=".$url.">请点击此处返回!</a></div>";
	return $a;
	}
	
	//采集替换定义字符
	function caiji_str($str){
	$str = str_replace("\r","",$str); //清除回车符
  $str = str_replace("\n","",$str); //清除换行符
  $str = str_replace("'","\"",$str); //清除换行符
  $str=preg_replace('/<img(.+?)src/','<img src',$str);
  $str=trim($str);
	return $str;
	}
	
function get_url_content($url) {
if(function_exists('file_get_contents')) {
$file_contents = file_get_contents($url);
} else {
$ch = curl_init();
$timeout = 5; 
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
}
return $file_contents;
}
	
$sorts=$fsorts=$uploads=array();
$query = $db -> query("SELECT * FROM {$tablepre}picsort ORDER BY ordermode ");
while($sort = $db -> fetch_array($query)){
	$sorts[$sort['id']]=$sort;
	$fsorts[$sort['upid']][$sort['id']]=$sort;
}

if (0==0){
$rel=Getstr($_GET["rel"]);
?>
<?php if($rel=='caiji_ok'){
$query = $db -> query("select * from {$tablepre}caiji where id='$cid'");
 while($row = $db->fetch_array($query)){
		  $strpage=get_url_content($url);//采集此地址的信息,保存在变量$strpage中.
		  $strpage=repcjpagetextstr($strpage,$row["z11"],$row["z12"],$row["z21"]);
		  /////////////////////////////////////////////////////////替换字符
		  $page1=split($row["title"],$strpage);
		  $page2=split($row["title2"],$page1[1]);
		  $newpname=$page2[0];
		  ////////////////////////////////////////////////////////分割出标题.
		  $page3=split($row["key1"],$strpage);
		  $page4=split($row["key2"],$page3[1]);
		  $pagekey=$page4[0];
		  ///////////////////////////////////////////////////////分割出关键字.
		  $page5=split($row["dis"],$strpage);
		  $page6=split($row["dis2"],$page5[1]);
		  $message=$page6[0];
		  //////////////////////////////////////////////////////分割出描述.
		  $page7=split($row["message"],$strpage);
		  $page8=split($row["message2"],$page7[1]);
		  $html=caiji_str($page8[0]);
		  //////////////////////////////////////////////////////分割出图片内容.

    $db -> query("update {$tablepre}geturl set cok='1' where url='$url'");
    $select = sortselect($fsorts,$ssid);
		include theme('pic_get', 'themes/admin', 'admin');
}
}
?>
<?php if($rel=='caiji_out'){
$query = $db -> query("select * from {$tablepre}caiji where id='$id'");
 while($row = $db->fetch_array($query)){
$outstr = "Pic Cms{|}".$row['name']."{|}".$row['url']."{|}".$row['urlq']."{|}".$row['urlq2']."{|}".$row['title']."{|}".$row['title2']."{|}".$row['key1']."{|}".$row['key2']."{|}".$row['dis']."{|}".$row['dis2']."{|}".$row['z11']."{|}".$row['z12']."{|}".$row['z21']."{|}".$row['z22']."{|}".$row['z31']."{|}".$row['z32']."{|}".$row['class']."{|}".$row['message']."{|}".$row['message2'];
    $type = "txt";
    $fp = fopen( "css/".$id.".".$type, "w" );
//base64_encode("加密");    
//base64_decode("解密");    //base64解密地址
    $outstr = trim( $outstr );
    $outstr = base64_encode($outstr);;
    fwrite( $fp, $outstr, strlen( $outstr ) );
    fclose( $fp );
    $fp = fopen( "css/".$id.".".$type, "r" );
    header( "Content-type:".$type );
    header( "Accept-Ranges: bytes" );
    header( "Accept-Length: ".filesize( "css/".$id.".".$type ) );
    header( "Content-Disposition: attachment; filename=".$id.".".$type );
    echo fread( $fp, filesize( "css/".$id.".".$type ) );
    fclose( $fp );
    unlink( "css/".$id.".".$type );
    exit( );
}
}
?>
<?php if($rel=='caiji_dao_ok'){
$daostr = base64_decode( $dao );
            $strArray = explode( "{|}", $daostr );
            $isMagic = @ini_get( "magic_quotes_gpc" );
            if ( $isMagic )
            {
                if ( is_array( $strArray ) )
                {
                    foreach ( $strArray as $key => $value )
                    {
                        $strArray[$key] = str_replace( "'", "\\'", $value );
                    }
                }
            }
            else if ( is_array( $strArray ) )
            {
                foreach ( $strArray as $key => $value )
                {
                    $strArray[$key] = addslashes( $value );
                }
            }
$name=$strArray[1];
$url=$strArray[2];
$urlq=$strArray[3];
$urlq2=$strArray[4];
$title=$strArray[5];
$title2=$strArray[6];
$key1=$strArray[7];
$key2=$strArray[8];
$dis=$strArray[9];
$dis2=$strArray[10];
$z11=$strArray[11];
$z12=$strArray[12];
$z21=$strArray[13];
$z22=$strArray[14];
$z31=$strArray[15];
$z32=$strArray[16];
$class=$strArray[17];
$message=$strArray[18];
$message2=$strArray[19];

if($name == '' || $url=='' || $urlq=='' || $urlq2=='' || $title=='' || $title2=='' || $message=='' || $message2==''){
cpmsg('规则导入失败，请确认导入规则正确！','cj.php');
}	

$time=date("y-m-d");
$db -> query("insert into {$tablepre}caiji (name,url,urlq,urlq2,title,title2,key1,key2,dis,dis2,z11,z12,z21,z22,z31,z32,class,message,message2,time) values ('$name','$url','$urlq','$urlq2','$title','$title2','$key1','$key2','$dis','$dis2','$z11','$z12','$z21','$z22','$z31','$z32','$class','$message','$message2','$time')");
cpmsg('规则导入成功','cj.php');

}
?>
<!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=<?=$charset?>" />
<title>图片采集测试版 v 1.10</title>
<style type="text/css">
<!--
body,td {font-family: Geneva, Arial, Helvetica, sans-serif, Tahoma;font-size: 12px;color:#1876b7;}
.login {font-family: Geneva, Arial, Helvetica, sans-serif, Tahoma;font-size: 12px;height: 16px;border-top-width: 1px;border-right-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-top-color: #FFFFFF;border-right-color: #EEEEEE;border-bottom-color: #EEEEEE;border-left-color: #FFFFFF;background-color: #f2f2f2;}
input,textarea {font-family: Geneva, Arial, Helvetica, sans-serif, Tahoma;font-size: 12px;border-top-width: 1px;border-right-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-top-color: #FFFFFF;border-right-color: #EEEEEE;border-bottom-color: #EEEEEE;border-left-color: #FFFFFF;background-color: #f2f2f2;}
a {color: #1876b7;text-decoration: none;}
a:hover {color: #000000;text-decoration: underline;}
.smalltxt{ font: 11px Arial, Tahoma; }
Input,select,textarea{ font: 11px Tahoma, Verdana; color: #000000; font-weight: normal; background-color: #F8F8F8; }
form{ margin: 0; padding: 0;}
select{ font: 11px Arial, Tahoma; color: #000000; font-weight: normal; background-color: #F8F8F8; }
.nav{ font: 12px Tahoma, Verdana; color: #000000; font-weight: bold; }
.nav a{ color: #000000;}
.header{ font: 12px Tahoma, Verdana; color: #1876B7; font-weight: bold;background-color: #DAEEFA;background-image:url(images/header.gif);}
.header a{ color: #1876b7; }
.category{ font: 11px Arial, Tahoma; color: #000000; background-color: #EEF6F9; }
.tableborder{ background: #DCEEF6; border: 1px solid #98D5EC }
 .smalltxt{ font: 11px Arial, Tahoma; }
.bold{ font-weight: bold; }
.altbg1{ background: #F8F8F8; }
.altbg2{ background: #FFFFFF; }
.maintable{ width: 98%; background-color: #FFFFFF; }
.menu {color:#FFFFFF;}
.menu a{color:#FFFFFF;font-weight:bold;}
.menu a:hover{color:#CCFFFF;}
-->
</style><link rel="stylesheet" type="text/css" href="css/subModal.css" />
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<script language="JavaScript">
<!--
function check(msg, url){
if(confirm(msg)){
return true;
}else{return false;
}
}
function AddRepAd(obj,val){
	var dh='';
	if(obj==1)
	{
		if(document.form2.z21.value!='')
		{
			dh=',';
		}
		document.form2.z21.value+=dh+val;
	}
	else
	{
		if(document.form2.repad.value!='')
		{
			dh=',';
		}
		document.form2.repad.value+=dh+val;
	}
}
//-->
</script>
<table cellspacing="0" cellpadding="3" border="0" width="100%" align="center" style="table-layout: fixed"> 
<tr class="header" ><td width="90%" align="left" nowrap>
<?php if($rel==''){
echo mainusertou("采集信息","");
 ?>
</td>    
</tr></table>
<br>
<table cellspacing="1" cellpadding="3" width="98%" align="center" class="tableborder">
<tr class="header"><td>
采集信息列表
</td></tr>
<tr><td align="left">
<table border="0" width="100%" cellspacing="1" cellpadding="3">
 <?php 
$query = $db -> query("select * from {$tablepre}caiji order by id desc");
 while($row = $db->fetch_array($query)){
 ?>
<tr>
<td class="altbg1">[<a href="cj.php?rel=caiji_geturl&id=<?php echo $row["id"];?>">开始采集列表</a>]  [<a href="cj.php?rel=caiji_list&cid=<?php echo $row["id"];?>">待采集地址</a>] 规则名称:<samp><?php echo $row["name"];?></samp> 目标地址:<?php echo $row["url"];?> [<a href="cj.php?rel=caiji_info&id=<?php echo $row["id"];?>">修改</a>] [<a href="cj.php?rel=caiji_del&id=<?php echo $row["id"];?>">删除</a>] [<a href="cj.php?rel=caiji_get_del&cid=<?php echo $row["id"];?>">清空本规则待采集地址</a>] [<a href="cj.php?rel=caiji_out&id=<?php echo $row["id"];?>">导出规则</a>]</td></tr>
 
 <?php }?>
<tr>
<td class="altbg1"><a href=cj.php?rel=caiji_add target=_self><samp>新建采集规则</samp></a>  <a href=cj.php?rel=caiji_dao target=_self><samp>采集规则导入</samp></a></td></tr>
  <?php
}
?>
 </table>
</td></tr></table>
<?php if($rel=='caiji_list'){
echo mainusertou("采集列表","");
 ?>
</td>    
</tr></table>
<br>
<table cellspacing="1" cellpadding="3" width="98%" align="center" class="tableborder">
<tr class="header"><td>
采集信息列表
</td></tr>
<tr><td align="left">
<table border="0" width="100%" cellspacing="1" cellpadding="3">
 <?php 
$query = $db -> query("select * from {$tablepre}geturl WHERE cok='0' and cid='$cid' order by id desc");
 while($row = $db->fetch_array($query)){
 ?>
<tr>
<td class="altbg1"><?php echo $row["id"];?>. 目标地址:<?php echo $row["url"];?> [<a href=cj.php?rel=caiji_ok&url=<?php echo urlencode($row["url"]);?>&cid=<?php echo $row["cid"];?>&ssid=<?php echo $row["sid"];?>>开始采集</a>] [<a href="cj.php?rel=caiji_get_del&id=<?php echo $row["id"];?>&cid=<?php echo $cid;?>">删除</a>]</td></tr>
 <?php }?>
  <?php
}
?>
<?php if($rel=='caiji_get_del'){
if($id==''){
$db -> query("delete from {$tablepre}geturl where cok='0' and cid='$cid'");
cpmsg('删除成功','cj.php');
}
else
{
$db -> query("delete from {$tablepre}geturl where id='$id'");
cpmsg('删除成功','cj.php?rel=caiji_list&cid='.$cid.'');
}
}
?>
<?php if($rel=='caiji_del'){
$db -> query("delete from {$tablepre}caiji where id='$id'");
cpmsg('删除成功','cj.php');
}
?>
<?php if($rel=='caiji_info'){
echo mainusertou("采集规则修改","caiji_info");
$id=Getstr($_GET["id"]);
$query = $db -> query("select * from {$tablepre}caiji where id='$id'");
 while($row = $db->fetch_array($query)){
 $select = sortselect($fsorts,$row["class"]);
 ?>
</td>    
</tr></table>
<br>
<table cellspacing="1" cellpadding="3" width="98%" align="center" class="tableborder">
<tr class="header"><td>
采集规则修改
</td></tr>
<tr><td align="left">
<table border="0" width="100%" cellspacing="1" cellpadding="3">
<form id="form2" name="form2" method="post" action="cj.php?rel=caiji_info_info">
<tr><td class="altbg1">采集网站地址:<input type="text" name="url" class="input1" value="<?php echo $row["url"];?>" size="60" />规则名称:<input type="text" name="name" class="input1" value="<?php echo $row["name"];?>" /></td></tr>
<tr><td class="altbg1">采集区间开始:<textarea name="urlq" rows="3" cols="50"><?php echo $row["urlq"];?></textarea>结束:<textarea name="urlq2" rows="3" cols="50"><?php echo $row["urlq2"];?></textarea></td></tr>
<tr><td class="altbg1">采集标题开始:<input type="text" name="title" class="input1" value="<?php echo $row["title"];?>" />结束:<input type="text" name="title2" class="input1" value="<?php echo $row["title2"];?>" /></td></tr>
<tr><td class="altbg1">采关键字开始:<textarea name="key1" rows="3" cols="50"><?php echo $row["key1"];?></textarea>结束:<textarea name="key2" rows="3" cols="50"><?php echo $row["key2"];?></textarea></td></tr>
<tr><td class="altbg1">图片描述开始:<textarea name="dis" rows="3" cols="50"><?php echo $row["dis"];?></textarea>结束:<textarea name="dis2" rows="3" cols="50"><?php echo $row["dis2"];?></textarea></td></tr>
<tr><td class="altbg1">图片内容开始:<textarea name="message" rows="3" cols="50"><?php echo $row["message"];?></textarea>结束:<textarea name="message2" rows="3" cols="50"><?php echo $row["message2"];?></textarea></td></tr>
<tr><td class="altbg1">被替换的字符:<textarea name="z11" rows="3" cols="50"><?php echo $row["z11"];?></textarea>换成:<textarea name="z12" rows="3" cols="50"><?php echo $row["z12"];?></textarea>(原字符多个请用","格开,如果是新字符是多个，可以用","格开，系统会对应替换)</td></tr>
<tr><td class="altbg1">页面过滤正则:<textarea name="z21" rows="3" cols="50"><?php echo $row["z21"];?></textarea><a href="#" onclick="AddRepAd(1,'<iframe*</iframe>,<IFRAME*</IFRAME>');">IFRAME</a> (*代表通用字符,多个请用","格开)</td></tr>
<tr><td class="altbg1">导入图片分类:
<select name="class" class="input1">
<option value="0">----清选择----</option>
<?=$select?>
</select> 选择分类.</td></tr>
<tr><td class="category">
  <input name="id" type="hidden" value="<?php echo $id;?>" />
 <input type="submit" name="Submit" value="确认添加" class="button1" /></td></tr>
</form>
 <?php
}}
?>
<?php if($rel=='caiji_info_info'){
$id=$_POST["id"];
$name=$_POST["name"];
$url=$_POST["url"];
$urlq=$_POST["urlq"];
$urlq2=$_POST["urlq2"];
$title=$_POST["title"];
$title2=$_POST["title2"];
$key1=$_POST["key1"];
$key2=$_POST["key2"];
$dis=$_POST["dis"];
$dis2=$_POST["dis2"];
$z11=$_POST["z11"];
$z12=$_POST["z12"];
$z21=$_POST["z21"];
$z22=$_POST["z22"];
$z31=$_POST["z31"];
$z32=$_POST["z32"];
$class=$_POST["class"];
$message=$_POST["message"];
$message2=$_POST["message2"];

$time=date("y-m-d");
$db -> query("update {$tablepre}caiji  set name='$name',url='$url',urlq='$urlq',urlq2='$urlq2',title='$title',title2='$title2',key1='$key1',key2='$key2',dis='$dis',dis2='$dis2',z11='$z11',z12='$z12',z21='$z21',z22='$z22',z31='$z31',z32='$z32',class='$class',message='$message',message2='$message2',time='$time' where id='$id'");

cpmsg('修改采集规则成功','cj.php');

}
?>
<?php if($rel=='caiji_add'){
echo mainusertou("采集规则添加","caiji_add");
$select = sortselect($fsorts,0);
 ?>
</td>    
</tr></table>
<br>
<table cellspacing="1" cellpadding="3" width="98%" align="center" class="tableborder">
<tr class="header"><td>
采集规则添加
</td></tr>
<tr><td align="left">
<table border="0" width="100%" cellspacing="1" cellpadding="3">
<form id="form1" name="form1" method="post" action="cj.php?rel=caiji_add_info">
<tr><td class="altbg1">采集网站地址:<input type="text" name="url" class="input1" size="60" />规则名称:<input type="text" name="name" class="input1" /></td></tr>
<tr><td class="altbg1">采集区间开始:<textarea name="urlq" rows="3" cols="50"></textarea>结束:<textarea name="urlq2" rows="3" cols="50"></textarea></td></tr>
<tr><td class="altbg1">采集标题开始:<input type="text" name="title" class="input1" value="<title>" />结束:<input type="text" name="title2" class="input1" value="</title>" /></td></tr>
<tr><td class="altbg1">采关键字开始:<textarea name="key1" rows="3" cols="50"></textarea>结束:<textarea name="key2" rows="3" cols="50"></textarea></td></tr>
<tr><td class="altbg1">图片描述开始:<textarea name="dis" rows="3" cols="50"></textarea>结束:<textarea name="dis2" rows="3" cols="50"></textarea></td></tr>
<tr><td class="altbg1">图片内容开始:<textarea name="message" rows="3" cols="50"></textarea>结束:<textarea name="message2" rows="3" cols="50"></textarea></td></tr>
<tr><td class="altbg1">被替换的字符:<textarea name="z11" rows="3" cols="50"></textarea>换成:<textarea name="z12" rows="3" cols="50"></textarea>(原字符多个请用","格开,如果是新字符是多个，可以用","格开，系统会对应替换)</td></tr>
<tr><td class="altbg1">页面过滤正则:<textarea name="z21" rows="3" cols="50"></textarea><a href="#" onclick="AddRepAd(1,'<iframe*</iframe>,<IFRAME*</IFRAME>');">IFRAME</a> (*代表通用字符,多个请用","格开)</td></tr>
<tr><td class="altbg1">导入图片分类:
<select name="class" class="input1">
<option value="0">----清选择----</option>
<?=$select?>
</select>
</td></tr>
<tr><td class="category">
 <input type="submit" name="Submit" value="确认添加" class="button1" /></td></tr>
</form>
 <?php
}
?>
<?php if($rel=='caiji_add_info'){
$name=$_POST["name"];
$url=$_POST["url"];
$urlq=$_POST["urlq"];
$urlq2=$_POST["urlq2"];
$title=$_POST["title"];
$title2=$_POST["title2"];
$key1=$_POST["key1"];
$key2=$_POST["key2"];
$dis=$_POST["dis"];
$dis2=$_POST["dis2"];
$z11=$_POST["z11"];
$z12=$_POST["z12"];
$z21=$_POST["z21"];
$z22=$_POST["z22"];
$z31=$_POST["z31"];
$z32=$_POST["z32"];
$class=$_POST["class"];
$message=$_POST["message"];
$message2=$_POST["message2"];

$time=date("y-m-d");
$db -> query("insert into {$tablepre}caiji (name,url,urlq,urlq2,title,title2,key1,key2,dis,dis2,z11,z12,z21,z22,z31,z32,class,message,message2,time) values ('$name','$url','$urlq','$urlq2','$title','$title2','$key1','$key2','$dis','$dis2','$z11','$z12','$z21','$z22','$z31','$z32','$class','$message','$message2','$time')");
cpmsg('添加采集规则成功','cj.php');

}
?>
<?php if($rel=='caiji_geturl'){
$query = $db -> query("select * from {$tablepre}caiji where id='$id'");
 while($row = $db->fetch_array($query)){
$sid=$row["class"];
$str=get_url_content($row["url"]);//按照地址进行采集
if ($str==false) {
		cpmsg('错误!采集连接地址不可用','cj.php');
}
$str=repcjpagetextstr($str,$row["z11"],$row["z12"],$row["z21"]);


$urlq=split($row["urlq"],$str);//区间开始切割
if (count($urlq)==2){
$strurl1=split($row["urlq2"],$urlq[1]);//区间结束切割,则$strurl[0]为所要采集信息地址快.
$strurl2=str_replace("\"","",$strurl1[0]);//去除信息快中"号,保存在变量$strurl2中.
$strurl21=str_replace("'","",$strurl2);//去除信息快中'号,保存在变量$strurl2中.
$strurl22=str_replace(" target",">",$strurl21);//去除信息快中'号,保存在变量$strurl2中.
   $strurl3=split("href=",$strurl22);
   if (count($strurl3)<>1)
   {
   $a=count($strurl3)-1;//数组个数减1,则为须去掉数组第一个.
   $ab=1;
      while($ab<=$a)
	  {
	  $strurl=split(">",$strurl3[$ab]);//获取正确的采集地址,保存在$strurl[0]里
	      $strurl4=split("ttp://",$strurl[0]);//切开获取的采集地址进行判断.
	      if (count($strurl4)==1){//判断字符不包含ttp://字符串则为不符合条件的地址,舍弃.
		  $htmls .= $ab.":地址:".$strurl[0]."<samp>不符合条件舍弃.</samp><br />";
		  }
		  else
		  {
		  $time=date("y-m-d");
		$query = $db -> query("SELECT id FROM {$tablepre}geturl WHERE url='$strurl[0]'");
		if($db -> num_rows($query)){
		} else
		  {
		$db -> query("INSERT INTO {$tablepre}geturl (url, cid, sid, time) VALUES ('$strurl[0]', '$id', '$sid', '$time') ");
		$htmls .= $ab.":获取未采集的列表<b>".$strurl[0]."</b>!<br />";
		  }
		  }
	  $ab=$ab+1;
	  } 
	 cpmsg('采集获取地址完成.<br>'.$htmls.'');
   }
   else
   {
   cpmsg('错误!无符合采集地址.','cj.php');
   }
   
}
else
{
cpmsg('错误!请添加正确的区间代码','cj.php');
}

}

}
?>
<?php if($rel=='caiji_dao'){
echo mainusertou("采集规则导入","caiji_dao");
 ?>
</td>    
</tr></table>
<br>
<table cellspacing="1" cellpadding="3" width="98%" align="center" class="tableborder">
<tr class="header"><td>
采集规则导入
</td></tr>
<tr><td align="left">
<table border="0" width="100%" cellspacing="1" cellpadding="3">
<form id="form1" name="form1" method="post" action="cj.php?rel=caiji_dao_ok">
<tr><td class="altbg1">导入规则内容:<textarea name="dao" rows="8" cols="90"></textarea></td></tr>
<tr><td class="category">
 <input type="submit" name="Submit" value="导入规则" class="button1" /></td></tr>
</form>
 <?php
}
?>
 </table>
</td></tr></table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ebf3f6">
  <tr>
    <td height="22" align="center"><?output()?><span class="smalltxt"> (<?opinfo()?>)</span></td>
  </tr>
</table>
</body>
</html>
</body>
</html>
<?php 
mexit();
}
?>