REBOL [
Title: "Phone Log"
Date: 2-Jul-2001
Version: 1.3.0
File: %phone-log.r
Author: "Sean C. Johnson"
Usage: {
^-This script is a cgi program. Place this script in the cgi-bin
^-directory of your webserver, change the path where the logs are saved,
^-call script from a browser (i.e. http://localhost/cgi-bin/phone-log.r).
^-Enjoy!
}
Purpose: {A cgi shared phone log in REBOL. Inspired by Andrew Grossman's guestbook.
}
History: {
^-1.3.0 Added debug func, revised logic to update log, more comments
^-1.1.0 Finally works with Xitami & Apache servers!
}
Email: sean@scj.net
Category: [cgi markup web 3]
Requires: %webpage.r
]
;--- Change the following path to be where you want to save the logs
;--- on your server. Remember it is relative to where the script is called!
;--- So, if your script is in Apache's cgi-bin this could be "%../htdocs/phone-logs/"
save-log-path: %"../webpages/reb/phone-logs/"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;--- You should not need to change anything below
;--- unless you like messing things up to learn :)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;--- Setup some basic junk
message-form: log-today: data: message: none
how-to-use: [
print rejoin [system/script/header/title ": "]
print system/script/header/purpose
print system/script/header/usage
print {This script quits in 15 seconds.}
wait 15
quit
]
if system/options/cgi/request-method = none [do how-to-use]
do system/script/header/requires
;--- Crude cgi debug functions
verbose: off ;--- turns on/off debug messages
cgi-debug: func [/local m][
if not verbose [return ""]
m: system/options/cgi/request-method
either m = "POST" [
data: retrieve-user-data
rejoin [m ":
" mold data]
][
rejoin [m ":
" system/options/cgi/query-string]
]
]
;--- Create phone log directories if they don't exist
;--- Logs are saved in dir "phone-logs", then by month (i.e. 3 means March),
;--- then by date (HTML).
log-path: rejoin [save-log-path now/month "/"]
log-today: to-file rejoin [log-path now/date ".html"]
if not exists? to-file log-path [make-dir/deep to-file log-path]
;--- HTML form for new messages
;--- May want to customize some field options
;--- Changes to form method require changes elsewhere in this script!
message-form: {