%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Check New Elements
FX_flag="MM_insert"
FX_rs = "" ' used for identification
FX_found = false
If (CStr(Request(FX_flag)) <> "") Then
FX_dupKeyRedirect="r_utilizador.asp"
FX_rsKeyConnection=MM_cenaberta_STRING
FX_dupKeyValue = CStr(Request.Form("email"))
FX_dupKeySQL="SELECT email FROM utilizadores WHERE email = '" & FX_dupKeyValue & "'"
FX_adodbRecordset="ADODB.Recordset"
set FX_rsKey=Server.CreateObject(FX_adodbRecordset)
FX_rsKey.ActiveConnection=FX_rsKeyConnection
FX_rsKey.Source=FX_dupKeySQL
FX_rsKey.CursorType=0
FX_rsKey.CursorLocation=2
FX_rsKey.LockType=3
FX_rsKey.Open
FX_dupKeyValue2 = CStr(Request.Form("chaveunica"))
FX_dupKeySQL2="SELECT chaveunica FROM utilizadores WHERE chaveunica = '" & FX_dupKeyValue2 & "'"
set FX_rsKey2=Server.CreateObject(FX_adodbRecordset)
FX_rsKey2.ActiveConnection=FX_rsKeyConnection
FX_rsKey2.Source=FX_dupKeySQL2
FX_rsKey2.CursorType=0
FX_rsKey2.CursorLocation=2
FX_rsKey2.LockType=3
FX_rsKey2.Open
If ((Not FX_rsKey.EOF Or Not FX_rsKey.BOF)) Then
' email foi encontrado
FX_found = true
FX_dupValue = "o email " & FX_dupKeyValue & "já existe na nossa base de dados!"
Else
If ((Not FX_rsKey2.EOF Or Not FX_rsKey2.BOF)) Then
' a chave única foi encontrada
FX_found = true
FX_dupValue = "houve um problema com a base de dados. Repita o processo"
End If
End If
if(FX_found) Then
FX_dupValue = FX_dupValue & ""
FX_qsChar = "?"
If (InStr(1,FX_dupKeyRedirect,"?") >= 1) Then FX_qsChar = "&"
FX_dupKeyRedirect = FX_dupKeyRedirect & FX_qsChar & "FX_ReqValue=" & Server.URLEncode(FX_dupValue)
Response.Redirect(FX_dupKeyRedirect)
End If
FX_rsKey.Close
FX_rsKey2.Close
End If
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")) = "form1") Then
MM_editConnection = MM_cenaberta_STRING
MM_editTable = "utilizadores"
MM_editRedirectUrl = ""
MM_fieldsStr = "email|value|expiracao|value|chaveunica|value"
MM_columnsStr = "email|',none,''|expiracao|',none,NULL|chaveunica|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(Request("MM_insert")) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
Else
'inserir aqui o script de envio
Dim objCDONTS ' Email object
Dim strFromName ' From persons' real name
Dim strFromEmail, strToEmail ' Email addresses
Dim strSubject, strBody ' Message
Dim strThisPage ' This page's URL
Dim strReferringPage ' The referring page's URL
Dim bValidInput ' A boolean indicating valid parameters
' Debugging lines:
'Response.Write strThisPage & " " & vbCrLf
'Response.Write strReferringPage & " " & vbCrLf
' Read in and set the initial values of our message parameters
strFromName ="cenaberta"
strFromEmail = "cenaberta@cenalusofona.pt"
strToEmail = Trim(Request.Form("email"))
strBcc = "cenaberta@cenalusofona.pt"
strSubject = "[registo cenaberta]"
strBody = ""
strchave = Trim(Request.Form("chaveunica"))
' I set the body message to a message that referenced the page the
' user arrived from. This makes it great if you place a link to it
' from your different articles, but can be weird if people link in
' from other web sites.
strBody = ""
strBody = strBody & "Olá," & vbCrLf
strBody = strBody & "bem-vindo ao cenaberta" & vbCrLf
strBody = strBody & "o e-mail " & strToEmail & " foi registado no site cenaberta." & vbCrLf
strBody = strBody & "se quiser receber a newsletter clique no link:" & vbCrLf
strBody = strBody & "http://www.cenalusofona.pt/cenaberta/utilizador_ok.asp?uid=" & strchave & vbCrLf
strBody = strBody & "Se o link não funcionar copie este endereço para o browser http://www.cenalusofona.pt/cenaberta/utilizador_ok.asp e, em seguida, copie o este código >> " & strchave & " << para o campo indicado." & vbCrLf
strBody = strBody & "" & vbCrLf
strBody = strBody & "Tem três dias para validar o seu endereço electrónico. Se não proceder à validação neste prazo, tem de repetir o processo de registo." & vbCrLf
' Set up our email object and send the message
Set objCDONTS = Server.CreateObject("CDONTS.NewMail")
objCDONTS.From = strFromName & " <" & strFromEmail & ">"
objCDONTS.To = strToEmail
objCDONTS.Bcc = strBcc
objCDONTS.Subject = strSubject
objCDONTS.Body = strBody
objCDONTS.Send
Set objCDONTS = Nothing
Response.Redirect("utilizador_ok.asp")
End If
End If
End If
%>
<%
set delete_old = Server.CreateObject("ADODB.Command")
delete_old.ActiveConnection = MM_cenaberta_STRING
delete_old.CommandText = "DELETE FROM utilizadores WHERE receber_newsletter = False and expiracao
<%
Dim ultimachave
Dim ultimachave_numRows
Set ultimachave = Server.CreateObject("ADODB.Recordset")
ultimachave.ActiveConnection = MM_cenaberta_STRING
ultimachave.Source = "SELECT chaveunica, id_utilizadores FROM utilizadores ORDER BY id_utilizadores DESC"
ultimachave.CursorType = 0
ultimachave.CursorLocation = 2
ultimachave.LockType = 1
ultimachave.Open()
ultimachave_numRows = 0
%>
<%
Session("FX_checkvalue") = ""
Session("FX_checkvalue2") = ""
%>
cenaberta
<% If Request.QueryString("cmd")="" or Request.QueryString("cmd")="off" Then %>
<%= Request.QueryString("FX_ReqValue") %>
<%
Dim X, Y, strPW
For X = 1 To 10
'Randomize the type of this character
Y = Int((3 * Rnd) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase
Select Case Y
Case 1
'Numeric character
Randomize
strPW = strPW & CHR(Int((9 * Rnd) + 48))
Case 2
'Uppercase character
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 65))
Case 3
'Lowercase character
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 97))
End Select
Next
RandomPW = strPW
strchave=Trim(Request.Form("chaveunica"))
%>
<% If Request.QueryString("erro")<>"" Then %>
<% End If %>
clique aqui para receber a newsletter do cenaberta, ou então envie um e-mail para cenaberta@cenalusofona.pt com [subscrever newsletter] no Assunto.
<% End if %>
<%
ultimachave.Close()
Set ultimachave = Nothing
%>