注册 登录
编程论坛 新人交流区

[求助]小弟弟有问题,希望有情人士出手相救!

shuofuzhe 发布于 2007-10-21 22:11, 364 次点击
能把下面这段ASP代码翻译下吗?谢谢了,无比感激啊!



<%
dim ComeUrl,cUrl,AdminName

ComeUrl=lcase(trim(request.ServerVariables("HTTP_REFERER")))
if ComeUrl="" then
response.write "<br><p align=center><font color='red'>对不起,为了系统安全,不允许直接输入地址访问本系统的后台管理页面。</font></p>"
response.end
else
cUrl=trim("http://" & Request.ServerVariables("SERVER_NAME"))
if mid(ComeUrl,len(cUrl)+1,1)=":" then
cUrl=cUrl & ":" & Request.ServerVariables("SERVER_PORT")
end if
cUrl=lcase(cUrl & request.ServerVariables("SCRIPT_NAME"))
if lcase(left(ComeUrl,instrrev(ComeUrl,"/")))<>lcase(left(cUrl,instrrev(cUrl,"/"))) then
response.write "<br><p align=center><font color='red'>对不起,为了系统安全,不允许从外部链接地址访问本系统的后台管理页面。</font></p>"
response.end
end if
end if

AdminName=replace(session("AdminName"),"'","")
if AdminName="" then
call CloseConn()
response.redirect "login.asp"
response.End()
end if
sql="select UserName from Admin where UserName='" & session("AdminName") & "' and Password='" & session("AdminPassword") & "'"
set rs=conn.execute(sql)
if rs.eof and rs.bof then
rs.close
response.Redirect("login.asp")
response.End()
end if
%>
5 回复
#2
sui20662007-10-22 01:45
#3
suplc2007-10-22 08:46
不懂

#4
wwhhjj2007-10-22 09:47
不懂
#5
yato094632007-10-22 15:27
那几个变量的用法我想就不用说了吧?request.servervariables("HTTP_REFERER") 是接收上一页的地址,如果这个地址为空,也就是说他的上一页链接为空,这种情况只有他直接输入地址造成的,所以response.write "<br><p align=center><font color='red'>对不起,为了系统安全,不允许直接输入地址访问本系统的后台管理页面。</font></p>"
response.end 先用RESPONSE.WRITE "" 输出提示,再用RESPONSE.END中止程序.
curl这个变量等于"http://"加上当前页面的服务器名.后面的语法就不是太熟了呵呵,只能邦你到这了希望给你有帮助
#6
yato094632007-10-22 15:31
AdminName=replace(session("AdminName"),"'","") 接收SESSION值
if AdminName="" then 如果为空
call CloseConn() 调用CLOSECONN() 应该是个关闭数据库连接的子程序
response.redirect "login.asp" 跳转出去
response.End()
end if



sql="select UserName from Admin where UserName='" & session("AdminName") & "' and Password='" & session("AdminPassword") & "'"
set rs=conn.execute(sql)
if rs.eof and rs.bof then
rs.close
通过SESSION值里的用户名和密码与数据库里对比,验证身份.



response.Redirect("login.asp")
response.End()
end if
%>
1