/[cvs]/eggdrop1.6/scripts/weed
ViewVC logotype

Annotation of /eggdrop1.6/scripts/weed

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (hide annotations) (download)
Sun Nov 11 20:24:46 2001 UTC (17 years, 11 months ago) by guppy
Branch: MAIN
CVS Tags: r1, eggdrop_1_6_15, eggdrop_1_6_13, blah, eggdrop1_6_9, test, v2_0, eggdrop1_6_7, eggdrop1_6_11
Changes since 1.7: +2 -2 lines
Yes, Tcl looks cooler anyways :P~

1 fabian 1.3 #! /bin/sh
2 guppy 1.6 # This trick is borrowed from Tothwolf's Wolfpack \
3     # Search for tclsh[0-9].[0-9] in each valid dir in PATH \
4     for dir in $(echo $PATH | sed 's/:/ /g'); \
5     do \
6     if test -d $dir; \
7     then \
8     files=$(/bin/ls $dir | egrep '^tclsh[0-9]\.[0-9]$'); \
9     if test "$files" != ""; \
10     then \
11     versions="${versions:+$versions }$(echo $files | sed 's/tclsh//g')"; \
12     fi; \
13     fi; \
14     done; \
15     for ver in $versions; \
16     do \
17     tmpver=$(echo $ver | sed 's/\.//g'); \
18     if test "$lasttmpver" != ""; \
19     then \
20     if test "$tmpver" -gt "$lasttmpver"; \
21     then \
22     lastver=$ver; \
23     lasttmpver=$tmpver; \
24     fi; \
25     else \
26     lastver=$ver; \
27     lasttmpver=$tmpver; \
28     fi; \
29     done; \
30     exec tclsh$lastver "$0" "$@"
31 segfault 1.1 #
32 guppy 1.8 # $Id: weed,v 1.7 2001/11/05 04:08:28 guppy Exp $
33 fabian 1.5 #
34 segfault 1.1 # weed out certain undesirables from an eggdrop userlist
35     # try just typing 'tclsh weed' to find out the options
36 guppy 1.7 # Robey Pointer, November 1994
37 segfault 1.1 #
38     # <cmwagner@gate.net>:
39     # I did a few bug fixes to the original weed script, things changed...
40     #
41     # when specifying other weed options they would unset the User() field and
42     # a maxlast weed would try and weed again and cause the script to stop due
43     # to User() being already unset (array nonexistant)
44     #
45     # when loadUserFile encountered an xtra field it would try and use the $info
46     # variable, which was supposed to be $xtra (something overlooked when the
47     # line was cut and pasted -- I hate it when that happens)
48     #
49     # changed the formatting of the saved weed file to match more closely to
50     # eggdrop 0.9tp (so this may cause incompatibilities), but when a hostmask
51     # field exactly matched 40 characters it would save it with no spaces after
52     # it and eggdrop would reject the user record. I know I could have easily
53     # changed one character, but I couldn't help myself. <grin>
54 fabian 1.4 # 5 march 1996
55 segfault 1.1 #
56 fabian 1.4 # <robey, 23jul1996>:
57 segfault 1.1 # upgrade for v2 userfiles
58 fabian 1.4 # <bruce s, 04sep1996>:
59 segfault 1.1 # fixed xtra field from getting truncated
60 fabian 1.4 # <robey, 20sep1996>:
61 segfault 1.1 # stopped it from mangling channel ban lists
62 fabian 1.4 # <Ec|ipse & dtM, 10jun1997>:
63 segfault 1.1 # upgrade for v3 userfiles
64 fabian 1.4 # <Ec|ipse 18jun1997>:
65 segfault 1.1 # added an option to remove users from unwanted channels
66 fabian 1.4 # <Ec|ipse 28oct1997>:
67 segfault 1.1 # upgrade for v4 userfiles, with v3 converter
68 fabian 1.4 # <Ernst 8mar1998>:
69 segfault 1.1 # fixed bug "list element in braces followed by X instead of space"
70     # (the use of "lrange" where you aren't sure if it's a list is bad)
71     # fixed --CONSOLE item not being included, creating "user" --CONSOLE
72 fabian 1.4 # <Ernst 1apr1998>:
73 guppy 1.7 # two more improper occurrences of "lrange" removed
74 fabian 1.2 # <rtc 20sep1999>:
75     # removed ancient way of determining the current time.
76 guppy 1.6 # <Tothwolf 21oct1999>:
77 guppy 1.8 # [clock] isn't in all versions of Tcl...
78 guppy 1.6 # <guppy 12Apr2001>:
79     # borrowed code from Tothwolf's Wolfpack to find tclsh better
80 segfault 1.1 #
81    
82     set exempt {*ban *ignore}
83     set exemptops 0 ; set exemptmasters 0 ; set exemptfriends 0
84     set exemptparty 0 ; set exemptfile 0 ; set exemptchanm 0
85     set exemptbotm 0 ; set exemptchann 0 ; set exemptchanf 0
86     set exemptchano 0
87     set maxlast 0 ; set maxban 0 ; set maxignore 0
88     set weedops 0 ; set weedmasters 0 ; set weednopw 0
89     set stripops 0 ; set stripmasters 0 ; set weedlurkers 0
90     set chanrem {}
91     set convert 0
92    
93 fabian 1.4 if {![string compare "" [info commands clock]]} then {
94     set fd [open "/tmp/egg.timer." w]
95     close $fd
96     set CURRENT [file atime "/tmp/egg.timer."]
97     exec rm -f /tmp/egg.timer.
98     } else {
99     set CURRENT [clock seconds]
100     }
101 segfault 1.1
102     if {$argc < 1} {
103     puts stdout "\nUsage: weed <userfile> \[options\]"
104     puts stdout " (weeds out users from an eggdrop userlist)"
105     puts stdout "Output goes to <userfile>.weed"
106     puts stdout "Possible options:"
107     puts stdout " -<nick> exempt this user from weeding"
108     puts stdout " ^o ^m ^f exempt ops or masters or friends"
109     puts stdout " ^co ^cm ^cf exempt chanops or chanmasters or chanfriends"
110     puts stdout " ^cn exempt chanowner"
111     puts stdout " ^p ^x exempt party-line or file-area users"
112     puts stdout " ^b exempt botnet master"
113     puts stdout " +<days> weed: haven't been seen in N days"
114     puts stdout " :n weed: haven't EVER been seen"
115     puts stdout " :o :m weed: ops or masters with no password set"
116 guppy 1.7 puts stdout " :a weed: anyone with no password set"
117 segfault 1.1 puts stdout " o m unop/unmaster: ops or masters with no pass."
118     puts stdout " b<days> weed: bans not used in N days"
119     puts stdout " i<days> weed: ignores created over N days ago"
120 guppy 1.7 puts stdout " =<chan> weed: channels no longer supported"
121 segfault 1.1 puts stdout " c convert v3 eggdrop userfile"
122     puts stdout ""
123     exit
124     }
125     puts stdout "\nWEED 18jun97, robey\n"
126    
127     set filename [lindex $argv 0]
128     for {set i 1} {$i < $argc} {incr i} {
129     set carg [lindex $argv $i]
130     if {$carg == ":n"} {
131     set weedlurkers 1
132     } elseif {$carg == ":o"} {
133     set weedops 1 ; set stripops 0 ; set weednopw 0
134     } elseif {$carg == ":m"} {
135     set weedmasters 1 ; set stripmasters 0 ; set weednopw 0
136     } elseif {$carg == ":a"} {
137     set weednopw 1 ; set weedops 0 ; set weedmasters 0
138     set stripops 0 ; set stripmasters 0
139     } elseif {$carg == "o"} {
140     set stripops 1 ; set weedops 0 ; set weednopw 0
141     } elseif {$carg == "m"} {
142     set stripmasters 1 ; set weedmasters 0 ; set weednopw 0
143     } elseif {$carg == "^m"} {
144     set exemptmasters 1
145     } elseif {$carg == "^o"} {
146     set exemptops 1
147     } elseif {$carg == "^f"} {
148     set exemptfriends 1
149     } elseif {$carg == "^p"} {
150     set exemptparty 1
151     } elseif {$carg == "^x"} {
152     set exemptfile 1
153     } elseif {$carg == "^cf"} {
154     set exemptchanf 1
155     } elseif {$carg == "^cm"} {
156     set exemptchanm 1
157     } elseif {$carg == "^cn"} {
158     set exemptchann 1
159     } elseif {$carg == "^b"} {
160     set exemptbotm 1
161     } elseif {$carg == "^co"} {
162     set exemptchano 1
163     } elseif {$carg == "c"} {
164     set convert 1
165     } elseif {[string index $carg 0] == "-"} {
166     lappend exempt [string range $carg 1 end]
167     } elseif {[string index $carg 0] == "+"} {
168     set maxlast [expr 60*60*24* [string range $carg 1 end]]
169     } elseif {[string index $carg 0] == "b"} {
170     set maxban [expr 60*60*24* [string range $carg 1 end]]
171     } elseif {[string index $carg 0] == "i"} {
172     set maxignore [expr 60*60*24* [string range $carg 1 end]]
173     } elseif {[string index $carg 0] == "="} {
174     lappend chanrem [string tolower [string range $carg 1 end]]
175     } else {
176     puts stderr "UNKNOWN OPTION: '$carg'\n"
177     exit
178     }
179     }
180    
181     if {(!$weedlurkers) && (!$weedops) && (!$weedmasters) && (!$weednopw) &&
182     (!$stripops) && (!$stripmasters) && ($maxlast == 0) && ($convert == 0) &&
183     ($maxban == 0) && ($maxignore == 0) && ($chanrem == {})} {
184     puts stderr "PROBLEM: You didn't specify anything to weed out.\n"
185     exit
186     }
187    
188     set weeding { } ; set strip { } ; set exempting { }
189     if {$weedlurkers} { lappend weeding "lurkers" }
190     if {$weedops} { lappend weeding "pwdless-ops" }
191     if {$weedmasters} { lappend weeding "pwdless-masters" }
192     if {$weednopw} { lappend weeding "pwdless-users" }
193     if {$chanrem != {}} { lappend weeding "unwanted-channel" }
194     if {$maxlast > 0} { lappend weeding ">[expr $maxlast /(60*60*24)]-days" }
195     if {$maxban > 0} { lappend weeding "bans>[expr $maxban /(60*60*24)]-days" }
196     if {$maxignore > 0} { lappend weeding "ign>[expr $maxignore /(60*60*24)]-days" }
197     if {$weeding != { }} { puts stdout "Weeding:$weeding" }
198    
199     if {$stripops} { lappend strip "pwdless-ops" }
200     if {$stripmasters} { lappend strip "pwdless-masters" }
201     if {$strip != { }} { puts stdout "Stripping:$strip" }
202    
203     if {$exemptops} { lappend exempting "(ops)" }
204     if {$exemptmasters} { lappend exempting "(masters)" }
205     if {$exemptfriends} { lappend exempting "(friends)" }
206     if {$exemptparty} { lappend exempting "(party-line)" }
207     if {$exemptfile} { lappend exempting "(file-area)" }
208     if {$exemptchann} { lappend exempting "(channel-owners)" }
209     if {$exemptchanm} { lappend exempting "(channel-masters)" }
210     if {$exemptchano} { lappend exempting "(channel-ops)" }
211     if {$exemptchanf} { lappend exempting "(channel-friends)" }
212     if {$exemptbotm} { lappend exempting "(botnet masters)" }
213     if {[llength $exempt]>2} { lappend exempting "[lrange $exempt 2 end]" }
214     if {$exempting != { }} { puts stdout "Exempt:$exempting" }
215    
216     puts stdout "\nReading $filename ..."
217    
218     proc convertUserFile {fname} {
219     global User Hostmask Channel Botflag LastOn BotAddr Xtra convert
220     puts stdout "\nRunning Converter on $fname"
221     set oldhandle {}
222     if {[catch {set fd [open $fname r]}] != 0} { return 0 }
223     set line [string trim [gets $fd]]
224     if {[string range $line 1 2] == "3v"} {
225     set convert 1
226     } elseif {[string range $line 1 2] == "4v"} {
227     return 0
228     }
229     while {![eof $fd]} {
230     set line [string trim [gets $fd]]
231     if {([string index $line 0] != "#") && ([string length $line] > 0)} {
232     scan $line "%s" handle
233     if {$handle == "-"} {
234     # hostmask
235     set hmList [split [string range $line 2 end] ,]
236     for {set i 0} {$i < [llength $hmList]} {incr i} {
237     lappend Hostmask($oldhandle) [string trim [lindex $hmList $i]]
238     }
239     } elseif {$handle == "!"} {
240     # channel
241     set chList [string trim [string range $line 1 end]]
242     lappend Channel($oldhandle) "[lrange $chList 0 1] [string trim [lindex $chList end] 0123456789]"
243     } elseif {$handle == "*"} {
244     # dccdir
245     set dccdir [string trim [string range $line 2 end]]
246     set User($oldhandle) [lreplace $User($oldhandle) 2 2 $dccdir]
247     } elseif {$handle == "+"} {
248     # email
249     set email [string trim [string range $line 2 end]]
250     set User($oldhandle) [lreplace $User($oldhandle) 3 3 $email]
251     } elseif {$handle == "="} {
252     # comment
253     set comment [string trim [string range $line 2 end]]
254     set User($oldhandle) [lreplace $User($oldhandle) 4 4 $comment]
255     } elseif {$handle == ":"} {
256     # user info line / bot addresses
257     if {[lsearch [split [lindex $User($oldhandle) 0] ""] b] == -1} {
258     set info [string trim [string range $line 1 end]]
259     set User($oldhandle) [lreplace $User($oldhandle) 5 5 $info]
260     } else {
261     set BotAddr($oldhandle) [string trim [string range $line 1 end]]
262     }
263     } elseif {$handle == "."} {
264     # xtra field start
265     if {![info exists xtraList($oldhandle)]} {
266     set xtraList($oldhandle) [string trim [string range $line 1 end]]
267     } {
268     set xtraList($oldhandle) "$xtraList($oldhandle) [string trim [string range $line 1 end]]"
269     }
270     } elseif {$handle == "!!"} {
271     # laston
272     set LastOn($oldhandle) [lindex $line 1]
273     } else {
274     # finish up xtra field first
275     if {[info exists xtraList($oldhandle)]} {
276     for {set i 0} {$i < [llength $xtraList($oldhandle)]} {incr i} {
277     lappend Xtra($oldhandle) [string trim [lindex $xtraList($oldhandle) $i] \{]
278     }
279     }
280     # begin of new user
281     scan $line "%s %s %s %s" handle pass attr ts
282     if {$convert == 1 && $attr != ""} {
283     regsub -all {B} $attr {t} attr
284     set botflags "s h a l r" ; set Botflag($handle) ""
285     set nattr [split [string trim $attr 0123456789] ""] ; set attr ""
286     foreach flag $botflags {
287     if {[lsearch -exact $nattr $flag] != -1} {append Botflag($handle) $flag}
288     }
289     foreach flag $nattr {
290     if {[lsearch -exact $botflags $flag] == -1} {append attr $flag}
291     }
292     }
293     set User($handle) [list $attr $pass {} {} {} {}]
294     set Hostmask($handle) {}
295     set Channel($handle) {}
296     set oldhandle $handle
297     }
298     }
299     }
300     return 1
301     }
302    
303     proc loadUserFile {fname} {
304     global User Hostmask Channel Botflag LastOn BotAddr Xtra
305     set oldhandle {}
306     if {[catch {set fd [open $fname r]}] != 0} { return 0 }
307     set line [string trim [gets $fd]]
308     if {[string range $line 1 2] != "4v"} {
309     if {[string range $line 1 2] == "3v"} {
310     convertUserFile $fname
311     return 1
312     } else {
313     puts stderr "Unknown userfile version! (not v4)\n"
314     exit
315     }
316     }
317     while {![eof $fd]} {
318     set line [string trim [gets $fd]]
319     if {([string index $line 0] != "#") && ([string length $line] > 0)} {
320     scan $line "%s" handle
321     if {$handle == "--HOSTS"} {
322     # hostmask
323     set hmList [lindex $line 1]
324     lappend Hostmask($oldhandle) [string trim $hmList]
325     } elseif {$handle == "-"} {
326     # hostmask
327 guppy 1.6 set hmList [join [lrange $line 1 end]]
328 segfault 1.1 lappend Hostmask($oldhandle) [string trim $hmList]
329     } elseif {$handle == "!"} {
330     # channel
331     set chList [string trim [string range $line 1 end]]
332     lappend Channel($oldhandle) $chList
333     } elseif {$handle == "--BOTADDR"} {
334     # botaddr
335     set BotAddr($oldhandle) [lindex $line 1]
336     } elseif {$handle == "--PASS"} {
337     # pass
338     set pass [string trim [string range $line [expr [string first " " $line] + 1] end]]
339     set User($oldhandle) [lreplace $User($oldhandle) 1 1 $pass]
340     } elseif {$handle == "--DCCDIR"} {
341     # dccdir
342     set first [string first " " $line]
343     if {$first != -1} {
344     set dccdir [string trim [string range $line [expr $first + 1] end]]
345     } {
346     set dccdir ""
347     }
348     set User($oldhandle) [lreplace $User($oldhandle) 2 2 $dccdir]
349     } elseif {$handle == "--COMMENT"} {
350     # comment
351     set first [string first " " $line]
352     if {$first != -1} {
353     set comment [string trim [string range $line [expr $first + 1] end]]
354     } {
355     set comment ""
356     }
357     set User($oldhandle) [lreplace $User($oldhandle) 4 4 $comment]
358     } elseif {$handle == "--INFO"} {
359     # user info line
360     set first [string first " " $line]
361     if {$first != -1} {
362     set info [string trim [string range $line [expr $first + 1] end]]
363     } {
364     set info ""
365     }
366     set User($oldhandle) [lreplace $User($oldhandle) 5 5 $info]
367     } elseif {$handle == "--CONSOLE"} {
368     # console
369     set first [string first " " $line]
370     if {$first != -1} {
371     set console [string trim [string range $line [expr $first + 1] end]]
372     } {
373     set console ""
374     }
375     set User($oldhandle) [lreplace $User($oldhandle) 6 6 $console]
376     } elseif {$handle == "--XTRA"} {
377     # xtra field
378     set first [string first " " $line]
379     if {$first != -1} {
380     set xtraList [string trim [string range $line [expr $first + 1] end]]
381     } {
382     set xtraList ""
383     }
384     lappend Xtra($oldhandle) $xtraList
385     } elseif {$handle == "--LASTON"} {
386     # laston
387     set LastOn($oldhandle) [lindex $line 1]
388     } elseif {$handle == "--BOTFL"} {
389     # botflags
390     set Botflag($oldhandle) [string trim [string range $line 1 end]]
391     } else {
392     # begin of new user
393     scan $line "%s %s %s" handle dash attr
394     set User($handle) [list $attr {} {} {} {} {} {}]
395     set Hostmask($handle) {}
396     set Channel($handle) {}
397     set oldhandle $handle
398     }
399     }
400     }
401     return 1
402     }
403    
404     proc saveUserFile fname {
405     global User Hostmask Channel Botflag LastOn BotAddr Xtra
406     if {[catch {set fd [open $fname w]}] != 0} { return 0 }
407     puts $fd "#4v: weed! now go away."
408     foreach i [array names User] {
409     set hmask "none"
410     set hmloop 0 ; set chloop 0 ; set loloop 0 ; set xloop 0 ; set aloop 0
411     if {[lindex $User($i) 1] == "bans"} {set plug "bans"} {set plug "-"}
412     set attr [lindex $User($i) 0]
413     set ts [lindex $User($i) 2]
414     puts $fd [format "%-9s %-20s %-24s" $i $plug $attr]
415     for {} {$hmloop < [llength $Hostmask($i)]} {incr hmloop} {
416     if {[string index $i 0] == "*" || [string range $i 0 1] == "::"} {
417     set hmask [lindex $Hostmask($i) $hmloop]
418     regsub -all {~} $hmask { } hmask
419     puts $fd "- $hmask"
420     } else {
421     puts $fd "--HOSTS [lindex $Hostmask($i) $hmloop]"
422     }
423     }
424     if {[info exists BotAddr($i)]} {
425     puts $fd "--BOTADDR [lindex $BotAddr($i) 0]"
426     }
427     if {[info exists Xtra($i)]} {
428     for {} {$xloop < [llength $Xtra($i)]} {incr xloop} {
429     puts $fd "--XTRA [lindex $Xtra($i) $xloop]"
430     }
431     }
432     if {[info exists Channel($i)]} {
433     for {} {$chloop < [llength $Channel($i)]} {incr chloop} {
434     puts $fd "! [lindex $Channel($i) $chloop]"
435     }
436     }
437     if {[info exists Botflag($i)]} {
438     if {$Botflag($i) != ""} { puts $fd "--BOTFL [lindex $Botflag($i) 0]" }
439     }
440     if {[string index $i 0] == "*" || [string range $i 0 1] == "::"} {
441     set User($i) [lreplace $User($i) 1 1 {}]
442     }
443     if {[lindex $User($i) 1] != {}} { puts $fd "--PASS [lindex $User($i) 1]" }
444     if {[lindex $User($i) 2] != {}} { puts $fd "--DCCDIR [lindex $User($i) 2]" }
445     if {[lindex $User($i) 3] != {}} { puts $fd "--XTRA EMAIL [lindex $User($i) 3]" }
446     if {[lindex $User($i) 4] != {}} { puts $fd "--COMMENT [lindex $User($i) 4]" }
447     if {[lindex $User($i) 5] != {}} { puts $fd "--INFO [lindex $User($i) 5]" }
448     if {[lindex $User($i) 6] != {}} { puts $fd "--CONSOLE [lindex $User($i) 6]" }
449     if {[info exists LastOn($i)]} {
450     puts $fd "--LASTON [lindex $LastOn($i) 0]"
451     }
452     }
453     close $fd
454     return 1
455     }
456    
457     if {![loadUserFile $filename]} {
458     puts stdout "* Couldn't load userfile!\n"
459     exit
460     }
461    
462     if {$convert == 0} {
463     puts stdout "Loaded. Weeding..."
464     puts stdout "(pwd = no pass, -o/-m = removed op/master, lrk = never seen, exp = expired)"
465     puts stdout "(uwc = unwanted channel)\n"
466     } else {
467     puts stdout "Loaded. Converting..."
468     }
469    
470     set total 0
471     set weeded 0
472     foreach i [array names User] {
473     incr total
474     set attr [lindex $User($i) 0]
475     set chanattr [lindex [lindex $Channel($i) 0] 2]
476     if {([lsearch -exact $exempt $i] == -1) &&
477     ([string range $i 0 1] != "::") &&
478     ([string range $i 0 1] != "--") &&
479     (([string first o $attr] == -1) || (!$exemptops)) &&
480     (([string first m $attr] == -1) || (!$exemptmasters)) &&
481     (([string first f $attr] == -1) || (!$exemptfriends)) &&
482     (([string first p $attr] == -1) || (!$exemptparty)) &&
483     (([string first x $attr] == -1) || (!$exemptfile)) &&
484     (([string first t $attr] == -1) || (!$exemptbotm)) &&
485     (([string first f $chanattr] == -1) || (!$exemptchanf)) &&
486     (([string first m $chanattr] == -1) || (!$exemptchanm)) &&
487     (([string first n $chanattr] == -1) || (!$exemptchann)) &&
488     (([string first o $chanattr] == -1) || (!$exemptchano))} {
489     set pass [lindex $User($i) 1]
490     if {[info exists LastOn($i)]} { set ts [lindex $LastOn($i) 0] } { set ts 0 }
491     if {([string compare $pass "-"] == 0) && ([string first b $attr] == -1)} {
492     if {$weednopw == 1} {
493     unset User($i) ; incr weeded
494     puts -nonewline stdout "[format "pwd: %-10s " $i]"
495     } elseif {([string first o $attr] != -1) && ($weedops == 1)} {
496     unset User($i) ; incr weeded
497     puts -nonewline stdout "[format "pwd: %-10s " $i]"
498     } elseif {([string first m $attr] != -1) && ($weedmasters == 1)} {
499     unset User($i) ; incr weeded
500     puts -nonewline stdout "[format "pwd: %-10s " $i]"
501     }
502     if {([string first o $attr] != -1) && ($stripops == 1)} {
503     set nattr {}
504     for {set x 0} {$x < [string length $attr]} {incr x} {
505     if {[string index $attr $x] != "o"} {
506     set nattr [format "%s%s" $nattr [string index $attr $x]]
507     }
508     }
509     if {$nattr == {}} { set nattr "-" }
510     set User($i) [lreplace $User($i) 0 0 $nattr]
511     puts -nonewline stdout "[format " -o: %-10s " $i]"
512     }
513     if {([string first m $attr] != -1) && ($stripmasters == 1)} {
514     set nattr {}
515     for {set x 0} {$x < [string length $attr]} {incr x} {
516     if {[string index $attr $x] != "m"} {
517     set nattr [format "%s%s" $nattr [string index $attr $x]]
518     }
519     }
520     if {$nattr == {}} { set nattr "-" }
521     set User($i) [lreplace $User($i) 0 0 $nattr]
522     puts -nonewline stdout "[format " -m: %-10s " $i]"
523     }
524     }
525     if {($ts==0) && ($weedlurkers==1) && ([string first b $attr] == -1) && [info exists User($i)]} {
526     unset User($i) ; incr weeded
527     puts -nonewline stdout "[format "lrk: %-10s " $i]"
528     }
529     if {($ts > 0) && ($maxlast > 0) && ($CURRENT-$ts > $maxlast && [info exists User($i)])} {
530     unset User($i) ; incr weeded
531     puts -nonewline stdout "[format "exp: %-10s " $i]"
532     }
533     if {$chanrem != {} && [info exists Channel($i)]} {
534     foreach unchan $chanrem {
535     set id [lsearch [string tolower $Channel($i)] *$unchan*]
536     if {$id != -1} {
537     set Channel($i) [lreplace $Channel($i) $id $id] ; incr weeded
538     puts -nonewline stdout "[format "uwc: %-10s " $i]"
539     }
540     }
541     }
542     }
543     flush stdout
544     }
545     if {$weeded == 0 && $convert == 0} { puts -nonewline stdout "uNF... Nothing to weed!" }
546     puts stdout "\n"
547    
548     foreach i [array names User] {
549     if {([string range $i 0 1] == "::") || ($i == "*ban")} {
550     for {set j 0} {$j < [llength $Hostmask($i)]} {incr j} {
551     set ban [split [lindex $Hostmask($i) $j] :]
552     if {[string range [lindex $ban 2] 0 0] == "+"} {
553     set lastused [lindex $ban 3]
554     if {($maxban > 0) && ($CURRENT-$lastused > $maxban)} {
555     if {$i == "*ban"} {
556     puts stdout "Expired ban: [lindex $ban 0]"
557     } {
558     puts stdout "Expired ban on [string range $i 2 end]: [lindex $ban 0]"
559     }
560     set Hostmask($i) [lreplace $Hostmask($i) $j $j]
561     incr j -1
562     }
563     }
564     }
565     }
566     if {$i == "*ignore"} {
567     for {set j 0} {$j < [llength $Hostmask($i)]} {incr j} {
568     set ign [split [lindex $Hostmask($i) $j] :]
569     set lastused [lindex $ign 3]
570     if {($maxignore > 0) && ($CURRENT-$lastused > $maxignore)} {
571     puts stdout "Expired ignore: [lindex $ign 0]"
572     set Hostmask($i) [lreplace $Hostmask($i) $j $j]
573     incr j -1
574     }
575     }
576     }
577     }
578    
579     puts stdout "\nFinished scan."
580     puts stdout "Original total ($total), new total ([expr $total-$weeded]), zapped ($weeded)"
581    
582     if {![saveUserFile $filename.weed]} {
583     puts stdout "* uNF... Couldn't save new userfile!\n"
584     exit
585     }
586     puts stdout "Wrote $filename.weed"

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23