% '************************************************************************* ' ASP Scripting: ' Filename: library_user_data_validation_functions.asp ' Written by: Wilbert Madarang ' Date: March 16, 2003 '************************************************************************* ' Description: This function consists of a series of functions for ' performing user data validation. ' Modification: '************************************************************************* %> <% '************************************************************** ' FUNCTION: parseData ' DESCRIPTION: Parses information MemberShip Information ' PARAMETERS: none ' RETURNS: none '************************************************************** ' SIDE-EFFECTS: Local Variables are Populated '************************************************************** Function parseData() 'UserId strUserId = Request( "userId" ) 'Parse Data strEmail = Request("email") strFirstname = Request( "firstname" ) strLastname = Request( "lastname" ) strConfirmEmail = Request( "confirm_email" ) strPassword = Request( "password" ) strConfirmPassword = Request( "confirm_password" ) strSecretPhrase = Request( "secret_phrase" ) strSecretPhraseHint = Request( "secret_phrase_hint" ) 'Address strAddress = Request( "address" ) strCity = Request( "city" ) strProvince = Request( "province" ) strPostalCode = Request( "postal_code" ) strCountry = Request( "country" ) 'ay111105 Add referring code strReferCode = Request ("refer_code") End Function '************************************************************** ' FUNCTION: isAllRequiredDataAvailable ' DESCRIPTION: Checks if All Required Data Available ' PARAMETERS: none ' RETURNS: returns Fail '************************************************************** ' SIDE-EFFECTS: Local Variables are Populated '************************************************************** Function isAllRequiredDataAvailable() bReturn = true If IsNull( LEN(strEmail) ) OR LEN(strEmail) = 0 Then bReturn = false Elseif IsNull( LEN(strConfirmEmail) ) OR LEN(strConfirmEmail) = 0 Then bReturn = false Elseif IsNull( LEN(strFirstname) ) OR LEN(strFirstname) = 0 Then bReturn = false Elseif IsNull( LEN(strLastname) ) OR LEN(strLastname) = 0 Then bReturn = false Elseif IsNull( LEN(strPassword) ) OR LEN(strPassword) = 0 Then bReturn = false Elseif IsNull( LEN(strConfirmPassword) ) OR LEN(strConfirmPassword) = 0 Then bReturn = false Elseif IsNull( LEN(strSecretPhrase) ) OR LEN(strSecretPhrase) = 0 Then bReturn = false Elseif IsNull( LEN(strSecretPhraseHint) ) OR LEN(strSecretPhraseHint) = 0 Then bReturn = false Elseif IsNull( LEN(strAddress) ) OR LEN(strAddress) = 0 Then bReturn = false Elseif IsNull( LEN(strCity) ) OR LEN(strCity) = 0 Then bReturn = false Elseif IsNull( LEN(strProvince) ) OR LEN(strProvince) = 0 Then bReturn = false Elseif IsNull( LEN(strPostalCode) ) OR LEN(strPostalCode) = 0 Then bReturn = false Elseif IsNull( LEN(strCountry) ) OR LEN(strCountry) = 0 Then bReturn = false End If isAllRequiredDataAvailable = bReturn End Function '************************************************************** ' FUNCTION: confirmEmail ' DESCRIPTION: check if both Email & Confirm Email are consistent ' PARAMETERS: email, confirmEmail ' RETURNS: true if email is equivalent to confirmEmail '************************************************************** Function confirmEmail( strEmail, strConfirmEmail ) Dim bSuccess 'Check if Confirmation Email is the same as Email If StrComp( strEmail, strConfirmEmail, vbTextCompare ) <> 0 Then bSuccess = false Else bSuccess = true End if confirmEmail = bSuccess End Function '************************************************************** ' FUNCTION: confirmPassword ' DESCRIPTION: check if both Password & confirmPassword are consistent ' PARAMETERS: password, confirmPassword ' RETURNS: true if email is equivalent to confirmEmail '************************************************************** Function confirmPassword( strPassword, strConfirmPassword ) Dim bSuccess 'Check if Confirmation Email is the same as Email If StrComp( strPassword, strConfirmPassword, vbTextCompare ) <> 0 Then bSuccess = false Else bSuccess = true End if confirmPassword = bSuccess End Function '************************************************************** ' FUNCTION: isEmailAvailable ' DESCRIPTION: Checks if the email is already taken ' PARAMETERS: the Email ' RETURNS: true if Email is still available ' false if Email is already taken '************************************************************** ' Written By: Wilbert Madarang ' Date: March 1, 2000 '************************************************************** Function isEmailAvailable( strEmail ) bAvailable = NOT (emailExists(strEmail) ) isEmailAvailable = bAvailable End Function '************************************************************** ' FUNCTION: hasEmailChanged ' DESCRIPTION: has the Email Changed? ' PARAMETERS: the Email ' RETURNS: true if Email has been modified ' false if Email has not changed '************************************************************** ' Written By: Wilbert Madarang ' Date: March 15, 2000 '************************************************************** Function hasEmailChanged( strEmail ) Dim bEmailChanged If strComp( strEmail,Session("MyOriginalEmail"), vbTextCompare ) <> 0 Then bEmailChanged = True Else bEmailChanged = False End If hasEmailChanged = bEmailChanged End Function '************************************************************** ' FUNCTION: doesReferCodeExists ' DESCRIPTION: Checks if the Refer Code exists in the db ' PARAMETERS: the Refer Code ' RETURNS: true if Refer Code exists ' false if Refer Code does not exist '************************************************************** ' Written By: Angela Madarang ' Date: November 11, 2005 '************************************************************** Function doesReferCodeExists( strReferCode ) Dim strSQL, rs Dim bSuccess If strReferCode = "" Then bSuccess = true Else 'Prepare SQL statement strSQL = "SELECT * FROM TReferCode WHERE ReferCode='" & strReferCode & "'" ' strSQL = "SELECT * FROM TReferCode WHERE ReferCode='WINTER2005'" 'Execute Query Call openDataConnection Set rs = dataConnection.Execute( strSQL ) Call closeDataConnection 'Obtain Information If NOT (rs.EOF AND rs.BOF) Then If DateDiff("d", Date(), DateValue(rs.Fields( "ExpiryDate" ))) >= 0 Then bSuccess = true End If Else bSuccess = false End If Set rs = Nothing End If doesReferCodeExists = bSuccess End Function '************************************************************** ' FUNCTION: printUserData ' DESCRIPTION: prints User Data ' PARAMETERS: none ' RETURNS: none '************************************************************** Function printUserData Response.Write "