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('LCAS_PATH')) define('LCAS_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 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
18 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
19 | |
---|
20 | load_language('plugin.lang', LCAS_PATH); |
---|
21 | load_language('help/plugin.lang', LCAS_PATH); |
---|
22 | |
---|
23 | $error = array(); |
---|
24 | |
---|
25 | /* Not useful */ |
---|
26 | /*$t = pwg_db_fetch_row(pwg_query(' |
---|
27 | SELECT `value` |
---|
28 | FROM `'.CONFIG_TABLE.'` |
---|
29 | WHERE `param` = "LoginCaseAccentsSensitivity" |
---|
30 | LIMIT 1; |
---|
31 | ')); |
---|
32 | |
---|
33 | $conf['LoginCaseAccentsSensitivity'] = $t[0];*/ |
---|
34 | |
---|
35 | // +-----------------------------------------------------------------------+ |
---|
36 | // | Getting plugin version | |
---|
37 | // +-----------------------------------------------------------------------+ |
---|
38 | $plugin = LCAS_PluginInfos(LCAS_PATH); |
---|
39 | $version = $plugin['version']; |
---|
40 | |
---|
41 | if (isset($_POST['submit']) and isset($_POST['LCAS_Option']) and isset($_POST['LCAS_Mail'])) |
---|
42 | { |
---|
43 | |
---|
44 | /* General configuration settings */ |
---|
45 | $_POST['LCAS_MailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['LCAS_MailText']))); |
---|
46 | |
---|
47 | $newconf_LCAS= array( |
---|
48 | $_POST['LCAS_Option'], |
---|
49 | $_POST['LCAS_Mail'], |
---|
50 | $_POST['LCAS_MailText']); |
---|
51 | |
---|
52 | $conf['LoginCaseAccentsSensitivity'] = serialize($newconf_LCAS); |
---|
53 | |
---|
54 | $query = ' |
---|
55 | UPDATE '.CONFIG_TABLE.' |
---|
56 | SET value="'.addslashes($conf['LoginCaseAccentsSensitivity']).'" |
---|
57 | WHERE param="LoginCaseAccentsSensitivity" |
---|
58 | LIMIT 1 |
---|
59 | ;'; |
---|
60 | |
---|
61 | pwg_query($query); |
---|
62 | |
---|
63 | array_push($page['infos'], l10n('LCAS_save_config')); |
---|
64 | } |
---|
65 | |
---|
66 | $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']); |
---|
67 | |
---|
68 | if (isset($conf_LCAS[0])) |
---|
69 | { |
---|
70 | $case_ins = ($conf_LCAS[0] == '1' or $conf_LCAS[0] == '3'); |
---|
71 | $acc_ins = ($conf_LCAS[0] == '2' or $conf_LCAS[0] == '3'); |
---|
72 | |
---|
73 | if ($case_ins or $acc_ins) |
---|
74 | { |
---|
75 | |
---|
76 | // +-----------------------------------------------------------------------+ |
---|
77 | // | user list | |
---|
78 | // +-----------------------------------------------------------------------+ |
---|
79 | |
---|
80 | $page['all_users'] = LCAS_get_user_list($conf_LCAS[0]); |
---|
81 | |
---|
82 | // +-----------------------------------------------------------------------+ |
---|
83 | // | initialization | |
---|
84 | // +-----------------------------------------------------------------------+ |
---|
85 | |
---|
86 | $lcas_UserToUpdate = -1; |
---|
87 | if ((isset($_POST['UserToUpdate'])) && ($_POST['UserToUpdate'] != -1)) { |
---|
88 | $lcas_UserToUpdate = $_POST['UserToUpdate']; |
---|
89 | |
---|
90 | if ((isset($_POST['user-'.$lcas_UserToUpdate])) && ($_POST['user-'.$lcas_UserToUpdate] != '')) { |
---|
91 | // Check if username already exists |
---|
92 | $count = 0; |
---|
93 | $lcas_previous_compare_user = LCAS_change_case($_POST['user-'.$lcas_UserToUpdate], $conf_LCAS[0]); |
---|
94 | foreach ($page['all_users'] as $local_user) |
---|
95 | { |
---|
96 | if ($lcas_previous_compare_user == $local_user['transformed']) { |
---|
97 | $count = 1; |
---|
98 | break; |
---|
99 | } |
---|
100 | } |
---|
101 | |
---|
102 | if ($count < 1) |
---|
103 | { |
---|
104 | // Get old username befor update - Usefull for user notification if is set |
---|
105 | $query =' |
---|
106 | SELECT username |
---|
107 | FROM '.USERS_TABLE.' |
---|
108 | WHERE id = '.$lcas_UserToUpdate.' |
---|
109 | ;'; |
---|
110 | |
---|
111 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
112 | |
---|
113 | // Username update |
---|
114 | $query = ' |
---|
115 | UPDATE '.USERS_TABLE.' |
---|
116 | SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'" |
---|
117 | WHERE id='.$lcas_UserToUpdate.' |
---|
118 | LIMIT 1 |
---|
119 | ;'; |
---|
120 | |
---|
121 | pwg_query($query); |
---|
122 | |
---|
123 | if (isset($conf_LCAS[1]) and $conf_LCAS[1] == 'true') |
---|
124 | { |
---|
125 | LCAS_SendMail($lcas_UserToUpdate, $data['username'], $_POST['user-'.$lcas_UserToUpdate]); |
---|
126 | } |
---|
127 | |
---|
128 | // Reloading conflict table content |
---|
129 | $page['all_users'] = LCAS_get_user_list($conf_LCAS[0]); |
---|
130 | array_push($page['infos'], l10n('LCAS_Info_userlist_username_renamed')); |
---|
131 | } |
---|
132 | else |
---|
133 | { |
---|
134 | // Username already exists |
---|
135 | array_push($page['errors'], l10n('LCAS_Err_Userlist_New_Username_Exists').'<br>"'.$lcas_previous_compare_user.'"'); |
---|
136 | } |
---|
137 | } |
---|
138 | else { |
---|
139 | // Username is empty |
---|
140 | array_push($page['errors'], l10n('LCAS_Err_Userlist_Empty_New_Username')); |
---|
141 | } |
---|
142 | } |
---|
143 | |
---|
144 | // +-----------------------------------------------------------------------+ |
---|
145 | // | user list | |
---|
146 | // +-----------------------------------------------------------------------+ |
---|
147 | |
---|
148 | $lcas_previous_compare_user = ''; |
---|
149 | $visible_user_list = array(); |
---|
150 | foreach ($page['all_users'] as $local_user) |
---|
151 | { |
---|
152 | if ($lcas_previous_compare_user != $local_user['transformed']) { |
---|
153 | $display = 'orange'; |
---|
154 | $lcas_previous_compare_user = $local_user['transformed']; |
---|
155 | } |
---|
156 | else { |
---|
157 | $display = ''; |
---|
158 | } |
---|
159 | |
---|
160 | $template->append( |
---|
161 | 'users', |
---|
162 | array( |
---|
163 | 'ID' => $local_user['id'], |
---|
164 | 'USERNAME' => stripslashes($local_user['username']), |
---|
165 | 'COMPARE' => stripslashes($local_user['transformed']), |
---|
166 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
167 | 'DISPLAY' => $display, |
---|
168 | ) |
---|
169 | ); |
---|
170 | } |
---|
171 | |
---|
172 | } |
---|
173 | } |
---|
174 | |
---|
175 | |
---|
176 | // +-----------------------------------------------------------------------+ |
---|
177 | // | templates init | |
---|
178 | // +-----------------------------------------------------------------------+ |
---|
179 | $template->assign( |
---|
180 | array( |
---|
181 | 'LCAS_VERSION' => $version, |
---|
182 | 'LCAS_PATH' => LCAS_PATH, |
---|
183 | 'LCAS_Option' => $conf_LCAS[0], |
---|
184 | 'LCAS_MAIL_TRUE' => $conf_LCAS[1] == 'true' ? 'checked = "checked"' : '' , |
---|
185 | 'LCAS_MAIL_FALSE' => $conf_LCAS[1] == 'false' ? 'checked = "checked"' : '' , |
---|
186 | 'LCAS_MAILTEXT' => $conf_LCAS[2] |
---|
187 | ) |
---|
188 | ); |
---|
189 | |
---|
190 | |
---|
191 | // +-----------------------------------------------------------------------+ |
---|
192 | // | errors display | |
---|
193 | // +-----------------------------------------------------------------------+ |
---|
194 | if (isset ($errors) and count($errors) != 0) |
---|
195 | { |
---|
196 | $template->assign('errors',array()); |
---|
197 | foreach ($errors as $error) |
---|
198 | { |
---|
199 | array_push($page['errors'], $error); |
---|
200 | } |
---|
201 | } |
---|
202 | |
---|
203 | // +-----------------------------------------------------------------------+ |
---|
204 | // | templates display | |
---|
205 | // +-----------------------------------------------------------------------+ |
---|
206 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/global.tpl'); |
---|
207 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
208 | |
---|
209 | ?> |
---|