diff options
author | Phil Davis <phil.davis@inf.org> | 2015-05-13 16:36:24 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2015-05-13 16:36:24 +0545 |
commit | 0162f9a1f078f25a935642f0b3db6a51b9b207a0 (patch) | |
tree | df456107826e6755f6e1dc5f142fa62fba441c0e /usr/local/www/load_balancer_monitor_edit.php | |
parent | c8f7068d1aaccf4ca1d1f782704289e9519233dc (diff) | |
download | pfsense-0162f9a1f078f25a935642f0b3db6a51b9b207a0.zip pfsense-0162f9a1f078f25a935642f0b3db6a51b9b207a0.tar.gz |
Code style Load Balancer
Diffstat (limited to 'usr/local/www/load_balancer_monitor_edit.php')
-rw-r--r-- | usr/local/www/load_balancer_monitor_edit.php | 86 |
1 files changed, 49 insertions, 37 deletions
diff --git a/usr/local/www/load_balancer_monitor_edit.php b/usr/local/www/load_balancer_monitor_edit.php index 280244b..b8806e1 100644 --- a/usr/local/www/load_balancer_monitor_edit.php +++ b/usr/local/www/load_balancer_monitor_edit.php @@ -49,10 +49,12 @@ if (!is_array($config['load_balancer']['monitor_type'])) { } $a_monitor = &$config['load_balancer']['monitor_type']; -if (is_numericint($_GET['id'])) +if (is_numericint($_GET['id'])) { $id = $_GET['id']; -if (isset($_POST['id']) && is_numericint($_POST['id'])) +} +if (isset($_POST['id']) && is_numericint($_POST['id'])) { $id = $_POST['id']; +} if (isset($id) && $a_monitor[$id]) { $pconfig['name'] = $a_monitor[$id]['name']; @@ -76,7 +78,7 @@ if ($_POST) { $pconfig = $_POST; /* turn $_POST['http_options_*'] into $pconfig['options'][*] */ - foreach($_POST as $key => $val) { + foreach ($_POST as $key => $val) { if (stristr($key, 'options') !== false) { if (stristr($key, $pconfig['type'].'_') !== false) { $opt = explode('_',$key); @@ -93,17 +95,21 @@ if ($_POST) { do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); /* Ensure that our monitor names are unique */ - for ($i=0; isset($config['load_balancer']['monitor_type'][$i]); $i++) - if (($_POST['name'] == $config['load_balancer']['monitor_type'][$i]['name']) && ($i != $id)) + for ($i=0; isset($config['load_balancer']['monitor_type'][$i]); $i++) { + if (($_POST['name'] == $config['load_balancer']['monitor_type'][$i]['name']) && ($i != $id)) { $input_errors[] = gettext("This monitor name has already been used. Monitor names must be unique."); + } + } - if (preg_match('/[ \/]/', $_POST['name'])) + if (preg_match('/[ \/]/', $_POST['name'])) { $input_errors[] = gettext("You cannot use spaces or slashes in the 'name' field."); + } - if (strlen($_POST['name']) > 16) + if (strlen($_POST['name']) > 16) { $input_errors[] = gettext("The 'name' field must be 16 characters or less."); + } - switch($_POST['type']) { + switch ($_POST['type']) { case 'icmp': { break; } @@ -120,7 +126,7 @@ if ($_POST) { } if (isset($pconfig['options']['code']) && $pconfig['options']['code'] != "") { // Check code - if(!is_rfc2616_code($pconfig['options']['code'])) { + if (!is_rfc2616_code($pconfig['options']['code'])) { $input_errors[] = gettext("HTTP(s) codes must be from RFC2616."); } } @@ -145,15 +151,17 @@ if ($_POST) { if (!$input_errors) { $monent = array(); - if(isset($id) && $a_monitor[$id]) + if (isset($id) && $a_monitor[$id]) { $monent = $a_monitor[$id]; - if($monent['name'] != "") + } + if ($monent['name'] != "") { $changedesc .= " " . sprintf(gettext("modified '%s' monitor:"), $monent['name']); - + } + update_if_changed("name", $monent['name'], $pconfig['name']); update_if_changed("type", $monent['type'], $pconfig['type']); update_if_changed("description", $monent['descr'], $pconfig['descr']); - if($pconfig['type'] == "http" || $pconfig['type'] == "https" ) { + if ($pconfig['type'] == "http" || $pconfig['type'] == "https") { /* log updates, then clear array and reassign - dumb, but easiest way to have a clear array */ update_if_changed("path", $monent['options']['path'], $pconfig['options']['path']); update_if_changed("host", $monent['options']['host'], $pconfig['options']['host']); @@ -163,7 +171,7 @@ if ($_POST) { $monent['options']['host'] = $pconfig['options']['host']; $monent['options']['code'] = $pconfig['options']['code']; } - if($pconfig['type'] == "send" ) { + if ($pconfig['type'] == "send") { /* log updates, then clear array and reassign - dumb, but easiest way to have a clear array */ update_if_changed("send", $monent['options']['send'], $pconfig['options']['send']); update_if_changed("expect", $monent['options']['expect'], $pconfig['options']['expect']); @@ -171,20 +179,22 @@ if ($_POST) { $monent['options']['send'] = $pconfig['options']['send']; $monent['options']['expect'] = $pconfig['options']['expect']; } - if($pconfig['type'] == "tcp" || $pconfig['type'] == "icmp") { + if ($pconfig['type'] == "tcp" || $pconfig['type'] == "icmp") { $monent['options'] = array(); } if (isset($id) && $a_monitor[$id]) { /* modify all pools with this name */ for ($i = 0; isset($config['load_balancer']['lbpool'][$i]); $i++) { - if ($config['load_balancer']['lbpool'][$i]['monitor'] == $a_monitor[$id]['name']) + if ($config['load_balancer']['lbpool'][$i]['monitor'] == $a_monitor[$id]['name']) { $config['load_balancer']['lbpool'][$i]['monitor'] = $monent['name']; + } } $a_monitor[$id] = $monent; - } else + } else { $a_monitor[] = $monent; - + } + if ($changecount > 0) { /* Mark config dirty */ mark_subsystem_dirty('loadbalancer'); @@ -208,8 +218,8 @@ $types = array("icmp" => gettext("ICMP"), "tcp" => gettext("TCP"), "http" => get <?php include("fbegin.inc"); ?> <script type="text/javascript"> //<![CDATA[ -function updateType(t){ - switch(t) { +function updateType(t) { + switch (t) { <?php /* OK, so this is sick using php to generate javascript, but it needed to be done */ foreach ($types as $key => $val) { @@ -231,21 +241,21 @@ function updateType(t){ <?php if ($input_errors) print_input_errors($input_errors); ?> - <form action="load_balancer_monitor_edit.php" method="post" name="iform" id="iform"> +<form action="load_balancer_monitor_edit.php" method="post" name="iform" id="iform"> <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="monitor entry"> - <tr> + <tr> <td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Load Balancer - Monitor entry"); ?></td> - </tr> + </tr> <tr align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Name"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input name="name" type="text" <?if(isset($pconfig['name'])) echo "value=\"" . htmlspecialchars($pconfig['name']) . "\"";?> size="16" maxlength="16" /> + <input name="name" type="text" <?if (isset($pconfig['name'])) echo "value=\"" . htmlspecialchars($pconfig['name']) . "\"";?> size="16" maxlength="16" /> </td> </tr> <tr align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Description"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input name="descr" type="text" <?if(isset($pconfig['descr'])) echo "value=\"" . htmlspecialchars($pconfig['descr']) . "\"";?> size="64" /> + <input name="descr" type="text" <?if (isset($pconfig['descr'])) echo "value=\"" . htmlspecialchars($pconfig['descr']) . "\"";?> size="64" /> </td> </tr> <tr align="left"> @@ -254,7 +264,7 @@ function updateType(t){ <select id="type" name="type"> <? foreach ($types as $key => $val) { - if(isset($pconfig['type']) && $pconfig['type'] == $key) { + if (isset($pconfig['type']) && $pconfig['type'] == $key) { $selected = " selected=\"selected\""; } else { $selected = ""; @@ -265,9 +275,11 @@ function updateType(t){ </select> </td> </tr> - <tr align="left" id="icmp"<?= $pconfig['type'] == "icmp" ? "" : " style=\"display:none;\""?>><td></td> + <tr align="left" id="icmp"<?= $pconfig['type'] == "icmp" ? "" : " style=\"display:none;\""?>> + <td></td> </tr> - <tr align="left" id="tcp"<?= $pconfig['type'] == "tcp" ? "" : " style=\"display:none;\""?>><td></td> + <tr align="left" id="tcp"<?= $pconfig['type'] == "tcp" ? "" : " style=\"display:none;\""?>> + <td></td> </tr> <tr align="left" id="http"<?= $pconfig['type'] == "http" ? "" : " style=\"display:none;\""?>> <td width="22%" valign="top" class="vncellreq"><?=gettext("HTTP"); ?></td> @@ -276,13 +288,13 @@ function updateType(t){ <tr align="left"> <td valign="top" align="right" class="vtable"><?=gettext("Path"); ?></td> <td class="vtable" colspan="2"> - <input name="http_options_path" type="text" <?if(isset($pconfig['options']['path'])) echo "value=\"" . htmlspecialchars($pconfig['options']['path']) . "\"";?> size="64" /> + <input name="http_options_path" type="text" <?if (isset($pconfig['options']['path'])) echo "value=\"" . htmlspecialchars($pconfig['options']['path']) . "\"";?> size="64" /> </td> </tr> <tr align="left"> <td valign="top" align="right" class="vtable"><?=gettext("Host"); ?></td> <td class="vtable" colspan="2"> - <input name="http_options_host" type="text" <?if(isset($pconfig['options']['host'])) echo "value=\"" . htmlspecialchars($pconfig['options']['host']) . "\"";?> size="64" /><br /><?=gettext("Hostname for Host: header if needed."); ?> + <input name="http_options_host" type="text" <?if (isset($pconfig['options']['host'])) echo "value=\"" . htmlspecialchars($pconfig['options']['host']) . "\"";?> size="64" /><br /><?=gettext("Hostname for Host: header if needed."); ?> </td> </tr> <tr align="left"> @@ -295,7 +307,7 @@ function updateType(t){ <tr align="left"> <td width="22%" valign="top" class="vncell">MD5 Page Digest</td> <td width="78%" class="vtable" colspan="2"> - <input name="digest" type="text" <?if(isset($pconfig['digest'])) echo "value=\"" . htmlspecialchars($pconfig['digest']) . "\"";?>size="32"><br /><b>TODO: add fetch functionality here</b> + <input name="digest" type="text" <?if (isset($pconfig['digest'])) echo "value=\"" . htmlspecialchars($pconfig['digest']) . "\"";?>size="32"><br /><b>TODO: add fetch functionality here</b> </td> </tr> --> @@ -309,13 +321,13 @@ function updateType(t){ <tr align="left"> <td valign="top" align="right" class="vtable"><?=gettext("Path"); ?></td> <td class="vtable" colspan="2"> - <input name="https_options_path" type="text" <?if(isset($pconfig['options']['path'])) echo "value=\"" . htmlspecialchars($pconfig['options']['path']) ."\"";?> size="64" /> + <input name="https_options_path" type="text" <?if (isset($pconfig['options']['path'])) echo "value=\"" . htmlspecialchars($pconfig['options']['path']) ."\"";?> size="64" /> </td> </tr> <tr align="left"> <td valign="top" align="right" class="vtable"><?=gettext("Host"); ?></td> <td class="vtable" colspan="2"> - <input name="https_options_host" type="text" <?if(isset($pconfig['options']['host'])) echo "value=\"" . htmlspecialchars($pconfig['options']['host']) . "\"";?> size="64" /><br /><?=gettext("Hostname for Host: header if needed."); ?> + <input name="https_options_host" type="text" <?if (isset($pconfig['options']['host'])) echo "value=\"" . htmlspecialchars($pconfig['options']['host']) . "\"";?> size="64" /><br /><?=gettext("Hostname for Host: header if needed."); ?> </td> </tr> <tr align="left"> @@ -329,7 +341,7 @@ function updateType(t){ <tr align="left"> <td width="22%" valign="top" class="vncellreq">MD5 Page Digest</td> <td width="78%" class="vtable" colspan="2"> - <input name="digest" type="text" <?if(isset($pconfig['digest'])) echo "value=\"" . htmlspecialchars($pconfig['digest']) . "\"";?>size="32"><br /><b>TODO: add fetch functionality here</b> + <input name="digest" type="text" <?if (isset($pconfig['digest'])) echo "value=\"" . htmlspecialchars($pconfig['digest']) . "\"";?>size="32"><br /><b>TODO: add fetch functionality here</b> </td> </tr> --> @@ -343,13 +355,13 @@ function updateType(t){ <tr align="left"> <td valign="top" align="right" class="vtable"><?=gettext("Send string"); ?></td> <td class="vtable" colspan="2"> - <input name="send_options_send" type="text" <?if(isset($pconfig['options']['send'])) echo "value=\"" . htmlspecialchars($pconfig['options']['send']) . "\"";?> size="64" /> + <input name="send_options_send" type="text" <?if (isset($pconfig['options']['send'])) echo "value=\"" . htmlspecialchars($pconfig['options']['send']) . "\"";?> size="64" /> </td> </tr> <tr align="left"> <td valign="top" align="right" class="vtable"><?=gettext("Expect string"); ?></td> <td class="vtable" colspan="2"> - <input name="send_options_expect" type="text" <?if(isset($pconfig['options']['expect'])) echo "value=\"" . htmlspecialchars($pconfig['options']['expect']) . "\"";?> size="64" /> + <input name="send_options_expect" type="text" <?if (isset($pconfig['options']['expect'])) echo "value=\"" . htmlspecialchars($pconfig['options']['expect']) . "\"";?> size="64" /> </td> </tr> </table> @@ -366,7 +378,7 @@ function updateType(t){ </td> </tr> </table> - </form> +</form> <br /> <?php include("fend.inc"); ?> </body> |