-- -- Quick and dirty (Apple)Script to put form results into a feedbak html file -- Requires -- DecodeURL_8bits ( http://mtlab.ecn.fpu.ac.jp/scripting/Jcode_osax.html ) -- Note: the strange chars at the end of some lines (Â) are opt-L in a Mac -- -- Uncomment next line for debuging -- set post_args to "" if post_args = "" then set debug to true set post_args to  "username=nobody" &  "&usermail=foo@hell.freeze.over.es" &  "&Home=Eres+un+%A1%22Cabr%F3n%22%21%0D%0Ajoperra" set username to "daemon" set client_address to "hell.freeze.over.es" else set debug to false end if -- -- Function which returns string after first '=' (or "???" if null) -- on stripnamevar(str) --cut all before first "=" set x to 1 repeat until character x of str = "=" set x to x + 1 end repeat set x to x + 1 if (x > length of str) then set newstr to "???" else -- copy text from character x to (length of str) of str to newstr set newstr to Decode URL text from character x to (length of str) of str end if return newstr end stripnamevar -- -- Main function; input = http_search_args -- set http_fields to {"username", "usermail", "Menu", "Home"} set LastField to number of items of http_fields set HTML_file to "Persephone:WWW:Admin:feedback.html" -- output file set crlf to (ASCII character 13) & (ASCII character 10) set http_10_header to "HTTP/1.0 200 OK" & crlf & "Server: MacHTTP" & crlf &  "MIME-Version: 1.0" & crlf & "Content-type: text/html" & crlf & crlf set x to 1 set args to "" repeat until x > length of post_args set c to character x of post_args if c = "+" then set args to args & space else set args to args & c end if set x to x + 1 end repeat -- change every '+' to ' ' set oldDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to "&" set LastArg to number of text items of args set CurrArg to "" set CurrField to 1 set CurrStr to 1 set output to {} repeat if text item CurrStr of args begins with item CurrField of http_fields then if CurrArg ­ "" then -- This is a 'not equal' set output to output & {CurrArg} end if set CurrField to CurrField + 1 if CurrField > LastField then set CurrField to LastField set CurrArg to text item CurrStr of args else set CurrArg to CurrArg & "&" & text item CurrStr of args end if set CurrStr to CurrStr + 1 if CurrStr > LastArg then exit repeat end if end repeat set output to output & {CurrArg} set uname to stripnamevar(first item of output) set addr to stripnamevar(second item of output) set os to stripnamevar(third item of output) set comment to stripnamevar(fourth item of output) set AppleScript's text item delimiters to oldDelimiters set feedback to "

" & uname & " (" & addr & "), " & os & Â ", said:

" & return & comment & "

" & return & Â "" & return if debug then return feedback else set output to (open for access alias HTML_file with write permission) write feedback starting at ((get eof output) + 1) to output close access output -- open HTML_file for append and write result return http_10_header & "Server Query Response" & Â "

Hi!

" & Â "We get it. Thanks for the feedback .

" & Â "


www@ivo.cps.unizar.es
" end if