Gossamer Forum
Home : Gossamer Threads Inc. : Custom Modification Jobs :

Importing script for Gossamer Forum

Quote Reply
Importing script for Gossamer Forum
What do you think will cost a script that import the messages from Discus (http://www.discusware.com) into Gossamer Forum?
Thank you
Max
The one with Mac OS X Server 10.4 :)
Quote Reply
Re: [maxpico] Importing script for Gossamer Forum In reply to
If you do a search of "discus" on the Gossamer Forum forum, you'll find that HeavyBombers has already done something like that. Send them an email/pm, and ask them about it.

Adrian
Quote Reply
Re: [maxpico] Importing script for Gossamer Forum In reply to
The following thread contains information about how to go about this (no need to spend a dollar ;-)):

http://www.gossamer-threads.com/...rum.cgi?post=175922;

- wil
Quote Reply
Re: [Wil] Importing script for Gossamer Forum In reply to
I had some trouble... I go to the link of the attached file provided by HeavyBombers and appears me a blank page. So I go to the source code and copy all the data and paste it into a text editor. Then I save it and run with my browser... It appears a blank page! So what extension must the saved file have? I must insert the html strings like <html></html>?
Note that I use IE 5 for Mac. Please HELP!
Thank you very much
Max
The one with Mac OS X Server 10.4 :)
Quote Reply
Re: [maxpico] Importing script for Gossamer Forum In reply to
Do a view source on this post. Or just copy what I've posted below.

Code:
<script language="vbscript">

Const FORUM_ID = EDIT

'---- CursorTypeEnum Values ----
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3

'---- LockTypeEnum Values ----
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4

sub window_onload()

dim o_tables
dim o_table
dim o_tmpElem
dim x
dim sEmail
dim sOutput
dim iStrPos
dim sPostDate
dim dPostDate
dim iPostUnixDate
dim iPostUnixLastReply
dim sPostText
dim sinm
dim sinh
dim sind
dim sUserName

dim lastpost_id
dim lastpost_poster
dim lastpost_unixdate

Dim Source
Dim Connect
Dim Source2

Dim Rs1
dim Rs2
dim Rs3
dim Rs4
dim Rs5

Source = "SELECT * FROM gforum_post"
Source2 = "select newid()"
Source3 = "select * from gforum_postview"
Source4 = "select * from gforum_forum where forum_id = " & cstr(forum_id)
Source5 = "select max(post_id) from gforum_post"

Connect = "Provider=sqloledb;Data Source=EDIT;Initial Catalog=EDIT;User Id=EDIT;Password=EDIT;"

Set Rs1 = CreateObject( "ADODB.Recordset" )
Rs1.Open Source, Connect, adOpenStatic, adLockOptimistic

Set Rs2 = CreateObject( "ADODB.Recordset" )
Rs2.Open Source2, Connect, adOpenStatic, adLockOptimistic

Set Rs3 = CreateObject( "ADODB.Recordset" )
Rs3.Open Source3, Connect, adOpenStatic, adLockOptimistic

Set Rs4 = CreateObject( "ADODB.Recordset" )
Rs4.Open Source4, Connect, adOpenStatic, adLockOptimistic

Set Rs5 = CreateObject( "ADODB.Recordset" )
Rs5.Open Source5, Connect, adOpenStatic, adLockOptimistic

if rs4.Fields("forum_total").Value > 0 then
msgbox("Posts already exist for this forum... no data loaded.. exiting")
exit sub
end if

sinm = 60
sinh = 60 * sinm
sind = 24 * sinh

set o_tables = document.all.tags("table")
set o_table = o_tables(0)

for x = 0 to o_table.rows.length - 1

set o_tmpElem = o_table.rows(x).cells(0).all.tags("A")
' post number
sOutput = sOutput & o_tmpElem(0).name & "<br>"

Rs1.AddNew

Rs1.Fields("user_id_fk") = 2

Rs2.requery
guidTmp = rs2.fields(0).value

guidTmp = replace(guidTmp, "{", "")
guidTmp = replace(guidTmp, "}", "")
guidTmp = replace(guidTmp, "-", "")

Rs1.Fields("post_unique_id") = guidTmp

' name
sUserName = o_table.rows(x).cells(0).innertext
Rs1.Fields("post_username") = sUserName
sOutput = sOutput & sUserName & "<br>"

Rs1.Fields("post_signature_deleted") = null
Rs1.Fields("forum_id_fk") = FORUM_ID
Rs1.Fields("post_root_id") = 0
Rs1.Fields("post_father_id") = 0
Rs1.Fields("post_depth") = 0

' get the position of the carrige returns that seperate the date and text
iStrPos = instr(1,o_table.rows(x).cells(1).innertext,chr(13))

' post date
sPostDate = mid(o_table.rows(x).cells(1).innertext,1,iStrPos - 1)
sPostDate = trim(mid(sPostDate,instr(1,sPostDate,",") + 1, (instr(1,sPostDate,"-")-1) - (instr(1,sPostDate,",") + 1))) & " " & trim(mid(sPostDate,instr(1,sPostDate,"-") + 1))

dPostDate = cdate(sPostDate)

iPostUnixDate = ((cdate(formatdatetime(dPostDate,2)) - cdate("1/1/1970")) * sind) + (sinh * (hour(dPostDate) + 6)) + (minute(dPostDate) * sinm) + second(dPostDate)

iPostUnixLastReply = 2000000000 - iPostUnixDate

' sOutput = sOutput & dPostDate & "<br>"

Rs1.Fields("post_time") = iPostUnixDate

sOutput = sOutput & iPostUnixDate & "<br>"

Rs1.Fields("post_latest_reply") = iPostUnixLastReply

sOutput = sOutput & iPostUnixLastReply & "<br>"

' post text
' formated like the following
' Email: mtevans@netdoor.com Imported from Discus on 01/02/2002
rest of post...

' email
if instr(1,o_tmpElem(1).href,"mailto:") then
sEmail = mid(o_tmpElem(1).href,8)
sPostText = "Email: " & sEmail & " "
else
sEmail = ""
sPostText = "Email: none "
end if

sPostText = sPostText & "Imported from Discus on " & date() & "
"

sPostText = sPostText & trim(mid(o_table.rows(x).cells(1).innertext,iStrPos + 4))

Rs1.Fields("post_message") = sPostText
sOutput = sOutput & sPostText & "<br>"

Rs1.fields("post_subject") = trim(mid(trim(mid(o_table.rows(x).cells(1).innertext,iStrPos + 4)),1,30)) & "..."

Rs1.Fields("post_style") = 1
Rs1.Fields("post_ip") = "1.1.1.1"
Rs1.Fields("post_last_edit_username") = null
Rs1.Fields("post_last_edit_time") = null
Rs1.Fields("post_anonymous_email") = null
Rs1.Fields("post_thread_hot") = null
Rs1.Fields("post_locked") = 0
Rs1.Fields("post_keep") = 0
Rs1.Fields("post_reply_notify") = 0
Rs1.Fields("post_has_attachments") = 0
Rs1.Fields("post_replies") = 0
Rs1.Fields("post_deleted") = 0
Rs1.Fields("post_deleted_by") = null
Rs1.Fields("post_deleted_time") = null
Rs1.Fields("post_icon") = null

sOutput = sOutput & "**********" & "<br>"

Rs1.Update

dim tmp_newid
rs5.Requery
tmp_newid = rs5.Fields(0).Value

Rs3.AddNew

rs3.Fields("post_id_fk") = tmp_newid
rs3.Fields("post_views") = 0
rs3.Fields("post_thread_views") = 0

rs3.Update

if x = 0 then

lastpost_id = tmp_newid
lastpost_poster = sUserName
lastpost_unixdate = iPostUnixDate

end if

window.status = "loading post " & cstr(x+1) & " of " & cstr(o_table.rows.length)

next

text_out.innerHTML = sOutput

Rs1.Close
rs3.Close

rs4.Fields("forum_total") = x
rs4.fields("forum_total_threads") = x
rs4.fields("forum_last") = lastpost_unixdate
rs4.fields("forum_last_poster") = lastpost_poster
rs4.fields("forum_last_id") = lastpost_id

rs4.update

results.innerhtml = cstr(x) & " posts added to forum: " & rs4.Fields("forum_name").Value
window.status = "Complete: " & cstr(x) & " posts added to forum: " & rs4.Fields("forum_name").Value

rs4.close

end sub


</script>

<!--Instert HTML Table Here-->

<div id="text_out">
</div>
<div id="results">
</div>

- wil
Quote Reply
Re: [Wil] Importing script for Gossamer Forum In reply to
I've done this passage but I don't know how to continue...
I've pasted the code into a text editor and saved as discus.vbs and opened with IE... I get a blank page...
What I missed?
Thanks
Max
The one with Mac OS X Server 10.4 :)
Quote Reply
Re: [maxpico] Importing script for Gossamer Forum In reply to
OK. I now suggest you contact the author of this code, try looking in his profile for ways of contacting him:

http://www.gossamer-threads.com/...ername=HeavyBombers;

Alternatively, you can post a message in the Gossamer Forum : Discuss forum.

- wil
Quote Reply
Re: [Wil] Importing script for Gossamer Forum In reply to
Yes I've already do that...
Thank you anyway
Max
The one with Mac OS X Server 10.4 :)