@@ -9,9 +9,9 @@ |
||
9 | 9 | |
10 | 10 | // switch user |
11 | 11 | if(@$_GET['subnetId']=="switch"){ |
12 | - $_SESSION['realipamusername'] = $_SESSION['ipamusername']; |
|
13 | - $_SESSION['ipamusername'] = $_GET['sPage']; |
|
14 | - print '<script>window.location.href = "'.create_link(null).'";</script>'; |
|
12 | + $_SESSION['realipamusername'] = $_SESSION['ipamusername']; |
|
13 | + $_SESSION['ipamusername'] = $_GET['sPage']; |
|
14 | + print '<script>window.location.href = "'.create_link(null).'";</script>'; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | # print all or specific user? |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | <td><?php print _('Authentication'); ?></td> |
71 | 71 | <td> |
72 | 72 | <?php |
73 | - if($auth_details===false) { print "<span class='text-muted'>No auth method</span>"; } |
|
74 | - else { print $auth_details->type." <span class='text-muted'>(".$auth_details->description.")</span>"; } |
|
75 | - ?> |
|
73 | + if($auth_details===false) { print "<span class='text-muted'>No auth method</span>"; } |
|
74 | + else { print $auth_details->type." <span class='text-muted'>(".$auth_details->description.")</span>"; } |
|
75 | + ?> |
|
76 | 76 | </td> |
77 | 77 | </tr> |
78 | 78 | <tr> |
@@ -87,22 +87,22 @@ discard block |
||
87 | 87 | <td><?php print _('Groups'); ?></td> |
88 | 88 | <td> |
89 | 89 | <?php |
90 | - if($user->role == "Administrator") { |
|
91 | - print _('All groups'); |
|
92 | - } |
|
93 | - else { |
|
94 | - $groups = json_decode($user->groups, true); |
|
95 | - $gr = $Admin->groups_parse($groups); |
|
96 | - if(sizeof($gr)>0) { |
|
97 | - foreach($gr as $group) { |
|
98 | - print $group['g_name']."<br>"; |
|
99 | - } |
|
100 | - } |
|
101 | - else { |
|
102 | - print "<span class='text-muted'>No groups</span>"; |
|
103 | - } |
|
104 | - } |
|
105 | - ?> |
|
90 | + if($user->role == "Administrator") { |
|
91 | + print _('All groups'); |
|
92 | + } |
|
93 | + else { |
|
94 | + $groups = json_decode($user->groups, true); |
|
95 | + $gr = $Admin->groups_parse($groups); |
|
96 | + if(sizeof($gr)>0) { |
|
97 | + foreach($gr as $group) { |
|
98 | + print $group['g_name']."<br>"; |
|
99 | + } |
|
100 | + } |
|
101 | + else { |
|
102 | + print "<span class='text-muted'>No groups</span>"; |
|
103 | + } |
|
104 | + } |
|
105 | + ?> |
|
106 | 106 | </td> |
107 | 107 | </tr> |
108 | 108 | <tr> |
@@ -151,26 +151,26 @@ discard block |
||
151 | 151 | <?php |
152 | 152 | # custom subnet fields |
153 | 153 | if(sizeof($custom_fields) > 0) { |
154 | - foreach($custom_fields as $key=>$field) { |
|
155 | - $user->$key = str_replace("\n", "<br>",$user->$key); |
|
156 | - print "<tr>"; |
|
157 | - print " <td>$key</td>"; |
|
158 | - print " <td>"; |
|
159 | - //no length |
|
160 | - if(strlen($user->$key)==0) { |
|
161 | - print "/"; |
|
162 | - } |
|
163 | - //booleans |
|
164 | - elseif($field['type']=="tinyint(1)") { |
|
165 | - if($user->$key == "0") { print _("No"); } |
|
166 | - elseif($user->$key == "1") { print _("Yes"); } |
|
167 | - } |
|
168 | - else { |
|
169 | - print $user->$key; |
|
170 | - } |
|
171 | - print " </td>"; |
|
172 | - print "</tr>"; |
|
173 | - } |
|
154 | + foreach($custom_fields as $key=>$field) { |
|
155 | + $user->$key = str_replace("\n", "<br>",$user->$key); |
|
156 | + print "<tr>"; |
|
157 | + print " <td>$key</td>"; |
|
158 | + print " <td>"; |
|
159 | + //no length |
|
160 | + if(strlen($user->$key)==0) { |
|
161 | + print "/"; |
|
162 | + } |
|
163 | + //booleans |
|
164 | + elseif($field['type']=="tinyint(1)") { |
|
165 | + if($user->$key == "0") { print _("No"); } |
|
166 | + elseif($user->$key == "1") { print _("Yes"); } |
|
167 | + } |
|
168 | + else { |
|
169 | + print $user->$key; |
|
170 | + } |
|
171 | + print " </td>"; |
|
172 | + print "</tr>"; |
|
173 | + } |
|
174 | 174 | } |
175 | 175 | ?> |
176 | 176 |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | |
33 | 33 | # ID must be numeric |
34 | 34 | if($_POST['action']=="edit"||$_POST['action']=="delete") { |
35 | - if(!is_numeric($_POST['userId'])) { $Result->show("danger", _("Invalid ID"), true); } |
|
35 | + if(!is_numeric($_POST['userId'])) { $Result->show("danger", _("Invalid ID"), true); } |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | # if password changes check and hash passwords |
39 | 39 | if(strlen(@$_POST['password1'])>0 || (@$_POST['action']=="add" && $auth_method->type=="local")) { |
40 | - //checks |
|
41 | - if($_POST['password1']!=$_POST['password2']) { $Result->show("danger", _("Passwords do not match"), true); } |
|
42 | - if(strlen($_POST['password1'])<8) { $Result->show("danger", _("Password must be at least 8 characters long!"), true); } |
|
40 | + //checks |
|
41 | + if($_POST['password1']!=$_POST['password2']) { $Result->show("danger", _("Passwords do not match"), true); } |
|
42 | + if(strlen($_POST['password1'])<8) { $Result->show("danger", _("Password must be at least 8 characters long!"), true); } |
|
43 | 43 | |
44 | - //hash passowrd |
|
45 | - $_POST['password1'] = $User->crypt_user_pass ($_POST['password1']); |
|
44 | + //hash passowrd |
|
45 | + $_POST['password1'] = $User->crypt_user_pass ($_POST['password1']); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | # general checks |
@@ -52,16 +52,16 @@ discard block |
||
52 | 52 | |
53 | 53 | # username must not already exist (if action is add) |
54 | 54 | if ($_POST['action']=="add") { |
55 | - //username > 8 chars |
|
56 | - if ($auth_method->type=="local") { |
|
57 | - if(strlen($_POST['username'])<6) { $Result->show("danger", _("Username must be at least 6 characters long!"), true); } |
|
58 | - } else { |
|
59 | - if(strlen($_POST['username'])==0) { $Result->show("danger", _("Username must be at least 1 character long!"), true); } |
|
60 | - } |
|
61 | - //check duplicate |
|
62 | - if($Admin->fetch_object("users", "username", $_POST['username'])!==false) { |
|
63 | - { $Result->show("danger", _("User")." ".$_POST['username']." "._("already exists!"), true); } |
|
64 | - } |
|
55 | + //username > 8 chars |
|
56 | + if ($auth_method->type=="local") { |
|
57 | + if(strlen($_POST['username'])<6) { $Result->show("danger", _("Username must be at least 6 characters long!"), true); } |
|
58 | + } else { |
|
59 | + if(strlen($_POST['username'])==0) { $Result->show("danger", _("Username must be at least 1 character long!"), true); } |
|
60 | + } |
|
61 | + //check duplicate |
|
62 | + if($Admin->fetch_object("users", "username", $_POST['username'])!==false) { |
|
63 | + { $Result->show("danger", _("User")." ".$_POST['username']." "._("already exists!"), true); } |
|
64 | + } |
|
65 | 65 | } |
66 | 66 | # admin user cannot be deleted |
67 | 67 | if($_POST['action']=="delete" && $_POST['username']=="admin") { $Result->show("danger", _("Admin user cannot be deleted"), true); } |
@@ -69,21 +69,21 @@ discard block |
||
69 | 69 | # custom fields check |
70 | 70 | $myFields = $Tools->fetch_custom_fields('users'); |
71 | 71 | if(sizeof($myFields) > 0) { |
72 | - foreach($myFields as $myField) { |
|
73 | - # replace possible ___ back to spaces! |
|
74 | - $myField['nameTest'] = str_replace(" ", "___", $myField['name']); |
|
75 | - |
|
76 | - if(isset($_POST[$myField['nameTest']])) { $_POST[$myField['name']] = $_POST[$myField['nameTest']];} |
|
77 | - |
|
78 | - //booleans can be only 0 and 1! |
|
79 | - if($myField['type']=="tinyint(1)") { |
|
80 | - if($_POST[$myField['name']]>1) { |
|
81 | - $$_POST[$myField['name']] = ""; |
|
82 | - } |
|
83 | - } |
|
84 | - //not null! |
|
85 | - if($myField['Null']=="NO" && strlen($_POST[$myField['name']])==0) { $Result->show("danger", '"'.$myField['name'].'" can not be empty!', true); } |
|
86 | - } |
|
72 | + foreach($myFields as $myField) { |
|
73 | + # replace possible ___ back to spaces! |
|
74 | + $myField['nameTest'] = str_replace(" ", "___", $myField['name']); |
|
75 | + |
|
76 | + if(isset($_POST[$myField['nameTest']])) { $_POST[$myField['name']] = $_POST[$myField['nameTest']];} |
|
77 | + |
|
78 | + //booleans can be only 0 and 1! |
|
79 | + if($myField['type']=="tinyint(1)") { |
|
80 | + if($_POST[$myField['name']]>1) { |
|
81 | + $$_POST[$myField['name']] = ""; |
|
82 | + } |
|
83 | + } |
|
84 | + //not null! |
|
85 | + if($myField['Null']=="NO" && strlen($_POST[$myField['name']])==0) { $Result->show("danger", '"'.$myField['name'].'" can not be empty!', true); } |
|
86 | + } |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -91,34 +91,34 @@ discard block |
||
91 | 91 | |
92 | 92 | # formulate update values |
93 | 93 | $values = array("id"=>@$_POST['userId'], |
94 | - "real_name"=>$_POST['real_name'], |
|
95 | - "username"=>$_POST['username'], |
|
96 | - "email"=>$_POST['email'], |
|
97 | - "role"=>$_POST['role'], |
|
98 | - "authMethod"=>$_POST['authMethod'], |
|
99 | - "lang"=>$_POST['lang'], |
|
100 | - "mailNotify"=>$_POST['mailNotify'], |
|
101 | - "mailChangelog"=>$_POST['mailChangelog'], |
|
102 | - "pdns"=>$_POST['pdns'] |
|
103 | - ); |
|
94 | + "real_name"=>$_POST['real_name'], |
|
95 | + "username"=>$_POST['username'], |
|
96 | + "email"=>$_POST['email'], |
|
97 | + "role"=>$_POST['role'], |
|
98 | + "authMethod"=>$_POST['authMethod'], |
|
99 | + "lang"=>$_POST['lang'], |
|
100 | + "mailNotify"=>$_POST['mailNotify'], |
|
101 | + "mailChangelog"=>$_POST['mailChangelog'], |
|
102 | + "pdns"=>$_POST['pdns'] |
|
103 | + ); |
|
104 | 104 | # update pass ? |
105 | 105 | if(strlen(@$_POST['password1'])>0 || (@$_POST['action']=="add" && $auth_method->type=="local")) { |
106 | - $values['password'] = $_POST['password1']; |
|
106 | + $values['password'] = $_POST['password1']; |
|
107 | 107 | } |
108 | 108 | # pass change |
109 | 109 | if(isset($_POST['passChange']) && $auth_method->type=="local") { |
110 | - $values['passChange'] = "Yes"; |
|
110 | + $values['passChange'] = "Yes"; |
|
111 | 111 | } |
112 | 112 | # set groups user belongs to |
113 | 113 | if($_POST['role']=="Administrator") { |
114 | - $values['groups'] = null; |
|
114 | + $values['groups'] = null; |
|
115 | 115 | } else { |
116 | - foreach($_POST as $key=>$post) { |
|
117 | - if(substr($key, 0,5) == "group") { |
|
118 | - $group[substr($key, 5)] = substr($key, 5); |
|
119 | - } |
|
120 | - } |
|
121 | - $values['groups'] = json_encode(@$group); |
|
116 | + foreach($_POST as $key=>$post) { |
|
117 | + if(substr($key, 0,5) == "group") { |
|
118 | + $group[substr($key, 5)] = substr($key, 5); |
|
119 | + } |
|
120 | + } |
|
121 | + $values['groups'] = json_encode(@$group); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | # execute |
@@ -33,17 +33,17 @@ discard block |
||
33 | 33 | |
34 | 34 | # set header parameters and fetch user |
35 | 35 | if($_POST['action']!="add") { |
36 | - $user = $Admin->fetch_object ("users", "id", $_POST['id']); |
|
37 | - //false |
|
38 | - if($user===false) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
39 | - else { |
|
40 | - $user = (array) $user; |
|
41 | - } |
|
36 | + $user = $Admin->fetch_object ("users", "id", $_POST['id']); |
|
37 | + //false |
|
38 | + if($user===false) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
39 | + else { |
|
40 | + $user = (array) $user; |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | else { |
44 | - $user = array(); |
|
45 | - //set default lang |
|
46 | - $user['lang']=$User->settings->defaultLang; |
|
44 | + $user = array(); |
|
45 | + //set default lang |
|
46 | + $user['lang']=$User->settings->defaultLang; |
|
47 | 47 | } |
48 | 48 | ?> |
49 | 49 | |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | <td> |
130 | 130 | <select name="authMethod" id="authMethod" class="form-control input-sm input-w-auto"> |
131 | 131 | <?php |
132 | - foreach($auth_types as $type) { |
|
133 | - # match |
|
134 | - if($type->id==@$user['authMethod']) { print "<option value='$type->id' selected>$type->type ($type->description)</option>"; } |
|
135 | - else { print "<option value='$type->id' >$type->type ($type->description)</option>"; } |
|
136 | - } |
|
137 | - ?> |
|
132 | + foreach($auth_types as $type) { |
|
133 | + # match |
|
134 | + if($type->id==@$user['authMethod']) { print "<option value='$type->id' selected>$type->type ($type->description)</option>"; } |
|
135 | + else { print "<option value='$type->id' >$type->type ($type->description)</option>"; } |
|
136 | + } |
|
137 | + ?> |
|
138 | 138 | </select> |
139 | 139 | </td> |
140 | 140 | <td class="info2"><?php print _("Select authentication method for user"); ?></td> |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | <td> |
185 | 185 | <select name="lang" class="form-control input-sm input-w-auto"> |
186 | 186 | <?php |
187 | - foreach($langs as $lang) { |
|
188 | - if($lang->l_id==$user['lang']) { print "<option value='$lang->l_id' selected>$lang->l_name ($lang->l_code)</option>"; } |
|
189 | - else { print "<option value='$lang->l_id' >$lang->l_name ($lang->l_code)</option>"; } |
|
190 | - } |
|
191 | - ?> |
|
187 | + foreach($langs as $lang) { |
|
188 | + if($lang->l_id==$user['lang']) { print "<option value='$lang->l_id' selected>$lang->l_name ($lang->l_code)</option>"; } |
|
189 | + else { print "<option value='$lang->l_id' >$lang->l_name ($lang->l_code)</option>"; } |
|
190 | + } |
|
191 | + ?> |
|
192 | 192 | </select> |
193 | 193 | </td> |
194 | 194 | <td class="info2"><?php print _('Select language'); ?></td> |
@@ -241,28 +241,28 @@ discard block |
||
241 | 241 | <td><?php print _('Groups'); ?></td> |
242 | 242 | <td class="groups"> |
243 | 243 | <?php |
244 | - //print groups |
|
245 | - if($groups!==false) { |
|
246 | - //set groups |
|
247 | - $ugroups = json_decode(@$user['groups'], true); |
|
248 | - $ugroups = $Admin->groups_parse_ids($ugroups); |
|
249 | - |
|
250 | - foreach($groups as $g) { |
|
251 | - # empty fix |
|
252 | - if(sizeof($ugroups) > 0) { |
|
253 | - if(in_array($g->g_id, $ugroups)) { print "<input type='checkbox' name='group$g->g_id' checked>$g->g_name<br>"; } |
|
254 | - else { print "<input type='checkbox' name='group$g->g_id' >$g->g_name<br>"; } |
|
255 | - } |
|
256 | - else { |
|
257 | - { print "<input type='checkbox' name='group$g->g_id'>$g->g_name<br>"; } |
|
258 | - } |
|
259 | - } |
|
260 | - } |
|
261 | - else { |
|
262 | - $Result->show("danger", _("No groups configured"), false); |
|
263 | - } |
|
264 | - |
|
265 | - ?> |
|
244 | + //print groups |
|
245 | + if($groups!==false) { |
|
246 | + //set groups |
|
247 | + $ugroups = json_decode(@$user['groups'], true); |
|
248 | + $ugroups = $Admin->groups_parse_ids($ugroups); |
|
249 | + |
|
250 | + foreach($groups as $g) { |
|
251 | + # empty fix |
|
252 | + if(sizeof($ugroups) > 0) { |
|
253 | + if(in_array($g->g_id, $ugroups)) { print "<input type='checkbox' name='group$g->g_id' checked>$g->g_name<br>"; } |
|
254 | + else { print "<input type='checkbox' name='group$g->g_id' >$g->g_name<br>"; } |
|
255 | + } |
|
256 | + else { |
|
257 | + { print "<input type='checkbox' name='group$g->g_id'>$g->g_name<br>"; } |
|
258 | + } |
|
259 | + } |
|
260 | + } |
|
261 | + else { |
|
262 | + $Result->show("danger", _("No groups configured"), false); |
|
263 | + } |
|
264 | + |
|
265 | + ?> |
|
266 | 266 | </td> |
267 | 267 | <td class="info2"><?php print _('Select to which groups the user belongs to'); ?></td> |
268 | 268 | </tr> |
@@ -284,99 +284,99 @@ discard block |
||
284 | 284 | |
285 | 285 | <!-- Custom --> |
286 | 286 | <?php |
287 | - if(sizeof($custom) > 0) { |
|
288 | - print '<tr>'; |
|
289 | - print ' <td colspan="3"><hr></td>'; |
|
290 | - print '</tr>'; |
|
291 | - |
|
292 | - # count datepickers |
|
293 | - $timeP = 0; |
|
294 | - |
|
295 | - # all my fields |
|
296 | - foreach($custom as $field) { |
|
297 | - # replace spaces with | |
|
298 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
299 | - |
|
300 | - # required |
|
301 | - if($field['Null']=="NO") { $required = "*"; } |
|
302 | - else { $required = ""; } |
|
303 | - |
|
304 | - # set default value ! |
|
305 | - if ($_POST['action']=="add") { $user[$field['name']] = $field['Default']; } |
|
306 | - |
|
307 | - print '<tr>'. "\n"; |
|
308 | - print ' <td>'. $field['name'] .' '.$required.'</td>'. "\n"; |
|
309 | - print ' <td>'. "\n"; |
|
310 | - |
|
311 | - //set type |
|
312 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
313 | - //parse values |
|
314 | - $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
315 | - //null |
|
316 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
317 | - |
|
318 | - print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
319 | - foreach($tmp as $v) { |
|
320 | - if($v==$user[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
321 | - else { print "<option value='$v'>$v</option>"; } |
|
322 | - } |
|
323 | - print "</select>"; |
|
324 | - } |
|
325 | - //date and time picker |
|
326 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
327 | - // just for first |
|
328 | - if($timeP==0) { |
|
329 | - print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
330 | - print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
331 | - print '<script type="text/javascript">'; |
|
332 | - print '$(document).ready(function() {'; |
|
333 | - //date only |
|
334 | - print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
335 | - //date + time |
|
336 | - print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
337 | - |
|
338 | - print '})'; |
|
339 | - print '</script>'; |
|
340 | - } |
|
341 | - $timeP++; |
|
342 | - |
|
343 | - //set size |
|
344 | - if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
345 | - else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
346 | - |
|
347 | - //field |
|
348 | - if(!isset($user[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
349 | - else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $user[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
350 | - } |
|
351 | - //boolean |
|
352 | - elseif($field['type'] == "tinyint(1)") { |
|
353 | - print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
354 | - $tmp = array(0=>"No",1=>"Yes"); |
|
355 | - //null |
|
356 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
357 | - |
|
358 | - foreach($tmp as $k=>$v) { |
|
359 | - if(strlen($user[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
360 | - elseif($k==$user[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
361 | - else { print "<option value='$k'>"._($v)."</option>"; } |
|
362 | - } |
|
363 | - print "</select>"; |
|
364 | - } |
|
365 | - //text |
|
366 | - elseif($field['type'] == "text") { |
|
367 | - print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3>'. $user[$field['name']]. '</textarea>'. "\n"; |
|
368 | - } |
|
369 | - //default - input field |
|
370 | - else { |
|
371 | - print ' <input type="text" class="ip_addr form-control input-sm" name="'. @$field['nameNew'] .'" placeholder="'. @$field['name'] .'" value="'. @$user[$field['name']]. '" size="30">'. "\n"; |
|
372 | - } |
|
373 | - |
|
374 | - print " <td class='info2'>".$field['Comment']."</td>"; |
|
375 | - print ' </td>'. "\n"; |
|
376 | - print '</tr>'. "\n"; |
|
377 | - } |
|
378 | - } |
|
379 | - ?> |
|
287 | + if(sizeof($custom) > 0) { |
|
288 | + print '<tr>'; |
|
289 | + print ' <td colspan="3"><hr></td>'; |
|
290 | + print '</tr>'; |
|
291 | + |
|
292 | + # count datepickers |
|
293 | + $timeP = 0; |
|
294 | + |
|
295 | + # all my fields |
|
296 | + foreach($custom as $field) { |
|
297 | + # replace spaces with | |
|
298 | + $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
299 | + |
|
300 | + # required |
|
301 | + if($field['Null']=="NO") { $required = "*"; } |
|
302 | + else { $required = ""; } |
|
303 | + |
|
304 | + # set default value ! |
|
305 | + if ($_POST['action']=="add") { $user[$field['name']] = $field['Default']; } |
|
306 | + |
|
307 | + print '<tr>'. "\n"; |
|
308 | + print ' <td>'. $field['name'] .' '.$required.'</td>'. "\n"; |
|
309 | + print ' <td>'. "\n"; |
|
310 | + |
|
311 | + //set type |
|
312 | + if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
313 | + //parse values |
|
314 | + $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
315 | + //null |
|
316 | + if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
317 | + |
|
318 | + print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
319 | + foreach($tmp as $v) { |
|
320 | + if($v==$user[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
321 | + else { print "<option value='$v'>$v</option>"; } |
|
322 | + } |
|
323 | + print "</select>"; |
|
324 | + } |
|
325 | + //date and time picker |
|
326 | + elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
327 | + // just for first |
|
328 | + if($timeP==0) { |
|
329 | + print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
330 | + print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
331 | + print '<script type="text/javascript">'; |
|
332 | + print '$(document).ready(function() {'; |
|
333 | + //date only |
|
334 | + print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
335 | + //date + time |
|
336 | + print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
337 | + |
|
338 | + print '})'; |
|
339 | + print '</script>'; |
|
340 | + } |
|
341 | + $timeP++; |
|
342 | + |
|
343 | + //set size |
|
344 | + if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
345 | + else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
346 | + |
|
347 | + //field |
|
348 | + if(!isset($user[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
349 | + else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $user[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
350 | + } |
|
351 | + //boolean |
|
352 | + elseif($field['type'] == "tinyint(1)") { |
|
353 | + print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
354 | + $tmp = array(0=>"No",1=>"Yes"); |
|
355 | + //null |
|
356 | + if($field['Null']!="NO") { $tmp[2] = ""; } |
|
357 | + |
|
358 | + foreach($tmp as $k=>$v) { |
|
359 | + if(strlen($user[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
360 | + elseif($k==$user[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
361 | + else { print "<option value='$k'>"._($v)."</option>"; } |
|
362 | + } |
|
363 | + print "</select>"; |
|
364 | + } |
|
365 | + //text |
|
366 | + elseif($field['type'] == "text") { |
|
367 | + print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3>'. $user[$field['name']]. '</textarea>'. "\n"; |
|
368 | + } |
|
369 | + //default - input field |
|
370 | + else { |
|
371 | + print ' <input type="text" class="ip_addr form-control input-sm" name="'. @$field['nameNew'] .'" placeholder="'. @$field['name'] .'" value="'. @$user[$field['name']]. '" size="30">'. "\n"; |
|
372 | + } |
|
373 | + |
|
374 | + print " <td class='info2'>".$field['Comment']."</td>"; |
|
375 | + print ' </td>'. "\n"; |
|
376 | + print '</tr>'. "\n"; |
|
377 | + } |
|
378 | + } |
|
379 | + ?> |
|
380 | 380 | </tbody> |
381 | 381 | |
382 | 382 |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | <th><?php print _('Groups'); ?></th> |
42 | 42 | <th><?php print _('Last login'); ?></th> |
43 | 43 | <?php |
44 | - if(sizeof(@$custom) > 0) { |
|
45 | - foreach($custom as $field) { |
|
46 | - if(!in_array($field['name'], $ffields)) { |
|
47 | - print "<th>$field[name]</th>"; |
|
48 | - } |
|
49 | - } |
|
50 | - } |
|
51 | - ?> |
|
44 | + if(sizeof(@$custom) > 0) { |
|
45 | + foreach($custom as $field) { |
|
46 | + if(!in_array($field['name'], $ffields)) { |
|
47 | + print "<th>$field[name]</th>"; |
|
48 | + } |
|
49 | + } |
|
50 | + } |
|
51 | + ?> |
|
52 | 52 | <th></th> |
53 | 53 | </tr> |
54 | 54 | </thead> |
@@ -57,104 +57,104 @@ discard block |
||
57 | 57 | <?php |
58 | 58 | /* print existing sections */ |
59 | 59 | foreach ($users as $user) { |
60 | - //cast |
|
61 | - $user = (array) $user; |
|
62 | - print '<tr>' . "\n"; |
|
63 | - |
|
64 | - # set icon based on normal user or admin |
|
65 | - if($user['role'] == "Administrator") { print ' <td><img src="css/1.2/images/userVader.png" rel="tooltip" title="'._('Administrator').'"></td>'. "\n"; } |
|
66 | - else { print ' <td><img src="css/1.2/images/userTrooper.png" rel="tooltip" title="'. _($user['role']) .'"></td>'. "\n"; } |
|
67 | - |
|
68 | - print ' <td><a href="'.create_link("administration","users",$user['id']).'">' . $user['real_name'] . '</a></td>'. "\n"; |
|
69 | - print ' <td>' . $user['username'] . '</td>'. "\n"; |
|
70 | - print ' <td>' . $user['email'] . '</td>'. "\n"; |
|
71 | - print ' <td>' . $user['role'] . '</td>'. "\n"; |
|
72 | - |
|
73 | - # language |
|
74 | - if(strlen($user['lang'])>0) { |
|
75 | - # get lang name |
|
76 | - $lname = $Admin->fetch_object("lang", "l_id", $user['lang']); |
|
77 | - print "<td>$lname->l_name</td>"; |
|
78 | - } |
|
79 | - else { |
|
80 | - print "<td>English (default)</td>"; |
|
81 | - } |
|
82 | - |
|
83 | - # check users auth method |
|
84 | - $auth_method = $Admin->fetch_object("usersAuthMethod", "id", $user['authMethod']); |
|
85 | - //false |
|
86 | - print "<td>"; |
|
87 | - if($auth_method===false) { print "<span class='text-muted'>No auth method</span>"; } |
|
88 | - else { print $auth_method->type." <span class='text-muted'>(".$auth_method->description."</a>)"; } |
|
89 | - print "</span></td>"; |
|
90 | - |
|
91 | - # powerDNS |
|
92 | - print "<td>"; |
|
93 | - print $user['pdns']; |
|
94 | - print "</td>"; |
|
95 | - |
|
96 | - # groups |
|
97 | - if($user['role'] == "Administrator") { |
|
98 | - print ' <td>'._('All groups').'</td>'. "\n"; |
|
99 | - } |
|
100 | - else { |
|
101 | - $groups = json_decode($user['groups'], true); |
|
102 | - $gr = $Admin->groups_parse($groups); |
|
103 | - |
|
104 | - print ' <td>'; |
|
105 | - if(sizeof($gr)>0) { |
|
106 | - foreach($gr as $group) { |
|
107 | - print $group['g_name']."<br>"; |
|
108 | - } |
|
109 | - } |
|
110 | - else { |
|
111 | - print "<span class='text-muted'>No groups</span>"; |
|
112 | - } |
|
113 | - print ' </td>'. "\n"; |
|
114 | - } |
|
115 | - |
|
116 | - # last login |
|
117 | - print "<td>"; |
|
118 | - print strlen($user['lastLogin'])>0 ? $user['lastLogin'] : "<span class='text-muted'>"._("Never")."</span>"; |
|
119 | - print "</td>"; |
|
120 | - |
|
121 | - # custom |
|
122 | - if(sizeof($custom) > 0) { |
|
123 | - foreach($custom as $field) { |
|
124 | - if(!in_array($field['name'], $ffields)) { |
|
125 | - print "<td>"; |
|
126 | - //booleans |
|
127 | - if($field['type']=="tinyint(1)") { |
|
128 | - if($user[$field['name']] == "0") { print _("No"); } |
|
129 | - elseif($user[$field['name']] == "1") { print _("Yes"); } |
|
130 | - } |
|
131 | - //text |
|
132 | - elseif($field['type']=="text") { |
|
133 | - if(strlen($user[$field['name']])>0) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $user[$field['name']])."'>"; } |
|
134 | - else { print ""; } |
|
135 | - } |
|
136 | - else { |
|
137 | - print $user[$field['name']]; |
|
138 | - |
|
139 | - } |
|
140 | - print "</td>"; |
|
141 | - } |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - # edit, delete |
|
146 | - print " <td class='actions'>"; |
|
147 | - print " <div class='btn-group'>"; |
|
148 | - print " <a class='btn btn-xs btn-default' href='".create_link("administration","users",$user['id'])."'><i class='fa fa-eye'></i></a></button>"; |
|
149 | - print " <button class='btn btn-xs btn-default editUser' data-userid='$user[id]' data-action='edit' ><i class='fa fa-pencil'></i></button>"; |
|
150 | - print " <a class='btn btn-xs btn-default"; |
|
151 | - if($_SESSION['realipamusername']) { print " disabled";} |
|
152 | - print "' href='".create_link("administration","users","switch","$user[username]")."'><i class='fa fa-exchange'></i></a></button>"; |
|
153 | - print " <button class='btn btn-xs btn-default editUser' data-userid='$user[id]' data-action='delete'><i class='fa fa-times'></i></button>"; |
|
154 | - print " </div>"; |
|
155 | - print " </td>"; |
|
156 | - |
|
157 | - print '</tr>' . "\n"; |
|
60 | + //cast |
|
61 | + $user = (array) $user; |
|
62 | + print '<tr>' . "\n"; |
|
63 | + |
|
64 | + # set icon based on normal user or admin |
|
65 | + if($user['role'] == "Administrator") { print ' <td><img src="css/1.2/images/userVader.png" rel="tooltip" title="'._('Administrator').'"></td>'. "\n"; } |
|
66 | + else { print ' <td><img src="css/1.2/images/userTrooper.png" rel="tooltip" title="'. _($user['role']) .'"></td>'. "\n"; } |
|
67 | + |
|
68 | + print ' <td><a href="'.create_link("administration","users",$user['id']).'">' . $user['real_name'] . '</a></td>'. "\n"; |
|
69 | + print ' <td>' . $user['username'] . '</td>'. "\n"; |
|
70 | + print ' <td>' . $user['email'] . '</td>'. "\n"; |
|
71 | + print ' <td>' . $user['role'] . '</td>'. "\n"; |
|
72 | + |
|
73 | + # language |
|
74 | + if(strlen($user['lang'])>0) { |
|
75 | + # get lang name |
|
76 | + $lname = $Admin->fetch_object("lang", "l_id", $user['lang']); |
|
77 | + print "<td>$lname->l_name</td>"; |
|
78 | + } |
|
79 | + else { |
|
80 | + print "<td>English (default)</td>"; |
|
81 | + } |
|
82 | + |
|
83 | + # check users auth method |
|
84 | + $auth_method = $Admin->fetch_object("usersAuthMethod", "id", $user['authMethod']); |
|
85 | + //false |
|
86 | + print "<td>"; |
|
87 | + if($auth_method===false) { print "<span class='text-muted'>No auth method</span>"; } |
|
88 | + else { print $auth_method->type." <span class='text-muted'>(".$auth_method->description."</a>)"; } |
|
89 | + print "</span></td>"; |
|
90 | + |
|
91 | + # powerDNS |
|
92 | + print "<td>"; |
|
93 | + print $user['pdns']; |
|
94 | + print "</td>"; |
|
95 | + |
|
96 | + # groups |
|
97 | + if($user['role'] == "Administrator") { |
|
98 | + print ' <td>'._('All groups').'</td>'. "\n"; |
|
99 | + } |
|
100 | + else { |
|
101 | + $groups = json_decode($user['groups'], true); |
|
102 | + $gr = $Admin->groups_parse($groups); |
|
103 | + |
|
104 | + print ' <td>'; |
|
105 | + if(sizeof($gr)>0) { |
|
106 | + foreach($gr as $group) { |
|
107 | + print $group['g_name']."<br>"; |
|
108 | + } |
|
109 | + } |
|
110 | + else { |
|
111 | + print "<span class='text-muted'>No groups</span>"; |
|
112 | + } |
|
113 | + print ' </td>'. "\n"; |
|
114 | + } |
|
115 | + |
|
116 | + # last login |
|
117 | + print "<td>"; |
|
118 | + print strlen($user['lastLogin'])>0 ? $user['lastLogin'] : "<span class='text-muted'>"._("Never")."</span>"; |
|
119 | + print "</td>"; |
|
120 | + |
|
121 | + # custom |
|
122 | + if(sizeof($custom) > 0) { |
|
123 | + foreach($custom as $field) { |
|
124 | + if(!in_array($field['name'], $ffields)) { |
|
125 | + print "<td>"; |
|
126 | + //booleans |
|
127 | + if($field['type']=="tinyint(1)") { |
|
128 | + if($user[$field['name']] == "0") { print _("No"); } |
|
129 | + elseif($user[$field['name']] == "1") { print _("Yes"); } |
|
130 | + } |
|
131 | + //text |
|
132 | + elseif($field['type']=="text") { |
|
133 | + if(strlen($user[$field['name']])>0) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $user[$field['name']])."'>"; } |
|
134 | + else { print ""; } |
|
135 | + } |
|
136 | + else { |
|
137 | + print $user[$field['name']]; |
|
138 | + |
|
139 | + } |
|
140 | + print "</td>"; |
|
141 | + } |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + # edit, delete |
|
146 | + print " <td class='actions'>"; |
|
147 | + print " <div class='btn-group'>"; |
|
148 | + print " <a class='btn btn-xs btn-default' href='".create_link("administration","users",$user['id'])."'><i class='fa fa-eye'></i></a></button>"; |
|
149 | + print " <button class='btn btn-xs btn-default editUser' data-userid='$user[id]' data-action='edit' ><i class='fa fa-pencil'></i></button>"; |
|
150 | + print " <a class='btn btn-xs btn-default"; |
|
151 | + if($_SESSION['realipamusername']) { print " disabled";} |
|
152 | + print "' href='".create_link("administration","users","switch","$user[username]")."'><i class='fa fa-exchange'></i></a></button>"; |
|
153 | + print " <button class='btn btn-xs btn-default editUser' data-userid='$user[id]' data-action='delete'><i class='fa fa-times'></i></button>"; |
|
154 | + print " </div>"; |
|
155 | + print " </td>"; |
|
156 | + |
|
157 | + print '</tr>' . "\n"; |
|
158 | 158 | } |
159 | 159 | ?> |
160 | 160 | </tbody> |
@@ -9,19 +9,19 @@ discard block |
||
9 | 9 | |
10 | 10 | # ID must be numeric */ |
11 | 11 | if($_POST['action']!="add") { |
12 | - if(!is_numeric($_POST['id'])) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
12 | + if(!is_numeric($_POST['id'])) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
13 | 13 | |
14 | - # feth method settings |
|
15 | - $method_settings = $Admin->fetch_object ("usersAuthMethod", "id", $_POST['id']); |
|
16 | - $method_settings->params = json_decode($method_settings->params); |
|
14 | + # feth method settings |
|
15 | + $method_settings = $Admin->fetch_object ("usersAuthMethod", "id", $_POST['id']); |
|
16 | + $method_settings->params = json_decode($method_settings->params); |
|
17 | 17 | } |
18 | 18 | else { |
19 | - $method_settings = new StdClass (); |
|
20 | - # set default values |
|
21 | - @$method_settings->params->domain_controllers = "dc1.domain.local;dc2.domain.local"; |
|
22 | - $method_settings->params->base_dn = "CN=Users,CN=Company,DC=domain,DC=local"; |
|
23 | - $method_settings->params->account_suffix = "@domain.local"; |
|
24 | - $method_settings->params->ad_port = 389; |
|
19 | + $method_settings = new StdClass (); |
|
20 | + # set default values |
|
21 | + @$method_settings->params->domain_controllers = "dc1.domain.local;dc2.domain.local"; |
|
22 | + $method_settings->params->base_dn = "CN=Users,CN=Company,DC=domain,DC=local"; |
|
23 | + $method_settings->params->account_suffix = "@domain.local"; |
|
24 | + $method_settings->params->ad_port = 389; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | # set delete flag |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | <div class="pContent"> |
36 | 36 | |
37 | 37 | <?php |
38 | - # make sure LDAP is supported ! |
|
39 | - if (!in_array("ldap", get_loaded_extensions())) { $Result->show("danger", _("ldap extension not enabled in php")."!<hr>", false); } |
|
40 | - ?> |
|
38 | + # make sure LDAP is supported ! |
|
39 | + if (!in_array("ldap", get_loaded_extensions())) { $Result->show("danger", _("ldap extension not enabled in php")."!<hr>", false); } |
|
40 | + ?> |
|
41 | 41 | |
42 | 42 | <form id="editAuthMethod" name="editAuthMethod"> |
43 | 43 | <table class="editAuthMethod table table-noborder table-condensed"> |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | </div> |
164 | 164 | |
165 | 165 | <?php |
166 | - if($_POST['action']=="delete") { |
|
167 | - # check for mathing users |
|
168 | - $users = $Admin->fetch_multiple_objects ("users", "authMethod", @$method_settings->id); |
|
169 | - if($users!==false) { |
|
170 | - $Result->show("warning", sizeof($users)._(" users have this method for logging in. They will be reset to local auth!"), false); |
|
171 | - } |
|
172 | - } |
|
173 | - ?> |
|
166 | + if($_POST['action']=="delete") { |
|
167 | + # check for mathing users |
|
168 | + $users = $Admin->fetch_multiple_objects ("users", "authMethod", @$method_settings->id); |
|
169 | + if($users!==false) { |
|
170 | + $Result->show("warning", sizeof($users)._(" users have this method for logging in. They will be reset to local auth!"), false); |
|
171 | + } |
|
172 | + } |
|
173 | + ?> |
|
174 | 174 | |
175 | 175 | <!-- Result --> |
176 | 176 | <div class="editAuthMethodResult"></div> |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | <div class="btn-group" style="margin-bottom: 20px;"> |
18 | 18 | <?php |
19 | 19 | foreach($all_method_types as $type) { |
20 | - print "<button class='btn btn-sm btn-default editAuthMethod' style='margin-bottom:10px;' data-action='add' data-type='$type'><i class='fa fa-plus'></i> "._("Create new $type authentication")."</button>"; |
|
20 | + print "<button class='btn btn-sm btn-default editAuthMethod' style='margin-bottom:10px;' data-action='add' data-type='$type'><i class='fa fa-plus'></i> "._("Create new $type authentication")."</button>"; |
|
21 | 21 | } |
22 | 22 | ?> |
23 | 23 | </div> |
@@ -39,44 +39,44 @@ discard block |
||
39 | 39 | <?php |
40 | 40 | //loop |
41 | 41 | foreach($all_methods as $method) { |
42 | - //set protected |
|
43 | - $protected_class = $method->protected=="yes" ? "danger" : ""; |
|
42 | + //set protected |
|
43 | + $protected_class = $method->protected=="yes" ? "danger" : ""; |
|
44 | 44 | |
45 | - //number of users |
|
46 | - $user_num = $Database->numObjectsFilter("users", "authMethod", $method->id); |
|
45 | + //number of users |
|
46 | + $user_num = $Database->numObjectsFilter("users", "authMethod", $method->id); |
|
47 | 47 | |
48 | - print "<tr>"; |
|
49 | - print " <td>$method->type</td>"; |
|
50 | - print " <td>$method->description</td>"; |
|
51 | - //parameters |
|
52 | - print " <td>"; |
|
53 | - print " <span class='text-muted'>"; |
|
54 | - if(strlen($method->params)>0) { |
|
55 | - $params = json_decode($method->params); |
|
56 | - foreach($params as $key=>$parameter) { |
|
57 | - // mask user/pass |
|
58 | - if($key=="adminPassword") { $parameter = "********"; } |
|
59 | ||
60 | - print $key." => ".$parameter."<br>"; |
|
61 | - } |
|
62 | - } |
|
63 | - else { |
|
64 | - print "no parameters"; |
|
65 | - } |
|
66 | - print " </span>"; |
|
67 | - print " </td>"; |
|
68 | - print " <td class='$protected_class'>$user_num</td>"; |
|
69 | - print " <td class='$protected_class'>$method->protected</td>"; |
|
70 | - //actions |
|
71 | - $disabled = $method->type=="local" ? "disabled" : ""; |
|
72 | - print " <td class='actions'>"; |
|
73 | - print " <div class='btn-group'>"; |
|
74 | - print " <button class='btn btn-xs btn-default editAuthMethod' data-id='$method->id' data-action='edit' data-type='$method->type' rel='tooltip' title='Edit'><i class='fa fa-pencil'></i></button>"; |
|
75 | - print " <button class='btn btn-xs btn-default editAuthMethod' data-id='$method->id' data-action='delete' data-type='$method->type' rel='tooltip' title='Delete'><i class='fa fa-times'></i></button>"; |
|
76 | - print " <button class='btn btn-xs btn-default checkAuthMethod' data-id='$method->id' data-action='check' data-type='$method->type' rel='tooltip' title='Verify connection' $disabled><i class='fa fa-bolt'></i></button>"; |
|
77 | - print " </div>"; |
|
78 | - print " </td>"; |
|
79 | - print "</tr>"; |
|
48 | + print "<tr>"; |
|
49 | + print " <td>$method->type</td>"; |
|
50 | + print " <td>$method->description</td>"; |
|
51 | + //parameters |
|
52 | + print " <td>"; |
|
53 | + print " <span class='text-muted'>"; |
|
54 | + if(strlen($method->params)>0) { |
|
55 | + $params = json_decode($method->params); |
|
56 | + foreach($params as $key=>$parameter) { |
|
57 | + // mask user/pass |
|
58 | + if($key=="adminPassword") { $parameter = "********"; } |
|
59 | ||
60 | + print $key." => ".$parameter."<br>"; |
|
61 | + } |
|
62 | + } |
|
63 | + else { |
|
64 | + print "no parameters"; |
|
65 | + } |
|
66 | + print " </span>"; |
|
67 | + print " </td>"; |
|
68 | + print " <td class='$protected_class'>$user_num</td>"; |
|
69 | + print " <td class='$protected_class'>$method->protected</td>"; |
|
70 | + //actions |
|
71 | + $disabled = $method->type=="local" ? "disabled" : ""; |
|
72 | + print " <td class='actions'>"; |
|
73 | + print " <div class='btn-group'>"; |
|
74 | + print " <button class='btn btn-xs btn-default editAuthMethod' data-id='$method->id' data-action='edit' data-type='$method->type' rel='tooltip' title='Edit'><i class='fa fa-pencil'></i></button>"; |
|
75 | + print " <button class='btn btn-xs btn-default editAuthMethod' data-id='$method->id' data-action='delete' data-type='$method->type' rel='tooltip' title='Delete'><i class='fa fa-times'></i></button>"; |
|
76 | + print " <button class='btn btn-xs btn-default checkAuthMethod' data-id='$method->id' data-action='check' data-type='$method->type' rel='tooltip' title='Verify connection' $disabled><i class='fa fa-bolt'></i></button>"; |
|
77 | + print " </div>"; |
|
78 | + print " </td>"; |
|
79 | + print "</tr>"; |
|
80 | 80 | } |
81 | 81 | ?> |
82 | 82 | </table> |
@@ -26,31 +26,31 @@ |
||
26 | 26 | |
27 | 27 | # AD? |
28 | 28 | if($auth_settings->type=="AD" || $auth_settings->type=="LDAP" || $auth_settings->type=="NetIQ") { |
29 | - # adLDAP function |
|
30 | - include (dirname(__FILE__) . "/../../../functions/adLDAP/src/adLDAP.php"); |
|
31 | - # set controllers |
|
32 | - $controllers = explode(";", str_replace(" ", "", $parameters->domain_controllers)); |
|
33 | - |
|
34 | - //open connection |
|
35 | - try { |
|
36 | - $adldap = new adLDAP(array( 'base_dn'=>$parameters->base_dn, 'account_suffix'=>@$parameters->account_suffix, |
|
37 | - 'domain_controllers'=>$controllers, 'use_ssl'=>$parameters->use_ssl, |
|
38 | - 'use_tls'=> $parameters->use_tls, 'ad_port'=> $parameters->ad_port |
|
39 | - )); |
|
40 | - //LDAP? |
|
41 | - if($auth_settings->type=="LDAP") $adldap->setUseOpenLDAP(true); |
|
42 | - |
|
43 | - } catch (adLDAPException $e) { |
|
44 | - //catch AD error |
|
45 | - $Result->show("danger", $e, true, true); |
|
46 | - } |
|
47 | - //result |
|
48 | - foreach($controllers as $c) { |
|
49 | - if($fp = @fsockopen($c, $parameters->ad_port, $errno, $errstr, 3)==false) { $Result->show("danger", "$c: $errstr ($errno)", false, true); } |
|
50 | - else { $Result->show("success", "$c: "._('AD network connection ok')."!", false, true); } |
|
51 | - } |
|
29 | + # adLDAP function |
|
30 | + include (dirname(__FILE__) . "/../../../functions/adLDAP/src/adLDAP.php"); |
|
31 | + # set controllers |
|
32 | + $controllers = explode(";", str_replace(" ", "", $parameters->domain_controllers)); |
|
33 | + |
|
34 | + //open connection |
|
35 | + try { |
|
36 | + $adldap = new adLDAP(array( 'base_dn'=>$parameters->base_dn, 'account_suffix'=>@$parameters->account_suffix, |
|
37 | + 'domain_controllers'=>$controllers, 'use_ssl'=>$parameters->use_ssl, |
|
38 | + 'use_tls'=> $parameters->use_tls, 'ad_port'=> $parameters->ad_port |
|
39 | + )); |
|
40 | + //LDAP? |
|
41 | + if($auth_settings->type=="LDAP") $adldap->setUseOpenLDAP(true); |
|
42 | + |
|
43 | + } catch (adLDAPException $e) { |
|
44 | + //catch AD error |
|
45 | + $Result->show("danger", $e, true, true); |
|
46 | + } |
|
47 | + //result |
|
48 | + foreach($controllers as $c) { |
|
49 | + if($fp = @fsockopen($c, $parameters->ad_port, $errno, $errstr, 3)==false) { $Result->show("danger", "$c: $errstr ($errno)", false, true); } |
|
50 | + else { $Result->show("success", "$c: "._('AD network connection ok')."!", false, true); } |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | else { |
54 | - $Result->show("danger", _("Check for not implemented"), true, true); |
|
54 | + $Result->show("danger", _("Check for not implemented"), true, true); |
|
55 | 55 | } |
56 | 56 | ?> |
57 | 57 | \ No newline at end of file |
@@ -28,25 +28,25 @@ discard block |
||
28 | 28 | |
29 | 29 | //for adding remove id |
30 | 30 | if($action=="add") { |
31 | - unset($_POST['id']); |
|
31 | + unset($_POST['id']); |
|
32 | 32 | } |
33 | 33 | else { |
34 | - //check id |
|
35 | - if(!is_numeric($_POST['id'])) { $Result->show("danger", _("Invalid ID"), true); } |
|
34 | + //check id |
|
35 | + if(!is_numeric($_POST['id'])) { $Result->show("danger", _("Invalid ID"), true); } |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | # set update query |
39 | 39 | $values = array("id"=>@$_POST['id'], |
40 | - "type"=>$_POST['type'], |
|
41 | - "description"=>@$_POST['description'], |
|
42 | - ); |
|
40 | + "type"=>$_POST['type'], |
|
41 | + "description"=>@$_POST['description'], |
|
42 | + ); |
|
43 | 43 | # add params |
44 | 44 | unset($_POST['id'], $_POST['type'], $_POST['description'], $_POST['action']); |
45 | 45 | $values["params"]=json_encode($_POST); |
46 | 46 | |
47 | 47 | # add - set protected |
48 | 48 | if($action=="add") { |
49 | - $values['protected'] = "No"; |
|
49 | + $values['protected'] = "No"; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | # update |
@@ -55,6 +55,6 @@ discard block |
||
55 | 55 | |
56 | 56 | # if delete also reset all users that have thos auth method |
57 | 57 | if($action=="delete") { |
58 | - $Database->runQuery("update `users` set `authMethod`=1 where `authMethod`= ?;", array($values['id'])); |
|
58 | + $Database->runQuery("update `users` set `authMethod`=1 where `authMethod`= ?;", array($values['id'])); |
|
59 | 59 | } |
60 | 60 | ?> |
61 | 61 | \ No newline at end of file |