All pastes #526417 Raw Edit

Mine

public text v1 · immutable
#526417 ·published 2007-05-31 20:14 UTC
rendered paste body
### search
proc echo:dupesearch { nick uhost handle chan arg } {
 global chan_ searchresults mysqltable minchar
 if { $chan == $chan_(echo) } {
        if { [string length $arg] > $minchar } {

                 set db [echo:mydbconn]
                 set count "0"
                 set found "0"
                 set rep "%"
                 set search %$arg%
                 regsub -all { }  $search $rep search
                 regsub -all {\.} $search $rep search
                 regsub -all {\_} $search $rep search

                 set data [mysqlsel $db "SELECT * FROM $mysqltable WHERE rls LIKE '$search' order by `pretime` DESC LIMIT 0,20;" -list]

                if {[string equal $data ""] == 1} {
                        putquickmc "PRIVMSG $chan_(echo) :Not Found"
                        mysqlclose $db
                        return ""
                }

                foreach rls $data {
                        set pretime [lindex $rls 1]
                        set section [lindex $rls 2]
                        set releasename [lindex $rls 3]
                        set isnuked [lindex $rls 5]
                        set hasinfo [lindex $rls 7]
                        if {$count < 20} {
                                if { $isnuked != 1 } {
                                        if { $hasinfo != 1} {
                                        putquick "PRIVMSG $nick :\[\00307$section\003\]-\[\00310$pretime\003\]-\[\002$releasename\002\]"
                                } elseif { $hasinfo == 1} {
                                        set megs [lindex $rls 8]
                                        set files [lindex $rls 9]
                                        putquick "PRIVMSG $nick :\[\00307$section\003\]-\[\00310$pretime\003\]-\[\002$releasename\002\]-\[\002$megs MB/$files file(s)\002\]"
                                }
                                } elseif { $isnuked == 1 } {
                                        set nukereason [lindex $rls 6]
                                        if { $hasinfo != 1} {
                                        putquick "PRIVMSG $nick :\[\00304\002NUKED\002\003\]-\[\00307$section\003\]-\[\00310$pretime\003\]-\[\002$releasename\002\]-\[\00304REASON: \00305$nukereason\003\]"
                                } elseif { $hasinfo == 1} {
                                        set megs [lindex $rls 8]
                                        set files [lindex $rls 9]
                                        putquick "PRIVMSG $nick :\[\00304\002NUKED\002\003\]-\[\00307$section\003\]-\[\00310$pretime\003\]-\[\002$releasename\002\]-\[\00304REASON: \00305$nukereason\003\]-\[\002$megs MB/$files file(s)\002\]"
                                        }

                               }
                        incr count
                        }
                }
                mysqlclose $db
                set data NULL
                return ""

        } elseif { [string length $arg] <= $minchar } {
                putquick "NOTICE $nick :^C00,01 *$arg* doesnt reached teh minimum of $minchars chars ^C"; putlog "PRESEARCH *$arg* min. chars not reached"
                return 0
        }
 }
}