当前位置: 移动技术网 > IT编程>开发语言>Asp > asp制作中常用到的函数库集合第1/8页

asp制作中常用到的函数库集合第1/8页

2017年12月12日  | 移动技术网IT编程  | 我要评论
asp函数库    <%    '''' 函数目录 ''''   

'************************************************** 
  '函数id:0002[过滤html] 
  '函数名:glhtml 
  '作 用:过滤html 元素 
  '参 数:str ---- 要过滤字符 
  '返回值:没有html 的字符 
  '************************************************** 
  public function glhtml(byval str) 
   if isnull(str) or trim(str) = "" then 
   glhtml = "" 
   exit function 
   end if 
   dim re 
   set re = new regexp 
   re.ignorecase = true 
   re.global = true 
   re.pattern = "(\<.[^\<]*\>)" 
   str = re.replace(str, " ") 
   re.pattern = "(\<\/[^\<]*\>)" 
   str = re.replace(str, " ") 
   set re = nothing 
   str = replace(str, "'", "") 
   str = replace(str, chr(34), "") 
   glhtml = str 
  end function 
  '************************************************** 
  '函数id:0003[打开任意数据表并显示表结构及内容] 
  '函数名:opotherdb 
  '作 用:打开任意数据表并显示表结构及内容 
  '参 数:dbthestr ---- 要打开表的数据库链接字串 
  '参 数:opentdname ---- 要打开表名 
  '返回值:显示表结构及内容 
  '************************************************** 
  public function opotherdb(byval dbthestr,byval opentdname) 
   response.write "<table border='0' width='100%' cellspacing='0' cellpadding='0'>" & vbcrlf 
   set opdb_conn=server.createobject("adodb.connection") 
   set opdb_rs =server.createobject("adodb.recordset") 
   opdb_conn.open dbthestr 
   opdb_sql_str="select * from "&opentdname 
   opdb_rs.open opdb_sql_str,opdb_conn,1,1 
   nfieldnumber=opdb_rs.fields.count 
   if nfieldnumber >0 then 
   response.write "<tr>" & vbcrlf 
   for i=0 to (nfieldnumber-1) 
   response.write "<td style='border-style: ridge; border-width: 1' bgcolor='#e1e1e1' valign='middle' align='center'>" 
   response.write trim(opdb_rs.fields(i).name) 
   response.write "</td>" & vbcrlf 
   next 
   temptbi=0 
   do while not opdb_rs.eof 
   response.write "</tr>" & vbcrlf 
   for i=0 to (nfieldnumber-1) 
   if (temptbi<2) then 
   response.write "<td style='border-style: ridge; border-width: 1' bgcolor='#f6f6f6' valign='middle'>" 
   response.write trim(opdb_rs.fields(i)) 
   response.write "</td>" & vbcrlf 
   temptbi=temptbi+1 
   else 
   response.write "<td style='border-style: ridge; border-width: 1' valign='middle'>" 
   response.write trim(opdb_rs.fields(i)) 
   response.write "</td>" & vbcrlf 
   if temptbi>=3 then 
   temptbi=0 
   else 
   temptbi=temptbi+1 
   end if 
   end if 
   next 
   opdb_rs.movenext 
   response.write "</tr>" & vbcrlf 
   loop 
   end if 
   opdb_rs.close 
   opdb_conn.close 
   set opdb_rs = nothing 
   set opdb_conn=nothing 
   response.write "</table>" & vbcrlf 
  end function 
  '************************************************** 
  '函数id:0004[读取两种路径] 
  '函数名:readsyspath 
  '作 用:读取路径 
  '参 数:lx ---- 0:服务器ip加路径 1:服务物理路径 
  '返回值:路径字串 
  '************************************************** 
  public function readsyspath(byval lx) 
   dim templj,arytemp,newpath 
   templj="" 
   newpath="" 
   if lx=0 then 
   templj="http://"&request("server_name")&request("path_info") 
   arytemp = split(templj,"/") 
   else 
   templj=request("path_translated") 
   arytemp = split(templj,"\") 
   end if 
   for i = lbound(arytemp) to ubound(arytemp)-1 
   if lx=0 then 
   newpath=newpath&arytemp(i)&"/" 
   else 
   newpath=newpath&arytemp(i)&"\" 
   end if 
   next 
   readsyspath=newpath 
  end function 
  '************************************************** 
  '函数id:0005[测试某个文件存在否] 
  '函数名:checkfile 
  '作 用:测试某个文件存在否 
  '参 数:ckfilename ---- 被测试的文件名(包括路径) 
  '返回值:文件存在返回true,否则false 
  '************************************************** 
  public function checkfile(byval ckfilename) 
   dim m_fso 
   checkfile=false 
   set m_fso = createobject("scripting.filesystemobject") 
   if m_fso.fileexists(ckfilename) then 
   checkfile=true 
   end if 
   set m_fso = nothing 
  end function 
  '************************************************** 
  '函数id:0006[删除某个文件] 
  '函数名:delfile 
  '作 用:删除某个文件 
  '参 数:dfilename ---- 被删除的文件名(包括路径) 
  '返回值:文件删除返回true,否则false 
  '************************************************** 
  public function delfile(byval dfilename) 
   dim m_fso 
   delfile=false 
   set m_fso = createobject("scripting.filesystemobject") 
   if m_fso.fileexists(dfilename) then 
   m_fso.deletefile(dfilename) 
   delfile=true 
   end if 
   set m_fso = nothing 
  end function 
  '************************************************** 
  '函数id:0007[判断目录是否存在] 
  '函数名:checkdir 
  '作 用:判断目录是否存在 
  '参 数:ckdirname ---- 目录名(包括路径) 
  '返回值:目录存在返回true,否则false 
  '************************************************** 
  public function checkdir(byval ckdirname) 
   dim m_fso 
   checkdir=false 
   set m_fso = createobject("scripting.filesystemobject") 
   if (m_fso.folderexists(ckdirname)) then 
   checkdir=true 
   end if 
   set m_fso = nothing 
  end function 
  '************************************************** 
  '函数id:0008[创建目录] 
  '函数名:createdir 
  '作 用:创建目录 
  '参 数:crdirname ---- 目录名(包括路径) 
  '返回值:目录创建成功返回true,否则false 
  '************************************************** 
  public function createdir(byval crdirname) 
   dim m_fso 
   createdir=false 
   set m_fso = createobject("scripting.filesystemobject") 
   if (m_fso.folderexists(crdirname)) then 
   createdir=false 
   else 
   m_fso.createfolder(crdirname) 
   createdir=true 
   end if 
   set m_fso = nothing 
  end function 
  '************************************************** 
  '函数id:0009[删除目录] 
  '函数名:deldir 
  '作 用:删除目录 
  '参 数:dldirname ---- 目录名(包括路径) 
  '返回值:目录删除成功返回true,否则false 
  '************************************************** 
  public function deldir(byval dldirname) 
   dim m_fso 
   deldir=false 
   set m_fso = createobject("scripting.filesystemobject") 
   if (m_fso.folderexists(dldirname)) then 
   m_fso.deletefolder(dldirname) 
   deldir=true 
   end if 
   set m_fso = nothing 
  end function 
  '************************************************** 
  '函数id:0010[指定目录的文件列表] 
  '函数名:listfiles 
  '作 用:指定目录的文件列表 
  '参 数:dirname ---- 目录名(包括路径) 
  '返回值:文件列表字符串,之间用“|”相隔 
  '************************************************** 
  public function listfiles(byval dirname) 
   dim m_fso,fns,fls,fnames,fnamesn 
   set m_fso = createobject("scripting.filesystemobject") 
   if (m_fso.folderexists(dirname)) then 
   set fns = m_fso.getfolder(dirname) 
   set fls=fns.files 
   for each fnamesn in fls 
   fnames=fnames & fnamesn.name 
   fnames=fnames & "|" 
   next 
   listfiles=fnames 
   end if 
   set m_fso = nothing 
  end function
2

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网