<?
class php52linuxthief
{
var $value_ ; //''窃取到的内容
var $src_ ; //''要偷的目标URL地址
var $isGet_ ; //判断是否已经偷过
function BytesToBstr($f) //''中文处理
{
return join("",$f
}
function _striptext($document)
{
// 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(uml|UML
''", // german
"''&o(uml|UML
''",
"''&u(uml|UML
''",
"''&A(uml|UML
''",
"''&O(uml|UML
''",
"''&U(uml|UML
''",
"''ß''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,$document
return $text;
}
function _striplinks($document)
{
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",$document,$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 $match;
}
function steal($toline=true) //''窃取目标URL地址的HTML代码/方法
{
if($this->src_!="")
{
$unix=true;
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 cut2($head,$bot)
{
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) //''参数是你自定义的正则表达式,新值
{
if(!$this->isGet_) $this->steal(
return $this->value_=join("",preg_replace($patrn,$str,$this->value_)
}
function pickByReg($patrn)
{
//
}
function debug()
{
$tempstr="<SCRIPT>function runEx(){var winEx2 = window.open(\\"\\", \\"winEx2\\", \\"width=500,height=300,status=yes,menubar=no,scrollbars=yes,resizable=yes\\"
winEx2.document.open(\\"text/html\\", \\"replace\\"
winEx2.document.write(unescape(event.srcElement.parentElement.children[0].value)
winEx2.document.close(
}function saveFile(){var win=window.open('''','''',''top=10000,left=10000''
win.document.write(document.all.asdf.innerText
win.document.execCommand(''SaveAs'','''',''javascript.htm''
win.close(
}</SCRIPT><center><TEXTAREA id=asdf name=textfield rows=32 wrap=VIRTUAL cols=\\"120\\">".$this->value_."</TEXTAREA><BR><BR><INPUT name=Button onclick=runEx() type=button value=\\"查看效果\\"> <INPUT name=Button onclick=asdf.select() type=button value=\\"全选\\"> <INPUT name=Button onclick=\\"asdf.value=''''\\" type=button value=\\"清空\\"> <INPUT onclick=saveFile(
type=button value=\\"保存代码\\"></center>";
echo $tempstr;
}
function getkeylinks($key)
{
// this function is used for toline=false
if(!$this->isGet_) $this->steal(
foreach($this->value_ as $k=>$v)
{
if(ereg($key,$v)) {
return $this->_striplinks($v
}
}
}
function hasit($key)
{
// this function is used for toline=false and true;
if(!$this->isGet_) $this->steal(
foreach($this->value_ as $k=>$v)
{
if(ereg($key,$v))
{
return true;
}
}
return false;
}
}
?>
class php52linuxthief
{
var $value_ ; //''窃取到的内容
var $src_ ; //''要偷的目标URL地址
var $isGet_ ; //判断是否已经偷过
function BytesToBstr($f) //''中文处理
{
return join("",$f
}
function _striptext($document)
{
// 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(uml|UML
''", // german
"''&o(uml|UML
''",
"''&u(uml|UML
''",
"''&A(uml|UML
''",
"''&O(uml|UML
''",
"''&U(uml|UML
''",
"''ß''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,$document
return $text;
}
function _striplinks($document)
{
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",$document,$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 $match;
}
function steal($toline=true) //''窃取目标URL地址的HTML代码/方法
{
if($this->src_!="")
{
$unix=true;
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 cut2($head,$bot)
{
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) //''参数是你自定义的正则表达式,新值
{
if(!$this->isGet_) $this->steal(
return $this->value_=join("",preg_replace($patrn,$str,$this->value_)
}
function pickByReg($patrn)
{
//
}
function debug()
{
$tempstr="<SCRIPT>function runEx(){var winEx2 = window.open(\\"\\", \\"winEx2\\", \\"width=500,height=300,status=yes,menubar=no,scrollbars=yes,resizable=yes\\"
winEx2.document.open(\\"text/html\\", \\"replace\\"
winEx2.document.write(unescape(event.srcElement.parentElement.children[0].value)
winEx2.document.close(
}function saveFile(){var win=window.open('''','''',''top=10000,left=10000''
win.document.write(document.all.asdf.innerText
win.document.execCommand(''SaveAs'','''',''javascript.htm''
win.close(
}</SCRIPT><center><TEXTAREA id=asdf name=textfield rows=32 wrap=VIRTUAL cols=\\"120\\">".$this->value_."</TEXTAREA><BR><BR><INPUT name=Button onclick=runEx() type=button value=\\"查看效果\\"> <INPUT name=Button onclick=asdf.select() type=button value=\\"全选\\"> <INPUT name=Button onclick=\\"asdf.value=''''\\" type=button value=\\"清空\\"> <INPUT onclick=saveFile(
type=button value=\\"保存代码\\"></center>";
echo $tempstr;
}
function getkeylinks($key)
{
// this function is used for toline=false
if(!$this->isGet_) $this->steal(
foreach($this->value_ as $k=>$v)
{
if(ereg($key,$v)) {
return $this->_striplinks($v
}
}
}
function hasit($key)
{
// this function is used for toline=false and true;
if(!$this->isGet_) $this->steal(
foreach($this->value_ as $k=>$v)
{
if(ereg($key,$v))
{
return true;
}
}
return false;
}
}
?>