<%@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 & "?" & Request.QueryString End If ' boolean to abort record edit MM_abortEdit = false ' query string to execute MM_editQuery = "" %> <% ' *** Insert Record: set variables If (CStr(Request("MM_insert")) = "form1") Then MM_editConnection = MM_cenaberta_STRING MM_editTable = "forum" MM_editRedirectUrl = "comentario_ok.asp?coment_ok=comentário adicionado com sucesso" MM_fieldsStr = "ftitulo|value|ftexto|value|fassinatura|value|femail|value|flocalidade|value|fanonimo|value|id_noticia|value|fpublicar|value" MM_columnsStr = "ftitulo|',none,''|ftexto|',none,''|fassinatura|',none,''|femail|',none,''|flocalidade|',none,''|fanonimo|none,1,0|id_noticia|none,none,NULL|fpublicar|none,none,NULL" ' 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) End If End If End If %> <% Dim menu Dim menu_numRows Set menu = Server.CreateObject("ADODB.Recordset") menu.ActiveConnection = MM_cenaberta_STRING menu.Source = "SELECT * FROM seccao WHERE mostrar=1 ORDER BY secao" menu.CursorType = 0 menu.CursorLocation = 2 menu.LockType = 1 menu.Open() menu_numRows = 0 %> <% Dim noticia__MMIdNoticia noticia__MMIdNoticia = "0" If (request.querystring("id") <> "") Then noticia__MMIdNoticia = request.querystring("id") End If %> <% Dim noticia__MMIdCanal noticia__MMIdCanal = "0" If (request.querystring("idcanal") <> "") Then noticia__MMIdCanal = request.querystring("idcanal") End If %> <% Dim noticia Dim noticia_numRows Set noticia = Server.CreateObject("ADODB.Recordset") noticia.ActiveConnection = MM_cenaberta_STRING noticia.Source = "SELECT * FROM noticias WHERE id_noticia=" + Replace(noticia__MMIdNoticia, "'", "''") + " AND id_seccao=" + Replace(noticia__MMIdCanal, "'", "''") + "" noticia.CursorType = 0 noticia.CursorLocation = 2 noticia.LockType = 1 noticia.Open() noticia_numRows = 0 %> <% Dim canal__MMIdCanal canal__MMIdCanal = "1" If (Request.querystring("idcanal") <> "") Then canal__MMIdCanal = Request.querystring("idcanal") End If %> <% Dim canal Dim canal_numRows Set canal = Server.CreateObject("ADODB.Recordset") canal.ActiveConnection = MM_cenaberta_STRING canal.Source = "SELECT * FROM seccao WHERE id_seccao=" + Replace(canal__MMIdCanal, "'", "''") + "" canal.CursorType = 0 canal.CursorLocation = 2 canal.LockType = 1 canal.Open() canal_numRows = 0 %> <% Dim imagens__MMIdNoticia imagens__MMIdNoticia = "0" If (request.QueryString("id") <> "") Then imagens__MMIdNoticia = request.QueryString("id") End If %> <% Dim imagens Dim imagens_numRows Set imagens = Server.CreateObject("ADODB.Recordset") imagens.ActiveConnection = MM_cenaberta_STRING imagens.Source = "SELECT * FROM imagens WHERE id_noticia=" + Replace(imagens__MMIdNoticia, "'", "''") + " AND destaque<>1" imagens.CursorType = 0 imagens.CursorLocation = 2 imagens.LockType = 1 imagens.Open() imagens_numRows = 0 %> <% Dim link_rela__MMColNotRela link_rela__MMColNotRela = "0" If (request.querystring("id") <> "") Then link_rela__MMColNotRela = request.querystring("id") End If %> <% Dim link_rela Dim link_rela_numRows Set link_rela = Server.CreateObject("ADODB.Recordset") link_rela.ActiveConnection = MM_cenaberta_STRING link_rela.Source = "SELECT * FROM relacionada WHERE id_noticia=" + Replace(link_rela__MMColNotRela, "'", "''") + " and tipo=1" link_rela.CursorType = 0 link_rela.CursorLocation = 2 link_rela.LockType = 1 link_rela.Open() link_rela_numRows = 0 %> <% Dim not_rela__MMColNotRela not_rela__MMColNotRela = "0" If (Request.querystring("id") <> "") Then not_rela__MMColNotRela = Request.querystring("id") End If %> <% Dim not_rela Dim not_rela_numRows Set not_rela = Server.CreateObject("ADODB.Recordset") not_rela.ActiveConnection = MM_cenaberta_STRING not_rela.Source = "SELECT * FROM relacionada WHERE id_noticia=" + Replace(not_rela__MMColNotRela, "'", "''") + " and tipo=2" not_rela.CursorType = 0 not_rela.CursorLocation = 2 not_rela.LockType = 1 not_rela.Open() not_rela_numRows = 0 %> <% Dim forum__MMColParamForum forum__MMColParamForum = "54" If (request.querystring("id") <> "") Then forum__MMColParamForum = request.querystring("id") End If %> <% Dim forum Dim forum_numRows Set forum = Server.CreateObject("ADODB.Recordset") forum.ActiveConnection = MM_cenaberta_STRING forum.Source = "SELECT * FROM forum WHERE id_noticia=" + Replace(forum__MMColParamForum, "'", "''") + " AND fpublicar=1" forum.CursorType = 0 forum.CursorLocation = 2 forum.LockType = 1 forum.Open() forum_numRows = 0 %> <% Dim Repeat1__numRows Dim Repeat1__index Repeat1__numRows = -1 Repeat1__index = 0 menu_numRows = menu_numRows + Repeat1__numRows %> <% Dim Repeat2__numRows Dim Repeat2__index Repeat2__numRows = -1 Repeat2__index = 0 imagens_numRows = imagens_numRows + Repeat2__numRows %> <% Dim Repeat3__numRows Dim Repeat3__index Repeat3__numRows = -1 Repeat3__index = 0 link_rela_numRows = link_rela_numRows + Repeat3__numRows %> <% Dim Repeat5__numRows Dim Repeat5__index Repeat5__numRows = -1 Repeat5__index = 0 forum_numRows = forum_numRows + Repeat5__numRows %> <% Dim Repeat4__numRows Dim Repeat4__index Repeat4__numRows = -1 Repeat4__index = 0 not_rela_numRows = not_rela_numRows + Repeat4__numRows %> cenaberta apresentação memória agenda documentação destaque edições conexões <% menu.Close() Set menu = Nothing %> <% noticia.Close() Set noticia = Nothing %> <% canal.Close() Set canal = Nothing %> <% imagens.Close() Set imagens = Nothing %> <% link_rela.Close() Set link_rela = Nothing %> <% not_rela.Close() Set not_rela = Nothing %> <% forum.Close() Set forum = Nothing %>