Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    Problemi con script CAPTCHA

    Ciao a tutti ragazzi, era un po' di tempo che non mi collegavo a questo magnifico forum.

    Ultimamente il mio guestbook è stato assediato dagli spam maledetti, quindi sono ricorso subito ai ripari, trovando in rete uno script captcha semplice semplice...con 4 file asp(form-controllo-connessione-setup)..e devo dire che funziona benissimo.

    Il mio problema è che quando vado ad integrarlo nelle mie pagine, inserendo il codice di controllo nella pagina: add_comment.asp (quella che scrive nel DB per intenderci) mi elude la validazione.
    Ovviamente io faccio prima passare il form per la pagina di controllo e poi dopo alla pagina del DB....ma non riesco a farla entrare nel DB...perchè mi genera una serie di errori.

    questa è la pagina del file che processa:

    process.asp:

    <%@LANGUAGE="VBSCRIPT" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title></title>
    <style type="text/css">
    <!--
    .title {font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; }
    .header {font-family: Arial, Helvetica, sans-serif; font-size: 18px; font-weight: bold; }
    .text {font-size: 12px; font-family: Arial, Helvetica, sans-serif;}
    .small {font-size: 10px}
    body { background-color: #CCCCCC; }
    -->
    </style>
    </head>
    <body>
    <div align="center" class="header">



    </div>
    <form action="process_form.asp" method="post" name="form1" id="form1">
    <table width="300" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#000000">
    <tr>
    <td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="1" cellpadding="3">
    <tr>
    <td><span class="title"></span></td>
    </tr>
    <tr>
    </tr>
    <tr>
    <td class="text">

    Il codice che hai inserito è:

    <span class="title">



    <%

    'Above we include the file that checks to see if the security code is correct

    'The variable 'blnCAPTCHAcodeCorrect' will be set to true if the security code is entered correctly

    If blnCAPTCHAcodeCorrect Then

    Response.Redirect("guestbook.asp")
    Else

    Response.Redirect("sign.asp")
    End If

    %>

    Un aiutino?

  2. #2
    Questa invece è la pagina in questione: add_comment.asp (dove devo inserire il codice del process.form)

    <% Option Explicit %>


    <%

    'Set the response buffer to true as we maybe redirecting
    Response.Buffer = True
    'Dimension variables
    Dim rsSmut 'Database Recordset holding the smut table
    Dim rsAddNewComments 'Database recordset to add new comments
    Dim strInputName 'Holds the Users name
    Dim strInputCountry 'Holds the users country
    Dim strInputEmailAddress 'Holds the Users e-mail address
    Dim strInputHomepage 'Holds the Users homepage
    Dim strInputComments 'Holds the Users comments
    Dim saryCommentWord 'Array to hold each word in the comments enetred by the user
    Dim intCheckWordLengthLoopCounter 'Loop counter
    Dim intWordLength 'Holds the length of the word to be checked
    Dim blnWordLenthOK 'Boolean set to False if any words in the description are above 30 characters
    Dim intLongestWordLength 'Holds the number of characters in the longest word entered in the description
    Dim strEmailSubject 'Holds the subject of the e-mail notification
    Dim strEmailBody 'Holds the body of the e-mail
    Dim blnEmailSent 'Set to tru if the e-mail is sent
    'Read in user deatils from the guestbook form
    strInputName = Request.Form("name")
    strInputCountry = Request.Form("country")
    strInputEmailAddress = Request.Form("email")
    strInputHomepage = Request.Form("homepage")
    strInputComments = Request.Form("comments")
    'Get rid of HTML tags
    strInputName = Replace(strInputName, "<", "&lt;", 1, -1, 1)
    strInputName = Replace(strInputName, ">", "&gt;", 1, -1, 1)
    strInputHomepage = Replace(strInputHomepage, "<", "&lt;", 1, -1, 1)
    strInputHomepage = Replace(strInputHomepage, ">", "&gt;", 1, -1, 1)
    strInputComments = Replace(strInputComments, "<", "&lt;", 1, -1, 1)
    strInputComments = Replace(strInputComments, ">", "&gt;", 1, -1, 1)
    'Split-up each word in the comments from the user to check that no word entered is over 50 characters
    saryCommentWord = Split(Trim(strInputComments), " ")
    'Initialse the word length variable
    blnWordLenthOK = True
    'Loop round to check that each word in the comments entered by the user is not above 50 characters
    For intCheckWordLengthLoopCounter = 0 To UBound(saryCommentWord)

    'Initialise the intWordLength variable with the length of the word to be searched
    intWordLength = Len(saryCommentWord(intCheckWordLengthLoopCounter) )

    'Get the number of characters in the longest word
    If intWordLength => intLongestWordLength Then
    intLongestWordLength = intWordLength
    End If

    'If the word length to be searched is more than or equal to 50 then set the blnWordLegthOK to false
    If intWordLength => 50 Then
    blnWordLenthOK = False
    End If
    Next

    'Change my own codes for bold and italic HTML tags back to the normal satndrd HTML tags now that the check for unwated HTML tags is over
    strInputComments = Replace(strInputComments, "", "", 1, -1, 1)
    strInputComments = Replace(strInputComments, "
    ", "
    ", 1, -1, 1)
    strInputComments = Replace(strInputComments, "", "", 1, -1, 1)
    strInputComments = Replace(strInputComments, "
    ", "
    ", 1, -1, 1)
    strInputComments = Replace(strInputComments, "", "<u>", 1, -1, 1)
    strInputComments = Replace(strInputComments, "
    ", "</u>", 1, -1, 1)

    'Change the emotion symbols for the path to the relative smiley icon
    strInputComments = Replace(strInputComments, "[]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[:errr:]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[:x]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[)]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[ops:]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[:star:]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[xx(]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[|)]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[:V:]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[:^:]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[}]", "[img][/img]", 1, -1, 1)
    strInputComments = Replace(strInputComments, "[8D]", "[img][/img]", 1, -1, 1)


    'Replace the vb new line code for the HTML new break code
    strInputComments = Replace(strInputComments, vbCrLf, "
    ")

    'Get rid of repeated return key hits so there arn't two many new lines going half way down the page (
    is the HTML tag for new line)
    'Loop though the comments entered by the user till all cases of two new lines togather are replaced by one new line
    Do While InStr(1, strInputComments, "

    " ,vbTextCompare) > 0

    'Replace

    with one case of

    strInputComments = Replace(strInputComments , "

    ", "
    ")
    Loop

    'Create recorset object
    Set rsSmut = Server.CreateObject("ADODB.Recordset")

    'Replace swear words with other words with ***
    'Initalise the SQL string with a query to read in all the words from the smut table
    strSQL = "SELECT tblSmut.* FROM tblSmut;"

    'Open the recordset
    rsSmut.Open strSQL, strCon

    'Loop through all the words to check for
    Do While NOT rsSmut.EOF

    'Replace the swear words with the words in the database the swear words
    strInputComments = Replace(strInputComments, rsSmut("Smut"), rsSmut("Word_replace"), 1, -1, 1)
    strInputName = Replace(strInputName, rsSmut("Smut"), rsSmut("Word_replace"), 1, -1, 1)
    strInputCountry = Replace(strInputCountry, rsSmut("Smut"), rsSmut("Word_replace"), 1, -1, 1)
    strInputHomepage = Replace(strInputHomepage, rsSmut("Smut"), rsSmut("Word_replace"), 1, -1, 1)

    'Move to the next word in the recordset
    rsSmut.MoveNext
    Loop

    'Reset recordset
    Set rsSmut = Nothing

    'Write to the database if there are no unwanted HTML tags or the word lengths in the commets entered by the user are OK
    If blnWordLenthOK = True Then

    'Create recorset object
    Set rsAddNewComments = Server.CreateObject("ADODB.Recordset")


    'Initalise the SQL string with a query to read in all the comments from the database
    strSQL = "SELECT tblComments.* FROM tblComments;"

    'Set the cursor type property of the record set to Dynamic so we can navigate through the record set
    rsAddNewComments.CursorType = 2

    'Set the Lock Type for the records so that the record set is only locked when it is updated
    rsAddNewComments.LockType = 3

    'Open the recordset
    rsAddNewComments.Open strSQL, strCon

    'Add a new record to the recordset
    rsAddNewComments.AddNew

    rsAddNewComments.Fields("Name") = strInputName
    rsAddNewComments.Fields("Country") = strInputCountry
    rsAddNewComments.Fields("EMail") = strInputEmailAddress
    rsAddNewComments.Fields("Homepage") = strInputHomepage
    rsAddNewComments.Fields("Comments") = strInputComments

    'Update the database with the new recordset
    rsAddNewComments.Update

    'Requery the database to make sure that the new comments have been added
    'This will make the script wait until Database has updated itself as sometimes Access can be a little slow at updating
    rsAddNewComments.Requery

    'Reset Sever Objects
    Set adoCon = Nothing
    Set rsAddNewComments = Nothing

    'If the guestbook is configured to send an e-mail then send one
    If blnEmail = True Then

    'Turn the smiley image paths back into text
    strInputComments = Replace(strInputComments, "[img][/img]", "")
    strInputComments = Replace(strInputComments, "[img][/img]", "")
    strInputComments = Replace(strInputComments, "[img][/img]", "")
    strInputComments = Replace(strInputComments, "[img][/img]", "")
    strInputComments = Replace(strInputComments, "[img][/img]", ":errr:")
    strInputComments = Replace(strInputComments, "[img][/img]", "")
    strInputComments = Replace(strInputComments, "[img][/img]", "X(")

    'Initilise the subject of the e-mail
    strEmailSubject = "Guestbook comment notification"

    'Initailise the e-mail body variable with the body of the e-mail
    strEmailBody = "Hi "
    strEmailBody = strEmailBody & "

    This e-mail is automactically generated by the Guestbook on your web site."
    strEmailBody = strEmailBody & "
    The following comment has been posted in the Guestbook: -"
    strEmailBody = strEmailBody & "

    Name: " & strInputName
    strEmailBody = strEmailBody & "
    E-Mail: " & strInputEmailAddress
    strEmailBody = strEmailBody & "
    Country: " & strInputCountry
    strEmailBody = strEmailBody & "
    Homepage: " & strInputHomepage
    strEmailBody = strEmailBody & "
    Comments: -
    " & strInputComments


    'Call the funtion to send the e-mail
    blnEmailSent = SendMail(strEmailBody, strWebSiteEmailAddress, strEmailSubject, strMailComponent)
    End If

    'Return to the guestbook
    Response.Redirect "default.asp?PagePosition=1"

    End If
    %>

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Sign the Guest Book - Error</title>

    <!-- The Web Wiz Guide ASP Guestbook is written by Bruce Corkhill ©2001
    If you want your Guestbook then goto http://www.webwizguide.info -->



    <script language="JavaScript">
    <!-- Hide from older browsers...

    //Display an error message in an alert box
    window.alert('Sorry one of the words used in your comments has <% = intLongestWordLength %> characters\nPlease shortern the length of this word to below 50 characters');

    //Return the user to there comments
    self.location.href='javascript:history.back(1)';
    // -->
    </script>
    </head>
    <body bgcolor="<% = strBgColour %>" text="<% = strTextColour %>" link="<% = strLinkColour %>" vlink="<% = strVisitedLinkColour %>" alink="<% = strActiveLinkColour %>">
    JavaScript must be enabled on your web browser!
    </body>
    </html>

    Un aiutino???

  3. #3
    vi devo postare l'errore esatto....questo lo so.

    Piu' tardi rimettero' di nuovo le pagine come prima e vi postero' gli errori.

    Grazie.

  4. #4
    Ciao a tutti,

    Ho risolto, il mio problema era legato al DB...bisognava impostare lunghezza zero in una tabella...tutto fatto.

    Grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.