1 | <?php |
---|
2 | |
---|
3 | global $user, $lang, $conf, $errors; |
---|
4 | |
---|
5 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | Check Access and exit when user status is not ok | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | check_status(ACCESS_ADMINISTRATOR); |
---|
10 | |
---|
11 | if (!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 | |
---|
16 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
17 | |
---|
18 | load_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 | if (isset($_POST['submit']) and isset($_POST['PP_Password_Enforced']) and isset($_POST['PP_AdminPassword_Enforced']) and isset($_POST['PP_PwdReset'])) |
---|
37 | { |
---|
38 | // Save global PP configuration |
---|
39 | // ----------------------------- |
---|
40 | $newconf_PP['PPVersion'] = $version; |
---|
41 | $newconf_PP['PASSWORDENF'] = (isset($_POST['PP_Password_Enforced']) ? $_POST['PP_Password_Enforced'] : 'false'); |
---|
42 | $newconf_PP['PASSWORD_SCORE'] = (isset($_POST['PP_Password_Score']) ? $_POST['PP_Password_Score'] : '100'); |
---|
43 | $newconf_PP['ADMINPASSWENF'] = (isset($_POST['PP_AdminPassword_Enforced']) ? $_POST['PP_AdminPassword_Enforced'] : 'false'); |
---|
44 | $newconf_PP['PWDRESET'] = (isset($_POST['PP_PwdReset']) ? $_POST['PP_PwdReset'] : 'false'); |
---|
45 | |
---|
46 | $conf['PasswordPolicy'] = serialize($newconf_PP); |
---|
47 | |
---|
48 | conf_update_param('PasswordPolicy', pwg_db_real_escape_string($conf['PasswordPolicy'])); |
---|
49 | |
---|
50 | array_push($page['infos'], l10n('PP_save_config')); |
---|
51 | } |
---|
52 | |
---|
53 | // Testing password enforcement |
---|
54 | // ---------------------------- |
---|
55 | if (isset($_POST['PasswordTest']) and isset($_POST['PP_Password_Test']) and !empty($_POST['PP_Password_Test'])) |
---|
56 | { |
---|
57 | $PP_Password_Test_Score = PP_testpassword($_POST['PP_Password_Test']); |
---|
58 | } |
---|
59 | else if (isset($_POST['PasswordTest']) and empty($_POST['PP_Password_Test'])) |
---|
60 | { |
---|
61 | array_push($page['errors'], l10n('PP_Error_Password_Mandatory')); |
---|
62 | } |
---|
63 | |
---|
64 | $conf_PP = unserialize($conf['PasswordPolicy']); |
---|
65 | |
---|
66 | // ------------------------------------------ |
---|
67 | // Template initialization for forms and data |
---|
68 | // ------------------------------------------ |
---|
69 | $themeconf=$template->get_template_vars('themeconf'); |
---|
70 | $PP_theme=$themeconf['id']; |
---|
71 | |
---|
72 | $template->assign( |
---|
73 | array( |
---|
74 | 'PP_VERSION' => $version, |
---|
75 | 'PP_PATH' => PP_PATH, |
---|
76 | 'PP_PASSWORDENF_TRUE' => $conf_PP['PASSWORDENF']=='true' ? 'checked="checked"' : '' , |
---|
77 | 'PP_PASSWORDENF_FALSE' => $conf_PP['PASSWORDENF']=='false' ? 'checked="checked"' : '' , |
---|
78 | 'PP_PASSWORD_SCORE' => $conf_PP['PASSWORD_SCORE'], |
---|
79 | 'PP_ADMINPASSWENF_TRUE' => $conf_PP['ADMINPASSWENF']=='true' ? 'checked="checked"' : '' , |
---|
80 | 'PP_ADMINPASSWENF_FALSE' => $conf_PP['ADMINPASSWENF']=='false' ? 'checked="checked"' : '' , |
---|
81 | 'PP_PWDRESET_TRUE' => $conf_PP['PWDRESET']=='true' ? 'checked="checked"' : '' , |
---|
82 | 'PP_PWDRESET_FALSE' => $conf_PP['PWDRESET']=='false' ? 'checked="checked"' : '' , |
---|
83 | 'PP_PASSWORD_TEST_SCORE' => $PP_Password_Test_Score, |
---|
84 | ) |
---|
85 | ); |
---|
86 | |
---|
87 | |
---|
88 | // +-----------------------------------------------------------------------+ |
---|
89 | // | errors display | |
---|
90 | // +-----------------------------------------------------------------------+ |
---|
91 | if (isset ($errors) and count($errors) != 0) |
---|
92 | { |
---|
93 | $template->assign('errors',array()); |
---|
94 | foreach ($errors as $error) |
---|
95 | { |
---|
96 | array_push($page['errors'], $error); |
---|
97 | } |
---|
98 | } |
---|
99 | |
---|
100 | // +-----------------------------------------------------------------------+ |
---|
101 | // | templates display | |
---|
102 | // +-----------------------------------------------------------------------+ |
---|
103 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/PP_admin.tpl'); |
---|
104 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
105 | ?> |
---|