"submit") { $fieldname = $field['name']; $fieldname = str_replace(" ", "", $fieldname); $fieldname = strtolower($fieldname); // update field with posted values. if ($field['unsetfield'] <> "") { $unset_fields = "yes"; } else { $unset_fields = ""; } if ($field['arraynum'] <> "") { $arraynum = $field['arraynum']; } else { $arraynum = ""; } update_config_field($field['bindstofield'], $_POST[$fieldname], $unset_fields, $arraynum, $field['type']); } } // run custom php code embedded in xml config. if ($pkg['step'][$stepid]['stepsubmitphpaction'] <> "") { eval($pkg['step'][$stepid]['stepsubmitphpaction']); } if (!$input_errors) { write_config(); } $stepid++; if ($stepid > $totalsteps) { $stepid = $totalsteps; } } function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) { global $config; $field_split = explode("->", $field); foreach ($field_split as $f) { $field_conv .= "['" . $f . "']"; } if ($field_conv == "") { return; } if ($arraynum <> "") { $field_conv .= "[" . $arraynum . "]"; } if (($field_type == "checkbox" and $updatetext <> "on") || $updatetext == "") { /* * item is a checkbox, it should have the value "on" * if it was checked */ $var = "\$config{$field_conv}"; $text = "if (isset({$var})) unset({$var});"; eval($text); return; } if ($field_type == "interfaces_selection") { $var = "\$config{$field_conv}"; $text = "if (isset({$var})) unset({$var});"; $text .= "\$config" . $field_conv . " = \"" . $updatetext . "\";"; eval($text); return; } if ($unset == "yes") { $text = "unset(\$config" . $field_conv . ");"; eval($text); } $text = "\$config" . $field_conv . " = \"" . addslashes($updatetext) . "\";"; eval($text); } $title = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['title']); $description = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['description']); // handle before form display event. do { $oldstepid = $stepid; if ($pkg['step'][$stepid]['stepbeforeformdisplay'] <> "") { eval($pkg['step'][$stepid]['stepbeforeformdisplay']); } } while ($oldstepid != $stepid); $closehead = false; $pgtitle = array($title); include("head.inc"); if (file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) { echo "\n"; } else { echo ""; } ?> "") { ?>
 
"; ?> logo

 

 
"; } ?> "") { foreach ($pkg['step'][$stepid]['fields']['field'] as $field) { $value = $field['value']; $name = $field['name']; $name = preg_replace("/\s+/", "", $name); $name = strtolower($name); if ($field['bindstofield'] <> "") { $arraynum = ""; $field_conv = ""; $field_split = explode("->", $field['bindstofield']); // arraynum is used in cases where there is an array of the same field // name such as dnsserver (2 of them) if ($field['arraynum'] <> "") { $arraynum = "[" . $field['arraynum'] . "]"; } foreach ($field_split as $f) { $field_conv .= "['" . $f . "']"; } if ($field['type'] == "checkbox") { $toeval = "if (isset(\$config" . $field_conv . $arraynum . ")) { \$value = \$config" . $field_conv . $arraynum . "; if (empty(\$value)) \$value = true; }"; } else { $toeval = "if (isset(\$config" . $field_conv . $arraynum . ")) \$value = \$config" . $field_conv . $arraynum . ";"; } eval($toeval); } if (!$field['combinefieldsend']) { echo ""; } switch ($field['type']) { case "input": if ($field['displayname']) { echo "\n"; } else if (!$field['dontdisplayname']) { echo "\n"; } if (!$field['dontcombinecells']) { echo "\n"; } else if (!$field['dontdisplayname']) { echo "\n"; } if (!$field['dontcombinecells']) { echo ""; echo "\n"; } else if (!$field['dontdisplayname']) { echo "\n"; } if (!$field['dontcombinecells']) { echo ""; echo ""; echo "\n"; } else if (!$field['dontdisplayname']) { echo "\n"; } if ($field['size']) { $size = " size='" . $field['size'] . "' "; } if ($field['multiple'] == "yes") { $multiple = "multiple=\"multiple\" "; } if (!$field['dontcombinecells']) { echo "\n"; } else if (!$field['dontdisplayname']) { echo ""; } if (!$field['dontcombinecells']) { echo ""; echo ""; echo "\n"; } else if (!$field['dontdisplayname']) { echo ""; } if (!$field['dontcombinecells']) { echo "\n"; } else if (!$field['dontdisplayname']) { echo ""; } if (!$field['dontcombinecells']) { echo "\n"; } else if (!$field['dontdisplayname']) { echo ""; } $checked = ""; if ($value <> "") { $checked = " checked=\"checked\""; } echo ""; } echo "\n"; } } } ?>
 
" . fixup_string($title) . "
\n"; echo $field['displayname']; echo ":\n"; echo fixup_string($field['name']); echo ":\n"; } echo "\n"; if ($field['description'] <> "") { echo "
" . $field['description']; } break; case "text": echo "
\n"; if ($field['description'] <> "") { echo "

" . $field['description'] . "
"; } break; case "inputalias": if ($field['displayname']) { echo "
\n"; echo $field['displayname']; echo ":\n"; echo fixup_string($field['name']); echo ":\n"; } $inputaliases[] = $name; echo "\n"; if ($field['description'] <> "") { echo "
" . $field['description']; } break; case "interfaces_selection": case "interface_select": $size = ""; $multiple = ""; $name = strtolower($name); echo "
\n"; echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n"; echo "\n"; if ($field['size'] <> "") { $size = "size=\"{$field['size']}\""; } if ($field['multiple'] <> "" and $field['multiple'] <> "0") { $multiple = "multiple=\"multiple\""; $name .= "[]"; } echo "\n"; if ($field['description'] <> "") { echo "
" . $field['description']; } break; case "password": if ($field['displayname']) { echo "
\n"; echo $field['displayname']; echo ":\n"; echo fixup_string($field['name']); echo ":"; } echo "\n"; if ($field['description'] <> "") { echo "
" . $field['description']; } break; case "certca_selection": $size = ""; $multiple = ""; $name = strtolower($name); echo "
\n"; echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n"; echo "\n"; if ($field['size'] <> "") { $size = "size=\"{$field['size']}\""; } echo "\n"; if ($field['description'] <> "") { echo "
" . $field['description']; } break; case "cert_selection": $size = ""; $multiple = ""; $name = strtolower($name); echo "
\n"; echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n"; echo "\n"; if ($field['size'] <> "") { $size = "size=\"{$field['size']}\""; } echo "\n"; if ($field['description'] <> "") { echo "
" . $field['description']; } break; case "select": if ($field['displayname']) { echo "
\n"; echo $field['displayname']; echo ":\n"; echo fixup_string($field['name']); echo ":\n"; } $onchange = ""; foreach ($field['options']['option'] as $opt) { if ($opt['enablefields'] <> "") { $onchange = "onchange=\"enableitems(this.selectedIndex);\" "; } } echo "\n"; echo "\n"; if ($field['description'] <> "") { echo $field['description']; } break; case "textarea": if ($field['displayname']) { echo "\n"; echo $field['displayname']; echo ":\n"; echo fixup_string($field['name']); echo ":"; } echo "\n"; if ($field['description'] <> "") { echo "
" . $field['description']; } break; case "submit": echo "
 
"; echo "\n"; if ($field['description'] <> "") { echo "
" . $field['description']; } break; case "listtopic": echo "
 
" . $field['name'] . "
\n"; break; case "subnet_select": if ($field['displayname']) { echo "
\n"; echo $field['displayname']; echo ":\n"; echo fixup_string($field['name']); echo ":"; } echo "\n"; if ($field['description'] <> "") { echo "
" . $field['description']; } break; case "timezone_select": exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist); $timezonelist = array_filter($timezonelist, 'is_timezone'); sort($timezonelist); /* kill carriage returns */ for ($x = 0; $x < count($timezonelist); $x++) { $timezonelist[$x] = str_replace("\n", "", $timezonelist[$x]); } if ($field['displayname']) { echo "
\n"; echo $field['displayname']; echo ":\n"; echo fixup_string($field['name']); echo ":"; } echo "\n"; if ($field['description'] <> "") { echo "
" . $field['description']; } break; case "checkbox": if ($field['displayname']) { echo "
\n"; echo $field['displayname']; echo ":\n"; echo $field['name']; echo ":\n"; if ($field['description'] <> "") { echo $field['description']; } break; } if ($field['typehint'] <> "") { echo $field['typehint']; } if ($field['warning'] <> "") { echo "
" . $field['warning'] . ""; } if (!$field['combinefieldsbegin']) { if (!$field['dontcombinecells']) { echo "

 
"") { // create a fieldname loop that can be used with javascript // hide and enable features. echo "\n\n\n"; } ?> "") { // handle after form display event. eval($pkg['step'][$stepid]['stepafterformdisplay']); } if ($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") { // handle after form display event. echo "\n\n\n"; } /* * HELPER FUNCTIONS */ function fixup_string($string) { global $config, $g, $myurl, $title; $newstring = $string; // fixup #1: $myurl -> http[s]://ip_address:port/ switch ($config['system']['webgui']['protocol']) { case "http": $proto = "http"; break; case "https": $proto = "https"; break; default: $proto = "http"; break; } $port = $config['system']['webgui']['port']; if ($port != "") { if (($port == "443" and $proto != "https") or ($port == "80" and $proto != "http")) { $urlport = ":" . $port; } elseif ($port != "80" and $port != "443") { $urlport = ":" . $port; } else { $urlport = ""; } } $http_host = $_SERVER['SERVER_NAME']; $urlhost = $http_host; // If finishing the setup wizard, check if accessing on a LAN or WAN address that changed if ($title == "Reload in progress") { if (is_ipaddr($urlhost)) { $host_if = find_ip_interface($urlhost); if ($host_if) { $host_if = convert_real_interface_to_friendly_interface_name($host_if); if ($host_if && is_ipaddr($config['interfaces'][$host_if]['ipaddr'])) { $urlhost = $config['interfaces'][$host_if]['ipaddr']; } } } else if ($urlhost == $config['system']['hostname']) { $urlhost = $config['wizardtemp']['system']['hostname']; } else if ($urlhost == $config['system']['hostname'] . '.' . $config['system']['domain']) { $urlhost = $config['wizardtemp']['system']['hostname'] . '.' . $config['wizardtemp']['system']['domain']; } } if ($urlhost != $http_host) { file_put_contents("{$g['tmp_path']}/setupwizard_lastreferrer", $proto . "://" . $http_host . $urlport . $_SERVER['REQUEST_URI']); } $myurl = $proto . "://" . $urlhost . $urlport . "/"; if (strstr($newstring, "\$myurl")) { $newstring = str_replace("\$myurl", $myurl, $newstring); } // fixup #2: $wanip if (strstr($newstring, "\$wanip")) { $curwanip = get_interface_ip(); $newstring = str_replace("\$wanip", $curwanip, $newstring); } // fixup #3: $lanip if (strstr($newstring, "\$lanip")) { $lanip = get_interface_ip("lan"); $newstring = str_replace("\$lanip", $lanip, $newstring); } // fixup #4: fix'r'up here. return $newstring; } function is_timezone($elt) { return !preg_match("/\/$/", $elt); } ?>