Go Back   FlashFXP Forums > >

Programming Need help with C/C++/Delphi? Ask here and make us all laugh.

Closed Thread
 
Thread Tools Rate Thread Display Modes
Old 11-11-2004, 07:31 AM   #1
jeza
Senior Member
ioFTPD Scripter
 
jeza's Avatar
 
Join Date: May 2003
Posts: 530
Default [ITCL] - groupinfo

groupfile
slots 5 2
users 3

can i get the info in itcl script of users(names/uids) in group and wich of them have leech/ratio ? or maybe how many leech slots are free?

if how?
jeza is offline  
Old 11-11-2004, 05:12 PM   #2
neoxed
Too much time...
FlashFXP Beta Tester
ioFTPD Scripter
 
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  
Old 11-12-2004, 05:01 AM   #3
jeza
Senior Member
ioFTPD Scripter
 
jeza's Avatar
 
Join Date: May 2003
Posts: 530
Default

tnx

if {[regexp -nocase {groups((sd+)+)} $UserFile Result GIDList]} {

whats this 'groups((sd+)+)'
jeza is offline  
Old 11-12-2004, 05:30 AM   #4
neoxed
Too much time...
FlashFXP Beta Tester
ioFTPD Scripter
 
Join Date: May 2003
Posts: 1,326
Default

Hmm, it appears the [PHP] vB tag removed the backslashes. I've corrected my previous post (using the [CODE] tag instead).
neoxed is offline  
Old 11-12-2004, 05:49 AM   #5
jeza
Senior Member
ioFTPD Scripter
 
jeza's Avatar
 
Join Date: May 2003
Posts: 530
Default

ok tnx for the help
jeza is offline  
Closed Thread

Tags
free, group, leech/ratio, slots, wich

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 08:54 AM.

Parts of this site powered by vBulletin Mods & Addons from DragonByte Technologies Ltd. (Details)