@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | |
66 | 66 | |
67 | 67 | # all devices |
68 | - $devices = $Admin->fetch_all_objects("devices", "id"); |
|
69 | - if ($devices!==false) { |
|
70 | - foreach($devices as $k=>$d) { |
|
71 | - if (strlen($d->rack)!=0) { |
|
72 | - unset($devices[$k]); |
|
73 | - } |
|
74 | - } |
|
75 | - } |
|
68 | + $devices = $Admin->fetch_all_objects("devices", "id"); |
|
69 | + if ($devices!==false) { |
|
70 | + foreach($devices as $k=>$d) { |
|
71 | + if (strlen($d->rack)!=0) { |
|
72 | + unset($devices[$k]); |
|
73 | + } |
|
74 | + } |
|
75 | + } |
|
76 | 76 | ?> |
77 | 77 | |
78 | 78 | <script type="text/javascript"> |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | <td> |
104 | 104 | <select name="deviceid" class="form-control input-sm input-w-auto"> |
105 | 105 | <?php |
106 | - foreach($devices as $d) { |
|
106 | + foreach($devices as $d) { |
|
107 | 107 | print "<option value='$d->id' >$d->hostname</option>"; |
108 | 108 | } |
109 | - ?> |
|
109 | + ?> |
|
110 | 110 | </select> |
111 | 111 | </td> |
112 | 112 | </tr> |
@@ -46,31 +46,31 @@ discard block |
||
46 | 46 | # fetch custom fields |
47 | 47 | $custom = $Tools->fetch_custom_fields('racks'); |
48 | 48 | if(sizeof($custom) > 0) { |
49 | - foreach($custom as $myField) { |
|
50 | - //booleans can be only 0 and 1! |
|
51 | - if($myField['type']=="tinyint(1)") { |
|
52 | - if($rack[$myField['name']]>1) { |
|
53 | - $rack[$myField['name']] = 0; |
|
54 | - } |
|
55 | - } |
|
56 | - //not null! |
|
57 | - if($myField['Null']=="NO" && strlen($rack[$myField['name']])==0) { |
|
58 | - { $Result->show("danger", $myField['name'].'" can not be empty!', true); } |
|
59 | - } |
|
60 | - # save to update array |
|
61 | - $update[$myField['name']] = $rack[$myField['name']]; |
|
62 | - } |
|
49 | + foreach($custom as $myField) { |
|
50 | + //booleans can be only 0 and 1! |
|
51 | + if($myField['type']=="tinyint(1)") { |
|
52 | + if($rack[$myField['name']]>1) { |
|
53 | + $rack[$myField['name']] = 0; |
|
54 | + } |
|
55 | + } |
|
56 | + //not null! |
|
57 | + if($myField['Null']=="NO" && strlen($rack[$myField['name']])==0) { |
|
58 | + { $Result->show("danger", $myField['name'].'" can not be empty!', true); } |
|
59 | + } |
|
60 | + # save to update array |
|
61 | + $update[$myField['name']] = $rack[$myField['name']]; |
|
62 | + } |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | # set update values |
66 | 66 | $values = array("id"=>@$rack['rackid'], |
67 | - "name"=>@$rack['name'], |
|
68 | - "size"=>@$rack['size'], |
|
69 | - "description"=>@$rack['description'] |
|
70 | - ); |
|
67 | + "name"=>@$rack['name'], |
|
68 | + "size"=>@$rack['size'], |
|
69 | + "description"=>@$rack['description'] |
|
70 | + ); |
|
71 | 71 | # custom fields |
72 | 72 | if(isset($update)) { |
73 | - $values = array_merge($values, $update); |
|
73 | + $values = array_merge($values, $update); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | # update rack |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | else { $Result->show("success", _("Rack $rack[action] successfull").'!', false); } |
79 | 79 | |
80 | 80 | if($_POST['action']=="delete"){ |
81 | - # remove all references from subnets and ip addresses |
|
82 | - $Admin->remove_object_references ("devices", "rack", $values["id"]); |
|
81 | + # remove all references from subnets and ip addresses |
|
82 | + $Admin->remove_object_references ("devices", "rack", $values["id"]); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | ?> |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | # fetch device details |
31 | 31 | if( ($_POST['action'] == "edit") || ($_POST['action'] == "delete") ) { |
32 | - $rack = $Admin->fetch_object("racks", "id", $_POST['rackid']); |
|
32 | + $rack = $Admin->fetch_object("racks", "id", $_POST['rackid']); |
|
33 | 33 | } |
34 | 34 | else { |
35 | 35 | $rack = new StdClass (); |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | <td> |
71 | 71 | <select name="size" class="form-control input-sm input-w-auto"> |
72 | 72 | <?php |
73 | - foreach($Racks->rack_sizes as $s) { |
|
74 | - if($rack->size == $s) { print "<option value='$s' selected='selected'>$s U</option>"; } |
|
75 | - else { print "<option value='$s' >$s U</option>"; } |
|
76 | - } |
|
77 | - ?> |
|
73 | + foreach($Racks->rack_sizes as $s) { |
|
74 | + if($rack->size == $s) { print "<option value='$s' selected='selected'>$s U</option>"; } |
|
75 | + else { print "<option value='$s' >$s U</option>"; } |
|
76 | + } |
|
77 | + ?> |
|
78 | 78 | </select> |
79 | 79 | </td> |
80 | 80 | </tr> |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | <td> |
86 | 86 | <textarea name="description" class="form-control input-sm" placeholder="<?php print _('Description'); ?>" <?php print $readonly; ?>><?php if(isset($rack->description)) print $rack->description; ?></textarea> |
87 | 87 | <?php |
88 | - if( ($_POST['action'] == "edit") || ($_POST['action'] == "delete") ) { |
|
89 | - print '<input type="hidden" name="rackid" value="'. $_POST['rackid'] .'">'. "\n"; |
|
90 | - } ?> |
|
88 | + if( ($_POST['action'] == "edit") || ($_POST['action'] == "delete") ) { |
|
89 | + print '<input type="hidden" name="rackid" value="'. $_POST['rackid'] .'">'. "\n"; |
|
90 | + } ?> |
|
91 | 91 | <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
92 | 92 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
93 | 93 | </td> |
@@ -95,101 +95,101 @@ discard block |
||
95 | 95 | |
96 | 96 | <!-- Custom --> |
97 | 97 | <?php |
98 | - if(sizeof($custom) > 0) { |
|
99 | - |
|
100 | - print '<tr>'; |
|
101 | - print ' <td colspan="2"><hr></td>'; |
|
102 | - print '</tr>'; |
|
103 | - |
|
104 | - # count datepickers |
|
105 | - $timeP = 0; |
|
106 | - |
|
107 | - # all my fields |
|
108 | - foreach($custom as $field) { |
|
109 | - # replace spaces with | |
|
110 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
111 | - |
|
112 | - # required |
|
113 | - if($field['Null']=="NO") { $required = "*"; } |
|
114 | - else { $required = ""; } |
|
115 | - |
|
116 | - # set default value ! |
|
117 | - if ($_POST['action']=="add") { $rack->$field['name'] = $field['Default']; } |
|
118 | - |
|
119 | - print '<tr>'. "\n"; |
|
120 | - print ' <td>'. ucwords($field['name']) .' '.$required.'</td>'. "\n"; |
|
121 | - print ' <td>'. "\n"; |
|
122 | - |
|
123 | - //set type |
|
124 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
125 | - //parse values |
|
126 | - $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
127 | - //null |
|
128 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
129 | - |
|
130 | - print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
131 | - foreach($tmp as $v) { |
|
132 | - if($v==$rack->$field['name']) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
133 | - else { print "<option value='$v'>$v</option>"; } |
|
134 | - } |
|
135 | - print "</select>"; |
|
136 | - } |
|
137 | - //date and time picker |
|
138 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
139 | - // just for first |
|
140 | - if($timeP==0) { |
|
141 | - print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
142 | - print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
143 | - print '<script type="text/javascript">'; |
|
144 | - print '$(document).ready(function() {'; |
|
145 | - //date only |
|
146 | - print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
147 | - //date + time |
|
148 | - print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
149 | - |
|
150 | - print '})'; |
|
151 | - print '</script>'; |
|
152 | - } |
|
153 | - $timeP++; |
|
154 | - |
|
155 | - //set size |
|
156 | - if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
157 | - else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
158 | - |
|
159 | - //field |
|
160 | - if(!isset($rack->$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"; } |
|
161 | - else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $rack->$field['name']. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
162 | - } |
|
163 | - //boolean |
|
164 | - elseif($field['type'] == "tinyint(1)") { |
|
165 | - print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
166 | - $tmp = array(0=>"No",1=>"Yes"); |
|
167 | - //null |
|
168 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
169 | - |
|
170 | - foreach($tmp as $k=>$v) { |
|
171 | - if(strlen($rack->$field['name'])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
172 | - elseif($k==$rack->$field['name']) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
173 | - else { print "<option value='$k'>"._($v)."</option>"; } |
|
174 | - } |
|
175 | - print "</select>"; |
|
176 | - } |
|
177 | - //text |
|
178 | - elseif($field['type'] == "text") { |
|
179 | - print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. $rack->$field['name']. '</textarea>'. "\n"; |
|
180 | - } |
|
181 | - //default - input field |
|
182 | - else { |
|
183 | - print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. $rack->$field['name']. '" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
184 | - } |
|
185 | - |
|
186 | - print ' </td>'. "\n"; |
|
187 | - print '</tr>'. "\n"; |
|
188 | - } |
|
189 | - |
|
190 | - } |
|
191 | - |
|
192 | - ?> |
|
98 | + if(sizeof($custom) > 0) { |
|
99 | + |
|
100 | + print '<tr>'; |
|
101 | + print ' <td colspan="2"><hr></td>'; |
|
102 | + print '</tr>'; |
|
103 | + |
|
104 | + # count datepickers |
|
105 | + $timeP = 0; |
|
106 | + |
|
107 | + # all my fields |
|
108 | + foreach($custom as $field) { |
|
109 | + # replace spaces with | |
|
110 | + $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
111 | + |
|
112 | + # required |
|
113 | + if($field['Null']=="NO") { $required = "*"; } |
|
114 | + else { $required = ""; } |
|
115 | + |
|
116 | + # set default value ! |
|
117 | + if ($_POST['action']=="add") { $rack->$field['name'] = $field['Default']; } |
|
118 | + |
|
119 | + print '<tr>'. "\n"; |
|
120 | + print ' <td>'. ucwords($field['name']) .' '.$required.'</td>'. "\n"; |
|
121 | + print ' <td>'. "\n"; |
|
122 | + |
|
123 | + //set type |
|
124 | + if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
125 | + //parse values |
|
126 | + $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
127 | + //null |
|
128 | + if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
129 | + |
|
130 | + print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
131 | + foreach($tmp as $v) { |
|
132 | + if($v==$rack->$field['name']) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
133 | + else { print "<option value='$v'>$v</option>"; } |
|
134 | + } |
|
135 | + print "</select>"; |
|
136 | + } |
|
137 | + //date and time picker |
|
138 | + elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
139 | + // just for first |
|
140 | + if($timeP==0) { |
|
141 | + print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
142 | + print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
143 | + print '<script type="text/javascript">'; |
|
144 | + print '$(document).ready(function() {'; |
|
145 | + //date only |
|
146 | + print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
147 | + //date + time |
|
148 | + print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
149 | + |
|
150 | + print '})'; |
|
151 | + print '</script>'; |
|
152 | + } |
|
153 | + $timeP++; |
|
154 | + |
|
155 | + //set size |
|
156 | + if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
157 | + else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
158 | + |
|
159 | + //field |
|
160 | + if(!isset($rack->$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"; } |
|
161 | + else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $rack->$field['name']. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
162 | + } |
|
163 | + //boolean |
|
164 | + elseif($field['type'] == "tinyint(1)") { |
|
165 | + print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
166 | + $tmp = array(0=>"No",1=>"Yes"); |
|
167 | + //null |
|
168 | + if($field['Null']!="NO") { $tmp[2] = ""; } |
|
169 | + |
|
170 | + foreach($tmp as $k=>$v) { |
|
171 | + if(strlen($rack->$field['name'])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
172 | + elseif($k==$rack->$field['name']) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
173 | + else { print "<option value='$k'>"._($v)."</option>"; } |
|
174 | + } |
|
175 | + print "</select>"; |
|
176 | + } |
|
177 | + //text |
|
178 | + elseif($field['type'] == "text") { |
|
179 | + print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. $rack->$field['name']. '</textarea>'. "\n"; |
|
180 | + } |
|
181 | + //default - input field |
|
182 | + else { |
|
183 | + print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. $rack->$field['name']. '" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
184 | + } |
|
185 | + |
|
186 | + print ' </td>'. "\n"; |
|
187 | + print '</tr>'. "\n"; |
|
188 | + } |
|
189 | + |
|
190 | + } |
|
191 | + |
|
192 | + ?> |
|
193 | 193 | |
194 | 194 | </table> |
195 | 195 | </form> |
@@ -22,87 +22,87 @@ discard block |
||
22 | 22 | |
23 | 23 | |
24 | 24 | <?php |
25 | - /* print existing APIs */ |
|
26 | - if($all_apis!==false) { |
|
27 | - |
|
28 | - print '<table id="userPrint" class="table table-striped table-top table-auto">'; |
|
29 | - # headers |
|
30 | - print '<tr>'; |
|
31 | - print "<th>"._('App id').'</th>'; |
|
32 | - print "<th>"._('App code').'</th>'; |
|
33 | - print "<th>"._('App permissions').'</th>'; |
|
34 | - print "<th>"._('App security').'</th>'; |
|
35 | - print "<th>"._('Comment').'</th>'; |
|
36 | - print '<th></th>'; |
|
37 | - print '</tr>'; |
|
38 | - |
|
39 | - # loop |
|
40 | - foreach ($all_apis as $a) { |
|
41 | - # cast |
|
42 | - $a = (array) $a; |
|
43 | - |
|
44 | - # hide key if not crpt |
|
45 | - if($a['app_security']!="crypt") { $a['app_code']="<span class='text-muted'>"._('Not used')."</span>"; } |
|
46 | - if($a['app_security']=="ssl") { $a['app_security'] = "SSL"; } |
|
47 | - |
|
48 | - print '<tr>' . "\n"; |
|
49 | - |
|
50 | - print ' <td>' . $a['app_id'] . '</td>'. "\n"; |
|
51 | - print ' <td>' . $a['app_code'] . '</td>'. "\n"; |
|
52 | - |
|
53 | - # reformat permissions |
|
54 | - if($a['app_permissions']==0) { $a['app_permissions'] = _("Disabled"); } |
|
55 | - elseif($a['app_permissions']==1) { $a['app_permissions'] = _("Read"); } |
|
56 | - elseif($a['app_permissions']==2) { $a['app_permissions'] = _("Read / Write"); } |
|
57 | - elseif($a['app_permissions']==3) { $a['app_permissions'] = _("Read / Write / Admin"); } |
|
58 | - |
|
59 | - # override permissions if user |
|
60 | - if($a['app_security']=="user") { $a['app_permissions']="<span class='text-muted'>"._('Per user')."</span>"; } |
|
61 | - |
|
62 | - print ' <td>' . $a['app_permissions'] . '</td>'. "\n"; |
|
63 | - print ' <td>' . ucwords($a['app_security']) . '</td>'. "\n"; |
|
64 | - print ' <td>' . $a['app_comment'] . '</td>'. "\n"; |
|
65 | - |
|
66 | - # add/remove APIs |
|
67 | - print " <td class='actions'>"; |
|
68 | - print " <div class='btn-group'>"; |
|
69 | - print " <button class='btn btn-xs btn-default editAPI' data-container='body' data-appid='$a[id]' data-action='edit' rel='tooltip' title='"._('edit app details')."'> <i class='fa fa-pencil'></i></button>"; |
|
70 | - print " <button class='btn btn-xs btn-default editAPI' data-container='body' data-appid='$a[id]' data-action='delete' rel='tooltip' title='"._('remove app')."'> <i class='fa fa-times'></i></button>"; |
|
71 | - print " </div>"; |
|
72 | - print "</td>"; |
|
73 | - |
|
74 | - print '</tr>' . "\n"; |
|
75 | - } |
|
76 | - print "</table>"; |
|
77 | - } |
|
78 | - else { |
|
79 | - $Result->show("info alert-nomargin", _("No Apps available")."!", false); |
|
80 | - } |
|
81 | - ?> |
|
25 | + /* print existing APIs */ |
|
26 | + if($all_apis!==false) { |
|
27 | + |
|
28 | + print '<table id="userPrint" class="table table-striped table-top table-auto">'; |
|
29 | + # headers |
|
30 | + print '<tr>'; |
|
31 | + print "<th>"._('App id').'</th>'; |
|
32 | + print "<th>"._('App code').'</th>'; |
|
33 | + print "<th>"._('App permissions').'</th>'; |
|
34 | + print "<th>"._('App security').'</th>'; |
|
35 | + print "<th>"._('Comment').'</th>'; |
|
36 | + print '<th></th>'; |
|
37 | + print '</tr>'; |
|
38 | + |
|
39 | + # loop |
|
40 | + foreach ($all_apis as $a) { |
|
41 | + # cast |
|
42 | + $a = (array) $a; |
|
43 | + |
|
44 | + # hide key if not crpt |
|
45 | + if($a['app_security']!="crypt") { $a['app_code']="<span class='text-muted'>"._('Not used')."</span>"; } |
|
46 | + if($a['app_security']=="ssl") { $a['app_security'] = "SSL"; } |
|
47 | + |
|
48 | + print '<tr>' . "\n"; |
|
49 | + |
|
50 | + print ' <td>' . $a['app_id'] . '</td>'. "\n"; |
|
51 | + print ' <td>' . $a['app_code'] . '</td>'. "\n"; |
|
52 | + |
|
53 | + # reformat permissions |
|
54 | + if($a['app_permissions']==0) { $a['app_permissions'] = _("Disabled"); } |
|
55 | + elseif($a['app_permissions']==1) { $a['app_permissions'] = _("Read"); } |
|
56 | + elseif($a['app_permissions']==2) { $a['app_permissions'] = _("Read / Write"); } |
|
57 | + elseif($a['app_permissions']==3) { $a['app_permissions'] = _("Read / Write / Admin"); } |
|
58 | + |
|
59 | + # override permissions if user |
|
60 | + if($a['app_security']=="user") { $a['app_permissions']="<span class='text-muted'>"._('Per user')."</span>"; } |
|
61 | + |
|
62 | + print ' <td>' . $a['app_permissions'] . '</td>'. "\n"; |
|
63 | + print ' <td>' . ucwords($a['app_security']) . '</td>'. "\n"; |
|
64 | + print ' <td>' . $a['app_comment'] . '</td>'. "\n"; |
|
65 | + |
|
66 | + # add/remove APIs |
|
67 | + print " <td class='actions'>"; |
|
68 | + print " <div class='btn-group'>"; |
|
69 | + print " <button class='btn btn-xs btn-default editAPI' data-container='body' data-appid='$a[id]' data-action='edit' rel='tooltip' title='"._('edit app details')."'> <i class='fa fa-pencil'></i></button>"; |
|
70 | + print " <button class='btn btn-xs btn-default editAPI' data-container='body' data-appid='$a[id]' data-action='delete' rel='tooltip' title='"._('remove app')."'> <i class='fa fa-times'></i></button>"; |
|
71 | + print " </div>"; |
|
72 | + print "</td>"; |
|
73 | + |
|
74 | + print '</tr>' . "\n"; |
|
75 | + } |
|
76 | + print "</table>"; |
|
77 | + } |
|
78 | + else { |
|
79 | + $Result->show("info alert-nomargin", _("No Apps available")."!", false); |
|
80 | + } |
|
81 | + ?> |
|
82 | 82 | |
83 | 83 | <?php |
84 | - # print error if extensions are not available on server! |
|
85 | - $requiredExt = array("mcrypt", "curl"); |
|
86 | - $availableExt = get_loaded_extensions(); |
|
87 | - # check for missing ext |
|
88 | - $missingExt = array(); |
|
89 | - foreach ($requiredExt as $extension) { |
|
90 | - if (!in_array($extension, $availableExt)) { |
|
91 | - $missingExt[] = $extension; |
|
92 | - } |
|
93 | - } |
|
94 | - # print warning if missing |
|
95 | - if (sizeof($missingExt) > 0) { |
|
96 | - print "<div class='alert alert alert-danger'><strong>"._('The following PHP extensions for API server are missing').":</strong><br><hr>"; |
|
97 | - print '<ul>' . "\n"; |
|
98 | - foreach ($missingExt as $missing) { |
|
99 | - print '<li>'. $missing .'</li>' . "\n"; |
|
100 | - } |
|
101 | - print '</ul>'; |
|
102 | - print _('Please recompile PHP to include missing extensions for API server') . "\n"; |
|
103 | - print "</div>"; |
|
104 | - } |
|
105 | - ?> |
|
84 | + # print error if extensions are not available on server! |
|
85 | + $requiredExt = array("mcrypt", "curl"); |
|
86 | + $availableExt = get_loaded_extensions(); |
|
87 | + # check for missing ext |
|
88 | + $missingExt = array(); |
|
89 | + foreach ($requiredExt as $extension) { |
|
90 | + if (!in_array($extension, $availableExt)) { |
|
91 | + $missingExt[] = $extension; |
|
92 | + } |
|
93 | + } |
|
94 | + # print warning if missing |
|
95 | + if (sizeof($missingExt) > 0) { |
|
96 | + print "<div class='alert alert alert-danger'><strong>"._('The following PHP extensions for API server are missing').":</strong><br><hr>"; |
|
97 | + print '<ul>' . "\n"; |
|
98 | + foreach ($missingExt as $missing) { |
|
99 | + print '<li>'. $missing .'</li>' . "\n"; |
|
100 | + } |
|
101 | + print '</ul>'; |
|
102 | + print _('Please recompile PHP to include missing extensions for API server') . "\n"; |
|
103 | + print "</div>"; |
|
104 | + } |
|
105 | + ?> |
|
106 | 106 | <hr> |
107 | 107 | |
108 | 108 | <h4><?php print _('API documentation'); ?></h4> |
@@ -110,6 +110,6 @@ discard block |
||
110 | 110 | |
111 | 111 | <?php |
112 | 112 | } else { |
113 | - $Result->show("info", _('Please enable API module under server management'), false); |
|
113 | + $Result->show("info", _('Please enable API module under server management'), false); |
|
114 | 114 | } |
115 | 115 | ?> |
116 | 116 | \ No newline at end of file |
@@ -26,34 +26,34 @@ |
||
26 | 26 | $error = array(); |
27 | 27 | |
28 | 28 | if($_POST['action']!="delete") { |
29 | - # code must be exactly 32 chars long and alfanumeric if app_security = crypt |
|
30 | - if($_POST['app_security']=="crypt") { |
|
31 | - if(strlen($_POST['app_code'])!=32 || !ctype_alnum($_POST['app_code'])) { $error[] = "Invalid application code"; } |
|
32 | - } |
|
33 | - # name must be more than 2 and alphanumberic |
|
34 | - if(strlen($_POST['app_id'])<3 || strlen($_POST['app_id'])>12 || !ctype_alnum($_POST['app_id'])) { $error[] = "Invalid application id"; } |
|
35 | - # permissions must be 0,1,2 |
|
36 | - if($_POST['app_security']!="user") { |
|
37 | - if(!($_POST['app_permissions']==0 || $_POST['app_permissions']==1 || $_POST['app_permissions'] ==2 || $_POST['app_permissions'] ==3 )) { $error[] = "Invalid permissions"; } |
|
38 | - } |
|
29 | + # code must be exactly 32 chars long and alfanumeric if app_security = crypt |
|
30 | + if($_POST['app_security']=="crypt") { |
|
31 | + if(strlen($_POST['app_code'])!=32 || !ctype_alnum($_POST['app_code'])) { $error[] = "Invalid application code"; } |
|
32 | + } |
|
33 | + # name must be more than 2 and alphanumberic |
|
34 | + if(strlen($_POST['app_id'])<3 || strlen($_POST['app_id'])>12 || !ctype_alnum($_POST['app_id'])) { $error[] = "Invalid application id"; } |
|
35 | + # permissions must be 0,1,2 |
|
36 | + if($_POST['app_security']!="user") { |
|
37 | + if(!($_POST['app_permissions']==0 || $_POST['app_permissions']==1 || $_POST['app_permissions'] ==2 || $_POST['app_permissions'] ==3 )) { $error[] = "Invalid permissions"; } |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | # die if errors |
42 | 42 | if(sizeof($error) > 0) { |
43 | - $Result->show("danger", $error, true); |
|
43 | + $Result->show("danger", $error, true); |
|
44 | 44 | } |
45 | 45 | else { |
46 | - # create array of values for modification |
|
47 | - $values = array("id"=>@$_POST['id'], |
|
48 | - "app_id"=>$_POST['app_id'], |
|
49 | - "app_code"=>@$_POST['app_code'], |
|
50 | - "app_permissions"=>@$_POST['app_permissions'], |
|
51 | - "app_security"=>@$_POST['app_security'], |
|
52 | - "app_comment"=>@$_POST['app_comment']); |
|
53 | - |
|
54 | - # execute |
|
55 | - if(!$Admin->object_modify("api", $_POST['action'], "id", $values)) { $Result->show("danger", _("API $_POST[action] error"), true); } |
|
56 | - else { $Result->show("success", _("API $_POST[action] success"), true); } |
|
46 | + # create array of values for modification |
|
47 | + $values = array("id"=>@$_POST['id'], |
|
48 | + "app_id"=>$_POST['app_id'], |
|
49 | + "app_code"=>@$_POST['app_code'], |
|
50 | + "app_permissions"=>@$_POST['app_permissions'], |
|
51 | + "app_security"=>@$_POST['app_security'], |
|
52 | + "app_comment"=>@$_POST['app_comment']); |
|
53 | + |
|
54 | + # execute |
|
55 | + if(!$Admin->object_modify("api", $_POST['action'], "id", $values)) { $Result->show("danger", _("API $_POST[action] error"), true); } |
|
56 | + else { $Result->show("success", _("API $_POST[action] success"), true); } |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | ?> |
60 | 60 | \ No newline at end of file |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | |
25 | 25 | # fetch api for edit / add |
26 | 26 | if($_POST['action']!="add") { |
27 | - # fetch api details |
|
28 | - $api = $Admin->fetch_object ("api", "id", $_POST['appid']); |
|
29 | - # null ? |
|
30 | - $api===false ? $Result->show("danger", _("Invalid ID"), true) : null; |
|
31 | - # title |
|
32 | - $title = ucwords($_POST['action']) .' '._('api').' '.$api->app_id; |
|
27 | + # fetch api details |
|
28 | + $api = $Admin->fetch_object ("api", "id", $_POST['appid']); |
|
29 | + # null ? |
|
30 | + $api===false ? $Result->show("danger", _("Invalid ID"), true) : null; |
|
31 | + # title |
|
32 | + $title = ucwords($_POST['action']) .' '._('api').' '.$api->app_id; |
|
33 | 33 | } else { |
34 | - # generate new code |
|
35 | - $api = new StdClass; |
|
36 | - $api->app_code = str_shuffle(md5(microtime())); |
|
37 | - # title |
|
38 | - $title = _('Add new api key'); |
|
34 | + # generate new code |
|
35 | + $api = new StdClass; |
|
36 | + $api->app_code = str_shuffle(md5(microtime())); |
|
37 | + # title |
|
38 | + $title = _('Add new api key'); |
|
39 | 39 | } |
40 | 40 | ?> |
41 | 41 | |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | <td> |
75 | 75 | <select name="app_permissions" class="form-control input-sm input-w-auto"> |
76 | 76 | <?php |
77 | - $perms = array(0=>"Disabled",1=>"Read",2=>"Read / Write",3=>"Read / Write / Admin"); |
|
78 | - foreach($perms as $k=>$p) { |
|
79 | - if($k==$api->app_permissions) { print "<option value='$k' selected='selected'>"._($p)."</option>"; } |
|
80 | - else { print "<option value='$k' >"._($p)."</option>"; } |
|
81 | - } |
|
82 | - ?> |
|
77 | + $perms = array(0=>"Disabled",1=>"Read",2=>"Read / Write",3=>"Read / Write / Admin"); |
|
78 | + foreach($perms as $k=>$p) { |
|
79 | + if($k==$api->app_permissions) { print "<option value='$k' selected='selected'>"._($p)."</option>"; } |
|
80 | + else { print "<option value='$k' >"._($p)."</option>"; } |
|
81 | + } |
|
82 | + ?> |
|
83 | 83 | </select> |
84 | 84 | <td class="info2"><?php print _('Application permissions'); ?></td> |
85 | 85 | </tr> |
@@ -90,16 +90,16 @@ discard block |
||
90 | 90 | <td> |
91 | 91 | <select name="app_security" class="form-control input-sm input-w-auto"> |
92 | 92 | <?php |
93 | - $perms = array(0=>"crypt",1=>"ssl",2=>"none",3=>"user"); |
|
93 | + $perms = array(0=>"crypt",1=>"ssl",2=>"none",3=>"user"); |
|
94 | 94 | |
95 | - // user not yet supported |
|
96 | - unset($perms[3]); |
|
95 | + // user not yet supported |
|
96 | + unset($perms[3]); |
|
97 | 97 | |
98 | - foreach($perms as $k=>$p) { |
|
99 | - if($p==$api->app_security) { print "<option value='$p' selected='selected'>"._($p)."</option>"; } |
|
100 | - else { print "<option value='$p' >"._($p)."</option>"; } |
|
101 | - } |
|
102 | - ?> |
|
98 | + foreach($perms as $k=>$p) { |
|
99 | + if($p==$api->app_security) { print "<option value='$p' selected='selected'>"._($p)."</option>"; } |
|
100 | + else { print "<option value='$p' >"._($p)."</option>"; } |
|
101 | + } |
|
102 | + ?> |
|
103 | 103 | </select> |
104 | 104 | <td class="info2"><?php print _('Application security'); ?></td> |
105 | 105 | </tr> |
@@ -34,22 +34,22 @@ discard block |
||
34 | 34 | |
35 | 35 | # ok, lets get results form post array! |
36 | 36 | foreach($_POST as $key=>$line) { |
37 | - // IP address |
|
38 | - if(substr($key, 0,4)=="name") { $res[substr($key, 4)]['name'] = $line; } |
|
39 | - // mac |
|
40 | - elseif(substr($key, 0,6)=="number") { $res[substr($key, 6)]['number'] = $line; } |
|
41 | - // device |
|
42 | - elseif(substr($key, 0,8)=="domainId") { $res[substr($key, 8)]['domainId'] = $line; } |
|
43 | - // description |
|
44 | - elseif(substr($key, 0,11)=="description") { $res[substr($key, 11)]['description'] = $line; } |
|
45 | - // custom fields |
|
46 | - elseif (isset($required_fields)) { |
|
47 | - foreach ($required_fields as $k=>$f) { |
|
48 | - if((strpos($key, $f['name'])) !== false) { |
|
37 | + // IP address |
|
38 | + if(substr($key, 0,4)=="name") { $res[substr($key, 4)]['name'] = $line; } |
|
39 | + // mac |
|
40 | + elseif(substr($key, 0,6)=="number") { $res[substr($key, 6)]['number'] = $line; } |
|
41 | + // device |
|
42 | + elseif(substr($key, 0,8)=="domainId") { $res[substr($key, 8)]['domainId'] = $line; } |
|
43 | + // description |
|
44 | + elseif(substr($key, 0,11)=="description") { $res[substr($key, 11)]['description'] = $line; } |
|
45 | + // custom fields |
|
46 | + elseif (isset($required_fields)) { |
|
47 | + foreach ($required_fields as $k=>$f) { |
|
48 | + if((strpos($key, $f['name'])) !== false) { |
|
49 | 49 | { $res[substr($key, strlen($f['name']))][$f['name']] = $line; } |
50 | - } |
|
51 | - } |
|
52 | - } |
|
50 | + } |
|
51 | + } |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /* |
@@ -60,26 +60,26 @@ discard block |
||
60 | 60 | |
61 | 61 | # insert entries |
62 | 62 | if(sizeof($res)>0) { |
63 | - $errors = 0; |
|
64 | - foreach($res as $r) { |
|
65 | - # set insert values |
|
66 | - $values = array("number"=>$r['number'], |
|
67 | - "name"=>$r['name'], |
|
68 | - "domainId"=>$r['domainId'], |
|
69 | - "description"=>$r['description'] |
|
70 | - ); |
|
63 | + $errors = 0; |
|
64 | + foreach($res as $r) { |
|
65 | + # set insert values |
|
66 | + $values = array("number"=>$r['number'], |
|
67 | + "name"=>$r['name'], |
|
68 | + "domainId"=>$r['domainId'], |
|
69 | + "description"=>$r['description'] |
|
70 | + ); |
|
71 | 71 | # custom fields |
72 | - if (isset($required_fields)) { |
|
73 | - foreach ($required_fields as $k=>$f) { |
|
74 | - $values[$f['name']] = $r[$f['name']]; |
|
75 | - } |
|
76 | - } |
|
72 | + if (isset($required_fields)) { |
|
73 | + foreach ($required_fields as $k=>$f) { |
|
74 | + $values[$f['name']] = $r[$f['name']]; |
|
75 | + } |
|
76 | + } |
|
77 | 77 | # insert vlans |
78 | 78 | if(!$Admin->object_modify("vlans", "add", "vlanId", $values)) { $Result->show("danger", _("Failed to import entry")." ".$r['number']." ".$r['name'], false); $errors++; } |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - # success if no errors |
|
82 | - if($errors==0) { $Result->show("success", _("Scan results added to database")."!", true); } |
|
81 | + # success if no errors |
|
82 | + if($errors==0) { $Result->show("success", _("Scan results added to database")."!", true); } |
|
83 | 83 | } |
84 | 84 | # error |
85 | 85 | else { $Result->show("danger", _("No entries available"), true); } |
@@ -33,26 +33,26 @@ discard block |
||
33 | 33 | |
34 | 34 | // set sections |
35 | 35 | if(@$_POST['id']!=1) { |
36 | - foreach($_POST as $key=>$line) { |
|
37 | - if (strlen(strstr($key,"section-"))>0) { |
|
38 | - $key2 = str_replace("section-", "", $key); |
|
39 | - $temp[] = $key2; |
|
40 | - unset($_POST[$key]); |
|
41 | - } |
|
42 | - } |
|
43 | - # glue sections together |
|
44 | - $_POST['permissions'] = sizeof($temp)>0 ? implode(";", $temp) : null; |
|
36 | + foreach($_POST as $key=>$line) { |
|
37 | + if (strlen(strstr($key,"section-"))>0) { |
|
38 | + $key2 = str_replace("section-", "", $key); |
|
39 | + $temp[] = $key2; |
|
40 | + unset($_POST[$key]); |
|
41 | + } |
|
42 | + } |
|
43 | + # glue sections together |
|
44 | + $_POST['permissions'] = sizeof($temp)>0 ? implode(";", $temp) : null; |
|
45 | 45 | } |
46 | 46 | else { |
47 | - $_POST['permissions'] = ""; |
|
47 | + $_POST['permissions'] = ""; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | # set update values |
51 | 51 | $values = array("id"=>@$_POST['id'], |
52 | - "name"=>@$_POST['name'], |
|
53 | - "description"=>@$_POST['description'], |
|
54 | - "permissions"=>@$_POST['permissions'] |
|
55 | - ); |
|
52 | + "name"=>@$_POST['name'], |
|
53 | + "description"=>@$_POST['description'], |
|
54 | + "permissions"=>@$_POST['permissions'] |
|
55 | + ); |
|
56 | 56 | |
57 | 57 | # update domain |
58 | 58 | if(!$Admin->object_modify("vlanDomains", $_POST['action'], "id", $values)) {} |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | # if delete move all vlans to default domain! |
62 | 62 | if($_POST['action']=="delete") { |
63 | - $Admin->update_object_references ("vlans", "domainId", $_POST['id'], 1); |
|
63 | + $Admin->update_object_references ("vlans", "domainId", $_POST['id'], 1); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | ?> |
67 | 67 | \ No newline at end of file |
@@ -59,14 +59,14 @@ |
||
59 | 59 | <input type="hidden" name="vlanId" value="<?php print $vlan->vlanId; ?>"> |
60 | 60 | <select name="newDomainId" class="form-control input-w-auto input-sm"> |
61 | 61 | <?php |
62 | - $m=0; |
|
63 | - foreach($vlan_domains as $d) { |
|
64 | - if($d->id!=$vlan_domain->id) { |
|
65 | - print "<option value='$d->id'>$d->name ($d->description)</option>"; |
|
66 | - $m++; |
|
67 | - } |
|
68 | - } |
|
69 | - ?> |
|
62 | + $m=0; |
|
63 | + foreach($vlan_domains as $d) { |
|
64 | + if($d->id!=$vlan_domain->id) { |
|
65 | + print "<option value='$d->id'>$d->name ($d->description)</option>"; |
|
66 | + $m++; |
|
67 | + } |
|
68 | + } |
|
69 | + ?> |
|
70 | 70 | </select> |
71 | 71 | </td> |
72 | 72 | </tr> |