Ops.. mi sono dimenticato di allegare il codice..
codice:
<table class="MODULO" width="500" align="center" cellpadding="3" cellspacing="0">
<form name="guestbook" method="post" action="guestbook2.asp?azione=Inserisci">
<tr>
<td width="150" bgcolor="#EEEEEE"><div align="left" class="Stile47 Stile53">Nome*</div></td>
<td width="350" bgcolor="#EEEEEE"><input name="nome" type="text" class="Stile47" style="width: 100%;" maxlength="50"></td>
</tr>
<tr>
<td bgcolor="#EEEEEE"><div align="left" class="Stile54">Email*</div></td>
<td bgcolor="#EEEEEE"><input name="email2" type="text" class="Stile47" style="width: 100%;" maxlength="50"></td>
</tr>
<tr>
<td bgcolor="#EEEEEE"><div align="left" class="Stile54">Homepage (opzionale)</div></td>
<td bgcolor="#EEEEEE"><input name="homepage" type="text" class="Stile47" style="width: 100%;" value="http://" maxlength="50"></td>
</tr>
<tr>
<td bgcolor="#EEEEEE"><div align="left" class="Stile54">Titolo*</div></td>
<td bgcolor="#EEEEEE"><input name="titolo" type="text" class="Stile47" style="width: 100%;" maxlength="70"></td>
</tr>
<tr bgcolor="#EEEEEE">
<td colspan="2"><div align="left" class="Stile54">Messaggio*</div></td>
</tr>
<tr bgcolor="#EEEEEE">
<td colspan="2" class="Stile48">
<textarea name="messaggio" cols="" rows="" class="Stile47" style="width: 100%; height: 70px;"></textarea>
<span class="Stile55">
Scrivere nella casella qui sotto il seguente codice antispam:
<label>
<span class="Stile57">
</span>
<input name="spam1" type="text" class="Stile57" id="spam1" style="text-align: center;" value="<%
var elencoCaratteri = "abcdefghikmnpqrstuvwxz23456789";
var minimoCaratteri = 6;
var massimoCaratteri = 6;
var differenzaCaratteri = massimoCaratteri - minimoCaratteri;
var lunghezza = Math.round((Math.random() * differenzaCaratteri) + minimoCaratteri);
var incremento = 0;
var controllo1 = "";
while (incremento < lunghezza)
{
controllo1 += elencoCaratteri.charAt(Math.round(Math.random() * elencoCaratteri.length));
incremento++;
}
Response.Write(controllo1);
%>" size="6" readonly="true">
</label>
<label> </label>
</span>
<label>
<input name="spam2" type="text" class="Stile57" id="spam2" style="text-align: center;" size="6">
</label>
<span class="Stile55">
</span></td>
</tr>
<tr bgcolor="#EEEEEE">
<td colspan="2" align="right"><input type="submit" class="Stile47" value=" Firma il Libro"></td>
</tr>
</form>
</table>
<p align="center" class="Stile33"><a name="leggi"></a></p>
<%
if (azione == "undefined")
{
%>
<table width="500" align="center" cellpadding="3" cellspacing="0">
<%
// MOSTRO I MESSAGGI A VIDEO
if (Mostra.EOF)
{
Response.Write("
Non ci sono messaggi...</p>");
}
else while (!Mostra.EOF && i<quanti)
{
%>
<tr>
<td bgcolor="#000000" class="Stile10" style="border-bottom: Dashed 1px #CCCCCC;"> <div align="left" class="Stile39"><span class="Stile42"><%=Mostra("titolo")%>[/b] <%Session("amministratore") == "OK" ? Response.Write(" (<a href=\"guestbook2.asp?azione=Cancella&id=" + Mostra("id") + "\">cancella</a>)") : Response.Write("")%>
</span></span>
<span class="Stile43">Autore:</span> <span class="Stile34">" class="Stile44"><%=Mostra("nome")%>
</span> <span class="Stile43">Data:</span> <%=Mostra("data")%> <span class="Stile43">ore</span> <%=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>")%>
</div></td>
</tr>
<%
i++;
colore++;
Mostra.MoveNext();
}
%>
</table>
</span>
<%
}
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("email2"));
var homepage = new String(Request.Form("homepage"));
var titolo = new String(Request.Form("titolo"));
var messaggio = new String(Request.Form("messaggio"));
var spam1 = new String(Request.Form("spam1"));
var spam2 = new String(Request.Form("spam2"));
// 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 = "guestbook2.asp?azione=errore&codice=";
if (nome == "" || nome == "undefined" || nome.charAt(0) == " ")
{
Response.Redirect(errore + "1");
}
else if (!verifica.test(email))
{
Response.Redirect(errore + "2");
}
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 if (((spam1) != (spam2)) || spam2 == "undefined" || spam2.charAt(0) == "" || spam2.charAt(0) == " ")
{
Response.Redirect(errore + "5");
}
else
{
var r_messaggio = messaggio.replace(/</g, "<");
var rr_messaggio = r_messaggio.replace(/>/g, ">");
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+spam1+spam2;
recordset("data") = data;
recordset("ora") = ora;
recordset.Update();
recordset.Close();
inviamiMail();
Response.Redirect("guestbook2.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 favore</p>" + correggi);
}
else if (codice == "4")
{
Response.Write("<p class=\"ERRORE\">Inserisci il corpo del messaggio favore</p>" + correggi);
}
else if (codice == "5")
{
Response.Write("<p class=\"ERRORE\">Il codice di controllo antispam risulta errato</p>" + correggi);
}
else
{
Response.Redirect("guestbook2.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("guestbook2.asp");
}
else if (azione == "Logout")
{
// LOGOUT PER L'AMMINISTRATORE
Session.Abandon();
Response.Redirect("guestbook2.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("guestbook2.asp");
}
else
{
Response.Redirect("guestbook2.asp");
}
%>
<p align="center" class="Stile39">
<%
// 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=\"guestbook2.asp?pagina=" + (x + 1) + "\">" + (x + 1) + "</a>] ");
}
}
%>
</p>
<p align="center" class="Stile12">
<form name="login" method="post" action="guestbook2.asp?azione=<%Session("amministratore") == null ? Response.Write("Login") : Response.Write("Logout")%>">
<%if (Session("amministratore") == null) {%>
<input type="password" name="password">
<%}%>
<input type="submit" value="<%Session("amministratore") == null ? Response.Write("Login") : Response.Write("Logout")%>">
</form>
</div>