Posted to tcl by patthoyts at Wed Jul 05 21:51:59 GMT 2006view raw

  1. # paste::cmd-Comment --
  2. #
  3. # Implement the new item
  4. #
  5. proc ::paste::cmd-Comment {sock suffix} {
  6. upvar #0 Httpd$sock data
  7. set title "Submit new item"
  8. set attr ""
  9. set html ""
  10. if {[info exists data(query)] && [string length $data(query)] > 0} {
  11. ncgi::reset
  12. ncgi::input $data(query)
  13. if {[ValidUser [ncgi::value user]]} {
  14. set db [Open]
  15. set id [ncgi::value id]; # [file tail $data(mime,referer)]
  16. set sql "INSERT INTO comments (user,date,id,comment) VALUES (\
  17. [SqlQuote [ncgi::value user]],'[clock seconds]','$id',
  18. [SqlQuote [ncgi::value comment]]);"
  19. set r [$db exec $sql]
  20. if {[$r errorcode]} {
  21. set title "Comment submission failed"
  22. set html "<h1>$title</h1><p>Your submission failed to be entered into the database.\
  23. The following error was returned:</p><pre>[$r errorinfo]</pre>"
  24. set html [Generate $title "" $html [Sidebar]]
  25. } else {
  26. set html [getItem $id]
  27. }
  28. Close $db
  29. }
  30. }
  31. return $html
  32. }
  33.