source: extensions/Password_Policy/admin/PP_admin.php @ 25973

Last change on this file since 25973 was 25089, checked in by Eric, 11 years ago

Initial release 2.5.0

File size: 6.1 KB
Line 
1<?php
2
3global $user, $lang, $conf, $errors;
4
5if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
6// +-----------------------------------------------------------------------+
7// | Check Access and exit when user status is not ok                      |
8// +-----------------------------------------------------------------------+
9check_status(ACCESS_ADMINISTRATOR);
10
11if (!defined('PP_PATH')) define('PP_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
12
13//ini_set('error_reporting', E_ALL);
14//ini_set('display_errors', true);
15
16include_once (PHPWG_ROOT_PATH.'/include/constants.php');
17
18load_language('plugin.lang', PP_PATH);
19
20
21// +-----------------------------------------------------------------------+
22// |                   Variables initialization                            |
23// +-----------------------------------------------------------------------+
24$page['global'] = array();
25$error = array();
26
27$PP_Password_Test_Score = 0;
28
29// +-----------------------------------------------------------------------+
30// |                      Getting plugin version                           |
31// +-----------------------------------------------------------------------+
32$plugin =  PPInfos(PP_PATH);
33$version = $plugin['version'];
34
35
36// +----------------------------------------------------------+
37// |            FCK Editor for email text fields              |
38// +----------------------------------------------------------+
39$toolbar = 'Basic';
40$width = '750px';
41$height = '300px';
42$areas = array();
43array_push($areas,'PP_CustomLockMsg');
44
45if (function_exists('set_fckeditor_instance'))
46{
47  $fcke_config = unserialize($conf['FCKEditor']);
48  foreach($areas as $area)
49  {
50    if (!isset($fcke_config[$area]))
51    {
52      $fcke_config[$area] = false;
53    }
54  }
55  $conf['FCKEditor'] = serialize($fcke_config);
56
57  set_fckeditor_instance($areas, $toolbar, $width, $height);
58}
59
60
61  if (isset($_POST['submit']) and isset($_POST['PP_Password_Enforced']) and isset($_POST['PP_AdminPassword_Enforced']) and isset($_POST['PP_PwdReset']) and isset($_POST['PP_LogFailedPassw']))
62  {
63    $_POST['PP_CustomLockMsg'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['PP_CustomLockMsg'])));
64    // Save global PP configuration
65    // -----------------------------
66    $newconf_PP['PPVersion'] = $version;
67    $newconf_PP['PASSWORDENF'] = (isset($_POST['PP_Password_Enforced']) ? $_POST['PP_Password_Enforced'] : 'false');
68    $newconf_PP['PASSWORD_SCORE'] = (isset($_POST['PP_Password_Score']) ? $_POST['PP_Password_Score'] : '100');
69    $newconf_PP['ADMINPASSWENF'] = (isset($_POST['PP_AdminPassword_Enforced']) ? $_POST['PP_AdminPassword_Enforced'] : 'false');
70    $newconf_PP['PWDRESET'] = (isset($_POST['PP_PwdReset']) ? $_POST['PP_PwdReset'] : 'false');
71    $newconf_PP['LOGFAILBLOCK'] = (isset($_POST['PP_LogFailedPassw']) ? $_POST['PP_LogFailedPassw'] : 'false');
72    $newconf_PP['NBLOGFAIL'] = (isset($_POST['PP_NbFailedPassw']) ? $_POST['PP_NbFailedPassw'] : '0');
73    $newconf_PP['USRLOCKEDTXT'] = (isset($_POST['PP_CustomLockMsg']) ? $_POST['PP_CustomLockMsg'] : l10n('PP_User_Account_Locked_Txt'));
74
75    $conf['PasswordPolicy'] = serialize($newconf_PP);
76
77    conf_update_param('PasswordPolicy', pwg_db_real_escape_string($conf['PasswordPolicy'])); 
78
79    array_push($page['infos'], l10n('PP_save_config'));
80  }
81
82  // Testing password enforcement
83  // ----------------------------
84  if (isset($_POST['PasswordTest']) and isset($_POST['PP_Password_Test']) and !empty($_POST['PP_Password_Test']))
85  {
86    $PP_Password_Test_Score = PP_testpassword($_POST['PP_Password_Test']);
87  }
88  else if (isset($_POST['PasswordTest']) and empty($_POST['PP_Password_Test']))
89  {
90    array_push($page['errors'], l10n('PP_Error_Password_Mandatory'));
91  }
92
93  $conf_PP = unserialize($conf['PasswordPolicy']);
94
95  // ------------------------------------------
96  // Template initialization for forms and data
97  // ------------------------------------------
98  $themeconf=$template->get_template_vars('themeconf');
99  $PP_theme=$themeconf['id'];
100
101  $template->assign(
102    array(
103            'PP_VERSION'                       => $version,
104            'PP_PATH'                          => PP_PATH,
105                                                'PP_PASSWORDENF_TRUE'              => $conf_PP['PASSWORDENF']=='true' ? 'checked="checked"' : '' ,
106                                                'PP_PASSWORDENF_FALSE'             => $conf_PP['PASSWORDENF']=='false' ? 'checked="checked"' : '' ,
107                                                'PP_PASSWORD_SCORE'                => $conf_PP['PASSWORD_SCORE'],
108            'PP_ADMINPASSWENF_TRUE'            => $conf_PP['ADMINPASSWENF']=='true' ? 'checked="checked"' : '' ,
109                                                'PP_ADMINPASSWENF_FALSE'           => $conf_PP['ADMINPASSWENF']=='false' ? 'checked="checked"' : '' ,
110            'PP_PWDRESET_TRUE'                 => $conf_PP['PWDRESET']=='true' ? 'checked="checked"' : '' ,
111            'PP_PWDRESET_FALSE'                => $conf_PP['PWDRESET']=='false' ? 'checked="checked"' : '' ,
112                                                'PP_PASSWORD_TEST_SCORE'           => $PP_Password_Test_Score,
113            'PP_LOGFAILEDPASSW_TRUE'           => $conf_PP['LOGFAILBLOCK']=='true' ? 'checked="checked"' : '' ,
114            'PP_LOGFAILEDPASSW_FALSE'          => $conf_PP['LOGFAILBLOCK']=='false' ? 'checked="checked"' : '' ,
115            'PP_NBLOGFAIL'                     => $conf_PP['NBLOGFAIL'],
116            'PP_USRLOCKEDTXT'                  => $conf_PP['USRLOCKEDTXT']
117    )
118  );
119
120
121// +-----------------------------------------------------------------------+
122// |                             errors display                            |
123// +-----------------------------------------------------------------------+
124  if (isset ($errors) and count($errors) != 0)
125  {
126    $template->assign('errors',array());
127    foreach ($errors as $error)
128    {
129      array_push($page['errors'], $error);
130    }
131  } 
132
133// +-----------------------------------------------------------------------+
134// |                           templates display                           |
135// +-----------------------------------------------------------------------+
136  $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/PP_admin.tpl');
137  $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
138?>
Note: See TracBrowser for help on using the repository browser.