Metropoli BBS
VIEWER: logonfrm.asp MODE: TEXT (ASCII)
<% @ LANGUAGE=VBSCRIPT CODEPAGE = 1252 %>
<!--#include file="constant.inc" -->
<!--#include file="lib/session.inc" -->
<!--#include file="lib/logon.inc" -->
<!--#include file="lib/pageutil.inc" -->
<%
'=======================
' RedirectToRequest
' Redirects user to their originally requested URL
'
'=======================
Sub RedirectToRequest
	On Error Resume Next

    bstrPgReq = Session(bstrURLReq)
	Session(bstrURLReq) = 0

    If (bstrPgReq <> 0) Then
	If InStr(1, bstrPgReq, ".asp", vbTextCompare) Then
		' WARNING! No script after this line will be executed!
		Response.Redirect bstrPgReq
	End If
    End If

End Sub


'=======================
' MainLogon
' Authenticates, and logs on user
'
'=======================
Sub MainLogon

	On Error Goto 0

    urlIsNewWindow = Request.QueryString("isnewwindow")
	CheckSession

    ' Logoff if already logged on
	ClearSession
    SetSessionStuff

	bstrMailbox = Request.QueryString("mailbox")

	If Session(CURRENT_MAILBOX) <> bstrMailbox Then
        Session(CURRENT_MAILBOX) = bstrMailbox
		Response.Buffer = TRUE
		Response.Status = ("401 Unauthorized")
		Response.end
	End If

	If "" = bstrMailbox Then
		bAuthenticated = True
		Session(bstrAuthenticated) = False
	Else
		bAuthenticated = BAuthenticateUser
		Session(bstrAuthenticated) = bAuthenticated
	End If
	Set objRenderApp = Application(bstrRenderApp)

	If bAuthenticated Then

		If (BLogonUser(bstrMailbox)) Then

			If "" = bstrMailbox Then
				bstrMailbox = Empty
				If objRenderApp.ConfigParameter("Anonymous Access") = True Then
					bstrMailboxURL = "/root.asp?acs=anon"
				ElseIf objRenderApp.ConfigParameter("Publish GAL") = True Then
					bstrMailboxURL = "/finduser/root.asp?acs=anon"
				Else
					ReportErrorLoad L_errPageDisabled_ErrorMessage, bstrVirtRoot & "/logon.asp"
				End If
			Else
				bstrMailboxURL = "/root.asp"
			End If

            SessionGet
            OpenAllStores
            If Session("iStoreReq")<>null  Then
                InitPage Session("iStoreReq")
                Session("iStoreReq") = null
            End If
            If urlIsNewWindow="1" Then 'new logon window so close me 
                Response.Redirect(bstrVirtRoot & "/relogon.htm")            
            Else 'refresh callers location
               'If original request was for a different URL, send user on their way
                RedirectToRequest   ' Execution will end here if user redirected

                'Else we go to inbox/anon root page
	            Response.Redirect(bstrVirtRoot & bstrMailboxURL)
            End If
		End If	
	Else 
         Session.Abandon
		 ReportError1 L_errFailedToAuthenticate_ErrorMessage
	End If
   
End Sub
%>
<%MainLogon%>
[ RETURN TO DIRECTORY ]