Alternc  latest
Alternc logiel libre pour l'hébergement
quotas_oneuser.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  LICENSE
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License (GPL)
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  To read the license please visit http://www.gnu.org/copyleft/gpl.html
17  ----------------------------------------------------------------------
18 */
19 
20 /**
21  * Show quotas for one user
22  *
23  * @copyright AlternC-Team 2000-2017 https://alternc.com/
24  */
25 
26 require_once("../class/config.php");
27 if (!defined("QUOTASONE")) return;
28 
29 // FIXME missing getfield for $mode
30 if (!isset($mode)) { // when included from adm_login, mode is not set
31  $mode = 0;
32 }
33 // $mode = 4; // to debug the graphical mode of quotas
34 
35 // If the var $usr exists, it means we call quotas for 1 user from the general admin page.
36 // If not, we get the ID of the user via $mem->user["login"]
37 if (isset($usr) && is_int($usr)) {
38  $id_usr=$usr;
39  $login=$admin->get_login_by_uid($id_usr);
40 } else {
41  $id_usr = $mem->user["uid"];
42  $login = $mem->user["login"];
43 }
44 ?>
45 <center>
46 
47 <h3 style="text-align:center;"><?php printf(_("<b>%s</b> account"),$login); ?></h3>
48 
49 <div style="width: 600px">
50 
51 <!-- Webspaces -->
52 
53 <?php
54 
55  $totalweb = $quota->getquota('web');
56  if ( $totalweb['u'] > 0 ) {
57  $t=$quota->get_size_unit($totalweb['u'] * 1024);
58  echo "<p>"._("quota_web")." "; // use quota_web because it's the magically translated string
59  echo sprintf("%.1f", $t['size'])."&nbsp;".$t['unit'];
60  echo "</p>";
61  }
62 ?>
63 
64 <!-- Mails -->
65 
66 <p style="text-align: left; font-size:16px;"><b><?php __("Emails"); ?></b></p>
67 
68 <table class="tedit" width="100%">
69 <thead>
70 <tr>
71  <th><?php __("Domains"); ?></th>
72  <th><?php __("Emails"); ?></th>
73  <th><?php __("Space"); ?></th>
74 </tr>
75 </thead>
76 <tbody>
77 <?php
78 
79  $domaines_user = $dom->enum_domains($id_usr);
81  foreach ($domaines_user as $domaine) {
82  $mstmp = $quota->get_size_mail_sum_domain($domaine);
83  $totalmail+=$mstmp;
84  }
85 
86  $t=$quota->get_size_unit($totalmail);
87 
88  foreach ($domaines_user as $domaine) {
89  $alias_sizes = $quota->get_size_mail_details_domain($domaine);
90  $domsize = 0;
91  foreach ($alias_sizes as $e) {
92  if($e['size'] > 0) {
93  $domsize += $e['size'];
94  echo "<tr><td>{$domaine}</td>";
95  echo "<td>".str_replace("_","@",$e["alias"])."</td>";
96  echo "<td"; if ($mode!=2) echo " style=\"text-align: right\""; echo ">";
97  $ms = $quota->get_size_unit($e['size']);
98  if ($totalmail) {
99  $pc=intval(100*($e['size']/$totalmail));
100  } else {
101  $pc=0;
102  }
103  if ($mode==0) {
104  echo sprintf("%.1f", $ms['size'])."&nbsp;".$ms['unit'];
105  } elseif ($mode==1) {
106  echo sprintf("%.1f", $pc)."&nbsp;%";
107  } else {
108  $quota->quota_displaybar($pc);
109  }
110  echo "</td></tr>";
111  }
112  }
113 
114  $d = $quota->get_size_unit($domsize);
115 
116  if ($totalmail) {
117  $tpc = intval(100 * $domsize / $totalmail);
118  } else {
119  $tpc = 0;
120  }
121  if (count($alias_sizes) > 0) {
122  echo "<tr><td style=\"text-align: right\"><i><b>". _('Total'). " {$domaine}</b></i></td><td></td>";
123  echo "<td";
124  if ($mode!=2) echo " style=\"text-align: right\"";
125  echo "><i><b>";
126  if ($mode==0) {
127  echo sprintf("%.1f", $d['size'])."&nbsp;".$d['unit'];
128  } elseif ($mode==1) {
129  echo sprintf("%.1f", $tpc)."&nbsp;%";
130  } else {
131  $quota->quota_displaybar($tpc);
132  }
133  echo "</b></i></td></tr>";
134  }
135 }
136 ?>
137 </tbody>
138 </table>
139 
140 <p>&nbsp;</p>
141 <!-- Databases -->
142 
143 <?php
144  $totaldb = $quota->get_size_db_sum_user($login);
145 
146  $t = $quota->get_size_unit($totaldb);
147 
148  echo "<p style=\"text-align: left; font-size:16px;\"><b>"._("Databases:")." ";
149  echo "</b></p>";
150 ?>
151 
152 <table class="tedit" width="100%">
153 <thead>
154 <tr>
155  <th width='50%'><?php __("DB"); ?></th>
156  <th width='50%'><?php __("Space"); ?></th>
157 </tr>
158 </thead>
159 <tbody>
160 <?php
161 
162  $db_sizes = $quota->get_size_db_details_user($login);
163  foreach ($db_sizes as $d) {
164  echo "<tr><td>".$d["db"]."</td><td";
165  if ($mode!=2) echo " style=\"text-align: right\"";
166  echo ">";
167  $ds = $quota->get_size_unit($d["size"]);
168  if ($totaldb) {
169  $pc=intval(100*$d['size']/$totaldb);
170  } else {
171  $pc=0;
172  }
173  if (isset($mode) && $mode==0) {
174  echo sprintf("%.1f", $ds['size'])."&nbsp;".$ds['unit'];
175  } elseif (isset($mode) &&$mode==1) {
176  echo sprintf("%.1f", $pc)."&nbsp;%";
177  } else {
178  $quota->quota_displaybar($pc, 0);
179  }
180  echo "</td></tr>";
181  }
182 
183  if (count($db_sizes) > 0 && $mode==0) {
184  echo "<tr><td style=\"text-align: right\"><i><b>". _('Total'). " " . _("Databases:")."</b></i></td>";
185  echo "<td style=\"text-align: right\"><i><b>";
186  echo sprintf("%.1f", $t['size'])."&nbsp;".$t['unit'];
187  echo "</b></i></td></tr>";
188  }
189 ?>
190 </tbody>
191 </table>
192 
193 <!-- Mailing lists -->
194 
195 <?php
196  $totallist = $quota->get_size_mailman_sum_user($id_usr);
197  if ($totallist) {
198  // $totalweb is in KB, so we call get_size_unit() with it in Bytes
199  $t=$quota->get_size_unit($totallist * 1024);
200 
201  echo "<p style=\"text-align: left; font-size:16px;\"><b>"._("Mailman lists:")." ";
202  echo "</b></p>";
203 ?>
204 
205 <table class="tedit" width='100%'>
206 <thead>
207 <tr>
208  <th><?php __("Lists"); ?></th>
209  <th><?php __("Space"); ?></th>
210 </tr>
211 </thead>
212 <tbody>
213 <?php
214 
215  $mailman_size = $quota->get_size_mailman_details_user($id_usr);
216  foreach ($mailman_size as $d) {
217  echo "<tr><td>".$d["list"]."</td><td";
218  if ($mode!=2) echo " style=\"text-align: right\"";
219  echo ">";
220  $ds = $quota->get_size_unit($d["size"] * 1024);
221  if ($totallist) {
222  $pc=intval(100*$d['size']/$totallist);
223  } else {
224  $pc=0;
225  }
226  if ($mode==0) {
227  echo sprintf("%.1f", $ds['size'])."&nbsp;".$ds['unit'];
228  } elseif ($mode==1) {
229  echo sprintf("%.1f", $pc)."&nbsp;%";
230  } else {
231  $quota->quota_displaybar($pc);
232  }
233  echo "</td></tr>";
234  }
235 
236  if (count($db_sizes) > 0 && $mode==0) {
237  echo "<tr><td style=\"text-align: right\"><i><b>". _('Total'). " " . _("Mailman lists:")."</b></i></td>";
238  echo "<td";
239  if ($mode!=2) echo " style=\"text-align: right\"";
240  echo "><i><b>";
241  echo sprintf("%.1f", $t['size'])."&nbsp;".$t['unit'];
242  echo "</b></i></td></tr>";
243  }
244 ?>
245 </tbody>
246 </table>
247 
248  <?php } /* totallist */ ?>
249 </div>
250 <p>&nbsp;</p>
251 </center>
$mode
Definition: adm_tldedit.php:40
$mem
Definition: bootstrap.php:71
$d
__($str)
Definition: functions.php:404
if(empty($site_name)) elseif($piwik->site_add( $site_name, $site_urls))
foreach($db_sizes as $d) if(count($db_sizes) > 0 && $mode==0) $totallist
$db_sizes
foreach($domaines_user as $domaine) $t
foreach($domaines_user as $domaine) $totaldb
$domaines_user
$totalmail
$totalweb
$login
$dom
Definition: whois_test.php:10