@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | //strip AS if provided, to get just the number |
22 | 22 | if(substr($_POST['as'], 0,2)=="AS" || substr($_POST['as'], 0,2)=="as") { |
23 | - $_POST['as'] = substr($_POST['as'], 2); |
|
23 | + $_POST['as'] = substr($_POST['as'], 2); |
|
24 | 24 | }; |
25 | 25 | |
26 | 26 | |
@@ -34,100 +34,100 @@ discard block |
||
34 | 34 | |
35 | 35 | //none found |
36 | 36 | if(sizeof(@$subnet) == 0) { |
37 | - print "<hr>"; |
|
38 | - $Result->show("danger alert-absolute", _('No subnets found').'!', true); |
|
37 | + print "<hr>"; |
|
38 | + $Result->show("danger alert-absolute", _('No subnets found').'!', true); |
|
39 | 39 | } |
40 | 40 | else { |
41 | - //form |
|
42 | - print '<form name="asImport" id="asImport">'; |
|
43 | - //table |
|
44 | - print '<table class="asImport table table-striped table-condensed table-top table-auto">'; |
|
45 | - //headers |
|
46 | - print '<tr>'; |
|
47 | - print ' <th colspan="5">'._('I found the following routes belonging to AS').' '.$_POST['as'].':</th>'; |
|
48 | - print '</tr> '; |
|
49 | - |
|
50 | - print "<tr>"; |
|
51 | - print " <th></th>"; |
|
52 | - print " <th>"._('Subnet')."</th>"; |
|
53 | - print " <th>"._('select section')."</th>"; |
|
54 | - print " <th>"._('Description')."</th>"; |
|
55 | - print " <th>"._('VLAN')."</th>"; |
|
56 | - print " <th>"._('VRF')."</th>"; |
|
57 | - print " <th>"._('Show name')."</th>"; |
|
58 | - |
|
59 | - print "</tr>"; |
|
60 | - |
|
61 | - //print found subnets |
|
62 | - $m = 0; |
|
63 | - foreach ($subnet as $route) { |
|
64 | - # only not empty |
|
65 | - if(strlen($route)>2) { |
|
66 | - print '<tr>'. "\n"; |
|
67 | - |
|
68 | - //delete |
|
69 | - print '<td class="removeSubnet">'. "\n"; |
|
70 | - print ' <button class="btn btn-xs btn-default btn-danger" rel="tooltip" title="'._('Remove this subnet').'"><i class="fa fa-times"></i></button>'. "\n"; |
|
71 | - print '</td>'. "\n"; |
|
72 | - //subnet |
|
73 | - print '<td>'. "\n"; |
|
74 | - print '<input type="text" class="form-control input-sm" name="subnet-'. $m .'" value="'. $route .'">'. "\n"; |
|
75 | - print '</td>'. "\n"; |
|
76 | - //section |
|
77 | - print '<td>'. "\n"; |
|
78 | - print '<select name="section-'. $m .'" class="form-control input-sm input-w-auto">'. "\n"; |
|
79 | - foreach($sections as $section) { |
|
80 | - print '<option value="'. $section->id .'">'. $section->name .'</option>'; |
|
81 | - } |
|
82 | - print '</select>'. "\n"; |
|
83 | - print '</td>'. "\n"; |
|
84 | - //description |
|
85 | - print '<td>'. "\n"; |
|
86 | - print '<input type="text" class="form-control input-sm input-w-250" name="description-'. $m .'">'. "\n"; |
|
87 | - print '</td>'. "\n"; |
|
88 | - //VLAN |
|
89 | - print '<td>'. "\n"; |
|
90 | - print '<select name="vlan-'. $m .'" class="form-control input-sm input-w-auto">'. "\n"; |
|
91 | - print '<option value="0">No VLAN</option>'; |
|
92 | - if(sizeof(@$vlans)>0) { |
|
93 | - foreach($vlans as $vlan) { |
|
94 | - # set description |
|
95 | - $vlan_description = strlen($vlan->description)>0 ? " (".$vlan->description.")" : ""; |
|
96 | - print '<option value="'.$vlan->vlanId.'">'.$vlan->number.$vlan_description.'</option>'; |
|
97 | - } |
|
98 | - } |
|
99 | - //VRF |
|
100 | - print '<td>'. "\n"; |
|
101 | - print '<select name="vrf-'. $m .'" class="form-control input-sm input-w-auto">'. "\n"; |
|
102 | - print '<option value="0">No VRF</option>'; |
|
103 | - if(sizeof(@$vrfs)>0) { |
|
104 | - foreach($vrfs as $vrf) { |
|
105 | - # set description |
|
106 | - $vrf_description = strlen($vrf->description)>0 ? " (".$vrf->description.")" : ""; |
|
107 | - print '<option value="'.$vrf->vrfId.'">'.$vrf->name.$vrf_description.'</option>'; |
|
108 | - } |
|
109 | - } |
|
110 | - //show name |
|
111 | - print '<td>'. "\n"; |
|
112 | - print '<select name="showName-'. $m .'" class="form-control input-sm input-w-auto">'. "\n"; |
|
113 | - print '<option value="0">'._('No') .'</option>'; |
|
114 | - print '<option value="1">'._('Yes').'</option>'; |
|
115 | - print '</td>'. "\n"; |
|
116 | - |
|
117 | - print '</tr>'. "\n"; |
|
118 | - } |
|
119 | - $m++; |
|
120 | - } |
|
121 | - |
|
122 | - //submit |
|
123 | - print '<tr style="border-top:1px solid white" class="th">'. "\n"; |
|
124 | - print '<td colspan="7" style="text-align:right">'. "\n"; |
|
125 | - print ' <input type="submit" class="btn btn-sm btn-default" value="'._('Import to database').'">'. "\n"; |
|
126 | - print '</td>'. "\n"; |
|
127 | - print '</tr>'. "\n"; |
|
128 | - |
|
129 | - print '</table>'. "\n"; |
|
130 | - print '</form>'. "\n"; |
|
41 | + //form |
|
42 | + print '<form name="asImport" id="asImport">'; |
|
43 | + //table |
|
44 | + print '<table class="asImport table table-striped table-condensed table-top table-auto">'; |
|
45 | + //headers |
|
46 | + print '<tr>'; |
|
47 | + print ' <th colspan="5">'._('I found the following routes belonging to AS').' '.$_POST['as'].':</th>'; |
|
48 | + print '</tr> '; |
|
49 | + |
|
50 | + print "<tr>"; |
|
51 | + print " <th></th>"; |
|
52 | + print " <th>"._('Subnet')."</th>"; |
|
53 | + print " <th>"._('select section')."</th>"; |
|
54 | + print " <th>"._('Description')."</th>"; |
|
55 | + print " <th>"._('VLAN')."</th>"; |
|
56 | + print " <th>"._('VRF')."</th>"; |
|
57 | + print " <th>"._('Show name')."</th>"; |
|
58 | + |
|
59 | + print "</tr>"; |
|
60 | + |
|
61 | + //print found subnets |
|
62 | + $m = 0; |
|
63 | + foreach ($subnet as $route) { |
|
64 | + # only not empty |
|
65 | + if(strlen($route)>2) { |
|
66 | + print '<tr>'. "\n"; |
|
67 | + |
|
68 | + //delete |
|
69 | + print '<td class="removeSubnet">'. "\n"; |
|
70 | + print ' <button class="btn btn-xs btn-default btn-danger" rel="tooltip" title="'._('Remove this subnet').'"><i class="fa fa-times"></i></button>'. "\n"; |
|
71 | + print '</td>'. "\n"; |
|
72 | + //subnet |
|
73 | + print '<td>'. "\n"; |
|
74 | + print '<input type="text" class="form-control input-sm" name="subnet-'. $m .'" value="'. $route .'">'. "\n"; |
|
75 | + print '</td>'. "\n"; |
|
76 | + //section |
|
77 | + print '<td>'. "\n"; |
|
78 | + print '<select name="section-'. $m .'" class="form-control input-sm input-w-auto">'. "\n"; |
|
79 | + foreach($sections as $section) { |
|
80 | + print '<option value="'. $section->id .'">'. $section->name .'</option>'; |
|
81 | + } |
|
82 | + print '</select>'. "\n"; |
|
83 | + print '</td>'. "\n"; |
|
84 | + //description |
|
85 | + print '<td>'. "\n"; |
|
86 | + print '<input type="text" class="form-control input-sm input-w-250" name="description-'. $m .'">'. "\n"; |
|
87 | + print '</td>'. "\n"; |
|
88 | + //VLAN |
|
89 | + print '<td>'. "\n"; |
|
90 | + print '<select name="vlan-'. $m .'" class="form-control input-sm input-w-auto">'. "\n"; |
|
91 | + print '<option value="0">No VLAN</option>'; |
|
92 | + if(sizeof(@$vlans)>0) { |
|
93 | + foreach($vlans as $vlan) { |
|
94 | + # set description |
|
95 | + $vlan_description = strlen($vlan->description)>0 ? " (".$vlan->description.")" : ""; |
|
96 | + print '<option value="'.$vlan->vlanId.'">'.$vlan->number.$vlan_description.'</option>'; |
|
97 | + } |
|
98 | + } |
|
99 | + //VRF |
|
100 | + print '<td>'. "\n"; |
|
101 | + print '<select name="vrf-'. $m .'" class="form-control input-sm input-w-auto">'. "\n"; |
|
102 | + print '<option value="0">No VRF</option>'; |
|
103 | + if(sizeof(@$vrfs)>0) { |
|
104 | + foreach($vrfs as $vrf) { |
|
105 | + # set description |
|
106 | + $vrf_description = strlen($vrf->description)>0 ? " (".$vrf->description.")" : ""; |
|
107 | + print '<option value="'.$vrf->vrfId.'">'.$vrf->name.$vrf_description.'</option>'; |
|
108 | + } |
|
109 | + } |
|
110 | + //show name |
|
111 | + print '<td>'. "\n"; |
|
112 | + print '<select name="showName-'. $m .'" class="form-control input-sm input-w-auto">'. "\n"; |
|
113 | + print '<option value="0">'._('No') .'</option>'; |
|
114 | + print '<option value="1">'._('Yes').'</option>'; |
|
115 | + print '</td>'. "\n"; |
|
116 | + |
|
117 | + print '</tr>'. "\n"; |
|
118 | + } |
|
119 | + $m++; |
|
120 | + } |
|
121 | + |
|
122 | + //submit |
|
123 | + print '<tr style="border-top:1px solid white" class="th">'. "\n"; |
|
124 | + print '<td colspan="7" style="text-align:right">'. "\n"; |
|
125 | + print ' <input type="submit" class="btn btn-sm btn-default" value="'._('Import to database').'">'. "\n"; |
|
126 | + print '</td>'. "\n"; |
|
127 | + print '</tr>'. "\n"; |
|
128 | + |
|
129 | + print '</table>'. "\n"; |
|
130 | + print '</form>'. "\n"; |
|
131 | 131 | } |
132 | 132 | ?> |
133 | 133 | <div class="ripeImportResult"></div> |
134 | 134 | \ No newline at end of file |
@@ -5,22 +5,22 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Subnets = new Subnets ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | |
21 | 21 | //strip AS if provided, to get just the number |
22 | -if(substr($_POST['as'], 0,2)=="AS" || substr($_POST['as'], 0,2)=="as") { |
|
23 | - $_POST['as'] = substr($_POST['as'], 2); |
|
22 | +if (substr ($_POST['as'], 0, 2) == "AS" || substr ($_POST['as'], 0, 2) == "as") { |
|
23 | + $_POST['as'] = substr ($_POST['as'], 2); |
|
24 | 24 | }; |
25 | 25 | |
26 | 26 | |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | |
30 | 30 | # fetch all sections |
31 | 31 | $sections = $Admin->fetch_all_objects ("sections", "id"); |
32 | -$vlans = $Admin->fetch_all_objects ("vlans", "vlanId"); |
|
33 | -$vrfs = $Admin->fetch_all_objects ("vrf", "vrfId"); |
|
32 | +$vlans = $Admin->fetch_all_objects ("vlans", "vlanId"); |
|
33 | +$vrfs = $Admin->fetch_all_objects ("vrf", "vrfId"); |
|
34 | 34 | |
35 | 35 | //none found |
36 | -if(sizeof(@$subnet) == 0) { |
|
36 | +if (sizeof (@$subnet) == 0) { |
|
37 | 37 | print "<hr>"; |
38 | - $Result->show("danger alert-absolute", _('No subnets found').'!', true); |
|
38 | + $Result->show ("danger alert-absolute", _ ('No subnets found').'!', true); |
|
39 | 39 | } |
40 | 40 | else { |
41 | 41 | //form |
@@ -44,17 +44,17 @@ discard block |
||
44 | 44 | print '<table class="asImport table table-striped table-condensed table-top table-auto">'; |
45 | 45 | //headers |
46 | 46 | print '<tr>'; |
47 | - print ' <th colspan="5">'._('I found the following routes belonging to AS').' '.$_POST['as'].':</th>'; |
|
47 | + print ' <th colspan="5">'._ ('I found the following routes belonging to AS').' '.$_POST['as'].':</th>'; |
|
48 | 48 | print '</tr> '; |
49 | 49 | |
50 | 50 | print "<tr>"; |
51 | 51 | print " <th></th>"; |
52 | - print " <th>"._('Subnet')."</th>"; |
|
53 | - print " <th>"._('select section')."</th>"; |
|
54 | - print " <th>"._('Description')."</th>"; |
|
55 | - print " <th>"._('VLAN')."</th>"; |
|
56 | - print " <th>"._('VRF')."</th>"; |
|
57 | - print " <th>"._('Show name')."</th>"; |
|
52 | + print " <th>"._ ('Subnet')."</th>"; |
|
53 | + print " <th>"._ ('select section')."</th>"; |
|
54 | + print " <th>"._ ('Description')."</th>"; |
|
55 | + print " <th>"._ ('VLAN')."</th>"; |
|
56 | + print " <th>"._ ('VRF')."</th>"; |
|
57 | + print " <th>"._ ('Show name')."</th>"; |
|
58 | 58 | |
59 | 59 | print "</tr>"; |
60 | 60 | |
@@ -62,72 +62,72 @@ discard block |
||
62 | 62 | $m = 0; |
63 | 63 | foreach ($subnet as $route) { |
64 | 64 | # only not empty |
65 | - if(strlen($route)>2) { |
|
66 | - print '<tr>'. "\n"; |
|
65 | + if (strlen ($route) > 2) { |
|
66 | + print '<tr>'."\n"; |
|
67 | 67 | |
68 | 68 | //delete |
69 | - print '<td class="removeSubnet">'. "\n"; |
|
70 | - print ' <button class="btn btn-xs btn-default btn-danger" rel="tooltip" title="'._('Remove this subnet').'"><i class="fa fa-times"></i></button>'. "\n"; |
|
71 | - print '</td>'. "\n"; |
|
69 | + print '<td class="removeSubnet">'."\n"; |
|
70 | + print ' <button class="btn btn-xs btn-default btn-danger" rel="tooltip" title="'._ ('Remove this subnet').'"><i class="fa fa-times"></i></button>'."\n"; |
|
71 | + print '</td>'."\n"; |
|
72 | 72 | //subnet |
73 | - print '<td>'. "\n"; |
|
74 | - print '<input type="text" class="form-control input-sm" name="subnet-'. $m .'" value="'. $route .'">'. "\n"; |
|
75 | - print '</td>'. "\n"; |
|
73 | + print '<td>'."\n"; |
|
74 | + print '<input type="text" class="form-control input-sm" name="subnet-'.$m.'" value="'.$route.'">'."\n"; |
|
75 | + print '</td>'."\n"; |
|
76 | 76 | //section |
77 | - print '<td>'. "\n"; |
|
78 | - print '<select name="section-'. $m .'" class="form-control input-sm input-w-auto">'. "\n"; |
|
79 | - foreach($sections as $section) { |
|
80 | - print '<option value="'. $section->id .'">'. $section->name .'</option>'; |
|
77 | + print '<td>'."\n"; |
|
78 | + print '<select name="section-'.$m.'" class="form-control input-sm input-w-auto">'."\n"; |
|
79 | + foreach ($sections as $section) { |
|
80 | + print '<option value="'.$section->id.'">'.$section->name.'</option>'; |
|
81 | 81 | } |
82 | - print '</select>'. "\n"; |
|
83 | - print '</td>'. "\n"; |
|
82 | + print '</select>'."\n"; |
|
83 | + print '</td>'."\n"; |
|
84 | 84 | //description |
85 | - print '<td>'. "\n"; |
|
86 | - print '<input type="text" class="form-control input-sm input-w-250" name="description-'. $m .'">'. "\n"; |
|
87 | - print '</td>'. "\n"; |
|
85 | + print '<td>'."\n"; |
|
86 | + print '<input type="text" class="form-control input-sm input-w-250" name="description-'.$m.'">'."\n"; |
|
87 | + print '</td>'."\n"; |
|
88 | 88 | //VLAN |
89 | - print '<td>'. "\n"; |
|
90 | - print '<select name="vlan-'. $m .'" class="form-control input-sm input-w-auto">'. "\n"; |
|
89 | + print '<td>'."\n"; |
|
90 | + print '<select name="vlan-'.$m.'" class="form-control input-sm input-w-auto">'."\n"; |
|
91 | 91 | print '<option value="0">No VLAN</option>'; |
92 | - if(sizeof(@$vlans)>0) { |
|
93 | - foreach($vlans as $vlan) { |
|
92 | + if (sizeof (@$vlans) > 0) { |
|
93 | + foreach ($vlans as $vlan) { |
|
94 | 94 | # set description |
95 | - $vlan_description = strlen($vlan->description)>0 ? " (".$vlan->description.")" : ""; |
|
95 | + $vlan_description = strlen ($vlan->description) > 0 ? " (".$vlan->description.")" : ""; |
|
96 | 96 | print '<option value="'.$vlan->vlanId.'">'.$vlan->number.$vlan_description.'</option>'; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | //VRF |
100 | - print '<td>'. "\n"; |
|
101 | - print '<select name="vrf-'. $m .'" class="form-control input-sm input-w-auto">'. "\n"; |
|
100 | + print '<td>'."\n"; |
|
101 | + print '<select name="vrf-'.$m.'" class="form-control input-sm input-w-auto">'."\n"; |
|
102 | 102 | print '<option value="0">No VRF</option>'; |
103 | - if(sizeof(@$vrfs)>0) { |
|
104 | - foreach($vrfs as $vrf) { |
|
103 | + if (sizeof (@$vrfs) > 0) { |
|
104 | + foreach ($vrfs as $vrf) { |
|
105 | 105 | # set description |
106 | - $vrf_description = strlen($vrf->description)>0 ? " (".$vrf->description.")" : ""; |
|
106 | + $vrf_description = strlen ($vrf->description) > 0 ? " (".$vrf->description.")" : ""; |
|
107 | 107 | print '<option value="'.$vrf->vrfId.'">'.$vrf->name.$vrf_description.'</option>'; |
108 | 108 | } |
109 | 109 | } |
110 | 110 | //show name |
111 | - print '<td>'. "\n"; |
|
112 | - print '<select name="showName-'. $m .'" class="form-control input-sm input-w-auto">'. "\n"; |
|
113 | - print '<option value="0">'._('No') .'</option>'; |
|
114 | - print '<option value="1">'._('Yes').'</option>'; |
|
115 | - print '</td>'. "\n"; |
|
111 | + print '<td>'."\n"; |
|
112 | + print '<select name="showName-'.$m.'" class="form-control input-sm input-w-auto">'."\n"; |
|
113 | + print '<option value="0">'._ ('No').'</option>'; |
|
114 | + print '<option value="1">'._ ('Yes').'</option>'; |
|
115 | + print '</td>'."\n"; |
|
116 | 116 | |
117 | - print '</tr>'. "\n"; |
|
117 | + print '</tr>'."\n"; |
|
118 | 118 | } |
119 | 119 | $m++; |
120 | 120 | } |
121 | 121 | |
122 | 122 | //submit |
123 | - print '<tr style="border-top:1px solid white" class="th">'. "\n"; |
|
124 | - print '<td colspan="7" style="text-align:right">'. "\n"; |
|
125 | - print ' <input type="submit" class="btn btn-sm btn-default" value="'._('Import to database').'">'. "\n"; |
|
126 | - print '</td>'. "\n"; |
|
127 | - print '</tr>'. "\n"; |
|
128 | - |
|
129 | - print '</table>'. "\n"; |
|
130 | - print '</form>'. "\n"; |
|
123 | + print '<tr style="border-top:1px solid white" class="th">'."\n"; |
|
124 | + print '<td colspan="7" style="text-align:right">'."\n"; |
|
125 | + print ' <input type="submit" class="btn btn-sm btn-default" value="'._ ('Import to database').'">'."\n"; |
|
126 | + print '</td>'."\n"; |
|
127 | + print '</tr>'."\n"; |
|
128 | + |
|
129 | + print '</table>'."\n"; |
|
130 | + print '</form>'."\n"; |
|
131 | 131 | } |
132 | 132 | ?> |
133 | 133 | <div class="ripeImportResult"></div> |
134 | 134 | \ No newline at end of file |
@@ -29,52 +29,52 @@ |
||
29 | 29 | |
30 | 30 | //open connection |
31 | 31 | try { |
32 | - if($server->type == "NetIQ") { $params->account_suffix = ""; } |
|
33 | - //set options |
|
34 | - $options = array( |
|
35 | - 'base_dn'=>$params->base_dn, |
|
36 | - 'account_suffix'=>$params->account_suffix, |
|
37 | - 'domain_controllers'=>explode(";",$params->domain_controllers), |
|
38 | - 'use_ssl'=>$params->use_ssl, |
|
39 | - 'use_tls'=>$params->use_tls, |
|
40 | - 'ad_port'=>$params->ad_port |
|
41 | - ); |
|
42 | - //AD |
|
43 | - $adldap = new adLDAP($options); |
|
32 | + if($server->type == "NetIQ") { $params->account_suffix = ""; } |
|
33 | + //set options |
|
34 | + $options = array( |
|
35 | + 'base_dn'=>$params->base_dn, |
|
36 | + 'account_suffix'=>$params->account_suffix, |
|
37 | + 'domain_controllers'=>explode(";",$params->domain_controllers), |
|
38 | + 'use_ssl'=>$params->use_ssl, |
|
39 | + 'use_tls'=>$params->use_tls, |
|
40 | + 'ad_port'=>$params->ad_port |
|
41 | + ); |
|
42 | + //AD |
|
43 | + $adldap = new adLDAP($options); |
|
44 | 44 | |
45 | - //try to login with higher credentials for search |
|
46 | - $authUser = $adldap->authenticate($params->adminUsername, $params->adminPassword); |
|
47 | - if ($authUser == false) { |
|
48 | - $Result->show("danger", _("Invalid credentials"), true); |
|
49 | - } |
|
45 | + //try to login with higher credentials for search |
|
46 | + $authUser = $adldap->authenticate($params->adminUsername, $params->adminPassword); |
|
47 | + if ($authUser == false) { |
|
48 | + $Result->show("danger", _("Invalid credentials"), true); |
|
49 | + } |
|
50 | 50 | |
51 | - // set OpenLDAP flag |
|
52 | - if($server->type == "LDAP") { $adldap->setUseOpenLDAP(true); } |
|
51 | + // set OpenLDAP flag |
|
52 | + if($server->type == "LDAP") { $adldap->setUseOpenLDAP(true); } |
|
53 | 53 | |
54 | - //fetch all groups |
|
55 | - $all_groups = $Admin->fetch_all_objects ("userGroups", "g_id"); |
|
56 | - if($all_groups !== false) { |
|
57 | - foreach($all_groups as $k=>$g) { |
|
58 | - //members |
|
59 | - $domain_group_members = $adldap->group()->members($g->g_name); |
|
60 | - //false |
|
61 | - if($domain_group_members!==false) { |
|
62 | - foreach($domain_group_members as $m) { |
|
63 | - if($m==$_POST['username']) { |
|
64 | - $membership[] = $g->g_id; |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
68 | - } |
|
69 | - } |
|
54 | + //fetch all groups |
|
55 | + $all_groups = $Admin->fetch_all_objects ("userGroups", "g_id"); |
|
56 | + if($all_groups !== false) { |
|
57 | + foreach($all_groups as $k=>$g) { |
|
58 | + //members |
|
59 | + $domain_group_members = $adldap->group()->members($g->g_name); |
|
60 | + //false |
|
61 | + if($domain_group_members!==false) { |
|
62 | + foreach($domain_group_members as $m) { |
|
63 | + if($m==$_POST['username']) { |
|
64 | + $membership[] = $g->g_id; |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | - # if something set print it |
|
72 | - if (isset($membership)) { |
|
73 | - print trim(implode(";", array_filter($membership))); |
|
74 | - } |
|
71 | + # if something set print it |
|
72 | + if (isset($membership)) { |
|
73 | + print trim(implode(";", array_filter($membership))); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | } |
77 | 77 | catch (adLDAPException $e) { |
78 | - $Result->show("danger", $e->getMessage(), true); |
|
78 | + $Result->show("danger", $e->getMessage(), true); |
|
79 | 79 | } |
80 | 80 | ?> |
81 | 81 | \ No newline at end of file |
@@ -73,8 +73,7 @@ |
||
73 | 73 | print trim(implode(";", array_filter($membership))); |
74 | 74 | } |
75 | 75 | |
76 | -} |
|
77 | -catch (adLDAPException $e) { |
|
76 | +} catch (adLDAPException $e) { |
|
78 | 77 | $Result->show("danger", $e->getMessage(), true); |
79 | 78 | } |
80 | 79 | ?> |
81 | 80 | \ No newline at end of file |
@@ -5,62 +5,62 @@ discard block |
||
5 | 5 | *************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
9 | -require( dirname(__FILE__) . "/../../../functions/adLDAP/src/adLDAP.php"); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | +require(dirname (__FILE__)."/../../../functions/adLDAP/src/adLDAP.php"); |
|
10 | 10 | |
11 | 11 | # initialize user object |
12 | -$Database = new Database_PDO; |
|
13 | -$User = new User ($Database); |
|
12 | +$Database = new Database_PDO; |
|
13 | +$User = new User ($Database); |
|
14 | 14 | $Admin = new Admin ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # fetch server |
21 | -$server = $Admin->fetch_object("usersAuthMethod", "id", $_POST['server']); |
|
22 | -$server!==false ? : $Result->show("danger", _("Invalid server ID"), true); |
|
21 | +$server = $Admin->fetch_object ("usersAuthMethod", "id", $_POST['server']); |
|
22 | +$server !== false ? : $Result->show ("danger", _ ("Invalid server ID"), true); |
|
23 | 23 | |
24 | 24 | //parse parameters |
25 | -$params = json_decode($server->params); |
|
25 | +$params = json_decode ($server->params); |
|
26 | 26 | |
27 | 27 | //no login parameters |
28 | -if(strlen(@$params->adminUsername)==0 || strlen(@$params->adminPassword)==0) { $Result->show("danger", _("Missing credentials"), true); } |
|
28 | +if (strlen (@$params->adminUsername) == 0 || strlen (@$params->adminPassword) == 0) { $Result->show ("danger", _ ("Missing credentials"), true); } |
|
29 | 29 | |
30 | 30 | //open connection |
31 | 31 | try { |
32 | - if($server->type == "NetIQ") { $params->account_suffix = ""; } |
|
32 | + if ($server->type == "NetIQ") { $params->account_suffix = ""; } |
|
33 | 33 | //set options |
34 | - $options = array( |
|
34 | + $options = array ( |
|
35 | 35 | 'base_dn'=>$params->base_dn, |
36 | 36 | 'account_suffix'=>$params->account_suffix, |
37 | - 'domain_controllers'=>explode(";",$params->domain_controllers), |
|
37 | + 'domain_controllers'=>explode (";", $params->domain_controllers), |
|
38 | 38 | 'use_ssl'=>$params->use_ssl, |
39 | 39 | 'use_tls'=>$params->use_tls, |
40 | 40 | 'ad_port'=>$params->ad_port |
41 | 41 | ); |
42 | 42 | //AD |
43 | - $adldap = new adLDAP($options); |
|
43 | + $adldap = new adLDAP ($options); |
|
44 | 44 | |
45 | 45 | //try to login with higher credentials for search |
46 | - $authUser = $adldap->authenticate($params->adminUsername, $params->adminPassword); |
|
46 | + $authUser = $adldap->authenticate ($params->adminUsername, $params->adminPassword); |
|
47 | 47 | if ($authUser == false) { |
48 | - $Result->show("danger", _("Invalid credentials"), true); |
|
48 | + $Result->show ("danger", _ ("Invalid credentials"), true); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // set OpenLDAP flag |
52 | - if($server->type == "LDAP") { $adldap->setUseOpenLDAP(true); } |
|
52 | + if ($server->type == "LDAP") { $adldap->setUseOpenLDAP (true); } |
|
53 | 53 | |
54 | 54 | //fetch all groups |
55 | 55 | $all_groups = $Admin->fetch_all_objects ("userGroups", "g_id"); |
56 | - if($all_groups !== false) { |
|
57 | - foreach($all_groups as $k=>$g) { |
|
56 | + if ($all_groups !== false) { |
|
57 | + foreach ($all_groups as $k=>$g) { |
|
58 | 58 | //members |
59 | - $domain_group_members = $adldap->group()->members($g->g_name); |
|
59 | + $domain_group_members = $adldap->group ()->members ($g->g_name); |
|
60 | 60 | //false |
61 | - if($domain_group_members!==false) { |
|
62 | - foreach($domain_group_members as $m) { |
|
63 | - if($m==$_POST['username']) { |
|
61 | + if ($domain_group_members !== false) { |
|
62 | + foreach ($domain_group_members as $m) { |
|
63 | + if ($m == $_POST['username']) { |
|
64 | 64 | $membership[] = $g->g_id; |
65 | 65 | } |
66 | 66 | } |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | |
71 | 71 | # if something set print it |
72 | 72 | if (isset($membership)) { |
73 | - print trim(implode(";", array_filter($membership))); |
|
73 | + print trim (implode (";", array_filter ($membership))); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | } |
77 | 77 | catch (adLDAPException $e) { |
78 | - $Result->show("danger", $e->getMessage(), true); |
|
78 | + $Result->show ("danger", $e->getMessage (), true); |
|
79 | 79 | } |
80 | 80 | ?> |
81 | 81 | \ No newline at end of file |
@@ -32,70 +32,70 @@ |
||
32 | 32 | |
33 | 33 | //open connection |
34 | 34 | try { |
35 | - if($server->type == "NetIQ") { $params->account_suffix = ""; } |
|
36 | - //set options |
|
37 | - $options = array( |
|
38 | - 'base_dn'=>$params->base_dn, |
|
39 | - 'account_suffix'=>$params->account_suffix, |
|
40 | - 'domain_controllers'=>explode(";",$params->domain_controllers), |
|
41 | - 'use_ssl'=>$params->use_ssl, |
|
42 | - 'use_tls'=>$params->use_tls, |
|
43 | - 'ad_port'=>$params->ad_port |
|
44 | - ); |
|
45 | - //AD |
|
46 | - $adldap = new adLDAP($options); |
|
47 | - |
|
48 | - //try to login with higher credentials for search |
|
49 | - $authUser = $adldap->authenticate($params->adminUsername, $params->adminPassword); |
|
50 | - if ($authUser == false) { |
|
51 | - $Result->show("danger", _("Invalid credentials"), true); |
|
52 | - } |
|
53 | - |
|
54 | - // set OpenLDAP flag |
|
55 | - if($server->type == "LDAP") { $adldap->setUseOpenLDAP(true); } |
|
56 | - |
|
57 | - //search for domain user! |
|
58 | - $userinfo = $adldap->user()->info("$_POST[dname]*", array("*"),false,$server->type); |
|
59 | - |
|
60 | - //echo $adldap->getLastError(); |
|
35 | + if($server->type == "NetIQ") { $params->account_suffix = ""; } |
|
36 | + //set options |
|
37 | + $options = array( |
|
38 | + 'base_dn'=>$params->base_dn, |
|
39 | + 'account_suffix'=>$params->account_suffix, |
|
40 | + 'domain_controllers'=>explode(";",$params->domain_controllers), |
|
41 | + 'use_ssl'=>$params->use_ssl, |
|
42 | + 'use_tls'=>$params->use_tls, |
|
43 | + 'ad_port'=>$params->ad_port |
|
44 | + ); |
|
45 | + //AD |
|
46 | + $adldap = new adLDAP($options); |
|
47 | + |
|
48 | + //try to login with higher credentials for search |
|
49 | + $authUser = $adldap->authenticate($params->adminUsername, $params->adminPassword); |
|
50 | + if ($authUser == false) { |
|
51 | + $Result->show("danger", _("Invalid credentials"), true); |
|
52 | + } |
|
53 | + |
|
54 | + // set OpenLDAP flag |
|
55 | + if($server->type == "LDAP") { $adldap->setUseOpenLDAP(true); } |
|
56 | + |
|
57 | + //search for domain user! |
|
58 | + $userinfo = $adldap->user()->info("$_POST[dname]*", array("*"),false,$server->type); |
|
59 | + |
|
60 | + //echo $adldap->getLastError(); |
|
61 | 61 | } |
62 | 62 | catch (adLDAPException $e) { |
63 | - $Result->show("danger", $e->getMessage(), true); |
|
63 | + $Result->show("danger", $e->getMessage(), true); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
67 | 67 | //check for found |
68 | 68 | if(!isset($userinfo['count'])) { |
69 | - print "<div class='alert alert-info'>"; |
|
70 | - print _('No users found')."!<hr>"; |
|
71 | - print _('Possible reasons').":"; |
|
72 | - print "<ul>"; |
|
73 | - print "<li>"._('Username not existing')."</li>"; |
|
74 | - print "<li>"._('Invalid baseDN setting for AD')."</li>"; |
|
75 | - print "<li>"._('AD account does not have enough privileges for search')."</li>"; |
|
76 | - print "</div>"; |
|
69 | + print "<div class='alert alert-info'>"; |
|
70 | + print _('No users found')."!<hr>"; |
|
71 | + print _('Possible reasons').":"; |
|
72 | + print "<ul>"; |
|
73 | + print "<li>"._('Username not existing')."</li>"; |
|
74 | + print "<li>"._('Invalid baseDN setting for AD')."</li>"; |
|
75 | + print "<li>"._('AD account does not have enough privileges for search')."</li>"; |
|
76 | + print "</div>"; |
|
77 | 77 | } else { |
78 | - print _(" Following users were found").": ($userinfo[count]):<hr>"; |
|
79 | - |
|
80 | - print "<table class='table table-striped'>"; |
|
81 | - |
|
82 | - unset($userinfo['count']); |
|
83 | - if(sizeof(@$userinfo)>0 && isset($userinfo)) { |
|
84 | - // loop |
|
85 | - foreach($userinfo as $u) { |
|
86 | - print "<tr>"; |
|
87 | - print " <td>".$u['displayname'][0]; |
|
88 | - print "</td>"; |
|
89 | - print " <td>".$u['samaccountname'][0]."</td>"; |
|
90 | - print " <td>".$u['mail'][0]."</td>"; |
|
91 | - //actions |
|
92 | - print " <td style='width:10px;'>"; |
|
93 | - print " <a href='' class='btn btn-sm btn-default btn-success userselect' data-uname='".$u['displayname'][0]."' data-username='".$u['samaccountname'][0]."' data-email='".$u['mail'][0]."' data-server='".$_POST['server']."' data-server-type='".$server->type."'>"._('Select')."</a>"; |
|
94 | - print " </td>"; |
|
95 | - print "</tr>"; |
|
96 | - } |
|
97 | - } |
|
98 | - print "</table>"; |
|
78 | + print _(" Following users were found").": ($userinfo[count]):<hr>"; |
|
79 | + |
|
80 | + print "<table class='table table-striped'>"; |
|
81 | + |
|
82 | + unset($userinfo['count']); |
|
83 | + if(sizeof(@$userinfo)>0 && isset($userinfo)) { |
|
84 | + // loop |
|
85 | + foreach($userinfo as $u) { |
|
86 | + print "<tr>"; |
|
87 | + print " <td>".$u['displayname'][0]; |
|
88 | + print "</td>"; |
|
89 | + print " <td>".$u['samaccountname'][0]."</td>"; |
|
90 | + print " <td>".$u['mail'][0]."</td>"; |
|
91 | + //actions |
|
92 | + print " <td style='width:10px;'>"; |
|
93 | + print " <a href='' class='btn btn-sm btn-default btn-success userselect' data-uname='".$u['displayname'][0]."' data-username='".$u['samaccountname'][0]."' data-email='".$u['mail'][0]."' data-server='".$_POST['server']."' data-server-type='".$server->type."'>"._('Select')."</a>"; |
|
94 | + print " </td>"; |
|
95 | + print "</tr>"; |
|
96 | + } |
|
97 | + } |
|
98 | + print "</table>"; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | ?> |
102 | 102 | \ No newline at end of file |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | $userinfo = $adldap->user()->info("$_POST[dname]*", array("*"),false,$server->type); |
59 | 59 | |
60 | 60 | //echo $adldap->getLastError(); |
61 | -} |
|
62 | -catch (adLDAPException $e) { |
|
61 | +} catch (adLDAPException $e) { |
|
63 | 62 | $Result->show("danger", $e->getMessage(), true); |
64 | 63 | } |
65 | 64 | |
@@ -74,7 +73,8 @@ discard block |
||
74 | 73 | print "<li>"._('Invalid baseDN setting for AD')."</li>"; |
75 | 74 | print "<li>"._('AD account does not have enough privileges for search')."</li>"; |
76 | 75 | print "</div>"; |
77 | -} else { |
|
76 | +} |
|
77 | +else { |
|
78 | 78 | print _(" Following users were found").": ($userinfo[count]):<hr>"; |
79 | 79 | |
80 | 80 | print "<table class='table table-striped'>"; |
@@ -5,84 +5,84 @@ discard block |
||
5 | 5 | *************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
9 | -require( dirname(__FILE__) . "/../../../functions/adLDAP/src/adLDAP.php"); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | +require(dirname (__FILE__)."/../../../functions/adLDAP/src/adLDAP.php"); |
|
10 | 10 | |
11 | 11 | # initialize user object |
12 | -$Database = new Database_PDO; |
|
13 | -$User = new User ($Database); |
|
12 | +$Database = new Database_PDO; |
|
13 | +$User = new User ($Database); |
|
14 | 14 | $Admin = new Admin ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # fetch server |
21 | -$server = $Admin->fetch_object("usersAuthMethod", "id", $_POST['server']); |
|
22 | -$server!==false ? : $Result->show("danger", _("Invalid server ID"), true); |
|
21 | +$server = $Admin->fetch_object ("usersAuthMethod", "id", $_POST['server']); |
|
22 | +$server !== false ? : $Result->show ("danger", _ ("Invalid server ID"), true); |
|
23 | 23 | |
24 | 24 | //parse parameters |
25 | -$params = json_decode($server->params); |
|
25 | +$params = json_decode ($server->params); |
|
26 | 26 | |
27 | 27 | //no login parameters |
28 | -if(strlen(@$params->adminUsername)==0 || strlen(@$params->adminPassword)==0) { $Result->show("danger", _("Missing credentials"), true); } |
|
28 | +if (strlen (@$params->adminUsername) == 0 || strlen (@$params->adminPassword) == 0) { $Result->show ("danger", _ ("Missing credentials"), true); } |
|
29 | 29 | //at least 2 chars |
30 | -if(strlen($_POST['dname'])<2) { $Result->show("danger", _('Please enter at least 2 characters'), true); } |
|
30 | +if (strlen ($_POST['dname']) < 2) { $Result->show ("danger", _ ('Please enter at least 2 characters'), true); } |
|
31 | 31 | |
32 | 32 | |
33 | 33 | //open connection |
34 | 34 | try { |
35 | - if($server->type == "NetIQ") { $params->account_suffix = ""; } |
|
35 | + if ($server->type == "NetIQ") { $params->account_suffix = ""; } |
|
36 | 36 | //set options |
37 | - $options = array( |
|
37 | + $options = array ( |
|
38 | 38 | 'base_dn'=>$params->base_dn, |
39 | 39 | 'account_suffix'=>$params->account_suffix, |
40 | - 'domain_controllers'=>explode(";",$params->domain_controllers), |
|
40 | + 'domain_controllers'=>explode (";", $params->domain_controllers), |
|
41 | 41 | 'use_ssl'=>$params->use_ssl, |
42 | 42 | 'use_tls'=>$params->use_tls, |
43 | 43 | 'ad_port'=>$params->ad_port |
44 | 44 | ); |
45 | 45 | //AD |
46 | - $adldap = new adLDAP($options); |
|
46 | + $adldap = new adLDAP ($options); |
|
47 | 47 | |
48 | 48 | //try to login with higher credentials for search |
49 | - $authUser = $adldap->authenticate($params->adminUsername, $params->adminPassword); |
|
49 | + $authUser = $adldap->authenticate ($params->adminUsername, $params->adminPassword); |
|
50 | 50 | if ($authUser == false) { |
51 | - $Result->show("danger", _("Invalid credentials"), true); |
|
51 | + $Result->show ("danger", _ ("Invalid credentials"), true); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | // set OpenLDAP flag |
55 | - if($server->type == "LDAP") { $adldap->setUseOpenLDAP(true); } |
|
55 | + if ($server->type == "LDAP") { $adldap->setUseOpenLDAP (true); } |
|
56 | 56 | |
57 | 57 | //search for domain user! |
58 | - $userinfo = $adldap->user()->info("$_POST[dname]*", array("*"),false,$server->type); |
|
58 | + $userinfo = $adldap->user ()->info ("$_POST[dname]*", array ("*"), false, $server->type); |
|
59 | 59 | |
60 | 60 | //echo $adldap->getLastError(); |
61 | 61 | } |
62 | 62 | catch (adLDAPException $e) { |
63 | - $Result->show("danger", $e->getMessage(), true); |
|
63 | + $Result->show ("danger", $e->getMessage (), true); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
67 | 67 | //check for found |
68 | -if(!isset($userinfo['count'])) { |
|
68 | +if (!isset($userinfo['count'])) { |
|
69 | 69 | print "<div class='alert alert-info'>"; |
70 | - print _('No users found')."!<hr>"; |
|
71 | - print _('Possible reasons').":"; |
|
70 | + print _ ('No users found')."!<hr>"; |
|
71 | + print _ ('Possible reasons').":"; |
|
72 | 72 | print "<ul>"; |
73 | - print "<li>"._('Username not existing')."</li>"; |
|
74 | - print "<li>"._('Invalid baseDN setting for AD')."</li>"; |
|
75 | - print "<li>"._('AD account does not have enough privileges for search')."</li>"; |
|
73 | + print "<li>"._ ('Username not existing')."</li>"; |
|
74 | + print "<li>"._ ('Invalid baseDN setting for AD')."</li>"; |
|
75 | + print "<li>"._ ('AD account does not have enough privileges for search')."</li>"; |
|
76 | 76 | print "</div>"; |
77 | 77 | } else { |
78 | - print _(" Following users were found").": ($userinfo[count]):<hr>"; |
|
78 | + print _ (" Following users were found").": ($userinfo[count]):<hr>"; |
|
79 | 79 | |
80 | 80 | print "<table class='table table-striped'>"; |
81 | 81 | |
82 | 82 | unset($userinfo['count']); |
83 | - if(sizeof(@$userinfo)>0 && isset($userinfo)) { |
|
83 | + if (sizeof (@$userinfo) > 0 && isset($userinfo)) { |
|
84 | 84 | // loop |
85 | - foreach($userinfo as $u) { |
|
85 | + foreach ($userinfo as $u) { |
|
86 | 86 | print "<tr>"; |
87 | 87 | print " <td>".$u['displayname'][0]; |
88 | 88 | print "</td>"; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | print " <td>".$u['mail'][0]."</td>"; |
91 | 91 | //actions |
92 | 92 | print " <td style='width:10px;'>"; |
93 | - print " <a href='' class='btn btn-sm btn-default btn-success userselect' data-uname='".$u['displayname'][0]."' data-username='".$u['samaccountname'][0]."' data-email='".$u['mail'][0]."' data-server='".$_POST['server']."' data-server-type='".$server->type."'>"._('Select')."</a>"; |
|
93 | + print " <a href='' class='btn btn-sm btn-default btn-success userselect' data-uname='".$u['displayname'][0]."' data-username='".$u['samaccountname'][0]."' data-email='".$u['mail'][0]."' data-server='".$_POST['server']."' data-server-type='".$server->type."'>"._ ('Select')."</a>"; |
|
94 | 94 | print " </td>"; |
95 | 95 | print "</tr>"; |
96 | 96 | } |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | # fetch users to receive notification and filter |
11 | 11 | $users = $Admin->fetch_multiple_objects ("users", "role", "Administrator"); |
12 | 12 | foreach ($users as $k=>$u) { |
13 | - if ($u->mailNotify != "Yes") { |
|
14 | - unset($users[$k]); |
|
15 | - } |
|
13 | + if ($u->mailNotify != "Yes") { |
|
14 | + unset($users[$k]); |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | # fetch mailer settings |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | # verify admin mail and name |
22 | 22 | if (strlen($mail_settings->mAdminMail)==0 || strlen($mail_settings->mAdminName)==0) { |
23 | - $Result->show("danger", _("Cannot send mail, mail settings are missing. Please set them under administration > Mail Settings !"), true); |
|
23 | + $Result->show("danger", _("Cannot send mail, mail settings are missing. Please set them under administration > Mail Settings !"), true); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | # initialize mailer |
@@ -79,23 +79,23 @@ discard block |
||
79 | 79 | |
80 | 80 | # try to send |
81 | 81 | try { |
82 | - $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName); |
|
83 | - $phpipam_mail->Php_mailer->addAddress(addslashes(trim($_POST['email'])), addslashes(trim($_POST['real_name']))); |
|
84 | - //add all admins to CC |
|
85 | - if (sizeof($users)>0) { |
|
86 | - foreach($users as $admin) { |
|
87 | - $phpipam_mail->Php_mailer->AddCC($admin->email); |
|
88 | - } |
|
89 | - } |
|
90 | - $phpipam_mail->Php_mailer->Subject = $subject; |
|
91 | - $phpipam_mail->Php_mailer->msgHTML($content); |
|
92 | - $phpipam_mail->Php_mailer->AltBody = $content_plain; |
|
93 | - //send |
|
94 | - $phpipam_mail->Php_mailer->send(); |
|
82 | + $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName); |
|
83 | + $phpipam_mail->Php_mailer->addAddress(addslashes(trim($_POST['email'])), addslashes(trim($_POST['real_name']))); |
|
84 | + //add all admins to CC |
|
85 | + if (sizeof($users)>0) { |
|
86 | + foreach($users as $admin) { |
|
87 | + $phpipam_mail->Php_mailer->AddCC($admin->email); |
|
88 | + } |
|
89 | + } |
|
90 | + $phpipam_mail->Php_mailer->Subject = $subject; |
|
91 | + $phpipam_mail->Php_mailer->msgHTML($content); |
|
92 | + $phpipam_mail->Php_mailer->AltBody = $content_plain; |
|
93 | + //send |
|
94 | + $phpipam_mail->Php_mailer->send(); |
|
95 | 95 | } catch (phpmailerException $e) { |
96 | - $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
96 | + $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
97 | 97 | } catch (Exception $e) { |
98 | - $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
98 | + $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | //if error not sent print ok |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | ***********************************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # fetch users to receive notification and filter |
11 | 11 | $users = $Admin->fetch_multiple_objects ("users", "role", "Administrator"); |
@@ -16,89 +16,89 @@ discard block |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | # fetch mailer settings |
19 | -$mail_settings = $Admin->fetch_object("settingsMail", "id", 1); |
|
19 | +$mail_settings = $Admin->fetch_object ("settingsMail", "id", 1); |
|
20 | 20 | |
21 | 21 | # verify admin mail and name |
22 | -if (strlen($mail_settings->mAdminMail)==0 || strlen($mail_settings->mAdminName)==0) { |
|
23 | - $Result->show("danger", _("Cannot send mail, mail settings are missing. Please set them under administration > Mail Settings !"), true); |
|
22 | +if (strlen ($mail_settings->mAdminMail) == 0 || strlen ($mail_settings->mAdminName) == 0) { |
|
23 | + $Result->show ("danger", _ ("Cannot send mail, mail settings are missing. Please set them under administration > Mail Settings !"), true); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | # initialize mailer |
27 | -$phpipam_mail = new phpipam_mail($User->settings, $mail_settings); |
|
28 | -$phpipam_mail->initialize_mailer(); |
|
27 | +$phpipam_mail = new phpipam_mail ($User->settings, $mail_settings); |
|
28 | +$phpipam_mail->initialize_mailer (); |
|
29 | 29 | |
30 | 30 | |
31 | 31 | # set subject |
32 | -if ($_POST['action'] == "Add") { $subject = _('New ipam account created'); } |
|
33 | -else if ($_POST['action'] == "Edit") { $subject = _('User ipam account updated'); } |
|
34 | -else { $subject = _('IPAM account details'); } |
|
32 | +if ($_POST['action'] == "Add") { $subject = _ ('New ipam account created'); } |
|
33 | +else if ($_POST['action'] == "Edit") { $subject = _ ('User ipam account updated'); } |
|
34 | +else { $subject = _ ('IPAM account details'); } |
|
35 | 35 | |
36 | 36 | |
37 | 37 | # set html content |
38 | 38 | $content[] = "<table style='margin-left:10px;margin-top:5px;width:auto;padding:0px;border-collapse:collapse;'>"; |
39 | 39 | $content[] = "<tr><td style='padding:5px;margin:0px;color:#333;font-size:16px;text-shadow:1px 1px 1px white;border-bottom:1px solid #eeeeee;' colspan='2'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:16px;'>$subject</font></td></tr>"; |
40 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;border-top:1px solid white;padding-top:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Name').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;padding-top:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'. $_POST['real_name'] .'</font></td></tr>'; |
|
40 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;border-top:1px solid white;padding-top:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Name').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;padding-top:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'.$_POST['real_name'].'</font></td></tr>'; |
|
41 | 41 | //we dont need pass for domain account |
42 | -if($auth_method->type == "local") { |
|
43 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Username').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'. $_POST['username'] .'</font></td></tr>'; |
|
44 | -if(strlen($_POST['password2']) != 0) { |
|
45 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Password').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'. $_POST['password2'] .'</font></td></tr>'; |
|
42 | +if ($auth_method->type == "local") { |
|
43 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Username').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'.$_POST['username'].'</font></td></tr>'; |
|
44 | +if (strlen ($_POST['password2']) != 0) { |
|
45 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Password').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'.$_POST['password2'].'</font></td></tr>'; |
|
46 | 46 | }} |
47 | 47 | else { |
48 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Username').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">* '._('your domain username').' ('. $_POST['username'] .')</font></td></tr>'; |
|
49 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Password').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">* '._('your domain password').'</font></td></tr>'; |
|
48 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Username').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">* '._ ('your domain username').' ('.$_POST['username'].')</font></td></tr>'; |
|
49 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Password').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">* '._ ('your domain password').'</font></td></tr>'; |
|
50 | 50 | } |
51 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Email').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;"><a href="mailto:'.$_POST['email'].'" style="color:#08c;">'.$_POST['email'].'</a></font></td></tr>'; |
|
52 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Role').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'. $_POST['role'] .'</font></td></tr>'; |
|
53 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;border-bottom:1px solid #eeeeee;padding-bottom:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('WebApp').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;border-bottom:1px solid #eeeeee;padding-bottom:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;"> <a href="'. $User->settings->siteURL .'" style="color:#08c;">'. $User->settings->siteURL. '</font></a><td></tr>'; |
|
54 | -$content[] = "<tr><td style='padding:5px;padding-left:15px;margin:0px;font-style:italic;padding-bottom:3px;text-align:right;color:#ccc;text-shadow:1px 1px 1px white;border-top:1px solid white;' colspan='2'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:11px;'>"._('Sent by user')." ".$User->user->real_name." at ".date('Y/m/d H:i')."</font></td></tr>"; |
|
51 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Email').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;"><a href="mailto:'.$_POST['email'].'" style="color:#08c;">'.$_POST['email'].'</a></font></td></tr>'; |
|
52 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Role').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'.$_POST['role'].'</font></td></tr>'; |
|
53 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;border-bottom:1px solid #eeeeee;padding-bottom:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('WebApp').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;border-bottom:1px solid #eeeeee;padding-bottom:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;"> <a href="'.$User->settings->siteURL.'" style="color:#08c;">'.$User->settings->siteURL.'</font></a><td></tr>'; |
|
54 | +$content[] = "<tr><td style='padding:5px;padding-left:15px;margin:0px;font-style:italic;padding-bottom:3px;text-align:right;color:#ccc;text-shadow:1px 1px 1px white;border-top:1px solid white;' colspan='2'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:11px;'>"._ ('Sent by user')." ".$User->user->real_name." at ".date ('Y/m/d H:i')."</font></td></tr>"; |
|
55 | 55 | $content[] = "</table>"; |
56 | 56 | |
57 | 57 | # plain |
58 | 58 | $content_plain[] = "$subject"."\r\n------------------------------\r\n"; |
59 | -$content_plain[] = _("Name").": $_POST[real_name]"; |
|
59 | +$content_plain[] = _ ("Name").": $_POST[real_name]"; |
|
60 | 60 | # we dont need pass for domain account |
61 | -if($auth_method->type == "local") { |
|
62 | -$content_plain[] = _("Username").": $_POST[username]"; |
|
63 | -if(strlen($_POST['password2']) != 0) { |
|
64 | -$content_plain[] = _("Password").": $_POST[password2]"; |
|
61 | +if ($auth_method->type == "local") { |
|
62 | +$content_plain[] = _ ("Username").": $_POST[username]"; |
|
63 | +if (strlen ($_POST['password2']) != 0) { |
|
64 | +$content_plain[] = _ ("Password").": $_POST[password2]"; |
|
65 | 65 | }} |
66 | 66 | else { |
67 | -$content_plain[] = _("Username").": * your domain username($_POST[username]"; |
|
68 | -$content_plain[] = _("Password").": * your domain password"; |
|
67 | +$content_plain[] = _ ("Username").": * your domain username($_POST[username]"; |
|
68 | +$content_plain[] = _ ("Password").": * your domain password"; |
|
69 | 69 | } |
70 | -$content_plain[] = _("Email").": $_POST[email]"; |
|
71 | -$content_plain[] = _("Role").": $_POST[role]"; |
|
72 | -$content_plain[] = _("WebApp").": ".$User->settings->siteURL; |
|
73 | -$content_plain[] = "\r\n"._("Sent by user")." ".$User->user->real_name." at ".date('Y/m/d H:i'); |
|
70 | +$content_plain[] = _ ("Email").": $_POST[email]"; |
|
71 | +$content_plain[] = _ ("Role").": $_POST[role]"; |
|
72 | +$content_plain[] = _ ("WebApp").": ".$User->settings->siteURL; |
|
73 | +$content_plain[] = "\r\n"._ ("Sent by user")." ".$User->user->real_name." at ".date ('Y/m/d H:i'); |
|
74 | 74 | |
75 | 75 | |
76 | 76 | # set content |
77 | -$content = $phpipam_mail->generate_message (implode("\r\n", $content)); |
|
78 | -$content_plain = implode("\r\n",$content_plain); |
|
77 | +$content = $phpipam_mail->generate_message (implode ("\r\n", $content)); |
|
78 | +$content_plain = implode ("\r\n", $content_plain); |
|
79 | 79 | |
80 | 80 | # try to send |
81 | 81 | try { |
82 | - $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName); |
|
83 | - $phpipam_mail->Php_mailer->addAddress(addslashes(trim($_POST['email'])), addslashes(trim($_POST['real_name']))); |
|
82 | + $phpipam_mail->Php_mailer->setFrom ($mail_settings->mAdminMail, $mail_settings->mAdminName); |
|
83 | + $phpipam_mail->Php_mailer->addAddress (addslashes (trim ($_POST['email'])), addslashes (trim ($_POST['real_name']))); |
|
84 | 84 | //add all admins to CC |
85 | - if (sizeof($users)>0) { |
|
86 | - foreach($users as $admin) { |
|
87 | - $phpipam_mail->Php_mailer->AddCC($admin->email); |
|
85 | + if (sizeof ($users) > 0) { |
|
86 | + foreach ($users as $admin) { |
|
87 | + $phpipam_mail->Php_mailer->AddCC ($admin->email); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | $phpipam_mail->Php_mailer->Subject = $subject; |
91 | - $phpipam_mail->Php_mailer->msgHTML($content); |
|
91 | + $phpipam_mail->Php_mailer->msgHTML ($content); |
|
92 | 92 | $phpipam_mail->Php_mailer->AltBody = $content_plain; |
93 | 93 | //send |
94 | - $phpipam_mail->Php_mailer->send(); |
|
94 | + $phpipam_mail->Php_mailer->send (); |
|
95 | 95 | } catch (phpmailerException $e) { |
96 | - $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
96 | + $Result->show ("danger", "Mailer Error: ".$e->errorMessage (), true); |
|
97 | 97 | } catch (Exception $e) { |
98 | - $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
98 | + $Result->show ("danger", "Mailer Error: ".$e->errorMessage (), true); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | //if error not sent print ok |
102 | -$Result->show("success", _('Notification mail for new account sent').'!', true); |
|
102 | +$Result->show ("success", _ ('Notification mail for new account sent').'!', true); |
|
103 | 103 | |
104 | 104 | ?> |
105 | 105 | \ No newline at end of file |
@@ -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? |
@@ -8,7 +8,7 @@ |
||
8 | 8 | $User->check_user_session(); |
9 | 9 | |
10 | 10 | // switch user |
11 | -if(@$_GET['subnetId']=="switch"){ |
|
11 | +if(@$_GET['subnetId']=="switch") { |
|
12 | 12 | $_SESSION['realipamusername'] = $_SESSION['ipamusername']; |
13 | 13 | $_SESSION['ipamusername'] = $_GET['sPage']; |
14 | 14 | print '<script>window.location.href = "'.create_link(null).'";</script>'; |
@@ -5,16 +5,16 @@ |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | // switch user |
11 | -if(@$_GET['subnetId']=="switch"){ |
|
11 | +if (@$_GET['subnetId'] == "switch") { |
|
12 | 12 | $_SESSION['realipamusername'] = $_SESSION['ipamusername']; |
13 | 13 | $_SESSION['ipamusername'] = $_GET['sPage']; |
14 | - print '<script>window.location.href = "'.create_link(null).'";</script>'; |
|
14 | + print '<script>window.location.href = "'.create_link (null).'";</script>'; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | # print all or specific user? |
18 | -if(isset($_GET['subnetId'])) { include("print-user.php"); } |
|
19 | -else { include("print-all.php"); } |
|
18 | +if (isset($_GET['subnetId'])) { include("print-user.php"); } |
|
19 | +else { include("print-all.php"); } |
|
20 | 20 | ?> |
21 | 21 | \ No newline at end of file |
@@ -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 |
@@ -161,7 +161,7 @@ |
||
161 | 161 | print "/"; |
162 | 162 | } |
163 | 163 | //booleans |
164 | - elseif($field['type']=="tinyint(1)") { |
|
164 | + elseif($field['type']=="tinyint(1)") { |
|
165 | 165 | if($user->$key == "0") { print _("No"); } |
166 | 166 | elseif($user->$key == "1") { print _("Yes"); } |
167 | 167 | } |
@@ -5,46 +5,46 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # fetch user details |
11 | -$user = $Admin->fetch_object("users", "id", $_GET['subnetId']); |
|
11 | +$user = $Admin->fetch_object ("users", "id", $_GET['subnetId']); |
|
12 | 12 | |
13 | 13 | # invalid? |
14 | -if($user===false) { $Result->show("danger", _("Invalid ID"), true); } |
|
14 | +if ($user === false) { $Result->show ("danger", _ ("Invalid ID"), true); } |
|
15 | 15 | |
16 | 16 | # fetch user lang |
17 | -$language = $Admin->fetch_object("lang", "l_id", $user->lang); |
|
17 | +$language = $Admin->fetch_object ("lang", "l_id", $user->lang); |
|
18 | 18 | # check users auth method |
19 | -$auth_details = $Admin->fetch_object("usersAuthMethod", "id", $user->authMethod); |
|
19 | +$auth_details = $Admin->fetch_object ("usersAuthMethod", "id", $user->authMethod); |
|
20 | 20 | # fetch custom fields |
21 | -$custom_fields = $Tools->fetch_custom_fields('users'); |
|
21 | +$custom_fields = $Tools->fetch_custom_fields ('users'); |
|
22 | 22 | ?> |
23 | 23 | |
24 | 24 | <!-- display existing users --> |
25 | -<h4><?php print _('User details'); ?></h4> |
|
25 | +<h4><?php print _ ('User details'); ?></h4> |
|
26 | 26 | <hr><br> |
27 | 27 | |
28 | 28 | <!-- Add new --> |
29 | -<a class='btn btn-sm btn-default' href="<?php print create_link("administration","users"); ?>" style="margin-bottom:10px;"><i class='fa fa-angle-left'></i> <?php print _('All users'); ?></a> |
|
29 | +<a class='btn btn-sm btn-default' href="<?php print create_link ("administration", "users"); ?>" style="margin-bottom:10px;"><i class='fa fa-angle-left'></i> <?php print _ ('All users'); ?></a> |
|
30 | 30 | |
31 | 31 | <!-- table --> |
32 | 32 | <table id="userPrint" class="table table-hover table-auto table-condensed"> |
33 | 33 | |
34 | 34 | <tr> |
35 | - <td><?php print _('Real Name'); ?></td> |
|
35 | + <td><?php print _ ('Real Name'); ?></td> |
|
36 | 36 | <td><strong><?php print $user->real_name; ?></strong></td> |
37 | 37 | </tr> |
38 | 38 | <tr> |
39 | - <td><?php print _('Username'); ?></td> |
|
39 | + <td><?php print _ ('Username'); ?></td> |
|
40 | 40 | <td><?php print $user->username; ?></td> |
41 | 41 | </tr> |
42 | 42 | <tr> |
43 | - <td><?php print _('E-mail'); ?></td> |
|
43 | + <td><?php print _ ('E-mail'); ?></td> |
|
44 | 44 | <td><?php print $user->email; ?></td> |
45 | 45 | </tr> |
46 | 46 | <tr> |
47 | - <td><?php print _('Language'); ?></td> |
|
47 | + <td><?php print _ ('Language'); ?></td> |
|
48 | 48 | <td><?php print $language->l_name; ?></td> |
49 | 49 | </tr> |
50 | 50 | <tr> |
@@ -59,42 +59,42 @@ discard block |
||
59 | 59 | |
60 | 60 | |
61 | 61 | <tr> |
62 | - <td colspan="2"><h4><?php print _('Authentication settings'); ?></h4><hr></td> |
|
62 | + <td colspan="2"><h4><?php print _ ('Authentication settings'); ?></h4><hr></td> |
|
63 | 63 | </tr> |
64 | 64 | |
65 | 65 | <tr> |
66 | - <td><?php print _('Role'); ?></td> |
|
66 | + <td><?php print _ ('Role'); ?></td> |
|
67 | 67 | <td><?php print $user->role; ?></td> |
68 | 68 | </tr> |
69 | 69 | <tr> |
70 | - <td><?php print _('Authentication'); ?></td> |
|
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>"; } |
|
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 | 75 | ?> |
76 | 76 | </td> |
77 | 77 | </tr> |
78 | 78 | <tr> |
79 | - <td><?php print _('Last login'); ?></td> |
|
80 | - <td><?php print strlen($user->lastLogin)>0 ? $user->lastLogin : "<span class='text-muted'>"._("Never")."</span>"; ?></td> |
|
79 | + <td><?php print _ ('Last login'); ?></td> |
|
80 | + <td><?php print strlen ($user->lastLogin) > 0 ? $user->lastLogin : "<span class='text-muted'>"._ ("Never")."</span>"; ?></td> |
|
81 | 81 | </tr> |
82 | 82 | <tr> |
83 | - <td><?php print _('Last activity'); ?></td> |
|
84 | - <td><?php print strlen($user->lastActivity)>0 ? $user->lastActivity : "<span class='text-muted'>"._("Never")."</span>"; ?></td> |
|
83 | + <td><?php print _ ('Last activity'); ?></td> |
|
84 | + <td><?php print strlen ($user->lastActivity) > 0 ? $user->lastActivity : "<span class='text-muted'>"._ ("Never")."</span>"; ?></td> |
|
85 | 85 | </tr> |
86 | 86 | <tr> |
87 | - <td><?php print _('Groups'); ?></td> |
|
87 | + <td><?php print _ ('Groups'); ?></td> |
|
88 | 88 | <td> |
89 | 89 | <?php |
90 | - if($user->role == "Administrator") { |
|
91 | - print _('All groups'); |
|
90 | + if ($user->role == "Administrator") { |
|
91 | + print _ ('All groups'); |
|
92 | 92 | } |
93 | 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) { |
|
94 | + $groups = json_decode ($user->groups, true); |
|
95 | + $gr = $Admin->groups_parse ($groups); |
|
96 | + if (sizeof ($gr) > 0) { |
|
97 | + foreach ($gr as $group) { |
|
98 | 98 | print $group['g_name']."<br>"; |
99 | 99 | } |
100 | 100 | } |
@@ -106,64 +106,64 @@ discard block |
||
106 | 106 | </td> |
107 | 107 | </tr> |
108 | 108 | <tr> |
109 | - <td><?php print _('Password change required'); ?></td> |
|
109 | + <td><?php print _ ('Password change required'); ?></td> |
|
110 | 110 | <td><?php print $user->passChange; ?></td> |
111 | 111 | </tr> |
112 | 112 | |
113 | 113 | |
114 | 114 | |
115 | 115 | <tr> |
116 | - <td colspan="2"><h4><?php print _('Display settings'); ?></h4><hr></td> |
|
116 | + <td colspan="2"><h4><?php print _ ('Display settings'); ?></h4><hr></td> |
|
117 | 117 | </tr> |
118 | 118 | <tr> |
119 | - <td><?php print _('compress override'); ?></td> |
|
120 | - <td><?php print $user->compressOverride==1 ? _("Yes") : _("No") ?></td> |
|
119 | + <td><?php print _ ('compress override'); ?></td> |
|
120 | + <td><?php print $user->compressOverride == 1 ? _ ("Yes") : _ ("No") ?></td> |
|
121 | 121 | </tr> |
122 | 122 | <tr> |
123 | - <td><?php print _('Hide free range'); ?></td> |
|
124 | - <td><?php print $user->hideFreeRange==1 ? _("Yes") : _("No") ?></td> |
|
123 | + <td><?php print _ ('Hide free range'); ?></td> |
|
124 | + <td><?php print $user->hideFreeRange == 1 ? _ ("Yes") : _ ("No") ?></td> |
|
125 | 125 | </tr> |
126 | 126 | <tr> |
127 | - <td><?php print _('IP address print limit'); ?></td> |
|
127 | + <td><?php print _ ('IP address print limit'); ?></td> |
|
128 | 128 | <td><?php print $user->printLimit; ?></td> |
129 | 129 | </tr> |
130 | 130 | |
131 | 131 | |
132 | 132 | |
133 | 133 | <tr> |
134 | - <td colspan="2"><h4><?php print _('Mail settings'); ?></h4><hr></td> |
|
134 | + <td colspan="2"><h4><?php print _ ('Mail settings'); ?></h4><hr></td> |
|
135 | 135 | </tr> |
136 | 136 | <tr> |
137 | - <td><?php print _('Mail notifications'); ?></td> |
|
138 | - <td><?php print $user->role == "Administrator" ? _($user->mailNotify) : _("No"); ?></td> |
|
137 | + <td><?php print _ ('Mail notifications'); ?></td> |
|
138 | + <td><?php print $user->role == "Administrator" ? _ ($user->mailNotify) : _ ("No"); ?></td> |
|
139 | 139 | </tr> |
140 | 140 | <tr> |
141 | - <td><?php print _('Changelog notifications'); ?></td> |
|
142 | - <td><?php print $user->role == "Administrator" ? _($user->mailChangelog) : _("No"); ?></td> |
|
141 | + <td><?php print _ ('Changelog notifications'); ?></td> |
|
142 | + <td><?php print $user->role == "Administrator" ? _ ($user->mailChangelog) : _ ("No"); ?></td> |
|
143 | 143 | </tr> |
144 | 144 | |
145 | 145 | |
146 | 146 | |
147 | 147 | <tr> |
148 | - <td colspan="2"><h4><?php print _('Custom fields'); ?></h4><hr></td> |
|
148 | + <td colspan="2"><h4><?php print _ ('Custom fields'); ?></h4><hr></td> |
|
149 | 149 | </tr> |
150 | 150 | |
151 | 151 | <?php |
152 | 152 | # custom subnet fields |
153 | -if(sizeof($custom_fields) > 0) { |
|
154 | - foreach($custom_fields as $key=>$field) { |
|
155 | - $user->$key = str_replace("\n", "<br>",$user->$key); |
|
153 | +if (sizeof ($custom_fields) > 0) { |
|
154 | + foreach ($custom_fields as $key=>$field) { |
|
155 | + $user->$key = str_replace ("\n", "<br>", $user->$key); |
|
156 | 156 | print "<tr>"; |
157 | 157 | print " <td>$key</td>"; |
158 | 158 | print " <td>"; |
159 | 159 | //no length |
160 | - if(strlen($user->$key)==0) { |
|
160 | + if (strlen ($user->$key) == 0) { |
|
161 | 161 | print "/"; |
162 | 162 | } |
163 | 163 | //booleans |
164 | - elseif($field['type']=="tinyint(1)") { |
|
165 | - if($user->$key == "0") { print _("No"); } |
|
166 | - elseif($user->$key == "1") { print _("Yes"); } |
|
164 | + elseif ($field['type'] == "tinyint(1)") { |
|
165 | + if ($user->$key == "0") { print _ ("No"); } |
|
166 | + elseif ($user->$key == "1") { print _ ("Yes"); } |
|
167 | 167 | } |
168 | 168 | else { |
169 | 169 | print $user->$key; |
@@ -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 |
@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | //username > 8 chars |
56 | 56 | if ($auth_method->type=="local") { |
57 | 57 | if(strlen($_POST['username'])<6) { $Result->show("danger", _("Username must be at least 6 characters long!"), true); } |
58 | - } else { |
|
58 | + } |
|
59 | + else { |
|
59 | 60 | if(strlen($_POST['username'])==0) { $Result->show("danger", _("Username must be at least 1 character long!"), true); } |
60 | 61 | } |
61 | 62 | //check duplicate |
@@ -112,7 +113,8 @@ discard block |
||
112 | 113 | # set groups user belongs to |
113 | 114 | if($_POST['role']=="Administrator") { |
114 | 115 | $values['groups'] = null; |
115 | -} else { |
|
116 | +} |
|
117 | +else { |
|
116 | 118 | foreach($_POST as $key=>$post) { |
117 | 119 | if(substr($key, 0,5) == "group") { |
118 | 120 | $group[substr($key, 5)] = substr($key, 5); |
@@ -5,85 +5,85 @@ discard block |
||
5 | 5 | *************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # strip input tags |
21 | -$_POST = $Admin->strip_input_tags($_POST); |
|
21 | +$_POST = $Admin->strip_input_tags ($_POST); |
|
22 | 22 | |
23 | 23 | # validate csrf cookie |
24 | -$User->csrf_cookie ("validate", "user", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; |
|
24 | +$User->csrf_cookie ("validate", "user", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : ""; |
|
25 | 25 | |
26 | 26 | # fetch auth method |
27 | 27 | $auth_method = $Admin->fetch_object ("usersAuthMethod", "id", $_POST['authMethod']); |
28 | -$auth_method!==false ? : $Result->show("danger", _("Invalid authentication method"), true); |
|
28 | +$auth_method !== false ? : $Result->show ("danger", _ ("Invalid authentication method"), true); |
|
29 | 29 | |
30 | 30 | |
31 | 31 | /* checks */ |
32 | 32 | |
33 | 33 | # ID must be numeric |
34 | -if($_POST['action']=="edit"||$_POST['action']=="delete") { |
|
35 | - if(!is_numeric($_POST['userId'])) { $Result->show("danger", _("Invalid ID"), true); } |
|
34 | +if ($_POST['action'] == "edit" || $_POST['action'] == "delete") { |
|
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 | -if($auth_method->type != "local") { $_POST['password1'] = ""; $_POST['password2'] = ""; } |
|
40 | -if((strlen(@$_POST['password1'])>0 || (@$_POST['action']=="add") && $auth_method->type=="local")) { |
|
39 | +if ($auth_method->type != "local") { $_POST['password1'] = ""; $_POST['password2'] = ""; } |
|
40 | +if ((strlen (@$_POST['password1']) > 0 || (@$_POST['action'] == "add") && $auth_method->type == "local")) { |
|
41 | 41 | //checks |
42 | - if($_POST['password1']!=$_POST['password2']) { $Result->show("danger", _("Passwords do not match"), true); } |
|
43 | - if(strlen($_POST['password1'])<8) { $Result->show("danger", _("Password must be at least 8 characters long!"), true); } |
|
42 | + if ($_POST['password1'] != $_POST['password2']) { $Result->show ("danger", _ ("Passwords do not match"), true); } |
|
43 | + if (strlen ($_POST['password1']) < 8) { $Result->show ("danger", _ ("Password must be at least 8 characters long!"), true); } |
|
44 | 44 | |
45 | 45 | //hash passowrd |
46 | 46 | $_POST['password1'] = $User->crypt_user_pass ($_POST['password1']); |
47 | 47 | } |
48 | 48 | |
49 | 49 | # general checks |
50 | -if(strlen(@$_POST['real_name'])==0) { $Result->show("danger", _("Real name field is mandatory!"), true); } |
|
50 | +if (strlen (@$_POST['real_name']) == 0) { $Result->show ("danger", _ ("Real name field is mandatory!"), true); } |
|
51 | 51 | # email format must be valid |
52 | -if (!$Result->validate_email(@$_POST['email'])) { $Result->show("danger", _("Invalid email address!"), true); } |
|
52 | +if (!$Result->validate_email (@$_POST['email'])) { $Result->show ("danger", _ ("Invalid email address!"), true); } |
|
53 | 53 | |
54 | 54 | # username must not already exist (if action is add) |
55 | -if ($_POST['action']=="add") { |
|
55 | +if ($_POST['action'] == "add") { |
|
56 | 56 | //username > 8 chars |
57 | - if ($auth_method->type=="local") { |
|
58 | - if(strlen($_POST['username'])<6) { $Result->show("danger", _("Username must be at least 6 characters long!"), true); } |
|
57 | + if ($auth_method->type == "local") { |
|
58 | + if (strlen ($_POST['username']) < 6) { $Result->show ("danger", _ ("Username must be at least 6 characters long!"), true); } |
|
59 | 59 | } else { |
60 | - if(strlen($_POST['username'])==0) { $Result->show("danger", _("Username must be at least 1 character long!"), true); } |
|
60 | + if (strlen ($_POST['username']) == 0) { $Result->show ("danger", _ ("Username must be at least 1 character long!"), true); } |
|
61 | 61 | } |
62 | 62 | //check duplicate |
63 | - if($Admin->fetch_object("users", "username", $_POST['username'])!==false) { |
|
64 | - { $Result->show("danger", _("User")." ".$_POST['username']." "._("already exists!"), true); } |
|
63 | + if ($Admin->fetch_object ("users", "username", $_POST['username']) !== false) { |
|
64 | + { $Result->show ("danger", _ ("User")." ".$_POST['username']." "._ ("already exists!"), true); } |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | # admin user cannot be deleted |
68 | -if($_POST['action']=="delete" && $_POST['username']=="admin") { $Result->show("danger", _("Admin user cannot be deleted"), true); } |
|
68 | +if ($_POST['action'] == "delete" && $_POST['username'] == "admin") { $Result->show ("danger", _ ("Admin user cannot be deleted"), true); } |
|
69 | 69 | |
70 | 70 | # custom fields check |
71 | -$myFields = $Tools->fetch_custom_fields('users'); |
|
72 | -if(sizeof($myFields) > 0) { |
|
73 | - foreach($myFields as $myField) { |
|
71 | +$myFields = $Tools->fetch_custom_fields ('users'); |
|
72 | +if (sizeof ($myFields) > 0) { |
|
73 | + foreach ($myFields as $myField) { |
|
74 | 74 | # replace possible ___ back to spaces! |
75 | - $myField['nameTest'] = str_replace(" ", "___", $myField['name']); |
|
75 | + $myField['nameTest'] = str_replace (" ", "___", $myField['name']); |
|
76 | 76 | |
77 | - if(isset($_POST[$myField['nameTest']])) { $_POST[$myField['name']] = $_POST[$myField['nameTest']];} |
|
77 | + if (isset($_POST[$myField['nameTest']])) { $_POST[$myField['name']] = $_POST[$myField['nameTest']]; } |
|
78 | 78 | |
79 | 79 | //booleans can be only 0 and 1! |
80 | - if($myField['type']=="tinyint(1)") { |
|
81 | - if($_POST[$myField['name']]>1) { |
|
80 | + if ($myField['type'] == "tinyint(1)") { |
|
81 | + if ($_POST[$myField['name']] > 1) { |
|
82 | 82 | $$_POST[$myField['name']] = ""; |
83 | 83 | } |
84 | 84 | } |
85 | 85 | //not null! |
86 | - if($myField['Null']=="NO" && strlen($_POST[$myField['name']])==0) { $Result->show("danger", '"'.$myField['name'].'" can not be empty!', true); } |
|
86 | + if ($myField['Null'] == "NO" && strlen ($_POST[$myField['name']]) == 0) { $Result->show ("danger", '"'.$myField['name'].'" can not be empty!', true); } |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | /* update */ |
92 | 92 | |
93 | 93 | # formulate update values |
94 | -$values = array("id"=>@$_POST['userId'], |
|
94 | +$values = array ("id"=>@$_POST['userId'], |
|
95 | 95 | "real_name"=>$_POST['real_name'], |
96 | 96 | "username"=>$_POST['username'], |
97 | 97 | "email"=>$_POST['email'], |
@@ -103,30 +103,30 @@ discard block |
||
103 | 103 | "pdns"=>$_POST['pdns'] |
104 | 104 | ); |
105 | 105 | # update pass ? |
106 | -if(strlen(@$_POST['password1'])>0 || (@$_POST['action']=="add" && $auth_method->type=="local")) { |
|
106 | +if (strlen (@$_POST['password1']) > 0 || (@$_POST['action'] == "add" && $auth_method->type == "local")) { |
|
107 | 107 | $values['password'] = $_POST['password1']; |
108 | 108 | } |
109 | 109 | # pass change |
110 | -if(isset($_POST['passChange']) && $auth_method->type=="local") { |
|
110 | +if (isset($_POST['passChange']) && $auth_method->type == "local") { |
|
111 | 111 | $values['passChange'] = "Yes"; |
112 | 112 | } |
113 | 113 | # set groups user belongs to |
114 | -if($_POST['role']=="Administrator") { |
|
114 | +if ($_POST['role'] == "Administrator") { |
|
115 | 115 | $values['groups'] = null; |
116 | 116 | } else { |
117 | - foreach($_POST as $key=>$post) { |
|
118 | - if(substr($key, 0,5) == "group") { |
|
119 | - $group[substr($key, 5)] = substr($key, 5); |
|
117 | + foreach ($_POST as $key=>$post) { |
|
118 | + if (substr ($key, 0, 5) == "group") { |
|
119 | + $group[substr ($key, 5)] = substr ($key, 5); |
|
120 | 120 | } |
121 | 121 | } |
122 | - $values['groups'] = json_encode(@$group); |
|
122 | + $values['groups'] = json_encode (@$group); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | # execute |
126 | -if(!$Admin->object_modify("users", $_POST['action'], "id", $values)) { $Result->show("danger", _("User $_POST[action] failed").'!', true); } |
|
127 | -else { $Result->show("success", _("User $_POST[action] successfull").'!', false); } |
|
126 | +if (!$Admin->object_modify ("users", $_POST['action'], "id", $values)) { $Result->show ("danger", _ ("User $_POST[action] failed").'!', true); } |
|
127 | +else { $Result->show ("success", _ ("User $_POST[action] successfull").'!', false); } |
|
128 | 128 | |
129 | 129 | # mail user |
130 | -if($Admin->verify_checkbox(@$_POST['notifyUser'])!="0") { include("edit-notify.php"); } |
|
130 | +if ($Admin->verify_checkbox (@$_POST['notifyUser']) != "0") { include("edit-notify.php"); } |
|
131 | 131 | |
132 | 132 | ?> |
@@ -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 |
@@ -85,7 +85,10 @@ discard block |
||
85 | 85 | <!-- username --> |
86 | 86 | <tr> |
87 | 87 | <td><?php print _('Username'); ?></td> |
88 | - <td><input type="text" class="form-control input-sm" name="username" value="<?php print @$user['username']; ?>" <?php if($_POST['action']=="edit"||$_POST['action']=="delete") print 'readonly'; ?>></td> |
|
88 | + <td><input type="text" class="form-control input-sm" name="username" value="<?php print @$user['username']; ?>" <?php if($_POST['action']=="edit"||$_POST['action']=="delete") { |
|
89 | + print 'readonly'; |
|
90 | +} |
|
91 | +?>></td> |
|
89 | 92 | <td class="info2"> |
90 | 93 | <a class='btn btn-xs btn-default adsearchuser' rel='tooltip' title='Search AD for user details'><i class='fa fa-search'></i></a> |
91 | 94 | <?php print _('Enter username'); ?> |
@@ -104,8 +107,14 @@ discard block |
||
104 | 107 | <td><?php print _('User role'); ?></td> |
105 | 108 | <td> |
106 | 109 | <select name="role" class="form-control input-sm input-w-auto"> |
107 | - <option value="Administrator" <?php if (@$user['role'] == "Administrator") print "selected"; ?>><?php print _('Administrator'); ?></option> |
|
108 | - <option value="User" <?php if (@$user['role'] == "User" || $_POST['action'] == "add") print "selected"; ?>><?php print _('Normal User'); ?></option> |
|
110 | + <option value="Administrator" <?php if (@$user['role'] == "Administrator") { |
|
111 | + print "selected"; |
|
112 | +} |
|
113 | +?>><?php print _('Administrator'); ?></option> |
|
114 | + <option value="User" <?php if (@$user['role'] == "User" || $_POST['action'] == "add") { |
|
115 | + print "selected"; |
|
116 | +} |
|
117 | +?>><?php print _('Normal User'); ?></option> |
|
109 | 118 | </select> |
110 | 119 | |
111 | 120 | |
@@ -147,7 +156,10 @@ discard block |
||
147 | 156 | </tbody> |
148 | 157 | |
149 | 158 | <!-- password --> |
150 | - <tbody id="user_password" <?php if(@$user['authMethod']!="1" && isset($user['authMethod'])) print "style='display:none'"; ?>> |
|
159 | + <tbody id="user_password" <?php if(@$user['authMethod']!="1" && isset($user['authMethod'])) { |
|
160 | + print "style='display:none'"; |
|
161 | +} |
|
162 | +?>> |
|
151 | 163 | |
152 | 164 | <tr class="password"> |
153 | 165 | <td><?php print _('Password'); ?></td> |
@@ -197,19 +209,26 @@ discard block |
||
197 | 209 | <!-- send notification mail --> |
198 | 210 | <tr> |
199 | 211 | <td><?php print _('Notification'); ?></td> |
200 | - <td><input type="checkbox" name="notifyUser" value="on" <?php if($_POST['action'] == "add") { print 'checked'; } else if($_POST['action'] == "delete") { print 'disabled="disabled"';} ?>></td> |
|
212 | + <td><input type="checkbox" name="notifyUser" value="on" <?php if($_POST['action'] == "add") { print 'checked'; } |
|
213 | +else if($_POST['action'] == "delete") { print 'disabled="disabled"';} ?>></td> |
|
201 | 214 | <td class="info2"><?php print _('Send notification email to user with account details'); ?></td> |
202 | 215 | </tr> |
203 | 216 | </tbody> |
204 | 217 | |
205 | 218 | <!-- mailNotify --> |
206 | - <tbody id="user_notifications" <?php if(@$user['role']!="Administrator") print "style='display:none'"; ?>> |
|
219 | + <tbody id="user_notifications" <?php if(@$user['role']!="Administrator") { |
|
220 | + print "style='display:none'"; |
|
221 | +} |
|
222 | +?>> |
|
207 | 223 | <tr> |
208 | 224 | <td><?php print _('Mail State changes'); ?></td> |
209 | 225 | <td> |
210 | 226 | <select name="mailNotify" class="form-control input-sm input-w-auto"> |
211 | 227 | <option value="No"><?php print _('No'); ?></option> |
212 | - <option value="Yes" <?php if (@$user['mailNotify'] == "Yes") print "selected='selected'"; ?>><?php print _('Yes'); ?></option> |
|
228 | + <option value="Yes" <?php if (@$user['mailNotify'] == "Yes") { |
|
229 | + print "selected='selected'"; |
|
230 | +} |
|
231 | +?>><?php print _('Yes'); ?></option> |
|
213 | 232 | </select> |
214 | 233 | |
215 | 234 | |
@@ -223,7 +242,10 @@ discard block |
||
223 | 242 | <td> |
224 | 243 | <select name="mailChangelog" class="form-control input-sm input-w-auto"> |
225 | 244 | <option value="No"><?php print _('No'); ?></option> |
226 | - <option value="Yes" <?php if (@$user['mailChangelog'] == "Yes") print "selected='selected'"; ?>><?php print _('Yes'); ?></option> |
|
245 | + <option value="Yes" <?php if (@$user['mailChangelog'] == "Yes") { |
|
246 | + print "selected='selected'"; |
|
247 | +} |
|
248 | +?>><?php print _('Yes'); ?></option> |
|
227 | 249 | </select> |
228 | 250 | |
229 | 251 | |
@@ -276,7 +298,10 @@ discard block |
||
276 | 298 | <tr> |
277 | 299 | <td><?php print _("PowerDNS"); ?></td> |
278 | 300 | <td> |
279 | - <input type="checkbox" class="input-switch" value="Yes" name="pdns" <?php if(@$user->pdns == "Yes") print 'checked'; ?>> |
|
301 | + <input type="checkbox" class="input-switch" value="Yes" name="pdns" <?php if(@$user->pdns == "Yes") { |
|
302 | + print 'checked'; |
|
303 | +} |
|
304 | +?>> |
|
280 | 305 | </td> |
281 | 306 | <td class="info2"><?php print _('Select to allow user to create DNS records'); ?></td> |
282 | 307 | </tr> |
@@ -390,7 +415,10 @@ discard block |
||
390 | 415 | <div class="pFooter"> |
391 | 416 | <div class="btn-group"> |
392 | 417 | <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
393 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editUserSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
418 | + <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } |
|
419 | +else { print "btn-success"; } ?>" id="editUserSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } |
|
420 | +else if ($_POST['action']=="delete") { print "fa-trash-o"; } |
|
421 | +else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
394 | 422 | </div> |
395 | 423 | |
396 | 424 | <!-- Result --> |
@@ -5,45 +5,45 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # create csrf token |
21 | 21 | $csrf = $User->csrf_cookie ("create", "user"); |
22 | 22 | |
23 | 23 | |
24 | 24 | # fetch custom fields |
25 | -$custom = $Tools->fetch_custom_fields('users'); |
|
25 | +$custom = $Tools->fetch_custom_fields ('users'); |
|
26 | 26 | # fetch all languages |
27 | 27 | $langs = $Admin->fetch_all_objects ("lang", "l_id"); |
28 | 28 | # fetch all auth types |
29 | 29 | $auth_types = $Admin->fetch_all_objects ("usersAuthMethod", "id"); |
30 | 30 | # fetch all groups |
31 | -$groups = $Admin->fetch_all_objects ("userGroups", "g_id"); |
|
31 | +$groups = $Admin->fetch_all_objects ("userGroups", "g_id"); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | # set header parameters and fetch user |
35 | -if($_POST['action']!="add") { |
|
35 | +if ($_POST['action'] != "add") { |
|
36 | 36 | $user = $Admin->fetch_object ("users", "id", $_POST['id']); |
37 | 37 | //false |
38 | - if($user===false) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
38 | + if ($user === false) { $Result->show ("danger", _ ("Invalid ID"), true, true); } |
|
39 | 39 | else { |
40 | 40 | $user = (array) $user; |
41 | 41 | } |
42 | 42 | } |
43 | 43 | else { |
44 | - $user = array(); |
|
44 | + $user = array (); |
|
45 | 45 | //set default lang |
46 | - $user['lang']=$User->settings->defaultLang; |
|
46 | + $user['lang'] = $User->settings->defaultLang; |
|
47 | 47 | } |
48 | 48 | ?> |
49 | 49 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | |
67 | 67 | <!-- header --> |
68 | -<div class="pHeader"><?php print ucwords($_POST['action'])." "._('user'); ?></div> |
|
68 | +<div class="pHeader"><?php print ucwords ($_POST['action'])." "._ ('user'); ?></div> |
|
69 | 69 | |
70 | 70 | |
71 | 71 | <!-- content --> |
@@ -77,35 +77,35 @@ discard block |
||
77 | 77 | <tbody> |
78 | 78 | <!-- real name --> |
79 | 79 | <tr> |
80 | - <td><?php print _('Real name'); ?></td> |
|
80 | + <td><?php print _ ('Real name'); ?></td> |
|
81 | 81 | <td><input type="text" class="form-control input-sm" name="real_name" value="<?php print @$user['real_name']; ?>"></td> |
82 | - <td class="info2"><?php print _('Enter users real name'); ?></td> |
|
82 | + <td class="info2"><?php print _ ('Enter users real name'); ?></td> |
|
83 | 83 | </tr> |
84 | 84 | |
85 | 85 | <!-- username --> |
86 | 86 | <tr> |
87 | - <td><?php print _('Username'); ?></td> |
|
88 | - <td><input type="text" class="form-control input-sm" name="username" value="<?php print @$user['username']; ?>" <?php if($_POST['action']=="edit"||$_POST['action']=="delete") print 'readonly'; ?>></td> |
|
87 | + <td><?php print _ ('Username'); ?></td> |
|
88 | + <td><input type="text" class="form-control input-sm" name="username" value="<?php print @$user['username']; ?>" <?php if ($_POST['action'] == "edit" || $_POST['action'] == "delete") print 'readonly'; ?>></td> |
|
89 | 89 | <td class="info2"> |
90 | 90 | <a class='btn btn-xs btn-default adsearchuser' rel='tooltip' title='Search AD for user details'><i class='fa fa-search'></i></a> |
91 | - <?php print _('Enter username'); ?> |
|
91 | + <?php print _ ('Enter username'); ?> |
|
92 | 92 | </td> |
93 | 93 | </tr> |
94 | 94 | |
95 | 95 | <!-- email --> |
96 | 96 | <tr> |
97 | - <td><?php print _('e-mail'); ?></td> |
|
97 | + <td><?php print _ ('e-mail'); ?></td> |
|
98 | 98 | <td><input type="text" class="form-control input-sm input-w-250" name="email" value="<?php print @$user['email']; ?>"></td> |
99 | - <td class="info2"><?php print _('Enter users email address'); ?></td> |
|
99 | + <td class="info2"><?php print _ ('Enter users email address'); ?></td> |
|
100 | 100 | </tr> |
101 | 101 | |
102 | 102 | <!-- role --> |
103 | 103 | <tr> |
104 | - <td><?php print _('User role'); ?></td> |
|
104 | + <td><?php print _ ('User role'); ?></td> |
|
105 | 105 | <td> |
106 | 106 | <select name="role" class="form-control input-sm input-w-auto"> |
107 | - <option value="Administrator" <?php if (@$user['role'] == "Administrator") print "selected"; ?>><?php print _('Administrator'); ?></option> |
|
108 | - <option value="User" <?php if (@$user['role'] == "User" || $_POST['action'] == "add") print "selected"; ?>><?php print _('Normal User'); ?></option> |
|
107 | + <option value="Administrator" <?php if (@$user['role'] == "Administrator") print "selected"; ?>><?php print _ ('Administrator'); ?></option> |
|
108 | + <option value="User" <?php if (@$user['role'] == "User" || $_POST['action'] == "add") print "selected"; ?>><?php print _ ('Normal User'); ?></option> |
|
109 | 109 | </select> |
110 | 110 | |
111 | 111 | |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
115 | 115 | |
116 | 116 | </td> |
117 | - <td class="info2"><?php print _('Select user role'); ?> |
|
117 | + <td class="info2"><?php print _ ('Select user role'); ?> |
|
118 | 118 | <ul> |
119 | - <li><?php print _('Administrator is almighty'); ?></li> |
|
120 | - <li><?php print _('Users have access defined based on groups'); ?></li> |
|
119 | + <li><?php print _ ('Administrator is almighty'); ?></li> |
|
120 | + <li><?php print _ ('Users have access defined based on groups'); ?></li> |
|
121 | 121 | </ul> |
122 | 122 | </td> |
123 | 123 | </tr> |
@@ -125,19 +125,19 @@ discard block |
||
125 | 125 | |
126 | 126 | <!-- auth type --> |
127 | 127 | <tr> |
128 | - <td><?php print _("Authentication method"); ?></td> |
|
128 | + <td><?php print _ ("Authentication method"); ?></td> |
|
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) { |
|
132 | + foreach ($auth_types as $type) { |
|
133 | 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>"; } |
|
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 | 136 | } |
137 | 137 | ?> |
138 | 138 | </select> |
139 | 139 | </td> |
140 | - <td class="info2"><?php print _("Select authentication method for user"); ?></td> |
|
140 | + <td class="info2"><?php print _ ("Select authentication method for user"); ?></td> |
|
141 | 141 | </tr> |
142 | 142 | |
143 | 143 | <tr> |
@@ -147,28 +147,28 @@ discard block |
||
147 | 147 | </tbody> |
148 | 148 | |
149 | 149 | <!-- password --> |
150 | - <tbody id="user_password" <?php if(@$user['authMethod']!="1" && isset($user['authMethod'])) print "style='display:none'"; ?>> |
|
150 | + <tbody id="user_password" <?php if (@$user['authMethod'] != "1" && isset($user['authMethod'])) print "style='display:none'"; ?>> |
|
151 | 151 | |
152 | 152 | <tr class="password"> |
153 | - <td><?php print _('Password'); ?></td> |
|
153 | + <td><?php print _ ('Password'); ?></td> |
|
154 | 154 | <td><input type="password" class="userPass form-control input-sm" name="password1"></td> |
155 | - <td class="info2"><?php print _("User's password"); ?> (<a href="#" id="randomPass"><?php print _('click to generate random'); ?>!</a>)</td> |
|
155 | + <td class="info2"><?php print _ ("User's password"); ?> (<a href="#" id="randomPass"><?php print _ ('click to generate random'); ?>!</a>)</td> |
|
156 | 156 | </tr> |
157 | 157 | |
158 | 158 | <!-- password repeat --> |
159 | 159 | <tr class="password"> |
160 | - <td><?php print _('Password'); ?></td> |
|
160 | + <td><?php print _ ('Password'); ?></td> |
|
161 | 161 | <td><input type="password" class="userPass form-control input-sm" name="password2"></td> |
162 | - <td class="info2"><?php print _('Re-type password'); ?></td> |
|
162 | + <td class="info2"><?php print _ ('Re-type password'); ?></td> |
|
163 | 163 | </tr> |
164 | 164 | |
165 | 165 | <!-- password change request --> |
166 | - <?php if($_POST['action']=="add") { ?> |
|
166 | + <?php if ($_POST['action'] == "add") { ?> |
|
167 | 167 | <tr class="password"> |
168 | 168 | <td></td> |
169 | 169 | <td class="info2" colspan="2"> |
170 | 170 | <input type="checkbox" name="passChange" value="On" checked> |
171 | - <?php print _('Require user to change password after initial login'); ?> |
|
171 | + <?php print _ ('Require user to change password after initial login'); ?> |
|
172 | 172 | </td> |
173 | 173 | </tr> |
174 | 174 | <?php } ?> |
@@ -180,55 +180,55 @@ discard block |
||
180 | 180 | <tbody> |
181 | 181 | <!-- Language --> |
182 | 182 | <tr> |
183 | - <td><?php print _('Language'); ?></td> |
|
183 | + <td><?php print _ ('Language'); ?></td> |
|
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>"; } |
|
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 | 190 | } |
191 | 191 | ?> |
192 | 192 | </select> |
193 | 193 | </td> |
194 | - <td class="info2"><?php print _('Select language'); ?></td> |
|
194 | + <td class="info2"><?php print _ ('Select language'); ?></td> |
|
195 | 195 | </tr> |
196 | 196 | |
197 | 197 | <!-- send notification mail --> |
198 | 198 | <tr> |
199 | - <td><?php print _('Notification'); ?></td> |
|
200 | - <td><input type="checkbox" name="notifyUser" value="on" <?php if($_POST['action'] == "add") { print 'checked'; } else if($_POST['action'] == "delete") { print 'disabled="disabled"';} ?>></td> |
|
201 | - <td class="info2"><?php print _('Send notification email to user with account details'); ?></td> |
|
199 | + <td><?php print _ ('Notification'); ?></td> |
|
200 | + <td><input type="checkbox" name="notifyUser" value="on" <?php if ($_POST['action'] == "add") { print 'checked'; } else if ($_POST['action'] == "delete") { print 'disabled="disabled"'; } ?>></td> |
|
201 | + <td class="info2"><?php print _ ('Send notification email to user with account details'); ?></td> |
|
202 | 202 | </tr> |
203 | 203 | </tbody> |
204 | 204 | |
205 | 205 | <!-- mailNotify --> |
206 | - <tbody id="user_notifications" <?php if(@$user['role']!="Administrator") print "style='display:none'"; ?>> |
|
206 | + <tbody id="user_notifications" <?php if (@$user['role'] != "Administrator") print "style='display:none'"; ?>> |
|
207 | 207 | <tr> |
208 | - <td><?php print _('Mail State changes'); ?></td> |
|
208 | + <td><?php print _ ('Mail State changes'); ?></td> |
|
209 | 209 | <td> |
210 | 210 | <select name="mailNotify" class="form-control input-sm input-w-auto"> |
211 | - <option value="No"><?php print _('No'); ?></option> |
|
212 | - <option value="Yes" <?php if (@$user['mailNotify'] == "Yes") print "selected='selected'"; ?>><?php print _('Yes'); ?></option> |
|
211 | + <option value="No"><?php print _ ('No'); ?></option> |
|
212 | + <option value="Yes" <?php if (@$user['mailNotify'] == "Yes") print "selected='selected'"; ?>><?php print _ ('Yes'); ?></option> |
|
213 | 213 | </select> |
214 | 214 | |
215 | 215 | |
216 | 216 | </td> |
217 | - <td class="info2"><?php print _('Select yes to receive notification change mail for State change'); ?></td> |
|
217 | + <td class="info2"><?php print _ ('Select yes to receive notification change mail for State change'); ?></td> |
|
218 | 218 | </tr> |
219 | 219 | |
220 | 220 | <!-- mailNotifyChangelog --> |
221 | 221 | <tr> |
222 | - <td><?php print _('Mail Changelog'); ?></td> |
|
222 | + <td><?php print _ ('Mail Changelog'); ?></td> |
|
223 | 223 | <td> |
224 | 224 | <select name="mailChangelog" class="form-control input-sm input-w-auto"> |
225 | - <option value="No"><?php print _('No'); ?></option> |
|
226 | - <option value="Yes" <?php if (@$user['mailChangelog'] == "Yes") print "selected='selected'"; ?>><?php print _('Yes'); ?></option> |
|
225 | + <option value="No"><?php print _ ('No'); ?></option> |
|
226 | + <option value="Yes" <?php if (@$user['mailChangelog'] == "Yes") print "selected='selected'"; ?>><?php print _ ('Yes'); ?></option> |
|
227 | 227 | </select> |
228 | 228 | |
229 | 229 | |
230 | 230 | </td> |
231 | - <td class="info2"><?php print _('Select yes to receive notification change mail for changelog'); ?></td> |
|
231 | + <td class="info2"><?php print _ ('Select yes to receive notification change mail for changelog'); ?></td> |
|
232 | 232 | </tr> |
233 | 233 | </tbody> |
234 | 234 | |
@@ -238,20 +238,20 @@ discard block |
||
238 | 238 | <td colspan="3"><hr></td> |
239 | 239 | </tr> |
240 | 240 | <tr> |
241 | - <td><?php print _('Groups'); ?></td> |
|
241 | + <td><?php print _ ('Groups'); ?></td> |
|
242 | 242 | <td class="groups"> |
243 | 243 | <?php |
244 | 244 | //print groups |
245 | - if($groups!==false) { |
|
245 | + if ($groups !== false) { |
|
246 | 246 | //set groups |
247 | - $ugroups = json_decode(@$user['groups'], true); |
|
248 | - $ugroups = $Admin->groups_parse_ids($ugroups); |
|
247 | + $ugroups = json_decode (@$user['groups'], true); |
|
248 | + $ugroups = $Admin->groups_parse_ids ($ugroups); |
|
249 | 249 | |
250 | - foreach($groups as $g) { |
|
250 | + foreach ($groups as $g) { |
|
251 | 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>"; } |
|
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 | 255 | } |
256 | 256 | else { |
257 | 257 | { print "<input type='checkbox' name='group$g->g_id'>$g->g_name<br>"; } |
@@ -259,32 +259,32 @@ discard block |
||
259 | 259 | } |
260 | 260 | } |
261 | 261 | else { |
262 | - $Result->show("danger", _("No groups configured"), false); |
|
262 | + $Result->show ("danger", _ ("No groups configured"), false); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | ?> |
266 | 266 | </td> |
267 | - <td class="info2"><?php print _('Select to which groups the user belongs to'); ?></td> |
|
267 | + <td class="info2"><?php print _ ('Select to which groups the user belongs to'); ?></td> |
|
268 | 268 | </tr> |
269 | 269 | |
270 | 270 | <!-- pdns --> |
271 | - <?php if ($User->settings->enablePowerDNS==1) { ?> |
|
271 | + <?php if ($User->settings->enablePowerDNS == 1) { ?> |
|
272 | 272 | <tbody> |
273 | 273 | <tr> |
274 | 274 | <td colspan="3"><hr></td> |
275 | 275 | </tr> |
276 | 276 | <tr> |
277 | - <td><?php print _("PowerDNS"); ?></td> |
|
277 | + <td><?php print _ ("PowerDNS"); ?></td> |
|
278 | 278 | <td> |
279 | - <input type="checkbox" class="input-switch" value="Yes" name="pdns" <?php if(@$user->pdns == "Yes") print 'checked'; ?>> |
|
279 | + <input type="checkbox" class="input-switch" value="Yes" name="pdns" <?php if (@$user->pdns == "Yes") print 'checked'; ?>> |
|
280 | 280 | </td> |
281 | - <td class="info2"><?php print _('Select to allow user to create DNS records'); ?></td> |
|
281 | + <td class="info2"><?php print _ ('Select to allow user to create DNS records'); ?></td> |
|
282 | 282 | </tr> |
283 | 283 | <?php } ?> |
284 | 284 | |
285 | 285 | <!-- Custom --> |
286 | 286 | <?php |
287 | - if(sizeof($custom) > 0) { |
|
287 | + if (sizeof ($custom) > 0) { |
|
288 | 288 | print '<tr>'; |
289 | 289 | print ' <td colspan="3"><hr></td>'; |
290 | 290 | print '</tr>'; |
@@ -293,39 +293,39 @@ discard block |
||
293 | 293 | $timeP = 0; |
294 | 294 | |
295 | 295 | # all my fields |
296 | - foreach($custom as $field) { |
|
296 | + foreach ($custom as $field) { |
|
297 | 297 | # replace spaces with | |
298 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
298 | + $field['nameNew'] = str_replace (" ", "___", $field['name']); |
|
299 | 299 | |
300 | 300 | # required |
301 | - if($field['Null']=="NO") { $required = "*"; } |
|
302 | - else { $required = ""; } |
|
301 | + if ($field['Null'] == "NO") { $required = "*"; } |
|
302 | + else { $required = ""; } |
|
303 | 303 | |
304 | 304 | # set default value ! |
305 | - if ($_POST['action']=="add") { $user[$field['name']] = $field['Default']; } |
|
305 | + if ($_POST['action'] == "add") { $user[$field['name']] = $field['Default']; } |
|
306 | 306 | |
307 | - print '<tr>'. "\n"; |
|
308 | - print ' <td>'. $field['name'] .' '.$required.'</td>'. "\n"; |
|
309 | - print ' <td>'. "\n"; |
|
307 | + print '<tr>'."\n"; |
|
308 | + print ' <td>'.$field['name'].' '.$required.'</td>'."\n"; |
|
309 | + print ' <td>'."\n"; |
|
310 | 310 | |
311 | 311 | //set type |
312 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
312 | + if (substr ($field['type'], 0, 3) == "set" || substr ($field['type'], 0, 4) == "enum") { |
|
313 | 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'])); |
|
314 | + $tmp = substr ($field['type'], 0, 3) == "set" ? explode (",", str_replace (array ("set(", ")", "'"), "", $field['type'])) : explode (",", str_replace (array ("enum(", ")", "'"), "", $field['type'])); |
|
315 | 315 | //null |
316 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
316 | + if ($field['Null'] != "NO") { array_unshift ($tmp, ""); } |
|
317 | 317 | |
318 | 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>"; } |
|
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 | 322 | } |
323 | 323 | print "</select>"; |
324 | 324 | } |
325 | 325 | //date and time picker |
326 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
326 | + elseif ($field['type'] == "date" || $field['type'] == "datetime") { |
|
327 | 327 | // just for first |
328 | - if($timeP==0) { |
|
328 | + if ($timeP == 0) { |
|
329 | 329 | print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
330 | 330 | print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
331 | 331 | print '<script type="text/javascript">'; |
@@ -341,39 +341,39 @@ discard block |
||
341 | 341 | $timeP++; |
342 | 342 | |
343 | 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"; } |
|
344 | + if ($field['type'] == "date") { $size = 10; $class = 'datepicker'; $format = "yyyy-MM-dd"; } |
|
345 | + else { $size = 19; $class = 'datetimepicker'; $format = "yyyy-MM-dd"; } |
|
346 | 346 | |
347 | 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"; } |
|
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 | 350 | } |
351 | 351 | //boolean |
352 | - elseif($field['type'] == "tinyint(1)") { |
|
352 | + elseif ($field['type'] == "tinyint(1)") { |
|
353 | 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"); |
|
354 | + $tmp = array (0=>"No", 1=>"Yes"); |
|
355 | 355 | //null |
356 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
356 | + if ($field['Null'] != "NO") { $tmp[2] = ""; } |
|
357 | 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>"; } |
|
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 | 362 | } |
363 | 363 | print "</select>"; |
364 | 364 | } |
365 | 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"; |
|
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 | 368 | } |
369 | 369 | //default - input field |
370 | 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"; |
|
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 | 372 | } |
373 | 373 | |
374 | 374 | print " <td class='info2'>".$field['Comment']."</td>"; |
375 | - print ' </td>'. "\n"; |
|
376 | - print '</tr>'. "\n"; |
|
375 | + print ' </td>'."\n"; |
|
376 | + print '</tr>'."\n"; |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | ?> |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | <!-- footer --> |
390 | 390 | <div class="pFooter"> |
391 | 391 | <div class="btn-group"> |
392 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
393 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editUserSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
392 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
393 | + <button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editUserSubmit"><i class="fa <?php if ($_POST['action'] == "add") { print "fa-plus"; } else if ($_POST['action'] == "delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords (_ ($_POST['action'])); ?></button> |
|
394 | 394 | </div> |
395 | 395 | |
396 | 396 | <!-- Result --> |
@@ -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> |
@@ -112,7 +112,7 @@ |
||
112 | 112 | $html_custom[] = " <th>$key</th>"; |
113 | 113 | $html_custom[] = " <td>"; |
114 | 114 | #booleans |
115 | - if($field['type']=="tinyint(1)") { |
|
115 | + if($field['type']=="tinyint(1)") { |
|
116 | 116 | if($subnet[$key] == "0") { $html_custom[] = _("No"); } |
117 | 117 | elseif($subnet[$key] == "1") { $html_custom[] = _("Yes"); } |
118 | 118 | } |
@@ -5,24 +5,24 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # fetch all APIs |
11 | -$users = $Admin->fetch_all_objects("users", "username"); |
|
11 | +$users = $Admin->fetch_all_objects ("users", "username"); |
|
12 | 12 | # fetch custom fields |
13 | -$custom = $Tools->fetch_custom_fields('users'); |
|
13 | +$custom = $Tools->fetch_custom_fields ('users'); |
|
14 | 14 | |
15 | 15 | /* check customfields */ |
16 | -$ffields = json_decode($User->settings->hiddenCustomFields, true); |
|
17 | -$ffields = is_array(@$ffields['users']) ? $ffields['users'] : array(); |
|
16 | +$ffields = json_decode ($User->settings->hiddenCustomFields, true); |
|
17 | +$ffields = is_array (@$ffields['users']) ? $ffields['users'] : array (); |
|
18 | 18 | ?> |
19 | 19 | |
20 | 20 | <!-- display existing users --> |
21 | -<h4><?php print _('User management'); ?></h4> |
|
21 | +<h4><?php print _ ('User management'); ?></h4> |
|
22 | 22 | <hr><br> |
23 | 23 | |
24 | 24 | <!-- Add new --> |
25 | -<button class='btn btn-sm btn-default editUser' style="margin-bottom:10px;" data-action='add'><i class='fa fa-plus'></i> <?php print _('Create user'); ?></button> |
|
25 | +<button class='btn btn-sm btn-default editUser' style="margin-bottom:10px;" data-action='add'><i class='fa fa-plus'></i> <?php print _ ('Create user'); ?></button> |
|
26 | 26 | |
27 | 27 | <!-- table --> |
28 | 28 | <table id="userPrint1" class="table sorted table-striped table-top"> |
@@ -31,19 +31,19 @@ discard block |
||
31 | 31 | <thead> |
32 | 32 | <tr> |
33 | 33 | <th></th> |
34 | - <th><?php print _('Real Name'); ?></th> |
|
35 | - <th><?php print _('Username'); ?></th> |
|
36 | - <th><?php print _('E-mail'); ?></th> |
|
37 | - <th><?php print _('Role'); ?></th> |
|
38 | - <th><?php print _('Language'); ?></th> |
|
39 | - <th><?php print _('Authentication'); ?></th> |
|
40 | - <th><?php print _('PowerDNS'); ?></th> |
|
41 | - <th><?php print _('Groups'); ?></th> |
|
42 | - <th><?php print _('Last login'); ?></th> |
|
34 | + <th><?php print _ ('Real Name'); ?></th> |
|
35 | + <th><?php print _ ('Username'); ?></th> |
|
36 | + <th><?php print _ ('E-mail'); ?></th> |
|
37 | + <th><?php print _ ('Role'); ?></th> |
|
38 | + <th><?php print _ ('Language'); ?></th> |
|
39 | + <th><?php print _ ('Authentication'); ?></th> |
|
40 | + <th><?php print _ ('PowerDNS'); ?></th> |
|
41 | + <th><?php print _ ('Groups'); ?></th> |
|
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)) { |
|
44 | + if (sizeof (@$custom) > 0) { |
|
45 | + foreach ($custom as $field) { |
|
46 | + if (!in_array ($field['name'], $ffields)) { |
|
47 | 47 | print "<th>$field[name]</th>"; |
48 | 48 | } |
49 | 49 | } |
@@ -59,21 +59,21 @@ discard block |
||
59 | 59 | foreach ($users as $user) { |
60 | 60 | //cast |
61 | 61 | $user = (array) $user; |
62 | - print '<tr>' . "\n"; |
|
62 | + print '<tr>'."\n"; |
|
63 | 63 | |
64 | 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"; } |
|
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 | 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"; |
|
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 | 72 | |
73 | 73 | # language |
74 | - if(strlen($user['lang'])>0) { |
|
74 | + if (strlen ($user['lang']) > 0) { |
|
75 | 75 | # get lang name |
76 | - $lname = $Admin->fetch_object("lang", "l_id", $user['lang']); |
|
76 | + $lname = $Admin->fetch_object ("lang", "l_id", $user['lang']); |
|
77 | 77 | print "<td>$lname->l_name</td>"; |
78 | 78 | } |
79 | 79 | else { |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | # check users auth method |
84 | - $auth_method = $Admin->fetch_object("usersAuthMethod", "id", $user['authMethod']); |
|
84 | + $auth_method = $Admin->fetch_object ("usersAuthMethod", "id", $user['authMethod']); |
|
85 | 85 | //false |
86 | 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>)"; } |
|
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 | 89 | print "</span></td>"; |
90 | 90 | |
91 | 91 | # powerDNS |
@@ -94,44 +94,44 @@ discard block |
||
94 | 94 | print "</td>"; |
95 | 95 | |
96 | 96 | # groups |
97 | - if($user['role'] == "Administrator") { |
|
98 | - print ' <td>'._('All groups').'</td>'. "\n"; |
|
97 | + if ($user['role'] == "Administrator") { |
|
98 | + print ' <td>'._ ('All groups').'</td>'."\n"; |
|
99 | 99 | } |
100 | 100 | else { |
101 | - $groups = json_decode($user['groups'], true); |
|
102 | - $gr = $Admin->groups_parse($groups); |
|
101 | + $groups = json_decode ($user['groups'], true); |
|
102 | + $gr = $Admin->groups_parse ($groups); |
|
103 | 103 | |
104 | 104 | print ' <td>'; |
105 | - if(sizeof($gr)>0) { |
|
106 | - foreach($gr as $group) { |
|
105 | + if (sizeof ($gr) > 0) { |
|
106 | + foreach ($gr as $group) { |
|
107 | 107 | print $group['g_name']."<br>"; |
108 | 108 | } |
109 | 109 | } |
110 | 110 | else { |
111 | 111 | print "<span class='text-muted'>No groups</span>"; |
112 | 112 | } |
113 | - print ' </td>'. "\n"; |
|
113 | + print ' </td>'."\n"; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | # last login |
117 | 117 | print "<td>"; |
118 | - print strlen($user['lastLogin'])>0 ? $user['lastLogin'] : "<span class='text-muted'>"._("Never")."</span>"; |
|
118 | + print strlen ($user['lastLogin']) > 0 ? $user['lastLogin'] : "<span class='text-muted'>"._ ("Never")."</span>"; |
|
119 | 119 | print "</td>"; |
120 | 120 | |
121 | 121 | # custom |
122 | - if(sizeof($custom) > 0) { |
|
123 | - foreach($custom as $field) { |
|
124 | - if(!in_array($field['name'], $ffields)) { |
|
122 | + if (sizeof ($custom) > 0) { |
|
123 | + foreach ($custom as $field) { |
|
124 | + if (!in_array ($field['name'], $ffields)) { |
|
125 | 125 | print "<td>"; |
126 | 126 | //booleans |
127 | - if($field['type']=="tinyint(1)") { |
|
128 | - if($user[$field['name']] == "0") { print _("No"); } |
|
129 | - elseif($user[$field['name']] == "1") { print _("Yes"); } |
|
127 | + if ($field['type'] == "tinyint(1)") { |
|
128 | + if ($user[$field['name']] == "0") { print _ ("No"); } |
|
129 | + elseif ($user[$field['name']] == "1") { print _ ("Yes"); } |
|
130 | 130 | } |
131 | 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 ""; } |
|
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 | 135 | } |
136 | 136 | else { |
137 | 137 | print $user[$field['name']]; |
@@ -145,16 +145,16 @@ discard block |
||
145 | 145 | # edit, delete |
146 | 146 | print " <td class='actions'>"; |
147 | 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>"; |
|
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 | 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 | 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>"; |
|
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 | 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 | 154 | print " </div>"; |
155 | 155 | print " </td>"; |
156 | 156 | |
157 | - print '</tr>' . "\n"; |
|
157 | + print '</tr>'."\n"; |
|
158 | 158 | } |
159 | 159 | ?> |
160 | 160 | </tbody> |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | <div class="alert alert-info alert-absolute"> |
164 | 164 | <ul> |
165 | - <li><?php print _('Administrator users will be able to view and edit all sections and subnets'); ?></li> |
|
166 | - <li><?php print _('Normal users will have permissions set based on group access to sections and subnets'); ?></li> |
|
165 | + <li><?php print _ ('Administrator users will be able to view and edit all sections and subnets'); ?></li> |
|
166 | + <li><?php print _ ('Normal users will have permissions set based on group access to sections and subnets'); ?></li> |
|
167 | 167 | </ul> |
168 | 168 | </div> |