codice:
<% Option Explicit %>
<% Response.Buffer = True %>
<%
If Not Session("user") And Not Session("admin") Then
Response.Redirect("userError.htm")
Else
%>
<%
' ********************************************************************
' INSERIMENTO NELLE VARIABILI DEI PARAMETRI DELLA TABELLA IMPOSTAZIONI
' ********************************************************************
Dim objRso, strSql, strFromAddress, strBccAddress, strObjectOthEmail, strOthChiusura, bolError, intCnt
Set objRso = Server.CreateObject("ADODB.Recordset")
strSql = "SELECT strFromAddress, strBccAddress, strObjectOthEmail, strOthChiusura FROM tblImpostazioni"
objRso.Open strSql, objCon, adOpenkeyset, adLockReadOnly, adCmdText
strFromAddress = objRso("strFromAddress")
strBccAddress = objRso("strBccAddress")
strObjectOthEmail = objRso("strObjectOthEmail")
strOthChiusura = objRso("strOthChiusura")
objRso.Close
%>
<%
Response.Expires = -1500
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
%>
<html>
<head>
<title>Modifiche eseguite</title>
<link rel="stylesheet" type="text/css" href="../stile/stile.css">
</head>
<script language=javascript>
<!--
function ferme() {
fenetre=this.window
fenetre.close()
}
//-->
</SCRIPT>
<body vlink="#0000FF" bgcolor="#003466">
<%
' ***************************************************************************************
' INSERIMENTO NELLE VARIABILI DEI CAMPI MODULO E CREAZIONE DELLA STRINGA SQL PER L'UPDATE
' ***************************************************************************************
Dim strFieldName, varFieldValue, strUpdateValues, chrWc
strSql = "SELECT strFieldName, strFieldDescription, chrWc FROM tblTableFields WHERE intPriority <> 0 " & _
"AND intPriority <> 91 AND intPriority <> 94 AND intPriority <> 95 AND intPriority <> 96 AND intPriority <> 97 " & _
"AND intPriority <> 98 AND intPriority <> 99 AND intPriority <> 90"
objRso.Open strSql, objCon, adOpenKeyset, adLockReadOnly, adCmdText
Do While Not objRso.EOF
strFieldName = objRso("strFieldName")
chrWc = objRso("chrWc")
varFieldValue = Server.HTMLEncode(Trim(Replace(Request.Form(strFieldName),"'","`")))
strUpdateValues = strUpdateValues & strFieldName & " = " & chrWc & varFieldValue & chrWc
objRso.Movenext
If Not objRso.EOF Then strUpdateValues = strUpdateValues & ", "
Loop
objRso.Close
strSql = "UPDATE tblUtenti SET " & strUpdateValues & " WHERE strSessione = '" & Session("id") & "'"
' **************************************************
' CREAZIONE OGGETTO COMMAND E SCRITTURA NEL DATABASE
' **************************************************
Dim objCmd, intNrOfRecords
Set objCmd = Server.CreateObject("ADODB.Command")
objCmd.ActiveConnection = objCon
objCmd.CommandText = strSql
objCmd.CommandType = adCmdText
objCmd.Execute intNrOfRecords
Set objCmd = Nothing
If intNrOfRecords = 1 Then
Dim strEmail, strEmailType, strUserid, strPassword
strSql = "SELECT strEmail, strEmailType, strUserid, strPassword FROM tblUtenti WHERE strSessione = '" & Session("id") & "'"
objRso.Open strSql, objCon, adOpenKeyset, adLockReadOnly, adCmdText
If objRso.Recordcount = 1 Then
strEmail = objRso("strEmail")
strEmailType = objRso("strEmailType")
strUSerid = objRso("strUserid")
strPassword = objRso("strPassword")
Dim strMsg
If strEmailType = "html" Then
strMsg = "<HTML>" & vbCrLf
strMsg = strMsg & "<HEAD><TITLE>Modifica dati utente</TITLE></HEAD>" & vbCrLf
strMsg = strMsg & "<BODY BGCOLOR=""#FFFFFF"">" & vbCrLf
strMsg = strMsg & "<FONT FACE=""Tahoma"" SIZE=""2"" COLOR=""#000000"">
Il tuo profilo è stato modificato.</P>" & vbCrLf
strMsg = strMsg & "
Per sicurezza comunichiamo gli attuali dati di accesso.</P>" & vbCrLf
strMsg = strMsg & "
" & strOthChiusura & "</P>" & vbCrLf
strMsg = strMsg & "
User-Id: " & strUserid & "
Password: " & strPassword & "</P>" & vbCrLf
strMsg = strMsg & "</BODY>" & vbCrLf
strMsg = strMsg & "</HTML>" & vbCrLf
Else
strMsg = "Il vostro profilo è stato modificato." & vbCrLf & vbCrLf
strMsg = strMsg & "Per sicurezza comunichiamo gli attuali dati di accesso." & vbCrLf & vbCrLf
strMsg = strMsg & strOthChiusura & vbCrLf & vbCrLf
strMsg = strMsg & "User-id: " & strUserid & vbCrLf & "Password: " & strPassword & vbCrLf & vbCrLf
End If
' ********************************************
' SPEDIZIONE E-MAIL PER CONFERMA MODIFICA DATI
' ********************************************
Dim objNewMail, CdoBodyFormatHTML, CdoMailFormatHTML, CdoBodyFormatTESTO, CdoMailFormatTESTO
CdoBodyFormatHTML = 0
CdoMailFormatHTML = 0
CdoBodyFormatTESTO = 1
CdoMailFormatTESTO = 1
Set objNewMail = CreateObject("CDONTS.NewMail")
objNewMail.From = strFromAddress
objNewMail.To = strEmail
objNewMail.Bcc = strBccAddress
objNewMail.Importance = 2
objNewMail.Subject = strObjectOthEmail
If strEmailType = "html" Then
objNewMail.BodyFormat = CdoBodyFormatHTML
objNewMail.MailFormat = CdoMailFormatHTML
Else
objNewMail.BodyFormat = CdoBodyFormatTESTO
objNewMail.MailFormat = CdoMailFormatTESTO
Call ConvertToPlainText(strMsg)
End If
objNewMail.Body = strMsg
objNewMail.Send
set objNewMail = Nothing
Response.Write "<font face=""verdana, arial"" size=""2"" color=""#FFFFFF"">Procedura eseguita correttamente.
"
Response.Write "Una E-mail è stata inviata all'indirizzo " & strEmail & ".
"
Else
Response.Write "<font face=""verdana, arial"" size=""2"" color=""#FFFFFF"">Problemi nella rilettura dei dati dal database.
"
Response.Write "Non è stato possibile spedire la e-mail di conferma.
"
Response.Write "Vi preghiamo di ricontrollare i vostri dati ed eventualmente di riprovare.</font>
"
End If
objRso.Close
Set objRso = Nothing
Else
Response.Write "<font face=""verdana, arial"" size=""2"" color=""#FFFFFF"">Problemi nella scrittura dei dati nel database.
"
Response.Write "Non è stato possibile effettuare l'operazione di modifica.
"
Response.Write "Vi preghiamo di riprovare.</font>
"
End If
%>
<a href="UserLogin.asp"><font color="#FFFFFF">Torna
indietro</font></a><font color="#FFFFFF"> - </font>
<a href="" onclick="window.close()"><font color="#FFFF00">Chiudi la
finestra</font></a></p>
</body>
</html>
<%
End If
' ***************************************
' SUB ROUTINE CONVERSIONE DA HTML A TESTO
' ***************************************
Sub ConvertToPlainText(frase)
frase = Replace(frase, "<", "<")
frase = Replace(frase, ">", ">")
frase = Replace(frase, "&", "&")
frase = Replace(frase, """, chr(34))
frase = Replace(frase, "€", chr(128))
frase = Replace(frase, "‚", chr(130))
frase = Replace(frase, "ƒ", chr(131))
frase = Replace(frase, "„", chr(132))
frase = Replace(frase, "…", chr(133))
frase = Replace(frase, "†", chr(134))
frase = Replace(frase, "‡", chr(135))
frase = Replace(frase, "ˆ", chr(136))
frase = Replace(frase, "‰", chr(137))
frase = Replace(frase, "Š", chr(138))
frase = Replace(frase, "‹", chr(139))
frase = Replace(frase, "Œ", chr(140))
frase = Replace(frase, "Ž", chr(142))
frase = Replace(frase, "‘", chr(145))
frase = Replace(frase, "’", chr(146))
frase = Replace(frase, "“", chr(147))
frase = Replace(frase, "”", chr(148))
frase = Replace(frase, "•", chr(149))
frase = Replace(frase, "–", chr(150))
frase = Replace(frase, "—", chr(151))
frase = Replace(frase, "˜", chr(152))
frase = Replace(frase, "™", chr(153))
frase = Replace(frase, "š", chr(154))
frase = Replace(frase, "›", chr(155))
frase = Replace(frase, "œ", chr(156))
frase = Replace(frase, "ž", chr(158))
frase = Replace(frase, "Ÿ", chr(159))
For intCnt = 160 to 255
frase = Replace(frase, "&#" & intCnt & ";", chr(intCnt))
Next
End Sub
%>