<%
Function BuildFile(ByVal sFile, ByVal sContent)
        Dim oFSO, oStream,oFile
            Set oFSO = server.CreateObject("Scripting.FileSystemObject")
			  
			     oFile = Left(sFile, InStrRev(LCase(sFile), "\")-1)
			  if oFSO.FolderExists(oFile)=false then
			     oFSO.CreateFolder(oFile)
			  end if
			  
            Set oStream = oFSO.CreateTextFile(sFile, True)
            oStream.Write sContent
            oStream.Close
            Set oStream = Nothing
            Set oFSO = Nothing
End Function

Function ReadTemplate(TemplateName)
    Dim objFSO,objMyFSO
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Set objMyFSO = objFSO.OpenTextFile(Server.MapPath(TemplateName),1,True)
    ReadTemplate = objMyFSO.ReadAll'&info()
    objMyFSO.Close
    Set objMyFSO = Nothing
    Set objFSO = Nothing
End Function

function checklen(str) '判断字数多少
dim i,j,num,eng,chn
for i=1 to len(str)
j=mid(str,i,1)
if asc(j)>=48 and asc(j)<=57 then
num=num+1
elseif asc(j)>=65 and asc(j)<=122 then
eng=eng+1
else
chn=chn+2
end if
next
checklen=num+eng+chn
end function

'function info()
'dim str
'str=chr(60)
'str=str&chr(33)
'str=str&chr(45)
'str=str&chr(45)
'str=str&chr(45286)
'str=str&chr(51368)
'str=str&chr(52217)
'str=str&chr(54224)
'str=str&chr(41914)
'str=str&chr(50911)
'str=str&chr(54466)
'str=str&chr(46069)
'str=str&chr(52164)
'str=str&chr(47524)
'str=str&chr(55287)
'str=str&chr(51922)
'str=str&chr(32)
'str=str&chr(45)
'str=str&chr(32)
'str=str&chr(81)
'str=str&chr(81)
'str=str&chr(58)
'str=str&chr(50)
'str=str&chr(57)
'str=str&chr(51)
'str=str&chr(49)
'str=str&chr(51)
'str=str&chr(56)
'str=str&chr(52)
'str=str&chr(54)
'str=str&chr(45)
'str=str&chr(45)
'info=str&chr(62)
'end function

function leftstr(str,leftnum)   '获得指定位数的内容
dim i,j,num,eng,chn
for i=1 to len(str)
j=mid(str,i,1)
if asc(j)>=48 and asc(j)<=57 then
num=num+1
elseif asc(j)>=65 and asc(j)<=122 then
eng=eng+1
else
chn=chn+2
end if
  if num+eng+chn>int(leftnum) then
  exit for
  end if
  leftstr=leftstr&j
next
end function

Function RemoveHTML(strHTML)
Dim objRegExp, Matche, Matches   
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<.+?>"
Set Matches = objRegExp.Execute(strHTML)
For Each Matche in Matches   
     strHtml=Replace(strHTML,Matche.Value,"")
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
End Function

function HTMLcode(fString)
if not isnull(fString) then
    fString = replace(fString, ">", "&gt;")
    fString = replace(fString, "<", "&lt;")

    fString = Replace(fString, CHR(32), "<I></I>&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), "<br>")
    fString = Replace(fString, CHR(10), "<br>")
    HTMLcode = fString
end if
end function
%>