<% '********************************************* 'words.asp * ' * '********************************************* ' INCLUDE FILES AND VARIABLES openPage = "index.asp" openDB = "../../access_db/sbDB.mdb" %> <%'SET SESSION TO CHANGE LINK COLOR ON MENU%> <% session("whichPage") = "main" %> [an error occurred while processing this directive] [an error occurred while processing this directive] susanbuck.net <% 'OPEN DATABASE Set Conn1 = OpenDB2(openPage,openDB) index="yes" %> [an error occurred while processing this directive]
<% 'figure out what the last entry is sqlLast ="SELECT * FROM blog" set rsLast = conn1.execute(sqlLast) do while NOT rsLast.eof lastId = rsLast.fields ("orderKey") rsLast.MoveNext Loop Set rsLast = Nothing ' -------------------------------- displayStart = request.queryString("displayStart") 'WHICH BLOGS TO SHOW ON THIS PAGE displayEnd = request.queryString("displayEnd") if displayStart = "999" then displayEnd = lastID displayStart = displayEnd - 4 %> <% end if 'SETUP QUERY STRINGS FROM URL commentAction = request.queryString("commentAction") orderKey = request.querystring("orderKey") 'WHICH IMAGE TO DISPLAY permanent = request.queryString("permanent") 'IS THIS A PERMALINK? permKey = request.queryString("permKey") 'WHICH IMAGE TO DISPLAY IF IT IS A PERMALINK tagCall = request.queryString("tagCall") displayStart = request.queryString("displayStart") displayEnd = request.queryString("displayEnd") %> <% 'GRAB IMAGE TO BE DISPLAYED if permanent = "yes" then 'IF THIS IS A PERMALINK, USE THE keyAction TO GRAB THE IMAGE sql = "SELECT * FROM blog WHERE permKey=" & permKey & "" 'don't need this any more - all tag requests are sent to tags.asp elseif tagCall <> "" then sql = "SELECT * FROM blog WHERE tag1='" & tagCall &"' OR tag2='" & tagCall &"' AND orderKey BETWEEN " & displayStart & " AND " & displayEnd & " ORDER BY [orderKey] DESC" else 'IF IT WASNT A PERMALINK, JUST GRAB THE IMAGE BY ID (WHICH REPRESENTS THE ORDER OF THE IMAGES) sql = "SELECT * FROM blog WHERE orderKey BETWEEN " & displayStart & " AND " & displayEnd & " ORDER BY [orderKey] DESC" end if set rsBlogs = conn1.execute(sql) %> <% count = 1 Do While Not rsBlogs.EOF 'SETUP VARIABLES titlePre = rsBlogs.fields("title") title1 = Replace(titlePre,"[[]]","""") title = Replace(title1,"[]","'") theDate = rsBlogs.fields("theDate") tag1 = rsBlogs.fields("tag1") tag2 = rsBlogs.fields("tag2") tag3 = rsBlogs.fields("tag3") tag4 = rsBlogs.fields("tag4") tag5 = rsBlogs.fields("tag5") contentPre = rsBlogs.fields("content") content1 = Replace(contentPre,"[[]]","""") contentA = Replace(content1,"[]","'") content = contentA count = count + 1 permKey = rsBlogs.fields("permKey") %>
<%p title%>
 
<%p theDate%>

<%p content%>



   <% 'GET COMMENT COUNT FOR THIS IMAGE commentcount = 0 sql = "SELECT * FROM blogComments WHERE permKeyConnect=" & permKey & "" 'GET ALL THE COMMENTS THAT HAVE THE SAME PICTURE KEY AS THE CURRENT IMAGES KEY set rsComment = conn1.execute(sql) do while not rsComment.eof 'LOOP THROUGH ALL THE COMMENTS THAT HAVE THE SAME PICTURE KEY, AND KEEP THE COUNT commentCount = commentCount + 1 'INCREMENT COUNTER rsComment.MoveNext loop %> <% commentAction = Request.QueryString("commentAction") 'which entry should comments be displayed 'commentAction was a string, whereas permKey was a number, and the two were showing false when compared - solution: convert commentAction to an integer. commentAction = Cint(commentAction) if commentAction <> permKey then 'permanent means only one entry is being shown - so the displayStart/End needs to be taken out if permanent = "yes" then %> [ <%p commentcount%> ] <% else %> [ <%p commentcount%> ] <% end if %> show comments <% else 'permanent means only one entry is being shown - so the displayStart/End needs to be taken out if permanent = "yes" then %> [ <%p commentcount%> ] <% else %> [ <%p commentcount%> ] <% end if %> hide comments <% end if %>    <% linkCalled = request.queryString("linkCalled") if linkCalled = "" then %> link this <% elseif linkCalled = "yes" then %> hide link <% end if %>    archive: <%p tag1%>  <%p tag2%>  <%p tag3%>  <%p tag4%>  <%p tag5%>
<% raction = request.queryString("raction") if linkCalled = "yes" then %>
Linking to this entry?
Use this URL : http://www.susanbuck.net/sb/words/index.asp?permanent=yes&permKey=<%p permKey%> <% end if %> <% if (count MOD 2 = 0) AND (permKey <> "") then %>

<% end if %> <% if permKey = commentAction then 'only if there is a commentAction do you do something %>
 

Comments

<% 'get all comments from the blogComments table where the permKeyConnect matches the connecting blog entry via commentAction getCommentSQL = "SELECT * FROM blogComments WHERE permKeyConnect=" & commentAction & "" Set rsGetComment = Conn1.Execute(getCommentSQL) 'THIS IS FOR DISPLAYING COMMENTS 'set up variables for each comment color = "on" Do While Not rsGetComment.EOF namePrex = rsGetComment.fields ("name") name1x = Replace(namePrex,"[[]]","""") name2x = Replace(name1x,"[]","'") theDate = rsGetComment.fields ("theDate") emailPre = rsGetComment.fields ("email") email1 = Replace(emailPre,"[[]]","""") email2 = Replace(email1,"[]","'") webAddressPre = rsGetComment.fields ("webAddress") webAddress1 = Replace(webAddressPre,"[[]]","""") webAddress2 = Replace(webAddress1,"[]","'") commentsPre = rsGetComment.fields ("comments") comments1 = Replace(commentsPre,"[[]]","""") comments2 = Replace(comments1,"[]","'") permKeyConnect = rsGetComment.fields ("permKeyConnect") %> <% if color = "on" then %>
<% color = "off" else %>
<% color = "on" end if If webAddress2 = "" Then p name2x Else%> <%p name2x%> <%End If%> wrote on <%p theDate%> -
<%p comments2%>

<% rsGetComment.MoveNext Loop %> <% submitAction = Request.QueryString("submitAction") 'if just viewing comments, set the values from any stored cookie values if submitAction = "" then nameValue = request.cookies("name") emailValue = request.cookies("email") commentValue = request.cookies("comments") webAddressvalue = request.cookies("webAddress") elseif submitAction = "clear" then nameValue = "" emailValue = "" commentValue = "" webAddressValue = "" else nameValue = request.queryString("nameValue") emailValue = request.queryString("emailValue") commentValue = request.queryString("commentValue") webAddressValue = request.queryString("webAddressValue") end if 'THIS IS FOR ADDING COMMENTS Select case(submitAction) case "add" 'SAVE COOKIES 'only do it if the check box is checked if Request.Form("rememberMe") = "checked" then Response.Cookies("name") = Request.Form("name") Response.Cookies("name").Expires=#January 18, 2038# Response.Cookies("email") = Request.Form("email") Response.Cookies("email").Expires=#January 18, 2038# Response.Cookies("comments") = Request.Form("comments") Response.Cookies("comments").Expires=#January 18, 2038# Response.Cookies("webAddress") = Request.Form("webAddress") Response.Cookies("webAddress").Expires=#January 18, 2038# else Response.Cookies("name") = "" Response.Cookies("email") = "" Response.Cookies("comments") = "" Response.Cookies("webAddress") = "" end if namePre = Request.Form("name") name1 = Replace(namePre,"""","[[]]") name2 = Replace(name1,"'","[]") name3 = Replace(name2,",","") 'fix for weird bug where commas are being added emailPre = Request.Form("email") email1 = Replace(emailPre,"""","[[]]") email2 = Replace(email1,"'","[]") email3 = Replace(email2,",","") 'fix for weird bug where commas are being added webAddressPre = Request.Form("webAddress") webAddress1 = Replace(webAddressPre,"""","[[]]") webAddress2 = Replace(webAddress1,"'","[]") webAddress3 = Replace(webAddress2,",","") 'fix for weird bug where commas are being added commentsPre = Request.Form("comments") comments1 = Replace(commentsPre,"""","[[]]") comments2 = Replace(comments1,"'","[]") comments3 = Replace(comments2,",","") 'fix for weird bug where commas are being added theDate2 = month(date) & "/" & day(date) & "/" & year(date) userIP = Request.ServerVariables("REMOTE_HOST") Set myMail=CreateObject("CDO.Message") myMail.Subject="susanbuck.net BLOG comments for [" & title & "]" myMail.From = emailPre myMail.To="susancbk@gmail.com" myMail.HTMLBody = namePre & " (" & emailPre & ") wrote on " & theDate2 & " about the image [" & title & "] -

" & commentsPre & "" myMail.Send set myMail=nothing sqlAdd = "INSERT into blogComments (userIP,theDate,permKeyConnect,name,email,webAddress,comments) VALUES ('" & userIP &"','" & theDate2 &"','" & commentAction &"','" & name3 &"','" & email3 & "','" & webAddress3 & "','" & comments3 & "')" conn1.Execute(sqlAdd) Response.Redirect "index.asp?displayStart=" & displayStart & "&displayEnd=" & displayEnd & "&commentAction=" & commentAction case "errorName" errorMsg = "Please enter your name." case "errorEmail" errorMsg = "Please enter your email address." case "errorComments" errorMsg = "Please enter a comment." case "errorSpamPrevention" errorMsg = "Please fill in the spam prevention question." end select %>
Leave a comment

Submit   Clear    remember me

hide comments


Name


Email (won't be posted)


Web Address (optional)


What color is a stop light? (spam preventionBy answering this question you're proving you're a human, not a computer trying to leave me spam.)

<%p errorMsg%>
<% end if 'end if test to see if a comment is being called for %>



<% rsBlogs.MoveNext loop %>
<% ' if at start, with no previous entries, don't display previous button if displayStart < 2 OR permanent = "yes" then ' do nothing else %>

previous five

<% end if%> <% ' if at end, with no more entries, don't display next button if lastId <> (displayStart + 4) then if permanent <> "yes" then %>

next five

<% end if%> <% end if %> <% if permanent = "yes" then %>

view most current entries

<% end if %>


<%conn1.close%>