Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 UBB 6.05 Members-to-SnitzDB transfer script
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

One Sick Puppy
Starting Member

22 Posts

Posted - 05 October 2002 :  18:31:44  Show Profile  Visit One Sick Puppy's Homepage
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

Edited by - Roland on 05 October 2002 18:35:15

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 05 October 2002 :  18:34:38  Show Profile
Very nice and hopefully helpful for many others.

I'll move this to the MOD W/ Code forum as that seems to be the appropriate place for this code.
Go to Top of Page

One Sick Puppy
Starting Member

22 Posts

Posted - 05 October 2002 :  18:36:21  Show Profile  Visit One Sick Puppy's Homepage
quote:
Originally posted by FrutZle

Very nice and hopefully helpful for many others.

I'll move this to the MOD W/ Code forum as that seems to be the appropriate place for this code.



Thanks. I looked around for where to put it, but figured someone would move it to where it best belonged.
Go to Top of Page

xstream
Junior Member

242 Posts

Posted - 21 October 2002 :  11:58:27  Show Profile  Visit xstream's Homepage  Send xstream an AOL message  Send xstream an ICQ Message
Is there a way to convert this so that a login is not required? Just have it pull all the info over?

X
Go to Top of Page

Tmpj
Junior Member

Denmark
467 Posts

Posted - 23 October 2002 :  03:48:46  Show Profile
Very Nice Work!!!

I have seen many sites running UBB 6.x (I don't see waht they would use the scrabled...)

As FrutZle says, hopefully helpful for many others.

I say the same!
Go to Top of Page

xstream
Junior Member

242 Posts

Posted - 23 October 2002 :  15:40:13  Show Profile  Visit xstream's Homepage  Send xstream an AOL message  Send xstream an ICQ Message
Anyone know if it can be converted to just convert all the member info without a login?

X
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.17 seconds. Powered By: Snitz Forums 2000 Version 3.4.07