The wizard system now works!

This commit is contained in:
Scott Ullrich 2004-12-18 20:24:50 +00:00
parent 57333fa05a
commit e48fc17dce
2 changed files with 53 additions and 29 deletions

View File

@ -56,19 +56,40 @@ $title = $pkg['step'][$stepid]['title'];
$description = $pkg['step'][$stepid]['description'];
if ($_POST) {
foreach ($pkg['step'][$stepid]['fields'] as $field) {
if($field['bindtofield'] <> "") {
// update field with posted values.
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
if($field['bindstofield'] <> "" and $field['type'] <> "submit") {
$fieldname = $field['name'];
$unset_fields = "";
$fieldname = ereg_replace(" ", "", $fieldname);
$fieldname = strtolower($fieldname);
// update field with posted values.
if($field['unsetfield'] <> "") $unset_fields = "yes";
if($field['bindstofield'])
update_config_field( $field['bindstofield'], $_POST[$fieldname], $unset_fields);
}
if($pkg['step'][$stepid]['stepsubmitphpaction']) {
eval($pkg['step'][$stepid]['stepsubmitphpaction']);
// run custom php code embedded in xml config.
eval($pkg['step'][$stepid]['stepsubmitphpaction']);
}
write_config();
}
$stepid++;
}
function update_config_field($field, $updatetext) {
$config[$field] = $updatetext;
function update_config_field($field, $updatetext, $unset) {
global $config;
$field_split = split("->",$field);
foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
if($field_conv == "") return;
if($unset <> "") {
$text = "unset(\$config" . $field_conv . ");";
eval($text);
$text = "\$config" . $field_conv . "[] = \"" . $updatetext . "\";";
eval($text);
} else {
$text = "\$config" . $field_conv . "[] = \"" . $updatetext . "\";";
eval($text);
}
}
?>
@ -81,19 +102,18 @@ function update_config_field($field, $updatetext) {
</head>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php
$config_tmp = $config;
$config = $pfSense_config;
include("fbegin.inc");
$config = $config_tmp;
?>
<p class="pgtitle"><?=$title?></p>
<form action="wizard.php" method="post">
<input type="hidden" name="xml" value="<?= $xml ?>">
<input type="hidden" name="stepid" value="<?= $stepid+1 ?>">
<input type="hidden" name="stepid" value="<?= $stepid ?>">
<?php if ($savemsg) print_info_box($savemsg); ?>
<table width="100%" border="1" cellpadding="6" cellspacing="0">
<center>
&nbsp;<br>
<img src="/logo.gif"><p>
<table width="500" border="1" cellpadding="6" cellspacing="0">
<tr>
<td bgcolor="#990000">
<font color="white"><center><b><?= $title ?></b></center></font>
@ -142,7 +162,7 @@ $config = $config_tmp;
echo ":</td><td>";
echo "<textarea name='" . $name . ">" . $value . "</textarea>\n";
} else if ($field['type'] == "submit") {
echo "<tr><td>&nbsp;</td></tr>";
echo "<tr><td>&nbsp;<br></td></tr>";
echo "<tr><td colspan='2'><center>";
echo "<input type='submit' name='" . $name . "' value='" . $field['name'] . "'>\n";
echo "</td><td>";
@ -152,12 +172,11 @@ $config = $config_tmp;
}
?>
</table>
&nbsp;<br>&nbsp;
&nbsp;<br>&nbsp;
</td>
</tr>
</table>
</form>
<?php include("fend.inc"); ?>
</body>
</html>

View File

@ -1,13 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<pfSenseWizard>
<pfsensewizard>
<totalsteps>2</totalsteps>
<step>
<id>1</id>
<title>pfSense Setup Wizard</title>
<description>This wizard will guide you through installing pfSense initially.</description>
<fields>
<name>Next</name>
<type>submit</type>
<field>
<name>Next</name>
<type>submit</type>
</field>
</fields>
</step>
<step>
@ -18,10 +20,14 @@
<field>
<name>Primary DNS Server</name>
<type>input</type>
<bindstofield>system->dnsserver</bindstofield>
<!-- we must unset the fields because this is an array. -->
<unsetfield>yes</unsetfield>
</field>
<field>
<name>Secondary DNS Server</name>
<type>input</type>
<bindstofield>system->dnsserver</bindstofield>
</field>
<field>
<name>Next</name>
@ -1696,16 +1702,16 @@
</field>
</fields>
<stepsubmitphpaction>
mwxec("date " . $_POST['Date'] . $_POST['Time']);
system("date " . $_POST['Date'] . $_POST['Time']);
</stepsubmitphpaction>
</step>
<step>
<id>4</id>
<title>Configure WAN</title>
<title>Configure WAN Interface</title>
<description>On this screen we will configure the Wide Area Network information.</description>
<fields>
<field>
<name>WAN IP Address:</name>
<name>WAN IP Address</name>
<type>input</type>
</field>
<field>
@ -1850,11 +1856,11 @@
</step>
<step>
<id>5</id>
<title>Configure LAN</title>
<title>Configure LAN Interface</title>
<description>On this screen we will configure the Local Area Network information.</description>
<fields>
<field>
<name>LAN IP Address:</name>
<name>LAN IP Address</name>
<type>input</type>
</field>
<field>
@ -1989,7 +1995,6 @@
<name>32</name>
<value>32</value>
</option>
</options>
</field>
</fields>
@ -2020,4 +2025,4 @@
</field>
</fields>
</step>
</pfSenseWizard>
</pfsensewizard>