Add new comment
Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
|
Martin Mrajca's contribution to add a banner with report of the user quota to the LIST command is useful, but his solution suffers from two flaws. If the quota is 0 (signified by bytes_in_avail = 0), it reports nonsense, also it uses more database queries than are necessary. These two flaws are fixed by using the following instead: SQLNamedQuery userquota SELECT "IF ((SELECT (@availmbytes:=ROUND((`bytes_in_avail`/1048576),2)) FROM `ftpquotalimits` WHERE `name`='%u') = 0, \"No user quota applies.\", CONCAT(\"User quota: Used \", (SELECT (@usedmbytes:=ROUND((`bytes_in_used`/1048576),2)) FROM `ftpquotatallies` WHERE `name`='%u'), \"MB from \", @availmbytes, \"MB. You have \", ROUND(@availmbytes-@usedmbytes,2), \"MB available space.\"))"
SQLShowInfo LIST "226" "%{userquota}"
This makes use of MySQL user defined variables to store the results of the two queries, so that the results can be reused. This works for me with MySQL 5.0; I think it should work against MySQL 4.x but I'm not promising.
Reply |





Recent comments
6 hours 9 min ago
11 hours 57 min ago
13 hours 49 min ago
15 hours 34 min ago
19 hours 24 min ago
1 day 1 hour ago
1 day 1 hour ago
1 day 5 hours ago
1 day 11 hours ago
1 day 16 hours ago