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 | load_language('plugin.lang', NBC_UserAdvManager_PATH); |
---|
12 | |
---|
13 | $error = array(); |
---|
14 | |
---|
15 | if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_Mail_Info']) and isset($_POST['UserAdvManager_No_Casse']) and isset($_POST['UserAdvManager_Username_Char']) and isset($_POST['UserAdvManager_Confirm_Mail']) and isset($_POST['UserAdvManager_No_Comment_Anonymous']) ) |
---|
16 | { |
---|
17 | $_POST['UserAdvManager_MailInfo_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_MailInfo_Text'])); |
---|
18 | $_POST['UserAdvManager_ConfirmMail_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_Text'])); |
---|
19 | |
---|
20 | $newconf_nbc_UserAdvManager = $_POST['UserAdvManager_Mail_Info'].';'.$_POST['UserAdvManager_No_Casse'].';'.$_POST['UserAdvManager_Confirm_Mail'].';'.(isset($_POST['UserAdvManager_No_Confirm_Group'])?$_POST['UserAdvManager_No_Confirm_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Group'])?$_POST['UserAdvManager_Validated_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Status'])?$_POST['UserAdvManager_Validated_Status']:'').';'.$_POST['UserAdvManager_No_Comment_Anonymous'].';'.$_POST['UserAdvManager_Username_Char'].';'.$_POST['UserAdvManager_Username_List'].';'.(isset($_POST['UserAdvManager_No_Confirm_Status'])?$_POST['UserAdvManager_No_Confirm_Status']:'').';'.$_POST['UserAdvManager_MailInfo_Text'].';'.$_POST['UserAdvManager_ConfirmMail_Text'].';'.$_POST['UserAdvManager_MailExclusion'].';'.$_POST['UserAdvManager_MailExclusion_List']; |
---|
21 | |
---|
22 | $conf['nbc_UserAdvManager'] = $newconf_nbc_UserAdvManager; |
---|
23 | |
---|
24 | $query = ' |
---|
25 | UPDATE '.CONFIG_TABLE.' |
---|
26 | SET value="'.$newconf_nbc_UserAdvManager.'" |
---|
27 | WHERE param="nbc_UserAdvManager" |
---|
28 | LIMIT 1 |
---|
29 | ;'; |
---|
30 | pwg_query($query); |
---|
31 | |
---|
32 | array_push($page['infos'], l10n('UserAdvManager_save_config')); |
---|
33 | } |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
38 | |
---|
39 | /* Group setting for unvalidated and validated users */ |
---|
40 | $groups[-1] = '---------'; |
---|
41 | $No_Valid = -1; |
---|
42 | $Valid = -1; |
---|
43 | |
---|
44 | /* Check groups list in database */ |
---|
45 | $query = ' |
---|
46 | SELECT id, name |
---|
47 | FROM '.GROUPS_TABLE.' |
---|
48 | ORDER BY name ASC |
---|
49 | ;'; |
---|
50 | $result = pwg_query($query); |
---|
51 | |
---|
52 | while ($row = mysql_fetch_array($result)) |
---|
53 | { |
---|
54 | $groups[$row['id']] = $row['name']; |
---|
55 | /* configuration value for unvalidated users */ |
---|
56 | if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == $row['id']) |
---|
57 | { |
---|
58 | $No_Valid = $row['id']; |
---|
59 | } |
---|
60 | /* configuration value for validated users */ |
---|
61 | if (isset($conf_nbc_UserAdvManager[4]) and $conf_nbc_UserAdvManager[4] == $row['id']) |
---|
62 | { |
---|
63 | $Valid = $row['id']; |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | /* Template initialization for unvalidated users group */ |
---|
68 | $template->assign( |
---|
69 | 'No_Confirm_Group', |
---|
70 | array( |
---|
71 | 'group_options'=> $groups, |
---|
72 | 'group_selected' => $No_Valid |
---|
73 | ) |
---|
74 | ); |
---|
75 | /* Template initialization for validated users group */ |
---|
76 | $template->assign( |
---|
77 | 'Validated_Group', |
---|
78 | array( |
---|
79 | 'group_options'=> $groups, |
---|
80 | 'group_selected' => $Valid |
---|
81 | ) |
---|
82 | ); |
---|
83 | |
---|
84 | /* Status setting for unvalidated and validated users */ |
---|
85 | $status_options[-1] = '------------'; |
---|
86 | $No_Valid_Status = -1; |
---|
87 | $Valid_Status = -1; |
---|
88 | |
---|
89 | /* Get status values */ |
---|
90 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
91 | { |
---|
92 | $status_options[$status] = l10n('user_status_'.$status); |
---|
93 | if (isset($conf_nbc_UserAdvManager[9]) and $conf_nbc_UserAdvManager[9] == $status) |
---|
94 | { |
---|
95 | $No_Valid_Status = $status; |
---|
96 | } |
---|
97 | /* Template initialization for unvalidated users group */ |
---|
98 | $template->assign( |
---|
99 | 'No_Confirm_Status', |
---|
100 | array( |
---|
101 | 'Status_options' => $status_options, |
---|
102 | 'Status_selected' => $No_Valid_Status |
---|
103 | )); |
---|
104 | } |
---|
105 | /* Get status values */ |
---|
106 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
107 | { |
---|
108 | $status_options[$status] = l10n('user_status_'.$status); |
---|
109 | if (isset($conf_nbc_UserAdvManager[5]) and $conf_nbc_UserAdvManager[5] == $status) |
---|
110 | { |
---|
111 | $Valid_Status = $status; |
---|
112 | } |
---|
113 | /* Template initialization for unvalidated users group */ |
---|
114 | $template->assign( |
---|
115 | 'Confirm_Status', |
---|
116 | array( |
---|
117 | 'Status_options' => $status_options, |
---|
118 | 'Status_selected' => $Valid_Status |
---|
119 | )); |
---|
120 | } |
---|
121 | |
---|
122 | |
---|
123 | $template->assign( |
---|
124 | array( |
---|
125 | 'UserAdvManager_MAIL_INFO_TRUE' => $conf_nbc_UserAdvManager[0]=='true' ? 'checked="checked"' : '' , |
---|
126 | 'UserAdvManager_MAIL_INFO_FALSE' => $conf_nbc_UserAdvManager[0]=='false' ? 'checked="checked"' : '' , |
---|
127 | 'UserAdvManager_MAILINFO_TEXT' => $conf_nbc_UserAdvManager[10], |
---|
128 | 'UserAdvManager_NO_CASSE_TRUE' => $conf_nbc_UserAdvManager[1]=='true' ? 'checked="checked"' : '' , |
---|
129 | 'UserAdvManager_NO_CASSE_FALSE' => $conf_nbc_UserAdvManager[1]=='false' ? 'checked="checked"' : '' , |
---|
130 | 'UserAdvManager_USERNAME_CHAR_TRUE' => $conf_nbc_UserAdvManager[7]=='true' ? 'checked="checked"' : '' , |
---|
131 | 'UserAdvManager_USERNAME_CHAR_FALSE' => $conf_nbc_UserAdvManager[7]=='false' ? 'checked="checked"' : '' , |
---|
132 | 'UserAdvManager_USERNAME_CHAR_LIST' => $conf_nbc_UserAdvManager[8], |
---|
133 | 'UserAdvManager_CONFIRM_MAIL_TRUE' => $conf_nbc_UserAdvManager[2]=='true' ? 'checked="checked"' : '' , |
---|
134 | 'UserAdvManager_CONFIRM_MAIL_FALSE' => $conf_nbc_UserAdvManager[2]=='false' ? 'checked="checked"' : '' , |
---|
135 | 'UserAdvManager_CONFIRMMAIL_TEXT' => $conf_nbc_UserAdvManager[11], |
---|
136 | 'UserAdvManager_No_Confirm_Group' => $conf_nbc_UserAdvManager[3], |
---|
137 | 'UserAdvManager_Validated_Group' => $conf_nbc_UserAdvManager[4], |
---|
138 | 'UserAdvManager_No_Confirm_Status' => $conf_nbc_UserAdvManager[9], |
---|
139 | 'UserAdvManager_Validated_Status' => $conf_nbc_UserAdvManager[5], |
---|
140 | 'UserAdvManager_NO_COMMENT_ANO_TRUE' => $conf_nbc_UserAdvManager[6]=='true' ? 'checked="checked"' : '' , |
---|
141 | 'UserAdvManager_NO_COMMENT_ANO_FALSE' => $conf_nbc_UserAdvManager[6]=='false' ? 'checked="checked"' : '' , |
---|
142 | 'UserAdvManager_MAILEXCLUSION_TRUE' => $conf_nbc_UserAdvManager[12]=='true' ? 'checked="checked"' : '' , |
---|
143 | 'UserAdvManager_MAILEXCLUSION_FALSE' => $conf_nbc_UserAdvManager[12]=='false' ? 'checked="checked"' : '' , |
---|
144 | 'UserAdvManager_MAILEXCLUSION_LIST' => $conf_nbc_UserAdvManager[13], |
---|
145 | ) |
---|
146 | ); |
---|
147 | |
---|
148 | |
---|
149 | if ( isset($_POST['audit']) or isset($_POST['submit']) ) |
---|
150 | { |
---|
151 | $msg_error1 = ''; |
---|
152 | |
---|
153 | /* username insensible a la casse */ |
---|
154 | if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == 'true') |
---|
155 | { |
---|
156 | $query = " |
---|
157 | SELECT ".$conf['user_fields']['username']." |
---|
158 | FROM ".USERS_TABLE." p1 |
---|
159 | WHERE EXISTS( |
---|
160 | SELECT ".$conf['user_fields']['username']." |
---|
161 | FROM ".USERS_TABLE." p2 |
---|
162 | WHERE p1.".$conf['user_fields']['id']." <> p2.".$conf['user_fields']['id']." |
---|
163 | AND LOWER(p1.".$conf['user_fields']['username'].") = LOWER(p2.".$conf['user_fields']['username'].") |
---|
164 | ) |
---|
165 | ;"; |
---|
166 | $result = pwg_query($query); |
---|
167 | |
---|
168 | while($row = mysql_fetch_array($result)) |
---|
169 | { |
---|
170 | $msg_error1 .= (($msg_error1 <> '') ? '<br/>' : '') . l10n('Err_audit_no_casse').$row['username']; |
---|
171 | } |
---|
172 | } |
---|
173 | |
---|
174 | |
---|
175 | |
---|
176 | $msg_error2 = ''; |
---|
177 | |
---|
178 | /* Username without forbidden keys */ |
---|
179 | if ( isset($conf_nbc_UserAdvManager[7]) and $conf_nbc_UserAdvManager[7] == 'true' ) |
---|
180 | { |
---|
181 | $query = " |
---|
182 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
---|
183 | FROM ".USERS_TABLE." |
---|
184 | ;"; |
---|
185 | $result = pwg_query($query); |
---|
186 | |
---|
187 | while($row = mysql_fetch_array($result)) |
---|
188 | { |
---|
189 | if ( !ValidateUsername($row['username']) ) |
---|
190 | $msg_error2 .= (($msg_error2 <> '') ? '<br/>' : '') . l10n('Err_audit_username_char').$row['username']; |
---|
191 | } |
---|
192 | } |
---|
193 | |
---|
194 | |
---|
195 | $msg_error3 = ''; |
---|
196 | |
---|
197 | /* Email without forbidden domain */ |
---|
198 | if ( isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' ) |
---|
199 | { |
---|
200 | $query = " |
---|
201 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
---|
202 | FROM ".USERS_TABLE." |
---|
203 | ;"; |
---|
204 | $result = pwg_query($query); |
---|
205 | |
---|
206 | while($row = mysql_fetch_array($result)) |
---|
207 | { |
---|
208 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
209 | $conf_nbc_MailExclusion = preg_split('/,/',$conf_nbc_UserAdvManager[13]); |
---|
210 | for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) |
---|
211 | { |
---|
212 | $pattern = '/'.$conf_nbc_MailExclusion[$i].'/'; |
---|
213 | if (preg_match($pattern, $row['mail_address'])) |
---|
214 | { |
---|
215 | $msg_error3 .= (($msg_error3 <> '') ? '<br/>' : '') . l10n('Err_audit_email_forbidden').$row['username'].' ('.$row['mail_address'].')'; |
---|
216 | } |
---|
217 | } |
---|
218 | } |
---|
219 | } |
---|
220 | |
---|
221 | if ($msg_error1 <> '') |
---|
222 | $errors[] = $msg_error1.'<br/><br/>'; |
---|
223 | |
---|
224 | if ($msg_error2 <> '') |
---|
225 | $errors[] = $msg_error2.'<br/><br/>'; |
---|
226 | |
---|
227 | if ($msg_error3 <> '') |
---|
228 | $errors[] = $msg_error3.'<br/><br/>'; |
---|
229 | |
---|
230 | |
---|
231 | if ($msg_error1 <> '' or $msg_error2 <> '' or $msg_error3 <> '') |
---|
232 | array_push($page['errors'], l10n('Err_audit_advise')); |
---|
233 | else |
---|
234 | array_push($page['infos'], l10n('UserAdvManager_audit_ok')); |
---|
235 | } |
---|
236 | |
---|
237 | |
---|
238 | // +-----------------------------------------------------------------------+ |
---|
239 | // | errors display | |
---|
240 | // +-----------------------------------------------------------------------+ |
---|
241 | if ( isset ($errors) and count($errors) != 0) |
---|
242 | { |
---|
243 | $template->assign('errors',array()); |
---|
244 | foreach ($errors as $error) |
---|
245 | { |
---|
246 | array_push($page['errors'], $error); |
---|
247 | } |
---|
248 | } |
---|
249 | |
---|
250 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/UserAdvManager_admin.tpl')); |
---|
251 | $template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); |
---|
252 | ?> |
---|