⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fun.asp

📁 用ASP设计的一个网上问卷系统,用于网上调查问卷系统的实现
💻 ASP
📖 第 1 页 / 共 2 页
字号:
    dim strSeed,seedLength,pos,str,i
    strSeed = "abcdefghijklmnopqrstuvwxyz1234567890"
    seedLength=len(strSeed)
    str=""
    Randomize
    for i=1 to intLength
     str=str+mid(strSeed,int(seedLength*rnd)+1,1)
    next
    randomStr=str
end function
'====================================================================
'数据库备份恢复,文件管理
'日期转换函数
'====================================================================
Function DateToStr(DateTime,ShowType)  
	Dim DateMonth,DateDay,DateHour,DateMinute,DateWeek,DateSecond
	Dim FullWeekday,shortWeekday,Fullmonth,Shortmonth,TimeZone1,TimeZone2
	TimeZone1="+0800"
	TimeZone2="+08:00"
	FullWeekday=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
	shortWeekday=Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
    Fullmonth=Array("January","February","March","April","May","June","July","August","September","October","November","December")
    Shortmonth=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

	DateMonth=Month(DateTime)
	DateDay=Day(DateTime)
	DateHour=Hour(DateTime)
	DateMinute=Minute(DateTime)
	DateWeek=weekday(DateTime)
	DateSecond=Second(DateTime)
	If Len(DateMonth)<2 Then DateMonth="0"&DateMonth
	If Len(DateDay)<2 Then DateDay="0"&DateDay
	If Len(DateMinute)<2 Then DateMinute="0"&DateMinute
	Select Case ShowType
	Case "Y-m-d"  
		DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay
	Case "Y-m-d H:I A"
		Dim DateAMPM
		If DateHour>12 Then 
			DateHour=DateHour-12
			DateAMPM="PM"
		Else
			DateHour=DateHour
			DateAMPM="AM"
		End If
		If Len(DateHour)<2 Then DateHour="0"&DateHour	
		DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&" "&DateAMPM
	Case "Y-m-d H:I:S"
		If Len(DateHour)<2 Then DateHour="0"&DateHour	
		If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
		DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&":"&DateSecond
	Case "YmdHIS"
		DateSecond=Second(DateTime)
		If Len(DateHour)<2 Then DateHour="0"&DateHour	
		If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
		DateToStr=Year(DateTime)&DateMonth&DateDay&DateHour&DateMinute&DateSecond	
	Case "ym"
		DateToStr=Right(Year(DateTime),2)&DateMonth
	Case "d"
		DateToStr=DateDay
    Case "ymd"
        DateToStr=Right(Year(DateTime),4)&DateMonth&DateDay
    Case "mdy" 
        Dim DayEnd
        select Case DateDay
         Case 1 
          DayEnd="st"
         Case 2
          DayEnd="nd"
         Case 3
          DayEnd="rd"
         Case Else
          DayEnd="th"
        End Select 
        DateToStr=Fullmonth(DateMonth-1)&" "&DateDay&DayEnd&" "&Right(Year(DateTime),4)
    Case "w,d m y H:I:S" 
		DateSecond=Second(DateTime)
		If Len(DateHour)<2 Then DateHour="0"&DateHour	
		If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
        DateToStr=shortWeekday(DateWeek-1)&","&DateDay&" "& Left(Fullmonth(DateMonth-1),3) &" "&Right(Year(DateTime),4)&" "&DateHour&":"&DateMinute&":"&DateSecond&" "&TimeZone1
    Case "y-m-dTH:I:S"
		If Len(DateHour)<2 Then DateHour="0"&DateHour	
		If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
		DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&"T"&DateHour&":"&DateMinute&":"&DateSecond&TimeZone2
	Case Else
		If Len(DateHour)<2 Then DateHour="0"&DateHour
		DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute
	End Select
End Function
'====================================================================
'数据库备份恢复,文件管理
'释放网站缓存
'====================================================================
Function FreeApplicationMemory
    on error resume next
	Response.Write "释放网站缓存数据列表:<div style='padding:5px 5px 5px 10px;'>"
	Dim Thing
	For Each Thing IN Application.Contents
		IF Left(Thing,Len(CookieName)) = CookieName Then
			Response.Write "<span style='color:#666'>" & thing & "</span><br/>"
			IF isObject(Application.Contents(Thing)) Then
				Application.Contents(Thing).Close
				Set Application.Contents(Thing) = Nothing
				Application.Contents(Thing) = Null
			ElseIF isArray(Application.Contents(Thing)) Then
				Set Application.Contents(Thing) = Nothing
				Application.Contents(Thing) = Null
			Else
				Application.Contents(Thing) = Null
			End IF
		End IF
	Next
	response.write "</div>"
End Function
'====================================================================
'数据库备份恢复,文件管理
'删除文件
'====================================================================
   if Request.form("whatdo")="DelFiles" then
    dim getFolders,getFiles,getFolder,getFile,getFolderCount,getFileCount
    Dim FSODel
    Set FSODel=Server.CreateObject("Scripting.FileSystemObject")
    getFolders=split(Request.form("folders"),", ")
    getFiles=split(Request.form("Files"),", ")
    getFolderCount=0
    getFileCount=0
    for each getFolder in getFolders
     if len(getPathList(getFolder)(1))>0 then
       session(CookieName&"_ShowMsg")=true
       session(CookieName&"_MsgText")="<span style=""color:#900"">“"&getFolder&"”</span> 文件夹内含有文件,无法删除!"
       Response.Redirect("mdb_files.asp?Smenu=Attachments")
     end if
     if FSODel.FolderExists(Server.MapPath(getFolder)) then
      FSODel.DeleteFolder Server.MapPath(getFolder),true
      getFolderCount=getFolderCount+1
     end if
    next
    for each getFile in getFiles
     if FSODel.FileExists(Server.MapPath(getFile)) then
      FSODel.DeleteFile Server.MapPath(getFile),true
      getFileCount=getFileCount+1
     end if
    next
    session(CookieName&"_ShowMsg")=true
    session(CookieName&"_MsgText")="有 <span style=""color:#900"">"&getFileCount&" 文件, "&getFolderCount&" 个文件夹</span> 被删除!"
	Call ShowAlert("删除成功~!","")
   end if
'====================================================================
'数据库备份恢复,文件管理
'获取文件图标
'====================================================================
Function getFileIcons(str) 
 dim FileIcon,Target
 Select Case str
  case ".jpg"
   FileIcon="jpg.gif"
  case ".gif"
   FileIcon="gif.gif"
  case ".bmp"
   FileIcon="bmp.gif"
  case ".png"
   FileIcon="png.gif"
 case ".zip"
   FileIcon="zip.gif"  
 case ".rar"
   FileIcon="rar.gif"  
 case ".swf"
   FileIcon="swf.gif"  
 case ".mdb"
   FileIcon="mdb.gif"  
 case ".doc"
   FileIcon="doc.gif"  
 case ".xls"
   FileIcon="xls.gif"  
 case ".pdf"
   FileIcon="pdf.gif"  
 case ".mbk"
   FileIcon="mbk.gif"
 case ".mp3"
   FileIcon="mp3.gif"
 case ".wmv"
   FileIcon="wma.gif"
 case ".wma"
   FileIcon="wma.gif"
 case else
   FileIcon="unknow.gif"
 end Select
 getFileIcons="<img border=""0"" src=""Images/file_icon/"&FileIcon&""" style=""margin:4px 3px -3px 0px""/>"
End Function
'====================================================================
'数据库备份恢复,文件管理
'获得路径的文件信息
'====================================================================
function getPathList(pathName)
 dim FSO,ServerFolder,getInfo,getInfos,tempS
 getInfo=""
		Set FSO=Server.CreateObject("Scripting.FileSystemObject")
		
		Set ServerFolder=FSO.GetFolder(Server.MapPath(pathName))
			Dim ServerFolderList,ServerFolderEvery
			Set ServerFolderList=ServerFolder.SubFolders
			tempS=""
			For Each ServerFolderEvery IN ServerFolderList
                getInfo=getInfo&tempS&ServerFolderEvery.Name
                tempS="*"
			Next
            getInfo=getInfo&"|"
			Dim ServerFileList,ServerFileEvery
			Set ServerFileList=ServerFolder.Files
			tempS=""
			For Each ServerFileEvery IN ServerFileList
                getInfo=getInfo&tempS&ServerFileEvery.Name
                tempS="*"
			Next
	Set FSO=Nothing
	getInfos=split(getInfo,"|")
	getPathList=getInfos
end function
'====================================================================
'数据库备份恢复,文件管理
'获取文件信息
'====================================================================
function getFileInfo(FileName)
 dim FSO,File,FileInfo(3)
 Set FSO=Server.CreateObject("Scripting.FileSystemObject")
 if FSO.FileExists(Server.MapPath(FileName)) then
   Set File=FSO.GetFile(Server.MapPath(FileName))
   FileInfo(0)=File.Size
   if FileInfo(0)/1000>1 then 
     FileInfo(0)=int(FileInfo(0)/1000)&" KB"
    else
     FileInfo(0)=FileInfo(0)&" Bytes"
   end if
   FileInfo(1)=lcase(right(FileName,4))
   FileInfo(2)=File.DateCreated
   FileInfo(3)=File.Type 
 end if
   getFileInfo=FileInfo
 Set FSO=Nothing
end function
'====================================================================
'根据类别的ID得到名字
'
'====================================================================
Function Get_Template_Column_Name(ID)   
Select Case ID
    Case "1" Get_Template_Column_Name="首页模板"
    Case "2" Get_Template_Column_Name="问卷列表模板"
    Case "3" Get_Template_Column_Name="问卷显示模板"
    Case "4" Get_Template_Column_Name="私有问卷页模板"
    Case "5" Get_Template_Column_Name="留言模板"
    Case "6" Get_Template_Column_Name="友情链接模板"
    Case "7" Get_Template_Column_Name="功能模板"
    Case "8" Get_Template_Column_Name="模板标签"
    Case "9" Get_Template_Column_Name="问卷后台预览模板"
End Select
End Function
'====================================================================
'结束组件函数
'
'====================================================================
Function pagend()
  set rs=nothing
  conn.close
  set conn=nothing
End Function
'====================================================================
'分页函数
'参数:目标页,单位,
'====================================================================
Function pageBox(page,unit,item_count,page_now,total)
  pageBox=pageBox&"当前第"&page_now&"页"
  pageBox=pageBox& "&nbsp;&nbsp;共"&item_count&""&unit&""
  if cint(page_now)=1 then
  pageBox=pageBox& "&nbsp;&nbsp;首页"
  else
  pageBox=pageBox& "&nbsp;&nbsp;<a href="""&page&"page=1"">首页</a>"
  end if
  if cint(page_now)>1 and cint(total)>1 then
  pageBox=pageBox& "&nbsp;&nbsp;<a href="""&page&"page="&page_now-1&""">上一页</a>"
  else
  pageBox=pageBox& "&nbsp;&nbsp;上一页"
  end if			
  if cint(page_now)<cint(total) then
  pageBox=pageBox& "&nbsp;&nbsp;<a href="""&page&"page="&page_now+1&""">下一页</a>"
  else
  pageBox=pageBox& "&nbsp;&nbsp;下一页"
  end if			
  if cint(page_now)<>cint(total) then
  pageBox=pageBox& "&nbsp;&nbsp;<a href="""&page&"page="&total&""">尾页</a>"
  else
  pageBox=pageBox& "&nbsp;&nbsp;尾页"
  end if
  pageBox=pageBox& "&nbsp;&nbsp;共"&total&"页"  
End Function

%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -