版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。
http://blog.csdn.net/mayongzhan - 马永占,myz,mayongzhan
程序是共通的...
下面是asp转php的代码
虽然有的地方不太清楚.基本上还是可以看出.任何语言都是可以互相转换的.
上面是php下面是asp
//-------------------------------------------------------------------------------------
class clsThief
{
//__________________
private $value_;
private $src_;
private $isGet_;
public function setSrc($str)
{
$this->src_ = $str;
}
public function getSrc()
{
return $this->src_;
}
public function getValue()
{
return $this->value_;
}
public function getVersion()
{
return "Version 2005";
}
function __construct()
{
$this->value_ = "";
$this->$src_ = "";
$this->isGet_ = false;
}
function __construct()
{
//construct
}
public function bytesToBstr($body,$cset)
{
$objstream = new Server.CreateObject("adodb.stream");//这个地方是什么...流?
$objstream->Type = 1;
//...
$text = $objstream->ReadText;//这里是要返回???
$objstream->Close;
$objstream = null;
}
public function steal()
{
if ($this->src_ == "") {
$http = new server.createobject("MSXML2.XMLHTTP");//这里是xml??
$http->open ;//...
//...
if ($http->readystate!=4) {
exit();//这里是中指执行
}
$this->value_ = $this->bytesToBstr(Http.responseBody,"GB2312");
$this->isGet_ = true;
$http = null;
if ($err->nulber!=0) { //这个应该不对
$err->Clear;
}
else {
echo "";
}
}
}
public function change($oldStr,$str)
{
if ($this->isGet_ = false) {
$this->steal();
$this->value_ = str_replace($this->value_,$oldStr,$str);//这里用的是php的函数
}
}
public function cutX($head,$bot)
{
if ($this->isGet_ = false) {
$this->steal();
if (strstr($this->value_, $head) && strstr($this->value_,$bot)) {//在$this->value中寻找$head ,找到返回true
$this->value_ = false;//这里是什么....
}
else {
$this->value_ = "
单词不存在
";}
}
}
}
?>
$myThief=new clsThief;
$myThief->src = "http://www.baidu.com/baidu?ie=gb2312&bs=&sr=&z=&ct=1048576&cl=3&f=8&word=".wd;
$myThief->steal;
$myThief->cutX("
- ","
$myThief->change("src='IMAGES/","src='http://www.baidu.com/IMAGES/");
$myThief->change("
以上结果由 Dr.eye译典通字典 提供","");
$page = $myThief->value;
$myThief=null;
$page="".page."";//这个有什么意义...
?>
<?php echo $wd;?>解释td,body{font-size:14.8px;color:#000}a:link{color:#000066;text-decoration:none}a:visited{COLOR:#000066;
TEXT-DECORATION:none}a:active{color:red;text-decoration:none}a:hover{color:green;text-decoration:underline}
.unnamed1 {
font-size: 9pt; line-height: 20px}
.font12_bold{
font-size:12px;
color:#000000;
font-weight:bold;
}
.ptitle {margin-top:3px; font-weight:bold}
.pcixin {margin - top : 3px; color = #FF0000}
.pexplain {margin-top:3px; margin-left:20px}
.pnewword {margin-top:3px; margin-right:10px; font-size:12; color:#9d0006; font-weight:bold}
.peng {margin-top:3px; margin-left:40px; font-size:16; color:#0000A0; font-weight:bold}
.pchi {margin-top:3px; margin-left:40px; font-size:16; color:#800040}
font.engi {color:#FF00FF; font-style:italic}
font.chinese {font-weight:normal; font-size:24; color:#008080}
#ft{clear:both;line-height:20px;background:#E6E6E6;text-align:center}
#ft,#ft *{color:#77C;font-size:12px;"" align=left>
#ft span{color:#666}
.sb{height:2em;width:5.6em;font-size:14px;}
.kw{font-size:16px;height:1.78em;padding-top:2px;}
<?php echo $wd;?> 的解释
|
<?php echo $page;?>/td> |
-------------------------------------------
-------------------------------------------
-----------MyZ的分割线-------------
-------------------------------------------
'-------------------------------------------------------------------------------------
Class clsThief
'____________________
Private value_
'
Private src_
'
Private isGet_
'
public property let src(str) '
src_=str
end property
public property get value '
value=value_
end property
Public Property get Version
Version="Version 2005"
End Property
private sub class_initialize()
value_=""
src_=""
isGet_= false
end sub
private sub class_terminate()
end sub
private Function BytesToBstr(body,Cset) '
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
public sub steal() '
if src_<>"" then
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",src_ ,false
Http.send()
if Http.readystate<>4 then
exit sub
end if
value_=BytesToBSTR(Http.responseBody,"GB2312")
isGet_= True
set http=nothing
if err.number<>0 then err.Clear
else
response.Write("")
end if
end sub
public sub change(oldStr,str)
if isGet_= false then call steal()
value_=replace(value_ , oldStr,str)
end sub
public sub cutX(head,bot)
if isGet_= false then call steal()
if instr(value_,head)>0 and instr(value_,bot)>0 then
value_=mid(value_ ,instr(value_ ,head),instr(value_ ,bot)-instr(value_ ,head)+len(bot))
else
value_= "
单词不存在"
end if
end sub
end class
%>
dim myThief,page
set myThief=new clsThief
myThief.src="http://www.baidu.com/baidu?ie=gb2312&bs=&sr=&z=&ct=1048576&cl=3&f=8&word="&wd&""
myThief.steal
myThief.cutX "
- ","
myThief.change "src=""IMAGES/","src=""http://www.baidu.com/IMAGES/"
myThief.change "
以上结果由 Dr.eye译典通字典 提供",""
page=myThief.value
set myThief=nothing
page=""&page&""
%>
解释td,body{font-size:14.8px;color:#000}a:link{color:#000066;text-decoration:none}a:visited{COLOR:#000066;
TEXT-DECORATION:none}a:active{color:red;text-decoration:none}a:hover{color:green;text-decoration:underline}
.unnamed1 {
font-size: 9pt; line-height: 20px}
.font12_bold{
font-size:12px;
color:#000000;
font-weight:bold;
}
.ptitle {margin-top:3px; font-weight:bold}
.pcixin {margin - top : 3px; color = #FF0000}
.pexplain {margin-top:3px; margin-left:20px}
.pnewword {margin-top:3px; margin-right:10px; font-size:12; color:#9d0006; font-weight:bold}
.peng {margin-top:3px; margin-left:40px; font-size:16; color:#0000A0; font-weight:bold}
.pchi {margin-top:3px; margin-left:40px; font-size:16; color:#800040}
font.engi {color:#FF00FF; font-style:italic}
font.chinese {font-weight:normal; font-size:24; color:#008080}
#ft{clear:both;line-height:20px;background:#E6E6E6;text-align:center}
#ft,#ft *{color:#77C;font-size:12px;"" align=left>
#ft span{color:#666}
.sb{height:2em;width:5.6em;font-size:14px;}
.kw{font-size:16px;height:1.78em;padding-top:2px;}
的解释
|
很对不住了.能改的我都改了...其他的忘了很多...有些不熟.....
by mayongzhan