站长简历 | 服务项目 | 成功案例 | 联系方式 | 过客留言 | 友情链接
   
网站首页 | 操作系统 | 办公软件 | 网络软件 | 工具软件 | 媒体动画 | Flash剧场 | 网站设计 | 网站开发 | 平面设计 | 关于站长
 
JScript用户手册 | VBScript用户手册 | ASP用户手册 | PHP用户手册 | ADO程序员手册 | 网页特效 | 3DS MAX6.0命令大全
 您现在的位置:网站首页 >> 网站开发 >> ASP >> 文章正文  
 
ASP常用函数收藏
作者:不详  出处:不详  更新日期:2005-09-10

*******************************************************************
取得IP地址
*******************************************************************
Function Userip()
    Dim GetClientIP
    如果客户端用了代理服务器,则应该用ServerVariables("HTTP_X_FORWARDED_FOR")方法
    GetClientIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
    If GetClientIP = "" or isnull(GetClientIP) or isempty(GetClientIP) Then
        如果客户端没用代理,应该用Request.ServerVariables("REMOTE_ADDR")方法
        GetClientIP = Request.ServerVariables("REMOTE_ADDR")
    end if
    Userip = GetClientIP
End function

*******************************************************************
 弹出对话框
*******************************************************************
Sub alert(message)
  message = replace(message,"","\")
  Response.Write ("<script>alert(" & message & ")</script>")
End Sub
 
*******************************************************************
 返回上一页,一般用在判断信息提交是否完全之后
*******************************************************************
Sub GoBack()
  Response.write ("<script>history.go(-1)</script>")
End Sub
 
*******************************************************************
 重定向另外的连接
*******************************************************************
Sub Go(url)
  Response.write ("<script>location.href(" & url & ")</script>")
End Sub

*******************************************************************
 指定秒数重定向另外的连接
*******************************************************************
sub GoPage(url,s)
  s=s*1000
  Response.Write "<SCRIPT LANGUAGE=javascript>"
  Response.Write "window.setTimeout("&chr(34)&"window.navigate("&url&")"&chr(34)&","&s&")"
  Response.Write "</script>"
end sub

*******************************************************************
 判断数字是否整形
*******************************************************************
function isInteger(para)
on error resume next
dim str
dim l,i
if isNUll(para) then 
isInteger=false
exit function
end if
str=cstr(para)
if trim(str)="" then
isInteger=false
exit function
end if
l=len(str)
for i=1 to l
if mid(str,i,1)>"9" or mid(str,i,1)<"0" then
isInteger=false 
exit function
end if
next
isInteger=true
if err.number<>0 then err.clear
end function

*******************************************************************
 获得文件扩展名
*******************************************************************
function GetExtend(filename)
dim tmp
if filename<>"" then
tmp=mid(filename,instrrev(filename,".")+1,len(filename)-instrrev(filename,"."))
tmp=LCase(tmp)
if instr(1,tmp,"asp")>0 or instr(1,tmp,"php")>0 or instr(1,tmp,"php3")>0 or instr(1,tmp,"aspx")>0 then
getextend="txt"
else
getextend=tmp
end if
else
getextend=""
end if
end function

 *----------------------------------------------------------------------------
 * 函数:CheckIn
 * 描述:检测参数是否有SQL危险字符
 * 参数:str要检测的数据
 * 返回:FALSE:安全 TRUE:不安全
 * 作者:
 * 日期:
 *----------------------------------------------------------------------------
function CheckIn(str)
if instr(1,str,chr(39))>0 or instr(1,str,chr(34))>0 or instr(1,str,chr(59))>0 then
CheckIn=true
else
CheckIn=false
end if
end function

 *----------------------------------------------------------------------------
 * 函数:HTMLEncode
 * 描述:过滤HTML代码
 * 参数:--
 * 返回:--
 * 作者:
 * 日期:
 *----------------------------------------------------------------------------
function HTMLEncode(fString)
if not isnull(fString) then
fString = replace(fString, ">", "&gt;")
fString = replace(fString, "<", "&lt;")

fString = Replace(fString, CHR(32), "&nbsp;")
fString = Replace(fString, CHR(9), "&nbsp;")
fString = Replace(fString, CHR(34), "&quot;")
fString = Replace(fString, CHR(39), "&#39;")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
fString = Replace(fString, CHR(10), "<BR> ")

HTMLEncode = fString
end if
end function

 *----------------------------------------------------------------------------
 * 函数:HTMLcode
 * 描述:过滤表单字符
 * 参数:--
 * 返回:--
 * 作者:
 * 日期:
 *----------------------------------------------------------------------------
function HTMLcode(fString)
if not isnull(fString) then
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
fString = Replace(fString, CHR(34), "")
fString = Replace(fString, CHR(10), "<BR>")
HTMLcode = fString
end if
end function



在百度中搜索:ASP常用函数收藏


上一篇:ASP小偷(远程数据获取)程序入门教程
下一篇:ADO 用户手册

  文章搜索
 
  MY广告
 
  本类热点
·ASP的开发工具
·在ASP中使用Oracle数
·ASP.NET安全身份验证的
·ASP.NET中密码保护
·jsp基础学习资料
·在ASP中使用简单Java类
·整理的Transact_SQ
·ASP开发10条经验总结
·ASP自动生成编号的方法
·初看ASP-针对初学者
 
  特别声明
  本站的大部分资料、文章都来自网上收集,其版权归作者本人所有,如果有任何侵犯您权益的地方,请与我联系,我们将马上进行整理,谢谢。
 
  网站导航  
操作系统 办公软件 网络软件
Windows2003 WindowsXP Windows2000/NT Windows9X/ME Linux 其他 Word Excel Access Powerpoint Outlook WPS 其他 网页浏览 上传下载 联络聊天 邮件工具 服务器软件 网络辅助
工具软件 媒体动画 网站设计
系统工具 媒体工具 压缩工具 图文处理 文件管理 其他 3DMAX Authorware Director Maya/SoftImage/Rhino 视频处理 其他 Flash Dreamweaver FireWorks FrontPage LiveMotion Golive HTML/CSS 其它
网站开发 平面设计 Flash剧场
ASP JSP PHP CGI JavaScript VBScript XML/SOAP Web服务器 Photoshop/ImageReady PhotoImpact CorelDraw Freehand/Illustrator 设计欣赏 其他 Flash MTV Flash小品 Flash游戏 Flash贺卡 Flash宣传 Flash专辑

冀ICP备05019428号
Copyright goodsgy Inc.All rights reserved.
TEL:13832340607
E_Mail:good_sgy@tom.com  
MSN:goodsgy@hotmail.com