Alternc  3.2
Alternc logiel libre pour l'hébergement
 All Data Structures Namespaces Files Functions Variables Pages
adm_list.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  AlternC - Web Hosting System
5  Copyright (C) 2006 Le réseau Koumbit Inc.
6  http://koumbit.org/
7  Copyright (C) 2002 by the AlternC Development Team.
8  http://alternc.org/
9  ----------------------------------------------------------------------
10  LICENSE
11 
12  This program is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License (GPL)
14  as published by the Free Software Foundation; either version 2
15  of the License, or (at your option) any later version.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  To read the license please visit http://www.gnu.org/copyleft/gpl.html
23  ----------------------------------------------------------------------
24  Original Author of file: Benjamin Sonntag
25  Purpose of file: Show the member list
26  ----------------------------------------------------------------------
27 */
28 require_once("../class/config.php");
29 include_once("head.php");
30 
31 if (!$admin->enabled) {
32  __("This page is restricted to authorized staff");
33  include_once('foot.php');
34  exit();
35 }
36 
37 $fields = array (
38  "show" => array ("request", "string", ""),
39  "creator" => array("request", "integer", 0),
40  "short" => array("request", "integer", -1),
41  "pattern" => array("post", "string", "*"),
42  "pattern_type" => array("post", "string", "login"),
43 );
45 
46 if (empty($pattern)) $pattern="*";
47 
48 if ($short!=-1) {
49  $mem->adminpref($short);
50  $mem->user["admlist"]=$short;
51 }
52 
53 $subadmin=variable_get("subadmin_restriction", 0);
54 
55 // If we ask for all account but we aren't "admin" and
56 // subadmin var is not 1
57 if ($show=="all" && !$subadmin==1 && $cuid != 2000) {
58  __("This page is restricted to authorized staff");
59  include('foot.php');
60  exit();
61 }
62 
63 if ($pattern && $pattern_type) {
64  $r=$admin->get_list($show == 'all' ? 1 : 0, $creator, $pattern, $pattern_type);
65 } else {
66  $r = FALSE;
67 }
68 ?>
69 
70 <h3><?php __("AlternC account list"); ?></h3>
71 <hr id="topbar"/>
72 
73 <?php
74 // Depending on the admin's choice, let's show a short list or a long list.
75 if ($mem->user["admlist"]==0) { // Normal (large) mode
76 ?>
77  <p><span class="ina" style="float: right;"><a href="adm_list.php?short=1"><?php __("Minimal view"); ?></a></span></p>
78 <?php
79 } else {
80 ?>
81  <p><span class="ina" style="float:right;"><a href="adm_list.php?short=0"><?php __("Complete view"); ?></a></span></p>
82 <?php
83 }
84 ?>
85 
86 <fieldset style="clear:both;">
87  <legend><?php __("Filters"); ?></legend>
88  <form method="post" action="adm_list.php" >
89  <p>
90  <label for="pattern_type_login"><?php __("Search for a Login"); ?></label><input type="radio" name="pattern_type" value="login" id="pattern_type_login" <?php if (!$pattern_type || $pattern_type === 'login') echo ' checked="checked" '; ?>/>&nbsp;
91  <label for="pattern_type_domain"><?php __("Search for a Domain"); ?></label><input type="radio" name="pattern_type" value="domaine" id="pattern_type_domain" <?php if ($pattern_type === 'domaine') echo ' checked="checked" '; ?>/>
92  <input type="text" id="pattern" name="pattern" value="<?php echo $pattern ?>"/> <input type="submit" class="inb filter" value="<?php __("submit"); ?>" />
93  </p>
94  </form>
95  <?php
96  $list_creators = $admin->get_creator_list();
97 
98  if ($subadmin==1 || $cuid==2000) {
99  if($show != 'all') {
100  echo '<p><span class="inb filter"><a href="adm_list.php?show=all">' . _('List all AlternC accounts') . '</a></span>';
101 
102  if ($subadmin==1 || $cuid==2000) {
103  $infos_creators = array();
104 
105  foreach ($list_creators as $key => $val) {
106  $infos_creators[] = '<a href="adm_list.php?creator=' . $val['uid'] . '">' . $val['login'] . '</a>';
107  }
108 
109  if (count($infos_creators)) {
110  echo ' ('._("Or only the accounts of:")." ". implode(', ', $infos_creators) . ')';
111  }
112  }
113  echo "</p>";
114  } else { // if show != all
115  echo '<p><span class="ina filter"><a href="adm_list.php">' . _('List only my accounts') . '</a></span></p>';
116  }
117  }// END ($subadmin==1 || $cuid==2000)
118  ?>
119 </fieldset>
120 
121 <?php
122 if ( !empty($error) ) {
123  echo '<p class="alert alert-danger">' , $error, '</p>';
124 }
125 
126 ?>
127 
128 <p>
129 <?php __("Here is the list of hosted AlternC accounts"); ?> (<?php printf(_("%s accounts"),count($r)); ?>)
130 </p>
131 
132 <p><span class="ina add"><a href="adm_add.php"><?php __("Create a new AlternC account"); ?></a></span></p>
133 
134 <?php
135 if (!is_array($r) || empty($r) ) {
136  echo '<p class="alert alert-danger">'._("No account defined for now").'</p>';
137  include('foot.php');
138 }
139 ?>
140 
141 <form method="post" action="adm_dodel.php">
142 <?php
143 // Depending on the admin's choice, let's show a short list or a long list.
144 
145 if ($mem->user["admlist"]==0) { // Normal (large) mode
146 ?>
147 <p>
148 <?php if (count($r)>5) { ?>
149 <input type="submit" class="inb delete" name="submit" value="<?php __("Delete checked accounts"); ?>" />
150 <?php } ?>
151 </p>
152 <table class="tlist" style="clear:both;">
153 <tr>
154 <th></th>
155 <th><?php __("Account"); ?></th>
156 <th><?php __("Manager"); ?></th>
157 <th><?php __("Created by") ?></th>
158 <th><?php __("Created on") ?></th>
159 <th><?php __("Quotas") ?></th>
160 <th><?php __("Last login"); ?></th>
161 <th><?php __("Last ip"); ?></th>
162 <th><?php __("Fails"); ?></th>
163 <th><?php __('Expiry') ?></th>
164 </tr>
165 <?php
166 reset($r);
167 
168 $col=1;
169 while (list($key,$val)=each($r)) {
170  $col=3-$col;
171 ?>
172  <tr class="lst<?php echo $col; ?>">
173 
174 <?php
175  if ($val["su"]) { ?>
176  <td id="user_<?php echo $val["uid"]; ?>">&nbsp;</td>
177 <?php } else { ?>
178  <td><input type="checkbox" class="inc" name="d[]" id="user_<?php echo $val["uid"]; ?>" value="<?php echo $val["uid"]; ?>" /></td>
179 <?php } // val['su'] ?>
180  <td <?php if ($val["su"]) echo 'style="color: red"'; ?>><label for="user_<?php echo $val["uid"]; ?>"><b><?php echo $val["login"] ?></b></label></td>
181  <td><a title="<?php __("Send an email");?>" href="mailto:<?php echo $val["mail"]; ?>"><?php echo $val["nom"]." ".$val["prenom"] ?></a>&nbsp;</td>
182  <td><?php echo $val["parentlogin"] ?></td>
183  <td><?php echo format_date(_('%3$d-%2$d-%1$d'),$val["created"]); ?></td>
184  <td><?php echo $val["type"] ?></td>
185  <td><?php echo $val["lastlogin"] ?></td>
186  <td><?php echo $val["lastip"] ?></td>
187  <td><?php echo $val["lastfail"] ?></td>
188  <td><div class="<?php echo 'exp' . $admin->renew_get_status($val['uid']) ?>"><?php echo $admin->renew_get_expiry($val['uid']) ?></div></td>
189  </tr>
190 
191 <tr class="lst<?php echo $col; ?>" >
192 <td/><td ><i><?php echo _("DB:").' '.$val['db_server_name']?></i></td>
193 <td colspan="8" >
194 <div id="admlistbtn">
195 <span class="ina<?php if ($col==2) echo "v"; ?>">
196  <a href="adm_login.php?id=<?php echo $val["uid"];?>"><?php __("Connect as"); ?></a>
197 </span>&nbsp;
198  &nbsp;
199 <span class="ina<?php if ($col==2) echo "v"; ?>" >
200  <a href="adm_edit.php?uid=<?php echo $val["uid"] ?>"><?php __("Edit"); ?></a>
201 </span>&nbsp;
202 <span class="ina<?php if ($col==2) echo "v"; ?>" >
203  <a href="adm_quotaedit.php?uid=<?php echo $val["uid"] ?>"><?php __("Quotas"); ?></a>
204 </span>&nbsp;
205  <?php if (!$val["su"]) { ?>
206 <span class="ina<?php if ($col==2) echo "v"; ?>" >
207  <a href="adm_deactivate.php?uid=<?php echo $val["uid"] ?>"><?php __("Disable"); ?></a>
208 </span>&nbsp;
209  <?php } ?>
210 </div>
211 </td>
212 </tr>
213 <?php
214 } // while (list($key,$val)=each($r)) {
215 echo '</table></form><br/>';
216 
217 } // NORMAL MODE
218 if ($mem->user["admlist"]==1) { // SHORT MODE
219 ?>
220 
221  [&nbsp;<?php __("C"); ?>&nbsp;] <?php __("Connect as"); ?> &nbsp; &nbsp;
222  [&nbsp;<?php __("E"); ?>&nbsp;] <?php __("Edit"); ?> &nbsp; &nbsp;
223  [&nbsp;<?php __("Q"); ?>&nbsp;] <?php __("Quotas"); ?> &nbsp; &nbsp;
224 
225 <p>
226 <?php if (count($r)>50) { ?>
227  <input type="submit" class="inb" name="submit" value="<?php __("Delete checked accounts"); ?>" />
228 <?php } // finc count > 50 ?>
229 </p>
230 
231 <table class="tlist" style="clear:both;">
232 <tr>
233  <th colspan="2"> </th><th><?php __("Account"); ?></th>
234  <th colspan="2"> </th><th><?php __("Account"); ?></th>
235  <th colspan="2"> </th><th><?php __("Account"); ?></th>
236 </tr>
237 <?php
238 reset($r);
239 
240 $count_r = 0;
241 foreach ($r as $val) {
242  if ( ($count_r % 3) == 0 ) { echo '<tr class="lst">'; }
243 
244  if ($val["su"]) {
245  echo '<td>&nbsp;</td>';
246  } else {
247  echo '<td align="center"><input type="checkbox" class="inc" name="d[]" value="'.$val["uid"].'" id="id_c_'.$val["uid"].'" /></td>';
248  } // if $val["su"] ?>
249  <td align="center">
250  <a href="adm_login.php?id=<?php echo $val["uid"];?>" title="<?php __("Connect as"); ?>">[&nbsp;<?php __("C"); ?>&nbsp;]</a>
251  <a href="adm_edit.php?uid=<?php echo $val["uid"] ?>" title="<?php __("Edit"); ?>">[&nbsp;<?php __("E"); ?>&nbsp;]</a>
252  <?php if($admin->checkcreator($val['uid'])) { ?>
253  <a href="adm_quotaedit.php?uid=<?php echo $val["uid"] ?>" title="<?php __("Quotas"); ?>">[&nbsp;<?php __("Q"); ?>&nbsp;]</a><?php
254  } // $admin->checkcreator
255  $creator_name = ( ($val['creator'] == '0')?_("himself"):$list_creators[$val['creator']]['login']) ?>
256  </td>
257  <td style="padding-right: 2px; border-right: 1px solid black; <?php if ($val["su"]) echo "color: red"; ?>"><b><label title="<?php printf(_("Creator: %s"), $creator_name);?>" for="id_c_<?php echo $val["uid"]; ?>"><?php echo $val["login"] ?></label></b></td>
258  <?php
259  if ( ($count_r % 3) == 2 ) { echo '</tr>'; }
260  ++$count_r;
261 } // foreach $r
262 ?>
263 </table>
264 <p><input type="submit" class="inb" name="submit" value="<?php __("Delete checked accounts"); ?>" /></p>
265 </form>
266 <?php
267 } // SHORT MODE
268 include_once("foot.php");
269 ?>