Project

General

Profile

Download (7.12 KB) Statistics
| Branch: | Tag: | Revision:
1 94ac0ffc Bill Marquette
<?php
2 577c9191 Bill Marquette
/* $Id$ */
3 94ac0ffc Bill Marquette
/*
4
	load_balancer_pool.php
5
	part of pfSense (http://www.pfsense.com/)
6
7
	Copyright (C) 2005 Bill Marquette <bill.marquette@gmail.com>.
8
	All rights reserved.
9
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
32
require("guiconfig.inc");
33
34 a9c6f68a Bill Marquette
if (!is_array($config['load_balancer']['lbpool'])) {
35
	$config['load_balancer']['lbpool'] = array();
36 94ac0ffc Bill Marquette
}
37 a9c6f68a Bill Marquette
$a_pool = &$config['load_balancer']['lbpool'];
38 94ac0ffc Bill Marquette
39
if ($_POST) {
40
	$pconfig = $_POST;
41
42
	if ($_POST['apply']) {
43
		$retval = 0;
44 920b3bb0 Scott Ullrich
45
		config_lock();
46
		$retval |= filter_configure();
47
		$retval |= slbd_configure();
48
		config_unlock();
49
50 94ac0ffc Bill Marquette
		$savemsg = get_std_save_message($retval);
51 9fa74125 Scott Ullrich
		unlink_if_exists($d_vsconfdirty_path);
52 94ac0ffc Bill Marquette
	}
53
}
54
55
if ($_GET['act'] == "del") {
56
	if ($a_pool[$_GET['id']]) {
57
		/* make sure no virtual servers reference this entry */
58
		if (is_array($config['load_balancer']['virtual_server'])) {
59
			foreach ($config['load_balancer']['virtual_server'] as $vs) {
60
				if ($vs['pool'] == $a_pool[$_GET['id']]['name']) {
61
					$input_errors[] = "This entry cannot be deleted because it is still referenced by at least one virtual server.";
62
					break;
63
				}
64
			}
65
		}
66
67
		if (!$input_errors) {
68
			unset($a_pool[$_GET['id']]);
69
			write_config();
70 9fa74125 Scott Ullrich
			touch($d_vsconfdirty_path);
71 94ac0ffc Bill Marquette
			header("Location: load_balancer_pool.php");
72
			exit;
73
		}
74
	}
75
}
76
77
$pgtitle = "Load Balancer: Pool";
78
include("head.inc");
79
80
?>
81
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
82
<?php include("fbegin.inc"); ?>
83
<p class="pgtitle"><?=$pgtitle?></p>
84
<form action="load_balancer_pool.php" method="post">
85
<?php if ($input_errors) print_input_errors($input_errors); ?>
86
<?php if ($savemsg) print_info_box($savemsg); ?>
87 9fa74125 Scott Ullrich
<?php if (file_exists($d_vsconfdirty_path)): ?><p>
88 94ac0ffc Bill Marquette
<?php print_info_box_np("The load balancer configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
89
<?php endif; ?>
90
<table width="100%" border="0" cellpadding="0" cellspacing="0">
91
  <tr><td class="tabnavtbl">
92
  <?php
93
        /* active tabs */
94
        $tab_array = array();
95
        $tab_array[] = array("Pools", true, "load_balancer_pool.php");
96
        $tab_array[] = array("Virtual Servers", false, "load_balancer_virtual_server.php");
97
        display_top_tabs($tab_array);
98
  ?>
99
  </td></tr>
100
  <tr>
101
    <td>
102
	<div id="mainarea">
103
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
104
                <tr>
105
                  <td width="10%" class="listhdrr">Name</td>
106 948a4838 Scott Ullrich
                  <td width="10%" class="listhdrr">Type</td>
107
                  <td width="15%" class="listhdrr">Servers/Gateways</td>
108 94ac0ffc Bill Marquette
                  <td width="10%" class="listhdrr">Port</td>
109
                  <td width="15%" class="listhdrr">Monitor</td>
110
                  <td width="30%" class="listhdr">Description</td>
111
                  <td width="10%" class="list"></td>
112
				</tr>
113
			  <?php $i = 0; foreach ($a_pool as $vipent): ?>
114
                <tr>
115
                  <td class="listlr" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
116
				<?=$vipent['name'];?>
117
                  </td>
118 d1a4365d Seth Mos
                  <td class="listr" align="center" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
119 948a4838 Scott Ullrich
				<?=$vipent['type'];?>
120 d1a4365d Seth Mos
				<br />
121
				(<?=$vipent['behaviour'];?>)
122 94ac0ffc Bill Marquette
                  </td>
123 948a4838 Scott Ullrich
                  <td class="listr" align="center" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
124
                        <?php
125
                                foreach ((array) $vipent['servers'] as $server) {
126
                                        $svr = split("\|", $server);
127
                                        echo "{$svr[0]}<br />";
128
                                }
129
                        ?>
130
                  </td>
131
                  <td class="listr" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
132 94ac0ffc Bill Marquette
				<?=$vipent['port'];?>
133
                  </td>
134 948a4838 Scott Ullrich
                  <td class="listr" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
135
                        <?php
136
                                if ($vipent['type'] == "gateway") {
137
                                        foreach ((array) $vipent['servers'] as $server) {
138
                                                $svr = split("\|", $server);
139
                                                echo "{$svr[1]}<br />";
140
                                        }
141
                                } else {
142
                                        echo $vipent['monitor'];
143
                                }
144
                        ?>
145 94ac0ffc Bill Marquette
                  </td>
146
                  <td class="listbg" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
147 d90212f3 Bill Marquette
				<font color="#FFFFFF"><?=$vipent['desc'];?></font>
148 94ac0ffc Bill Marquette
                  </td>
149
                  <td class="list" nowrap>
150
                    <table border="0" cellspacing="0" cellpadding="1">
151
                      <tr>
152
                        <td valign="middle"><a href="load_balancer_pool_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
153
                        <td valign="middle"><a href="load_balancer_pool.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
154
                      </tr>
155
                    </table>
156
                  </td>
157
                </tr>
158
                <?php $i++; endforeach; ?>
159
                <tr>
160 948a4838 Scott Ullrich
                  <td class="list" colspan="6"></td>
161 94ac0ffc Bill Marquette
                  <td class="list">
162
                    <table border="0" cellspacing="0" cellpadding="1">
163
                      <tr>
164
                        <td valign="middle"><a href="load_balancer_pool_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
165
                      </tr>
166
                    </table>
167
                  </td>
168
                </tr>
169
              </table>
170
	   </div>
171
	</table>
172
            </form>
173
<?php include("fend.inc"); ?>
174
</body>
175
</html>