文章探索:   分类:    关键字:  
  + 栏目导航
  + 相关文章
asp中有关字符编码转换的几个函数
绝妙的asp生成静态页面html函数
Asp计算页面执行时间
一个简单的用存储过程分页
将asp页面转换成htm页面
ASP网站漏洞解析及黑客入侵防范方法
URL编码与SQL注入
几种常用排序算法(asp)
ASP调用带参数存储过程的几种方式
实用的ASP连接数据库的函数
ASP如何获取真实IP地址
ASP中怎么实现SQL数据库备份、恢复
判断Cookies是否处于开启状态
怎样才能将服务器端文件夹下的文件,..
几行Asp代码实现防止表单重复提交
用ASP设计网站在线人数统计程序
asp论坛在线人数统计研究
如何用ASP远程在数据库中创建Table
用ASP调用SQL Server的视图和存储过程
Asp与XML的关系
ASP读取EXCEL
在ASP中使用Oracle数据库技巧
一个通过web.Mail发送邮件的类
几种打开记录集方式的比较
购物车范例(购物车页面 )
如何使用FSO搜索硬盘文件
GB码和BIG5码的互换技术
用ASP开发WEB日期选择器
一个投票系统的源程序(coveryourasp.c..
列出服务器上的打印机


技术教程 -> ASP教程 ->  
ASP实用函数库(1)
来源:转载   人气:628   录入时间:2007-11-8
     <%
    '判断文件名是否合法
    Function isFilename(aFilename)
    Dim sErrorStr,iNameLength,i
    isFilename=TRUE
    sErrorStr=Array("/","\",":","*","?","""","<",">","|")
    iNameLength=Len(aFilename)
    If iNameLength<1 Or iNameLength=null Then
    isFilename=FALSE
    Else
    For i=0 To 8
    If instr(aFilename,sErrorStr(i)) Then
    isFilename=FALSE
    End If
    Next
    End If
    End Function
   
    '去掉字符串头尾的连续的回车和空格
    function trimVBcrlf(str)
    trimVBcrlf=rtrimVBcrlf(ltrimVBcrlf(str))
    end function
   
    '去掉字符串开头的连续的回车和空格
    function ltrimVBcrlf(str)
    dim pos,isBlankChar
    pos=1
    isBlankChar=true
    while isBlankChar
    if mid(str,pos,1)=" " then
    pos=pos+1
    elseif mid(str,pos,2)=VBcrlf then
    pos=pos+2
    else
    isBlankChar=false
    end if
    wend
    ltrimVBcrlf=right(str,len(str)-pos+1)
    end function
   
    '去掉字符串末尾的连续的回车和空格
    function rtrimVBcrlf(str)
    dim pos,isBlankChar
    pos=len(str)
    isBlankChar=true
    while isBlankChar and pos>=2
    if mid(str,pos,1)=" " then
    pos=pos-1
    elseif mid(str,pos-1,2)=VBcrlf then
    pos=pos-2
    else
    isBlankChar=false
    end if
    wend
    rtrimVBcrlf=rtrim(left(str,pos))
    end function
   
    '判断Email是否有效,返回1表示正确
    Function isEmail(aEmail)
    Dim iLocat,v,iLength,i,checkletter
    If instr(aEmail,"@") = 0 Or instr(aEmail,".") = 0 Then
    isEmail=0
    EXIT FUNCTION
    End If
    iLocat=instr(aEmail,"@")
    If instr(iLocat,aEmail,".")=0 Or instr(iLocat+1,aEmail,"@")>0 Then
    isEmail=0
    EXIT FUNCTION
    End If
    If left(aEmail,1)="." Or right(aEmail,1)="." Or left(aEmail,1)="@" Or right(aEmail,1)="@" Then
    isEmail=0
    EXIT FUNCTION
    End If
    v="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.@"
    iLength=len(aEmail)
    For i=1 To iLength
    checkletter=mid(aEmail,i,1)
    If instr(v,checkletter)=0 Then
    isEmail=0
    EXIT FUNCTION
    End If
    Next
    isEmail=1
    End Function
   
    '测试用:显示服务器信息
    Sub showServer
    Dim name
    Response.write "<Table border=1 bordercolor=lightblue CELLSPACING=0>"
    for each name in request.servervariables
    Response.write "<tr>"
    Response.write "<td>"&name&"</td>"
    Response.write "<td>"&request.servervariables(name)&"<br></td>"
    Response.write "</tr>"
    next
    Response.write "</table>"
    End Sub
   
    '测试用:显示Rs结果集以及字段名称
    Sub showRs(rs)
    Dim strTable,whatever
    Response.write "<center><table><tr>"
    for each whatever in rs.fields
    response.write "<td><b>" & whatever.name & "</B></TD>"
    next
    strTable = "</tr><tr><td>"&rs.GetString(,,"</td><td>","</tr><tr><td>"," ") &"</td></tr></table></center>"
    Response.Write(strTable)
    End Sub
   
    '用HTML格式显示文本
    function HTMLEncode(fString)
    if not isnull(fString) then
    fString = replace(fString, ">", ">")
    fString = replace(fString, "<", "<")
   
    fString = Replace(fString, CHR(32), " ")
    fString = Replace(fString, CHR(34), """)
    fString = Replace(fString, CHR(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
   
    '测试用:显示调试错误信息
    Sub showError
    Dim sErrMsg
    sErrMsg=Err.Source&" "&Err.Description
    Response.write "<center>"&sErrMsg&"</center>"
    Err.clear
    End Sub
   
    '显示文字计数器
    Sub showCounter
    Dim fs,outfile,filename,count
    filename=server.mappath("count.txt")
    Set fs = CreateObject("Scripting.FileSystemObject")
    If fs.fileExists(filename) Then
    Set outfile=fs.openTextFile(filename,1)
    count=outfile.readline
    count=count+1
    Response.write "<center>浏览人次:"&count&"<center>"
    outfile.close
    Set outfile=fs.CreateTextFile(filename)
    outfile.writeline(count)
    Else
    Set outfile=fs.openTextFile(filename,8,TRUE)
    count=0
    outfile.writeline(count)
    END IF
    outfile.close
    set fs=nothing
    End Sub
    %>
   




Copyright(C)2007-2024 广州市佳沛数码科技有限公司 版权所有
公司地址: 广州市荔湾区东漖北路560号511室
电话:020-81803473 传真:020-81544987