;; ==============================================
;; Script: web-tool.cgi
;; downloaded from: www.REBOL.org
;; on: 28-Mar-2024
;; at: 17:36:30.86327 UTC
;; owner: notchent [script library member who can
;; update this script]
;; ==============================================
REBOL [
title: "Web Server Management Tool"
date: 3-oct-2009
file: %web-tool.cgi
purpose: {
A CGI script to manage your web server. List directory contents,
upload, download, edit, and search for files, execute OS commands
(chmod, ls, mv, cp, etc. - any command available on your web server's
operating system), and run REBOL commands directly on your server.
Edited files are automatically backed up into an "edit_history" folder
on the server before being saved. No configuration is required for
most web servers. Just put this script AND the REBOL interpreter
into the same folder as your index.html file, set permissions (chmod)
to 755, then go to http://yourwebsite/web-tool.cgi :)
** THIS SCRIPT CAN POSE A MAJOR SECURITY THREAT TO YOUR SERVER **
It can potentially enable anyone to gain control of your web server
and everything it contains. DO NOT install it on your server if you're
at all concerned about security, or if you don't know how to secure your
server yourself.
The first line of this script must point to the location of the REBOL
interpreter on your web server, and you must use a version of REBOL
which supports the "call" function (version 2.76 is recommended). By
default, the REBOL interpreter should be uploaded to the same path
as this script, that folder should be publicly accessible, and you must
use the correct version of REBOL for the operating system on which
your server runs. IN THIS EXAMPLE, THE REBOL INTERPRETER HAS
BEEN RENAMED "REBOL276".
Taken from the tutorial at http://musiclessonz.com/rebol.html
}
]
;-------------------------------------------------------------------
; THE SCRIPT BEGINS ON THE LINE BELOW. If you install it on your web
; server, erase everything before "#! ./rebol276 -cs".
;-------------------------------------------------------------------
#! ./rebol276 -cs
REBOL [Title: "REBOL CGI Web Site Manager"]
;-------------------------------------------------------------------------
; Upload this script to the same path as index.html on your server, then
; upload REBOL interpreter to the path above (same, by default), chmod it
; AND this script 755. Run this script at www.yoursite.com/web-tool.cgi .
;-------------------------------------------------------------------------
; YOU CAN EDIT THESE VARIABLES, _IF_ NECESSARY (change the quoted values):
; The user name you want to use to log in:
set-username: "username"
; The password you want to use to log in:
set-password: "password"
;-------------------------------------------------------------------------
; Do NOT edit these variables:
doc-path: to-string what-dir
script-subfolder: find/match what-dir doc-path
if script-subfolder = none [script-subfolder: ""]
;-------------------------------------------------------------------------
; Get submitted data:
selection: decode-cgi system/options/cgi/query-string
read-cgi: func [/local data buffer][
switch system/options/cgi/request-method [
"POST" [
data: make string! 1020
buffer: make string! 16380
while [positive? read-io system/ports/input buffer 16380][
append data buffer
clear buffer
]
]
"GET" [data: system/options/cgi/query-string]
]
the-data: data
data
]
submitted: read-cgi
submitted-block: decode-cgi the-data
; ------------------------------------------------------------------------
; This section should be first because it prints a different header
; for a push download (not "content-type: text/html^/"):
if selection/2 = "download-confirm" [
print rejoin [
"Content-Type: application/x-unknown"
newline
"Content-Length: "
(size? to-file selection/4)
newline
"Content-Disposition: attachment; filename="
(second split-path to-file selection/4)
newline
]
data: read/binary to-file selection/4
data-length: size? to-file selection/4
write-io system/ports/output data data-length
quit
]
;-------------------------------------------------------------------------
; Print the normal HTML headers, for use by the rest of the script:
print "content-type: text/html^/"
print {
Web Site Manager}
;-------------------------------------------------------------------------
; If search has been called (via link on main form):
if selection/2 = "confirm-search" [
print rejoin [
{Back to Web Site Manager}
]
print {}
]
quit
]
;-------------------------------------------------------------------------
; If edited file text has been submitted:
if submitted-block/2 = "save" [
; Save newly edited document:
write (to-file submitted-block/6) submitted-block/4
print {Document Saved:
}
prin [" "<\/textarea>"
print []
print rejoin [
{ |
Back to Web Site Manager}
{