@@ -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 |
@@ -4,59 +4,59 @@ |
||
4 | 4 | * truncate subnet result |
5 | 5 | *********************/ |
6 | 6 | /* functions */ |
7 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
7 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
8 | 8 | |
9 | 9 | # initialize user object |
10 | -$Database = new Database_PDO; |
|
11 | -$User = new User ($Database); |
|
10 | +$Database = new Database_PDO; |
|
11 | +$User = new User ($Database); |
|
12 | 12 | $Admin = new Admin ($Database, false); |
13 | 13 | $Subnets = new Subnets ($Database); |
14 | -$Addresses = new Addresses ($Database); |
|
14 | +$Addresses = new Addresses ($Database); |
|
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # validate csrf cookie |
21 | -$User->csrf_cookie ("validate", "truncate", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; |
|
21 | +$User->csrf_cookie ("validate", "truncate", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : ""; |
|
22 | 22 | |
23 | 23 | |
24 | 24 | # id must be numeric |
25 | -if(!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true); } |
|
25 | +if (!is_numeric ($_POST['subnetId'])) { $Result->show ("danger", _ ("Invalid ID"), true); } |
|
26 | 26 | |
27 | 27 | # get subnet details |
28 | 28 | $subnet = $Subnets->fetch_subnet (null, $_POST['subnetId']); |
29 | 29 | |
30 | 30 | # verify that user has write permissions for subnet |
31 | 31 | $subnetPerm = $Subnets->check_permission ($User->user, $subnet->id); |
32 | -if($subnetPerm < 3) { $Result->show("danger", _('You do not have permissions to resize subnet').'!', true); } |
|
32 | +if ($subnetPerm < 3) { $Result->show ("danger", _ ('You do not have permissions to resize subnet').'!', true); } |
|
33 | 33 | |
34 | 34 | # truncate network |
35 | -if(!$Subnets->subnet_truncate($subnet->id)) { $Result->show("danger", _("Failed to truncate subnet"), false); } |
|
36 | -else { $Result->show("success", _("Subnet truncated succesfully")."!", false); } |
|
35 | +if (!$Subnets->subnet_truncate ($subnet->id)) { $Result->show ("danger", _ ("Failed to truncate subnet"), false); } |
|
36 | +else { $Result->show ("success", _ ("Subnet truncated succesfully")."!", false); } |
|
37 | 37 | |
38 | 38 | # check for DNS PTR records |
39 | -if ($User->settings->enablePowerDNS=="1" && $subnet->DNSrecursive=="1") { |
|
39 | +if ($User->settings->enablePowerDNS == "1" && $subnet->DNSrecursive == "1") { |
|
40 | 40 | # powerDNS class |
41 | 41 | $PowerDNS = new PowerDNS ($Database); |
42 | - if($PowerDNS->db_check()!==false) { |
|
42 | + if ($PowerDNS->db_check () !== false) { |
|
43 | 43 | // set name |
44 | 44 | $zone = $PowerDNS->get_ptr_zone_name ($subnet->ip, $subnet->mask); |
45 | 45 | // fetch domain |
46 | 46 | $domain = $PowerDNS->fetch_domain_by_name ($zone); |
47 | 47 | // if it exist remove all PTR records |
48 | - if ($domain!==false) { |
|
48 | + if ($domain !== false) { |
|
49 | 49 | // get all PTRs |
50 | 50 | $ptr_indexes = $Addresses->ptr_get_subnet_indexes ($subnet->id); |
51 | 51 | // remove existing records and links |
52 | 52 | $PowerDNS->remove_all_ptr_records ($domain->id, $ptr_indexes); |
53 | 53 | // ok |
54 | - $Result->show("success", "PTR records removed", false); |
|
54 | + $Result->show ("success", "PTR records removed", false); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | # error |
58 | 58 | else { |
59 | - $Result->show("danger", "Cannot connect to powerDNS database", false); |
|
59 | + $Result->show ("danger", "Cannot connect to powerDNS database", false); |
|
60 | 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 |
@@ -67,7 +67,9 @@ |
||
67 | 67 | if (sizeof($custom_fields>0)) { |
68 | 68 | foreach ($custom_fields as $f) { |
69 | 69 | // replace descr with description |
70 | - if ($k=="descr") $k = "description"; |
|
70 | + if ($k=="descr") { |
|
71 | + $k = "description"; |
|
72 | + } |
|
71 | 73 | |
72 | 74 | if (strtolower($f['name'])==strtolower($k)) { print "<option values='$f[name]' selected='selected'>$f[name]</option>"; } |
73 | 75 | else { print "<option values='$f[name]'>$f[name]</option>"; } |
@@ -5,48 +5,48 @@ discard block |
||
5 | 5 | ********************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
11 | +$Database = new Database_PDO; |
|
12 | 12 | $User = new User ($Database); |
13 | 13 | $Subnets = new Subnets ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # try to fetch |
21 | 21 | $res = $Subnets->resolve_ripe_arin ($_POST['subnet']); |
22 | 22 | ?> |
23 | 23 | |
24 | 24 | <!-- header --> |
25 | -<div class="pHeader"><?php print _(ucwords($res['result'])); ?></div> |
|
25 | +<div class="pHeader"><?php print _ (ucwords ($res['result'])); ?></div> |
|
26 | 26 | |
27 | 27 | <!-- content --> |
28 | 28 | <div class="pContent"> |
29 | 29 | <?php |
30 | 30 | // error ? |
31 | - if ($res['result']=="error") { |
|
32 | - $Result->show("danger", _(ucwords($res['error'])), false); |
|
31 | + if ($res['result'] == "error") { |
|
32 | + $Result->show ("danger", _ (ucwords ($res['error'])), false); |
|
33 | 33 | } |
34 | 34 | // ok, print field matching |
35 | 35 | else { |
36 | 36 | // fetch all fields for subnets |
37 | - $standard_fields = array("description"); |
|
37 | + $standard_fields = array ("description"); |
|
38 | 38 | $custom_fields = $Tools->fetch_custom_fields ("subnets"); |
39 | 39 | |
40 | 40 | // leave only varchar and text |
41 | 41 | foreach ($custom_fields as $k=>$f) { |
42 | - if (!(strpos($f['type'], "varchar")!==false || $f['type']=="text")) { |
|
42 | + if (!(strpos ($f['type'], "varchar") !== false || $f['type'] == "text")) { |
|
43 | 43 | unset($custom_fields[$k]); |
44 | 44 | } |
45 | 45 | } |
46 | 46 | // append description |
47 | - $custom_fields = array_merge(array("description"=>array("name"=>"description")), $custom_fields); |
|
47 | + $custom_fields = array_merge (array ("description"=>array ("name"=>"description")), $custom_fields); |
|
48 | 48 | |
49 | - print "<h4>"._("Please select fields to populate:")."</h4>"; |
|
49 | + print "<h4>"._ ("Please select fields to populate:")."</h4>"; |
|
50 | 50 | // form |
51 | 51 | print "<form name='ripe-fields' id='ripe-fields'>"; |
52 | 52 | print "<table class='table'>"; |
@@ -60,17 +60,17 @@ discard block |
||
60 | 60 | |
61 | 61 | print "<td>"; |
62 | 62 | // add + |
63 | - $d = str_replace(" ", "___", $d); |
|
63 | + $d = str_replace (" ", "___", $d); |
|
64 | 64 | print "<select name='$d' class='form-control input-sm'>"; |
65 | 65 | print "<option value='0'>None</option>"; |
66 | 66 | // print custom |
67 | - if (sizeof($custom_fields>0)) { |
|
67 | + if (sizeof ($custom_fields > 0)) { |
|
68 | 68 | foreach ($custom_fields as $f) { |
69 | 69 | // replace descr with description |
70 | - if ($k=="descr") $k = "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>"; } |
|
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 | 74 | } |
75 | 75 | } |
76 | 76 | print "</select>"; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | } |
81 | 81 | else { |
82 | - $Result->show("info", _("No result"), false); |
|
82 | + $Result->show ("info", _ ("No result"), false); |
|
83 | 83 | } |
84 | 84 | print "</table>"; |
85 | 85 | print "</form>"; |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | <!-- footer --> |
93 | 93 | <div class="pFooter"> |
94 | 94 | <div class="btn-group"> |
95 | - <button class="btn btn-sm btn-default hidePopup2"><?php print _('Cancel'); ?></button> |
|
96 | - <?php if($res['result']!="error") { ?> |
|
97 | - <button class="btn btn-sm btn-default btn-success" id="ripeMatchSubmit"><i class="fa fa-check"></i> <?php print _('fill'); ?></button> |
|
95 | + <button class="btn btn-sm btn-default hidePopup2"><?php print _ ('Cancel'); ?></button> |
|
96 | + <?php if ($res['result'] != "error") { ?> |
|
97 | + <button class="btn btn-sm btn-default btn-success" id="ripeMatchSubmit"><i class="fa fa-check"></i> <?php print _ ('fill'); ?></button> |
|
98 | 98 | <?php } ?> |
99 | 99 | </div> |
100 | 100 | </div> |
101 | 101 | \ No newline at end of file |
@@ -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 |
@@ -77,8 +77,9 @@ discard block |
||
77 | 77 | # fetch custom fields |
78 | 78 | $custom_fields = $Tools->fetch_custom_fields('subnets'); |
79 | 79 | # fetch vrfs |
80 | -if($User->settings->enableVRF==1) |
|
81 | -$vrfs = $Tools->fetch_all_objects("vrf", "name"); |
|
80 | +if($User->settings->enableVRF==1) { |
|
81 | + $vrfs = $Tools->fetch_all_objects("vrf", "name"); |
|
82 | +} |
|
82 | 83 | # check if it has slaves - if yes it cannot be splitted! |
83 | 84 | $slaves = $Subnets->has_slaves($_POST['subnetId']); |
84 | 85 | # fetch all sections |
@@ -162,8 +163,12 @@ discard block |
||
162 | 163 | |
163 | 164 | |
164 | 165 | <?php if (!$showDropMenuFull){ ?> |
165 | - <input type="text" class="form-control input-sm input-w-200" name="subnet" placeholder="<?php print _('subnet in CIDR'); ?>" value="<?php print @$cidr; ?>" <?php if ($readonly) print "readonly"; ?>> |
|
166 | - <?php } else { ?> |
|
166 | + <input type="text" class="form-control input-sm input-w-200" name="subnet" placeholder="<?php print _('subnet in CIDR'); ?>" value="<?php print @$cidr; ?>" <?php if ($readonly) { |
|
167 | + print "readonly"; |
|
168 | +} |
|
169 | +?>> |
|
170 | + <?php } |
|
171 | +else { ?> |
|
167 | 172 | <div class="input-group input-w-200"> |
168 | 173 | <input type="text" class="form-control input-sm input-w-200" name="subnet" placeholder="<?php print _('subnet in CIDR'); ?>" value="<?php print @$cidr; ?>"> |
169 | 174 | <?php if (strlen($dropdown_menu)>0) { ?> |
@@ -362,7 +367,10 @@ discard block |
||
362 | 367 | <td> |
363 | 368 | <div class="btn-group"> |
364 | 369 | <button class="btn btn-xs btn-default" id="resize" rel="tooltip" data-container='body' title="<?php print _('Resize subnet'); ?>" data-subnetId="<?php print $_POST['subnetId']; ?>"><i class="fa fa-gray fa-arrows-v"></i></button> |
365 | - <button class="btn btn-xs btn-default <?php if($slaves) print "disabled"; ?>" id="split" rel="tooltip" data-container='body' title="<?php print _('Split subnet'); ?>" data-subnetId="<?php print $_POST['subnetId']; ?>"><i class="fa fa-gray fa-expand"></i></button> |
|
370 | + <button class="btn btn-xs btn-default <?php if($slaves) { |
|
371 | + print "disabled"; |
|
372 | +} |
|
373 | +?>" id="split" rel="tooltip" data-container='body' title="<?php print _('Split subnet'); ?>" data-subnetId="<?php print $_POST['subnetId']; ?>"><i class="fa fa-gray fa-expand"></i></button> |
|
366 | 374 | <button class="btn btn-xs btn-default" id="truncate" rel="tooltip" data-container='body' title="<?php print _('Truncate subnet'); ?>" data-subnetId="<?php print $_POST['subnetId']; ?>"><i class="fa fa-gray fa-trash-o"></i></button> |
367 | 375 | </div> |
368 | 376 | </td> |
@@ -625,7 +633,15 @@ discard block |
||
625 | 633 | print "<button class='btn btn-sm btn-default btn-danger editSubnetSubmitDelete editSubnetSubmit'><i class='icon-white icon-trash'></i> "._('Delete subnet')."</button>"; |
626 | 634 | } |
627 | 635 | ?> |
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> |
|
636 | + <button type="submit" class="btn btn-sm btn-default editSubnetSubmit <?php if($_POST['action']=="delete") { |
|
637 | + print "btn-danger"; |
|
638 | +} |
|
639 | +else { |
|
640 | + print "btn-success"; |
|
641 | +} |
|
642 | +?>"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } |
|
643 | +else if ($_POST['action']=="delete") { print "fa-trash-o"; } |
|
644 | +else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
629 | 645 | </div> |
630 | 646 | |
631 | 647 | <div class="manageSubnetEditResult"></div> |
@@ -6,31 +6,31 @@ discard block |
||
6 | 6 | |
7 | 7 | |
8 | 8 | /* functions */ |
9 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
9 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
10 | 10 | |
11 | 11 | # initialize user object |
12 | -$Database = new Database_PDO; |
|
13 | -$User = new User ($Database); |
|
12 | +$Database = new Database_PDO; |
|
13 | +$User = new User ($Database); |
|
14 | 14 | $Admin = new Admin ($Database, false); |
15 | -$Sections = new Sections ($Database); |
|
15 | +$Sections = new Sections ($Database); |
|
16 | 16 | $Subnets = new Subnets ($Database); |
17 | -$Tools = new Tools ($Database); |
|
17 | +$Tools = new Tools ($Database); |
|
18 | 18 | $Result = new Result (); |
19 | 19 | |
20 | 20 | # verify that user is logged in |
21 | -$User->check_user_session(); |
|
21 | +$User->check_user_session (); |
|
22 | 22 | |
23 | 23 | # create csrf token |
24 | 24 | $csrf = $User->csrf_cookie ("create", "subnet"); |
25 | 25 | |
26 | 26 | |
27 | 27 | # verify that user has permissions to add subnet |
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); } |
|
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); } |
|
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 | |
@@ -46,51 +46,51 @@ discard block |
||
46 | 46 | |
47 | 47 | # we are editing or deleting existing subnet, get old details |
48 | 48 | if ($_POST['action'] != "add") { |
49 | - $subnet_old_details = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']); |
|
49 | + $subnet_old_details = (array) $Subnets->fetch_subnet (null, $_POST['subnetId']); |
|
50 | 50 | # false id |
51 | - if (sizeof($subnet_old_details)==0) { $Result->show("danger", _("Invalid subnetId"), true, true); } |
|
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 | 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 |
|
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 | 59 | // slave subnet inheritance |
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 |
|
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 | 70 | |
71 | 71 | } |
72 | 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 :) |
|
73 | + if (isset($_POST['freespaceMSID'])) { |
|
74 | + $subnet_old_details['masterSubnetId'] = $_POST['freespaceMSID']; // dumb name, but it will do :) |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | # fetch custom fields |
78 | -$custom_fields = $Tools->fetch_custom_fields('subnets'); |
|
78 | +$custom_fields = $Tools->fetch_custom_fields ('subnets'); |
|
79 | 79 | # fetch vrfs |
80 | -if($User->settings->enableVRF==1) |
|
81 | -$vrfs = $Tools->fetch_all_objects("vrf", "name"); |
|
80 | +if ($User->settings->enableVRF == 1) |
|
81 | +$vrfs = $Tools->fetch_all_objects ("vrf", "name"); |
|
82 | 82 | # check if it has slaves - if yes it cannot be splitted! |
83 | -$slaves = $Subnets->has_slaves($_POST['subnetId']); |
|
83 | +$slaves = $Subnets->has_slaves ($_POST['subnetId']); |
|
84 | 84 | # fetch all sections |
85 | -$sections = $Sections->fetch_all_sections(); |
|
85 | +$sections = $Sections->fetch_all_sections (); |
|
86 | 86 | |
87 | 87 | # for vlan result on the fly |
88 | -if(isset($_POST['vlanId'])) { |
|
88 | +if (isset($_POST['vlanId'])) { |
|
89 | 89 | $subnet_old_details['vlanId'] = $_POST['vlanId']; |
90 | 90 | } |
91 | 91 | |
92 | 92 | # set readonly flag |
93 | -$readonly = $_POST['action']=="edit" || $_POST['action']=="delete" ? true : false; |
|
93 | +$readonly = $_POST['action'] == "edit" || $_POST['action'] == "delete" ? true : false; |
|
94 | 94 | ?> |
95 | 95 | |
96 | 96 | <script type="text/javascript"> |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | if (ping==true || scan==true) { $("tr#scanAgentDropdown").removeClass("hidden"); } |
119 | 119 | else if (ping==false && scan==false) { $("tr#scanAgentDropdown").addClass("hidden"); } |
120 | 120 | }); |
121 | -<?php if ($User->settings->enableThreshold=="1") { ?> |
|
121 | +<?php if ($User->settings->enableThreshold == "1") { ?> |
|
122 | 122 | $('.slider').slider().on('slide', function(ev){ |
123 | 123 | $('.slider-text span').html(ev.value); |
124 | 124 | }); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | |
132 | 132 | <!-- header --> |
133 | -<div class="pHeader"><?php print ucwords(_("$_POST[action]")); ?> <?php print _('subnet'); ?></div> |
|
133 | +<div class="pHeader"><?php print ucwords (_ ("$_POST[action]")); ?> <?php print _ ('subnet'); ?></div> |
|
134 | 134 | |
135 | 135 | <!-- content --> |
136 | 136 | <div class="pContent"> |
@@ -140,33 +140,33 @@ discard block |
||
140 | 140 | |
141 | 141 | <!-- name --> |
142 | 142 | <tr> |
143 | - <td class="middle"><?php print _('Subnet'); ?></td> |
|
143 | + <td class="middle"><?php print _ ('Subnet'); ?></td> |
|
144 | 144 | <td> |
145 | 145 | <?php |
146 | - if ($_POST['subnetId'] && $_POST['action'] == "add"){ $showDropMenuFull = 1; } |
|
146 | + if ($_POST['subnetId'] && $_POST['action'] == "add") { $showDropMenuFull = 1; } |
|
147 | 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']); } |
|
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 |
|
152 | - if ($_POST['action'] != "add") { $cidr = $Subnets->transform_to_dotted($subnet_old_details['subnet']).'/'.$subnet_old_details['mask']; } //editing existing |
|
151 | + if (@$_POST['location'] == "ipcalc") { $cidr = strlen ($_POST['bitmask']) > 0 ? $_POST['subnet'].'/'.$_POST['bitmask'] : $_POST['subnet']; } //from ipcalc |
|
152 | + if ($_POST['action'] != "add") { $cidr = $Subnets->transform_to_dotted ($subnet_old_details['subnet']).'/'.$subnet_old_details['mask']; } //editing existing |
|
153 | 153 | |
154 | 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); |
|
155 | + if ($showDropMenuFull && strlen (@$dropdown_menu) > 2) { |
|
156 | + $cidr = explode ("\n", $dropdown_menu); |
|
157 | + $cidr = substr (strip_tags ($cidr[1]), 2); |
|
158 | 158 | //validate |
159 | - if ($Subnets->verify_cidr_address($cidr)===false) { unset($cidr); }; |
|
159 | + if ($Subnets->verify_cidr_address ($cidr) === false) { unset($cidr); }; |
|
160 | 160 | } |
161 | 161 | ?> |
162 | 162 | |
163 | 163 | |
164 | - <?php if (!$showDropMenuFull){ ?> |
|
165 | - <input type="text" class="form-control input-sm input-w-200" name="subnet" placeholder="<?php print _('subnet in CIDR'); ?>" value="<?php print @$cidr; ?>" <?php if ($readonly) print "readonly"; ?>> |
|
164 | + <?php if (!$showDropMenuFull) { ?> |
|
165 | + <input type="text" class="form-control input-sm input-w-200" name="subnet" placeholder="<?php print _ ('subnet in CIDR'); ?>" value="<?php print @$cidr; ?>" <?php if ($readonly) print "readonly"; ?>> |
|
166 | 166 | <?php } else { ?> |
167 | 167 | <div class="input-group input-w-200"> |
168 | - <input type="text" class="form-control input-sm input-w-200" name="subnet" placeholder="<?php print _('subnet in CIDR'); ?>" value="<?php print @$cidr; ?>"> |
|
169 | - <?php if (strlen($dropdown_menu)>0) { ?> |
|
168 | + <input type="text" class="form-control input-sm input-w-200" name="subnet" placeholder="<?php print _ ('subnet in CIDR'); ?>" value="<?php print @$cidr; ?>"> |
|
169 | + <?php if (strlen ($dropdown_menu) > 0) { ?> |
|
170 | 170 | <div class="input-group-btn"> |
171 | 171 | <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Select <span class="caret"></span></button> |
172 | 172 | <ul class="dropdown-menu dropdown-menu-right dropdown-subnets"> |
@@ -180,193 +180,193 @@ discard block |
||
180 | 180 | </td> |
181 | 181 | <td class="info2"> |
182 | 182 | <div class="btn-group"> |
183 | - <button type="button" class="btn btn-xs btn-default show-masks" rel='tooltip' data-placement="bottom" title='<?php print _('Subnet masks'); ?>' data-closeClass="hidePopup2"><i class="fa fa-th-large"></i></button> |
|
184 | - <?php if($User->settings->enableSNMP == "1" && $_POST['action']=="add") { ?> |
|
185 | - <button type="button" class="btn btn-xs btn-default" id='snmp-routing' rel='tooltip' data-placement="bottom" title='<?php print _('Search for subnets through SNMP'); ?>'><i class="fa fa-cogs"></i></button> |
|
183 | + <button type="button" class="btn btn-xs btn-default show-masks" rel='tooltip' data-placement="bottom" title='<?php print _ ('Subnet masks'); ?>' data-closeClass="hidePopup2"><i class="fa fa-th-large"></i></button> |
|
184 | + <?php if ($User->settings->enableSNMP == "1" && $_POST['action'] == "add") { ?> |
|
185 | + <button type="button" class="btn btn-xs btn-default" id='snmp-routing' rel='tooltip' data-placement="bottom" title='<?php print _ ('Search for subnets through SNMP'); ?>'><i class="fa fa-cogs"></i></button> |
|
186 | 186 | <?php } ?> |
187 | - <button type="button" class="btn btn-xs btn-default" id='get-ripe' rel='tooltip' data-placement="bottom" title='<?php print _('Get information from RIPE / ARIN database'); ?>'><i class="fa fa-refresh"></i></button> |
|
187 | + <button type="button" class="btn btn-xs btn-default" id='get-ripe' rel='tooltip' data-placement="bottom" title='<?php print _ ('Get information from RIPE / ARIN database'); ?>'><i class="fa fa-refresh"></i></button> |
|
188 | 188 | </div> |
189 | - <?php print _('Enter subnet in CIDR format'); ?> |
|
189 | + <?php print _ ('Enter subnet in CIDR format'); ?> |
|
190 | 190 | </td> |
191 | 191 | </tr> |
192 | 192 | |
193 | 193 | <!-- description --> |
194 | 194 | <tr> |
195 | - <td class="middle"><?php print _('Description'); ?></td> |
|
195 | + <td class="middle"><?php print _ ('Description'); ?></td> |
|
196 | 196 | <td> |
197 | - <input type="text" class="form-control input-sm input-w-200" id="field-description" name="description" placeholder="<?php print _('subnet description'); ?>" value="<?php print @$subnet_old_details['description']; ?>"> |
|
197 | + <input type="text" class="form-control input-sm input-w-200" id="field-description" name="description" placeholder="<?php print _ ('subnet description'); ?>" value="<?php print @$subnet_old_details['description']; ?>"> |
|
198 | 198 | </td> |
199 | - <td class="info2"><?php print _('Enter subnet description'); ?></td> |
|
199 | + <td class="info2"><?php print _ ('Enter subnet description'); ?></td> |
|
200 | 200 | </tr> |
201 | 201 | |
202 | - <?php if($_POST['action'] != "add") { ?> |
|
202 | + <?php if ($_POST['action'] != "add") { ?> |
|
203 | 203 | <!-- move to different section --> |
204 | 204 | <tr> |
205 | - <td class="middle"><?php print _('Section'); ?></td> |
|
205 | + <td class="middle"><?php print _ ('Section'); ?></td> |
|
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) { |
|
209 | + if ($sections !== false) { |
|
210 | + foreach ($sections as $section) { |
|
211 | 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"; } |
|
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 | 214 | } |
215 | 215 | } |
216 | 216 | ?> |
217 | 217 | </select> |
218 | 218 | </td> |
219 | - <td class="info2"><?php print _('Move to different section'); ?></td> |
|
219 | + <td class="info2"><?php print _ ('Move to different section'); ?></td> |
|
220 | 220 | </tr> |
221 | 221 | <?php } ?> |
222 | 222 | |
223 | 223 | <!-- vlan --> |
224 | 224 | <tr> |
225 | - <td class="middle"><?php print _('VLAN'); ?></td> |
|
225 | + <td class="middle"><?php print _ ('VLAN'); ?></td> |
|
226 | 226 | <td id="vlanDropdown"> |
227 | 227 | <?php include('edit-vlan-dropdown.php'); ?> |
228 | 228 | </td> |
229 | - <td class="info2"><?php print _('Select VLAN'); ?></td> |
|
229 | + <td class="info2"><?php print _ ('Select VLAN'); ?></td> |
|
230 | 230 | </tr> |
231 | 231 | |
232 | 232 | <!-- Device --> |
233 | 233 | <tr> |
234 | - <td class="middle"><?php print _('Device'); ?></td> |
|
234 | + <td class="middle"><?php print _ ('Device'); ?></td> |
|
235 | 235 | <td id="deviceDropdown"> |
236 | 236 | <select name="device" class="form-control input-sm input-w-auto"> |
237 | - <option value="0"><?php print _('None'); ?></option> |
|
237 | + <option value="0"><?php print _ ('None'); ?></option> |
|
238 | 238 | <?php |
239 | 239 | // fetch all devices |
240 | - $devices = $Admin->fetch_all_objects("devices"); |
|
240 | + $devices = $Admin->fetch_all_objects ("devices"); |
|
241 | 241 | // loop |
242 | - if ($devices!==false) { |
|
243 | - foreach($devices as $device) { |
|
242 | + if ($devices !== false) { |
|
243 | + foreach ($devices as $device) { |
|
244 | 244 | //check if permitted in this section! |
245 | - $sections = explode(";", $device->sections); |
|
246 | - if(in_array($_POST['sectionId'], $sections)) { |
|
245 | + $sections = explode (";", $device->sections); |
|
246 | + if (in_array ($_POST['sectionId'], $sections)) { |
|
247 | 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"; } |
|
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 | 250 | } |
251 | 251 | } |
252 | 252 | } |
253 | 253 | ?> |
254 | 254 | </select> |
255 | 255 | </td> |
256 | - <td class="info2"><?php print _('Select device where subnet is located'); ?></td> |
|
256 | + <td class="info2"><?php print _ ('Select device where subnet is located'); ?></td> |
|
257 | 257 | </tr> |
258 | 258 | |
259 | 259 | <!-- Nameservers --> |
260 | 260 | <tr> |
261 | - <td class="middle"><?php print _('Nameservers'); ?></td> |
|
261 | + <td class="middle"><?php print _ ('Nameservers'); ?></td> |
|
262 | 262 | <td id="nameserverDropdown"> |
263 | 263 | <?php include('edit-nameserver-dropdown.php'); ?> |
264 | 264 | </td> |
265 | - <td class="info2"><?php print _('Select nameserver set'); ?></td> |
|
265 | + <td class="info2"><?php print _ ('Select nameserver set'); ?></td> |
|
266 | 266 | </tr> |
267 | 267 | |
268 | 268 | <!-- Master subnet --> |
269 | 269 | <tr> |
270 | - <td><?php print _('Master Subnet'); ?></td> |
|
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']);} |
|
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 | 275 | ?> |
276 | 276 | </td> |
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> |
|
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> |
279 | 279 | |
280 | 280 | <?php |
281 | 281 | |
282 | 282 | |
283 | 283 | /* set default value */ |
284 | - if(empty($subnet_old_details['vrfId'])) { $subnet_old_details['vrfId'] = "0"; } |
|
284 | + if (empty($subnet_old_details['vrfId'])) { $subnet_old_details['vrfId'] = "0"; } |
|
285 | 285 | /* set default value */ |
286 | - if(empty($subnet_old_details['allowRequests'])) { $subnet_old_details['allowRequests'] = "0"; } |
|
286 | + if (empty($subnet_old_details['allowRequests'])) { $subnet_old_details['allowRequests'] = "0"; } |
|
287 | 287 | |
288 | 288 | /* if vlan support is enabled print available vlans */ |
289 | - if($User->settings->enableVRF==1) { |
|
290 | - print '<tr>' . "\n"; |
|
291 | - print ' <td class="middle">'._('VRF').'</td>' . "\n"; |
|
292 | - print ' <td>' . "\n"; |
|
293 | - print ' <select name="vrfId" class="form-control input-sm input-w-auto">'. "\n"; |
|
289 | + if ($User->settings->enableVRF == 1) { |
|
290 | + print '<tr>'."\n"; |
|
291 | + print ' <td class="middle">'._ ('VRF').'</td>'."\n"; |
|
292 | + print ' <td>'."\n"; |
|
293 | + print ' <select name="vrfId" class="form-control input-sm input-w-auto">'."\n"; |
|
294 | 294 | |
295 | 295 | //blank |
296 | - print '<option disabled="disabled">'._('Select VRF').'</option>'; |
|
297 | - print '<option value="0">'._('None').'</option>'; |
|
296 | + print '<option disabled="disabled">'._ ('Select VRF').'</option>'; |
|
297 | + print '<option value="0">'._ ('None').'</option>'; |
|
298 | 298 | |
299 | - if($vrfs!=false) { |
|
300 | - foreach($vrfs as $vrf) { |
|
299 | + if ($vrfs != false) { |
|
300 | + foreach ($vrfs as $vrf) { |
|
301 | 301 | // set permitted |
302 | - $permitted_sections = explode(";", $vrf->sections); |
|
302 | + $permitted_sections = explode (";", $vrf->sections); |
|
303 | 303 | // section must be in array |
304 | - if (strlen($vrf->sections)==0 || in_array(@$_POST['sectionId'], $permitted_sections)) { |
|
304 | + if (strlen ($vrf->sections) == 0 || in_array (@$_POST['sectionId'], $permitted_sections)) { |
|
305 | 305 | //cast |
306 | 306 | $vrf = (array) $vrf; |
307 | 307 | // set description if present |
308 | - $vrf['description'] = strlen($vrf['description'])>0 ? " ($vrf[description])" : ""; |
|
308 | + $vrf['description'] = strlen ($vrf['description']) > 0 ? " ($vrf[description])" : ""; |
|
309 | 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>'; } |
|
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 | 312 | } |
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
316 | - print ' </select>'. "\n"; |
|
317 | - print ' </td>' . "\n"; |
|
318 | - print ' <td class="info2">'._('Add this subnet to VRF').'</td>' . "\n"; |
|
319 | - print '</tr>' . "\n"; |
|
316 | + print ' </select>'."\n"; |
|
317 | + print ' </td>'."\n"; |
|
318 | + print ' <td class="info2">'._ ('Add this subnet to VRF').'</td>'."\n"; |
|
319 | + print '</tr>'."\n"; |
|
320 | 320 | |
321 | 321 | } |
322 | 322 | else { |
323 | - print '<tr style="display:none"><td colspan="8"><input type="hidden" name="vrfId" value="'. $subnet_old_details['vrfId'] .'"></td></tr>'. "\n"; |
|
323 | + print '<tr style="display:none"><td colspan="8"><input type="hidden" name="vrfId" value="'.$subnet_old_details['vrfId'].'"></td></tr>'."\n"; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | ?> |
327 | 327 | |
328 | - <?php if($_POST['action']!="delete") { ?> |
|
328 | + <?php if ($_POST['action'] != "delete") { ?> |
|
329 | 329 | <!-- mark full --> |
330 | 330 | <tr> |
331 | 331 | <td colspan="3"><hr></td> |
332 | 332 | </tr> |
333 | 333 | <tr> |
334 | - <td class="middle"><?php print _('Mark as full'); ?></td> |
|
334 | + <td class="middle"><?php print _ ('Mark as full'); ?></td> |
|
335 | 335 | <td> |
336 | - <?php $checked = @$subnet_old_details['isFull']==1 ? "checked": ""; ?> |
|
336 | + <?php $checked = @$subnet_old_details['isFull'] == 1 ? "checked" : ""; ?> |
|
337 | 337 | <input type="checkbox" name="isFull" class="input-switch" value="1" <?php print $checked; ?>> |
338 | 338 | </td> |
339 | - <td class="info2"><?php print _('Mark subnet as utilized'); ?></td> |
|
339 | + <td class="info2"><?php print _ ('Mark subnet as utilized'); ?></td> |
|
340 | 340 | </tr> |
341 | - <?php if ($User->settings->enableThreshold=="1") { ?> |
|
341 | + <?php if ($User->settings->enableThreshold == "1") { ?> |
|
342 | 342 | <tr> |
343 | - <td class="middle"><?php print _('Threshold'); ?></td> |
|
343 | + <td class="middle"><?php print _ ('Threshold'); ?></td> |
|
344 | 344 | <td> |
345 | - <?php $svalue = !is_null($subnet_old_details['threshold']) ? $subnet_old_details['threshold'] : 0; ?> |
|
345 | + <?php $svalue = !is_null ($subnet_old_details['threshold']) ? $subnet_old_details['threshold'] : 0; ?> |
|
346 | 346 | <input type="text" style="width:200px;" class="slider" name="threshold" value="<?php print $svalue; ?>" data-slider-handle="square" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="<?php print $svalue; ?>" data-slider-orientation="horizontal" data-slider-selection="after"> |
347 | 347 | </td> |
348 | - <td class="info2"><?php print _('Set subnet alert threshold'); ?> <span class='badge badge1 badge5 slider-text'><span><?php print $svalue; ?></span>%</span></td> |
|
348 | + <td class="info2"><?php print _ ('Set subnet alert threshold'); ?> <span class='badge badge1 badge5 slider-text'><span><?php print $svalue; ?></span>%</span></td> |
|
349 | 349 | </tr> |
350 | 350 | <?php } ?> |
351 | 351 | |
352 | 352 | <?php } ?> |
353 | 353 | |
354 | - <?php if($_POST['action']=="edit") { ?> |
|
354 | + <?php if ($_POST['action'] == "edit") { ?> |
|
355 | 355 | <!-- resize / split --> |
356 | 356 | <tr> |
357 | 357 | <td colspan="3"><hr></td> |
358 | 358 | </tr> |
359 | 359 | |
360 | 360 | <tr> |
361 | - <td class="middle"><?php print _('Resize'); ?> / <?php print _('split'); ?></td> |
|
361 | + <td class="middle"><?php print _ ('Resize'); ?> / <?php print _ ('split'); ?></td> |
|
362 | 362 | <td> |
363 | 363 | <div class="btn-group"> |
364 | - <button class="btn btn-xs btn-default" id="resize" rel="tooltip" data-container='body' title="<?php print _('Resize subnet'); ?>" data-subnetId="<?php print $_POST['subnetId']; ?>"><i class="fa fa-gray fa-arrows-v"></i></button> |
|
365 | - <button class="btn btn-xs btn-default <?php if($slaves) print "disabled"; ?>" id="split" rel="tooltip" data-container='body' title="<?php print _('Split subnet'); ?>" data-subnetId="<?php print $_POST['subnetId']; ?>"><i class="fa fa-gray fa-expand"></i></button> |
|
366 | - <button class="btn btn-xs btn-default" id="truncate" rel="tooltip" data-container='body' title="<?php print _('Truncate subnet'); ?>" data-subnetId="<?php print $_POST['subnetId']; ?>"><i class="fa fa-gray fa-trash-o"></i></button> |
|
364 | + <button class="btn btn-xs btn-default" id="resize" rel="tooltip" data-container='body' title="<?php print _ ('Resize subnet'); ?>" data-subnetId="<?php print $_POST['subnetId']; ?>"><i class="fa fa-gray fa-arrows-v"></i></button> |
|
365 | + <button class="btn btn-xs btn-default <?php if ($slaves) print "disabled"; ?>" id="split" rel="tooltip" data-container='body' title="<?php print _ ('Split subnet'); ?>" data-subnetId="<?php print $_POST['subnetId']; ?>"><i class="fa fa-gray fa-expand"></i></button> |
|
366 | + <button class="btn btn-xs btn-default" id="truncate" rel="tooltip" data-container='body' title="<?php print _ ('Truncate subnet'); ?>" data-subnetId="<?php print $_POST['subnetId']; ?>"><i class="fa fa-gray fa-trash-o"></i></button> |
|
367 | 367 | </div> |
368 | 368 | </td> |
369 | - <td class="info2"><?php print _('Resize, split or truncate this subnet'); ?></td> |
|
369 | + <td class="info2"><?php print _ ('Resize, split or truncate this subnet'); ?></td> |
|
370 | 370 | </tr> |
371 | 371 | <?php } ?> |
372 | 372 | |
@@ -379,42 +379,42 @@ discard block |
||
379 | 379 | //fetch agents |
380 | 380 | $agents = $Tools->fetch_all_objects ("scanAgents"); |
381 | 381 | // set hidden |
382 | - if (@$subnet_old_details['pingSubnet']=="1" || @$subnet_old_details['discoverSubnet']=="1") { $hidden = ""; } |
|
383 | - else { $hidden = "hidden"; } |
|
382 | + if (@$subnet_old_details['pingSubnet'] == "1" || @$subnet_old_details['discoverSubnet'] == "1") { $hidden = ""; } |
|
383 | + else { $hidden = "hidden"; } |
|
384 | 384 | //print form |
385 | - if ($agents!==false) { |
|
385 | + if ($agents !== false) { |
|
386 | 386 | print "<tr id='scanAgentDropdown' class='$hidden'>"; |
387 | - print "<td>"._('Select agent')."</td>"; |
|
387 | + print "<td>"._ ('Select agent')."</td>"; |
|
388 | 388 | print "<td>"; |
389 | 389 | print "<select name='scanAgent' class='form-control input-sm'>"; |
390 | 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>"; } |
|
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 | 393 | } |
394 | 394 | print "</select>"; |
395 | 395 | print "</td>"; |
396 | - print ' <td class="info2">'._('Select which scanagent to use').'</td>' . "\n"; |
|
396 | + print ' <td class="info2">'._ ('Select which scanagent to use').'</td>'."\n"; |
|
397 | 397 | print "</tr>"; |
398 | 398 | } |
399 | 399 | |
400 | 400 | //check host status |
401 | - $checked = @$subnet_old_details['pingSubnet']==1 ? "checked": ""; |
|
402 | - print '<tr>' . "\n"; |
|
403 | - print ' <td>'._('Check hosts status').'</td>' . "\n"; |
|
404 | - print ' <td>' . "\n"; |
|
405 | - print ' <input type="checkbox" name="pingSubnet" class="input-switch-agents-ping" value="1" '.$checked.'>'. "\n"; |
|
406 | - print ' </td>' . "\n"; |
|
407 | - print ' <td class="info2">'._('Ping hosts inside subnet to check availability').'</td>' . "\n"; |
|
401 | + $checked = @$subnet_old_details['pingSubnet'] == 1 ? "checked" : ""; |
|
402 | + print '<tr>'."\n"; |
|
403 | + print ' <td>'._ ('Check hosts status').'</td>'."\n"; |
|
404 | + print ' <td>'."\n"; |
|
405 | + print ' <input type="checkbox" name="pingSubnet" class="input-switch-agents-ping" value="1" '.$checked.'>'."\n"; |
|
406 | + print ' </td>'."\n"; |
|
407 | + print ' <td class="info2">'._ ('Ping hosts inside subnet to check availability').'</td>'."\n"; |
|
408 | 408 | print '</tr>'; |
409 | 409 | |
410 | 410 | //Discover new hosts |
411 | - $checked = @$subnet_old_details['discoverSubnet']==1 ? "checked": ""; |
|
412 | - print '<tr>' . "\n"; |
|
413 | - print ' <td>'._('Discover new hosts').'</td>' . "\n"; |
|
414 | - print ' <td>' . "\n"; |
|
415 | - print ' <input type="checkbox" name="discoverSubnet" class="input-switch-agents-scan" value="1" '.$checked.'>'. "\n"; |
|
416 | - print ' </td>' . "\n"; |
|
417 | - print ' <td class="info2">'._('Discover new hosts in this subnet').'</td>' . "\n"; |
|
411 | + $checked = @$subnet_old_details['discoverSubnet'] == 1 ? "checked" : ""; |
|
412 | + print '<tr>'."\n"; |
|
413 | + print ' <td>'._ ('Discover new hosts').'</td>'."\n"; |
|
414 | + print ' <td>'."\n"; |
|
415 | + print ' <input type="checkbox" name="discoverSubnet" class="input-switch-agents-scan" value="1" '.$checked.'>'."\n"; |
|
416 | + print ' </td>'."\n"; |
|
417 | + print ' <td class="info2">'._ ('Discover new hosts in this subnet').'</td>'."\n"; |
|
418 | 418 | print '</tr>'; |
419 | 419 | ?> |
420 | 420 | |
@@ -424,113 +424,113 @@ discard block |
||
424 | 424 | |
425 | 425 | <?php |
426 | 426 | /* allow / deny IP requests if enabled in settings */ |
427 | - if($User->settings->enableIPrequests==1) { |
|
427 | + if ($User->settings->enableIPrequests == 1) { |
|
428 | 428 | //checked |
429 | - $checked = @$subnet_old_details['allowRequests']==1 ? "checked" : ""; |
|
429 | + $checked = @$subnet_old_details['allowRequests'] == 1 ? "checked" : ""; |
|
430 | 430 | |
431 | - print '<tr>' . "\n"; |
|
432 | - print ' <td>'._('IP Requests').'</td>' . "\n"; |
|
433 | - print ' <td>' . "\n"; |
|
434 | - print ' <input type="checkbox" name="allowRequests" class="input-switch" value="1" '.$checked.'>'. "\n"; |
|
435 | - print ' </td>' . "\n"; |
|
436 | - print ' <td class="info2">'._('Allow or deny IP requests for this subnet').'</td>' . "\n"; |
|
437 | - print '</tr>' . "\n"; |
|
431 | + print '<tr>'."\n"; |
|
432 | + print ' <td>'._ ('IP Requests').'</td>'."\n"; |
|
433 | + print ' <td>'."\n"; |
|
434 | + print ' <input type="checkbox" name="allowRequests" class="input-switch" value="1" '.$checked.'>'."\n"; |
|
435 | + print ' </td>'."\n"; |
|
436 | + print ' <td class="info2">'._ ('Allow or deny IP requests for this subnet').'</td>'."\n"; |
|
437 | + print '</tr>'."\n"; |
|
438 | 438 | |
439 | 439 | } |
440 | 440 | else { |
441 | - print '<tr style="display:none"><td colspan="8"><input type="hidden" name="allowRequests" value="'. $subnet_old_details['allowRequests'] .'"></td></tr>'. "\n"; |
|
441 | + print '<tr style="display:none"><td colspan="8"><input type="hidden" name="allowRequests" value="'.$subnet_old_details['allowRequests'].'"></td></tr>'."\n"; |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | //show names instead of ip address |
445 | - print '<tr>' . "\n"; |
|
446 | - print ' <td>'._('Show as name').'</td>' . "\n"; |
|
447 | - print ' <td>' . "\n"; |
|
448 | - print ' <input type="checkbox" name="showName" class="input-switch" value="1" ' . "\n"; |
|
449 | - if( @$subnet_old_details['showName'] == 1) { print 'checked';} |
|
450 | - print ' >'. "\n"; |
|
445 | + print '<tr>'."\n"; |
|
446 | + print ' <td>'._ ('Show as name').'</td>'."\n"; |
|
447 | + print ' <td>'."\n"; |
|
448 | + print ' <input type="checkbox" name="showName" class="input-switch" value="1" '."\n"; |
|
449 | + if (@$subnet_old_details['showName'] == 1) { print 'checked'; } |
|
450 | + print ' >'."\n"; |
|
451 | 451 | |
452 | 452 | //hidden ones |
453 | 453 | ?> |
454 | 454 | <!-- hidden values --> |
455 | 455 | <input type="hidden" name="sectionId" value="<?php print $_POST['sectionId']; ?>"> |
456 | - <input type="hidden" name="subnetId" value="<?php print $_POST['subnetId']; ?>"> |
|
457 | - <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
|
456 | + <input type="hidden" name="subnetId" value="<?php print $_POST['subnetId']; ?>"> |
|
457 | + <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
|
458 | 458 | <input type="hidden" name="location" value="<?php print @$_POST['location']; ?>"> |
459 | - <?php if(isset($_POST['freespaceMSID'])) { ?> |
|
459 | + <?php if (isset($_POST['freespaceMSID'])) { ?> |
|
460 | 460 | <input type="hidden" name="freespace" value="true"> |
461 | 461 | <?php } ?> |
462 | - <input type="hidden" name="vrfIdOld" value="<?php print $subnet_old_details['vrfId']; ?>"> |
|
462 | + <input type="hidden" name="vrfIdOld" value="<?php print $subnet_old_details['vrfId']; ?>"> |
|
463 | 463 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
464 | 464 | |
465 | 465 | <?php |
466 | - print ' </td>' . "\n"; |
|
467 | - print ' <td class="info2">'._('Show Subnet name instead of subnet IP address').'</td>' . "\n"; |
|
468 | - print '</tr>' . "\n"; |
|
466 | + print ' </td>'."\n"; |
|
467 | + print ' <td class="info2">'._ ('Show Subnet name instead of subnet IP address').'</td>'."\n"; |
|
468 | + print '</tr>'."\n"; |
|
469 | 469 | |
470 | 470 | //autocreate reverse records |
471 | - if($User->settings->enablePowerDNS==1) { |
|
472 | - $checked = @$subnet_old_details['DNSrecursive']==1 ? "checked": ""; |
|
473 | - print '<tr>' . "\n"; |
|
474 | - print ' <td>'._('Autocreate reverse records').'</td>' . "\n"; |
|
475 | - print ' <td>' . "\n"; |
|
476 | - print ' <input type="checkbox" name="DNSrecursive" class="input-switch" value="1" '.$checked.'>'. "\n"; |
|
477 | - print ' </td>' . "\n"; |
|
478 | - print ' <td class="info2">'._('Auto create reverse (PTR) records for this subnet').'</td>' . "\n"; |
|
471 | + if ($User->settings->enablePowerDNS == 1) { |
|
472 | + $checked = @$subnet_old_details['DNSrecursive'] == 1 ? "checked" : ""; |
|
473 | + print '<tr>'."\n"; |
|
474 | + print ' <td>'._ ('Autocreate reverse records').'</td>'."\n"; |
|
475 | + print ' <td>'."\n"; |
|
476 | + print ' <input type="checkbox" name="DNSrecursive" class="input-switch" value="1" '.$checked.'>'."\n"; |
|
477 | + print ' </td>'."\n"; |
|
478 | + print ' <td class="info2">'._ ('Auto create reverse (PTR) records for this subnet').'</td>'."\n"; |
|
479 | 479 | print '</tr>'; |
480 | 480 | |
481 | 481 | // show records |
482 | - $checked = @$subnet_old_details['DNSrecords']==1 ? "checked": ""; |
|
483 | - print '<tr>' . "\n"; |
|
484 | - print ' <td>'._('Show DNS records').'</td>' . "\n"; |
|
485 | - print ' <td>' . "\n"; |
|
486 | - print ' <input type="checkbox" name="DNSrecords" class="input-switch" value="1" '.$checked.'>'. "\n"; |
|
487 | - print ' </td>' . "\n"; |
|
488 | - print ' <td class="info2">'._('Show DNS records for hosts').'</td>' . "\n"; |
|
482 | + $checked = @$subnet_old_details['DNSrecords'] == 1 ? "checked" : ""; |
|
483 | + print '<tr>'."\n"; |
|
484 | + print ' <td>'._ ('Show DNS records').'</td>'."\n"; |
|
485 | + print ' <td>'."\n"; |
|
486 | + print ' <input type="checkbox" name="DNSrecords" class="input-switch" value="1" '.$checked.'>'."\n"; |
|
487 | + print ' </td>'."\n"; |
|
488 | + print ' <td class="info2">'._ ('Show DNS records for hosts').'</td>'."\n"; |
|
489 | 489 | print '</tr>'; |
490 | 490 | } |
491 | 491 | |
492 | 492 | //custom Subnet fields |
493 | - if(sizeof($custom_fields) > 0) { |
|
493 | + if (sizeof ($custom_fields) > 0) { |
|
494 | 494 | # count datepickers |
495 | 495 | $timeP = 0; |
496 | 496 | |
497 | 497 | print "<tr>"; |
498 | 498 | print " <td colspan='3' class='hr'><hr></td>"; |
499 | 499 | print "</tr>"; |
500 | - foreach($custom_fields as $field) { |
|
500 | + foreach ($custom_fields as $field) { |
|
501 | 501 | |
502 | 502 | # replace spaces |
503 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
503 | + $field['nameNew'] = str_replace (" ", "___", $field['name']); |
|
504 | 504 | # retain newlines |
505 | - $subnet_old_details[$field['name']] = str_replace("\n", "\\n", @$subnet_old_details[$field['name']]); |
|
505 | + $subnet_old_details[$field['name']] = str_replace ("\n", "\\n", @$subnet_old_details[$field['name']]); |
|
506 | 506 | |
507 | 507 | # set default value ! |
508 | - if ($_POST['action']=="add") { $subnet_old_details[$field['name']] = $field['Default']; } |
|
508 | + if ($_POST['action'] == "add") { $subnet_old_details[$field['name']] = $field['Default']; } |
|
509 | 509 | |
510 | 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"; |
|
511 | + $required = $field['Null'] == "NO" ? "*" : ""; |
|
512 | + print '<tr>'."\n"; |
|
513 | + print ' <td>'.$field['name'].' '.$required.'</td>'."\n"; |
|
514 | + print ' <td colspan="2">'."\n"; |
|
515 | 515 | |
516 | 516 | //set type |
517 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
517 | + if (substr ($field['type'], 0, 3) == "set" || substr ($field['type'], 0, 4) == "enum") { |
|
518 | 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'])); |
|
519 | + $tmp = substr ($field['type'], 0, 3) == "set" ? explode (",", str_replace (array ("set(", ")", "'"), "", $field['type'])) : explode (",", str_replace (array ("enum(", ")", "'"), "", $field['type'])); |
|
520 | 520 | //null |
521 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
521 | + if ($field['Null'] != "NO") { array_unshift ($tmp, ""); } |
|
522 | 522 | |
523 | 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>"; } |
|
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 | 527 | } |
528 | 528 | print "</select>"; |
529 | 529 | } |
530 | 530 | //date and time picker |
531 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
531 | + elseif ($field['type'] == "date" || $field['type'] == "datetime") { |
|
532 | 532 | // just for first |
533 | - if($timeP==0) { |
|
533 | + if ($timeP == 0) { |
|
534 | 534 | print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
535 | 535 | print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
536 | 536 | print '<script type="text/javascript">'; |
@@ -546,38 +546,38 @@ discard block |
||
546 | 546 | $timeP++; |
547 | 547 | |
548 | 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"; } |
|
549 | + if ($field['type'] == "date") { $size = 10; $class = 'datepicker'; $format = "yyyy-MM-dd"; } |
|
550 | + else { $size = 19; $class = 'datetimepicker'; $format = "yyyy-MM-dd"; } |
|
551 | 551 | |
552 | 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"; } |
|
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 | 555 | } |
556 | 556 | //boolean |
557 | - elseif($field['type'] == "tinyint(1)") { |
|
557 | + elseif ($field['type'] == "tinyint(1)") { |
|
558 | 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"); |
|
559 | + $tmp = array (0=>"No", 1=>"Yes"); |
|
560 | 560 | //null |
561 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
561 | + if ($field['Null'] != "NO") { $tmp[2] = ""; } |
|
562 | 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>"; } |
|
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 | 567 | } |
568 | 568 | print "</select>"; |
569 | 569 | } |
570 | 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"; |
|
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 | 573 | } |
574 | 574 | //default - input field |
575 | 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"; |
|
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 | 577 | } |
578 | 578 | |
579 | - print ' </td>'. "\n"; |
|
580 | - print '</tr>'. "\n"; |
|
579 | + print ' </td>'."\n"; |
|
580 | + print '</tr>'."\n"; |
|
581 | 581 | } |
582 | 582 | } |
583 | 583 | |
@@ -588,12 +588,12 @@ discard block |
||
588 | 588 | ?> |
589 | 589 | |
590 | 590 | <!-- set parameters to slave subnets --> |
591 | - <?php if($slaves && $_POST['action']=="edit") { ?> |
|
591 | + <?php if ($slaves && $_POST['action'] == "edit") { ?> |
|
592 | 592 | <tr> |
593 | - <td><?php print _('Propagate changes'); ?></td> |
|
593 | + <td><?php print _ ('Propagate changes'); ?></td> |
|
594 | 594 | <td colspan="2"> |
595 | 595 | <input type="checkbox" name="set_inheritance" class="input-switch" value="Yes"> |
596 | - <span class="text-muted"><?php print _("Apply changes to underlying subnets"); ?></span> |
|
596 | + <span class="text-muted"><?php print _ ("Apply changes to underlying subnets"); ?></span> |
|
597 | 597 | </td> |
598 | 598 | </tr> |
599 | 599 | <tr> |
@@ -606,8 +606,8 @@ discard block |
||
606 | 606 | |
607 | 607 | <?php |
608 | 608 | # warning if delete |
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>"; |
|
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>"; |
|
611 | 611 | } |
612 | 612 | ?> |
613 | 613 | |
@@ -618,14 +618,14 @@ discard block |
||
618 | 618 | <!-- footer --> |
619 | 619 | <div class="pFooter"> |
620 | 620 | <div class="btn-group"> |
621 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
621 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
622 | 622 | <?php |
623 | 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>"; |
|
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 | 626 | } |
627 | 627 | ?> |
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> |
|
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 | |
631 | 631 | <div class="manageSubnetEditResult"></div> |
@@ -23,50 +23,50 @@ |
||
23 | 23 | /* print existing APIs */ |
24 | 24 | if($all_agents!==false) { |
25 | 25 | |
26 | - print '<table id="userPrint" class="table table-striped table-top table-auto">'; |
|
27 | - # headers |
|
28 | - print '<tr>'; |
|
26 | + print '<table id="userPrint" class="table table-striped table-top table-auto">'; |
|
27 | + # headers |
|
28 | + print '<tr>'; |
|
29 | 29 | print "<th>"._('Agent id').'</th>'; |
30 | - print "<th>"._('Name').'</th>'; |
|
30 | + print "<th>"._('Name').'</th>'; |
|
31 | 31 | print "<th>"._('Description').'</th>'; |
32 | 32 | print "<th>"._('Type').'</th>'; |
33 | 33 | print "<th>"._('Code').'</th>'; |
34 | 34 | print "<th>"._('Last access').'</th>'; |
35 | 35 | print '<th></th>'; |
36 | - print '</tr>'; |
|
36 | + print '</tr>'; |
|
37 | 37 | |
38 | - # loop |
|
39 | - foreach ($all_agents as $a) { |
|
40 | - //cast |
|
41 | - $a = (array) $a; |
|
38 | + # loop |
|
39 | + foreach ($all_agents as $a) { |
|
40 | + //cast |
|
41 | + $a = (array) $a; |
|
42 | 42 | |
43 | - // fixes |
|
44 | - $a['code'] = strlen($a['code'])===0 ? "/" : $a['code']; |
|
45 | - $a['last_access'] = strlen($a['last_access'])===0 ? "<span class='text-muted'>Never</span>" : $a['last_access']; |
|
43 | + // fixes |
|
44 | + $a['code'] = strlen($a['code'])===0 ? "/" : $a['code']; |
|
45 | + $a['last_access'] = strlen($a['last_access'])===0 ? "<span class='text-muted'>Never</span>" : $a['last_access']; |
|
46 | 46 | |
47 | ||
48 | - print '<tr>' . "\n"; |
|
49 | - print ' <td>' . $a['id'] . '</td>'. "\n"; |
|
50 | - print ' <td>' . $a['name'] . '</td>'. "\n"; |
|
51 | - print ' <td>' . $a['description'] . '</td>'. "\n"; |
|
52 | - print ' <td>' . $a['type'] . '</td>'. "\n"; |
|
53 | - print ' <td>' . $a['code'] . '</td>'. "\n"; |
|
54 | - print ' <td>' . $a['last_access'] . '</td>'. "\n"; |
|
47 | ||
48 | + print '<tr>' . "\n"; |
|
49 | + print ' <td>' . $a['id'] . '</td>'. "\n"; |
|
50 | + print ' <td>' . $a['name'] . '</td>'. "\n"; |
|
51 | + print ' <td>' . $a['description'] . '</td>'. "\n"; |
|
52 | + print ' <td>' . $a['type'] . '</td>'. "\n"; |
|
53 | + print ' <td>' . $a['code'] . '</td>'. "\n"; |
|
54 | + print ' <td>' . $a['last_access'] . '</td>'. "\n"; |
|
55 | 55 | |
56 | - // add/remove agents |
|
57 | - print " <td class='actions'>"; |
|
58 | - print " <div class='btn-group'>"; |
|
59 | - print " <button class='btn btn-xs btn-default editAgent' data-container='body' data-id='$a[id]' data-action='edit' rel='tooltip' title='"._('edit agent details')."'> <i class='fa fa-pencil'></i></button>"; |
|
60 | - print " <button class='btn btn-xs btn-default editAgent' data-container='body' data-id='$a[id]' data-action='delete' rel='tooltip' title='"._('remove agent')."'> <i class='fa fa-times'></i></button>"; |
|
61 | - print " </div>"; |
|
62 | - print "</td>"; |
|
56 | + // add/remove agents |
|
57 | + print " <td class='actions'>"; |
|
58 | + print " <div class='btn-group'>"; |
|
59 | + print " <button class='btn btn-xs btn-default editAgent' data-container='body' data-id='$a[id]' data-action='edit' rel='tooltip' title='"._('edit agent details')."'> <i class='fa fa-pencil'></i></button>"; |
|
60 | + print " <button class='btn btn-xs btn-default editAgent' data-container='body' data-id='$a[id]' data-action='delete' rel='tooltip' title='"._('remove agent')."'> <i class='fa fa-times'></i></button>"; |
|
61 | + print " </div>"; |
|
62 | + print "</td>"; |
|
63 | 63 | |
64 | - print '</tr>' . "\n"; |
|
65 | - } |
|
66 | - print "</table>"; |
|
64 | + print '</tr>' . "\n"; |
|
65 | + } |
|
66 | + print "</table>"; |
|
67 | 67 | } |
68 | 68 | else { |
69 | - $Result->show("info alert-nomargin", _("No agents available")."!", false); |
|
69 | + $Result->show("info alert-nomargin", _("No agents available")."!", false); |
|
70 | 70 | } |
71 | 71 | ?> |
72 | 72 | <hr> |
@@ -5,33 +5,33 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # fetch all APIs |
11 | -$all_agents = $Admin->fetch_all_objects("scanAgents"); |
|
11 | +$all_agents = $Admin->fetch_all_objects ("scanAgents"); |
|
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <!-- display existing groups --> |
15 | -<h4><?php print _('phpipam Scan agents'); ?></h4> |
|
15 | +<h4><?php print _ ('phpipam Scan agents'); ?></h4> |
|
16 | 16 | <hr><br> |
17 | 17 | |
18 | 18 | <!-- Add new --> |
19 | -<button class='btn btn-sm btn-default editAgent' style="margin-bottom:10px;" data-action='add'><i class='fa fa-plus'></i> <?php print _('Create new agent'); ?></button> |
|
19 | +<button class='btn btn-sm btn-default editAgent' style="margin-bottom:10px;" data-action='add'><i class='fa fa-plus'></i> <?php print _ ('Create new agent'); ?></button> |
|
20 | 20 | |
21 | 21 | |
22 | 22 | <?php |
23 | 23 | /* print existing APIs */ |
24 | -if($all_agents!==false) { |
|
24 | +if ($all_agents !== false) { |
|
25 | 25 | |
26 | 26 | print '<table id="userPrint" class="table table-striped table-top table-auto">'; |
27 | 27 | # headers |
28 | 28 | print '<tr>'; |
29 | - print "<th>"._('Agent id').'</th>'; |
|
30 | - print "<th>"._('Name').'</th>'; |
|
31 | - print "<th>"._('Description').'</th>'; |
|
32 | - print "<th>"._('Type').'</th>'; |
|
33 | - print "<th>"._('Code').'</th>'; |
|
34 | - print "<th>"._('Last access').'</th>'; |
|
29 | + print "<th>"._ ('Agent id').'</th>'; |
|
30 | + print "<th>"._ ('Name').'</th>'; |
|
31 | + print "<th>"._ ('Description').'</th>'; |
|
32 | + print "<th>"._ ('Type').'</th>'; |
|
33 | + print "<th>"._ ('Code').'</th>'; |
|
34 | + print "<th>"._ ('Last access').'</th>'; |
|
35 | 35 | print '<th></th>'; |
36 | 36 | print '</tr>'; |
37 | 37 | |
@@ -41,35 +41,35 @@ discard block |
||
41 | 41 | $a = (array) $a; |
42 | 42 | |
43 | 43 | // fixes |
44 | - $a['code'] = strlen($a['code'])===0 ? "/" : $a['code']; |
|
45 | - $a['last_access'] = strlen($a['last_access'])===0 ? "<span class='text-muted'>Never</span>" : $a['last_access']; |
|
44 | + $a['code'] = strlen ($a['code']) === 0 ? "/" : $a['code']; |
|
45 | + $a['last_access'] = strlen ($a['last_access']) === 0 ? "<span class='text-muted'>Never</span>" : $a['last_access']; |
|
46 | 46 | |
47 | 47 | |
48 | - print '<tr>' . "\n"; |
|
49 | - print ' <td>' . $a['id'] . '</td>'. "\n"; |
|
50 | - print ' <td>' . $a['name'] . '</td>'. "\n"; |
|
51 | - print ' <td>' . $a['description'] . '</td>'. "\n"; |
|
52 | - print ' <td>' . $a['type'] . '</td>'. "\n"; |
|
53 | - print ' <td>' . $a['code'] . '</td>'. "\n"; |
|
54 | - print ' <td>' . $a['last_access'] . '</td>'. "\n"; |
|
48 | + print '<tr>'."\n"; |
|
49 | + print ' <td>'.$a['id'].'</td>'."\n"; |
|
50 | + print ' <td>'.$a['name'].'</td>'."\n"; |
|
51 | + print ' <td>'.$a['description'].'</td>'."\n"; |
|
52 | + print ' <td>'.$a['type'].'</td>'."\n"; |
|
53 | + print ' <td>'.$a['code'].'</td>'."\n"; |
|
54 | + print ' <td>'.$a['last_access'].'</td>'."\n"; |
|
55 | 55 | |
56 | 56 | // add/remove agents |
57 | 57 | print " <td class='actions'>"; |
58 | 58 | print " <div class='btn-group'>"; |
59 | - print " <button class='btn btn-xs btn-default editAgent' data-container='body' data-id='$a[id]' data-action='edit' rel='tooltip' title='"._('edit agent details')."'> <i class='fa fa-pencil'></i></button>"; |
|
60 | - print " <button class='btn btn-xs btn-default editAgent' data-container='body' data-id='$a[id]' data-action='delete' rel='tooltip' title='"._('remove agent')."'> <i class='fa fa-times'></i></button>"; |
|
59 | + print " <button class='btn btn-xs btn-default editAgent' data-container='body' data-id='$a[id]' data-action='edit' rel='tooltip' title='"._ ('edit agent details')."'> <i class='fa fa-pencil'></i></button>"; |
|
60 | + print " <button class='btn btn-xs btn-default editAgent' data-container='body' data-id='$a[id]' data-action='delete' rel='tooltip' title='"._ ('remove agent')."'> <i class='fa fa-times'></i></button>"; |
|
61 | 61 | print " </div>"; |
62 | 62 | print "</td>"; |
63 | 63 | |
64 | - print '</tr>' . "\n"; |
|
64 | + print '</tr>'."\n"; |
|
65 | 65 | } |
66 | 66 | print "</table>"; |
67 | 67 | } |
68 | 68 | else { |
69 | - $Result->show("info alert-nomargin", _("No agents available")."!", false); |
|
69 | + $Result->show ("info alert-nomargin", _ ("No agents available")."!", false); |
|
70 | 70 | } |
71 | 71 | ?> |
72 | 72 | <hr> |
73 | 73 | |
74 | -<h4><?php print _('phpipam-agent documentation'); ?></h4> |
|
74 | +<h4><?php print _ ('phpipam-agent documentation'); ?></h4> |
|
75 | 75 | <a href="https://github.com/phpipam/phpipam-agent">https://github.com/phpipam/phpipam-agent</a> |
@@ -27,62 +27,62 @@ |
||
27 | 27 | |
28 | 28 | # for edit check old details |
29 | 29 | if ($_POST['action']=="edit" || $_POST['action']=="delete") { |
30 | - # old |
|
31 | - $agent_old = $Admin->fetch_object ("scanAgents", "id", $_POST['id']); |
|
32 | - // invalid id |
|
33 | - if($agent_old===false) { $error[] = "Invalid agent Id"; } |
|
34 | - // remove type and code if direct |
|
35 | - if (@$agent_old->type=="direct") { |
|
36 | - unset($_POST['type'], $_POST['code']); |
|
37 | - } |
|
30 | + # old |
|
31 | + $agent_old = $Admin->fetch_object ("scanAgents", "id", $_POST['id']); |
|
32 | + // invalid id |
|
33 | + if($agent_old===false) { $error[] = "Invalid agent Id"; } |
|
34 | + // remove type and code if direct |
|
35 | + if (@$agent_old->type=="direct") { |
|
36 | + unset($_POST['type'], $_POST['code']); |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | # die if direct and delete |
41 | 41 | if (@$agent_old->type=="direct" && $_POST['action']=="delete") { |
42 | - $Result->show("danger", _("Cannot remove localhost scan agent"),true); |
|
42 | + $Result->show("danger", _("Cannot remove localhost scan agent"),true); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | # checks for edit / add |
46 | 46 | if($_POST['action']!="delete") { |
47 | - # code must be exactly 32 chars long and alfanumeric if app_security = crypt |
|
48 | - if(@$agent_old->type!="direct") { |
|
49 | - if(strlen($_POST['code'])!=32 || !ctype_alnum($_POST['code'])) { $error[] = "Invalid agent code"; } |
|
50 | - } |
|
51 | - # name must be more than 2 and alphanumberic |
|
52 | - if(strlen($_POST['name'])==0) { $error[] = "Invalid agent name"; } |
|
47 | + # code must be exactly 32 chars long and alfanumeric if app_security = crypt |
|
48 | + if(@$agent_old->type!="direct") { |
|
49 | + if(strlen($_POST['code'])!=32 || !ctype_alnum($_POST['code'])) { $error[] = "Invalid agent code"; } |
|
50 | + } |
|
51 | + # name must be more than 2 and alphanumberic |
|
52 | + if(strlen($_POST['name'])==0) { $error[] = "Invalid agent name"; } |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | # die if errors |
56 | 56 | if(sizeof($error) > 0) { |
57 | - $Result->show("danger", $error, true); |
|
57 | + $Result->show("danger", $error, true); |
|
58 | 58 | } |
59 | 59 | else { |
60 | - # create array of values for modification |
|
61 | - $values = array("id"=>@$_POST['id'], |
|
62 | - "name"=>$_POST['name'], |
|
63 | - "description"=>@$_POST['description'], |
|
64 | - "code"=>@$_POST['code'], |
|
65 | - "type"=>@$_POST['type'] |
|
66 | - ); |
|
67 | - # null |
|
68 | - $values = $Admin->remove_empty_array_fields ($values); |
|
60 | + # create array of values for modification |
|
61 | + $values = array("id"=>@$_POST['id'], |
|
62 | + "name"=>$_POST['name'], |
|
63 | + "description"=>@$_POST['description'], |
|
64 | + "code"=>@$_POST['code'], |
|
65 | + "type"=>@$_POST['type'] |
|
66 | + ); |
|
67 | + # null |
|
68 | + $values = $Admin->remove_empty_array_fields ($values); |
|
69 | 69 | |
70 | - # execute |
|
71 | - if(!$Admin->object_modify("scanAgents", $_POST['action'], "id", $values)) { $Result->show("danger", _("Agent $_POST[action] error"), true); } |
|
72 | - else { $Result->show("success", _("Agent $_POST[action] success"), false); } |
|
70 | + # execute |
|
71 | + if(!$Admin->object_modify("scanAgents", $_POST['action'], "id", $values)) { $Result->show("danger", _("Agent $_POST[action] error"), true); } |
|
72 | + else { $Result->show("success", _("Agent $_POST[action] success"), false); } |
|
73 | 73 | |
74 | - # delete - unset scanning in all subnets |
|
75 | - if ($_POST['action']=="delete") { |
|
76 | - $query = "update `subnets` set `scanAgent`=0, `pingSubnet`=0, `discoverSubnet`=0 where `scanAgent` = ?;"; |
|
74 | + # delete - unset scanning in all subnets |
|
75 | + if ($_POST['action']=="delete") { |
|
76 | + $query = "update `subnets` set `scanAgent`=0, `pingSubnet`=0, `discoverSubnet`=0 where `scanAgent` = ?;"; |
|
77 | 77 | |
78 | - try { $Database->runQuery($query, array($_POST['id'])); } |
|
79 | - catch (Exception $e) { |
|
80 | - $this->Result->show("danger", _("Error: ").$e->getMessage()); |
|
81 | - return false; |
|
82 | - } |
|
83 | - // references removed |
|
84 | - $this->Result->show("info", _("Scan agent references removed")); |
|
85 | - } |
|
78 | + try { $Database->runQuery($query, array($_POST['id'])); } |
|
79 | + catch (Exception $e) { |
|
80 | + $this->Result->show("danger", _("Error: ").$e->getMessage()); |
|
81 | + return false; |
|
82 | + } |
|
83 | + // references removed |
|
84 | + $this->Result->show("info", _("Scan agent references removed")); |
|
85 | + } |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | ?> |
89 | 89 | \ No newline at end of file |
@@ -75,8 +75,7 @@ |
||
75 | 75 | if ($_POST['action']=="delete") { |
76 | 76 | $query = "update `subnets` set `scanAgent`=0, `pingSubnet`=0, `discoverSubnet`=0 where `scanAgent` = ?;"; |
77 | 77 | |
78 | - try { $Database->runQuery($query, array($_POST['id'])); } |
|
79 | - catch (Exception $e) { |
|
78 | + try { $Database->runQuery($query, array($_POST['id'])); } catch (Exception $e) { |
|
80 | 79 | $this->Result->show("danger", _("Error: ").$e->getMessage()); |
81 | 80 | return false; |
82 | 81 | } |
@@ -5,60 +5,60 @@ discard block |
||
5 | 5 | *************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Result = new Result (); |
15 | 15 | |
16 | 16 | # verify that user is logged in |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # strip input tags |
20 | -$_POST = $Admin->strip_input_tags($_POST); |
|
20 | +$_POST = $Admin->strip_input_tags ($_POST); |
|
21 | 21 | |
22 | 22 | # validate csrf cookie |
23 | -$User->csrf_cookie ("validate", "agent", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; |
|
23 | +$User->csrf_cookie ("validate", "agent", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : ""; |
|
24 | 24 | |
25 | 25 | /* checks */ |
26 | -$error = array(); |
|
26 | +$error = array (); |
|
27 | 27 | |
28 | 28 | # for edit check old details |
29 | -if ($_POST['action']=="edit" || $_POST['action']=="delete") { |
|
29 | +if ($_POST['action'] == "edit" || $_POST['action'] == "delete") { |
|
30 | 30 | # old |
31 | 31 | $agent_old = $Admin->fetch_object ("scanAgents", "id", $_POST['id']); |
32 | 32 | // invalid id |
33 | - if($agent_old===false) { $error[] = "Invalid agent Id"; } |
|
33 | + if ($agent_old === false) { $error[] = "Invalid agent Id"; } |
|
34 | 34 | // remove type and code if direct |
35 | - if (@$agent_old->type=="direct") { |
|
35 | + if (@$agent_old->type == "direct") { |
|
36 | 36 | unset($_POST['type'], $_POST['code']); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | 40 | # die if direct and delete |
41 | -if (@$agent_old->type=="direct" && $_POST['action']=="delete") { |
|
42 | - $Result->show("danger", _("Cannot remove localhost scan agent"),true); |
|
41 | +if (@$agent_old->type == "direct" && $_POST['action'] == "delete") { |
|
42 | + $Result->show ("danger", _ ("Cannot remove localhost scan agent"), true); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | # checks for edit / add |
46 | -if($_POST['action']!="delete") { |
|
46 | +if ($_POST['action'] != "delete") { |
|
47 | 47 | # code must be exactly 32 chars long and alfanumeric if app_security = crypt |
48 | - if(@$agent_old->type!="direct") { |
|
49 | - if(strlen($_POST['code'])!=32 || !ctype_alnum($_POST['code'])) { $error[] = "Invalid agent code"; } |
|
48 | + if (@$agent_old->type != "direct") { |
|
49 | + if (strlen ($_POST['code']) != 32 || !ctype_alnum ($_POST['code'])) { $error[] = "Invalid agent code"; } |
|
50 | 50 | } |
51 | 51 | # name must be more than 2 and alphanumberic |
52 | - if(strlen($_POST['name'])==0) { $error[] = "Invalid agent name"; } |
|
52 | + if (strlen ($_POST['name']) == 0) { $error[] = "Invalid agent name"; } |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | # die if errors |
56 | -if(sizeof($error) > 0) { |
|
57 | - $Result->show("danger", $error, true); |
|
56 | +if (sizeof ($error) > 0) { |
|
57 | + $Result->show ("danger", $error, true); |
|
58 | 58 | } |
59 | 59 | else { |
60 | 60 | # create array of values for modification |
61 | - $values = array("id"=>@$_POST['id'], |
|
61 | + $values = array ("id"=>@$_POST['id'], |
|
62 | 62 | "name"=>$_POST['name'], |
63 | 63 | "description"=>@$_POST['description'], |
64 | 64 | "code"=>@$_POST['code'], |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | $values = $Admin->remove_empty_array_fields ($values); |
69 | 69 | |
70 | 70 | # execute |
71 | - if(!$Admin->object_modify("scanAgents", $_POST['action'], "id", $values)) { $Result->show("danger", _("Agent $_POST[action] error"), true); } |
|
72 | - else { $Result->show("success", _("Agent $_POST[action] success"), false); } |
|
71 | + if (!$Admin->object_modify ("scanAgents", $_POST['action'], "id", $values)) { $Result->show ("danger", _ ("Agent $_POST[action] error"), true); } |
|
72 | + else { $Result->show ("success", _ ("Agent $_POST[action] success"), false); } |
|
73 | 73 | |
74 | 74 | # delete - unset scanning in all subnets |
75 | - if ($_POST['action']=="delete") { |
|
75 | + if ($_POST['action'] == "delete") { |
|
76 | 76 | $query = "update `subnets` set `scanAgent`=0, `pingSubnet`=0, `discoverSubnet`=0 where `scanAgent` = ?;"; |
77 | 77 | |
78 | - try { $Database->runQuery($query, array($_POST['id'])); } |
|
78 | + try { $Database->runQuery ($query, array ($_POST['id'])); } |
|
79 | 79 | catch (Exception $e) { |
80 | - $this->Result->show("danger", _("Error: ").$e->getMessage()); |
|
80 | + $this->Result->show ("danger", _ ("Error: ").$e->getMessage ()); |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | // references removed |
84 | - $this->Result->show("info", _("Scan agent references removed")); |
|
84 | + $this->Result->show ("info", _ ("Scan agent references removed")); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 |
@@ -24,23 +24,23 @@ discard block |
||
24 | 24 | |
25 | 25 | # fetch api for edit / add |
26 | 26 | if($_POST['action']!="add") { |
27 | - # fetch api details |
|
28 | - $agent = $Admin->fetch_object ("scanAgents", "id", $_POST['id']); |
|
29 | - # null ? |
|
30 | - $agent===false ? $Result->show("danger", _("Invalid ID"), true) : null; |
|
31 | - # title |
|
32 | - $title = ucwords($_POST['action']) .' '._('agent').' '.$agent->name; |
|
27 | + # fetch api details |
|
28 | + $agent = $Admin->fetch_object ("scanAgents", "id", $_POST['id']); |
|
29 | + # null ? |
|
30 | + $agent===false ? $Result->show("danger", _("Invalid ID"), true) : null; |
|
31 | + # title |
|
32 | + $title = ucwords($_POST['action']) .' '._('agent').' '.$agent->name; |
|
33 | 33 | } else { |
34 | - # generate new code |
|
35 | - $agent = new StdClass; |
|
36 | - $agent->code = str_shuffle(md5(microtime())); |
|
37 | - # title |
|
38 | - $title = _('Create new scan agent'); |
|
34 | + # generate new code |
|
35 | + $agent = new StdClass; |
|
36 | + $agent->code = str_shuffle(md5(microtime())); |
|
37 | + # title |
|
38 | + $title = _('Create new scan agent'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | # die if direct and delete |
42 | 42 | if (@$agent->type=="direct" && $_POST['action']=="delete") { |
43 | - $Result->show("danger", _("Cannot remove localhost scan agent"),true, true); |
|
43 | + $Result->show("danger", _("Cannot remove localhost scan agent"),true, true); |
|
44 | 44 | } |
45 | 45 | ?> |
46 | 46 | |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | <td> |
88 | 88 | <select name="type" class="form-control input-sm input-w-auto" <?php if(@$agent->type=="direct"||$_POST['action'] == "delete") print "readonly"; ?>> |
89 | 89 | <?php |
90 | - //$types = array("mysql"=>"MySQL", "api"=>"Api"); |
|
91 | - $types = array("mysql"=>"MySQL"); |
|
92 | - |
|
93 | - foreach($types as $k=>$p) { |
|
94 | - if($k==$agent->type) { print "<option value='$k' selected='selected'>"._($p)."</option>"; } |
|
95 | - else { print "<option value='$k' >"._($p)."</option>"; } |
|
96 | - } |
|
97 | - ?> |
|
90 | + //$types = array("mysql"=>"MySQL", "api"=>"Api"); |
|
91 | + $types = array("mysql"=>"MySQL"); |
|
92 | + |
|
93 | + foreach($types as $k=>$p) { |
|
94 | + if($k==$agent->type) { print "<option value='$k' selected='selected'>"._($p)."</option>"; } |
|
95 | + else { print "<option value='$k' >"._($p)."</option>"; } |
|
96 | + } |
|
97 | + ?> |
|
98 | 98 | </select> |
99 | 99 | <td class="info2"><?php print _('Agent type'); ?></td> |
100 | 100 | </tr> |
@@ -30,7 +30,8 @@ discard block |
||
30 | 30 | $agent===false ? $Result->show("danger", _("Invalid ID"), true) : null; |
31 | 31 | # title |
32 | 32 | $title = ucwords($_POST['action']) .' '._('agent').' '.$agent->name; |
33 | -} else { |
|
33 | +} |
|
34 | +else { |
|
34 | 35 | # generate new code |
35 | 36 | $agent = new StdClass; |
36 | 37 | $agent->code = str_shuffle(md5(microtime())); |
@@ -58,7 +59,10 @@ discard block |
||
58 | 59 | <tr> |
59 | 60 | <td><?php print _('Name'); ?></td> |
60 | 61 | <td> |
61 | - <input type="text" name="name" class="form-control input-sm" value="<?php print @$agent->name; ?>" <?php if($_POST['action'] == "delete") print "readonly"; ?>> |
|
62 | + <input type="text" name="name" class="form-control input-sm" value="<?php print @$agent->name; ?>" <?php if($_POST['action'] == "delete") { |
|
63 | + print "readonly"; |
|
64 | +} |
|
65 | +?>> |
|
62 | 66 | <input type="hidden" name="id" value="<?php print $agent->id; ?>"> |
63 | 67 | <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
64 | 68 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
@@ -69,7 +73,10 @@ discard block |
||
69 | 73 | <!-- description --> |
70 | 74 | <tr> |
71 | 75 | <td><?php print _('Description'); ?></td> |
72 | - <td><input type="text" id="description" name="description" class="form-control input-sm" value="<?php print @$agent->description; ?>" <?php if($_POST['action'] == "delete") print "readonly"; ?>></td> |
|
76 | + <td><input type="text" id="description" name="description" class="form-control input-sm" value="<?php print @$agent->description; ?>" <?php if($_POST['action'] == "delete") { |
|
77 | + print "readonly"; |
|
78 | +} |
|
79 | +?>></td> |
|
73 | 80 | <td class="info2"><?php print _('Agent description'); ?></td> |
74 | 81 | </tr> |
75 | 82 | |
@@ -77,7 +84,10 @@ discard block |
||
77 | 84 | <!-- code --> |
78 | 85 | <tr> |
79 | 86 | <td><?php print _('Code'); ?></td> |
80 | - <td><input type="text" id="code" name="code" class="form-control input-sm" value="<?php print @$agent->code; ?>" maxlength='32' <?php if(@$agent->type=="direct"||$_POST['action'] == "delete") print "readonly"; ?>></td> |
|
87 | + <td><input type="text" id="code" name="code" class="form-control input-sm" value="<?php print @$agent->code; ?>" maxlength='32' <?php if(@$agent->type=="direct"||$_POST['action'] == "delete") { |
|
88 | + print "readonly"; |
|
89 | +} |
|
90 | +?>></td> |
|
81 | 91 | <td class="info2"><?php print _('Agent code'); ?><?php if(@$agent->type!="direct") { ?> <button class="btn btn-xs btn-default" id="regAgentKey"><i class="fa fa-random"></i> <?php print _('Regenerate'); ?></button><?php } ?></td> |
82 | 92 | </tr> |
83 | 93 | |
@@ -85,7 +95,10 @@ discard block |
||
85 | 95 | <tr> |
86 | 96 | <td><?php print _('Agent type'); ?></td> |
87 | 97 | <td> |
88 | - <select name="type" class="form-control input-sm input-w-auto" <?php if(@$agent->type=="direct"||$_POST['action'] == "delete") print "readonly"; ?>> |
|
98 | + <select name="type" class="form-control input-sm input-w-auto" <?php if(@$agent->type=="direct"||$_POST['action'] == "delete") { |
|
99 | + print "readonly"; |
|
100 | +} |
|
101 | +?>> |
|
89 | 102 | <?php |
90 | 103 | //$types = array("mysql"=>"MySQL", "api"=>"Api"); |
91 | 104 | $types = array("mysql"=>"MySQL"); |
@@ -110,7 +123,10 @@ discard block |
||
110 | 123 | <div class="pFooter"> |
111 | 124 | <div class="btn-group"> |
112 | 125 | <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
113 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="agentEditSubmit"><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> |
|
126 | + <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } |
|
127 | +else { print "btn-success"; } ?>" id="agentEditSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } |
|
128 | +else if ($_POST['action']=="delete") { print "fa-trash-o"; } |
|
129 | +else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
114 | 130 | </div> |
115 | 131 | <!-- Result --> |
116 | 132 | <div class="agentEditResult"></div> |
@@ -5,42 +5,42 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Result = new Result (); |
15 | 15 | |
16 | 16 | # verify that user is logged in |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # create csrf token |
20 | 20 | $csrf = $User->csrf_cookie ("create", "agent"); |
21 | 21 | |
22 | 22 | # ID must be numeric |
23 | -if($_POST['action']!="add" && !is_numeric($_POST['id'])) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
23 | +if ($_POST['action'] != "add" && !is_numeric ($_POST['id'])) { $Result->show ("danger", _ ("Invalid ID"), true, true); } |
|
24 | 24 | |
25 | 25 | # fetch api for edit / add |
26 | -if($_POST['action']!="add") { |
|
26 | +if ($_POST['action'] != "add") { |
|
27 | 27 | # fetch api details |
28 | 28 | $agent = $Admin->fetch_object ("scanAgents", "id", $_POST['id']); |
29 | 29 | # null ? |
30 | - $agent===false ? $Result->show("danger", _("Invalid ID"), true) : null; |
|
30 | + $agent === false ? $Result->show ("danger", _ ("Invalid ID"), true) : null; |
|
31 | 31 | # title |
32 | - $title = ucwords($_POST['action']) .' '._('agent').' '.$agent->name; |
|
32 | + $title = ucwords ($_POST['action']).' '._ ('agent').' '.$agent->name; |
|
33 | 33 | } else { |
34 | 34 | # generate new code |
35 | 35 | $agent = new StdClass; |
36 | - $agent->code = str_shuffle(md5(microtime())); |
|
36 | + $agent->code = str_shuffle (md5 (microtime ())); |
|
37 | 37 | # title |
38 | - $title = _('Create new scan agent'); |
|
38 | + $title = _ ('Create new scan agent'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | # die if direct and delete |
42 | -if (@$agent->type=="direct" && $_POST['action']=="delete") { |
|
43 | - $Result->show("danger", _("Cannot remove localhost scan agent"),true, true); |
|
42 | +if (@$agent->type == "direct" && $_POST['action'] == "delete") { |
|
43 | + $Result->show ("danger", _ ("Cannot remove localhost scan agent"), true, true); |
|
44 | 44 | } |
45 | 45 | ?> |
46 | 46 | |
@@ -56,47 +56,47 @@ discard block |
||
56 | 56 | |
57 | 57 | <!-- name --> |
58 | 58 | <tr> |
59 | - <td><?php print _('Name'); ?></td> |
|
59 | + <td><?php print _ ('Name'); ?></td> |
|
60 | 60 | <td> |
61 | - <input type="text" name="name" class="form-control input-sm" value="<?php print @$agent->name; ?>" <?php if($_POST['action'] == "delete") print "readonly"; ?>> |
|
61 | + <input type="text" name="name" class="form-control input-sm" value="<?php print @$agent->name; ?>" <?php if ($_POST['action'] == "delete") print "readonly"; ?>> |
|
62 | 62 | <input type="hidden" name="id" value="<?php print $agent->id; ?>"> |
63 | 63 | <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
64 | 64 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
65 | 65 | </td> |
66 | - <td class="info2"><?php print _('Enter scan agent name'); ?></td> |
|
66 | + <td class="info2"><?php print _ ('Enter scan agent name'); ?></td> |
|
67 | 67 | </tr> |
68 | 68 | |
69 | 69 | <!-- description --> |
70 | 70 | <tr> |
71 | - <td><?php print _('Description'); ?></td> |
|
72 | - <td><input type="text" id="description" name="description" class="form-control input-sm" value="<?php print @$agent->description; ?>" <?php if($_POST['action'] == "delete") print "readonly"; ?>></td> |
|
73 | - <td class="info2"><?php print _('Agent description'); ?></td> |
|
71 | + <td><?php print _ ('Description'); ?></td> |
|
72 | + <td><input type="text" id="description" name="description" class="form-control input-sm" value="<?php print @$agent->description; ?>" <?php if ($_POST['action'] == "delete") print "readonly"; ?>></td> |
|
73 | + <td class="info2"><?php print _ ('Agent description'); ?></td> |
|
74 | 74 | </tr> |
75 | 75 | |
76 | - <?php if(@$agent->type!=="direct") { ?> |
|
76 | + <?php if (@$agent->type !== "direct") { ?> |
|
77 | 77 | <!-- code --> |
78 | 78 | <tr> |
79 | - <td><?php print _('Code'); ?></td> |
|
80 | - <td><input type="text" id="code" name="code" class="form-control input-sm" value="<?php print @$agent->code; ?>" maxlength='32' <?php if(@$agent->type=="direct"||$_POST['action'] == "delete") print "readonly"; ?>></td> |
|
81 | - <td class="info2"><?php print _('Agent code'); ?><?php if(@$agent->type!="direct") { ?> <button class="btn btn-xs btn-default" id="regAgentKey"><i class="fa fa-random"></i> <?php print _('Regenerate'); ?></button><?php } ?></td> |
|
79 | + <td><?php print _ ('Code'); ?></td> |
|
80 | + <td><input type="text" id="code" name="code" class="form-control input-sm" value="<?php print @$agent->code; ?>" maxlength='32' <?php if (@$agent->type == "direct" || $_POST['action'] == "delete") print "readonly"; ?>></td> |
|
81 | + <td class="info2"><?php print _ ('Agent code'); ?><?php if (@$agent->type != "direct") { ?> <button class="btn btn-xs btn-default" id="regAgentKey"><i class="fa fa-random"></i> <?php print _ ('Regenerate'); ?></button><?php } ?></td> |
|
82 | 82 | </tr> |
83 | 83 | |
84 | 84 | <!-- type --> |
85 | 85 | <tr> |
86 | - <td><?php print _('Agent type'); ?></td> |
|
86 | + <td><?php print _ ('Agent type'); ?></td> |
|
87 | 87 | <td> |
88 | - <select name="type" class="form-control input-sm input-w-auto" <?php if(@$agent->type=="direct"||$_POST['action'] == "delete") print "readonly"; ?>> |
|
88 | + <select name="type" class="form-control input-sm input-w-auto" <?php if (@$agent->type == "direct" || $_POST['action'] == "delete") print "readonly"; ?>> |
|
89 | 89 | <?php |
90 | 90 | //$types = array("mysql"=>"MySQL", "api"=>"Api"); |
91 | - $types = array("mysql"=>"MySQL"); |
|
91 | + $types = array ("mysql"=>"MySQL"); |
|
92 | 92 | |
93 | - foreach($types as $k=>$p) { |
|
94 | - if($k==$agent->type) { print "<option value='$k' selected='selected'>"._($p)."</option>"; } |
|
95 | - else { print "<option value='$k' >"._($p)."</option>"; } |
|
93 | + foreach ($types as $k=>$p) { |
|
94 | + if ($k == $agent->type) { print "<option value='$k' selected='selected'>"._ ($p)."</option>"; } |
|
95 | + else { print "<option value='$k' >"._ ($p)."</option>"; } |
|
96 | 96 | } |
97 | 97 | ?> |
98 | 98 | </select> |
99 | - <td class="info2"><?php print _('Agent type'); ?></td> |
|
99 | + <td class="info2"><?php print _ ('Agent type'); ?></td> |
|
100 | 100 | </tr> |
101 | 101 | <?php } ?> |
102 | 102 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | <!-- footer --> |
110 | 110 | <div class="pFooter"> |
111 | 111 | <div class="btn-group"> |
112 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
113 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="agentEditSubmit"><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> |
|
112 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
113 | + <button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="agentEditSubmit"><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> |
|
114 | 114 | </div> |
115 | 115 | <!-- Result --> |
116 | 116 | <div class="agentEditResult"></div> |
@@ -12,25 +12,25 @@ discard block |
||
12 | 12 | |
13 | 13 | // fetch required domains |
14 | 14 | switch ($type) { |
15 | - // fetch forward domains |
|
16 | - case 'domains': |
|
17 | - $title = _("Domains"); |
|
18 | - $domains = $PowerDNS->fetch_all_forward_domains (); |
|
19 | - break; |
|
20 | - // fetch v4 reverse domains |
|
21 | - case 'reverse_v4': |
|
22 | - $title = _("IPv4 reverse domains"); |
|
23 | - $domains = $PowerDNS->fetch_reverse_v4_domains (); |
|
24 | - break; |
|
25 | - // fetch v6 reverse domains |
|
26 | - case 'reverse_v6': |
|
27 | - $title = _("IPv6 reverse domains"); |
|
28 | - $domains = $PowerDNS->fetch_reverse_v6_domains (); |
|
29 | - break; |
|
30 | - // error |
|
31 | - default: |
|
32 | - $Result->show("danger", "Invalid request", true); |
|
33 | - break; |
|
15 | + // fetch forward domains |
|
16 | + case 'domains': |
|
17 | + $title = _("Domains"); |
|
18 | + $domains = $PowerDNS->fetch_all_forward_domains (); |
|
19 | + break; |
|
20 | + // fetch v4 reverse domains |
|
21 | + case 'reverse_v4': |
|
22 | + $title = _("IPv4 reverse domains"); |
|
23 | + $domains = $PowerDNS->fetch_reverse_v4_domains (); |
|
24 | + break; |
|
25 | + // fetch v6 reverse domains |
|
26 | + case 'reverse_v6': |
|
27 | + $title = _("IPv6 reverse domains"); |
|
28 | + $domains = $PowerDNS->fetch_reverse_v6_domains (); |
|
29 | + break; |
|
30 | + // error |
|
31 | + default: |
|
32 | + $Result->show("danger", "Invalid request", true); |
|
33 | + break; |
|
34 | 34 | } |
35 | 35 | ?> |
36 | 36 | |
@@ -71,34 +71,34 @@ discard block |
||
71 | 71 | <?php |
72 | 72 | /* prints domain records */ |
73 | 73 | foreach ($domains as $d) { |
74 | - // nulls |
|
75 | - foreach($d as $k=>$v) { |
|
76 | - if (strlen($v)==0) $d->$k = "<span class='muted'>/</span>"; |
|
77 | - } |
|
78 | - // cont records |
|
79 | - $cnt = $PowerDNS->count_domain_records ($d->id); |
|
80 | - // get SOA record |
|
81 | - $soa = $PowerDNS->fetch_domain_records_by_type ($d->id, "SOA"); |
|
82 | - $serial = explode(" ", $soa[0]->content); |
|
83 | - $serial = $serial[2]; |
|
74 | + // nulls |
|
75 | + foreach($d as $k=>$v) { |
|
76 | + if (strlen($v)==0) $d->$k = "<span class='muted'>/</span>"; |
|
77 | + } |
|
78 | + // cont records |
|
79 | + $cnt = $PowerDNS->count_domain_records ($d->id); |
|
80 | + // get SOA record |
|
81 | + $soa = $PowerDNS->fetch_domain_records_by_type ($d->id, "SOA"); |
|
82 | + $serial = explode(" ", $soa[0]->content); |
|
83 | + $serial = $serial[2]; |
|
84 | 84 | |
85 | - print "<tr>"; |
|
86 | - // actions |
|
87 | - print " <td>"; |
|
88 | - print " <div class='btn-group'>"; |
|
89 | - print " <button class='btn btn-default btn-xs editDomain' data-action='edit' data-id='$d->id'><i class='fa fa-pencil'></i></button>"; |
|
90 | - print " <button class='btn btn-default btn-xs editDomain' data-action='delete' data-id='$d->id'><i class='fa fa-remove'></i></button>"; |
|
91 | - print " </div>"; |
|
92 | - print " </td>"; |
|
85 | + print "<tr>"; |
|
86 | + // actions |
|
87 | + print " <td>"; |
|
88 | + print " <div class='btn-group'>"; |
|
89 | + print " <button class='btn btn-default btn-xs editDomain' data-action='edit' data-id='$d->id'><i class='fa fa-pencil'></i></button>"; |
|
90 | + print " <button class='btn btn-default btn-xs editDomain' data-action='delete' data-id='$d->id'><i class='fa fa-remove'></i></button>"; |
|
91 | + print " </div>"; |
|
92 | + print " </td>"; |
|
93 | 93 | |
94 | - // content |
|
95 | - print " <td><a href='".create_link("administration", "powerDNS", $_GET['subnetId'], "records", $d->name)."'>$d->name</a></td>"; |
|
96 | - print " <td><span class='badge badge1'>$d->type</span></td>"; |
|
97 | - print " <td>$d->master</td>"; |
|
98 | - print " <td><span class='badge'>$cnt</span></td>"; |
|
99 | - print " <td>$serial</td>"; |
|
94 | + // content |
|
95 | + print " <td><a href='".create_link("administration", "powerDNS", $_GET['subnetId'], "records", $d->name)."'>$d->name</a></td>"; |
|
96 | + print " <td><span class='badge badge1'>$d->type</span></td>"; |
|
97 | + print " <td>$d->master</td>"; |
|
98 | + print " <td><span class='badge'>$cnt</span></td>"; |
|
99 | + print " <td>$serial</td>"; |
|
100 | 100 | |
101 | - print "</tr>"; |
|
101 | + print "</tr>"; |
|
102 | 102 | } |
103 | 103 | ?> |
104 | 104 | </tbody> |
@@ -73,7 +73,9 @@ |
||
73 | 73 | foreach ($domains as $d) { |
74 | 74 | // nulls |
75 | 75 | foreach($d as $k=>$v) { |
76 | - if (strlen($v)==0) $d->$k = "<span class='muted'>/</span>"; |
|
76 | + if (strlen($v)==0) { |
|
77 | + $d->$k = "<span class='muted'>/</span>"; |
|
78 | + } |
|
77 | 79 | } |
78 | 80 | // cont records |
79 | 81 | $cnt = $PowerDNS->count_domain_records ($d->id); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # fetch domains |
11 | 11 | $type = $_GET['subnetId']; |
@@ -14,22 +14,22 @@ discard block |
||
14 | 14 | switch ($type) { |
15 | 15 | // fetch forward domains |
16 | 16 | case 'domains': |
17 | - $title = _("Domains"); |
|
17 | + $title = _ ("Domains"); |
|
18 | 18 | $domains = $PowerDNS->fetch_all_forward_domains (); |
19 | 19 | break; |
20 | 20 | // fetch v4 reverse domains |
21 | 21 | case 'reverse_v4': |
22 | - $title = _("IPv4 reverse domains"); |
|
22 | + $title = _ ("IPv4 reverse domains"); |
|
23 | 23 | $domains = $PowerDNS->fetch_reverse_v4_domains (); |
24 | 24 | break; |
25 | 25 | // fetch v6 reverse domains |
26 | 26 | case 'reverse_v6': |
27 | - $title = _("IPv6 reverse domains"); |
|
27 | + $title = _ ("IPv6 reverse domains"); |
|
28 | 28 | $domains = $PowerDNS->fetch_reverse_v6_domains (); |
29 | 29 | break; |
30 | 30 | // error |
31 | 31 | default: |
32 | - $Result->show("danger", "Invalid request", true); |
|
32 | + $Result->show ("danger", "Invalid request", true); |
|
33 | 33 | break; |
34 | 34 | } |
35 | 35 | ?> |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | |
40 | 40 | <!-- Back --> |
41 | 41 | <div class="btn-group" style="margin-bottom:10px;margin-top: 10px;"> |
42 | - <button class='btn btn-sm btn-default btn-success editDomain' data-action='add' data-id='0'><i class='fa fa-plus'></i> <?php print _('Create domain'); ?></button> |
|
42 | + <button class='btn btn-sm btn-default btn-success editDomain' data-action='add' data-id='0'><i class='fa fa-plus'></i> <?php print _ ('Create domain'); ?></button> |
|
43 | 43 | </div> |
44 | 44 | <br> |
45 | 45 | |
46 | 46 | |
47 | 47 | <?php |
48 | 48 | // none |
49 | -if($domains===false) { $Result->show("info alert-absolute", _("No domains configured"), false); } |
|
49 | +if ($domains === false) { $Result->show ("info alert-absolute", _ ("No domains configured"), false); } |
|
50 | 50 | else { |
51 | 51 | |
52 | 52 | ?> |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | <thead id="headers"> |
59 | 59 | <tr> |
60 | 60 | <th style="width:80px;"></th> |
61 | - <th><?php print _('Domain'); ?></th> |
|
62 | - <th><?php print _('Type'); ?></th> |
|
63 | - <th><?php print _('Master NS'); ?></th> |
|
64 | - <th><?php print _('Records'); ?></th> |
|
65 | - <th><?php print _('Serial number'); ?></th> |
|
61 | + <th><?php print _ ('Domain'); ?></th> |
|
62 | + <th><?php print _ ('Type'); ?></th> |
|
63 | + <th><?php print _ ('Master NS'); ?></th> |
|
64 | + <th><?php print _ ('Records'); ?></th> |
|
65 | + <th><?php print _ ('Serial number'); ?></th> |
|
66 | 66 | </tr> |
67 | 67 | </thead> |
68 | 68 | |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | /* prints domain records */ |
73 | 73 | foreach ($domains as $d) { |
74 | 74 | // nulls |
75 | - foreach($d as $k=>$v) { |
|
76 | - if (strlen($v)==0) $d->$k = "<span class='muted'>/</span>"; |
|
75 | + foreach ($d as $k=>$v) { |
|
76 | + if (strlen ($v) == 0) $d->$k = "<span class='muted'>/</span>"; |
|
77 | 77 | } |
78 | 78 | // cont records |
79 | 79 | $cnt = $PowerDNS->count_domain_records ($d->id); |
80 | 80 | // get SOA record |
81 | 81 | $soa = $PowerDNS->fetch_domain_records_by_type ($d->id, "SOA"); |
82 | - $serial = explode(" ", $soa[0]->content); |
|
82 | + $serial = explode (" ", $soa[0]->content); |
|
83 | 83 | $serial = $serial[2]; |
84 | 84 | |
85 | 85 | print "<tr>"; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | print " </td>"; |
93 | 93 | |
94 | 94 | // content |
95 | - print " <td><a href='".create_link("administration", "powerDNS", $_GET['subnetId'], "records", $d->name)."'>$d->name</a></td>"; |
|
95 | + print " <td><a href='".create_link ("administration", "powerDNS", $_GET['subnetId'], "records", $d->name)."'>$d->name</a></td>"; |
|
96 | 96 | print " <td><span class='badge badge1'>$d->type</span></td>"; |
97 | 97 | print " <td>$d->master</td>"; |
98 | 98 | print " <td><span class='badge'>$cnt</span></td>"; |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <!-- header --> |
2 | -<div class="pHeader"><?php print _("PTR zone refresh records"); ?></div> |
|
2 | +<div class="pHeader"><?php print _ ("PTR zone refresh records"); ?></div> |
|
3 | 3 | |
4 | 4 | <!-- content --> |
5 | 5 | <div class="pContent"> |
6 | - <?php print _('Clicking on regenerate will remove all PTR records for subnet and recreate new.'); ?> |
|
6 | + <?php print _ ('Clicking on regenerate will remove all PTR records for subnet and recreate new.'); ?> |
|
7 | 7 | <br> |
8 | 8 | |
9 | 9 | <div class="text-righ2t"> |
@@ -19,6 +19,6 @@ discard block |
||
19 | 19 | <!-- footer --> |
20 | 20 | <div class="pFooter"> |
21 | 21 | <div class="btn-group"> |
22 | - <button class="btn btn-sm btn-default hidePopupsReload"><?php print _('Close'); ?></button> |
|
22 | + <button class="btn btn-sm btn-default hidePopupsReload"><?php print _ ('Close'); ?></button> |
|
23 | 23 | </div> |
24 | 24 | </div> |
25 | 25 | \ No newline at end of file |
@@ -44,8 +44,8 @@ |
||
44 | 44 | |
45 | 45 | # set update values |
46 | 46 | $values_new = array("id"=>1, |
47 | - "powerDNS"=>json_encode($values), |
|
48 | - ); |
|
47 | + "powerDNS"=>json_encode($values), |
|
48 | + ); |
|
49 | 49 | if(!$Admin->object_modify("settings", "edit", "id", $values_new)) { $Result->show("danger", _("Cannot update settings"), false); } |
50 | 50 | else { $Result->show("success", _("Settings updated successfully"), false); } |
51 | 51 |
@@ -5,24 +5,24 @@ discard block |
||
5 | 5 | **************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Result = new Result (); |
15 | 15 | |
16 | 16 | # verify that user is logged in |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # validate csrf cookie |
20 | -$User->csrf_cookie ("validate", "pdns_settings", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; |
|
20 | +$User->csrf_cookie ("validate", "pdns_settings", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : ""; |
|
21 | 21 | |
22 | 22 | // validations |
23 | -if(strlen($_POST['name'])==0) { $Result->show("danger", "Invalid database name", true); } |
|
24 | -if(strlen($_POST['port'])==0) { $_POST['port'] = 3306; } |
|
25 | -elseif (!is_numeric($_POST['port'])) { $Result->show("danger", "Invalid port number", true); } |
|
23 | +if (strlen ($_POST['name']) == 0) { $Result->show ("danger", "Invalid database name", true); } |
|
24 | +if (strlen ($_POST['port']) == 0) { $_POST['port'] = 3306; } |
|
25 | +elseif (!is_numeric ($_POST['port'])) { $Result->show ("danger", "Invalid port number", true); } |
|
26 | 26 | |
27 | 27 | // formulate json |
28 | 28 | $values = new StdClass (); |
@@ -35,30 +35,30 @@ discard block |
||
35 | 35 | $values->autoserial = isset($_POST['autoserial']) ? "Yes" : "No"; |
36 | 36 | |
37 | 37 | // get old settings for defaults |
38 | -$old_values = json_decode($User->settings->powerDNS); |
|
38 | +$old_values = json_decode ($User->settings->powerDNS); |
|
39 | 39 | |
40 | -$values->ns = $old_values->ns; |
|
41 | -$values->hostmaster = $old_values->hostmaster; |
|
42 | -$values->def_ptr_domain = $old_values->def_ptr_domain; |
|
43 | -$values->refresh = $old_values->refresh; |
|
40 | +$values->ns = $old_values->ns; |
|
41 | +$values->hostmaster = $old_values->hostmaster; |
|
42 | +$values->def_ptr_domain = $old_values->def_ptr_domain; |
|
43 | +$values->refresh = $old_values->refresh; |
|
44 | 44 | $values->retry = $old_values->retry; |
45 | 45 | $values->expire = $old_values->expire; |
46 | 46 | $values->nxdomain_ttl = $old_values->nxdomain_ttl; |
47 | -$values->ttl = $old_values->ttl; |
|
47 | +$values->ttl = $old_values->ttl; |
|
48 | 48 | |
49 | 49 | # set update values |
50 | -$values_new = array("id"=>1, |
|
51 | - "powerDNS"=>json_encode($values), |
|
50 | +$values_new = array ("id"=>1, |
|
51 | + "powerDNS"=>json_encode ($values), |
|
52 | 52 | ); |
53 | -if(!$Admin->object_modify("settings", "edit", "id", $values_new)) { $Result->show("danger", _("Cannot update settings"), false); } |
|
54 | -else { $Result->show("success", _("Settings updated successfully"), false); } |
|
53 | +if (!$Admin->object_modify ("settings", "edit", "id", $values_new)) { $Result->show ("danger", _ ("Cannot update settings"), false); } |
|
54 | +else { $Result->show ("success", _ ("Settings updated successfully"), false); } |
|
55 | 55 | |
56 | 56 | # autoserial change - set default SOA for all records ! |
57 | -if ($values->autoserial!==@$old_values->autoserial) { |
|
57 | +if ($values->autoserial !== @$old_values->autoserial) { |
|
58 | 58 | // start class |
59 | - $PowerDNS = new PowerDNS ($Database); |
|
59 | + $PowerDNS = new PowerDNS ($Database); |
|
60 | 60 | // check connection |
61 | - if($PowerDNS->db_check()!==false) { |
|
61 | + if ($PowerDNS->db_check () !== false) { |
|
62 | 62 | // update all serials |
63 | 63 | $PowerDNS->update_all_soa_serials ($values->autoserial); |
64 | 64 | } |