“ASP” 相关主题的文章存档:

ASP 生成柱型体,折线图,饼图源代码

<%
function table2(total,table_x,table_y,all_width,all_height,line_no)
’参数含义(传递的数组,横坐标,纵坐标,图表的宽度,图表的高度,折线条数)
’纯ASP代码生成图表函数2——折线图
’版本1.0 最后修改日期 2003-8-11
’非常感谢您使用这个函数,请您使用和转载时保留版权信息,这是对作者工作的最好的尊重。
line_color="#69f"
left_width=70
total_no=ubound(total,1)
temp1=0
for i=1 to total_no
for j=1 to line_no
if temp1<total(i,j) then temp1=total(i,j)
next
next
temp1=int(temp1)
if temp1>9 then
temp2=mid(cstr(temp1),2,1)
if temp2>4 then
temp3=(int(temp1/(10^(len(cstr(temp1))-1)))+1)*10^(len(cstr(temp1))-1) 感兴趣?继续阅读 »

在 ASP 中设置 IP 访问限制

刚刚在{2XL}看到的,觉得很有用,收录在此:

<%
''获取访问者的地址
ip=Request.ServerVariables("REMOTE_ADDR")''允许的IP地址段为10.0.0.0~10.68.63.255
allowip1="10.0.0.0"
allowip2="10.68.10.71"
response.write checkip(ip,allowip1,allowip2)
function checkip(ip,allowip1,allowip2)
dim check(4)
checkip=false
ipstr=split(ip,".")
allow1=split(allowip1,".")
allow2=split(allowip2,".")
if cint(allow1(0))>cint(allow2(0)) then ''判断IP地址段是否合法
response.write "禁止访问"
exit function
end if
for i=0 to ubound(ipstr)
if cint(allow1(i))<cint(allow2(i)) then 感兴趣?继续阅读 »

文本方式实现同一 IP 端口绑定不同域名

本站曾经介绍过在IIS 中设置主机头,实现 “在一个IP的一个端口下,不同的来访域名对应到到不同的主机” 的方法。今天再给大家介绍几种通过ASP 或JS 实现多个域名使用一个主机放置不同的站点的方法,如下面所示:

用ASP方法实现:

1、
<%
if Request.ServerVariables("SERVER_NAME")="www.alli.cn" then
response.redirect "index.htm"
elseif Request.ServerVariables("SERVER_NAME")="blog.alli.cn" then
response.redirect "blog"
elseif Request.ServerVariables("SERVER_NAME")="album.alli.cn" then
response.redirect "album"
end if
%>

2、
<%
if Request.ServerVariables("SERVER_NAME")="www.alli.cn" then
Server.Transfer("index.htm")
elseif Request.ServerVariables("SERVER_NAME")="blog.alli.cn" then
Server.Transfer("blog")
elseif Request.ServerVariables("SERVER_NAME")="album.alli.cn" then
Server.Transfer("album")
else
Server.Transfer("index.htm")
end if
%>

3、
<%
if instr(Request.ServerVariables("SERVER_NAME"),"www.alli.cn")>0 then
response.redirect "index.htm"
elseif instr(Request.ServerVariables("SERVER_NAME"),"blog.alli.cn")>0 then
response.redirect "blog"
elseif instr(Request.ServerVariables("SERVER_NAME"),"album.alli.cn")>0 then
response.redirect "album"
end if
%>

4、
<%
select case request.servervariables("http_host")
case "www.alli.cn" '1
Server.Transfer("index.htm")
case "blog.alli.cn" '2
Server.Transfer("blog")
case "album.alli.cn" '3
Server.Transfer("album")
...... 继续添加 ......
end select
%>

具体做法:
将需要做转向的域名指向到你的空间的IP.
建立默认首页的asp 文件, 将代码添加到文件的头部.
上传就 OK 了!

用JS方法实现:

在空间的默认首页面建立文件如:default.htm

<html>
<script language="javascript">
if(this.location=="http://alli.cn/")
{this.location.href="http://alli.cn/index.htm";}
else
if(this.location=="http://www.alli.cn/")
{this.location.href="http://www.alli.cn/index.htm";}
else
if(this.location=="http://blog.alli.cn/")
{this.location.href="http://www.alli.cn/blog/";}
else
if(this.location=="http://album.alli.cn/")
{this.location.href="http://www.alli.cn/album/";}
else
if(this.location=="http://wap.alli.cn/")
{this.location.href="http://www.alli.cn/wap/";}
else
{this.location.href="http://www.alli.cn/index.htm";}
</script>
</html>

ASP中各种数据库连接代码

20条ASP初学者常用的代码

1.获得系统时间:
<%=now()%>

2.取得来访用的IP:
<%=request.serverVariables("remote_host")%>

3.获得系统,浏览器版本:
<script>
window.document.write("版本:"+navigator.appName+navigator.appVersion+" browser.")
</script>
感兴趣?继续阅读 »