Add new comment
Want to support HowtoForge? Become 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
14 hours 30 min ago
19 hours 19 min ago
1 day 8 min ago
1 day 2 hours ago
1 day 2 hours ago
1 day 2 hours ago
1 day 6 hours ago
1 day 7 hours ago
1 day 9 hours ago
1 day 17 hours ago