Alternc  3.2
Alternc logiel libre pour l'hébergement
 All Data Structures Namespaces Files Functions Variables Pages
adm_passpolicy.php
Go to the documentation of this file.
1 <?php
2 /*
3  adm_passpolicy.php
4  ----------------------------------------------------------------------
5  AlternC - Web Hosting System
6  Copyright (C) 2002-2010 by the AlternC Development Team.
7  http://alternc.org/
8  ----------------------------------------------------------------------
9  LICENSE
10 
11  This program is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License (GPL)
13  as published by the Free Software Foundation; either version 2
14  of the License, or (at your option) any later version.
15 
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  To read the license please visit http://www.gnu.org/copyleft/gpl.html
22  ----------------------------------------------------------------------
23  Original Author of file: Benjamin Sonntag
24  Purpose of file: Manage the password policy for AlternC
25  ----------------------------------------------------------------------
26 */
27 require_once("../class/config.php");
28 
29 if (!$admin->enabled) {
30  __("This page is restricted to authorized staff");
31  exit();
32 }
33 
34 $fields = array (
35  "edit" => array ("request", "string", ""),
36  "doedit" => array ("request", "string", ""),
37  "minsize" => array ("request", "integer", "0"),
38  "maxsize" => array ("request", "integer", "64"),
39  "classcount" => array ("request", "integer", "0"),
40  "allowlogin" => array ("request", "integer", "0"),
41 );
42 
44 
45 
46 include_once("head.php");
47 
48 ?>
49 <h3><?php __("Manage Password Policy"); ?></h3>
50 <hr id="topbar"/>
51 <br />
52 <?php
53  if (isset($error) && $error) {
54  echo "<p class=\"alert alert-danger\">$error</p>";
55  }
56 
57 
58 $c=$admin->listPasswordPolicies();
59 //echo "<pre>"; print_r($c); echo "</pre>";
60 
61 if (isset($doedit) && $doedit) {
62  if (!$c[$doedit]) {
63  echo "<p class=\"alert alert-danger\">"._("Policy not found")."</p>";
64  } else {
65  // Change it ;)
66  if ($admin->editPolicy($doedit,$minsize,$maxsize,$classcount,$allowlogin)) {
67  echo "<p class=\"info\">"._("Policy changed")."</p>";
68  unset($edit);
69  $c=$admin->listPasswordPolicies();
70  } else {
71  echo "<p class=\"alert alert-danger\">"._("Cannot edit the policy, an error occurred")."</p>";
72  }
73  }
74 }
75 
76 if (!empty($edit)) {
77  if (!$c[$edit]) {
78  echo "<p class=\"alert alert-danger\">"._("Policy not found")."</p>";
79  } else {
80 ?>
81 
82  <p><?php __("Please choose which policy you want to apply to this password kind:"); ?></p>
83 
84  <p><b><?php echo $c[$edit]["description"]; ?></b></p>
85 
86 <form method="post" action="adm_passpolicy.php">
87 <input type="hidden" name="doedit" value="<?php echo $edit; ?>"/>
88 <table class="tlist">
89 <tr>
90  <th><?php __("Minimum Password Size:"); ?></th>
91  <td><select class="inl" name="minsize" id="minsize"><?php for($i=0;$i<=64;$i++) {
92  echo "<option";
93  if ($c[$edit]["minsize"]==$i) echo " selected=\"selected\"";
94  echo ">$i</option>";
95  }
96 ?></td></tr>
97  <tr><th><?php __("Maximum Password Size:"); ?></th>
98  <td><select class="inl" name="maxsize" id="maxsize"><?php for($i=0;$i<=64;$i++) {
99  echo "<option";
100  if ($c[$edit]["maxsize"]==$i) echo " selected=\"selected\"";
101  echo ">$i</option>";
102  }
103 ?></td></tr>
104  <tr> <th><?php __("In how many classes of characters must be the password (at least):"); ?></th>
105  <td><select class="inl" name="classcount" id="classcount"><?php for($i=0;$i<=4;$i++) {
106  echo "<option";
107  if ($c[$edit]["classcount"]==$i) echo " selected=\"selected\"";
108  echo ">$i</option>";
109  }
110 ?></td></tr>
111  <tr> <th><?php __("Do we allow the password to be like the login?"); ?></th>
112  <td>
113  <input type="radio" name="allowlogin" id="allowlogin0" value="0" <?php cbox(!$c[$edit]["allowlogin"]); ?> />&nbsp;<?php __("No"); ?>
114  <input type="radio" name="allowlogin" id="allowlogin1" value="1" <?php cbox($c[$edit]["allowlogin"]); ?> />&nbsp;<?php __("Yes"); ?>
115 </td></tr>
116 </table>
117 <p><input type="submit" class="inb ok" name="go" value="<?php __("Apply this password policy"); ?>" /> &nbsp;
118 <input type="button" class="inb cancel" name="cancel" value="<?php __("Cancel and go back to the policy list"); ?>" onclick="document.location='adm_passpolicy.php'" /></p>
119 </form>
120 
121  <p><?php __("The classes of characters are : <br />1. Low-case letters (a-z)<br />2. Upper-case letters (A-Z)<br />3. Figures (0-9)<br />4. Ascii symbols (!\"#$%&'()*+,-./:;<=>?@[\\]^_`)<br />5. Non-Ascii symbols (accents...)"); ?></p>
122 </p>
123 
124 <?php
125  require_once("foot.php");
126  exit();
127  }
128 }
129 
130 if (is_array($c)) {
131 
132 ?>
133 <p>
134 <?php __("Here is the list of the password policies for each place a password may be needed in AlternC's services. For each of those password kind, you can choose which policy will be applied to passwords. A policy is a minimum and maximum password size, and how many classes of characters must appear in the password. You can also forbid (or not) to use the login or part of it as a password."); ?>
135 </p>
136 
137 <table class="tlist">
138  <tr><th rowspan="2"> </th><th rowspan="2"><?php __("Password Kind"); ?></th><th colspan="4"><?php __("Password Policy"); ?></th></tr>
139 <tr>
140  <th><?php __("Min Size"); ?></th>
141  <th><?php __("Max Size"); ?></th>
142  <th><?php __("Complexity"); ?></th>
143  <th><?php __("Allow Password=Login?"); ?></th>
144 </tr>
145 <?php
146 foreach($c as $v) {
147 ?>
148 
149 <tr class="lst">
150 <td class="center">
151  <div class="ina edit"><a href="adm_passpolicy.php?edit=<?php echo urlencode($v["name"]); ?>"><?php __("Edit"); ?></a></div>
152 </td>
153  <td><?php echo $v["description"]; ?></td>
154  <td class="center"><?php echo $v["minsize"]; ?></td>
155  <td class="center"><?php echo $v["maxsize"]; ?></td>
156  <td class="center"><?php echo $v["classcount"]; ?></td>
157  <td class="center"><?php if ($v["allowlogin"]) __("Yes"); else __("No"); ?></td>
158 </tr>
159 <?php
160 }
161 ?>
162 </table>
163 
164  <?php } ?>
165 
166 <?php include_once("foot.php"); ?>