ATP04
Posts: 57 Joined: 9/8/2004 Status: offline
|
Guest Book Integration - 3/16/2008 12:08:18
Hi! I'm trying to integrate CAPTCHA image verification into my guestbook. I have found several different .asp codes, but I don't know how to get any of them to work with the guestbook. Would anyone know how to integrate the code with the FP Guestbook WEBBOTS? I figure I can have only one form per webpage, and I'm don't know how to separate the guestbook into two pages or what it is I need to do to get this all to work together. Thanks so much! Teresa. The code I am using is: <%
' makit Image verification Script
' version 1.0
' http://www.makit.net/
' Copyright (C) 2006 Martyn Kilbryde
' Declare option explicit
Option Explicit
' Set the session timeout to be 10 minutes, as filling in a guestbook shouldn't take long
Session.Timeout = 10
' Run randomize to make sure a random number is retrieved
Randomize
' Declare the variables
Dim jpeg
Dim pixelsAcross
Dim backColour
Dim borderColour
Dim textColour
' The background colour of the image (the last 6 letters are the HTML hex colour code)
backColour = &HEEEEEE
' The border colour
borderColour = &H3C6194
' The text colour
textColour = &H3C6194
' The initial pixels across, where the text starts from
pixelsAcross = 10
' Create the jpeg object
Set jpeg = Server.CreateObject("Persits.jpeg")
' Create a new image of size 110x35 with the defined colour background
jpeg.new 110, 35, backColour
' Draw a border around the image
drawBorder
' Run the sub which does the lettering
doString
' Draw random lines over the image
drawLines
' Return the binary, which sets this page a jpeg
jpeg.SendBinary
' Sub to draw a border around the image
Sub drawBorder
' Set the pen colour to be blue
jpeg.Canvas.Pen.Color = borderColour
' Sets it so the whole image isn't painted, just the border that is to be drawn
jpeg.Canvas.Brush.Solid = False
' Draw a border around the image
jpeg.Canvas.DrawBar 0, 0, jpeg.Width, jpeg.Height
End Sub
' Sub to draw random lines on the image
Sub drawLines
' Set the pen colour as the same colour as the text
jpeg.Canvas.Pen.Color = textColour
' Draw a border around the image
jpeg.Canvas.DrawLine 0, Int(Rnd * 35), jpeg.Width, Int(Rnd * 35)
' Draw a border around the image
jpeg.Canvas.DrawLine 0, Int(Rnd * 35), jpeg.Width, Int(Rnd * 35)
End Sub
' Sub to do the lettering
Sub doString
' Define the local variables that are used
Dim theString
Dim x
' Get the string
theString = createRandomString()
' Loop through each letter of the string
For x = 1 to len(theString)
' Add the letter at the current position
addLetter(Mid(theString, x, 1))
Next
End Sub
' Sub to print a letter
Sub addLetter(theLetter)
' Set the font colour to be the defined colour
jpeg.Canvas.Font.Color = textColour
' Maybe set as bold
if doTextStyle then
jpeg.Canvas.Font.Bold = True
End If
' Maybe set as underlined
if doTextStyle then
jpeg.Canvas.Font.Underlined = True
End If
' Maybe set as italic
if doTextStyle then
jpeg.Canvas.Font.Italic = True
End If
' Set the font to be arial
jpeg.Canvas.Font.Family = randomFont()
' Set the size to be 15
jpeg.Canvas.Font.Size = randomFontSize()
' Antialias the text
jpeg.Canvas.Font.Quality = 4
' Set the backcolour to be the same as the image background
jpeg.Canvas.Font.BkColor = backColour
' Set the test background color to be opaque and not transparent
jpeg.Canvas.Font.BkMode = "Opaque"
' Print the letter
jpeg.canvas.print pixelsAcross, 5, theLetter
' Add 19 to how many pixels across the text should be
pixelsAcross = pixelsAcross + 19
End Sub
' Function that returns a true or false on a 50/50 basis
Function doTextStyle()
' If a random number is above 0.5 return true, else return false
if Rnd() > 0.5 then
doTextStyle = true
else
doTextStyle = false
end if
End Function
' Function to return a random font size
Function randomFontSize()
' Define the local variable used
Dim theNumber
' Get a random number, multiply by 14, change to an int and add 12 (so always above 12 and below 26)
theNumber = Int(Rnd * 14) + 12
' Return the number
randomFontSize = theNumber
End Function
' Function to return a random font
Function randomFont()
' Define the local variables used
Dim theNumber
Dim font
' Get a random number
theNumber = Rnd
' Use a long if-then-else on the random number for 5 possible fonts
if theNumber < 0.2 then
font = "Arial"
elseif theNumber < 0.4 then
font = "Courier New"
elseif theNumber < 0.6 then
font = "Helvetica"
elseif theNumber < 0.8 then
font = "Times New Roman"
else
font = "Geneva"
end if
' Return the font
randomFont = font
End Function
' Function to create a random string
Function createRandomString()
' Define the local variables used
Dim outputString
Dim x
' Loop 5 times
For x = 0 To 4
' 60% of the time a letter will be added, 40% will be a number
if rnd() < 0.6 then
' Add a random capital letter to the string
outputString = outputString & Chr(Int((26 * rnd()) + 65))
else
' Add a number to the string
outputString = outputString & Chr(Int((10 * rnd()) + 48))
end if
Next
' Store the output string to a session
Session("image_ver") = outputString
' Return the string
createRandomString = outputString
End Function
%>
|