@@ -5,22 +5,22 @@ 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 | 11 | $Database = new Database_PDO; |
12 | -$User = new User ($Database); |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Tools = new Tools ($Database); |
14 | -$Admin = new Admin ($Database); |
|
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 | $tpl_field_names = ""; |
20 | 20 | $tpl_field_types = ""; |
21 | 21 | |
22 | 22 | # predefine field list |
23 | -$expfields = array ("section","subnet","mask","description","vlan","domain","vrf"); |
|
23 | +$expfields = array ("section", "subnet", "mask", "description", "vlan", "domain", "vrf"); |
|
24 | 24 | // we don't want to support importing of special fields yet, like master, requests, ping, permissions, etc. |
25 | 25 | // $expfields = array ("section","subnet","mask","description","vlan","domain","vrf","master_subnet","master_mask","allowRequests","pingSubnet","discoverSubnet"); |
26 | 26 | $mtable = "subnets"; # main table where to check the fields |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | // $extfields["master_mask"]["field"] = "mask"; |
45 | 45 | // $extfields["master_mask"]["pname"] = "master"; |
46 | 46 | # required fields without which we will not continue, vrf is optional - if not set we check against default VRF |
47 | -$reqfields = array("section","subnet"); |
|
47 | +$reqfields = array ("section", "subnet"); |
|
48 | 48 | |
49 | 49 | # manually adjust the standard fields |
50 | -foreach($expfields as $std_field) { |
|
50 | +foreach ($expfields as $std_field) { |
|
51 | 51 | # extra table and field |
52 | 52 | if (isset($extfields[$std_field])) { |
53 | 53 | $cfield = $extfields[$std_field]["field"]; |
@@ -61,28 +61,28 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | # read field attributes |
64 | - $field = $Tools->fetch_full_field_definition($ctable,$cfield); |
|
64 | + $field = $Tools->fetch_full_field_definition ($ctable, $cfield); |
|
65 | 65 | $field = (array) $field; |
66 | 66 | |
67 | 67 | # mark required fields with * |
68 | - $msgr = in_array($std_field,$reqfields) ? "*" : ""; |
|
68 | + $msgr = in_array ($std_field, $reqfields) ? "*" : ""; |
|
69 | 69 | |
70 | 70 | #prebuild template table rows to avoid useless foreach loops |
71 | - $tpl_field_names.= "<th>".$pname.$field['Field'].$msgr."</th>"; |
|
72 | - $tpl_field_types.= "<td><small>". wordwrap($field['Type'],18,"<br>\n",true) ."</small></td>"; |
|
71 | + $tpl_field_names .= "<th>".$pname.$field['Field'].$msgr."</th>"; |
|
72 | + $tpl_field_types .= "<td><small>".wordwrap ($field['Type'], 18, "<br>\n", true)."</small></td>"; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | # append the custom fields, if any |
76 | -$custom_fields = $Tools->fetch_custom_fields($mtable); |
|
77 | -if(sizeof($custom_fields) > 0) { |
|
78 | - foreach($custom_fields as $myField) { |
|
76 | +$custom_fields = $Tools->fetch_custom_fields ($mtable); |
|
77 | +if (sizeof ($custom_fields) > 0) { |
|
78 | + foreach ($custom_fields as $myField) { |
|
79 | 79 | # add field to required fields if needed |
80 | 80 | if ($myField['Null'] == "NO") { $reqfields[] = $myField['name']; } |
81 | 81 | # mark required fields with * |
82 | - $msgr = in_array($myField['name'],$reqfields) ? "*" : ""; |
|
82 | + $msgr = in_array ($myField['name'], $reqfields) ? "*" : ""; |
|
83 | 83 | |
84 | - $tpl_field_names.= "<th>".$myField['name'].$msgr."</th>"; |
|
85 | - $tpl_field_types.= "<td><small>". wordwrap($myField['type'],18,"<br>\n",true) ."</small></td>"; |
|
84 | + $tpl_field_names .= "<th>".$myField['name'].$msgr."</th>"; |
|
85 | + $tpl_field_types .= "<td><small>".wordwrap ($myField['type'], 18, "<br>\n", true)."</small></td>"; |
|
86 | 86 | $expfields[] = $myField['name']; |
87 | 87 | } |
88 | 88 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ?> |
91 | 91 | |
92 | 92 | <!-- header --> |
93 | -<div class="pHeader"><?php print _("Select Subnets file and fields to import"); ?></div> |
|
93 | +<div class="pHeader"><?php print _ ("Select Subnets file and fields to import"); ?></div> |
|
94 | 94 | |
95 | 95 | <!-- content --> |
96 | 96 | <div class="pContent"> |
@@ -99,18 +99,18 @@ discard block |
||
99 | 99 | |
100 | 100 | # print template form |
101 | 101 | print "<form id='selectImportFields'><div id='topmsg'>"; |
102 | -print '<h4>'._("Template").'</h4><hr>'; |
|
103 | -print _("The import XLS/CSV should have the following fields and a <b>header row</b> for a succesful import:"); |
|
102 | +print '<h4>'._ ("Template").'</h4><hr>'; |
|
103 | +print _ ("The import XLS/CSV should have the following fields and a <b>header row</b> for a succesful import:"); |
|
104 | 104 | print "</div>"; |
105 | -print "<input name='expfields' type='hidden' value='".implode('|',$expfields)."' style='display:none;'>"; |
|
106 | -print "<input name='reqfields' type='hidden' value='".implode('|',$reqfields)."' style='display:none;'>"; |
|
105 | +print "<input name='expfields' type='hidden' value='".implode ('|', $expfields)."' style='display:none;'>"; |
|
106 | +print "<input name='reqfields' type='hidden' value='".implode ('|', $reqfields)."' style='display:none;'>"; |
|
107 | 107 | print "<input name='filetype' id='filetype' type='hidden' value='' style='display:none;'>"; |
108 | 108 | print "<table class='table table-striped table-condensed' id='fieldstable'><tbody>"; |
109 | -print "<tr>" . $tpl_field_names . "</tr>"; |
|
110 | -print "<tr>" . $tpl_field_types . "</tr>"; |
|
109 | +print "<tr>".$tpl_field_names."</tr>"; |
|
110 | +print "<tr>".$tpl_field_types."</tr>"; |
|
111 | 111 | print "</tbody></table>"; |
112 | -print "<div id='bottommsg'>"._("The fields marked with * are mandatory.")." |
|
113 | - <br>"._("The mask can be provided either as a separate field or with the subnet, sparated by \"/\"")." |
|
112 | +print "<div id='bottommsg'>"._ ("The fields marked with * are mandatory.")." |
|
113 | + <br>"._ ("The mask can be provided either as a separate field or with the subnet, sparated by \"/\"")." |
|
114 | 114 | </div>"; |
115 | 115 | #TODO# add option to hide php fields |
116 | 116 | #print "<div class='checkbox'><label><input name='showspecific' id='showspecific' type='checkbox' unchecked>"._("Show PHPIPAM specific columns.")."</label></div>"; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $templatetype = 'subnets'; |
120 | 120 | # print upload section |
121 | 121 | print "<div id='uplmsg'>"; |
122 | -print '<h4>'._("Upload file").'</h4><hr>'; |
|
122 | +print '<h4>'._ ("Upload file").'</h4><hr>'; |
|
123 | 123 | include 'import-button.php'; |
124 | 124 | print "</div>"; |
125 | 125 | ?> |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | <!-- footer --> |
129 | 129 | <div class="pFooter"> |
130 | 130 | <div class="btn-group"> |
131 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
132 | - <button class="btn btn-sm btn-default" id="dataImportPreview" data-type="subnets" disabled><i class="fa fa-eye"></i> <?php print _('Preview'); ?></button> |
|
131 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
132 | + <button class="btn btn-sm btn-default" id="dataImportPreview" data-type="subnets" disabled><i class="fa fa-eye"></i> <?php print _ ('Preview'); ?></button> |
|
133 | 133 | </div> |
134 | 134 | </div> |
@@ -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 _("VRF import"); ?></div> |
|
24 | +<div class="pHeader"><?php print _ ("VRF 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("vrfId"=>$cdata['vrfId'], |
|
38 | + $values = array ("vrfId"=>$cdata['vrfId'], |
|
39 | 39 | "name"=>$cdata['name'], |
40 | 40 | "rd"=>$cdata['rd'], |
41 | 41 | "description"=>$cdata['description'] |
42 | 42 | ); |
43 | 43 | # update |
44 | - $cdata['result'] = $Admin->object_modify("vrf", $cdata['action'], "vrfId", $values); |
|
44 | + $cdata['result'] = $Admin->object_modify ("vrf", $cdata['action'], "vrfId", $values); |
|
45 | 45 | |
46 | 46 | if ($cdata['result']) { |
47 | 47 | $trc = $colors[$cdata['action']]; |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | $trc = "danger"; |
51 | 51 | $msg = "VRF ".$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['rd']."</td> |
56 | 56 | <td>".$cdata['description']."</td> |
57 | - <td>"._($msg)."</td></tr>"; |
|
57 | + <td>"._ ($msg)."</td></tr>"; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -68,5 +68,5 @@ discard block |
||
68 | 68 | |
69 | 69 | <!-- footer --> |
70 | 70 | <div class="pFooter"> |
71 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Close'); ?></button> |
|
71 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Close'); ?></button> |
|
72 | 72 | </div> |
@@ -4,61 +4,61 @@ discard block |
||
4 | 4 | *************************************************/ |
5 | 5 | |
6 | 6 | # include required scripts |
7 | -require_once( dirname(__FILE__) . '/../../../functions/functions.php' ); |
|
7 | +require_once(dirname (__FILE__).'/../../../functions/functions.php'); |
|
8 | 8 | |
9 | 9 | # initialize user object, if not already set |
10 | -if (!isset($Database)) { $Database = new Database_PDO; } |
|
10 | +if (!isset($Database)) { $Database = new Database_PDO; } |
|
11 | 11 | if (!isset($User)) { $User = new User ($Database); } |
12 | 12 | if (!isset($Result)) { $Result = new Result; } |
13 | 13 | |
14 | 14 | # verify that user is logged in, to guard against direct access of page and possible exploits |
15 | -$User->check_user_session(); |
|
15 | +$User->check_user_session (); |
|
16 | 16 | |
17 | -$expfields = explode("|",$_GET['expfields']); |
|
18 | -$reqfields = explode("|",$_GET['reqfields']); |
|
17 | +$expfields = explode ("|", $_GET['expfields']); |
|
18 | +$reqfields = explode ("|", $_GET['reqfields']); |
|
19 | 19 | if (isset($_GET['filetype'])) { |
20 | 20 | $filetype = $_GET['filetype']; |
21 | 21 | } else { |
22 | - $Result->show('danger', _("Error: could not read the uploaded file type!"), true, true); |
|
22 | + $Result->show ('danger', _ ("Error: could not read the uploaded file type!"), true, true); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | # Load colors and icons |
26 | 26 | include 'import-constants.php'; |
27 | 27 | |
28 | 28 | $hrow = "<td></td>"; |
29 | -$hiddenfields=""; |
|
29 | +$hiddenfields = ""; |
|
30 | 30 | |
31 | 31 | # read field mapping from previous window |
32 | 32 | foreach ($expfields as $expfield) { |
33 | - if (isset($_GET['importFields__'.str_replace(" ", "_",$expfield)])) { |
|
34 | - $impfield = $_GET['importFields__'.str_replace(" ", "_",$expfield)]; |
|
35 | - if (in_array($expfield,$reqfields) && ($impfield == "-")) { |
|
36 | - $Result->show('danger', _("Error: missing required field mapping for expected field")." <b>".$expfield."</b>."._("Please check field matching in previous window."), true, true); |
|
33 | + if (isset($_GET['importFields__'.str_replace (" ", "_", $expfield)])) { |
|
34 | + $impfield = $_GET['importFields__'.str_replace (" ", "_", $expfield)]; |
|
35 | + if (in_array ($expfield, $reqfields) && ($impfield == "-")) { |
|
36 | + $Result->show ('danger', _ ("Error: missing required field mapping for expected field")." <b>".$expfield."</b>."._ ("Please check field matching in previous window."), true, true); |
|
37 | 37 | } else { |
38 | 38 | if ($impfield != "-") { $impfields[$impfield] = $expfield; } |
39 | 39 | } |
40 | 40 | } else { |
41 | - $Result->show('danger', _("Internal error: missing import field mapping."), true, true); |
|
41 | + $Result->show ('danger', _ ("Internal error: missing import field mapping."), true, true); |
|
42 | 42 | } |
43 | 43 | # prepare header row for preview table |
44 | - $hrow.="<th>".$expfield."</th>"; |
|
44 | + $hrow .= "<th>".$expfield."</th>"; |
|
45 | 45 | # prepare select field to transfer to actual import file |
46 | - $hiddenfields.="<input name='importFields__".str_replace(" ", "_",$expfield)."' type='hidden' value='".$impfield."' style='display:none;'>"; |
|
46 | + $hiddenfields .= "<input name='importFields__".str_replace (" ", "_", $expfield)."' type='hidden' value='".$impfield."' style='display:none;'>"; |
|
47 | 47 | } |
48 | 48 | |
49 | -$data = array(); |
|
49 | +$data = array (); |
|
50 | 50 | |
51 | 51 | # read first row from CSV |
52 | -if (strtolower($filetype) == "csv") { |
|
52 | +if (strtolower ($filetype) == "csv") { |
|
53 | 53 | # open CSV file |
54 | - $filehdl = fopen('upload/data_import.csv', 'r'); |
|
54 | + $filehdl = fopen ('upload/data_import.csv', 'r'); |
|
55 | 55 | |
56 | 56 | # read header row |
57 | - $row = 0;$col = 0; |
|
58 | - $line = fgets($filehdl); |
|
57 | + $row = 0; $col = 0; |
|
58 | + $line = fgets ($filehdl); |
|
59 | 59 | $row++; |
60 | - $line = str_replace( array("\r\n","\r") , "" , $line); //remove line break |
|
61 | - $cols = preg_split("/[;]/", $line); //split by comma or semi-colon |
|
60 | + $line = str_replace (array ("\r\n", "\r"), "", $line); //remove line break |
|
61 | + $cols = preg_split ("/[;]/", $line); //split by comma or semi-colon |
|
62 | 62 | foreach ($cols as $val) { |
63 | 63 | $col++; |
64 | 64 | # map import columns to expected fields as per previous window |
@@ -67,46 +67,46 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | # read each remaining row into a dictionary with expected fields as keys |
70 | - while (($line = fgets($filehdl)) !== false) { |
|
71 | - $row++;$col = 0; |
|
72 | - $line = str_replace( array("\r\n","\r") , "" , $line); //remove line break |
|
73 | - $cols = preg_split("/[;]/", $line); //split by comma or semi-colon |
|
74 | - $record = array(); |
|
70 | + while (($line = fgets ($filehdl)) !== false) { |
|
71 | + $row++; $col = 0; |
|
72 | + $line = str_replace (array ("\r\n", "\r"), "", $line); //remove line break |
|
73 | + $cols = preg_split ("/[;]/", $line); //split by comma or semi-colon |
|
74 | + $record = array (); |
|
75 | 75 | foreach ($cols as $val) { |
76 | 76 | $col++; |
77 | 77 | if ($col > $hcol) { |
78 | - $Result->show('danger', _("Extra column found on line ").$row._(" in CSV file. CSV delimiter used in value field?"), true); |
|
78 | + $Result->show ('danger', _ ("Extra column found on line ").$row._ (" in CSV file. CSV delimiter used in value field?"), true); |
|
79 | 79 | } else { |
80 | 80 | # read each row into a dictionary with expected fields as keys |
81 | - $record[$fieldmap[$col]] = trim($val); |
|
81 | + $record[$fieldmap[$col]] = trim ($val); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | $data[] = $record; |
85 | 85 | } |
86 | - fclose($filehdl); |
|
86 | + fclose ($filehdl); |
|
87 | 87 | } |
88 | 88 | # read first row from XLS |
89 | -elseif(strtolower($filetype) == "xls") { |
|
89 | +elseif (strtolower ($filetype) == "xls") { |
|
90 | 90 | # get excel object |
91 | - require_once(dirname(__FILE__) . '/../../../functions/php-excel-reader/excel_reader2.php'); //excel reader 2.21 |
|
92 | - $xls = new Spreadsheet_Excel_Reader('upload/data_import.xls', false); |
|
91 | + require_once(dirname (__FILE__).'/../../../functions/php-excel-reader/excel_reader2.php'); //excel reader 2.21 |
|
92 | + $xls = new Spreadsheet_Excel_Reader ('upload/data_import.xls', false); |
|
93 | 93 | $sheet = 0; $row = 1; |
94 | 94 | |
95 | 95 | # map import columns to expected fields as per previous window |
96 | - for($col=1;$col<=$xls->colcount($sheet);$col++) { |
|
97 | - $fieldmap[$col] = $impfields[$xls->val($row,$col,$sheet)]; |
|
96 | + for ($col = 1; $col <= $xls->colcount ($sheet); $col++) { |
|
97 | + $fieldmap[$col] = $impfields[$xls->val ($row, $col, $sheet)]; |
|
98 | 98 | $hcol = $col; |
99 | 99 | } |
100 | 100 | |
101 | 101 | # read each remaining row into a dictionary with expected fields as keys |
102 | - for($row=2;$row<=$xls->rowcount($sheet);$row++) { |
|
103 | - $record = array(); |
|
104 | - for($col=1;$col<=$xls->colcount($sheet);$col++) { |
|
102 | + for ($row = 2; $row <= $xls->rowcount ($sheet); $row++) { |
|
103 | + $record = array (); |
|
104 | + for ($col = 1; $col <= $xls->colcount ($sheet); $col++) { |
|
105 | 105 | $record++; |
106 | 106 | if ($col > $hcol) { |
107 | - $Result->show('danger', _("Extra column found on line ").$row._(" in XLS file. Please check input file."), true); |
|
107 | + $Result->show ('danger', _ ("Extra column found on line ").$row._ (" in XLS file. Please check input file."), true); |
|
108 | 108 | } else { |
109 | - $record[$fieldmap[$col]] = trim($xls->val($row,$col,$sheet)); |
|
109 | + $record[$fieldmap[$col]] = trim ($xls->val ($row, $col, $sheet)); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | $data[] = $record; |
@@ -5,21 +5,21 @@ 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 | |
15 | 15 | # verify that user is logged in, to guard against direct access of page and possible exploits |
16 | -$User->check_user_session(); |
|
16 | +$User->check_user_session (); |
|
17 | 17 | |
18 | 18 | # Load existing data |
19 | -$all_vrfs = $Admin->fetch_all_objects("vrf", "vrfId"); |
|
20 | -if (!$all_vrfs) { $all_vrfs = array(); } |
|
19 | +$all_vrfs = $Admin->fetch_all_objects ("vrf", "vrfId"); |
|
20 | +if (!$all_vrfs) { $all_vrfs = array (); } |
|
21 | 21 | |
22 | -$edata = array(); |
|
22 | +$edata = array (); |
|
23 | 23 | # process for easier later check |
24 | 24 | foreach ($all_vrfs as $vrf) { |
25 | 25 | //cast |
@@ -28,22 +28,22 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | $rows = ""; |
31 | -$counters = array(); |
|
31 | +$counters = array (); |
|
32 | 32 | |
33 | 33 | # check the fields |
34 | 34 | foreach ($data as &$cdata) { |
35 | 35 | $msg = ""; $action = ""; |
36 | 36 | |
37 | 37 | # check if required fields are present and not empty |
38 | - foreach($reqfields as $creq) { |
|
39 | - if ((!isset($cdata[$creq])) or ($cdata[$creq] == "")) { $msg.= "Required field ".$creq." missing or empty."; $action = "error"; } |
|
38 | + foreach ($reqfields as $creq) { |
|
39 | + if ((!isset($cdata[$creq])) or ($cdata[$creq] == "")) { $msg .= "Required field ".$creq." missing or empty."; $action = "error"; } |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | # check data format |
43 | 43 | if ($action != "error") { |
44 | - if (!preg_match("/^[a-zA-Z0-9-]+$/", $cdata['name'])) { $msg.="Invalid name format."; $action = "error"; } |
|
45 | - if (!preg_match("/^[0-9:]+$/", $cdata['rd'])) { $msg.="Invalid RD format."; $action = "error"; } |
|
46 | - if (preg_match("/[;'\"]/", $cdata['description'])) { $msg.="Invalid characters in description."; $action = "error"; } |
|
44 | + if (!preg_match ("/^[a-zA-Z0-9-]+$/", $cdata['name'])) { $msg .= "Invalid name format."; $action = "error"; } |
|
45 | + if (!preg_match ("/^[0-9:]+$/", $cdata['rd'])) { $msg .= "Invalid RD format."; $action = "error"; } |
|
46 | + if (preg_match ("/[;'\"]/", $cdata['description'])) { $msg .= "Invalid characters in description."; $action = "error"; } |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | # check if existing |
@@ -51,26 +51,26 @@ discard block |
||
51 | 51 | if (isset($edata[$cdata['rd']])) { |
52 | 52 | $cdata['vrfId'] = $edata[$cdata['rd']]['vrfId']; |
53 | 53 | $action = "skip"; # skip duplicate fields if identical, update if different |
54 | - if ($cdata['name'] != $edata[$cdata['rd']]['name']) { $msg.= "VRF name will be updated."; $action = "edit"; } |
|
55 | - if ($cdata['description'] != $edata[$cdata['rd']]['description']) { $msg.= "VRF description will be updated."; $action = "edit"; } |
|
54 | + if ($cdata['name'] != $edata[$cdata['rd']]['name']) { $msg .= "VRF name will be updated."; $action = "edit"; } |
|
55 | + if ($cdata['description'] != $edata[$cdata['rd']]['description']) { $msg .= "VRF description will be updated."; $action = "edit"; } |
|
56 | 56 | |
57 | 57 | if ($action == "skip") { |
58 | - $msg.= "Duplicate, will skip."; |
|
58 | + $msg .= "Duplicate, will skip."; |
|
59 | 59 | } |
60 | 60 | } else { |
61 | - $msg.="New entry, will be added."; $action = "add"; |
|
61 | + $msg .= "New entry, will be added."; $action = "add"; |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | - $cdata['msg'].= $msg; |
|
65 | + $cdata['msg'] .= $msg; |
|
66 | 66 | $cdata['action'] = $action; |
67 | 67 | $counters[$action]++; |
68 | 68 | |
69 | - $rows.="<tr class='".$colors[$action]."'><td><i class='fa ".$icons[$action]."' rel='tooltip' data-placement='bottom' title='"._($msg)."'></i></td> |
|
69 | + $rows .= "<tr class='".$colors[$action]."'><td><i class='fa ".$icons[$action]."' rel='tooltip' data-placement='bottom' title='"._ ($msg)."'></i></td> |
|
70 | 70 | <td>".$cdata['name']."</td> |
71 | 71 | <td>".$cdata['rd']."</td> |
72 | 72 | <td>".$cdata['description']."</td> |
73 | - <td>"._($msg)."</td></tr>"; |
|
73 | + <td>"._ ($msg)."</td></tr>"; |
|
74 | 74 | |
75 | 75 | } |
76 | 76 |
@@ -5,35 +5,35 @@ 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 user object |
12 | 12 | $Database = new Database_PDO; |
13 | -$User = new User ($Database); |
|
13 | +$User = new User ($Database); |
|
14 | 14 | $Admin = new Admin ($Database); |
15 | 15 | $Tools = new Tools ($Database); |
16 | 16 | $Subnets = new Subnets ($Database); |
17 | -$Sections = new Sections ($Database); |
|
17 | +$Sections = new Sections ($Database); |
|
18 | 18 | |
19 | 19 | # verify that user is logged in |
20 | -$User->check_user_session(); |
|
20 | +$User->check_user_session (); |
|
21 | 21 | |
22 | 22 | # Won't check per subnet/section rights since this is an admin section, where the admin user has full access |
23 | 23 | |
24 | 24 | # fetch all sections |
25 | -$all_sections = $Sections->fetch_all_sections(); |
|
25 | +$all_sections = $Sections->fetch_all_sections (); |
|
26 | 26 | |
27 | 27 | # Lets do some reordering to show slaves! |
28 | -if($all_sections !== false) { |
|
29 | - foreach($all_sections as $s) { |
|
30 | - if($s->masterSection=="0") { |
|
28 | +if ($all_sections !== false) { |
|
29 | + foreach ($all_sections as $s) { |
|
30 | + if ($s->masterSection == "0") { |
|
31 | 31 | # it is master |
32 | 32 | $s->class = "master"; |
33 | 33 | $sectionssorted[] = $s; |
34 | 34 | # check for slaves |
35 | - foreach($all_sections as $ss) { |
|
36 | - if($ss->masterSection==$s->id) { |
|
35 | + foreach ($all_sections as $ss) { |
|
36 | + if ($ss->masterSection == $s->id) { |
|
37 | 37 | $ss->class = "slave"; |
38 | 38 | $sectionssorted[] = $ss; |
39 | 39 | } |
@@ -46,78 +46,78 @@ discard block |
||
46 | 46 | |
47 | 47 | |
48 | 48 | # get all custom fields |
49 | -$custom_fields = $Tools->fetch_custom_fields('subnets'); |
|
49 | +$custom_fields = $Tools->fetch_custom_fields ('subnets'); |
|
50 | 50 | |
51 | 51 | # Create a workbook |
52 | -$today = date("Ymd"); |
|
52 | +$today = date ("Ymd"); |
|
53 | 53 | $filename = $today."_phpipam_subnets_export.xls"; |
54 | -$workbook = new Spreadsheet_Excel_Writer(); |
|
54 | +$workbook = new Spreadsheet_Excel_Writer (); |
|
55 | 55 | |
56 | 56 | //formatting headers |
57 | -$format_header =& $workbook->addFormat(); |
|
58 | -$format_header->setBold(); |
|
59 | -$format_header->setColor('black'); |
|
60 | -$format_header->setSize(12); |
|
61 | -$format_header->setAlign('left'); |
|
57 | +$format_header = & $workbook->addFormat (); |
|
58 | +$format_header->setBold (); |
|
59 | +$format_header->setColor ('black'); |
|
60 | +$format_header->setSize (12); |
|
61 | +$format_header->setAlign ('left'); |
|
62 | 62 | |
63 | 63 | //formatting content |
64 | -$format_text =& $workbook->addFormat(); |
|
64 | +$format_text = & $workbook->addFormat (); |
|
65 | 65 | |
66 | 66 | // Create a worksheet |
67 | 67 | $worksheet_name = "Subnets"; |
68 | -$worksheet =& $workbook->addWorksheet($worksheet_name); |
|
68 | +$worksheet = & $workbook->addWorksheet ($worksheet_name); |
|
69 | 69 | |
70 | 70 | $lineCount = 0; |
71 | 71 | $rowCount = 0; |
72 | 72 | |
73 | 73 | //write headers |
74 | -if( (isset($_GET['section'])) && ($_GET['section'] == "on") ) { |
|
75 | - $worksheet->write($lineCount, $rowCount, _('Section') ,$format_header); |
|
74 | +if ((isset($_GET['section'])) && ($_GET['section'] == "on")) { |
|
75 | + $worksheet->write ($lineCount, $rowCount, _ ('Section'), $format_header); |
|
76 | 76 | $rowCount++; |
77 | 77 | } |
78 | -if( (isset($_GET['subnet'])) && ($_GET['subnet'] == "on") ) { |
|
79 | - $worksheet->write($lineCount, $rowCount, _('Subnet') ,$format_header); |
|
78 | +if ((isset($_GET['subnet'])) && ($_GET['subnet'] == "on")) { |
|
79 | + $worksheet->write ($lineCount, $rowCount, _ ('Subnet'), $format_header); |
|
80 | 80 | $rowCount++; |
81 | 81 | } |
82 | -if( (isset($_GET['description'])) && ($_GET['description'] == "on") ) { |
|
83 | - $worksheet->write($lineCount, $rowCount, _('Description') ,$format_header); |
|
82 | +if ((isset($_GET['description'])) && ($_GET['description'] == "on")) { |
|
83 | + $worksheet->write ($lineCount, $rowCount, _ ('Description'), $format_header); |
|
84 | 84 | $rowCount++; |
85 | 85 | } |
86 | -if( (isset($_GET['VLAN'])) && ($_GET['VLAN'] == "on") ) { |
|
87 | - $worksheet->write($lineCount, $rowCount, _('VLAN') ,$format_header); |
|
86 | +if ((isset($_GET['VLAN'])) && ($_GET['VLAN'] == "on")) { |
|
87 | + $worksheet->write ($lineCount, $rowCount, _ ('VLAN'), $format_header); |
|
88 | 88 | $rowCount++; |
89 | - $worksheet->write($lineCount, $rowCount, _('VLAN Domain') ,$format_header); |
|
89 | + $worksheet->write ($lineCount, $rowCount, _ ('VLAN Domain'), $format_header); |
|
90 | 90 | $rowCount++; |
91 | 91 | } |
92 | -if( (isset($_GET['VRF'])) && ($_GET['VRF'] == "on") ) { |
|
93 | - $worksheet->write($lineCount, $rowCount, _('VRF') ,$format_header); |
|
92 | +if ((isset($_GET['VRF'])) && ($_GET['VRF'] == "on")) { |
|
93 | + $worksheet->write ($lineCount, $rowCount, _ ('VRF'), $format_header); |
|
94 | 94 | $rowCount++; |
95 | 95 | } |
96 | -if( (isset($_GET['master'])) && ($_GET['master'] == "on") ) { |
|
97 | - $worksheet->write($lineCount, $rowCount, _('Master Subnet') ,$format_header); |
|
96 | +if ((isset($_GET['master'])) && ($_GET['master'] == "on")) { |
|
97 | + $worksheet->write ($lineCount, $rowCount, _ ('Master Subnet'), $format_header); |
|
98 | 98 | $rowCount++; |
99 | 99 | } |
100 | -if( (isset($_GET['requests'])) && ($_GET['requests'] == "on") ) { |
|
101 | - $worksheet->write($lineCount, $rowCount, _('Requests') ,$format_header); |
|
100 | +if ((isset($_GET['requests'])) && ($_GET['requests'] == "on")) { |
|
101 | + $worksheet->write ($lineCount, $rowCount, _ ('Requests'), $format_header); |
|
102 | 102 | $rowCount++; |
103 | 103 | } |
104 | -if( (isset($_GET['hostscheck'])) && ($_GET['hostscheck'] == "on") ) { |
|
105 | - $worksheet->write($lineCount, $rowCount, _('Host check') ,$format_header); |
|
104 | +if ((isset($_GET['hostscheck'])) && ($_GET['hostscheck'] == "on")) { |
|
105 | + $worksheet->write ($lineCount, $rowCount, _ ('Host check'), $format_header); |
|
106 | 106 | $rowCount++; |
107 | 107 | } |
108 | -if( (isset($_GET['discover'])) && ($_GET['discover'] == "on") ) { |
|
109 | - $worksheet->write($lineCount, $rowCount, _('Discover') ,$format_header); |
|
108 | +if ((isset($_GET['discover'])) && ($_GET['discover'] == "on")) { |
|
109 | + $worksheet->write ($lineCount, $rowCount, _ ('Discover'), $format_header); |
|
110 | 110 | $rowCount++; |
111 | 111 | } |
112 | 112 | |
113 | 113 | //custom fields |
114 | -if(sizeof($custom_fields) > 0) { |
|
115 | - foreach($custom_fields as $myField) { |
|
114 | +if (sizeof ($custom_fields) > 0) { |
|
115 | + foreach ($custom_fields as $myField) { |
|
116 | 116 | //set temp name - replace space with three ___ |
117 | - $myField['nameTemp'] = str_replace(" ", "___", $myField['name']); |
|
117 | + $myField['nameTemp'] = str_replace (" ", "___", $myField['name']); |
|
118 | 118 | |
119 | - if( (isset($_GET[$myField['nameTemp']])) && ($_GET[$myField['nameTemp']] == "on") ) { |
|
120 | - $worksheet->write($lineCount, $rowCount, $myField['name'] ,$format_header); |
|
119 | + if ((isset($_GET[$myField['nameTemp']])) && ($_GET[$myField['nameTemp']] == "on")) { |
|
120 | + $worksheet->write ($lineCount, $rowCount, $myField['name'], $format_header); |
|
121 | 121 | $rowCount++; |
122 | 122 | } |
123 | 123 | } |
@@ -127,107 +127,107 @@ discard block |
||
127 | 127 | $lineCount++; |
128 | 128 | |
129 | 129 | //write Subnet entries for the selected sections |
130 | -if($all_sections!==false) { |
|
130 | +if ($all_sections !== false) { |
|
131 | 131 | foreach ($all_sections as $section) { |
132 | 132 | //cast |
133 | 133 | $section = (array) $section; |
134 | 134 | |
135 | - if( (isset($_GET['exportSection__'.$section['name']])) && ($_GET['exportSection__'.$section['name']] == "on") ) { |
|
135 | + if ((isset($_GET['exportSection__'.$section['name']])) && ($_GET['exportSection__'.$section['name']] == "on")) { |
|
136 | 136 | // get all subnets in section |
137 | - $section_subnets = $Subnets->fetch_section_subnets($section['id']); |
|
137 | + $section_subnets = $Subnets->fetch_section_subnets ($section['id']); |
|
138 | 138 | |
139 | - if (sizeof($section_subnets)==0) { continue; } |
|
139 | + if (sizeof ($section_subnets) == 0) { continue; } |
|
140 | 140 | |
141 | 141 | foreach ($section_subnets as $subnet) { |
142 | 142 | |
143 | 143 | $subnet = (array) $subnet; |
144 | 144 | |
145 | - if( (isset($_GET['section'])) && ($_GET['section'] == "on") ) { |
|
146 | - $worksheet->write($lineCount, $rowCount, $section['name'], $format_text); |
|
145 | + if ((isset($_GET['section'])) && ($_GET['section'] == "on")) { |
|
146 | + $worksheet->write ($lineCount, $rowCount, $section['name'], $format_text); |
|
147 | 147 | $rowCount++; |
148 | 148 | } |
149 | 149 | |
150 | - if( (isset($_GET['subnet'])) && ($_GET['subnet'] == "on") ) { |
|
150 | + if ((isset($_GET['subnet'])) && ($_GET['subnet'] == "on")) { |
|
151 | 151 | $subnet_text = ''; |
152 | 152 | if ($subnet['isFolder']) { |
153 | 153 | $subnet_text = $subnet['description']." (folder)"; |
154 | 154 | } else { |
155 | 155 | $subnet_text = $subnet['ip']."/".$subnet['mask']; |
156 | 156 | } |
157 | - $worksheet->write($lineCount, $rowCount, $subnet_text, $format_text); |
|
157 | + $worksheet->write ($lineCount, $rowCount, $subnet_text, $format_text); |
|
158 | 158 | $rowCount++; |
159 | 159 | } |
160 | 160 | |
161 | - if( (isset($_GET['description'])) && ($_GET['description'] == "on") ) { |
|
162 | - $worksheet->write($lineCount, $rowCount, $subnet['description'], $format_text); |
|
161 | + if ((isset($_GET['description'])) && ($_GET['description'] == "on")) { |
|
162 | + $worksheet->write ($lineCount, $rowCount, $subnet['description'], $format_text); |
|
163 | 163 | $rowCount++; |
164 | 164 | } |
165 | 165 | |
166 | - if( (isset($_GET['VLAN'])) && ($_GET['VLAN'] == "on") ) { |
|
166 | + if ((isset($_GET['VLAN'])) && ($_GET['VLAN'] == "on")) { |
|
167 | 167 | // get VLAN |
168 | - $vlan = (array) $Tools->fetch_object("vlans", "vlanId", $subnet['vlanId']); |
|
168 | + $vlan = (array) $Tools->fetch_object ("vlans", "vlanId", $subnet['vlanId']); |
|
169 | 169 | /* if(@$vlan[0]===false) { $vlan['number'] = "NA"; $vlan['name'] = "NA"; } # no VLAN |
170 | 170 | $worksheet->write($lineCount, $rowCount, $vlan['number']." [".$vlan['name']."]", $format_text); */ |
171 | - if(@$vlan[0]===false) { $vlan['number'] = "NA"; } # no VLAN |
|
172 | - $worksheet->write($lineCount, $rowCount, $vlan['number'], $format_text); |
|
171 | + if (@$vlan[0] === false) { $vlan['number'] = "NA"; } # no VLAN |
|
172 | + $worksheet->write ($lineCount, $rowCount, $vlan['number'], $format_text); |
|
173 | 173 | $rowCount++; |
174 | 174 | // VLAN Domain |
175 | - $vlan_domain = (array) $Tools->fetch_object("vlanDomains", "id", $vlan['domainId']); |
|
176 | - $worksheet->write($lineCount, $rowCount, $vlan_domain['name'], $format_text); |
|
175 | + $vlan_domain = (array) $Tools->fetch_object ("vlanDomains", "id", $vlan['domainId']); |
|
176 | + $worksheet->write ($lineCount, $rowCount, $vlan_domain['name'], $format_text); |
|
177 | 177 | $rowCount++; |
178 | 178 | } |
179 | 179 | |
180 | - if( (isset($_GET['VRF'])) && ($_GET['VRF'] == "on") ) { |
|
180 | + if ((isset($_GET['VRF'])) && ($_GET['VRF'] == "on")) { |
|
181 | 181 | // get vrf |
182 | 182 | if (!empty($subnet['vrfId'])) { |
183 | - $vrf = (array) $Tools->fetch_object("vrf", "vrfId", $subnet['vrfId']); |
|
184 | - $worksheet->write($lineCount, $rowCount, $vrf['name'], $format_text); |
|
183 | + $vrf = (array) $Tools->fetch_object ("vrf", "vrfId", $subnet['vrfId']); |
|
184 | + $worksheet->write ($lineCount, $rowCount, $vrf['name'], $format_text); |
|
185 | 185 | } else { |
186 | - $worksheet->write($lineCount, $rowCount, '', $format_text); |
|
186 | + $worksheet->write ($lineCount, $rowCount, '', $format_text); |
|
187 | 187 | } |
188 | 188 | $rowCount++; |
189 | 189 | } |
190 | 190 | |
191 | - if( (isset($_GET['master'])) && ($_GET['master'] == "on") ) { |
|
191 | + if ((isset($_GET['master'])) && ($_GET['master'] == "on")) { |
|
192 | 192 | // get master subnet |
193 | 193 | // zet - could optimize here and reference the already loaded subnets, with the help of a dictionary variable |
194 | - $masterSubnet = ( $subnet['masterSubnetId']==0 || empty($subnet['masterSubnetId']) ) ? false : true; |
|
195 | - if($masterSubnet) { |
|
194 | + $masterSubnet = ($subnet['masterSubnetId'] == 0 || empty($subnet['masterSubnetId'])) ? false : true; |
|
195 | + if ($masterSubnet) { |
|
196 | 196 | $master = (array) $Subnets->fetch_subnet (null, $subnet['masterSubnetId']); |
197 | - if($master['isFolder']) { |
|
198 | - $worksheet->write($lineCount, $rowCount, $master['description']." [folder]", $format_text); |
|
197 | + if ($master['isFolder']) { |
|
198 | + $worksheet->write ($lineCount, $rowCount, $master['description']." [folder]", $format_text); |
|
199 | 199 | } else { |
200 | - $worksheet->write($lineCount, $rowCount, $master['ip']."/".$master['mask'], $format_text); |
|
200 | + $worksheet->write ($lineCount, $rowCount, $master['ip']."/".$master['mask'], $format_text); |
|
201 | 201 | } |
202 | 202 | } else { |
203 | - $worksheet->write($lineCount, $rowCount, "/", $format_text); |
|
203 | + $worksheet->write ($lineCount, $rowCount, "/", $format_text); |
|
204 | 204 | } |
205 | 205 | $rowCount++; |
206 | 206 | } |
207 | 207 | |
208 | - if( (isset($_GET['requests'])) && ($_GET['requests'] == "on") ) { |
|
209 | - $worksheet->write($lineCount, $rowCount, $subnet['allowRequests'], $format_text); |
|
208 | + if ((isset($_GET['requests'])) && ($_GET['requests'] == "on")) { |
|
209 | + $worksheet->write ($lineCount, $rowCount, $subnet['allowRequests'], $format_text); |
|
210 | 210 | $rowCount++; |
211 | 211 | } |
212 | 212 | |
213 | - if( (isset($_GET['hostscheck'])) && ($_GET['hostscheck'] == "on") ) { |
|
214 | - $worksheet->write($lineCount, $rowCount, $subnet['pingSubnet'], $format_text); |
|
213 | + if ((isset($_GET['hostscheck'])) && ($_GET['hostscheck'] == "on")) { |
|
214 | + $worksheet->write ($lineCount, $rowCount, $subnet['pingSubnet'], $format_text); |
|
215 | 215 | $rowCount++; |
216 | 216 | } |
217 | 217 | |
218 | - if( (isset($_GET['discover'])) && ($_GET['discover'] == "on") ) { |
|
219 | - $worksheet->write($lineCount, $rowCount, $subnet['discoverSubnet'], $format_text); |
|
218 | + if ((isset($_GET['discover'])) && ($_GET['discover'] == "on")) { |
|
219 | + $worksheet->write ($lineCount, $rowCount, $subnet['discoverSubnet'], $format_text); |
|
220 | 220 | $rowCount++; |
221 | 221 | } |
222 | 222 | |
223 | 223 | //custom fields, per subnet |
224 | - if(sizeof($custom_fields) > 0) { |
|
225 | - foreach($custom_fields as $myField) { |
|
224 | + if (sizeof ($custom_fields) > 0) { |
|
225 | + foreach ($custom_fields as $myField) { |
|
226 | 226 | //set temp name - replace space with three ___ |
227 | - $myField['nameTemp'] = str_replace(" ", "___", $myField['name']); |
|
227 | + $myField['nameTemp'] = str_replace (" ", "___", $myField['name']); |
|
228 | 228 | |
229 | - if( (isset($_GET[$myField['nameTemp']])) && ($_GET[$myField['nameTemp']] == "on") ) { |
|
230 | - $worksheet->write($lineCount, $rowCount, $subnet[$myField['name']], $format_text); |
|
229 | + if ((isset($_GET[$myField['nameTemp']])) && ($_GET[$myField['nameTemp']] == "on")) { |
|
230 | + $worksheet->write ($lineCount, $rowCount, $subnet[$myField['name']], $format_text); |
|
231 | 231 | $rowCount++; |
232 | 232 | } |
233 | 233 | } |
@@ -245,19 +245,19 @@ discard block |
||
245 | 245 | $lineCount++; |
246 | 246 | |
247 | 247 | //write section sheet |
248 | -if( (isset($_GET['exportSections'])) && ($_GET['exportSections'] == "on") ) { |
|
248 | +if ((isset($_GET['exportSections'])) && ($_GET['exportSections'] == "on")) { |
|
249 | 249 | // Create a worksheet |
250 | - $worksheet_sections =& $workbook->addWorksheet('Sections'); |
|
250 | + $worksheet_sections = & $workbook->addWorksheet ('Sections'); |
|
251 | 251 | |
252 | 252 | $lineCount = 0; |
253 | 253 | $rowCount = 0; |
254 | 254 | |
255 | 255 | //write headers |
256 | - $worksheet_sections->write($lineCount, $rowCount, _('Name') ,$format_header); |
|
256 | + $worksheet_sections->write ($lineCount, $rowCount, _ ('Name'), $format_header); |
|
257 | 257 | $rowCount++; |
258 | - $worksheet_sections->write($lineCount, $rowCount, _('Description') ,$format_header); |
|
258 | + $worksheet_sections->write ($lineCount, $rowCount, _ ('Description'), $format_header); |
|
259 | 259 | $rowCount++; |
260 | - $worksheet_sections->write($lineCount, $rowCount, _('Parent') ,$format_header); |
|
260 | + $worksheet_sections->write ($lineCount, $rowCount, _ ('Parent'), $format_header); |
|
261 | 261 | $rowCount++; |
262 | 262 | |
263 | 263 | $lineCount++; |
@@ -267,19 +267,19 @@ discard block |
||
267 | 267 | //cast |
268 | 268 | $section = (array) $section; |
269 | 269 | |
270 | - if( (isset($_GET['exportSection__'.str_replace(" ", "_", $section['name'])])) && ($_GET['exportSection__'.str_replace(" ", "_", $section['name'])] == "on") ) { |
|
271 | - $worksheet_sections->write($lineCount, $rowCount, $section['name'], $format_text); |
|
270 | + if ((isset($_GET['exportSection__'.str_replace (" ", "_", $section['name'])])) && ($_GET['exportSection__'.str_replace (" ", "_", $section['name'])] == "on")) { |
|
271 | + $worksheet_sections->write ($lineCount, $rowCount, $section['name'], $format_text); |
|
272 | 272 | $rowCount++; |
273 | - $worksheet_sections->write($lineCount, $rowCount, $section['description'], $format_text); |
|
273 | + $worksheet_sections->write ($lineCount, $rowCount, $section['description'], $format_text); |
|
274 | 274 | $rowCount++; |
275 | 275 | //master Section |
276 | - if($section['masterSection']!=0) { |
|
276 | + if ($section['masterSection'] != 0) { |
|
277 | 277 | # get section details |
278 | - $ssec = $Admin->fetch_object("sections", "id", $section['masterSection']); |
|
279 | - $worksheet_sections->write($lineCount, $rowCount, $ssec->name, $format_text); |
|
278 | + $ssec = $Admin->fetch_object ("sections", "id", $section['masterSection']); |
|
279 | + $worksheet_sections->write ($lineCount, $rowCount, $ssec->name, $format_text); |
|
280 | 280 | $rowCount++; |
281 | 281 | } else { |
282 | - $worksheet_sections->write($lineCount, $rowCount, "/", $format_text); |
|
282 | + $worksheet_sections->write ($lineCount, $rowCount, "/", $format_text); |
|
283 | 283 | $rowCount++; |
284 | 284 | } |
285 | 285 | } |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | // sending HTTP headers |
293 | -$workbook->send($filename); |
|
293 | +$workbook->send ($filename); |
|
294 | 294 | |
295 | 295 | // Let's send the file |
296 | -$workbook->close(); |
|
296 | +$workbook->close (); |
|
297 | 297 | |
298 | 298 | ?> |
@@ -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 _("Subnets import"); ?></div> |
|
24 | +<div class="pHeader"><?php print _ ("Subnets import"); ?></div> |
|
25 | 25 | |
26 | 26 | <!-- content --> |
27 | 27 | <div class="pContent"> |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | if (($cdata['action'] == "add") || ($cdata['action'] == "edit")) { |
37 | 37 | // # set update array |
38 | 38 | |
39 | - $values = array("id"=>$cdata['id'], |
|
39 | + $values = array ("id"=>$cdata['id'], |
|
40 | 40 | "sectionId"=>$cdata['sectionId'], |
41 | - "subnet"=>$Subnets->transform_to_decimal($cdata['subnet']), |
|
41 | + "subnet"=>$Subnets->transform_to_decimal ($cdata['subnet']), |
|
42 | 42 | "mask"=>$cdata['mask'], |
43 | 43 | "description"=>@$cdata['description'], |
44 | 44 | "vlanId"=>$cdata['vlanId'], |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | ); |
50 | 50 | |
51 | 51 | # add custom fields |
52 | - if(sizeof($custom_fields) > 0) { |
|
53 | - foreach($custom_fields as $myField) { |
|
54 | - if(isset($cdata[$myField['name']])) { $values[$myField['name']] = $cdata[$myField['name']]; } |
|
52 | + if (sizeof ($custom_fields) > 0) { |
|
53 | + foreach ($custom_fields as $myField) { |
|
54 | + if (isset($cdata[$myField['name']])) { $values[$myField['name']] = $cdata[$myField['name']]; } |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | # update |
59 | - $cdata['result'] = $Admin->object_modify("subnets", $cdata['action'], "id", $values); |
|
59 | + $cdata['result'] = $Admin->object_modify ("subnets", $cdata['action'], "id", $values); |
|
60 | 60 | |
61 | 61 | if ($cdata['result']) { |
62 | 62 | $trc = $colors[$cdata['action']]; |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | $msg = "Subnets ".$cdata['action']." failed."; |
67 | 67 | } |
68 | 68 | |
69 | - $rows.="<tr class='".$trc."'><td><i class='fa ".$icons[$action]."' rel='tooltip' data-placement='bottom' title='"._($msg)."'></i></td>"; |
|
70 | - foreach ($expfields as $cfield) { $rows.= "<td>".$cdata[$cfield]."</td>"; } |
|
71 | - $rows.= "<td>"._($msg)."</td></tr>"; |
|
69 | + $rows .= "<tr class='".$trc."'><td><i class='fa ".$icons[$action]."' rel='tooltip' data-placement='bottom' title='"._ ($msg)."'></i></td>"; |
|
70 | + foreach ($expfields as $cfield) { $rows .= "<td>".$cdata[$cfield]."</td>"; } |
|
71 | + $rows .= "<td>"._ ($msg)."</td></tr>"; |
|
72 | 72 | |
73 | 73 | } |
74 | 74 | } |
75 | -print _("After the import you should perform an automatic recomputation of the master/nested relations using the Recompute button after you close this window."); |
|
75 | +print _ ("After the import you should perform an automatic recomputation of the master/nested relations using the Recompute button after you close this window."); |
|
76 | 76 | print "<table class='table table-condensed table-hover' id='resultstable'><tbody>"; |
77 | 77 | print "<tr class='active'>".$hrow."<th>Result</th></tr>"; |
78 | 78 | print $rows; |
@@ -83,5 +83,5 @@ discard block |
||
83 | 83 | |
84 | 84 | <!-- footer --> |
85 | 85 | <div class="pFooter"> |
86 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Close'); ?></button> |
|
86 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Close'); ?></button> |
|
87 | 87 | </div> |
@@ -5,31 +5,31 @@ 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 | 11 | $Database = new Database_PDO; |
12 | -$User = new User ($Database); |
|
12 | +$User = new User ($Database); |
|
13 | 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","number","description","domain"); |
|
22 | +$expfields = array ("name", "number", "description", "domain"); |
|
23 | 23 | $mtable = "vlans"; # main table where to check the fields |
24 | 24 | # extra fields |
25 | 25 | $extfields["domain"]["table"] = "vlanDomains"; |
26 | 26 | $extfields["domain"]["field"] = "name"; |
27 | 27 | $extfields["domain"]["pname"] = "domain"; # name prefix for fields from other tables |
28 | 28 | # required fields without which we will not continue |
29 | -$reqfields = array("number","name"); |
|
29 | +$reqfields = array ("number", "name"); |
|
30 | 30 | |
31 | 31 | # manually adjust the standard fields |
32 | -foreach($expfields as $std_field) { |
|
32 | +foreach ($expfields as $std_field) { |
|
33 | 33 | # extra table and field |
34 | 34 | if (isset($extfields[$std_field])) { |
35 | 35 | $cfield = $extfields[$std_field]["field"]; |
@@ -43,28 +43,28 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | # read field attributes |
46 | - $field = $Tools->fetch_full_field_definition($ctable,$cfield); |
|
46 | + $field = $Tools->fetch_full_field_definition ($ctable, $cfield); |
|
47 | 47 | $field = (array) $field; |
48 | 48 | |
49 | 49 | # mark required fields with * |
50 | - $msgr = in_array($std_field,$reqfields) ? "*" : ""; |
|
50 | + $msgr = in_array ($std_field, $reqfields) ? "*" : ""; |
|
51 | 51 | |
52 | 52 | #prebuild template table rows to avoid useless foreach loops |
53 | - $tpl_field_names.= "<th>".$pname.$field['Field'].$msgr."</th>"; |
|
54 | - $tpl_field_types.= "<td><small>". wordwrap($field['Type'],18,"<br>\n",true) ."</small></td>"; |
|
53 | + $tpl_field_names .= "<th>".$pname.$field['Field'].$msgr."</th>"; |
|
54 | + $tpl_field_types .= "<td><small>".wordwrap ($field['Type'], 18, "<br>\n", true)."</small></td>"; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | # append the custom fields, if any |
58 | -$custom_fields = $Tools->fetch_custom_fields($mtable); |
|
59 | -if(sizeof($custom_fields) > 0) { |
|
60 | - foreach($custom_fields as $myField) { |
|
58 | +$custom_fields = $Tools->fetch_custom_fields ($mtable); |
|
59 | +if (sizeof ($custom_fields) > 0) { |
|
60 | + foreach ($custom_fields as $myField) { |
|
61 | 61 | # add field to required fields if needed |
62 | 62 | if ($myField['Null'] == "NO") { $reqfields[] = $myField['name']; } |
63 | 63 | # mark required fields with * |
64 | - $msgr = in_array($myField['name'],$reqfields) ? "*" : ""; |
|
64 | + $msgr = in_array ($myField['name'], $reqfields) ? "*" : ""; |
|
65 | 65 | |
66 | - $tpl_field_names.= "<th>".$myField['name'].$msgr."</th>"; |
|
67 | - $tpl_field_types.= "<td><small>". wordwrap($myField['type'],18,"<br>\n",true) ."</small></td>"; |
|
66 | + $tpl_field_names .= "<th>".$myField['name'].$msgr."</th>"; |
|
67 | + $tpl_field_types .= "<td><small>".wordwrap ($myField['type'], 18, "<br>\n", true)."</small></td>"; |
|
68 | 68 | $expfields[] = $myField['name']; |
69 | 69 | } |
70 | 70 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | ?> |
73 | 73 | |
74 | 74 | <!-- header --> |
75 | -<div class="pHeader"><?php print _("Select VLAN file and fields to import"); ?></div> |
|
75 | +<div class="pHeader"><?php print _ ("Select VLAN file and fields to import"); ?></div> |
|
76 | 76 | |
77 | 77 | <!-- content --> |
78 | 78 | <div class="pContent"> |
@@ -81,24 +81,24 @@ discard block |
||
81 | 81 | |
82 | 82 | # print template form |
83 | 83 | print "<form id='selectImportFields'><div id='topmsg'>"; |
84 | -print '<h4>'._("Template").'</h4><hr>'; |
|
85 | -print _("The import XLS/CSV should have the following fields and a <b>header row</b> for a succesful import:"); |
|
84 | +print '<h4>'._ ("Template").'</h4><hr>'; |
|
85 | +print _ ("The import XLS/CSV should have the following fields and a <b>header row</b> for a succesful import:"); |
|
86 | 86 | print "</div>"; |
87 | -print "<input name='expfields' type='hidden' value='".implode('|',$expfields)."' style='display:none;'>"; |
|
88 | -print "<input name='reqfields' type='hidden' value='".implode('|',$reqfields)."' style='display:none;'>"; |
|
87 | +print "<input name='expfields' type='hidden' value='".implode ('|', $expfields)."' style='display:none;'>"; |
|
88 | +print "<input name='reqfields' type='hidden' value='".implode ('|', $reqfields)."' style='display:none;'>"; |
|
89 | 89 | print "<input name='filetype' id='filetype' type='hidden' value='' style='display:none;'>"; |
90 | 90 | print "<table class='table table-striped table-condensed' id='fieldstable'><tbody>"; |
91 | -print "<tr>" . $tpl_field_names . "</tr>"; |
|
92 | -print "<tr>" . $tpl_field_types . "</tr>"; |
|
91 | +print "<tr>".$tpl_field_names."</tr>"; |
|
92 | +print "<tr>".$tpl_field_types."</tr>"; |
|
93 | 93 | print "</tbody></table>"; |
94 | -print "<div id='bottommsg'>"._("The fields marked with * are mandatory.")."<br>"._("If no VLAN domain is specified the VLAN is added/changed in the default domain.")."</div>"; |
|
94 | +print "<div id='bottommsg'>"._ ("The fields marked with * are mandatory.")."<br>"._ ("If no VLAN domain is specified the VLAN is added/changed in the default domain.")."</div>"; |
|
95 | 95 | ##print "<div class='checkbox'><label><input name='adddomain' type='checkbox' checked>"._("Add missing VLAN domains")."</label></div>"; |
96 | 96 | print "</form>"; |
97 | 97 | |
98 | 98 | $templatetype = 'vlans'; |
99 | 99 | # print upload section |
100 | 100 | print "<div id='uplmsg'>"; |
101 | -print '<h4>'._("Upload file").'</h4><hr>'; |
|
101 | +print '<h4>'._ ("Upload file").'</h4><hr>'; |
|
102 | 102 | include 'import-button.php'; |
103 | 103 | print "</div>"; |
104 | 104 | |
@@ -109,7 +109,7 @@ 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" id="dataImportPreview" data-type="vlan" disabled><i class="fa fa-eye"></i> <?php print _('Preview'); ?></button> |
|
112 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
113 | + <button class="btn btn-sm btn-default" id="dataImportPreview" data-type="vlan" disabled><i class="fa fa-eye"></i> <?php print _ ('Preview'); ?></button> |
|
114 | 114 | </div> |
115 | 115 | </div> |
@@ -4,15 +4,15 @@ 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 | -$Admin = new Admin ($Database); |
|
12 | +$Admin = new Admin ($Database); |
|
13 | 13 | |
14 | 14 | # verify that user is logged in |
15 | -$User->check_user_session(); |
|
15 | +$User->check_user_session (); |
|
16 | 16 | |
17 | 17 | # Load subnets and recompute the master/nested relations |
18 | 18 | include 'import-recompute-logic.php'; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | ?> |
21 | 21 | |
22 | 22 | <!-- header --> |
23 | -<div class="pHeader"><?php print _("Subnets master/nested recompute save"); ?></div> |
|
23 | +<div class="pHeader"><?php print _ ("Subnets master/nested recompute save"); ?></div> |
|
24 | 24 | |
25 | 25 | <!-- content --> |
26 | 26 | <div class="pContent"> |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | if ($c_subnet['action'] == "edit") { |
41 | 41 | |
42 | 42 | # We only need id and new master |
43 | - $values = array("id"=>$c_subnet['id'], "masterSubnetId"=>$c_subnet['new_masterSubnetId']); |
|
43 | + $values = array ("id"=>$c_subnet['id'], "masterSubnetId"=>$c_subnet['new_masterSubnetId']); |
|
44 | 44 | |
45 | 45 | # update |
46 | - $c_subnet['result'] = $Admin->object_modify("subnets", $c_subnet['action'], "id", $values); |
|
46 | + $c_subnet['result'] = $Admin->object_modify ("subnets", $c_subnet['action'], "id", $values); |
|
47 | 47 | |
48 | 48 | if ($c_subnet['result']) { |
49 | 49 | $trc = $colors[$c_subnet['action']]; |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | $msg = "Master ".$c_subnet['action']." failed."; |
54 | 54 | } |
55 | 55 | |
56 | - $rows.="<tr class='".$trc."'><td><i class='fa ".$icons[$c_subnet['action']]."' rel='tooltip' data-placement='bottom' title='"._($msg)."'></i></td>"; |
|
57 | - $rows.="<td>".$sect_names[$sect_id]."</td><td>".$c_subnet['ip']."/".$c_subnet['mask']."</td>"; |
|
58 | - $rows.="<td>".$c_subnet['description']."</td><td>".$vrf_name[$c_subnet['vrfId']]."</td><td>"; |
|
59 | - $rows.=$c_subnet['new_master']."</td><td>"._($msg)."</td></tr>\n"; |
|
56 | + $rows .= "<tr class='".$trc."'><td><i class='fa ".$icons[$c_subnet['action']]."' rel='tooltip' data-placement='bottom' title='"._ ($msg)."'></i></td>"; |
|
57 | + $rows .= "<td>".$sect_names[$sect_id]."</td><td>".$c_subnet['ip']."/".$c_subnet['mask']."</td>"; |
|
58 | + $rows .= "<td>".$c_subnet['description']."</td><td>".$vrf_name[$c_subnet['vrfId']]."</td><td>"; |
|
59 | + $rows .= $c_subnet['new_master']."</td><td>"._ ($msg)."</td></tr>\n"; |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | } |
@@ -72,5 +72,5 @@ discard block |
||
72 | 72 | |
73 | 73 | <!-- footer --> |
74 | 74 | <div class="pFooter"> |
75 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Close'); ?></button> |
|
75 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Close'); ?></button> |
|
76 | 76 | </div> |
@@ -5,25 +5,25 @@ 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 | # read again the custom fields, if any |
23 | -if (!isset($custom_fields)) { $custom_fields = $Tools->fetch_custom_fields("vlans"); } |
|
23 | +if (!isset($custom_fields)) { $custom_fields = $Tools->fetch_custom_fields ("vlans"); } |
|
24 | 24 | |
25 | 25 | # Load existing data |
26 | -$edata = array(); $vdom = array(); $vdomid = array(); |
|
26 | +$edata = array (); $vdom = array (); $vdomid = array (); |
|
27 | 27 | # process for easier later check |
28 | 28 | foreach ($vlan_domains as $vlan_domain) { |
29 | 29 | //cast |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $vdom[] = $vlan_domain['name']; |
32 | 32 | $vdomid[$vlan_domain['name']] = $vlan_domain['id']; |
33 | 33 | // read vlans |
34 | - $all_vlans = $Admin->fetch_multiple_objects("vlans", "domainId", $vlan_domain['id'], "number"); |
|
34 | + $all_vlans = $Admin->fetch_multiple_objects ("vlans", "domainId", $vlan_domain['id'], "number"); |
|
35 | 35 | $all_vlans = (array) $all_vlans; |
36 | 36 | // skip empty domains |
37 | - if (sizeof($all_vlans)==0) { continue; } |
|
37 | + if (sizeof ($all_vlans) == 0) { continue; } |
|
38 | 38 | //write all VLAN entries |
39 | 39 | foreach ($all_vlans as $vlan) { |
40 | 40 | //cast |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | $rows = ""; |
47 | -$counters = array(); |
|
48 | -$unique = array(); |
|
47 | +$counters = array (); |
|
48 | +$unique = array (); |
|
49 | 49 | |
50 | 50 | # check the fields |
51 | 51 | foreach ($data as &$cdata) { |
@@ -55,68 +55,68 @@ discard block |
||
55 | 55 | if ($cdata['domain'] != "") { $cdom = $cdata['domain']; } else { $cdom = "default"; } |
56 | 56 | |
57 | 57 | # check if domain exists and link ID, otherwise issue error |
58 | - if (!in_array($cdom,$vdom)) { |
|
59 | - $msg.= "Missing VLAN domain. Please add/import VLAN domain first."; $action = "error"; |
|
58 | + if (!in_array ($cdom, $vdom)) { |
|
59 | + $msg .= "Missing VLAN domain. Please add/import VLAN domain first."; $action = "error"; |
|
60 | 60 | } else { |
61 | 61 | $cdata['domainId'] = $vdomid[$cdom]; |
62 | 62 | } |
63 | 63 | |
64 | 64 | # check if required fields are present and not empty |
65 | - foreach($reqfields as $creq) { |
|
66 | - if ((!isset($cdata[$creq])) or ($cdata[$creq] == "")) { $msg.= "Required field ".$creq." missing or empty."; $action = "error"; } |
|
65 | + foreach ($reqfields as $creq) { |
|
66 | + if ((!isset($cdata[$creq])) or ($cdata[$creq] == "")) { $msg .= "Required field ".$creq." missing or empty."; $action = "error"; } |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | # check data format |
70 | 70 | if ($action != "error") { |
71 | - if (!preg_match("/^[a-zA-Z0-9-_]+$/", $cdata['name'])) { $msg.="Invalid name format."; $action = "error"; } |
|
72 | - if (!preg_match("/^[0-9]+$/", $cdata['number'])) { $msg.="Invalid number format."; $action = "error"; } |
|
73 | - if (preg_match("/[;'\"]/", $cdata['description'])) { $msg.="Invalid characters in description."; $action = "error"; } |
|
74 | - if (!preg_match("/^[a-zA-Z0-9-_ ]+$/", $cdata['domain'])) { $msg.="Invalid domain format."; $action = "error"; } |
|
75 | - if ($action != "error") { if ($cdata['number']>$User->settings->vlanMax) { $msg.= _('Highest possible VLAN number is ').$User->settings->vlanMax.'!'; $action = "error"; } } |
|
71 | + if (!preg_match ("/^[a-zA-Z0-9-_]+$/", $cdata['name'])) { $msg .= "Invalid name format."; $action = "error"; } |
|
72 | + if (!preg_match ("/^[0-9]+$/", $cdata['number'])) { $msg .= "Invalid number format."; $action = "error"; } |
|
73 | + if (preg_match ("/[;'\"]/", $cdata['description'])) { $msg .= "Invalid characters in description."; $action = "error"; } |
|
74 | + if (!preg_match ("/^[a-zA-Z0-9-_ ]+$/", $cdata['domain'])) { $msg .= "Invalid domain format."; $action = "error"; } |
|
75 | + if ($action != "error") { if ($cdata['number'] > $User->settings->vlanMax) { $msg .= _ ('Highest possible VLAN number is ').$User->settings->vlanMax.'!'; $action = "error"; } } |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | # Generate the custom fields columns |
79 | - if(sizeof($custom_fields) > 0) { foreach($custom_fields as $myField) { $cfieldtds.= "<td>".$cdata[$myField['name']]."</td>"; } } |
|
79 | + if (sizeof ($custom_fields) > 0) { foreach ($custom_fields as $myField) { $cfieldtds .= "<td>".$cdata[$myField['name']]."</td>"; } } |
|
80 | 80 | |
81 | 81 | # check if duplicate VLAN |
82 | - if (isset($unique[$cdom][$cdata['number']])) { $msg.= "Duplicate VLAN domain and number not supported. Please check import file."; $action = "error"; } |
|
82 | + if (isset($unique[$cdom][$cdata['number']])) { $msg .= "Duplicate VLAN domain and number not supported. Please check import file."; $action = "error"; } |
|
83 | 83 | |
84 | 84 | # check if existing |
85 | 85 | if ($action != "error") { |
86 | 86 | if (isset($edata[$cdom][$cdata['number']])) { |
87 | 87 | $cdata['vlanId'] = $edata[$cdom][$cdata['number']]['vlanId']; |
88 | 88 | $action = "skip"; # skip duplicate fields if identical, update if different |
89 | - if ($cdata['name'] != $edata[$cdom][$cdata['number']]['name']) { $msg.= "VLAN name will be updated."; $action = "edit"; } |
|
90 | - if ($cdata['description'] != $edata[$cdom][$cdata['number']]['description']) { $msg.= "VLAN description will be updated."; $action = "edit"; } |
|
89 | + if ($cdata['name'] != $edata[$cdom][$cdata['number']]['name']) { $msg .= "VLAN name will be updated."; $action = "edit"; } |
|
90 | + if ($cdata['description'] != $edata[$cdom][$cdata['number']]['description']) { $msg .= "VLAN description will be updated."; $action = "edit"; } |
|
91 | 91 | # Check if the values of the custom fields have changed |
92 | - if(sizeof($custom_fields) > 0) { |
|
93 | - foreach($custom_fields as $myField) { |
|
92 | + if (sizeof ($custom_fields) > 0) { |
|
93 | + foreach ($custom_fields as $myField) { |
|
94 | 94 | if ($cdata[$myField['name']] != $edata[$cdom][$cdata['number']][$myField['name']]) { |
95 | - $msg.= "VLAN ".$myField['name']." will be updated."; $action = "edit"; |
|
95 | + $msg .= "VLAN ".$myField['name']." will be updated."; $action = "edit"; |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | 100 | if ($action == "skip") { |
101 | - $msg.= "Duplicate, will skip."; |
|
101 | + $msg .= "Duplicate, will skip."; |
|
102 | 102 | } |
103 | 103 | } else { |
104 | - $msg.="New entry, will be added."; $action = "add"; |
|
104 | + $msg .= "New entry, will be added."; $action = "add"; |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | - $cdata['msg'].= $msg; |
|
108 | + $cdata['msg'] .= $msg; |
|
109 | 109 | $cdata['action'] = $action; |
110 | 110 | $counters[$action]++; |
111 | 111 | if (!isset($unique[$cdom][$cdata['number']])) { $unique[$cdom][$cdata['number']] = $cdata['name']; } |
112 | 112 | |
113 | - $rows.="<tr class='".$colors[$action]."'><td><i class='fa ".$icons[$action]."' rel='tooltip' data-placement='bottom' title='"._($msg)."'></i></td> |
|
113 | + $rows .= "<tr class='".$colors[$action]."'><td><i class='fa ".$icons[$action]."' rel='tooltip' data-placement='bottom' title='"._ ($msg)."'></i></td> |
|
114 | 114 | <td>".$cdata['name']."</td> |
115 | 115 | <td>".$cdata['number']."</td> |
116 | 116 | <td>".$cdata['description']."</td> |
117 | 117 | <td>".$cdata['domain']."</td> |
118 | 118 | ".$cfieldtds." |
119 | - <td>"._($cdata['msg'])."</td></tr>"; |
|
119 | + <td>"._ ($cdata['msg'])."</td></tr>"; |
|
120 | 120 | |
121 | 121 | } |
122 | 122 |