2009-11-30 06:01:34 +00:00
< ? php
/*
----------------------------------------------------------------------
LICENSE
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License ( GPL )
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
To read the license please visit http :// www . gnu . org / copyleft / gpl . html
----------------------------------------------------------------------
*/
2017-10-12 15:54:48 +00:00
/**
* Manages password policy for misc . services on AlternC ( ftp , mail etc . )
*
* @ copyright AlternC - Team 2000 - 2017 https :// alternc . com /
*/
2009-11-30 06:01:34 +00:00
require_once ( " ../class/config.php " );
if ( ! $admin -> enabled ) {
2017-10-06 16:04:36 +00:00
$msg -> raise ( " ERROR " , " admin " , _ ( " This page is restricted to authorized staff " ));
2017-08-15 15:03:56 +00:00
echo $msg -> msg_html_all ();
2009-11-30 06:01:34 +00:00
exit ();
}
$fields = array (
" edit " => array ( " request " , " string " , " " ),
2016-05-23 13:03:13 +00:00
" doedit " => array ( " post " , " string " , " " ),
" minsize " => array ( " post " , " integer " , " 0 " ),
" maxsize " => array ( " post " , " integer " , " 64 " ),
" classcount " => array ( " post " , " integer " , " 0 " ),
" allowlogin " => array ( " post " , " integer " , " 0 " ),
2009-11-30 06:01:34 +00:00
);
getFields ( $fields );
include_once ( " head.php " );
?>
< h3 >< ? php __ ( " Manage Password Policy " ); ?> </h3>
2010-06-02 22:42:03 +00:00
< hr id = " topbar " />
< br />
2009-11-30 06:01:34 +00:00
< ? php
$c = $admin -> listPasswordPolicies ();
2012-06-19 15:26:48 +00:00
if ( isset ( $doedit ) && $doedit ) {
2009-11-30 06:01:34 +00:00
if ( ! $c [ $doedit ]) {
2017-10-06 16:04:36 +00:00
$msg -> raise ( " ERROR " , " admin " , _ ( " Policy not found " ));
2009-11-30 06:01:34 +00:00
} else {
// Change it ;)
if ( $admin -> editPolicy ( $doedit , $minsize , $maxsize , $classcount , $allowlogin )) {
2017-10-06 16:04:36 +00:00
$msg -> raise ( " INFO " , " admin " , _ ( " Policy changed " ));
2009-11-30 06:01:34 +00:00
unset ( $edit );
$c = $admin -> listPasswordPolicies ();
} else {
2017-10-06 16:04:36 +00:00
$msg -> raise ( " ERROR " , " admin " , _ ( " Cannot edit the policy, an error occurred " ));
2009-11-30 06:01:34 +00:00
}
}
}
2017-10-06 16:04:36 +00:00
echo $msg -> msg_html_all ( true , true );
2009-11-30 06:01:34 +00:00
2013-04-23 23:38:08 +00:00
if ( ! empty ( $edit )) {
2009-11-30 06:01:34 +00:00
if ( ! $c [ $edit ]) {
2017-10-06 16:04:36 +00:00
$msg -> raise ( " ERROR " , " admin " , _ ( " Policy not found " ));
2017-08-15 15:03:56 +00:00
echo $msg -> msg_html_all ();
2009-11-30 06:01:34 +00:00
} else {
?>
2017-08-15 15:03:56 +00:00
< p >< ? php __ ( " Please choose which policy you want to apply to this password kind: " ); ?> </p>
2009-11-30 06:01:34 +00:00
2017-08-15 15:03:56 +00:00
< p >< b >< ? php echo $c [ $edit ][ " description " ]; ?> </b></p>
2009-11-30 06:01:34 +00:00
2013-04-23 23:38:08 +00:00
< form method = " post " action = " adm_passpolicy.php " >
2016-05-20 12:21:47 +00:00
< ? php csrf_get (); ?>
2016-05-22 18:14:26 +00:00
< input type = " hidden " name = " doedit " value = " <?php ehe( $edit ); ?> " />
2010-04-29 14:29:27 +00:00
< table class = " tlist " >
2010-04-29 10:07:15 +00:00
< tr >
2009-11-30 06:01:34 +00:00
< th >< ? php __ ( " Minimum Password Size: " ); ?> </th>
2010-04-29 10:07:15 +00:00
< td >< select class = " inl " name = " minsize " id = " minsize " >< ? php for ( $i = 0 ; $i <= 64 ; $i ++ ) {
2009-11-30 06:01:34 +00:00
echo " <option " ;
if ( $c [ $edit ][ " minsize " ] == $i ) echo " selected= \" selected \" " ;
echo " > $i </option> " ;
}
?> </td></tr>
2010-04-29 10:07:15 +00:00
< tr >< th >< ? php __ ( " Maximum Password Size: " ); ?> </th>
< td >< select class = " inl " name = " maxsize " id = " maxsize " >< ? php for ( $i = 0 ; $i <= 64 ; $i ++ ) {
2009-11-30 06:01:34 +00:00
echo " <option " ;
if ( $c [ $edit ][ " maxsize " ] == $i ) echo " selected= \" selected \" " ;
echo " > $i </option> " ;
}
?> </td></tr>
2010-04-29 10:07:15 +00:00
< tr > < th >< ? php __ ( " In how many classes of characters must be the password (at least): " ); ?> </th>
< td >< select class = " inl " name = " classcount " id = " classcount " >< ? php for ( $i = 0 ; $i <= 4 ; $i ++ ) {
2009-11-30 06:01:34 +00:00
echo " <option " ;
if ( $c [ $edit ][ " classcount " ] == $i ) echo " selected= \" selected \" " ;
echo " > $i </option> " ;
}
?> </td></tr>
2010-04-29 10:07:15 +00:00
< tr > < th >< ? php __ ( " Do we allow the password to be like the login? " ); ?> </th>
< td >
< input type = " radio " name = " allowlogin " id = " allowlogin0 " value = " 0 " < ? php cbox ( ! $c [ $edit ][ " allowlogin " ]); ?> /> <?php __("No"); ?>
< input type = " radio " name = " allowlogin " id = " allowlogin1 " value = " 1 " < ? php cbox ( $c [ $edit ][ " allowlogin " ]); ?> /> <?php __("Yes"); ?>
</ td ></ tr >
2009-11-30 06:01:34 +00:00
</ table >
2013-10-18 13:40:34 +00:00
< p >< input type = " submit " class = " inb ok " name = " go " value = " <?php __( " Apply this password policy " ); ?> " /> & nbsp ;
< 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 >
2009-11-30 06:01:34 +00:00
</ form >
2011-03-11 08:07:22 +00:00
< 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>
2009-11-30 06:01:34 +00:00
</ p >
< ? php
require_once ( " foot.php " );
exit ();
}
}
if ( is_array ( $c )) {
?>
< p >
< ? 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. " ); ?>
</ p >
2010-04-29 14:29:27 +00:00
< table class = " tlist " >
2011-02-09 08:37:23 +00:00
< tr >< th rowspan = " 2 " > </ th >< th rowspan = " 2 " >< ? php __ ( " Password Kind " ); ?> </th><th colspan="4"><?php __("Password Policy"); ?></th></tr>
2009-11-30 06:01:34 +00:00
< tr >
< th >< ? php __ ( " Min Size " ); ?> </th>
< th >< ? php __ ( " Max Size " ); ?> </th>
< th >< ? php __ ( " Complexity " ); ?> </th>
< th >< ? php __ ( " Allow Password=Login? " ); ?> </th>
</ tr >
< ? php
2013-05-23 16:18:56 +00:00
foreach ( $c as $v ) {
2009-11-30 06:01:34 +00:00
?>
2013-05-23 16:18:56 +00:00
< tr class = " lst " >
2010-04-29 10:07:15 +00:00
< td class = " center " >
2013-04-25 12:39:24 +00:00
< div class = " ina edit " >< a href = " adm_passpolicy.php?edit=<?php echo urlencode( $v["name"] ); ?> " >< ? php __ ( " Edit " ); ?> </a></div>
2010-04-29 10:07:15 +00:00
</ td >
2009-11-30 06:01:34 +00:00
< td >< ? php echo $v [ " description " ]; ?> </td>
< td class = " center " >< ? php echo $v [ " minsize " ]; ?> </td>
< td class = " center " >< ? php echo $v [ " maxsize " ]; ?> </td>
< td class = " center " >< ? php echo $v [ " classcount " ]; ?> </td>
< td class = " center " >< ? php if ( $v [ " allowlogin " ]) __ ( " Yes " ); else __ ( " No " ); ?> </td>
</ tr >
< ? php
}
?>
</ table >
< ? php } ?>
< ? php include_once ( " foot.php " ); ?>