@@ -5,34 +5,34 @@ discard block |
||
5 | 5 | ************************************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # fetch all vrfs |
11 | -$all_types = $Admin->fetch_all_objects("ipTags"); |
|
11 | +$all_types = $Admin->fetch_all_objects ("ipTags"); |
|
12 | 12 | ?> |
13 | 13 | |
14 | -<h4><?php print _('Manage Address Tags'); ?></h4> |
|
14 | +<h4><?php print _ ('Manage Address Tags'); ?></h4> |
|
15 | 15 | <hr><br> |
16 | 16 | |
17 | -<button class='btn btn-sm btn-default editType' data-action='add' data-vrfid='' style='margin-bottom:10px;'><i class='fa fa-plus'></i> <?php print _('Add Tag'); ?></button> |
|
17 | +<button class='btn btn-sm btn-default editType' data-action='add' data-vrfid='' style='margin-bottom:10px;'><i class='fa fa-plus'></i> <?php print _ ('Add Tag'); ?></button> |
|
18 | 18 | |
19 | 19 | <!-- vrfs --> |
20 | 20 | <?php |
21 | -print '<table class="table table-striped table-top table-auto">'. "\n"; |
|
21 | +print '<table class="table table-striped table-top table-auto">'."\n"; |
|
22 | 22 | |
23 | 23 | # headers |
24 | -print '<tr>'. "\n"; |
|
25 | -print ' <th>'._('type').'</th>'. "\n"; |
|
26 | -print ' <th>'._('Show Tag').'</th>'. "\n"; |
|
27 | -print ' <th>'._('BG color').'</th>'. "\n"; |
|
28 | -print ' <th>'._('FG color').'</th>'. "\n"; |
|
29 | -print ' <th>'._('Compress range').'</th>'. "\n"; |
|
30 | -print ' <th>'._('Locked').'</th>'. "\n"; |
|
31 | -print ' <th></th>'. "\n"; |
|
32 | -print '</tr>'. "\n"; |
|
24 | +print '<tr>'."\n"; |
|
25 | +print ' <th>'._ ('type').'</th>'."\n"; |
|
26 | +print ' <th>'._ ('Show Tag').'</th>'."\n"; |
|
27 | +print ' <th>'._ ('BG color').'</th>'."\n"; |
|
28 | +print ' <th>'._ ('FG color').'</th>'."\n"; |
|
29 | +print ' <th>'._ ('Compress range').'</th>'."\n"; |
|
30 | +print ' <th>'._ ('Locked').'</th>'."\n"; |
|
31 | +print ' <th></th>'."\n"; |
|
32 | +print '</tr>'."\n"; |
|
33 | 33 | |
34 | 34 | # loop |
35 | -if ($all_types!==false) { |
|
35 | +if ($all_types !== false) { |
|
36 | 36 | // cast |
37 | 37 | $all_types = (array) $all_types; |
38 | 38 | // loop |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | $type = (array) $type; |
42 | 42 | |
43 | 43 | //format type |
44 | - $showtag = $type['showtag']==1 ? "Yes" : "No"; |
|
44 | + $showtag = $type['showtag'] == 1 ? "Yes" : "No"; |
|
45 | 45 | |
46 | 46 | //print details |
47 | - print '<tr>'. "\n"; |
|
48 | - print ' <td>'. $type['type'] .'</td>'. "\n"; |
|
49 | - print ' <td>'.$showtag.'</td>'. "\n"; |
|
50 | - print ' <td style="background-color:'.$type['bgcolor'].'">'. $type['bgcolor'] .'</td>'. "\n"; |
|
51 | - print ' <td style="background-color:'.$type['fgcolor'].'">'. $type['fgcolor'] .'</td>'. "\n"; |
|
52 | - print ' <td>'. $type['compress'] .'</td>'. "\n"; |
|
53 | - print ' <td>'. $type['locked'] .'</td>'. "\n"; |
|
47 | + print '<tr>'."\n"; |
|
48 | + print ' <td>'.$type['type'].'</td>'."\n"; |
|
49 | + print ' <td>'.$showtag.'</td>'."\n"; |
|
50 | + print ' <td style="background-color:'.$type['bgcolor'].'">'.$type['bgcolor'].'</td>'."\n"; |
|
51 | + print ' <td style="background-color:'.$type['fgcolor'].'">'.$type['fgcolor'].'</td>'."\n"; |
|
52 | + print ' <td>'.$type['compress'].'</td>'."\n"; |
|
53 | + print ' <td>'.$type['locked'].'</td>'."\n"; |
|
54 | 54 | |
55 | 55 | print " <td class='actions'>"; |
56 | 56 | print " <div class='btn-group'>"; |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | print " <button class='btn btn-xs btn-default editType' data-action='delete' data-id='$type[id]'><i class='fa fa-times'></i></button>"; |
59 | 59 | print " </div>"; |
60 | 60 | print " </td>"; |
61 | - print '</tr>'. "\n"; |
|
61 | + print '</tr>'."\n"; |
|
62 | 62 | } |
63 | 63 | } |
64 | -print '</table>'. "\n"; |
|
64 | +print '</table>'."\n"; |
|
65 | 65 | ?> |
66 | 66 | |
67 | 67 | <!-- edit result holder --> |
@@ -5,39 +5,39 @@ discard block |
||
5 | 5 | ************************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | -$Sections = new Sections ($Database); |
|
15 | +$Sections = new Sections ($Database); |
|
16 | 16 | $Result = new Result (); |
17 | 17 | |
18 | 18 | # verify that user is logged in |
19 | -$User->check_user_session(); |
|
19 | +$User->check_user_session (); |
|
20 | 20 | |
21 | 21 | # create csrf token |
22 | 22 | $csrf = $User->csrf_cookie ("create", "vrf"); |
23 | 23 | |
24 | 24 | # get VRF |
25 | -if($_POST['action']!="add") { |
|
25 | +if ($_POST['action'] != "add") { |
|
26 | 26 | $vrf = $Admin->fetch_object ("vrf", "vrfId", $_POST['vrfId']); |
27 | - $vrf!==false ? : $Result->show("danger", _("Invalid ID"), true, true); |
|
27 | + $vrf !== false ? : $Result->show ("danger", _ ("Invalid ID"), true, true); |
|
28 | 28 | $vrf = (array) $vrf; |
29 | 29 | } |
30 | 30 | |
31 | 31 | # disable edit on delete |
32 | -$readonly = $_POST['action']=="delete" ? "readonly" : ""; |
|
32 | +$readonly = $_POST['action'] == "delete" ? "readonly" : ""; |
|
33 | 33 | |
34 | 34 | # fetch custom fields |
35 | -$custom = $Tools->fetch_custom_fields('vrf'); |
|
35 | +$custom = $Tools->fetch_custom_fields ('vrf'); |
|
36 | 36 | ?> |
37 | 37 | |
38 | 38 | |
39 | 39 | <!-- header --> |
40 | -<div class="pHeader"><?php print ucwords(_("$_POST[action]")); ?> <?php print _('VRF'); ?></div> |
|
40 | +<div class="pHeader"><?php print ucwords (_ ("$_POST[action]")); ?> <?php print _ ('VRF'); ?></div> |
|
41 | 41 | |
42 | 42 | <!-- content --> |
43 | 43 | <div class="pContent"> |
@@ -47,28 +47,28 @@ discard block |
||
47 | 47 | |
48 | 48 | <!-- name --> |
49 | 49 | <tr> |
50 | - <td><?php print _('Name'); ?></td> |
|
50 | + <td><?php print _ ('Name'); ?></td> |
|
51 | 51 | <td> |
52 | - <input type="text" class="name form-control input-sm" name="name" placeholder="<?php print _('VRF name'); ?>" value="<?php print @$vrf['name']; ?>" <?php print $readonly; ?>> |
|
52 | + <input type="text" class="name form-control input-sm" name="name" placeholder="<?php print _ ('VRF name'); ?>" value="<?php print @$vrf['name']; ?>" <?php print $readonly; ?>> |
|
53 | 53 | </td> |
54 | 54 | </tr> |
55 | 55 | <!-- RD --> |
56 | 56 | <tr> |
57 | - <td><?php print _('RD'); ?></td> |
|
57 | + <td><?php print _ ('RD'); ?></td> |
|
58 | 58 | <td> |
59 | - <input type="text" class="rd form-control input-sm" name="rd" placeholder="<?php print _('Route distinguisher'); ?>" value="<?php print @$vrf['rd']; ?>" <?php print $readonly; ?>> |
|
59 | + <input type="text" class="rd form-control input-sm" name="rd" placeholder="<?php print _ ('Route distinguisher'); ?>" value="<?php print @$vrf['rd']; ?>" <?php print $readonly; ?>> |
|
60 | 60 | </td> |
61 | 61 | </tr> |
62 | 62 | <!-- Description --> |
63 | 63 | <tr> |
64 | - <td><?php print _('Description'); ?></td> |
|
64 | + <td><?php print _ ('Description'); ?></td> |
|
65 | 65 | <td> |
66 | 66 | <?php |
67 | - if( ($_POST['action'] == "edit") || ($_POST['action'] == "delete") ) { print '<input type="hidden" name="vrfId" value="'. $_POST['vrfId'] .'">'. "\n";} |
|
67 | + if (($_POST['action'] == "edit") || ($_POST['action'] == "delete")) { print '<input type="hidden" name="vrfId" value="'.$_POST['vrfId'].'">'."\n"; } |
|
68 | 68 | ?> |
69 | 69 | <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
70 | 70 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
71 | - <input type="text" class="description form-control input-sm" name="description" placeholder="<?php print _('Description'); ?>" value="<?php print @$vrf['description']; ?>" <?php print $readonly; ?>> |
|
71 | + <input type="text" class="description form-control input-sm" name="description" placeholder="<?php print _ ('Description'); ?>" value="<?php print @$vrf['description']; ?>" <?php print $readonly; ?>> |
|
72 | 72 | </td> |
73 | 73 | </tr> |
74 | 74 | <tr> |
@@ -76,19 +76,19 @@ discard block |
||
76 | 76 | </tr> |
77 | 77 | <!-- sections --> |
78 | 78 | <tr> |
79 | - <td style="vertical-align: top !important"><?php print _('Sections'); ?>:</td> |
|
79 | + <td style="vertical-align: top !important"><?php print _ ('Sections'); ?>:</td> |
|
80 | 80 | <td> |
81 | 81 | <?php |
82 | 82 | # select sections |
83 | - $sections = $Sections->fetch_all_sections(); |
|
83 | + $sections = $Sections->fetch_all_sections (); |
|
84 | 84 | # reformat domains sections to array |
85 | - $vrf_sections = explode(";", @$vrf['sections']); |
|
86 | - $vrf_sections = is_array($vrf_sections) ? $vrf_sections : array(); |
|
85 | + $vrf_sections = explode (";", @$vrf['sections']); |
|
86 | + $vrf_sections = is_array ($vrf_sections) ? $vrf_sections : array (); |
|
87 | 87 | // loop |
88 | - if($sections!==false) { |
|
89 | - foreach($sections as $section) { |
|
90 | - if(in_array($section->id, @$vrf_sections)) { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on" checked> '. $section->name .'</div>'. "\n"; } |
|
91 | - else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on">'. $section->name .'</span></div>'. "\n"; } |
|
88 | + if ($sections !== false) { |
|
89 | + foreach ($sections as $section) { |
|
90 | + if (in_array ($section->id, @$vrf_sections)) { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'.$section->id.'" value="on" checked> '.$section->name.'</div>'."\n"; } |
|
91 | + else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'.$section->id.'" value="on">'.$section->name.'</span></div>'."\n"; } |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | ?> |
@@ -97,46 +97,46 @@ discard block |
||
97 | 97 | |
98 | 98 | <!-- Custom --> |
99 | 99 | <?php |
100 | - if(sizeof($custom) > 0) { |
|
100 | + if (sizeof ($custom) > 0) { |
|
101 | 101 | |
102 | 102 | print '<tr>'; |
103 | 103 | print ' <td colspan="2"><hr></td>'; |
104 | 104 | print '</tr>'; |
105 | 105 | |
106 | - foreach($custom as $field) { |
|
106 | + foreach ($custom as $field) { |
|
107 | 107 | |
108 | 108 | # replace spaces |
109 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
109 | + $field['nameNew'] = str_replace (" ", "___", $field['name']); |
|
110 | 110 | |
111 | 111 | # required |
112 | - if($field['Null']=="NO") { $required = "*"; } |
|
113 | - else { $required = ""; } |
|
112 | + if ($field['Null'] == "NO") { $required = "*"; } |
|
113 | + else { $required = ""; } |
|
114 | 114 | |
115 | 115 | # set default value ! |
116 | - if ($_POST['action']=="add") { $vrf[$field['name']] = $field['Default']; } |
|
116 | + if ($_POST['action'] == "add") { $vrf[$field['name']] = $field['Default']; } |
|
117 | 117 | |
118 | - print '<tr>'. "\n"; |
|
119 | - print ' <td>'. $field['name'] .' '.$required.'</td>'. "\n"; |
|
120 | - print ' <td>'. "\n"; |
|
118 | + print '<tr>'."\n"; |
|
119 | + print ' <td>'.$field['name'].' '.$required.'</td>'."\n"; |
|
120 | + print ' <td>'."\n"; |
|
121 | 121 | |
122 | 122 | //set type |
123 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
123 | + if (substr ($field['type'], 0, 3) == "set" || substr ($field['type'], 0, 4) == "enum") { |
|
124 | 124 | //parse values |
125 | - $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
125 | + $tmp = substr ($field['type'], 0, 3) == "set" ? explode (",", str_replace (array ("set(", ")", "'"), "", $field['type'])) : explode (",", str_replace (array ("enum(", ")", "'"), "", $field['type'])); |
|
126 | 126 | //null |
127 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
127 | + if ($field['Null'] != "NO") { array_unshift ($tmp, ""); } |
|
128 | 128 | |
129 | 129 | print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
130 | - foreach($tmp as $v) { |
|
131 | - if($v==$vrf[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
132 | - else { print "<option value='$v'>$v</option>"; } |
|
130 | + foreach ($tmp as $v) { |
|
131 | + if ($v == $vrf[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
132 | + else { print "<option value='$v'>$v</option>"; } |
|
133 | 133 | } |
134 | 134 | print "</select>"; |
135 | 135 | } |
136 | 136 | //date and time picker |
137 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
137 | + elseif ($field['type'] == "date" || $field['type'] == "datetime") { |
|
138 | 138 | // just for first |
139 | - if($timeP==0) { |
|
139 | + if ($timeP == 0) { |
|
140 | 140 | print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
141 | 141 | print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
142 | 142 | print '<script type="text/javascript">'; |
@@ -152,38 +152,38 @@ discard block |
||
152 | 152 | $timeP++; |
153 | 153 | |
154 | 154 | //set size |
155 | - if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
156 | - else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
155 | + if ($field['type'] == "date") { $size = 10; $class = 'datepicker'; $format = "yyyy-MM-dd"; } |
|
156 | + else { $size = 19; $class = 'datetimepicker'; $format = "yyyy-MM-dd"; } |
|
157 | 157 | |
158 | 158 | //field |
159 | - if(!isset($vrf[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
160 | - else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $vrf[$field['name']]. '" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
159 | + if (!isset($vrf[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$field['nameNew'].'" maxlength="'.$size.'" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; } |
|
160 | + else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$field['nameNew'].'" maxlength="'.$size.'" value="'.$vrf[$field['name']].'" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; } |
|
161 | 161 | } |
162 | 162 | //boolean |
163 | - elseif($field['type'] == "tinyint(1)") { |
|
163 | + elseif ($field['type'] == "tinyint(1)") { |
|
164 | 164 | print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
165 | - $tmp = array(0=>"No",1=>"Yes"); |
|
165 | + $tmp = array (0=>"No", 1=>"Yes"); |
|
166 | 166 | //null |
167 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
167 | + if ($field['Null'] != "NO") { $tmp[2] = ""; } |
|
168 | 168 | |
169 | - foreach($tmp as $k=>$v) { |
|
170 | - if(strlen($vrf[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
171 | - elseif($k==$vrf[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
172 | - else { print "<option value='$k'>"._($v)."</option>"; } |
|
169 | + foreach ($tmp as $k=>$v) { |
|
170 | + if (strlen ($vrf[$field['name']]) == 0 && $k == 2) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; } |
|
171 | + elseif ($k == $vrf[$field['name']]) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; } |
|
172 | + else { print "<option value='$k'>"._ ($v)."</option>"; } |
|
173 | 173 | } |
174 | 174 | print "</select>"; |
175 | 175 | } |
176 | 176 | //text |
177 | - elseif($field['type'] == "text") { |
|
178 | - print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" '.$readonly.' rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. $vrf[$field['name']]. '</textarea>'. "\n"; |
|
177 | + elseif ($field['type'] == "text") { |
|
178 | + print ' <textarea class="form-control input-sm" name="'.$field['nameNew'].'" placeholder="'.$field['name'].'" '.$readonly.' rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'.$vrf[$field['name']].'</textarea>'."\n"; |
|
179 | 179 | } |
180 | 180 | //default - input field |
181 | 181 | else { |
182 | - print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. @$vrf[$field['name']]. '" size="30" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
182 | + print ' <input type="text" class="ip_addr form-control input-sm" name="'.$field['nameNew'].'" placeholder="'.$field['name'].'" value="'.@$vrf[$field['name']].'" size="30" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; |
|
183 | 183 | } |
184 | 184 | |
185 | - print ' </td>'. "\n"; |
|
186 | - print '</tr>'. "\n"; |
|
185 | + print ' </td>'."\n"; |
|
186 | + print '</tr>'."\n"; |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | ?> |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | <?php |
196 | 196 | //print delete warning |
197 | - if($_POST['action'] == "delete") { $Result->show("warning", "<strong>"._('Warning').":</strong> "._("removing VRF will also remove VRF reference from belonging subnets!"), false);} |
|
197 | + if ($_POST['action'] == "delete") { $Result->show ("warning", "<strong>"._ ('Warning').":</strong> "._ ("removing VRF will also remove VRF reference from belonging subnets!"), false); } |
|
198 | 198 | ?> |
199 | 199 | </div> |
200 | 200 | |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | <!-- footer --> |
203 | 203 | <div class="pFooter"> |
204 | 204 | <div class="btn-group"> |
205 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
206 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editVRF"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
205 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
206 | + <button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editVRF"><i class="fa <?php if ($_POST['action'] == "add") { print "fa-plus"; } else if ($_POST['action'] == "delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords (_ ($_POST['action'])); ?></button> |
|
207 | 207 | </div> |
208 | 208 | <!-- result --> |
209 | 209 | <div class="vrfManagementEditResult"></div> |
@@ -5,65 +5,65 @@ |
||
5 | 5 | ***************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # strip input tags |
21 | -$_POST = $Admin->strip_input_tags($_POST); |
|
21 | +$_POST = $Admin->strip_input_tags ($_POST); |
|
22 | 22 | |
23 | 23 | # validate csrf cookie |
24 | -$User->csrf_cookie ("validate", "vrf", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; |
|
24 | +$User->csrf_cookie ("validate", "vrf", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : ""; |
|
25 | 25 | |
26 | 26 | # fetch custom fields |
27 | -$custom = $Tools->fetch_custom_fields('vrf'); |
|
27 | +$custom = $Tools->fetch_custom_fields ('vrf'); |
|
28 | 28 | |
29 | 29 | |
30 | 30 | # Hostname must be present! |
31 | -if($_POST['name'] == "") { $Result->show("danger", _("Name is mandatory"), true); } |
|
31 | +if ($_POST['name'] == "") { $Result->show ("danger", _ ("Name is mandatory"), true); } |
|
32 | 32 | |
33 | 33 | // set sections |
34 | -foreach($_POST as $key=>$line) { |
|
35 | - if (strlen(strstr($key,"section-"))>0) { |
|
36 | - $key2 = str_replace("section-", "", $key); |
|
34 | +foreach ($_POST as $key=>$line) { |
|
35 | + if (strlen (strstr ($key, "section-")) > 0) { |
|
36 | + $key2 = str_replace ("section-", "", $key); |
|
37 | 37 | $temp[] = $key2; |
38 | 38 | unset($_POST[$key]); |
39 | 39 | } |
40 | 40 | } |
41 | 41 | # glue sections together |
42 | -$_POST['sections'] = sizeof($temp)>0 ? implode(";", $temp) : null; |
|
42 | +$_POST['sections'] = sizeof ($temp) > 0 ? implode (";", $temp) : null; |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | 46 | # set update array |
47 | -$values = array("vrfId"=>@$_POST['vrfId'], |
|
47 | +$values = array ("vrfId"=>@$_POST['vrfId'], |
|
48 | 48 | "name"=>$_POST['name'], |
49 | 49 | "rd"=>$_POST['rd'], |
50 | 50 | "sections"=>$_POST['sections'], |
51 | 51 | "description"=>$_POST['description'] |
52 | 52 | ); |
53 | 53 | # append custom |
54 | -if(sizeof($custom) > 0) { |
|
55 | - foreach($custom as $myField) { |
|
54 | +if (sizeof ($custom) > 0) { |
|
55 | + foreach ($custom as $myField) { |
|
56 | 56 | # replace possible ___ back to spaces! |
57 | - $myField['nameTest'] = str_replace(" ", "___", $myField['name']); |
|
58 | - if(isset($_POST[$myField['nameTest']])) { $values[$myField['name']] = @$_POST[$myField['nameTest']];} |
|
57 | + $myField['nameTest'] = str_replace (" ", "___", $myField['name']); |
|
58 | + if (isset($_POST[$myField['nameTest']])) { $values[$myField['name']] = @$_POST[$myField['nameTest']]; } |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | 62 | # update |
63 | -if(!$Admin->object_modify("vrf", $_POST['action'], "vrfId", $values)) { $Result->show("danger", _("Failed to $_POST[action] VRF").'!', true); } |
|
64 | -else { $Result->show("success", _("VRF $_POST[action] successfull").'!', false); } |
|
63 | +if (!$Admin->object_modify ("vrf", $_POST['action'], "vrfId", $values)) { $Result->show ("danger", _ ("Failed to $_POST[action] VRF").'!', true); } |
|
64 | +else { $Result->show ("success", _ ("VRF $_POST[action] successfull").'!', false); } |
|
65 | 65 | |
66 | 66 | |
67 | 67 | # remove all references if delete |
68 | -if($_POST['action']=="delete") { $Admin->remove_object_references ("subnets", "vrfId", $_POST['vrfId']); } |
|
68 | +if ($_POST['action'] == "delete") { $Admin->remove_object_references ("subnets", "vrfId", $_POST['vrfId']); } |
|
69 | 69 | ?> |
@@ -5,31 +5,31 @@ discard block |
||
5 | 5 | ************************************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # fetch all vrfs |
11 | -$all_vrfs = $Admin->fetch_all_objects("vrf", "name"); |
|
11 | +$all_vrfs = $Admin->fetch_all_objects ("vrf", "name"); |
|
12 | 12 | |
13 | 13 | # fetch custom fields |
14 | -$custom = $Tools->fetch_custom_fields('vrf'); |
|
14 | +$custom = $Tools->fetch_custom_fields ('vrf'); |
|
15 | 15 | |
16 | 16 | # set hidden fields |
17 | -$hidden_fields = json_decode($User->settings->hiddenCustomFields, true); |
|
18 | -$hidden_fields = is_array(@$hidden_fields['vrf']) ? $hidden_fields['vrf'] : array(); |
|
17 | +$hidden_fields = json_decode ($User->settings->hiddenCustomFields, true); |
|
18 | +$hidden_fields = is_array (@$hidden_fields['vrf']) ? $hidden_fields['vrf'] : array (); |
|
19 | 19 | |
20 | 20 | # set size of custom fields |
21 | -$custom_size = sizeof($custom) - sizeof($hidden_fields); |
|
21 | +$custom_size = sizeof ($custom) - sizeof ($hidden_fields); |
|
22 | 22 | ?> |
23 | 23 | |
24 | -<h4><?php print _('Manage VRF'); ?></h4> |
|
24 | +<h4><?php print _ ('Manage VRF'); ?></h4> |
|
25 | 25 | <hr><br> |
26 | 26 | |
27 | 27 | <div class="btn-group"> |
28 | - <button class='btn btn-sm btn-default vrfManagement' data-action='add' data-vrfid='' style='margin-bottom:10px;'><i class='fa fa-plus'></i> <?php print _('Add VRF'); ?></button> |
|
28 | + <button class='btn btn-sm btn-default vrfManagement' data-action='add' data-vrfid='' style='margin-bottom:10px;'><i class='fa fa-plus'></i> <?php print _ ('Add VRF'); ?></button> |
|
29 | 29 | <?php |
30 | 30 | // snmp |
31 | - if($User->is_admin()===true && $User->settings->enableSNMP==1) { ?> |
|
32 | - <button class="btn btn-sm btn-default" id="snmp-vrf" data-action="add"><i class="fa fa-cogs"></i> <?php print _('Scan for VRFs'); ?></button> |
|
31 | + if ($User->is_admin () === true && $User->settings->enableSNMP == 1) { ?> |
|
32 | + <button class="btn btn-sm btn-default" id="snmp-vrf" data-action="add"><i class="fa fa-cogs"></i> <?php print _ ('Scan for VRFs'); ?></button> |
|
33 | 33 | <?php } ?> |
34 | 34 | |
35 | 35 | </div> |
@@ -38,26 +38,26 @@ discard block |
||
38 | 38 | <?php |
39 | 39 | |
40 | 40 | # first check if they exist! |
41 | -if($all_vrfs===false) { $Result->show("info", _("No VRFs configured")."!", false);} |
|
41 | +if ($all_vrfs === false) { $Result->show ("info", _ ("No VRFs configured")."!", false); } |
|
42 | 42 | else { |
43 | - print '<table id="vrfManagement" class="table sorted table-striped table-top table-hover">'. "\n"; |
|
43 | + print '<table id="vrfManagement" class="table sorted table-striped table-top table-hover">'."\n"; |
|
44 | 44 | |
45 | 45 | # headers |
46 | 46 | print "<thead>"; |
47 | - print '<tr>'. "\n"; |
|
48 | - print ' <th>'._('Name').'</th>'. "\n"; |
|
49 | - print ' <th>'._('RD').'</th>'. "\n"; |
|
50 | - print ' <th>'._('Sections').'</th>'. "\n"; |
|
51 | - print ' <th>'._('Description').'</th>'. "\n"; |
|
52 | - if(sizeof($custom) > 0) { |
|
53 | - foreach($custom as $field) { |
|
54 | - if(!in_array($field['name'], $hidden_fields)) { |
|
47 | + print '<tr>'."\n"; |
|
48 | + print ' <th>'._ ('Name').'</th>'."\n"; |
|
49 | + print ' <th>'._ ('RD').'</th>'."\n"; |
|
50 | + print ' <th>'._ ('Sections').'</th>'."\n"; |
|
51 | + print ' <th>'._ ('Description').'</th>'."\n"; |
|
52 | + if (sizeof ($custom) > 0) { |
|
53 | + foreach ($custom as $field) { |
|
54 | + if (!in_array ($field['name'], $hidden_fields)) { |
|
55 | 55 | print "<th class='customField hidden-xs hidden-sm'>$field[name]</th>"; |
56 | 56 | } |
57 | 57 | } |
58 | 58 | } |
59 | - print ' <th></th>'. "\n"; |
|
60 | - print '</tr>'. "\n"; |
|
59 | + print ' <th></th>'."\n"; |
|
60 | + print '</tr>'."\n"; |
|
61 | 61 | print "</thead>"; |
62 | 62 | |
63 | 63 | print "<tbody>"; |
@@ -67,33 +67,33 @@ discard block |
||
67 | 67 | $vrf = (array) $vrf; |
68 | 68 | |
69 | 69 | // format sections |
70 | - if(strlen($vrf['sections'])==0) { |
|
70 | + if (strlen ($vrf['sections']) == 0) { |
|
71 | 71 | $sections = "All sections"; |
72 | 72 | } |
73 | 73 | else { |
74 | 74 | //explode |
75 | 75 | unset($sec); |
76 | - $sections_tmp = explode(";", $vrf['sections']); |
|
77 | - foreach($sections_tmp as $t) { |
|
76 | + $sections_tmp = explode (";", $vrf['sections']); |
|
77 | + foreach ($sections_tmp as $t) { |
|
78 | 78 | //fetch section |
79 | - $tmp_section = $Sections->fetch_section(null, $t); |
|
79 | + $tmp_section = $Sections->fetch_section (null, $t); |
|
80 | 80 | $sec[] = " · ".$tmp_section->name; |
81 | 81 | } |
82 | 82 | //implode |
83 | - $sections = implode("<br>", $sec); |
|
83 | + $sections = implode ("<br>", $sec); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | //print details |
87 | - print '<tr class="text-top">'. "\n"; |
|
88 | - print ' <td class="name">'. $vrf['name'] .'</td>'. "\n"; |
|
89 | - print ' <td class="rd">'. $vrf['rd'] .'</td>'. "\n"; |
|
87 | + print '<tr class="text-top">'."\n"; |
|
88 | + print ' <td class="name">'.$vrf['name'].'</td>'."\n"; |
|
89 | + print ' <td class="rd">'.$vrf['rd'].'</td>'."\n"; |
|
90 | 90 | print " <td><span class='text-muted'>$sections</span></td>"; |
91 | - print ' <td class="description">'. $vrf['description'] .'</td>'. "\n"; |
|
91 | + print ' <td class="description">'.$vrf['description'].'</td>'."\n"; |
|
92 | 92 | |
93 | 93 | // custom fields |
94 | - if(sizeof($custom) > 0) { |
|
95 | - foreach($custom as $field) { |
|
96 | - if(!in_array($field['name'], $hidden_fields)) { |
|
94 | + if (sizeof ($custom) > 0) { |
|
95 | + foreach ($custom as $field) { |
|
96 | + if (!in_array ($field['name'], $hidden_fields)) { |
|
97 | 97 | |
98 | 98 | print "<td class='customField hidden-xs hidden-sm'>"; |
99 | 99 | |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | $vrf[$field['name']] = $Result->create_links ($vrf[$field['name']], $field['type']); |
102 | 102 | |
103 | 103 | //booleans |
104 | - if($field['type']=="tinyint(1)") { |
|
105 | - if($vrf[$field['name']] == "0") { print _("No"); } |
|
106 | - elseif($vrf[$field['name']] == "1") { print _("Yes"); } |
|
104 | + if ($field['type'] == "tinyint(1)") { |
|
105 | + if ($vrf[$field['name']] == "0") { print _ ("No"); } |
|
106 | + elseif ($vrf[$field['name']] == "1") { print _ ("Yes"); } |
|
107 | 107 | } |
108 | 108 | //text |
109 | - elseif($field['type']=="text") { |
|
110 | - if(strlen($vrf[$field['name']])>0) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $vrf[$field['name']])."'>"; } |
|
111 | - else { print ""; } |
|
109 | + elseif ($field['type'] == "text") { |
|
110 | + if (strlen ($vrf[$field['name']]) > 0) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace ("\n", "<br>", $vrf[$field['name']])."'>"; } |
|
111 | + else { print ""; } |
|
112 | 112 | } |
113 | 113 | else { |
114 | 114 | print $vrf[$field['name']]; |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | print " <button class='btn btn-xs btn-default vrfManagement' data-action='delete' data-vrfid='$vrf[vrfId]'><i class='fa fa-times'></i></button>"; |
126 | 126 | print " </div>"; |
127 | 127 | print " </td>"; |
128 | - print '</tr>'. "\n"; |
|
128 | + print '</tr>'."\n"; |
|
129 | 129 | } |
130 | 130 | print "</tbody>"; |
131 | - print '</table>'. "\n"; |
|
131 | + print '</table>'."\n"; |
|
132 | 132 | } |
133 | 133 | ?> |
134 | 134 |
@@ -5,45 +5,45 @@ discard block |
||
5 | 5 | *******************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # fake error |
21 | 21 | print "<div class='alert-danger hidden'></div>"; |
22 | 22 | |
23 | 23 | # scan disabled |
24 | -if ($User->settings->enableSNMP!="1") { $Result->show("danger", _("SNMP module disbled"), true); } |
|
24 | +if ($User->settings->enableSNMP != "1") { $Result->show ("danger", _ ("SNMP module disbled"), true); } |
|
25 | 25 | # admin check |
26 | -if($User->is_admin()!==true) { $Result->show("danger", _('Admin privileges required'), true); } |
|
26 | +if ($User->is_admin () !== true) { $Result->show ("danger", _ ('Admin privileges required'), true); } |
|
27 | 27 | |
28 | 28 | # set class |
29 | 29 | $Snmp = new phpipamSNMP (); |
30 | 30 | |
31 | 31 | # get existing vrfs |
32 | 32 | $existing_vrfs = $Tools->fetch_all_objects ("vrf", "vrfId"); |
33 | -if ($existing_vrfs!==false) { |
|
33 | +if ($existing_vrfs !== false) { |
|
34 | 34 | foreach ($existing_vrfs as $v) { |
35 | 35 | $ex_vrfs[$v->name] = $v->rd; |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | 39 | // no errors |
40 | -error_reporting(E_ERROR); |
|
40 | +error_reporting (E_ERROR); |
|
41 | 41 | |
42 | 42 | # set devices |
43 | 43 | foreach ($_POST as $k=>$p) { |
44 | - if (strpos($k, "device-")!==false) { |
|
44 | + if (strpos ($k, "device-") !== false) { |
|
45 | 45 | # fetch device |
46 | - $device = $Tools->fetch_object ("devices", "id", str_replace("device-", "", $k)); |
|
46 | + $device = $Tools->fetch_object ("devices", "id", str_replace ("device-", "", $k)); |
|
47 | 47 | if ($device !== false) { |
48 | 48 | $scan_devices[] = $device; |
49 | 49 | } |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | // if none set die |
54 | -if (!isset($scan_devices)) { $Result->show("danger", _("No devices for SNMP VRF query available"), true); } |
|
54 | +if (!isset($scan_devices)) { $Result->show ("danger", _ ("No devices for SNMP VRF query available"), true); } |
|
55 | 55 | |
56 | 56 | // init result array |
57 | -$new_vrfs = array(); |
|
57 | +$new_vrfs = array (); |
|
58 | 58 | |
59 | 59 | // ok, we have devices, connect to each device and do query |
60 | 60 | foreach ($scan_devices as $d) { |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | $Snmp->set_snmp_device ($d); |
63 | 63 | // fetch arp table |
64 | 64 | try { |
65 | - $res = $Snmp->get_query("get_vrf_table"); |
|
65 | + $res = $Snmp->get_query ("get_vrf_table"); |
|
66 | 66 | // remove those not in subnet |
67 | - if (sizeof($res)>0) { |
|
67 | + if (sizeof ($res) > 0) { |
|
68 | 68 | // save for debug |
69 | 69 | $debug[$d->hostname]["get_vrf_table"] = $res; |
70 | 70 | // loop and save |
71 | 71 | foreach ($res as $k=>$r) { |
72 | - if (!array_key_exists($k, $new_vrfs) && !array_key_exists($k, $ex_vrfs) ) { |
|
72 | + if (!array_key_exists ($k, $new_vrfs) && !array_key_exists ($k, $ex_vrfs)) { |
|
73 | 73 | $new_vrfs[$k] = $r; |
74 | 74 | } |
75 | 75 | } |
@@ -77,31 +77,31 @@ discard block |
||
77 | 77 | } catch (Exception $e) { |
78 | 78 | // save for debug |
79 | 79 | $debug[$d->hostname]["get_vrf_table"] = $res; |
80 | - $errors[] = $e->getMessage(); |
|
80 | + $errors[] = $e->getMessage (); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | 84 | # none and errors |
85 | -if(sizeof($new_vrfs)==0 && isset($errors)) { |
|
86 | - $Result->show("info", _("No vrfs found"), false); |
|
87 | - $Result->show("warning", implode("<hr>", $errors), false); |
|
85 | +if (sizeof ($new_vrfs) == 0 && isset($errors)) { |
|
86 | + $Result->show ("info", _ ("No vrfs found"), false); |
|
87 | + $Result->show ("warning", implode ("<hr>", $errors), false); |
|
88 | 88 | } |
89 | 89 | # none |
90 | -elseif(sizeof($new_vrfs)==0) { $Result->show("info", _("No vrfs found")."!", false); } |
|
90 | +elseif (sizeof ($new_vrfs) == 0) { $Result->show ("info", _ ("No vrfs found")."!", false); } |
|
91 | 91 | # ok |
92 | 92 | else { |
93 | 93 | // fetch custom fields and check for required |
94 | 94 | $required_fields = $Tools->fetch_custom_fields ('vrf'); |
95 | - if($required_fields!==false) { |
|
95 | + if ($required_fields !== false) { |
|
96 | 96 | foreach ($required_fields as $k=>$f) { |
97 | - if ($f['Null']!="NO") { |
|
97 | + if ($f['Null'] != "NO") { |
|
98 | 98 | unset($required_fields[$k]); |
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | 103 | // calculate colspan |
104 | - $colspan = 4 + sizeof(@$required_fields); |
|
104 | + $colspan = 4 + sizeof (@$required_fields); |
|
105 | 105 | |
106 | 106 | |
107 | 107 | //form |
@@ -110,21 +110,21 @@ discard block |
||
110 | 110 | |
111 | 111 | // titles |
112 | 112 | print "<tr>"; |
113 | - print " <th>"._("Name")."</th>"; |
|
114 | - print " <th>"._("RD")."</th>"; |
|
115 | - print " <th>"._("Description")."</th>"; |
|
113 | + print " <th>"._ ("Name")."</th>"; |
|
114 | + print " <th>"._ ("RD")."</th>"; |
|
115 | + print " <th>"._ ("Description")."</th>"; |
|
116 | 116 | // custom |
117 | 117 | if (isset($required_fields)) { |
118 | 118 | foreach ($required_fields as $field) { |
119 | - print "<th>"._($field['name'])."</th>"; |
|
119 | + print "<th>"._ ($field['name'])."</th>"; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | print " <th></th>"; |
123 | 123 | print "</tr>"; |
124 | 124 | |
125 | 125 | // alive |
126 | - $m=0; |
|
127 | - foreach ($new_vrfs as $name=>$rd ) { |
|
126 | + $m = 0; |
|
127 | + foreach ($new_vrfs as $name=>$rd) { |
|
128 | 128 | print "<tr class='result$m'>"; |
129 | 129 | //name |
130 | 130 | print "<td>$name</td>"; |
@@ -141,28 +141,28 @@ discard block |
||
141 | 141 | if (isset($required_fields)) { |
142 | 142 | foreach ($required_fields as $field) { |
143 | 143 | # replace spaces with | |
144 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
144 | + $field['nameNew'] = str_replace (" ", "___", $field['name']); |
|
145 | 145 | |
146 | - print ' <td>'. "\n"; |
|
146 | + print ' <td>'."\n"; |
|
147 | 147 | |
148 | 148 | //set type |
149 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
149 | + if (substr ($field['type'], 0, 3) == "set" || substr ($field['type'], 0, 4) == "enum") { |
|
150 | 150 | //parse values |
151 | - $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
151 | + $tmp = substr ($field['type'], 0, 3) == "set" ? explode (",", str_replace (array ("set(", ")", "'"), "", $field['type'])) : explode (",", str_replace (array ("enum(", ")", "'"), "", $field['type'])); |
|
152 | 152 | //null |
153 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
153 | + if ($field['Null'] != "NO") { array_unshift ($tmp, ""); } |
|
154 | 154 | |
155 | 155 | print "<select name='$field[nameNew]$m' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
156 | - foreach($tmp as $v) { |
|
157 | - if($v==@$address[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
158 | - else { print "<option value='$v'>$v</option>"; } |
|
156 | + foreach ($tmp as $v) { |
|
157 | + if ($v == @$address[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
158 | + else { print "<option value='$v'>$v</option>"; } |
|
159 | 159 | } |
160 | 160 | print "</select>"; |
161 | 161 | } |
162 | 162 | //date and time picker |
163 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
163 | + elseif ($field['type'] == "date" || $field['type'] == "datetime") { |
|
164 | 164 | // just for first |
165 | - if($timeP==0) { |
|
165 | + if ($timeP == 0) { |
|
166 | 166 | print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
167 | 167 | print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
168 | 168 | print '<script type="text/javascript">'; |
@@ -178,30 +178,30 @@ discard block |
||
178 | 178 | $timeP++; |
179 | 179 | |
180 | 180 | //set size |
181 | - if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
182 | - else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
181 | + if ($field['type'] == "date") { $size = 10; $class = 'datepicker'; $format = "yyyy-MM-dd"; } |
|
182 | + else { $size = 19; $class = 'datetimepicker'; $format = "yyyy-MM-dd"; } |
|
183 | 183 | |
184 | 184 | //field |
185 | - if(!isset($address[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'].$m .'" maxlength="'.$size.'" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
186 | - else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'].$m .'" maxlength="'.$size.'" value="'. $address[$field['name']]. '" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
185 | + if (!isset($address[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$field['nameNew'].$m.'" maxlength="'.$size.'" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; } |
|
186 | + else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$field['nameNew'].$m.'" maxlength="'.$size.'" value="'.$address[$field['name']].'" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; } |
|
187 | 187 | } |
188 | 188 | //boolean |
189 | - elseif($field['type'] == "tinyint(1)") { |
|
189 | + elseif ($field['type'] == "tinyint(1)") { |
|
190 | 190 | print "<select name='$field[nameNew]$m' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
191 | - $tmp = array(0=>"No",1=>"Yes"); |
|
191 | + $tmp = array (0=>"No", 1=>"Yes"); |
|
192 | 192 | //null |
193 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
193 | + if ($field['Null'] != "NO") { $tmp[2] = ""; } |
|
194 | 194 | |
195 | - foreach($tmp as $k=>$v) { |
|
196 | - if(strlen(@$address[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
197 | - elseif($k==@$address[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
198 | - else { print "<option value='$k'>"._($v)."</option>"; } |
|
195 | + foreach ($tmp as $k=>$v) { |
|
196 | + if (strlen (@$address[$field['name']]) == 0 && $k == 2) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; } |
|
197 | + elseif ($k == @$address[$field['name']]) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; } |
|
198 | + else { print "<option value='$k'>"._ ($v)."</option>"; } |
|
199 | 199 | } |
200 | 200 | print "</select>"; |
201 | 201 | } |
202 | 202 | //default - input field |
203 | 203 | else { |
204 | - print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'].$m .'" placeholder="'. $field['name'] .'" value="'. @$address[$field['name']]. '" size="30" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
204 | + print ' <input type="text" class="ip_addr form-control input-sm" name="'.$field['nameNew'].$m.'" placeholder="'.$field['name'].'" value="'.@$address[$field['name']].'" size="30" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | print " </td>"; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | print "<tr>"; |
219 | 219 | print " <td colspan='$colspan'>"; |
220 | 220 | print " <div id='vrfScanAddResult'></div>"; |
221 | - print " <a href='' class='btn btn-sm btn-success pull-right' id='saveVrfScanResults'><i class='fa fa-plus'></i> "._("Add discovered vrfs")."</a>"; |
|
221 | + print " <a href='' class='btn btn-sm btn-success pull-right' id='saveVrfScanResults'><i class='fa fa-plus'></i> "._ ("Add discovered vrfs")."</a>"; |
|
222 | 222 | print " </td>"; |
223 | 223 | print "</tr>"; |
224 | 224 | |
@@ -246,5 +246,5 @@ discard block |
||
246 | 246 | print "</div>"; |
247 | 247 | |
248 | 248 | # show debug? |
249 | -if($_POST['debug']==1) { print "<pre>"; print_r($debug); print "</pre>"; } |
|
249 | +if ($_POST['debug'] == 1) { print "<pre>"; print_r ($debug); print "</pre>"; } |
|
250 | 250 | ?> |
251 | 251 | \ No newline at end of file |
@@ -4,58 +4,58 @@ discard block |
||
4 | 4 | *******************************/ |
5 | 5 | |
6 | 6 | /* functions */ |
7 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
7 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
8 | 8 | |
9 | 9 | # initialize user object |
10 | -$Database = new Database_PDO; |
|
11 | -$User = new User ($Database); |
|
10 | +$Database = new Database_PDO; |
|
11 | +$User = new User ($Database); |
|
12 | 12 | $Admin = new Admin ($Database); |
13 | 13 | $Subnets = new Subnets ($Database); |
14 | -$Addresses = new Addresses ($Database); |
|
15 | -$Tools = new Tools ($Database); |
|
14 | +$Addresses = new Addresses ($Database); |
|
15 | +$Tools = new Tools ($Database); |
|
16 | 16 | $Result = new Result (); |
17 | 17 | |
18 | 18 | # verify that user is logged in |
19 | -$User->check_user_session(); |
|
19 | +$User->check_user_session (); |
|
20 | 20 | |
21 | 21 | # check for number of input values |
22 | -$max = ini_get("max_input_vars"); |
|
23 | -if(sizeof($_POST)>=ini_get("max_input_vars")) { $Result->show("danger", _("Number of discovered hosts exceed maximum possible defined by php.ini - set to ")." $max <hr>"._("Please adjust your php.ini settings for value `max_input_vars`"), true); } |
|
22 | +$max = ini_get ("max_input_vars"); |
|
23 | +if (sizeof ($_POST) >= ini_get ("max_input_vars")) { $Result->show ("danger", _ ("Number of discovered hosts exceed maximum possible defined by php.ini - set to ")." $max <hr>"._ ("Please adjust your php.ini settings for value `max_input_vars`"), true); } |
|
24 | 24 | |
25 | 25 | // fetch custom fields and check for required |
26 | 26 | $required_fields = $Tools->fetch_custom_fields ('vrf'); |
27 | -if($required_fields!==false) { |
|
27 | +if ($required_fields !== false) { |
|
28 | 28 | foreach ($required_fields as $k=>$f) { |
29 | - if ($f['Null']!="NO") { |
|
29 | + if ($f['Null'] != "NO") { |
|
30 | 30 | unset($required_fields[$k]); |
31 | 31 | } |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | 35 | # ok, lets get results form post array! |
36 | -foreach($_POST as $key=>$line) { |
|
36 | +foreach ($_POST as $key=>$line) { |
|
37 | 37 | // IP address |
38 | - if(substr($key, 0,2)=="rd") { $res[substr($key, 2)]['rd'] = $line; } |
|
38 | + if (substr ($key, 0, 2) == "rd") { $res[substr ($key, 2)]['rd'] = $line; } |
|
39 | 39 | // mac |
40 | - elseif(substr($key, 0,4)=="name") { $res[substr($key, 4)]['name'] = $line; } |
|
40 | + elseif (substr ($key, 0, 4) == "name") { $res[substr ($key, 4)]['name'] = $line; } |
|
41 | 41 | // description |
42 | - elseif(substr($key, 0,11)=="description") { $res[substr($key, 11)]['description'] = $line; } |
|
42 | + elseif (substr ($key, 0, 11) == "description") { $res[substr ($key, 11)]['description'] = $line; } |
|
43 | 43 | // custom fields |
44 | 44 | elseif (isset($required_fields)) { |
45 | 45 | foreach ($required_fields as $k=>$f) { |
46 | - if((strpos($key, $f['name'])) !== false) { |
|
47 | - { $res[substr($key, strlen($f['name']))][$f['name']] = $line; } |
|
46 | + if ((strpos ($key, $f['name'])) !== false) { |
|
47 | + { $res[substr ($key, strlen ($f['name']))][$f['name']] = $line; } |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | 53 | # insert entries |
54 | -if(sizeof($res)>0) { |
|
54 | +if (sizeof ($res) > 0) { |
|
55 | 55 | $errors = 0; |
56 | - foreach($res as $r) { |
|
56 | + foreach ($res as $r) { |
|
57 | 57 | # set insert values |
58 | - $values = array("rd"=>$r['rd'], |
|
58 | + $values = array ("rd"=>$r['rd'], |
|
59 | 59 | "name"=>$r['name'], |
60 | 60 | "description"=>$r['description'] |
61 | 61 | ); |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | } |
67 | 67 | } |
68 | 68 | # insert vrfs |
69 | - if(!$Admin->object_modify("vrf", "add", "vrfId", $values)) { $Result->show("danger", _("Failed to import entry")." ".$r['number']." ".$r['name'], false); $errors++; } |
|
69 | + if (!$Admin->object_modify ("vrf", "add", "vrfId", $values)) { $Result->show ("danger", _ ("Failed to import entry")." ".$r['number']." ".$r['name'], false); $errors++; } |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | # success if no errors |
73 | - if($errors==0) { $Result->show("success", _("Scan results added to database")."!", true); } |
|
73 | + if ($errors == 0) { $Result->show ("success", _ ("Scan results added to database")."!", true); } |
|
74 | 74 | } |
75 | 75 | # error |
76 | -else { $Result->show("danger", _("No entries available"), true); } |
|
76 | +else { $Result->show ("danger", _ ("No entries available"), true); } |
|
77 | 77 | ?> |
78 | 78 | \ No newline at end of file |
@@ -5,44 +5,44 @@ discard block |
||
5 | 5 | *************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # scan disabled |
21 | -if ($User->settings->enableSNMP!="1") { $Result->show("danger", _("SNMP module disbled"), true, true); } |
|
21 | +if ($User->settings->enableSNMP != "1") { $Result->show ("danger", _ ("SNMP module disbled"), true, true); } |
|
22 | 22 | # admin check |
23 | -if($User->is_admin()!==true) { $Result->show("danger", _('Admin privileges required'), true, true); } |
|
23 | +if ($User->is_admin () !== true) { $Result->show ("danger", _ ('Admin privileges required'), true, true); } |
|
24 | 24 | |
25 | 25 | # fetch devices that use get_routing_table query |
26 | 26 | $scan_devices = $Tools->fetch_multiple_objects ("devices", "snmp_queries", "%get_vrf_table%", "id", true, true); |
27 | 27 | |
28 | 28 | // if none set die |
29 | -if ($scan_devices===false) { $Result->show("danger", _("No devices for SNMP VRF query available"), true, true); } |
|
29 | +if ($scan_devices === false) { $Result->show ("danger", _ ("No devices for SNMP VRF query available"), true, true); } |
|
30 | 30 | |
31 | 31 | ?> |
32 | 32 | |
33 | 33 | <!-- header --> |
34 | -<div class='pHeader'><?php print _("Select devices"); ?></div> |
|
34 | +<div class='pHeader'><?php print _ ("Select devices"); ?></div> |
|
35 | 35 | |
36 | 36 | <!-- content --> |
37 | 37 | <div class='pContent'> |
38 | - <h4><?php print _("Select devices to query VRF table from"); ?></h4><hr> |
|
38 | + <h4><?php print _ ("Select devices to query VRF table from"); ?></h4><hr> |
|
39 | 39 | |
40 | 40 | <div style="padding: 20px;"> |
41 | 41 | <form name="select-devices" id="select-devices-vrf-scan"> |
42 | 42 | <?php |
43 | 43 | // loop |
44 | 44 | foreach ($scan_devices as $d) { |
45 | - $description = strlen($d->description)>0 ? "<span class='text-muted'>$d->description</span>" : ""; |
|
45 | + $description = strlen ($d->description) > 0 ? "<span class='text-muted'>$d->description</span>" : ""; |
|
46 | 46 | print " <input type='checkbox' name='device-$d->id' checked> $d->hostname ($d->ip_addr) $description<br>"; |
47 | 47 | } |
48 | 48 | ?> |
@@ -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-success show-vrf-scan-result"><?php print _('Scan'); ?></button> |
|
60 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
61 | + <button class="btn btn-sm btn-success show-vrf-scan-result"><?php print _ ('Scan'); ?></button> |
|
62 | 62 | |
63 | 63 | </div> |
64 | 64 | </div> |
65 | 65 | \ No newline at end of file |
@@ -5,22 +5,22 @@ discard block |
||
5 | 5 | **************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Result = new Result (); |
15 | 15 | |
16 | 16 | # verify that user is logged in |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # validate csrf cookie |
20 | -$User->csrf_cookie ("validate", "mail", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; |
|
20 | +$User->csrf_cookie ("validate", "mail", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : ""; |
|
21 | 21 | |
22 | 22 | # set update query |
23 | -$values = array("id"=>1, |
|
23 | +$values = array ("id"=>1, |
|
24 | 24 | "mtype"=>$_POST['mtype'], |
25 | 25 | "msecure"=>@$_POST['msecure'], |
26 | 26 | "mauth"=>@$_POST['mauth'], |
@@ -33,6 +33,6 @@ discard block |
||
33 | 33 | ); |
34 | 34 | |
35 | 35 | # update |
36 | -if(!$Admin->object_modify("settingsMail", "edit", "id", $values)) { $Result->show("danger", _('Cannot update settings').'!', true); } |
|
37 | -else { $Result->show("success", _('Settings updated successfully')."!", true); } |
|
36 | +if (!$Admin->object_modify ("settingsMail", "edit", "id", $values)) { $Result->show ("danger", _ ('Cannot update settings').'!', true); } |
|
37 | +else { $Result->show ("success", _ ('Settings updated successfully')."!", true); } |
|
38 | 38 | ?> |
39 | 39 | \ No newline at end of file |
@@ -5,56 +5,56 @@ |
||
5 | 5 | **************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Result = new Result (); |
15 | 15 | |
16 | 16 | # verify that user is logged in |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # fetch mailer settings |
20 | -$mail_settings = $Admin->fetch_object("settingsMail", "id", 1); |
|
20 | +$mail_settings = $Admin->fetch_object ("settingsMail", "id", 1); |
|
21 | 21 | |
22 | 22 | # verify admin mail and name |
23 | -if (strlen($mail_settings->mAdminMail)==0 || strlen($mail_settings->mAdminName)==0) { |
|
24 | - $Result->show("danger", _("Mail settings are missing. Please set admin mail and name!"), true); |
|
23 | +if (strlen ($mail_settings->mAdminMail) == 0 || strlen ($mail_settings->mAdminName) == 0) { |
|
24 | + $Result->show ("danger", _ ("Mail settings are missing. Please set admin mail and name!"), true); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | 28 | # initialize mailer |
29 | -$phpipam_mail = new phpipam_mail($User->settings, $mail_settings); |
|
29 | +$phpipam_mail = new phpipam_mail ($User->settings, $mail_settings); |
|
30 | 30 | //override settings |
31 | -$phpipam_mail->override_settings($_POST); |
|
31 | +$phpipam_mail->override_settings ($_POST); |
|
32 | 32 | //create object |
33 | -$phpipam_mail->initialize_mailer(); |
|
33 | +$phpipam_mail->initialize_mailer (); |
|
34 | 34 | //debugging |
35 | -$phpipam_mail->set_debugging(2); |
|
35 | +$phpipam_mail->set_debugging (2); |
|
36 | 36 | |
37 | 37 | |
38 | 38 | # set content |
39 | -$content = $phpipam_mail->generate_message ("phpIPAM test HTML message"); |
|
40 | -$content_plain = "phpIPAM test text message"; |
|
39 | +$content = $phpipam_mail->generate_message ("phpIPAM test HTML message"); |
|
40 | +$content_plain = "phpIPAM test text message"; |
|
41 | 41 | |
42 | 42 | |
43 | 43 | # try to send |
44 | 44 | try { |
45 | - $phpipam_mail->Php_mailer->setFrom($_POST['mAdminMail'], $_POST['mAdminName']); |
|
46 | - $phpipam_mail->Php_mailer->addAddress($User->settings->siteAdminMail, $User->settings->siteAdminName); |
|
45 | + $phpipam_mail->Php_mailer->setFrom ($_POST['mAdminMail'], $_POST['mAdminName']); |
|
46 | + $phpipam_mail->Php_mailer->addAddress ($User->settings->siteAdminMail, $User->settings->siteAdminName); |
|
47 | 47 | $phpipam_mail->Php_mailer->Subject = 'phpIPAM localhost mail test'; |
48 | - $phpipam_mail->Php_mailer->msgHTML($content); |
|
48 | + $phpipam_mail->Php_mailer->msgHTML ($content); |
|
49 | 49 | $phpipam_mail->Php_mailer->AltBody = $content_plain; |
50 | 50 | //send |
51 | - $phpipam_mail->Php_mailer->send(); |
|
51 | + $phpipam_mail->Php_mailer->send (); |
|
52 | 52 | } catch (phpmailerException $e) { |
53 | - $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
53 | + $Result->show ("danger", "Mailer Error: ".$e->errorMessage (), true); |
|
54 | 54 | } catch (Exception $e) { |
55 | - $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
55 | + $Result->show ("danger", "Mailer Error: ".$e->errorMessage (), true); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | //if error not sent print ok |
59 | -$Result->show("success alert-absolute", "Message sent to site admin (".$User->settings->siteAdminMail.")!", true); |
|
59 | +$Result->show ("success alert-absolute", "Message sent to site admin (".$User->settings->siteAdminMail.")!", true); |
|
60 | 60 | ?> |
61 | 61 | \ No newline at end of file |