% Const Pass = "LB53572" ' Must be UPPER CASE. Not case-sensitive for end-user. ' Online end-user quickie HTML editor. Allow users to edit their own web sites. ' ' Copyright 2005 by Dennis Hevener http://hosenose.net ' ' Put comments in HTML before and after text that the user is allowed to edit: ' ' ' (editable html....) ' ' ' Be sure to put spaces before & after the tags as shown above. ' ' Then just make a hyperlink to this page. ' Optional parameters that can be passed on the command line: ' ' FileName Name of the file to edit. Defaults to the calling page. ' BeginDemim Comment tag marking beginning of user-editable text. Default is BEGINUSER ' EndDemim Comment tag marking beginning of user-editable text. Default is ENDUSER ' ' Changing the beginning and ending delimiters allows having more than one editable region on a page. class StringSplitter ' split string into three parts. Used to extract parts of a .HTML file ' for editing. Place a begin and end tag as a comment in the .HTML. private m_text Public Property Get Text() Text = m_text End Property Public Property Let Text(x) m_Text = x End Property ' get text between delimiters Public function GetMiddle(BeginDelim, EndDelim) Dim BegPtr, EndPtr BegPtr = instr(m_text, BeginDelim) + len(begindelim) EndPtr = instr(m_text, EndDelim) GetMiddle = Mid(m_text, BegPtr, EndPtr - BegPtr) End function ' Replace the text between delimiters Public Function SetMiddle(BeginDelim, EndDelim, NewText) m_text = Left(m_text, instr(m_text, BeginDelim) - 1) _ & BeginDelim _ & NewText _ & EndDelim _ & Mid(m_text, instr(m_text, EndDelim)+ len(EndDelim)) end function end class %>
<% ElseIf Len(Request.Form("FCKeditor1")) > 0 Then ' write page Dim oFSO, oFile, strHTML Set oFSO = Server.CreateObject("Scripting.FileSystemObject") ' Open the file, read it, substitute between the tags, and write back Set oFile = oFSO.OpenTextFile(server.mappath(request.form("filename"))) strHtml = oFile.ReadAll() set StrSplitter = new StringSplitter StrSplitter.Text = strHtml StrSplitter.SetMiddle "", "", Request.Form("FCKEditor1") Set oFile = oFSO.CreateTextFile(server.mappath(request.form("filename")), True) oFile.Write(StrSplitter.Text) oFile.Close() Set oFile = Nothing Set oFSO = Nothing Set StrSplitter=nothing session.abandon %> Changes posted. ">Click here to see the results. You may have to click the Refresh button in your browser to reload the page. <% else ' Edit %>