Posted to tcl by patthoyts at Wed Jul 05 21:51:59 GMT 2006view raw
- # paste::cmd-Comment --
- #
- # Implement the new item
- #
- proc ::paste::cmd-Comment {sock suffix} {
- upvar #0 Httpd$sock data
- set title "Submit new item"
- set attr ""
- set html ""
- if {[info exists data(query)] && [string length $data(query)] > 0} {
- ncgi::reset
- ncgi::input $data(query)
- if {[ValidUser [ncgi::value user]]} {
- set db [Open]
- set id [ncgi::value id]; # [file tail $data(mime,referer)]
- set sql "INSERT INTO comments (user,date,id,comment) VALUES (\
- [SqlQuote [ncgi::value user]],'[clock seconds]','$id',
- [SqlQuote [ncgi::value comment]]);"
- set r [$db exec $sql]
- if {[$r errorcode]} {
- set title "Comment submission failed"
- set html "<h1>$title</h1><p>Your submission failed to be entered into the database.\
- The following error was returned:</p><pre>[$r errorinfo]</pre>"
- set html [Generate $title "" $html [Sidebar]]
- } else {
- set html [getItem $id]
- }
- Close $db
- }
- }
- return $html
- }