<%@ LANGUAGE="VBScript" %> <% Option Explicit Dim sDbLocation, sConnection, sSiteName, sHomeURL ' The following are some variables that have to be ' individually customized for this website sSiteName = "Hopenet Forums" sHomeURL = "http://www.hopenetworks.org/" sDbLocation = Server.MapPath("forum.mdb") sConnection = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & sDbLocation & ";" 'ConnectDB: a simple function to make database connections FUNCTION ConnectDb () Dim conForum SET conForum = Server.CreateObject("ADODB.Connection") conForum.Open sConnection Set ConnectDb = conForum conForum.Close SET conForum = NOTHING END FUNCTION 'InputFix: Prepares Text in the proper format for inserting ' into the database. FUNCTION InputFix(strInput) Dim strTemp strTemp = Replace(strInput, "'", "`") InputFix = strTemp END FUNCTION 'OutputFix: Prepares Text in the proper format for inserting ' into the html code of a page. FUNCTION OutputFix(strInput) Dim strTemp strTemp= Replace(strInput, vbcrlf, "
") strTemp = Replace(strTemp, "`", "'") OutputFix = strTemp END FUNCTION %> <% 'retrieve querystring variables Dim ForumID, ThreadID Dim cookieName, cookieEmail Dim messageType ' this decides if the message is a reply or a new post ForumID = Request.QueryString("forum_id") IF ForumID = "" then Response.Redirect "default.asp" ThreadID = Request.QueryString("thread_id") 'values to fill the textboxes with. makes it more user-friendly cookieName = Request.Cookies("name") cookieEmail = Request.Cookies("email") Dim strSQL Dim rstForumName Dim ForumName Dim conForum 'open a connection Set conForum = Server.CreateObject("ADODB.Connection") conForum.Open sConnection 'Get the forum Name Set rstForumName = conForum.Execute("Select * From tblForums Where forum_id=" & ForumID & ";") ForumName = rstForumName("ForumName") rstForumName.Close Set rstForumName = NOTHING Dim Subject, pageTitle, navBar If IsNull(ThreadID) or ThreadID = "" then Subject = "" pageTitle = sSiteName & " > " & ForumName & " > " & "Post New Thread" 'find out the next number for the thread ID, since this is a 'new thread (no thread_id was detected in the querystring) Dim rstThread Set rstThread = conForum.Execute("SELECT Max(thread_id) as LargeThread FROM tblMessages;") IF rstThread.EOF and rstThread.BOF THEN ThreadID = 1 ELSE rstThread.MoveFirst ThreadID = rstThread.Fields("LargeThread") + 1 END IF rstThread.Close Set rstThread = NOTHING if ThreadID = "" then ThreadID = 1 navBar = "

" navBar = navBar & "" &sSiteName& " > " &ForumName& " > Post New Thread >

" Else 'get the subject from database 'ThreadID stays the same as what was gathered from querystring Dim rstSubject Set rstSubject = conForum.Execute("SELECT thread_id, message_subject From tblMessages Where thread_id=" &ThreadID& ";") Subject = rstSubject("message_subject") rstSubject.Close Set rstSubject = NOTHING pageTitle = sSiteName & " > " & ForumName & " > " & Subject & " > New Reply" navBar = navBar & "

" &sSiteName& " > " &ForumName& " > " &Subject& " > Reply

" 'format the subject and include the hidden field Subject = "RE: " & Subject & "" End If if isnull(ThreadID) then ThreadID = 1 %> forums
<%=navBar%>
Name: 
E-mail Address: 
Subject:  <%=Subject%>
Message: