Alternc  latest
Alternc logiel libre pour l'hébergement
adm_passpolicy.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  * Manages password policy for misc. services on AlternC (ftp, mail etc.)
22  *
23  * @copyright AlternC-Team 2000-2017 https://alternc.com/
24  */
25 
26 require_once("../class/config.php");
27 
28 if (!$admin->enabled) {
29  $msg->raise("ERROR", "admin", _("This page is restricted to authorized staff"));
30  echo $msg->msg_html_all();
31  exit();
32 }
33 
34 $fields = array (
35  "edit" => array ("request", "string", ""),
36  "doedit" => array ("post", "string", ""),
37  "minsize" => array ("post", "integer", "0"),
38  "maxsize" => array ("post", "integer", "64"),
39  "classcount" => array ("post", "integer", "0"),
40  "allowlogin" => array ("post", "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 $c=$admin->listPasswordPolicies();
54 
55 if (isset($doedit) && $doedit) {
56  if (!$c[$doedit]) {
57  $msg->raise("ERROR", "admin", _("Policy not found"));
58  } else {
59  // Change it ;)
60  if ($admin->editPolicy($doedit,$minsize,$maxsize,$classcount,$allowlogin)) {
61  $msg->raise("INFO", "admin", _("Policy changed"));
62  unset($edit);
63  $c=$admin->listPasswordPolicies();
64  } else {
65  $msg->raise("ERROR", "admin", _("Cannot edit the policy, an error occurred"));
66  }
67  }
68 }
69 echo $msg->msg_html_all(true, true);
70 
71 if (!empty($edit)) {
72  if (!$c[$edit]) {
73  $msg->raise("ERROR", "admin", _("Policy not found"));
74  echo $msg->msg_html_all();
75  } else {
76 ?>
77 
78 <p><?php __("Please choose which policy you want to apply to this password kind:"); ?></p>
79 
80 <p><b><?php echo $c[$edit]["description"]; ?></b></p>
81 
82 <form method="post" action="adm_passpolicy.php">
83  <?php csrf_get(); ?>
84 <input type="hidden" name="doedit" value="<?php ehe($edit); ?>"/>
85 <table class="tlist">
86 <tr>
87  <th><?php __("Minimum Password Size:"); ?></th>
88  <td><select class="inl" name="minsize" id="minsize"><?php for($i=0;$i<=64;$i++) {
89  echo "<option";
90  if ($c[$edit]["minsize"]==$i) echo " selected=\"selected\"";
91  echo ">$i</option>";
92  }
93 ?></td></tr>
94  <tr><th><?php __("Maximum Password Size:"); ?></th>
95  <td><select class="inl" name="maxsize" id="maxsize"><?php for($i=0;$i<=64;$i++) {
96  echo "<option";
97  if ($c[$edit]["maxsize"]==$i) echo " selected=\"selected\"";
98  echo ">$i</option>";
99  }
100 ?></td></tr>
101  <tr> <th><?php __("In how many classes of characters must be the password (at least):"); ?></th>
102  <td><select class="inl" name="classcount" id="classcount"><?php for($i=0;$i<=4;$i++) {
103  echo "<option";
104  if ($c[$edit]["classcount"]==$i) echo " selected=\"selected\"";
105  echo ">$i</option>";
106  }
107 ?></td></tr>
108  <tr> <th><?php __("Do we allow the password to be like the login?"); ?></th>
109  <td>
110  <input type="radio" name="allowlogin" id="allowlogin0" value="0" <?php cbox(!$c[$edit]["allowlogin"]); ?> />&nbsp;<?php __("No"); ?>
111  <input type="radio" name="allowlogin" id="allowlogin1" value="1" <?php cbox($c[$edit]["allowlogin"]); ?> />&nbsp;<?php __("Yes"); ?>
112 </td></tr>
113 </table>
114 <p><input type="submit" class="inb ok" name="go" value="<?php __("Apply this password policy"); ?>" /> &nbsp;
115 <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>
116 </form>
117 
118  <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>
119 </p>
120 
121 <?php
122  require_once("foot.php");
123  exit();
124  }
125 }
126 
127 if (is_array($c)) {
128 
129 ?>
130 <p>
131 <?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."); ?>
132 </p>
133 
134 <table class="tlist">
135  <tr><th rowspan="2"> </th><th rowspan="2"><?php __("Password Kind"); ?></th><th colspan="4"><?php __("Password Policy"); ?></th></tr>
136 <tr>
137  <th><?php __("Min Size"); ?></th>
138  <th><?php __("Max Size"); ?></th>
139  <th><?php __("Complexity"); ?></th>
140  <th><?php __("Allow Password=Login?"); ?></th>
141 </tr>
142 <?php
143 foreach($c as $v) {
144 ?>
145 
146 <tr class="lst">
147 <td class="center">
148  <div class="ina edit"><a href="adm_passpolicy.php?edit=<?php echo urlencode($v["name"]); ?>"><?php __("Edit"); ?></a></div>
149 </td>
150  <td><?php echo $v["description"]; ?></td>
151  <td class="center"><?php echo $v["minsize"]; ?></td>
152  <td class="center"><?php echo $v["maxsize"]; ?></td>
153  <td class="center"><?php echo $v["classcount"]; ?></td>
154  <td class="center"><?php if ($v["allowlogin"]) __("Yes"); else __("No"); ?></td>
155 </tr>
156 <?php
157 }
158 ?>
159 </table>
160 
161  <?php } ?>
162 
163 <?php include_once("foot.php"); ?>
exit
Definition: adm_doadd.php:70
if(! $admin->enabled) $fields
Manages password policy for misc.
$msg
Definition: bootstrap.php:75
__($str)
Definition: functions.php:404
cbox($test, $echo=true)
ECHOes checked="checked" only if the parameter is true useful for checkboxes and radio buttons.
Definition: functions.php:345
getFields($fields, $requestOnly=false)
Get the Fields of the posted form from $_REQUEST or POST or GET and check their type.
Definition: functions.php:688
csrf_get($return=false)
Give a new CSRF uniq token for a form the session must be up since the CSRF is linked to the session ...
Definition: functions.php:1159
$i