@@ -5,22 +5,22 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | # include required scripts |
8 | -require_once( dirname(__FILE__) . '/../../../functions/functions.php' ); |
|
8 | +require_once(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object, if not already set |
11 | -if (!isset($Database)) { $Database = new Database_PDO; } |
|
11 | +if (!isset($Database)) { $Database = new Database_PDO; } |
|
12 | 12 | if (!isset($User)) { $User = new User ($Database); } |
13 | 13 | if (!isset($Admin)) { $Admin = new Admin ($Database); } |
14 | 14 | if (!isset($Tools)) { $Tools = new Tools ($Database); } |
15 | 15 | |
16 | 16 | # verify that user is logged in, to guard against direct access of page and possible exploits |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # fetch all l2 domains |
20 | -$vlan_domains = $Admin->fetch_all_objects("vlanDomains", "id"); |
|
20 | +$vlan_domains = $Admin->fetch_all_objects ("vlanDomains", "id"); |
|
21 | 21 | |
22 | 22 | # Load existing data |
23 | -$edata = array(); |
|
23 | +$edata = array (); |
|
24 | 24 | # process for easier later check |
25 | 25 | foreach ($vlan_domains as $vlan_domain) { |
26 | 26 | //cast |
@@ -29,51 +29,51 @@ discard block |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | $rows = ""; |
32 | -$counters = array(); |
|
33 | -$unique = array(); |
|
32 | +$counters = array (); |
|
33 | +$unique = array (); |
|
34 | 34 | |
35 | 35 | # check the fields |
36 | 36 | foreach ($data as &$cdata) { |
37 | 37 | $msg = ""; $action = ""; $cfieldtds = ""; |
38 | 38 | |
39 | 39 | # check if required fields are present and not empty |
40 | - foreach($reqfields as $creq) { |
|
41 | - if ((!isset($cdata[$creq])) or ($cdata[$creq] == "")) { $msg.= "Required field ".$creq." missing or empty."; $action = "error"; } |
|
40 | + foreach ($reqfields as $creq) { |
|
41 | + if ((!isset($cdata[$creq])) or ($cdata[$creq] == "")) { $msg .= "Required field ".$creq." missing or empty."; $action = "error"; } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | # check data format |
45 | 45 | if ($action != "error") { |
46 | - if (!preg_match("/^[a-zA-Z0-9-_ ]+$/", $cdata['name'])) { $msg.="Invalid name format."; $action = "error"; } |
|
47 | - if (preg_match("/[;'\"]/", $cdata['description'])) { $msg.="Invalid characters in description."; $action = "error"; } |
|
46 | + if (!preg_match ("/^[a-zA-Z0-9-_ ]+$/", $cdata['name'])) { $msg .= "Invalid name format."; $action = "error"; } |
|
47 | + if (preg_match ("/[;'\"]/", $cdata['description'])) { $msg .= "Invalid characters in description."; $action = "error"; } |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | # check if duplicate L2 domain |
51 | - if (isset($unique[$cdata['name']])) { $msg.= "Duplicate VLAN domain found. Please check import file."; $action = "error"; } |
|
51 | + if (isset($unique[$cdata['name']])) { $msg .= "Duplicate VLAN domain found. Please check import file."; $action = "error"; } |
|
52 | 52 | |
53 | 53 | # check if existing |
54 | 54 | if ($action != "error") { |
55 | 55 | if (isset($edata[$cdata['name']])) { |
56 | 56 | $cdata['id'] = $edata[$cdata['name']]['id']; |
57 | 57 | $action = "skip"; # skip duplicate fields if identical, update if different |
58 | - if ($cdata['description'] != $edata[$cdata['name']]['description']) { $msg.= "L2 Domain description will be updated."; $action = "edit"; } |
|
58 | + if ($cdata['description'] != $edata[$cdata['name']]['description']) { $msg .= "L2 Domain description will be updated."; $action = "edit"; } |
|
59 | 59 | |
60 | 60 | if ($action == "skip") { |
61 | - $msg.= "Duplicate, will skip."; |
|
61 | + $msg .= "Duplicate, will skip."; |
|
62 | 62 | } |
63 | 63 | } else { |
64 | - $msg.="New entry, will be added."; $action = "add"; |
|
64 | + $msg .= "New entry, will be added."; $action = "add"; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - $cdata['msg'].= $msg; |
|
68 | + $cdata['msg'] .= $msg; |
|
69 | 69 | $cdata['action'] = $action; |
70 | 70 | $counters[$action]++; |
71 | 71 | if (!isset($unique[$cdata['name']])) { $unique[$cdata['name']] = $cdata['name']; } |
72 | 72 | |
73 | - $rows.="<tr class='".$colors[$action]."'><td><i class='fa ".$icons[$action]."' rel='tooltip' data-placement='bottom' title='"._($msg)."'></i></td> |
|
73 | + $rows .= "<tr class='".$colors[$action]."'><td><i class='fa ".$icons[$action]."' rel='tooltip' data-placement='bottom' title='"._ ($msg)."'></i></td> |
|
74 | 74 | <td>".$cdata['name']."</td> |
75 | 75 | <td>".$cdata['description']."</td> |
76 | - <td>"._($cdata['msg'])."</td></tr>"; |
|
76 | + <td>"._ ($cdata['msg'])."</td></tr>"; |
|
77 | 77 | |
78 | 78 | } |
79 | 79 |
@@ -4,14 +4,14 @@ discard block |
||
4 | 4 | ************************************************/ |
5 | 5 | |
6 | 6 | # include required scripts |
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; |
|
10 | +$Database = new Database_PDO; |
|
11 | 11 | $User = new User ($Database); |
12 | 12 | |
13 | 13 | # verify that user is logged in, to guard against direct access of page and possible exploits |
14 | -$User->check_user_session(); |
|
14 | +$User->check_user_session (); |
|
15 | 15 | |
16 | 16 | # load data from uploaded file |
17 | 17 | include 'import-load-data.php'; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | ?> |
22 | 22 | |
23 | 23 | <!-- header --> |
24 | -<div class="pHeader"><?php print _("L2 Domain import"); ?></div> |
|
24 | +<div class="pHeader"><?php print _ ("L2 Domain import"); ?></div> |
|
25 | 25 | |
26 | 26 | <!-- content --> |
27 | 27 | <div class="pContent"> |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | foreach ($data as &$cdata) { |
36 | 36 | if (($cdata['action'] == "add") || ($cdata['action'] == "edit")) { |
37 | 37 | # set update array |
38 | - $values = array("id"=>$cdata['id'], |
|
38 | + $values = array ("id"=>$cdata['id'], |
|
39 | 39 | "name"=>$cdata['name'], |
40 | 40 | "description"=>$cdata['description'] |
41 | 41 | ); |
42 | 42 | |
43 | 43 | # update |
44 | - $cdata['result'] = $Admin->object_modify("vlanDomains", $cdata['action'], "id", $values); |
|
44 | + $cdata['result'] = $Admin->object_modify ("vlanDomains", $cdata['action'], "id", $values); |
|
45 | 45 | |
46 | 46 | if ($cdata['result']) { |
47 | 47 | $trc = $colors[$cdata['action']]; |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | $trc = "danger"; |
51 | 51 | $msg = "L2 Domain ".$cdata['action']." failed."; |
52 | 52 | } |
53 | - $rows.="<tr class='".$trc."'><td><i class='fa ".$icons[$cdata['action']]."' rel='tooltip' data-placement='bottom' title='"._($msg)."'></i></td> |
|
53 | + $rows .= "<tr class='".$trc."'><td><i class='fa ".$icons[$cdata['action']]."' rel='tooltip' data-placement='bottom' title='"._ ($msg)."'></i></td> |
|
54 | 54 | <td>".$cdata['name']."</td> |
55 | 55 | <td>".$cdata['description']."</td> |
56 | - <td>"._($msg)."</td></tr>"; |
|
56 | + <td>"._ ($msg)."</td></tr>"; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -67,5 +67,5 @@ discard block |
||
67 | 67 | |
68 | 68 | <!-- footer --> |
69 | 69 | <div class="pFooter"> |
70 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Close'); ?></button> |
|
70 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Close'); ?></button> |
|
71 | 71 | </div> |
@@ -5,40 +5,40 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | # include required scripts |
8 | -require_once( dirname(__FILE__) . '/../../../functions/functions.php' ); |
|
8 | +require_once(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object, if not already set |
11 | -if (!isset($Database)) { $Database = new Database_PDO; } |
|
11 | +if (!isset($Database)) { $Database = new Database_PDO; } |
|
12 | 12 | if (!isset($User)) { $User = new User ($Database); } |
13 | 13 | if (!isset($Admin)) { $Admin = new Admin ($Database); } |
14 | 14 | if (!isset($Tools)) { $Tools = new Tools ($Database); } |
15 | -if (!isset($Sections)) { $Sections = new Sections ($Database); } |
|
16 | -if (!isset($Subnets)) { $Subnets = new Subnets ($Database); } |
|
15 | +if (!isset($Sections)) { $Sections = new Sections ($Database); } |
|
16 | +if (!isset($Subnets)) { $Subnets = new Subnets ($Database); } |
|
17 | 17 | |
18 | 18 | # verify that user is logged in, to guard against direct access of page and possible exploits |
19 | -$User->check_user_session(); |
|
19 | +$User->check_user_session (); |
|
20 | 20 | |
21 | 21 | # Get mask check |
22 | 22 | #automated $cidrformat = isset($_GET['cidrformat']) ? $_GET['cidrformat'] : "off"; |
23 | 23 | #separate option $rebuildmnr = isset($_GET['rebuildmnr']) ? $_GET['rebuildmnr'] : "off"; |
24 | 24 | |
25 | 25 | # read again the custom fields, if any |
26 | -if (!isset($custom_fields)) { $custom_fields = $Tools->fetch_custom_fields("subnets"); } |
|
26 | +if (!isset($custom_fields)) { $custom_fields = $Tools->fetch_custom_fields ("subnets"); } |
|
27 | 27 | |
28 | 28 | # fetch all l2 domains |
29 | -$vlan_domains = $Admin->fetch_all_objects("vlanDomains", "id"); |
|
29 | +$vlan_domains = $Admin->fetch_all_objects ("vlanDomains", "id"); |
|
30 | 30 | # load VLANs and process for easier later check |
31 | -$vlan_data = array(); |
|
31 | +$vlan_data = array (); |
|
32 | 32 | foreach ($vlan_domains as $vlan_domain) { |
33 | 33 | //cast |
34 | 34 | $vlan_domain = (array) $vlan_domain; |
35 | 35 | // read vlans |
36 | - $all_vlans = $Admin->fetch_multiple_objects("vlans", "domainId", $vlan_domain['id'], "number"); |
|
36 | + $all_vlans = $Admin->fetch_multiple_objects ("vlans", "domainId", $vlan_domain['id'], "number"); |
|
37 | 37 | $all_vlans = (array) $all_vlans; |
38 | 38 | // skip empty domains |
39 | - if (sizeof($all_vlans)==0) { |
|
39 | + if (sizeof ($all_vlans) == 0) { |
|
40 | 40 | # create entry for domain check |
41 | - $vlan_data[$vlan_domain['name']] = array(); |
|
41 | + $vlan_data[$vlan_domain['name']] = array (); |
|
42 | 42 | continue; |
43 | 43 | } |
44 | 44 | //write all VLAN entries |
@@ -50,75 +50,75 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | # fetch all VRFs |
53 | -$all_vrfs = $Admin->fetch_all_objects("vrf", "vrfId"); |
|
54 | -if (!$all_vrfs) { $all_vrfs = array(); } |
|
53 | +$all_vrfs = $Admin->fetch_all_objects ("vrf", "vrfId"); |
|
54 | +if (!$all_vrfs) { $all_vrfs = array (); } |
|
55 | 55 | # insert default VRF in the list |
56 | -array_splice($all_vrfs,0,0,(object) array(array('vrfId' => '0', 'name' => 'default', 'rd' => '0:0'))); |
|
56 | +array_splice ($all_vrfs, 0, 0, (object) array (array ('vrfId' => '0', 'name' => 'default', 'rd' => '0:0'))); |
|
57 | 57 | # process for easier later check |
58 | -$vrf_data = array(); |
|
58 | +$vrf_data = array (); |
|
59 | 59 | foreach ($all_vrfs as $vrf) { |
60 | 60 | //cast |
61 | 61 | $vrf = (array) $vrf; |
62 | 62 | $vrf_data[$vrf['name']] = $vrf; |
63 | - $vrf_data[$vrf['rd']] = $vrf; # add also RD as VRF name, will allow matches against both name and RD |
|
63 | + $vrf_data[$vrf['rd']] = $vrf; # add also RD as VRF name, will allow matches against both name and RD |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | # fetch all sections and load all subnets |
67 | -$all_sections = $Sections->fetch_all_sections(); |
|
67 | +$all_sections = $Sections->fetch_all_sections (); |
|
68 | 68 | |
69 | 69 | # get all subnets in all sections |
70 | -$edata = array(); $section_names = array(); |
|
70 | +$edata = array (); $section_names = array (); |
|
71 | 71 | |
72 | 72 | foreach ($all_sections as $section) { |
73 | 73 | $section = (array) $section; |
74 | 74 | $section_names[$section['name']] = $section; |
75 | - $section_subnets = $Subnets->fetch_section_subnets($section['id']); |
|
75 | + $section_subnets = $Subnets->fetch_section_subnets ($section['id']); |
|
76 | 76 | # skip empty sections |
77 | - if (sizeof($section_subnets)==0) { continue; } |
|
77 | + if (sizeof ($section_subnets) == 0) { continue; } |
|
78 | 78 | |
79 | 79 | foreach ($section_subnets as $subnet) { |
80 | 80 | $subnet = (array) $subnet; |
81 | 81 | # load whole record in array |
82 | 82 | $edata[$section['id']][$subnet['vrfId']][$subnet['ip']][$subnet['mask']] = $subnet; |
83 | - $edata[$section['id']][$subnet['vrfId']][$subnet['ip']][$subnet['mask']]['type'] = $Subnets->identify_address($subnet['ip']); |
|
83 | + $edata[$section['id']][$subnet['vrfId']][$subnet['ip']][$subnet['mask']]['type'] = $Subnets->identify_address ($subnet['ip']); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | 87 | #print_r($vlan_data); |
88 | 88 | |
89 | 89 | $rows = ""; |
90 | -$counters = array(); |
|
91 | -$ndata = array(); # store new networks in a similar format with edata for easier processing |
|
90 | +$counters = array (); |
|
91 | +$ndata = array (); # store new networks in a similar format with edata for easier processing |
|
92 | 92 | |
93 | 93 | # check the fields |
94 | 94 | foreach ($data as &$cdata) { |
95 | 95 | $msg = ""; $action = ""; $cfieldtds = ""; |
96 | 96 | |
97 | 97 | # check if required fields are present and not empty |
98 | - foreach($reqfields as $creq) { |
|
99 | - if ((!isset($cdata[$creq])) or ($cdata[$creq] == "")) { $msg.= "Required field ".$creq." missing or empty."; $action = "error"; } |
|
98 | + foreach ($reqfields as $creq) { |
|
99 | + if ((!isset($cdata[$creq])) or ($cdata[$creq] == "")) { $msg .= "Required field ".$creq." missing or empty."; $action = "error"; } |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | # if the subnet contains "/", split it in network and mask |
103 | 103 | if ($action != "error") { |
104 | - if (preg_match("/\//", $cdata['subnet'])) { |
|
105 | - list($caddr,$cmask) = explode("/",$cdata['subnet'],2); |
|
104 | + if (preg_match ("/\//", $cdata['subnet'])) { |
|
105 | + list($caddr, $cmask) = explode ("/", $cdata['subnet'], 2); |
|
106 | 106 | $cdata['mask'] = $cmask; |
107 | 107 | $cdata['subnet'] = $caddr; |
108 | 108 | } else { # check that mask is provided |
109 | - if ((!isset($cdata['mask'])) or ($cdata['mask'] == "")) { $msg.= "Required field mask missing or empty."; $action = "error"; } |
|
109 | + if ((!isset($cdata['mask'])) or ($cdata['mask'] == "")) { $msg .= "Required field mask missing or empty."; $action = "error"; } |
|
110 | 110 | } |
111 | - if ((!empty($cdata['mask'])) && (!preg_match("/^([0-9]+|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)$/", $cdata['mask']))) { |
|
112 | - $msg.="Invalid network mask format."; $action = "error"; |
|
111 | + if ((!empty($cdata['mask'])) && (!preg_match ("/^([0-9]+|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)$/", $cdata['mask']))) { |
|
112 | + $msg .= "Invalid network mask format."; $action = "error"; |
|
113 | 113 | } else { |
114 | - $cdata['type'] = $Subnets->identify_address($cdata['subnet']); |
|
115 | - if (($cdata['type'] == "IPv6") && (($cdata['mask']<0) || ($cdata['mask']>128))) { $msg.="Invalid IPv6 network mask."; $action = "error"; } |
|
114 | + $cdata['type'] = $Subnets->identify_address ($cdata['subnet']); |
|
115 | + if (($cdata['type'] == "IPv6") && (($cdata['mask'] < 0) || ($cdata['mask'] > 128))) { $msg .= "Invalid IPv6 network mask."; $action = "error"; } |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | 119 | # Check if section is provided and valid and link it if it is |
120 | 120 | if (!isset($section_names[$cdata['section']])) { |
121 | - $msg.= "Invalid section."; $action = "error"; |
|
121 | + $msg .= "Invalid section."; $action = "error"; |
|
122 | 122 | } else { |
123 | 123 | $cdata['sectionId'] = $section_names[$cdata['section']]['id']; |
124 | 124 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | # Check if VRF is provided and valid and link it if it is |
127 | 127 | if (!empty($cdata['vrf'])) { |
128 | 128 | if (!isset($vrf_data[$cdata['vrf']])) { |
129 | - $msg.= "Invalid VRF."; $action = "error"; |
|
129 | + $msg .= "Invalid VRF."; $action = "error"; |
|
130 | 130 | } else { |
131 | 131 | $cdata['vrfId'] = $vrf_data[$cdata['vrf']]['vrfId']; |
132 | 132 | } |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | if (!empty($cdata['domain'])) { $cdom = $cdata['domain']; } else { $cdom = "default"; } |
140 | 140 | if (!isset($vlan_data[$cdom])) { |
141 | 141 | # the default domain is always there, so if anything is missing we return an error |
142 | - $msg.= "Invalid VLAN domain."; $action = "error"; |
|
142 | + $msg .= "Invalid VLAN domain."; $action = "error"; |
|
143 | 143 | } else { |
144 | 144 | if (!empty($cdata['vlan'])) { |
145 | - if (in_array(strtolower($cdata['vlan']),array("na","n/a","nan"))) { $cdata['vlan'] = ""; } |
|
146 | - if ((!empty($cdata['vlan'])) && (strtolower($cdata['vlan']) != "na")) { |
|
145 | + if (in_array (strtolower ($cdata['vlan']), array ("na", "n/a", "nan"))) { $cdata['vlan'] = ""; } |
|
146 | + if ((!empty($cdata['vlan'])) && (strtolower ($cdata['vlan']) != "na")) { |
|
147 | 147 | if (!isset($vlan_data[$cdom][$cdata['vlan']])) { |
148 | - $msg.= "VLAN not found in provided domain."; $action = "error"; |
|
148 | + $msg .= "VLAN not found in provided domain."; $action = "error"; |
|
149 | 149 | } else { |
150 | 150 | $cdata['vlanId'] = $vlan_data[$cdom][$cdata['vlan']]['vlanId']; |
151 | 151 | } |
@@ -158,20 +158,20 @@ discard block |
||
158 | 158 | |
159 | 159 | # check data format |
160 | 160 | if ($action != "error") { |
161 | - if ($net = $Subnets->get_network_boundaries($cdata['subnet'],$cdata['mask'])) { |
|
161 | + if ($net = $Subnets->get_network_boundaries ($cdata['subnet'], $cdata['mask'])) { |
|
162 | 162 | $cdata['mask'] = $net['bitmask']; |
163 | - $cidr_check = $Subnets->verify_cidr_address($cdata['subnet']."/".$cdata['mask']); |
|
164 | - if (strlen($cidr_check)>5) { $msg.=$cidr_check; $action = "error"; } |
|
165 | - } else { $msg.=$net['message']; $action = "error"; } |
|
166 | - if (preg_match("/[;'\"]/", $cdata['description'])) { $msg.="Invalid characters in description."; $action = "error"; } |
|
167 | - if ((!empty($cdata['vrf'])) && (!preg_match("/^[a-zA-Z0-9-:]+$/", $cdata['vrf']))) { $msg.="Invalid VRF name format."; $action = "error"; } |
|
168 | - if ((!empty($cdata['vlan'])) && (!preg_match("/^[0-9]+$/", $cdata['vlan']))) { $msg.="Invalid VLAN number format."; $action = "error"; } |
|
169 | - if ((!empty($cdata['domain'])) && (!preg_match("/^[a-zA-Z0-9-_ ]+$/", $cdata['domain']))) { $msg.="Invalid VLAN domain format."; $action = "error"; } |
|
163 | + $cidr_check = $Subnets->verify_cidr_address ($cdata['subnet']."/".$cdata['mask']); |
|
164 | + if (strlen ($cidr_check) > 5) { $msg .= $cidr_check; $action = "error"; } |
|
165 | + } else { $msg .= $net['message']; $action = "error"; } |
|
166 | + if (preg_match ("/[;'\"]/", $cdata['description'])) { $msg .= "Invalid characters in description."; $action = "error"; } |
|
167 | + if ((!empty($cdata['vrf'])) && (!preg_match ("/^[a-zA-Z0-9-:]+$/", $cdata['vrf']))) { $msg .= "Invalid VRF name format."; $action = "error"; } |
|
168 | + if ((!empty($cdata['vlan'])) && (!preg_match ("/^[0-9]+$/", $cdata['vlan']))) { $msg .= "Invalid VLAN number format."; $action = "error"; } |
|
169 | + if ((!empty($cdata['domain'])) && (!preg_match ("/^[a-zA-Z0-9-_ ]+$/", $cdata['domain']))) { $msg .= "Invalid VLAN domain format."; $action = "error"; } |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | # check if duplicate in the import data |
173 | 173 | if ($action != "error") { |
174 | - if (isset($ndata[$cdata['sectionId']][$cdata['vrfId']][$cdata['subnet']][$cdata['mask']])) { $msg.="Duplicate entry in imported data."; $action = "error"; } |
|
174 | + if (isset($ndata[$cdata['sectionId']][$cdata['vrfId']][$cdata['subnet']][$cdata['mask']])) { $msg .= "Duplicate entry in imported data."; $action = "error"; } |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | # check if existing in database |
@@ -182,19 +182,19 @@ discard block |
||
182 | 182 | |
183 | 183 | # Check if we need to change any fields |
184 | 184 | $action = "skip"; # skip duplicate fields if identical, update if different |
185 | - if ($cdata['description'] != $cedata['description']) { $msg.= "Subnet description will be updated."; $action = "edit"; } |
|
186 | - if ($cdata['vlanId'] != $cedata['vlanId']) { $msg.= "VLAN ID will be updated."; $action = "edit"; } |
|
185 | + if ($cdata['description'] != $cedata['description']) { $msg .= "Subnet description will be updated."; $action = "edit"; } |
|
186 | + if ($cdata['vlanId'] != $cedata['vlanId']) { $msg .= "VLAN ID will be updated."; $action = "edit"; } |
|
187 | 187 | # Check if the values of the custom fields have changed |
188 | - if(sizeof($custom_fields) > 0) { |
|
189 | - foreach($custom_fields as $myField) { |
|
188 | + if (sizeof ($custom_fields) > 0) { |
|
189 | + foreach ($custom_fields as $myField) { |
|
190 | 190 | if ($cdata[$myField['name']] != $cedata[$myField['name']]) { |
191 | - $msg.= $myField['name']." will be updated."; $action = "edit"; |
|
191 | + $msg .= $myField['name']." will be updated."; $action = "edit"; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | 196 | if ($action == "skip") { |
197 | - $msg.= "Duplicate, will skip."; |
|
197 | + $msg .= "Duplicate, will skip."; |
|
198 | 198 | } else { |
199 | 199 | # set id of matched subnet |
200 | 200 | $cdata['id'] = $cedata['id']; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | // $cdata['pingSubnet'] = $cedata['pingSubnet']; $cdata['discoverSubnet'] = $cedata['discoverSubnet']; |
206 | 206 | } |
207 | 207 | } else { |
208 | - $msg.="New entry, will be added."; $action = "add"; |
|
208 | + $msg .= "New entry, will be added."; $action = "add"; |
|
209 | 209 | # Set master to 0 for now, will figure that after we add it, with the recompute function |
210 | 210 | $cdata['masterSubnetId'] = "0"; |
211 | 211 | # Inherit section permissions for new subnets |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - $cdata['msg'].= $msg; |
|
222 | + $cdata['msg'] .= $msg; |
|
223 | 223 | $cdata['action'] = $action; |
224 | 224 | $counters[$action]++; |
225 | 225 | |
226 | - $rows.="<tr class='".$colors[$action]."'><td><i class='fa ".$icons[$action]."' rel='tooltip' data-placement='bottom' title='"._($msg)."'></i></td>"; |
|
227 | - foreach ($expfields as $cfield) { $rows.= "<td>".$cdata[$cfield]."</td>"; } |
|
228 | - $rows.= "<td>"._($cdata['msg'])."</td></tr>"; |
|
226 | + $rows .= "<tr class='".$colors[$action]."'><td><i class='fa ".$icons[$action]."' rel='tooltip' data-placement='bottom' title='"._ ($msg)."'></i></td>"; |
|
227 | + foreach ($expfields as $cfield) { $rows .= "<td>".$cdata[$cfield]."</td>"; } |
|
228 | + $rows .= "<td>"._ ($cdata['msg'])."</td></tr>"; |
|
229 | 229 | |
230 | 230 | } |
231 | 231 |
@@ -5,55 +5,55 @@ discard block |
||
5 | 5 | *********************************/ |
6 | 6 | |
7 | 7 | # include required scripts |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php' ); |
|
9 | -require( dirname(__FILE__) . '/../../../functions/PEAR/Spreadsheet/Excel/Writer.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | +require(dirname (__FILE__).'/../../../functions/PEAR/Spreadsheet/Excel/Writer.php'); |
|
10 | 10 | |
11 | 11 | # initialize required objects |
12 | -$Database = new Database_PDO; |
|
12 | +$Database = new Database_PDO; |
|
13 | 13 | $Result = new Result; |
14 | -$User = new User ($Database); |
|
14 | +$User = new User ($Database); |
|
15 | 15 | $Admin = new Admin ($Database); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # fetch all vrfs |
21 | -$all_vrfs = $Admin->fetch_all_objects("vrf", "vrfId"); |
|
22 | -if (!$all_vrfs) { $all_vrfs = array(); } |
|
21 | +$all_vrfs = $Admin->fetch_all_objects ("vrf", "vrfId"); |
|
22 | +if (!$all_vrfs) { $all_vrfs = array (); } |
|
23 | 23 | |
24 | 24 | # Create a workbook |
25 | -$today = date("Ymd"); |
|
25 | +$today = date ("Ymd"); |
|
26 | 26 | $filename = $today."_phpipam_VRF_export.xls"; |
27 | -$workbook = new Spreadsheet_Excel_Writer(); |
|
27 | +$workbook = new Spreadsheet_Excel_Writer (); |
|
28 | 28 | |
29 | 29 | //formatting headers |
30 | -$format_header =& $workbook->addFormat(); |
|
31 | -$format_header->setBold(); |
|
32 | -$format_header->setColor('black'); |
|
33 | -$format_header->setSize(12); |
|
34 | -$format_header->setAlign('left'); |
|
30 | +$format_header = & $workbook->addFormat (); |
|
31 | +$format_header->setBold (); |
|
32 | +$format_header->setColor ('black'); |
|
33 | +$format_header->setSize (12); |
|
34 | +$format_header->setAlign ('left'); |
|
35 | 35 | |
36 | 36 | //formatting content |
37 | -$format_text =& $workbook->addFormat(); |
|
37 | +$format_text = & $workbook->addFormat (); |
|
38 | 38 | |
39 | 39 | // Create a worksheet |
40 | 40 | $worksheet_name = "VRFs"; |
41 | -$worksheet =& $workbook->addWorksheet($worksheet_name); |
|
41 | +$worksheet = & $workbook->addWorksheet ($worksheet_name); |
|
42 | 42 | |
43 | 43 | $lineCount = 0; |
44 | 44 | $rowCount = 0; |
45 | 45 | |
46 | 46 | //write headers |
47 | -if( (isset($_GET['name'])) && ($_GET['name'] == "on") ) { |
|
48 | - $worksheet->write($lineCount, $rowCount, _('Name') ,$format_header); |
|
47 | +if ((isset($_GET['name'])) && ($_GET['name'] == "on")) { |
|
48 | + $worksheet->write ($lineCount, $rowCount, _ ('Name'), $format_header); |
|
49 | 49 | $rowCount++; |
50 | 50 | } |
51 | -if( (isset($_GET['rd'])) && ($_GET['rd'] == "on") ) { |
|
52 | - $worksheet->write($lineCount, $rowCount, _('RD') ,$format_header); |
|
51 | +if ((isset($_GET['rd'])) && ($_GET['rd'] == "on")) { |
|
52 | + $worksheet->write ($lineCount, $rowCount, _ ('RD'), $format_header); |
|
53 | 53 | $rowCount++; |
54 | 54 | } |
55 | -if( (isset($_GET['description'])) && ($_GET['description'] == "on") ) { |
|
56 | - $worksheet->write($lineCount, $rowCount, _('Description') ,$format_header); |
|
55 | +if ((isset($_GET['description'])) && ($_GET['description'] == "on")) { |
|
56 | + $worksheet->write ($lineCount, $rowCount, _ ('Description'), $format_header); |
|
57 | 57 | $rowCount++; |
58 | 58 | } |
59 | 59 | |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | //reset row count |
68 | 68 | $rowCount = 0; |
69 | 69 | |
70 | - if( (isset($_GET['name'])) && ($_GET['name'] == "on") ) { |
|
71 | - $worksheet->write($lineCount, $rowCount, $vrf['name'], $format_text); |
|
70 | + if ((isset($_GET['name'])) && ($_GET['name'] == "on")) { |
|
71 | + $worksheet->write ($lineCount, $rowCount, $vrf['name'], $format_text); |
|
72 | 72 | $rowCount++; |
73 | 73 | } |
74 | - if( (isset($_GET['rd'])) && ($_GET['rd'] == "on") ) { |
|
75 | - $worksheet->write($lineCount, $rowCount, $vrf['rd'], $format_text); |
|
74 | + if ((isset($_GET['rd'])) && ($_GET['rd'] == "on")) { |
|
75 | + $worksheet->write ($lineCount, $rowCount, $vrf['rd'], $format_text); |
|
76 | 76 | $rowCount++; |
77 | 77 | } |
78 | - if( (isset($_GET['description'])) && ($_GET['description'] == "on") ) { |
|
79 | - $worksheet->write($lineCount, $rowCount, $vrf['description'], $format_text); |
|
78 | + if ((isset($_GET['description'])) && ($_GET['description'] == "on")) { |
|
79 | + $worksheet->write ($lineCount, $rowCount, $vrf['description'], $format_text); |
|
80 | 80 | $rowCount++; |
81 | 81 | } |
82 | 82 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | $lineCount++; |
88 | 88 | |
89 | 89 | // sending HTTP headers |
90 | -$workbook->send($filename); |
|
90 | +$workbook->send ($filename); |
|
91 | 91 | |
92 | 92 | // Let's send the file |
93 | -$workbook->close(); |
|
93 | +$workbook->close (); |
|
94 | 94 | |
95 | 95 | ?> |
96 | 96 | \ No newline at end of file |
@@ -5,15 +5,15 @@ discard block |
||
5 | 5 | ************************************/ |
6 | 6 | |
7 | 7 | # include required scripts |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php' ); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize required objects |
11 | -$Database = new Database_PDO; |
|
12 | -$Result = new Result; |
|
13 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$Result = new Result; |
|
13 | +$User = new User ($Database); |
|
14 | 14 | |
15 | 15 | # verify that user is logged in |
16 | -$User->check_user_session(); |
|
16 | +$User->check_user_session (); |
|
17 | 17 | |
18 | 18 | # load data from uploaded file |
19 | 19 | include 'import-load-data.php'; |
@@ -23,26 +23,26 @@ discard block |
||
23 | 23 | ?> |
24 | 24 | |
25 | 25 | <!-- header --> |
26 | -<div class="pHeader"><?php print _("VLAN import data preview"); ?></div> |
|
26 | +<div class="pHeader"><?php print _ ("VLAN import data preview"); ?></div> |
|
27 | 27 | |
28 | 28 | <!-- content --> |
29 | 29 | <div class="pContent"> |
30 | 30 | <?php |
31 | 31 | |
32 | -print '<h4>'._("Uploaded data").'</h4><hr>'; |
|
33 | -print _("The entries marked with ")."<i class='fa ".$icons['add']."'></i>, "._("will be added, |
|
34 | - the ones marked with ")."<i class='fa ".$icons['edit']."'></i>, "._("will be updated |
|
35 | - and the ones marked with ")."<i class='fa ".$icons['skip']."'></i> "._("will be skipped."); |
|
32 | +print '<h4>'._ ("Uploaded data").'</h4><hr>'; |
|
33 | +print _ ("The entries marked with ")."<i class='fa ".$icons['add']."'></i>, "._ ("will be added, |
|
34 | + the ones marked with ")."<i class='fa ".$icons['edit']."'></i>, "._ ("will be updated |
|
35 | + and the ones marked with ")."<i class='fa ".$icons['skip']."'></i> "._ ("will be skipped."); |
|
36 | 36 | |
37 | -print "<b>"._("Summary: ")."</b>".($counters['add'] > 0 ? $counters['add'] : "no")._(" new entries. |
|
38 | - ").($counters['edit'] > 0 ? $counters['edit'] : "no")._(" updated entries. |
|
39 | - ").($counters['error'] > 0 ? $counters['error'] : "no")._(" entries skipped due to errors. |
|
40 | - ").($counters['skip'] > 0 ? $counters['skip'] : "no")._(" duplicate entries. |
|
41 | - ")._("Scroll down for details."); |
|
37 | +print "<b>"._ ("Summary: ")."</b>".($counters['add'] > 0 ? $counters['add'] : "no")._ (" new entries. |
|
38 | + ").($counters['edit'] > 0 ? $counters['edit'] : "no")._ (" updated entries. |
|
39 | + ").($counters['error'] > 0 ? $counters['error'] : "no")._ (" entries skipped due to errors. |
|
40 | + ").($counters['skip'] > 0 ? $counters['skip'] : "no")._ (" duplicate entries. |
|
41 | + ")._ ("Scroll down for details."); |
|
42 | 42 | |
43 | 43 | print "<form id='selectImportFields'>"; |
44 | -print "<input name='expfields' type='hidden' value='".implode('|',$expfields)."' style='display:none;'>"; |
|
45 | -print "<input name='reqfields' type='hidden' value='".implode('|',$reqfields)."' style='display:none;'>"; |
|
44 | +print "<input name='expfields' type='hidden' value='".implode ('|', $expfields)."' style='display:none;'>"; |
|
45 | +print "<input name='reqfields' type='hidden' value='".implode ('|', $reqfields)."' style='display:none;'>"; |
|
46 | 46 | print $hiddenfields; |
47 | 47 | print "<input name='filetype' id='filetype' type='hidden' value='".$filetype."' style='display:none;'>"; |
48 | 48 | print "</form>"; |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | <!-- footer --> |
58 | 58 | <div class="pFooter"> |
59 | 59 | <div class="btn-group"> |
60 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
61 | - <button class="btn btn-sm btn-default" id="dataImportSubmit" data-type="vlan" disabled><i class="fa fa-download"></i> <?php print _('Import'); ?></button> |
|
60 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
61 | + <button class="btn btn-sm btn-default" id="dataImportSubmit" data-type="vlan" disabled><i class="fa fa-download"></i> <?php print _ ('Import'); ?></button> |
|
62 | 62 | </div> |
63 | 63 | </div> |
64 | 64 |
@@ -5,16 +5,16 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | # include required scripts |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php' ); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | 15 | |
16 | 16 | # verify that user is logged in |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # prepare HTML variables |
20 | 20 | $custom_fields_names = ""; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ?> |
24 | 24 | |
25 | 25 | <!-- header --> |
26 | -<div class="pHeader"><?php print _("Select L2 Domain fields to export"); ?></div> |
|
26 | +<div class="pHeader"><?php print _ ("Select L2 Domain fields to export"); ?></div> |
|
27 | 27 | |
28 | 28 | <!-- content --> |
29 | 29 | <div class="pContent" style="overflow:auto;"> |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | print " <table class='table table-striped table-condensed'>"; |
38 | 38 | |
39 | 39 | print " <tr>"; |
40 | -print " <th>"._('Name')."</th>"; |
|
41 | -print " <th>"._('Description')."</th>"; |
|
40 | +print " <th>"._ ('Name')."</th>"; |
|
41 | +print " <th>"._ ('Description')."</th>"; |
|
42 | 42 | print " </tr>"; |
43 | 43 | |
44 | 44 | print " <tr>"; |
45 | -print " <td><input type='checkbox' name='name' checked title='"._('Mandatory')."'></td>"; |
|
45 | +print " <td><input type='checkbox' name='name' checked title='"._ ('Mandatory')."'></td>"; |
|
46 | 46 | print " <td><input type='checkbox' name='description' checked> </td>"; |
47 | 47 | print " </tr>"; |
48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | <!-- footer --> |
57 | 57 | <div class="pFooter"> |
58 | 58 | <div class="btn-group"> |
59 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
60 | - <button class="btn btn-sm btn-success" id="dataExportSubmit" data-type="l2dom"><i class="fa fa-upload"></i> <?php print _('Export'); ?></button> |
|
59 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
60 | + <button class="btn btn-sm btn-success" id="dataExportSubmit" data-type="l2dom"><i class="fa fa-upload"></i> <?php print _ ('Export'); ?></button> |
|
61 | 61 | </div> |
62 | 62 | </div> |
@@ -5,16 +5,16 @@ discard block |
||
5 | 5 | ************************************/ |
6 | 6 | |
7 | 7 | # include required scripts |
8 | -require_once( dirname(__FILE__) . '/../../../functions/functions.php' ); |
|
8 | +require_once(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize required objects |
11 | -$Database = new Database_PDO; |
|
11 | +$Database = new Database_PDO; |
|
12 | 12 | $Result = new Result; |
13 | -$User = new User ($Database); |
|
13 | +$User = new User ($Database); |
|
14 | 14 | $Admin = new Admin ($Database); |
15 | 15 | |
16 | 16 | # verify that user is logged in |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # Load subnets and recompute the master/nested relations |
20 | 20 | include 'import-recompute-logic.php'; |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | ?> |
23 | 23 | |
24 | 24 | <!-- header --> |
25 | -<div class="pHeader"><?php print _("Subnets master/nested recompute data preview"); ?></div> |
|
25 | +<div class="pHeader"><?php print _ ("Subnets master/nested recompute data preview"); ?></div> |
|
26 | 26 | |
27 | 27 | <!-- content --> |
28 | 28 | <div class="pContent"> |
29 | 29 | <?php |
30 | 30 | |
31 | -print '<h4>'._("Recomputed data").'</h4><hr>'; |
|
32 | -print _("The entries marked with ")."<i class='fa ".$icons['edit']."'></i>, "._("have new masters and will be updated, |
|
33 | - the ones marked with ")."<i class='fa ".$icons['skip']."'></i>, "._("didn't change the master."); |
|
31 | +print '<h4>'._ ("Recomputed data").'</h4><hr>'; |
|
32 | +print _ ("The entries marked with ")."<i class='fa ".$icons['edit']."'></i>, "._ ("have new masters and will be updated, |
|
33 | + the ones marked with ")."<i class='fa ".$icons['skip']."'></i>, "._ ("didn't change the master."); |
|
34 | 34 | |
35 | 35 | print "<form id='selectImportFields'>".$pass_inputs."</form>"; |
36 | 36 | print "<table class='table table-condensed table-hover' id='previewtable'><tbody>"; |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | <!-- footer --> |
47 | 47 | <div class="pFooter"> |
48 | 48 | <div class="btn-group"> |
49 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
50 | - <button class="btn btn-sm btn-default" id="dataImportSubmit" data-type="recompute" disabled><i class="fa fa-magic"></i> <?php print _('Save'); ?></button> |
|
49 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
50 | + <button class="btn btn-sm btn-default" id="dataImportSubmit" data-type="recompute" disabled><i class="fa fa-magic"></i> <?php print _ ('Save'); ?></button> |
|
51 | 51 | </div> |
52 | 52 | </div> |
53 | 53 |
@@ -5,39 +5,39 @@ discard block |
||
5 | 5 | *********************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
9 | -require( dirname(__FILE__) . '/../../../functions/PEAR/Spreadsheet/Excel/Writer.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | +require(dirname (__FILE__).'/../../../functions/PEAR/Spreadsheet/Excel/Writer.php'); |
|
10 | 10 | |
11 | 11 | |
12 | 12 | # initialize user object |
13 | -$Database = new Database_PDO; |
|
14 | -$User = new User ($Database); |
|
15 | -$Sections = new Sections ($Database); |
|
13 | +$Database = new Database_PDO; |
|
14 | +$User = new User ($Database); |
|
15 | +$Sections = new Sections ($Database); |
|
16 | 16 | $Subnets = new Subnets ($Database); |
17 | -$Addresses = new Addresses ($Database); |
|
18 | -$Tools = new Tools ($Database); |
|
17 | +$Addresses = new Addresses ($Database); |
|
18 | +$Tools = new Tools ($Database); |
|
19 | 19 | $Result = new Result (); |
20 | 20 | |
21 | 21 | # verify that user is logged in |
22 | -$User->check_user_session(); |
|
22 | +$User->check_user_session (); |
|
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | 26 | // Create a workbook |
27 | -$filename = "phpipam_IP_adress_export_". date("Y-m-d") .".xls"; |
|
28 | -$workbook = new Spreadsheet_Excel_Writer(); |
|
29 | -$workbook->setVersion(8); |
|
27 | +$filename = "phpipam_IP_adress_export_".date ("Y-m-d").".xls"; |
|
28 | +$workbook = new Spreadsheet_Excel_Writer (); |
|
29 | +$workbook->setVersion (8); |
|
30 | 30 | |
31 | 31 | //fetch sections, and for each section write new tab, inside tab write all values! |
32 | -$sections = $Sections->fetch_sections(); |
|
32 | +$sections = $Sections->fetch_sections (); |
|
33 | 33 | |
34 | 34 | //we need to reformat state! |
35 | -$ip_types = $Addresses->addresses_types_fetch(); |
|
35 | +$ip_types = $Addresses->addresses_types_fetch (); |
|
36 | 36 | //fetch devices and reorder |
37 | -$devices = $Tools->fetch_all_objects("devices", "hostname"); |
|
38 | -$devices_indexed = array(); |
|
39 | -if ($devices!==false) { |
|
40 | - foreach($devices as $d) { |
|
37 | +$devices = $Tools->fetch_all_objects ("devices", "hostname"); |
|
38 | +$devices_indexed = array (); |
|
39 | +if ($devices !== false) { |
|
40 | + foreach ($devices as $d) { |
|
41 | 41 | $devices_indexed[$d->id] = $d; |
42 | 42 | } |
43 | 43 | } |
@@ -46,43 +46,43 @@ discard block |
||
46 | 46 | |
47 | 47 | //get all custom fields! |
48 | 48 | # fetch custom fields |
49 | -$myFields = $Tools->fetch_custom_fields('ipaddresses'); |
|
50 | -$myFieldsSize = sizeof($myFields); |
|
49 | +$myFields = $Tools->fetch_custom_fields ('ipaddresses'); |
|
50 | +$myFieldsSize = sizeof ($myFields); |
|
51 | 51 | |
52 | 52 | $colSize = 8 + $myFieldsSize; |
53 | 53 | |
54 | 54 | //formatting headers |
55 | -$format_header = $workbook->addFormat(); |
|
56 | -$format_header->setBold(); |
|
57 | -$format_header->setColor('white'); |
|
58 | -$format_header->setFgColor('black'); |
|
55 | +$format_header = $workbook->addFormat (); |
|
56 | +$format_header->setBold (); |
|
57 | +$format_header->setColor ('white'); |
|
58 | +$format_header->setFgColor ('black'); |
|
59 | 59 | |
60 | 60 | //formatting titles |
61 | -$format_title = $workbook->addFormat(); |
|
62 | -$format_title->setColor('black'); |
|
63 | -$format_title->setFgColor(22); //light gray |
|
64 | -$format_title->setBottom(2); |
|
65 | -$format_title->setLeft(1); |
|
66 | -$format_title->setRight(1); |
|
67 | -$format_title->setTop(1); |
|
68 | -$format_title->setAlign('left'); |
|
61 | +$format_title = $workbook->addFormat (); |
|
62 | +$format_title->setColor ('black'); |
|
63 | +$format_title->setFgColor (22); //light gray |
|
64 | +$format_title->setBottom (2); |
|
65 | +$format_title->setLeft (1); |
|
66 | +$format_title->setRight (1); |
|
67 | +$format_title->setTop (1); |
|
68 | +$format_title->setAlign ('left'); |
|
69 | 69 | |
70 | 70 | //formatting content - borders around IP addresses |
71 | -$format_right = $workbook->addFormat(); |
|
72 | -$format_right->setRight(1); |
|
73 | -$format_left = $workbook->addFormat(); |
|
74 | -$format_left->setLeft(1); |
|
75 | -$format_top = $workbook->addFormat(); |
|
76 | -$format_top->setTop(1); |
|
71 | +$format_right = $workbook->addFormat (); |
|
72 | +$format_right->setRight (1); |
|
73 | +$format_left = $workbook->addFormat (); |
|
74 | +$format_left->setLeft (1); |
|
75 | +$format_top = $workbook->addFormat (); |
|
76 | +$format_top->setTop (1); |
|
77 | 77 | |
78 | 78 | |
79 | 79 | foreach ($sections as $section) { |
80 | 80 | //cast |
81 | 81 | $section = (array) $section; |
82 | 82 | // Create a worksheet |
83 | - $worksheet_name = strlen($section['name']) > 30 ? substr($section['name'],0,27).'...' : $section['name']; |
|
84 | - $worksheet =& $workbook->addWorksheet($worksheet_name); |
|
85 | - $worksheet->setInputEncoding("utf-8"); |
|
83 | + $worksheet_name = strlen ($section['name']) > 30 ? substr ($section['name'], 0, 27).'...' : $section['name']; |
|
84 | + $worksheet = & $workbook->addWorksheet ($worksheet_name); |
|
85 | + $worksheet->setInputEncoding ("utf-8"); |
|
86 | 86 | |
87 | 87 | //get all subnets in this section |
88 | 88 | $subnets = $Subnets->fetch_section_subnets ($section['id']); |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | //cast |
94 | 94 | $subnet = (array) $subnet; |
95 | 95 | //ignore folders! |
96 | - if($subnet['isFolder']!="1") { |
|
96 | + if ($subnet['isFolder'] != "1") { |
|
97 | 97 | //vlan details |
98 | - $vlan = (array) $Tools->fetch_object("vlans", "vlanId", $subnet['vlanId']); |
|
99 | - if(strlen($vlan['number']) > 0) { |
|
100 | - $vlanText = " (vlan: " . $vlan['number']; |
|
101 | - if(strlen($vlan['name']) > 0) { |
|
102 | - $vlanText .= ' - '. $vlan['name'] . ')'; |
|
98 | + $vlan = (array) $Tools->fetch_object ("vlans", "vlanId", $subnet['vlanId']); |
|
99 | + if (strlen ($vlan['number']) > 0) { |
|
100 | + $vlanText = " (vlan: ".$vlan['number']; |
|
101 | + if (strlen ($vlan['name']) > 0) { |
|
102 | + $vlanText .= ' - '.$vlan['name'].')'; |
|
103 | 103 | } |
104 | 104 | else { |
105 | 105 | $vlanText .= ")"; |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | $vlanText = ""; |
110 | 110 | } |
111 | 111 | |
112 | - $worksheet->write($lineCount, 0, $Subnets->transform_to_dotted($subnet['subnet']) . "/" .$subnet['mask'] . " - " . $subnet['description'] . $vlanText, $format_header ); |
|
113 | - $worksheet->mergeCells($lineCount, 0, $lineCount, $colSize); |
|
112 | + $worksheet->write ($lineCount, 0, $Subnets->transform_to_dotted ($subnet['subnet'])."/".$subnet['mask']." - ".$subnet['description'].$vlanText, $format_header); |
|
113 | + $worksheet->mergeCells ($lineCount, 0, $lineCount, $colSize); |
|
114 | 114 | |
115 | 115 | $lineCount++; |
116 | 116 | |
@@ -118,53 +118,53 @@ discard block |
||
118 | 118 | $ipaddresses = $Addresses->fetch_subnet_addresses ($subnet['id']); |
119 | 119 | |
120 | 120 | //write headers |
121 | - $worksheet->write($lineCount, 0, _('ip address' ),$format_title); |
|
122 | - $worksheet->write($lineCount, 1, _('ip state' ),$format_title); |
|
123 | - $worksheet->write($lineCount, 2, _('description' ),$format_title); |
|
124 | - $worksheet->write($lineCount, 3, _('hostname' ),$format_title); |
|
125 | - $worksheet->write($lineCount, 4, _('mac' ),$format_title); |
|
126 | - $worksheet->write($lineCount, 5, _('owner' ),$format_title); |
|
127 | - $worksheet->write($lineCount, 6, _('device' ),$format_title); |
|
128 | - $worksheet->write($lineCount, 7, _('port' ),$format_title); |
|
129 | - $worksheet->write($lineCount, 8, _('note' ),$format_title); |
|
121 | + $worksheet->write ($lineCount, 0, _ ('ip address'), $format_title); |
|
122 | + $worksheet->write ($lineCount, 1, _ ('ip state'), $format_title); |
|
123 | + $worksheet->write ($lineCount, 2, _ ('description'), $format_title); |
|
124 | + $worksheet->write ($lineCount, 3, _ ('hostname'), $format_title); |
|
125 | + $worksheet->write ($lineCount, 4, _ ('mac'), $format_title); |
|
126 | + $worksheet->write ($lineCount, 5, _ ('owner'), $format_title); |
|
127 | + $worksheet->write ($lineCount, 6, _ ('device'), $format_title); |
|
128 | + $worksheet->write ($lineCount, 7, _ ('port'), $format_title); |
|
129 | + $worksheet->write ($lineCount, 8, _ ('note'), $format_title); |
|
130 | 130 | $m = 9; |
131 | 131 | //custom |
132 | - if(sizeof($myFields) > 0) { |
|
133 | - foreach($myFields as $myField) { |
|
134 | - $worksheet->write($lineCount, $m, $myField['name'] ,$format_title); |
|
132 | + if (sizeof ($myFields) > 0) { |
|
133 | + foreach ($myFields as $myField) { |
|
134 | + $worksheet->write ($lineCount, $m, $myField['name'], $format_title); |
|
135 | 135 | $m++; |
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | 139 | $lineCount++; |
140 | 140 | |
141 | - if(sizeof($ipaddresses) > 0) { |
|
141 | + if (sizeof ($ipaddresses) > 0) { |
|
142 | 142 | |
143 | 143 | foreach ($ipaddresses as $ip) { |
144 | 144 | //cast |
145 | 145 | $ip = (array) $ip; |
146 | 146 | |
147 | 147 | //reformat state |
148 | - if(@$ip_types[$ip['state']]['showtag']==1) { $ip['state'] = $ip_types[$ip['state']]['type']; } |
|
149 | - else { $ip['state'] = ""; } |
|
148 | + if (@$ip_types[$ip['state']]['showtag'] == 1) { $ip['state'] = $ip_types[$ip['state']]['type']; } |
|
149 | + else { $ip['state'] = ""; } |
|
150 | 150 | |
151 | 151 | //change switch ID to name |
152 | - $ip['switch'] = is_null($ip['switch'])||strlen($ip['switch'])==0||$ip['switch']==0 ? "" : $devices_indexed[$ip['switch']]->hostname; |
|
153 | - |
|
154 | - $worksheet->write($lineCount, 0, $Subnets->transform_to_dotted($ip['ip_addr']), $format_left); |
|
155 | - $worksheet->write($lineCount, 1, $ip['state']); |
|
156 | - $worksheet->write($lineCount, 2, $ip['description']); |
|
157 | - $worksheet->write($lineCount, 3, $ip['dns_name']); |
|
158 | - $worksheet->write($lineCount, 4, $ip['mac']); |
|
159 | - $worksheet->write($lineCount, 5, $ip['owner']); |
|
160 | - $worksheet->write($lineCount, 6, $ip['switch']); |
|
161 | - $worksheet->write($lineCount, 7, $ip['port']); |
|
162 | - $worksheet->write($lineCount, 8, $ip['note']); |
|
152 | + $ip['switch'] = is_null ($ip['switch']) || strlen ($ip['switch']) == 0 || $ip['switch'] == 0 ? "" : $devices_indexed[$ip['switch']]->hostname; |
|
153 | + |
|
154 | + $worksheet->write ($lineCount, 0, $Subnets->transform_to_dotted ($ip['ip_addr']), $format_left); |
|
155 | + $worksheet->write ($lineCount, 1, $ip['state']); |
|
156 | + $worksheet->write ($lineCount, 2, $ip['description']); |
|
157 | + $worksheet->write ($lineCount, 3, $ip['dns_name']); |
|
158 | + $worksheet->write ($lineCount, 4, $ip['mac']); |
|
159 | + $worksheet->write ($lineCount, 5, $ip['owner']); |
|
160 | + $worksheet->write ($lineCount, 6, $ip['switch']); |
|
161 | + $worksheet->write ($lineCount, 7, $ip['port']); |
|
162 | + $worksheet->write ($lineCount, 8, $ip['note']); |
|
163 | 163 | //custom |
164 | 164 | $m = 9; |
165 | - if(sizeof($myFields) > 0) { |
|
166 | - foreach($myFields as $myField) { |
|
167 | - $worksheet->write($lineCount, $m, $ip[$myField['name']]); |
|
165 | + if (sizeof ($myFields) > 0) { |
|
166 | + foreach ($myFields as $myField) { |
|
167 | + $worksheet->write ($lineCount, $m, $ip[$myField['name']]); |
|
168 | 168 | $m++; |
169 | 169 | } |
170 | 170 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | } |
176 | 176 | else { |
177 | - $worksheet->write($lineCount, 0, _('No hosts')); |
|
177 | + $worksheet->write ($lineCount, 0, _ ('No hosts')); |
|
178 | 178 | $lineCount++; |
179 | 179 | } |
180 | 180 | |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | // sending HTTP headers |
188 | -$workbook->send($filename); |
|
188 | +$workbook->send ($filename); |
|
189 | 189 | |
190 | 190 | // Let's send the file |
191 | -$workbook->close(); |
|
191 | +$workbook->close (); |
|
192 | 192 | |
193 | 193 | ?> |
194 | 194 | \ No newline at end of file |
@@ -5,27 +5,27 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | # include required scripts |
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); |
|
13 | -$Tools = new Tools ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | +$Tools = new Tools ($Database); |
|
14 | 14 | |
15 | 15 | # verify that user is logged in |
16 | -$User->check_user_session(); |
|
16 | +$User->check_user_session (); |
|
17 | 17 | |
18 | 18 | $tpl_field_names = ""; |
19 | 19 | $tpl_field_types = ""; |
20 | 20 | |
21 | 21 | # predefine field list |
22 | -$expfields = array ("name","description"); |
|
22 | +$expfields = array ("name", "description"); |
|
23 | 23 | $mtable = "vlanDomains"; # main table where to check the fields |
24 | 24 | # required fields without which we will not continue |
25 | -$reqfields = array("name"); |
|
25 | +$reqfields = array ("name"); |
|
26 | 26 | |
27 | 27 | # manually adjust the standard fields |
28 | -foreach($expfields as $std_field) { |
|
28 | +foreach ($expfields as $std_field) { |
|
29 | 29 | # extra table and field |
30 | 30 | if (isset($extfields[$std_field])) { |
31 | 31 | $cfield = $extfields[$std_field]["field"]; |
@@ -39,21 +39,21 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | # read field attributes |
42 | - $field = $Tools->fetch_full_field_definition($ctable,$cfield); |
|
42 | + $field = $Tools->fetch_full_field_definition ($ctable, $cfield); |
|
43 | 43 | $field = (array) $field; |
44 | 44 | |
45 | 45 | # mark required fields with * |
46 | - $msgr = in_array($std_field,$reqfields) ? "*" : ""; |
|
46 | + $msgr = in_array ($std_field, $reqfields) ? "*" : ""; |
|
47 | 47 | |
48 | 48 | #prebuild template table rows to avoid useless foreach loops |
49 | - $tpl_field_names.= "<th>".$pname.$field['Field'].$msgr."</th>"; |
|
50 | - $tpl_field_types.= "<td><small>". wordwrap($field['Type'],18,"<br>\n",true) ."</small></td>"; |
|
49 | + $tpl_field_names .= "<th>".$pname.$field['Field'].$msgr."</th>"; |
|
50 | + $tpl_field_types .= "<td><small>".wordwrap ($field['Type'], 18, "<br>\n", true)."</small></td>"; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | ?> |
54 | 54 | |
55 | 55 | <!-- header --> |
56 | -<div class="pHeader"><?php print _("Select L2 Domain file and fields to import"); ?></div> |
|
56 | +<div class="pHeader"><?php print _ ("Select L2 Domain file and fields to import"); ?></div> |
|
57 | 57 | |
58 | 58 | <!-- content --> |
59 | 59 | <div class="pContent"> |
@@ -62,23 +62,23 @@ discard block |
||
62 | 62 | |
63 | 63 | # print template form |
64 | 64 | print "<form id='selectImportFields'><div id='topmsg'>"; |
65 | -print '<h4>'._("Template").'</h4><hr>'; |
|
66 | -print _("The import XLS/CSV should have the following fields and a <b>header row</b> for a succesful import:"); |
|
65 | +print '<h4>'._ ("Template").'</h4><hr>'; |
|
66 | +print _ ("The import XLS/CSV should have the following fields and a <b>header row</b> for a succesful import:"); |
|
67 | 67 | print "</div>"; |
68 | -print "<input name='expfields' type='hidden' value='".implode('|',$expfields)."' style='display:none;'>"; |
|
69 | -print "<input name='reqfields' type='hidden' value='".implode('|',$reqfields)."' style='display:none;'>"; |
|
68 | +print "<input name='expfields' type='hidden' value='".implode ('|', $expfields)."' style='display:none;'>"; |
|
69 | +print "<input name='reqfields' type='hidden' value='".implode ('|', $reqfields)."' style='display:none;'>"; |
|
70 | 70 | print "<input name='filetype' id='filetype' type='hidden' value='' style='display:none;'>"; |
71 | 71 | print "<table class='table table-striped table-condensed' id='fieldstable'><tbody>"; |
72 | -print "<tr>" . $tpl_field_names . "</tr>"; |
|
73 | -print "<tr>" . $tpl_field_types . "</tr>"; |
|
72 | +print "<tr>".$tpl_field_names."</tr>"; |
|
73 | +print "<tr>".$tpl_field_types."</tr>"; |
|
74 | 74 | print "</tbody></table>"; |
75 | -print "<div id='bottommsg'>"._("The fields marked with * are mandatory")."</div>"; |
|
75 | +print "<div id='bottommsg'>"._ ("The fields marked with * are mandatory")."</div>"; |
|
76 | 76 | print "</form>"; |
77 | 77 | |
78 | 78 | $templatetype = 'l2dom'; |
79 | 79 | # print upload section |
80 | 80 | print "<div id='uplmsg'>"; |
81 | -print '<h4>'._("Upload file").'</h4><hr>'; |
|
81 | +print '<h4>'._ ("Upload file").'</h4><hr>'; |
|
82 | 82 | include 'import-button.php'; |
83 | 83 | print "</div>"; |
84 | 84 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | <!-- footer --> |
90 | 90 | <div class="pFooter"> |
91 | 91 | <div class="btn-group"> |
92 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
93 | - <button class="btn btn-sm btn-default" id="dataImportPreview" data-type="l2dom" disabled><i class="fa fa-eye"></i> <?php print _('Preview'); ?></button> |
|
92 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
93 | + <button class="btn btn-sm btn-default" id="dataImportPreview" data-type="l2dom" disabled><i class="fa fa-eye"></i> <?php print _ ('Preview'); ?></button> |
|
94 | 94 | </div> |
95 | 95 | </div> |