Commit 62e7fd28 authored by Franco Fichtner's avatar Franco Fichtner

wizard: more "improvements"

o Remove a subtype of <includefile/> to reduce feature bloat
o Select 32 bit subnet (host) as a suggestion
o Never skip LAN and make it optional instead
o Fix regression of $xml passing
o Fix voodoo on Static
parent 467f41e5
......@@ -28,6 +28,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
</copyright>
<includefile>openvpn_wizard.inc</includefile>
<totalsteps>12</totalsteps>
<step>
<id>1</id>
......@@ -66,7 +67,6 @@
</field>
</fields>
<stepsubmitphpaction>step1_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step>
<step>
<id>2</id>
......@@ -102,7 +102,6 @@
<stepbeforeformdisplay>step2_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step2_submitphpaction();</stepsubmitphpaction>
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
<includefile>openvpn_wizard.inc</includefile>
</step>
<step>
<id>3</id>
......@@ -229,7 +228,6 @@
</fields>
<stepsubmitphpaction>step3_submitphpaction();</stepsubmitphpaction>
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
<includefile>openvpn_wizard.inc</includefile>
</step>
<step>
<id>4</id>
......@@ -265,7 +263,6 @@
<stepbeforeformdisplay>step4_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step4_submitphpaction();</stepsubmitphpaction>
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
<includefile>openvpn_wizard.inc</includefile>
</step>
<step>
<id>5</id>
......@@ -314,7 +311,6 @@
</field>
</fields>
<stepsubmitphpaction>step5_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step>
<step>
<id>6</id>
......@@ -343,7 +339,6 @@
</fields>
<stepbeforeformdisplay>step6_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step6_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step>
<step>
<id>7</id>
......@@ -444,7 +439,6 @@
</field>
</fields>
<stepsubmitphpaction>step7_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
</step>
<step>
......@@ -474,7 +468,6 @@
</fields>
<stepbeforeformdisplay>step8_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step8_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step>
<step>
<id>9</id>
......@@ -576,7 +569,6 @@
</fields>
<stepbeforeformdisplay>step9_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step9_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step>
<step>
<id>10</id>
......@@ -911,7 +903,6 @@
</fields>
<stepbeforeformdisplay>step10_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step10_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step>
<step>
<id>11</id>
......@@ -979,6 +970,5 @@
</field>
</fields>
<stepsubmitphpaction>step12_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step>
</opnsensewizard>
......@@ -477,11 +477,9 @@
</stepsubmitphpaction>
<stepsubmitbeforesave>
<![CDATA[
if ($_POST['selectedtype'] != "Static") {
$_POST['ipaddress'] = $_POST['selectedtype'];
$config['interfaces']['wan']['ipaddr'] = $_POST['selectedtype'];
write_config();
if (!isset($config['interfaces']['lan'])) {
header("Location: /wizard.php?xml=setup&stepid=5");
}
]]>
</stepsubmitbeforesave>
......@@ -496,6 +494,7 @@
<type>input</type>
<bindstofield>interfaces->lan->ipaddr</bindstofield>
<validate>^(?:[0]*(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:[0]*(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9]))$</validate>
<description>(leave empty for none)</description>
<message>LAN IP Address field is invalid</message>
</field>
<field>
......@@ -510,16 +509,19 @@
</fields>
<stepsubmitphpaction>
<![CDATA[
if(empty($_POST['lanipaddress']) || !is_ipaddr($_POST['lanipaddress'])) {
if (!empty(trim($_POST['lanipaddress']))) {
if (!is_ipaddr($_POST['lanipaddress'])) {
print_info_box_np("Invalid LAN IP Address. Please press back in your browser window and correct.");
die;
}
if ($_POST['subnetmask'] < 31 &&
($_POST['lanipaddress'] == gen_subnet($_POST['lanipaddress'], $_POST['subnetmask']) ||
$_POST['lanipaddress'] == gen_subnet_max($_POST['lanipaddress'], $_POST['subnetmask']))) {
print_info_box_np("Invalid LAN IP Address. Please press back in your browser window and correct.");
die;
}
$ft = explode(".", $_POST['lanipaddress']);
$ft_ip = $ft[0] . "." . $ft[1] . "." . $ft[2] . ".";
$config['dhcpd']['lan']['range']['from'] = $ft_ip . "10";
......@@ -527,6 +529,11 @@
$hi = explode(".", $highestip);
$highestip = $hi[3]-10;
$config['dhcpd']['lan']['range']['to'] = $ft_ip . $highestip;
} else {
if (isset($config['interfaces']['lan'])) {
unset($config['interfaces']['lan']);
}
}
]]>
</stepsubmitphpaction>
</step>
......
......@@ -89,10 +89,9 @@ if (isset($_GET['xml'])) {
*/
switch ($xml) {
case 'openvpn':
$xml = 'openvpn.xml';
break;
default:
$xml = 'setup.xml';
$xml = 'setup';
break;
}
......@@ -122,7 +121,7 @@ $listtags = array_flip(array(
'template',
));
$pkg = parse_xml_config_raw('/usr/local/wizard/' . $xml, 'opnsensewizard', false);
$pkg = parse_xml_config_raw("/usr/local/wizard/{$xml}.xml", 'opnsensewizard', false);
if (!is_array($pkg)) {
print_info_box_np(sprintf(gettext("ERROR: Could not parse %s wizard file."), $xml));
die;
......@@ -132,11 +131,9 @@ $description = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$step
$title = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['title']);
$totalsteps = $pkg['totalsteps'];
if ($pkg['includefile'])
if ($pkg['includefile']) {
require_once($pkg['includefile']);
if ($pkg['step'][$stepid]['includefile'])
require_once($pkg['step'][$stepid]['includefile']);
}
if($pkg['step'][$stepid]['stepsubmitbeforesave']) {
eval($pkg['step'][$stepid]['stepsubmitbeforesave']);
......@@ -726,11 +723,19 @@ function showchange() {
if(!$field['dontcombinecells'])
echo "<td class=\"vtable\">";
echo "<select class='form-control' name='{$name}' style='max-width:5em;'>\n";
for($x=1; $x<33; $x++) {
$CHECKED = "";
if($value == $x) $CHECKED = " selected=\"selected\"";
if($x <> 31)
echo "<option value='{$x}' {$CHECKED}>{$x}</option>\n";
$CHECKED = ' selected="selected"';
for ($x = 1; $x <= 32; $x++) {
if ($x == 31) {
continue;
}
if ($value == $x) $CHECKED = " selected=\"selected\"";
echo "<option value='{$x}'";
if ($value == $x || $x == 32) {
echo $CHECKED;
/* only used once */
$CHECKED = '';
}
echo ">{$x}</option>\n";
}
echo "</select>\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment