summaryrefslogtreecommitdiffstats
path: root/usr/local/www/load_balancer_pool_edit.php
diff options
context:
space:
mode:
authorBill Marquette <billm@pfsense.org>2005-08-07 16:18:31 +0000
committerBill Marquette <billm@pfsense.org>2005-08-07 16:18:31 +0000
commite8db8b2c622c2a691bfdd6386aa861525a87af1d (patch)
tree99837198efcb281f88d6fc109353b14624af3c0d /usr/local/www/load_balancer_pool_edit.php
parent8b3ccf12b63df763bc1a603a8557d2670be7f02b (diff)
downloadpfsense-e8db8b2c622c2a691bfdd6386aa861525a87af1d.zip
pfsense-e8db8b2c622c2a691bfdd6386aa861525a87af1d.tar.gz
Add some sanity checking
Utilize config change code so we can fully log changes :)
Diffstat (limited to 'usr/local/www/load_balancer_pool_edit.php')
-rwxr-xr-xusr/local/www/load_balancer_pool_edit.php36
1 files changed, 28 insertions, 8 deletions
diff --git a/usr/local/www/load_balancer_pool_edit.php b/usr/local/www/load_balancer_pool_edit.php
index b5bb59b..2f4dd6d 100755
--- a/usr/local/www/load_balancer_pool_edit.php
+++ b/usr/local/www/load_balancer_pool_edit.php
@@ -49,13 +49,18 @@ if (isset($id) && $a_pool[$id]) {
$pconfig['monitor'] = $a_pool[$id]['monitor'];
}
+$changedesc = "Load Balancer: Pool: ";
+$changecount = 0;
+
if ($_POST) {
+ $changecount++;
+
unset($input_errors);
$pconfig = $_POST;
/* input validation */
- $reqdfields = explode(" ", "name");
- $reqdfieldsn = explode(",", "Name");
+ $reqdfields = explode(" ", "name port monitor servers");
+ $reqdfieldsn = explode(",", "Name,Port,Monitor,Server List");
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
@@ -63,15 +68,29 @@ if ($_POST) {
for ($i=0; isset($config['load_balancer']['lbpool'][$i]); $i++)
if (($_POST['name'] == $config['load_balancer']['lbpool'][$i]['name']) && ($i != $id))
$input_errors[] = "This pool name has already been used. Pool names must be unique.";
+ if (!is_port($_POST['port']))
+ $input_errors[] = "The port must be an integer between 1 and 65535.";
+ if (is_array($_POST['servers'])) {
+ foreach($pconfig['servers'] as $svrent) {
+ if (!is_ipaddr($svrent))
+ $input_errors[] = "{$svrent} is not a valid IP address.";
+ }
+ }
+ if ($_POST['monitor'] != "TCP" && $_POST['monitor'] != "HTTP")
+ $input_errors[] = "Invalid monitor chosen.";
if (!$input_errors) {
$poolent = array();
+ if(isset($id) && $a_pool[$id])
+ $poolent = $a_pool[$id];
+ if($poolent['name'] != "")
+ $changedesc .= " modified '{$poolent['name']}' pool:";
- $poolent['name'] = $_POST['name'];
- $poolent['desc'] = $_POST['desc'];
- $poolent['port'] = $_POST['port'];
- $poolent['servers'] = $_POST['servers'];
- $poolent['monitor'] = $_POST['monitor'];
+ update_if_changed("name", $poolent['name'], $_POST['name']);
+ update_if_changed("description", $poolent['desc'], $_POST['desc']);
+ update_if_changed("port", $poolent['port'], $_POST['port']);
+ update_if_changed("servers", $poolent['servers'], $_POST['servers']);
+ update_if_changed("monitor", $poolent['monitor'], $_POST['monitor']);
if (isset($id) && $a_pool[$id]) {
/* modify all virtual servers with this name */
@@ -85,7 +104,8 @@ if ($_POST) {
touch($d_poolconfdirty_path);
- write_config();
+ if ($changecount > 0)
+ write_config($changedesc);
header("Location: load_balancer_pool.php");
exit;
OpenPOWER on IntegriCloud