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

    integrazione codice: guestbook con Captcha

    ciao
    penso che aiutare a risolvere il mio problema possa anche aiutare molti altri ragazzi alle prese con il mio problema

    Io ho un guestbook favoloso, funzionante........ ecc ecc...
    unico problema che si riempe di spam...
    girando in rete ho trovato del codice Captcha semplicissimo (ma non me per me ) che se integrato al codice del guestbook che ho, ne farebbe secondo me il miglio guestbook si per grafica che per funzionalita ma...
    HO BISOGNO DI AIUTOOOOOOOOOOOOOOOOOOOOOOOOOO NON LO SO FAREEEEEEEEE
    ho tentato ma non ci riesco.
    potreste darmi una manina, vi posto sia il codice del guestbook che del controllo Captcha

    grazie

    lo metto in in due risposte perche è troppo lungo
    ..: Serie A :..
    ..: FORZA PALERMOOOOoooo.....

  2. #2
    codice:
    <%@LANGUAGE = JScript%> <%
    	Response.Buffer = true;
    
    	/*
    		Autore: Luca Ruggiero - http://www.lukeonweb.net
    		Fonte:  freeAsp.it - http://freeasp.html.it
    	*/
    
    	// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
    
    	// QUESTA E' LA PASSWORD DI AMMINISTRATORE PER ELIMINARE MESSAGGI INDESIDERATI... CAMBIALAAAAAAAAAAAAAAA :-)
    	var admin_password = "admin_password";
    
    	// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
    	
    	
    	/*
    		ASPETTI DELLA CONFIGURAZIONE DELL'APPLICAZIONE NON CONTEMPLATI NEI SINGOLI PASSAGGI DI CODICE
    		
    		Pur trattandosi di un semplice Guestbook, questo singolo file consente di effettare
    		tutte le operazioni possibili. A tal proposito è necessario puntualizzare alcune cose:
    		
    		1. E' importante, qualora dovessi decidere di rinominare questo file,
    		   modificare tutti i punti in cui si fa riferimento al file guestbook.asp
    		   sostituendo col nome del file che hai utilizzato per la rinomina.
    		
    		2. La grafica è personalizzabile in tutti i minimi particolari,
    		   ma è importante non confondere alcuna condizione del codice Asp
    		   evitando che generino errori.
    		   
    		Gli altri punti cardine dell'applicazione sono contemplati seguendo i vari passi del codice.
    	*/
    	
    	// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
    	
    	
    	// APRO LA CONNESSIONE VERSO IL DATABASE
    	// SE SUL TUO SERVER HAI NECESSITA' DI SPOSTARE IL DATABASE IN UNA CARTELLA DI SISTEMA DEDICATA
    	// DEVI MODIFICARE IL PERCORSO NELLA PORZIONE DI CODICE Server.MapPath("../mdb-database/db_firme_ospiti.mdb")
    	var connessione = new ActiveXObject("ADODB.Connection");
    	var stringa = "driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("../mdb-database/db_firme_ospiti.mdb");
    	connessione.Open(stringa);
    	
    	// UTILIZZEREMO UN SOLO FILE PER ESEGUIRE TUTTE LE OPERAZIONI POSSIBILI
    	// INSERIMENTO DEI MESSAGGI, VISUALIZZAZIONE DEI MESSAGGI, CANCELLAZIONE DI MESSAGGI DA PARTE DELL'AMMINISTRATORE, ECC...
    	// QUINDI DICHIARO UNA VARIABILE QUERYSTRING PER OTTENERE RISULTATI DIVERSI A SECONDA DEL LORO VALORE
    	var azione = new String(Request.QueryString("azione"));
    	
    	// CONTO I MESSAGGI PREDENTI SUL DATABASE
    	var conta = connessione.Execute("SELECT COUNT(*) AS id FROM messaggi");
    	
    	// EFFETTUO LA PAGINAZIONE PER MOSTRARE SOLO UN CERTO NUMERO DI MESSAGGI A VIDEO
    	// IN QUESTO CASO 5
    	var quanti = 5;
    	var Mostra = new ActiveXObject("ADODB.Recordset");
    		Mostra.Open("SELECT * FROM messaggi ORDER BY id DESC",connessione,1);
    	var pagina = parseInt(Request.QueryString("pagina"));
    	    if (isNaN(pagina) || pagina < 1) pagina = 1;
    	    if (!Mostra.EOF)
    	    {
    	         Mostra.PageSize = quanti;
    	         Mostra.AbsolutePage = pagina;
    	    }
    	var i = 0;
    	
    	// IMPOSTO IL COLORE DI SFONDO DELLE CELLE CHE CONTENGONO I MESSAGGI
    	var colore = 0;
    %>
    
    <head>
    <title>. . : : Firma il Libro Ospiti : : . .</title>
    <link rel="stylesheet" type="text/css" href="guestbook.css">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="GENERATOR" content="Microsoft FrontPage 12.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <style type="text/css">
    <style type="text/css"> a { color: #451228; text-decoration: None }
    a:hover {
    	color: #FF0000;
    	text-decoration: Underline;
    }
    .style1 {
    	text-align: center;
    }
    .style2 {
    	border-style: solid;
    	border-width: 1px;
    }
    </style>
    </head>
    
    <body background="../images/sfondo.jpg" onload="document.guestbook.nome.focus();">
    
    
    
    
    
    </p>
    <h2><font color="#451228">Guestbook</font> </h2>
    <table class="MODULO" width="500" align="center" cellpadding="3" cellspacing="0">
    	<form name="guestbook" method="post" action="guestbook.asp?azione=Inserisci">
    		<tr>
    			<td width="150">Cognome e Nome
    
    			<font size="1">(Surname and Name)</font> </td>
    			<td style="width: 412px">
    			<input type="text" name="nome" maxlength="50" style="border-style: solid; border-width: 1; width: 100%" size="20">
    			</td>
    		</tr>
    		<tr>
    			<td>Email (opzionale)
    
    			<font size="1">Email (optional)</font> </td>
    			<td style="width: 412px">
    			<input type="text" name="email" maxlength="50" style="border-style: solid; border-width: 1; width: 100%" size="20">
    			</td>
    		</tr>
    		<tr>
    			<td>Homepage (opzionale)
    
    			<font size="1">Homepage (optional)</font> </td>
    			<td style="width: 412px">
    			<input type="text" name="homepage" maxlength="50" style="border-style: solid; border-width: 1; width: 100%" value="http://" size="20">
    			</td>
    		</tr>
    		<tr>
    			<td>Titolo del Messaggio
    
    			<font size="1">Title of Message</font> 
    
    			</td>
    			<td style="width: 412px">
    			<input type="text" name="titolo" maxlength="70" style="border-style: solid; border-width: 1; width: 100%" size="20">
    			</td>
    		</tr>
    		<tr>
    			<td colspan="2">Messaggio
    
    			<font size="1">Message</font> </td>
    		</tr>
    		<tr>
    			<td colspan="2">
    			<textarea name="messaggio" style="border-style: solid; border-width: 1; width: 100%; height: 100px" rows="1" cols="20"></textarea>
    			</td>
    		</tr>
    		<tr>
    			<td colspan="2" class="style1">
    			<input type="submit" value=" Firma il Guestbook " style="border-style: solid; border-width: 1">
    			</td>
    		</tr>
    	</form>
    </table>
    <p align="center">
    
    
    
    Ci sono <%=conta("id")%> messaggi </p>
    <%
    	if (azione == "undefined")
    	{
    %> <%
    	// MOSTRO I MESSAGGI A VIDEO
    	if (Mostra.EOF)
    	{
    		Response.Write("");
    	}
    	else while (!Mostra.EOF && i<quanti)
    	{
    %>
    <table width="500" align="center" cellpadding="3" cellspacing="0">
    	<tr>
    		<td bgcolor='#<%colore%2 == 0 ? Response.Write("FFFFFF") : Response.Write("EEEEEE")%>' style="border-bottom: Dashed 1px #CCCCCC;">
    		<font color="#451228"><%=Mostra("titolo")%></font> <%Session("amministratore") == "OK" ? Response.Write(" (<a href=\"guestbook.asp?azione=Cancella&id=" + Mostra("id") + "\">cancella</a>)") : Response.Write("")%>
    		
    
    		<font color="#993300">Autore</font> <font color="#666666">:</font>
    		<%=Mostra("nome")%>
    
    		<font color="#993300">Data:</font> <font color="#451228"><%=Mostra("data")%>
    		<font color="#993300">ore</font> <%=Mostra("ora")%>
    
    		
    
    		<%=Mostra("messaggio")%> <%Mostra("homepage") == "http://" || Mostra("homepage") == "" || Mostra("homepage") == "undefined" ? Response.Write("") : Response.Write("
    
    <a href=\"" + Mostra("homepage") + "\" target=\"_blank\">" + Mostra("homepage") + "</a>")%>
    		</font></td>
    	</tr>
    	<%
    		i++;
    		colore++;
    		Mostra.MoveNext();
    	}
    %>
    </table>
    <%
    	}
    	else if (azione == "Inserisci")
    	{
    // RECUPERO I DATI DAL MODULO PER EFFETTUARE LA REGISTRAZIONE
            var nome = new String(Request.Form("nome"));
    		var email = new String(Request.Form("email"));
    		var homepage = new String(Request.Form("homepage"));
    		var titolo = new String(Request.Form("titolo"));
    		var messaggio = new String(Request.Form("messaggio"));
    		// ESPRESSIONE REGOLARE PER LA VERIFICA DELL'INDIRIZZO EMAIL
    		var verifica = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
    		// CREO LA DATA
    		var oggi = new Date();
    		var data = oggi.getDate() + "/" + (oggi.getMonth() + 1) + "/" + oggi.getFullYear();
    		var ora = oggi.getHours() + ":" + oggi.getMinutes();
    		// VALIDAZIONE DEI DATI INSERITI DALL'UTENTE
    		var errore = "guestbook.asp?azione=errore&codice=";
    	    if (nome == "" || nome == "undefined" || nome.charAt(0) == " ")
    		{
    			Response.Redirect(errore + "1");
    		}
    		else if (titolo == "" || titolo == "undefined" || titolo.charAt(0) == " ")
    		{
    			Response.Redirect(errore + "3");
    		}
    		else if (messaggio == "" || messaggio == "undefined" || messaggio.charAt(0) == " ")
    		{
    			Response.Redirect(errore + "4");
    		}
    		else
    		{
    			var r_messaggio = messaggio.replace(/</g, "&lt;");
    			var rr_messaggio = r_messaggio.replace(/>/g, "&gt;");
    			var rrr_messaggio = rr_messaggio.replace(/&/g, "&");
    			var rrrr_messaggio = rrr_messaggio.replace(/\n/g, "
    ");
    			// CASO IN CUI TUTTE LE CONDIZIONI SONO STATE SODDISFATTE
    			// QUINDI PROCEDO CON LA REGISTRAZIONE DEL MESSAGGIO
    			var recordset = new ActiveXObject("ADODB.Recordset");
    				recordset.Open("messaggi",connessione,3,3);
    					recordset.AddNew();
    						recordset("nome") = nome;
    						recordset("email") = email;
    						recordset("homepage") = homepage;
    						recordset("titolo") = titolo;
    						recordset("messaggio") = rrrr_messaggio;
    						recordset("data") = data;
    						recordset("ora") = ora;
    					recordset.Update();
    				recordset.Close();
    			Response.Redirect("guestbook.asp");
    		}
    	}
    	else if (azione == "errore")
    	{
    		// GESTIONE DEI MESSAGGI DI ERRORE
    		var codice = parseInt(Request.QueryString("codice"));
    		var correggi = "<p align=\"center\"><input type=\"button\" value=\"Correggi\" onClick=\"window.history.back()\">";
    		if (codice == "1")
    		{
    			Response.Write("<p class=\"ERRORE\">Inserisci il tuo nome per favore</p>" + correggi);
    		}
    		else if (codice == "2")
    		{
    			Response.Write("<p class=\"ERRORE\">Inserisci la tua email per favore</p>" + correggi);
    		}
    		else if (codice == "2")
    		{
    			Response.Write("<p class=\"ERRORE\">Inserisci la tua email per favore</p>" + correggi);
    		}
    		else if (codice == "3")
    		{
    			Response.Write("<p class=\"ERRORE\">Inserisci il titolo del messaggio per favore</p>" + correggi);
    		}
    		else if (codice == "4")
    		{
    			Response.Write("<p class=\"ERRORE\">Inserisci il corpo del messaggio per favore</p>" + correggi);
    		}
    		else
    		{
    			Response.Redirect("guestbook.asp");
    		}
    	}
    	else if (azione == "Login")
    	{
    		// LOGIN PER L'AMMINISTRATORE
    		var password = new String(Request.Form("password"));
    		if (password == admin_password)
    		{
    			Session("amministratore") = "OK";
    		}
    		Response.Redirect("guestbook.asp");
    	}
    	else if (azione == "Logout")
    	{
    		// LOGOUT PER L'AMMINISTRATORE
    		Session.Abandon();
    		Response.Redirect("guestbook.asp");
    	}
    	else if (azione == "Cancella")
    	{
    		// EFFETTUO LA CANCELLAZIONE DEL MESSAGGIO (SOLO SE AUTENTICATO)
    		if (Session("amministratore") != null)
    		{
    			var id = parseInt(Request.QueryString("id"));
    			connessione.Execute("DELETE * FROM messaggi WHERE id LIKE '" + id + "'");
    		}
    		Response.Redirect("guestbook.asp");
    	}
    	else
    	{
    		Response.Redirect("guestbook.asp");
    	}
    %> 
    
    
    
    <p align="center" color="#451228" font="verdana"><%
    	// CREO LA BARRA DI NAVIGAZIONE PER VISITARE "TUTTE LE PAGINE" CONTENENTI I VECCHI MESSAGGI
    	for (var x=0; x<Mostra.PageCount; x++)
    	{
    		if (pagina == (x + 1))
    		{
    			Response.Write("[" + (x + 1) + "] ");
    		}
    		else
    		{
    			Response.Write("[<a href=\"guestbook.asp?pagina=" + (x + 1) + "\">" + (x + 1) + "</a>] ");
    		}
    	}
    %> 
    
    <a href="../default.asp"><font size="2">Torna alla Homepage</font>
    </a></p>
    <div align="center">
    	<table width="200" border="1" height="55" cellspacing="3" cellpadding="3" style="border-collapse: collapse" bordercolor="#111111">
    		<tr>
    			<td align="center" height="13" width="570">
    			<font color="#451228" size="1" face="Verdana, Arial, Helvetica, sans-serif">
    			Area Riservata</font> </td>
    		</tr>
    		<tr>
    			<td align="center" height="30" width="570">
    			<form name="login" method="post" action='guestbook.asp?azione=<%Session("amministratore") == null ? Response.Write("Login") : Response.Write("Logout")%>'>
    				<%if (Session("amministratore") == null) {%>
    				<input type="password" name="password" size="20" style="border-style: solid; border-width: 1">
    				<%}%>
    				<input type="submit" value='<%Session("amministratore") == null ? Response.Write("Login") : Response.Write("Logout")%>' style="border-style: solid; border-width: 1">
    			</form>
    			</td>
    		</tr>
    	</table>
    </div>
    <p align="center"> </p>
    
    </body>
    
    </html>
    <%connessione.Close()%>
    ..: Serie A :..
    ..: FORZA PALERMOOOOoooo.....

  3. #3
    codice:
    <%@LANGUAGE="VBSCRIPT"%>
    <%
    function TestCaptcha(byval valSession, byval valCaptcha)
    	dim tmpSession
    	valSession = Trim(valSession)
    	valCaptcha = Trim(valCaptcha)
    	if (valSession = vbNullString) or (valCaptcha = vbNullString) then
    		TestCaptcha = false
    	else
    		tmpSession = valSession
    		valSession = Trim(Session(valSession))
    		Session(tmpSession) = vbNullString
    		if valSession = vbNullString then
    			TestCaptcha = false
    		else
    			valCaptcha = Replace(valCaptcha,"i","I")
    			if StrComp(valSession,valCaptcha,1) = 0 then
    				TestCaptcha = true
    			else
    				TestCaptcha = false
    			end if
    		end if		
    	end if
    end function
    %>
    
    <!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-9" />
    <title>CAPTCHA Example</title>
    <style type="text/css">
    body {
    	font-size:12px;
    	font-family:Verdana, Arial, Helvetica, sans-serif;
    }
    </style>
    <script language="javascript">
    function RefreshImage(valImageId) {
    	var objImage = document.images[valImageId];
    	if (objImage == undefined) {
    		return;
    	}
    	var now = new Date();
    	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
    }
    </script>
    </head>
    <body>
    <form id="form1" name="form1" method="post" action="">
      <table width="400" border="1" align="center">
        <tr>
          <td colspan="2" align="center">CAPTCHA Example</td>
        </tr>
        <tr>
          <td width="261">CAPTCHA Image</td>
          <td width="123">[img]captcha.asp[/img]
    Change Image</td>
        </tr>
        <tr>
          <td>Write the characters in the image above</td>
          <td><input name="captchacode" type="text" id="captchacode" size="10" /></td>
        </tr>
        <tr>
          <td></td>
          <td><input type="submit" name="btnTest" id="btnTest" value="Test Input" /></td>
        </tr>
        <%
    	if not IsEmpty(Request.Form("btnTest")) then
    		Response.Write("<tr><td colspan=""2"" align=""center"">")
    		if TestCaptcha("ASPCAPTCHA", Request.Form("captchacode")) then
    			Response.Write("<b style=""color:#00CC33"">The code you enter verified.[/b]")
    		else
    			Response.Write("<b style=""color:#FF0000"">You entered the wrong code.[/b]")
    		end if
    		Response.Write("</td></tr>" & vbCrLf)
    	end if
    	%>
      </table>
    </form>
    </body>
    </html>
    ..: Serie A :..
    ..: FORZA PALERMOOOOoooo.....

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.