<%
'**********读IP函数*************
Function GetIP()			
	GetIp = Request.ServerVariables("HTTP_X_FORWARDED_FOR") 
	If GetIp = "" Then GetIp = Request.ServerVariables("REMOTE_ADDR") 
End Function
'*************判断Email格式*************
function IsValidEmail(email) 
dim names, name, i, c 
IsValidEmail = true 
names = Split(email, "@") 
if UBound(names) <> 1 then 
IsValidEmail = false 
exit function 
end if 
for each name in names 
if Len(name) <= 0 then 
IsValidEmail = false 
exit function 
end if 
for i = 1 to Len(name) 
c = Lcase(Mid(name, i, 1)) 
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then 
IsValidEmail = false 
exit function 
end if 
next 
if Left(name, 1) = "." or Right(name, 1) = "." then 
IsValidEmail = false 
exit function 
end if 
next 
if InStr(names(1), ".") <= 0 then 
IsValidEmail = false 
exit function 
end if 
i = Len(names(1)) - InStrRev(names(1), ".") 
if i <> 2 and i <> 3 then 
IsValidEmail = false 
exit function 
end if 
if InStr(email, "..") > 0 then 
IsValidEmail = false 
end if 
end function
'*************HTML文章转换*************
Function RemoveHTML(strHTML) 
	Dim objRegExp, Match, Matches 
	Set objRegExp = New Regexp 
	objRegExp.IgnoreCase = True 
	objRegExp.Global = True 
	objRegExp.Pattern = "<.+?>"  
	Set Matches = objRegExp.Execute(strHTML) 
	For Each Match in Matches 
	strHtml=Replace(strHTML,Match.Value,"") 
	Next 
	RemoveHTML=strHTML 
	Set objRegExp = Nothing 
	set Matches=nothing
End Function 

Function EnCodeHtml(str)
	str = Replace(str, vbcrlf, "<br />")
	str = Replace(str, "　", "&nbsp;&nbsp;")
	str = Replace(str, " ", "&nbsp;")
	Str = Replace(Str, ">", "&gt;")
	Str = Replace(Str, "<", "&lt;")
	EnCodeHtml = str
End Function

Function DeCodeHtml(str)
	Str = Replace(Str, "&gt;", ">")
	Str = Replace(Str, "&lt;", "<")
	str = Replace(str, "&nbsp;", " ")
	str = Replace(str, "&nbsp;&nbsp;", "　")
	DeCodeHtml = str
End Function

Function ShowHtml(str)
	Str = Replace(Str, "&gt;", ">")
	Str = Replace(Str, "&lt;", "<")
	str = Replace(str, "&nbsp;", " ")
	str = Replace(str, "&nbsp;&nbsp;", "　")
	ShowHtml = str
End Function

'*************全球唯一标识码*************
Function GetGUID()
	Dim oTypeLib
	Set oTypeLib = CreateObject("Scriptlet.TypeLib")
	GetGUID = Trim(oTypeLib.Guid)
	GetGUID = Mid(GetGUID, 2, Len(GetGUID) - 4)
	GetGUID = Replace(GetGUID,"-","")
	GetGUID = LCase(GetGUID)
End Function
Dim sGuid
sGuid = GetGuid()

'****************************************************
Class Snkey
 '***************时间格式转成数字*********************
Public Function FormatTime(DateTime,Format) 
  select case Format
  case "1"
    FormatTime=""&year(DateTime)&"年"&month(DateTime)&"月"&day(DateTime)&"日"
  case "2"
    FormatTime=""&month(DateTime)&"月"&day(DateTime)&"日"
  case "3" 
    FormatTime=""&year(DateTime)&"/"&month(DateTime)&"/"&day(DateTime)&""
  case "4"
    FormatTime=""&month(DateTime)&"/"&day(DateTime)&""
  case "5"
    FormatTime=""&month(DateTime)&"月"&day(DateTime)&"日"&FormatDateTime(DateTime,4)&""
  case "6"
     temp="周日,周一,周二,周三,周四,周五,周六"
     temp=split(temp,",") 
     FormatTime=temp(Weekday(DateTime)-1)
  case "7"  
   dYear   =   Year(date) 
   dMonth   =   Month(date) 
   dDay   =   Day(date) 
  FormatTime=   dYear&Right( "0"&dMonth, "2 ")&Right( "0"&dDay, "2 ") 

case Else
  FormatTime=DateTime
  end select
 End Function
 '***************IP转换*********************
Public Function CLngIP(ByVal asNewIP) 
Dim lnResults 
Dim lnIndex 
Dim lnIpAry 
lnIpAry = Split(asNewIP, ".", 82) 
For lnIndex = 0 To 3 
If Not lnIndex = 3 Then 
lnIpAry(lnIndex) = lnIpAry(lnIndex) * (256 ^ (3 - lnIndex)) 
End If 
lnResults = lnResults + lnIpAry(lnIndex) 
Next 
CLngIP = lnResults 
End Function 
'***************数字转IP算法开始***************
Public Function CStrIP(ByVal anNewIP)
    Dim lsResults
    Dim lnTemp
    Dim lnIndex
    For lnIndex = 3 To 0 Step -1
        lnTemp = Int(anNewIP / (256 ^ lnIndex))
        lsResults = lsResults & lnTemp & "."
        anNewIP = anNewIP - (lnTemp * (256 ^ lnIndex))
    Next
    lsResults = Left(lsResults, Len(lsResults) - 1)
    CStrIP = lsResults
End Function
'############################################
End Class

'*********提示信息******************
Function Alert(message,gourl) 
    message = replace(message,"'","\'")
    If gourl="-1" then
        Response.Write ("<script language=javascript>alert('" & message & "');history.go(-1)</script>")
    ElseIf gourl="-2" then
        Response.Write ("<script language=javascript>alert('" & message & "');history.go(-2)</script>")
    ElseIf gourl="-3" then
        Response.Write ("<script language=javascript>alert('" & message & "');window.close();</script>")
    Else
        Response.Write ("<script language=javascript>alert('" & message & "');location='" & gourl &"'</script>")
    End If
    Response.End()
End Function

Function backurl(goourl) 
    If goourl="-1" then
        Response.Write ("<script language=javascript>history.go(-1)</script>")
    ElseIf goourl="-2" then
        Response.Write ("<script language=javascript>history.go(-2)</script>")
    Else
        Response.Write ("<script language=javascript>location='" & goourl &"'</script>")
    End If
    Response.End()
End Function
'############################################
Function myHotel(cdcc,cddd)
Dim oRshhtt,sqlhhtt
	sqlhhtt= "Select TOP 1 Id,Hotelname FROM [HotelList] where Id= "&cdcc
	Set oRshhtt= Server.CreateObject("ADODB.Recordset")
	oRshhtt.open sqlhhtt,oconn,1,1
	if oRshhtt.eof and oRshhtt.bof then
	Response.Write "0"
	Else
	select case cddd
	case 1 Response.Write ""&oRshhtt(0)&""
	case 2 Response.Write ""&left(oRshhtt(1),5)&".."
	End select
	End if
	oRshhtt.close
	set oRshhtt=nothing
end Function


'############################################
Function Airname(aabb,bbcc)
Dim oRsair,sqlair
	sqlair= "Select TOP 1 Id,Airname,Airpic FROM [AirList] where Id= "&aabb
	Set oRsair= Server.CreateObject("ADODB.Recordset")
	oRsair.open sqlair,oconn,1,1
	if oRsair.eof and oRsair.bof then
	Response.Write "0"
	Else
	select case bbcc
	case 1 Response.Write ""&oRsair(1)&""
	case 2 Response.Write "<img src="&oRsair(2)&">"
	End select
	End if
	oRsair.close
	set oRsair=nothing
end Function
%>