1+ <?php
2+
3+ class dashlet_limits {
4+
5+ function show () {
6+ global $ app , $ conf ;
7+
8+ $ limits = array ();
9+
10+ /* Limits to be shown*/
11+
12+ $ limits [] = array ('field ' => 'limit_maildomain ' ,
13+ 'db_table ' => 'mail_domain ' ,
14+ 'db_where ' => '' );
15+
16+ $ limits [] = array ('field ' => 'limit_mailbox ' ,
17+ 'db_table ' => 'mail_user ' ,
18+ 'db_where ' => '' );
19+
20+ $ limits [] = array ('field ' => 'limit_mailalias ' ,
21+ 'db_table ' => 'mail_forwarding ' ,
22+ 'db_where ' => "type = 'alias' " );
23+
24+ $ limits [] = array ('field ' => 'limit_mailaliasdomain ' ,
25+ 'db_table ' => 'mail_forwarding ' ,
26+ 'db_where ' => "type = 'aliasdomain' " );
27+
28+ $ limits [] = array ('field ' => 'limit_mailforward ' ,
29+ 'db_table ' => 'mail_forwarding ' ,
30+ 'db_where ' => "type = 'forward' " );
31+
32+ $ limits [] = array ('field ' => 'limit_mailcatchall ' ,
33+ 'db_table ' => 'mail_forwarding ' ,
34+ 'db_where ' => "type = 'catchall' " );
35+
36+ $ limits [] = array ('field ' => 'limit_mailrouting ' ,
37+ 'db_table ' => 'mail_transport ' ,
38+ 'db_where ' => "" );
39+
40+ $ limits [] = array ('field ' => 'limit_mailfilter ' ,
41+ 'db_table ' => 'mail_user_filter ' ,
42+ 'db_where ' => "" );
43+
44+ $ limits [] = array ('field ' => 'limit_fetchmail ' ,
45+ 'db_table ' => 'mail_get ' ,
46+ 'db_where ' => "" );
47+
48+ $ limits [] = array ('field ' => 'limit_spamfilter_wblist ' ,
49+ 'db_table ' => 'spamfilter_wblist ' ,
50+ 'db_where ' => "" );
51+
52+ $ limits [] = array ('field ' => 'limit_spamfilter_user ' ,
53+ 'db_table ' => 'spamfilter_users ' ,
54+ 'db_where ' => "" );
55+
56+ $ limits [] = array ('field ' => 'limit_spamfilter_policy ' ,
57+ 'db_table ' => 'spamfilter_policy ' ,
58+ 'db_where ' => "" );
59+
60+ $ limits [] = array ('field ' => 'limit_web_domain ' ,
61+ 'db_table ' => 'web_domain ' ,
62+ 'db_where ' => "type = 'vhost' " );
63+
64+ $ limits [] = array ('field ' => 'limit_web_subdomain ' ,
65+ 'db_table ' => 'web_domain ' ,
66+ 'db_where ' => "type = 'subdomain' " );
67+
68+ $ limits [] = array ('field ' => 'limit_web_aliasdomain ' ,
69+ 'db_table ' => 'web_domain ' ,
70+ 'db_where ' => "type = 'aliasdomain' " );
71+
72+ $ limits [] = array ('field ' => 'limit_ftp_user ' ,
73+ 'db_table ' => 'ftp_user ' ,
74+ 'db_where ' => "" );
75+
76+ $ limits [] = array ('field ' => 'limit_shell_user ' ,
77+ 'db_table ' => 'shell_user ' ,
78+ 'db_where ' => "" );
79+
80+ $ limits [] = array ('field ' => 'limit_dns_zone ' ,
81+ 'db_table ' => 'dns_soa ' ,
82+ 'db_where ' => "" );
83+
84+ $ limits [] = array ('field ' => 'limit_dns_record ' ,
85+ 'db_table ' => 'dns_rr ' ,
86+ 'db_where ' => "" );
87+
88+ $ limits [] = array ('field ' => 'limit_database ' ,
89+ 'db_table ' => 'web_database ' ,
90+ 'db_where ' => "" );
91+
92+ $ limits [] = array ('field ' => 'limit_cron ' ,
93+ 'db_table ' => 'cron ' ,
94+ 'db_where ' => "" );
95+
96+ $ limits [] = array ('field ' => 'limit_client ' ,
97+ 'db_table ' => 'client ' ,
98+ 'db_where ' => "" );
99+
100+
101+
102+
103+ //* Loading Template
104+ $ app ->uses ('tpl,tform ' );
105+
106+ $ tpl = new tpl ;
107+ $ tpl ->newTemplate ("dashlets/templates/limits.htm " );
108+
109+ $ lng_file = 'lib/lang/ ' .$ _SESSION ['s ' ]['language ' ].'_dashlet_limits.lng ' ;
110+ include ($ lng_file );
111+ $ tpl ->setVar ($ wb );
112+
113+ if ($ app ->auth ->is_admin ()) {
114+ $ user_is_admin = 1 ;
115+ } else {
116+ $ user_is_admin = 0 ;
117+ }
118+ $ tpl ->setVar ('is_admin ' ,$ user_is_admin );
119+
120+ if ($ user_is_admin == 0 ) {
121+ $ client_group_id = $ _SESSION ["s " ]["user " ]["default_group " ];
122+ $ client = $ app ->db ->queryOneRecord ("SELECT * FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $ client_group_id " );
123+
124+ $ rows = array ();
125+ foreach ($ limits as $ limit ) {
126+ $ field = $ limit ['field ' ];
127+ if ($ client [$ field ] != 0 ) {
128+ $ value = ($ client [$ field ] == '-1 ' )?$ wb ['unlimited_txt ' ]:$ client [$ field ];
129+ $ rows [] = array ('field ' => $ field ,
130+ 'field_txt ' => $ wb [$ field .'_txt ' ],
131+ 'value ' => $ value ,
132+ 'usage ' => $ this ->_get_limit_usage ($ limit ));
133+ }
134+ }
135+ $ tpl ->setLoop ('rows ' ,$ rows );
136+ }
137+
138+
139+ return $ tpl ->grab ();
140+
141+ }
142+
143+ function _get_limit_usage ($ limit ) {
144+ global $ app ;
145+
146+ $ sql = "SELECT count(sys_userid) as number FROM " .$ limit ['db_table ' ]." WHERE " ;
147+ if ($ limit ['db_where ' ] != '' ) $ sql .= $ limit ['db_where ' ]." AND " ;
148+ $ sql .= $ app ->tform ->getAuthSQL ('r ' );
149+ $ rec = $ app ->db ->queryOneRecord ($ sql );
150+ return $ rec ['number ' ];
151+
152+ }
153+
154+ }
155+
156+
157+
158+
159+
160+
161+
162+
163+ ?>
0 commit comments