Edit Your files from any Website

Added By: yahavbr

(3 of 5) by 9.
Rate Snippet:
Description:  Simple Editor, basically alike Brinkster's Editor which enables an admin to edit any page on your site. Usage: on any page you want to edit, HTML or ASP, put link to the script, e.g. <A href='Edit.asp'>Edit This Page</A> and that's it. The Edit.asp page identifies the page to be edited as the Referer, prompts for username/password and displays textarea letting the admin edit the file and Saving it. There is also time-counter which shows how much time is left until session is expired, to prevent undesired data loss. Comments/Suggestions please send to yahavbr@hotmail.com Yahav
Language:  Visual Basic Script

Save to web space
E-mail Link

Code Snippet:

") Response.Write("
") Response.Write("
") Response.Write("Cancel, and return to "&pageToEdit&"") Response.Write("
") Response.Write("") Else Response.Write("

Requested file, "&strFilePath&", does not exist on the Server.

") End If Set fso=Nothing Response.END End Function Function GrabPath(strAddress) Dim strHost, iHostIndex, iHostLength strHost=Request.ServerVariables("HTTP_HOST") iHostIndex=InStr(strAddress, strHost) If iHostIndex=0 Then Response.Write("

You can edit only pages of this site!

") Response.END End If iHostLength=Len(strHost) GrabPath=Server.MapPath(Mid(strAddress, iHostIndex+iHostLength, Len(strAddress))) End Function Function GetRowsCount(str) Dim arrLines arrLines=Split(str, VBCrLf) GetRowsCount=UBound(arrLines)+1 'free memory: Erase arrLines End Function Function GetColsCount(str) Dim arrLines, x, iMaxLength iMaxLength=0 arrLines=Split(str, VBCrLf) For x=0 To UBound(arrLines) If Len(arrLines(x))>iMaxLength Then iMaxLength=Len(arrLines(x)) End If Next GetColsCount=iMaxLength 'free memory: Erase arrLines End Function Function SaveFile() If Session("AdminLogged")="" Then Response.Write("

Session expired, page not saved.

") Exit Function End If Dim fso, objFile, strPath Dim strContents strPath=Request.Form("pagePath") strContents=Request.Form("fileContents") If Len(strContents)<1 Then Response.Write("

You can't delete this file.

") Exit Function End If Set fso=Server.CreateObject("Scripting.FileSystemObject") If fso.FileExists(strPath) Then Set objFile=fso.CreateTextFile(strPath) objFile.Write(strContents) objFile.Close Set objFile=Nothing Response.Write("

File Saved Successfully.

") Else Response.Write("

File does not exist! You can't create new files.

") End If Set fso=Nothing End Function Function WriteCounterScript() Response.Write("") End Function %>