aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorDaniel Stefan Haischt <dsh@pfsense.org>2007-01-22 04:19:21 +0000
committerDaniel Stefan Haischt <dsh@pfsense.org>2007-01-22 04:19:21 +0000
commitf81276457e9a666b2f0928ce45c6d14862f655af (patch)
treea257075745f0a535a66b952d7b29dd8b90bde834 /packages
parent5aff0dc6fb9af67f401edeafe55e6953e8145a52 (diff)
downloadpfsense-packages-f81276457e9a666b2f0928ce45c6d14862f655af.tar.gz
pfsense-packages-f81276457e9a666b2f0928ce45c6d14862f655af.tar.bz2
pfsense-packages-f81276457e9a666b2f0928ce45c6d14862f655af.zip
forgot to add these pages...
Diffstat (limited to 'packages')
-rw-r--r--packages/freenas/www/services_nfs_export.php165
-rw-r--r--packages/freenas/www/services_nfs_export_edit.php783
2 files changed, 948 insertions, 0 deletions
diff --git a/packages/freenas/www/services_nfs_export.php b/packages/freenas/www/services_nfs_export.php
new file mode 100644
index 00000000..c1712762
--- /dev/null
+++ b/packages/freenas/www/services_nfs_export.php
@@ -0,0 +1,165 @@
+<?php
+/* $Id$ */
+/* ========================================================================== */
+/*
+ services_nfs_export.php
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name>
+ All rights reserved.
+
+ Based on FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+
+$pgtitle = array(gettext("Services"),
+ gettext("NFS"),
+ gettext("Exports"));
+
+require_once("freenas_config.inc");
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['mounts']['mount']))
+ $freenas_config['mounts']['mount'] = array();
+
+mount_sort();
+
+$a_mount = &$freenas_config['mounts']['mount'];
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors)
+ {
+ if($_POST['apply']) {
+ $retval = 0;
+ if(!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ services_nfs_configure();
+ services_zeroconf_configure();
+ config_unlock();
+ }
+
+ $savemsg = get_std_save_message($retval);
+
+ if(0 == $retval) {
+ if(file_exists($d_nfsexportconfdirty_path))
+ unlink($d_nfsexportconfdirty_path);
+ }
+ }
+ }
+}
+
+if($_GET['act'] == "ret") {
+ pfSenseHeader("services_nfs_export.php");
+ exit;
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
+<?php include("fbegin.inc"); ?>
+
+<form id="iform" name="iform" action="services_nfs_export.php" method="post">
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<?php if (file_exists($d_nfsexportconfdirty_path)): ?>
+<?php print_info_box_np(gettext("The exports have been modified.") . "<br />" .
+ gettext("You must apply the changes in order for them to take effect."));?>
+<?php endif; ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<div id="inputerrors"></div>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Settings"), false, "services_nfs.php");
+ $tab_array[1] = array(gettext("Exports"), true, "services_nfs_export.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="20%" class="listhdrr"><?= gettext("Export"); ?></td>
+ <td width="25%" class="listhdrr"><?= gettext("Description"); ?></td>
+ <td width="20%" class="listhdrr"><?= gettext("Export To"); ?></td>
+ <td width="10%" class="list"></td>
+ </tr>
+ <?php $i = 0; foreach($a_mount as $mountv): ?>
+ <tr>
+ <td class="listr">/mnt/<?=htmlspecialchars($mountv['sharename']);?></td>
+ <td class="listr"><?=htmlspecialchars($mountv['desc']);?></td>
+ <td class="listbg" style="color: #FFFFFF;"><?= isset($mountv['nfs']['networks']) ? str_replace(",", "<br />", htmlspecialchars($mountv['nfs']['networks'])) : gettext("None"); ?></td>
+ <td valign="middle" nowrap class="list">
+ <?php if(isset($freenas_config['nfs']['enable']))
+ echo("<a href='services_nfs_export_edit.php?id={$i}'><img src='./themes/" . $g['theme'] . "/images/icons/icon_e.gif' alt='" . gettext("Edit Export") . "' title='" . gettext("Edit Export") . "' width='17' height='17' border='0' /></a>");
+ ?>
+ </td>
+ </tr>
+ <?php $i++; endforeach; ?>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/services_nfs_export_edit.php b/packages/freenas/www/services_nfs_export_edit.php
new file mode 100644
index 00000000..f9fd53ea
--- /dev/null
+++ b/packages/freenas/www/services_nfs_export_edit.php
@@ -0,0 +1,783 @@
+<?php
+/* $Id$ */
+/* ========================================================================== */
+/*
+ services_samba_share_edit.php
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name>
+ All rights reserved.
+
+ Based on FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+
+$pgtitle = array(gettext("Services"),
+ gettext("NFS"),
+ gettext("Exports"),
+ gettext("Edit"));
+
+require_once("freenas_config.inc");
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+$id = $_GET['id'];
+if (isset($_POST['id']))
+ $id = $_POST['id'];
+
+if (!is_array($freenas_config['mounts']['mount']))
+ $freenas_config['mounts']['mount'] = array();
+
+mount_sort();
+
+$pconfig['mapall'] = $freenas_config['mounts']['mount'][$id]['nfs']['mapall'];
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ $reqdfields = explode(" ", "authnetworks");
+ $reqdfieldsn = explode(",", "Destination network");
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (isset($_POST['authnetworks']) && is_array($_POST['authnetworks'])) {
+ foreach ($_POST['authnetworks'] as $netel) {
+ list($_POST['network'], $_POST['network_subnet']) = explode('/', $netel);
+
+ if (($_POST['network'] && !is_ipaddr($_POST['network']))) {
+ $error_bucket[] = array("error" => gettext("A valid network must be specified."),
+ "field" => "network");
+ }
+
+ if (($_POST['network_subnet'] && !is_numeric($_POST['network_subnet']))) {
+ $error_bucket[] = array("error" => gettext("A valid network bit count must be specified."),
+ "field" => "network_subnet");
+ }
+
+ $osn[] = gen_subnet($_POST['network'], $_POST['network_subnet']) . "/" . $_POST['network_subnet'];
+ }
+ }
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors)
+ {
+ $freenas_config['mounts']['mount'][$id]['nfs']['networks'] = implode(",", $osn);
+ $freenas_config['mounts']['mount'][$id]['nfs']['mapall'] = $_POST['mapall'];
+
+ touch($d_nfsexportconfdirty_path);
+ write_config();
+ pfSenseHeader("services_nfs_export.php");
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+
+$addressTransString = gettext("Address");
+$plusimgDescTransString = gettext("add to network list");
+$minusimgDescTransString = gettext("remove from network list");
+$currentnetTransString = gettext("Current networks");
+$networksTypehintTransString = gettext("Network that is authorised to access NFS shares");
+
+$networkCount = count($freenas_config['nfs']['nfsnetwork']);
+$generatedWANSubnet = gen_subnet($config['interfaces']['wan']['ipaddr'],
+ $config['interfaces']['wan']['subnet']);
+$generatedLANSubnet = gen_subnet($config['interfaces']['lan']['ipaddr'],
+ $config['interfaces']['lan']['subnet']);
+
+$jscriptstr = <<<EOD
+<script type="text/javascript">
+<!--
+function network_exists(myValue) {
+ for (i = 0; i < $('authnetworks').options.length; i++) {
+ if ($('authnetworks').options[i].value == myValue) {
+ return true;
+ }
+ }
+
+ return false;
+}
+function selectnetel() {
+ for (i = 0; i < $('authnetworks').options.length; i++) {
+ $('authnetworks').options[i].selected = true;
+ }
+}
+function get_selected_listitems() {
+ var selected = new Array();
+
+ if (!$('authnetworks')) { return; }
+
+ for (i = 0; i < $('authnetworks').options.length; i++) {
+ if ($('authnetworks').childNodes[i].selected == true) {
+ selected.push($('authnetworks').options[i]);
+ }
+ }
+
+ return selected;
+}
+
+function add_selnetwork(net, mask) {
+ var newOption = document.createElement("option");
+ var newOptionText = document.createTextNode(net + '/' + mask);
+ var selectSize = $('authnetworks').size;
+
+ if (!net || !mask) { return; }
+
+ if (network_exists(net + '/' + mask)) {
+ alert('Element already exist in the network list');
+ return;
+ }
+
+ newOption.setAttribute('value', net + '/' + mask);
+ newOption.appendChild(newOptionText);
+
+ /* add the option to the select element */
+ $('authnetworks').appendChild(newOption);
+ $('authnetworks').setAttribute('size', '3');
+
+ /* clear values from HTML fields */
+ if ($('network')) { $('network').value = ''; }
+ if ($('network_subnet')) { $('network_subnet').selectedIndex = 0; }
+}
+
+function remove_selnetwork() {
+ var selectedItems = get_selected_listitems();
+
+ if (selectedItems.length <= 0) {
+ alert('No element selected!');
+ return;
+ }
+
+ for (i = 0; i < selectedItems.length; i++) {
+ $('authnetworks').removeChild(selectedItems[i]);
+ }
+}
+
+function create_authnetworks_tr(selectElement) {
+ var newTR = document.createElement("tr");
+ newTR.setAttribute('id', 'authNetworksTR');
+
+ var newImageTR = document.createElement("tr");
+ newImageTR.setAttribute('id', 'authNetworksImageTR');
+
+ var descTD = document.createElement("td");
+ descTD.setAttribute('align', 'left');
+ descTD.setAttribute('valign', 'top');
+ descTD.setAttribute('style', 'padding-top: 10px; border-top: solid 1px grey;');
+
+ var selectTD = document.createElement("td");
+ selectTD.setAttribute('align', 'left');
+ selectTD.setAttribute('valign', 'middle');
+ selectTD.setAttribute('style', 'padding-top: 10px; border-top: solid 1px grey;');
+
+ var typehintTD = document.createElement("td");
+ typehintTD.setAttribute('align', 'left');
+ typehintTD.setAttribute('valign', 'middle');
+ typehintTD.setAttribute('colspan', '2');
+ typehintTD.setAttribute('style', 'padding-top: 10px; border-top: solid 1px grey;');
+
+ var blankTD = document.createElement("td");
+ blankTD.setAttribute('align', 'left');
+ blankTD.setAttribute('valign', 'top');
+
+ var imageTD = document.createElement("td");
+ imageTD.setAttribute('align', 'left');
+ imageTD.setAttribute('valign', 'middle');
+ imageTD.setAttribute('style', 'vertical-align: middle;');
+ imageTD.setAttribute('colspan', '3');
+
+ var newSpan = document.createElement("span");
+ newSpan.setAttribute('style', 'padding-left: 5px; vertical-align: middle;');
+
+ var newTypehintSpan = document.createElement("span");
+ newTypehintSpan.setAttribute('style', 'padding-left: 5px; vertical-align: middle;');
+
+ var newDescription = document.createTextNode('{$currentnetTransString}:');
+ var newImgDescription = document.createTextNode('{$minusimgDescTransString}');
+ var typehint = document.createTextNode('{$networksTypehintTransString}');
+
+ var newSelect = document.createElement("select");
+ newSelect.setAttribute('name', 'authnetworks[]');
+ newSelect.setAttribute('class', 'formselect');
+ newSelect.setAttribute('id', 'authnetworks');
+ newSelect.setAttribute('multiple', 'multiple');
+ newSelect.setAttribute('size', '{$networkCount}');
+
+ /* divs are used to achieve proper alignement */
+ newImageDiv = document.createElement("div");
+ newImageDiv.setAttribute('style', 'float: left;');
+
+ newImageDescDiv = document.createElement("div");
+ newImageDescDiv.setAttribute('style', 'padding-top: 1px;');
+
+ /* try to add each network to the select element */
+
+EOD;
+
+if (isset($freenas_config['mounts']['mount'][$id]['nfs']['networks'])) {
+ foreach (explode(",", $freenas_config['mounts']['mount'][$id]['nfs']['networks']) as $networkel) {
+ list($netaddress, $netmask) = explode('/', $networkel);
+ $networkSanitized = htmlspecialchars($netaddress);
+
+ $jscriptstr .= <<<EOD
+ var newOption = document.createElement("option");
+ var newOptionText = document.createTextNode('{$networkSanitized}/{$netmask}');
+
+ newOption.setAttribute('value', '{$networkSanitized}/{$netmask}');
+ newOption.appendChild(newOptionText);
+
+ /* add the option to the select element */
+ newSelect.appendChild(newOption);
+
+EOD;
+ } // end if
+} // end foreach
+
+$jscriptstr .= <<<EOD
+ var newImage = document.createElement("img");
+ newImage.setAttribute('src', '/themes/{$g['theme']}/images/misc/bullet_toggle_minus.png');
+ newImage.setAttribute('alt', 'remove network');
+ newImage.setAttribute('border', '0');
+ newImage.setAttribute('style', 'margin-right: 5px; border: solid 1px silver; cursor: pointer;');
+ newImage.setAttribute('onclick', 'remove_selnetwork();');
+
+ /* assemble everything */
+ newTypehintSpan.appendChild(typehint);
+
+ descTD.appendChild(newDescription);
+ selectElement != null ? selectTD.appendChild(selectElement) : selectTD.appendChild(newSelect);
+ typehintTD.appendChild(newTypehintSpan);
+
+ newImageDiv.appendChild(newImage);
+ newImageDescDiv.appendChild(newImgDescription);
+
+ imageTD.appendChild(newImageDiv);
+ imageTD.appendChild(newImageDescDiv);
+
+ newTR.appendChild(descTD);
+ newTR.appendChild(selectTD);
+ newTR.appendChild(typehintTD);
+
+ newImageTR.appendChild(blankTD);
+ newImageTR.appendChild(imageTD);
+
+ $('networkopttab').appendChild(newTR);
+ $('networkopttab').appendChild(newImageTR);
+}
+
+function create_network_tr() {
+ var newTR = document.createElement("tr");
+ newTR.setAttribute('id', 'typeDetailsTR');
+
+ var descTD = document.createElement("td");
+ descTD.setAttribute('align', 'left');
+ descTD.setAttribute('valign', 'top');
+
+ var inputTD = document.createElement("td");
+ inputTD.setAttribute('align', 'left');
+ inputTD.setAttribute('valign', 'top');
+
+ var selectTD = document.createElement("td");
+ selectTD.setAttribute('align', 'left');
+ selectTD.setAttribute('valign', 'middle');
+
+ var imageTD = document.createElement("td");
+ imageTD.setAttribute('align', 'left');
+ imageTD.setAttribute('valign', 'middle');
+
+ var newDescription = document.createTextNode('{$addressTransString}:');
+ var newImgDescription = document.createTextNode('{$plusimgDescTransString}');
+
+ var newInput = document.createElement("input");
+ newInput.setAttribute('name', 'network');
+ newInput.setAttribute('type', 'text');
+ newInput.setAttribute('class', 'formfld host');
+ newInput.setAttribute('id', 'network');
+ newInput.setAttribute('size', '20');
+ newInput.setAttribute('value', '');
+
+ var newSelect = document.createElement("select");
+ newSelect.setAttribute('name', 'network_subnet');
+ newSelect.setAttribute('class', 'formselect');
+ newSelect.setAttribute('id', 'network_subnet');
+
+ var newImage = document.createElement("img");
+ newImage.setAttribute('src', '/themes/{$g['theme']}/images/misc/bullet_toggle_plus.png');
+ newImage.setAttribute('alt', 'add network');
+ newImage.setAttribute('border', '0');
+ newImage.setAttribute('style', 'margin-right: 5px; border: solid 1px silver; cursor: pointer;');
+ newImage.setAttribute('onclick', 'add_selnetwork($("network").value, $("network_subnet").value);');
+
+ /* divs are used to achieve proper alignement */
+ newImageDiv = document.createElement("div");
+ newImageDiv.setAttribute('style', 'float: left;');
+
+ newImageDescDiv = document.createElement("div");
+ newImageDescDiv.setAttribute('style', 'padding-top: 1px;');
+
+ /* add options to select */
+ for (i = 31; i > 0; i--) {
+ var newOption = document.createElement("option");
+ var newOptionText = document.createTextNode(i.toString());
+
+ newOption.setAttribute('value', i);
+ newOption.appendChild(newOptionText);
+
+ /* add the option to the select element */
+ newSelect.appendChild(newOption);
+ }
+
+ /* assemble everything */
+ descTD.appendChild(newDescription);
+ inputTD.appendChild(newInput);
+ selectTD.appendChild(newSelect);
+
+ newImageDiv.appendChild(newImage);
+ newImageDescDiv.appendChild(newImgDescription);
+
+ imageTD.appendChild(newImageDiv);
+ imageTD.appendChild(newImageDescDiv);
+
+ newTR.appendChild(descTD);
+ newTR.appendChild(inputTD);
+ newTR.appendChild(selectTD);
+ newTR.appendChild(imageTD);
+
+ $('networkopttab').appendChild(newTR);
+}
+
+function create_wan_tr() {
+ var wanSubnet = '{$config['interfaces']['wan']['subnet']}';
+
+ var newTR = document.createElement("tr");
+ newTR.setAttribute('id', 'typeDetailsTR');
+
+ var descTD = document.createElement("td");
+ descTD.setAttribute('align', 'left');
+ descTD.setAttribute('valign', 'top');
+
+ var nettextTD = document.createElement("td");
+ nettextTD.setAttribute('align', 'left');
+ nettextTD.setAttribute('valign', 'top');
+
+ var imageTD = document.createElement("td");
+ imageTD.setAttribute('align', 'left');
+ imageTD.setAttribute('valign', 'middle');
+ imageTD.setAttribute('colspan', '2');
+
+ var newDescription = document.createTextNode('{$addressTransString}:');
+ var newWanDescription = document.createTextNode('{$generatedWANSubnet}/' + wanSubnet);
+
+ var newNetTextSpan = document.createElement("span");
+ newNetTextSpan.setAttribute('style', 'font-weight: bold; font-style: italic; vertical-align: middle;');
+
+ var newImage = document.createElement("img");
+ newImage.setAttribute('src', '/themes/{$g['theme']}/images/misc/bullet_toggle_plus.png');
+ newImage.setAttribute('alt', 'add network');
+ newImage.setAttribute('border', '0');
+ newImage.setAttribute('style', 'margin-right: 5px; border: solid 1px silver; cursor: pointer;');
+ newImage.setAttribute('onclick', 'add_selnetwork("{$generatedWANSubnet}", ' + wanSubnet + ');');
+
+ /* divs are used to achieve proper alignement */
+ newImageDiv = document.createElement("div");
+ newImageDiv.setAttribute('style', 'float: left;');
+
+ newImageDescDiv = document.createElement("div");
+ newImageDescDiv.setAttribute('style', 'padding-top: 1px;');
+
+ var newImgDescription = document.createTextNode('{$plusimgDescTransString}');
+
+ /* assemble everything */
+ newNetTextSpan.appendChild(newWanDescription);
+
+ descTD.appendChild(newDescription);
+ nettextTD.appendChild(newNetTextSpan);
+
+ newImageDiv.appendChild(newImage);
+ newImageDescDiv.appendChild(newImgDescription);
+
+ imageTD.appendChild(newImageDiv);
+ imageTD.appendChild(newImageDescDiv);
+
+ newTR.appendChild(descTD);
+ newTR.appendChild(nettextTD);
+ newTR.appendChild(imageTD);
+
+ $('networkopttab').appendChild(newTR);
+}
+
+function create_lan_tr() {
+ var lanSubnet = '{$config['interfaces']['lan']['subnet']}';
+
+ var newTR = document.createElement("tr");
+ newTR.setAttribute('id', 'typeDetailsTR');
+
+ var descTD = document.createElement("td");
+ descTD.setAttribute('align', 'left');
+ descTD.setAttribute('valign', 'top');
+
+ var nettextTD = document.createElement("td");
+ nettextTD.setAttribute('align', 'left');
+ nettextTD.setAttribute('valign', 'top');
+
+ var imageTD = document.createElement("td");
+ imageTD.setAttribute('align', 'left');
+ imageTD.setAttribute('valign', 'middle');
+ imageTD.setAttribute('colspan', '2');
+
+ var newDescription = document.createTextNode('{$addressTransString}:');
+ var newLanDescription = document.createTextNode('{$generatedLANSubnet}/' + lanSubnet);
+
+ var newNetTextSpan = document.createElement("span");
+ newNetTextSpan.setAttribute('style', 'font-weight: bold; font-style: italic; vertical-align: middle;');
+
+ var newImage = document.createElement("img");
+ newImage.setAttribute('src', '/themes/{$g['theme']}/images/misc/bullet_toggle_plus.png');
+ newImage.setAttribute('alt', 'add network');
+ newImage.setAttribute('border', '0');
+ newImage.setAttribute('style', 'margin-right: 5px; border: solid 1px silver; cursor: pointer;');
+ newImage.setAttribute('onclick', 'add_selnetwork("{$generatedLANSubnet}", ' + lanSubnet + ');');
+
+ /* divs are used to achieve proper alignement */
+ newImageDiv = document.createElement("div");
+ newImageDiv.setAttribute('style', 'float: left;');
+
+ newImageDescDiv = document.createElement("div");
+ newImageDescDiv.setAttribute('style', 'padding-top: 1px;');
+
+ var newImgDescription = document.createTextNode('{$plusimgDescTransString}');
+
+ /* assemble everything */
+ newNetTextSpan.appendChild(newLanDescription);
+
+ descTD.appendChild(newDescription);
+ nettextTD.appendChild(newNetTextSpan);
+
+ newImageDiv.appendChild(newImage);
+ newImageDescDiv.appendChild(newImgDescription);
+
+ imageTD.appendChild(newImageDiv);
+ imageTD.appendChild(newImageDescDiv);
+
+ newTR.appendChild(descTD);
+ newTR.appendChild(nettextTD);
+ newTR.appendChild(imageTD);
+
+ $('networkopttab').appendChild(newTR);
+}
+
+function get_optnetwork() {
+ var slashIndex= $('opt_iface_desc').firstChild.nodeValue.indexOf('/');
+ var myNetwork = $('opt_iface_desc').firstChild.nodeValue.substring(0, slashIndex);
+
+ return myNetwork;
+}
+
+function get_optsubnet() {
+ var slashIndex= $('opt_iface_desc').firstChild.nodeValue.indexOf('/');
+ var mySubnet = $('opt_iface_desc').firstChild.nodeValue.substring(slashIndex + 1, $('opt_iface_desc').firstChild.nodeValue.length);
+
+ return mySubnet;
+}
+
+function create_opt_tr() {
+ var newTR = document.createElement("tr");
+ newTR.setAttribute('id', 'typeDetailsTR');
+
+ var descTD = document.createElement("td");
+ descTD.setAttribute('align', 'left');
+ descTD.setAttribute('valign', 'top');
+
+ var nettextTD = document.createElement("td");
+ nettextTD.setAttribute('align', 'left');
+ nettextTD.setAttribute('valign', 'top');
+
+ var imageTD = document.createElement("td");
+ imageTD.setAttribute('align', 'left');
+ imageTD.setAttribute('valign', 'middle');
+ imageTD.setAttribute('colspan', '2');
+
+ var newDescription = document.createTextNode('{$addressTransString}:');
+ var newImgDescription = document.createTextNode('{$plusimgDescTransString}');
+
+ var newImage = document.createElement("img");
+ newImage.setAttribute('src', '/themes/{$g['theme']}/images/misc/bullet_toggle_plus.png');
+ newImage.setAttribute('alt', 'add network');
+ newImage.setAttribute('border', '0');
+ newImage.setAttribute('style', 'margin-right: 5px; border: solid 1px silver; cursor: pointer;');
+ newImage.setAttribute('onclick', 'add_selnetwork(get_optnetwork(), get_optsubnet());');
+
+ /* divs are used to achieve proper alignement */
+ newImageDiv = document.createElement("div");
+ newImageDiv.setAttribute('style', 'float: left;');
+
+ newImageDescDiv = document.createElement("div");
+ newImageDescDiv.setAttribute('style', 'padding-top: 1px;');
+
+ /* add options to select */
+
+EOD;
+
+for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
+ $optSubnet = $config['interfaces']['opt' . $i]['subnet'];
+ $generatedOPTSubnet = gen_subnet($config['interfaces']['opt' . $i]['ipaddr'],
+ $config['interfaces']['opt' . $i]['subnet']);
+
+ if (empty($optSubnet) || empty($generatedOPTSubnet)) { continue; }
+
+ $jscriptstr .= <<<EOD
+ var selOptIndex = $('authnettype').selectedIndex;
+ var optNumber = $('authnettype').options[selOptIndex].value.substr(3, $('authnettype').options[selOptIndex].value.length);
+ var newOptDescription = null;
+ var newNetTextSpan = null;
+
+ if (optNumber == {$i}) {
+ newOptDescription = document.createTextNode('{$generatedOPTSubnet}/{$optSubnet}');
+
+ newNetTextSpan = document.createElement("span");
+ newNetTextSpan.setAttribute('id', 'opt_iface_desc');
+ newNetTextSpan.setAttribute('style', 'font-weight: bold; font-style: italic; vertical-align: middle;');
+ }
+
+EOD;
+}
+
+$jscriptstr .= <<<EOD
+ /* assemble everything */
+ if (newNetTextSpan)
+ newNetTextSpan.appendChild(newOptDescription);
+
+ descTD.appendChild(newDescription);
+ if (newNetTextSpan)
+ nettextTD.appendChild(newNetTextSpan);
+
+ newImageDiv.appendChild(newImage);
+ newImageDescDiv.appendChild(newImgDescription);
+
+ imageTD.appendChild(newImageDiv);
+ imageTD.appendChild(newImageDescDiv);
+
+ newTR.appendChild(descTD);
+ newTR.appendChild(nettextTD);
+ newTR.appendChild(imageTD);
+
+ $('networkopttab').appendChild(newTR);
+}
+
+function authnet_change() {
+ var tmpElement = $('authnetworks');
+
+ if ($('typeDetailsTR')) { $('networkopttab').removeChild($('typeDetailsTR')); }
+ if ($('authNetworksTR')) { $('networkopttab').removeChild($('authNetworksTR')); }
+ if ($('authNetworksImageTR')) { $('networkopttab').removeChild($('authNetworksImageTR')); }
+
+ switch ($('authnettype').selectedIndex) {
+ case 0:
+ /* Network */
+ create_network_tr();
+ break;
+ case 1:
+ /* WAN subnet */
+ create_wan_tr();
+ break;
+ case 2:
+ /* LAN subnet */
+ create_lan_tr();
+ break;
+
+EOD;
+
+for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
+ $case_count = 2 + $i;
+
+ $jscriptstr .= <<<EOD
+ case {$case_count}:
+ /* OPT subnet */
+ create_opt_tr();
+ break;
+
+EOD;
+
+} // end for
+
+$jscriptstr .= <<<EOD
+ } // end switch
+
+ create_authnetworks_tr(tmpElement);
+} // end function authnet_change
+//-->
+</script>
+
+EOD;
+
+$pfSenseHead->addScript($jscriptstr);
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+ <div id="inputerrors"></div>
+ <form id="iform" name="iform" action="disks_mount_edit.php" method="post">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="100%" align="left" valign="middle" class="listtopic" colspan="2"><?=gettext("Export Options");?></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?= gettext("Export Name"); ?></td>
+ <td width="78%" class="vtable">
+ <input type="text" class="formfld file" size="30" value="/mnt/<?=htmlspecialchars($freenas_config['mounts']['mount'][$id]['sharename']);?>" readonly="readonly" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?= gettext("Description"); ?></td>
+ <td width="78%" class="vtable">
+ <input type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($freenas_config['mounts']['mount'][$id]['desc']);?>" readonly="readonly" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("map all user to root");?></td>
+ <td width="78%" class="vtable">
+ <select name="mapall" class="formselect" id="mapall">
+ <?php
+ $types = explode(",", "Yes,No");
+ $vals = explode(" ", "yes no");
+ $j = 0;
+
+ for ($j = 0; $j < count($vals); $j++):
+ ?>
+ <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['mapall']) echo "selected=\"selected\"";?>>
+ <?=htmlspecialchars($types[$j]);?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ <br />
+ <?= gettext("All users will have the root privilege."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Authorised network");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <table border="0" cellspacing="0" cellpadding="4" id="networkopttab">
+ <tr>
+ <td align="left" valign="middle"><?=gettext("Type");?>:</td>
+ <td align="left" valign="middle" colspan="4">
+ <select name="authnettype" id="authnettype" class="formselect" onchange="authnet_change();">
+ <option value="network">
+ <?=gettext("Network")?>
+ </option>
+ <option value="wan">
+ <?=gettext("WAN subnet");?>
+ </option>
+ <option value="lan">
+ <?=gettext("LAN subnet");?>
+ </option>
+ <?php
+ for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++):
+ ?>
+ <option value="opt<?=$i;?>">
+ <?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?>
+ <?=gettext("subnet");?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ </td>
+ </tr>
+ </table>
+ </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");?>" onmousedown="selectnetel();" onkeydown="selectnetel();" />
+ <?php if(isset($id)): ?>
+ <input id="id" name="id" type="hidden" value="<?=$id;?>" />
+ <?php endif; ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <span class="red">
+ <strong><?= gettext("NOTE"); ?>:</strong>
+ </span>
+ <br />
+ <ul>
+ <li>
+ <span class="vexpl">
+ <?= gettext("The name of each exported directory is: /mnt/sharename"); ?>
+ </span>
+ </li>
+ <li>
+ <span class="vexpl">
+ <?= gettext("Try adding networks to the 'current networks' list to authorize each particular network."); ?>
+ </span>
+ </li>
+ <li>
+ <span class="vexpl">
+ <?= gettext("Use ctrl-click (or command-click on the Mac) to select and de-select elements from the 'current networks' list."); ?>
+ </span>
+ </li>
+ </ul>
+ </td>
+ </tr>
+ </table>
+ </form>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+<script type="text/javascript">
+<!--
+authnet_change();
+//-->
+</script>
+</body>
+</html>