summaryrefslogtreecommitdiff
path: root/web/src/cgi.tcl-1.10/example/visitor.cgi
blob: ee73922e265bd19296b3e08c2a987e43cb390125 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/depot/path/tclsh

package require cgi

cgi_eval {
    source example.tcl

    cgi_title "Visitor count example"

    cgi_body {
	cgi_put "This page demonstrates how easy it is to do visitor counts."

	cgi_uid_check http

	cgi_form visitor {
	    set cfname "$DATADIR/visitor.cnt"

	    if {[catch {set fid [open $cfname r+]} errormsg]} {
		h4 "Couldn't open $cfname to maintain visitor count: $errormsg"
		return
	    }
	    gets $fid count
	    seek $fid 0 start
	    puts $fid [incr count]
	    close $fid
	    h4 "You are visitor $count.  Revisit soon!"
	    cgi_submit_button "=Revisit"
	}
    }
}