18 require_once SQ_LIB_PATH.
'/config/config.inc';
19 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
41 var $config_vars = Array(
42 'SQ_PASSWD_RULE_LENGTH' => Array(
'editable' => 1,
'default' => 6),
43 'SQ_PASSWD_RULE_DISALLOW_USER_INFO' => Array(
'editable' => 1,
'default' => 1),
44 'SQ_PASSWD_RULE_NUM_CAPS' => Array(
'editable' => 1,
'default' => 0),
45 'SQ_PASSWD_RULE_NUM_LOWER' => Array(
'editable' => 1,
'default' => 0),
46 'SQ_PASSWD_RULE_NUM_INT' => Array(
'editable' => 1,
'default' => 0),
47 'SQ_PASSWD_RULE_NUM_PUNC' => Array(
'editable' => 1,
'default' => 0),
48 'SQ_PASSWD_RULE_NUM_SPC' => Array(
'editable' => 1,
'default' => 0),
49 'SQ_PASSWD_RULE_DISALLOWED' => Array(
'editable' => 0,
'default' => -1),
50 'SQ_PASSWD_RULE_DISABLED' => Array(
'editable' => 0,
'default' => 0),
51 'SQ_PASSWD_RULE_BLACK_LIST' => Array(
'editable' => 1,
'default' =>
''),
52 'SQ_PASSWD_RULE_BLACK_LIST_EXACT' => Array(
'editable' => 1,
'default' => 1),
62 parent::__construct();
63 $this->config_file = SQ_DATA_PATH.
'/private/conf/password_rules.inc';
79 function save($vars, $backup_existing=FALSE, $send_message=TRUE)
81 if ($GLOBALS[
'SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_PERMISSIONS)) {
82 $is_root = $GLOBALS[
'SQ_SYSTEM']->userRoot();
83 $is_admin = ($is_root || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
87 trigger_localised_error(
'SYS0267', E_USER_WARNING, $this->name);
92 if (isset($vars[
'SQ_PASSWD_RULE_BLACK_LIST'])) {
93 $vars[
'SQ_PASSWD_RULE_BLACK_LIST']= trim($vars[
'SQ_PASSWD_RULE_BLACK_LIST']);
96 return parent::save($vars, $backup_existing, $send_message);
111 return ($GLOBALS[
'SQ_SYSTEM']->userRoot() || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
124 if (!parent::writeAccess())
return FALSE;
125 if (!$GLOBALS[
'SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_PERMISSIONS)) {
130 return ($GLOBALS[
'SQ_SYSTEM']->userRoot() || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
150 parent::paintBackend($o);
154 $is_root = $GLOBALS[
'SQ_SYSTEM']->userRoot();
156 $class = get_class_lower($this);
158 $o->openSection(translate(
'manage_passwd_rules'));
161 $o->openField(translate(
'min_length'),
'', translate(
'specify_min_length_passwd'));
162 if ($write_access && $is_root) {
163 text_box($class.
'[SQ_PASSWD_RULE_LENGTH]', SQ_PASSWD_RULE_LENGTH, 5);
165 echo SQ_PASSWD_RULE_LENGTH;
169 $o->openField(translate(
'disallow_user_info'),
'', translate(
'disallow_user_info_note'));
170 if ($write_access && $is_root) {
171 combo_box($class.
'[SQ_PASSWD_RULE_DISALLOW_USER_INFO]', Array(
'0' => translate(
'yes'),
'1' => translate(
'no')), FALSE, SQ_PASSWD_RULE_DISALLOW_USER_INFO);
173 echo (SQ_PASSWD_RULE_DISALLOW_USER_INFO) ? translate(
'no') : translate(
'yes');
177 $o->openField(translate(
'character_rules'),
'', translate(
'character_rules_note'));
180 <table
class=
"sq-backend-table">
182 <td style=
"width: 50px;" class=
"sq-backend-table-header"><?php echo translate(
'active_question'); ?>?</td>
183 <td style=
"width: 200px;" class=
"sq-backend-table-header"><?php echo translate(
'character_type'); ?></td>
184 <td
class=
"sq-backend-table-header"><?php echo translate(
'min_number'); ?></td>
185 <td style=
"width: 150px;" class=
"sq-backend-table-header"><?php echo translate(
'disallow_char_type_question'); ?></td>
188 foreach (get_constant_values(
'SQ_PASSWD_RULE_NUM') as $password_rule => $value) {
191 <td
class=
"sq-backend-table-cell">
194 check_box($class.
'_active'.
'['.$password_rule.
']',
'1', ($value != SQ_PASSWD_RULE_DISABLED ? TRUE : FALSE));
196 ?><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo $value != SQ_PASSWD_RULE_DISABLED ? 'tick' : 'cross'; ?>.gif" width=
"15" height=
"15" /><?php
200 <td
class=
"sq-backend-table-cell">
202 switch ($password_rule) {
203 case 'SQ_PASSWD_RULE_NUM_CAPS':
204 echo ucfirst(translate(
'capital_letters'));
206 case 'SQ_PASSWD_RULE_NUM_LOWER':
207 echo ucfirst(translate(
'lowercase_letters'));
209 case 'SQ_PASSWD_RULE_NUM_INT':
210 echo ucfirst(translate(
'numeric_digits'));
212 case 'SQ_PASSWD_RULE_NUM_PUNC':
213 echo ucfirst(translate(
'punctuation_characters'));
215 case 'SQ_PASSWD_RULE_NUM_SPC':
216 echo ucfirst(translate(
'spaces'));
224 <td
class=
"sq-backend-table-cell">
226 if ($value != SQ_PASSWD_RULE_DISABLED && $value != SQ_PASSWD_RULE_DISALLOWED) {
228 int_text_box($class.
'['.$password_rule.
']', $value, FALSE, 5);
237 <td
class=
"sq-backend-table-cell" style=
"text-align: center;">
240 if ($value == SQ_PASSWD_RULE_DISABLED) {
244 check_box($class.
'_disallow'.
'['.$password_rule.
']',
'1', ($value == SQ_PASSWD_RULE_DISALLOWED));
246 ?><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo $value == SQ_PASSWD_RULE_DISALLOWED ? 'tick' : 'cross'; ?>.gif" width=
"15" height=
"15" /><?php
260 $o->openSection(translate(
'passwd_blacklist'));
261 $o->openField(translate(
'word_list'),
'', translate(
'word_list_note'));
264 text_area($class.
'[SQ_PASSWD_RULE_BLACK_LIST]', SQ_PASSWD_RULE_BLACK_LIST, 30, 8);
266 echo nl2br(SQ_PASSWD_RULE_BLACK_LIST);
270 $o->openField(translate(
'exact_match'));
273 check_box($class.
'[SQ_PASSWD_RULE_BLACK_LIST_EXACT]',
'1', SQ_PASSWD_RULE_BLACK_LIST_EXACT);
275 ?><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo SQ_PASSWD_RULE_BLACK_LIST_EXACT ? 'tick' : 'cross'; ?>.gif" width=
"15" height=
"15" /><?php
282 if ($write_access) $o->commitButton(
'', TRUE);
299 $class = get_class_lower($this);
300 require_once $this->config_file;
302 $const = get_constant_values(
'SQ_PASSWD_RULE_NUM');
303 foreach ($const as $password_rule => $value) {
305 eval(
'$active_check_box = isset($_POST'.
"['".$class.
'_active'.
"']".
"['".$password_rule.
"']".
');');
306 eval(
'$disallow_check_box = isset($_POST'.
"['".$class.
'_disallow'.
"']".
"['".$password_rule.
"']".
');');
307 eval(
'$text_box = (isset($_POST'.
"['".$class.
"']".
"['".$password_rule.
"']".
') ? $_POST'.
"['".$class.
"']".
"['".$password_rule.
"']".
' : false);');
309 if ($disallow_check_box) {
310 if ($active_check_box) {
311 $_POST[$class][$password_rule] = SQ_PASSWD_RULE_DISALLOWED;
313 $_POST[$class][$password_rule] = SQ_PASSWD_RULE_DISABLED;
316 if ($active_check_box) {
317 if ($text_box === FALSE) {
318 $_POST[$class][$password_rule] = 1;
321 $_POST[$class][$password_rule] = SQ_PASSWD_RULE_DISABLED;
326 if (!isset($_POST[$class][
'SQ_PASSWD_RULE_BLACK_LIST_EXACT'])) {
327 $_POST[$class][
'SQ_PASSWD_RULE_BLACK_LIST_EXACT'] = 0;
329 $_POST[$class][
'SQ_PASSWD_RULE_BLACK_LIST_EXACT'] = 1;
332 return parent::processBackend($o);