44 |
44 |
require("guiconfig.inc");
|
45 |
45 |
require_once("functions.inc");
|
46 |
46 |
|
47 |
|
$pgtitle = array(gettext("Interfaces"),gettext("Groups"),gettext("Edit"));
|
|
47 |
$pgtitle = array(gettext("Interfaces"),gettext("Groups"),gettext("Interface Group Edit"));
|
48 |
48 |
$shortcut_section = "interfaces";
|
49 |
49 |
|
50 |
|
if (!is_array($config['ifgroups']['ifgroupentry']))
|
|
50 |
if (!is_array($config['ifgroups']['ifgroupentry'])) {
|
51 |
51 |
$config['ifgroups']['ifgroupentry'] = array();
|
|
52 |
}
|
52 |
53 |
|
53 |
54 |
$a_ifgroups = &$config['ifgroups']['ifgroupentry'];
|
54 |
55 |
|
55 |
|
if (is_numericint($_GET['id']))
|
|
56 |
if (is_numericint($_GET['id'])){
|
56 |
57 |
$id = $_GET['id'];
|
57 |
|
if (isset($_POST['id']) && is_numericint($_POST['id']))
|
|
58 |
}
|
|
59 |
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
|
58 |
60 |
$id = $_POST['id'];
|
|
61 |
}
|
59 |
62 |
|
60 |
63 |
if (isset($id) && $a_ifgroups[$id]) {
|
61 |
64 |
$pconfig['ifname'] = $a_ifgroups[$id]['ifname'];
|
... | ... | |
63 |
66 |
$pconfig['descr'] = html_entity_decode($a_ifgroups[$id]['descr']);
|
64 |
67 |
}
|
65 |
68 |
|
66 |
|
$iflist = get_configured_interface_with_descr();
|
67 |
|
$iflist_disabled = get_configured_interface_with_descr(false, true);
|
|
69 |
$interface_list = get_configured_interface_with_descr();
|
|
70 |
$interface_list_disabled = get_configured_interface_with_descr(false, true);
|
68 |
71 |
|
69 |
72 |
if ($_POST) {
|
70 |
|
|
71 |
73 |
unset($input_errors);
|
72 |
74 |
$pconfig = $_POST;
|
73 |
75 |
|
74 |
76 |
if (!isset($id)) {
|
75 |
|
foreach ($a_ifgroups as $groupentry)
|
76 |
|
if ($groupentry['ifname'] == $_POST['ifname'])
|
|
77 |
foreach ($a_ifgroups as $group_entry)
|
|
78 |
if ($group_entry['ifname'] == $_POST['ifname'])
|
77 |
79 |
$input_errors[] = gettext("Group name already exists!");
|
78 |
80 |
}
|
79 |
|
if (preg_match("/([^a-zA-Z])+/", $_POST['ifname'], $match))
|
|
81 |
if (preg_match("/([^a-zA-Z])+/", $_POST['ifname'], $match)) {
|
80 |
82 |
$input_errors[] = gettext("Only letters A-Z are allowed as the group name.");
|
|
83 |
}
|
81 |
84 |
|
82 |
|
foreach ($iflist as $gif => $gdescr) {
|
|
85 |
/* chech if ifname is the same as an interface name */
|
|
86 |
foreach ($interface_list as $gif => $gdescr) {
|
83 |
87 |
if ($gdescr == $_POST['ifname'] || $gif == $_POST['ifname'])
|
84 |
88 |
$input_errors[] = "The specified group name is already used by an interface. Please choose another name.";
|
85 |
89 |
}
|
86 |
|
$members = "";
|
87 |
|
$isfirst = 0;
|
88 |
|
/* item is a normal ifgroupentry type */
|
89 |
|
for($x=0; $x<9999; $x++) {
|
90 |
|
if($_POST["members{$x}"] <> "") {
|
91 |
|
if ($isfirst > 0)
|
92 |
|
$members .= " ";
|
93 |
|
$members .= $_POST["members{$x}"];
|
94 |
|
$isfirst++;
|
95 |
|
}
|
96 |
|
}
|
|
90 |
|
|
91 |
$members = isset($_POST['members']) ? join(' ', $_POST['members']) : "";
|
97 |
92 |
|
98 |
93 |
if (!$input_errors) {
|
99 |
94 |
$ifgroupentry = array();
|
100 |
95 |
$ifgroupentry['members'] = $members;
|
101 |
96 |
$ifgroupentry['descr'] = $_POST['descr'];
|
102 |
97 |
|
|
98 |
// Edit group name
|
103 |
99 |
if (isset($id) && $a_ifgroups[$id] && $_POST['ifname'] != $a_ifgroups[$id]['ifname']) {
|
104 |
100 |
if (!empty($config['filter']) && is_array($config['filter']['rule'])) {
|
105 |
101 |
foreach ($config['filter']['rule'] as $ridx => $rule) {
|
... | ... | |
112 |
108 |
$rule_changed = true;
|
113 |
109 |
}
|
114 |
110 |
}
|
115 |
|
if ($rule_changed)
|
|
111 |
if ($rule_changed) {
|
116 |
112 |
$config['filter']['rule'][$ridx]['interface'] = implode(",", $rule_ifs);
|
|
113 |
}
|
117 |
114 |
} else {
|
118 |
|
if ($rule['interface'] == $a_ifgroups[$id]['ifname'])
|
|
115 |
if ($rule['interface'] == $a_ifgroups[$id]['ifname']) {
|
119 |
116 |
$config['filter']['rule'][$ridx]['interface'] = $_POST['ifname'];
|
|
117 |
}
|
120 |
118 |
}
|
121 |
119 |
}
|
122 |
120 |
}
|
123 |
121 |
if (!empty($config['nat']) && is_array($config['nat']['rule'])) {
|
124 |
122 |
foreach ($config['nat']['rule'] as $ridx => $rule) {
|
125 |
|
if ($rule['interface'] == $a_ifgroups[$id]['ifname'])
|
|
123 |
if ($rule['interface'] == $a_ifgroups[$id]['ifname']) {
|
126 |
124 |
$config['nat']['rule'][$ridx]['interface'] = $_POST['ifname'];
|
|
125 |
}
|
127 |
126 |
}
|
128 |
127 |
}
|
129 |
128 |
$omembers = explode(" ", $a_ifgroups[$id]['members']);
|
130 |
129 |
if (count($omembers) > 0) {
|
131 |
130 |
foreach ($omembers as $ifs) {
|
132 |
131 |
$realif = get_real_interface($ifs);
|
133 |
|
if ($realif)
|
|
132 |
if ($realif) {
|
134 |
133 |
mwexec("/sbin/ifconfig {$realif} -group " . $a_ifgroups[$id]['ifname']);
|
|
134 |
}
|
135 |
135 |
}
|
136 |
136 |
}
|
137 |
137 |
$ifgroupentry['ifname'] = $_POST['ifname'];
|
138 |
138 |
$a_ifgroups[$id] = $ifgroupentry;
|
|
139 |
|
|
140 |
// Edit old group
|
139 |
141 |
} else if (isset($id) && $a_ifgroups[$id]) {
|
140 |
142 |
$omembers = explode(" ", $a_ifgroups[$id]['members']);
|
141 |
143 |
$nmembers = explode(" ", $members);
|
... | ... | |
143 |
145 |
if (count($delmembers) > 0) {
|
144 |
146 |
foreach ($delmembers as $ifs) {
|
145 |
147 |
$realif = get_real_interface($ifs);
|
146 |
|
if ($realif)
|
|
148 |
if ($realif) {
|
147 |
149 |
mwexec("/sbin/ifconfig {$realif} -group " . $a_ifgroups[$id]['ifname']);
|
|
150 |
}
|
148 |
151 |
}
|
149 |
152 |
}
|
150 |
153 |
$ifgroupentry['ifname'] = $_POST['ifname'];
|
151 |
154 |
$a_ifgroups[$id] = $ifgroupentry;
|
|
155 |
|
|
156 |
// Create new group
|
152 |
157 |
} else {
|
153 |
158 |
$ifgroupentry['ifname'] = $_POST['ifname'];
|
154 |
159 |
$a_ifgroups[] = $ifgroupentry;
|
155 |
160 |
}
|
156 |
161 |
|
157 |
162 |
write_config();
|
158 |
|
|
159 |
163 |
interface_group_setup($ifgroupentry);
|
160 |
164 |
|
161 |
165 |
header("Location: interfaces_groups.php");
|
... | ... | |
168 |
172 |
|
169 |
173 |
include("head.inc");
|
170 |
174 |
|
171 |
|
?>
|
172 |
|
|
173 |
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
|
174 |
|
<?php include("fbegin.inc"); ?>
|
175 |
|
|
176 |
|
<script type="text/javascript">
|
177 |
|
//<![CDATA[
|
178 |
|
// Global Variables
|
179 |
|
var rowname = new Array(9999);
|
180 |
|
var rowtype = new Array(9999);
|
181 |
|
var newrow = new Array(9999);
|
182 |
|
var rowsize = new Array(9999);
|
183 |
|
|
184 |
|
for (i = 0; i < 9999; i++) {
|
185 |
|
rowname[i] = '';
|
186 |
|
rowtype[i] = 'select';
|
187 |
|
newrow[i] = '';
|
188 |
|
rowsize[i] = '30';
|
189 |
|
}
|
190 |
|
|
191 |
|
var field_counter_js = 0;
|
192 |
|
var loaded = 0;
|
193 |
|
var is_streaming_progress_bar = 0;
|
194 |
|
var temp_streaming_text = "";
|
195 |
|
|
196 |
|
var addRowTo = (function() {
|
197 |
|
return (function (tableId) {
|
198 |
|
var d, tbody, tr, td, bgc, i, ii, j;
|
199 |
|
d = document;
|
200 |
|
tbody = d.getElementById(tableId).getElementsByTagName("tbody").item(0);
|
201 |
|
tr = d.createElement("tr");
|
202 |
|
for (i = 0; i < field_counter_js; i++) {
|
203 |
|
td = d.createElement("td");
|
204 |
|
<?php
|
205 |
|
$innerHTML="\"<input type='hidden' value='\" + totalrows +\"' name='\" + rowname[i] + \"_row-\" + totalrows + \"' /><select size='1' name='\" + rowname[i] + totalrows + \"'>\" +\"";
|
206 |
|
|
207 |
|
foreach ($iflist as $ifnam => $ifdescr)
|
208 |
|
$innerHTML .= "<option value='{$ifnam}'>{$ifdescr}<\/option>";
|
209 |
|
$innerHTML .= "<\/select>\";";
|
210 |
|
?>
|
211 |
|
td.innerHTML=<?=$innerHTML;?>
|
212 |
|
tr.appendChild(td);
|
213 |
|
}
|
214 |
|
td = d.createElement("td");
|
215 |
|
td.rowSpan = "1";
|
216 |
|
|
217 |
|
td.innerHTML = '<a onclick="removeRow(this);return false;" href="#"><img border="0" src="/themes/' + theme + '/images/icons/icon_x.gif" alt="remove" /><\/a>';
|
218 |
|
tr.appendChild(td);
|
219 |
|
tbody.appendChild(tr);
|
220 |
|
totalrows++;
|
221 |
|
});
|
222 |
|
})();
|
223 |
|
|
224 |
|
function removeRow(el) {
|
225 |
|
var cel;
|
226 |
|
while (el && el.nodeName.toLowerCase() != "tr")
|
227 |
|
el = el.parentNode;
|
228 |
|
|
229 |
|
if (el && el.parentNode) {
|
230 |
|
cel = el.getElementsByTagName("td").item(0);
|
231 |
|
el.parentNode.removeChild(el);
|
232 |
|
}
|
|
175 |
if ($input_errors) {
|
|
176 |
print_input_errors($input_errors);
|
233 |
177 |
}
|
234 |
178 |
|
235 |
|
rowname[0] = "members";
|
236 |
|
rowtype[0] = "textbox";
|
237 |
|
rowsize[0] = "30";
|
238 |
|
|
239 |
|
rowname[2] = "detail";
|
240 |
|
rowtype[2] = "textbox";
|
241 |
|
rowsize[2] = "50";
|
242 |
|
//]]>
|
243 |
|
</script>
|
244 |
|
<input type='hidden' name='members_type' value='textbox' class="formfld unknown" />
|
245 |
|
|
246 |
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
|
179 |
?>
|
247 |
180 |
<div id="inputerrors"></div>
|
248 |
|
|
249 |
|
<form action="interfaces_groups_edit.php" method="post" name="iform" id="iform">
|
250 |
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces groups edit">
|
251 |
|
<tr>
|
252 |
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Interface Groups Edit");?></td>
|
253 |
|
</tr>
|
254 |
|
<tr>
|
255 |
|
<td valign="top" class="vncellreq"><?=gettext("Group Name");?></td>
|
256 |
|
<td class="vtable">
|
257 |
|
<input class="formfld unknown" name="ifname" id="ifname" maxlength="15" value="<?=htmlspecialchars($pconfig['ifname']);?>" />
|
258 |
|
<br />
|
259 |
|
<?=gettext("No numbers or spaces are allowed. Only characters in a-zA-Z");?>
|
260 |
|
</td>
|
261 |
|
</tr>
|
262 |
|
<tr>
|
263 |
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
|
264 |
|
<td width="78%" class="vtable">
|
265 |
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
|
266 |
|
<br />
|
267 |
|
<span class="vexpl">
|
268 |
|
<?=gettext("You may enter a description here for your reference (not parsed).");?>
|
269 |
|
</span>
|
270 |
|
</td>
|
271 |
|
</tr>
|
272 |
|
<tr>
|
273 |
|
<td width="22%" valign="top" class="vncellreq"><div id="membersnetworkport"><?=gettext("Member (s)");?></div></td>
|
274 |
|
<td width="78%" class="vtable">
|
275 |
|
<table id="maintable" summary="main table">
|
276 |
|
<tbody>
|
277 |
|
<tr>
|
278 |
|
<td><div id="onecolumn"><?=gettext("Interface");?></div></td>
|
279 |
|
</tr>
|
280 |
|
|
281 |
|
<?php
|
282 |
|
$counter = 0;
|
283 |
|
$members = $pconfig['members'];
|
284 |
|
if ($members <> "") {
|
285 |
|
$item = explode(" ", $members);
|
286 |
|
foreach($item as $ww) {
|
287 |
|
$members = $item[$counter];
|
288 |
|
$tracker = $counter;
|
289 |
|
?>
|
290 |
|
<tr>
|
291 |
|
<td class="vtable">
|
292 |
|
<select name="members<?php echo $tracker; ?>" class="formselect" id="members<?php echo $tracker; ?>">
|
293 |
|
<?php
|
294 |
|
$found = false;
|
295 |
|
foreach ($iflist as $ifnam => $ifdescr) {
|
296 |
|
echo "<option value=\"{$ifnam}\"";
|
297 |
|
if ($ifnam == $members) {
|
298 |
|
$found = true;
|
299 |
|
echo " selected=\"selected\"";
|
300 |
|
}
|
301 |
|
echo ">{$ifdescr}</option>";
|
302 |
|
}
|
303 |
|
|
304 |
|
if ($found === false)
|
305 |
|
foreach ($iflist_disabled as $ifnam => $ifdescr)
|
306 |
|
if ($ifnam == $members)
|
307 |
|
echo "<option value=\"{$ifnam}\" selected=\"selected\">{$ifdescr}</option>";
|
308 |
|
?>
|
309 |
|
</select>
|
310 |
|
</td>
|
311 |
|
<td>
|
312 |
|
<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" alt="remove" /></a>
|
313 |
|
</td>
|
314 |
|
</tr>
|
315 |
181 |
<?php
|
316 |
|
$counter++;
|
|
182 |
$tab_array = array();
|
|
183 |
$tab_array[0] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
|
|
184 |
$tab_array[1] = array(gettext("Interface Groups"), true, "interfaces_groups.php");
|
|
185 |
$tab_array[2] = array(gettext("Wireless"), false, "interfaces_wireless.php");
|
|
186 |
$tab_array[3] = array(gettext("VLANs"), false, "interfaces_vlan.php");
|
|
187 |
$tab_array[4] = array(gettext("QinQs"), false, "interfaces_qinq.php");
|
|
188 |
$tab_array[5] = array(gettext("PPPs"), false, "interfaces_ppps.php");
|
|
189 |
$tab_array[7] = array(gettext("GRE"), false, "interfaces_gre.php");
|
|
190 |
$tab_array[8] = array(gettext("GIF"), false, "interfaces_gif.php");
|
|
191 |
$tab_array[9] = array(gettext("Bridges"), false, "interfaces_bridge.php");
|
|
192 |
$tab_array[10] = array(gettext("LAGG"), false, "interfaces_lagg.php");
|
|
193 |
display_top_tabs($tab_array);
|
|
194 |
|
|
195 |
require('classes/Form.class.php');
|
|
196 |
$form = new Form;
|
|
197 |
$section = new Form_Section('Interface Group Edit');
|
|
198 |
|
|
199 |
$section->addInput(new Form_Input(
|
|
200 |
'ifname',
|
|
201 |
'Group Name',
|
|
202 |
'text',
|
|
203 |
$pconfig['ifname'],
|
|
204 |
['placeholder' => 'Group Name']
|
|
205 |
))->setWidth(6)->setHelp('No numbers or spaces are allowed. '.
|
|
206 |
'Only characters in a-zA-Z');
|
|
207 |
|
|
208 |
$section->addInput(new Form_Input(
|
|
209 |
'descr',
|
|
210 |
'Group Description',
|
|
211 |
'text',
|
|
212 |
$pconfig['descr'],
|
|
213 |
['placeholder' => 'Group Description']
|
|
214 |
))->setWidth(6)->setHelp('You may enter a group decsription '.
|
|
215 |
'here for your reference (not parsed)');
|
|
216 |
|
|
217 |
$section->addInput(new Form_Select(
|
|
218 |
'members[]',
|
|
219 |
'Group Members',
|
|
220 |
explode(' ', $pconfig['members']),
|
|
221 |
$interface_list,
|
|
222 |
true
|
|
223 |
))->setWidth(6)->setHelp('NOTE: Rules for WAN type '.
|
|
224 |
'interfaces in groups do not contain the reply-to mechanism upon which '.
|
|
225 |
'Multi-WAN typically relies. '.
|
|
226 |
'<a href="https://doc.pfsense.org/index.php/ifgroups">More Information</a>');
|
317 |
227 |
|
318 |
|
} // end foreach
|
319 |
|
} // end if
|
320 |
|
?>
|
321 |
|
</tbody>
|
322 |
|
</table>
|
323 |
|
<a onclick="javascript:addRowTo('maintable'); return false;" href="#">
|
324 |
|
<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
|
325 |
|
</a>
|
326 |
|
<br /><br />
|
327 |
|
<strong><?PHP echo gettext("NOTE:");?></strong>
|
328 |
|
<?PHP echo gettext("Rules for WAN type interfaces in groups do not contain the reply-to mechanism upon which Multi-WAN typically relies.");?>
|
329 |
|
<a href="https://doc.pfsense.org/index.php/Interface_Groups"><?PHP echo gettext("More Information");?></a>
|
330 |
|
</td>
|
331 |
|
</tr>
|
332 |
|
<tr>
|
333 |
|
<td width="22%" valign="top"> </td>
|
334 |
|
<td width="78%">
|
335 |
|
<input id="submit" name="submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
|
336 |
|
<a href="interfaces_groups.php"><input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="<?=gettext("Cancel");?>" /></a>
|
337 |
|
<?php if (isset($id) && $a_ifgroups[$id]): ?>
|
338 |
|
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
|
339 |
|
<?php endif; ?>
|
340 |
|
</td>
|
341 |
|
</tr>
|
342 |
|
</table>
|
343 |
|
</form>
|
344 |
|
|
345 |
|
<script type="text/javascript">
|
346 |
|
//<![CDATA[
|
347 |
|
field_counter_js = 1;
|
348 |
|
rows = 1;
|
349 |
|
totalrows = <?php echo $counter; ?>;
|
350 |
|
loaded = <?php echo $counter; ?>;
|
351 |
|
//]]>
|
352 |
|
</script>
|
|
228 |
if (isset($id) && $a_ifgroups[$id]) {
|
|
229 |
$form->addGlobal(new Form_Input(
|
|
230 |
'id',
|
|
231 |
'id',
|
|
232 |
'hidden',
|
|
233 |
$id
|
|
234 |
));
|
|
235 |
}
|
353 |
236 |
|
354 |
|
<?php
|
355 |
|
unset($iflist);
|
356 |
|
unset($iflist_disabled);
|
357 |
|
include("fend.inc");
|
|
237 |
$form->add($section);
|
|
238 |
print $form;
|
|
239 |
|
|
240 |
unset($interface_list);
|
|
241 |
unset($interface_list_disabled);
|
|
242 |
include("fend.inc");
|
358 |
243 |
?>
|
359 |
|
</body>
|
360 |
|
</html>
|
Initial commit for Interface > Interface Groups bootstrap convert