Commit f5eb5ea8 authored by Franco Fichtner's avatar Franco Fichtner

wizard: some sanity improvements

o We could potentially pass files using xml=../../xxx, so just
  hardcode the wizards we know for now.  I don't expect them to
  grow, otherwise we may be able to do a directory expand.

o Move xml files out of the /usr/local/www/wizards into /usr/local/wizard.

o Move the include file to the normal include path /usr/local/etc/inc.

o Allow the menu to always expand to the setup wizard, even though
  we many be triggering the OpenVPN wizard.  This gives a consistent
  feel of navigation, especially since POST requests hide the invoked
  wizard later on anyway.
parent 381fc845
<?php <?php
/* /*
Copyright (C) 2010 Ermal Luçi Copyright (C) 2010 Ermal Luçi
All rights reserved. All rights reserved.
...@@ -442,7 +443,7 @@ function step12_submitphpaction() { ...@@ -442,7 +443,7 @@ function step12_submitphpaction() {
if (!is_array($config['ovpnserver'])) { if (!is_array($config['ovpnserver'])) {
$message = "No configuration found please retry again."; $message = "No configuration found please retry again.";
header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1&message={$message}"); header("Location:wizard.php?xml=openvpn&stepid=1&message={$message}");
exit; exit;
} }
...@@ -484,11 +485,11 @@ function step12_submitphpaction() { ...@@ -484,11 +485,11 @@ function step12_submitphpaction() {
$config['system']['authserver'][] = $auth; $config['system']['authserver'][] = $auth;
} else if (!isset($pconfig['step2']['uselist']) && empty($pconfig['step2']['authserv'])) { } else if (!isset($pconfig['step2']['uselist']) && empty($pconfig['step2']['authserv'])) {
$message = "Please choose an authentication server ."; $message = "Please choose an authentication server .";
header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1&message={$message}"); header("Location:wizard.php?xml=openvpn&stepid=1&message={$message}");
exit; exit;
} else if (!($auth = auth_get_authserver($pconfig['step2']['authserv']))) { } else if (!($auth = auth_get_authserver($pconfig['step2']['authserv']))) {
$message = "Not a valid authentication server has been specified."; $message = "Not a valid authentication server has been specified.";
header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1&message={$message}"); header("Location:wizard.php?xml=openvpn&stepid=1&message={$message}");
exit; exit;
} }
...@@ -511,11 +512,11 @@ function step12_submitphpaction() { ...@@ -511,11 +512,11 @@ function step12_submitphpaction() {
$config['ca'][] = $ca; $config['ca'][] = $ca;
} else if (!isset($pconfig['step6']['uselist']) && empty($pconfig['step6']['authcertca'])) { } else if (!isset($pconfig['step6']['uselist']) && empty($pconfig['step6']['authcertca'])) {
$message = "Please choose a Certificate Authority."; $message = "Please choose a Certificate Authority.";
header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=5&message={$message}"); header("Location:wizard.php?xml=openvpn&stepid=5&message={$message}");
exit; exit;
} else if (!($ca = lookup_ca($pconfig['step6']['authcertca']))) { } else if (!($ca = lookup_ca($pconfig['step6']['authcertca']))) {
$message = "Not a valid Certificate Authority specified."; $message = "Not a valid Certificate Authority specified.";
header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=5&message={$message}"); header("Location:wizard.php?xml=openvpn&stepid=5&message={$message}");
exit; exit;
} }
...@@ -538,11 +539,11 @@ function step12_submitphpaction() { ...@@ -538,11 +539,11 @@ function step12_submitphpaction() {
$config['cert'][] = $cert; $config['cert'][] = $cert;
} else if (!isset($pconfig['step9']['uselist']) && empty($pconfig['step9']['authcertname'])) { } else if (!isset($pconfig['step9']['uselist']) && empty($pconfig['step9']['authcertname'])) {
$message = "Please choose a Certificate."; $message = "Please choose a Certificate.";
header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=7&message={$message}"); header("Location:wizard.php?xml=openvpn&stepid=7&message={$message}");
exit; exit;
} else if (!($cert = lookup_cert($pconfig['step9']['authcertname']))) { } else if (!($cert = lookup_cert($pconfig['step9']['authcertname']))) {
$message = "Not a valid Certificate specified."; $message = "Not a valid Certificate specified.";
header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=7&message={$message}"); header("Location:wizard.php?xml=openvpn&stepid=7&message={$message}");
exit; exit;
} }
$server = array(); $server = array();
......
...@@ -54,7 +54,9 @@ ...@@ -54,7 +54,9 @@
<System_Tunables VisibleName="System Tunables" url="/system_advanced_sysctl.php"/> <System_Tunables VisibleName="System Tunables" url="/system_advanced_sysctl.php"/>
<Notifications url="/system_advanced_notifications.php"/> <Notifications url="/system_advanced_notifications.php"/>
</Settings> </Settings>
<SetupWizard VisibleName="Setup Wizard" url="/wizard.php?xml=setup_wizard.xml"/> <SetupWizard VisibleName="Setup Wizard" url="/wizard.php">
<Step url="/wizard.php*"/>
</SetupWizard>
<UserManager VisibleName="User Manager" url="/system_usermanager.php"> <UserManager VisibleName="User Manager" url="/system_usermanager.php">
<Users url="/system_usermanager.php"/> <Users url="/system_usermanager.php"/>
<Groups url="/system_groupmanager.php"/> <Groups url="/system_groupmanager.php"/>
...@@ -206,7 +208,6 @@ ...@@ -206,7 +208,6 @@
<ServerEdit url="/vpn_openvpn_server.php?*"/> <ServerEdit url="/vpn_openvpn_server.php?*"/>
<Client url="/vpn_openvpn_client.php*"/> <Client url="/vpn_openvpn_client.php*"/>
<CSC url="/vpn_openvpn_csc.php*"/> <CSC url="/vpn_openvpn_csc.php*"/>
<Wizards url="/wizard.php?xml=openvpn_wizard.xml"/>
<ClientExport url="/vpn_openvpn_export.php*"/> <ClientExport url="/vpn_openvpn_export.php*"/>
<SharedKeyExport url="/vpn_openvpn_export_shared.php"/> <SharedKeyExport url="/vpn_openvpn_export_shared.php"/>
</OpenVPN> </OpenVPN>
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
</field> </field>
</fields> </fields>
<stepsubmitphpaction>step1_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step1_submitphpaction();</stepsubmitphpaction>
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> <includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>2</id> <id>2</id>
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
<stepbeforeformdisplay>step2_stepbeforeformdisplay();</stepbeforeformdisplay> <stepbeforeformdisplay>step2_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step2_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step2_submitphpaction();</stepsubmitphpaction>
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay> <javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> <includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>3</id> <id>3</id>
...@@ -229,7 +229,7 @@ ...@@ -229,7 +229,7 @@
</fields> </fields>
<stepsubmitphpaction>step3_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step3_submitphpaction();</stepsubmitphpaction>
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay> <javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> <includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>4</id> <id>4</id>
...@@ -265,7 +265,7 @@ ...@@ -265,7 +265,7 @@
<stepbeforeformdisplay>step4_stepbeforeformdisplay();</stepbeforeformdisplay> <stepbeforeformdisplay>step4_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step4_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step4_submitphpaction();</stepsubmitphpaction>
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay> <javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> <includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>5</id> <id>5</id>
...@@ -314,7 +314,7 @@ ...@@ -314,7 +314,7 @@
</field> </field>
</fields> </fields>
<stepsubmitphpaction>step5_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step5_submitphpaction();</stepsubmitphpaction>
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> <includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>6</id> <id>6</id>
...@@ -343,7 +343,7 @@ ...@@ -343,7 +343,7 @@
</fields> </fields>
<stepbeforeformdisplay>step6_stepbeforeformdisplay();</stepbeforeformdisplay> <stepbeforeformdisplay>step6_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step6_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step6_submitphpaction();</stepsubmitphpaction>
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> <includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>7</id> <id>7</id>
...@@ -444,7 +444,7 @@ ...@@ -444,7 +444,7 @@
</field> </field>
</fields> </fields>
<stepsubmitphpaction>step7_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step7_submitphpaction();</stepsubmitphpaction>
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> <includefile>openvpn_wizard.inc</includefile>
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay> <javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
</step> </step>
<step> <step>
...@@ -474,7 +474,7 @@ ...@@ -474,7 +474,7 @@
</fields> </fields>
<stepbeforeformdisplay>step8_stepbeforeformdisplay();</stepbeforeformdisplay> <stepbeforeformdisplay>step8_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step8_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step8_submitphpaction();</stepsubmitphpaction>
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> <includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>9</id> <id>9</id>
...@@ -576,7 +576,7 @@ ...@@ -576,7 +576,7 @@
</fields> </fields>
<stepbeforeformdisplay>step9_stepbeforeformdisplay();</stepbeforeformdisplay> <stepbeforeformdisplay>step9_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step9_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step9_submitphpaction();</stepsubmitphpaction>
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> <includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>10</id> <id>10</id>
...@@ -911,7 +911,7 @@ ...@@ -911,7 +911,7 @@
</fields> </fields>
<stepbeforeformdisplay>step10_stepbeforeformdisplay();</stepbeforeformdisplay> <stepbeforeformdisplay>step10_stepbeforeformdisplay();</stepbeforeformdisplay>
<stepsubmitphpaction>step10_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step10_submitphpaction();</stepsubmitphpaction>
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> <includefile>openvpn_wizard.inc</includefile>
</step> </step>
<step> <step>
<id>11</id> <id>11</id>
...@@ -979,6 +979,6 @@ ...@@ -979,6 +979,6 @@
</field> </field>
</fields> </fields>
<stepsubmitphpaction>step12_submitphpaction();</stepsubmitphpaction> <stepsubmitphpaction>step12_submitphpaction();</stepsubmitphpaction>
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> <includefile>openvpn_wizard.inc</includefile>
</step> </step>
</opnsensewizard> </opnsensewizard>
...@@ -484,7 +484,7 @@ ...@@ -484,7 +484,7 @@
$config['interfaces']['wan']['ipaddr'] = $_POST['selectedtype']; $config['interfaces']['wan']['ipaddr'] = $_POST['selectedtype'];
write_config(); write_config();
if(!$config['interfaces']['lan']) if(!$config['interfaces']['lan'])
header("Location: /wizard.php?xml=setup_wizard.xml&stepid=6&next=Next"); header("Location: /wizard.php?xml=setup&stepid=6&next=Next");
} }
]]> ]]>
</stepsubmitbeforesave> </stepsubmitbeforesave>
...@@ -622,7 +622,7 @@ ...@@ -622,7 +622,7 @@
<title>Reload in progress</title> <title>Reload in progress</title>
<description> <description>
A reload is now in progress. Please wait. &lt;p&gt; A reload is now in progress. Please wait. &lt;p&gt;
&lt;meta http-equiv="refresh" content="5; url=wizard.php?xml=setup_wizard.xml&amp;stepid=8" &gt; &lt;meta http-equiv="refresh" content="5; url=wizard.php?xml=setup&amp;stepid=8" &gt;
&lt;p&gt; &lt;p&gt;
The wizard will redirect to the next step once the reload is completed. The wizard will redirect to the next step once the reload is completed.
</description> </description>
......
...@@ -400,7 +400,7 @@ if (isset($config['trigger_initial_wizard'])) : ...@@ -400,7 +400,7 @@ if (isset($config['trigger_initial_wizard'])) :
</div> </div>
</div> </div>
</section> </section>
<meta http-equiv="refresh" content="3;url=wizard.php?xml=setup_wizard.xml"> <meta http-equiv="refresh" content="3;url=wizard.php">
<?php exit; ?> <?php exit; ?>
<?php <?php
endif; ?> endif; ?>
......
...@@ -1771,7 +1771,7 @@ else : ...@@ -1771,7 +1771,7 @@ else :
</tbody> </tbody>
<tfoot> <tfoot>
<tr><td colspan="5"> <tr><td colspan="5">
<a href="wizard.php?xml=openvpn_wizard.xml" class="btn btn-default btn-xs"><span class="fa fa-magic"></span></a> <a href="wizard.php?xml=openvpn" class="btn btn-default btn-xs"><span class="fa fa-magic"></span></a>
&nbsp;<?=gettext("Use a wizard to setup a new server");?> &nbsp;<?=gettext("Use a wizard to setup a new server");?>
</td></tr> </td></tr>
</tfoot> </tfoot>
......
...@@ -70,41 +70,67 @@ function find_ip_interface($ip, $bits = null) { ...@@ -70,41 +70,67 @@ function find_ip_interface($ip, $bits = null) {
} }
global $g;
$stepid = htmlspecialchars($_GET['stepid']); $stepid = htmlspecialchars($_GET['stepid']);
if (isset($_POST['stepid'])) if (isset($_POST['stepid']))
$stepid = htmlspecialchars($_POST['stepid']); $stepid = htmlspecialchars($_POST['stepid']);
if (!$stepid) if (!$stepid)
$stepid = "0"; $stepid = "0";
$xml = htmlspecialchars($_GET['xml']); $xml = '';
if($_POST['xml']) if (isset($_GET['xml'])) {
$xml = htmlspecialchars($_GET['xml']);
} elseif (isset($_POST['xml'])) {
$xml = htmlspecialchars($_POST['xml']); $xml = htmlspecialchars($_POST['xml']);
}
if(empty($xml)) { /*
$xml = "not_defined"; * XXX If we don't want hardcoding we could
print_info_box_np(sprintf(gettext("ERROR: Could not open %s."), $xml)); * probe /usr/local/wizard for viable files.
die; */
} else { switch ($xml) {
if (file_exists("/usr/local/www/wizards/{$xml}")) { case 'openvpn':
global $listtags ; $xml = 'openvpn.xml';
$listtags = array_flip(array('build_port_path', 'depends_on_package', 'onetoone', 'queue', 'rule', 'servernat', 'alias', 'additional_files_needed', 'tab', 'template', 'menu', 'rowhelperfield', 'service', 'step', 'package', 'columnitem', 'option', 'item', 'field', 'package', 'file')); break;
$pkg = parse_xml_config_raw('/usr/local/www/wizards/' . $xml, 'opnsensewizard', false); default:
} else { $xml = 'setup.xml';
print_info_box_np(sprintf(gettext("ERROR: Could not open %s."), $xml)); break;
die;
}
} }
global $g, $listtags;
$listtags = array_flip(array(
'additional_files_needed',
'alias',
'build_port_path',
'columnitem',
'depends_on_package',
'field',
'file',
'item',
'menu',
'onetoone',
'option',
'package',
'package',
'queue',
'rowhelperfield',
'rule',
'servernat',
'service',
'step',
'tab',
'template',
));
$pkg = parse_xml_config_raw('/usr/local/wizard/' . $xml, 'opnsensewizard', false);
if (!is_array($pkg)) { if (!is_array($pkg)) {
print_info_box_np(sprintf(gettext("ERROR: Could not parse /usr/local/www/wizards/%s file."), $xml)); print_info_box_np(sprintf(gettext("ERROR: Could not parse %s wizard file."), $xml));
die; die;
} }
$title = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['title']);
$description = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['description']); $description = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['description']);
$totalsteps = $pkg['totalsteps']; $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']); require_once($pkg['includefile']);
......
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