aboutsummaryrefslogtreecommitdiffstats
path: root/config/pfflowd.xml
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2011-04-29 10:44:53 -0400
committerjim-p <jimp@pfsense.org>2011-04-29 10:45:47 -0400
commitd186202dfa508cde7887c55f49d8385f76afba9b (patch)
treeaeeb3d73036d92c3d77f4d0dbc873bb952730adb /config/pfflowd.xml
parent86f69114fe89f3915d17e7937b7c146d743aee77 (diff)
downloadpfsense-packages-d186202dfa508cde7887c55f49d8385f76afba9b.tar.gz
pfsense-packages-d186202dfa508cde7887c55f49d8385f76afba9b.tar.bz2
pfsense-packages-d186202dfa508cde7887c55f49d8385f76afba9b.zip
Cleanup any potentially empty/redundant pfflowd config entries before loading the form to edit settings. While I'm here, add input validation for required fields.
Diffstat (limited to 'config/pfflowd.xml')
-rw-r--r--config/pfflowd.xml35
1 files changed, 32 insertions, 3 deletions
diff --git a/config/pfflowd.xml b/config/pfflowd.xml
index 6f2c7a0f..f8552189 100644
--- a/config/pfflowd.xml
+++ b/config/pfflowd.xml
@@ -77,11 +77,12 @@
</field>
</fields>
<custom_php_global_functions>
+ <![CDATA[
function sync_package_pfflowd() {
conf_mount_rw();
- config_lock();
- global $config;
- foreach($config['installedpackages']['pfflowd']['config'] as $cf) {
+ config_lock();
+ global $config;
+ foreach($config['installedpackages']['pfflowd']['config'] as $cf) {
if($cf['host'] != "") {
$start = "\n/sbin/ifconfig pfsync0 up\n";
$start .= "/usr/local/sbin/pfflowd ";
@@ -107,8 +108,36 @@
conf_mount_ro();
config_unlock();
}
+
+ function validate_form_pfflowd($post, $input_errors) {
+ if(($post['host'] == "") || !is_ipaddr($post['host']))
+ $input_errors[] = 'You must specify a valid ip address in the \'Host\' field';
+ if(($post['port'] == "") || !is_port($post['port']))
+ $input_errors[] = 'You must specify a valid port number in the \'Port\' field';
+ }
+
+ function cleanup_config_pfflowd() {
+ global $a_pkg;
+ $pffconf = array();
+ if (is_array($a_pkg)) {
+ foreach($a_pkg as $cf) {
+ if($cf['host'] != "") {
+ $pffconf = $cf;
+ }
+ }
+ }
+ $a_pkg = array();
+ $a_pkg[0] = $pffconf;
+ }
+ ]]>
</custom_php_global_functions>
<custom_php_resync_config_command>
sync_package_pfflowd();
</custom_php_resync_config_command>
+ <custom_php_validation_command>
+ validate_form_pfflowd($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+ <custom_php_command_before_form>
+ cleanup_config_pfflowd();
+ </custom_php_command_before_form>
</packagegui>