Alternc  3.2
Alternc logiel libre pour l'h├ębergement
 All Data Structures Namespaces Files Functions Variables Pages
quotas_users.php
Go to the documentation of this file.
1 <?php
2 
3 require_once("../class/config.php");
4 
5 $fields = array (
6  "mode" => array ("get", "integer" ,0),
7  "sd" => array ("get", "integer" ,0),
8  "usr" => array ("get", "integer" ,0),
9 );
11 
12 if (!$admin->enabled) {
13  __("This page is restricted to authorized staff");
14  exit();
15 }
16 
17 include_once ("head.php");
18 
19 ?>
20 <h3><?php __("Quotas status"); ?></h3>
21 <hr id="topbar"/>
22 <br />
23 <?php
24 if (isset($error) && $error) {
25  echo "<p class=\"alert alert-warning\">$error</p>";
26 }
27 ?>
28 <p>
29 <?php __("This page shows the space and service count of your AlternC server and each AlternC accounts.");
30 echo "<br /><br />"; printf(_("If you want to manage them, go to")."&nbsp;<a href=\"adm_list.php\">"._("Administration -> Manage the Alternc accounts")."</a>"); ?>
31 </p>
32 <p>
33 <?php printf(_("Sizes are shown as %s"),($mode==0 || $mode==4)?_("MB."):_("% of the total.")); ?>
34 </p>
35 <p>
36 <?php __("Server-side view:"); ?> <span class="ina <?php if ($mode==4) { echo 'ina-active'; } ?>"><a href="quotas_users.php?mode=4"><?php __("Global"); ?></a></span><br /><br />
37 <?php __("Detailed view:"); ?>
38  <span class="ina <?php if ($mode==0) { echo 'ina-active'; } ?>"><a href="quotas_users.php?mode=0&amp;sd=<?php echo $sd; ?>&amp;usr=<?php echo $usr; ?>"><?php __("In MB"); ?></a></span>
39  <span class="ina <?php if ($mode==1) { echo 'ina-active'; } ?>"><a href="quotas_users.php?mode=1&amp;sd=<?php echo $sd; ?>&amp;usr=<?php echo $usr; ?>"><?php __("Percentage"); ?></a></span>
40  <span class="ina <?php if ($mode==2) { echo 'ina-active'; } ?>"><a href="quotas_users.php?mode=2&amp;sd=<?php echo $sd; ?>&amp;usr=<?php echo $usr; ?>"><?php __("Graphical"); ?></a></span>
41 <?php if ($mode != 4) { ?>
42 <?php if ($usr==0) { if ($sd==0) { ?>
43  <span class="ina"><a href="quotas_users.php?mode=<?php echo $mode; ?>&amp;sd=1&amp;usr=<?php echo $usr; ?>"><?php __("Show the domain names"); ?></a></span>
44  <?php } else { ?>
45  <span class="ina"><a href="quotas_users.php?mode=<?php echo $mode; ?>&amp;sd=0&amp;usr=<?php echo $usr; ?>"><?php __("Hide the domain names"); ?></a></span>
46  <?php } } ?>
47 <?php if ($usr) { ?>
48  <span class="ina"><a href="quotas_users.php?mode=<?php echo $mode; ?>&amp;sd=<?php echo $sd; ?>"><?php __("All accounts"); ?></a></span>
49 <?php } ?>
50 <?php } ?>
51 </p>
52 
53 <?php if ($mode == 4) {
54  // Mode : affichage des donn´┐Żes globales
55 
56  if ($cuid != 2000)
57  {
58  $mList = array();
59  $membres_list = $admin->get_list(0, $cuid);
60  foreach ($membres_list as $n) {
61  $domList = $dom->enum_domains($n["uid"]);
62  $mList[$n["uid"]] = array (
63  "login" => $n["login"],
64  "domaines" => $domList,
65  );
66  }
67 
68  $totalweb = 0; $totalmail = 0; $totallist = 0; $totaldb = 0;
69  $dc = 0; $mc = 0; $mlc = 0; $dbc = 0;
70 
71  foreach ($mList as $mUID => $mData)
72  {
73  $tmpweb = $quota->get_size_web_sum_user($mUID);
74  $totalweb += $tmpweb;
75 
76  if (!empty($mData["domaines"]))
77  {
78  foreach ($mData["domaines"] as $domaine)
79  {
80  $dc++;
81 
82  $tmpmail = $quota->get_size_mail_sum_domain($domaine);
83  $totalmail += $tmpmail;
84  $mc = $quota->get_size_mail_count_domain($domaine);
85 
86  $tmplist = $quota->get_size_mailman_sum_domain($domaine);
87  $totallist += $tmplist;
88  }
89  }
90 
91  $mlc = $quota->get_size_mailman_count_user($mUID);
92  $tmpdb = $quota->get_size_db_sum_user($mData["login"]);
93  $totaldb += $tmpdb;
94  $dbc = $quota->get_size_db_count_user($mData["login"]);
95  }
96 
97  $tmptotal=$totalweb+$totallist+$totalmail+($totaldb/1024);
98  $totaltotal=$quota->get_size_unit($tmptotal);
99  }
100  else
101  {
102  $tmptotalweb = $quota->get_size_web_sum_all(); // In KB
103  $totalweb=$quota->get_size_unit($tmptotalweb * 1024);
104 
105  $tmptotalmail = $quota->get_size_mail_sum_all(); // In B
106  $totalmail=$quota->get_size_unit($tmptotalmail);
107 
108  $tmptotallist = $quota->get_size_mailman_sum_all(); // IN KB
109  $totallist=$quota->get_size_unit($tmptotallist * 1024);
110 
111  $tmptotaldb = $quota->get_size_db_sum_all(); // IN B
112  $totaldb=$quota->get_size_unit($tmptotaldb);
113 
114  $tmptotaltotal=($tmptotalweb*1024)+($tmptotallist*1024)+$tmptotalmail+($tmptotaldb/1024); // IN B
115  $totaltotal=$quota->get_size_unit($tmptotaltotal);
116 
117  $dc = $dom->count_domains_all();
118  $mc = $quota->get_size_mail_count_all();
119  $mlc = $quota->get_size_mailman_count_all();
120  $dbc = $quota->get_size_db_count_all();
121  }
122 
123 ?>
124 <center>
125 <div>
126 <table class="tedit" width="100%">
127 <thead>
128  <tr><th>&nbsp;</th><th><?php __("Count"); ?></th><th><?php __("Space"); ?></th></tr>
129 </thead>
130 <tbody>
131 <tr>
132  <th><?php __("Domains"); ?></th>
133  <td><?php echo $dc; ?></td>
134  <td><?php echo sprintf("%.1f", $totalweb['size'])."&nbsp;".$totalweb['unit']; ?></td>
135 </tr>
136 <tr>
137  <th><?php __("Email addresses"); ?></th>
138  <td><?php echo $mc; ?></td>
139  <td><?php echo sprintf("%.1f", $totalmail['size'])."&nbsp;".$totalmail['unit']; ?></td>
140 </tr>
141 <?php if ($mlc) { ?>
142 <tr>
143  <th><?php __("Mailman lists"); ?></th>
144  <td><?php echo $mlc; ?></td>
145  <td><?php echo sprintf("%.1f", $totallist['size'])."&nbsp;".$totallist['unit']; ?></td>
146 </tr>
147  <?php } ?>
148 <tr>
149  <th><?php __("MySQL Databases"); ?></th>
150  <td><?php echo $dbc; ?></td>
151  <td><?php echo sprintf("%.1f", $totaldb['size'])."&nbsp;".$totaldb['unit']; ?></td>
152 </tr>
153 <tr>
154  <th colspan="2"><?php __("Total"); ?></th>
155  <td><?php echo sprintf("%.1f", $totaltotal['size'])."&nbsp;".$totaltotal['unit']; ?></td>
156 </tr>
157 </tbody>
158 </table>
159 </div>
160 </center>
161 <?php } elseif ($usr==0) {
162  // Mode : affichage de tous les comptes
163 ?>
164 <center>
165 
166 <div>
167 <table class="tedit" width="100%">
168 <thead>
169  <tr><th rowspan="2"><?php __("Account"); ?></th><th colspan="3"><?php __("Count"); ?></th><th colspan="5"><?php __("Space"); ?></th></tr>
170 <tr>
171  <th><?php __("Dom"); ?></th>
172  <th><?php __("Mails"); ?></th>
173  <th><?php __("Lists"); ?></th>
174  <th><?php __("Web"); ?></th>
175  <th><?php __("Mails"); ?></th>
176  <th><?php __("Lists"); ?></th>
177  <th><?php __("DB"); ?></th>
178  <th><?php __("Total"); ?></th>
179 </tr>
180 </thead>
181 <tbody>
182 <?php
183 
184 if ($cuid != 2000)
185 {
186  $mList = array();
187  $membres_list = $admin->get_list(0, $cuid);
188  foreach ($membres_list as $minfo) {
189  $domList = $dom->enum_domains($minfo['uid']);
190  $mList[$muid] = array (
191  "login" => $minfo['login'],
192  "domaines" => $domList,
193  );
194  }
195 
196  $totalweb = 0; $totalmail = 0; $totallist = 0; $totaldb = 0;
197  $dc = 0; $mc = 0; $mlc = 0; $dbc = 0;
198 
199  foreach ($mList as $mUID => $mData)
200  {
201  $tmpweb = $quota->get_size_web_sum_user($mUID);
202  $totalweb += $tmpweb;
203 
204  if (!empty($mData["domaines"]))
205  {
206  foreach ($mData["domaines"] as $domaine)
207  {
208  $dc++;
209 
210  $tmpmail = $quota->get_size_mail_sum_domain($domaine);
211  $totalmail += $tmpmail;
212  $mc = $quota->get_size_mail_count_domain($domaine);
213 
214  $tmplist = $quota->get_size_mailman_sum_domain($domaine);
215  $totallist += $tmplist;
216  }
217  }
218 
219  $mlc = $quota->get_size_mailman_count_user($mUID);
220  $tmpdb = $quota->get_size_db_sum_user($mData["login"]);
221  $totaldb += $tmpdb;
222  $dbc = $quota->get_size_db_count_user($mData["login"]);
223  }
224 
225 }
226 else
227 {
228  $totalweb = $quota->get_size_web_sum_all();
229  $totalmail = $quota->get_size_mail_sum_all();
230  $totallist = $quota->get_size_mailman_sum_all();
231  $totaldb = $quota->get_size_db_sum_all();
232 }
233 
234 $totaltotal=$totalweb+$totallist+($totalmail/1024)+($totaldb/1024); // In KB
235 if ($totaltotal==0) $totaltotal=1;
236 
237 if ($cuid != 2000) {
238  $membres_list = $admin->get_list(0, $cuid);
239 } else {
240  $membres_list = $admin->get_list(1);
241 }
242 
243 foreach ($membres_list as $c) {
244 
245  echo "<tr><td>";
246 
247  // On affiche le compte et ses domaines :
248  echo "<b><a href=\"quotas_users.php?mode=".$mode."&sd=".$sd."&usr=".$c["uid"]."\">".$c["login"]."</a></b><br />\n";
249  $domaines_list = $dom->enum_domains($c["uid"]);
250  $dc=0; // Domain Count
251  $ms=0; // Mail Space
252  $mls=0;
253  foreach ($domaines_list as $d) {
254  if ($sd) echo "&nbsp;&nbsp;&nbsp;-&nbsp;{$d}<br />\n";
255  $dc++;
256  $mstmp = $quota->get_size_mail_sum_domain($d);
257  $ms+=$mstmp;
258  $mlstmp = $quota->get_size_mailman_sum_domain($d);
259  $mls+=$mlstmp;
260  }
261 
262  $mailsize=$quota->get_size_unit($ms);
263 
264  if($mls != 0)
265  $mailmansize=$quota->get_size_unit($mls);
266  else
267  $mailmansize=$quota->get_size_unit($quota->get_size_mailman_sum_user($c["uid"]) * 1024);
268 
269  // Mail Count
270  $maildomains_list = $mail->enum_domains($c["uid"]);
271  $mc = 0;
272  foreach ($maildomains_list as $md) {
273  $mc += $md['nb_mail'];
274  }
275 
276  // Mailman List Count
277  if (isset($mailman)) {
278  $mlc = $mailman->count_ml_user($c["uid"]);
279  echo "</td><td>$dc</td><td>$mc</td><td>$mlc</td><td";
280  if ($mode!=2) echo " style=\"text-align: right\"";
281  echo ">";
282  }
283 
284  // Espace WEB
285  $ws = $quota->get_size_web_sum_user($c["uid"]);
286  $webspace=$quota->get_size_unit($ws * 1024);
287  if (isset($totalweb) && $totalweb){
288  $pc=intval(100*$ws/$totalweb);
289  }
290  else{
291  $pc=0;
292  }
293 
294 if ($mode==0) {
295  echo sprintf("%.1f", $webspace['size'])."&nbsp;".$webspace['unit'];
296 } elseif ($mode==1) {
297  echo sprintf("%.1f",$pc)."&nbsp;%";
298 } else {
299  #echo "<img src=\"images/hippo_bleue.gif\" style=\"width: ".(1*$pc)."px; height: 16px\" alt=\"".$pc."%\" title=\"".$pc."\"/>";
300  $quota->quota_displaybar($pc);
301 }
302  echo "</td><td";
303  if ($mode!=2) echo " style=\"text-align: right\"";
304  echo ">";
305 
306  // Espace Mail :
307 
308 if ($totalmail)
309  $pc=intval(100*$ms/$totalmail);
310 else
311  $pc=0;
312 
313 if ($mode==0) {
314  echo sprintf("%.1f", $mailsize['size'])."&nbsp;".$mailsize['unit'];
315 } elseif ($mode==1) {
316  echo sprintf("%.1f",$pc)."&nbsp;%";
317 } else {
318  #echo "<img src=\"images/hippo_bleue.gif\" style=\"width: ".(1*$pc)."px; height: 16px\" alt=\"".$pc."%\" title=\"".$pc."%\"/>";
319  $quota->quota_displaybar($pc);
320 }
321 
322  echo "</td><td";
323  if ($mode!=2) echo " style=\"text-align: right\"";
324  echo ">";
325 
326  // Espace Mailman :
327 if ($totallist)
328  $pc=intval(100*$mls/$totallist);
329 else
330  $pc=0;
331 
332 if ($mode==0) {
333  echo sprintf("%.1f", $mailmansize['size'])."&nbsp;".$mailmansize['unit'];
334 } elseif ($mode==1) {
335  echo sprintf("%.1f",$pc)."&nbsp;%";
336 } else {
337  #echo "<img src=\"images/hippo_bleue.gif\" style=\"width: ".(1*$pc)."px; height: 16px\" alt=\"".$pc."%\" title=\"".$pc."%\"/>";
338  $quota->quota_displaybar($pc);
339 }
340 
341 echo "</td><td";
342 if ($mode!=2) echo " style=\"text-align: right\"";
343 echo ">";
344 
345 // Espace DB :
346 $ds = $quota->get_size_db_sum_user($c["login"]);
347 $dbsize=$quota->get_size_unit($ds);
348 
349 if ($totaldb)
350  $pc=intval(100*$ds/$totaldb);
351 else
352  $pc=0;
353 
354 if ($mode==0) {
355  echo sprintf("%.1f", $dbsize['size'])."&nbsp;".$dbsize['unit'];
356 } elseif ($mode==1) {
357  echo sprintf("%.1f",$pc)."&nbsp;%";
358 } else {
359  #echo "<img src=\"images/hippo_bleue.gif\" style=\"width: ".(1*$pc)."px; height: 16px\" alt=\"".$pc."%\" title=\"".$pc."%\"/>";
360  $quota->quota_displaybar($pc);
361 }
362 
363 echo "</td><td";
364 if ($mode!=2) echo " style=\"text-align: right\"";
365 echo ">";
366 
367 $ts=$ds/1024+$ws+$ms/1024+$mls; // In KB
368 $totalsize=$quota->get_size_unit($ts * 1024);
369 if ($mode==0) {
370  echo sprintf("%.1f", $totalsize['size'])."&nbsp;".$totalsize['unit'];
371 } elseif ($mode==1) {
372  echo sprintf("%.1f",(100*$ts/$totaltotal))."&nbsp;%";
373 } else {
374  if ($totaltotal) {
375  $pc=intval(100*$ts/$totaltotal);
376  } else {
377  $pc=0;
378  }
379  #echo "<img src=\"images/hippo_bleue.gif\" style=\"width: ".(1*$pc)."px; height: 16px\" alt=\"".$pc."%\" title=\"".$pc."%\"/>";
380  $quota->quota_displaybar($pc);
381 }
382 
383 
384 echo "</td>";
385 
386 echo "</tr>";
387 
388 }
389 
390 ?>
391 </tbody>
392 
393 
394 </table>
395 </div>
396 </center>
397 <?php
398  } else { // Mode affichage d'UN seul compte
399 
400  $oneuser_ok = false;
401  if ($cuid != 2000) {
402  $c = $admin->get($usr);
403  $mcreator = $admin->get_creator($c['uid']);
404  if ($mcreator['uid'] == $cuid) {
405  $oneuser_ok = true;
406  }
407  } else {
408  $c = $admin->get($usr);
409  if ($c != false) {
410  $oneuser_ok = true;
411  }
412  }
413 
414  if ($oneuser_ok) { # quotas_oneuser.php will used prefilled $c
415  define("QUOTASONE","1");
416  require_once("quotas_oneuser.php");
417  }
418 
419  } // endif un seul compte
420 ?>
421 <?php include_once("foot.php"); ?>