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 @@ ...@@ -28,6 +28,7 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
</copyright> </copyright>
<includefile>openvpn_wizard.inc</includefile>
<totalsteps>12</totalsteps> <totalsteps>12</totalsteps>
<step> <step>
<id>1</id> <id>1</id>
...@@ -66,7 +67,6 @@ ...@@ -66,7 +67,6 @@
</field> </field>
</fields> </fields>
<stepsubmitphpaction>step1_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step1_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>2</id> <id>2</id>
...@@ -102,7 +102,6 @@ ...@@ -102,7 +102,6 @@
<stepbeforeformdisplay>step2_stepbeforeformdisplay();</stepbeforeformdisplay> <stepbeforeformdisplay>step2_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step2_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step2_submitphpaction();</stepsubmitphpaction>
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay> <javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
<includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>3</id> <id>3</id>
...@@ -229,7 +228,6 @@ ...@@ -229,7 +228,6 @@
</fields> </fields>
<stepsubmitphpaction>step3_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step3_submitphpaction();</stepsubmitphpaction>
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay> <javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
<includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>4</id> <id>4</id>
...@@ -265,7 +263,6 @@ ...@@ -265,7 +263,6 @@
<stepbeforeformdisplay>step4_stepbeforeformdisplay();</stepbeforeformdisplay> <stepbeforeformdisplay>step4_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step4_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step4_submitphpaction();</stepsubmitphpaction>
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay> <javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
<includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>5</id> <id>5</id>
...@@ -314,7 +311,6 @@ ...@@ -314,7 +311,6 @@
</field> </field>
</fields> </fields>
<stepsubmitphpaction>step5_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step5_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>6</id> <id>6</id>
...@@ -343,7 +339,6 @@ ...@@ -343,7 +339,6 @@
</fields> </fields>
<stepbeforeformdisplay>step6_stepbeforeformdisplay();</stepbeforeformdisplay> <stepbeforeformdisplay>step6_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step6_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step6_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>7</id> <id>7</id>
...@@ -444,7 +439,6 @@ ...@@ -444,7 +439,6 @@
</field> </field>
</fields> </fields>
<stepsubmitphpaction>step7_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step7_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay> <javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
</step> </step>
<step> <step>
...@@ -474,7 +468,6 @@ ...@@ -474,7 +468,6 @@
</fields> </fields>
<stepbeforeformdisplay>step8_stepbeforeformdisplay();</stepbeforeformdisplay> <stepbeforeformdisplay>step8_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step8_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step8_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>9</id> <id>9</id>
...@@ -576,7 +569,6 @@ ...@@ -576,7 +569,6 @@
</fields> </fields>
<stepbeforeformdisplay>step9_stepbeforeformdisplay();</stepbeforeformdisplay> <stepbeforeformdisplay>step9_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step9_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step9_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>10</id> <id>10</id>
...@@ -911,7 +903,6 @@ ...@@ -911,7 +903,6 @@
</fields> </fields>
<stepbeforeformdisplay>step10_stepbeforeformdisplay();</stepbeforeformdisplay> <stepbeforeformdisplay>step10_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step10_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step10_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>11</id> <id>11</id>
...@@ -979,6 +970,5 @@ ...@@ -979,6 +970,5 @@
</field> </field>
</fields> </fields>
<stepsubmitphpaction>step12_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step12_submitphpaction();</stepsubmitphpaction>
<includefile>openvpn_wizard.inc</includefile>
</step> </step>
</opnsensewizard> </opnsensewizard>
...@@ -477,11 +477,9 @@ ...@@ -477,11 +477,9 @@
</stepsubmitphpaction> </stepsubmitphpaction>
<stepsubmitbeforesave> <stepsubmitbeforesave>
<![CDATA[ <![CDATA[
$_POST['ipaddress'] = $_POST['selectedtype']; if ($_POST['selectedtype'] != "Static") {
$config['interfaces']['wan']['ipaddr'] = $_POST['selectedtype']; $_POST['ipaddress'] = $_POST['selectedtype'];
write_config(); $config['interfaces']['wan']['ipaddr'] = $_POST['selectedtype'];
if (!isset($config['interfaces']['lan'])) {
header("Location: /wizard.php?xml=setup&stepid=5");
} }
]]> ]]>
</stepsubmitbeforesave> </stepsubmitbeforesave>
...@@ -496,6 +494,7 @@ ...@@ -496,6 +494,7 @@
<type>input</type> <type>input</type>
<bindstofield>interfaces->lan->ipaddr</bindstofield> <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> <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> <message>LAN IP Address field is invalid</message>
</field> </field>
<field> <field>
...@@ -510,23 +509,31 @@ ...@@ -510,23 +509,31 @@
</fields> </fields>
<stepsubmitphpaction> <stepsubmitphpaction>
<![CDATA[ <![CDATA[
if(empty($_POST['lanipaddress']) || !is_ipaddr($_POST['lanipaddress'])) { if (!empty(trim($_POST['lanipaddress']))) {
print_info_box_np("Invalid LAN IP Address. Please press back in your browser window and correct."); if (!is_ipaddr($_POST['lanipaddress'])) {
die; 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']))) { if ($_POST['subnetmask'] < 31 &&
print_info_box_np("Invalid LAN IP Address. Please press back in your browser window and correct."); ($_POST['lanipaddress'] == gen_subnet($_POST['lanipaddress'], $_POST['subnetmask']) ||
die; $_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";
$highestip = gen_subnet_max($_POST['lanipaddress'], $config['interfaces']['lan']['subnet']);
$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']);
}
} }
$ft = explode(".", $_POST['lanipaddress']);
$ft_ip = $ft[0] . "." . $ft[1] . "." . $ft[2] . ".";
$config['dhcpd']['lan']['range']['from'] = $ft_ip . "10";
$highestip = gen_subnet_max($_POST['lanipaddress'], $config['interfaces']['lan']['subnet']);
$hi = explode(".", $highestip);
$highestip = $hi[3]-10;
$config['dhcpd']['lan']['range']['to'] = $ft_ip . $highestip;
]]> ]]>
</stepsubmitphpaction> </stepsubmitphpaction>
</step> </step>
......
...@@ -89,10 +89,9 @@ if (isset($_GET['xml'])) { ...@@ -89,10 +89,9 @@ if (isset($_GET['xml'])) {
*/ */
switch ($xml) { switch ($xml) {
case 'openvpn': case 'openvpn':
$xml = 'openvpn.xml';
break; break;
default: default:
$xml = 'setup.xml'; $xml = 'setup';
break; break;
} }
...@@ -122,7 +121,7 @@ $listtags = array_flip(array( ...@@ -122,7 +121,7 @@ $listtags = array_flip(array(
'template', '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)) { if (!is_array($pkg)) {
print_info_box_np(sprintf(gettext("ERROR: Could not parse %s wizard file."), $xml)); print_info_box_np(sprintf(gettext("ERROR: Could not parse %s wizard file."), $xml));
die; die;
...@@ -132,11 +131,9 @@ $description = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$step ...@@ -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']); $title = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['title']);
$totalsteps = $pkg['totalsteps']; $totalsteps = $pkg['totalsteps'];
if ($pkg['includefile']) if ($pkg['includefile']) {
require_once($pkg['includefile']); require_once($pkg['includefile']);
}
if ($pkg['step'][$stepid]['includefile'])
require_once($pkg['step'][$stepid]['includefile']);
if($pkg['step'][$stepid]['stepsubmitbeforesave']) { if($pkg['step'][$stepid]['stepsubmitbeforesave']) {
eval($pkg['step'][$stepid]['stepsubmitbeforesave']); eval($pkg['step'][$stepid]['stepsubmitbeforesave']);
...@@ -726,11 +723,19 @@ function showchange() { ...@@ -726,11 +723,19 @@ function showchange() {
if(!$field['dontcombinecells']) if(!$field['dontcombinecells'])
echo "<td class=\"vtable\">"; echo "<td class=\"vtable\">";
echo "<select class='form-control' name='{$name}' style='max-width:5em;'>\n"; echo "<select class='form-control' name='{$name}' style='max-width:5em;'>\n";
for($x=1; $x<33; $x++) { $CHECKED = ' selected="selected"';
$CHECKED = ""; for ($x = 1; $x <= 32; $x++) {
if($value == $x) $CHECKED = " selected=\"selected\""; if ($x == 31) {
if($x <> 31) continue;
echo "<option value='{$x}' {$CHECKED}>{$x}</option>\n"; }
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"; 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