@@ -6,15 +6,15 @@ discard block |
||
6 | 6 | |
7 | 7 | /* required functions */ |
8 | 8 | if(!is_object($User)) { |
9 | - /* functions */ |
|
10 | - require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
11 | - |
|
12 | - # initialize user object |
|
13 | - $Database = new Database_PDO; |
|
14 | - $User = new User ($Database); |
|
15 | - $Tools = new Tools ($Database); |
|
16 | - $Sections = new Sections ($Database); |
|
17 | - $Result = new Result (); |
|
9 | + /* functions */ |
|
10 | + require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
11 | + |
|
12 | + # initialize user object |
|
13 | + $Database = new Database_PDO; |
|
14 | + $User = new User ($Database); |
|
15 | + $Tools = new Tools ($Database); |
|
16 | + $Sections = new Sections ($Database); |
|
17 | + $Result = new Result (); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | # verify that user is logged in |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | |
29 | 29 | # Only parse nameserver if any exists |
30 | 30 | if($permitted_nameservers != false) { |
31 | - foreach($permitted_nameservers as $k=>$n) { |
|
32 | - // fetch nameserver sets and append |
|
33 | - $nameserver_set = $Tools->fetch_multiple_objects("nameservers", "id", $n, "name", "namesrv1"); |
|
34 | - |
|
35 | - //save to array |
|
36 | - $nsout[$n] = $nameserver_set; |
|
37 | - |
|
38 | - //count add |
|
39 | - $cnt++; |
|
40 | - } |
|
41 | - //filter out empty |
|
42 | - $permitted_nameservers = isset($nsout) ? array_filter($nsout) : false; |
|
31 | + foreach($permitted_nameservers as $k=>$n) { |
|
32 | + // fetch nameserver sets and append |
|
33 | + $nameserver_set = $Tools->fetch_multiple_objects("nameservers", "id", $n, "name", "namesrv1"); |
|
34 | + |
|
35 | + //save to array |
|
36 | + $nsout[$n] = $nameserver_set; |
|
37 | + |
|
38 | + //count add |
|
39 | + $cnt++; |
|
40 | + } |
|
41 | + //filter out empty |
|
42 | + $permitted_nameservers = isset($nsout) ? array_filter($nsout) : false; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | ?> |
@@ -49,25 +49,25 @@ discard block |
||
49 | 49 | |
50 | 50 | <option value="0"><?php print _('No nameservers'); ?></option> |
51 | 51 | <?php |
52 | - # print all available nameserver sets |
|
53 | - if ($permitted_nameservers!==false) { |
|
54 | - foreach($permitted_nameservers as $n) { |
|
55 | - |
|
56 | - if($n[0]!==null) { |
|
57 | - foreach($n as $ns) { |
|
58 | - // set print |
|
59 | - $printNS = "$ns->name"; |
|
60 | - $printNS .= " (" . array_shift(explode(";",$ns->namesrv1)).",...)"; |
|
61 | - |
|
62 | - /* selected? */ |
|
63 | - if(@$subnet_old_details['nameserverId']==$ns->id) { print '<option value="'. $ns->id .'" selected>'. $printNS .'</option>'. "\n"; } |
|
64 | - elseif(@$_POST['nameserverId'] == $ns->id) { print '<option value="'. $ns->id .'" selected>'. $printNS .'</option>'. "\n"; } |
|
65 | - else { print '<option value="'. $ns->id .'">'. $printNS .'</option>'. "\n"; } |
|
66 | - } |
|
67 | - } |
|
68 | - } |
|
69 | - } |
|
70 | - ?> |
|
52 | + # print all available nameserver sets |
|
53 | + if ($permitted_nameservers!==false) { |
|
54 | + foreach($permitted_nameservers as $n) { |
|
55 | + |
|
56 | + if($n[0]!==null) { |
|
57 | + foreach($n as $ns) { |
|
58 | + // set print |
|
59 | + $printNS = "$ns->name"; |
|
60 | + $printNS .= " (" . array_shift(explode(";",$ns->namesrv1)).",...)"; |
|
61 | + |
|
62 | + /* selected? */ |
|
63 | + if(@$subnet_old_details['nameserverId']==$ns->id) { print '<option value="'. $ns->id .'" selected>'. $printNS .'</option>'. "\n"; } |
|
64 | + elseif(@$_POST['nameserverId'] == $ns->id) { print '<option value="'. $ns->id .'" selected>'. $printNS .'</option>'. "\n"; } |
|
65 | + else { print '<option value="'. $ns->id .'">'. $printNS .'</option>'. "\n"; } |
|
66 | + } |
|
67 | + } |
|
68 | + } |
|
69 | + } |
|
70 | + ?> |
|
71 | 71 | </optgroup> |
72 | 72 | |
73 | 73 |
@@ -6,15 +6,15 @@ discard block |
||
6 | 6 | |
7 | 7 | /* required functions */ |
8 | 8 | if(!isset($User)) { |
9 | - /* functions */ |
|
10 | - require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
9 | + /* functions */ |
|
10 | + require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
11 | 11 | |
12 | - # initialize user object |
|
13 | - $Database = new Database_PDO; |
|
14 | - $User = new User ($Database); |
|
15 | - $Tools = new Tools ($Database); |
|
16 | - $Sections = new Sections ($Database); |
|
17 | - $Result = new Result (); |
|
12 | + # initialize user object |
|
13 | + $Database = new Database_PDO; |
|
14 | + $User = new User ($Database); |
|
15 | + $Tools = new Tools ($Database); |
|
16 | + $Sections = new Sections ($Database); |
|
17 | + $Result = new Result (); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | # verify that user is logged in |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | # fetch all belonging vlans |
27 | 27 | $cnt = 0; |
28 | 28 | foreach($permitted_domains as $k=>$d) { |
29 | - //fetch domain |
|
30 | - $domain = $Tools->fetch_object("vlanDomains","id",$d); |
|
31 | - // fetch vlans and append |
|
32 | - $vlans = $Tools->fetch_multiple_objects("vlans", "domainId", $domain->id, "number"); |
|
33 | - //save to array |
|
34 | - $out[$d]['domain'] = $domain; |
|
35 | - $out[$d]['vlans'] = $vlans; |
|
36 | - //count add |
|
37 | - $cnt++; |
|
29 | + //fetch domain |
|
30 | + $domain = $Tools->fetch_object("vlanDomains","id",$d); |
|
31 | + // fetch vlans and append |
|
32 | + $vlans = $Tools->fetch_multiple_objects("vlans", "domainId", $domain->id, "number"); |
|
33 | + //save to array |
|
34 | + $out[$d]['domain'] = $domain; |
|
35 | + $out[$d]['vlans'] = $vlans; |
|
36 | + //count add |
|
37 | + $cnt++; |
|
38 | 38 | } |
39 | 39 | //filter out empty |
40 | 40 | $permitted_domains = array_filter($out); |
@@ -44,29 +44,29 @@ discard block |
||
44 | 44 | <option disabled="disabled"><?php print _('Select VLAN'); ?>:</option> |
45 | 45 | <option value="0"><?php print _('No VLAN'); ?></option> |
46 | 46 | <?php |
47 | - # print all available domains |
|
48 | - foreach($permitted_domains as $d) { |
|
49 | - //more than default |
|
50 | - print "<optgroup label='".$d['domain']->name."'>"; |
|
51 | - //add |
|
52 | - print "<option value='Add' data-domain='".$d['domain']->id."'>"._('+ Add new VLAN')."</option>"; |
|
47 | + # print all available domains |
|
48 | + foreach($permitted_domains as $d) { |
|
49 | + //more than default |
|
50 | + print "<optgroup label='".$d['domain']->name."'>"; |
|
51 | + //add |
|
52 | + print "<option value='Add' data-domain='".$d['domain']->id."'>"._('+ Add new VLAN')."</option>"; |
|
53 | 53 | |
54 | - if($d['vlans'][0]!==null) { |
|
55 | - foreach($d['vlans'] as $v) { |
|
56 | - // set print |
|
57 | - $printVLAN = $v->number; |
|
58 | - if(!empty($v->name)) { $printVLAN .= " ($v->name)"; } |
|
54 | + if($d['vlans'][0]!==null) { |
|
55 | + foreach($d['vlans'] as $v) { |
|
56 | + // set print |
|
57 | + $printVLAN = $v->number; |
|
58 | + if(!empty($v->name)) { $printVLAN .= " ($v->name)"; } |
|
59 | 59 | |
60 | - /* selected? */ |
|
61 | - if(@$subnet_old_details['vlanId']==$v->vlanId) { print '<option value="'. $v->vlanId .'" selected>'. $printVLAN .'</option>'. "\n"; } |
|
62 | - elseif(@$_POST['vlanId'] == $v->vlanId) { print '<option value="'. $v->vlanId .'" selected>'. $printVLAN .'</option>'. "\n"; } |
|
63 | - else { print '<option value="'. $v->vlanId .'">'. $printVLAN .'</option>'. "\n"; } |
|
64 | - } |
|
65 | - } |
|
66 | - else { |
|
67 | - print "<option value='0' disabled>"._('No VLANs')."</option>"; |
|
68 | - } |
|
69 | - print "</optgroup>"; |
|
70 | - } |
|
71 | - ?> |
|
60 | + /* selected? */ |
|
61 | + if(@$subnet_old_details['vlanId']==$v->vlanId) { print '<option value="'. $v->vlanId .'" selected>'. $printVLAN .'</option>'. "\n"; } |
|
62 | + elseif(@$_POST['vlanId'] == $v->vlanId) { print '<option value="'. $v->vlanId .'" selected>'. $printVLAN .'</option>'. "\n"; } |
|
63 | + else { print '<option value="'. $v->vlanId .'">'. $printVLAN .'</option>'. "\n"; } |
|
64 | + } |
|
65 | + } |
|
66 | + else { |
|
67 | + print "<option value='0' disabled>"._('No VLANs')."</option>"; |
|
68 | + } |
|
69 | + print "</optgroup>"; |
|
70 | + } |
|
71 | + ?> |
|
72 | 72 | </select> |
73 | 73 | \ No newline at end of file |
@@ -24,87 +24,87 @@ |
||
24 | 24 | /* Foreach section fetch subnets and print it! */ |
25 | 25 | if(sizeof($sections) > 0) { |
26 | 26 | |
27 | - # print table structure |
|
28 | - print "<table id='manageSubnets' class='table sorted table-striped table-condensed table-top'>"; |
|
29 | - |
|
30 | - # headers |
|
31 | - print "<thead>"; |
|
32 | - print " <tr>"; |
|
33 | - print " <th>"._('Subnet')."</th>"; |
|
34 | - print " <th>"._('Description')."</th>"; |
|
35 | - print " <th>"._('VLAN')."</th>"; |
|
36 | - if($User->settings->enableVRF == 1) { |
|
37 | - print " <th>"._('VRF')."</th>"; |
|
38 | - } |
|
39 | - print " <th>"._('Master Subnet')."</th>"; |
|
40 | - print " <th>"._('Device')."</th>"; |
|
41 | - print " <th class='hidden-xs hidden-sm'>"._('Requests')."</th>"; |
|
42 | - |
|
43 | - if(sizeof($custom_fields) > 0) { |
|
44 | - foreach($custom_fields as $field) { |
|
45 | - # hidden? |
|
46 | - if(!in_array($field['name'], $hidden_custom_fields)) { |
|
47 | - print " <th class='hidden-xs hidden-sm hidden-md'>$field[name]</th>"; |
|
48 | - } |
|
49 | - } |
|
50 | - } |
|
51 | - # actions |
|
52 | - print "<th class='actions' style='padding:0px;'></th>"; |
|
53 | - print "</tr>"; |
|
54 | - print "</thead>"; |
|
55 | - |
|
56 | - |
|
57 | - $m = 0; //for subnet index |
|
27 | + # print table structure |
|
28 | + print "<table id='manageSubnets' class='table sorted table-striped table-condensed table-top'>"; |
|
29 | + |
|
30 | + # headers |
|
31 | + print "<thead>"; |
|
32 | + print " <tr>"; |
|
33 | + print " <th>"._('Subnet')."</th>"; |
|
34 | + print " <th>"._('Description')."</th>"; |
|
35 | + print " <th>"._('VLAN')."</th>"; |
|
36 | + if($User->settings->enableVRF == 1) { |
|
37 | + print " <th>"._('VRF')."</th>"; |
|
38 | + } |
|
39 | + print " <th>"._('Master Subnet')."</th>"; |
|
40 | + print " <th>"._('Device')."</th>"; |
|
41 | + print " <th class='hidden-xs hidden-sm'>"._('Requests')."</th>"; |
|
42 | + |
|
43 | + if(sizeof($custom_fields) > 0) { |
|
44 | + foreach($custom_fields as $field) { |
|
45 | + # hidden? |
|
46 | + if(!in_array($field['name'], $hidden_custom_fields)) { |
|
47 | + print " <th class='hidden-xs hidden-sm hidden-md'>$field[name]</th>"; |
|
48 | + } |
|
49 | + } |
|
50 | + } |
|
51 | + # actions |
|
52 | + print "<th class='actions' style='padding:0px;'></th>"; |
|
53 | + print "</tr>"; |
|
54 | + print "</thead>"; |
|
55 | + |
|
56 | + |
|
57 | + $m = 0; //for subnet index |
|
58 | 58 | |
59 | 59 | print "<tbody>"; |
60 | - # print titles and content |
|
61 | - if($sections!==false) { |
|
62 | - foreach($sections as $section) { |
|
63 | - //cast |
|
64 | - $section = (array) $section; |
|
65 | - # set colcount |
|
66 | - $colCount = $User->settings->enableVRF==1 ? 10 : 9; |
|
67 | - |
|
68 | - # just for count |
|
69 | - if(sizeof($custom_fields) > 0) { |
|
70 | - foreach($custom_fields as $field) { |
|
71 | - if(!in_array($field['name'], $hidden_custom_fields)) { |
|
72 | - $colCount++; |
|
73 | - } |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - # print name |
|
78 | - print "<tr class='subnet-title'>"; |
|
79 | - print " <th colspan='$colCount'>"; |
|
80 | - print " <h4> $section[name] </h4>"; |
|
81 | - print " </th>"; |
|
82 | - print "</tr>"; |
|
83 | - |
|
84 | - # get all subnets in section |
|
85 | - $section_subnets = $Subnets->fetch_section_subnets($section['id']); |
|
86 | - |
|
87 | - # add new link |
|
88 | - print "<tr>"; |
|
89 | - print " <td colspan='$colCount'>"; |
|
90 | - print " <button class='btn btn-sm btn-default editSubnet' data-action='add' data-sectionid='$section[id]' data-subnetId='' rel='tooltip' data-placement='right' title='"._('Add new subnet to section')." $section[name]'><i class='fa fa-plus'></i> "._('Add subnet')."</button>"; |
|
91 | - print " </td>"; |
|
92 | - print " </tr>"; |
|
93 | - |
|
94 | - # no subnets |
|
95 | - if(sizeof($section_subnets) == 0) { |
|
96 | - print "<tr><td colspan='$colCount'><div class='alert alert-info'>"._('Section has no subnets')."!</div></td></tr>"; |
|
97 | - } |
|
98 | - else { |
|
99 | - # subnets |
|
100 | - $Subnets->print_subnets_tools($User->user, $section_subnets, $custom_fields); |
|
101 | - } |
|
102 | - $m++; |
|
103 | - } |
|
104 | - } |
|
105 | - print "</tbody>"; |
|
106 | - |
|
107 | - # end master table |
|
108 | - print "</table>"; |
|
60 | + # print titles and content |
|
61 | + if($sections!==false) { |
|
62 | + foreach($sections as $section) { |
|
63 | + //cast |
|
64 | + $section = (array) $section; |
|
65 | + # set colcount |
|
66 | + $colCount = $User->settings->enableVRF==1 ? 10 : 9; |
|
67 | + |
|
68 | + # just for count |
|
69 | + if(sizeof($custom_fields) > 0) { |
|
70 | + foreach($custom_fields as $field) { |
|
71 | + if(!in_array($field['name'], $hidden_custom_fields)) { |
|
72 | + $colCount++; |
|
73 | + } |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + # print name |
|
78 | + print "<tr class='subnet-title'>"; |
|
79 | + print " <th colspan='$colCount'>"; |
|
80 | + print " <h4> $section[name] </h4>"; |
|
81 | + print " </th>"; |
|
82 | + print "</tr>"; |
|
83 | + |
|
84 | + # get all subnets in section |
|
85 | + $section_subnets = $Subnets->fetch_section_subnets($section['id']); |
|
86 | + |
|
87 | + # add new link |
|
88 | + print "<tr>"; |
|
89 | + print " <td colspan='$colCount'>"; |
|
90 | + print " <button class='btn btn-sm btn-default editSubnet' data-action='add' data-sectionid='$section[id]' data-subnetId='' rel='tooltip' data-placement='right' title='"._('Add new subnet to section')." $section[name]'><i class='fa fa-plus'></i> "._('Add subnet')."</button>"; |
|
91 | + print " </td>"; |
|
92 | + print " </tr>"; |
|
93 | + |
|
94 | + # no subnets |
|
95 | + if(sizeof($section_subnets) == 0) { |
|
96 | + print "<tr><td colspan='$colCount'><div class='alert alert-info'>"._('Section has no subnets')."!</div></td></tr>"; |
|
97 | + } |
|
98 | + else { |
|
99 | + # subnets |
|
100 | + $Subnets->print_subnets_tools($User->user, $section_subnets, $custom_fields); |
|
101 | + } |
|
102 | + $m++; |
|
103 | + } |
|
104 | + } |
|
105 | + print "</tbody>"; |
|
106 | + |
|
107 | + # end master table |
|
108 | + print "</table>"; |
|
109 | 109 | } |
110 | 110 | ?> |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | |
47 | 47 | //set mask options |
48 | 48 | for($mask=($subnet->mask+1); $mask<=$max_new_mask; $mask++) { |
49 | - # set vars |
|
50 | - $opts[$m]['mask'] = $mask; |
|
51 | - $opts[$m]['number'] = $n; |
|
52 | - $opts[$m]['max'] = $Subnets->get_max_hosts ($mask, $Subnets->identify_address($Subnets->transform_to_dotted($subnet->subnet))); |
|
53 | - |
|
54 | - # next |
|
55 | - $m++; |
|
56 | - $n = $n * 2; |
|
57 | - |
|
58 | - # max number = 16! |
|
59 | - if($n > 256) { |
|
60 | - $mask = 1000; |
|
61 | - } |
|
49 | + # set vars |
|
50 | + $opts[$m]['mask'] = $mask; |
|
51 | + $opts[$m]['number'] = $n; |
|
52 | + $opts[$m]['max'] = $Subnets->get_max_hosts ($mask, $Subnets->identify_address($Subnets->transform_to_dotted($subnet->subnet))); |
|
53 | + |
|
54 | + # next |
|
55 | + $m++; |
|
56 | + $n = $n * 2; |
|
57 | + |
|
58 | + # max number = 16! |
|
59 | + if($n > 256) { |
|
60 | + $mask = 1000; |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | ?> |
64 | 64 | |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | <td style="vertical-align:middle"> |
85 | 85 | <select name="number" class="form-control input-sm input-w-auto"> |
86 | 86 | <?php |
87 | - foreach($opts as $line) { |
|
88 | - print "<option value='$line[number]'>$line[number]x /$line[mask] subnet ($line[number]x $line[max] hosts)</option>"; |
|
89 | - } |
|
90 | - ?> |
|
87 | + foreach($opts as $line) { |
|
88 | + print "<option value='$line[number]'>$line[number]x /$line[mask] subnet ($line[number]x $line[max] hosts)</option>"; |
|
89 | + } |
|
90 | + ?> |
|
91 | 91 | </select> |
92 | 92 | <input type="hidden" name="subnetId" value="<?php print $subnet->id; ?>"> |
93 | 93 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | |
25 | 25 | # ID must be numeric |
26 | 26 | if($_POST['action']!="add") { |
27 | - if(!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
27 | + if(!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | # verify that user has permissions to add subnet |
31 | 31 | if($_POST['action'] == "add") { |
32 | - if($Sections->check_permission ($User->user, $_POST['sectionId']) != 3) { $Result->show("danger", _('You do not have permissions to add new subnet in this section')."!", true, true); } |
|
32 | + if($Sections->check_permission ($User->user, $_POST['sectionId']) != 3) { $Result->show("danger", _('You do not have permissions to add new subnet in this section')."!", true, true); } |
|
33 | 33 | } |
34 | 34 | # otherwise check subnet permission |
35 | 35 | else { |
36 | - if($Subnets->check_permission ($User->user, $_POST['subnetId']) != 3) { $Result->show("danger", _('You do not have permissions to add edit/delete this subnet')."!", true, true); } |
|
36 | + if($Subnets->check_permission ($User->user, $_POST['subnetId']) != 3) { $Result->show("danger", _('You do not have permissions to add edit/delete this subnet')."!", true, true); } |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | } |
44 | 44 | # we are adding new folder - get folder details |
45 | 45 | else { |
46 | - # for selecting master subnet if added from subnet details! |
|
47 | - if(strlen($_POST['subnetId']) > 0) { |
|
48 | - $subnet_old_temp = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']); |
|
49 | - $subnet_old_details['masterSubnetId'] = @$subnet_old_temp['id']; // same master subnet ID for nested |
|
50 | - $subnet_old_details['vlanId'] = @$subnet_old_temp['vlanId']; // same default vlan for nested |
|
51 | - $subnet_old_details['vrfId'] = @$subnet_old_temp['vrfId']; // same default vrf for nested |
|
52 | - } |
|
46 | + # for selecting master subnet if added from subnet details! |
|
47 | + if(strlen($_POST['subnetId']) > 0) { |
|
48 | + $subnet_old_temp = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']); |
|
49 | + $subnet_old_details['masterSubnetId'] = @$subnet_old_temp['id']; // same master subnet ID for nested |
|
50 | + $subnet_old_details['vlanId'] = @$subnet_old_temp['vlanId']; // same default vlan for nested |
|
51 | + $subnet_old_details['vrfId'] = @$subnet_old_temp['vrfId']; // same default vrf for nested |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | # fetch custom fields |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | <td> |
91 | 91 | <select name="sectionIdNew" class="form-control input-sm input-w-auto"> |
92 | 92 | <?php |
93 | - if($sections!==false) { |
|
94 | - foreach($sections as $section) { |
|
95 | - /* selected? */ |
|
96 | - if($_POST['sectionId'] == $section->id) { print '<option value="'. $section->id .'" selected>'. $section->name .'</option>'. "\n"; } |
|
97 | - else { print '<option value="'. $section->id .'">'. $section->name .'</option>'. "\n"; } |
|
98 | - } |
|
99 | - } |
|
100 | - ?> |
|
93 | + if($sections!==false) { |
|
94 | + foreach($sections as $section) { |
|
95 | + /* selected? */ |
|
96 | + if($_POST['sectionId'] == $section->id) { print '<option value="'. $section->id .'" selected>'. $section->name .'</option>'. "\n"; } |
|
97 | + else { print '<option value="'. $section->id .'">'. $section->name .'</option>'. "\n"; } |
|
98 | + } |
|
99 | + } |
|
100 | + ?> |
|
101 | 101 | </select> |
102 | 102 | |
103 | 103 | </select> |
@@ -124,100 +124,100 @@ discard block |
||
124 | 124 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
125 | 125 | |
126 | 126 | <?php |
127 | - # custom Subnet fields |
|
128 | - if(sizeof($custom_fields) > 0) { |
|
129 | - # count datepickers |
|
130 | - $timeP = 0; |
|
131 | - |
|
132 | - print "<tr>"; |
|
133 | - print " <td colspan='3' class='hr'><hr></td>"; |
|
134 | - print "</tr>"; |
|
135 | - foreach($custom_fields as $field) { |
|
136 | - |
|
137 | - # replace spaces |
|
138 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
139 | - # retain newlines |
|
140 | - $folder_old_details[$field['name']] = str_replace("\n", "\\n", @$folder_old_details[$field['name']]); |
|
141 | - |
|
142 | - # set default value ! |
|
143 | - if ($_POST['action']=="add"){ $folder_old_details[$field['name']] = $field['Default']; } |
|
144 | - |
|
145 | - # required |
|
146 | - if($field['Null']=="NO") { $required = "*"; } |
|
147 | - else { $required = ""; } |
|
148 | - |
|
149 | - print '<tr>'. "\n"; |
|
150 | - print ' <td>'. $field['name'] .' '.$required.'</td>'. "\n"; |
|
151 | - print ' <td colspan="2">'. "\n"; |
|
152 | - |
|
153 | - //set type |
|
154 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
155 | - //parse values |
|
156 | - $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
157 | - |
|
158 | - //null |
|
159 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
160 | - |
|
161 | - print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
162 | - foreach($tmp as $v) { |
|
163 | - if($v==$folder_old_details[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
164 | - else { print "<option value='$v'>$v</option>"; } |
|
165 | - } |
|
166 | - print "</select>"; |
|
167 | - } |
|
168 | - //date and time picker |
|
169 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
170 | - // just for first |
|
171 | - if($timeP==0) { |
|
172 | - print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
173 | - print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
174 | - print '<script type="text/javascript">'; |
|
175 | - print '$(document).ready(function() {'; |
|
176 | - //date only |
|
177 | - print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
178 | - //date + time |
|
179 | - print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
180 | - |
|
181 | - print '})'; |
|
182 | - print '</script>'; |
|
183 | - } |
|
184 | - $timeP++; |
|
185 | - |
|
186 | - //set size |
|
187 | - if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
188 | - else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
189 | - |
|
190 | - //field |
|
191 | - if(!isset($folder_old_details[$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"; } |
|
192 | - else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $folder_old_details[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
193 | - } |
|
194 | - //boolean |
|
195 | - elseif($field['type'] == "tinyint(1)") { |
|
196 | - print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
197 | - $tmp = array(0=>"No",1=>"Yes"); |
|
198 | - //null |
|
199 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
200 | - |
|
201 | - foreach($tmp as $k=>$v) { |
|
202 | - if(strlen($folder_old_details[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
203 | - elseif($k==$folder_old_details[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
204 | - else { print "<option value='$k'>"._($v)."</option>"; } |
|
205 | - } |
|
206 | - print "</select>"; |
|
207 | - } |
|
208 | - //text |
|
209 | - elseif($field['type'] == "text") { |
|
210 | - print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. str_replace("\\n","",$folder_old_details[$field['name']]). '</textarea>'. "\n"; |
|
211 | - } |
|
212 | - //default - input field |
|
213 | - else { |
|
214 | - print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. $folder_old_details[$field['name']]. '" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
215 | - } |
|
216 | - |
|
217 | - print ' </td>'. "\n"; |
|
218 | - print '</tr>'. "\n"; |
|
219 | - } |
|
220 | - } |
|
127 | + # custom Subnet fields |
|
128 | + if(sizeof($custom_fields) > 0) { |
|
129 | + # count datepickers |
|
130 | + $timeP = 0; |
|
131 | + |
|
132 | + print "<tr>"; |
|
133 | + print " <td colspan='3' class='hr'><hr></td>"; |
|
134 | + print "</tr>"; |
|
135 | + foreach($custom_fields as $field) { |
|
136 | + |
|
137 | + # replace spaces |
|
138 | + $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
139 | + # retain newlines |
|
140 | + $folder_old_details[$field['name']] = str_replace("\n", "\\n", @$folder_old_details[$field['name']]); |
|
141 | + |
|
142 | + # set default value ! |
|
143 | + if ($_POST['action']=="add"){ $folder_old_details[$field['name']] = $field['Default']; } |
|
144 | + |
|
145 | + # required |
|
146 | + if($field['Null']=="NO") { $required = "*"; } |
|
147 | + else { $required = ""; } |
|
148 | + |
|
149 | + print '<tr>'. "\n"; |
|
150 | + print ' <td>'. $field['name'] .' '.$required.'</td>'. "\n"; |
|
151 | + print ' <td colspan="2">'. "\n"; |
|
152 | + |
|
153 | + //set type |
|
154 | + if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
155 | + //parse values |
|
156 | + $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
157 | + |
|
158 | + //null |
|
159 | + if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
160 | + |
|
161 | + print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
162 | + foreach($tmp as $v) { |
|
163 | + if($v==$folder_old_details[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
164 | + else { print "<option value='$v'>$v</option>"; } |
|
165 | + } |
|
166 | + print "</select>"; |
|
167 | + } |
|
168 | + //date and time picker |
|
169 | + elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
170 | + // just for first |
|
171 | + if($timeP==0) { |
|
172 | + print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
173 | + print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
174 | + print '<script type="text/javascript">'; |
|
175 | + print '$(document).ready(function() {'; |
|
176 | + //date only |
|
177 | + print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
178 | + //date + time |
|
179 | + print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
180 | + |
|
181 | + print '})'; |
|
182 | + print '</script>'; |
|
183 | + } |
|
184 | + $timeP++; |
|
185 | + |
|
186 | + //set size |
|
187 | + if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
188 | + else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
189 | + |
|
190 | + //field |
|
191 | + if(!isset($folder_old_details[$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"; } |
|
192 | + else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $folder_old_details[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
193 | + } |
|
194 | + //boolean |
|
195 | + elseif($field['type'] == "tinyint(1)") { |
|
196 | + print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
197 | + $tmp = array(0=>"No",1=>"Yes"); |
|
198 | + //null |
|
199 | + if($field['Null']!="NO") { $tmp[2] = ""; } |
|
200 | + |
|
201 | + foreach($tmp as $k=>$v) { |
|
202 | + if(strlen($folder_old_details[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
203 | + elseif($k==$folder_old_details[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
204 | + else { print "<option value='$k'>"._($v)."</option>"; } |
|
205 | + } |
|
206 | + print "</select>"; |
|
207 | + } |
|
208 | + //text |
|
209 | + elseif($field['type'] == "text") { |
|
210 | + print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. str_replace("\\n","",$folder_old_details[$field['name']]). '</textarea>'. "\n"; |
|
211 | + } |
|
212 | + //default - input field |
|
213 | + else { |
|
214 | + print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. $folder_old_details[$field['name']]. '" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
215 | + } |
|
216 | + |
|
217 | + print ' </td>'. "\n"; |
|
218 | + print '</tr>'. "\n"; |
|
219 | + } |
|
220 | + } |
|
221 | 221 | |
222 | 222 | |
223 | 223 | # divider |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | <?php |
233 | 233 | # warning if delete |
234 | 234 | if($_POST['action'] == "delete") { |
235 | - print "<div class='alert alert-warning' style='margin-top:0px;'><strong>"._('Warning')."</strong><br>"._('Removing subnets will delete ALL underlaying subnets and belonging IP addresses')."!</div>"; |
|
235 | + print "<div class='alert alert-warning' style='margin-top:0px;'><strong>"._('Warning')."</strong><br>"._('Removing subnets will delete ALL underlaying subnets and belonging IP addresses')."!</div>"; |
|
236 | 236 | } |
237 | 237 | ?> |
238 | 238 | |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | <div class="btn-group"> |
246 | 246 | <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
247 | 247 | <?php |
248 | - //if action == edit and location = IPaddresses print also delete form |
|
249 | - if(($_POST['action'] == "edit") && ($_POST['location'] == "IPaddresses") ) { |
|
250 | - print "<button class='btn btn-sm btn-default btn-danger editFolderSubmitDelete' data-action='delete' data-subnetId='$folder_old_details[id]'><i class='fa fa-trash-o'></i> "._('Delete folder')."</button>"; |
|
251 | - } |
|
252 | - ?> |
|
248 | + //if action == edit and location = IPaddresses print also delete form |
|
249 | + if(($_POST['action'] == "edit") && ($_POST['location'] == "IPaddresses") ) { |
|
250 | + print "<button class='btn btn-sm btn-default btn-danger editFolderSubmitDelete' data-action='delete' data-subnetId='$folder_old_details[id]'><i class='fa fa-trash-o'></i> "._('Delete folder')."</button>"; |
|
251 | + } |
|
252 | + ?> |
|
253 | 253 | <button class="btn btn-sm btn-default editFolderSubmit <?php if($_POST['action']=="delete") print "btn-danger"; else print "btn-success"; ?>"><i class="<?php if($_POST['action']=="add") { print "fa fa-plus"; } else if ($_POST['action']=="delete") { print "fa fa-trash-o"; } else { print "fa fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
254 | 254 | </div> |
255 | 255 |
@@ -36,18 +36,18 @@ |
||
36 | 36 | |
37 | 37 | # we need to recalculate subnet address if needed |
38 | 38 | if ($subnet_old['mask'] < $_POST['newMask']) { |
39 | - $subnet_new['subnet'] = $subnet_old['subnet']; |
|
39 | + $subnet_new['subnet'] = $subnet_old['subnet']; |
|
40 | 40 | } |
41 | 41 | else { |
42 | - $new_boundaries = $Subnets->get_network_boundaries ($Subnets->transform_address($subnet_old['subnet'], "dotted"), $_POST['newMask']); |
|
43 | - $subnet_new['subnet'] = $Subnets->transform_address($new_boundaries['network'], "decimal"); |
|
42 | + $new_boundaries = $Subnets->get_network_boundaries ($Subnets->transform_address($subnet_old['subnet'], "dotted"), $_POST['newMask']); |
|
43 | + $subnet_new['subnet'] = $Subnets->transform_address($new_boundaries['network'], "decimal"); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | # set update values |
47 | 47 | $values = array("id"=>$_POST['subnetId'], |
48 | - "subnet"=>$subnet_new['subnet'], |
|
49 | - "mask"=>$_POST['newMask'] |
|
50 | - ); |
|
48 | + "subnet"=>$subnet_new['subnet'], |
|
49 | + "mask"=>$_POST['newMask'] |
|
50 | + ); |
|
51 | 51 | if(!$Subnets->modify_subnet ("resize", $values)) { $Result->show("danger", _("Error resizing subnet")."!", true); } |
52 | 52 | else { $Result->show("success", _("Subnet resized successfully")."!", true); } |
53 | 53 |
@@ -37,26 +37,26 @@ |
||
37 | 37 | |
38 | 38 | # check for DNS PTR records |
39 | 39 | if ($User->settings->enablePowerDNS=="1" && $subnet->DNSrecursive=="1") { |
40 | - # powerDNS class |
|
41 | - $PowerDNS = new PowerDNS ($Database); |
|
42 | - if($PowerDNS->db_check()!==false) { |
|
43 | - // set name |
|
44 | - $zone = $PowerDNS->get_ptr_zone_name ($subnet->ip, $subnet->mask); |
|
45 | - // fetch domain |
|
46 | - $domain = $PowerDNS->fetch_domain_by_name ($zone); |
|
47 | - // if it exist remove all PTR records |
|
48 | - if ($domain!==false) { |
|
49 | - // get all PTRs |
|
50 | - $ptr_indexes = $Addresses->ptr_get_subnet_indexes ($subnet->id); |
|
51 | - // remove existing records and links |
|
52 | - $PowerDNS->remove_all_ptr_records ($domain->id, $ptr_indexes); |
|
53 | - // ok |
|
54 | - $Result->show("success", "PTR records removed", false); |
|
55 | - } |
|
56 | - } |
|
57 | - # error |
|
58 | - else { |
|
59 | - $Result->show("danger", "Cannot connect to powerDNS database", false); |
|
60 | - } |
|
40 | + # powerDNS class |
|
41 | + $PowerDNS = new PowerDNS ($Database); |
|
42 | + if($PowerDNS->db_check()!==false) { |
|
43 | + // set name |
|
44 | + $zone = $PowerDNS->get_ptr_zone_name ($subnet->ip, $subnet->mask); |
|
45 | + // fetch domain |
|
46 | + $domain = $PowerDNS->fetch_domain_by_name ($zone); |
|
47 | + // if it exist remove all PTR records |
|
48 | + if ($domain!==false) { |
|
49 | + // get all PTRs |
|
50 | + $ptr_indexes = $Addresses->ptr_get_subnet_indexes ($subnet->id); |
|
51 | + // remove existing records and links |
|
52 | + $PowerDNS->remove_all_ptr_records ($domain->id, $ptr_indexes); |
|
53 | + // ok |
|
54 | + $Result->show("success", "PTR records removed", false); |
|
55 | + } |
|
56 | + } |
|
57 | + # error |
|
58 | + else { |
|
59 | + $Result->show("danger", "Cannot connect to powerDNS database", false); |
|
60 | + } |
|
61 | 61 | } |
62 | 62 | ?> |
63 | 63 | \ No newline at end of file |
@@ -27,64 +27,64 @@ |
||
27 | 27 | <!-- content --> |
28 | 28 | <div class="pContent"> |
29 | 29 | <?php |
30 | - // error ? |
|
31 | - if ($res['result']=="error") { |
|
32 | - $Result->show("danger", _(ucwords($res['error'])), false); |
|
33 | - } |
|
34 | - // ok, print field matching |
|
35 | - else { |
|
36 | - // fetch all fields for subnets |
|
37 | - $standard_fields = array("description"); |
|
38 | - $custom_fields = $Tools->fetch_custom_fields ("subnets"); |
|
30 | + // error ? |
|
31 | + if ($res['result']=="error") { |
|
32 | + $Result->show("danger", _(ucwords($res['error'])), false); |
|
33 | + } |
|
34 | + // ok, print field matching |
|
35 | + else { |
|
36 | + // fetch all fields for subnets |
|
37 | + $standard_fields = array("description"); |
|
38 | + $custom_fields = $Tools->fetch_custom_fields ("subnets"); |
|
39 | 39 | |
40 | - // leave only varchar and text |
|
41 | - foreach ($custom_fields as $k=>$f) { |
|
42 | - if (!(strpos($f['type'], "varchar")!==false || $f['type']=="text")) { |
|
43 | - unset($custom_fields[$k]); |
|
44 | - } |
|
45 | - } |
|
46 | - // append description |
|
47 | - $custom_fields = array_merge(array("description"=>array("name"=>"description")), $custom_fields); |
|
40 | + // leave only varchar and text |
|
41 | + foreach ($custom_fields as $k=>$f) { |
|
42 | + if (!(strpos($f['type'], "varchar")!==false || $f['type']=="text")) { |
|
43 | + unset($custom_fields[$k]); |
|
44 | + } |
|
45 | + } |
|
46 | + // append description |
|
47 | + $custom_fields = array_merge(array("description"=>array("name"=>"description")), $custom_fields); |
|
48 | 48 | |
49 | - print "<h4>"._("Please select fields to populate:")."</h4>"; |
|
50 | - // form |
|
51 | - print "<form name='ripe-fields' id='ripe-fields'>"; |
|
52 | - print "<table class='table'>"; |
|
53 | - // loop |
|
54 | - if (isset($res['data'])) { |
|
55 | - foreach ($res['data'] as $k=>$d) { |
|
56 | - print "<tr>"; |
|
57 | - print "<td>"; |
|
58 | - print " <span class='text-muted'>$k</span>: $d"; |
|
59 | - print "</td>"; |
|
49 | + print "<h4>"._("Please select fields to populate:")."</h4>"; |
|
50 | + // form |
|
51 | + print "<form name='ripe-fields' id='ripe-fields'>"; |
|
52 | + print "<table class='table'>"; |
|
53 | + // loop |
|
54 | + if (isset($res['data'])) { |
|
55 | + foreach ($res['data'] as $k=>$d) { |
|
56 | + print "<tr>"; |
|
57 | + print "<td>"; |
|
58 | + print " <span class='text-muted'>$k</span>: $d"; |
|
59 | + print "</td>"; |
|
60 | 60 | |
61 | - print "<td>"; |
|
62 | - // add + |
|
63 | - $d = str_replace(" ", "___", $d); |
|
64 | - print "<select name='$d' class='form-control input-sm'>"; |
|
65 | - print "<option value='0'>None</option>"; |
|
66 | - // print custom |
|
67 | - if (sizeof($custom_fields>0)) { |
|
68 | - foreach ($custom_fields as $f) { |
|
69 | - // replace descr with description |
|
70 | - if ($k=="descr") $k = "description"; |
|
61 | + print "<td>"; |
|
62 | + // add + |
|
63 | + $d = str_replace(" ", "___", $d); |
|
64 | + print "<select name='$d' class='form-control input-sm'>"; |
|
65 | + print "<option value='0'>None</option>"; |
|
66 | + // print custom |
|
67 | + if (sizeof($custom_fields>0)) { |
|
68 | + foreach ($custom_fields as $f) { |
|
69 | + // replace descr with description |
|
70 | + if ($k=="descr") $k = "description"; |
|
71 | 71 | |
72 | - if (strtolower($f['name'])==strtolower($k)) { print "<option values='$f[name]' selected='selected'>$f[name]</option>"; } |
|
73 | - else { print "<option values='$f[name]'>$f[name]</option>"; } |
|
74 | - } |
|
75 | - } |
|
76 | - print "</select>"; |
|
77 | - print "</td>"; |
|
78 | - print "</tr>"; |
|
79 | - } |
|
80 | - } |
|
81 | - else { |
|
82 | - $Result->show("info", _("No result"), false); |
|
83 | - } |
|
84 | - print "</table>"; |
|
85 | - print "</form>"; |
|
86 | - } |
|
87 | - ?> |
|
72 | + if (strtolower($f['name'])==strtolower($k)) { print "<option values='$f[name]' selected='selected'>$f[name]</option>"; } |
|
73 | + else { print "<option values='$f[name]'>$f[name]</option>"; } |
|
74 | + } |
|
75 | + } |
|
76 | + print "</select>"; |
|
77 | + print "</td>"; |
|
78 | + print "</tr>"; |
|
79 | + } |
|
80 | + } |
|
81 | + else { |
|
82 | + $Result->show("info", _("No result"), false); |
|
83 | + } |
|
84 | + print "</table>"; |
|
85 | + print "</form>"; |
|
86 | + } |
|
87 | + ?> |
|
88 | 88 | </pre> |
89 | 89 | </div> |
90 | 90 |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | |
27 | 27 | # verify that user has permissions to add subnet |
28 | 28 | if($_POST['action'] == "add") { |
29 | - if($Sections->check_permission ($User->user, $_POST['sectionId']) != 3) { $Result->show("danger", _('You do not have permissions to add new subnet in this section')."!", true, true); } |
|
29 | + if($Sections->check_permission ($User->user, $_POST['sectionId']) != 3) { $Result->show("danger", _('You do not have permissions to add new subnet in this section')."!", true, true); } |
|
30 | 30 | } |
31 | 31 | # otherwise check subnet permission |
32 | 32 | else { |
33 | - if($Subnets->check_permission ($User->user, $_POST['subnetId']) != 3) { $Result->show("danger", _('You do not have permissions to add edit/delete this subnet')."!", true, true); } |
|
33 | + if($Subnets->check_permission ($User->user, $_POST['subnetId']) != 3) { $Result->show("danger", _('You do not have permissions to add edit/delete this subnet')."!", true, true); } |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -47,32 +47,32 @@ discard block |
||
47 | 47 | # we are editing or deleting existing subnet, get old details |
48 | 48 | if ($_POST['action'] != "add") { |
49 | 49 | $subnet_old_details = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']); |
50 | - # false id |
|
51 | - if (sizeof($subnet_old_details)==0) { $Result->show("danger", _("Invalid subnetId"), true, true); } |
|
50 | + # false id |
|
51 | + if (sizeof($subnet_old_details)==0) { $Result->show("danger", _("Invalid subnetId"), true, true); } |
|
52 | 52 | } |
53 | 53 | # we are adding new subnet |
54 | 54 | else { |
55 | - # for selecting master subnet if added from subnet details and slave inheritance! |
|
56 | - if(strlen($_POST['subnetId']) > 0) { |
|
57 | - $subnet_old_temp = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']); |
|
58 | - $subnet_old_details['masterSubnetId'] = @$subnet_old_temp['id']; // same master subnet ID for nested |
|
59 | - // slave subnet inheritance |
|
55 | + # for selecting master subnet if added from subnet details and slave inheritance! |
|
56 | + if(strlen($_POST['subnetId']) > 0) { |
|
57 | + $subnet_old_temp = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']); |
|
58 | + $subnet_old_details['masterSubnetId'] = @$subnet_old_temp['id']; // same master subnet ID for nested |
|
59 | + // slave subnet inheritance |
|
60 | 60 | $subnet_old_details['vlanId'] = @$subnet_old_temp['vlanId']; // inherit vlanId |
61 | - $subnet_old_details['vrfId'] = @$subnet_old_temp['vrfId']; // inherit vrfId |
|
62 | - $subnet_old_details['allowRequests'] = @$subnet_old_temp['allowRequests']; // inherit requests |
|
63 | - $subnet_old_details['showName'] = @$subnet_old_temp['showName']; // inherit show name |
|
64 | - $subnet_old_details['device'] = @$subnet_old_temp['device']; // inherit device |
|
65 | - $subnet_old_details['permissions'] = @$subnet_old_temp['permissions']; // inherit permissions |
|
66 | - $subnet_old_details['scanAgent'] = @$subnet_old_temp['scanAgent']; // inherit scanAgent |
|
67 | - $subnet_old_details['pingSubnet'] = @$subnet_old_temp['pingSubnet']; // inherit pingSubnet |
|
68 | - $subnet_old_details['discoverSubnet'] = @$subnet_old_temp['discoverSubnet']; // inherit discovery |
|
69 | - $subnet_old_details['nameserverId'] = @$subnet_old_temp['nameserverId']; // inherit nameserver |
|
70 | - |
|
71 | - } |
|
72 | - # set master if it came from free space! |
|
73 | - if(isset($_POST['freespaceMSID'])) { |
|
74 | - $subnet_old_details['masterSubnetId'] = $_POST['freespaceMSID']; // dumb name, but it will do :) |
|
75 | - } |
|
61 | + $subnet_old_details['vrfId'] = @$subnet_old_temp['vrfId']; // inherit vrfId |
|
62 | + $subnet_old_details['allowRequests'] = @$subnet_old_temp['allowRequests']; // inherit requests |
|
63 | + $subnet_old_details['showName'] = @$subnet_old_temp['showName']; // inherit show name |
|
64 | + $subnet_old_details['device'] = @$subnet_old_temp['device']; // inherit device |
|
65 | + $subnet_old_details['permissions'] = @$subnet_old_temp['permissions']; // inherit permissions |
|
66 | + $subnet_old_details['scanAgent'] = @$subnet_old_temp['scanAgent']; // inherit scanAgent |
|
67 | + $subnet_old_details['pingSubnet'] = @$subnet_old_temp['pingSubnet']; // inherit pingSubnet |
|
68 | + $subnet_old_details['discoverSubnet'] = @$subnet_old_temp['discoverSubnet']; // inherit discovery |
|
69 | + $subnet_old_details['nameserverId'] = @$subnet_old_temp['nameserverId']; // inherit nameserver |
|
70 | + |
|
71 | + } |
|
72 | + # set master if it came from free space! |
|
73 | + if(isset($_POST['freespaceMSID'])) { |
|
74 | + $subnet_old_details['masterSubnetId'] = $_POST['freespaceMSID']; // dumb name, but it will do :) |
|
75 | + } |
|
76 | 76 | } |
77 | 77 | # fetch custom fields |
78 | 78 | $custom_fields = $Tools->fetch_custom_fields('subnets'); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | # for vlan result on the fly |
88 | 88 | if(isset($_POST['vlanId'])) { |
89 | - $subnet_old_details['vlanId'] = $_POST['vlanId']; |
|
89 | + $subnet_old_details['vlanId'] = $_POST['vlanId']; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | # set readonly flag |
@@ -144,21 +144,21 @@ discard block |
||
144 | 144 | <td> |
145 | 145 | <?php |
146 | 146 | if ($_POST['subnetId'] && $_POST['action'] == "add"){ $showDropMenuFull = 1; } |
147 | - # set CIDR |
|
148 | - if (isset($subnet_old_temp['subnet'])&&$subnet_old_temp['isFolder']!="1") { $cidr = $Subnets->transform_to_dotted($subnet_old_temp['subnet']).'/'.($subnet_old_temp['mask']+1);} //for nested |
|
149 | - if (isset($subnet_old_temp['subnet']) && ($showDropMenuFull)) { $dropdown_menu = $Subnets->subnet_dropdown_print_available($_POST['sectionId'], $_POST['subnetId']); } |
|
147 | + # set CIDR |
|
148 | + if (isset($subnet_old_temp['subnet'])&&$subnet_old_temp['isFolder']!="1") { $cidr = $Subnets->transform_to_dotted($subnet_old_temp['subnet']).'/'.($subnet_old_temp['mask']+1);} //for nested |
|
149 | + if (isset($subnet_old_temp['subnet']) && ($showDropMenuFull)) { $dropdown_menu = $Subnets->subnet_dropdown_print_available($_POST['sectionId'], $_POST['subnetId']); } |
|
150 | 150 | |
151 | - if (@$_POST['location'] == "ipcalc") { $cidr = strlen($_POST['bitmask'])>0 ? $_POST['subnet'].'/'.$_POST['bitmask'] : $_POST['subnet']; } //from ipcalc |
|
151 | + if (@$_POST['location'] == "ipcalc") { $cidr = strlen($_POST['bitmask'])>0 ? $_POST['subnet'].'/'.$_POST['bitmask'] : $_POST['subnet']; } //from ipcalc |
|
152 | 152 | if ($_POST['action'] != "add") { $cidr = $Subnets->transform_to_dotted($subnet_old_details['subnet']).'/'.$subnet_old_details['mask']; } //editing existing |
153 | 153 | |
154 | - # reset CIDR if $showDropMenuFull |
|
155 | - if ($showDropMenuFull && strlen(@$dropdown_menu)>2) { |
|
156 | - $cidr = explode("\n",$dropdown_menu); |
|
157 | - $cidr = substr(strip_tags($cidr[1]), 2); |
|
158 | - //validate |
|
159 | - if ($Subnets->verify_cidr_address($cidr)===false) { unset($cidr); }; |
|
160 | - } |
|
161 | - ?> |
|
154 | + # reset CIDR if $showDropMenuFull |
|
155 | + if ($showDropMenuFull && strlen(@$dropdown_menu)>2) { |
|
156 | + $cidr = explode("\n",$dropdown_menu); |
|
157 | + $cidr = substr(strip_tags($cidr[1]), 2); |
|
158 | + //validate |
|
159 | + if ($Subnets->verify_cidr_address($cidr)===false) { unset($cidr); }; |
|
160 | + } |
|
161 | + ?> |
|
162 | 162 | |
163 | 163 | |
164 | 164 | <?php if (!$showDropMenuFull){ ?> |
@@ -206,13 +206,13 @@ discard block |
||
206 | 206 | <td> |
207 | 207 | <select name="sectionIdNew" class="form-control input-sm input-w-auto"> |
208 | 208 | <?php |
209 | - if($sections!==false) { |
|
210 | - foreach($sections as $section) { |
|
211 | - /* selected? */ |
|
212 | - if($_POST['sectionId'] == $section->id) { print '<option value="'. $section->id .'" selected>'. $section->name .'</option>'. "\n"; } |
|
213 | - else { print '<option value="'. $section->id .'">'. $section->name .'</option>'. "\n"; } |
|
214 | - } |
|
215 | - } |
|
209 | + if($sections!==false) { |
|
210 | + foreach($sections as $section) { |
|
211 | + /* selected? */ |
|
212 | + if($_POST['sectionId'] == $section->id) { print '<option value="'. $section->id .'" selected>'. $section->name .'</option>'. "\n"; } |
|
213 | + else { print '<option value="'. $section->id .'">'. $section->name .'</option>'. "\n"; } |
|
214 | + } |
|
215 | + } |
|
216 | 216 | ?> |
217 | 217 | </select> |
218 | 218 | </td> |
@@ -236,21 +236,21 @@ discard block |
||
236 | 236 | <select name="device" class="form-control input-sm input-w-auto"> |
237 | 237 | <option value="0"><?php print _('None'); ?></option> |
238 | 238 | <?php |
239 | - // fetch all devices |
|
240 | - $devices = $Admin->fetch_all_objects("devices"); |
|
241 | - // loop |
|
242 | - if ($devices!==false) { |
|
243 | - foreach($devices as $device) { |
|
244 | - //check if permitted in this section! |
|
245 | - $sections = explode(";", $device->sections); |
|
246 | - if(in_array($_POST['sectionId'], $sections)) { |
|
247 | - //if same |
|
248 | - if($device->id == @$subnet_old_details['device']) { print '<option value="'. $device->id .'" selected>'. $device->hostname .'</option>'. "\n"; } |
|
249 | - else { print '<option value="'. $device->id .'">'. $device->hostname .'</option>'. "\n"; } |
|
250 | - } |
|
251 | - } |
|
252 | - } |
|
253 | - ?> |
|
239 | + // fetch all devices |
|
240 | + $devices = $Admin->fetch_all_objects("devices"); |
|
241 | + // loop |
|
242 | + if ($devices!==false) { |
|
243 | + foreach($devices as $device) { |
|
244 | + //check if permitted in this section! |
|
245 | + $sections = explode(";", $device->sections); |
|
246 | + if(in_array($_POST['sectionId'], $sections)) { |
|
247 | + //if same |
|
248 | + if($device->id == @$subnet_old_details['device']) { print '<option value="'. $device->id .'" selected>'. $device->hostname .'</option>'. "\n"; } |
|
249 | + else { print '<option value="'. $device->id .'">'. $device->hostname .'</option>'. "\n"; } |
|
250 | + } |
|
251 | + } |
|
252 | + } |
|
253 | + ?> |
|
254 | 254 | </select> |
255 | 255 | </td> |
256 | 256 | <td class="info2"><?php print _('Select device where subnet is located'); ?></td> |
@@ -270,9 +270,9 @@ discard block |
||
270 | 270 | <td><?php print _('Master Subnet'); ?></td> |
271 | 271 | <td> |
272 | 272 | <?php |
273 | - if ($showDropMenuFull) { $Subnets->subnet_dropdown_master_only (@$subnet_old_details['masterSubnetId']); } |
|
274 | - else { $Subnets->print_mastersubnet_dropdown_menu ($_POST['sectionId'], @$subnet_old_details['masterSubnetId']);} |
|
275 | - ?> |
|
273 | + if ($showDropMenuFull) { $Subnets->subnet_dropdown_master_only (@$subnet_old_details['masterSubnetId']); } |
|
274 | + else { $Subnets->print_mastersubnet_dropdown_menu ($_POST['sectionId'], @$subnet_old_details['masterSubnetId']);} |
|
275 | + ?> |
|
276 | 276 | </td> |
277 | 277 | <td class="info2"><?php print _('Enter master subnet if you want to nest it under existing subnet, or select root to create root subnet'); ?>!</td> |
278 | 278 | </tr> |
@@ -280,14 +280,14 @@ discard block |
||
280 | 280 | <?php |
281 | 281 | |
282 | 282 | |
283 | - /* set default value */ |
|
284 | - if(empty($subnet_old_details['vrfId'])) { $subnet_old_details['vrfId'] = "0"; } |
|
285 | - /* set default value */ |
|
286 | - if(empty($subnet_old_details['allowRequests'])) { $subnet_old_details['allowRequests'] = "0"; } |
|
283 | + /* set default value */ |
|
284 | + if(empty($subnet_old_details['vrfId'])) { $subnet_old_details['vrfId'] = "0"; } |
|
285 | + /* set default value */ |
|
286 | + if(empty($subnet_old_details['allowRequests'])) { $subnet_old_details['allowRequests'] = "0"; } |
|
287 | 287 | |
288 | - /* if vlan support is enabled print available vlans */ |
|
289 | - if($User->settings->enableVRF==1) { |
|
290 | - print '<tr>' . "\n"; |
|
288 | + /* if vlan support is enabled print available vlans */ |
|
289 | + if($User->settings->enableVRF==1) { |
|
290 | + print '<tr>' . "\n"; |
|
291 | 291 | print ' <td class="middle">'._('VRF').'</td>' . "\n"; |
292 | 292 | print ' <td>' . "\n"; |
293 | 293 | print ' <select name="vrfId" class="form-control input-sm input-w-auto">'. "\n"; |
@@ -297,33 +297,33 @@ discard block |
||
297 | 297 | print '<option value="0">'._('None').'</option>'; |
298 | 298 | |
299 | 299 | if($vrfs!=false) { |
300 | - foreach($vrfs as $vrf) { |
|
301 | - // set permitted |
|
302 | - $permitted_sections = explode(";", $vrf->sections); |
|
303 | - // section must be in array |
|
304 | - if (strlen($vrf->sections)==0 || in_array(@$_POST['sectionId'], $permitted_sections)) { |
|
305 | - //cast |
|
306 | - $vrf = (array) $vrf; |
|
307 | - // set description if present |
|
308 | - $vrf['description'] = strlen($vrf['description'])>0 ? " ($vrf[description])" : ""; |
|
309 | - |
|
310 | - if ($vrf['vrfId'] == $subnet_old_details['vrfId']) { print '<option value="'. $vrf['vrfId'] .'" selected>'.$vrf['name'].$vrf['description'].'</option>'; } |
|
311 | - else { print '<option value="'. $vrf['vrfId'] .'">'.$vrf['name'].$vrf['description'].'</option>'; } |
|
312 | - } |
|
313 | - } |
|
300 | + foreach($vrfs as $vrf) { |
|
301 | + // set permitted |
|
302 | + $permitted_sections = explode(";", $vrf->sections); |
|
303 | + // section must be in array |
|
304 | + if (strlen($vrf->sections)==0 || in_array(@$_POST['sectionId'], $permitted_sections)) { |
|
305 | + //cast |
|
306 | + $vrf = (array) $vrf; |
|
307 | + // set description if present |
|
308 | + $vrf['description'] = strlen($vrf['description'])>0 ? " ($vrf[description])" : ""; |
|
309 | + |
|
310 | + if ($vrf['vrfId'] == $subnet_old_details['vrfId']) { print '<option value="'. $vrf['vrfId'] .'" selected>'.$vrf['name'].$vrf['description'].'</option>'; } |
|
311 | + else { print '<option value="'. $vrf['vrfId'] .'">'.$vrf['name'].$vrf['description'].'</option>'; } |
|
312 | + } |
|
313 | + } |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | print ' </select>'. "\n"; |
317 | 317 | print ' </td>' . "\n"; |
318 | 318 | print ' <td class="info2">'._('Add this subnet to VRF').'</td>' . "\n"; |
319 | - print '</tr>' . "\n"; |
|
319 | + print '</tr>' . "\n"; |
|
320 | 320 | |
321 | - } |
|
322 | - else { |
|
323 | - print '<tr style="display:none"><td colspan="8"><input type="hidden" name="vrfId" value="'. $subnet_old_details['vrfId'] .'"></td></tr>'. "\n"; |
|
324 | - } |
|
321 | + } |
|
322 | + else { |
|
323 | + print '<tr style="display:none"><td colspan="8"><input type="hidden" name="vrfId" value="'. $subnet_old_details['vrfId'] .'"></td></tr>'. "\n"; |
|
324 | + } |
|
325 | 325 | |
326 | - ?> |
|
326 | + ?> |
|
327 | 327 | |
328 | 328 | <?php if($_POST['action']!="delete") { ?> |
329 | 329 | <!-- mark full --> |
@@ -376,30 +376,30 @@ discard block |
||
376 | 376 | |
377 | 377 | <!-- Scan agents --> |
378 | 378 | <?php |
379 | - //fetch agents |
|
380 | - $agents = $Tools->fetch_all_objects ("scanAgents"); |
|
381 | - // set hidden |
|
382 | - if (@$subnet_old_details['pingSubnet']=="1" || @$subnet_old_details['discoverSubnet']=="1") { $hidden = ""; } |
|
383 | - else { $hidden = "hidden"; } |
|
384 | - //print form |
|
385 | - if ($agents!==false) { |
|
386 | - print "<tr id='scanAgentDropdown' class='$hidden'>"; |
|
387 | - print "<td>"._('Select agent')."</td>"; |
|
388 | - print "<td>"; |
|
389 | - print "<select name='scanAgent' class='form-control input-sm'>"; |
|
390 | - foreach ($agents as $a) { |
|
391 | - if ($a->id==@$subnet_old_details['scanAgent']) { print "<option value='".$a->id."' selected='selected'>".$a->name." (".$a->description.")</option>"; } |
|
392 | - else { print "<option value='".$a->id."'>".$a->name." (".$a->description.")</option>"; } |
|
393 | - } |
|
394 | - print "</select>"; |
|
395 | - print "</td>"; |
|
396 | - print ' <td class="info2">'._('Select which scanagent to use').'</td>' . "\n"; |
|
397 | - print "</tr>"; |
|
398 | - } |
|
399 | - |
|
400 | - //check host status |
|
401 | - $checked = @$subnet_old_details['pingSubnet']==1 ? "checked": ""; |
|
402 | - print '<tr>' . "\n"; |
|
379 | + //fetch agents |
|
380 | + $agents = $Tools->fetch_all_objects ("scanAgents"); |
|
381 | + // set hidden |
|
382 | + if (@$subnet_old_details['pingSubnet']=="1" || @$subnet_old_details['discoverSubnet']=="1") { $hidden = ""; } |
|
383 | + else { $hidden = "hidden"; } |
|
384 | + //print form |
|
385 | + if ($agents!==false) { |
|
386 | + print "<tr id='scanAgentDropdown' class='$hidden'>"; |
|
387 | + print "<td>"._('Select agent')."</td>"; |
|
388 | + print "<td>"; |
|
389 | + print "<select name='scanAgent' class='form-control input-sm'>"; |
|
390 | + foreach ($agents as $a) { |
|
391 | + if ($a->id==@$subnet_old_details['scanAgent']) { print "<option value='".$a->id."' selected='selected'>".$a->name." (".$a->description.")</option>"; } |
|
392 | + else { print "<option value='".$a->id."'>".$a->name." (".$a->description.")</option>"; } |
|
393 | + } |
|
394 | + print "</select>"; |
|
395 | + print "</td>"; |
|
396 | + print ' <td class="info2">'._('Select which scanagent to use').'</td>' . "\n"; |
|
397 | + print "</tr>"; |
|
398 | + } |
|
399 | + |
|
400 | + //check host status |
|
401 | + $checked = @$subnet_old_details['pingSubnet']==1 ? "checked": ""; |
|
402 | + print '<tr>' . "\n"; |
|
403 | 403 | print ' <td>'._('Check hosts status').'</td>' . "\n"; |
404 | 404 | print ' <td>' . "\n"; |
405 | 405 | print ' <input type="checkbox" name="pingSubnet" class="input-switch-agents-ping" value="1" '.$checked.'>'. "\n"; |
@@ -407,42 +407,42 @@ discard block |
||
407 | 407 | print ' <td class="info2">'._('Ping hosts inside subnet to check availability').'</td>' . "\n"; |
408 | 408 | print '</tr>'; |
409 | 409 | |
410 | - //Discover new hosts |
|
411 | - $checked = @$subnet_old_details['discoverSubnet']==1 ? "checked": ""; |
|
412 | - print '<tr>' . "\n"; |
|
410 | + //Discover new hosts |
|
411 | + $checked = @$subnet_old_details['discoverSubnet']==1 ? "checked": ""; |
|
412 | + print '<tr>' . "\n"; |
|
413 | 413 | print ' <td>'._('Discover new hosts').'</td>' . "\n"; |
414 | 414 | print ' <td>' . "\n"; |
415 | 415 | print ' <input type="checkbox" name="discoverSubnet" class="input-switch-agents-scan" value="1" '.$checked.'>'. "\n"; |
416 | 416 | print ' </td>' . "\n"; |
417 | 417 | print ' <td class="info2">'._('Discover new hosts in this subnet').'</td>' . "\n"; |
418 | 418 | print '</tr>'; |
419 | - ?> |
|
419 | + ?> |
|
420 | 420 | |
421 | 421 | <tr> |
422 | 422 | <td colspan="3"><hr></td> |
423 | 423 | </tr> |
424 | 424 | |
425 | 425 | <?php |
426 | - /* allow / deny IP requests if enabled in settings */ |
|
427 | - if($User->settings->enableIPrequests==1) { |
|
428 | - //checked |
|
429 | - $checked = @$subnet_old_details['allowRequests']==1 ? "checked" : ""; |
|
426 | + /* allow / deny IP requests if enabled in settings */ |
|
427 | + if($User->settings->enableIPrequests==1) { |
|
428 | + //checked |
|
429 | + $checked = @$subnet_old_details['allowRequests']==1 ? "checked" : ""; |
|
430 | 430 | |
431 | - print '<tr>' . "\n"; |
|
431 | + print '<tr>' . "\n"; |
|
432 | 432 | print ' <td>'._('IP Requests').'</td>' . "\n"; |
433 | 433 | print ' <td>' . "\n"; |
434 | 434 | print ' <input type="checkbox" name="allowRequests" class="input-switch" value="1" '.$checked.'>'. "\n"; |
435 | 435 | print ' </td>' . "\n"; |
436 | 436 | print ' <td class="info2">'._('Allow or deny IP requests for this subnet').'</td>' . "\n"; |
437 | - print '</tr>' . "\n"; |
|
437 | + print '</tr>' . "\n"; |
|
438 | 438 | |
439 | - } |
|
440 | - else { |
|
441 | - print '<tr style="display:none"><td colspan="8"><input type="hidden" name="allowRequests" value="'. $subnet_old_details['allowRequests'] .'"></td></tr>'. "\n"; |
|
442 | - } |
|
439 | + } |
|
440 | + else { |
|
441 | + print '<tr style="display:none"><td colspan="8"><input type="hidden" name="allowRequests" value="'. $subnet_old_details['allowRequests'] .'"></td></tr>'. "\n"; |
|
442 | + } |
|
443 | 443 | |
444 | - //show names instead of ip address |
|
445 | - print '<tr>' . "\n"; |
|
444 | + //show names instead of ip address |
|
445 | + print '<tr>' . "\n"; |
|
446 | 446 | print ' <td>'._('Show as name').'</td>' . "\n"; |
447 | 447 | print ' <td>' . "\n"; |
448 | 448 | print ' <input type="checkbox" name="showName" class="input-switch" value="1" ' . "\n"; |
@@ -465,12 +465,12 @@ discard block |
||
465 | 465 | <?php |
466 | 466 | print ' </td>' . "\n"; |
467 | 467 | print ' <td class="info2">'._('Show Subnet name instead of subnet IP address').'</td>' . "\n"; |
468 | - print '</tr>' . "\n"; |
|
468 | + print '</tr>' . "\n"; |
|
469 | 469 | |
470 | - //autocreate reverse records |
|
471 | - if($User->settings->enablePowerDNS==1) { |
|
472 | - $checked = @$subnet_old_details['DNSrecursive']==1 ? "checked": ""; |
|
473 | - print '<tr>' . "\n"; |
|
470 | + //autocreate reverse records |
|
471 | + if($User->settings->enablePowerDNS==1) { |
|
472 | + $checked = @$subnet_old_details['DNSrecursive']==1 ? "checked": ""; |
|
473 | + print '<tr>' . "\n"; |
|
474 | 474 | print ' <td>'._('Autocreate reverse records').'</td>' . "\n"; |
475 | 475 | print ' <td>' . "\n"; |
476 | 476 | print ' <input type="checkbox" name="DNSrecursive" class="input-switch" value="1" '.$checked.'>'. "\n"; |
@@ -478,9 +478,9 @@ discard block |
||
478 | 478 | print ' <td class="info2">'._('Auto create reverse (PTR) records for this subnet').'</td>' . "\n"; |
479 | 479 | print '</tr>'; |
480 | 480 | |
481 | - // show records |
|
482 | - $checked = @$subnet_old_details['DNSrecords']==1 ? "checked": ""; |
|
483 | - print '<tr>' . "\n"; |
|
481 | + // show records |
|
482 | + $checked = @$subnet_old_details['DNSrecords']==1 ? "checked": ""; |
|
483 | + print '<tr>' . "\n"; |
|
484 | 484 | print ' <td>'._('Show DNS records').'</td>' . "\n"; |
485 | 485 | print ' <td>' . "\n"; |
486 | 486 | print ' <input type="checkbox" name="DNSrecords" class="input-switch" value="1" '.$checked.'>'. "\n"; |
@@ -489,102 +489,102 @@ discard block |
||
489 | 489 | print '</tr>'; |
490 | 490 | } |
491 | 491 | |
492 | - //custom Subnet fields |
|
493 | - if(sizeof($custom_fields) > 0) { |
|
494 | - # count datepickers |
|
495 | - $timeP = 0; |
|
496 | - |
|
497 | - print "<tr>"; |
|
498 | - print " <td colspan='3' class='hr'><hr></td>"; |
|
499 | - print "</tr>"; |
|
500 | - foreach($custom_fields as $field) { |
|
501 | - |
|
502 | - # replace spaces |
|
503 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
504 | - # retain newlines |
|
505 | - $subnet_old_details[$field['name']] = str_replace("\n", "\\n", @$subnet_old_details[$field['name']]); |
|
506 | - |
|
507 | - # set default value ! |
|
508 | - if ($_POST['action']=="add") { $subnet_old_details[$field['name']] = $field['Default']; } |
|
509 | - |
|
510 | - # required |
|
511 | - $required = $field['Null']=="NO" ? "*" : ""; |
|
512 | - print '<tr>'. "\n"; |
|
513 | - print ' <td>'. $field['name'] .' '.$required.'</td>'. "\n"; |
|
514 | - print ' <td colspan="2">'. "\n"; |
|
515 | - |
|
516 | - //set type |
|
517 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
518 | - //parse values |
|
519 | - $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
520 | - //null |
|
521 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
522 | - |
|
523 | - print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
524 | - foreach($tmp as $v) { |
|
525 | - if($v==$subnet_old_details[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
526 | - else { print "<option value='$v'>$v</option>"; } |
|
527 | - } |
|
528 | - print "</select>"; |
|
529 | - } |
|
530 | - //date and time picker |
|
531 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
532 | - // just for first |
|
533 | - if($timeP==0) { |
|
534 | - print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
535 | - print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
536 | - print '<script type="text/javascript">'; |
|
537 | - print '$(document).ready(function() {'; |
|
538 | - //date only |
|
539 | - print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
540 | - //date + time |
|
541 | - print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
542 | - |
|
543 | - print '})'; |
|
544 | - print '</script>'; |
|
545 | - } |
|
546 | - $timeP++; |
|
547 | - |
|
548 | - //set size |
|
549 | - if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
550 | - else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
551 | - |
|
552 | - //field |
|
553 | - if(!isset($subnet_old_details[$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"; } |
|
554 | - else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $subnet_old_details[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
555 | - } |
|
556 | - //boolean |
|
557 | - elseif($field['type'] == "tinyint(1)") { |
|
558 | - print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
559 | - $tmp = array(0=>"No",1=>"Yes"); |
|
560 | - //null |
|
561 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
562 | - |
|
563 | - foreach($tmp as $k=>$v) { |
|
564 | - if(strlen($subnet_old_details[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
565 | - elseif($k==$subnet_old_details[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
566 | - else { print "<option value='$k'>"._($v)."</option>"; } |
|
567 | - } |
|
568 | - print "</select>"; |
|
569 | - } |
|
570 | - //text |
|
571 | - elseif($field['type'] == "text") { |
|
572 | - print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. str_replace("\\n","",$subnet_old_details[$field['name']]). '</textarea>'. "\n"; |
|
573 | - } |
|
574 | - //default - input field |
|
575 | - else { |
|
576 | - print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. $subnet_old_details[$field['name']]. '" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
577 | - } |
|
578 | - |
|
579 | - print ' </td>'. "\n"; |
|
580 | - print '</tr>'. "\n"; |
|
581 | - } |
|
582 | - } |
|
583 | - |
|
584 | - # divider |
|
585 | - print "<tr>"; |
|
586 | - print " <td colspan='3' class='hr'><hr></td>"; |
|
587 | - print "</tr>"; |
|
492 | + //custom Subnet fields |
|
493 | + if(sizeof($custom_fields) > 0) { |
|
494 | + # count datepickers |
|
495 | + $timeP = 0; |
|
496 | + |
|
497 | + print "<tr>"; |
|
498 | + print " <td colspan='3' class='hr'><hr></td>"; |
|
499 | + print "</tr>"; |
|
500 | + foreach($custom_fields as $field) { |
|
501 | + |
|
502 | + # replace spaces |
|
503 | + $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
504 | + # retain newlines |
|
505 | + $subnet_old_details[$field['name']] = str_replace("\n", "\\n", @$subnet_old_details[$field['name']]); |
|
506 | + |
|
507 | + # set default value ! |
|
508 | + if ($_POST['action']=="add") { $subnet_old_details[$field['name']] = $field['Default']; } |
|
509 | + |
|
510 | + # required |
|
511 | + $required = $field['Null']=="NO" ? "*" : ""; |
|
512 | + print '<tr>'. "\n"; |
|
513 | + print ' <td>'. $field['name'] .' '.$required.'</td>'. "\n"; |
|
514 | + print ' <td colspan="2">'. "\n"; |
|
515 | + |
|
516 | + //set type |
|
517 | + if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
518 | + //parse values |
|
519 | + $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
520 | + //null |
|
521 | + if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
522 | + |
|
523 | + print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
524 | + foreach($tmp as $v) { |
|
525 | + if($v==$subnet_old_details[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
526 | + else { print "<option value='$v'>$v</option>"; } |
|
527 | + } |
|
528 | + print "</select>"; |
|
529 | + } |
|
530 | + //date and time picker |
|
531 | + elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
532 | + // just for first |
|
533 | + if($timeP==0) { |
|
534 | + print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
535 | + print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
536 | + print '<script type="text/javascript">'; |
|
537 | + print '$(document).ready(function() {'; |
|
538 | + //date only |
|
539 | + print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
540 | + //date + time |
|
541 | + print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
542 | + |
|
543 | + print '})'; |
|
544 | + print '</script>'; |
|
545 | + } |
|
546 | + $timeP++; |
|
547 | + |
|
548 | + //set size |
|
549 | + if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
550 | + else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
551 | + |
|
552 | + //field |
|
553 | + if(!isset($subnet_old_details[$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"; } |
|
554 | + else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $subnet_old_details[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
555 | + } |
|
556 | + //boolean |
|
557 | + elseif($field['type'] == "tinyint(1)") { |
|
558 | + print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
559 | + $tmp = array(0=>"No",1=>"Yes"); |
|
560 | + //null |
|
561 | + if($field['Null']!="NO") { $tmp[2] = ""; } |
|
562 | + |
|
563 | + foreach($tmp as $k=>$v) { |
|
564 | + if(strlen($subnet_old_details[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
565 | + elseif($k==$subnet_old_details[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
566 | + else { print "<option value='$k'>"._($v)."</option>"; } |
|
567 | + } |
|
568 | + print "</select>"; |
|
569 | + } |
|
570 | + //text |
|
571 | + elseif($field['type'] == "text") { |
|
572 | + print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. str_replace("\\n","",$subnet_old_details[$field['name']]). '</textarea>'. "\n"; |
|
573 | + } |
|
574 | + //default - input field |
|
575 | + else { |
|
576 | + print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. $subnet_old_details[$field['name']]. '" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
577 | + } |
|
578 | + |
|
579 | + print ' </td>'. "\n"; |
|
580 | + print '</tr>'. "\n"; |
|
581 | + } |
|
582 | + } |
|
583 | + |
|
584 | + # divider |
|
585 | + print "<tr>"; |
|
586 | + print " <td colspan='3' class='hr'><hr></td>"; |
|
587 | + print "</tr>"; |
|
588 | 588 | ?> |
589 | 589 | |
590 | 590 | <!-- set parameters to slave subnets --> |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | <?php |
608 | 608 | # warning if delete |
609 | 609 | if($_POST['action'] == "delete" || (@$_POST['location'] == "IPaddresses" && $_POST['action'] != "add" )) { |
610 | - print "<div class='alert alert-warning' style='margin-top:0px;'><strong>"._('Warning')."</strong><br>"._('Removing subnets will delete ALL underlaying subnets and belonging IP addresses')."!</div>"; |
|
610 | + print "<div class='alert alert-warning' style='margin-top:0px;'><strong>"._('Warning')."</strong><br>"._('Removing subnets will delete ALL underlaying subnets and belonging IP addresses')."!</div>"; |
|
611 | 611 | } |
612 | 612 | ?> |
613 | 613 | |
@@ -620,11 +620,11 @@ discard block |
||
620 | 620 | <div class="btn-group"> |
621 | 621 | <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
622 | 622 | <?php |
623 | - //if action == edit and location = IPaddresses print also delete form |
|
624 | - if($_POST['action'] == "edit" && @$_POST['location'] == "IPaddresses") { |
|
625 | - print "<button class='btn btn-sm btn-default btn-danger editSubnetSubmitDelete editSubnetSubmit'><i class='icon-white icon-trash'></i> "._('Delete subnet')."</button>"; |
|
626 | - } |
|
627 | - ?> |
|
623 | + //if action == edit and location = IPaddresses print also delete form |
|
624 | + if($_POST['action'] == "edit" && @$_POST['location'] == "IPaddresses") { |
|
625 | + print "<button class='btn btn-sm btn-default btn-danger editSubnetSubmitDelete editSubnetSubmit'><i class='icon-white icon-trash'></i> "._('Delete subnet')."</button>"; |
|
626 | + } |
|
627 | + ?> |
|
628 | 628 | <button type="submit" class="btn btn-sm btn-default editSubnetSubmit <?php if($_POST['action']=="delete") print "btn-danger"; else print "btn-success"; ?>"><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> |
629 | 629 | </div> |
630 | 630 |