Posted by electronerd Tue 20th Mar 2007 01:20 - Syntax is Diff - 16 views
Download | New Post | Modify | Hide line numbers
  1. diff --git a/newseen.tcl b/newseen.tcl
  2. index 3fc51a5..34e4820 100644
  3. --- a/newseen.tcl
  4. +++ b/newseen.tcl
  5. @@ -5,12 +5,20 @@ set hseen_db [::mysql::connect -host localhost -user $mysqluser -password $mysql
  6.  set hseen_channel #nerdstar-test
  7.  
  8.  
  9. +proc hseen_pingdb { } {
  10. +    global hseen_db mysqluser mysqlpass mysqldb
  11. +    if { ! [::mysql::ping $hseen_db] } {
  12. +        ::mysql::close $hseen_db
  13. +        set hseen_db [::mysql::connect -host localhost -user $mysqluser -password $mysqlpass -db $mysqldb]
  14. +    }
  15. +}
  16. +
  17.  #a little test proc
  18.  bind PUB - !hseen hseen
  19.  proc hseen {nick uhost hand chan txt} {
  20.      global hseen_db
  21.      #make sure the connection is up
  22. -    ::mysql::ping $hseen_db   
  23. +    hseen_pingdb
  24.  
  25.      #escape what's gonna be put into an SQL statement from the outside
  26.      set txt [::mysql::escape $hseen_db $txt]
  27. @@ -40,7 +48,7 @@ proc hseen:join {nick uhost hand chan} {
  28.      
  29.      global hseen_db
  30.      #make sure the server is alive
  31. -    ::mysql::ping $hseen_db   
  32. +    hseen_pingdb
  33.  
  34.      #escape what we're shoving in the query
  35.      set hand [::mysql::escape $hseen_db $hand]
  36. @@ -72,7 +80,7 @@ proc hseen:leave {hand reason} {
  37.  
  38.      global hseen_db
  39.      #make sure the connection is alive
  40. -    ::mysql::ping $hseen_db   
  41. +    hseen_pingdb
  42.  
  43.      #escape what's going into the SQL to avoid injection
  44.      set hand [::mysql::escape $hseen_db $hand]
  45. @@ -102,7 +110,7 @@ proc hseen:finishbotjoin {from kw txt} {
  46.      set nicks [chanlist $hseen_channel]
  47.      putlog $nicks
  48.      global hseen_db
  49. -    ::mysql::ping $hseen_db
  50. +    hseen_pingdb
  51.  
  52.      #set everyone offline
  53.      ::mysql::exec $hseen_db "UPDATE ixc_users

PermaLink to this entry https://pastebin.co.uk/12068
Posted by electronerd Tue 20th Mar 2007 01:20 - Syntax is Diff - 16 views
Download | New Post | Modify | Hide line numbers

 

Comments: 0