<%
' 文件名称Common.asp 数据函数
' Ss简单网站管理系统-开源版 
'晴天设计www.xxzwz.com
' 您有什么好的意见或建议，别忘了Email:qtwebs@163.com
sub dbinit(databasepath)
		connstr = "Provider=Microsoft.Jet.OLEdb.4.0;Data Source=" & server.mappath(databasepath)							
		on error resume next
		set conn = server.createobject("adodb.connection")
		conn.open connstr
		If Err Then
    	Err.Clear
    	Set Conn = Nothing
    	Response.Write "数据库连接错误，请检查连接参数！"
    	Response.End
		End If
end sub

function db(byval sqlstr,byval sqltype)
select case sqltype
	case 0
		conn.Execute (sqlstr)
	case 1
		set db = conn.execute(sqlstr)
	case 2
		set db = server.createobject("Adodb.Recordset")
		db.open sqlstr, conn, 1, 1
	case 3:
		set db = server.createobject("Adodb.Recordset")
		db.open sqlstr, conn, 1, 3
	case 4:
		set db = server.createobject("Adodb.Recordset")
		db.open sqlstr, conn, 0, 1	
	end select
end function
Dim conn,connstr
call dbinit(""&SysRootDir&""&SiteDataPath&"")	


Public SiteTitle, SiteUrl, ComName, Address, ZipCode, Telephone,SeoTitle
Public Fax, Email, Keywords, Descriptions, Video, IcpNumber, MesViewFlag, SiteLogo, Comabout,Copyright,ICP
Sub SiteInfo()
Dim objDom,objnodes,loadResult
	'创建DOM对象 
set objDom=server.CreateObject("MicroSoft.XMLDom") 
objDom.async = False
'取得xml数据 
loadResult=objDom.load(Server.MapPath("/inc/sitedata.xml")) 
If Not loadResult Then
             Response.Write ("加载XML文件出错!")
               Response.End
End If
set objnodes=objDom.SelectSingleNode("siteinfo")
if Not IsNull(objnodes) then
SiteTitle=objnodes.childNodes(0).text
SiteUrl=objNodes.childNodes(1).text
ComName=objNodes.childNodes(2).text
Address=objNodes.childNodes(3).text
Email=objNodes.childNodes(4).text
Keywords=objNodes.childNodes(5).text
Descriptions=objNodes.childNodes(6).text
SiteLogo=objNodes.childNodes(7).text
Comabout=objNodes.childNodes(8).text
Copyright=objNodes.childNodes(9).text
ICP=objNodes.childNodes(10).text
end if
end sub
'templatepath=SysRootDir&templatepath

Function writer(str)
response.Write(str)
end function
Function Alert(Message,types)
	Select case types
	case "g-1"
	response.Write "<script language='JavaScript'>alert('"&Message&"');" & "history.go(-1)" & ";</script>"
	case "b0"
    response.Write "<script language='JavaScript'>alert('"&Message&"');" & "history.back()" & ";</script>"
	case "b-1"
	response.Write "<script language='JavaScript'>alert('"&Message&"');" & "history.back(-1)" & ";</script>"
	case else
		if instr(types,"$")<1 then
		response.Write "<script language='JavaScript'>alert('"&Message&"');" & "location.replace('"&types&"')" & ";</script>"
		else
		response.Write "<script language='JavaScript'>alert('"&Message&"');" & "location.href='"&replace(types,"$","",5)&"'" & ";</script>"
		end if
	end select	
End Function

function URLDecode(strIn)
URLDecode = ""
Dim sl: sl = 1
Dim tl: tl = 1
Dim key: key = "%"
Dim kl: kl = Len(key)
sl = InStr(sl, strIn, key, 1)
Do While sl>0
If (tl=1 And sl<>1) Or tl<sl Then
URLDecode = URLDecode & Mid(strIn, tl, sl-tl)
End If
Dim hh, hi, hl
Dim a
Select Case UCase(Mid(strIn, sl+kl, 1))
Case "U":'Unicode URLEncode
a = Mid(strIn, sl+kl+1, 4)
URLDecode = URLDecode & ChrW("&H" & a)
sl = sl + 6
Case "E":'UTF-8 URLEncode
hh = Mid(strIn, sl+kl, 2)
a = Int("&H" & hh)'ascii码
If Abs(a)<128 Then
sl = sl + 3
URLDecode = URLDecode & Chr(a)
Else
hi = Mid(strIn, sl+3+kl, 2)
hl = Mid(strIn, sl+6+kl, 2)
a = ("&H" & hh And &H0F) * 2 ^12 Or ("&H" & hi And &H3F) * 2 ^ 6 Or ("&H" & hl And &H3F)
If a<0 Then a = a + 65536
URLDecode = URLDecode & ChrW(a)
sl = sl + 9
End If
Case Else:'Asc URLEncode
hh = Mid(strIn, sl+kl, 2)'高位
a = Int("&H" & hh)'ascii码
If Abs(a)<128 Then
sl = sl + 3
Else
hi = Mid(strIn, sl+3+kl, 2)'低位
a = Int("&H" & hh & hi)'非ascii码
sl = sl + 6
End If
URLDecode = URLDecode & Chr(a)
End Select
tl = sl
sl = InStr(sl, strIn, key, 1)
Loop
URLDecode = URLDecode & Mid(strIn, tl)
End function
%>
