ioFTPD General New releases, comments, questions regarding the latest version of ioFTPD. |
01-28-2014, 04:56 PM
|
#1
|
Junior Member
Join Date: Jan 2014
Posts: 18
|
Display custom stats (or way to modify existing)
I wanted to have "site stats" return just the stats for user who issued the command (so user cannot see others stats).
Or, return the stats, but all other user names would be censored such as with xxxxxx.
I imagine censoring user names would be too hard. I imagine easiest way to accomplish this is to just write new TCL script that will return the users stats only -- such as "site mystats". Unfortunately I don't know how to do this. I did search for "custom stats" ioftpd, and various other searches such as stats tcl ioftpd. I could not find any data or examples, or discussions how to achieve this. Any advice or pointers would be appreciated!
|
|
|
01-29-2014, 12:20 AM
|
#2
|
Too much time...
FlashFXP Beta Tester ioFTPD Administrator
Join Date: May 2005
Posts: 1,194
|
The site stats command is actually pretty flexible, BUT it's purpose is to give out stats about other users so if you don't want them to see that then set the permissions on 'site stats' so they can't use it If you just want them to view THEIR stats (but no ranking) then check out 'site myinfo' which gives the same data as 'site uinfo' but only for their account which is hopefully all that you're looking for.
I don't see a trivial way to get the ranking (say, 5th largest uploader this month) without having the server also list other users by name. Even using the super-message cookie %[STATS()], see doc/Cookies.txt, which can be used to generate output just like the 'site stats' command won't really solve your problem.
The easiest way is to just write a small TCL script. Grab the list of all known uids, open each user and grab the stat you want out of it and save the name/stat in a list, sort the list, and spit out just the data for the caller. All the iTCL (ioFTPD specific TCL calls) are defined in doc/iTCL.txt. Check out the UGrep script I wrote (should be pinned to the top here) which does most of what you'll need.
|
|
|
01-29-2014, 05:29 AM
|
#3
|
Junior Member
Join Date: Jan 2014
Posts: 18
|
It looks like 'site myinfo' is all I really want because it's an already existing command. I already denied access to 'site stats' long ago.
I remember the issue with 'site myinfo' is that it didn't return any of the info I saw for the user in the 'site stats' command.
I just want the user to be able to see their alup at least.
There are no fixed sections on the site, each user has their own unique folder. They can make whatever folders they like in their own directory, I just want them to be able able to see the statistics for the number of files they've uploaded.
Under [Sections] I have only defined: Default = 0 0 0 *
An example of the 'site myinfo' output the user gets is below, and then what I see with "site stats". I guess I don't understand why there is no data populated for them under wkup/monthup/allup.
[2] 200-| | Section Name | Ratio/ | Credits (MB) |
[2] 200-|SEC| DayUp| DayDn| WkUp| WkDn| MonthUp| MonthDn| AllUp| AllDn|
[2] 200-|---+-------+-------+-------+-------+--------+--------+---------+---------|
[2] 200-|# 0|NAME: Default | Leech | Credits = 0 |
[2] 200-| | | | | | | | 414| |
[1] site stats
[1] 200-.--[ ioFTPD - Stats ]--------------------------------.
[1] 200-| Week Top Uploaders |
[1] 200-| Section # -1 : [TOTAL] |
[1] 200-|----------------------------------------------------|
[1] 200-| ## | User | Group | Size(MB) | Files |
[1] 200-|----------------------------------------------------|
[1] 200-| 01 | user | NoGroup | 201 | 29666 |
|
|
|
01-29-2014, 09:26 PM
|
#4
|
Too much time...
FlashFXP Beta Tester ioFTPD Administrator
Join Date: May 2005
Posts: 1,194
|
Is that the same user in both cases? The 'site myinfo' looks like that user has an allup of 414MB but no day, week, or monthly uploads so only the total up is displayed. The other user has 201MB up this month so it seems unlikely it's the same user. Try a few users and see how it works. You mentioned just the default section. If you ever had multiple sections and then went to just the default the now undefined sections won't show up via site uinfo/myinfo.
You should be able to see the total MB uploaded in all 4 time periods via site myinfo or site stats. The only difference is you can't get number of files, or time/transfer speeds from myinfo/uinfo. But that didn't seem like it mattered to you anyway.
|
|
|
01-29-2014, 10:41 PM
|
#5
|
Junior Member
Join Date: Jan 2014
Posts: 18
|
Ah, I see now. I was using the test user and hadn't uploaded in some time with the account so that was my mistake. I was looking for or expecting the # of files, I just realized after you pointed it out the 414 number was the MB uploaded. So the command works fine and shows accurate data (proper output below). Also from the beginning I've only ever had default section defined and no other.
I wanted to get the number of files as well, would there be an easy way to show that? I don't care about any other information, the files is the more important stat I wanted them to be able to see really (more than the MB, plus MB is already shown via site myinfo).
[2] 200-|SEC| DayUp| DayDn| WkUp| WkDn| MonthUp| MonthDn| AllUp| AllDn|
[2] 200-|---+-------+-------+-------+-------+--------+--------+---------+---------|
[2] 200-|# 0|NAME: Default | Leech | Credits = 0 |
[2] 200-| | 1| | 212| | 230| | 5744| |
|
|
|
01-29-2014, 10:46 PM
|
#6
|
Junior Member
Join Date: Jan 2014
Posts: 18
|
I did want to see if I could play with UGrep to see if I could figure out how to make the solution myself. I did attempt to load UGrep.itcl earlier but after adding the following line to ioftpd.ini under #[FTP_Custom_Commands] and rehashing, 'site ugrep' and 'site UGrep' returned 500 Command not understood. I am sure I'm doing something wrong, just not sure what.
line that I added:
UGrep = TCL ..\scripts\UGrep.itcl
I also tried:
ugrep = TCL ..\scripts\UGrep.itcl
Also UGrep.itcl does exist in the ioftpd scripts directory.
|
|
|
01-29-2014, 11:08 PM
|
#7
|
Junior Member
Join Date: Jan 2014
Posts: 18
|
This is kind of what I was hoping to make / the stats I wanted displayed.
[2] site mystats
[2] 200-.--[ ioFTPD - MyStats ]---------------------------------------------------------.
[2] 200-| DayUp(MB/Files)| WkUp(MB/Files)| MonthUp(MB/Files)|AllUp(MB/Files) |
[2] 200-|-------------------+-----------------+---------------------+-------------------|
[2] 200-| 1/126 | 212/31096 | 314/54234 | 5744/803747 |
[2] 200-|---------------------------------------------------------------------------------|
|
|
|
01-30-2014, 12:03 AM
|
#8
|
Too much time...
FlashFXP Beta Tester ioFTPD Administrator
Join Date: May 2005
Posts: 1,194
|
After you added the command did you use 'site rehash' to force the server to reload the .ini file? You probably don't want anyone else to use ugrep, but it's best to enter explicit permissions (M is the default for anything not listed) for it in the .ini file as well under [FTP_Site_Permissions] just to make it clear who can use it.
The cookie code used in the file text/Ftp/UserInfo.Section and MyInfo.Section is where you want to make the change to display files and transfer averages. It looks REALLY ugly/complex but after a few minutes you'll get the idea. All the %[T(#)] stuff is applying theme color/bold/etc so you can use 'site color' to make things look pretty. It makes a mess of reading the thing though. There's also some logic to print things differently depending on values in the userfile using %[IF()], but because of the VERY simple cookie parser the brackets change/double because they are inside a cookie/expression. Most of the time it's not bad, but the uinfo/myinfo stuff is REALLY ugly! Bleck. I need a WYSIWYG/GUI editor for this stuff.
I think everything you need should be documented in doc/Cookies.txt and system/Themes.ini and you can also check the Changelog.txt file for maybe more info. All you'll need to do is just add a few more lines for each section and have it use %[ALLDN()] or %[DAYUP()] to get files or speed instead of bytes so you can get whatever you want.
The only other confusing thing you'll find is the *SIZE* argument to something like %[ALLUP()]. It's defined in Cookies.txt and very powerful. Instead of just number of bytes (which is HUGE), you'll want to use MB, but then maybe you'll want it to switch to GB/TB if it gets too big. That is all well documented and pretty straightforward, BUT that isn't what I use because I leave the decision about HOW the data is displayed up to the theme to define. This is VERY cool. If you type 'site myinfo' right now you get the total transferred in MB just like you cut/pasted above. That makes sense since it's what people expected and I found that if I used the auto/3digit modes it was hard to easily tell if someone did 3.23 MB vs 3.23 TB and I liked bigger width numbers meaning more. However I use FlashFXP and it supports ANSI colors so I enable it and all of a sudden 'site myinfo' shows 3.23 MB in GREEN or 3.23 TB in YELLOW which is kind of hard to miss
Almost all server generated responses apply themes I created in a consistent color pattern. Assuming a dark-themed setting MB's are in green, GB in purple, TB in yellow as are some important things, and errors / super-important stuff in red. There are really only 8 colors so it's not a lot of choices. It's a much nicer experience especially for 'site uinfo', but it also helps on 'site users' a lot too. The reason I mention all of this is because leaving how the server colors things, and even how to format a value is left up to the theme designer and that really complicates what the text/ftp Cookie files look like which means you have to deal with my mess if you want to change 'site myinfo' and 'site uinfo' to work for users with color enabled. Basically you use %[F(#)] to point to an entry in the theme and then you prefix the size argument with a '*' and it will use the F entry if a theme is defined else whatever is after the *. The actual way you specify the formatting via a number in the theme is documented in system/Theme.ini. You may not even need to touch that since you can just use existing entries. Again, it's well documented but not really used by anyone.
Anyway, hope that helps point you in the right direction.
If all of that seems to confusing, just ditch all the color stuff by making a new site command which is just a text file full of cookies like mystats = !mystats.txt and just use plain %[ALLDN], etc to display the data. That should be trivially easy. The only thing this wouldn't get you is the ranking against other users which is what I was afraid you wanted...
|
|
|
01-30-2014, 12:56 AM
|
#9
|
Junior Member
Join Date: Jan 2014
Posts: 18
|
Thanks Yil! A lot of info and now I know where to play with things :P
REHASH - Reload config file. (SITE CONFIG REHASH) | (*BAD*)
This did used to work I believe, not sure what happened. It explains why rehash didn't work. I rehashed via the GUI which always did work, not quite sure how it broke.
There was a long time when 'alldn' and other aliases returned the same BAD message. But now they work (not sure why), never changed any code related to any of these commands that I'm aware of, never touched the command aliases in the config either. But alldn etc all do work now, just site rehash doesn't, I can't explain any of that. :P
|
|
|
01-30-2014, 04:16 AM
|
#10
|
Junior Member
Join Date: Jan 2014
Posts: 18
|
Edited myinfo to display stats as I wanted. Thanks Yil!
I made an alias for myinfo called mystats, and restarted ioftpd but it didn't work. I then realized it's because #[FTP_Custom_Commands] was commented out (with # sign). That explains why earlier it didn't work when I tried ugrep.
Last edited by icezellion; 01-30-2014 at 04:48 AM.
|
|
|
01-30-2014, 08:48 AM
|
#11
|
Junior Member
Join Date: Jan 2014
Posts: 18
|
The mystats command displays perfectly in FTPRush for all users, but the end of line formatting character '|' is a bit off in FlashFXP. I'll see if I can figure it out.
Update: It also displays proper formatting in ioGUI, just not FlashFXP. So is maybe FlashFXP issue.. not too sure.
Last edited by icezellion; 01-30-2014 at 09:30 AM.
|
|
|
01-30-2014, 02:14 PM
|
#12
|
Too much time...
FlashFXP Beta Tester ioFTPD Administrator
Join Date: May 2005
Posts: 1,194
|
Make sure you are using a fixed width font otherwise most things won't line up... Flash uses a proportional font by default. Try Terminal font for the status window because that displays .nfo / diz stuff better than other font's I've tried.
|
|
|
01-31-2014, 12:38 AM
|
#13
|
Junior Member
Join Date: Jan 2014
Posts: 18
|
Thanks! Terminal fixed it for FlashFXP.
|
|
|
01-31-2014, 06:26 PM
|
#14
|
Junior Member
Join Date: Jan 2014
Posts: 18
|
Is there by any chance the code for the 'site stats' command somewhere for reference, a stats.itcl or Stats.Header, Stats.Body, Stats.Footer? I'm pretty sure answer is no just asking anyhow, my guess is that stuff is part of the actual program code.
|
|
|
02-01-2014, 12:19 AM
|
#15
|
Too much time...
FlashFXP Beta Tester ioFTPD Administrator
Join Date: May 2005
Posts: 1,194
|
For all the options to 'site stats' use 'site help stats', or check doc/Cookies.txt for %[STATS] message cookie. The message cookie's first argument and last 2 arguments are the names of custom files to process. Check out text/ftp/AllDn.*, AllUP.*, etc for examples since those are what 'site stats' actually uses. The entire userfile for each user processed is available so you can do whatever you want as the cookies are pretty useful and expose almost every field. If you managed to figure out MyInfo.Section this should be trivial.
All of that requires no actual code modification, but the source for the actual server is in the first post of most releases.
I can't think of a trivial solution to hiding the other usernames in a site stat listing though... The reason is the entire userfile of the matching user temporarily replaces the active user while AllUp.Body is being processed and there currently isn't a TrueName or TrueUID or something that you could use %[IF] to compare against... Maybe I'm missing something, but I can't think of a workaround off the top of my head.
|
|
|
Thread Tools |
|
Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 09:08 PM.
|