<%
Class JC_MainFunction

Private OXML,ObjStream,FSO
Private Sub Class_Initialize()
	Set OXML = server.CreateObject("MSXML2.XMLHTTP") 
	Set FSO  =  Server.CreateObject("Scripting.FileSystemObject")  
	Set ObjStream = Server.CreateObject("ADODB.Stream")
End Sub 

Private Sub Class_Terminate()
	Set OXML = Nothing 
	Set FSO  = Nothing
	Set ObjStream = Nothing
	If IsObject(Conn) Then Conn.Close : Set Conn = Nothing
End Sub  

Public Property get Version
	Version="fjmusic system 2006(website:www.0hao.cn  E-Mail:12jc17@163.com QQ:115000470)"
End Property

Public Function Execute(Command)
	If Not IsObject(Conn) Then ConnectionDatabase
	Set Execute = Conn.Execute(Command)
End Function

'随机字符串, LengthNum：符串长度
Public Function GetRandomCode(LengthNum)
	Dim Ran, i 
	
	GetRandomCode = ""
	For i = 1 To LengthNum
		Randomize
		Ran = CInt(Rnd * 2)
		Randomize
		If Ran = 0 Then
			Ran = CInt(Rnd * 25) + 97
			GetRandomCode = GetRandomCode & UCase(Chr(Ran))
		ElseIf Ran = 1 Then
			Ran = CInt(Rnd * 9)
			GetRandomCode = GetRandomCode & Ran
		ElseIf Ran = 2 Then
			Ran = CInt(Rnd * 25) + 97
			GetRandomCode = GetRandomCode & Chr(Ran)
		End If
	Next
End Function

Public Function IsExists(filespec) 
	Set FSO  =  Server.CreateObject("Scripting.FileSystemObject") 
	If (FSO.FileExists(server.MapPath(filespec))) Then
	IsExists = True
	Else
	IsExists = False
	End If
	Set FSO  =  Nothing
End Function

Public Function IsFolder(Folder) 
	Set FSO  =  Server.CreateObject("Scripting.FileSystemObject") 
	If  FSO.FolderExists(server.MapPath(Folder))  Then  
	IsFolder = True
	Else
	IsFolder = False
	End If
	Set FSO  =  Nothing
End Function

Public Function CreateFolder(Filepath)
	on error resume next
	fldr=""
	If IsExists(Filepath)=false then 
	GetNewsFold=split(Filepath,"/")
	For i=0 to Ubound(GetNewsFold)-1
	if fldr="" then
	fldr=GetNewsFold(i)
	else
	fldr=fldr&"\"&GetNewsFold(i)
	end if
	If IsFolder(fldr)=false then

	Dim fso, f
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	Set f = fso.CreateFolder(Server.MapPath(fldr))
	CreateFolder = f.Path
	Set f=nothing
	Set fso=nothing

	End if
	Next
	End if
End Function  

Public Function GetRndFileName(ByVal sExt)
	Dim sRnd
	Randomize
	sRnd = Int(900 * Rnd) + 100
	If Month(Now) < 10 Then c_month = "0" & Month(Now) Else c_month = Month(Now)
	If Day(Now) < 10 Then c_day = "0" & Day(Now) Else c_day = Day(Now)
	If Hour(Now) < 10 Then c_hour = "0" & Hour(Now) Else c_hour = Hour(Now)
	If Minute(Now) < 10 Then c_minute = "0" & Minute(Now) Else c_minute = Minute(Now)
	If Second(Now) < 10 Then c_second = "0" & Second(Now) Else c_second = Minute(Now)
	GetRndFileName = Year(Now) & c_month & c_day & c_hour & c_minute & c_second & "_" & sRnd & "." & GetFileExtName(sExt)
End Function

Public Function GetFileExtName(ByVal sName)
	Dim  Temp,FileName
	Temp = Split(sName, ".")
	FileName = Temp(UBound(Temp))
	If instr(FileName, "?")>0 then FileName=Left(FileName,instr(FileName, "?")-1)
	GetFileExtName = FileName
End Function

Function ChkQueryStr(ByVal str)
		On Error Resume Next
		If IsNull(str) Then
			ChkQueryStr = ""
			Exit Function
		End If
		str = Replace(str, "!", "")
		str = Replace(str, "]", "")
		str = Replace(str, "[", "")
		str = Replace(str, ")", "")
		str = Replace(str, "(", "")
		str = Replace(str, "|", "")
		str = Replace(str, "=", "")
		str = Replace(str, "'", "''")
		str = Replace(str, "%", "")
		str = Replace(str, "&", "")
		str = Replace(str, "#", "")
		str = Replace(str, "^", "")
		str = Replace(str, ">", "")
		str = Replace(str, "<", "")
		str = Replace(str, "&nbsp;", " ")
		str = Replace(str, "+", " ")
		str = Replace(str, " or ", "")
		str = Replace(str, " and ", "")
		ChkQueryStr = str
End Function
Function HTMLEncode(fString)
if not isnull(fString) then
    fString = Replace(fString, CHR(38), "&#38;")
    fString = replace(fString, ">", "&gt;")
    fString = replace(fString, "<", "&lt;")
    fString = Replace(fString, CHR(39), "&#39;")
    fString = Replace(fString, CHR(32), "&nbsp;")
    fString = Replace(fString, CHR(34), "&quot;")
    fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10), "<br/>")
    HTMLEncode = fString
end if
End Function
Function JSUrlEncode(ByVal str)
if not isnull(str) then
    str = Replace(str, CHR(32), "+")
    'str = Replace(str, CHR(34), "&quot;")
    str = replace(str, "'", "`")
    JSUrlEncode = str
end if
End Function

Public Function PrintSpace(vv)
	Dim v
	v = vv
	If v > 1024 Then
		v = v/1024
		If inStr(v,".") Then
			v = Left(v,inStr(v,".")+2)
		End If
		v = v & " M"
	Else
		If v<1 then v="0"&v
		v = v & " K"
	End If
	PrintSpace = v
End Function

End Class
%>