$! CGIUTL.C Usage Example $! Submitted by example form WASD_ROOT:[SRC.MISC]CGIUTL_EXAMPLE.HTML $! 28-DEC-2008 MGD bugfix; CGI response for DEBUG=1 $! 24-APR-1999 MGD now using CGILIB, remove http$input redirect $! 13-FEB-1999 MGD add /2QUOTE $! 07-FEB-1999 MGD initial $! $ Debug = 0 $ if Debug $ then $ write sys$output "Content-type: text/plain" $ write sys$output "" $ set verify $ endif $! $! Change to 1, copy procedure to WASD_ROOT:[SCRIPT_LOCAL] to permanently enable. $ MailEnabled = 0 $! Or, define this logical to anything to enable. $ if f$trnlnm("CGIUTL_EXAMPLE$ENABLE") .nes. "" then MailEnabled = 1 $! $ say = "write sys$output" $ CGIutl = "$cgi-bin:[000000]cgiutl" $! Locate a unique scratch file somewhere we know the server account can write. $ FileName = "wasd_scratch:CGIUTL" + f$cvtime(,,"year") + - f$cvtime(,,"month") + f$cvtime(,,"day") + f$cvtime(,,"hour") + - f$cvtime(,,"minute") + f$cvtime(,,"second") + - f$cvtime(,,"hundredth") + ".TXT" $! $ if Debug then show symbol * $! Use the CGIUTL utility to process the POSTed body contents. $ CGIutl /urldecode /symbols=(lines,nocontrol) /output='FileName' $ if Debug then show symbol * $! $ if f$search(FileName) .eqs. "" $ then $ say "Content-Type: text/html" $ say "" $ say "ERROR generating survey file!" $ exit $ endif $! $ set noon $ on error then goto CleanUp $! $! ensure there are enough quotes for DCL substitution $ if Debug then show symbol www_http_referer $ CGIutl www_http_referer /2quote $ if Debug then show symbol www_http_referer $! some additional information $ open /append FileHandle 'FileName' $! just over-cautious $ WWW_REMOTE_HOST = f$element(0,"/",WWW_REMOTE_HOST) $ WWW_HTTP_REFERER = f$element(0,"/",WWW_HTTP_REFERER) $ write FileHandle "(from: ''WWW_REMOTE_HOST' via ''WWW_HTTP_REFERER')" $ close FileHandle $! $! 'cgiutl_subject' should be a symbol created by CGIUTL from request body. $ if f$type(cgiutl_subject) .eqs. "" then cgiutl_subject = "*NO SUBJECT*" $! ensure there are enough quotes for DCL substitution $ if Debug then show symbol cgiutl_subject $ CGIutl cgiutl_subject /2quote $ if Debug then show symbol cgiutl_subject $! $ if MailEnabled $ then $! $ mail 'FileName' SYSTEM /subject="''cgiutl_subject'" $! $ MailStatus = $STATUS $ say "Content-Type: text/html" $ say "" $ if MailStatus $ then $ say "Survey submitted.  Thankyou." $ else $ say "Error occured when mailing survey: ''MailStatus'" $ endif $! $ else $! $ say "Content-Type: text/plain" $ say "" $ say "Actual mailing of this survey is NOT ENABLED!" $ say "To enable, modify the procedure WASD_ROOT:[SCRIPT]CGIUTL_EXAMPLE.COM" $ say "or do a DEFINE /SYSTEM CGIUTL_EXAMPLE$ENABLE 1" $ say "" $ say "This is what the addressee would have received by mail:" $ say "" $ say f$fao("!80*-") $ say "From: " + f$getsyi("nodename") + "::" + - f$edit(f$getjpi("","USERNAME"),"COLLAPSE") $ say "To: SYSTEM" $ say "CC:" $ say "Subj: ''cgiutl_subject'" $ say "" $ type /nopage 'FileName' $ say f$fao("!80*-") $ say "" $ say "And here are the CGIUTL-specific symbols created from the request:" $ say "" $ show symbol cgiutl%* $ say "" $! $ endif $! $ CleanUp: $ if f$trnlnm("FileHandle","LNM$PROCESS") .nes. "" then close FileHandle $ if f$search(FileName) .nes. "" then delete /nolog /noconfirm 'FileName';*