I wrote this little script so that my UBB users could transfer the essential values (name, password, email, post count, registration date) of their UBB member profiles to the new Snitz forum database. This allows them to keep their "seniority".
I've intentionally kept the values that are transferred to a minimum, but feel free to edit the code if you want to add more values to be transferred.
I'm not sure if this code will work for previous and later versions of the UBB, but I'm pretty sure all you would have to do is edit the readline section of my script to accomodate varying member .cgi files. IE. Field X might not be on line Y in a UBB5.xx .cgi member file as it is in a UBB6.05 file. Also note that UBB6.xx has MORE profile values than previous UBB's.
Anyhoo... to install the script:
1. Copy the code below
2. Paste the code into notepad (or Homesite, etc.)
3. Edit the "strFileDirectory" (line 10) and "strDBConn" (line 12) variables to reflect where your UBB members directory is located and what your preffered database connection, respectively.
4. Edit the URL (line 105)that links to the Snitz profile page reflecting your own forum URL
5. Save the file to your Snitz forum directory with the name of your choice specifying a .asp extension.
6. Load the script in a browser
USEAGE:
1. Enter the member number of UBB member.
2. Enter the password of the UBB member of step 1.
3. Press submit.
NOTES:
- Since the snitz forum database is not set to disallow duplicate emails or usernames (the snitz scripts do this) I have added code for these functions. If you want to preserve the permitance (is that a word?) of duplicate emails/usernames for registrations, then you'll have to cut out the code that checks for duplicates (it's easy to find)
<!--#INCLUDE FILE="inc_sha256.asp"-->
<%
Dim objFileSys, objTxtFile, objConn, objRS
Dim strDBConn, strFileDirectory, strFileLocation
Dim strUserName, strPassword, strIP, strEncryptedPassword, strEmail, strPostCount, strRegDate, strCGIFileName, strSQL
Dim intUBBID
'Directory of your UBB member files
strFileDirectory = "e:\Members\"
'Connection string for your Snitz forum database
strDBConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\snitz_forums_2000.mdb"
'Get login information
intUBBID = Request.Form("UBBID")
strPassword = Request.Form("Password")
'Login
If Request.Form("UBBID") = "" Or Request.Form("Password") = "" Then
Response.Write "<form action="""" method=""post"">"
Response.Write "UBB Member Number: <input name=UBBID type=Text> Password: <input name=Password type=password> "
Response.Write "<Input type=submit value=Submit></form>"
Response.End
End If
'Determine member CGI filename
If intUBBID > 0 And intUBBID < 10 Then strCGIFileName = "0000000" & intUBBID & ".cgi"
If intUBBID > 9 And intUBBID < 100 Then strCGIFileName = "000000" & intUBBID & ".cgi"
If intUBBID > 99 And intUBBID < 1000 Then strCGIFileName = "00000" & intUBBID & ".cgi"
If intUBBID > 999 And intUBBID < 10000 Then strCGIFileName = "0000" & intUBBID & ".cgi"
If intUBBID > 9999 And intUBBID < 100000 Then strCGIFileName = "000" & intUBBID & ".cgi"
If intUBBID > 99999 And intUBBID < 1000000 Then strCGIFileName = "00" & intUBBID & ".cgi"
If intUBBID > 999999 And intUBBID < 10000000 Then strCGIFileName = "0" & intUBBID & ".cgi"
If intUBBID > 9999999 And intUBBID < 100000000 Then strCGIFileName = "" & intUBBID & ".cgi"
'Open and Read File
Set objFileSys = CreateObject("Scripting.FileSystemObject")
strFileLocation = strFileDirectory & strCGIFileName
'Check if file exists, then extract member information or display error message.
If objFileSys.FileExists(strFileLocation) Then
Set objTxtFile = objFileSys.OpenTextFile(strFileLocation,1, 0)
strUsername = objTxtFile.Readline
strPassword = objTxtFile.Readline
strEmail = objTxtFile.Readline
objTxtFile.skipline
objTxtFile.skipline
objTxtFile.skipline
objTxtFile.skipline
strPostCount = objTxtFile.Readline
objTxtFile.skipline
objTxtFile.skipline
strRegDate = objTxtFile.Readline
'Check if passwords match
If strPassword <> Request.Form("Password") Then
Response.Write "<strong><font color=""#FF0000"">ERROR:</font> The password you entered is incorrect.</strong>"
Response.End
End If
'Insert data into database
Set objConn = Server.CreateObject("ADODB.Connection")
'open database
objConn.Open strDBConn
Set objRS = Server.CreateObject("ADODB.Recordset")
'Check if username exists in database already.
Set objRS = objConn.Execute("SELECT M_NAME FROM FORUM_MEMBERS WHERE M_NAME='" & strUserName & "'")
If objRS.EOF <> True And objRS.BOF <> True Then
Response.Write "<strong><font color=""#FF0000"">ERROR:</font> This username is already taken.</strong>"
Response.End
End If
'Check if username exists in database already.
Set objRS = objConn.Execute("SELECT M_EMAIL FROM FORUM_MEMBERS WHERE M_EMAIL='" & strEmail & "'")
If objRS.EOF <> True And objRS.BOF <> True Then
Response.Write "<strong><font color=""#FF0000"">ERROR:</font> This email is already taken. Duplicate emails are not permitted.</strong>"
Response.End
End If
'Encrypt password using the sha256 include file routine.
strEncryptedPassword = sha256("" & trim(strPassword))
'Get User's IP
strIP = Request.ServerVariables("REMOTE_HOST")
'Determine date
strRegDate = DateToStr(strRegDate & " " & Time)
strSQL = "INSERT INTO FORUM_MEMBERS (M_NAME, M_PASSWORD, M_EMAIL, M_POSTS, M_DATE, M_LASTHEREDATE, M_IP, M_LAST_IP) VALUES ('" & strUserName & "', '" & strEncryptedPassword & "', '" & strEmail & "', '" & strPostCount & "', '" & strRegDate & "', '" & strRegDate & "', '" & strIP & "', '" & strIP & "')"
Set objRS = objConn.execute(strSQL)
Response.Write "The following information from your old account has been successfully transferred to the new forums:" & "<br><br>"
Response.Write "<strong>Username:</strong> " & strUsername & "<br>"
Response.Write "<strong>Password:</strong>" & "<br>"
Response.Write "<strong>Email:</strong> " & strEmail & "<br>"
Response.Write "<strong>PostCount:</strong> " & strPostCount & "<br>"
Response.Write "<strong>RegDate:</strong> " & strRegDate & "<br><br>"
Response.Write "<a href=""http://www.yourdomain.com/yourforumdirectory/pop_profile.asp?mode=Edit"">Login to your new account.</a>"
Else
Response.Write "<strong><font color=""#FF0000"">ERROR:</font> The member does not exist.</strong>"
End If
'These functions are needed to format the date for the Snitz members table M_DATE and M_LASTHEREDATE fields.
function DateToStr(dtDateTime)
DateToStr = year(dtDateTime) & doublenum(Month(dtdateTime)) & doublenum(Day(dtdateTime)) & doublenum(Hour(dtdateTime)) & doublenum(Minute(dtdateTime)) & doublenum(Second(dtdateTime)) & ""
end function
function doublenum(fNum)
if fNum > 9 then
doublenum = fNum
else
doublenum = "0" & fNum
end if
end function
%>
Moved from the Help: General / Current Version (v3.4.xx) forum