[0001] [0002] [0003] [0004] [0005] [0006] [0007] [0008] [0009] [0010] [0011] [0012] [0013] [0014] [0015] [0016] [0017] [0018] [0019] [0020] [0021] [0022] [0023] [0024] [0025] [0026] [0027] [0028] [0029] [0030] [0031] [0032] [0033] [0034] [0035] [0036] [0037] [0038] [0039] [0040] [0041] [0042] [0043] [0044] [0045] [0046] [0047] [0048] [0049] [0050] [0051] [0052] [0053] [0054] [0055] [0056] [0057] [0058] [0059] [0060] [0061] [0062] [0063] [0064] [0065] [0066] [0067] [0068] [0069] [0070] [0071] [0072] [0073] [0074] [0075] [0076] [0077] [0078] [0079] [0080] [0081] [0082] [0083] [0084] [0085] [0086] [0087] [0088] [0089] [0090] [0091] [0092] [0093] [0094] [0095] [0096] [0097] [0098] [0099] [0100] [0101] [0102] [0103] [0104] [0105] [0106] [0107] [0108]
$! 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';*