<%
Dim SysHost, RootHost
Dim CurrentHostUrl, CurrentReallyDirectory
Dim SiteS, SiteT, SiteW, SiteX, SiteU

SysHost = GetSysHost()
RootHost = GetRootHost()

Function GetSysHost()
	Call GetHost
	u = CurrentHostUrl
	if Request.ServerVariables("HTTPS") <> "on" Then
		If Request.ServerVariables("HTTPS") = True Then
			u = "https://" & u
		Else 
			u = "http://" & u
		End If
	else
		u = "https://" & u
	end If
	GetSysHost = u
End Function

Function GetRootHost()
	Call GetHost
	If Not IsObject(PublicObjFSO) Then Set PublicObjFSO = Server.CreateObject("Scripting.FileSystemObject")
	t = LCase(Replace(PublicObjFSO.GetFolder(SiteW & "../").Path, "\", "/"))
	x = Right(SiteS, Len(SiteS) - Len(t))
	u = Replace(SiteT, x, "")

	If u = LCase(Request.ServerVariables("HTTP_HOST")) Then
		u = ""
	Else
		If Right(u, 1) <> "/" Then u = u & "/"
		u = replace(u, LCase(Request.ServerVariables("HTTP_HOST")), "")
	End If
	GetRootHost = u
End Function

Function GetHost()
	On Error Resume Next
	Dim PhysicsPath
	PhysicsPath = Server.MapPath(".") & "\"
	If Not IsObject(PublicObjFSO) Then Set PublicObjFSO = Server.CreateObject("Scripting.FileSystemObject")
	If PublicObjFSO.FolderExists(PhysicsPath & "Ke01\") Then
		PhysicsPath = PhysicsPath
	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\Ke01\") Then
		PhysicsPath = PhysicsPath & "..\"
	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\..\Ke01\") Then
		PhysicsPath = PhysicsPath & "..\..\"
	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\..\..\Ke01\") Then
		PhysicsPath = PhysicsPath & "..\..\..\"
	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\..\..\..\Ke01\") Then
		PhysicsPath = PhysicsPath & "..\..\..\..\"
	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\..\..\..\..\Ke01\") Then
		PhysicsPath = PhysicsPath & "..\..\..\..\..\"
	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\..\..\..\..\..\Ke01\") Then
		PhysicsPath = PhysicsPath & "..\..\..\..\..\..\"
	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\..\..\..\..\..\..\Ke01\") Then
		PhysicsPath = PhysicsPath & "..\..\..\..\..\..\..\"
	End If
	Set fso = Nothing

	PhysicsPath = PublicObjFSO.GetFolder(PhysicsPath).Path
	If Right(PhysicsPath, 1) <> "\" Then PhysicsPath = PhysicsPath & "\"
	CurrentReallyDirectory = PhysicsPath
	Err.Clear

	SiteS = LCase(Replace(Request.ServerVariables("PATH_TRANSLATED"), "\", "/"))
	SiteT = LCase(Request.ServerVariables("HTTP_HOST") & Split(Request.ServerVariables("URL"), "?")(0))
	SiteW = LCase(Replace(PhysicsPath, "\", "/"))
	SiteX = Right(SiteS, Len(SiteS) - Len(SiteW))
	SiteU = Replace(SiteT, SiteX, "")
	CurrentHostUrl = SiteU
End Function

'Function GetCurrentHost()
'	On Error Resume Next
'	Dim PhysicsPath
'	PhysicsPath = Server.MapPath(".") & "\"
'	If Not IsObject(PublicObjFSO) Then Set PublicObjFSO = Server.CreateObject("Scripting.FileSystemObject")
'
'	If PublicObjFSO.FolderExists(PhysicsPath & "Ke01\") Then
'		PhysicsPath = PhysicsPath
'	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\Ke01\") Then
'		PhysicsPath = PhysicsPath & "..\"
'	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\..\Ke01\") Then
'		PhysicsPath = PhysicsPath & "..\..\"
'	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\..\..\Ke01\") Then
'		PhysicsPath = PhysicsPath & "..\..\..\"
'	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\..\..\..\Ke01\") Then
'		PhysicsPath = PhysicsPath & "..\..\..\..\"
'	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\..\..\..\..\Ke01\") Then
'		PhysicsPath = PhysicsPath & "..\..\..\..\..\"
'	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\..\..\..\..\..\Ke01\") Then
'		PhysicsPath = PhysicsPath & "..\..\..\..\..\..\"
'	ElseIf PublicObjFSO.FolderExists(PhysicsPath & "..\..\..\..\..\..\..\Ke01\") Then
'		PhysicsPath = PhysicsPath & "..\..\..\..\..\..\..\"
'	End If
'	Set fso = Nothing
'
'	PhysicsPath = PublicObjFSO.GetFolder(PhysicsPath).Path
'	If Right(PhysicsPath, 1) <> "\" Then PhysicsPath = PhysicsPath & "\"
'	CurrentReallyDirectory = PhysicsPath
'	
'	Err.Clear
'	If ZC_PERMANENT_DOMAIN_ENABLE = True Then
'		CurrentHostUrl = ZC_BLOG_HOST
'		GetCurrentHost = CurrentHostUrl
'		If Err.Number = 0 Then
'			Exit Function
'		End If
'	End If
'
'	Dim s, t, u, i, w, x
'	'Kangle 3.0下Request.ServerVariables("URL")含有QueryString
'	s = LCase(Replace(Request.ServerVariables("PATH_TRANSLATED"), "\", "/"))
'	t = LCase(Request.ServerVariables("HTTP_HOST") & Split(Request.ServerVariables("URL"), "?")(0))
'	w = LCase(Replace(PhysicsPath, "\", "/"))
'	x = Right(s, Len(s) - Len(w))
'	u = Replace(t, x, "")

'	'Kangle的返回值为True\False..
'	if Request.ServerVariables("HTTPS") <> "on" Then
'		If Request.ServerVariables("HTTPS") = True Then
'			u = "https://" & u
'		Else 
'			u = "http://" & u
'		End If
'	else
'		u = "https://" & u
'	end If
'
'	If Right(u, 1) <> "/" Then u = u & "/"
'	CurrentHostUrl = u
'	GetCurrentHost = CurrentHostUrl
'End Function
%>