Attribute VB_Name = "mdlLogin"
Public SSOTicket As String
Public InfoPort As String
Public InfoHost As String
Public MusHost As String
Public ExternalTexts As String
Public ExternalVariables As String
Public MusPort As String
Public DCR As String

Public Function DefinedConnection(Username As String, Password As String, Hotel As String)
On Error Resume Next
' Variables.
Dim SecurityTicket As String
Dim StrHTML As String
' Get the URL source of the security_check.
StrHTML = GetUrlSource("https://" & Hotel & "account/login?service=%2Fsecurity_check")
' Split the SecurityTicket from the StrHTML.
SecurityTicket = Split(StrHTML, "<input type=""hidden"" name=""loginTicket"" value=""")(1)
SecurityTicket = Split(SecurityTicket, """ />")(0)
' Error control.
On Error GoTo LoggedIn
' Log you in.
frmMain.Web.Navigate "https://" & Hotel & "account/submit?loginTicket=" & SecurityTicket & "&page=/&service=/security_check&credentials.username=" & Username & "&credentials.password=" & Password
Exit Function
LoggedIn:
frmMain.Web.Navigate "https://" & Hotel & "client"
End Function

Public Function SplitClientInfo(SourceCode As String)
' Split all the loader info here.
SSOTicket = Split(SourceCode, ";sso.ticket=")(1)
SSOTicket = Split(SSOTicket, Chr(34))(0)

InfoHost = Split(SourceCode, "value=""connection.info.host=")(1)
InfoPort = Split(InfoHost, ";connection.info.port=")(1)
InfoPort = Split(InfoPort, """>")(0)
InfoHost = Split(InfoHost, ";")(0)


MusHost = Split(SourceCode, "value=""connection.mus.host=")(1)
MusPort = Split(MusHost, ";connection.mus.port=")(1)
MusPort = Split(MusPort, """>")(0)
MusHost = Split(MusHost, ";")(0)

ExternalVariables = Split(SourceCode, "value=""external.variables.txt=")(1)
ExternalTexts = Split(ExternalVariables, ";external.texts.txt=")(1)
ExternalTexts = Split(ExternalTexts, """>")(0)
ExternalVariables = Split(ExternalVariables, ";")(0)

DCR = Split(SourceCode, "name=""src"" value=""")(1)
DCR = Split(DCR, """>")(0)

frmMain.sckClient.LocalPort = InfoPort
frmMain.sckClient.Listen
frmMain.sckServer.RemoteHost = InfoHost
frmMain.sckServer.RemotePort = InfoPort

Call LoadingPage
End Function

Public Function LoadingPage()
' Create and load the browser.
Open App.Path & "\loader.html" For Output As #1
    Print #1, "<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN>"
    Print #1, "<meta http-equive = content-type content = text/html; charset= iso-8859-1>"
    Print #1, "<html>"
    Print #1, "<head>"
    Print #1, "<title>FookIT! Version 3 - By Dean - http://script-o-matic.net</title>"
    Print #1, "</head>"
    Print #1, "<body bgcolor=""#000000"">"
    Print #1, "<object classid=""clsid:166B1BCA-3F9C-11CF-8075-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0"" id=""habbo"" width=""720"" height=""540"">"
    Print #1, "<param name=""src"" value=" & DCR & ">"
    Print #1, "<param name=""swRemote"" value=""swSaveEnabled='true' swVolume='true' swRestart='false' swPausePlay='false' swFastForward='false' swTitle='Habbo Hotel' swContextMenu='true' "">"
    Print #1, "<param name=""swStretchStyle"" value=""none"">"
    Print #1, "<param name=""swText"" value="""">"
    Print #1, "<param name=""bgColor"" value=""#000000"">"
    Print #1, "<param name=""sw6"" value=""use.sso.ticket=1;sso.ticket=" & SSOTicket & """>"
    Print #1, "<param name=""sw2"" value=""connection.info.host=" & "fookit" & ";connection.info.port=" & InfoPort & """>"
    Print #1, "<param name=""sw4"" value=""connection.mus.host=" & MusHost & ";connection.mus.port=" & MusPort & """>"
    Print #1, "<param name=""sw3"" value=""client.reload.url=http://www.habbo.co.uk/client"">"
    Print #1, "<param name=""sw1"" value=""site.url=http://www.habbo.co.uk;url.prefix=http://www.habbo.co.uk"">"
    Print #1, "<param name=""sw5"" value=""external.variables.txt=" & ExternalVariables & ";external.texts.txt=" & ExternalTexts & """>"
    Print #1, "<embed src=""" & DCR & """ bgColor=""#000000"" width=""720"" height=""540"" swRemote="" swSaveEnabled='true' swVolume='true' swRestart='false' swPausePlay='false' swFastForward='false' swTitle='Habbo Hotel' swContextMenu='true' "" swStretchStyle=""none"" swText="""" type=""application/x-director"" pluginspage=""http://www.macromedia.com/shockwave/download/"""
    Print #1, "sw6 = ""use.sso.ticket=1;sso.ticket=" & SSOTicket & """"
    Print #1, "sw2 = ""connection.info.host=" & "fookit" & ";connection.info.port=" & InfoPort & ""
    Print #1, "sw4 = ""connection.mus.host=" & MusHost & ";connection.mus.port=" & MusPort & ""
    Print #1, "sw3 = ""client.reload.url=http://www.habbo.co.uk/client"""
    Print #1, "sw1 = ""site.url=http://www.habbo.co.uk;url.prefix=http://www.habbo.co.uk"""
    Print #1, "sw5=""external.variables.txt=" & ExternalVariables & ";external.texts.txt=" & ExternalTexts & """ ></embed>"
    Print #1, "</embed>"
    Print #1, "</object>"
    Print #1, "</body>"
    Print #1, "</html>"
Close #1
OpenBrowser App.Path & "\loader.html", 1
End Function
