1#!/depot/path/tclsh 2 3package require cgi 4 5cgi_eval { 6 source example.tcl 7 8 input 9 10 title "cgi.tcl examples" 11 12 # use targets if we are framed 13 if {0==[catch {import framed}]} { 14 set target "target=script" 15 } else { 16 set target "" 17 } 18 19 # create a hyperlink to run a script 20 proc run {name} { 21 url $name.cgi [cgi $name] [uplevel {set target}] 22 } 23 24 # create hyperlink to show script source 25 proc display {name} { 26 url $name.cgi [cgi display scriptname=$name.cgi] [uplevel {set target}] 27 } 28 29 body bgcolor=#d0a0a0 text=#000000 { 30 p "These are examples of cgi.tcl, a CGI support library for Tcl 31 programmers. If you would like to show off what you've 32 written with cgi.tcl, give me an html-formatted blurb and I'll 33 add it to a page of [link realapps]. For more information, 34 visit the [link CGITCL]." 35 36 bullet_list { 37 li "[run cookie] - Cookie example. Also see [run passwd-form] to see cookies in the context of a real application." 38 li "[run creditcard] - Check a credit card." 39 li "[run download] - Demonstrate file downloading. Also see [run upload]." 40 li "[run echo] - Echo everything - good for debugging forms." 41 li "[run error] - Error handling example." 42 li "[run evaljs] - Evaluate an expression using JavaScript." 43 li "[run examples] - Generate the page you are now reading." 44 li "[run form-tour] and [display form-tour-result] - Show 45 many different form elements and the backend to process them." 46 li "[run format-tour] - Demonstrate many formats." 47 li "[run frame] - Framed example (of this page)." 48 li "[url "image.cgi" [cgi display-in-frame [cgi_cgi_set scriptname \ 49 image.cgi]] $target] - Produce a raw image." 50 li "[run img] - Examples of images embedded in a page." 51 li "[run kill] - Allow anyone to kill runaway CGI processes." 52 li "[display oratcl] - Use [link Oratcl] to query an Oracle database." 53 li "[run nistguest] - Specialized guestbook" 54 li "[run parray] - Demonstrate parray (print array elements)." 55 li "[run passwd-form] and [display passwd] - Form for 56 changing a password and its backend. Note that this CGI script 57 is [bold not] setuid because it is written using [link Expect]. 58 The script also demonstrates a nice use of cookies." 59 li "[run push] - Demonstrate server-push." 60 li "[run rm] - Allow anyone to remove old CGI files from /tmp." 61 li "[run stopwatch] - A stopwatch written as a Tcl applet." 62 li "[display unimail] - A universal mail backend that mails the 63 values of any form back to the form owner." 64 li "[run upload] - Demonstrate file uploading. Also see [run download]." 65 li "[run utf] - Demonstrate UTF output." 66 li "[run validate] - Validate input fields using JavaScript." 67 li "[run vclock] - Lincoln Stein's virtual clock. 68 This was the big example in his CGI.pm paper. Examine the 69 source to [eval url [list "his Perl version"] \ 70 [cgi display scriptname=vclock.pl] $target] or compare them 71 [url "side by side" [cgi vclock-src-frame] target=script2]." 72 li "[run visitor] - Example of a visitor counter." 73 li "[run version] - Show version information." 74 li "[run vote] - Vote for a quote." 75 li "[run display] - Display a CGI script with clickable 76 source commands. Not a particularly interesting application - 77 just a utility to help demo these other CGI scripts! But it is 78 written using cgi.tcl so it might as well be listed here." 79 } 80 } 81} 82