Project

General

Profile

Download (7.48 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 d88c6a9f Scott Ullrich
$pgtitle = array("Load Balancer","Pool");
78 94ac0ffc Bill Marquette
include("head.inc");
79
80
?>
81
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
82
<?php include("fbegin.inc"); ?>
83
<form action="load_balancer_pool.php" method="post">
84
<?php if ($input_errors) print_input_errors($input_errors); ?>
85
<?php if ($savemsg) print_info_box($savemsg); ?>
86 9fa74125 Scott Ullrich
<?php if (file_exists($d_vsconfdirty_path)): ?><p>
87 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>
88
<?php endif; ?>
89
<table width="100%" border="0" cellpadding="0" cellspacing="0">
90
  <tr><td class="tabnavtbl">
91
  <?php
92
        /* active tabs */
93
        $tab_array = array();
94
        $tab_array[] = array("Pools", true, "load_balancer_pool.php");
95
        $tab_array[] = array("Virtual Servers", false, "load_balancer_virtual_server.php");
96
        display_top_tabs($tab_array);
97
  ?>
98
  </td></tr>
99
  <tr>
100
    <td>
101
	<div id="mainarea">
102
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
103
                <tr>
104
                  <td width="10%" class="listhdrr">Name</td>
105 948a4838 Scott Ullrich
                  <td width="10%" class="listhdrr">Type</td>
106
                  <td width="15%" class="listhdrr">Servers/Gateways</td>
107 94ac0ffc Bill Marquette
                  <td width="10%" class="listhdrr">Port</td>
108
                  <td width="15%" class="listhdrr">Monitor</td>
109
                  <td width="30%" class="listhdr">Description</td>
110 d415d821 Seth Mos
                  <td width="10%" class="list">
111
                    <table border="0" cellspacing="0" cellpadding="1">
112
                      <tr>
113
			<td width="17"></td>
114
                        <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>
115
                      </tr>
116
                    </table>
117
		</td>
118
		</tr>
119 94ac0ffc Bill Marquette
			  <?php $i = 0; foreach ($a_pool as $vipent): ?>
120
                <tr>
121
                  <td class="listlr" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
122
				<?=$vipent['name'];?>
123
                  </td>
124 d1a4365d Seth Mos
                  <td class="listr" align="center" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
125 948a4838 Scott Ullrich
				<?=$vipent['type'];?>
126 d1a4365d Seth Mos
				<br />
127
				(<?=$vipent['behaviour'];?>)
128 94ac0ffc Bill Marquette
                  </td>
129 948a4838 Scott Ullrich
                  <td class="listr" align="center" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
130
                        <?php
131
                                foreach ((array) $vipent['servers'] as $server) {
132
                                        $svr = split("\|", $server);
133
                                        echo "{$svr[0]}<br />";
134
                                }
135
                        ?>
136
                  </td>
137
                  <td class="listr" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
138 94ac0ffc Bill Marquette
				<?=$vipent['port'];?>
139
                  </td>
140 948a4838 Scott Ullrich
                  <td class="listr" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
141
                        <?php
142
                                if ($vipent['type'] == "gateway") {
143
                                        foreach ((array) $vipent['servers'] as $server) {
144
                                                $svr = split("\|", $server);
145
                                                echo "{$svr[1]}<br />";
146
                                        }
147
                                } else {
148
                                        echo $vipent['monitor'];
149
                                }
150
                        ?>
151 94ac0ffc Bill Marquette
                  </td>
152
                  <td class="listbg" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
153 d90212f3 Bill Marquette
				<font color="#FFFFFF"><?=$vipent['desc'];?></font>
154 94ac0ffc Bill Marquette
                  </td>
155
                  <td class="list" nowrap>
156
                    <table border="0" cellspacing="0" cellpadding="1">
157
                      <tr>
158
                        <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>
159
                        <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>
160
                      </tr>
161
                    </table>
162
                  </td>
163
                </tr>
164
                <?php $i++; endforeach; ?>
165
                <tr>
166 948a4838 Scott Ullrich
                  <td class="list" colspan="6"></td>
167 94ac0ffc Bill Marquette
                  <td class="list">
168
                    <table border="0" cellspacing="0" cellpadding="1">
169
                      <tr>
170 d415d821 Seth Mos
			<td width="17"></td>
171 94ac0ffc Bill Marquette
                        <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>
172
                      </tr>
173
                    </table>
174
                  </td>
175
                </tr>
176
              </table>
177
	   </div>
178
	</table>
179
            </form>
180
<?php include("fend.inc"); ?>
181
</body>
182
</html>