一段asp轉php
來源:互聯網
上載者:User
著作權聲明:原創作品,允許轉載,轉載時請務必以超連結形式標明文章原始出版、作者資訊和本聲明。否則將追究法律責任。http://blog.csdn.net/mayongzhan - 馬永占,myz,mayongzhan程式是共通的...下面是asp轉php的代碼雖然有的地方不太清楚.基本上還是可以看出.任何語言都是可以互相轉換的.上面是php下面是asp <?php//-------------------------------------------------------------------------------------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 "<script language='javascript'>alert('請先設定src屬性!');</script>"; } } } 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_ = "<p align='center'>單詞不存在</p>"; } } }}?><html><head><?php $wd=$_REQUEST['word'];$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("<ol>","</ol>");//這裡是什麼 $myThief->change("src='IMAGES/","src='http://www.baidu.com/IMAGES/"); $myThief->change("<br>以上結果由 <a href='http://www.dreye.com.cn' target='_blank'>Dr.eye譯典通字典</a> 提供",""); $page = $myThief->value; $myThief=null; $page="".page."";//這個有什麼意義...?><title><?php echo $wd;?>解釋</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><style type="text/css">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;}</style><style type="text/css">.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;}</style></head><body><div align="center"> <p><a href=""><font color="#FF0000" size="+1"><strong>英漢詞典</strong></font></a></p></div> <br><table width="770" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="4"><div align="center"> <form name="f1" action="index.asp"> <input name="word" type="text" id="word" class=kw> <input type=submit value=詞典搜尋 class=sb></form> </div></td> </tr> <tr> <td height="30" colspan="4"><div align="center"><font color="green" size="3"><strong><?php echo $wd;?> 的解釋</strong></font></div></td> </tr></table><table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="bm81"> <tr> <td><?php echo $page;?>/td> </tr></table> </body></html> -------------------------------------------------------------------------------------------------MyZ的分割線-------------------------------------------------------- <% '-------------------------------------------------------------------------------------Class clsThief'____________________Private value_ 'Private src_ 'Private isGet_ ' public property let src(str) 'src_=strend property public property get value 'value=value_end property Public Property get VersionVersion="Version 2005"End Property private sub class_initialize()value_=""src_=""isGet_= falseend sub private sub class_terminate()end sub private Function BytesToBstr(body,Cset) 'dim objstreamset objstream = Server.CreateObject("adodb.stream")objstream.Type = 1objstream.Mode =3objstream.Openobjstream.Write bodyobjstream.Position = 0objstream.Type = 2objstream.Charset = CsetBytesToBstr = objstream.ReadText objstream.Closeset objstream = nothingEnd Function public sub steal() 'if src_<>"" thendim Httpset Http=server.createobject("MSXML2.XMLHTTP")Http.open "GET",src_ ,falseHttp.send()if Http.readystate<>4 then exit subend ifvalue_=BytesToBSTR(Http.responseBody,"GB2312")isGet_= Trueset http=nothingif err.number<>0 then err.Clearelse response.Write("<script>alert(""請先設定src屬性!"")</script>")end ifend 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_= "<p align=""center"">單詞不存在" end ifend sub end class%><html><head><%wd=request("word")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 "<ol>","</ol>" myThief.change "src=""IMAGES/","src=""http://www.baidu.com/IMAGES/" myThief.change "<br>以上結果由 <a href=""http://www.dreye.com.cn"" target=_blank>Dr.eye譯典通字典</a> 提供","" page=myThief.value set myThief=nothing page=""&page&""%><title><%=wd%>解釋</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><style type="text/css">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;}</style><style type="text/css">.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;}</style></head><body><div align="center"> <p><a href=""><font color="#FF0000" size="+1"><strong>英漢詞典</strong></font></a></p></div> <br><table width="770" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="4"><div align="center"> <form name="f1" action="index.asp"> <input name="word" type="text" id="word" class=kw> <input type=submit value=詞典搜尋 class=sb></form> </div></td> </tr> <tr> <td height="30" colspan="4"><div align="center"><font color="green" size="3"><strong><%=wd%> 的解釋</strong></font></div></td> </tr></table><table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="bm81"> <tr> <td><%response.write(page) %></td> </tr></table> </body></html> 很對不住了.能改的我都改了...其他的忘了很多...有些不熟.....by mayongzhan