summaryrefslogtreecommitdiffstats
path: root/usr/local/www/interfaces_qinq_edit.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-05-13 13:06:17 +0545
committerPhil Davis <phil.davis@inf.org>2015-05-13 13:06:17 +0545
commit2af86dda298716d3e0b3f62fbc8a5ccc3e4fa840 (patch)
treeda8ebcd1d169f898d88c1d7dfe166caedb812a72 /usr/local/www/interfaces_qinq_edit.php
parentc8f7068d1aaccf4ca1d1f782704289e9519233dc (diff)
downloadpfsense-2af86dda298716d3e0b3f62fbc8a5ccc3e4fa840.zip
pfsense-2af86dda298716d3e0b3f62fbc8a5ccc3e4fa840.tar.gz
Code style interfaces miscellaneous files
Diffstat (limited to 'usr/local/www/interfaces_qinq_edit.php')
-rw-r--r--usr/local/www/interfaces_qinq_edit.php346
1 files changed, 185 insertions, 161 deletions
diff --git a/usr/local/www/interfaces_qinq_edit.php b/usr/local/www/interfaces_qinq_edit.php
index 085ab8d..4efe42b 100644
--- a/usr/local/www/interfaces_qinq_edit.php
+++ b/usr/local/www/interfaces_qinq_edit.php
@@ -28,7 +28,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
/*
- pfSense_BUILDER_BINARIES: /usr/sbin/ngctl
+ pfSense_BUILDER_BINARIES: /usr/sbin/ngctl
pfSense_MODULE: interfaces
*/
@@ -44,8 +44,9 @@ $shortcut_section = "interfaces";
require("guiconfig.inc");
-if (!is_array($config['qinqs']['qinqentry']))
+if (!is_array($config['qinqs']['qinqentry'])) {
$config['qinqs']['qinqentry'] = array();
+}
$a_qinqs = &$config['qinqs']['qinqentry'];
@@ -53,8 +54,9 @@ $portlist = get_interface_list();
/* add LAGG interfaces */
if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) {
- foreach ($config['laggs']['lagg'] as $lagg)
- $portlist[$lagg['laggif']] = $lagg;
+ foreach ($config['laggs']['lagg'] as $lagg) {
+ $portlist[$lagg['laggif']] = $lagg;
+ }
}
if (count($portlist) < 1) {
@@ -62,10 +64,12 @@ if (count($portlist) < 1) {
exit;
}
-if (is_numericint($_GET['id']))
+if (is_numericint($_GET['id'])) {
$id = $_GET['id'];
-if (isset($_POST['id']) && is_numericint($_POST['id']))
+}
+if (isset($_POST['id']) && is_numericint($_POST['id'])) {
$id = $_POST['id'];
+}
if (isset($id) && $a_qinqs[$id]) {
$pconfig['if'] = $a_qinqs[$id]['if'];
@@ -85,20 +89,27 @@ if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
- if (empty($_POST['tag']))
+ if (empty($_POST['tag'])) {
$input_errors[] = gettext("First level tag cannot be empty.");
- if (isset($id) && $a_qinqs[$id]['tag'] != $_POST['tag'])
+ }
+ if (isset($id) && $a_qinqs[$id]['tag'] != $_POST['tag']) {
$input_errors[] = gettext("You are editing an existing entry and modifying the first level tag is not allowed.");
- if (isset($id) && $a_qinqs[$id]['if'] != $_POST['if'])
+ }
+ if (isset($id) && $a_qinqs[$id]['if'] != $_POST['if']) {
$input_errors[] = gettext("You are editing an existing entry and modifying the interface is not allowed.");
+ }
if (!isset($id)) {
- foreach ($a_qinqs as $qinqentry)
- if ($qinqentry['tag'] == $_POST['tag'] && $qinqentry['if'] == $_POST['if'])
+ foreach ($a_qinqs as $qinqentry) {
+ if ($qinqentry['tag'] == $_POST['tag'] && $qinqentry['if'] == $_POST['if']) {
$input_errors[] = gettext("QinQ level already exists for this interface, edit it!");
+ }
+ }
if (is_array($config['vlans']['vlan'])) {
- foreach ($config['vlans']['vlan'] as $vlan)
- if ($vlan['tag'] == $_POST['tag'] && $vlan['if'] == $_POST['if'])
+ foreach ($config['vlans']['vlan'] as $vlan) {
+ if ($vlan['tag'] == $_POST['tag'] && $vlan['if'] == $_POST['if']) {
$input_errors[] = gettext("A normal VLAN exists with this tag please remove it to use this tag for QinQ first level.");
+ }
+ }
}
}
@@ -106,39 +117,47 @@ if ($_POST) {
$qinqentry['if'] = $_POST['if'];
$qinqentry['tag'] = $_POST['tag'];
/*
- if ($_POST['autoassign'] == "yes") {
+ if ($_POST['autoassign'] == "yes") { {
$qinqentry['autoassign'] = true;
- if ($_POST['autoenable'] == "yes")
+ }
+ if ($_POST['autoenable'] == "yes") {
$qinqentry['autoenable'] = true;
- if ($_POST['autoadjust'] == "yes")
+ }
+ if ($_POST['autoadjust'] == "yes") {
$qinqentry['autoadjustmtu'] = true;
+ }
*/
- if ($_POST['autogroup'] == "yes")
+ if ($_POST['autogroup'] == "yes") {
$qinqentry['autogroup'] = true;
+ }
$members = "";
$isfirst = 0;
/* item is a normal qinqentry type */
- for($x=0; $x<9999; $x++) {
- if($_POST["members{$x}"] <> "") {
+ for ($x=0; $x<9999; $x++) {
+ if ($_POST["members{$x}"] <> "") {
$member = explode("-", $_POST["members{$x}"]);
if (count($member) > 1) {
if (preg_match("/([^0-9])+/", $member[0], $match) ||
- preg_match("/([^0-9])+/", $member[1], $match))
+ preg_match("/([^0-9])+/", $member[1], $match)) {
$input_errors[] = gettext("Tags can contain only numbers or a range in format #-#.");
+ }
for ($i = $member[0]; $i <= $member[1]; $i++) {
- if ($isfirst > 0)
+ if ($isfirst > 0) {
$members .= " ";
+ }
$members .= $i;
$isfirst++;
}
} else {
- if (preg_match("/([^0-9])+/", $_POST["members{$x}"], $match))
+ if (preg_match("/([^0-9])+/", $_POST["members{$x}"], $match)) {
$input_errors[] = gettext("Tags can contain only numbers or a range in format #-#.");
+ }
- if ($isfirst > 0)
+ if ($isfirst > 0) {
$members .= " ";
+ }
$members .= $_POST["members{$x}"];
$isfirst++;
}
@@ -180,8 +199,9 @@ if ($_POST) {
$a_qinqs[] = $qinqentry;
}
if ($_POST['autogroup'] == "yes") {
- if (!is_array($config['ifgroups']['ifgroupentry']))
+ if (!is_array($config['ifgroups']['ifgroupentry'])) {
$config['ifgroups']['ifgroupentry'] = array();
+ }
foreach ($config['ifgroups']['ifgroupentry'] as $gid => $group) {
if ($group['ifname'] == "QinQ") {
$found = true;
@@ -189,12 +209,13 @@ if ($_POST) {
}
}
$additions = "";
- foreach($nmembers as $qtag)
+ foreach ($nmembers as $qtag) {
$additions .= "{$qinqentry['vlanif']}_{$qtag} ";
+ }
$additions .= "{$qinqentry['vlanif']}";
- if ($found == true)
+ if ($found == true) {
$config['ifgroups']['ifgroupentry'][$gid]['members'] .= " {$additions}";
- else {
+ } else {
$gentry = array();
$gentry['ifname'] = "QinQ";
$gentry['members'] = "{$additions}";
@@ -230,10 +251,10 @@ var newrow = new Array(9999);
var rowsize = new Array(9999);
for (i = 0; i < 9999; i++) {
- rowname[i] = 'members';
- rowtype[i] = 'select';
- newrow[i] = '';
- rowsize[i] = '30';
+ rowname[i] = 'members';
+ rowtype[i] = 'select';
+ newrow[i] = '';
+ rowsize[i] = '30';
}
var field_counter_js = 0;
@@ -242,35 +263,36 @@ var is_streaming_progress_bar = 0;
var temp_streaming_text = "";
var addRowTo = (function() {
- return (function (tableId) {
- var d, tbody, tr, td, bgc, i, ii, j;
- d = document;
- tbody = d.getElementById(tableId).getElementsByTagName("tbody").item(0);
- tr = d.createElement("tr");
- for (i = 0; i < field_counter_js; i++) {
- td = d.createElement("td");
- td.innerHTML="<input type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "' /><input size='" + rowsize[i] + "' class='formfld unknown' name='" + rowname[i] + totalrows + "' /> ";
- tr.appendChild(td);
- }
- td = d.createElement("td");
- td.rowSpan = "1";
-
- td.innerHTML = '<a onclick="removeRow(this);return false;" href="#"><img border="0" src="/themes/' + theme + '/images/icons/icon_x.gif" alt="remove" /><\/a>';
- tr.appendChild(td);
- tbody.appendChild(tr);
- totalrows++;
- });
+ return (function (tableId) {
+ var d, tbody, tr, td, bgc, i, ii, j;
+ d = document;
+ tbody = d.getElementById(tableId).getElementsByTagName("tbody").item(0);
+ tr = d.createElement("tr");
+ for (i = 0; i < field_counter_js; i++) {
+ td = d.createElement("td");
+ td.innerHTML="<input type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "' /><input size='" + rowsize[i] + "' class='formfld unknown' name='" + rowname[i] + totalrows + "' /> ";
+ tr.appendChild(td);
+ }
+ td = d.createElement("td");
+ td.rowSpan = "1";
+
+ td.innerHTML = '<a onclick="removeRow(this);return false;" href="#"><img border="0" src="/themes/' + theme + '/images/icons/icon_x.gif" alt="remove" /><\/a>';
+ tr.appendChild(td);
+ tbody.appendChild(tr);
+ totalrows++;
+ });
})();
function removeRow(el) {
- var cel;
- while (el && el.nodeName.toLowerCase() != "tr")
- el = el.parentNode;
-
- if (el && el.parentNode) {
- cel = el.getElementsByTagName("td").item(0);
- el.parentNode.removeChild(el);
- }
+ var cel;
+ while (el && el.nodeName.toLowerCase() != "tr") {
+ el = el.parentNode;
+ }
+
+ if (el && el.parentNode) {
+ cel = el.getElementsByTagName("td").item(0);
+ el.parentNode.removeChild(el);
+ }
}
rowname[0] = <?=gettext("members");?>;
@@ -288,122 +310,124 @@ function removeRow(el) {
<div id="inputerrors"></div>
<form action="interfaces_qinq_edit.php" method="post" name="iform" id="iform">
-<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces qinq edit">
- <tr>
- <td colspan="2" valign="top" class="listtopic"><?=gettext("Interface QinQ Edit");?></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Parent interface");?></td>
- <td width="78%" class="vtable">
- <select name="if" id="if" class="formselect">
- <?php
- foreach ($portlist as $ifn => $ifinfo) {
- if (is_jumbo_capable($ifn)) {
- echo "<option value=\"{$ifn}\"";
- if ($ifn == $pconfig['if'])
- echo " selected=\"selected\"";
- echo ">";
- echo htmlspecialchars($ifn . " (" . $ifinfo['mac'] . ")");
- echo "</option>";
- }
- }
- ?>
- </select>
- <br />
- <span class="vexpl"><?=gettext("Only QinQ capable interfaces will be shown.");?></span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("First level tag");?></td>
- <td width="78%" class="vtable">
- <input name="tag" type="text" class="formfld unknown" id="tag" size="10" value="<?=htmlspecialchars($pconfig['tag']);?>" />
- <br />
- <span class="vexpl">
- <?=gettext("This is the first level VLAN tag. On top of this are stacked the member VLANs defined below.");?>
- </span>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("Options");?></td>
- <td width="78%" class="vtable">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces qinq edit">
+ <tr>
+ <td colspan="2" valign="top" class="listtopic"><?=gettext("Interface QinQ Edit");?></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Parent interface");?></td>
+ <td width="78%" class="vtable">
+ <select name="if" id="if" class="formselect">
+ <?php
+ foreach ($portlist as $ifn => $ifinfo) {
+ if (is_jumbo_capable($ifn)) {
+ echo "<option value=\"{$ifn}\"";
+ if ($ifn == $pconfig['if']) {
+ echo " selected=\"selected\"";
+ }
+ echo ">";
+ echo htmlspecialchars($ifn . " (" . $ifinfo['mac'] . ")");
+ echo "</option>";
+ }
+ }
+ ?>
+ </select>
+ <br />
+ <span class="vexpl"><?=gettext("Only QinQ capable interfaces will be shown.");?></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("First level tag");?></td>
+ <td width="78%" class="vtable">
+ <input name="tag" type="text" class="formfld unknown" id="tag" size="10" value="<?=htmlspecialchars($pconfig['tag']);?>" />
+ <br />
+ <span class="vexpl">
+ <?=gettext("This is the first level VLAN tag. On top of this are stacked the member VLANs defined below.");?>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Options");?></td>
+ <td width="78%" class="vtable">
<?php /* ?>
- <br />
- <input type="checkbox" value="yes" name="autoassign" id="autoassign" <?php if ($pconfig['autoassign']) echo "checked=\"checked\""; ?> />
- <span class="vexpl"> Auto assign interface so it can be configured with ip etc...</span>
- <br />
- <input type="checkbox" value="yes" name="autoenable" id="autoenable" <?php if ($pconfig['autoenable']) echo "checked=\"checked\""; ?> />
- <span class="vexpl"> Auto enable interface so it can be used on filter rules.</span>
- <br />
- <input type="checkbox" value="yes" name="autoadjustmtu" id="autoadjustmtu" <?php if ($pconfig['autoadjustmtu']) echo "checked=\"checked\""; ?> />
- <span class="vexpl"> Allows to keep clients mtu unchanged(1500). <br />NOTE: if you are using jumbo frames this option is not needed and may produce incorrect results!</span>
+ <br />
+ <input type="checkbox" value="yes" name="autoassign" id="autoassign" <?php if ($pconfig['autoassign']) echo "checked=\"checked\""; ?> />
+ <span class="vexpl"> Auto assign interface so it can be configured with ip etc...</span>
+ <br />
+ <input type="checkbox" value="yes" name="autoenable" id="autoenable" <?php if ($pconfig['autoenable']) echo "checked=\"checked\""; ?> />
+ <span class="vexpl"> Auto enable interface so it can be used on filter rules.</span>
+ <br />
+ <input type="checkbox" value="yes" name="autoadjustmtu" id="autoadjustmtu" <?php if ($pconfig['autoadjustmtu']) echo "checked=\"checked\""; ?> />
+ <span class="vexpl"> Allows to keep clients mtu unchanged(1500). <br />NOTE: if you are using jumbo frames this option is not needed and may produce incorrect results!</span>
<?php */ ?>
- <br />
- <input name="autogroup" type="checkbox" value="yes" id="autogroup" <?php if ($pconfig['autogroup']) echo "checked=\"checked\""; ?> />
- <span class="vexpl"><?=gettext("Adds interface to QinQ interface groups so you can write filter rules easily.");?></span>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
- <td width="78%" class="vtable">
- <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
- <br />
- <span class="vexpl">
- <?=gettext("You may enter a description here for your reference (not parsed).");?>
- </span>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><div id="membersnetworkport"><?=gettext("Member (s)");?></div></td>
- <td width="78%" class="vtable">
- <span class="vexpl">
- <?=gettext("You can specify ranges in the input below. The format is pretty simple i.e 9-100 or 10.20...");?>
- </span>
- <br />
- <table id="maintable" summary="main table">
- <tbody>
- <tr>
- <td><div id="onecolumn"><?=gettext("Tag");?></div></td>
- </tr>
-
- <?php
+ <br />
+ <input name="autogroup" type="checkbox" value="yes" id="autogroup" <?php if ($pconfig['autogroup']) echo "checked=\"checked\""; ?> />
+ <span class="vexpl"><?=gettext("Adds interface to QinQ interface groups so you can write filter rules easily.");?></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
+ <td width="78%" class="vtable">
+ <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
+ <br />
+ <span class="vexpl">
+ <?=gettext("You may enter a description here for your reference (not parsed).");?>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><div id="membersnetworkport"><?=gettext("Member (s)");?></div></td>
+ <td width="78%" class="vtable">
+ <span class="vexpl">
+ <?=gettext("You can specify ranges in the input below. The format is pretty simple i.e 9-100 or 10.20...");?>
+ </span>
+ <br />
+ <table id="maintable" summary="main table">
+ <tbody>
+ <tr>
+ <td><div id="onecolumn"><?=gettext("Tag");?></div></td>
+ </tr>
+
+<?php
$counter = 0;
$members = $pconfig['members'];
if ($members <> "") {
$item = explode(" ", $members);
- foreach($item as $ww) {
+ foreach ($item as $ww) {
$member = $item[$counter];
- ?>
- <tr>
- <td class="vtable">
- <input name="members<?php echo $counter; ?>" class="formselect" id="members<?php echo $counter; ?>" value="<?php echo $member;?>" />
- </td>
- <td>
- <a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" alt="remove" /></a>
- </td>
- </tr>
+?>
+ <tr>
+ <td class="vtable">
+ <input name="members<?php echo $counter; ?>" class="formselect" id="members<?php echo $counter; ?>" value="<?php echo $member;?>" />
+ </td>
+ <td>
+ <a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" alt="remove" /></a>
+ </td>
+ </tr>
<?php
- $counter++;
+ $counter++;
} // end foreach
} // end if
?>
- </tbody>
- </table>
- <a onclick="javascript:addRowTo('maintable'); return false;" href="#">
- <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
- </a>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input id="submit" name="submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
- <a href="interfaces_qinq.php"><input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="<?=gettext("Cancel");?>" /></a>
- <?php if (isset($id) && $a_qinqs[$id]): ?>
- <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
- <?php endif; ?>
- </td>
- </tr>
-</table>
+ </tbody>
+ </table>
+ <a onclick="javascript:addRowTo('maintable'); return false;" href="#">
+ <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
+ </a>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
+ <a href="interfaces_qinq.php"><input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="<?=gettext("Cancel");?>" /></a>
+ <?php if (isset($id) && $a_qinqs[$id]): ?>
+ <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
+ <?php endif; ?>
+ </td>
+ </tr>
+ </table>
</form>
<script type="text/javascript">
OpenPOWER on IntegriCloud