<% '==== Function - FixaTecken ======================= ' Frisera till alla inkommande tecken så att de inte ' innehåller apostrof-tecken samt onödiga mellanslag. ' Tar även bort ev HTML. '================================================== Function InFixaTecken(sfix) ' sfif = Server.HTMLEncode(sfix) ' sfix = Replace(sfix, "a", "AAPPAA") sfix = Replace(Trim(sfix), "'", "''") sfix = Replace(sfix, "|", "-") sfix = Replace(sfix, "<", "«") sfix = Replace(sfix, ">", "»") InFixaTecken = sfix End Function '================================================== ' Öppnar databasen ' Ladda include file som innehåller kommandon för att öppna databaskoplingen. '================================================== ' Set Connect = Server.CreateObject("ADODB.Connection") ' På webben ' Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=h:\home\users\FA03-14-04-34_398e4bt49w34juqhwdbh\wennberg.net\public_html\fun.mdb" ' Connect.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" server.MapPath("fun.mdb") ' Hemma ' Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=C:\Mina dokument\Mina webbplatser\www.Wennberg.net\sys_db\fun.mdb" ' Set RecSet = Server.CreateObject("ADODB.Recordset") %> <% ' Vilket språk. dim UseLanguage If Request.QueryString("lang") = "sv" Then UseLanguage = "Swedish" Else UseLanguage = "English" End If %> Guestbook Fun

Guestbook - Fun
[ To more Fun ] [ Cave of Magic ]

<% '================================================== ' Spara ny posten i db. '================================================== If Request.QueryString("what") = "add" Then Addera = "SELECT * FROM guestbook_fun" RecSet.Open Addera, Connect, adOpenStatic, adLockOptimistic RecSet.AddNew ' Oöskade tecken tas bort via SubScript. RecSet("Name") = InFixaTecken(Request.Form("InName")) RecSet("Email") = InFixaTecken(Request.Form("InEmail")) RecSet("Homepage") = InFixaTecken(Request.Form("InHomepage")) RecSet("Hometown") = InFixaTecken(Request.Form("InHometown")) RecSet("About") = InFixaTecken(Request.Form("InAbout")) RecSet("Comments") = InFixaTecken(Request.Form("InComments")) ' Kryssa att posten ej skall visas. RecSet("NotShow") = True ' SparadIP = Request.ServerVariables("REMOTE_ADDR") ' SparadDateTime = Date + Time RecSet("FromIP") = Request.ServerVariables("REMOTE_ADDR") RecSet("FromDateTime") = Date + Time RecSet.Update ' RecSet.Close ' Set JMail = Server.CreateObject ("JMail.SMTPMail") ' This is my local SMTP server ' JMail.ServerAddress = "smtp.digikom.net" ' This is me.... ' JMail.Sender = "myemail@mydomain.net" ' JMail.Sender = "Cave_of_Magic@Wennberg.net" ' JMail.Subject = "Signs in - Cave of Magic" ' Get the recipients mailbox from a form (note the lack of a equal sign). ' JMail.AddRecipient "mum@any.com" ' JMail.AddRecipient "Mathias@Wennberg.net" ' The body property is both read and write. ' If you want to append text to the body you can ' use JMail.Body = JMail.Body & "Hello world! " ' or you can use JMail.AppendText "Hello World! " ' which in many cases is easier to use. ' JMail.Body = "Signs in Cave of Magic, Good" ' Priority: 1 - highest (Urgent), 3 - normal, 5 - lowest ' JMail.Priority = 1 ' JMail.AddHeader "Originating-IP", Request.ServerVariables ("REMOTE_ADDR") ' Send it... ' JMail.Execute %>

Thanks !

[ Back to guestbook ]

<% ' Om inte korrekt what. Else %>

It will take a short time after you have submitted a comment before you will
be able to read it in the Guestbook.  This is to avoid giving away the
secret of the Cave of Magic.  However, you are free to speculate regarding
how it works. I will then comment about your speculation and post it in the Guestbook.

Name: *
E-mail:
Homepage:
Location:
Message: *
<% ' Visa endast de poster som får visas. ' Sortera posterna efter inskrivning datum o tid. ' Visa = "SELECT * FROM guestbook_fun WHERE NotShow = False ORDER BY FromDateTime DESC" ' RecSet.Open Visa, Connect ' RecSet.Open Visa, Connect, adOpenStatic, adLockOptimistic ' Declare our vars Dim iPageSize ' How big our pages are Dim iPageCount ' The number of pages we get back Dim iPageCurrent ' The page we want to show Dim strOrderBy ' A fake parameter used to illustrate passing them Dim strSQL ' SQL command to execute ' Dim objPagingConn ' The ADODB connection object Dim RecSet ' The ADODB recordset object Dim iRecordsShown ' Loop controller for displaying just iPageSize records Dim I ' Standard looping var ' Get parameters iPageSize = 25 ' You could easily allow users to change this ' Retrieve page to show or default to 1 If Request.QueryString("page") = "" Then iPageCurrent = 1 Else iPageCurrent = CInt(Request.QueryString("page")) End If ' Build our SQL String using the parameters we just got. ' strSQL = "SELECT * FROM sample ORDER BY " & strOrderBy & ";" ' Visa endast de poster som får visas. ' Sortera posterna efter inskrivning datum o tid. strSQL = "SELECT * FROM guestbook_fun WHERE NotShow = False ORDER BY FromDateTime DESC" ' Some lines I used while writing to debug... uh "test", yeah that's it! ' Left them FYI. 'strSQL = "SELECT * FROM sample WHERE id=1234 ORDER BY id;" 'strSQL = "SELECT * FROM sample;" 'Response.Write "SQL Query: " & strSQL & "
" & vbCrLf ' Now we finally get to the DB work... ' Create and open our connection ' Set objPagingConn = Server.CreateObject("ADODB.Connection") ' objPagingConn.Open CONN_STRING, CONN_USER, CONN_PASS ' Create recordset and set the page size ' Set objPagingRS = Server.CreateObject("ADODB.Recordset") ' objPagingRS.PageSize = iPageSize RecSet.PageSize = iPageSize ' You can change other settings as with any RS 'objPagingRS.CursorLocation = adUseClient ' objPagingRS.CacheSize = iPageSize RecSet.CacheSize = iPageSize ' Open RS ' objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly, adCmdText RecSet.Open strSQL, Connect, adOpenStatic, adLockReadOnly, adCmdText ' Get the count of the pages using the given page size ' iPageCount = objPagingRS.PageCount iPageCount = RecSet.PageCount ' If the request page falls outside the acceptable range, ' give them the closest match (1 or max) If iPageCurrent > iPageCount Then iPageCurrent = iPageCount If iPageCurrent < 1 Then iPageCurrent = 1 ' Check page count to prevent bombing when zero results are returned! If iPageCount = 0 Then Response.Write "No records found!" Else ' Move to the selected page ' objPagingRS.AbsolutePage = iPageCurrent RecSet.AbsolutePage = iPageCurrent ' Start output with a page x of n line %>

Amount of messages: <% Response.Write(RecSet.RecordCount) %>

<% ' Spacing Response.Write vbCrLf ' Show "previous" and "next" page links which pass the page to view ' and any parameters needed to rebuild the query. Response.Write ("

") If iPageCurrent > 1 Then %> [<< Prev] <% End If ' Show page numbers: For I = 1 To iPageCount If I = iPageCurrent Then Response.Write ("" & I & "") Else %> <%= I %> <% End If Next 'I If iPageCurrent < iPageCount Then %> [Next >>] <% End If Response.Write("

") ' Loop through our records and ouput 1 row per record iRecordsShown = 0 ' Do While iRecordsShown < iPageSize And Not objPagingRS.EOF Do While iRecordsShown < iPageSize And Not RecSet.EOF %>
<% ' Datum och Tid. Response.Write(RecSet("FromDateTime") & "
") ' Man och E-post. ShowName = RecSet("Name") ShowEmail = RecSet("Email") Response.Write("Name: ") If ShowEmail <> "" Then %> <% =ShowName %>
<% Else %> <% =ShowName %>
<% End If %> <% ' Hemstad. ShowHometown = RecSet("Hometown") If ShowHometown <> "" Then Response.Write("Location: " & ShowHometown) Response.Write("
") End If ' Hemsida. ShowHomepage = RecSet("Homepage") If ShowHomepage <> "http://" Then Response.Write("Homepage: " & ShowHomepage & "") Response.Write("
") End If ' Kommentar om. ShowAbout = RecSet("About") If ShowAbout <> "" Then Response.Write("Comment about: " & ShowAbout) Response.Write("
") End If %>
<% ' Denna koden gör att radbrytningar fungerar ShowComments = RecSet("Comments") If ShowComments <> "" Then ShowComments = Replace(ShowComments , Chr(34), "''") ShowComments = Replace(ShowComments , vbCrLf, "
") %> <% =ShowComments %> <% Else %> # Inlägge saknas # <% End If %> <% ' Denna koden gör att radbrytningar fungerar ShowMyComments = RecSet("MyComments") If ShowMyComments <> "" Then ShowMyComments = Replace(ShowMyComments , Chr(34), "''") ShowMyComments = Replace(ShowMyComments , vbCrLf, "
") %>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<% =ShowMyComments %>
<% End If %>
<% ' TOMRAD MELLAN POSTERNA %>
<% ' Increment the number of records we've shown iRecordsShown = iRecordsShown + 1 ' Can't forget to move to the next record! RecSet.MoveNext Loop ' All done - close table End If ' Close DB objects and free variables 'objPagingRS.Close 'Set objPagingRS = Nothing 'objPagingConn.Close 'Set objPagingConn = Nothing ' Show "previous" and "next" page links which pass the page to view ' and any parameters needed to rebuild the query. Response.Write ("

") If iPageCurrent > 1 Then %> [<< Prev] <% End If ' Show page numbers: For I = 1 To iPageCount If I = iPageCurrent Then Response.Write ("" & I & "") Else %> <%= I %> <% End If Next 'I If iPageCurrent < iPageCount Then %> [Next >>] <% End If %>

<% ' SLUT PÅ GUESTBOOK %>
<% End If %>

[ Up ]


(c) M. Wennberg 2002