永城市公安局新闻:有谁可以为我解释一下下面的ASP代码?

来源:百度文库 编辑:高校问答 时间:2024/04/28 14:32:00
<!-- #include file="conn.asp" -->
<center>
<%
dim rs,sql,sURL,MyUrl
sURL=Request.ServerVariables("HTTP_HOST")
if InStr(sURL,"=")<>0 or InStr(sURL,"`")<>0 or InStr(sURL,"'")<>0 or InStr(sURL," ")<>0 or InStr(sURL," ")<>0 or InStr(sURL,"'")<>0 or InStr(sURL,chr(34))<>0 or InStr(sURL,"\")<>0 or InStr(sURL,",")<>0 or InStr(sURL,"<")<>0 or InStr(sURL,">")<>0 then
Response.Write("<font color=red>您输入的域名有非法字符,请重新输入!</font>")
Response.End
end if
MyUrl=split(sURL,".")
if ubound(MyUrl)>2 then
Response.Write("<font color=red>您输入的域名有误,请重新输入!</font>")
Response.End
elseif ubound(MyUrl)=1 or MyUrl(0)="www" then
Response.Redirect("index.asp")
end if
set rs=Server.CreateObject("ADODB.recordset")
sql="select ispass,hiden,url,sitename from [domain] where [domain]='"&MyUrl(0)&"'"
rs.open sql,conn,1,1
if not rs.eof then
if rs("ispass")=0 then
Response.Write("<font color=red>你的域名被禁止使用,请联系管理员</font>")
else
if rs("hiden")=0 then
Response.Redirect ""&rs("url")&""
else
Response.Write "<html><head><script language=javascript>document.write('<title>"&rs("sitename")&"</title>');function start(url){this.txt.document.write('Loading......');this.txt.location.href='"+rs("url")+"'}</script></head><frameset cols=0,* rows=* border=0 framespacing=0 frameborder=NO onload=start('"&rs("url")&"')><frame src=about:blank marginwidth=0 marginheight=0 name=top noresize><frame src=about:blank name=txt></frameset></html>"
Response.Write "<frameset cols=0,* rows=* border=0 framespacing=0 frameborder=NO><frame src=about:blank marginwidth=0 marginheight=0 name=top noresize><frame src="&rs("url")&" name=txt></frameset>"
end if
end if
else
Response.Write("域名不存在")
end if
%></center>

前面是检查域名里有否带非法字符,可以看下instr函数
split分离函数,ubound数组里元素个数,接下来就是查2级域名是否被禁止使用,接下来就是管理了