mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 00:24:40 +00:00
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.
This commit is contained in:
parent
381fc84511
commit
f5eb5ea80e
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2010 Ermal Luçi
|
||||
All rights reserved.
|
||||
@ -442,7 +443,7 @@ function step12_submitphpaction() {
|
||||
|
||||
if (!is_array($config['ovpnserver'])) {
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -484,11 +485,11 @@ function step12_submitphpaction() {
|
||||
$config['system']['authserver'][] = $auth;
|
||||
} else if (!isset($pconfig['step2']['uselist']) && empty($pconfig['step2']['authserv'])) {
|
||||
$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;
|
||||
} else if (!($auth = auth_get_authserver($pconfig['step2']['authserv']))) {
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -511,11 +512,11 @@ function step12_submitphpaction() {
|
||||
$config['ca'][] = $ca;
|
||||
} else if (!isset($pconfig['step6']['uselist']) && empty($pconfig['step6']['authcertca'])) {
|
||||
$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;
|
||||
} else if (!($ca = lookup_ca($pconfig['step6']['authcertca']))) {
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -538,11 +539,11 @@ function step12_submitphpaction() {
|
||||
$config['cert'][] = $cert;
|
||||
} else if (!isset($pconfig['step9']['uselist']) && empty($pconfig['step9']['authcertname'])) {
|
||||
$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;
|
||||
} else if (!($cert = lookup_cert($pconfig['step9']['authcertname']))) {
|
||||
$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;
|
||||
}
|
||||
$server = array();
|
||||
@ -54,7 +54,9 @@
|
||||
<System_Tunables VisibleName="System Tunables" url="/system_advanced_sysctl.php"/>
|
||||
<Notifications url="/system_advanced_notifications.php"/>
|
||||
</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">
|
||||
<Users url="/system_usermanager.php"/>
|
||||
<Groups url="/system_groupmanager.php"/>
|
||||
@ -206,7 +208,6 @@
|
||||
<ServerEdit url="/vpn_openvpn_server.php?*"/>
|
||||
<Client url="/vpn_openvpn_client.php*"/>
|
||||
<CSC url="/vpn_openvpn_csc.php*"/>
|
||||
<Wizards url="/wizard.php?xml=openvpn_wizard.xml"/>
|
||||
<ClientExport url="/vpn_openvpn_export.php*"/>
|
||||
<SharedKeyExport url="/vpn_openvpn_export_shared.php"/>
|
||||
</OpenVPN>
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
</field>
|
||||
</fields>
|
||||
<stepsubmitphpaction>step1_submitphpaction();</stepsubmitphpaction>
|
||||
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile>
|
||||
<includefile>openvpn_wizard.inc</includefile>
|
||||
</step>
|
||||
<step>
|
||||
<id>2</id>
|
||||
@ -102,7 +102,7 @@
|
||||
<stepbeforeformdisplay>step2_stepbeforeformdisplay();</stepbeforeformdisplay>
|
||||
<stepsubmitphpaction>step2_submitphpaction();</stepsubmitphpaction>
|
||||
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
|
||||
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile>
|
||||
<includefile>openvpn_wizard.inc</includefile>
|
||||
</step>
|
||||
<step>
|
||||
<id>3</id>
|
||||
@ -229,7 +229,7 @@
|
||||
</fields>
|
||||
<stepsubmitphpaction>step3_submitphpaction();</stepsubmitphpaction>
|
||||
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
|
||||
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile>
|
||||
<includefile>openvpn_wizard.inc</includefile>
|
||||
</step>
|
||||
<step>
|
||||
<id>4</id>
|
||||
@ -265,7 +265,7 @@
|
||||
<stepbeforeformdisplay>step4_stepbeforeformdisplay();</stepbeforeformdisplay>
|
||||
<stepsubmitphpaction>step4_submitphpaction();</stepsubmitphpaction>
|
||||
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
|
||||
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile>
|
||||
<includefile>openvpn_wizard.inc</includefile>
|
||||
</step>
|
||||
<step>
|
||||
<id>5</id>
|
||||
@ -314,7 +314,7 @@
|
||||
</field>
|
||||
</fields>
|
||||
<stepsubmitphpaction>step5_submitphpaction();</stepsubmitphpaction>
|
||||
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile>
|
||||
<includefile>openvpn_wizard.inc</includefile>
|
||||
</step>
|
||||
<step>
|
||||
<id>6</id>
|
||||
@ -343,7 +343,7 @@
|
||||
</fields>
|
||||
<stepbeforeformdisplay>step6_stepbeforeformdisplay();</stepbeforeformdisplay>
|
||||
<stepsubmitphpaction>step6_submitphpaction();</stepsubmitphpaction>
|
||||
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile>
|
||||
<includefile>openvpn_wizard.inc</includefile>
|
||||
</step>
|
||||
<step>
|
||||
<id>7</id>
|
||||
@ -444,7 +444,7 @@
|
||||
</field>
|
||||
</fields>
|
||||
<stepsubmitphpaction>step7_submitphpaction();</stepsubmitphpaction>
|
||||
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile>
|
||||
<includefile>openvpn_wizard.inc</includefile>
|
||||
<javascriptafterformdisplay>enablechange();</javascriptafterformdisplay>
|
||||
</step>
|
||||
<step>
|
||||
@ -474,7 +474,7 @@
|
||||
</fields>
|
||||
<stepbeforeformdisplay>step8_stepbeforeformdisplay();</stepbeforeformdisplay>
|
||||
<stepsubmitphpaction>step8_submitphpaction();</stepsubmitphpaction>
|
||||
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile>
|
||||
<includefile>openvpn_wizard.inc</includefile>
|
||||
</step>
|
||||
<step>
|
||||
<id>9</id>
|
||||
@ -576,7 +576,7 @@
|
||||
</fields>
|
||||
<stepbeforeformdisplay>step9_stepbeforeformdisplay();</stepbeforeformdisplay>
|
||||
<stepsubmitphpaction>step9_submitphpaction();</stepsubmitphpaction>
|
||||
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile>
|
||||
<includefile>openvpn_wizard.inc</includefile>
|
||||
</step>
|
||||
<step>
|
||||
<id>10</id>
|
||||
@ -911,7 +911,7 @@
|
||||
</fields>
|
||||
<stepbeforeformdisplay>step10_stepbeforeformdisplay();</stepbeforeformdisplay>
|
||||
<stepsubmitphpaction>step10_submitphpaction();</stepsubmitphpaction>
|
||||
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile>
|
||||
<includefile>openvpn_wizard.inc</includefile>
|
||||
</step>
|
||||
<step>
|
||||
<id>11</id>
|
||||
@ -979,6 +979,6 @@
|
||||
</field>
|
||||
</fields>
|
||||
<stepsubmitphpaction>step12_submitphpaction();</stepsubmitphpaction>
|
||||
<includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile>
|
||||
<includefile>openvpn_wizard.inc</includefile>
|
||||
</step>
|
||||
</opnsensewizard>
|
||||
@ -484,7 +484,7 @@
|
||||
$config['interfaces']['wan']['ipaddr'] = $_POST['selectedtype'];
|
||||
write_config();
|
||||
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>
|
||||
@ -622,7 +622,7 @@
|
||||
<title>Reload in progress</title>
|
||||
<description>
|
||||
A reload is now in progress. Please wait. <p>
|
||||
<meta http-equiv="refresh" content="5; url=wizard.php?xml=setup_wizard.xml&stepid=8" >
|
||||
<meta http-equiv="refresh" content="5; url=wizard.php?xml=setup&stepid=8" >
|
||||
<p>
|
||||
The wizard will redirect to the next step once the reload is completed.
|
||||
</description>
|
||||
@ -400,7 +400,7 @@ if (isset($config['trigger_initial_wizard'])) :
|
||||
</div>
|
||||
</div>
|
||||
</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
|
||||
endif; ?>
|
||||
|
||||
@ -1771,7 +1771,7 @@ else :
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<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>
|
||||
<?=gettext("Use a wizard to setup a new server");?>
|
||||
</td></tr>
|
||||
</tfoot>
|
||||
|
||||
@ -70,41 +70,67 @@ function find_ip_interface($ip, $bits = null) {
|
||||
}
|
||||
|
||||
|
||||
global $g;
|
||||
|
||||
$stepid = htmlspecialchars($_GET['stepid']);
|
||||
if (isset($_POST['stepid']))
|
||||
$stepid = htmlspecialchars($_POST['stepid']);
|
||||
if (!$stepid)
|
||||
$stepid = "0";
|
||||
|
||||
$xml = htmlspecialchars($_GET['xml']);
|
||||
if($_POST['xml'])
|
||||
$xml = '';
|
||||
if (isset($_GET['xml'])) {
|
||||
$xml = htmlspecialchars($_GET['xml']);
|
||||
} elseif (isset($_POST['xml'])) {
|
||||
$xml = htmlspecialchars($_POST['xml']);
|
||||
|
||||
if(empty($xml)) {
|
||||
$xml = "not_defined";
|
||||
print_info_box_np(sprintf(gettext("ERROR: Could not open %s."), $xml));
|
||||
die;
|
||||
} else {
|
||||
if (file_exists("/usr/local/www/wizards/{$xml}")) {
|
||||
global $listtags ;
|
||||
$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'));
|
||||
$pkg = parse_xml_config_raw('/usr/local/www/wizards/' . $xml, 'opnsensewizard', false);
|
||||
} else {
|
||||
print_info_box_np(sprintf(gettext("ERROR: Could not open %s."), $xml));
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX If we don't want hardcoding we could
|
||||
* probe /usr/local/wizard for viable files.
|
||||
*/
|
||||
switch ($xml) {
|
||||
case 'openvpn':
|
||||
$xml = 'openvpn.xml';
|
||||
break;
|
||||
default:
|
||||
$xml = 'setup.xml';
|
||||
break;
|
||||
}
|
||||
|
||||
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)) {
|
||||
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;
|
||||
}
|
||||
|
||||
$title = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['title']);
|
||||
$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'])
|
||||
require_once($pkg['includefile']);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user