application.cfc:
<!---
Filename: Application.cfc
Created by: Raymond Camden ([email protected])
Please Note: Executes for every page request
--->
<cfcomponent output="false">
<!--- Name the application. --->
<cfset this.name="NBPTS">
<!--- Turn on session management. --->
<cfset this.sessionManagement="true">
<!--- set path to cfform.js --->
<cfparam name="Request.CFFORM_JS_Lib" type="string" default="http://76.12.181.86/CFIDE/scripts/cfform.js" />
<!--- function: onApplicationStart --->
<cffunction name="onApplicationStart" output="false" returnType="void">
<!--- Any variables set here can be used by all of the application's pages --->
<cfset APPLICATION.dataSource = "ebwebwork">
<cfset APPLICATION.companyName = "NBPTS">
</cffunction>
<!--- function: onSessionStart --->
<cffunction name="onSessionStart" returntype="void">
<!--- defined all session variables, so they will always exist ---->
<cfset session.auth.isLoggedIn = "false">
<cfset session.auth.UserID = "">
<cfset session.auth.Honorific = "">
<cfset session.auth.FirstName = "">
<cfset session.auth.LastName = "">
<cfset session.auth.Credential = "">
<cfset session.auth.Organization = "">
<cfset session.auth.Address = "">
<cfset session.auth.City = "">
<cfset session.auth.State = "">
<cfset session.auth.ZIP = "">
<cfset session.auth.Telephone = "">
<cfset session.auth.FAX = "">
<cfset session.auth.UserEmail = "">
<cfset session.auth.UserWebSite = "">
<cfset session.auth.UserPassword = "">
<cfset session.auth.UserRoleID = "">
</cffunction>
<!--- close function: onSessionStart --->
<!--- function: onRequestStart --->
<cffunction name="onRequestStart" output="false" returnType="void">
<cfset var secureDirectories = "temp">
<cfif listFindNoCase(secureDirectories,listFirst(cgi.script_name,"/"))
and session.auth.isLoggedIn is False>
<cfinclude template="LoginForm.cfm">
<cfabort>
</cfif>
<!--- if query_string contains cast(, then abort! --->
<cfif cgi.query_string contains "cast(">
<cfabort>
</cfif>
<!--- end abort cast --->
<cfset request.encryptionKey = "xxxxx">
</cffunction>
<!--- close function: onRequestStart --->
</cfcomponent>
loginCheck.cfm:
<!---
Filename: LoginCheck.cfm
Created by: Nate Weiss (NMW)
Purpose: Validates a user's UserPassword entries
Please Note Included by LoginForm.cfm
--->
<cfset APPLICATION.dataSource = "ebwebwork">
<!--- Make sure we have Login name and UserPassword --->
<cfparam name="FORM.UserEmail" type="string" />
<cfparam name="FORM.UserPassword" type="string" />
<!--- Find record with this UserEmail/UserPassword --->
<!--- If no rows returned, UserPassword not valid --->
<cfquery name="getUser" datasource="#APPLICATION.dataSource#">
SELECT UserID, FirstName, UserRoleID
FROM tbl_NBPTS_Principals
WHERE UserEmail = <cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.UserEmail#" maxlength="255">
AND UserPassword = <cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.UserPassword#" maxlength="255">
</cfquery>
<!--- If the UserEmail and UserPassword are correct --->
<cfif getUser.recordCount eq 1>
<!--- Remember user's logged-in status, plus --->
<!--- UserID and First Name, in structure --->
<cfset SESSION.auth = structNew()>
<cfset SESSION.auth.isLoggedIn = "Yes">
<cfset SESSION.auth.UserID = getUser.UserID>
<cfset SESSION.auth.FirstName = getUser.firstName>
<cfset SESSION.auth.UserRoleID = getUser.UserRoleID>
<cfset SESSION.auth.UserEmail= FORM.UserEmail>
<!--- Now that user is logged in, send them --->
<!--- to whatever page makes sense to start --->
<cflocation url="/">
</cfif>
loginForm.cfm:
<!---
Filename: LoginForm.cfm
Created by: Nate Weiss (NMW)
Purpose: Presented whenever a user has not logged in yet
Please Note Included by Application.cfc
--->
<!--- If the user is now submitting Login form, --->
<!--- Include Login Check code to validate user --->
<cfif isDefined("FORM.UserEmail")>
<cfinclude template="LoginCheck.cfm">
</cfif>
<cfinclude template="/SiteHeader.cfm" />
<!-- begin row1 -->
<div id="row1">
<!-- begin row1content_left -->
<div class="row1content_left">
<img src="/img/row1_photo1.jpg" width="582" height="157" alt="NBPTS" class="border0" />
</div>
<!-- /row1content_left -->
<!-- begin row1content_right -->
<div class="row1content_right">
</div>
<!-- /row1content_right -->
<!-- end row1 -->
</div>
<!-- begin row2 -->
<div id="row2">
<!--- Place cursor in "UserEmail" field when page loads--->
<body onLoad="document.LoginForm.UserEmail.focus();">
<!--- Start Login Form --->
<!--- note that the scriptsrc is defined in application.cfc --->
<cfform scriptsrc="#Request.CFFORM_JS_LIB#" action="#CGI.SCRIPT_NAME#" name="LoginForm" method="post">
<!--- Make the UserEmail and UserPassword fields required --->
<input type="hidden" name="UserEmail_required">
<input type="hidden" name="UserPassword_required">
<p> <strong>Your Email Address:</strong><br />
<!--- Text field for UserEmail --->
<cfinput
type="text"
name="UserEmail"
size="20"
value=""
maxlength="20"
required="Yes"
message="Please type your UserEmail first."></p>
<p><strong>Your Password:</strong><br />
<!--- Text field for UserPassword --->
<cfinput
type="password"
name="UserPassword"
size="12"
value=""
maxlength="20"
required="Yes"
message="Please type your UserPassword first."></p>
<input type="submit" value="Enter">
</cfform>
<!-- end row2 -->
</div>
<cfinclude template="/SiteFooter.cfm" />
|