设为首页 收藏本站
查看: 549|回复: 0

[经验分享] 一段asp转php

[复制链接]

尚未签到

发表于 2017-3-27 09:33:09 | 显示全部楼层 |阅读模式
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。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_=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("<script>alert(""请先设置src属性!"")</script>")
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_= "<p align=""center"">单词不存在"
end if
end 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

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-355923-1-1.html 上篇帖子: 【点滴】php调试,小总结 下篇帖子: php面向对象技术(三)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表