View Single Post
Old 11-11-2004, 05:12 PM  
neoxed
Too much time...
 
Join Date: May 2003
Posts: 1,326
Default

Code:
proc GetUserList {} {
	set UserList ""
	foreach UserID [user list] {lappend UserList [resolve uid $UserID]}
	return [lsort -ascii $UserList]
}

proc GetGroupList {} {
	set GroupList ""
	foreach GroupID [group list] {lappend GroupList [resolve gid $GroupID]}
	return [lsort -ascii $GroupList]
}

proc GetGroupUsers {GroupID} {
	set UserList ""
	foreach UserName [GetUserList] {
		if {[userfile open $UserName] != 0} {continue}
		set UserFile [userfile bin2ascii]
		if {[regexp -nocase {groups ([\s\d]+)} $UserFile Result GIDList]} {
			if {[lsearch -exact $GIDList $GroupID] != -1} {lappend UserList $UserName}
		}
	}
	return $UserList
}
These functions return a list of users, groups and users in the specified group, respectively. If you want to find out a users ratio, you'll have to use ioFTPD's 'userfile' command to read their user file.

Code:
## This will create a list of user names with a ratio of 0 in section 0 in the STAFF group
set LeechUsers ""
set GroupUsers [GetGroupUsers [resolve group "STAFF"]]
foreach UserName $GroupUsers {
	if {[userfile open $UserName] == 0} {
	set UserFile [userfile bin2ascii]
	foreach UserLine [split $UserFile "\n"] {
		if {[string equal -nocase "ratio" [lindex $UserLine 0]]} {
			## Append the user to the leech list if they have a ratio of 0 in section 0
			if {[lindex $UserLine 1] == 0} {lappend LeechUsers $UserName}
			break
		}
	}
}
neoxed is offline