USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Dicas

  ASP - Active Server Page    (Miscelâneas)

Título da Dica:  Editor On-Line
Postada em 3/10/2003 por ^HEAVY-METAL^            
Um editor on Line Sempre ajuda

----------------------------------
<%
arquivo = request("arquivo")

' Gravação da alteração
if request("fill")=1 then
     Dim objFSO, objCountFile
     Dim strCountFileName
     strCountFileName = Server.MapPath(arquivo)
     Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
     Set objCountFile = objFSO.CreateTextFile(strCountFileName, True)
     objCountFile.Write request("texto")
     objCountFile.Close
     Set objCountFile = Nothing
     Set objFSO = Nothing
     ' Ação depois da alteração
     response.redirect("editor.asp?arquivo=" & arquivo)
else

' Verifica se existe o texto a ser editado
if arquivo <> "" then
     Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
     Set objFolder = objFSO.GetFolder(Server.MapPath("."))
          existe = 0
          For Each objFile in objFolder.Files
               if right(objFile,len(arquivo)) = arquivo then
                    existe = 1
               end if
          next
     Set objFolder = Nothing
     Set objFSO = Nothing
end if

if existe = 1 then
' Se existir, lê o texto atual
    Set fs = Server.CreateObject("Scripting.FileSystemObject")
     Set arq = fs.OpenTextFile(server.MapPath(arquivo))
     Do while Arq.AtEndOfStream = false
         texto = texto & arq.Readline
     Loop
          ' Texto encontrado
          texto = left(texto,len(texto))
          texto = replace(texto,chr(34),"'",1)
     Set fs = nothing
     Set arq = nothing
else
          ' Texto não encontrado
          response.write "Texto não encontrado!"
end if
%>

<html>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
  function Pick_Text(f) {
    f.elements.texto.value = document.all.editor.html + "";
  }
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
  function Preencher() {
    document.all.editor.html = <%= chr(34) & texto & chr(34) %>;
  }
</SCRIPT>
</HEAD>
<BODY onload="Preencher();" leftmargin="20" topmargin="20">

<FORM METHOD="POST" NAME="XXX" ACTION="editor.asp" onSubmit="Pick_Text(this);">
     <TEXTAREA NAME="texto" STYLE="display: none"></TEXTAREA>
     <OBJECT ID=editor DATA="editor.htm" TYPE="text/x-scriptlet" WIDTH="450" HEIGHT="300">
          <!-- Isto só é exibido em browsers que não suportam scriptlets -->
     </OBJECT>
     <br>
     <INPUT TYPE="Submit" NAME="submit" VALUE="Salvar">
     <INPUT TYPE="Hidden" NAME="fill" VALUE="1">
     <INPUT TYPE="Hidden" NAME="arquivo" VALUE='<%= arquivo %>'>
</FORM>

<% end if %>

</BODY>
</html>

---------------------

T+,
 


CyberWEB Network Ltda.    © Copyright 2000-2024   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página