减小字体
增大字体
<? ////////////////////////////////////////////////////////////// // // 统一搜集系统 Univeral Gather System (UGS) // 作者 zj@52linux.com // 主页 http://www.52linux.com // 联系QQ 733905 ////////////////////////////////////////////////////////////// class ugs { var $value_ ; //'窃取到的内容 var $src_ ; //'要偷的目标URL地址 var $isGet_ ; //判断是否已经偷过
function BytesToBstr($f) //'变成1行 { return join("",$f);
} function _striptext() //取得文字内容 {
// I didn't use preg eval (//e) since that is only available in PHP 4.0. // so, list your entities one by one here. I included some of the // more common ones.
$search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript "'<[\/\!]*?[^<>]*?>'si", // strip out html tags "'([\r\n])[\s]+'", // strip out white space "'&(quot#34#034#x22);'i", // replace html entities "'&(amp#38#038#x26);'i", // added hexadecimal values "'&(lt#60#060#x3c);'i", "'&(gt#62#062#x3e);'i", "'&(nbsp#160#xa0);'i", "'&(iexcl#161);'i", "'&(cent#162);'i", "'&(pound#163);'i", "'&(copy#169);'i", "'&(reg#174);'i", "'&(deg#176);'i", "'&(#39#039#x27);'", "'&(euro#8364);'i", // europe "'&a(umlUML);'", // german "'&o(umlUML);'", "'&u(umlUML);'", "'&A(umlUML);'", "'&O(umlUML);'", "'&U(umlUML);'", "'ß'i", ); $replace = array( "", "", "\\1", "\"", "&", "<", ">", " ", chr(161), chr(162), chr(163), chr(169), chr(174), chr(176), chr(39), chr(128), "?", "?", "?", "?", "?", "?", "?", );
$text = preg_replace($search,$replace,$this->value_);
return $this->value_=$text; } function _striplinks() //取得链接Array { preg_match_all("'<\s*a\s.*?href\s*=\s* # find <a href= ([\"\'])? # find single or double quote (?(1) (.*?)\\1 ([^\s\>]+)) # if quote found, match up to next matching # quote, otherwise match up to next space 'isx",$this->value_,$links);
// catenate the non-empty matches from the conditional subpattern
while(list($key,$val) = each($links[2])) { if(!empty($val)) $match[] = $val; }
while(list($key,$val) = each($links[3])) { if(!empty($val)) $match[] = $val; }
// return the links return $this->value_=$match; }
function steal($toline=true) //'窃取目标URL地址的HTML代码的方法 {
if($this->src_!="") { $unix=false; //如果您是unix系统 请设置true 条件是系统里有wget 这个软件,如果是window系统,设置为false,或者当有wget.exe 这个软件时也可以设置为true // wget.exe 可从下面地址得到 http://allserv.ugent.be/~bpuype/wget/ if($unix){ $tmpfile=tempnam("/tmp","FOO");
$cmd="wget -nv -O $tmpfile \"$this->src_\""; //echo $cmd; exec($cmd);
$http=file($tmpfile);
unlink($tmpfile);
} else { $http=file($this->src_);
}
//print_r($http); if($toline) { $this->isGet_=true; return $this->value_=$this->BytesToBstr($http);
} else { $this->isGet_=true;
return $this->value_=$http;
} } else {
echo ("<script>alert(\"请先设置src属性!\")</script>"); }
} function steal_local($toline=true) // 此方法为处理本地文件使用 { if($this->src_!="") { if($toline) { $http=file($this->src_); $this->isGet_=true; return $this->value_=$this->BytesToBstr($http);
} else { $http=file($this->src_); $this->isGet_=true; return $this->value_=$http;
}
} else {
echo ("<script>alert(\"请先设置src属性!\")</script>"); }
}
//'删除偷到的内容中里面的换行、回车符以便进一步加工/方法 function noReturn() {
if(!$this->isGet_) $this->steal(); $this->value_=str_replace("\n","",$this->value_); $this->value_=str_replace("\r","",$this->value_); }
//'对偷到的内容中的个别字符串用新值更换/方法 function change($oldStr,$str) //'参数分别是旧字符串,新字符串 { if(!$this->isGet_) $this->steal(); $this->value_=str_replace($oldStr,$str,$this->value_ ); }
//'按指定首尾字符串对偷取的内容进行裁减(不包括首尾字符串)/方法 function cut($head,$bot) //'参数分别是首字符串,尾字符串 { if(!$this->isGet_) $this->steal();
$message=explode($head,$this->value_);
if(count($message)>1) { $message=explode($bot,$message[1]); return $this->value_= $message[0]; } else { return $this->value_=""; }
}
function cutpro($start,$end,$no='1',$comprise='') // $no must in {1,2,3,4,5.....} zero is not support //此方法较cut方法有进步,是可以调节$no 确定切到指定第no个符合条件的文字串 { $string=explode($start,$this->value_); //print_r($string); $string=explode($end,$string[$no]); //print_r($string); switch ($comprise){ case 'start': $string=$start.$string[0]; break; case 'end': $string=$string[0].$end; break; case 'all': $string=$start.$string[0].$end; break; default: $string=$string[0]; } return $this->value_=$string; }
function cut2($head,$bot) //cut 的另一种实现方法 { return substr($this->value_,strpos($this->value_,$head)+strlen($head),strpos($this->value_,$bot)-strpos($this->value_,$head)-strlen($head)); }
//'按指定首尾字符串对偷取的内容进行裁减(包括首尾字符串)/方法 function cutX($head,$bot) //'参数分别是首字符串,尾字符串 { $tmp=$this->cut($head,$bot);
return $this->value_=$head.$tmp.$bot;
}
//'按指定首尾字符串位置偏移指针对偷取的内容进行裁减/方法 function cutBy($head,$headCusor,$bot,$botCusor) //'参数分别是首字符串,首偏移值,尾字符串,尾偏移值,左偏移用负值,偏移指针单位为字符数 { if(!$this->isGet_) $this->steal(); return substr($this->value_,strpos($this->value_,$head)+strlen($head)+$headCusor,strpos($this->value_,$bot)-1+$botCusor-strpos($this->value_,$head)-strlen($head)-$headcusor);
}
//'按指定首尾字符串对偷取的内容用新值进行替换(不包括首尾字符串)/方法 function filt($head,$bot,$str)// '参数分别是首字符串,尾字符串,新值,新值位空则为过滤 { if(!$this->isGet_) $this->steal(); $tmp_v=$this->value_; $tmp=$this->cut($head,$bot); return $this->value_=str_replace($tmp,$str,$tmp_v); }
function filtX($head,$bot,$str)// '参数分别是首字符串,尾字符串,新值,新值位空则为过滤 { if(!$this->isGet_) $this->steal(); $tmp_v=$this->value_;
$tmp=$this->cutX($head,$bot);
return $this->value_=str_replace($tmp,$str,$tmp_v); }
//'按指定首尾字符串位置偏移指针对偷取的内容新值进行替换/方法 function filtBy($head,$headCusor,$bot,$botCusor,$str) //'参数分别是首字符串,首偏移值,尾字符串,尾偏移值,新值,左偏移用负值,偏移指针单位为字符数,新值为空则为过滤 { if(!$this->isGet_) $this->steal(); // 这里写代码 $tmp_v=$this->value_; $ttt=substr($this->value_ ,strpos($this->value_ ,$head)+strlen($head)+$headCusor,strpos($this->value_ ,$bot)-1+$botCusor-strpos($this->value_ ,$head)-strlen($head)-$headCusor); //echo $ttt; return $this->value_=str_replace($ttt,$str,$tmp_v );
}
//'将偷取的内容中的绝对URL地址改为本地相对地址 function local() {
}
//'对偷到的内容中的符合正则表达式的字符串用新值进行替换/方法 function replaceByReg($patrn,$str) //'参数是你自定义的正则表达式,新值
|