<%@LANGUAGE = JScript%> <% /* 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 = "riccardo"; // ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- /* 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. */ // ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- Response.Buffer = true; // 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("percorso/guestbook.mdb") var connessione = new ActiveXObject("ADODB.Connection"); var stringa = "driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("/mdb-database/ordine.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 ordine"); %> Modulo richiesta

 

 

 

  AERITEL - Astronomia - Telecomunicazioni   

 

 

 

Per chiedere informazioni inerenti i nostri prodotti

compilate il seguente modulo.

 

In caso di ordine, inserire i dati relativi. Prima di rendere esecutivo

lo stesso vi contatteremo, per accordi, via e-mail o telefonicamente.

 

 

 

Cognome e Nome
Indirizzo - Cittā - Telefono
e-mail
Prodotto - info

Pagamento

Inserire messaggio

 

<% if (azione == "undefined") { %> <% %> <% %>

<% } 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 prodotto = new String(Request.Form("prodotto")); var pagamento = new String(Request.Form("pagamento")); 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 = "ordine.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 (messaggio == "" || messaggio == "undefined" || messaggio.charAt(0) == " ") { Response.Redirect(errore + "4"); } else { var r_messaggio = 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("ordine",connessione,3,3); recordset.AddNew(); recordset("nome") = nome; recordset("email") = email; recordset("homepage") = homepage; recordset("titolo") = prodotto; recordset("messaggio") = rrrr_messaggio; recordset("pagamento") = pagamento; recordset("data") = data; recordset("ora") = ora; recordset.Update(); recordset.Close(); Response.Redirect("invio.htm"); } } else if (azione == "errore") { // GESTIONE DEI MESSAGGI DI ERRORE var codice = parseInt(Request.QueryString("codice")); var correggi = "

"; if (codice == "1") { Response.Write("

Inserisci il tuo nome per favore

" + correggi); } else if (codice == "2") { Response.Write("

Inserisci la tua email per favore

" + correggi); } else if (codice == "2") { Response.Write("

Inserisci la tua email per favore

" + correggi); } else if (codice == "4") { Response.Write("

Inserisci il corpo del messaggio favore

" + correggi); } else { Response.Redirect("ordine.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("ordine.asp"); } else if (azione == "Logout") { // LOGOUT PER L'AMMINISTRATORE Session.Abandon(); Response.Redirect("ordine.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("ordine.asp"); } else { Response.Redirect("ordine.asp"); } %>
">

<%if (Session("amministratore") == null) {%> <%}%> ">

<%connessione.Close()%>