% @ Language=VBScript %> <% Option Explicit %> <% 'Set the response buffer to true Response.Buffer = True 'Dimension variables Dim rsAdminDetails 'recordset holding the admin details Dim strMode 'holds the mode of the page, set to true if changes are to be made to the database Dim strEncyptedPassword 'Holds the new password Dim blnUserNameOK 'Set to ture if the Name is not already in the database Dim strCheckUserName 'Holds the Name from the database that we are checking against Dim blnUpdated 'Set to true if the username and password are updated 'Initialise variables blnUserNameOK = True blnUpdated = False 'Redirect if this is not the main forum account If lngLoggedInUserID <> 1 Then 'Reset Server Objects Set rsCommon = Nothing adoCon.Close Set adoCon = Nothing Response.Redirect("admin_menu.asp") End If 'Read in the users details from the form strMode = Request.Form("mode") 'If the user is changing there username and password then update the database If strMode = "postBack" Then 'Read in the userName and password from the form strUserName = Trim(Mid(Request.Form("userName"), 1, 15)) strPassword = LCase(Trim(Mid(Request.Form("password"), 1, 15))) 'If there is no userName entered then don't save If strUserName = "" Then blnUserNameOK = False 'Make sure the user has not entered disallowed userNames If InStr(1, strUserName, "password", vbTextCompare) Then blnUserNameOK = False If InStr(1, strUserName, "author", vbTextCompare) Then blnUserNameOK = False If InStr(1, strUserName, "code", vbTextCompare) Then blnUserNameOK = False If InStr(1, strUserName, "userName", vbTextCompare) Then blnUserNameOK = False If InStr(1, strUserName, "N0act", vbTextCompare) Then blnUserNameOK = False 'Clean up user input strUserName = formatSQLInput(strUserName) 'Intialise the ADO recordset object Set rsCommon = Server.CreateObject("ADODB.Recordset") 'Read in the userNames from the database to check the userName does not alreday exsist 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT " & strDbTable & "Author.UserName FROM " & strDbTable & "Author WHERE " & strDbTable & "Author.UserName = '" & strUserName & "' AND NOT " & strDbTable & "Author.Author_ID = 1;" 'Query the database rsCommon.Open strSQL, adoCon 'If there is a record returned then the userName is already in use If NOT rsCommon.EOF Then blnUserNameOK = False 'Remove SQL safe single quote double up set in the format SQL function strUserName = Replace(strUserName, "''", "'", 1, -1, 1) 'Clean up rsCommon.Close 'If the UserName dose not already exsists then save the users details to the database If blnUserNameOK Then 'Only encrypt password if this is enabled If blnEncryptedPasswords Then 'Generate new salt strSalt = getSalt(Len(strPassword)) 'Concatenate salt value to the password strEncyptedPassword = strPassword & strSalt 'Re-Genreate encypted password with new salt value strEncyptedPassword = HashEncode(strEncyptedPassword) 'Else the password is not set to be encrypted so place the un-encrypted password into the strEncyptedPassword variable Else strEncyptedPassword = strPassword End If 'Intialise the strSQL variable with an SQL string to open a record set for the Author table strSQL = "SELECT " & strDbTable & "Author.UserName, " & strDbTable & "Author.Password, " & strDbTable & "Author.Salt, " & strDbTable & "Author.User_code " strSQL = strSQL & "From " & strDbTable & "Author " strSQL = strSQL & "WHERE " & strDbTable & "Author.Author_ID=1;" 'Set the Lock Type for the records so that the record set is only locked when it is updated rsCommon.LockType = 3 'Set the Cursor Type to dynamic rsCommon.CursorType = 2 'Open the author table rsCommon.Open strSQL, adoCon 'Randomise the system timer Randomize Timer 'Calculate a code for the user strUserCode = userCode(strUserName) With rsCommon 'Update the recordset .Fields("UserName") = strUserName .Fields("Password") = strEncyptedPassword .Fields("Salt") = strSalt .Fields("User_code") = strUserCode 'Update the database with the new user's details .Update 'Re-run the NewUser query to read in the updated recordset from the database .Requery 'Write a cookie with the User ID number so the user logged in throughout the forum 'Write the cookie with the Name Forum containing the value UserID number Response.Cookies(strCookieName)("UID") = strUserCode 'Read back in the new userName strUserName = rsCommon("UserName") 'Clean up .Close End With 'Set the update field to true blnUpdated = True End If End If 'Reset Server Objects Set rsCommon = Nothing adoCon.Close Set adoCon = Nothing %>
|
THE USERNAME YOU REQUESTED IS ALREADY TAKEN.
PLEASE CHOOSE ANOTHER USERNAME. |
| USERNAME & PASSWORD HAVE BEEN UPDATED. |