ASP Function in common use
2018-09-06 11:33
=======================
检测上页是否从本站提交
返回:True,False
=======================
FunctionIsSelfRefer()
DimsHttp_Referer,sServer_Name
sHttp_Referer=CStr(Request.ServerVariables(HTTP_REFERER))
sServer_Name=CStr(Request.ServerVariables(SERVER_NAME))
IfMid(sHttp_Referer,8,Len(sServer_Name))=sServer_NameThen
IsSelfRefer=True
Else
IsSelfRefer=False
EndIf
EndFunction
*****************************
创建文件目录
*****************************
DimFs,NewPath,DelPath,FPath,DelFPath
FunctionFsFolder(TName)
NewPath=Server.MapPath(Tname)
SetFs=Server.CreateObject(Scripting.FileSystemObject)
IfFs.FolderExists(NewPath)=TrueThen
Response.Write<script language=JavaScript>_
alert(有此文件夹名请重新命名);_
history.go(-1);_
</script>
Response.End
Else
Fs.CreateFolder(NewPath)
SetFs=Nothing
EndIf
EndFunction
*****************************
删除文件目录
*****************************
FunctionDelFolder(TName)
DelPath=Server.MapPath(TName)
SetFs=Server.CreateObject(Scripting.FileSystemObject)
IfFs.FolderExists(DelPath)=TrueThen
Fs.DeleteFolderDelPath,True
EndIf
SetFs=Nothing
EndFunction
***************************************
创建文件
***************************************
FunctionCreateFile(FName,strFile)
DimFPath,Os,Fs
FPath=Server.MapPath(FName)
SetFs=Server.CreateObject(Scripting.FileSystemObject)
SetOs=Fs.CreateTextFile(FPath,True,False)
Os.WritestrFile
Os.Close
SetOs=Nothing
SetFs=Nothing
EndFunction
***************************************
删除文件
***************************************
FunctionDelFile(Fname)
SetFs=Server.CreateObject(Scripting.FileSystemObject)
Fname=Server.MapPath(Fname)
Response.WriteFname
IfFs.FileExists(Fname)=FalseThen
ExitFunction
Else
Fs.DeleteFileFname,True
EndIf
SetFs=Nothing
EndFunction
*****************************
读取文件
*****************************
FunctionReadFile(Fname)
DimStrFile,Fs,Os
SetFs=Server.CreateObject(Scripting.FileSystemObject)
Fname=Server.MapPath(Fname)
IfFs.FileExists(Fname)=FalseThen
ReadFile=
ExitFunction
Else
SetOs=Fs.OpenTextFile(Fname,1,False,False)
StrFile=Os.ReadAll
Os.Close
SetOs=Nothing
Response.WriteStrFile
ReadFile=StrFile
EndIf
SetFs=Nothing
EndFunction
***------分页开始------
FunctionURLStr(FieldName,FieldValue)
Dimi
IfNotIsArray(FieldName)ThenExitFunction
Fori=0toUbound(FieldName)
URLStr=URLStrCstr(FieldName(i))=Cstr(FieldValue(i))
Next
EndFunction
FunctionPageList(iPageValue,iRetCount,iCurrentPage,FieldName,FieldValue)
DimUrl
DimPageCount 页总数
DimPageRoot 页列表头
DimPageFoot 页列表尾
DimOutStr
Url=URLStr(FieldName,FieldValue)
If(iRetCountModiPageValue)=0Then
PageCount=iRetCountiPageValue
Else
PageCount=(iRetCountiPageValue)+1
EndIf
IfiCurrentPage-4<=1 Then
PageRoot=1
Else
PageRoot=iCurrentPage-4
End If
If iCurrentPage+4>=PageCountThen
PageFoot=PageCount
Else
PageFoot=iCurrentPage+4
EndIf
OutStr=分页:iCurrentPage/PageCount页共iRetCount条
IfPageRoot=1Then
IfiCurrentPage=1Then
OutStr=OutStr9
OutStr=OutStr7
Else
OutStr=OutStr<a href=?page=1
OutStr=OutStrUrl
OutStr=OutStr title=\首页>9
OutStr=OutStr<a href=?page=iCurrentPage-1
OutStr=OutStrUrl
OutStr=OutStr title=\上页>7
EndIf
Else
OutStr=OutStr<a href=?page=1
OutStr=OutStrUrl
OutStr=OutStr title=\首页>9
OutStr=OutStr<a href=?page=iCurrentPage-1
OutStr=OutStrUrl
OutStr=OutStr title=\上页>7...
EndIf
Fori=PageRootToPageFoot
Ifi=Cint(iCurrentPage)Then
OutStr=OutStr[+Cstr(i)+]
Else
OutStr=OutStr<a href=?page=Cstr(i)
OutStr=OutStrUrl
OutStr=OutStr>[+Cstr(i)+]
EndIf
Ifi=PageCountThenExitFor
Next
IfPageFoot=PageCountThen
IfCint(iCurrentPage)=Cint(PageCount)Then
OutStr=OutStr8
OutStr=OutStr:
Else
OutStr=OutStr<a href=?page=iCurrentPage+1
OutStr=OutStrUrl
OutStr=OutStr title=\下页>8
OutStr=OutStr<a href=?page=PageCount
OutStr=OutStrUrl
OutStr=OutStr title=\尾页>:
EndIf
Else
OutStr=OutStr...<a href=?page=iCurrentPage+1
OutStr=OutStrUrl
OutStr=OutStr title=\下页>8
OutStr=OutStr<a href=?page=PageCount
OutStr=OutStrUrl
OutStr=OutStr title=\尾页>:
EndIf
OutStr=OutStr<INPUT TYPE=text class=in size=3 value=iCurrentPage onmouseover=this.focus();this.select() NAME=PGNumber><INPUT TYPE=button id=button1 name=button1 class=bot value= GO onclick=if(document.all.PGNumber.value>0document.all.PGNumber.value<=PageCount){window.location=?Page=+document.all.PGNumber.value+Url} onmouseover=this.focus() onfocus=this.blur() >
PageList=OutStr
EndFunction
文章标题:ASP Function in common use
文章链接:http://soscw.com/index.php/essay/9493.html